tandem-editor 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,262 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/path-DpyQXOHZ.js","assets/core-DhEqZVGG.js","assets/index-Dm_QtxGQ.js","assets/event-CNdo2oXa.js","assets/CoworkSettings-vFVSs4Qc.js","assets/CoworkSettings-C-1BnhBH.css","assets/index-RV3NNz1L.js","assets/base-Cdw59IzI.js","assets/index-B1hpCY-M.js","assets/webview-KiZyy_pC.js","assets/window-DePn7tLG.js"])))=>i.map(i=>d[i]);
2
+ var w6=Object.defineProperty;var cw=t=>{throw TypeError(t)};var k6=(t,e,n)=>e in t?w6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Wn=(t,e,n)=>k6(t,typeof e!="symbol"?e+"":e,n),_g=(t,e,n)=>e.has(t)||cw("Cannot "+n);var oe=(t,e,n)=>(_g(t,e,"read from private field"),n?n.call(t):e.get(t)),yt=(t,e,n)=>e.has(t)?cw("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),wt=(t,e,n,r)=>(_g(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Ht=(t,e,n)=>(_g(t,e,"access private method"),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();const F_=!1;var Gb=Array.isArray,x6=Array.prototype.indexOf,ac=Array.prototype.includes,vm=Array.from,_6=Object.defineProperty,js=Object.getOwnPropertyDescriptor,z_=Object.getOwnPropertyDescriptors,C6=Object.prototype,S6=Array.prototype,Zb=Object.getPrototypeOf,uw=Object.isExtensible;function Cl(t){return typeof t=="function"}const kn=()=>{};function E6(t){return typeof(t==null?void 0:t.then)=="function"}function A6(t){for(var e=0;e<t.length;e++)t[e]()}function B_(){var t,e,n=new Promise((r,i)=>{t=r,e=i});return{promise:n,resolve:t,reject:e}}function _f(t,e){if(Array.isArray(t))return t;if(e===void 0||!(Symbol.iterator in t))return Array.from(t);const n=[];for(const r of t)if(n.push(r),n.length===e)break;return n}const ur=2,lc=4,bm=8,H_=1<<24,Ci=16,Zi=32,as=64,Q0=128,Si=512,Bn=1024,Xn=2048,Eo=4096,Sr=8192,Ei=16384,sa=32768,$0=1<<25,ls=65536,Fh=1<<17,T6=1<<18,sl=1<<19,M6=1<<20,bo=1<<25,Wa=65536,zh=1<<21,Fl=1<<22,qs=1<<23,xo=Symbol("$state"),V_=Symbol("legacy props"),D6=Symbol(""),ah=Symbol("attributes"),ev=Symbol("class"),tv=Symbol("style"),fu=Symbol("text"),lh=Symbol("form reset"),ym=new class extends Error{constructor(){super(...arguments);Wn(this,"name","StaleReactionError");Wn(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var N_;const O6=!!((N_=globalThis.document)!=null&&N_.contentType)&&globalThis.document.contentType.includes("xml");function U_(t){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function I6(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function R6(t,e,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function N6(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function P6(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function L6(t){throw new Error("https://svelte.dev/e/effect_orphan")}function F6(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function z6(t){throw new Error("https://svelte.dev/e/props_invalid_value")}function B6(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function H6(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function V6(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function U6(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const j6=1,q6=2,j_=4,W6=8,K6=16,G6=1,Z6=2,Y6=4,J6=8,X6=16,Q6=1,$6=2,eM=4,q_=1,tM=2,Pn=Symbol(),W_="http://www.w3.org/1999/xhtml",nM="http://www.w3.org/2000/svg",rM="http://www.w3.org/1998/Math/MathML";function iM(){console.warn("https://svelte.dev/e/derived_inert")}function oM(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function sM(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function K_(t){return t===this.v}function G_(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function Z_(t){return!G_(t,this.v)}let Pc=!1,aM=!1;function lM(){Pc=!0}let Cn=null;function cc(t){Cn=t}function nt(t,e=!1,n){Cn={p:Cn,i:!1,c:null,e:null,s:t,x:null,r:Mt,l:Pc&&!e?{s:null,u:null,$:[]}:null}}function rt(t){var e=Cn,n=e.e;if(n!==null){e.e=null;for(var r of n)vC(r)}return t!==void 0&&(e.x=t),e.i=!0,Cn=e.p,t??{}}function al(){return!Pc||Cn!==null&&Cn.l===null}let wa=[];function Y_(){var t=wa;wa=[],A6(t)}function Ki(t){if(wa.length===0&&!zl){var e=wa;queueMicrotask(()=>{e===wa&&Y_()})}wa.push(t)}function cM(){for(;wa.length>0;)Y_()}function J_(t){var e=Mt;if(e===null)return Bt.f|=qs,t;if((e.f&sa)===0&&(e.f&lc)===0)throw t;Fs(t,e)}function Fs(t,e){for(;e!==null;){if((e.f&Q0)!==0){if((e.f&sa)===0)throw t;try{e.b.error(t);return}catch(n){t=n}}e=e.parent}throw t}const uM=-7169;function xn(t,e){t.f=t.f&uM|e}function Yb(t){(t.f&Si)!==0||t.deps===null?xn(t,Bn):xn(t,Eo)}function X_(t){if(t!==null)for(const e of t)(e.f&ur)===0||(e.f&Wa)===0||(e.f^=Wa,X_(e.deps))}function Q_(t,e,n){(t.f&Xn)!==0?e.add(t):(t.f&Eo)!==0&&n.add(t),X_(t.deps),xn(t,Bn)}let Cf=!1;function dM(t){var e=Cf;try{return Cf=!1,[t(),Cf]}finally{Cf=e}}let Cg=null,ml=null,pt=null,Cu=null,sr=null,nv=null,zl=!1,Sg=!1,Rl=null,ch=null;var dw=0;let fM=1;var $l,Rs,Ma,ec,tc,Da,nc,Zo,Pd,Qr,Ld,Ns,mo,go,rc,ic,Gt,rv,hu,iv,$_,eC,uh,hM,ov,Sl;const dm=class dm{constructor(){yt(this,Gt);Wn(this,"id",fM++);yt(this,$l,!1);Wn(this,"linked",!0);yt(this,Rs,null);yt(this,Ma,null);Wn(this,"async_deriveds",new Map);Wn(this,"current",new Map);Wn(this,"previous",new Map);Wn(this,"unblocked",new Set);yt(this,ec,new Set);yt(this,tc,new Set);yt(this,Da,new Set);yt(this,nc,0);yt(this,Zo,new Map);yt(this,Pd,null);yt(this,Qr,[]);yt(this,Ld,[]);yt(this,Ns,new Set);yt(this,mo,new Set);yt(this,go,new Map);yt(this,rc,new Set);Wn(this,"is_fork",!1);yt(this,ic,!1)}skip_effect(e){oe(this,go).has(e)||oe(this,go).set(e,{d:[],m:[]}),oe(this,rc).delete(e)}unskip_effect(e,n=r=>this.schedule(r)){var r=oe(this,go).get(e);if(r){oe(this,go).delete(e);for(var i of r.d)xn(i,Xn),n(i);for(i of r.m)xn(i,Eo),n(i)}oe(this,rc).add(e)}capture(e,n,r=!1){e.v!==Pn&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&qs)===0&&(this.current.set(e,[n,r]),sr==null||sr.set(e,n)),this.is_fork||(e.v=n)}activate(){pt=this}deactivate(){pt=null,sr=null}flush(){try{Sg=!0,pt=this,Ht(this,Gt,hu).call(this)}finally{dw=0,nv=null,Rl=null,ch=null,Sg=!1,pt=null,sr=null,Na.clear()}}discard(){for(const e of oe(this,tc))e(this);oe(this,tc).clear(),oe(this,Da).clear(),Ht(this,Gt,Sl).call(this)}register_created_effect(e){oe(this,Ld).push(e)}increment(e,n){if(wt(this,nc,oe(this,nc)+1),e){let r=oe(this,Zo).get(n)??0;oe(this,Zo).set(n,r+1)}}decrement(e,n){if(wt(this,nc,oe(this,nc)-1),e){let r=oe(this,Zo).get(n)??0;r===1?oe(this,Zo).delete(n):oe(this,Zo).set(n,r-1)}oe(this,ic)||(wt(this,ic,!0),Ki(()=>{wt(this,ic,!1),this.linked&&this.flush()}))}transfer_effects(e,n){for(const r of e)oe(this,Ns).add(r);for(const r of n)oe(this,mo).add(r);e.clear(),n.clear()}oncommit(e){oe(this,ec).add(e)}ondiscard(e){oe(this,tc).add(e)}on_fork_commit(e){oe(this,Da).add(e)}run_fork_commit_callbacks(){for(const e of oe(this,Da))e(this);oe(this,Da).clear()}settled(){return(oe(this,Pd)??wt(this,Pd,B_())).promise}static ensure(){var e;if(pt===null){const n=pt=new dm;Ht(e=n,Gt,ov).call(e),!Sg&&!zl&&Ki(()=>{oe(n,$l)||n.flush()})}return pt}apply(){{sr=null;return}}schedule(e){var i;if(nv=e,(i=e.b)!=null&&i.is_pending&&(e.f&(lc|bm|H_))!==0&&(e.f&sa)===0){e.b.defer_effect(e);return}for(var n=e;n.parent!==null;){n=n.parent;var r=n.f;if(Rl!==null&&n===Mt&&(Bt===null||(Bt.f&ur)===0))return;if((r&(as|Zi))!==0){if((r&Bn)===0)return;n.f^=Bn}}oe(this,Qr).push(n)}};$l=new WeakMap,Rs=new WeakMap,Ma=new WeakMap,ec=new WeakMap,tc=new WeakMap,Da=new WeakMap,nc=new WeakMap,Zo=new WeakMap,Pd=new WeakMap,Qr=new WeakMap,Ld=new WeakMap,Ns=new WeakMap,mo=new WeakMap,go=new WeakMap,rc=new WeakMap,ic=new WeakMap,Gt=new WeakSet,rv=function(){if(this.is_fork)return!0;for(const r of oe(this,Zo).keys()){for(var e=r,n=!1;e.parent!==null;){if(oe(this,go).has(e)){n=!0;break}e=e.parent}if(!n)return!0}return!1},hu=function(){var l,c,d,f;if(wt(this,$l,!0),dw++>1e3&&(Ht(this,Gt,Sl).call(this),pM()),!Ht(this,Gt,rv).call(this)){for(const h of oe(this,Ns))oe(this,mo).delete(h),xn(h,Xn),this.schedule(h);for(const h of oe(this,mo))xn(h,Eo),this.schedule(h)}const e=oe(this,Qr);wt(this,Qr,[]),this.apply();var n=Rl=[],r=[],i=ch=[];for(const h of e)try{Ht(this,Gt,iv).call(this,h,n,r)}catch(p){throw iC(h),p}if(pt=null,i.length>0){var o=dm.ensure();for(const h of i)o.schedule(h)}if(Rl=null,ch=null,Ht(this,Gt,rv).call(this)){Ht(this,Gt,uh).call(this,r),Ht(this,Gt,uh).call(this,n);for(const[h,p]of oe(this,go))rC(h,p);i.length>0&&Ht(l=pt,Gt,hu).call(l);return}const s=Ht(this,Gt,$_).call(this);if(s){Ht(c=s,Gt,eC).call(c,this);return}oe(this,Ns).clear(),oe(this,mo).clear();for(const h of oe(this,ec))h(this);oe(this,ec).clear(),Cu=this,fw(r),fw(n),Cu=null,(d=oe(this,Pd))==null||d.resolve();var a=pt;if(this.linked&&oe(this,nc)===0&&Ht(this,Gt,Sl).call(this),oe(this,Qr).length>0){a===null&&(a=this,Ht(this,Gt,ov).call(this));const h=a;oe(h,Qr).push(...oe(this,Qr).filter(p=>!oe(h,Qr).includes(p)))}a!==null&&Ht(f=a,Gt,hu).call(f)},iv=function(e,n,r){e.f^=Bn;for(var i=e.first;i!==null;){var o=i.f,s=(o&(Zi|as))!==0,a=s&&(o&Bn)!==0,l=a||(o&Sr)!==0||oe(this,go).has(i);if(!l&&i.fn!==null){s?i.f^=Bn:(o&lc)!==0?n.push(i):Wd(i)&&((o&Ci)!==0&&oe(this,mo).add(i),uc(i));var c=i.first;if(c!==null){i=c;continue}}for(;i!==null;){var d=i.next;if(d!==null){i=d;break}i=i.parent}}},$_=function(){for(var e=oe(this,Rs);e!==null;){if(!e.is_fork){for(const[n,[,r]]of this.current)if(e.current.has(n)&&!r)return e}e=oe(e,Rs)}return null},eC=function(e){var r;for(const[i,o]of e.current)!this.previous.has(i)&&e.previous.has(i)&&this.previous.set(i,e.previous.get(i)),this.current.set(i,o);for(const[i,o]of e.async_deriveds){const s=this.async_deriveds.get(i);s&&o.promise.then(s.resolve)}const n=i=>{var o=i.reactions;if(o!==null)for(const l of o){var s=l.f;if((s&ur)!==0)n(l);else{var a=l;s&(Fl|Ci)&&!this.async_deriveds.has(a)&&(oe(this,mo).delete(a),xn(a,Xn),this.schedule(a))}}};for(const i of this.current.keys())n(i);this.oncommit(()=>e.discard()),Ht(r=e,Gt,Sl).call(r),pt=this,Ht(this,Gt,hu).call(this)},uh=function(e){for(var n=0;n<e.length;n+=1)Q_(e[n],oe(this,Ns),oe(this,mo))},hM=function(){var d;Ht(this,Gt,Sl).call(this);for(let f=Cg;f!==null;f=oe(f,Ma)){var e=f.id<this.id,n=[];for(const[h,[p,m]]of this.current){if(f.current.has(h)){var r=f.current.get(h)[0];if(e&&p!==r)f.current.set(h,[p,m]);else continue}n.push(h)}if(e)for(const[h,p]of this.async_deriveds){const m=f.async_deriveds.get(h);m&&p.promise.then(m.resolve)}if(oe(f,$l)){var i=[...f.current.keys()].filter(h=>!this.current.has(h));if(i.length===0)e&&f.discard();else if(n.length>0){if(e)for(const h of oe(this,rc))f.unskip_effect(h,p=>{var m;(p.f&(Ci|Fl))!==0?f.schedule(p):Ht(m=f,Gt,uh).call(m,[p])});f.activate();var o=new Set,s=new Map;for(var a of n)nC(a,i,o,s);s=new Map;var l=[...f.current.keys()].filter(h=>this.current.has(h)?this.current.get(h)[0]!==h.v:!0);if(l.length>0)for(const h of oe(this,Ld))(h.f&(Ei|Sr|Fh))===0&&Jb(h,l,s)&&((h.f&(Fl|Ci))!==0?(xn(h,Xn),f.schedule(h)):oe(f,Ns).add(h));if(oe(f,Qr).length>0){f.apply();for(var c of oe(f,Qr))Ht(d=f,Gt,iv).call(d,c,[],[]);wt(f,Qr,[])}f.deactivate()}}}},ov=function(){ml===null?Cg=ml=this:(wt(ml,Ma,this),wt(this,Rs,ml)),ml=this},Sl=function(){var e=oe(this,Rs),n=oe(this,Ma);e===null?Cg=n:wt(e,Ma,n),n===null?ml=e:wt(n,Rs,e),this.linked=!1};let cs=dm;function tC(t){var e=zl;zl=!0;try{for(var n;;){if(cM(),pt===null)return n;pt.flush()}}finally{zl=e}}function pM(){try{F6()}catch(t){Fs(t,nv)}}let Vi=null;function fw(t){var e=t.length;if(e!==0){for(var n=0;n<e;){var r=t[n++];if((r.f&(Ei|Sr))===0&&Wd(r)&&(Vi=new Set,uc(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&kC(r),(Vi==null?void 0:Vi.size)>0)){Na.clear();for(const i of Vi){if((i.f&(Ei|Sr))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)Vi.has(s)&&(Vi.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){const l=o[a];(l.f&(Ei|Sr))===0&&uc(l)}}Vi.clear()}}Vi=null}}function nC(t,e,n,r){if(!n.has(t)&&(n.add(t),t.reactions!==null))for(const i of t.reactions){const o=i.f;(o&ur)!==0?nC(i,e,n,r):(o&(Fl|Ci))!==0&&(o&Xn)===0&&Jb(i,e,r)&&(xn(i,Xn),Xb(i))}}function Jb(t,e,n){const r=n.get(t);if(r!==void 0)return r;if(t.deps!==null)for(const i of t.deps){if(ac.call(e,i))return!0;if((i.f&ur)!==0&&Jb(i,e,n))return n.set(i,!0),!0}return n.set(t,!1),!1}function Xb(t){pt.schedule(t)}function rC(t,e){if(!((t.f&Zi)!==0&&(t.f&Bn)!==0)){(t.f&Xn)!==0?e.d.push(t):(t.f&Eo)!==0&&e.m.push(t),xn(t,Bn);for(var n=t.first;n!==null;)rC(n,e),n=n.next}}function iC(t){xn(t,Bn);for(var e=t.first;e!==null;)iC(e),e=e.next}function mM(t){let e=0,n=us(0),r;return()=>{t1()&&(u(n),qd(()=>(e===0&&(r=Ct(()=>t(()=>Su(n)))),e+=1,()=>{Ki(()=>{e-=1,e===0&&(r==null||r(),r=void 0,Su(n))})})))}}var gM=ls|sl;function oC(t,e,n,r){new vM(t,e,n,r)}var mi,Kb,gi,Oa,Lr,vi,Cr,$r,Yo,Ia,Ps,oc,Fd,zd,Jo,fm,Sn,bM,yM,wM,sv,dh,fh,av,lv;class vM{constructor(e,n,r,i){yt(this,Sn);Wn(this,"parent");Wn(this,"is_pending",!1);Wn(this,"transform_error");yt(this,mi);yt(this,Kb,null);yt(this,gi);yt(this,Oa);yt(this,Lr);yt(this,vi,null);yt(this,Cr,null);yt(this,$r,null);yt(this,Yo,null);yt(this,Ia,0);yt(this,Ps,0);yt(this,oc,!1);yt(this,Fd,new Set);yt(this,zd,new Set);yt(this,Jo,null);yt(this,fm,mM(()=>(wt(this,Jo,us(oe(this,Ia))),()=>{wt(this,Jo,null)})));var o;wt(this,mi,e),wt(this,gi,n),wt(this,Oa,s=>{var a=Mt;a.b=this,a.f|=Q0,r(s)}),this.parent=Mt.b,this.transform_error=i??((o=this.parent)==null?void 0:o.transform_error)??(s=>s),wt(this,Lr,ll(()=>{Ht(this,Sn,sv).call(this)},gM))}defer_effect(e){Q_(e,oe(this,Fd),oe(this,zd))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!oe(this,gi).pending}update_pending_count(e,n){Ht(this,Sn,av).call(this,e,n),wt(this,Ia,oe(this,Ia)+e),!(!oe(this,Jo)||oe(this,oc))&&(wt(this,oc,!0),Ki(()=>{wt(this,oc,!1),oe(this,Jo)&&$o(oe(this,Jo),oe(this,Ia))}))}get_effect_pending(){return oe(this,fm).call(this),u(oe(this,Jo))}error(e){if(!oe(this,gi).onerror&&!oe(this,gi).failed)throw e;pt!=null&&pt.is_fork?(oe(this,vi)&&pt.skip_effect(oe(this,vi)),oe(this,Cr)&&pt.skip_effect(oe(this,Cr)),oe(this,$r)&&pt.skip_effect(oe(this,$r)),pt.on_fork_commit(()=>{Ht(this,Sn,lv).call(this,e)})):Ht(this,Sn,lv).call(this,e)}}mi=new WeakMap,Kb=new WeakMap,gi=new WeakMap,Oa=new WeakMap,Lr=new WeakMap,vi=new WeakMap,Cr=new WeakMap,$r=new WeakMap,Yo=new WeakMap,Ia=new WeakMap,Ps=new WeakMap,oc=new WeakMap,Fd=new WeakMap,zd=new WeakMap,Jo=new WeakMap,fm=new WeakMap,Sn=new WeakSet,bM=function(){try{wt(this,vi,bi(()=>oe(this,Oa).call(this,oe(this,mi))))}catch(e){this.error(e)}},yM=function(e){const n=oe(this,gi).failed;n&&wt(this,$r,bi(()=>{n(oe(this,mi),()=>e,()=>()=>{})}))},wM=function(){const e=oe(this,gi).pending;e&&(this.is_pending=!0,wt(this,Cr,bi(()=>e(oe(this,mi)))),Ki(()=>{var n=wt(this,Yo,document.createDocumentFragment()),r=es();n.append(r),wt(this,vi,Ht(this,Sn,fh).call(this,()=>bi(()=>oe(this,Oa).call(this,r)))),oe(this,Ps)===0&&(oe(this,mi).before(n),wt(this,Yo,null),Pa(oe(this,Cr),()=>{wt(this,Cr,null)}),Ht(this,Sn,dh).call(this,pt))}))},sv=function(){try{if(this.is_pending=this.has_pending_snippet(),wt(this,Ps,0),wt(this,Ia,0),wt(this,vi,bi(()=>{oe(this,Oa).call(this,oe(this,mi))})),oe(this,Ps)>0){var e=wt(this,Yo,document.createDocumentFragment());o1(oe(this,vi),e);const n=oe(this,gi).pending;wt(this,Cr,bi(()=>n(oe(this,mi))))}else Ht(this,Sn,dh).call(this,pt)}catch(n){this.error(n)}},dh=function(e){this.is_pending=!1,e.transfer_effects(oe(this,Fd),oe(this,zd))},fh=function(e){var n=Mt,r=Bt,i=Cn;Ao(oe(this,Lr)),Ii(oe(this,Lr)),cc(oe(this,Lr).ctx);try{return cs.ensure(),e()}catch(o){return J_(o),null}finally{Ao(n),Ii(r),cc(i)}},av=function(e,n){var r;if(!this.has_pending_snippet()){this.parent&&Ht(r=this.parent,Sn,av).call(r,e,n);return}wt(this,Ps,oe(this,Ps)+e),oe(this,Ps)===0&&(Ht(this,Sn,dh).call(this,n),oe(this,Cr)&&Pa(oe(this,Cr),()=>{wt(this,Cr,null)}),oe(this,Yo)&&(oe(this,mi).before(oe(this,Yo)),wt(this,Yo,null)))},lv=function(e){oe(this,vi)&&(Er(oe(this,vi)),wt(this,vi,null)),oe(this,Cr)&&(Er(oe(this,Cr)),wt(this,Cr,null)),oe(this,$r)&&(Er(oe(this,$r)),wt(this,$r,null));var n=oe(this,gi).onerror;let r=oe(this,gi).failed;var i=!1,o=!1;const s=()=>{if(i){sM();return}i=!0,o&&U6(),oe(this,$r)!==null&&Pa(oe(this,$r),()=>{wt(this,$r,null)}),Ht(this,Sn,fh).call(this,()=>{Ht(this,Sn,sv).call(this)})},a=l=>{try{o=!0,n==null||n(l,s),o=!1}catch(c){Fs(c,oe(this,Lr)&&oe(this,Lr).parent)}r&&wt(this,$r,Ht(this,Sn,fh).call(this,()=>{try{return bi(()=>{var c=Mt;c.b=this,c.f|=Q0,r(oe(this,mi),()=>l,()=>s)})}catch(c){return Fs(c,oe(this,Lr).parent),null}}))};Ki(()=>{var l;try{l=this.transform_error(e)}catch(c){Fs(c,oe(this,Lr)&&oe(this,Lr).parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(a,c=>Fs(c,oe(this,Lr)&&oe(this,Lr).parent)):a(l)})};function kM(t,e,n,r){const i=al()?Ku:Qb;var o=t.filter(h=>!h.settled);if(n.length===0&&o.length===0){r(e.map(i));return}var s=Mt,a=sC(),l=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(h=>h.promise)):null;function c(h){if((s.f&Ei)===0){a();try{r(h)}catch(p){Fs(p,s)}Wu()}}var d=aC();if(n.length===0){l.then(()=>c(e.map(i))).finally(d);return}function f(){Promise.all(n.map(h=>xM(h))).then(h=>c([...e.map(i),...h])).catch(h=>Fs(h,s)).finally(d)}l?l.then(()=>{a(),f(),Wu()}):f()}function sC(){var t=Mt,e=Bt,n=Cn,r=pt;return function(o=!0){Ao(t),Ii(e),cc(n),o&&(t.f&Ei)===0&&(r==null||r.activate(),r==null||r.apply())}}function Wu(t=!0){Ao(null),Ii(null),cc(null),t&&(pt==null||pt.deactivate())}function aC(){var t=Mt,e=t.b,n=pt,r=e.is_rendered();return e.update_pending_count(1,n),n.increment(r,t),()=>{e.update_pending_count(-1,n),n.decrement(r,t)}}function Ku(t){var e=ur|Xn;return Mt!==null&&(Mt.f|=sl),{ctx:Cn,deps:null,effects:null,equals:K_,f:e,fn:t,reactions:null,rv:0,v:Pn,wv:0,parent:Mt,ac:null}}const Sf=Symbol("obsolete");function xM(t,e,n){let r=Mt;r===null&&I6();var i=void 0,o=us(Pn),s=!Bt,a=new Set;return NM(()=>{var p;var l=Mt,c=B_();i=c.promise;try{Promise.resolve(t()).then(c.resolve,m=>{m!==ym&&c.reject(m)}).finally(Wu)}catch(m){c.reject(m),Wu()}var d=pt;if(s){if((l.f&sa)!==0)var f=aC();if(r.b.is_rendered())(p=d.async_deriveds.get(l))==null||p.reject(Sf);else for(const m of a.values())m.reject(Sf);a.add(c),d.async_deriveds.set(l,c)}const h=(m,v=void 0)=>{f==null||f(),a.delete(c),v!==Sf&&(d.activate(),v?(o.f|=qs,$o(o,v)):((o.f&qs)!==0&&(o.f^=qs),$o(o,m)),d.deactivate())};c.promise.then(h,m=>h(null,m||"unknown"))}),n1(()=>{for(const l of a)l.reject(Sf)}),new Promise(l=>{function c(d){function f(){d===i?l(o):c(i)}d.then(f,f)}c(i)})}function L(t){const e=Ku(t);return CC(e),e}function Qb(t){const e=Ku(t);return e.equals=Z_,e}function _M(t){var e=t.effects;if(e!==null){t.effects=null;for(var n=0;n<e.length;n+=1)Er(e[n])}}function $b(t){var e,n=Mt,r=t.parent;if(!ds&&r!==null&&(r.f&(Ei|Sr))!==0)return iM(),t.v;Ao(r);try{t.f&=~Wa,_M(t),e=TC(t)}finally{Ao(n)}return e}function lC(t){var e=$b(t);if(!t.equals(e)&&(t.wv=EC(),(!(pt!=null&&pt.is_fork)||t.deps===null)&&(pt!==null?(pt.capture(t,e,!0),Cu==null||Cu.capture(t,e,!0)):t.v=e,t.deps===null))){xn(t,Bn);return}ds||(sr!==null?(t1()||pt!=null&&pt.is_fork)&&sr.set(t,e):Yb(t))}function CM(t){var e,n;if(t.effects!==null)for(const r of t.effects)(r.teardown||r.ac)&&((e=r.teardown)==null||e.call(r),(n=r.ac)==null||n.abort(ym),r.teardown=kn,r.ac=null,Zu(r,0),r1(r))}function cC(t){if(t.effects!==null)for(const e of t.effects)e.teardown&&uc(e)}let Bh=new Set;const Na=new Map;let uC=!1;function us(t,e){var n={f:0,v:t,reactions:null,equals:K_,rv:0,wv:0};return n}function F(t,e){const n=us(t);return CC(n),n}function cv(t,e=!1,n=!0){var i;const r=us(t);return e||(r.equals=Z_),Pc&&n&&Cn!==null&&Cn.l!==null&&((i=Cn.l).s??(i.s=[])).push(r),r}function b(t,e,n=!1){Bt!==null&&(!qi||(Bt.f&Fh)!==0)&&al()&&(Bt.f&(ur|Ci|Fl|Fh))!==0&&(Ai===null||!ac.call(Ai,t))&&V6();let r=n?tt(e):e;return $o(t,r,ch)}function $o(t,e,n=null){if(!t.equals(e)){Na.set(t,ds?e:t.v);var r=cs.ensure();if(r.capture(t,e),(t.f&ur)!==0){const i=t;(t.f&Xn)!==0&&$b(i),sr===null&&Yb(i)}t.wv=EC(),dC(t,Xn,n),al()&&Mt!==null&&(Mt.f&Bn)!==0&&(Mt.f&(Zi|as))===0&&(pi===null?LM([t]):pi.push(t)),!r.is_fork&&Bh.size>0&&!uC&&SM()}return e}function SM(){uC=!1;for(const t of Bh){(t.f&Bn)!==0&&xn(t,Eo);let e;try{e=Wd(t)}catch{e=!0}e&&uc(t)}Bh.clear()}function Gu(t,e=1){var n=u(t),r=e===1?n++:n--;return b(t,n),r}function Su(t){b(t,t.v+1)}function dC(t,e,n){var r=t.reactions;if(r!==null)for(var i=al(),o=r.length,s=0;s<o;s++){var a=r[s],l=a.f;if(!(!i&&a===Mt)){var c=(l&Xn)===0;if(c&&xn(a,e),(l&Fh)!==0)Bh.add(a);else if((l&ur)!==0){var d=a;sr==null||sr.delete(d),(l&Wa)===0&&(l&Si&&(Mt===null||(Mt.f&zh)===0)&&(a.f|=Wa),dC(d,Eo,n))}else if(c){var f=a;(l&Ci)!==0&&Vi!==null&&Vi.add(f),n!==null?n.push(f):Xb(f)}}}}function tt(t){if(typeof t!="object"||t===null||xo in t)return t;const e=Zb(t);if(e!==C6&&e!==S6)return t;var n=new Map,r=Gb(t),i=F(0),o=La,s=a=>{if(La===o)return a();var l=Bt,c=La;Ii(null),vw(o);var d=a();return Ii(l),vw(c),d};return r&&n.set("length",F(t.length)),new Proxy(t,{defineProperty(a,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&B6();var d=n.get(l);return d===void 0?s(()=>{var f=F(c.value);return n.set(l,f),f}):b(d,c.value,!0),!0},deleteProperty(a,l){var c=n.get(l);if(c===void 0){if(l in a){const d=s(()=>F(Pn));n.set(l,d),Su(i)}}else b(c,Pn),Su(i);return!0},get(a,l,c){var p;if(l===xo)return t;var d=n.get(l),f=l in a;if(d===void 0&&(!f||(p=js(a,l))!=null&&p.writable)&&(d=s(()=>{var m=tt(f?a[l]:Pn),v=F(m);return v}),n.set(l,d)),d!==void 0){var h=u(d);return h===Pn?void 0:h}return Reflect.get(a,l,c)},getOwnPropertyDescriptor(a,l){var c=Reflect.getOwnPropertyDescriptor(a,l);if(c&&"value"in c){var d=n.get(l);d&&(c.value=u(d))}else if(c===void 0){var f=n.get(l),h=f==null?void 0:f.v;if(f!==void 0&&h!==Pn)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(a,l){var h;if(l===xo)return!0;var c=n.get(l),d=c!==void 0&&c.v!==Pn||Reflect.has(a,l);if(c!==void 0||Mt!==null&&(!d||(h=js(a,l))!=null&&h.writable)){c===void 0&&(c=s(()=>{var p=d?tt(a[l]):Pn,m=F(p);return m}),n.set(l,c));var f=u(c);if(f===Pn)return!1}return d},set(a,l,c,d){var _;var f=n.get(l),h=l in a;if(r&&l==="length")for(var p=c;p<f.v;p+=1){var m=n.get(p+"");m!==void 0?b(m,Pn):p in a&&(m=s(()=>F(Pn)),n.set(p+"",m))}if(f===void 0)(!h||(_=js(a,l))!=null&&_.writable)&&(f=s(()=>F(void 0)),b(f,tt(c)),n.set(l,f));else{h=f.v!==Pn;var v=s(()=>tt(c));b(f,v)}var g=Reflect.getOwnPropertyDescriptor(a,l);if(g!=null&&g.set&&g.set.call(d,c),!h){if(r&&typeof l=="string"){var y=n.get("length"),C=Number(l);Number.isInteger(C)&&C>=y.v&&b(y,C+1)}Su(i)}return!0},ownKeys(a){u(i);var l=Reflect.ownKeys(a).filter(f=>{var h=n.get(f);return h===void 0||h.v!==Pn});for(var[c,d]of n)d.v!==Pn&&!(c in a)&&l.push(c);return l},setPrototypeOf(){H6()}})}function hw(t){try{if(t!==null&&typeof t=="object"&&xo in t)return t[xo]}catch{}return t}function EM(t,e){return Object.is(hw(t),hw(e))}var pw,fC,hC,pC;function AM(){if(pw===void 0){pw=window,fC=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,n=Text.prototype;hC=js(e,"firstChild").get,pC=js(e,"nextSibling").get,uw(t)&&(t[ev]=void 0,t[ah]=null,t[tv]=void 0,t.__e=void 0),uw(n)&&(n[fu]=void 0)}}function es(t=""){return document.createTextNode(t)}function ti(t){return hC.call(t)}function jd(t){return pC.call(t)}function w(t,e){return ti(t)}function Ae(t,e=!1){{var n=ti(t);return n instanceof Comment&&n.data===""?jd(n):n}}function k(t,e=1,n=!1){let r=t;for(;e--;)r=jd(r);return r}function TM(t){t.textContent=""}function mC(){return!1}function gC(t,e,n){return document.createElementNS(e??W_,t,void 0)}function MM(t,e){{const n=document.body;t.autofocus=!0,Ki(()=>{document.activeElement===n&&t.focus()})}}let mw=!1;function DM(){mw||(mw=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{var e;if(!t.defaultPrevented)for(const n of t.target.elements)(e=n[lh])==null||e.call(n)})},{capture:!0}))}function Lc(t){var e=Bt,n=Mt;Ii(null),Ao(null);try{return t()}finally{Ii(e),Ao(n)}}function e1(t,e,n,r=n){t.addEventListener(e,()=>Lc(n));const i=t[lh];i?t[lh]=()=>{i(),r(!0)}:t[lh]=()=>r(!0),DM()}function OM(t){Mt===null&&(Bt===null&&L6(),P6()),ds&&N6()}function IM(t,e){var n=e.last;n===null?e.last=e.first=t:(n.next=t,t.prev=n,e.last=t)}function Io(t,e){var n=Mt;n!==null&&(n.f&Sr)!==0&&(t|=Sr);var r={ctx:Cn,deps:null,nodes:null,f:t|Xn|Si,first:null,fn:e,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};pt==null||pt.register_created_effect(r);var i=r;if((t&lc)!==0)Rl!==null?Rl.push(r):cs.ensure().schedule(r);else if(e!==null){try{uc(r)}catch(s){throw Er(r),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&sl)===0&&(i=i.first,(t&Ci)!==0&&(t&ls)!==0&&i!==null&&(i.f|=ls))}if(i!==null&&(i.parent=n,n!==null&&IM(i,n),Bt!==null&&(Bt.f&ur)!==0&&(t&as)===0)){var o=Bt;(o.effects??(o.effects=[])).push(i)}return r}function t1(){return Bt!==null&&!qi}function n1(t){const e=Io(bm,null);return xn(e,Bn),e.teardown=t,e}function pe(t){OM();var e=Mt.f,n=!Bt&&(e&Zi)!==0&&(e&sa)===0;if(n){var r=Cn;(r.e??(r.e=[])).push(t)}else return vC(t)}function vC(t){return Io(lc|M6,t)}function bC(t){cs.ensure();const e=Io(as|sl,t);return()=>{Er(e)}}function RM(t){cs.ensure();const e=Io(as|sl,t);return(n={})=>new Promise(r=>{n.outro?Pa(e,()=>{Er(e),r(void 0)}):(Er(e),r(void 0))})}function Fc(t){return Io(lc,t)}function NM(t){return Io(Fl|sl,t)}function qd(t,e=0){return Io(bm|e,t)}function W(t,e=[],n=[],r=[]){kM(r,e,n,i=>{Io(bm,()=>t(...i.map(u)))})}function ll(t,e=0){var n=Io(Ci|e,t);return n}function bi(t){return Io(Zi|sl,t)}function yC(t){var e=t.teardown;if(e!==null){const n=ds,r=Bt;gw(!0),Ii(null);try{e.call(null)}finally{gw(n),Ii(r)}}}function r1(t,e=!1){var n=t.first;for(t.first=t.last=null;n!==null;){const i=n.ac;i!==null&&Lc(()=>{i.abort(ym)});var r=n.next;(n.f&as)!==0?n.parent=null:Er(n,e),n=r}}function PM(t){for(var e=t.first;e!==null;){var n=e.next;(e.f&Zi)===0&&Er(e),e=n}}function Er(t,e=!0){var n=!1;(e||(t.f&T6)!==0)&&t.nodes!==null&&t.nodes.end!==null&&(wC(t.nodes.start,t.nodes.end),n=!0),xn(t,$0),r1(t,e&&!n),Zu(t,0);var r=t.nodes&&t.nodes.t;if(r!==null)for(const o of r)o.stop();yC(t),t.f^=$0,t.f|=Ei;var i=t.parent;i!==null&&i.first!==null&&kC(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes=t.ac=t.b=null}function wC(t,e){for(;t!==null;){var n=t===e?null:jd(t);t.remove(),t=n}}function kC(t){var e=t.parent,n=t.prev,r=t.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),e!==null&&(e.first===t&&(e.first=r),e.last===t&&(e.last=n))}function Pa(t,e,n=!0){var r=[];xC(t,r,!0);var i=()=>{n&&Er(t),e&&e()},o=r.length;if(o>0){var s=()=>--o||i();for(var a of r)a.out(s)}else i()}function xC(t,e,n){if((t.f&Sr)===0){t.f^=Sr;var r=t.nodes&&t.nodes.t;if(r!==null)for(const a of r)(a.is_global||n)&&e.push(a);for(var i=t.first;i!==null;){var o=i.next;if((i.f&as)===0){var s=(i.f&ls)!==0||(i.f&Zi)!==0&&(t.f&Ci)!==0;xC(i,e,s?n:!1)}i=o}}}function i1(t){_C(t,!0)}function _C(t,e){if((t.f&Sr)!==0){t.f^=Sr,(t.f&Bn)===0&&(xn(t,Xn),cs.ensure().schedule(t));for(var n=t.first;n!==null;){var r=n.next,i=(n.f&ls)!==0||(n.f&Zi)!==0;_C(n,i?e:!1),n=r}var o=t.nodes&&t.nodes.t;if(o!==null)for(const s of o)(s.is_global||e)&&s.in()}}function o1(t,e){if(t.nodes)for(var n=t.nodes.start,r=t.nodes.end;n!==null;){var i=n===r?null:jd(n);e.append(n),n=i}}let hh=!1,ds=!1;function gw(t){ds=t}let Bt=null,qi=!1;function Ii(t){Bt=t}let Mt=null;function Ao(t){Mt=t}let Ai=null;function CC(t){Bt!==null&&(Ai===null?Ai=[t]:Ai.push(t))}let Fr=null,Yr=0,pi=null;function LM(t){pi=t}let SC=1,ka=0,La=ka;function vw(t){La=t}function EC(){return++SC}function Wd(t){var e=t.f;if((e&Xn)!==0)return!0;if(e&ur&&(t.f&=~Wa),(e&Eo)!==0){for(var n=t.deps,r=n.length,i=0;i<r;i++){var o=n[i];if(Wd(o)&&lC(o),o.wv>t.wv)return!0}(e&Si)!==0&&sr===null&&xn(t,Bn)}return!1}function AC(t,e,n=!0){var r=t.reactions;if(r!==null&&!(Ai!==null&&ac.call(Ai,t)))for(var i=0;i<r.length;i++){var o=r[i];(o.f&ur)!==0?AC(o,e,!1):e===o&&(n?xn(o,Xn):(o.f&Bn)!==0&&xn(o,Eo),Xb(o))}}function TC(t){var v;var e=Fr,n=Yr,r=pi,i=Bt,o=Ai,s=Cn,a=qi,l=La,c=t.f;Fr=null,Yr=0,pi=null,Bt=(c&(Zi|as))===0?t:null,Ai=null,cc(t.ctx),qi=!1,La=++ka,t.ac!==null&&(Lc(()=>{t.ac.abort(ym)}),t.ac=null);try{t.f|=zh;var d=t.fn,f=d();t.f|=sa;var h=t.deps,p=pt==null?void 0:pt.is_fork;if(Fr!==null){var m;if(p||Zu(t,Yr),h!==null&&Yr>0)for(h.length=Yr+Fr.length,m=0;m<Fr.length;m++)h[Yr+m]=Fr[m];else t.deps=h=Fr;if(t1()&&(t.f&Si)!==0)for(m=Yr;m<h.length;m++)((v=h[m]).reactions??(v.reactions=[])).push(t)}else!p&&h!==null&&Yr<h.length&&(Zu(t,Yr),h.length=Yr);if(al()&&pi!==null&&!qi&&h!==null&&(t.f&(ur|Eo|Xn))===0)for(m=0;m<pi.length;m++)AC(pi[m],t);if(i!==null&&i!==t){if(ka++,i.deps!==null)for(let g=0;g<n;g+=1)i.deps[g].rv=ka;if(e!==null)for(const g of e)g.rv=ka;pi!==null&&(r===null?r=pi:r.push(...pi))}return(t.f&qs)!==0&&(t.f^=qs),f}catch(g){return J_(g)}finally{t.f^=zh,Fr=e,Yr=n,pi=r,Bt=i,Ai=o,cc(s),qi=a,La=l}}function FM(t,e){let n=e.reactions;if(n!==null){var r=x6.call(n,t);if(r!==-1){var i=n.length-1;i===0?n=e.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&(e.f&ur)!==0&&(Fr===null||!ac.call(Fr,e))){var o=e;(o.f&Si)!==0&&(o.f^=Si,o.f&=~Wa),o.v!==Pn&&Yb(o),CM(o),Zu(o,0)}}function Zu(t,e){var n=t.deps;if(n!==null)for(var r=e;r<n.length;r++)FM(t,n[r])}function uc(t){var e=t.f;if((e&Ei)===0){xn(t,Bn);var n=Mt,r=hh;Mt=t,hh=!0;try{(e&(Ci|H_))!==0?PM(t):r1(t),yC(t);var i=TC(t);t.teardown=typeof i=="function"?i:null,t.wv=SC;var o;F_&&aM&&(t.f&Xn)!==0&&t.deps}finally{hh=r,Mt=n}}}async function MC(){await Promise.resolve(),tC()}function u(t){var e=t.f,n=(e&ur)!==0;if(Bt!==null&&!qi){var r=Mt!==null&&(Mt.f&Ei)!==0;if(!r&&(Ai===null||!ac.call(Ai,t))){var i=Bt.deps;if((Bt.f&zh)!==0)t.rv<ka&&(t.rv=ka,Fr===null&&i!==null&&i[Yr]===t?Yr++:Fr===null?Fr=[t]:Fr.push(t));else{(Bt.deps??(Bt.deps=[])).push(t);var o=t.reactions;o===null?t.reactions=[Bt]:ac.call(o,Bt)||o.push(Bt)}}}if(ds&&Na.has(t))return Na.get(t);if(n){var s=t;if(ds){var a=s.v;return((s.f&Bn)===0&&s.reactions!==null||OC(s))&&(a=$b(s)),Na.set(s,a),a}var l=(s.f&Si)===0&&!qi&&Bt!==null&&(hh||(Bt.f&Si)!==0),c=(s.f&sa)===0;Wd(s)&&(l&&(s.f|=Si),lC(s)),l&&!c&&(cC(s),DC(s))}if(sr!=null&&sr.has(t))return sr.get(t);if((t.f&qs)!==0)throw t.v;return t.v}function DC(t){if(t.f|=Si,t.deps!==null)for(const e of t.deps)(e.reactions??(e.reactions=[])).push(t),(e.f&ur)!==0&&(e.f&Si)===0&&(cC(e),DC(e))}function OC(t){if(t.v===Pn)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(Na.has(e)||(e.f&ur)!==0&&OC(e))return!0;return!1}function Ct(t){var e=qi;try{return qi=!0,t()}finally{qi=e}}function zM(t){if(!(typeof t!="object"||!t||t instanceof EventTarget)){if(xo in t)uv(t);else if(!Array.isArray(t))for(let e in t){const n=t[e];typeof n=="object"&&n&&xo in n&&uv(n)}}}function uv(t,e=new Set){if(typeof t=="object"&&t!==null&&!(t instanceof EventTarget)&&!e.has(t)){e.add(t),t instanceof Date&&t.getTime();for(let r in t)try{uv(t[r],e)}catch{}const n=Zb(t);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const r=z_(n);for(let i in r){const o=r[i].get;if(o)try{o.call(t)}catch{}}}}}const BM=["touchstart","touchmove"];function HM(t){return BM.includes(t)}const xa=Symbol("events"),IC=new Set,dv=new Set;function VM(t,e,n,r={}){function i(o){if(r.capture||fv.call(e,o),!o.cancelBubble)return Lc(()=>n==null?void 0:n.call(this,o))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?Ki(()=>{e.addEventListener(t,i,r)}):e.addEventListener(t,i,r),i}function Qt(t,e,n,r,i){var o={capture:r,passive:i},s=VM(t,e,n,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&n1(()=>{e.removeEventListener(t,s,o)})}function P(t,e,n){(e[xa]??(e[xa]={}))[t]=n}function lt(t){for(var e=0;e<t.length;e++)IC.add(t[e]);for(var n of dv)n(t)}let bw=null;function fv(t){var g,y;var e=this,n=e.ownerDocument,r=t.type,i=((g=t.composedPath)==null?void 0:g.call(t))||[],o=i[0]||t.target;bw=t;var s=0,a=bw===t&&t[xa];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){t[xa]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||t.target,o!==e){_6(t,"currentTarget",{configurable:!0,get(){return o||n}});var d=Bt,f=Mt;Ii(null),Ao(null);try{for(var h,p=[];o!==null;){var m=o.assignedSlot||o.parentNode||o.host||null;try{var v=(y=o[xa])==null?void 0:y[r];v!=null&&(!o.disabled||t.target===o)&&v.call(o,t)}catch(C){h?p.push(C):h=C}if(t.cancelBubble||m===e||m===null)break;o=m}if(h){for(let C of p)queueMicrotask(()=>{throw C});throw h}}finally{t[xa]=e,delete t.currentTarget,Ii(d),Ao(f)}}}var P_;const Eg=((P_=globalThis==null?void 0:globalThis.window)==null?void 0:P_.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:t=>t});function UM(t){return(Eg==null?void 0:Eg.createHTML(t))??t}function RC(t){var e=gC("template");return e.innerHTML=UM(t.replaceAll("<!>","<!---->")),e.content}function Js(t,e){var n=Mt;n.nodes===null&&(n.nodes={start:t,end:e,a:null,t:null})}function T(t,e){var n=(e&q_)!==0,r=(e&tM)!==0,i,o=!t.startsWith("<!>");return()=>{i===void 0&&(i=RC(o?t:"<!>"+t),n||(i=ti(i)));var s=r||fC?document.importNode(i,!0):i.cloneNode(!0);if(n){var a=ti(s),l=s.lastChild;Js(a,l)}else Js(s,s);return s}}function jM(t,e,n="svg"){var r=!t.startsWith("<!>"),i=(e&q_)!==0,o=`<${n}>${r?t:"<!>"+t}</${n}>`,s;return()=>{if(!s){var a=RC(o),l=ti(a);if(i)for(s=document.createDocumentFragment();ti(l);)s.appendChild(ti(l));else s=ti(l)}var c=s.cloneNode(!0);if(i){var d=ti(c),f=c.lastChild;Js(d,f)}else Js(c,c);return c}}function an(t,e){return jM(t,e,"svg")}function fr(t=""){{var e=es(t+"");return Js(e,e),e}}function St(){var t=document.createDocumentFragment(),e=document.createComment(""),n=es();return t.append(e,n),Js(e,n),t}function x(t,e){t!==null&&t.before(e)}let hv=!0;function G(t,e){var n=e==null?"":typeof e=="object"?`${e}`:e;n!==(t[fu]??(t[fu]=t.nodeValue))&&(t[fu]=n,t.nodeValue=`${n}`)}function qM(t,e){return WM(t,e)}const Ef=new Map;function WM(t,{target:e,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:a}){AM();var l=void 0,c=RM(()=>{var d=n??e.appendChild(es());oC(d,{pending:()=>{}},p=>{nt({});var m=Cn;o&&(m.c=o),i&&(r.$$events=i),hv=s,l=t(p,r)||{},hv=!0,rt()},a);var f=new Set,h=p=>{for(var m=0;m<p.length;m++){var v=p[m];if(!f.has(v)){f.add(v);var g=HM(v);for(const _ of[e,document]){var y=Ef.get(_);y===void 0&&(y=new Map,Ef.set(_,y));var C=y.get(v);C===void 0?(_.addEventListener(v,fv,{passive:g}),y.set(v,1)):y.set(v,C+1)}}}};return h(vm(IC)),dv.add(h),()=>{var g;for(var p of f)for(const y of[e,document]){var m=Ef.get(y),v=m.get(p);--v==0?(y.removeEventListener(p,fv),m.delete(p),m.size===0&&Ef.delete(y)):m.set(p,v)}dv.delete(h),d!==n&&((g=d.parentNode)==null||g.removeChild(d))}});return KM.set(l,c),l}let KM=new WeakMap;var Ui,vo,ei,Ra,Bd,Hd,hm;class Kd{constructor(e,n=!0){Wn(this,"anchor");yt(this,Ui,new Map);yt(this,vo,new Map);yt(this,ei,new Map);yt(this,Ra,new Set);yt(this,Bd,!0);yt(this,Hd,e=>{if(oe(this,Ui).has(e)){var n=oe(this,Ui).get(e),r=oe(this,vo).get(n);if(r)i1(r),oe(this,Ra).delete(n);else{var i=oe(this,ei).get(n);i&&(oe(this,vo).set(n,i.effect),oe(this,ei).delete(n),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[o,s]of oe(this,Ui)){if(oe(this,Ui).delete(o),o===e)break;const a=oe(this,ei).get(s);a&&(Er(a.effect),oe(this,ei).delete(s))}for(const[o,s]of oe(this,vo)){if(o===n||oe(this,Ra).has(o))continue;const a=()=>{if(Array.from(oe(this,Ui).values()).includes(o)){var c=document.createDocumentFragment();o1(s,c),c.append(es()),oe(this,ei).set(o,{effect:s,fragment:c})}else Er(s);oe(this,Ra).delete(o),oe(this,vo).delete(o)};oe(this,Bd)||!r?(oe(this,Ra).add(o),Pa(s,a,!1)):a()}}});yt(this,hm,e=>{oe(this,Ui).delete(e);const n=Array.from(oe(this,Ui).values());for(const[r,i]of oe(this,ei))n.includes(r)||(Er(i.effect),oe(this,ei).delete(r))});this.anchor=e,wt(this,Bd,n)}ensure(e,n){var r=pt,i=mC();if(n&&!oe(this,vo).has(e)&&!oe(this,ei).has(e))if(i){var o=document.createDocumentFragment(),s=es();o.append(s),oe(this,ei).set(e,{effect:bi(()=>n(s)),fragment:o})}else oe(this,vo).set(e,bi(()=>n(this.anchor)));if(oe(this,Ui).set(r,e),i){for(const[a,l]of oe(this,vo))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of oe(this,ei))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(oe(this,Hd)),r.ondiscard(oe(this,hm))}else oe(this,Hd).call(this,r)}}Ui=new WeakMap,vo=new WeakMap,ei=new WeakMap,Ra=new WeakMap,Bd=new WeakMap,Hd=new WeakMap,hm=new WeakMap;const GM=0,yw=1,ZM=2;function NC(t,e,n,r,i){var o=al(),s=Pn,a=o?us(s):cv(s,!1,!1),l=o?us(s):cv(s,!1,!1),c=new Kd(t);ll(()=>{var d=pt;d.deactivate();var f=e();d.activate();var h=!1;if(E6(f)){var p=sC(),m=!1;const v=g=>{if(!h){m=!0,p(!1),cs.ensure();try{g()}finally{Wu(!1),zl||tC()}}};f.then(g=>{v(()=>{$o(a,g),c.ensure(yw,r&&(y=>r(y,a)))})},g=>{v(()=>{if($o(l,g),c.ensure(ZM,i&&(y=>i(y,l))),!i)throw l.v})}),Ki(()=>{m||v(()=>{c.ensure(GM,n)})})}else $o(a,f),c.ensure(yw,r&&(v=>r(v,a)));return()=>{h=!0}})}function j(t,e,n=!1){var r=new Kd(t),i=n?ls:0;function o(s,a){r.ensure(s,a)}ll(()=>{var s=!1;e((a,l=0)=>{s=!0,o(l,a)}),s||o(-1,null)},i)}const YM=Symbol("NaN");function Bl(t,e,n){var r=new Kd(t),i=!al();ll(()=>{var o=e();o!==o&&(o=YM),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,n)})}function dc(t,e){return e}function JM(t,e,n){for(var r=[],i=e.length,o,s=e.length,a=0;a<i;a++){let f=e[a];Pa(f,()=>{if(o){if(o.pending.delete(f),o.done.add(f),o.pending.size===0){var h=t.outrogroups;pv(t,vm(o.done)),h.delete(o),h.size===0&&(t.outrogroups=null)}}else s-=1},!1)}if(s===0){var l=r.length===0&&n!==null;if(l){var c=n,d=c.parentNode;TM(d),d.append(c),t.items.clear()}pv(t,e,!l)}else o={pending:new Set(e),done:new Set},(t.outrogroups??(t.outrogroups=new Set)).add(o)}function pv(t,e,n=!0){var r;if(t.pending.size>0){r=new Set;for(const s of t.pending.values())for(const a of s)r.add(t.items.get(a).e)}for(var i=0;i<e.length;i++){var o=e[i];if(r!=null&&r.has(o)){o.f|=bo;const s=document.createDocumentFragment();o1(o,s)}else Er(e[i],n)}}var ww;function mt(t,e,n,r,i,o=null){var s=t,a=new Map,l=(e&j_)!==0;if(l){var c=t;s=c.appendChild(es())}var d=null,f=Qb(()=>{var _=n();return Gb(_)?_:_==null?[]:vm(_)}),h,p=new Map,m=!0;function v(_){(C.effect.f&Ei)===0&&(C.pending.delete(_),C.fallback=d,XM(C,h,s,e,r),d!==null&&(h.length===0?(d.f&bo)===0?i1(d):(d.f^=bo,pu(d,null,s)):Pa(d,()=>{d=null})))}function g(_){C.pending.delete(_)}var y=ll(()=>{h=u(f);for(var _=h.length,S=new Set,A=pt,O=mC(),E=0;E<_;E+=1){var M=h[E],R=r(M,E),D=m?null:a.get(R);D?(D.v&&$o(D.v,M),D.i&&$o(D.i,E),O&&A.unskip_effect(D.e)):(D=QM(a,m?s:ww??(ww=es()),M,R,E,i,e,n),m||(D.e.f|=bo),a.set(R,D)),S.add(R)}if(_===0&&o&&!d&&(m?d=bi(()=>o(s)):(d=bi(()=>o(ww??(ww=es()))),d.f|=bo)),_>S.size&&R6(),!m)if(p.set(A,S),O){for(const[I,H]of a)S.has(I)||A.skip_effect(H.e);A.oncommit(v),A.ondiscard(g)}else v(A);u(f)}),C={effect:y,items:a,pending:p,outrogroups:null,fallback:d};m=!1}function eu(t){for(;t!==null&&(t.f&Zi)===0;)t=t.next;return t}function XM(t,e,n,r,i){var D,I,H,z,Q,ie,me,le,ke;var o=(r&W6)!==0,s=e.length,a=t.items,l=eu(t.effect.first),c,d=null,f,h=[],p=[],m,v,g,y;if(o)for(y=0;y<s;y+=1)m=e[y],v=i(m,y),g=a.get(v).e,(g.f&bo)===0&&((I=(D=g.nodes)==null?void 0:D.a)==null||I.measure(),(f??(f=new Set)).add(g));for(y=0;y<s;y+=1){if(m=e[y],v=i(m,y),g=a.get(v).e,t.outrogroups!==null)for(const ce of t.outrogroups)ce.pending.delete(g),ce.done.delete(g);if((g.f&Sr)!==0&&(i1(g),o&&((z=(H=g.nodes)==null?void 0:H.a)==null||z.unfix(),(f??(f=new Set)).delete(g))),(g.f&bo)!==0)if(g.f^=bo,g===l)pu(g,null,n);else{var C=d?d.next:l;g===t.effect.last&&(t.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),ys(t,d,g),ys(t,g,C),pu(g,C,n),d=g,h=[],p=[],l=eu(d.next);continue}if(g!==l){if(c!==void 0&&c.has(g)){if(h.length<p.length){var _=p[0],S;d=_.prev;var A=h[0],O=h[h.length-1];for(S=0;S<h.length;S+=1)pu(h[S],_,n);for(S=0;S<p.length;S+=1)c.delete(p[S]);ys(t,A.prev,O.next),ys(t,d,A),ys(t,O,_),l=_,d=O,y-=1,h=[],p=[]}else c.delete(g),pu(g,l,n),ys(t,g.prev,g.next),ys(t,g,d===null?t.effect.first:d.next),ys(t,d,g),d=g;continue}for(h=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=eu(l.next);if(l===null)continue}(g.f&bo)===0&&h.push(g),d=g,l=eu(g.next)}if(t.outrogroups!==null){for(const ce of t.outrogroups)ce.pending.size===0&&(pv(t,vm(ce.done)),(Q=t.outrogroups)==null||Q.delete(ce));t.outrogroups.size===0&&(t.outrogroups=null)}if(l!==null||c!==void 0){var E=[];if(c!==void 0)for(g of c)(g.f&Sr)===0&&E.push(g);for(;l!==null;)(l.f&Sr)===0&&l!==t.fallback&&E.push(l),l=eu(l.next);var M=E.length;if(M>0){var R=(r&j_)!==0&&s===0?n:null;if(o){for(y=0;y<M;y+=1)(me=(ie=E[y].nodes)==null?void 0:ie.a)==null||me.measure();for(y=0;y<M;y+=1)(ke=(le=E[y].nodes)==null?void 0:le.a)==null||ke.fix()}JM(t,E,R)}}o&&Ki(()=>{var ce,ve;if(f!==void 0)for(g of f)(ve=(ce=g.nodes)==null?void 0:ce.a)==null||ve.apply()})}function QM(t,e,n,r,i,o,s,a){var l=(s&j6)!==0?(s&K6)===0?cv(n,!1,!1):us(n):null,c=(s&q6)!==0?us(i):null;return{v:l,i:c,e:bi(()=>(o(e,l??n,c??i,a),()=>{t.delete(r)}))}}function pu(t,e,n){if(t.nodes)for(var r=t.nodes.start,i=t.nodes.end,o=e&&(e.f&bo)===0?e.nodes.start:n;r!==null;){var s=jd(r);if(o.before(r),r===i)return;r=s}}function ys(t,e,n){e===null?t.effect.first=n:e.next=n,n===null?t.effect.last=e:n.prev=e}function $M(t,e,n=!1,r=!1,i=!1,o=!1){var s=t,a="";if(n)var l=t;W(()=>{var c=Mt;if(a!==(a=e()??"")){if(n){c.nodes=null,l.innerHTML=a,a!==""&&Js(ti(l),l.lastChild);return}if(c.nodes!==null&&(wC(c.nodes.start,c.nodes.end),c.nodes=null),a!==""){var d=r?nM:i?rM:void 0,f=gC(r?"svg":i?"math":"template",d);f.innerHTML=a;var h=r||i?f:f.content;if(Js(ti(h),h.lastChild),r||i)for(;ti(h);)s.before(ti(h));else s.before(h)}}})}function Gd(t,e,...n){var r=new Kd(t);ll(()=>{const i=e()??null;r.ensure(i,i&&(o=>i(o,...n)))},ls)}function s1(t,e,n){var r=new Kd(t);ll(()=>{var i=e()??null;r.ensure(i,i&&(o=>n(o,i)))},ls)}const eD=()=>performance.now(),Xo={tick:t=>requestAnimationFrame(t),now:()=>eD(),tasks:new Set};function PC(){const t=Xo.now();Xo.tasks.forEach(e=>{e.c(t)||(Xo.tasks.delete(e),e.f())}),Xo.tasks.size!==0&&Xo.tick(PC)}function tD(t){let e;return Xo.tasks.size===0&&Xo.tick(PC),{promise:new Promise(n=>{Xo.tasks.add(e={c:t,f:n})}),abort(){Xo.tasks.delete(e)}}}function Af(t,e){Lc(()=>{t.dispatchEvent(new CustomEvent(e))})}function nD(t){if(t==="float")return"cssFloat";if(t==="offset")return"cssOffset";if(t.startsWith("--"))return t;const e=t.split("-");return e.length===1?e[0]:e[0]+e.slice(1).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function kw(t){const e={},n=t.split(";");for(const r of n){const[i,o]=r.split(":");if(!i||o===void 0)break;const s=nD(i.trim());e[s]=o.trim()}return e}const rD=t=>t;function Yi(t,e,n,r){var _;var i=(t&Q6)!==0,o=(t&$6)!==0,s=i&&o,a=(t&eM)!==0,l=s?"both":i?"in":"out",c,d=e.inert,f=e.style.overflow,h,p;function m(){return Lc(()=>c??(c=n()(e,(r==null?void 0:r())??{},{direction:l})))}var v={is_global:a,in(){var S;if(e.inert=d,!i){p==null||p.abort(),(S=p==null?void 0:p.reset)==null||S.call(p);return}o||h==null||h.abort(),h=mv(e,m(),p,1,()=>{Af(e,"introstart")},()=>{Af(e,"introend"),h==null||h.abort(),h=c=void 0,e.style.overflow=f})},out(S){if(!o){S==null||S(),c=void 0;return}e.inert=!0,p=mv(e,m(),h,0,()=>{Af(e,"outrostart")},()=>{Af(e,"outroend"),S==null||S()})},stop:()=>{h==null||h.abort(),p==null||p.abort()}},g=Mt;if(((_=g.nodes).t??(_.t=[])).push(v),i&&hv){var y=a;if(!y){for(var C=g.parent;C&&(C.f&ls)!==0;)for(;(C=C.parent)&&(C.f&Ci)===0;);y=!C||(C.f&sa)!==0}y&&Fc(()=>{Ct(()=>v.in())})}}function mv(t,e,n,r,i,o){var s=r===1;if(Cl(e)){var a,l=!1;return Ki(()=>{if(!l){var y=e({direction:s?"in":"out"});a=mv(t,y,n,r,i,o)}}),{abort:()=>{l=!0,a==null||a.abort()},deactivate:()=>a.deactivate(),reset:()=>a.reset(),t:()=>a.t()}}if(n==null||n.deactivate(),!(e!=null&&e.duration)&&!(e!=null&&e.delay))return i(),o(),{abort:kn,deactivate:kn,reset:kn,t:()=>r};const{delay:c=0,css:d,tick:f,easing:h=rD}=e;var p=[];if(s&&n===void 0&&(f&&f(0,1),d)){var m=kw(d(0,1));p.push(m,m)}var v=()=>1-r,g=t.animate(p,{duration:c,fill:"forwards"});return g.onfinish=()=>{g.cancel(),i();var y=(n==null?void 0:n.t())??1-r;n==null||n.abort();var C=r-y,_=e.duration*Math.abs(C),S=[];if(_>0){var A=!1;if(d)for(var O=Math.ceil(_/16.666666666666668),E=0;E<=O;E+=1){var M=y+C*h(E/O),R=kw(d(M,1-M));S.push(R),A||(A=R.overflow==="hidden")}A&&(t.style.overflow="hidden"),v=()=>{var D=g.currentTime;return y+C*h(D/_)},f&&tD(()=>{if(g.playState!=="running")return!1;var D=v();return f(D,1-D),!0})}g=t.animate(S,{duration:_,fill:"forwards"}),g.onfinish=()=>{v=()=>r,f==null||f(r,1-r),o()}},{abort:()=>{g&&(g.cancel(),g.effect=null,g.onfinish=kn)},deactivate:()=>{o=kn},reset:()=>{r===0&&(f==null||f(1,0))},t:()=>v()}}function qr(t,e,n){Fc(()=>{var r=Ct(()=>e(t,n==null?void 0:n())||{});if(n&&(r!=null&&r.update)){var i=!1,o={};qd(()=>{var s=n();zM(s),i&&G_(o,s)&&(o=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}function LC(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=LC(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function iD(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=LC(t))&&(r&&(r+=" "),r+=e);return r}function Hh(t){return typeof t=="object"?iD(t):t??""}const xw=[...`
3
+ \r\f \v\uFEFF`];function oD(t,e,n){var r=t==null?"":""+t;if(e&&(r=r?r+" "+e:e),n){for(var i of Object.keys(n))if(n[i])r=r?r+" "+i:i;else if(r.length)for(var o=i.length,s=0;(s=r.indexOf(i,s))>=0;){var a=s+o;(s===0||xw.includes(r[s-1]))&&(a===r.length||xw.includes(r[a]))?r=(s===0?"":r.substring(0,s))+r.substring(a+1):s=a}}return r===""?null:r}function sD(t,e){return t==null?null:String(t)}function bt(t,e,n,r,i,o){var s=t[ev];if(s!==n||s===void 0){var a=oD(n,r,o);a==null?t.removeAttribute("class"):e?t.className=a:t.setAttribute("class",a),t[ev]=n}else if(o&&i!==o)for(var l in o){var c=!!o[l];(i==null||c!==!!i[l])&&t.classList.toggle(l,c)}return o}function Pe(t,e,n,r){var i=t[tv];if(i!==e){var o=sD(e);o==null?t.removeAttribute("style"):t.style.cssText=o,t[tv]=e}return r}function a1(t,e,n=!1){if(t.multiple){if(e==null)return;if(!Gb(e))return oM();for(var r of t.options)r.selected=e.includes(Eu(r));return}for(r of t.options){var i=Eu(r);if(EM(i,e)){r.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function FC(t){var e=new MutationObserver(()=>{a1(t,t.__value)});e.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),n1(()=>{e.disconnect()})}function aD(t,e,n=e){var r=new WeakSet,i=!0;e1(t,"change",o=>{var s=o?"[selected]":":checked",a;if(t.multiple)a=[].map.call(t.querySelectorAll(s),Eu);else{var l=t.querySelector(s)??t.querySelector("option:not([disabled])");a=l&&Eu(l)}n(a),t.__value=a,pt!==null&&r.add(pt)}),Fc(()=>{var o=e();if(t===document.activeElement){var s=pt;if(r.has(s))return}if(a1(t,o,i),i&&o===void 0){var a=t.querySelector(":checked");a!==null&&(o=Eu(a),n(o))}t.__value=o,i=!1}),FC(t)}function Eu(t){return"__value"in t?t.__value:t.value}const lD=Symbol("is custom element"),cD=Symbol("is html"),uD=O6?"progress":"PROGRESS";function Vr(t,e){var n=l1(t);n.value===(n.value=e??void 0)||t.value===e&&(e!==0||t.nodeName!==uD)||(t.value=e??"")}function Fn(t,e){var n=l1(t);n.checked!==(n.checked=e??void 0)&&(t.checked=e)}function U(t,e,n,r){var i=l1(t);i[e]!==(i[e]=n)&&(e==="loading"&&(t[D6]=n),n==null?t.removeAttribute(e):typeof n!="string"&&dD(t).includes(e)?t[e]=n:t.setAttribute(e,n))}function l1(t){return t[ah]??(t[ah]={[lD]:t.nodeName.includes("-"),[cD]:t.namespaceURI===W_})}var _w=new Map;function dD(t){var e=t.getAttribute("is")||t.nodeName,n=_w.get(e);if(n)return n;_w.set(e,n=[]);for(var r,i=t,o=Element.prototype;o!==i;){r=z_(i);for(var s in r)r[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&n.push(s);i=Zb(i)}return n}function Hr(t,e,n=e){var r=new WeakSet;e1(t,"input",async i=>{var o=i?t.defaultValue:t.value;if(o=Ag(t)?Tg(o):o,n(o),pt!==null&&r.add(pt),await MC(),o!==(o=e())){var s=t.selectionStart,a=t.selectionEnd,l=t.value.length;if(t.value=o??"",a!==null){var c=t.value.length;s===a&&a===l&&c>l?(t.selectionStart=c,t.selectionEnd=c):(t.selectionStart=s,t.selectionEnd=Math.min(a,c))}}}),Ct(e)==null&&t.value&&(n(Ag(t)?Tg(t.value):t.value),pt!==null&&r.add(pt)),qd(()=>{var i=e();if(t===document.activeElement){var o=pt;if(r.has(o))return}Ag(t)&&i===Tg(t.value)||t.type==="date"&&!i&&!t.value||i!==t.value&&(t.value=i??"")})}function ph(t,e,n=e){e1(t,"change",r=>{var i=r?t.defaultChecked:t.checked;n(i)}),Ct(e)==null&&n(t.checked),qd(()=>{var r=e();t.checked=!!r})}function Ag(t){var e=t.type;return e==="number"||e==="range"}function Tg(t){return t===""?null:+t}var Ls,sc,Vd,pm,zC;const mm=class mm{constructor(e){yt(this,pm);yt(this,Ls,new WeakMap);yt(this,sc);yt(this,Vd);wt(this,Vd,e)}observe(e,n){var r=oe(this,Ls).get(e)||new Set;return r.add(n),oe(this,Ls).set(e,r),Ht(this,pm,zC).call(this).observe(e,oe(this,Vd)),()=>{var i=oe(this,Ls).get(e);i.delete(n),i.size===0&&(oe(this,Ls).delete(e),oe(this,sc).unobserve(e))}}};Ls=new WeakMap,sc=new WeakMap,Vd=new WeakMap,pm=new WeakSet,zC=function(){return oe(this,sc)??wt(this,sc,new ResizeObserver(e=>{for(var n of e){mm.entries.set(n.target,n);for(var r of oe(this,Ls).get(n.target)||[])r(n)}}))},Wn(mm,"entries",new WeakMap);let gv=mm;var fD=new gv({box:"border-box"});function hD(t,e,n){var r=fD.observe(t,()=>n(t[e]));Fc(()=>(Ct(()=>n(t[e])),r))}function Mg(t,e){return t===e||(t==null?void 0:t[xo])===e}function Dt(t={},e,n,r){var i=Cn.r,o=Mt;return Fc(()=>{var s,a;return qd(()=>{s=a,a=(r==null?void 0:r())||[],Ct(()=>{Mg(n(...a),t)||(e(t,...a),s&&Mg(n(...s),t)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&$0;)l=l.parent;const c=()=>{a&&Mg(n(...a),t)&&e(null,...a)},d=l.teardown;l.teardown=()=>{c(),d==null||d()}}}),t}const pD={get(t,e){if(!t.exclude.includes(e))return t.props[e]},set(t,e){return!1},getOwnPropertyDescriptor(t,e){if(!t.exclude.includes(e)&&e in t.props)return{enumerable:!0,configurable:!0,value:t.props[e]}},has(t,e){return t.exclude.includes(e)?!1:e in t.props},ownKeys(t){return Reflect.ownKeys(t.props).filter(e=>!t.exclude.includes(e))}};function mD(t,e,n){return new Proxy({props:t,exclude:e},pD)}const gD={get(t,e){let n=t.props.length;for(;n--;){let r=t.props[n];if(Cl(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r)return r[e]}},set(t,e,n){let r=t.props.length;for(;r--;){let i=t.props[r];Cl(i)&&(i=i());const o=js(i,e);if(o&&o.set)return o.set(n),!0}return!1},getOwnPropertyDescriptor(t,e){let n=t.props.length;for(;n--;){let r=t.props[n];if(Cl(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r){const i=js(r,e);return i&&!i.configurable&&(i.configurable=!0),i}}},has(t,e){if(e===xo||e===V_)return!1;for(let n of t.props)if(Cl(n)&&(n=n()),n!=null&&e in n)return!0;return!1},ownKeys(t){const e=[];for(let n of t.props)if(Cl(n)&&(n=n()),!!n){for(const r in n)e.includes(r)||e.push(r);for(const r of Object.getOwnPropertySymbols(n))e.includes(r)||e.push(r)}return e}};function mu(...t){return new Proxy({props:t},gD)}function Ze(t,e,n,r){var S;var i=!Pc||(n&Z6)!==0,o=(n&J6)!==0,s=(n&X6)!==0,a=r,l=!0,c=void 0,d=()=>s&&i?(c??(c=Ku(r)),u(c)):(l&&(l=!1,a=s?Ct(r):r),a);let f;if(o){var h=xo in t||V_ in t;f=((S=js(t,e))==null?void 0:S.set)??(h&&e in t?A=>t[e]=A:void 0)}var p,m=!1;o?[p,m]=dM(()=>t[e]):p=t[e],p===void 0&&r!==void 0&&(p=d(),f&&(i&&z6(),f(p)));var v;if(i?v=()=>{var A=t[e];return A===void 0?d():(l=!0,A)}:v=()=>{var A=t[e];return A!==void 0&&(a=void 0),A===void 0?a:A},i&&(n&Y6)===0)return v;if(f){var g=t.$$legacy;return(function(A,O){return arguments.length>0?((!i||!O||g||m)&&f(O?v():A),A):v()})}var y=!1,C=((n&G6)!==0?Ku:Qb)(()=>(y=!1,v()));o&&u(C);var _=Mt;return(function(A,O){if(arguments.length>0){const E=O?u(C):i&&o?tt(A):A;return b(C,E),y=!0,a!==void 0&&(a=E),A}return ds&&y||(_.f&Ei)!==0?C.v:u(C)})}function zc(t){Cn===null&&U_(),Pc&&Cn.l!==null?vD(Cn).m.push(t):pe(()=>{const e=Ct(t);if(typeof e=="function")return e})}function Dn(t){Cn===null&&U_(),zc(()=>()=>Ct(t))}function vD(t){var e=t.l;return e.u??(e.u={a:[],b:[],m:[]})}const bD="5";var L_;typeof window<"u"&&((L_=window.__svelte??(window.__svelte={})).v??(L_.v=new Set)).add(bD);lM();const yD="modulepreload",wD=function(t){return"/"+t},Cw={},Zt=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let s=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=s(n.map(c=>{if(c=wD(c),c in Cw)return;Cw[c]=!0;const d=c.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":yD,d||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),d)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return e().catch(o)})},Sw=3478,Gi=3479,BC="https://github.com/bloknayrb/tandem",HC=`${BC}/issues/new`,kD=!1,Zd=new Set([".md",".txt",".html",".htm",".docx"]),xD=3e3,_D=3e3,CD=3e4,VC={yellow:"rgba(255, 235, 59, 0.3)",green:"rgba(76, 175, 80, 0.3)",blue:"rgba(33, 150, 243, 0.3)",pink:"rgba(236, 72, 153, 0.3)"},Yu={yellow:"var(--tandem-highlight-yellow)",green:"var(--tandem-highlight-green)",blue:"var(--tandem-highlight-blue)",pink:"var(--tandem-highlight-pink)"};function UC(t){return t&&t in VC?t:"yellow"}const Ew="tandem",Tf="tandem:mode",jC="tandem:settings",SD="tandem-panel-width",ED="tandem-left-panel-width",qC={left:ED,right:SD},WC=1e3,fc=500,hc=3e3,AD="__tandem_ctrl__",Ri="annotations",KC="awareness",vv="userAwareness",TD="mode",MD="selectionDwellMs",Aw="chat",Vh="documentMeta",GC="annotationReplies",Tw="savedAtVersion",Mw="authorship",Dw="selection",Ow="activity",bv="claude",tu="openDocuments",nu="activeDocumentId",ru="activeDocumentEpoch",Dg="storeReadOnly",Iw="externalConflict",ZC="tandem:showAuthorship",YC="tandem:decorationVisibility",c1="tandem:recentFiles",DD=20,u1="tandem:userName",JC="You",yv="tandem:user-name-changed",wm=40,Rw={error:8e3,warning:6e3,info:4e3},OD=5,ID="tandem:activityHistory",XC=50,RD=5*6e4,QC="tandem:tutorialCompleted",$C="tutorial-",eS="tandem:coworkOnboardingSkipped",ND=3e4,Fre=2e3,Nw="tandem:zoomLevel",Pw=.5,Lw=2,iu=1,PD="upload://",tS="upload://scratchpad/";function El(t){return t.startsWith(PD)}function km(t){return t.startsWith(tS)}function nS(t){if(!km(t))return null;const n=t.slice(tS.length).split("/")[0];return n.length>0?n:null}const mh=t=>t,zn=t=>t;var Kt;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const o={};for(const s of i)o[s]=s;return o},t.getValidEnumValues=i=>{const o=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(const a of o)s[a]=i[a];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const o=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},t.find=(i,o)=>{for(const s of i)if(o(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Kt||(Kt={}));var Fw;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Fw||(Fw={}));const st=Kt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),xs=t=>{switch(typeof t){case"undefined":return st.undefined;case"string":return st.string;case"number":return Number.isNaN(t)?st.nan:st.number;case"boolean":return st.boolean;case"function":return st.function;case"bigint":return st.bigint;case"symbol":return st.symbol;case"object":return Array.isArray(t)?st.array:t===null?st.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?st.promise:typeof Map<"u"&&t instanceof Map?st.map:typeof Set<"u"&&t instanceof Set?st.set:typeof Date<"u"&&t instanceof Date?st.date:st.object;default:return st.unknown}},Ue=Kt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class fs extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(o){return o.message},r={_errors:[]},i=o=>{for(const s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let a=r,l=0;for(;l<s.path.length;){const c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(s))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(e){if(!(e instanceof fs))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Kt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const o=i.path[0];n[o]=n[o]||[],n[o].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}fs.create=t=>new fs(t);const wv=(t,e)=>{let n;switch(t.code){case Ue.invalid_type:t.received===st.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case Ue.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Kt.jsonStringifyReplacer)}`;break;case Ue.unrecognized_keys:n=`Unrecognized key(s) in object: ${Kt.joinValues(t.keys,", ")}`;break;case Ue.invalid_union:n="Invalid input";break;case Ue.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Kt.joinValues(t.options)}`;break;case Ue.invalid_enum_value:n=`Invalid enum value. Expected ${Kt.joinValues(t.options)}, received '${t.received}'`;break;case Ue.invalid_arguments:n="Invalid function arguments";break;case Ue.invalid_return_type:n="Invalid function return type";break;case Ue.invalid_date:n="Invalid date";break;case Ue.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Kt.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case Ue.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case Ue.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case Ue.custom:n="Invalid input";break;case Ue.invalid_intersection_types:n="Intersection results could not be merged";break;case Ue.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case Ue.not_finite:n="Number must be finite";break;default:n=e.defaultError,Kt.assertNever(t)}return{message:n}};let LD=wv;function FD(){return LD}const zD=t=>{const{data:e,path:n,errorMaps:r,issueData:i}=t,o=[...n,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(s,{data:e,defaultError:a}).message;return{...i,path:o,message:a}};function Qe(t,e){const n=FD(),r=zD({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===wv?void 0:wv].filter(i=>!!i)});t.common.issues.push(r)}class ii{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const i of n){if(i.status==="aborted")return kt;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const i of n){const o=await i.key,s=await i.value;r.push({key:o,value:s})}return ii.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const i of n){const{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return kt;o.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(r[o.value]=s.value)}return{status:e.value,value:r}}}const kt=Object.freeze({status:"aborted"}),gu=t=>({status:"dirty",value:t}),Ni=t=>({status:"valid",value:t}),zw=t=>t.status==="aborted",Bw=t=>t.status==="dirty",pc=t=>t.status==="valid",Uh=t=>typeof Promise<"u"&&t instanceof Promise;var at;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(at||(at={}));class Xs{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Hw=(t,e)=>{if(pc(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new fs(t.common.issues);return this._error=n,this._error}}};function Rt(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:i}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,a)=>{const{message:l}=t;return s.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class jt{get description(){return this._def.description}_getType(e){return xs(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:xs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ii,ctx:{common:e.parent.common,data:e.data,parsedType:xs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Uh(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xs(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Hw(r,i)}"~validate"(e){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xs(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:n});return pc(o)?{value:o.value}:{issues:n.common.issues}}catch(o){(i=(r=o==null?void 0:o.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(o=>pc(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xs(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(Uh(i)?i:Promise.resolve(i));return Hw(r,o)}refine(e,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,o)=>{const s=e(i),a=()=>o.addIssue({code:Ue.custom,...r(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new gc({schema:this,typeName:xt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ws.create(this,this._def)}nullable(){return vc.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _o.create(this)}promise(){return Kh.create(this,this._def)}or(e){return qh.create([this,e],this._def)}and(e){return Wh.create(this,e,this._def)}transform(e){return new gc({...Rt(this._def),schema:this,typeName:xt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new xv({...Rt(this._def),innerType:this,defaultValue:n,typeName:xt.ZodDefault})}brand(){return new aO({typeName:xt.ZodBranded,type:this,...Rt(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new _v({...Rt(this._def),innerType:this,catchValue:n,typeName:xt.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return d1.create(this,e)}readonly(){return Cv.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const BD=/^c[^\s-]{8,}$/i,HD=/^[0-9a-z]+$/,VD=/^[0-9A-HJKMNP-TV-Z]{26}$/i,UD=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,jD=/^[a-z0-9_-]{21}$/i,qD=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,WD=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,KD=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,GD="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Og;const ZD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,YD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,JD=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,XD=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,QD=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$D=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,rS="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",eO=new RegExp(`^${rS}$`);function iS(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function tO(t){return new RegExp(`^${iS(t)}$`)}function nO(t){let e=`${rS}T${iS(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function rO(t,e){return!!((e==="v4"||!e)&&ZD.test(t)||(e==="v6"||!e)&&JD.test(t))}function iO(t,e){if(!qD.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function oO(t,e){return!!((e==="v4"||!e)&&YD.test(t)||(e==="v6"||!e)&&XD.test(t))}class _a extends jt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==st.string){const o=this._getOrReturnCtx(e);return Qe(o,{code:Ue.invalid_type,expected:st.string,received:o.parsedType}),kt}const r=new ii;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const s=e.data.length>o.value,a=e.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(e,i),s?Qe(i,{code:Ue.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&Qe(i,{code:Ue.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")KD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"email",code:Ue.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")Og||(Og=new RegExp(GD,"u")),Og.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"emoji",code:Ue.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")UD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"uuid",code:Ue.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")jD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"nanoid",code:Ue.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")BD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"cuid",code:Ue.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")HD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"cuid2",code:Ue.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")VD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"ulid",code:Ue.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Qe(i,{validation:"url",code:Ue.invalid_string,message:o.message}),r.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"regex",code:Ue.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?nO(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?eO.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?tO(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?WD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"duration",code:Ue.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?rO(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"ip",code:Ue.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?iO(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"jwt",code:Ue.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?oO(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"cidr",code:Ue.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?QD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"base64",code:Ue.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?$D.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"base64url",code:Ue.invalid_string,message:o.message}),r.dirty()):Kt.assertNever(o);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:Ue.invalid_string,...at.errToObj(r)})}_addCheck(e){return new _a({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...at.errToObj(e)})}url(e){return this._addCheck({kind:"url",...at.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...at.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...at.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...at.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...at.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...at.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...at.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...at.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...at.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...at.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...at.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...at.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...at.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...at.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...at.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...at.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...at.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...at.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...at.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...at.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...at.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...at.errToObj(n)})}nonempty(e){return this.min(1,at.errToObj(e))}trim(){return new _a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new _a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new _a({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}_a.create=t=>new _a({checks:[],typeName:xt.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Rt(t)});function sO(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,o=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return o%s/10**i}class Ju extends jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==st.number){const o=this._getOrReturnCtx(e);return Qe(o,{code:Ue.invalid_type,expected:st.number,received:o.parsedType}),kt}let r;const i=new ii;for(const o of this._def.checks)o.kind==="int"?Kt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),Qe(r,{code:Ue.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),Qe(r,{code:Ue.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),Qe(r,{code:Ue.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?sO(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),Qe(r,{code:Ue.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),Qe(r,{code:Ue.not_finite,message:o.message}),i.dirty()):Kt.assertNever(o);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,at.toString(n))}gt(e,n){return this.setLimit("min",e,!1,at.toString(n))}lte(e,n){return this.setLimit("max",e,!0,at.toString(n))}lt(e,n){return this.setLimit("max",e,!1,at.toString(n))}setLimit(e,n,r,i){return new Ju({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:at.toString(i)}]})}_addCheck(e){return new Ju({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:at.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:at.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:at.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:at.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:at.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:at.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:at.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:at.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:at.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Kt.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Ju.create=t=>new Ju({checks:[],typeName:xt.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Rt(t)});class Xu extends jt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==st.bigint)return this._getInvalidInput(e);let r;const i=new ii;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),Qe(r,{code:Ue.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),Qe(r,{code:Ue.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),Qe(r,{code:Ue.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Kt.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return Qe(n,{code:Ue.invalid_type,expected:st.bigint,received:n.parsedType}),kt}gte(e,n){return this.setLimit("min",e,!0,at.toString(n))}gt(e,n){return this.setLimit("min",e,!1,at.toString(n))}lte(e,n){return this.setLimit("max",e,!0,at.toString(n))}lt(e,n){return this.setLimit("max",e,!1,at.toString(n))}setLimit(e,n,r,i){return new Xu({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:at.toString(i)}]})}_addCheck(e){return new Xu({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:at.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:at.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:at.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:at.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:at.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Xu.create=t=>new Xu({checks:[],typeName:xt.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Rt(t)});class Vw extends jt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==st.boolean){const r=this._getOrReturnCtx(e);return Qe(r,{code:Ue.invalid_type,expected:st.boolean,received:r.parsedType}),kt}return Ni(e.data)}}Vw.create=t=>new Vw({typeName:xt.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Rt(t)});class jh extends jt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==st.date){const o=this._getOrReturnCtx(e);return Qe(o,{code:Ue.invalid_type,expected:st.date,received:o.parsedType}),kt}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return Qe(o,{code:Ue.invalid_date}),kt}const r=new ii;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),Qe(i,{code:Ue.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):Kt.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new jh({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:at.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:at.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}jh.create=t=>new jh({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:xt.ZodDate,...Rt(t)});class Uw extends jt{_parse(e){if(this._getType(e)!==st.symbol){const r=this._getOrReturnCtx(e);return Qe(r,{code:Ue.invalid_type,expected:st.symbol,received:r.parsedType}),kt}return Ni(e.data)}}Uw.create=t=>new Uw({typeName:xt.ZodSymbol,...Rt(t)});class jw extends jt{_parse(e){if(this._getType(e)!==st.undefined){const r=this._getOrReturnCtx(e);return Qe(r,{code:Ue.invalid_type,expected:st.undefined,received:r.parsedType}),kt}return Ni(e.data)}}jw.create=t=>new jw({typeName:xt.ZodUndefined,...Rt(t)});class qw extends jt{_parse(e){if(this._getType(e)!==st.null){const r=this._getOrReturnCtx(e);return Qe(r,{code:Ue.invalid_type,expected:st.null,received:r.parsedType}),kt}return Ni(e.data)}}qw.create=t=>new qw({typeName:xt.ZodNull,...Rt(t)});class Ww extends jt{constructor(){super(...arguments),this._any=!0}_parse(e){return Ni(e.data)}}Ww.create=t=>new Ww({typeName:xt.ZodAny,...Rt(t)});class Kw extends jt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ni(e.data)}}Kw.create=t=>new Kw({typeName:xt.ZodUnknown,...Rt(t)});class Qs extends jt{_parse(e){const n=this._getOrReturnCtx(e);return Qe(n,{code:Ue.invalid_type,expected:st.never,received:n.parsedType}),kt}}Qs.create=t=>new Qs({typeName:xt.ZodNever,...Rt(t)});class Gw extends jt{_parse(e){if(this._getType(e)!==st.undefined){const r=this._getOrReturnCtx(e);return Qe(r,{code:Ue.invalid_type,expected:st.void,received:r.parsedType}),kt}return Ni(e.data)}}Gw.create=t=>new Gw({typeName:xt.ZodVoid,...Rt(t)});class _o extends jt{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==st.array)return Qe(n,{code:Ue.invalid_type,expected:st.array,received:n.parsedType}),kt;if(i.exactLength!==null){const s=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(s||a)&&(Qe(n,{code:s?Ue.too_big:Ue.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(Qe(n,{code:Ue.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(Qe(n,{code:Ue.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((s,a)=>i.type._parseAsync(new Xs(n,s,n.path,a)))).then(s=>ii.mergeArray(r,s));const o=[...n.data].map((s,a)=>i.type._parseSync(new Xs(n,s,n.path,a)));return ii.mergeArray(r,o)}get element(){return this._def.type}min(e,n){return new _o({...this._def,minLength:{value:e,message:at.toString(n)}})}max(e,n){return new _o({...this._def,maxLength:{value:e,message:at.toString(n)}})}length(e,n){return new _o({...this._def,exactLength:{value:e,message:at.toString(n)}})}nonempty(e){return this.min(1,e)}}_o.create=(t,e)=>new _o({type:t,minLength:null,maxLength:null,exactLength:null,typeName:xt.ZodArray,...Rt(e)});function Al(t){if(t instanceof Ln){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Ws.create(Al(r))}return new Ln({...t._def,shape:()=>e})}else return t instanceof _o?new _o({...t._def,type:Al(t.element)}):t instanceof Ws?Ws.create(Al(t.unwrap())):t instanceof vc?vc.create(Al(t.unwrap())):t instanceof Ka?Ka.create(t.items.map(e=>Al(e))):t}class Ln extends jt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=Kt.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==st.object){const c=this._getOrReturnCtx(e);return Qe(c,{code:Ue.invalid_type,expected:st.object,received:c.parsedType}),kt}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Qs&&this._def.unknownKeys==="strip"))for(const c in i.data)s.includes(c)||a.push(c);const l=[];for(const c of s){const d=o[c],f=i.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new Xs(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Qs){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of a)l.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")a.length>0&&(Qe(i,{code:Ue.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of a){const f=i.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new Xs(i,f,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const f=await d.key,h=await d.value;c.push({key:f,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>ii.mergeObjectSync(r,c)):ii.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return at.errToObj,new Ln({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var o,s;const i=((s=(o=this._def).errorMap)==null?void 0:s.call(o,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:at.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new Ln({...this._def,unknownKeys:"strip"})}passthrough(){return new Ln({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ln({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ln({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:xt.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Ln({...this._def,catchall:e})}pick(e){const n={};for(const r of Kt.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Ln({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Kt.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new Ln({...this._def,shape:()=>n})}deepPartial(){return Al(this)}partial(e){const n={};for(const r of Kt.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new Ln({...this._def,shape:()=>n})}required(e){const n={};for(const r of Kt.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof Ws;)o=o._def.innerType;n[r]=o}return new Ln({...this._def,shape:()=>n})}keyof(){return oS(Kt.objectKeys(this.shape))}}Ln.create=(t,e)=>new Ln({shape:()=>t,unknownKeys:"strip",catchall:Qs.create(),typeName:xt.ZodObject,...Rt(e)});Ln.strictCreate=(t,e)=>new Ln({shape:()=>t,unknownKeys:"strict",catchall:Qs.create(),typeName:xt.ZodObject,...Rt(e)});Ln.lazycreate=(t,e)=>new Ln({shape:t,unknownKeys:"strip",catchall:Qs.create(),typeName:xt.ZodObject,...Rt(e)});class qh extends jt{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function i(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const s=o.map(a=>new fs(a.ctx.common.issues));return Qe(n,{code:Ue.invalid_union,unionErrors:s}),kt}if(n.common.async)return Promise.all(r.map(async o=>{const s={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(i);{let o;const s=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(l=>new fs(l));return Qe(n,{code:Ue.invalid_union,unionErrors:a}),kt}}get options(){return this._def.options}}qh.create=(t,e)=>new qh({options:t,typeName:xt.ZodUnion,...Rt(e)});function kv(t,e){const n=xs(t),r=xs(e);if(t===e)return{valid:!0,data:t};if(n===st.object&&r===st.object){const i=Kt.objectKeys(e),o=Kt.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...e};for(const a of o){const l=kv(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===st.array&&r===st.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let o=0;o<t.length;o++){const s=t[o],a=e[o],l=kv(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===st.date&&r===st.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Wh extends jt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(zw(o)||zw(s))return kt;const a=kv(o.value,s.value);return a.valid?((Bw(o)||Bw(s))&&n.dirty(),{status:n.value,value:a.data}):(Qe(r,{code:Ue.invalid_intersection_types}),kt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Wh.create=(t,e,n)=>new Wh({left:t,right:e,typeName:xt.ZodIntersection,...Rt(n)});class Ka extends jt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==st.array)return Qe(r,{code:Ue.invalid_type,expected:st.array,received:r.parsedType}),kt;if(r.data.length<this._def.items.length)return Qe(r,{code:Ue.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),kt;!this._def.rest&&r.data.length>this._def.items.length&&(Qe(r,{code:Ue.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((s,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new Xs(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>ii.mergeArray(n,s)):ii.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new Ka({...this._def,rest:e})}}Ka.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ka({items:t,typeName:xt.ZodTuple,rest:null,...Rt(e)})};class Zw extends jt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==st.map)return Qe(r,{code:Ue.invalid_type,expected:st.map,received:r.parsedType}),kt;const i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new Xs(r,a,r.path,[c,"key"])),value:o._parse(new Xs(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of s){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return kt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of s){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return kt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}}}}Zw.create=(t,e,n)=>new Zw({valueType:e,keyType:t,typeName:xt.ZodMap,...Rt(n)});class Qu extends jt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==st.set)return Qe(r,{code:Ue.invalid_type,expected:st.set,received:r.parsedType}),kt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Qe(r,{code:Ue.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(Qe(r,{code:Ue.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const o=this._def.valueType;function s(l){const c=new Set;for(const d of l){if(d.status==="aborted")return kt;d.status==="dirty"&&n.dirty(),c.add(d.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>o._parse(new Xs(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,n){return new Qu({...this._def,minSize:{value:e,message:at.toString(n)}})}max(e,n){return new Qu({...this._def,maxSize:{value:e,message:at.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Qu.create=(t,e)=>new Qu({valueType:t,minSize:null,maxSize:null,typeName:xt.ZodSet,...Rt(e)});class Yw extends jt{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Yw.create=(t,e)=>new Yw({getter:t,typeName:xt.ZodLazy,...Rt(e)});class Jw extends jt{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return Qe(n,{received:n.data,code:Ue.invalid_literal,expected:this._def.value}),kt}return{status:"valid",value:e.data}}get value(){return this._def.value}}Jw.create=(t,e)=>new Jw({value:t,typeName:xt.ZodLiteral,...Rt(e)});function oS(t,e){return new mc({values:t,typeName:xt.ZodEnum,...Rt(e)})}class mc extends jt{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return Qe(n,{expected:Kt.joinValues(r),received:n.parsedType,code:Ue.invalid_type}),kt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return Qe(n,{received:n.data,code:Ue.invalid_enum_value,options:r}),kt}return Ni(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return mc.create(e,{...this._def,...n})}exclude(e,n=this._def){return mc.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}mc.create=oS;class Xw extends jt{_parse(e){const n=Kt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==st.string&&r.parsedType!==st.number){const i=Kt.objectValues(n);return Qe(r,{expected:Kt.joinValues(i),received:r.parsedType,code:Ue.invalid_type}),kt}if(this._cache||(this._cache=new Set(Kt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=Kt.objectValues(n);return Qe(r,{received:r.data,code:Ue.invalid_enum_value,options:i}),kt}return Ni(e.data)}get enum(){return this._def.values}}Xw.create=(t,e)=>new Xw({values:t,typeName:xt.ZodNativeEnum,...Rt(e)});class Kh extends jt{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==st.promise&&n.common.async===!1)return Qe(n,{code:Ue.invalid_type,expected:st.promise,received:n.parsedType}),kt;const r=n.parsedType===st.promise?n.data:Promise.resolve(n.data);return Ni(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Kh.create=(t,e)=>new Kh({type:t,typeName:xt.ZodPromise,...Rt(e)});class gc extends jt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===xt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:s=>{Qe(r,s),s.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const s=i.transform(r.data,o);if(r.common.async)return Promise.resolve(s).then(async a=>{if(n.value==="aborted")return kt;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?kt:l.status==="dirty"||n.value==="dirty"?gu(l.value):l});{if(n.value==="aborted")return kt;const a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?kt:a.status==="dirty"||n.value==="dirty"?gu(a.value):a}}if(i.type==="refinement"){const s=a=>{const l=i.refinement(a,o);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?kt:(a.status==="dirty"&&n.dirty(),s(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?kt:(a.status==="dirty"&&n.dirty(),s(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!pc(s))return kt;const a=i.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>pc(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:n.value,value:a})):kt);Kt.assertNever(i)}}gc.create=(t,e,n)=>new gc({schema:t,typeName:xt.ZodEffects,effect:e,...Rt(n)});gc.createWithPreprocess=(t,e,n)=>new gc({schema:e,effect:{type:"preprocess",transform:t},typeName:xt.ZodEffects,...Rt(n)});class Ws extends jt{_parse(e){return this._getType(e)===st.undefined?Ni(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ws.create=(t,e)=>new Ws({innerType:t,typeName:xt.ZodOptional,...Rt(e)});class vc extends jt{_parse(e){return this._getType(e)===st.null?Ni(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}vc.create=(t,e)=>new vc({innerType:t,typeName:xt.ZodNullable,...Rt(e)});class xv extends jt{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===st.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}xv.create=(t,e)=>new xv({innerType:t,typeName:xt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Rt(e)});class _v extends jt{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Uh(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new fs(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new fs(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}_v.create=(t,e)=>new _v({innerType:t,typeName:xt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Rt(e)});class Qw extends jt{_parse(e){if(this._getType(e)!==st.nan){const r=this._getOrReturnCtx(e);return Qe(r,{code:Ue.invalid_type,expected:st.nan,received:r.parsedType}),kt}return{status:"valid",value:e.data}}}Qw.create=t=>new Qw({typeName:xt.ZodNaN,...Rt(t)});class aO extends jt{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class d1 extends jt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?kt:o.status==="dirty"?(n.dirty(),gu(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?kt:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new d1({in:e,out:n,typeName:xt.ZodPipeline})}}class Cv extends jt{_parse(e){const n=this._def.innerType._parse(e),r=i=>(pc(i)&&(i.value=Object.freeze(i.value)),i);return Uh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Cv.create=(t,e)=>new Cv({innerType:t,typeName:xt.ZodReadonly,...Rt(e)});var xt;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(xt||(xt={}));Qs.create;_o.create;qh.create;Wh.create;Ka.create;const Pi=mc.create;Kh.create;Ws.create;vc.create;Pi(["highlight","note","comment"]);Pi(["pending","accepted","dismissed"]);Pi(["yellow","green","blue","pink"]);Pi(["info","warning","error","success"]);const lO=Pi(["solo","tandem"]);Pi(["user","claude","import"]);Pi(["user","claude","import"]);Pi(["accept","dismiss"]);Pi(["markdown","json"]);Pi(["md","txt","html","docx"]);Pi(["RANGE_GONE","RANGE_MOVED","FILE_LOCKED","FILE_NOT_FOUND","NO_DOCUMENT","INVALID_RANGE","INVALID_ARGUMENT","NOT_FOUND","ANNOTATION_RESOLVED","FORMAT_ERROR","PERMISSION_DENIED"]);Pi(["CHANNEL_CONNECT_FAILED","MONITOR_CONNECT_FAILED"]);function cO(t){return t.author!=="user"}function Gh(t){return t.status==="pending"&&cO(t)}function xm(t){return`${t}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Sv(){return xm("ann")}function uO(){return xm("msg")}function gl(){return xm("ntf")}function dO(t){return xm(t)}const fO="/api/notify-stream",Ev="/api/info",hO="/api/diagnostics",pO="/health",mO="/api/open",gO="/api/close",f1="/api/save",vO="/api/rename",sS="/api/upload",bO="/api/scratchpad",yO="/api/convert",wO="/api/apply-changes",kO="/api/document/raw",xO="/api/document/reload",_O="/api/backups",CO="/api/backups/restore",SO="/api/docx-conflict/resolve",EO="/api/annotation-reply",AO="/api/remove-annotation",TO="/api/store/reclaim-lock",MO="/api/chat",DO="/api/sessions",OO="/api/sessions/delete",IO="/api/sessions/clear",aS="/api/launcher/status",RO="/api/launcher/nonce",NO="/api/launcher/relaunch",PO="/api/launcher/start-fresh",LO="/api/launcher/working-directory",Ga=["save","save-as","settings","settings-modal","toggle-palette","new-scratchpad","close-tab","open-file","toggle-mode","reopen-closed-tab","comment-on-selection","toggle-authorship","toggle-left-panel","toggle-right-panel","annotation-next","annotation-prev","select-block","new-tab-menu"],FO=new Set(Ga);function lS(t){return FO.has(t)}const Av={save:"Save document","save-as":"Save As…",settings:"Open settings","settings-modal":"Open settings (new)","toggle-palette":"Toggle command palette","new-scratchpad":"New Scratchpad","close-tab":"Close active tab","open-file":"Open file…","toggle-mode":"Toggle Solo / Tandem mode","reopen-closed-tab":"Reopen closed tab","comment-on-selection":"Comment on selection","toggle-authorship":"Toggle authorship colors","toggle-left-panel":"Toggle left panel","toggle-right-panel":"Toggle right panel","annotation-next":"Next annotation","annotation-prev":"Previous annotation","select-block":"Select containing block","new-tab-menu":"New tab menu"},zO={save:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyS"},"save-as":{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyS"},settings:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Comma"},"settings-modal":{ctrlOrMeta:!0,alt:!1,shift:!0,code:"Comma"},"toggle-palette":{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyP"},"new-scratchpad":{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyN"},"close-tab":{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyW"},"open-file":{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyO"},"toggle-mode":{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyM"},"reopen-closed-tab":{ctrlOrMeta:!0,alt:!0,shift:!1,code:"KeyT"},"comment-on-selection":{ctrlOrMeta:!0,alt:!0,shift:!1,code:"KeyM"},"toggle-authorship":{ctrlOrMeta:!0,alt:!0,shift:!1,code:"KeyA"},"toggle-left-panel":{ctrlOrMeta:!1,alt:!0,shift:!0,code:"ArrowLeft"},"toggle-right-panel":{ctrlOrMeta:!1,alt:!0,shift:!0,code:"ArrowRight"},"annotation-next":{ctrlOrMeta:!1,alt:!0,shift:!1,code:"BracketRight"},"annotation-prev":{ctrlOrMeta:!1,alt:!0,shift:!1,code:"BracketLeft"},"select-block":{ctrlOrMeta:!1,alt:!0,shift:!1,code:"KeyL"},"new-tab-menu":{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyT"}},cS=[{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Tab"},label:"Next document tab"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"Tab"},label:"Previous document tab"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Digit0"},label:"Reset zoom"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Equal"},label:"Zoom in"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"Equal"},label:"Zoom in"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"Minus"},label:"Zoom out"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"Minus"},label:"Zoom out"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyB"},label:"Bold"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyI"},label:"Italic"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyE"},label:"Inline code"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyX"},label:"Strikethrough"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyZ"},label:"Undo"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyY"},label:"Redo"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyZ"},label:"Redo"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:"KeyK"},label:"Add link"},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:"KeyB"},label:"Blockquote"}],uS={save:"save","save-as":"save-as",settings:"settings","settings-modal":"settings-modal","new-scratchpad":"new-scratchpad","close-tab":"close-tab","open-file":"open-file","toggle-mode":"toggle-mode","reopen-closed-tab":"reopen-closed-tab","toggle-authorship":"toggle-authorship","toggle-left-panel":"toggle-left-panel","toggle-right-panel":"toggle-right-panel","annotation-next":"annotation-next","annotation-previous":"annotation-prev","select-block":"select-block"},BO=/^(Control|Shift|Alt|Meta|OS)/,HO=new Set(["Tab","Escape","Enter","NumpadEnter","NumLock","CapsLock","ContextMenu","Insert"]);function dS(t){return BO.test(t.code)||t.code.startsWith("Numpad")||HO.has(t.code)?!1:t.ctrlOrMeta||t.alt}function VO(t){if(!t.code||t.key==="Dead")return null;const e={ctrlOrMeta:t.ctrlKey||t.metaKey,alt:t.altKey,shift:t.shiftKey,code:t.code};return dS(e)?e:null}function UO(t,e){return t.ctrlOrMeta===(e.ctrlKey||e.metaKey)&&t.alt===e.altKey&&t.shift===e.shiftKey&&t.code===e.code}function Zh(t,e){return t.ctrlOrMeta===e.ctrlOrMeta&&t.alt===e.alt&&t.shift===e.shift&&t.code===e.code}function jO(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.ctrlOrMeta=="boolean"&&typeof e.alt=="boolean"&&typeof e.shift=="boolean"&&typeof e.code=="string"&&e.code.length>0&&e.code.length<=32}function fS(){var t;try{if(typeof navigator>"u")return!1;const e=((t=navigator.userAgentData)==null?void 0:t.platform)??navigator.platform;return/Mac|iPhone|iPad|iPod/i.test(e??"")}catch{return!1}}function qO(t){return t.startsWith("Key")?t.slice(3):t.startsWith("Digit")?t.slice(5):{Comma:",",Period:".",Slash:"/",Backslash:"\\",Semicolon:";",Quote:"'",BracketLeft:"[",BracketRight:"]",Backquote:"`",Minus:"-",Equal:"=",Space:"Space",Tab:"Tab",Enter:"Enter",ArrowLeft:"←",ArrowRight:"→",ArrowUp:"↑",ArrowDown:"↓"}[t]??t}function Tv(t){const e=fS(),n=[];return t.ctrlOrMeta&&n.push(e?"⌘":"Ctrl"),t.alt&&n.push(e?"⌥":"Alt"),t.shift&&n.push(e?"⇧":"Shift"),n.push(qO(t.code)),e?n.join(""):n.join("+")}function h1(t,e){return e.get(t)??zO[t]}function WO(t){const e=new Map;for(const n of Ga)e.set(n,Tv(h1(n,t)));return e}function Kn(t,e){return e?e.has(t):!1}function hS(t,e){if(t.isComposing)return null;if(e&&e.size>0)for(const r of Ga){const i=e.get(r);if(i&&UO(i,t))return{id:r}}const n=t.ctrlKey||t.metaKey;if(t.key==="?")return{id:"toggle-help"};if(n){if(t.shiftKey&&t.code==="Comma"&&!Kn("settings-modal",e))return{id:"settings-modal"};if(!t.shiftKey&&t.code==="Comma"&&!Kn("settings",e))return{id:"settings"};if(t.key==="/")return{id:"toggle-help"};if(!t.altKey&&!t.shiftKey&&t.code==="KeyA")return{id:"select-all"};if(t.shiftKey&&!t.altKey&&t.code==="KeyS"&&!Kn("save-as",e))return{id:"save-as"};if(t.code==="KeyS"&&!Kn("save",e))return{id:"save"};if(t.shiftKey&&t.code==="KeyP"&&!Kn("toggle-palette",e))return{id:"toggle-palette"};if(t.code==="KeyN"&&!Kn("new-scratchpad",e))return{id:"new-scratchpad"};if(t.code==="KeyW"&&!Kn("close-tab",e))return{id:"close-tab"};if(t.code==="KeyO"&&!Kn("open-file",e))return{id:"open-file"};if(/^Digit[1-9]$/.test(t.code))return{id:"pick-tab",context:{tabIndex:Number(t.code.slice(5))}};if(t.shiftKey&&!t.altKey&&t.code==="KeyM"&&!Kn("toggle-mode",e))return{id:"toggle-mode"};if(t.altKey&&t.code==="KeyT"&&!Kn("reopen-closed-tab",e))return{id:"reopen-closed-tab"};if(!t.altKey&&!t.shiftKey&&t.code==="KeyT"&&!Kn("new-tab-menu",e))return{id:"new-tab-menu"};if(t.code==="KeyF")return{id:"find",context:{shift:t.shiftKey}};if(t.code==="KeyG")return{id:"find-nav",context:{shift:t.shiftKey}};if(t.key==="Enter")return{id:"annotation-accept-or-dismiss",context:{shift:t.shiftKey}};if(t.altKey&&t.code==="KeyM"&&!Kn("comment-on-selection",e))return{id:"comment-on-selection"};if(t.altKey&&t.code==="KeyA"&&!Kn("toggle-authorship",e))return{id:"toggle-authorship"}}if(t.altKey&&!t.ctrlKey&&!t.metaKey){if(t.shiftKey){if(t.code==="ArrowLeft"&&!Kn("toggle-left-panel",e))return{id:"toggle-left-panel"};if(t.code==="ArrowRight"&&!Kn("toggle-right-panel",e))return{id:"toggle-right-panel"}}if(!t.shiftKey){if(t.code==="BracketRight"&&!Kn("annotation-next",e))return{id:"annotation-next"};if(t.code==="BracketLeft"&&!Kn("annotation-prev",e))return{id:"annotation-prev"}}if(!t.shiftKey&&t.code==="KeyL"&&!Kn("select-block",e))return{id:"select-block"}}return null}function KO(t){return t.code==="Slash"?t.shift?"?":"/":t.code==="Enter"||t.code==="NumpadEnter"?"Enter":""}function GO(t){return{key:KO(t),code:t.code,ctrlKey:t.ctrlOrMeta,metaKey:!1,altKey:t.alt,shiftKey:t.shift,isComposing:!1}}function ZO(t,e){switch(t){case"toggle-help":return"Show keyboard shortcuts";case"select-all":return"Select all";case"find":return e!=null&&e.shift?"Find in open tabs":"Find / Replace";case"find-nav":return e!=null&&e.shift?"Find previous":"Find next";case"annotation-accept-or-dismiss":return e!=null&&e.shift?"Dismiss annotation":"Accept annotation";case"pick-tab":return e!=null&&e.tabIndex?`Jump to tab ${e.tabIndex}`:"Jump to tab";default:return""}}function pS(t){const e=hS(GO(t));return!e||lS(e.id)?null:ZO(e.id,e.context)||null}function YO(t,e,n){for(const i of Ga)if(i!==n&&Zh(h1(i,e),t))return Av[i];const r=pS(t);if(r)return r;for(const i of cS)if(Zh(i.chord,t))return i.label;return null}function JO(t){return cS.some(e=>Zh(e.chord,t))}function p1(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[i,o]of Object.entries(t))lS(i)&&jO(o)&&dS(o)&&(JO(o)||pS(o)||(e[i]=o));const n={},r=[];for(const i of Ga){const o=e[i];o&&(r.some(s=>Zh(s,o))||(r.push(o),n[i]=o))}return n}function mS(t){const e=new Map;for(const[n,r]of Object.entries(p1(t)))e.set(n,r);return e}const XO=["narrow","comfortable","wide","full"],$w={narrow:"58ch",comfortable:"68ch",wide:"82ch",full:"100%"};function gS(t){return typeof t=="string"&&XO.includes(t)}const vS=["anthropic","openai","gemini","local-ollama","local-llamacpp"],QO=50,$O={s:14,m:16,l:18};function bS(){try{return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}const gn={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:15,primaryTab:"annotations",panelOrder:"chat-editor-annotations",editorMeasure:"comfortable",selectionDwellMs:WC,showAuthorship:!0,reduceMotion:!1,textSize:"m",theme:"system",systemLightVariant:"light",accentHue:275,editorFont:"sans",fontByExtension:{},defaultSaveDirectory:null,density:"cozy",defaultMode:"tandem",highContrast:!1,annotationPatterns:!1,selectionToolbar:!0,formattingBarVisible:!0,railHoverReveal:!0,soloRailHidden:!0,degradedBannerDelayMs:3e4,sidecarRetryStrategy:"exponential",holdAnnotationsWhileOffline:!0,marginView:!1,showComments:!0,showHighlights:!0,showNotes:!0,showRawMarkdown:!0,decorationsMuted:!1,models:[],defaultModelId:null,customShortcuts:{}},e5=64,t5=512;function yS(t){if(!Array.isArray(t))return[];const e=[];for(const n of t){if(e.length>=QO)break;if(!n||typeof n!="object")continue;const r=n;if(typeof r.id!="string"||r.id.length===0||r.id.length>64||typeof r.provider!="string"||!vS.includes(r.provider)||typeof r.displayName!="string"||r.displayName.length>256||typeof r.modelId!="string"||r.modelId.length===0||r.modelId.length>256||typeof r.enabled!="boolean")continue;const i={id:r.id,provider:r.provider,displayName:r.displayName,modelId:r.modelId,enabled:r.enabled};if(typeof r.apiKeyRef=="string"&&r.apiKeyRef.length>0&&r.apiKeyRef.length<=e5&&/^[A-Za-z0-9_-]+$/.test(r.apiKeyRef)?i.apiKeyRef=r.apiKeyRef:typeof r.apiKey=="string"&&r.apiKey.length<=t5&&(i._legacyApiKey=r.apiKey),typeof r.endpoint=="string"&&r.endpoint.length<=2048&&(i.endpoint=r.endpoint),r.params&&typeof r.params=="object"&&!Array.isArray(r.params)){const o={};for(const[s,a]of Object.entries(r.params))(typeof a=="number"||typeof a=="string"||typeof a=="boolean")&&(o[s]=a);i.params=o}e.push(i)}return e}const n5=["serif","sans","mono"];function wS(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,r]of Object.entries(t))n==="__proto__"||n==="constructor"||n==="prototype"||typeof n!="string"||n.length===0||n.length>32||typeof r=="string"&&n5.includes(r)&&(e[n]=r);return e}const gh=15;function ek(t){return{leftPanelVisible:t.leftPanelVisible===!0,rightPanelVisible:t.rightPanelVisible!==!1,schemaVersion:gh,primaryTab:t.primaryTab==="annotations"?"annotations":"chat",panelOrder:t.panelOrder==="annotations-editor-chat"?"annotations-editor-chat":"chat-editor-annotations",editorMeasure:gS(t.editorMeasure)?t.editorMeasure:gn.editorMeasure,selectionDwellMs:Math.max(fc,Math.min(hc,Number(t.selectionDwellMs)||WC)),showAuthorship:t.showAuthorship===!1?!1:gn.showAuthorship,reduceMotion:typeof t.reduceMotion=="boolean"?t.reduceMotion:bS(),textSize:t.textSize==="s"||t.textSize==="m"||t.textSize==="l"?t.textSize:gn.textSize,theme:t.theme==="light"||t.theme==="dark"||t.theme==="warm"||t.theme==="system"?t.theme:gn.theme,systemLightVariant:t.systemLightVariant==="warm"?"warm":gn.systemLightVariant,accentHue:typeof t.accentHue=="number"&&t.accentHue>=0&&t.accentHue<=360?t.accentHue:gn.accentHue,editorFont:t.editorFont==="serif"||t.editorFont==="sans"||t.editorFont==="mono"?t.editorFont:gn.editorFont,fontByExtension:wS(t.fontByExtension),defaultSaveDirectory:typeof t.defaultSaveDirectory=="string"&&t.defaultSaveDirectory.trim()?t.defaultSaveDirectory.trim():null,density:t.density==="compact"||t.density==="cozy"||t.density==="spacious"?t.density:gn.density,defaultMode:t.defaultMode==="solo"||t.defaultMode==="tandem"?t.defaultMode:gn.defaultMode,highContrast:t.highContrast===!0,annotationPatterns:t.annotationPatterns===!0,selectionToolbar:t.selectionToolbar===!1?!1:gn.selectionToolbar,formattingBarVisible:t.formattingBarVisible===!1?!1:gn.formattingBarVisible,railHoverReveal:t.railHoverReveal===!1?!1:gn.railHoverReveal,soloRailHidden:t.soloRailHidden===!1?!1:gn.soloRailHidden,degradedBannerDelayMs:typeof t.degradedBannerDelayMs=="number"&&t.degradedBannerDelayMs>=5e3&&t.degradedBannerDelayMs<=12e4?t.degradedBannerDelayMs:gn.degradedBannerDelayMs,sidecarRetryStrategy:t.sidecarRetryStrategy==="exponential"||t.sidecarRetryStrategy==="constant-2s"||t.sidecarRetryStrategy==="manual"?t.sidecarRetryStrategy:gn.sidecarRetryStrategy,holdAnnotationsWhileOffline:typeof t.holdAnnotationsWhileOffline=="boolean"?t.holdAnnotationsWhileOffline:gn.holdAnnotationsWhileOffline,marginView:t.marginView===!0,showComments:t.showComments===!1?!1:gn.showComments,showHighlights:t.showHighlights===!1?!1:gn.showHighlights,showNotes:t.showNotes===!1?!1:gn.showNotes,showRawMarkdown:t.showRawMarkdown===!1?!1:gn.showRawMarkdown,decorationsMuted:t.decorationsMuted===!0,models:yS(t.models),defaultModelId:typeof t.defaultModelId=="string"&&t.defaultModelId.length>0?t.defaultModelId:null,customShortcuts:p1(t.customShortcuts)}}function _m(){let t;try{t=localStorage.getItem(jC)}catch{t=null}if(t)try{let e=JSON.parse(t);if((!e||typeof e!="object"||Array.isArray(e))&&(e={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:1}),(typeof e.schemaVersion=="number"?e.schemaVersion:1)===1){const r=e.panelHidden===!0;let i=!1,o=!0;r?(i=!1,o=!1):e.layout==="three-panel"?(i=!0,o=!0):e.layout==="tabbed-left"&&(i=!0,o=!1),e={...e,leftPanelVisible:i,rightPanelVisible:o,schemaVersion:2},delete e.layout,delete e.panelHidden}if(e.schemaVersion===2&&(e={...e,models:[],schemaVersion:3}),e.schemaVersion===3&&(e={...e,schemaVersion:4}),e.schemaVersion===4){const r={...e,schemaVersion:5};delete r.leftRailTabs,delete r.rightRailTabs,e=r}if(e.schemaVersion===5){const r={...e,schemaVersion:6};delete r.showIntegrationWizard,e=r}if(e.schemaVersion===6){const i=(Array.isArray(e.models)?e.models:[]).find(o=>typeof(o==null?void 0:o.id)=="string"&&o.enabled===!0);e={...e,schemaVersion:7,defaultModelId:i&&typeof i.id=="string"?i.id:null}}if(e.schemaVersion===7&&(e={...e,schemaVersion:8}),e.schemaVersion===8){const r=e.showAnnotationDecorations===!1,i={...e,showComments:!r,showHighlights:!r,showNotes:!r,decorationsMuted:!1,schemaVersion:9};delete i.showAnnotationDecorations,e=i}if(e.schemaVersion===9&&(e={...e,schemaVersion:10}),e.schemaVersion===10&&(e={...e,schemaVersion:11}),e.schemaVersion===11){const r={...e,schemaVersion:12};if(r.editorMeasure===void 0){const i=e.editorWidthPercent;r.editorMeasure=i===void 0||i===100?"full":"comfortable"}delete r.editorWidthPercent,e=r}if(e.showAnnotationDecorations===!1&&e.showComments===void 0&&(e={...e,showComments:!1,showHighlights:!1,showNotes:!1}),e.schemaVersion===12&&(e={...e,schemaVersion:13}),e.schemaVersion===13&&(e={...e,schemaVersion:14}),e.schemaVersion===14&&(e={...e,schemaVersion:15}),typeof e.schemaVersion=="number"&&e.schemaVersion>gh){console.warn(`[tandem] settings schemaVersion=${e.schemaVersion} is newer than v${gh}; loading defensively without writing.`);const r=e.editorMeasure,i=ek(e);typeof r=="string"&&r!==i.editorMeasure&&console.warn(`[tandem] editorMeasure=${JSON.stringify(r)} from newer client is unknown to v${gh}; displaying as ${JSON.stringify(i.editorMeasure)} (your setting is preserved on-disk).`);const o=new Set(Object.keys(i)),s=new Set(["leftRailTabs","rightRailTabs","showIntegrationWizard","showAnnotationDecorations","editorWidthPercent"]),a={};for(const[l,c]of Object.entries(e))!o.has(l)&&l!=="_readOnly"&&!s.has(l)&&(a[l]=c);return{...i,...a,_readOnly:!0}}return ek(e)}catch(e){console.warn("[tandem] settings JSON is corrupt, resetting to defaults:",e)}return{...gn,reduceMotion:bS()}}function r5(t,e){const n={...t,...e},r=yS(n.models);return{...n,customShortcuts:p1(n.customShortcuts),fontByExtension:wS(n.fontByExtension),defaultSaveDirectory:typeof n.defaultSaveDirectory=="string"&&n.defaultSaveDirectory.trim()?n.defaultSaveDirectory.trim():null,selectionDwellMs:Math.max(fc,Math.min(hc,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):gn.accentHue,editorMeasure:gS(n.editorMeasure)?n.editorMeasure:gn.editorMeasure,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,n.degradedBannerDelayMs)),models:r,defaultModelId:typeof n.defaultModelId=="string"&&r.some(i=>i.id===n.defaultModelId)?n.defaultModelId:null}}function i5(t,e){var n;if(e){const r=(n=t.fontByExtension)==null?void 0:n[e];if(r)return r}return t.editorFont}const nn=`http://127.0.0.1:${Gi}`;function o5(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return btoa(n)}function s5(t){return t.toLowerCase().endsWith(".docx")}async function kS(t){if(s5(t.name)){const e=await t.arrayBuffer();return o5(e)}return t.text()}function a5(){try{return _m().defaultSaveDirectory}catch{return null}}async function l5(){var n,r;const t=new AbortController,e=setTimeout(()=>t.abort(),250);try{const i=await fetch(`${nn}/api/integrations`,{signal:t.signal});if(!i.ok)return null;const s=(r=(n=(await i.json()).integrations)==null?void 0:n.find(a=>a.kind==="claude-code"))==null?void 0:r.workingDirectory;return typeof s=="string"&&s.trim()?s.trim():null}catch{return null}finally{clearTimeout(e)}}async function c5(){try{const{homeDir:t}=await Zt(async()=>{const{homeDir:n}=await import("./path-DpyQXOHZ.js");return{homeDir:n}},__vite__mapDeps([0,1])),e=await t();return typeof e=="string"&&e.trim()?e:null}catch{return null}}async function xS(){return a5()||await l5()||await c5()}function Yd(t,e,n=Date.now(),r=DD){const o=t.find(a=>a.path===e)??{path:e,openedAt:n},s=t.filter(a=>a.path!==e);return[o,...s].slice(0,r)}function tk(t){return t.map(e=>e.path)}function u5(t,e=Date.now()){if(!t)return"";const n=e-t;if(n<6e4)return"just now";const r=Math.floor(n/6e4);if(r<60)return`${r}m`;const i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function bc(){try{const t=localStorage.getItem(c1);if(!t)return[];const e=JSON.parse(t);return Array.isArray(e)?e.map(n=>{if(typeof n=="string")return{path:n,openedAt:0};if(n!==null&&typeof n=="object"&&typeof n.path=="string"){const r=n;return{path:r.path,openedAt:typeof r.openedAt=="number"?r.openedAt:0}}return null}).filter(n=>n!==null):[]}catch(t){return console.warn("[tandem] failed to load recent files:",t),[]}}function Jd(t){try{localStorage.setItem(c1,JSON.stringify(t)),_S()}catch(e){console.warn("[tandem] failed to save recent files:",e)}}function d5(){try{localStorage.removeItem(c1),_S()}catch(t){console.warn("[tandem] failed to clear recent files:",t)}}const f5=3e4;let vu=null;function nk(){const t=Date.now();if(vu&&t-vu.ts<f5)return vu.files;const e=bc();return vu={files:e,ts:t},e}function _S(){vu=null}const CS=["editor","navigation","view","document","annotations","claude"];let vh=F(tt(new Map));function h5(t,e={}){if(u(vh).has(t.id)&&!e.replace){const n=`[actions] id collision: "${t.id}" — existing action silently replaced. Pass { replace: true } to suppress this warning.`;console.warn(n)}return b(vh,new Map(u(vh)).set(t.id,t),!0),!0}function Yh(){return u(vh)}let Mv=null;function p5(t){Mv=t}function rn(t,e){if(!Mv){console.warn(`[actions] "${t}" invoked before App mounted — deps not wired yet`);return}e(Mv)}let Dv=F(!1);const m5={get saving(){return u(Dv)}};let Ig=!1,Rg=!1;const g5=400;function v5(t){return t.connected&&t.tabCount===0&&t.activeTabId===null}async function Jh(){if(!Rg){Rg=!0;try{const t=await fetch(`${nn}${bO}`,{method:"POST"});if(!t.ok){const e=await t.json().catch(()=>({}));console.warn("[Tandem] New Scratchpad failed:",e.message??t.statusText)}}catch(t){console.warn("[Tandem] New Scratchpad request failed:",t)}finally{Rg=!1}}}function SS(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}let Ng=!1;async function b5(t){const e=await xS();if(!e)return t;try{const{join:n}=await Zt(async()=>{const{join:r}=await import("./path-DpyQXOHZ.js");return{join:r}},__vite__mapDeps([0,1]));return await n(e,t)}catch{return t}}function y5(t,e){const n=`.${e}`,r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return t.slice(r+1).includes(".")?t.slice(t.lastIndexOf(".")).toLowerCase()===n?t:`${t.slice(0,t.lastIndexOf("."))}${n}`:`${t}${n}`}function w5(t,e,n){const r=new Blob([t],{type:n}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(i),0)}async function rk(t){if(Ng)return;const{activeDocId:e,notify:n,defaultName:r,sourceFormat:i}=t;if(!e){n("warning","No active document to save.");return}Ng=!0;try{SS()?await k5(e,n,r??"Scratchpad.md"):await x5(e,n,i)}finally{Ng=!1}}async function k5(t,e,n){var a,l;let r;try{const{save:c}=await Zt(async()=>{const{save:f}=await import("./index-Dm_QtxGQ.js");return{save:f}},__vite__mapDeps([2,1])),d=await b5(n);r=await c({defaultPath:d,filters:[{name:"Markdown",extensions:["md"]},{name:"Plain Text",extensions:["txt"]}]})}catch(c){e("error",`Save As dialog unavailable: ${c instanceof Error?c.message:c}`);return}if(typeof r!="string"||r.length===0)return;const o=r.toLowerCase().endsWith(".txt")?"txt":"md",s=y5(r,o);s!==r&&e("info",`Saving as ${o.toUpperCase()} — only .md and .txt are supported.`);try{const c=await fetch(`${nn}${f1}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t,targetPath:s,format:o})});if(!c.ok){const p=await c.json().catch(()=>({}));e("error",`Save As failed: ${p.message??c.statusText}`);return}const d=await c.json().catch(()=>null),f=((a=d==null?void 0:d.data)==null?void 0:a.fileName)??s,h=((l=d==null?void 0:d.data)==null?void 0:l.targetPath)??s;Jd(Yd(bc(),h)),e("info",`Saved to ${f}.`)}catch(c){e("error",`Save As request failed: ${c instanceof Error?c.message:c}`)}}async function x5(t,e,n){var i,o;const r=n==="txt"?"txt":"md";try{const s=await fetch(`${nn}${f1}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t,serialize:!0,format:r})});if(!s.ok){const d=await s.json().catch(()=>({}));e("error",`Save As failed: ${d.message??s.statusText}`);return}const a=await s.json().catch(()=>null),l=(i=a==null?void 0:a.data)==null?void 0:i.content,c=((o=a==null?void 0:a.data)==null?void 0:o.fileName)??`Scratchpad.${r}`;if(typeof l!="string"){e("error","Save As returned no content.");return}w5(l,c,r==="md"?"text/markdown":"text/plain"),e("info","Downloaded; scratchpad remains in-session.")}catch(s){e("error",`Save As request failed: ${s instanceof Error?s.message:s}`)}}async function Ov(t){if(!(!t||Ig)){Ig=!0,b(Dv,!0);try{const e=await fetch(`${nn}${f1}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t})});if(!e.ok){const n=await e.json().catch(()=>({}));console.warn("[Tandem] Save failed:",n.message??e.statusText)}}catch(e){console.warn("[Tandem] Save request failed:",e)}finally{Ig=!1,b(Dv,!1)}}}let $u=!1;async function _5(){let t;try{t=await fetch(`${nn}${aS}`)}catch(e){return{ok:!1,kind:"network",detail:e instanceof Error?e.message:String(e)}}return t.status===404?{ok:!1,kind:"not-built"}:t.ok?{ok:!0,value:await t.json()}:{ok:!1,kind:"server-error",detail:`HTTP ${t.status}`}}async function C5(){let t;try{t=await fetch(`${nn}${RO}`,{method:"GET"})}catch(n){return{ok:!1,kind:"network",detail:n instanceof Error?n.message:String(n)}}if(t.status===404)return{ok:!1,kind:"not-built"};if(!t.ok)return{ok:!1,kind:"server-error",detail:`HTTP ${t.status}`};const e=await t.json();return typeof e.nonce!="string"?{ok:!1,kind:"server-error",detail:"malformed nonce response"}:{ok:!0,value:e.nonce}}function S5(t){if(!t||/^[a-z]+:\/\//.test(t))return null;const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>0?t.slice(0,e):null}async function ES(t,e,n,r){const i=await C5();if(!i.ok){t.notify("error",`Failed to acquire launcher nonce: ${i.kind}${i.detail?` (${i.detail})`:""}.`);return}const o=i.value;try{const s=await fetch(`${nn}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,nonce:o})});if(!s.ok){const a=await s.json().catch(()=>({}));t.notify("error",`${r.failPrefix}: ${a.message??s.statusText}`);return}t.notify("info",r.successMessage)}catch(s){t.notify("error",`${r.requestFailPrefix}: ${s instanceof Error?s.message:s}`)}}async function AS(t){if($u)return!1;const e=await _5();if(!e.ok)return e.kind==="not-built"?t.notify("warning","Claude launcher not active in this Tandem build."):e.kind==="network"?t.notify("error",`Cannot reach Tandem server${e.detail?`: ${e.detail}`:""}.`):t.notify("error",`Launcher status check failed${e.detail?`: ${e.detail}`:""}.`),!1;const n=e.value;return n.available?("skillRefresh"in n&&n.skillRefresh&&t.notify("warning",`Bundled skill refresh failed: ${n.skillRefresh.message}. Run \`tandem setup\` to retry.`),!0):(t.notify("warning","Claude launcher not active in this Tandem build."),!1)}async function TS(t){if(!await AS(t))return;const e=S5(t.getActiveDocumentPath());if(!e){t.notify("warning","Active document isn't saved to a folder. Set a working directory in Settings → Claude Code.");return}if(confirm(`Restart Claude in:
4
+ ${e}
5
+
6
+ Your current task may be interrupted.`)){$u=!0;try{await ES(t,NO,{cwd:e},{failPrefix:"Relaunch failed",requestFailPrefix:"Relaunch request failed",successMessage:`Claude restarting in ${e}.`})}finally{$u=!1}}}function E5(){rn("launcher-relaunch-here",t=>void TS(t))}async function A5(t){if(await AS(t)&&confirm("Drop Claude's saved conversation and restart fresh. This cannot be undone.")){$u=!0;try{await ES(t,PO,{},{failPrefix:"Start fresh failed",requestFailPrefix:"Start-fresh request failed",successMessage:"Claude restarting with a fresh conversation."})}finally{$u=!1}}}let Pg=!1;function Lg(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}async function T5(t){var n;if(Pg)return;const e=t.getActiveTabId();if(!e){t.notify("warning","No active document.");return}Pg=!0;try{const r=await fetch(`${nn}${_O}?documentId=${encodeURIComponent(e)}`);if(!r.ok){const d=await r.json().catch(()=>({}));t.notify("error",`Couldn't list backups: ${d.message??r.statusText}`);return}const i=await r.json().catch(()=>null),o=((n=i==null?void 0:i.data)==null?void 0:n.backups)??[];if(o.length===0){t.notify("info","No backups exist for this document yet. Tandem snapshots the on-disk file before its first overwrite each session.");return}const s=o[0],a=o.map((d,f)=>` ${f+1}. ${Lg(d.timestamp)}`).join(`
7
+ `);if(!confirm(`Available backups (newest first):
8
+ ${a}
9
+
10
+ Restore the most recent backup (${Lg(s.timestamp)})? The document reloads with the backup's content; annotations are preserved.
11
+
12
+ Older backups can be restored by asking Claude (tandem_restoreBackup).`))return;const c=await fetch(`${nn}${CO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e,backup:s.name})});if(!c.ok){const d=await c.json().catch(()=>({}));t.notify("error",`Restore failed: ${d.message??c.statusText}`);return}t.notify("info",`Restored backup from ${Lg(s.timestamp)}.`)}catch(r){t.notify("error",`Restore request failed: ${r instanceof Error?r.message:r}`)}finally{Pg=!1}}async function M5(t){const e=t.getActiveDocumentPath();if(!e){t.notify("warning","This document isn't saved to a file yet.");return}try{const{invoke:n}=await Zt(async()=>{const{invoke:r}=await import("./core-DhEqZVGG.js");return{invoke:r}},[]);await n("show_in_file_manager",{path:e})}catch(n){t.notify("error",`Couldn't reveal in file manager: ${n instanceof Error?n.message:String(n)}`)}}const D5=[{id:"save",label:"Save document",group:"document",shortcut:"Ctrl+S",run(){rn("save",t=>void Ov(t.getActiveTabId()))}},{id:"settings",label:"Open settings",group:"view",shortcut:"Ctrl+,",run(){rn("settings",t=>t.openSettings())}},{id:"settings-modal",label:"Open settings (new)",group:"view",shortcut:"Ctrl+Shift+,",run(){rn("settings-modal",t=>t.openSettingsModal())}},{id:"toggle-mode",label:"Toggle Solo / Tandem mode",group:"document",shortcut:"Ctrl+Shift+M",run(){rn("toggle-mode",t=>t.toggleSoloMode())}},{id:"new-scratchpad",label:"New Scratchpad",group:"document",shortcut:"Ctrl+N",run(){Jh()}},{id:"save-as",label:"Save As…",group:"document",shortcut:"Ctrl+Shift+S",run(){rn("save-as",t=>void t.saveAs())}},{id:"close-tab",label:"Close active tab",group:"document",shortcut:"Ctrl+W",run(){rn("close-tab",t=>t.closeActiveTab())}},{id:"open-file",label:"Open file…",group:"document",shortcut:"Ctrl+O",run(){rn("open-file",t=>t.openFileDialog())}},{id:"find",label:"Find / Replace",group:"navigation",shortcut:"Ctrl+F",run(){rn("find",t=>t.openFindBar())}},{id:"find-in-tabs",label:"Find in open tabs",group:"navigation",shortcut:"Ctrl+Shift+F",run(){rn("find-in-tabs",t=>t.openFindBarTabs())}},{id:"find-next",label:"Find next match",group:"navigation",shortcut:"Ctrl+G",run(){rn("find-next",t=>t.findNext())}},{id:"find-previous",label:"Find previous match",group:"navigation",shortcut:"Ctrl+Shift+G",run(){rn("find-previous",t=>t.findPrev())}},{id:"toggle-left-panel",label:"Toggle left panel",group:"view",shortcut:"Alt+Shift+Left",run(){rn("toggle-left-panel",t=>t.toggleLeftPanel())}},{id:"toggle-right-panel",label:"Toggle right panel",group:"view",shortcut:"Alt+Shift+Right",run(){rn("toggle-right-panel",t=>t.toggleRightPanel())}},{id:"reopen-closed-tab",label:"Reopen closed tab (this session)",group:"document",shortcut:"Ctrl+Alt+T",run(){rn("reopen-closed-tab",t=>t.reopenClosedTab())}},{id:"annotation-next",label:"Next annotation",group:"annotations",shortcut:"Alt+]",run(){rn("annotation-next",t=>t.annotationNext())}},{id:"annotation-previous",label:"Previous annotation",group:"annotations",shortcut:"Alt+[",run(){rn("annotation-previous",t=>t.annotationPrev())}},{id:"annotation-accept",label:"Accept focused annotation",group:"annotations",shortcut:"Ctrl+Enter",run(){rn("annotation-accept",t=>t.annotationAccept())}},{id:"annotation-dismiss",label:"Dismiss focused annotation",group:"annotations",shortcut:"Ctrl+Shift+Enter",run(){rn("annotation-dismiss",t=>t.annotationDismiss())}},{id:"select-block",label:"Select containing block",group:"editor",shortcut:"Alt+L",run(){rn("select-block",t=>t.selectBlock())}},{id:"toggle-authorship",label:"Toggle authorship colors",group:"view",shortcut:"Ctrl+Alt+A",run(){rn("toggle-authorship",t=>t.toggleAuthorship())}},{id:"toggle-formatting-bar",label:"Toggle formatting bar",group:"view",run(){rn("toggle-formatting-bar",t=>t.toggleFormattingBar())}},{id:"toggle-source-view",label:"Toggle markdown source view",group:"view",run(){rn("toggle-source-view",t=>t.toggleSourceView())}},{id:"restore-backup",label:"Restore a backup of this document…",group:"document",run(){rn("restore-backup",t=>void T5(t))}},{id:"launcher-relaunch-here",label:"Relaunch Claude in this folder",group:"claude",run(){rn("launcher-relaunch-here",t=>void TS(t))}},{id:"launcher-start-fresh",label:"Start fresh Claude conversation",group:"claude",run(){rn("launcher-start-fresh",t=>void A5(t))}},...SS()?[{id:"show-in-file-explorer",label:"Show in file explorer",group:"document",run(){rn("show-in-file-explorer",t=>void M5(t))}}]:[]];for(const t of D5)h5(t);function $t(t,e="y"){function n(){if(t.isConnected){if(e==="y"||e==="both"){const o=t.scrollTop>0,s=t.scrollTop+t.clientHeight<t.scrollHeight-1;r("data-overflow-top",o),r("data-overflow-bottom",s)}if(e==="x"||e==="both"){const o=t.scrollLeft>0,s=t.scrollLeft+t.clientWidth<t.scrollWidth-1;r("data-overflow-left",o),r("data-overflow-right",s)}}}function r(o,s){s?t.setAttribute(o,"true"):t.removeAttribute(o)}n(),t.addEventListener("scroll",n,{passive:!0});let i=null;try{i=new ResizeObserver(n),i.observe(t)}catch(o){console.warn("[tandem:scrollFade] ResizeObserver init failed",o)}return{destroy(){t.removeEventListener("scroll",n),i==null||i.disconnect()}}}function MS(t){return t.type==="save-error"&&t.documentId?{label:"Retry",documentId:t.documentId}:null}const DS={info:["M12 3a9 9 0 100 18 9 9 0 000-18z","M12 11v6","M12 8h.01"],warning:["M10.3 3.86 1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z","M12 9v4","M12 17h.01"],error:["M12 3a9 9 0 100 18 9 9 0 000-18z","M15 9l-6 6","M9 9l6 6"]};function O5(t,e=Date.now()){const n=Math.max(0,Math.floor((e-t)/1e3));if(n<5)return"now";if(n<60)return`${n}s`;const r=Math.floor(n/60);if(r<60)return`${r}m`;const i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}var I5=T('<button type="button" data-testid="activity-clear-all" class="svelte-bf7dij">Clear all</button>'),R5=T('<div class="tray-empty svelte-bf7dij" data-testid="activity-empty">Nothing to report. <div class="sub svelte-bf7dij">Saves, errors, and integration events appear here.</div></div>'),N5=an('<path class="svelte-bf7dij"></path>'),P5=T('<span class="badge svelte-bf7dij"> </span>'),L5=T('<button type="button" class="action svelte-bf7dij"><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bf7dij"><path d="M21 12a9 9 0 1 1-3-7" class="svelte-bf7dij"></path><path d="M21 4v5h-5" class="svelte-bf7dij"></path></svg> </button>'),F5=T('<div><span class="glyph svelte-bf7dij"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bf7dij"></svg></span> <div class="body svelte-bf7dij"><div class="msg-row svelte-bf7dij"><span class="msg svelte-bf7dij"> </span> <!> <span class="ts svelte-bf7dij"> </span></div> <!></div> <button type="button" class="dismiss svelte-bf7dij" aria-label="Dismiss activity item"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bf7dij"><path d="M6 6l12 12" class="svelte-bf7dij"></path><path d="M6 18L18 6" class="svelte-bf7dij"></path></svg></button></div>'),z5=T("<div></div>"),B5=T('<div class="tray-inner svelte-bf7dij" id="activity-tray" role="region" aria-label="Activity" data-testid="activity-tray"><div class="tray-head svelte-bf7dij"><span class="label svelte-bf7dij">Activity</span> <span class="num svelte-bf7dij"> </span> <span class="spacer svelte-bf7dij"></span> <!></div> <!></div>'),H5=T('<span class="svelte-bf7dij">No activity</span>'),V5=T('<span class="svelte-bf7dij">Activity</span> <span class="count svelte-bf7dij"> </span>',1),U5=T('<div class="activity-anchor svelte-bf7dij"><div><div class="tray-wrap svelte-bf7dij"><!></div> <button type="button" class="pill-row svelte-bf7dij" data-testid="activity-pill"><span class="led svelte-bf7dij"></span> <!> <span class="spacer svelte-bf7dij"></span> <span class="chev svelte-bf7dij"><svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bf7dij"><path d="M6 9l6 6 6-6" class="svelte-bf7dij"></path></svg></span></button></div></div>');function j5(t,e){nt(e,!0);const n=L(()=>e.items.length),r=L(()=>e.items.some(_=>_.severity==="error")?"has-error":e.items.some(_=>_.severity==="warning")?"has-warning":e.items.some(_=>_.severity==="info")?"has-info":"idle");let i=F(tt(Date.now()));const o=setInterval(()=>{b(i,Date.now(),!0)},3e4);let s=F(!1),a=!1,l;pe(()=>{e.open&&!a?(b(s,!0),l&&clearTimeout(l),l=setTimeout(()=>{b(s,!1)},1800)):!e.open&&a&&(b(s,!1),l&&(clearTimeout(l),l=void 0)),a=e.open}),Dn(()=>{clearInterval(o),l&&clearTimeout(l)});var c=U5(),d=w(c);let f;var h=w(d),p=w(h);{var m=_=>{var S=B5(),A=w(S),O=k(w(A),2),E=w(O),M=k(O,4);{var R=z=>{var Q=I5();P("click",Q,function(...ie){var me;(me=e.onClear)==null||me.apply(this,ie)}),x(z,Q)};j(M,z=>{u(n)>0&&z(R)})}var D=k(A,2);{var I=z=>{var Q=R5();x(z,Q)},H=z=>{var Q=z5();let ie;mt(Q,21,()=>e.items,me=>me.id,(me,le)=>{const ke=L(()=>MS(u(le)));var ce=F5(),ve=w(ce),De=w(ve);mt(De,20,()=>DS[u(le).severity],X=>X,(X,ye)=>{var Y=N5();W(()=>U(Y,"d",ye)),x(X,Y)});var ee=k(ve,2),q=w(ee),V=w(q),re=w(V),te=k(V,2);{var Z=X=>{var ye=P5(),Y=w(ye);W(()=>G(Y,`×${u(le).count??""}`)),x(X,ye)};j(te,X=>{u(le).count>1&&X(Z)})}var ge=k(te,2),Ie=w(ge),Se=k(q,2);{var fe=X=>{var ye=L5(),Y=k(w(ye));W(()=>{U(ye,"data-testid",`activity-action-${u(le).id}`),G(Y,` ${u(ke).label??""}`)}),P("click",ye,()=>e.onAction(u(le))),x(X,ye)};j(Se,X=>{u(ke)&&X(fe)})}var _e=k(ee,2);W(X=>{bt(ce,1,`toast-row ${u(le).severity??""}`,"svelte-bf7dij"),U(ce,"data-testid",`activity-row-${u(le).id}`),G(re,u(le).message),G(Ie,X),U(_e,"data-testid",`activity-dismiss-${u(le).id}`)},[()=>O5(u(le).timestamp,u(i))]),P("click",_e,()=>e.onDismiss(u(le).id)),x(me,ce)}),W(()=>ie=bt(Q,1,"tray-list svelte-bf7dij",null,ie,{cascade:u(s)})),x(z,Q)};j(D,z=>{u(n)===0?z(I):z(H,-1)})}W(()=>G(E,u(n)===0?"No events":`${u(n)} event${u(n)===1?"":"s"}`)),x(_,S)};j(p,_=>{e.open&&_(m)})}var v=k(h,2),g=k(w(v),2);{var y=_=>{var S=H5();x(_,S)},C=_=>{var S=V5(),A=k(Ae(S),2),O=w(A);W(()=>G(O,u(n))),x(_,S)};j(g,_=>{u(n)===0?_(y):_(C,-1)})}W(()=>{f=bt(d,1,`activity-shell ${u(r)??""}`,"svelte-bf7dij",f,{open:e.open}),U(v,"aria-expanded",e.open),U(v,"aria-controls",e.open?"activity-tray":void 0)}),P("click",v,function(..._){var S;(S=e.onToggle)==null||S.apply(this,_)}),x(t,c),rt()}lt(["click"]);function ir(t){this.content=t}ir.prototype={constructor:ir,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),o=r.content.slice();return i==-1?o.push(n||t,e):(o[i+1]=e,n&&(o[i]=n)),new ir(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new ir(n)},addToStart:function(t,e){return new ir([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ir(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),o=r.find(t);return i.splice(o==-1?i.length:o,0,e,n),new ir(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=ir.from(t),t.size?new ir(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ir.from(t),t.size?new ir(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ir.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};ir.from=function(t){if(t instanceof ir)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ir(e)};function OS(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)n++;return n}if(i.content.size||o.content.size){let s=OS(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function IS(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=t.child(--i),a=e.child(--o),l=s.nodeSize;if(s==a){n-=l,r-=l;continue}if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let c=0,d=Math.min(s.text.length,a.text.length);for(;c<d&&s.text[s.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let c=IS(s.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class Ce{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,o){for(let s=0,a=0;a<n;s++){let l=this.content[s],c=a+l.nodeSize;if(c>e&&r(l,i+a,o||null,s)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),r,i+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",s=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new Ce(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let o=0,s=0;s<n;o++){let a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-s),Math.min(a.text.length,n-s)):a=a.cut(Math.max(0,e-s-1),Math.min(a.content.size,n-s-1))),r.push(a),i+=a.nodeSize),s=l}return new Ce(r,i)}cutByIndex(e,n){return e==n?Ce.empty:e==0&&n==this.content.length?this:new Ce(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new Ce(i,o)}addToStart(e){return new Ce([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ce(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return OS(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return IS(this,e,n,r)}findIndex(e){if(e==0)return Mf(0,e);if(e==this.size)return Mf(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),o=r+i.nodeSize;if(o>=e)return o==e?Mf(n+1,o):Mf(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Ce.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ce(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ce.empty;let n,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(n||(n=e.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new Ce(n||e,r)}static from(e){if(!e)return Ce.empty;if(e instanceof Ce)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Ce([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Ce.empty=new Ce([],0);const Fg={index:0,offset:0};function Mf(t,e){return Fg.index=t,Fg.offset=e,Fg}function Xh(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Xh(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Xh(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let en=class Iv{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Xh(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Iv.none;if(e instanceof Iv)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};en.none=[];class Qh extends Error{}class Ge{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=NS(this.content,e+this.openStart,n);return r&&new Ge(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ge(RS(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Ge.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ge(Ce.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new Ge(e,r,i)}}Ge.empty=new Ge(Ce.empty,0,0);function RS(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:s,offset:a}=t.findIndex(n);if(i==e||o.isText){if(a!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(RS(o.content,e-i-1,n-i-1)))}function NS(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),s=t.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=NS(s.content,e-o-1,n,s);return a&&t.replaceChild(i,s.copy(a))}function q5(t,e,n){if(n.openStart>t.depth)throw new Qh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Qh("Inconsistent open depths");return PS(t,e,n,0)}function PS(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=PS(t,e,n,r+1);return o.copy(o.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,a=s.content;return za(s,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=W5(n,t);return za(o,FS(t,s,a,e,r))}else return za(o,$h(t,e,r))}function LS(t,e){if(!e.type.compatibleContent(t.type))throw new Qh("Cannot join "+e.type.name+" onto "+t.type.name)}function Rv(t,e,n){let r=t.node(n);return LS(r,e.node(n)),r}function Fa(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Au(t,e,n,r){let i=(e||t).node(n),o=0,s=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Fa(t.nodeAfter,r),o++));for(let a=o;a<s;a++)Fa(i.child(a),r);e&&e.depth==n&&e.textOffset&&Fa(e.nodeBefore,r)}function za(t,e){return t.type.checkContent(e),t.copy(e)}function FS(t,e,n,r,i){let o=t.depth>i&&Rv(t,e,i+1),s=r.depth>i&&Rv(n,r,i+1),a=[];return Au(null,t,i,a),o&&s&&e.index(i)==n.index(i)?(LS(o,s),Fa(za(o,FS(t,e,n,r,i+1)),a)):(o&&Fa(za(o,$h(t,e,i+1)),a),Au(e,n,i,a),s&&Fa(za(s,$h(n,r,i+1)),a)),Au(r,null,i,a),new Ce(a)}function $h(t,e,n){let r=[];if(Au(null,t,n,r),t.depth>n){let i=Rv(t,e,n+1);Fa(za(i,$h(t,e,n+1)),r)}return Au(e,null,n,r),new Ce(r)}function W5(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(Ce.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class ed{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return en.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let a=r;r=i,i=a}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new ep(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let s=e;;){let{index:a,offset:l}=s.content.findIndex(o),c=o-l;if(r.push(s,a,i+l),!c||(s=s.child(a),s.isText))break;o=c-1,i+=l+1}return new ed(n,r,o)}static resolveCached(e,n){let r=ik.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==n)return s}else ik.set(e,r=new K5);let i=r.elts[r.i]=ed.resolve(e,n);return r.i=(r.i+1)%G5,i}}class K5{constructor(){this.elts=[],this.i=0}}const G5=12,ik=new WeakMap;class ep{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Z5=Object.create(null);let Ks=class Nv{constructor(e,n,r,i=en.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||Ce.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Xh(this.attrs,n||e.defaultAttrs||Z5)&&en.sameSet(this.marks,r||en.none)}copy(e=null){return e==this.content?this:new Nv(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Nv(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Ge.empty;let i=this.resolve(e),o=this.resolve(n),s=r?0:i.sharedDepth(n),a=i.start(s),c=i.node(s).content.cut(i.pos-a,o.pos-a);return new Ge(c,i.depth-s,o.depth-s)}replace(e,n,r){return q5(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return ed.resolveCached(this,e)}resolveNoCache(e){return ed.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),zS(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=Ce.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),a=s&&s.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;l<o;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=en.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!en.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=Ce.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};Ks.prototype.text=void 0;class tp extends Ks{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):zS(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new tp(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new tp(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function zS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Za{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Y5(e,n);if(r.next==null)return Za.empty;let i=BS(r);r.next&&r.err("Unexpected trailing text");let o=nI(tI(i));return rI(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let o=n;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function o(s,a){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return Ce.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:f}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let h=o(f,a.concat(d));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let a=i;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(`
13
+ `)}}Za.empty=new Za(!0);class Y5{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function BS(t){let e=[];do e.push(J5(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function J5(t){let e=[];do e.push(X5(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function X5(t){let e=eI(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Q5(t,e);else break;return e}function ok(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Q5(t,e){let n=ok(t),r=n;return t.eat(",")&&(t.next!="}"?r=ok(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function $5(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function eI(t){if(t.eat("(")){let e=BS(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=$5(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function tI(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(s,a,l){let c={term:l,to:a};return e[s].push(c),c}function i(s,a){s.forEach(l=>l.to=a)}function o(s,a){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(o(c,a)),[]);if(s.type=="seq")for(let l=0;;l++){let c=o(s.exprs[l],a);if(l==s.exprs.length-1)return c;i(c,a=n())}else if(s.type=="star"){let l=n();return r(a,l),i(o(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return i(o(s.expr,a),l),i(o(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(a)].concat(o(s.expr,a));if(s.type=="range"){let l=a;for(let c=0;c<s.min;c++){let d=n();i(o(s.expr,l),d),l=d}if(s.max==-1)i(o(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let d=n();r(l,d),i(o(s.expr,l),d),l=d}return[r(l)]}else{if(s.type=="name")return[r(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function HS(t,e){return e-t}function sk(t,e){let n=[];return r(e),n.sort(HS);function r(i){let o=t[i];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(i);for(let s=0;s<o.length;s++){let{term:a,to:l}=o[s];!a&&n.indexOf(l)==-1&&r(l)}}}function nI(t){let e=Object.create(null);return n(sk(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<i.length;d++)i[d][0]==a&&(c=i[d][1]);sk(t,l).forEach(d=>{c||i.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new Za(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(HS);o.next.push({type:i[s][0],next:e[a.join(",")]||n(a)})}return o}}function rI(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],o=!i.validEnd,s=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];s.push(l.name),o&&!(l.isText||l.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function VS(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function US(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let o=t[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function jS(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let o=t[i];o.validate&&o.validate(e[i])}}function qS(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new oI(t,r,e[r]);return n}let ak=class WS{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=qS(e,r.attrs),this.defaultAttrs=VS(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Za.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:US(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ks(this,this.computeAttrs(e),Ce.from(n),en.setFrom(r))}createChecked(e=null,n,r){return n=Ce.from(n),this.checkContent(n),new Ks(this,this.computeAttrs(e),n,en.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Ce.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),o=i&&i.fillBefore(Ce.empty,!0);return o?new Ks(this,e,n.append(o),en.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){jS(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:en.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new WS(o,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function iI(t,e,n){let r=n.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class oI{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?iI(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Cm{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=qS(e,i.attrs),this.excluded=null;let o=VS(this.attrs);this.instance=o?new en(this,o):null}create(e=null){return!e&&this.instance?this.instance:new en(this,US(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new Cm(o,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){jS(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let m1=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=ir.from(e.nodes),n.marks=ir.from(e.marks||{}),this.nodes=ak.compile(this.spec.nodes,this),this.marks=Cm.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",a=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=Za.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=a=="_"?null:a?lk(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:lk(this,s.split(" "))}this.nodeFromJSON=i=>Ks.fromJSON(this,i),this.markFromJSON=i=>en.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ak){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new tp(r,r.defaultAttrs,e,en.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function lk(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],o=t.marks[i],s=o;if(o)n.push(o);else for(let a in t.marks){let l=t.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function sI(t){return t.tag!=null}function aI(t){return t.style!=null}let Tu=class Pv{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(sI(i))this.tags.push(i);else if(aI(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new uk(this,n,!1);return r.addAll(e,en.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new uk(this,n,!0);return r.addAll(e,en.none,n.from,n.to),Ge.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(uI(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,n,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],a=s.style;if(!(a.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let a=n[s];if((a.priority==null?50:a.priority)<o)break}n.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=dk(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=dk(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Pv(e,Pv.schemaRules(e)))}};const KS={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},lI={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},GS={ol:!0,ul:!0},td=1,Lv=2,Mu=4;function ck(t,e,n){return e!=null?(e?td:0)|(e==="full"?Lv:0):t&&t.whitespace=="pre"?td|Lv:n&~Mu}class Df{constructor(e,n,r,i,o,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=en.none,this.match=o||(s&Mu?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ce.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&td)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=Ce.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ce.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!KS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class uk{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,o,s=ck(null,n.preserveWhitespace,0)|(r?Mu:0);i?o=new Df(i.type,i.attrs,en.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new Df(null,null,en.none,!0,null,s):o=new Df(e.schema.topNodeType,null,en.none,!0,null,s),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,o=i.options&Lv?"full":this.localPreserveWS||(i.options&td)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
14
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(s.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),a;GS.hasOwnProperty(s)&&this.parser.normalizeLists&&cI(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:lI.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(KS.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),c&&this.sync(o),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
15
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let a=void 0;;){let l=this.parser.matchStyle(o,s,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,i){let o,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(o=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}o&&this.sync(a)&&this.open--}addAll(e,n,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];s!=a;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,n);this.findAtPoint(e,o)}findPlace(e,n,r){let i,o;for(let s=this.open,a=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,o=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=en.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):fk(a.type,e.type))&&(s=a.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,i)),o}enterInner(e,n,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let a=ck(e,o,s.options);s.options&Mu&&s.content.length==0&&(a|=Mu);let l=en.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):fk(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Df(e,n,l,i,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=td)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let d=l>0||l==0&&i?this.nodes[l].type:r&&l>=o?r.node(l-o).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function cI(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&GS.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function uI(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function dk(t){let e={};for(let n in t)e[n]=t[n];return e}function fk(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],s=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||o.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class cl{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=zg(n).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let a=0,l=0;for(;a<o.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(o[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)i=o.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],d=this.serializeMark(c,s.isInline,n);d&&(o.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=bh(zg(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&bh(zg(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return bh(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new cl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=hk(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return hk(e.marks)}}function hk(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function zg(t){return t.document||window.document}const pk=new WeakMap;function dI(t){let e=pk.get(t);return e===void 0&&pk.set(t,e=fI(t)),e}function fI(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function bh(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=dI(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let f in c)if(c[f]!=null){let h=f.indexOf(" ");h>0?l.setAttributeNS(f.slice(0,h),f.slice(h+1),c[f]):f=="style"&&l.style?l.style.cssText=c[f]:l.setAttribute(f,c[f])}}for(let f=d;f<e.length;f++){let h=e[f];if(h===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:m}=bh(t,h,n,r);if(l.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const ZS=65535,YS=Math.pow(2,16);function hI(t,e){return t+e*YS}function mk(t){return t&ZS}function pI(t){return(t-(t&ZS))/YS}const JS=1,XS=2,yh=4,QS=8;class Fv{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&QS)>0}get deletedBefore(){return(this.delInfo&(JS|yh))>0}get deletedAfter(){return(this.delInfo&(XS|yh))>0}get deletedAcross(){return(this.delInfo&yh)>0}}class ni{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ni.empty)return ni.empty}recover(e){let n=0,r=mk(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+pI(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+o],d=this.ranges[a+s],f=l+c;if(e<=f){let h=c?e==l?-1:e==f?1:n:n,p=l+i+(h<0?0:d);if(r)return p;let m=e==(n<0?l:f)?null:hI(a/3,e-l),v=e==l?XS:e==f?JS:yh;return(n<0?e!=l:e!=f)&&(v|=QS),new Fv(p,v,m)}i+=d-c}return r?e+i:new Fv(e+i,0,null)}touches(e,n){let r=0,i=mk(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+o],d=l+c;if(e<=d&&a==i*3)return!0;r+=this.ranges[a+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],a=s-(this.inverted?o:0),l=s+(this.inverted?0:o),c=this.ranges[i+n],d=this.ranges[i+r];e(a,a+c,l,l+d),o+=d-c}}invert(){return new ni(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ni.empty:new ni(e<0?[0,-e,0]:[0,0,e])}}ni.empty=new ni([]);class nd{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new nd(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new nd;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],a=s.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new Fv(e,i,null)}}const Bg=Object.create(null);class br{getMap(){return ni.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Bg[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Bg)throw new RangeError("Duplicate use of step JSON ID "+e);return Bg[e]=n,n.prototype.jsonID=e,n}}class On{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new On(e,null)}static fail(e){return new On(null,e)}static fromReplace(e,n,r,i){try{return On.ok(e.replace(n,r,i))}catch(o){if(o instanceof Qh)return On.fail(o.message);throw o}}}function g1(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(g1(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return Ce.fromArray(r)}class zs extends br{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new Ge(g1(n.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return On.fromReplace(e,this.from,this.to,o)}invert(){return new yo(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new zs(n.pos,r.pos,this.mark)}merge(e){return e instanceof zs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new zs(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new zs(n.from,n.to,e.markFromJSON(n.mark))}}br.jsonID("addMark",zs);class yo extends br{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Ge(g1(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return On.fromReplace(e,this.from,this.to,r)}invert(){return new zs(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new yo(n.pos,r.pos,this.mark)}merge(e){return e instanceof yo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new yo(n.from,n.to,e.markFromJSON(n.mark))}}br.jsonID("removeMark",yo);class Bs extends br{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return On.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return On.fromReplace(e,this.pos,this.pos+1,new Ge(Ce.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Bs(this.pos,n.marks[i]);return new Bs(this.pos,this.mark)}}return new Ya(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Bs(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Bs(n.pos,e.markFromJSON(n.mark))}}br.jsonID("addNodeMark",Bs);class Ya extends br{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return On.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return On.fromReplace(e,this.pos,this.pos+1,new Ge(Ce.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Bs(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ya(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ya(n.pos,e.markFromJSON(n.mark))}}br.jsonID("removeNodeMark",Ya);class Yn extends br{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&zv(e,this.from,this.to)?On.fail("Structure replace would overwrite content"):On.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ni([this.from,this.to-this.from,this.slice.size])}invert(e){return new Yn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Yn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Yn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Ge.empty:new Ge(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Yn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Ge.empty:new Ge(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Yn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Yn(n.from,n.to,Ge.fromJSON(e,n.slice),!!n.structure)}}br.jsonID("replace",Yn);class Qn extends br{constructor(e,n,r,i,o,s,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=a}apply(e){if(this.structure&&(zv(e,this.from,this.gapFrom)||zv(e,this.gapTo,this.to)))return On.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return On.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?On.fromReplace(e,this.from,this.to,r):On.fail("Content does not fit in gap")}getMap(){return new ni([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Qn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new Qn(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Qn(n.from,n.to,n.gapFrom,n.gapTo,Ge.fromJSON(e,n.slice),n.insert,!!n.structure)}}br.jsonID("replaceAround",Qn);function zv(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function mI(t,e,n,r){let i=[],o=[],s,a;t.doc.nodesBetween(e,n,(l,c,d)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+l.nodeSize,n),m=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(m)||(s&&s.to==h&&s.mark.eq(f[v])?s.to=p:i.push(s=new yo(h,p,f[v])));a&&a.to==h?a.to=p:o.push(a=new zs(h,p,r))}}),i.forEach(l=>t.step(l)),o.forEach(l=>t.step(l))}function gI(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(r instanceof Cm){let c=s.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,n);for(let d=0;d<l.length;d++){let f=l[d],h;for(let p=0;p<i.length;p++){let m=i[p];m.step==o-1&&f.eq(i[p].style)&&(h=m)}h?(h.to=c,h.step=o):i.push({style:f,from:Math.max(a,e),to:c,step:o})}}}),i.forEach(s=>t.step(new yo(s.from,s.to,s.style)))}function v1(t,e,n,r=n.contentMatch,i=!0){let o=t.doc.nodeAt(e),s=[],a=e+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),d=a+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new Yn(a,d,Ge.empty));else{r=f;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new yo(a,d,c.marks[h]));if(i&&c.isText&&n.whitespace!="pre"){let h,p=/\r?\n|\r/g,m;for(;h=p.exec(c.text);)m||(m=new Ge(Ce.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new Yn(a+h.index,a+h.index+h[0].length,m))}}a=d}if(!r.validEnd){let l=r.fillBefore(Ce.empty,!0);t.replace(a,a,new Ge(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function vI(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Bc(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,o=0;;--r){let s=t.$from.node(r),a=t.$from.index(r)+i,l=t.$to.indexAfter(r)-o;if(r<t.depth&&s.canReplace(a,l,n))return r;if(r==0||s.type.spec.isolating||!vI(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function bI(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),a=i.after(o+1),l=s,c=a,d=Ce.empty,f=0;for(let m=o,v=!1;m>n;m--)v||r.index(m)>0?(v=!0,d=Ce.from(r.node(m).copy(d)),f++):l--;let h=Ce.empty,p=0;for(let m=o,v=!1;m>n;m--)v||i.after(m+1)<i.end(m)?(v=!0,h=Ce.from(i.node(m).copy(h)),p++):c++;t.step(new Qn(l,c,s,a,new Ge(d.append(h),f,p),d.size-f,!0))}function b1(t,e,n=null,r=t){let i=yI(t,e),o=i&&wI(r,e);return o?i.map(gk).concat({type:e,attrs:n}).concat(o.map(gk)):null}function gk(t){return{type:t,attrs:null}}function yI(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return n.canReplaceWith(r,i,s)?o:null}function wI(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:s}function kI(t,e,n){let r=Ce.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let a=n[s].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Ce.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new Qn(i,o,i,o,new Ge(r,0,0),n.length,!0))}function xI(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,a)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&_I(t.doc,t.mapping.slice(o).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?c=!1:!p&&m&&(c=!0)}c===!1&&e3(t,s,a,o),v1(t,t.mapping.slice(o).map(a,1),r,void 0,c===null);let d=t.mapping.slice(o),f=d.map(a,1),h=d.map(a+s.nodeSize,1);return t.step(new Qn(f,h,f+1,h-1,new Ge(Ce.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&$S(t,s,a,o),!1}})}function $S(t,e,n,r){e.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let l=t.mapping.slice(r).map(n+1+o+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function e3(t,e,n,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+o);t.replaceWith(s,s+1,e.type.schema.text(`
16
+ `))}})}function _I(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function CI(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Qn(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new Ge(Ce.from(s),0,0),1,!0))}function ts(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=n-2;c>o;c--,d--){let f=i.node(c),h=i.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(h,f.childCount),m=r&&r[d+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let v=r&&r[d]||f;if(!f.canReplace(h+1,f.childCount)||!v.type.validContent(p))return!1}let a=i.indexAfter(o),l=r&&r[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function SI(t,e,n=1,r){let i=t.doc.resolve(e),o=Ce.empty,s=Ce.empty;for(let a=i.depth,l=i.depth-n,c=n-1;a>l;a--,c--){o=Ce.from(i.node(a).copy(o));let d=r&&r[c];s=Ce.from(d?d.type.create(d.attrs,s):i.node(a).copy(s))}t.step(new Yn(e,e,new Ge(o.append(s),n,n),!0))}function aa(t,e){let n=t.resolve(e),r=n.index();return t3(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function EI(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function t3(t,e){return!!(t&&e&&!t.isLeaf&&EI(t,e))}function Sm(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let o,s,a=r.index(i);if(i==r.depth?(o=r.nodeBefore,s=r.nodeAfter):n>0?(o=r.node(i+1),a++,s=r.node(i).maybeChild(a)):(o=r.node(i).maybeChild(a-1),s=r.node(i+1)),o&&!o.isTextblock&&t3(o,s)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function AI(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),s=o.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let a=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);e3(t,d.node(),d.before(),a)}s.inlineContent&&v1(t,e+n-1,s,o.node().contentMatchAt(o.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new Yn(c,l.map(e+n,-1),Ge.empty,!0)),r===!0){let d=t.doc.resolve(c);$S(t,d.node(),d.before(),t.steps.length)}return t}function TI(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function n3(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let s=r.depth;s>=0;s--){let a=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.index(s)+(a>0?1:0),c=r.node(s),d=!1;if(o==1)d=c.canReplace(l,l,i);else{let f=c.contentMatchAt(l).findWrapping(i.firstChild.type);d=f&&c.canReplaceWith(l,l,f[0])}if(d)return a==0?r.pos:a<0?r.before(s+1):r.after(s+1)}return null}function Em(t,e,n=e,r=Ge.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return r3(i,o,r)?new Yn(e,n,r):new MI(i,o,r).fit()}function r3(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class MI{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Ce.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=Ce.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,a=i.depth;for(;s&&a&&o.childCount==1;)o=o.firstChild.content,s--,a--;let l=new Ge(o,s,a);return e>-1?new Qn(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Yn(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Hg(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,f=null;if(n==1&&(s?c.matchType(s.type)||(f=c.fillBefore(Ce.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:f};if(n==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:d};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Hg(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ge(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Hg(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new Ge(bu(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new Ge(bu(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let v=0;v<o.length;v++)this.openFrontierNode(o[v]);let s=this.unplaced,a=r?r.content:s.content,l=s.openStart-e,c=0,d=[],{match:f,type:h}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}let p=a.size+e-(s.content.size-s.openEnd);for(;c<a.childCount;){let v=a.child(c),g=f.matchType(v.type);if(!g)break;c++,(c>1||l==0||v.content.size)&&(f=g,d.push(i3(v.mark(h.allowedMarks(v.marks)),c==1?l:0,c==a.childCount?p:-1)))}let m=c==a.childCount;m||(p=-1),this.placed=yu(this.placed,n,Ce.from(d)),this.frontier[n].match=f,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,g=a;v<p;v++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=m?e==0?Ge.empty:new Ge(bu(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new Ge(bu(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Vg(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=Vg(e,n,i,r,o);if(s){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=Vg(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=yu(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=yu(this.placed,this.depth,Ce.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ce.empty,!0);n.childCount&&(this.placed=yu(this.placed,this.frontier.length,n))}}function bu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(bu(t.firstChild.content,e-1,n)))}function yu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(yu(t.lastChild.content,e-1,n)))}function Hg(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function i3(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,i3(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(Ce.empty,!0)))),t.copy(r)}function Vg(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!DI(n,o.content,s)?a:null}function DI(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function OI(t){return t.spec.defining||t.spec.definingForContent}function II(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(r3(i,o,r))return t.step(new Yn(e,n,r));let s=s3(i,o);s[s.length-1]==0&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let h=i.depth,p=i.pos-1;h>0;h--,p--){let m=i.node(h).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;s.indexOf(h)>-1?a=h:i.before(h)==p&&s.splice(1,0,-h)}let l=s.indexOf(a),c=[],d=r.openStart;for(let h=r.content,p=0;;p++){let m=h.firstChild;if(c.push(m),p==r.openStart)break;h=m.content}for(let h=d-1;h>=0;h--){let p=c[h],m=OI(p.type);if(m&&!p.sameMarkup(i.node(Math.abs(a)-1)))d=h;else if(m||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+d+1)%(r.openStart+1),m=c[p];if(m)for(let v=0;v<s.length;v++){let g=s[(v+l)%s.length],y=!0;g<0&&(y=!1,g=-g);let C=i.node(g-1),_=i.index(g-1);if(C.canReplaceWith(_,_,m.type,m.marks))return t.replace(i.before(g),y?o.after(g):n,new Ge(o3(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let h=s.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>f));h--){let p=s[h];p<0||(e=i.before(p),n=o.after(p))}}function o3(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(o3(o.content,e+1,n,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(Ce.empty,!0))}return t}function RI(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=TI(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ge(Ce.from(r),0,0))}function NI(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=s3(r,i);for(let s=0;s<o.length;s++){let a=o[s],l=s==o.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return t.delete(r.start(a),i.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return t.delete(r.before(a),i.after(a))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function s3(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(o<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class Hl extends br{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return On.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return On.fromReplace(e,this.pos,this.pos+1,new Ge(Ce.from(i),0,n.isLeaf?0:1))}getMap(){return ni.empty}invert(e){return new Hl(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Hl(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Hl(n.pos,n.attr,n.value)}}br.jsonID("attr",Hl);class rd extends br{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return On.ok(r)}getMap(){return ni.empty}invert(e){return new rd(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new rd(n.attr,n.value)}}br.jsonID("docAttr",rd);let yc=class extends Error{};yc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};yc.prototype=Object.create(Error.prototype);yc.prototype.constructor=yc;yc.prototype.name="TransformError";class y1{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nd}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new yc(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((o,s,a,l)=>{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Ge.empty){let i=Em(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ge(Ce.from(r),0,0))}delete(e,n){return this.replace(e,n,Ge.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return II(this,e,n,r),this}replaceRangeWith(e,n,r){return RI(this,e,n,r),this}deleteRange(e,n){return NI(this,e,n),this}lift(e,n){return bI(this,e,n),this}join(e,n=1){return AI(this,e,n),this}wrap(e,n){return kI(this,e,n),this}setBlockType(e,n=e,r,i=null){return xI(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return CI(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Hl(e,n,r)),this}setDocAttribute(e,n){return this.step(new rd(e,n)),this}addNodeMark(e,n){return this.step(new Bs(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof en)n.isInSet(r.marks)&&this.step(new Ya(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Ya(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,n=1,r){return SI(this,e,n,r),this}addMark(e,n,r){return mI(this,e,n,r),this}removeMark(e,n,r){return gI(this,e,n,r),this}clearIncompatible(e,n,r){return v1(this,e,n,r),this}}const Ug=Object.create(null);class gt{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new a3(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Ge.empty){let r=n.content.lastChild,i=null;for(let a=0;a<n.openEnd;a++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:l,$to:c}=s[a],d=e.mapping.slice(o);e.replaceRange(d.map(l.pos),d.map(c.pos),a?Ge.empty:n),a==0&&yk(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:a}=i[o],l=e.mapping.slice(r),c=l.map(s.pos),d=l.map(a.pos);o?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),yk(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new ut(e):Tl(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=n<0?Tl(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Tl(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ur(e.node(0))}static atStart(e){return Tl(e,e,0,0,1)||new Ur(e)}static atEnd(e){return Tl(e,e,e.content.size,e.childCount,-1)||new Ur(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ug[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ug)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ug[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ut.between(this.$anchor,this.$head).getBookmark()}}gt.prototype.visible=!0;class a3{constructor(e,n){this.$from=e,this.$to=n}}let vk=!1;function bk(t){!vk&&!t.parent.inlineContent&&(vk=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ut extends gt{constructor(e,n=e){bk(e),bk(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return gt.near(r);let i=e.resolve(n.map(this.anchor));return new ut(i.parent.inlineContent?i:r,r)}replace(e,n=Ge.empty){if(super.replace(e,n),n==Ge.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ut&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Am(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ut(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=gt.findFrom(n,r,!0)||gt.findFrom(n,-r,!0);if(o)n=o.$head;else return gt.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(gt.findFrom(e,-r,!0)||gt.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new ut(e,n)}}gt.jsonID("text",ut);class Am{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Am(e.map(this.anchor),e.map(this.head))}resolve(e){return ut.between(e.resolve(this.anchor),e.resolve(this.head))}}class ft extends gt{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=e.resolve(i);return r?gt.near(o):new ft(o)}content(){return new Ge(Ce.from(this.node),0,0)}eq(e){return e instanceof ft&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new w1(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ft(e.resolve(n.anchor))}static create(e,n){return new ft(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ft.prototype.visible=!1;gt.jsonID("node",ft);class w1{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Am(r,r):new w1(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ft.isSelectable(r)?new ft(n):gt.near(n)}}class Ur extends gt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ge.empty){if(n==Ge.empty){e.delete(0,e.doc.content.size);let r=gt.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ur(e)}map(e){return new Ur(e)}eq(e){return e instanceof Ur}getBookmark(){return PI}}gt.jsonID("all",Ur);const PI={map(){return this},resolve(t){return new Ur(t)}};function Tl(t,e,n,r,i,o=!1){if(e.inlineContent)return ut.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&ft.isSelectable(a))return ft.create(t,n-(i<0?a.nodeSize:0))}else{let l=Tl(t,a,n+i,i<0?a.childCount:0,i,o);if(l)return l}n+=a.nodeSize*i}return null}function yk(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Yn||i instanceof Qn))return;let o=t.mapping.maps[r],s;o.forEach((a,l,c,d)=>{s==null&&(s=d)}),t.setSelection(gt.near(t.doc.resolve(s),n))}const wk=1,Of=2,kk=4;let LI=class extends y1{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|wk)&~Of,this.storedMarks=null,this}get selectionSet(){return(this.updated&wk)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Of,this}ensureMarks(e){return en.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Of)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Of,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||en.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(gt.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=kk,this}get scrolledIntoView(){return(this.updated&kk)>0}};function xk(t,e){return!e||!t?t:t.bind(e)}class wu{constructor(e,n,r){this.name=e,this.init=xk(n.init,r),this.apply=xk(n.apply,r)}}const FI=[new wu("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new wu("selection",{init(t,e){return t.selection||gt.atStart(e.doc)},apply(t){return t.selection}}),new wu("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new wu("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class jg{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=FI.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new wu(r.key,r.spec.state,r))})}}class Nl{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let a=this.config.plugins[s];if(a.spec.appendTransaction){let l=i?i[s].n:0,c=i?i[s].state:this,d=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,c,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),o=!0}i&&(i[s]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Nl(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new LI(this)}static create(e){let n=new jg(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Nl(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new jg(this.schema,e.plugins),r=n.fields,i=new Nl(n);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new jg(e.schema,e.plugins),o=new Nl(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Ks.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=gt.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){o[s.name]=c.fromJSON.call(l,e,n[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function l3(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=l3(i,e,{})),n[r]=i}return n}class Vt{constructor(e){this.spec=e,this.props={},e.props&&l3(e.props,this,this.props),this.key=e.key?e.key.key:c3("plugin")}getState(e){return e[this.key]}}const qg=Object.create(null);function c3(t){return t in qg?t+"$"+ ++qg[t]:(qg[t]=0,t+"$")}class Yt{constructor(e="key"){this.key=c3(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const np=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"? or Ctrl+/",description:"Show keyboard shortcuts"},{keys:"Ctrl+Tab",description:"Next document tab"},{keys:"Ctrl+Shift+Tab",description:"Previous document tab"},{keys:"Ctrl+1 – Ctrl+9",description:"Jump to tab by number"},{keys:"Ctrl+Alt+1",description:"Heading 1"},{keys:"Ctrl+Alt+2",description:"Heading 2"},{keys:"Ctrl+Alt+3",description:"Heading 3"},{keys:"Ctrl+Alt+4",description:"Heading 4"},{keys:"Ctrl+Alt+5",description:"Heading 5"},{keys:"Ctrl+Alt+6",description:"Heading 6"}];function Bv(t){const e=[];return t.state.doc.descendants((n,r)=>{n.type.name==="heading"&&n.attrs.level<=3&&e.push({text:n.textContent,level:n.attrs.level,pos:r})}),e}var zI=T('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>'),BI=T('<li data-testid="palette-empty" style="padding: var(--tandem-space-3) var(--tandem-space-4); font-size: var(--tandem-text-sm); color: var(--tandem-fg-faint); font-style: italic;"> </li>'),HI=T('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>'),VI=T('<span style="font-size: var(--tandem-text-sm);"> </span> <!>',1),UI=T(`<span style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="
17
+ font-size: var(--tandem-text-xs);
18
+ color: var(--tandem-fg-subtle);
19
+ font-family: var(--tandem-font-mono);
20
+ min-width: 20px;
21
+ "> </span> <span> </span></span>`),jI=T('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>'),qI=T('<span style="display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0;"><span style="font-size: var(--tandem-text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></span> <span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); flex-shrink: 0; margin-left: var(--tandem-space-2);"> </span>',1),WI=T('<span style="font-size: var(--tandem-text-sm);"> </span> <span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>',1),KI=T('<li role="option"><!></li>'),GI=T(`<div role="presentation" class="palette-scrim svelte-gunx66" style="
22
+ position: fixed; inset: 0;
23
+ background: rgba(0,0,0,0.4);
24
+ backdrop-filter: blur(2px);
25
+ z-index: var(--tandem-z-above-titlebar);
26
+ display: flex; align-items: flex-start; justify-content: center;
27
+ padding-top: 15vh;
28
+ "><div data-testid="command-palette" role="dialog" tabindex="-1" aria-modal="true" aria-label="Command palette" class="palette-modal svelte-gunx66" style="
29
+ width: 640px; max-width: 92vw;
30
+ background: var(--tandem-surface);
31
+ border: 1px solid var(--tandem-border);
32
+ border-radius: var(--tandem-r-5);
33
+ box-shadow: var(--tandem-shadow-4);
34
+ overflow: hidden;
35
+ display: flex; flex-direction: column;
36
+ "><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--tandem-fg-faint)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" style="flex-shrink: 0;"><circle cx="11" cy="11" r="7"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg> <input data-testid="palette-input" type="text" aria-label="Search commands" aria-controls="palette-results" style="
37
+ flex: 1; min-width: 0; padding: 6px 0;
38
+ font-size: var(--tandem-text-md); color: var(--tandem-fg);
39
+ background: transparent; border: none; outline: none;
40
+ "/> <span class="palette-kbd svelte-gunx66" aria-hidden="true">Esc</span></div> <!></div> <ul id="palette-results" role="listbox" aria-label="Results" class="tandem-scroll-fade-y" style="max-height: 400px; overflow-y: auto; padding: var(--tandem-space-1); list-style: none; margin: 0;"><!></ul> <div style="
41
+ padding: var(--tandem-space-2) var(--tandem-space-4);
42
+ border-top: 1px solid var(--tandem-border);
43
+ background: var(--tandem-surface-muted);
44
+ display: flex; align-items: center; gap: var(--tandem-space-3);
45
+ font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);
46
+ "><span><kbd class="palette-kbd svelte-gunx66">#</kbd> headings</span> <span><kbd class="palette-kbd svelte-gunx66">@</kbd> annotations</span> <span><kbd class="palette-kbd svelte-gunx66">?</kbd> shortcuts</span> <span><kbd class="palette-kbd svelte-gunx66">&gt;</kbd> commands</span></div></div></div>`);function ZI(t,e){nt(e,!0);let n=Ze(e,"editor",3,null),r=Ze(e,"annotations",19,()=>[]),i=F(""),o=F(0),s=F(null);const a=["#","@","?",">"],l=L(()=>a.find(M=>u(i).startsWith(M))??null),c=L(()=>(u(l)?u(i).slice(1):u(i)).trim().toLowerCase()),d=L(()=>{var I;if(u(l)!==null&&u(l)!==">")return[];const M=Yh(),R=u(c),D=[];for(const H of M.values())(!R||H.label.toLowerCase().includes(R)||H.group.toLowerCase().includes(R)||(((I=H.shortcut)==null?void 0:I.toLowerCase().includes(R))??!1))&&D.push({kind:"action",id:H.id,action:H});return D}),f=L(()=>{if(u(l)!=="#")return[];const M=n();if(!M||M.isDestroyed)return[];const R=u(c);return Bv(M).filter(D=>!R||D.text.toLowerCase().includes(R)).map((D,I)=>({kind:"heading",id:`heading-${I}`,...D}))}),h=L(()=>{if(u(l)!=="@")return[];const M=u(c);return r().filter(R=>{var D;return M?R.content.toLowerCase().includes(M)||((D=R.textSnapshot)==null?void 0:D.toLowerCase().includes(M)):!0}).slice(0,50).map(R=>({kind:"annotation",id:`annotation-${R.id}`,label:R.content?R.content.slice(0,60):"(no content)",snippet:R.textSnapshot??"",annotationType:R.type}))}),p=L(()=>{if(u(l)!=="?")return[];const M=u(c),R=Yh(),D=[];for(const I of R.values())I.shortcut&&(!M||I.label.toLowerCase().includes(M)||I.shortcut.toLowerCase().includes(M))&&D.push({kind:"shortcut",id:`shortcut-registry-${I.id}`,keys:I.shortcut,description:I.label,group:I.group});for(let I=0;I<np.length;I++){const H=np[I];(!M||H.description.toLowerCase().includes(M)||H.keys.toLowerCase().includes(M))&&D.push({kind:"shortcut",id:`shortcut-static-${I}`,keys:H.keys,description:H.description,group:"other"})}return D}),m=L(()=>[...u(d),...u(f),...u(h),...u(p)]);pe(()=>{u(m),b(o,0)}),pe(()=>{e.open&&(b(i,""),b(o,0),Promise.resolve().then(()=>{var M;return(M=u(s))==null?void 0:M.focus()}))}),zc(()=>{const M=R=>{R.key!=="Escape"||!e.open||(R.preventDefault(),R.stopPropagation(),y())};return window.addEventListener("keydown",M,{capture:!0}),()=>window.removeEventListener("keydown",M,{capture:!0})});const v={"#":"Search headings…","@":"Search annotations…","?":"Search shortcuts…",">":"Search commands…"},g=L(()=>u(l)?v[u(l)]:"Type a command, # headings, @ annotations, ? shortcuts…");function y(){e.onClose()}function C(M){var R;if(M.kind==="action")y(),M.action.run();else if(M.kind==="heading"){y();const D=n();if(!D||D.isDestroyed)return;const I=M.pos;try{const H=D.state.doc.resolve(I+1),z=ut.near(H);D.view.dispatch(D.state.tr.setSelection(z).scrollIntoView()),D.view.focus()}catch{}}else M.kind==="annotation"&&(y(),(R=e.onFocusAnnotation)==null||R.call(e,M.id.replace("annotation-","")))}function _(M){const R=u(m).length;if(M.key==="ArrowDown")M.preventDefault(),b(o,(u(o)+1)%Math.max(1,R));else if(M.key==="ArrowUp")M.preventDefault(),b(o,(u(o)-1+Math.max(1,R))%Math.max(1,R));else if(M.key==="Enter"){M.preventDefault();const D=u(m)[u(o)];D&&C(D)}else M.key==="Escape"&&(M.preventDefault(),y())}function S(M){M.target===M.currentTarget&&y()}var A=St(),O=Ae(A);{var E=M=>{var R=GI(),D=w(R),I=w(D),H=w(I),z=k(w(H),2);Dt(z,ve=>b(s,ve),()=>u(s));var Q=k(H,2);{var ie=ve=>{var De=zI(),ee=w(De);{var q=Se=>{var fe=fr("Searching document headings");x(Se,fe)};j(ee,Se=>{u(l)==="#"&&Se(q)})}var V=k(ee,2);{var re=Se=>{var fe=fr("Searching annotations");x(Se,fe)};j(V,Se=>{u(l)==="@"&&Se(re)})}var te=k(V,2);{var Z=Se=>{var fe=fr("Showing keyboard shortcuts");x(Se,fe)};j(te,Se=>{u(l)==="?"&&Se(Z)})}var ge=k(te,2);{var Ie=Se=>{var fe=fr("Filtering commands");x(Se,fe)};j(ge,Se=>{u(l)===">"&&Se(Ie)})}x(ve,De)};j(Q,ve=>{u(l)&&ve(ie)})}var me=k(I,2),le=w(me);{var ke=ve=>{var De=BI(),ee=w(De);W(()=>G(ee,u(l)==="#"?"No headings found":u(l)==="@"?"No annotations found":u(l)==="?"?"No shortcuts found":"No commands match")),x(ve,De)},ce=ve=>{var De=St(),ee=Ae(De);mt(ee,19,()=>u(m),q=>q.id,(q,V,re)=>{const te=L(()=>u(re)===u(o));var Z=KI(),ge=w(Z);{var Ie=X=>{var ye=VI(),Y=Ae(ye),se=w(Y),Te=k(Y,2);{var Re=ze=>{var Je=HI(),ue=w(Je);W(()=>G(ue,u(V).action.shortcut)),x(ze,Je)};j(Te,ze=>{u(V).action.shortcut&&ze(Re)})}W(()=>G(se,u(V).action.label)),x(X,ye)},Se=X=>{var ye=UI(),Y=w(ye),se=w(Y),Te=k(Y,2),Re=w(Te);W(()=>{G(se,`H${u(V).level??""}`),Pe(Te,`font-size: var(--tandem-text-sm); padding-left: calc(${u(V).level-1} * var(--tandem-space-2));`),G(Re,u(V).text)}),x(X,ye)},fe=X=>{var ye=qI(),Y=Ae(ye),se=w(Y),Te=w(se),Re=k(se,2);{var ze=Ne=>{var qe=jI(),Xe=w(qe);W(()=>G(Xe,`"${u(V).snippet??""}"`)),x(Ne,qe)};j(Re,Ne=>{u(V).snippet&&Ne(ze)})}var Je=k(Y,2),ue=w(Je);W(Ne=>{G(Te,u(V).label),G(ue,Ne)},[()=>u(V).annotationType.charAt(0).toUpperCase()+u(V).annotationType.slice(1)]),x(X,ye)},_e=X=>{var ye=WI(),Y=Ae(ye),se=w(Y),Te=k(Y,2),Re=w(Te);W(()=>{G(se,u(V).description),G(Re,u(V).keys)}),x(X,ye)};j(ge,X=>{u(V).kind==="action"?X(Ie):u(V).kind==="heading"?X(Se,1):u(V).kind==="annotation"?X(fe,2):u(V).kind==="shortcut"&&X(_e,3)})}W(()=>{U(Z,"id",`palette-item-${u(V).id}`),U(Z,"data-testid",`palette-item-${u(V).id}`),U(Z,"aria-selected",u(te)),Pe(Z,`
47
+ display: flex; align-items: center; justify-content: space-between;
48
+ padding: 8px var(--tandem-space-3);
49
+ border-radius: var(--tandem-r-3);
50
+ transition: background 80ms;
51
+ cursor: ${u(V).kind==="shortcut"?"default":"pointer"};
52
+ background: ${u(te)?"var(--tandem-accent-bg)":"transparent"};
53
+ color: ${u(te)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg)"};
54
+ `)}),P("click",Z,()=>C(u(V))),Qt("mouseenter",Z,()=>b(o,u(re),!0)),x(q,Z)}),x(ve,De)};j(le,ve=>{u(m).length===0?ve(ke):ve(ce,-1)})}qr(me,(ve,De)=>$t==null?void 0:$t(ve,De),()=>"y"),W(()=>{U(z,"placeholder",u(g)),U(z,"aria-activedescendant",u(m)[u(o)]?`palette-item-${u(m)[u(o)].id}`:void 0)}),P("click",R,S),P("keydown",R,ve=>{ve.key==="Escape"&&y()}),P("keydown",D,_),Hr(z,()=>u(i),ve=>b(i,ve)),x(M,R)};j(O,M=>{e.open&&M(E)})}x(t,A),rt()}lt(["click","keydown"]);var YI=T(`<div class="tandem-banner tandem-banner--error" role="status" aria-live="polite" data-testid="connection-banner"><span class="tandem-banner__icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 2l20 20"></path><path d="M5.16 5.26A6 6 0 008 17h11a4 4 0 00.74-7.93"></path><path d="M12 7a5 5 0 014.9 4"></path></svg></span> <span class="tandem-banner__message">We've lost the connection to the Tandem server. Please check that it's still running.</span> <button type="button" class="tandem-banner__cta" data-testid="connection-banner-retry">Retry now</button> <button type="button" class="tandem-banner__dismiss" aria-label="Dismiss connection banner"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>`);function JI(t,e){var n=YI(),r=k(w(n),4),i=k(r,2);P("click",r,function(...o){var s;(s=e.onRetry)==null||s.apply(this,o)}),P("click",i,function(...o){var s;(s=e.onDismiss)==null||s.apply(this,o)}),x(t,n)}lt(["click"]);function XI(t){return t?t.osSupported?t.coworkDetected?"normal":"undetected":"unsupported":"loading"}function QI(t){return t.claudeDesktopDetected??!1?(t.workspacesBlocked??0)>0?"blocked":"noWorkspacesYet":"noClaude"}function $I(t){switch(t.kind){case"adminDeclined":return"Tandem couldn't update Windows Firewall — that needs administrator rights, and Tandem doesn't run as admin. Nothing was changed, and your documents stay on this computer (the server is only reachable locally).";case"netshNotFound":return"Windows Firewall command (netsh) was not found on PATH. Confirm your Windows install is intact.";case"netshFailure":return`Windows Firewall command failed (exit ${t.exitCode}). Details: ${e8(t.stderrTail)}`;case"subnetDetectionFailed":return"Could not detect the Hyper-V / Cowork VM subnet. Is Claude Desktop Cowork actually set up on this machine?";case"adapterEnumerationFailed":return"Could not enumerate Hyper-V network adapters. Run Tandem as administrator or reboot to refresh the adapter list.";default:return`Unexpected firewall error (${t.kind}). Please restart Tandem.`}}function e8(t){const e=t.trim();return e.length===0?"(no output)":e.length<=200?e:`${e.slice(0,197)}...`}function k1(t){try{const e=JSON.parse(t);if(typeof e=="object"&&e!==null&&"kind"in e&&typeof e.kind=="string")try{return $I(e)}catch(n){return console.error("[cowork] firewallErrorHint failed for:",e,n),t}return t}catch{return t}}function Hre(t){switch(t){case"ok":return"Installed";case"alreadyPresent":return"Already installed";case"locked":return"Locked (retrying)";case"schemaDrift":return"Schema drift";case"insecureAcl":return"Insecure ACL";case"failed":return"Failed";case"notConfigured":return"Not configured"}}function Vre(t){switch(t){case"ok":case"alreadyPresent":return"success";case"locked":return"warning";case"schemaDrift":case"insecureAcl":case"failed":return"error";case"notConfigured":return"neutral"}}function Ure(t){const e=["failed","schemaDrift","insecureAcl","locked","notConfigured","alreadyPresent","ok"],n=[t.installedPlugins,t.knownMarketplaces,t.coworkSettings];for(const r of e)if(n.includes(r))return r;return"ok"}function u3(t,e){return!(!t||e||!t.osSupported||!t.coworkDetected||t.enabled)}function d3(){try{return localStorage.getItem(eS)==="true"}catch{return!1}}function t8(){try{localStorage.setItem(eS,"true")}catch{}}function Tt(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}function jre(t){let e=null;return{schedule(n){e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,n()},t)},cancel(){e!==null&&(clearTimeout(e),e=null)}}}const f3="Tauri runtime not available";async function hs(){try{return(await Zt(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Tt()&&console.error("[cowork] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(f3)))}}function n8(t){return t("cowork_get_status")}function x1(t,e){return t("cowork_toggle_integration",{enabled:e})}function qre(t){return t("cowork_rescan")}function Wre(t,e){return t("cowork_set_lan_ip_override",{enabled:e})}function r8(t){return t("cowork_retry_admin_elevation")}function _1(t){let e=F(null),n=F(!1),r=F(null),i=null,o=!1,s=!0,a=null;Dn(()=>{s=!1,a!==null&&(clearInterval(a),a=null)});const l=async()=>{if(o){s&&b(n,!1);return}const c=i;if(c)try{const d=await n8(c);if(!s)return;b(e,d,!0),b(r,null)}catch(d){if(!s)return;const f=d instanceof Error?d.message:String(d);if(f===f3){o=!0,a!==null&&(clearInterval(a),a=null),b(n,!1);return}b(r,f,!0)}finally{s&&b(n,!1)}};return pe(()=>{if(!t()){b(n,!1);return}let d=!1;return hs().then(f=>{if(!d)return i=f,b(n,!0),l()}).catch(f=>{if(d)return;const h=f instanceof Error?f.message:String(f);b(r,h,!0),b(n,!1)}),a=setInterval(()=>{d||o||l()},ND),()=>{d=!0,a!==null&&(clearInterval(a),a=null)}}),{get status(){return u(e)},get loading(){return u(n)},get error(){return u(r)},refetch:l}}var i8=T(`<div class="cad-toast svelte-cbdwov" data-testid="cowork-admin-declined-status-error" role="alert">Cowork status check failed: unable to determine if admin elevation was declined. Please
55
+ restart Tandem to restore normal operation.</div>`),o8=T('<div class="cad-error svelte-cbdwov" data-testid="cowork-admin-declined-error" role="alert"> </div>'),s8=T('<div class="cad-warning-banner svelte-cbdwov" data-testid="cowork-admin-declined-confirm-disable"><div class="cad-confirm-heading svelte-cbdwov">Disable Cowork integration?</div> <div class="cad-confirm-body svelte-cbdwov">The deny rule will remain in place. You can re-enable Cowork later from Settings.</div> <div class="cad-actions svelte-cbdwov"><button class="cad-btn cad-btn--destructive svelte-cbdwov" data-testid="cowork-admin-declined-disable-confirm-btn" type="button">Disable</button> <button class="cad-btn cad-btn--ghost svelte-cbdwov" data-testid="cowork-admin-declined-disable-cancel-btn" type="button">Cancel</button></div></div>'),a8=T('<div class="cad-actions cad-actions--right svelte-cbdwov"><button class="cad-btn cad-btn--ghost cad-btn--lg svelte-cbdwov" data-testid="cowork-admin-declined-disable-btn" type="button">Disable Cowork</button> <button class="cad-btn cad-btn--primary cad-btn--lg svelte-cbdwov" data-testid="cowork-admin-declined-retry-btn" type="button">Retry with admin</button></div>'),l8=T(`<div class="cad-backdrop svelte-cbdwov" data-testid="cowork-admin-declined-backdrop"><div class="cad-dialog svelte-cbdwov" data-testid="cowork-admin-declined-modal" role="dialog" aria-modal="true" aria-labelledby="cowork-admin-declined-heading"><h2 class="cad-heading svelte-cbdwov" id="cowork-admin-declined-heading">Admin permission required</h2> <div class="cad-description svelte-cbdwov">Cowork integration requires Windows admin permission to configure firewall rules. Without
56
+ it, Tandem can't safely be reached from inside the Cowork VM. Port 3479 is currently
57
+ blocked by a deny rule to protect your machine.</div> <!> <!></div></div>`);function c8(t,e){nt(e,!0);const n='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',r=_1(()=>!0),i=L(()=>{var g;return((g=r.status)==null?void 0:g.uacDeclined)===!0});let o=F(void 0),s=F(!1),a=F(!1),l=F(null);pe(()=>{if(!u(i))return;const g=typeof document<"u"?document.title:null;return typeof document<"u"&&!document.title.startsWith("⚠")&&(document.title=`⚠ ${document.title}`),()=>{typeof document<"u"&&g!==null&&(document.title=g)}}),pe(()=>{if(!u(i))return;const g=y=>{if(y.key!=="Tab"||!u(o))return;const C=u(o).querySelectorAll(n);if(C.length===0)return;const _=C[0],S=C[C.length-1],A=document.activeElement;if(!u(o).contains(A)){y.preventDefault(),_.focus();return}y.shiftKey&&A===_?(y.preventDefault(),S.focus()):!y.shiftKey&&A===S&&(y.preventDefault(),_.focus())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)}),pe(()=>{var g;u(i)&&((g=u(o))==null||g.focus())});async function c(g,y){b(a,!0),b(l,null);try{const C=await hs();await g(C)}catch(C){const _=C instanceof Error?C.message:String(C),S=k1(_);b(l,`${y}: ${S}`)}finally{b(a,!1)}}async function d(){await c(async g=>{await r8(g),await r.refetch()},"Retry failed")}async function f(){await c(async g=>{await x1(g,!1),await r.refetch()},"Failed to disable Cowork"),b(s,!1)}var h=St(),p=Ae(h);{var m=g=>{var y=i8();x(g,y)},v=g=>{var y=l8(),C=w(y);U(C,"tabindex",-1);var _=k(w(C),4);{var S=M=>{var R=o8(),D=w(R);W(()=>G(D,u(l))),x(M,R)};j(_,M=>{u(l)&&M(S)})}var A=k(_,2);{var O=M=>{var R=s8(),D=k(w(R),4),I=w(D),H=k(I,2);W(()=>{I.disabled=u(a),H.disabled=u(a)}),P("click",I,()=>void f()),P("click",H,()=>{b(s,!1)}),x(M,R)},E=M=>{var R=a8(),D=w(R),I=k(D,2);W(()=>{D.disabled=u(a),I.disabled=u(a)}),P("click",D,()=>{b(s,!0)}),P("click",I,()=>void d()),x(M,R)};j(A,M=>{u(s)?M(O):M(E,-1)})}Dt(C,M=>b(o,M),()=>u(o)),x(g,y)};j(p,g=>{r.error&&!r.status?g(m):u(i)&&g(v,1)})}x(t,h),rt()}lt(["click"]);var u8=T('<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>'),d8=T('<div class="tandem-banner tandem-banner--warning" role="status" aria-live="polite" data-testid="docx-conflict-banner"><span class="tandem-banner__message"> </span> <!> <button type="button" class="tandem-banner__cta" data-testid="docx-conflict-keep-btn"> </button> <button type="button" class="tandem-banner__cta" data-testid="docx-conflict-reload-btn"> </button></div>');function f8(t,e){nt(e,!0);let n=F(null),r=F(null),i=F(null);pe(()=>{const d=e.ydoc.getMap(Vh),f=()=>{b(n,d.get(Iw)??null,!0)};f();const h=p=>{p.keysChanged.has(Iw)&&f()};return d.observe(h),()=>{d.unobserve(h),b(n,null),b(i,null),b(r,null)}});const o=L(()=>u(n)?u(n).kind==="external-edit"?`${e.fileName} changed on disk while you have unsaved edits. Keeping your edits means your next save overwrites the disk changes; reloading discards your unsaved edits.`:u(n).diskChanged?`Unsaved edits for ${e.fileName} were restored from your last session, but the file also changed on disk. Keep your restored edits, or reload the file from disk (discards them)?`:`Unsaved edits for ${e.fileName} were restored from your last session. Keep them, or reload fresh from the file on disk (discards them)?`:"");async function s(d){if(!u(r)){b(r,d,!0),b(i,null);try{const f=await fetch(`${nn}${SO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId,choice:d})});if(!f.ok){const h=await f.json().catch(()=>null);b(i,(h==null?void 0:h.message)??`Request failed (HTTP ${f.status}).`,!0)}}catch{b(i,"Could not reach the server.")}finally{b(r,null)}}}var a=St(),l=Ae(a);{var c=d=>{var f=d8(),h=w(f),p=w(h),m=k(h,2);{var v=S=>{var A=u8(),O=w(A);W(()=>G(O,u(i))),x(S,A)};j(m,S=>{u(i)&&S(v)})}var g=k(m,2),y=w(g),C=k(g,2),_=w(C);W(()=>{G(p,u(o)),g.disabled=u(r)!==null,G(y,u(r)==="keep"?"Keeping…":"Keep my edits"),C.disabled=u(r)!==null,G(_,u(r)==="reload"?"Reloading…":"Reload from file")}),P("click",g,()=>s("keep")),P("click",C,()=>s("reload")),x(d,f)};j(l,d=>{u(n)&&d(c)})}x(t,a),rt()}lt(["click"]);var h8=T(`<div class="empty-illus svelte-16uow3k" aria-hidden="true"><svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="13" cy="36" r="9" stroke="var(--tandem-fg-faint)" stroke-width="1.5" fill="var(--tandem-surface)"></circle><circle cx="13" cy="36" r="3.5" fill="var(--tandem-fg-faint)"></circle><circle cx="59" cy="36" r="9" stroke="var(--tandem-border-strong)" stroke-width="1.5" fill="var(--tandem-surface-muted)"></circle><circle cx="59" cy="36" r="3.5" fill="var(--tandem-border-strong)"></circle><line x1="22" y1="36" x2="30" y2="36" stroke="var(--tandem-fg-faint)" stroke-width="1.5" stroke-linecap="round"></line><line x1="42" y1="36" x2="50" y2="36" stroke="var(--tandem-border-strong)" stroke-width="1.5" stroke-linecap="round"></line><line x1="32" y1="31" x2="40" y2="41" stroke="var(--tandem-error)" stroke-width="1.8" stroke-linecap="round"></line><line x1="40" y1="31" x2="32" y2="41" stroke="var(--tandem-error)" stroke-width="1.8" stroke-linecap="round"></line></svg></div> <p class="empty-heading svelte-16uow3k">Server unavailable</p> <p class="empty-sub svelte-16uow3k">Tandem can't reach its sync server. Make sure it's running locally.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-retry">Retry</button> <button class="empty-link svelte-16uow3k" data-testid="empty-state-open-settings">Open settings</button></div>`,1),p8=T('<p class="empty-sub empty-sub-secondary svelte-16uow3k">No AI is connected yet.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-connect-ai" data-ai-chip="connect">Connect AI</button></div>',1),m8=T('<p class="empty-sub empty-sub-secondary svelte-16uow3k">Claude Code has stopped.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-connect-ai" data-ai-chip="restart">Restart Claude Code</button></div>',1),g8=T('<p class="empty-sub empty-sub-secondary svelte-16uow3k">Tandem works alongside Claude (the default integration) or any MCP-capable AI client.</p>'),v8=T('<div class="empty-illus svelte-16uow3k" aria-hidden="true"><svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="11" y="10" width="36" height="46" rx="3" stroke="var(--tandem-border-strong)" stroke-width="1.2" fill="var(--tandem-surface-muted)"></rect><rect x="20" y="17" width="36" height="46" rx="3" stroke="var(--tandem-fg-faint)" stroke-width="1.5" fill="var(--tandem-surface)"></rect><line x1="27" y1="27" x2="49" y2="27" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><line x1="27" y1="33" x2="46" y2="33" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><line x1="27" y1="39" x2="49" y2="39" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><line x1="27" y1="45" x2="44" y2="45" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><circle cx="56" cy="16" r="9" fill="var(--tandem-surface)" stroke="var(--tandem-fg-faint)" stroke-width="1.5"></circle><line x1="56" y1="11.5" x2="56" y2="20.5" stroke="var(--tandem-fg-faint)" stroke-width="1.5" stroke-linecap="round"></line><line x1="51.5" y1="16" x2="60.5" y2="16" stroke="var(--tandem-fg-faint)" stroke-width="1.5" stroke-linecap="round"></line></svg></div> <p class="empty-heading svelte-16uow3k">Nothing open yet</p> <p class="empty-sub svelte-16uow3k">Click + in the tab bar, or drop a Markdown file here.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-open-file">Open file…</button></div> <!>',1),b8=T('<div class="empty-state svelte-16uow3k"><!></div>');function y8(t,e){nt(e,!0);let n=Ze(e,"aiChip",3,null),r=F(!1);pe(()=>{if(e.connected){b(r,!1);return}const l=setTimeout(()=>{b(r,!0)},_D);return()=>clearTimeout(l)});var i=b8(),o=w(i);{var s=l=>{var c=h8(),d=k(Ae(c),6),f=w(d),h=k(f,2);P("click",f,function(...p){var m;(m=e.onRetry)==null||m.apply(this,p)}),P("click",h,function(...p){var m;(m=e.onOpenSettings)==null||m.apply(this,p)}),x(l,c)},a=l=>{var c=v8(),d=k(Ae(c),6),f=w(d),h=k(d,2);{var p=g=>{var y=p8(),C=k(Ae(y),2),_=w(C);P("click",_,function(...S){var A;(A=e.onConnectAi)==null||A.apply(this,S)}),x(g,y)},m=g=>{var y=m8(),C=k(Ae(y),2),_=w(C);P("click",_,function(...S){var A;(A=e.onRestartClaude)==null||A.apply(this,S)}),x(g,y)},v=g=>{var y=g8();x(g,y)};j(h,g=>{e.connected&&n()==="connect"?g(p):e.connected&&n()==="restart"?g(m,1):e.connected&&g(v,2)})}P("click",f,function(...g){var y;(y=e.onOpenFile)==null||y.apply(this,g)}),x(l,c)};j(o,l=>{u(r)?l(s):l(a,-1)})}x(t,i),rt()}lt(["click"]);async function ms(t,e={}){const{readOnly:n=!1,notFoundMessage:r="File not found.",failureMessage:i="Failed to open file."}=e;try{const o=await fetch(`${nn}${mO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:t,readOnly:n})});if(!o.ok){let s=i;try{const a=await o.json();a.message&&(s=a.message)}catch{}return o.status===404&&(s=r),{ok:!1,error:s}}return{ok:!0}}catch(o){return console.warn("[tandem] openServerPath failed:",o),{ok:!1,error:"Server unavailable."}}}const w8=Array.from(Zd).sort().map(t=>t.replace(/^\./,""));async function h3(){const{open:t}=await Zt(async()=>{const{open:r}=await import("./index-Dm_QtxGQ.js");return{open:r}},__vite__mapDeps([2,1])),e=await xS()??void 0,n=await t({multiple:!1,directory:!1,title:"Open file in Tandem",defaultPath:e,filters:[{name:"Documents",extensions:w8}]});return typeof n=="string"?n:null}async function k8(t={}){var r,i;let e;try{e=await h3()}catch(o){console.error("[tandem] native file picker unavailable:",o),(r=t.onError)==null||r.call(t,`File picker unavailable: ${o instanceof Error?o.message:o}`);return}if(!e)return;const n=await ms(e);if(!n.ok){(i=t.onError)==null||i.call(t,n.error);return}Jd(Yd(bc(),e))}async function x8(t){t.isTauri?await k8({onError:t.onError}):t.openModal()}async function p3(t,e){try{const n=await fetch(`${nn}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0,data:r.data??{}}:{ok:!1,error:r.message??"Request failed."}}catch(n){return console.warn("[tandem] sessions request failed:",n),{ok:!1,error:"Server unavailable."}}}async function _8(){var t;try{const e=await fetch(`${nn}${DO}`),n=await e.json().catch(()=>({}));return e.ok?{ok:!0,data:((t=n.data)==null?void 0:t.sessions)??[]}:{ok:!1,error:n.message??"Failed to load sessions."}}catch(e){return console.warn("[tandem] fetchSessions failed:",e),{ok:!1,error:"Server unavailable."}}}async function C8(t){return p3(OO,{filePath:t})}async function S8(){return p3(IO,{})}var E8=T('<input type="file" style="display: none;"/>'),A8=T('<p style="margin: 8px 0 0; font-size: 11px; color: var(--tandem-fg-subtle); text-align: center;">…or drop a file anywhere in the window</p>'),T8=T('<button type="button" style="background: none; border: none; padding: 6px 8px; border-radius: var(--tandem-r-2); cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 1px;"><span style="font-size: 13px; color: var(--tandem-fg);"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px;"> </span></button>'),M8=T('<div data-testid="recent-files-list" style="margin-top: 16px;"><div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;"><span style="font-size: 11px; color: var(--tandem-fg-subtle); text-transform: uppercase; letter-spacing: 0.05em;">Recent</span> <button data-testid="clear-recent-files" type="button" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline;">Clear all</button></div> <div class="tandem-scroll-fade-y" style="max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div></div>'),D8=T('<p data-testid="sessions-loading" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">Loading…</p>'),O8=T('<p data-testid="sessions-empty" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">No saved sessions.</p>'),I8=T('<div data-testid="session-row" style="display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: var(--tandem-r-2);"><button type="button" data-testid="session-reopen" style="flex: 1; min-width: 0; background: none; border: none; padding: 0; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 1px;"><span style="font-size: 13px; color: var(--tandem-fg);"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle);"> </span></button> <button type="button" data-testid="session-delete" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 14px; cursor: pointer; padding: 4px; line-height: 1;">×</button></div>'),R8=T('<div style="display: flex; justify-content: flex-end; margin: 6px 0;"><button data-testid="sessions-clear-all" type="button" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline;">Clear all</button></div> <div class="tandem-scroll-fade-y" style="max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div>',1),N8=T('<div data-testid="sessions-error" style="margin-top: 8px; padding: 8px 10px; font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-error-border);"> </div>'),P8=T("<!> <!>",1),L8=T('<div style="margin-top: 10px; padding: 8px 10px; font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-error-border);" data-testid="file-open-error"> </div>'),F8=T('<div role="dialog" aria-modal="true" aria-label="Open File" style="position: fixed; inset: 0; z-index: var(--tandem-z-above-titlebar); display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent);"><div style="background: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-5); box-shadow: var(--tandem-shadow-3); width: 440px; padding: 20px;" data-testid="file-open-dialog"><div style="display: flex; justify-content: space-between; margin-bottom: 16px;"><h3 style="margin: 0; font-size: 15px; font-weight: 600; color: var(--tandem-fg);">Open File</h3> <button class="modal-close svelte-ik1xhg" aria-label="Close">×</button></div> <button type="button" data-testid="file-open-browse"> </button> <!> <!> <!> <div data-testid="sessions-section" style="margin-top: 16px;"><button type="button" data-testid="sessions-toggle" style="width: 100%; background: none; border: none; padding: 0; cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: var(--tandem-fg-subtle);"><span style="font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;">Saved sessions</span> <span style="font-size: 11px;"> </span></button> <!></div> <!></div></div>');function z8(t,e){nt(e,!0);let n=F(null),r=F(!1),i=F(void 0),o=F(tt(tk(bc()))),s=F(tt([])),a=F(!1),l=F(!1),c=F(!1),d=F(null);async function f(){b(l,!0),b(d,null);const fe=await _8();fe.ok?(b(s,fe.data,!0),b(c,!0)):b(d,fe.error,!0),b(l,!1)}function h(){b(a,!u(a)),u(a)&&!u(c)&&!u(l)&&f()}async function p(fe){b(d,null);const _e=await C8(fe);_e.ok?b(s,u(s).filter(X=>X.filePath!==fe),!0):b(d,_e.error,!0)}async function m(){b(d,null);const fe=await S8();fe.ok?b(s,[],!0):b(d,fe.error,!0)}function v(fe){if(!fe)return"unknown";const _e=Date.now()-fe,X=Math.floor(_e/6e4);if(X<1)return"just now";if(X<60)return`${X}m ago`;const ye=Math.floor(X/60);return ye<24?`${ye}h ago`:`${Math.floor(ye/24)}d ago`}const y=Array.from(Zd).sort().join(",");function C(fe){const _e=Yd(bc(),fe);Jd(_e),b(o,tk(_e),!0)}function _(){d5(),b(o,[],!0)}async function S(fe){if(!u(r)){b(n,null),b(r,!0);try{const _e=await ms(fe);if(!_e.ok){b(n,_e.error,!0);return}C(fe),e.onClose()}finally{b(r,!1)}}}async function A(){if(!u(r))try{const fe=await h3();fe&&await S(fe)}catch(fe){b(n,`File picker unavailable: ${fe instanceof Error?fe.message:fe}`)}}async function O(fe){if(!u(r)){b(n,null),b(r,!0);try{const _e=await kS(fe),X=await fetch(`${nn}${sS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:fe.name,content:_e})}),ye=await X.json();if(!X.ok){b(n,ye.message??"Failed to open file",!0);return}e.onClose()}catch(_e){console.error("FileOpenDialog: upload failed",_e),_e instanceof SyntaxError?b(n,"Server returned an unexpected response"):_e instanceof TypeError?b(n,"Unexpected response format"):b(n,"Cannot reach server. Is it running?")}finally{b(r,!1)}}}function E(fe){var ye;const X=(ye=fe.target.files)==null?void 0:ye[0];X&&O(X)}function M(){var fe;Tt()?A():(fe=u(i))==null||fe.click()}var R=F8();U(R,"tabindex",-1);var D=w(R),I=w(D),H=k(w(I),2),z=k(I,2);MM(z);var Q=w(z),ie=k(z,2);{var me=fe=>{var _e=E8();Dt(_e,X=>b(i,X),()=>u(i)),W(()=>U(_e,"accept",y)),P("change",_e,E),x(fe,_e)},le=L(()=>!Tt());j(ie,fe=>{u(le)&&fe(me)})}var ke=k(ie,2);{var ce=fe=>{var _e=A8();x(fe,_e)},ve=L(()=>Tt());j(ke,fe=>{u(ve)&&fe(ce)})}var De=k(ke,2);{var ee=fe=>{var _e=M8(),X=w(_e),ye=k(w(X),2),Y=k(X,2);mt(Y,22,()=>u(o),se=>se,(se,Te,Re)=>{const ze=L(()=>Te.split(/[/\\]/)),Je=L(()=>u(ze).at(-1)??Te),ue=L(()=>u(ze).slice(0,-1).join("/")||"/");var Ne=T8(),qe=w(Ne),Xe=w(qe),ae=k(qe,2),de=w(ae);W(()=>{U(Ne,"data-testid",`recent-file-${u(Re)}`),G(Xe,u(Je)),G(de,u(ue))}),P("click",Ne,()=>S(Te)),Qt("mouseenter",Ne,xe=>{xe.currentTarget.style.background="var(--tandem-surface-muted)"}),Qt("mouseleave",Ne,xe=>{xe.currentTarget.style.background="transparent"}),x(se,Ne)}),qr(Y,(se,Te)=>$t==null?void 0:$t(se,Te),()=>"y"),P("click",ye,_),x(fe,_e)};j(De,fe=>{u(o).length>0&&fe(ee)})}var q=k(De,2),V=w(q),re=k(w(V),2),te=w(re),Z=k(V,2);{var ge=fe=>{var _e=P8(),X=Ae(_e);{var ye=ze=>{var Je=D8();x(ze,Je)},Y=ze=>{var Je=O8();x(ze,Je)},se=ze=>{var Je=R8(),ue=Ae(Je),Ne=w(ue),qe=k(ue,2);mt(qe,21,()=>u(s),Xe=>Xe.filePath,(Xe,ae)=>{const de=L(()=>u(ae).filePath.split(/[/\\]/)),xe=L(()=>u(de).at(-1)??u(ae).filePath),Le=L(()=>u(de).slice(0,-1).join("/")||"/");var it=I8(),ne=w(it),Ee=w(ne),B=w(Ee),$=k(Ee,2),we=w($),He=k($,2),Oe=w(He),K=k(ne,2);W(he=>{U(ne,"title",u(ae).filePath),G(B,u(xe)),G(we,u(Le)),G(Oe,`${he??""} · ${u(ae).annotationCount??""} annotation${u(ae).annotationCount===1?"":"s"}`),U(K,"aria-label",`Delete session for ${u(xe)}`)},[()=>v(u(ae).lastAccessed)]),P("click",ne,()=>S(u(ae).filePath)),P("click",K,()=>p(u(ae).filePath)),x(Xe,it)}),qr(qe,(Xe,ae)=>$t==null?void 0:$t(Xe,ae),()=>"y"),P("click",Ne,m),x(ze,Je)};j(X,ze=>{u(l)?ze(ye):u(s).length===0?ze(Y,1):ze(se,-1)})}var Te=k(X,2);{var Re=ze=>{var Je=N8(),ue=w(Je);W(()=>G(ue,u(d))),x(ze,Je)};j(Te,ze=>{u(d)&&ze(Re)})}x(fe,_e)};j(Z,fe=>{u(a)&&fe(ge)})}var Ie=k(q,2);{var Se=fe=>{var _e=L8(),X=w(_e);W(()=>G(X,u(n))),x(fe,_e)};j(Ie,fe=>{u(n)&&fe(Se)})}W(()=>{z.disabled=u(r),Pe(z,`width: 100%; padding: 12px; font-size: 14px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: ${u(r)?"wait":"pointer"}; background: ${u(r)?"var(--tandem-fg-subtle)":"var(--tandem-accent)"}; color: var(--tandem-accent-fg);`),G(Q,u(r)?"Opening…":"Browse…"),U(V,"aria-expanded",u(a)),G(te,u(a)?"▾":"▸")}),P("click",R,fe=>{fe.target===fe.currentTarget&&e.onClose()}),P("keydown",R,fe=>{fe.key==="Escape"&&e.onClose()}),P("click",H,function(...fe){var _e;(_e=e.onClose)==null||_e.apply(this,fe)}),P("click",z,M),P("click",V,h),x(t,R),rt()}lt(["click","keydown","change"]);var B8=T('<span style="font-size: 12px; font-family: ui-monospace, SFMono-Regular, monospace; white-space: nowrap;"><kbd style="display: inline-block; padding: 1px 6px; font-size: 12px; font-family: inherit; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom: 2px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); color: var(--tandem-fg); line-height: 1.5;"> </kbd></span> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),H8=T('<div style="margin-bottom: 18px;"><div style="font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tandem-fg-subtle); margin-bottom: 6px;"> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></div>'),V8=T('<span style="font-size: 12px; font-family: ui-monospace, SFMono-Regular, monospace; white-space: nowrap;"><kbd style="display: inline-block; padding: 1px 6px; font-size: 12px; font-family: inherit; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom: 2px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); color: var(--tandem-fg); line-height: 1.5;"> </kbd></span> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),U8=T(`<div role="presentation" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); display: flex; align-items: center; justify-content: center; z-index: var(--tandem-z-above-titlebar);" data-testid="help-modal"><div role="dialog" aria-modal="true" aria-label="Keyboard Shortcuts" tabindex="-1" class="tandem-scroll-fade-y" style="background-color: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-5); box-shadow: var(--tandem-shadow-3); padding: 24px 28px 20px; width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto; position: relative;"><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;"><h2 style="margin: 0; font-size: 16px; font-weight: 600; color: var(--tandem-fg);">Keyboard Shortcuts</h2> <button type="button" class="modal-close svelte-6zgoeu" aria-label="Close help" data-testid="help-modal-close">✕</button></div> <!> <div style="margin-bottom: 18px;"><div style="font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tandem-fg-subtle); margin-bottom: 6px;">Other</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></div> <div style="margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--tandem-border); font-size: 11px; color: var(--tandem-fg-subtle); text-align: center;">Press <kbd style="font-size: 11px; padding: 1px 4px; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); color: var(--tandem-fg-subtle);">?</kbd>, <kbd style="font-size: 11px; padding: 1px 4px; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); color: var(--tandem-fg-subtle);">Ctrl+/</kbd>,
58
+ or <kbd style="font-size: 11px; padding: 1px 4px; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); color: var(--tandem-fg-subtle);">Esc</kbd> to close</div></div></div>`);function j8(t,e){nt(e,!0);const n=L(()=>{const l=Yh(),c=e.effectiveShortcutLabels,d=new Map;for(const f of l.values()){if(!f.shortcut)continue;const h=uS[f.id],p=h&&(c==null?void 0:c.get(h))||f.shortcut,m=d.get(f.group)??[];m.push({keys:p,description:f.label}),d.set(f.group,m)}return CS.map(f=>({title:f.charAt(0).toUpperCase()+f.slice(1),rows:d.get(f)??[]})).filter(f=>f.rows.length>0)});let r=F(null),i=null;pe(()=>{if(!e.open)return;const l=Ct(()=>u(r));if(!l)return;i=document.activeElement,l.focus();const c=d=>{l&&!l.contains(d.target)&&l.focus()};return document.addEventListener("focusin",c),()=>{document.removeEventListener("focusin",c),i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),pe(()=>{if(!e.open)return;const l=c=>{c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),e.onClose())};return window.addEventListener("keydown",l,{capture:!0}),()=>window.removeEventListener("keydown",l,{capture:!0})});var o=St(),s=Ae(o);{var a=l=>{var c=U8(),d=w(c),f=w(d),h=k(w(f),2),p=k(f,2);mt(p,17,()=>u(n),g=>g.title,(g,y)=>{var C=H8(),_=w(C),S=w(_),A=k(_,2);mt(A,21,()=>u(y).rows,O=>O.description,(O,E)=>{var M=B8(),R=Ae(M),D=w(R),I=w(D),H=k(R,2),z=w(H);W(()=>{G(I,u(E).keys),G(z,u(E).description)}),x(O,M)}),W(()=>G(S,u(y).title)),x(g,C)});var m=k(p,2),v=k(w(m),2);mt(v,21,()=>np,g=>g.description,(g,y)=>{var C=V8(),_=Ae(C),S=w(_),A=w(S),O=k(_,2),E=w(O);W(()=>{G(A,u(y).keys),G(E,u(y).description)}),x(g,C)}),Dt(d,g=>b(r,g),()=>u(r)),qr(d,(g,y)=>$t==null?void 0:$t(g,y),()=>"y"),P("click",c,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),P("click",d,g=>g.stopPropagation()),P("keydown",d,g=>{if(g.key==="Escape"){e.onClose();return}if(g.stopPropagation(),g.key==="Tab"&&u(r)){const y=Array.from(u(r).querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(S=>!S.closest("[hidden]"));if(y.length===0){g.preventDefault();return}const C=y[0],_=y[y.length-1];g.shiftKey&&document.activeElement===C?(g.preventDefault(),_.focus()):!g.shiftKey&&document.activeElement===_&&(g.preventDefault(),C.focus())}}),P("click",h,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),x(l,c)};j(s,l=>{e.open&&l(a)})}x(t,o),rt()}lt(["click","keydown"]);const q8="/api/integrations/existing",W8="/api/integrations",K8="/api/integrations/apply",G8="/api/integrations/first-run-needed";function Z8(t){return`/api/integrations/secrets/${encodeURIComponent(t)}`}function Y8(t){return`/api/models/secrets/${encodeURIComponent(t)}`}const J8=3,X8="KEYCHAIN_UNAVAILABLE",Q8="/api/integrations/claude-cli-status",$8="/api/integrations/install-claude-code";function eR(t,e="",n=globalThis.fetch.bind(globalThis)){let r=F(null),i=F(!1),o=F(null),s=F(!1),a=F(null),l=!0;Dn(()=>{l=!1});const c=async h=>{try{const p=await n(`${e}${Q8}`);if(!l||h())return;if(!p.ok){b(o,`Could not check for Claude (status ${p.status}).`);return}const m=await p.json();if(!l||h())return;b(r,m.presence,!0),b(o,null)}catch(p){if(!l||h())return;b(o,p instanceof Error?p.message:String(p),!0)}finally{l&&!h()&&b(i,!1)}},d=async()=>{l&&(b(i,!0),b(a,null),await c(()=>!1))},f=async()=>{if(!l)return null;b(s,!0),b(a,null);try{const h=await n(`${e}${$8}`,{method:"POST"});if(!l)return null;if(!h.ok){const m=await h.json().catch(()=>null);return l&&b(a,tR(h.status,m),!0),null}const p=await h.json();return l?(b(r,p.presence,!0),p.presence==="NOT_INSTALLED"&&b(a,`The installer finished but Claude wasn't detected yet. Open a new terminal and click "Check again", or install Claude Code manually.`),p.presence):null}catch(h){return l&&b(a,h instanceof Error?h.message:String(h),!0),null}finally{l&&b(s,!1)}};return pe(()=>{if(!t()){b(i,!1);return}let h=!1;return b(i,!0),c(()=>h),()=>{h=!0}}),{get presence(){return u(r)},get loading(){return u(i)},get error(){return u(o)},get installing(){return u(s)},get installError(){return u(a)},install:f,refetch:d}}function tR(t,e){var i;const n=e??null;if((n==null?void 0:n.code)==="UNSUPPORTED_PLATFORM")return"Automatic install isn't available on this operating system. Install Claude Code manually, then check again.";if((n==null?void 0:n.code)==="INSTALL_IN_PROGRESS")return"An install is already in progress.";const r=(i=n==null?void 0:n.stderrTail)==null?void 0:i.trim();return r?`Install failed (exit ${typeof(n==null?void 0:n.exitCode)=="number"?n.exitCode:"?"}). ${r}`:(n==null?void 0:n.message)??`Install failed (status ${t}).`}const nR="Tauri runtime not available";async function rR(){try{return(await Zt(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Tt()&&console.error("[keychain] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(nR)))}}function iR(t,e,n){return t("keychain_set",{account:e,secret:n})}function oR(t,e){return t("keychain_delete",{account:e})}function sR(t={}){const e=t.fetchFn??((...i)=>globalThis.fetch(...i)),n=t.baseUrl??"",r=t.pathFor??Z8;return{async set(i,o){try{const s=await e(`${n}${r(i)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({secret:o})});if(s.status===503){const a=await s.json().catch(()=>null);if((a==null?void 0:a.code)===X8)return{status:"unavailable"}}return s.ok?{status:"ok"}:{status:"error",message:`HTTP ${s.status}`}}catch(s){return{status:"error",message:s instanceof Error?s.message:String(s)}}},async delete(i){await e(`${n}${r(i)}`,{method:"DELETE"}).catch(()=>{})}}}const aR=["keychain-init","Platform secure storage failure","Couldn't access platform secure storage"];function lR(t){return aR.some(e=>t.includes(e))}function cR(t={}){const e=()=>t.invoke?Promise.resolve(t.invoke):rR();return{async set(n,r){try{const i=await e();return await iR(i,n,r),{status:"ok"}}catch(i){const o=i instanceof Error?i.message:String(i);return lR(o)?{status:"unavailable"}:{status:"error",message:o}}},async delete(n){try{const r=await e();await oR(r,n)}catch{}}}}function m3(t={}){return t.force==="tauri"||t.force!=="http"&&Tt()?cR({invoke:t.invoke}):sR({fetchFn:t.fetchFn,baseUrl:t.baseUrl,pathFor:t.pathFor})}function C1(t){return t.tandemValidation!==void 0&&t.tandemValidation.status!=="valid"}function g3(t){return(t.status==="ok"||t.status==="missing")&&!C1(t)}function uR(t){const e=crypto.randomUUID().replace(/-/g,"").slice(0,12);return`${t}-${e}`}function _k(t){return`${t}-${crypto.randomUUID().slice(0,8)}`}function v3(t){var e;if(t.target.kind==="claude-code"){const n=((e=t.tandemEntry)==null?void 0:e.url)??`http://127.0.0.1:${Gi}`,r=_k("claude-code");return{id:r,config:{kind:"claude-code",id:r,label:t.target.label,configPath:t.target.configPath,transport:"http",url:n},hasStoredSecret:!1,keychainUnavailable:!1}}if(t.target.kind==="claude-desktop"){const n=_k("claude-desktop");return{id:n,config:{kind:"claude-desktop",id:n,label:t.target.label,configPath:t.target.configPath,transport:"stdio"},hasStoredSecret:!1,keychainUnavailable:!1}}return null}function dR(t={}){const e=t.fetchFn??globalThis.fetch.bind(globalThis),n=t.baseUrl??"",r=t.keychainBackend??m3({fetchFn:e,baseUrl:n});let i=F("connect"),o=F(!0),s=F(tt([])),a=F(tt([])),l=F(null),c=F(tt([])),d=F(!1),f=0;const h=S=>{b(l,S,!0),b(i,"error"),b(o,!1)},p=async()=>{const S=++f;b(o,!0),b(i,"connect"),b(l,null);try{const A=await e(`${n}${q8}`);if(S!==f)return;if(!A.ok){h(`Could not load existing entries (HTTP ${A.status}).`);return}const O=await A.json();if(S!==f)return;b(s,O.installs,!0),b(a,O.installs.filter(g3).map(v3).filter(E=>E!==null),!0)}catch(A){if(S!==f)return;if(A instanceof TypeError&&/fetch|load failed|network/i.test(A.message)){h("Could not reach the Tandem server. Make sure Tandem is running, then try again.");return}h(A instanceof Error?A.message:String(A))}finally{S===f&&b(o,!1)}},m=S=>{const A=u(a).filter(O=>O.config.tokenSecretRef&&!S.some(E=>E.id===O.id));b(a,S,!0);for(const O of A){const E=O.config.tokenSecretRef;E&&r.delete(E)}},v=async(S,A)=>{const O=uR(S.id),E=await r.set(O,A);if(E.status==="unavailable"){b(d,!0),b(a,u(a).map(M=>M.id===S.id?{...M,keychainUnavailable:!0}:M),!0);return}if(E.status==="error"){r.delete(O),h(`Could not store secret: ${E.message}`);return}b(a,u(a).map(M=>M.id===S.id?{...M,config:{...M.config,tokenSecretRef:O},hasStoredSecret:!0,keychainUnavailable:!1}:M),!0)},g=async()=>{const S=u(a).map(A=>A.config.tokenSecretRef).filter(A=>typeof A=="string"&&A.length>0);await Promise.all(S.map(A=>r.delete(A)))};return{get step(){return u(i)},get detecting(){return u(o)},get existing(){return u(s)},get picked(){return u(a)},get errorMessage(){return u(l)},get applyResults(){return u(c)},get keychainUnavailable(){return u(d)},begin:p,setPicked:m,submitSecret:v,save:async()=>{b(i,"applying");const S=u(a).map(E=>{if(E.config.kind==="other-mcp")return{...E.config,apply:"skip"};const M=E.config.configPath,R=u(s).find(I=>I.target.configPath===M),D=R!==void 0&&C1(R);return{...E.config,apply:D?"skip":"create"}}),A={schemaVersion:J8,integrations:S};let O=!1;try{const E=await e(`${n}${W8}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(A)});if(!E.ok){const I=await E.json().catch(()=>null);await g(),h((I==null?void 0:I.message)??`Could not save (HTTP ${E.status}).`);return}O=!0;const M=await E.json(),R=await e(`${n}${K8}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:M.ids,confirmationNonce:M.confirmationNonce})});if(!R.ok){const I=await R.json().catch(()=>null);h((I==null?void 0:I.message)??`Could not apply (HTTP ${R.status}).`);return}const D=await R.json();b(c,D.results,!0),b(i,"done")}catch(E){O||await g(),h(E instanceof Error?E.message:String(E))}},reset:()=>{b(i,"connect"),b(o,!1),b(s,[],!0),b(a,[],!0),b(l,null),b(c,[],!0),b(d,!1)},cleanupUnsavedSecrets:async()=>{u(i)==="connect"&&await g()}}}var fR=an('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" class="svelte-q7klwd"><path d="M4 5h16a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z"></path><path d="M7 9l3 3-3 3"></path><path d="M13 15h4"></path></svg>'),hR=an('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" class="svelte-q7klwd"><path d="M3 5h18a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z"></path><path d="M2 9h20"></path></svg>'),pR=an('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-q7klwd"><path d="M5 13l4 4L19 7"></path></svg>'),mR=T('<span class="itc-check-empty svelte-q7klwd"></span>'),gR=T('<label><input type="checkbox" class="itc-checkbox svelte-q7klwd"/> <span class="itc-icon svelte-q7klwd" aria-hidden="true"><!></span> <span class="itc-text svelte-q7klwd"><span class="itc-name svelte-q7klwd"> </span> <span> </span> <span class="itc-path svelte-q7klwd"> </span></span> <span class="itc-check svelte-q7klwd" aria-hidden="true"><!></span></label>');function vR(t,e){nt(e,!0);const n=L(()=>g3(e.install)),r=L(()=>e.install.target.configPath.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()),i=L(()=>e.install.status==="error"?{text:e.install.errorMessage?`Couldn't check this one — ${e.install.errorMessage}`:"Couldn't check this one",family:"error"}:e.install.status==="malformed"?{text:"Settings file couldn't be read — we'll leave it alone",family:"warning"}:e.install.tandemEntry!==void 0?C1(e.install)?{text:"Has a custom setup — we won't touch it",family:"warning"}:{text:"Already connected — we'll refresh it",family:"success"}:e.install.status==="missing"?{text:"Ready to connect (settings file will be created)",family:null}:{text:"Ready to connect",family:null});var o=gR();let s;var a=w(o),l=k(a,2),c=w(l);{var d=O=>{var E=fR();x(O,E)},f=O=>{var E=hR();x(O,E)};j(c,O=>{e.install.target.kind==="claude-code"?O(d):O(f,-1)})}var h=k(l,2),p=w(h),m=w(p),v=k(p,2),g=w(v),y=k(v,2),C=w(y),_=k(h,2),S=w(_);{var A=O=>{var E=St(),M=Ae(E);{var R=I=>{var H=pR();x(I,H)},D=I=>{var H=mR();x(I,H)};j(M,I=>{e.selected?I(R):I(D,-1)})}x(O,E)};j(S,O=>{u(n)&&O(A)})}W(()=>{s=bt(o,1,"itc-card svelte-q7klwd",null,s,{"is-selected":e.selected,"is-locked":!u(n)}),U(o,"data-testid",`integration-wizard-card-${u(r)??""}`),Fn(a,e.selected),a.disabled=!u(n),U(a,"data-testid",`integration-wizard-pick-${u(r)??""}`),G(m,e.install.target.label),bt(v,1,`itc-status itc-status-${u(i).family??"neutral"??""}`,"svelte-q7klwd"),G(g,u(i).text),G(C,e.install.target.configPath)}),P("change",a,function(...O){var E;(E=e.onToggle)==null||E.apply(this,O)}),x(t,o),rt()}lt(["change"]);const vl=(t,e=kn)=>{var n=bR();W(()=>bt(n,0,Hh(e()),"svelte-bt94ms")),x(t,n)},ou=t=>{var e=yR();x(t,e)},Ck=t=>{var e=wR();x(t,e)},Sk=(t,e=kn)=>{var n=kR(),r=k(w(n));W(()=>G(r,` ${e()??""}`)),x(t,n)};var bR=an('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3l9 16H3z" class="svelte-bt94ms"></path><path d="M12 9v4" class="svelte-bt94ms"></path><path d="M12 17h.01" class="svelte-bt94ms"></path></svg>'),yR=an('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bt94ms"><path d="M5 13l4 4L19 7" class="svelte-bt94ms"></path></svg>'),wR=an('<svg class="iw-chevron svelte-bt94ms" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6" class="svelte-bt94ms"></path></svg>'),kR=T('<div class="iw-loading svelte-bt94ms" aria-live="polite"><span class="iw-dots svelte-bt94ms" aria-hidden="true"><span class="iw-dot svelte-bt94ms"></span><span class="iw-dot svelte-bt94ms"></span><span class="iw-dot svelte-bt94ms"></span></span> </div>'),xR=T('<p class="iw-subtitle svelte-bt94ms">Connect your AI assistant.</p>'),_R=T(`<p class="iw-subtitle svelte-bt94ms">Let a teammate's Claude join from the Cowork VM.</p>`),CR=T('<div class="iw-whats-next svelte-bt94ms"><!> <span class="svelte-bt94ms">Cowork is enabled. Manage workspaces in Settings&nbsp;→&nbsp;Network.</span></div>'),SR=T('<p class="iw-hint-text svelte-bt94ms" data-testid="cowork-vethernet-cidr">Detected Cowork environment: <code class="iw-code-inline svelte-bt94ms"> </code></p>'),ER=T(`<p class="iw-hint-text svelte-bt94ms">A previous attempt couldn't update Windows Firewall (that needs administrator
59
+ rights). Enabling writes the workspace plugin entries either way.</p>`),AR=T(`<div class="iw-banner-warning svelte-bt94ms"><!> <span class="svelte-bt94ms">Tandem writes plugin entries to every detected Cowork workspace so Claude running
60
+ in Cowork can reach the documents you have open.</span></div> <!> <!>`,1),TR=T('<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-cowork-error"><!> <span class="svelte-bt94ms"> </span></div>'),MR=T('<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-cowork-step"><!> <!></section>'),DR=T('<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-install-error"><!> <span class="svelte-bt94ms"> </span></div>'),OR=T(`<p class="iw-hint-text svelte-bt94ms">Don't have Claude Code yet? Install it now — a small, signed download
61
+ straight from Anthropic.</p> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-install-claude"> </button> <!>`,1),IR=T('<div class="iw-whats-next svelte-bt94ms" data-testid="integration-wizard-install-success"><!> <span class="svelte-bt94ms">Claude Code is installed. Open a new terminal and run <code class="svelte-bt94ms">claude</code> once, then choose “Check again”.</span></div>'),RR=T(`<div class="iw-empty svelte-bt94ms" data-testid="integration-wizard-empty"><p class="iw-empty-title svelte-bt94ms">We couldn't find Claude on this computer.</p> <!> <p class="iw-hint-text svelte-bt94ms">If you use Claude Code or Claude Desktop, open it once, then check again. To
62
+ connect a different MCP-compatible app manually, point it at:</p> <code class="iw-code svelte-bt94ms"> </code></div>`),NR=T(`<div class="iw-banner-warning svelte-bt94ms" data-testid="integration-wizard-keychain-fallback"><!> <span class="svelte-bt94ms">Your operating system's secure storage isn't reachable from this Tandem
63
+ build, so tokens entered here can't be saved. Set the environment
64
+ variable <code class="iw-code-inline svelte-bt94ms">TANDEM_INTEGRATION_&lt;id&gt;_TOKEN</code> instead, or add the token in your AI client's own configuration.</span></div>`),PR=T('<span class="iw-secret-stored svelte-bt94ms"><!> Token saved</span>'),LR=T('<span class="iw-secret-skipped svelte-bt94ms">Skipped (secure storage unavailable)</span>'),FR=T('<div class="iw-secret-input svelte-bt94ms"><input type="password" placeholder="Paste access token" class="svelte-bt94ms"/> <button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Save token</button></div>'),zR=T('<div class="iw-secret-row svelte-bt94ms"><span class="iw-secret-label svelte-bt94ms"> </span> <!></div>'),BR=T(`<details class="iw-advanced svelte-bt94ms" data-testid="integration-wizard-advanced"><summary class="svelte-bt94ms"><!> Advanced — set an access token</summary> <div class="iw-advanced-body svelte-bt94ms"><p class="iw-hint-text svelte-bt94ms">Only needed if you've changed Tandem to listen on your network instead of
65
+ just this computer. Most people can skip this. Tokens are stored in your
66
+ operating system's secure storage.</p> <!> <!></div></details>`),HR=T(`<p class="iw-intro svelte-bt94ms">We'll add a small entry to Claude's settings file so Claude can read and edit the
67
+ documents you have open in Tandem. Nothing else is touched, and you can undo this
68
+ any time.</p> <div class="iw-cards svelte-bt94ms"></div> <!>`,1),VR=T('<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-step-detect"><!> <p class="iw-hint-text iw-reopen-hint svelte-bt94ms" data-testid="integration-wizard-reopen-hint">Not now? You can reopen this wizard anytime from Settings → AI Assistant.</p></section>'),UR=T(`<section class="iw-step iw-center svelte-bt94ms" data-testid="integration-wizard-step-applying"><!> <p class="iw-hint-text svelte-bt94ms">Updating Claude's settings file. This takes a second.</p></section>`),jR=T('<span class="iw-result-detail svelte-bt94ms">Connected</span>'),qR=T(`<span class="iw-result-detail svelte-bt94ms">Left unchanged (already set up, or couldn't be safely edited)</span>`),WR=T('<span class="iw-result-detail svelte-bt94ms"> </span>'),KR=T('<div><span class="iw-result-mark svelte-bt94ms" aria-hidden="true"><!></span> <span class="iw-result-text svelte-bt94ms"><span class="iw-result-name svelte-bt94ms"> </span> <!></span></div>'),GR=T('<div class="iw-results svelte-bt94ms"></div>'),ZR=T(`<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-step-done"><div class="iw-done-header svelte-bt94ms"><svg class="iw-done-check svelte-bt94ms" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path class="iw-check-path svelte-bt94ms" d="M4 13l5 5L20 7"></path></svg> <h3 class="iw-done-title svelte-bt94ms"> </h3></div> <!> <div class="iw-whats-next svelte-bt94ms"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bt94ms"><circle cx="12" cy="12" r="9" class="svelte-bt94ms"></circle><path d="M12 11v5" class="svelte-bt94ms"></path><path d="M12 8h.01" class="svelte-bt94ms"></path></svg> <span class="svelte-bt94ms">Restart Claude Code, then type <code class="iw-code-inline svelte-bt94ms">/mcp</code> to verify —
69
+ or just ask Claude to open a document.</span></div></section>`),YR=T('<p class="iw-hint-text svelte-bt94ms"> </p>'),JR=T('<details class="iw-tech-details svelte-bt94ms"><summary class="svelte-bt94ms"><!> Technical details</summary> <pre class="iw-tech-text svelte-bt94ms"> </pre></details>'),XR=T('<section class="iw-step iw-center svelte-bt94ms" data-testid="integration-wizard-step-error"><!> <h3 class="iw-error-title svelte-bt94ms">Something went wrong while connecting</h3> <!> <!></section>'),QR=T('<span class="iw-more-badge svelte-bt94ms"><!> Enabled</span>'),$R=T('<button type="button" class="iw-btn iw-btn-secondary iw-more-btn svelte-bt94ms" aria-label="Set up Cowork" data-testid="integration-wizard-cowork-setup">Set up</button>'),eN=T('<div class="iw-more-row svelte-bt94ms"><div class="iw-more-row-text svelte-bt94ms"><span class="iw-more-row-name svelte-bt94ms">Cowork</span> <span class="iw-more-row-detail svelte-bt94ms"> </span></div> <!></div>'),tN=T('<div class="iw-more-row iw-more-row-disabled svelte-bt94ms"><div class="iw-more-row-text svelte-bt94ms"><span class="iw-more-row-name svelte-bt94ms">AI models</span> <span class="iw-more-row-detail svelte-bt94ms">Bring your own model — coming soon</span></div></div>'),nN=T('<section class="iw-more svelte-bt94ms" data-testid="integration-wizard-more"><div class="iw-more-label svelte-bt94ms">More integrations</div> <!> <!></section>'),rN=T("<!> <!>",1),iN=T('<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms">Done</button>'),oN=T('<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="cowork-enable-confirm-btn"> </button>'),sN=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-cowork-back">Back</button> <!>',1),aN=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Cancel</button>'),lN=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Close</button> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-check-again">Check again</button>',1),cN=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Not now</button> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-connect-btn"> </button>',1),uN=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" disabled="">Connecting…</button>'),dN=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-done-retry">Try again</button>'),fN=T('<!> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-done-close">Done</button>',1),hN=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Close</button> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-error-retry">Try again</button>',1),pN=T('<div role="presentation" class="iw-scrim svelte-bt94ms" data-testid="integration-wizard"><div role="dialog" aria-modal="true" aria-label="Integration Setup Wizard" tabindex="-1" class="iw-dialog svelte-bt94ms"><header class="iw-header svelte-bt94ms"><div class="iw-header-text svelte-bt94ms"><h2 class="iw-title svelte-bt94ms"> </h2> <!></div> <button type="button" class="iw-close svelte-bt94ms" aria-label="Close wizard" data-testid="integration-wizard-close">×</button></header> <div class="iw-body svelte-bt94ms"><!></div> <footer class="iw-footer svelte-bt94ms"><!></footer></div></div>');function mN(t,e){nt(e,!0);const n=dR({baseUrl:`http://127.0.0.1:${Gi}`}),r=_1(()=>Tt()),i=L(()=>XI(r.status)),o=eR(()=>e.open&&n.step==="connect",`http://127.0.0.1:${Gi}`),s=L(()=>o.presence==="NOT_INSTALLED"),a=L(()=>o.presence==="INSTALLED_NOT_ON_PATH");let l=F("main"),c=F(!1),d=F(null),f=F(null),h=null,p=F(tt({}));pe(()=>{if(!e.open)return;const ce=Ct(()=>u(f));if(ce)return h=document.activeElement,ce.focus(),()=>{h instanceof HTMLElement&&document.contains(h)&&h.focus()}}),pe(()=>{e.open&&(b(l,"main"),n.begin())});async function m(){b(c,!0),b(d,null);try{const ce=await hs();await x1(ce,!0),await r.refetch(),b(l,"main")}catch(ce){const ve=ce instanceof Error?ce.message:String(ce);b(d,k1(ve),!0)}finally{b(c,!1)}}const v=L(()=>{if(u(i)==="loading")return"Checking…";if(u(i)==="unsupported")return"Coming soon to macOS & Linux";if(u(i)==="undetected"){const ve=r.status,De=ve?QI(ve):"noClaude";return De==="blocked"?"Found in a network-redirected or synced location Tandem can't safely configure":De==="noWorkspacesYet"?"Claude Desktop detected — run a Cowork session once, then set up here":"Not detected on this computer"}const ce=r.status;return ce!=null&&ce.enabled?"Connected — token provisioned":ce!=null&&ce.uacDeclined?"Setup didn't complete last time — try again from here":"Let a teammate's Claude join from the Cowork VM"});pe(()=>{if(!e.open)return;const ce=ve=>{ve.key==="Escape"&&g()};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)});function g(){n.cleanupUnsavedSecrets().catch(()=>{}),n.reset(),b(p,{},!0),e.onClose()}function y(){n.reset(),b(p,{},!0),n.begin(),o.refetch(),r.refetch()}async function C(){const ce=await o.install();ce&&ce!=="NOT_INSTALLED"&&n.begin()}const _='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])';function S(ce){if(ce.key!=="Tab"||!u(f))return;const ve=Array.from(u(f).querySelectorAll(_)).filter(V=>V.offsetParent!==null);if(ve.length===0)return;const De=ve[0],ee=ve[ve.length-1],q=document.activeElement;ce.shiftKey&&(q===De||q===u(f))?(ce.preventDefault(),ee.focus()):!ce.shiftKey&&q===ee&&(ce.preventDefault(),De.focus())}function A(ce){const ve=n.picked.findIndex(ee=>ee.config.configPath===ce.target.configPath);if(ve>=0){n.setPicked(n.picked.filter((ee,q)=>q!==ve));return}const De=v3(ce);De&&n.setPicked([...n.picked,De])}function O(ce){return n.picked.some(ve=>ve.config.configPath===ce.target.configPath)}async function E(ce){const ve=u(p)[ce.id]??"";ve.length!==0&&(await n.submitSecret(ce,ve),u(p)[ce.id]="")}const M=/HTTP 5\d\d/,R=/HTTP 4\d\d/,D=/fetch|network|Failed to/i,I=L(()=>n.picked.length===1?`Connect ${n.picked[0].config.label}`:"Connect selected");function H(ce){var ve;return((ve=n.picked.find(De=>De.id===ce.id))==null?void 0:ve.config.label)??"Unknown"}function z(ce){switch(ce.code){case"WRITE_FAILED":return"Couldn't write the settings file — check it isn't open in another program, then try again.";case"SECRET_MISSING":return"The access token wasn't found — re-enter it under Advanced and try again.";case"TARGET_NOT_DETECTED":return"This assistant's settings file couldn't be found anymore — it may have moved.";case"PATH_REJECTED":return"The settings file is in an unexpected location, so Tandem left it alone for safety.";case"OTHER_MCP_NOT_APPLICABLE":return"Tandem can't auto-configure this app — connect it manually from that app's settings.";default:return ce.message??"Something went wrong applying this one."}}const Q=L(()=>{const ce=n.errorMessage??"";return M.test(ce)?"Tandem's helper isn't responding. Make sure Tandem is running, then try again.":R.test(ce)?"Tandem couldn't save the connection. Try again in a moment.":D.test(ce)?"Couldn't reach Tandem — is it still running?":null}),ie=L(()=>n.applyResults.some(ce=>ce.status==="error"));var me=St(),le=Ae(me);{var ke=ce=>{var ve=pN(),De=w(ve),ee=w(De),q=w(ee),V=w(q),re=w(V),te=k(V,2);{var Z=ue=>{var Ne=xR();x(ue,Ne)},ge=ue=>{var Ne=_R();x(ue,Ne)};j(te,ue=>{u(l)==="main"&&n.step==="connect"?ue(Z):u(l)==="cowork"&&ue(ge,1)})}var Ie=k(q,2),Se=k(ee,2),fe=w(Se);{var _e=ue=>{var Ne=MR(),qe=w(Ne);{var Xe=Le=>{var it=CR(),ne=w(it);ou(ne),x(Le,it)},ae=Le=>{var it=AR(),ne=Ae(it),Ee=w(ne);vl(Ee);var B=k(ne,2);{var $=Oe=>{var K=SR(),he=k(w(K)),Me=w(he);W(()=>G(Me,r.status.vethernetCidr)),x(Oe,K)};j(B,Oe=>{var K;(K=r.status)!=null&&K.vethernetCidr&&Oe($)})}var we=k(B,2);{var He=Oe=>{var K=ER();x(Oe,K)};j(we,Oe=>{var K;(K=r.status)!=null&&K.uacDeclined&&Oe(He)})}x(Le,it)};j(qe,Le=>{var it;(it=r.status)!=null&&it.enabled?Le(Xe):Le(ae,-1)})}var de=k(qe,2);{var xe=Le=>{var it=TR(),ne=w(it);vl(ne);var Ee=k(ne,2),B=w(Ee);W(()=>G(B,u(d))),x(Le,it)};j(de,Le=>{u(d)&&Le(xe)})}x(ue,Ne)},X=ue=>{var Ne=rN(),qe=Ae(Ne);{var Xe=ne=>{var Ee=VR(),B=w(Ee);{var $=Oe=>{Sk(Oe,()=>"Looking for Claude on your computer…")},we=Oe=>{var K=RR(),he=k(w(K),2);{var Me=Ve=>{var $e=OR(),ct=k(Ae($e),2),dt=w(ct),qt=k(ct,2);{var Nt=Ot=>{var Ft=DR(),En=w(Ft);vl(En);var Hn=k(En,2),An=w(Hn);W(()=>G(An,o.installError)),x(Ot,Ft)};j(qt,Ot=>{o.installError&&Ot(Nt)})}W(()=>{ct.disabled=o.installing,G(dt,o.installing?"Installing…":"Install Claude Code")}),P("click",ct,C),x(Ve,$e)},Fe=Ve=>{var $e=IR(),ct=w($e);ou(ct),x(Ve,$e)};j(he,Ve=>{u(s)?Ve(Me):u(a)&&Ve(Fe,1)})}var We=k(he,4),je=w(We);W(()=>G(je,`http://127.0.0.1:${Gi}/mcp`)),x(Oe,K)},He=Oe=>{var K=HR(),he=k(Ae(K),2);mt(he,21,()=>n.existing,We=>We.target.configPath,(We,je)=>{{let Ve=L(()=>O(u(je)));vR(We,{get install(){return u(je)},get selected(){return u(Ve)},onToggle:()=>A(u(je))})}});var Me=k(he,2);{var Fe=We=>{var je=BR(),Ve=w(je),$e=w(Ve);Ck($e);var ct=k(Ve,2),dt=k(w(ct),2);{var qt=Ot=>{var Ft=NR(),En=w(Ft);vl(En),x(Ot,Ft)};j(dt,Ot=>{n.keychainUnavailable&&Ot(qt)})}var Nt=k(dt,2);mt(Nt,17,()=>n.picked,Ot=>Ot.id,(Ot,Ft)=>{var En=zR(),Hn=w(En),An=w(Hn),zt=k(Hn,2);{var mn=Mn=>{var li=PR(),oo=w(li);ou(oo),x(Mn,li)},Vn=Mn=>{var li=LR();x(Mn,li)},Li=Mn=>{var li=FR(),oo=w(li),ci=k(oo,2);W(()=>{U(oo,"data-testid",`integration-wizard-secret-input-${u(Ft).id??""}`),ci.disabled=!u(p)[u(Ft).id],U(ci,"data-testid",`integration-wizard-secret-submit-${u(Ft).id??""}`)}),Hr(oo,()=>u(p)[u(Ft).id],ua=>u(p)[u(Ft).id]=ua),P("click",ci,()=>E(u(Ft))),x(Mn,li)};j(zt,Mn=>{u(Ft).hasStoredSecret?Mn(mn):u(Ft).keychainUnavailable?Mn(Vn,1):Mn(Li,-1)})}W(()=>G(An,u(Ft).config.label)),x(Ot,En)}),x(We,je)};j(Me,We=>{n.picked.length>0&&We(Fe)})}x(Oe,K)};j(B,Oe=>{n.detecting?Oe($):n.existing.length===0?Oe(we,1):Oe(He,-1)})}x(ne,Ee)},ae=ne=>{var Ee=UR(),B=w(Ee);Sk(B,()=>"Connecting Claude…"),x(ne,Ee)},de=ne=>{var Ee=ZR(),B=w(Ee),$=k(w(B),2),we=w($),He=k(B,2);{var Oe=K=>{var he=GR();mt(he,21,()=>n.applyResults,Me=>Me.id,(Me,Fe)=>{var We=KR(),je=w(We),Ve=w(je);{var $e=zt=>{ou(zt)},ct=zt=>{var mn=fr("—");x(zt,mn)},dt=zt=>{vl(zt)};j(Ve,zt=>{u(Fe).status==="applied"?zt($e):u(Fe).status==="skipped"?zt(ct,1):zt(dt,-1)})}var qt=k(je,2),Nt=w(qt),Ot=w(Nt),Ft=k(Nt,2);{var En=zt=>{var mn=jR();x(zt,mn)},Hn=zt=>{var mn=qR();x(zt,mn)},An=zt=>{var mn=WR(),Vn=w(mn);W(Li=>G(Vn,Li),[()=>z(u(Fe))]),x(zt,mn)};j(Ft,zt=>{u(Fe).status==="applied"?zt(En):u(Fe).status==="skipped"?zt(Hn,1):zt(An,-1)})}W(zt=>{bt(We,1,`iw-result iw-result-${u(Fe).status??""}`,"svelte-bt94ms"),U(We,"data-testid",`integration-wizard-apply-result-${u(Fe).id??""}`),G(Ot,zt)},[()=>H(u(Fe))]),x(Me,We)}),x(K,he)};j(He,K=>{n.applyResults.length>0&&K(Oe)})}W(()=>G(we,u(ie)?"Partly connected":"Claude is connected to Tandem")),x(ne,Ee)},xe=ne=>{var Ee=XR(),B=w(Ee);vl(B,()=>"iw-error-icon");var $=k(B,4);{var we=K=>{var he=YR(),Me=w(he);W(()=>G(Me,u(Q))),x(K,he)};j($,K=>{u(Q)&&K(we)})}var He=k($,2);{var Oe=K=>{var he=JR(),Me=w(he),Fe=w(Me);Ck(Fe);var We=k(Me,2),je=w(We);W(()=>G(je,n.errorMessage)),x(K,he)};j(He,K=>{n.errorMessage&&K(Oe)})}x(ne,Ee)};j(qe,ne=>{n.step==="connect"?ne(Xe):n.step==="applying"?ne(ae,1):n.step==="done"?ne(de,2):n.step==="error"&&ne(xe,3)})}var Le=k(qe,2);{var it=ne=>{var Ee=nN(),B=k(w(Ee),2);{var $=K=>{var he=eN(),Me=w(he),Fe=k(w(Me),2),We=w(Fe),je=k(Me,2);{var Ve=ct=>{var dt=QR(),qt=w(dt);ou(qt),x(ct,dt)},$e=ct=>{var dt=$R();P("click",dt,()=>{b(d,null),b(c,!1),b(l,"cowork")}),x(ct,dt)};j(je,ct=>{var dt;(dt=r.status)!=null&&dt.enabled?ct(Ve):u(i)==="normal"&&ct($e,1)})}W(()=>G(We,u(v))),x(K,he)},we=L(()=>Tt());j(B,K=>{u(we)&&K($)})}var He=k(B,2);{var Oe=K=>{var he=tN();x(K,he)};j(He,K=>{K(Oe)})}x(ne,Ee)};j(Le,ne=>{(n.step==="connect"||n.step==="done")&&ne(it)})}x(ue,Ne)};j(fe,ue=>{u(l)==="cowork"?ue(_e):ue(X,-1)})}var ye=k(Se,2),Y=w(ye);{var se=ue=>{var Ne=sN(),qe=Ae(Ne),Xe=k(qe,2);{var ae=xe=>{var Le=iN();P("click",Le,()=>b(l,"main")),x(xe,Le)},de=xe=>{var Le=oN(),it=w(Le);W(()=>{Le.disabled=u(c),G(it,u(c)?"Enabling…":"Enable Cowork")}),P("click",Le,m),x(xe,Le)};j(Xe,xe=>{var Le;(Le=r.status)!=null&&Le.enabled?xe(ae):xe(de,-1)})}W(()=>qe.disabled=u(c)),P("click",qe,()=>b(l,"main")),x(ue,Ne)},Te=ue=>{var Ne=St(),qe=Ae(Ne);{var Xe=xe=>{var Le=aN();P("click",Le,g),x(xe,Le)},ae=xe=>{var Le=lN(),it=Ae(Le),ne=k(it,2);P("click",it,g),P("click",ne,y),x(xe,Le)},de=xe=>{var Le=cN(),it=Ae(Le),ne=k(it,2),Ee=w(ne);W(()=>{ne.disabled=n.picked.length===0,G(Ee,u(I))}),P("click",it,g),P("click",ne,()=>n.save()),x(xe,Le)};j(qe,xe=>{n.detecting?xe(Xe):n.existing.length===0?xe(ae,1):xe(de,-1)})}x(ue,Ne)},Re=ue=>{var Ne=uN();x(ue,Ne)},ze=ue=>{var Ne=fN(),qe=Ae(Ne);{var Xe=de=>{var xe=dN();P("click",xe,y),x(de,xe)};j(qe,de=>{u(ie)&&de(Xe)})}var ae=k(qe,2);P("click",ae,g),x(ue,Ne)},Je=ue=>{var Ne=hN(),qe=Ae(Ne),Xe=k(qe,2);P("click",qe,g),P("click",Xe,y),x(ue,Ne)};j(Y,ue=>{u(l)==="cowork"?ue(se):n.step==="connect"?ue(Te,1):n.step==="applying"?ue(Re,2):n.step==="done"?ue(ze,3):n.step==="error"&&ue(Je,4)})}Dt(De,ue=>b(f,ue),()=>u(f)),W(()=>G(re,u(l)==="cowork"?"Set up Cowork":"Connect Claude to Tandem")),P("click",ve,ue=>{ue.target===ue.currentTarget&&g()}),P("keydown",De,ue=>{if(ue.key==="Escape"){ue.stopPropagation(),g();return}if(ue.key==="Tab"){S(ue);return}ue.stopPropagation()}),P("click",Ie,g),x(ce,ve)};j(le,ce=>{e.open&&ce(ke)})}x(t,me),rt()}lt(["click","keydown"]);const gN=t=>t;function vN(t,{delay:e=0,duration:n=400,easing:r=gN}={}){const i=+getComputedStyle(t).opacity;return{delay:e,duration:n,easing:r,css:o=>`opacity: ${o*i}`}}let If=null;function Ek(t){const e=t.decorationsMuted;try{localStorage.setItem(ZC,String(!e&&t.showAuthorship)),localStorage.setItem(YC,JSON.stringify({comment:!e&&t.showComments,highlight:!e&&t.showHighlights,note:!e&&t.showNotes}))}catch{}}function ai(){if(If)return If;const t=_m();let e=F(tt(t));return Ek(t),If={get settings(){return u(e)},updateSettings:r=>{if(u(e)._readOnly)return;const i=r5(u(e),r);try{localStorage.setItem(jC,JSON.stringify(i))}catch{}Ek(i),b(e,i,!0)}},If}function b3(t,e,n,r){const i=3*t,o=3*(n-t)-i,s=1-i-o,a=3*e,l=3*(r-e)-a,c=1-a-l,d=m=>((s*m+o)*m+i)*m,f=m=>((c*m+l)*m+a)*m,h=m=>(3*s*m+2*o)*m+i,p=m=>{let v=m;for(let C=0;C<8;C++){const _=d(v)-m;if(Math.abs(_)<1e-5)return v;const S=h(v);if(Math.abs(S)<1e-6)break;v-=_/S}let g=0,y=1;v=m;for(let C=0;C<20;C++){const _=d(v)-m;if(Math.abs(_)<1e-5)break;_>0?y=v:g=v,v=(g+y)/2}return v};return m=>m<=0?0:m>=1?1:f(p(m))}const ul=b3(.2,.8,.2,1),bN=b3(.4,0,.2,1),yN=260,wN=260,kN=280;function to(t){return t?!0:typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Xd(t){return{h:t.offsetHeight,mb:Number.parseFloat(getComputedStyle(t).marginBottom)||0}}function xN(t,{enabled:e,reduceMotion:n}){if(!e||to(n))return{duration:0};const{h:r,mb:i}=Xd(t);return{duration:yN,easing:ul,css:(o,s)=>`opacity:${o}; transform:translateY(${-6*s}px); height:${o*r}px; margin-bottom:${o*i}px; overflow:clip; box-sizing:border-box;`}}function _N(t,{enabled:e,reduceMotion:n,id:r,modes:i}){const o=i==null?void 0:i.get(r);if(i==null||i.delete(r),!e||to(n))return{duration:0};const{h:s,mb:a}=Xd(t),l=c=>o==="accept"?`translateY(${-8*c}px)`:o==="dismiss"?`translateX(${40*c}px) scale(${1-.04*c})`:"none";return{duration:wN,easing:ul,css:(c,d)=>`opacity:${c}; height:${c*s}px; margin-bottom:${c*a}px; transform:${l(d)}; overflow:clip; box-sizing:border-box;`}}function y3(t,{reduceMotion:e}){if(to(e))return{duration:0};const{h:n,mb:r}=Xd(t);return{duration:kN,easing:ul,css:(i,o)=>`opacity:${i}; transform:translateY(${-8*o}px); height:${i*n}px; margin-bottom:${i*r}px; overflow:clip; box-sizing:border-box;`}}function w3(t,{reduceMotion:e,exitMs:n=200}){if(to(e))return{duration:0};const{h:r,mb:i}=Xd(t);return{duration:n,easing:bN,css:(o,s)=>`opacity:${o}; transform:translateY(${-8*s}px); height:${o*r}px; margin-bottom:${o*i}px; overflow:clip; box-sizing:border-box;`}}const rp=new Map,CN=480,SN=1e3;function Ak(t,e){rp.set(t,e),setTimeout(()=>rp.delete(t),SN)}function EN(t,{id:e,reduceMotion:n}){const r=rp.get(e);if(rp.delete(e),!r||to(n))return{duration:0};const i=t.getBoundingClientRect(),o=r.left-i.left,s=r.top-i.top;return{duration:CN,easing:ul,css:(a,l)=>`transform:translate(${o*l}px, ${s*l}px); opacity:${.2+.8*a};`}}const AN=200;function TN(t,{reduceMotion:e}){if(to(e))return{duration:0};const n=t.offsetWidth;return{duration:AN,easing:ul,css:r=>`opacity:${r}; width:${r*n}px; min-width:0; overflow:clip; box-sizing:border-box; pointer-events:none;`}}const k3=440;function MN(t,{reduceMotion:e}){if(to(e))return{duration:0};const n=t.offsetWidth,r=t.offsetHeight;return{duration:k3,easing:ul,css:i=>`opacity:${i}; width:${i*n}px; height:${i*r}px; overflow:clip; box-sizing:border-box;`}}const DN=380;function ON(t,{reduceMotion:e}){if(to(e))return{duration:0};const{h:n,mb:r}=Xd(t);return{duration:DN,easing:ul,css:i=>`opacity:${i}; height:${i*n}px; margin-bottom:${i*r}px; overflow:clip; box-sizing:border-box;`}}var IN=T("Detected VM subnet: <code> </code>.",1),RN=T('<div class="cos-error svelte-1h0desi" data-testid="cowork-onboarding-error" role="alert"> </div>'),NN=T(`<div class="cos-confirm-banner svelte-1h0desi" data-testid="cowork-onboarding-confirm"><div class="cos-confirm-heading svelte-1h0desi">Confirm: Enable Cowork</div> <div class="cos-confirm-body svelte-1h0desi">Tandem will write plugin entries to every detected Cowork workspace so Claude running in
70
+ Cowork can reach the documents you have open.</div> <div class="cos-actions svelte-1h0desi"><button data-testid="cowork-onboarding-enable-confirm-btn" class="cos-btn cos-btn--primary svelte-1h0desi" type="button">Enable</button> <button data-testid="cowork-onboarding-enable-cancel-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Cancel</button></div></div>`),PN=T('<button data-testid="cowork-onboarding-learn-more-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Learn more</button>'),LN=T('<a class="cos-learn-more-link svelte-1h0desi" data-testid="cowork-onboarding-learn-more-link" target="_blank" rel="noreferrer">Learn more</a>'),FN=T('<div class="cos-actions svelte-1h0desi"><button data-testid="cowork-onboarding-enable-btn" class="cos-btn cos-btn--primary svelte-1h0desi" type="button">Enable</button> <button data-testid="cowork-onboarding-skip-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Skip</button> <!></div>'),zN=T('<div class="cos-root svelte-1h0desi" data-testid="cowork-onboarding-step"><div class="cos-title svelte-1h0desi">Claude Desktop Cowork detected</div> <div class="cos-description svelte-1h0desi">Enable Tandem inside Cowork workspaces? <!></div> <!> <!></div>');function BN(t,e){nt(e,!0);let n=F(!1),r=F(!1),i=F(null);async function o(y,C){b(r,!0),b(i,null);try{const _=await hs();return await y(_),!0}catch(_){const S=_ instanceof Error?_.message:String(_),A=k1(S);return b(i,`${C}: ${A}`),!1}finally{b(r,!1)}}async function s(){await o(async C=>{await x1(C,!0)},"Failed to enable Cowork")&&e.onAdvance()}function a(){t8(),e.onAdvance()}var l=zN(),c=k(w(l),2),d=k(w(c));{var f=y=>{var C=IN(),_=k(Ae(C)),S=w(_);W(()=>G(S,e.status.vethernetCidr)),x(y,C)};j(d,y=>{e.status.vethernetCidr!==null&&y(f)})}var h=k(c,2);{var p=y=>{var C=RN(),_=w(C);W(()=>G(_,u(i))),x(y,C)};j(h,y=>{u(i)&&y(p)})}var m=k(h,2);{var v=y=>{var C=NN(),_=k(w(C),4),S=w(_),A=k(S,2);W(()=>{S.disabled=u(r),A.disabled=u(r)}),P("click",S,()=>void s()),P("click",A,()=>{b(n,!1)}),x(y,C)},g=y=>{var C=FN(),_=w(C),S=k(_,2),A=k(S,2);{var O=M=>{var R=PN();W(()=>R.disabled=u(r)),P("click",R,function(...D){var I;(I=e.onLearnMore)==null||I.apply(this,D)}),x(M,R)},E=M=>{var R=LN();W(()=>U(R,"href",`${BC}#cowork`)),x(M,R)};j(A,M=>{e.onLearnMore?M(O):M(E,-1)})}W(()=>{_.disabled=u(r),S.disabled=u(r)}),P("click",_,()=>{b(n,!0)}),P("click",S,a),x(y,C)};j(m,y=>{u(n)?y(v):y(g,-1)})}x(t,l),rt()}lt(["click"]);var HN=T("<div></div>"),VN=T('<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);" class="svelte-1us4jmd"></div>'),UN=T('<div style="font-size: var(--tandem-text-sm); font-weight: 600; color: var(--tandem-fg); margin-bottom: var(--tandem-space-1);" class="svelte-1us4jmd"> </div> <div class="svelte-1us4jmd"> </div>',1),jN=T('<div class="svelte-1us4jmd"><!></div>'),qN=T('<div style="display: flex; justify-content: space-between; align-items: center;" class="svelte-1us4jmd"><span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);" class="svelte-1us4jmd"> </span> <div style="display: flex; gap: 12px; align-items: center;" class="svelte-1us4jmd"><button data-testid="tutorial-dismiss-btn" style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); padding: 0; text-decoration: underline;" class="svelte-1us4jmd">Dismiss tutorial</button> <button data-testid="tutorial-next-btn" style="padding: var(--tandem-space-1) var(--tandem-space-3); font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-pill); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; font-weight: 500;" class="svelte-1us4jmd"> </button></div></div>'),WN=T('<div data-testid="onboarding-tutorial" style="position: fixed; bottom: 48px; left: 24px; z-index: var(--tandem-z-overlay); max-width: 340px; background: var(--tandem-surface); border-left: 4px solid var(--tandem-accent); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-2); padding: var(--tandem-space-4) var(--tandem-space-5); font-family: inherit;" class="svelte-1us4jmd"><!> <!> <!></div>');function KN(t,e){nt(e,!0);const n=ai(),r=L(()=>to(n.settings.reduceMotion)?0:220),i=[{id:"review",title:"Review an annotation",text:"Open the side panel and accept or dismiss one of the highlighted annotations — or turn on the margin view to see them beside the text. Ctrl+Enter accepts the selected annotation; Ctrl+Shift+Enter dismisses it."},{id:"question",title:"Ask a question",text:"Select text and click Annotate, then send it to your AI assistant — or keep it as a private note to yourself. You can also use the Chat panel."},{id:"edit",title:"Make an edit",text:"Click in the document and type something. All changes sync in real-time. Open a tab or scratchpad with Ctrl+N, and jump anywhere with the command palette (Ctrl+Shift+P)."},{id:"cowork",title:"Claude Desktop Cowork detected",text:""},{id:"complete",title:"You're ready!",text:"You've learned the basics. Press ? anytime for keyboard shortcuts, or Ctrl+Shift+, to customize them."}],o=Tt(),s=d3(),a=L(()=>o&&u3(e.coworkStatus,s)),l=L(()=>i.filter(g=>g.id!=="cowork"||u(a))),c=L(()=>u(l).length-1),d=L(()=>u(l)[e.currentStep]),f=L(()=>e.currentStep>=u(c)),h=L(()=>{var g;return((g=u(d))==null?void 0:g.id)==="cowork"});var p=St(),m=Ae(p);{var v=g=>{var y=WN(),C=w(y);{var _=E=>{var M=VN();mt(M,20,()=>Array.from({length:u(c)},(R,D)=>D),R=>R,(R,D)=>{var I=HN();let H;W(()=>{H=bt(I,1,"tut-dot svelte-1us4jmd",null,H,{"is-current":D===e.currentStep}),Pe(I,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${D<=e.currentStep?"var(--tandem-accent)":"var(--tandem-border)"}; transition: background 0.2s;`)}),x(R,I)}),x(E,M)};j(C,E=>{u(f)||E(_)})}var S=k(C,2);Bl(S,()=>u(d).id,E=>{var M=jN(),R=w(M);{var D=H=>{BN(H,{get status(){return e.coworkStatus},get onAdvance(){return e.onNext}})},I=H=>{var z=UN(),Q=Ae(z),ie=w(Q),me=k(Q,2),le=w(me);W(()=>{G(ie,u(d).title),Pe(me,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${u(f)?0:14}px;`),G(le,u(d).text)}),x(H,z)};j(R,H=>{u(h)&&e.coworkStatus!==null?H(D):H(I,-1)})}Yi(1,M,()=>vN,()=>({duration:u(r)})),x(E,M)});var A=k(S,2);{var O=E=>{var M=qN(),R=w(M),D=w(R),I=k(R,2),H=w(I),z=k(H,2),Q=w(z);W(()=>{G(D,`Step ${e.currentStep+1} of ${u(c)??""}`),G(Q,e.currentStep===u(c)-1?"Done":"Next")}),P("click",H,function(...ie){var me;(me=e.onDismiss)==null||me.apply(this,ie)}),P("click",z,function(...ie){var me;(me=e.onNext)==null||me.apply(this,ie)}),x(E,M)};j(A,E=>{!u(f)&&!u(h)&&E(O)})}x(g,y)};j(m,g=>{u(d)&&g(v)})}x(t,p),rt()}lt(["click"]);const Ti=()=>new Map,Hv=t=>{const e=Ti();return t.forEach((n,r)=>{e.set(r,n)}),e},Ro=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},GN=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},ZN=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Ja=()=>new Set,Wg=t=>t[t.length-1],YN=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},$s=Array.from,S1=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},E1=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},JN=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},wc=Array.isArray;class x3{constructor(){this._observers=Ti()}on(e,n){return Ro(this._observers,e,Ja).add(n),n}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return $s((this._observers.get(e)||Ti()).values()).forEach(r=>r(...n))}destroy(){this._observers=Ti()}}const Ji=Math.floor,wh=Math.abs,ns=(t,e)=>t<e?t:e,Xi=(t,e)=>t>e?t:e,_3=t=>t!==0?t<0:1/t<0,Tk=1,Mk=2,Kg=4,Gg=8,id=32,rs=64,Ar=128,XN=1<<29,Tm=31,Vv=63,Ba=127,QN=2147483647,ip=Number.MAX_SAFE_INTEGER,Dk=Number.MIN_SAFE_INTEGER,$N=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Ji(t)===t),C3=String.fromCharCode,e9=t=>t.toLowerCase(),t9=/^\s*/g,n9=t=>t.replace(t9,""),r9=/([A-Z])/g,Ok=(t,e)=>n9(t.replace(r9,n=>`${e}${e9(n)}`)),i9=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},od=typeof TextEncoder<"u"?new TextEncoder:null,o9=t=>od.encode(t),s9=od?o9:i9;let Du=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Du&&Du.decode(new Uint8Array).length===1&&(Du=null);const a9=(t,e)=>JN(e,()=>t).join("");let Qd=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};const $d=()=>new Qd,l9=t=>{const e=$d();return t(e),Wi(e)},c9=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Wi=t=>{const e=new Uint8Array(c9(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},u9=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Xi(n,e)*2),t.cpos=0)},Zn=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Uv=Zn,Lt=(t,e)=>{for(;e>Ba;)Zn(t,Ar|Ba&e),e=Ji(e/128);Zn(t,Ba&e)},A1=(t,e)=>{const n=_3(e);for(n&&(e=-e),Zn(t,(e>Vv?Ar:0)|(n?rs:0)|Vv&e),e=Ji(e/64);e>0;)Zn(t,(e>Ba?Ar:0)|Ba&e),e=Ji(e/128)},jv=new Uint8Array(3e4),d9=jv.length/3,f9=(t,e)=>{if(e.length<d9){const n=od.encodeInto(e,jv).written||0;Lt(t,n);for(let r=0;r<n;r++)Zn(t,jv[r])}else Jr(t,s9(e))},h9=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Lt(t,r);for(let i=0;i<r;i++)Zn(t,n.codePointAt(i))},Vl=od&&od.encodeInto?f9:h9,Mm=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=ns(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Xi(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},Jr=(t,e)=>{Lt(t,e.byteLength),Mm(t,e)},T1=(t,e)=>{u9(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},p9=(t,e)=>T1(t,4).setFloat32(0,e,!1),m9=(t,e)=>T1(t,8).setFloat64(0,e,!1),g9=(t,e)=>T1(t,8).setBigInt64(0,e,!1),Ik=new DataView(new ArrayBuffer(4)),v9=t=>(Ik.setFloat32(0,t),Ik.getFloat32(0)===t),kc=(t,e)=>{switch(typeof e){case"string":Zn(t,119),Vl(t,e);break;case"number":$N(e)&&wh(e)<=QN?(Zn(t,125),A1(t,e)):v9(e)?(Zn(t,124),p9(t,e)):(Zn(t,123),m9(t,e));break;case"bigint":Zn(t,122),g9(t,e);break;case"object":if(e===null)Zn(t,126);else if(wc(e)){Zn(t,117),Lt(t,e.length);for(let n=0;n<e.length;n++)kc(t,e[n])}else if(e instanceof Uint8Array)Zn(t,116),Jr(t,e);else{Zn(t,118);const n=Object.keys(e);Lt(t,n.length);for(let r=0;r<n.length;r++){const i=n[r];Vl(t,i),kc(t,e[i])}}break;case"boolean":Zn(t,e?120:121);break;default:Zn(t,127)}};class Rk extends Qd{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Lt(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Nk=t=>{t.count>0&&(A1(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Lt(t.encoder,t.count-2))};class kh{constructor(){this.encoder=new Qd,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Nk(this),this.count=1,this.s=e)}toUint8Array(){return Nk(this),Wi(this.encoder)}}const Pk=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);A1(t.encoder,e),t.count>1&&Lt(t.encoder,t.count-2)}};class Zg{constructor(){this.encoder=new Qd,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Pk(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Pk(this),Wi(this.encoder)}}class b9{constructor(){this.sarr=[],this.s="",this.lensE=new kh}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Qd;return this.sarr.push(this.s),this.s="",Vl(e,this.sarr.join("")),Mm(e,this.lensE.toUint8Array()),Wi(e)}}const To=t=>new Error(t),Mi=()=>{throw To("Method unimplemented")},mr=()=>{throw To("Unexpected case")},S3=To("Unexpected end of array"),E3=To("Integer out of Range");let Dm=class{constructor(e){this.arr=e,this.pos=0}};const Hc=t=>new Dm(t),y9=t=>t.pos!==t.arr.length,w9=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Xr=t=>w9(t,It(t)),xc=t=>t.arr[t.pos++],It=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&Ba)*n,n*=128,i<Ar)return e;if(e>ip)throw E3}throw S3},M1=t=>{let e=t.arr[t.pos++],n=e&Vv,r=64;const i=(e&rs)>0?-1:1;if((e&Ar)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&Ba)*r,r*=128,e<Ar)return i*n;if(n>ip)throw E3}throw S3},k9=t=>{let e=It(t);if(e===0)return"";{let n=String.fromCodePoint(xc(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(xc(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},x9=t=>Du.decode(Xr(t)),Ul=Du?x9:k9,D1=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},_9=t=>D1(t,4).getFloat32(0,!1),C9=t=>D1(t,8).getFloat64(0,!1),S9=t=>D1(t,8).getBigInt64(0,!1),E9=[t=>{},t=>null,M1,_9,C9,S9,t=>!1,t=>!0,Ul,t=>{const e=It(t),n={};for(let r=0;r<e;r++){const i=Ul(t);n[i]=sd(t)}return n},t=>{const e=It(t),n=[];for(let r=0;r<e;r++)n.push(sd(t));return n},Xr],sd=t=>E9[127-xc(t)](t);class Lk extends Dm{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),y9(this)?this.count=It(this)+1:this.count=-1),this.count--,this.s}}class xh extends Dm{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=M1(this);const e=_3(this.s);this.count=1,e&&(this.s=-this.s,this.count=It(this)+2)}return this.count--,this.s}}class Yg extends Dm{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=M1(this),n=e&1;this.diff=Ji(e/2),this.count=1,n&&(this.count=It(this)+2)}return this.s+=this.diff,this.count--,this.s}}class A9{constructor(e){this.decoder=new xh(e),this.str=Ul(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const T9=crypto.getRandomValues.bind(crypto),M9=Math.random,A3=()=>T9(new Uint32Array(1))[0],D9=t=>t[Ji(M9()*t.length)],O9="10000000-1000-4000-8000"+-1e11,I9=()=>O9.replace(/[018]/g,t=>(t^A3()&15>>t/4).toString(16)),R9=Date.now,Fk=t=>new Promise(t);Promise.all.bind(Promise);const zk=t=>t===void 0?null:t;class N9{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let T3=new N9,P9=!0;try{typeof localStorage<"u"&&localStorage&&(T3=localStorage,P9=!1)}catch{}const L9=T3,ad=Symbol("Equality"),M3=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[ad])!=null&&n.call(t,e))||!1},F9=t=>typeof t=="object",z9=Object.assign,D3=Object.keys,B9=(t,e)=>{for(const n in t)e(t[n],n)},op=t=>D3(t).length,H9=t=>{for(const e in t)return!1;return!0},Vc=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},O1=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),V9=(t,e)=>t===e||op(t)===op(e)&&Vc(t,(n,r)=>(n!==void 0||O1(e,r))&&M3(e[r],n)),U9=Object.freeze,O3=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&O3(t[e])}return U9(t)},I1=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&I1(t,e,n+1)}},j9=t=>t,_h=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[ad]!=null)return t[ad](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!_h(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(op(t)!==op(e))return!1;for(const n in t)if(!O1(t,n)||!_h(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!_h(t[n],e[n]))return!1;break;default:return!1}return!0},q9=(t,e)=>e.includes(t);var I3={};const _c=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",R3=typeof window<"u"&&typeof document<"u"&&!_c;let co;const W9=()=>{if(co===void 0)if(_c){co=Ti();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&co.set(e,""),e=r):e!==null&&(co.set(e,r),e=null)}e!==null&&co.set(e,"")}else typeof location=="object"?(co=Ti(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");co.set(`--${Ok(e,"-")}`,n),co.set(`-${Ok(e,"-")}`,n)}})):co=Ti();return co},qv=t=>W9().has(t),sp=t=>zk(_c?I3[t.toUpperCase().replaceAll("-","_")]:L9.getItem(t)),N3=t=>qv("--"+t)||sp(t)!==null,K9=N3("production"),G9=_c&&q9(I3.FORCE_COLOR,["true","1","2"]),Z9=G9||!qv("--no-colors")&&!N3("no-color")&&(!_c||process.stdout.isTTY)&&(!_c||qv("--color")||sp("COLORTERM")!==null||(sp("TERM")||"").includes("color")),Y9=t=>new Uint8Array(t),J9=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=C3(t[n]);return btoa(e)},X9=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Q9=R3?J9:X9,$9=t=>{const e=Y9(t.byteLength);return e.set(t),e},eP=t=>l9(e=>kc(e,t));class tP{constructor(e,n){this.left=e,this.right=n}}const zo=(t,e)=>new tP(t,e),Bk=t=>t.next()>=.5,Jg=(t,e,n)=>Ji(t.next()*(n+1-e)+e),P3=(t,e,n)=>Ji(t.next()*(n+1-e)+e),R1=(t,e,n)=>P3(t,e,n),nP=t=>C3(R1(t,97,122)),rP=(t,e=0,n=20)=>{const r=R1(t,e,n);let i="";for(let o=0;o<r;o++)i+=nP(t);return i},Xg=(t,e)=>e[R1(t,0,e.length-1)],iP=Symbol("0schema");class oP{constructor(){this._rerrs=[]}extend(e,n,r,i=null){this._rerrs.push({path:e,expected:n,has:r,message:i})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(a9(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
71
+ `)}}const Wv=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[ad]?M3(t,e):wc(t)?S1(t,n=>E1(e,r=>Wv(n,r))):F9(t)?Vc(t,(n,r)=>Wv(n,e[r])):!1;class yr{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),Wv(n,r)}equals(e){return this.constructor===e.constructor&&_h(this.shape,e.shape)}[iP](){return!0}[ad](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Mi()}get nullable(){return Uc(this,Pm)}get optional(){return new z3(this)}cast(e){return Hk(e,this),e}expect(e){return Hk(e,this),e}}Wn(yr,"_dilutes",!1);class N1 extends yr{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=(e==null?void 0:e.constructor)===this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name,(e==null?void 0:e.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}}const Nn=(t,e=null)=>new N1(t,e);Nn(N1);class P1 extends yr{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&(n==null||n.extend(null,"custom prop",e==null?void 0:e.constructor.name,"failed to check custom prop")),r}}const nr=t=>new P1(t);Nn(P1);class Om extends yr{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(i=>i===e);return!r&&(n==null||n.extend(null,this.shape.join(" | "),e.toString())),r}}const Im=(...t)=>new Om(t),L3=Nn(Om),sP=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),F3=t=>{if(Cc.check(t))return[sP(t)];if(L3.check(t))return t.shape.map(e=>e+"");if(G3.check(t))return["[+-]?\\d+.?\\d*"];if(Z3.check(t))return[".*"];if(lp.check(t))return t.shape.map(F3).flat(1);mr()};class aP extends yr{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(F3).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&(n==null||n.extend(null,this._r.toString(),e.toString(),"String doesn't match string template.")),r}}Nn(aP);const lP=Symbol("optional");class z3 extends yr{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&(n==null||n.extend(null,"undefined (optional)","()")),r}get[lP](){return!0}}const cP=Nn(z3);class uP extends yr{check(e,n){return n==null||n.extend(null,"never",typeof e),!1}}Nn(uP);const gm=class gm extends yr{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new gm(this.shape,!0)}check(e,n){return e==null?(n==null||n.extend(null,"object","null"),!1):Vc(this.shape,(r,i)=>{const o=this._isPartial&&!O1(e,i)||r.check(e[i],n);return!o&&(n==null||n.extend(i.toString(),r.toString(),typeof e[i],"Object property does not match")),o})}};Wn(gm,"_dilutes",!0);let ap=gm;const dP=t=>new ap(t),fP=Nn(ap),hP=nr(t=>t!=null&&(t.constructor===Object||t.constructor==null));class B3 extends yr{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&Vc(e,(r,i)=>{const o=this.shape.keys.check(i,n);return!o&&(n==null||n.extend(i+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value")),o&&this.shape.values.check(r,n)})}}const H3=(t,e)=>new B3(t,e),pP=Nn(B3);class V3 extends yr{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&Vc(this.shape,(r,i)=>{const o=r.check(e[i],n);return!o&&(n==null||n.extend(i.toString(),"Tuple",typeof r)),o})}}const mP=(...t)=>new V3(t);Nn(V3);class U3 extends yr{constructor(e){super(),this.shape=e.length===1?e[0]:new Rm(e)}check(e,n){const r=wc(e)&&S1(e,i=>this.shape.check(i));return!r&&(n==null||n.extend(null,"Array","")),r}}const j3=(...t)=>new U3(t),gP=Nn(U3),vP=nr(t=>wc(t));class q3 extends yr{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name)),r}}const bP=(t,e=null)=>new q3(t,e);Nn(q3);const yP=bP(yr);class wP extends yr{constructor(e){super(),this.len=e.length-1,this.args=mP(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&(n==null||n.extend(null,"function",typeof e)),r}}const kP=Nn(wP),xP=nr(t=>typeof t=="function");class _P extends yr{constructor(e){super(),this.shape=e}check(e,n){const r=S1(this.shape,i=>i.check(e,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof e)),r}}Nn(_P,t=>t.shape.length>0);class Rm extends yr{constructor(e){super(),this.shape=e}check(e,n){const r=E1(this.shape,i=>i.check(e,n));return n==null||n.extend(null,"Union",typeof e),r}}Wn(Rm,"_dilutes",!0);const Uc=(...t)=>t.findIndex(e=>lp.check(e))>=0?Uc(...t.map(e=>ld(e)).map(e=>lp.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Rm(t),lp=Nn(Rm),W3=()=>!0,cp=nr(W3),CP=Nn(P1,t=>t.shape===W3),L1=nr(t=>typeof t=="bigint"),SP=nr(t=>t===L1),K3=nr(t=>typeof t=="symbol");nr(t=>t===K3);const jl=nr(t=>typeof t=="number"),G3=nr(t=>t===jl),Cc=nr(t=>typeof t=="string"),Z3=nr(t=>t===Cc),Nm=nr(t=>typeof t=="boolean"),EP=nr(t=>t===Nm),Y3=Im(void 0);Nn(Om,t=>t.shape.length===1&&t.shape[0]===void 0);Im(void 0);const Pm=Im(null),AP=Nn(Om,t=>t.shape.length===1&&t.shape[0]===null);Nn(Uint8Array);Nn(N1,t=>t.shape===Uint8Array);const TP=Uc(jl,Cc,Pm,Y3,L1,Nm,K3);(()=>{const t=j3(cp),e=H3(Cc,cp),n=Uc(jl,Cc,Pm,Nm,t,e);return t.shape=n,e.shape.values=n,n})();const ld=t=>{if(yP.check(t))return t;if(hP.check(t)){const e={};for(const n in t)e[n]=ld(t[n]);return dP(e)}else{if(vP.check(t))return Uc(...t.map(ld));if(TP.check(t))return Im(t);if(xP.check(t))return Nn(t)}mr()},Hk=K9?()=>{}:(t,e)=>{const n=new oP;if(!e.check(t,n))throw To(`Expected value to be of type ${e.constructor.name}.
72
+ ${n.toString()}`)};class MP{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:ld(e),h:n}),this}else(e){return this.if(cp,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const i=this.patterns[r];if(i.if.check(e))return i.h(e,n)}throw To("Unhandled pattern")}}}const DP=t=>new MP(t),J3=DP(cp).if(G3,(t,e)=>Jg(e,Dk,ip)).if(Z3,(t,e)=>rP(e)).if(EP,(t,e)=>Bk(e)).if(SP,(t,e)=>BigInt(Jg(e,Dk,ip))).if(lp,(t,e)=>bl(e,Xg(e,t.shape))).if(fP,(t,e)=>{const n={};for(const r in t.shape){let i=t.shape[r];if(cP.check(i)){if(Bk(e))continue;i=i.shape}n[r]=J3(i,e)}return n}).if(gP,(t,e)=>{const n=[],r=P3(e,0,42);for(let i=0;i<r;i++)n.push(bl(e,t.shape));return n}).if(L3,(t,e)=>Xg(e,t.shape)).if(AP,(t,e)=>null).if(kP,(t,e)=>{const n=bl(e,t.res);return()=>n}).if(CP,(t,e)=>bl(e,Xg(e,[jl,Cc,Pm,Y3,L1,Nm,j3(jl),H3(Uc("a","b","c"),jl)]))).if(pP,(t,e)=>{const n={},r=Jg(e,0,3);for(let i=0;i<r;i++){const o=bl(e,t.shape.keys),s=bl(e,t.shape.values);n[o]=s}return n}).done(),bl=(t,e)=>J3(ld(e),t),ef=typeof document<"u"?document:{};nr(t=>t.nodeType===PP);typeof DOMParser<"u"&&new DOMParser;nr(t=>t.nodeType===IP);nr(t=>t.nodeType===RP);const OP=t=>GN(t,(e,n)=>`${n}:${e};`).join(""),IP=ef.ELEMENT_NODE,RP=ef.TEXT_NODE,NP=ef.DOCUMENT_NODE,PP=ef.DOCUMENT_FRAGMENT_NODE;nr(t=>t.nodeType===NP);const LP=t=>class{constructor(n){this._=n}destroy(){t(this._)}},FP=LP(clearTimeout),F1=(t,e)=>new FP(setTimeout(e,t)),gs=Symbol,X3=gs(),Q3=gs(),zP=gs(),BP=gs(),HP=gs(),$3=gs(),VP=gs(),z1=gs(),UP=gs(),jP=t=>{var i;t.length===1&&((i=t[0])==null?void 0:i.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const o=t[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)e.push(o);else if(o.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const o=t[r];o instanceof Symbol||n.push(o)}return n},qP={[X3]:zo("font-weight","bold"),[Q3]:zo("font-weight","normal"),[zP]:zo("color","blue"),[HP]:zo("color","green"),[BP]:zo("color","grey"),[$3]:zo("color","red"),[VP]:zo("color","purple"),[z1]:zo("color","orange"),[UP]:zo("color","black")},WP=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[],r=Ti();let i=[],o=0;for(;o<t.length;o++){const a=t[o],l=qP[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const c=OP(r);o>0||c.length>0?(e.push("%c"+a),n.push(c)):e.push(a)}else break}}for(o>0&&(i=n,i.unshift(e.join("")));o<t.length;o++){const a=t[o];a instanceof Symbol||i.push(a)}return i},eE=Z9?WP:jP,KP=(...t)=>{console.log(...eE(t)),nE.forEach(e=>e.print(t))},tE=(...t)=>{console.warn(...eE(t)),t.unshift(z1),nE.forEach(e=>e.print(t))},nE=Ja(),rE=t=>({[Symbol.iterator](){return this},next:t}),GP=(t,e)=>rE(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Qg=(t,e)=>rE(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Lm{constructor(e,n){this.clock=e,this.len=n}}class jc{constructor(){this.clients=new Map}}const ea=(t,e,n)=>e.clients.forEach((r,i)=>{const o=t.doc.store.clients.get(i);if(o!=null){const s=o[o.length-1],a=s.id.clock+s.length;for(let l=0,c=r[l];l<r.length&&c.clock<a;c=r[++l])vE(t,o,c.clock,c.len,n)}}),ZP=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const i=Ji((n+r)/2),o=t[i],s=o.clock;if(s<=e){if(e<s+o.len)return i;n=i+1}else r=i-1}return null},qc=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&ZP(n,e.clock)!==null},B1=t=>{t.clients.forEach(e=>{e.sort((i,o)=>i.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){const i=e[r-1],o=e[n];i.clock+i.len>=o.clock?e[r-1]=new Lm(i.clock,Xi(i.len,o.clock+o.len-i.clock)):(r<n&&(e[r]=o),r++)}e.length=r})},Kv=t=>{const e=new jc;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,i)=>{if(!e.clients.has(i)){const o=r.slice();for(let s=n+1;s<t.length;s++)YN(o,t[s].clients.get(i)||[]);e.clients.set(i,o)}});return B1(e),e},cd=(t,e,n,r)=>{Ro(t.clients,e,()=>[]).push(new Lm(n,r))},iE=()=>new jc,oE=t=>{const e=iE();return t.clients.forEach((n,r)=>{const i=[];for(let o=0;o<n.length;o++){const s=n[o];if(s.deleted){const a=s.id.clock;let l=s.length;if(o+1<n.length)for(let c=n[o+1];o+1<n.length&&c.deleted;c=n[++o+1])l+=c.length;i.push(new Lm(a,l))}}i.length>0&&e.clients.set(r,i)}),e},Wc=(t,e)=>{Lt(t.restEncoder,e.clients.size),$s(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Lt(t.restEncoder,n);const i=r.length;Lt(t.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];t.writeDsClock(s.clock),t.writeDsLen(s.len)}})},H1=t=>{const e=new jc,n=It(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const i=It(t.restDecoder),o=It(t.restDecoder);if(o>0){const s=Ro(e.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new Lm(t.readDsClock(),t.readDsLen()))}}return e},Vk=(t,e,n)=>{const r=new jc,i=It(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();const s=It(t.restDecoder),a=It(t.restDecoder),l=n.clients.get(s)||[],c=Tn(n,s);for(let d=0;d<a;d++){const f=t.readDsClock(),h=f+t.readDsLen();if(f<c){c<h&&cd(r,s,c,h-c);let p=Qi(l,f),m=l[p];for(!m.deleted&&m.id.clock<f&&(l.splice(p+1,0,gp(e,m,f-m.id.clock)),p++);p<l.length&&(m=l[p++],m.id.clock<h);)m.deleted||(h<m.id.clock+m.length&&l.splice(p,0,gp(e,m,h-m.id.clock)),m.delete(e))}else cd(r,s,f,h-f)}}if(r.clients.size>0){const o=new Xa;return Lt(o.restEncoder,0),Wc(o,r),o.toUint8Array()}return null},sE=A3;class Mo extends x3{constructor({guid:e=I9(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=sE(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new mE,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Fk(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Fk(c=>{const d=f=>{(f===void 0||f===!0)&&(this.off("sync",d),c())};this.on("sync",d)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&on(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set($s(this.subdocs).map(e=>e.guid))}transact(e,n=null){return on(this,e,n)}get(e,n=$n){const r=Ro(this.share,e,()=>{const o=new n;return o._integrate(this,null),o}),i=r.constructor;if(n!==$n&&i!==n)if(i===$n){const o=new n;o._map=r._map,r._map.forEach(s=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,Kl)}getText(e=""){return this.get(e,ta)}getMap(e=""){return this.get(e,Ec)}getXmlElement(e=""){return this.get(e,bn)}getXmlFragment(e=""){return this.get(e,Qa)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,$s(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Mo({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,on(e.parent.doc,r=>{const i=n.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class aE{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return It(this.restDecoder)}readDsLen(){return It(this.restDecoder)}}class lE extends aE{readLeftID(){return _t(It(this.restDecoder),It(this.restDecoder))}readRightID(){return _t(It(this.restDecoder),It(this.restDecoder))}readClient(){return It(this.restDecoder)}readInfo(){return xc(this.restDecoder)}readString(){return Ul(this.restDecoder)}readParentInfo(){return It(this.restDecoder)===1}readTypeRef(){return It(this.restDecoder)}readLen(){return It(this.restDecoder)}readAny(){return sd(this.restDecoder)}readBuf(){return $9(Xr(this.restDecoder))}readJSON(){return JSON.parse(Ul(this.restDecoder))}readKey(){return Ul(this.restDecoder)}}class YP{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=It(this.restDecoder),this.dsCurrVal}readDsLen(){const e=It(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Sc extends YP{constructor(e){super(e),this.keys=[],It(e),this.keyClockDecoder=new Yg(Xr(e)),this.clientDecoder=new xh(Xr(e)),this.leftClockDecoder=new Yg(Xr(e)),this.rightClockDecoder=new Yg(Xr(e)),this.infoDecoder=new Lk(Xr(e),xc),this.stringDecoder=new A9(Xr(e)),this.parentInfoDecoder=new Lk(Xr(e),xc),this.typeRefDecoder=new xh(Xr(e)),this.lenDecoder=new xh(Xr(e))}readLeftID(){return new ql(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ql(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 sd(this.restDecoder)}readBuf(){return Xr(this.restDecoder)}readJSON(){return sd(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class cE{constructor(){this.restEncoder=$d()}toUint8Array(){return Wi(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Lt(this.restEncoder,e)}writeDsLen(e){Lt(this.restEncoder,e)}}class tf extends cE{writeLeftID(e){Lt(this.restEncoder,e.client),Lt(this.restEncoder,e.clock)}writeRightID(e){Lt(this.restEncoder,e.client),Lt(this.restEncoder,e.clock)}writeClient(e){Lt(this.restEncoder,e)}writeInfo(e){Uv(this.restEncoder,e)}writeString(e){Vl(this.restEncoder,e)}writeParentInfo(e){Lt(this.restEncoder,e?1:0)}writeTypeRef(e){Lt(this.restEncoder,e)}writeLen(e){Lt(this.restEncoder,e)}writeAny(e){kc(this.restEncoder,e)}writeBuf(e){Jr(this.restEncoder,e)}writeJSON(e){Vl(this.restEncoder,JSON.stringify(e))}writeKey(e){Vl(this.restEncoder,e)}}class uE{constructor(){this.restEncoder=$d(),this.dsCurrVal=0}toUint8Array(){return Wi(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,Lt(this.restEncoder,n)}writeDsLen(e){e===0&&mr(),Lt(this.restEncoder,e-1),this.dsCurrVal+=e}}class Xa extends uE{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Zg,this.clientEncoder=new kh,this.leftClockEncoder=new Zg,this.rightClockEncoder=new Zg,this.infoEncoder=new Rk(Uv),this.stringEncoder=new b9,this.parentInfoEncoder=new Rk(Uv),this.typeRefEncoder=new kh,this.lenEncoder=new kh}toUint8Array(){const e=$d();return Lt(e,0),Jr(e,this.keyClockEncoder.toUint8Array()),Jr(e,this.clientEncoder.toUint8Array()),Jr(e,this.leftClockEncoder.toUint8Array()),Jr(e,this.rightClockEncoder.toUint8Array()),Jr(e,Wi(this.infoEncoder)),Jr(e,this.stringEncoder.toUint8Array()),Jr(e,Wi(this.parentInfoEncoder)),Jr(e,this.typeRefEncoder.toUint8Array()),Jr(e,this.lenEncoder.toUint8Array()),Mm(e,Wi(this.restEncoder)),Wi(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?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){kc(this.restEncoder,e)}writeBuf(e){Jr(this.restEncoder,e)}writeJSON(e){kc(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const JP=(t,e,n,r)=>{r=Xi(r,e[0].id.clock);const i=Qi(e,r);Lt(t.restEncoder,e.length-i),t.writeClient(n),Lt(t.restEncoder,r);const o=e[i];o.write(t,r-o.id.clock);for(let s=i+1;s<e.length;s++)e[s].write(t,0)},V1=(t,e,n)=>{const r=new Map;n.forEach((i,o)=>{Tn(e,o)>i&&r.set(o,i)}),nf(e).forEach((i,o)=>{n.has(o)||r.set(o,0)}),Lt(t.restEncoder,r.size),$s(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{JP(t,e.clients.get(i),i,o)})},XP=(t,e)=>{const n=Ti(),r=It(t.restDecoder);for(let i=0;i<r;i++){const o=It(t.restDecoder),s=new Array(o),a=t.readClient();let l=It(t.restDecoder);n.set(a,{i:0,refs:s});for(let c=0;c<o;c++){const d=t.readInfo();switch(Tm&d){case 0:{const f=t.readLen();s[c]=new ki(_t(a,l),f),l+=f;break}case 10:{const f=It(t.restDecoder);s[c]=new xi(_t(a,l),f),l+=f;break}default:{const f=(d&(rs|Ar))===0,h=new ln(_t(a,l),null,(d&Ar)===Ar?t.readLeftID():null,null,(d&rs)===rs?t.readRightID():null,f?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,f&&(d&id)===id?t.readString():null,BE(t,d));s[c]=h,l+=h.length}}}}return n},QP=(t,e,n)=>{const r=[];let i=$s(n.keys()).sort((p,m)=>p-m);if(i.length===0)return null;const o=()=>{if(i.length===0)return null;let p=n.get(i[i.length-1]);for(;p.refs.length===p.i;)if(i.pop(),i.length>0)p=n.get(i[i.length-1]);else return null;return p};let s=o();if(s===null)return null;const a=new mE,l=new Map,c=(p,m)=>{const v=l.get(p);(v==null||v>m)&&l.set(p,m)};let d=s.refs[s.i++];const f=new Map,h=()=>{for(const p of r){const m=p.id.client,v=n.get(m);v?(v.i--,a.clients.set(m,v.refs.slice(v.i)),n.delete(m),v.i=0,v.refs=[]):a.clients.set(m,[p]),i=i.filter(g=>g!==m)}r.length=0};for(;;){if(d.constructor!==xi){const m=Ro(f,d.id.client,()=>Tn(e,d.id.client))-d.id.clock;if(m<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{const v=d.getMissing(t,e);if(v!==null){r.push(d);const g=n.get(v)||{refs:[],i:0};if(g.refs.length===g.i)c(v,Tn(e,v)),h();else{d=g.refs[g.i++];continue}}else(m===0||m<d.length)&&(d.integrate(t,m),f.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(s!==null&&s.i<s.refs.length)d=s.refs[s.i++];else{if(s=o(),s===null)break;d=s.refs[s.i++]}}if(a.clients.size>0){const p=new Xa;return V1(p,a,new Map),Lt(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},$P=(t,e)=>V1(t,e.doc.store,e.beforeState),eL=(t,e,n,r=new Sc(t))=>on(e,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=XP(r,s),c=QP(i,a,l),d=a.pendingStructs;if(d){for(const[h,p]of d.missing)if(p<Tn(a,h)){o=!0;break}if(c){for(const[h,p]of c.missing){const m=d.missing.get(h);(m==null||m>p)&&d.missing.set(h,p)}d.update=dp([d.update,c.update])}}else a.pendingStructs=c;const f=Vk(r,i,a);if(a.pendingDs){const h=new Sc(Hc(a.pendingDs));It(h.restDecoder);const p=Vk(h,i,a);f&&p?a.pendingDs=dp([f,p]):a.pendingDs=f||p}else a.pendingDs=f;if(o){const h=a.pendingStructs.update;a.pendingStructs=null,up(i.doc,h)}},n,!1),up=(t,e,n,r=Sc)=>{const i=Hc(e);eL(i,t,n,new r(i))},tL=(t,e,n)=>up(t,e,n,lE),nL=(t,e,n=new Map)=>{V1(t,e.store,n),Wc(t,oE(e.store))},rL=(t,e=new Uint8Array([0]),n=new Xa)=>{const r=dE(e);nL(n,t,r);const i=[n.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(xL(t.store.pendingStructs.update,e)),i.length>1){if(n.constructor===tf)return wL(i.map((o,s)=>s===0?o:CL(o)));if(n.constructor===Xa)return dp(i)}return i[0]},iL=(t,e)=>rL(t,e,new tf),oL=t=>{const e=new Map,n=It(t.restDecoder);for(let r=0;r<n;r++){const i=It(t.restDecoder),o=It(t.restDecoder);e.set(i,o)}return e},dE=t=>oL(new aE(Hc(t))),fE=(t,e)=>(Lt(t.restEncoder,e.size),$s(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{Lt(t.restEncoder,n),Lt(t.restEncoder,r)}),t),sL=(t,e)=>fE(t,nf(e.store)),aL=(t,e=new uE)=>(t instanceof Map?fE(e,t):sL(e,t),e.toUint8Array()),lL=t=>aL(t,new cE);class cL{constructor(){this.l=[]}}const Uk=()=>new cL,jk=(t,e)=>t.l.push(e),qk=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(i=>e!==i),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},hE=(t,e,n)=>I1(t.l,[e,n]);class ql{constructor(e,n){this.client=e,this.clock=n}}const Pl=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,_t=(t,e)=>new ql(t,e),ud=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw mr()},dd=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class fd{constructor(e,n,r,i=0){this.type=e,this.tname=n,this.item=r,this.assoc=i}}const Ha=t=>new fd(t.type==null?null:_t(t.type.client,t.type.clock),t.tname??null,t.item==null?null:_t(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class uL{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const dL=(t,e,n=0)=>new uL(t,e,n),Rf=(t,e,n)=>{let r=null,i=null;return t._item===null?i=ud(t):r=_t(t._item.id.client,t._item.id.clock),new fd(r,i,e,n)},$g=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Rf(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Rf(t,_t(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Rf(t,r.lastId,n);r=r.right}return Rf(t,null,n)},fL=(t,e)=>{const n=Wl(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},Gv=(t,e,n=!0)=>{const r=e.store,i=t.item,o=t.type,s=t.tname,a=t.assoc;let l=null,c=0;if(i!==null){if(Tn(r,i.client)<=i.clock)return null;const d=n?Xv(r,i):fL(r,i),f=d.item;if(!(f instanceof ln))return null;if(l=f.parent,l._item===null||!l._item.deleted){c=f.deleted||!f.countable?0:d.diff+(a>=0?0:1);let h=f.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(s!==null)l=e.get(s);else if(o!==null){if(Tn(r,o.client)<=o.clock)return null;const{item:d}=n?Xv(r,o):{item:Wl(r,o)};if(d instanceof ln&&d.content instanceof no)l=d.content.type;else return null}else throw mr();a>=0?c=l._length:c=0}return dL(l,c,t.assoc)},Wk=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&Pl(t.item,e.item)&&Pl(t.type,e.type)&&t.assoc===e.assoc;class U1{constructor(e,n){this.ds=e,this.sv=n}}const pE=(t,e)=>new U1(t,e),e0=t=>pE(oE(t.store),nf(t.store)),va=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!qc(e.ds,t.id),Zv=(t,e)=>{const n=Ro(t.meta,Zv,Ja),r=t.doc.store;n.has(e)||(e.sv.forEach((i,o)=>{i<Tn(r,o)&&Br(t,_t(o,i))}),ea(t,e.ds,i=>{}),n.add(e))};class mE{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const nf=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const i=n[n.length-1];e.set(r,i.id.clock+i.length)}),e},Tn=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},gE=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw mr()}n.push(e)},Qi=(t,e)=>{let n=0,r=t.length-1,i=t[r],o=i.id.clock;if(o===e)return r;let s=Ji(e/(o+i.length-1)*r);for(;n<=r;){if(i=t[s],o=i.id.clock,o<=e){if(e<o+i.length)return s;n=s+1}else r=s-1;s=Ji((n+r)/2)}throw mr()},hL=(t,e)=>{const n=t.clients.get(e.client);return n[Qi(n,e.clock)]},Wl=hL,Yv=(t,e,n)=>{const r=Qi(e,n),i=e[r];return i.id.clock<n&&i instanceof ln?(e.splice(r+1,0,gp(t,i,n-i.id.clock)),r+1):r},Br=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Yv(t,n,e.clock)]},Kk=(t,e,n)=>{const r=e.clients.get(n.client),i=Qi(r,n.clock),o=r[i];return n.clock!==o.id.clock+o.length-1&&o.constructor!==ki&&r.splice(i+1,0,gp(t,o,n.clock-o.id.clock+1)),o},pL=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Qi(r,e.id.clock)]=n},vE=(t,e,n,r,i)=>{if(r===0)return;const o=n+r;let s=Yv(t,e,n),a;do a=e[s++],o<a.id.clock+a.length&&Yv(t,e,o),i(a);while(s<e.length&&e[s].id.clock<o)};class mL{constructor(e,n,r){this.doc=e,this.deleteSet=new jc,this.beforeState=nf(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Gk=(t,e)=>e.deleteSet.clients.size===0&&!ZN(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(B1(e.deleteSet),$P(t,e),Wc(t,e.deleteSet),!0),Zk=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Ro(t.changed,e,Ja).add(n)},Ch=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0;n=r,r=t[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof ln&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const o=e-i;return o&&t.splice(e+1-o,o),o},gL=(t,e,n)=>{for(const[r,i]of t.clients.entries()){const o=e.clients.get(r);for(let s=i.length-1;s>=0;s--){const a=i[s],l=a.clock+a.len;for(let c=Qi(o,a.clock),d=o[c];c<o.length&&d.id.clock<l;d=o[++c]){const f=o[c];if(a.clock+a.len<=f.id.clock)break;f instanceof ln&&f.deleted&&!f.keep&&n(f)&&f.gc(e,!1)}}}},vL=(t,e)=>{t.clients.forEach((n,r)=>{const i=e.clients.get(r);for(let o=n.length-1;o>=0;o--){const s=n[o],a=ns(i.length-1,1+Qi(i,s.clock+s.len-1));for(let l=a,c=i[l];l>0&&c.id.clock>=s.clock;c=i[l])l-=1+Ch(i,l)}})},bE=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,i=r.store,o=n.deleteSet,s=n._mergeStructs;try{B1(o),n.afterState=nf(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(d=>d.target._item===null||!d.target._item.deleted),l.forEach(d=>{d.currentTarget=c,d._path=null}),l.sort((d,f)=>d.path.length-f.path.length),a.push(()=>{hE(c._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&zL(n)})}),I1(a,[])}finally{r.gc&&gL(o,i,r.gcFilter),vL(o,i),n.afterState.forEach((d,f)=>{const h=n.beforeState.get(f)||0;if(h!==d){const p=i.clients.get(f),m=Xi(Qi(p,h),1);for(let v=p.length-1;v>=m;)v-=1+Ch(p,v)}});for(let d=s.length-1;d>=0;d--){const{client:f,clock:h}=s[d].id,p=i.clients.get(f),m=Qi(p,h);m+1<p.length&&Ch(p,m+1)>1||m>0&&Ch(p,m)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(KP(z1,X3,"[yjs] ",Q3,$3,"Changed the client-id because another client seems to be using it."),r.clientID=sE()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const d=new tf;Gk(d,n)&&r.emit("update",[d.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const d=new Xa;Gk(d,n)&&r.emit("updateV2",[d.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=n;(a.size>0||c.size>0||l.size>0)&&(a.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),c.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,n]),c.forEach(d=>d.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):bE(t,e+1)}}},on=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let o=!1,s=null;t._transaction===null&&(o=!0,t._transaction=new mL(t,n,r),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{s=e(t._transaction)}finally{if(o){const a=t._transaction===i[0];t._transaction=null,a&&bE(i,0)}}return s};class bL{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Yk=(t,e,n)=>{ea(t,n.deletions,r=>{r instanceof ln&&e.scope.some(i=>i===t.doc||dd(i,r))&&J1(r,!1)})},Jk=(t,e,n)=>{let r=null;const i=t.doc,o=t.scope;on(i,a=>{for(;e.length>0&&t.currStackItem===null;){const l=i.store,c=e.pop(),d=new Set,f=[];let h=!1;ea(a,c.insertions,p=>{if(p instanceof ln){if(p.redone!==null){let{item:m,diff:v}=Xv(l,p.id);v>0&&(m=Br(a,_t(m.id.client,m.id.clock+v))),p=m}!p.deleted&&o.some(m=>m===a.doc||dd(m,p))&&f.push(p)}}),ea(a,c.deletions,p=>{p instanceof ln&&o.some(m=>m===a.doc||dd(m,p))&&!qc(c.insertions,p.id)&&d.add(p)}),d.forEach(p=>{h=zE(a,p,d,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let p=f.length-1;p>=0;p--){const m=f[p];t.deleteFilter(m)&&(m.delete(a),h=!0)}t.currStackItem=h?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},t);const s=t.currStackItem;if(s!=null){const a=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:s,type:n,changedParentTypes:a,origin:t},t]),t.currStackItem=null}return s};class yE extends x3{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:a=wc(e)?e[0].doc:e instanceof Mo?e:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=i,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=s,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(g=>l.changedParentTypes.has(g)||g===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const c=this.undoing,d=this.redoing,f=c?this.redoStack:this.undoStack;c?this.stopCapturing():d||this.clear(!1,!0);const h=new jc;l.afterState.forEach((g,y)=>{const C=l.beforeState.get(y)||0,_=g-C;_>0&&cd(h,y,C,_)});const p=R9();let m=!1;if(this.lastChange>0&&p-this.lastChange<this.captureTimeout&&f.length>0&&!c&&!d){const g=f[f.length-1];g.deletions=Kv([g.deletions,l.deleteSet]),g.insertions=Kv([g.insertions,h])}else f.push(new bL(l.deleteSet,h)),m=!0;!c&&!d&&(this.lastChange=p),ea(l,l.deleteSet,g=>{g instanceof ln&&this.scope.some(y=>y===l.doc||dd(y,g))&&J1(g,!0)});const v=[{stackItem:f[f.length-1],origin:l.origin,type:c?"redo":"undo",changedParentTypes:l.changedParentTypes},this];m?this.emit("stack-item-added",v):this.emit("stack-item-updated",v)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=wc(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof $n?r.doc!==this.doc:r!==this.doc)&&tE("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>Yk(r,this,i)),this.undoStack=[]),n&&(this.redoStack.forEach(i=>Yk(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Jk(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Jk(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*yL(t){const e=It(t.restDecoder);for(let n=0;n<e;n++){const r=It(t.restDecoder),i=t.readClient();let o=It(t.restDecoder);for(let s=0;s<r;s++){const a=t.readInfo();if(a===10){const l=It(t.restDecoder);yield new xi(_t(i,o),l),o+=l}else if((Tm&a)!==0){const l=(a&(rs|Ar))===0,c=new ln(_t(i,o),null,(a&Ar)===Ar?t.readLeftID():null,null,(a&rs)===rs?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(a&id)===id?t.readString():null,BE(t,a));yield c,o+=c.length}else{const l=t.readLen();yield new ki(_t(i,o),l),o+=l}}}}class j1{constructor(e,n){this.gen=yL(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===xi);return this.curr}}class q1{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const wL=t=>dp(t,lE,tf),kL=(t,e)=>{if(t.constructor===ki){const{client:n,clock:r}=t.id;return new ki(_t(n,r+e),t.length-e)}else if(t.constructor===xi){const{client:n,clock:r}=t.id;return new xi(_t(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new ln(_t(r,i+e),null,_t(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},dp=(t,e=Sc,n=Xa)=>{if(t.length===1)return t[0];const r=t.map(d=>new e(Hc(d)));let i=r.map(d=>new j1(d,!0)),o=null;const s=new n,a=new q1(s);for(;i=i.filter(h=>h.curr!==null),i.sort((h,p)=>{if(h.curr.id.client===p.curr.id.client){const m=h.curr.id.clock-p.curr.id.clock;return m===0?h.curr.constructor===p.curr.constructor?0:h.curr.constructor===xi?1:-1:m}else return p.curr.id.client-h.curr.id.client}),i.length!==0;){const d=i[0],f=d.curr.id.client;if(o!==null){let h=d.curr,p=!1;for(;h!==null&&h.id.clock+h.length<=o.struct.id.clock+o.struct.length&&h.id.client>=o.struct.id.client;)h=d.next(),p=!0;if(h===null||h.id.client!==f||p&&h.id.clock>o.struct.id.clock+o.struct.length)continue;if(f!==o.struct.id.client)Ts(a,o.struct,o.offset),o={struct:h,offset:0},d.next();else if(o.struct.id.clock+o.struct.length<h.id.clock)if(o.struct.constructor===xi)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{Ts(a,o.struct,o.offset);const m=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new xi(_t(f,o.struct.id.clock+o.struct.length),m),offset:0}}else{const m=o.struct.id.clock+o.struct.length-h.id.clock;m>0&&(o.struct.constructor===xi?o.struct.length-=m:h=kL(h,m)),o.struct.mergeWith(h)||(Ts(a,o.struct,o.offset),o={struct:h,offset:0},d.next())}}else o={struct:d.curr,offset:0},d.next();for(let h=d.curr;h!==null&&h.id.client===f&&h.id.clock===o.struct.id.clock+o.struct.length&&h.constructor!==xi;h=d.next())Ts(a,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(Ts(a,o.struct,o.offset),o=null),W1(a);const l=r.map(d=>H1(d)),c=Kv(l);return Wc(s,c),s.toUint8Array()},xL=(t,e,n=Sc,r=Xa)=>{const i=dE(e),o=new r,s=new q1(o),a=new n(Hc(t)),l=new j1(a,!1);for(;l.curr;){const d=l.curr,f=d.id.client,h=i.get(f)||0;if(l.curr.constructor===xi){l.next();continue}if(d.id.clock+d.length>h)for(Ts(s,d,Xi(h-d.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)Ts(s,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=h;)l.next()}W1(s);const c=H1(a);return Wc(o,c),o.toUint8Array()},wE=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Wi(t.encoder.restEncoder)}),t.encoder.restEncoder=$d(),t.written=0)},Ts=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&wE(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Lt(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},W1=t=>{wE(t);const e=t.encoder.restEncoder;Lt(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];Lt(e,r.written),Mm(e,r.restEncoder)}},_L=(t,e,n,r)=>{const i=new n(Hc(t)),o=new j1(i,!1),s=new r,a=new q1(s);for(let c=o.curr;c!==null;c=o.next())Ts(a,e(c),0);W1(a);const l=H1(i);return Wc(s,l),s.toUint8Array()},CL=t=>_L(t,j9,Sc,tf),Xk="You must not compute changes after the event-handler fired.";class Fm{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=SL(this.currentTarget,this.target))}deletes(e){return qc(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw To(Xk);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(i=>{if(i!==null){const o=n._map.get(i);let s,a;if(this.adds(o)){let l=o.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(o))if(l!==null&&this.deletes(l))s="delete",a=Wg(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",a=Wg(l.content.getContent())):(s="add",a=void 0)}else if(this.deletes(o))s="delete",a=Wg(o.content.getContent());else return;e.set(i,{action:s,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 To(Xk);const n=this.target,r=Ja(),i=Ja(),o=[];if(e={added:r,deleted:i,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let a=null;const l=()=>{a&&o.push(a)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,i.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const SL=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;n.unshift(r)}e=e._item.parent}return n},hr=()=>{tE("Invalid access: Add Yjs type to a document before reading data.")},kE=80;let K1=0;class EL{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=K1++}}const AL=t=>{t.timestamp=K1++},xE=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=K1++},TL=(t,e,n)=>{if(t.length>=kE){const r=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return xE(r,e,n),r}else{const r=new EL(e,n);return t.push(r),r}},zm=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,s)=>wh(e-o.index)<wh(e-s.index)?o:s);let r=t._start,i=0;for(n!==null&&(r=n.p,i=n.index,AL(n));r.right!==null&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>e;)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&&wh(n.index-i)<r.parent.length/kE?(xE(n,r,i),n):TL(t._searchMarker,r,i)},hd=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let o=i.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(i.index-=o.length);if(o===null||o.marker===!0){t.splice(r,1);continue}i.p=o,o.marker=!0}(e<i.index||n>0&&e===i.index)&&(i.index=Xi(e,i.index+n))}},Bm=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;Ro(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;hE(r._eH,n,e)};class $n{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Uk(),this._dEH=Uk(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Mi()}clone(){throw Mi()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){jk(this._eH,e)}observeDeep(e){jk(this._dEH,e)}unobserve(e){qk(this._eH,e)}unobserveDeep(e){qk(this._dEH,e)}toJSON(){}}const _E=(t,e,n)=>{t.doc??hr(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let o=t._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const s=o.content.getContent();if(s.length<=e)e-=s.length;else{for(let a=e;a<s.length&&r>0;a++)i.push(s[a]),r--;e=0}}o=o.right}return i},CE=t=>{t.doc??hr();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}n=n.right}return e},SE=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&va(r,e)){const i=r.content.getContent();for(let o=0;o<i.length;o++)n.push(i[o])}r=r.right}return n},pd=(t,e)=>{let n=0,r=t._start;for(t.doc??hr();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let o=0;o<i.length;o++)e(i[o],n++,t)}r=r.right}},EE=(t,e)=>{const n=[];return pd(t,(r,i)=>{n.push(e(r,i,t))}),n},ML=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},AE=(t,e)=>{t.doc??hr();const n=zm(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},fp=(t,e,n,r)=>{let i=n;const o=t.doc,s=o.clientID,a=o.store,l=n===null?e._start:n.right;let c=[];const d=()=>{c.length>0&&(i=new ln(_t(s,Tn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new $a(c)),i.integrate(t,0),c=[])};r.forEach(f=>{if(f===null)c.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(f);break;default:switch(d(),f.constructor){case Uint8Array:case ArrayBuffer:i=new ln(_t(s,Tn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new rf(new Uint8Array(f))),i.integrate(t,0);break;case Mo:i=new ln(_t(s,Tn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new of(f)),i.integrate(t,0);break;default:if(f instanceof $n)i=new ln(_t(s,Tn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new no(f)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},TE=()=>To("Length exceeded!"),ME=(t,e,n,r)=>{if(n>e._length)throw TE();if(n===0)return e._searchMarker&&hd(e._searchMarker,n,r.length),fp(t,e,null,r);const i=n,o=zm(e,n);let s=e._start;for(o!==null&&(s=o.p,n-=o.index,n===0&&(s=s.prev,n+=s&&s.countable&&!s.deleted?s.length:0));s!==null;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&Br(t,_t(s.id.client,s.id.clock+n));break}n-=s.length}return e._searchMarker&&hd(e._searchMarker,i,r.length),fp(t,e,s,r)},DL=(t,e,n)=>{let i=(e._searchMarker||[]).reduce((o,s)=>s.index>o.index?s:o,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return fp(t,e,i,n)},DE=(t,e,n,r)=>{if(r===0)return;const i=n,o=r,s=zm(e,n);let a=e._start;for(s!==null&&(a=s.p,n-=s.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&Br(t,_t(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Br(t,_t(a.id.client,a.id.clock+r)),a.delete(t),r-=a.length),a=a.right;if(r>0)throw TE();e._searchMarker&&hd(e._searchMarker,i,-o+r)},hp=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},G1=(t,e,n,r)=>{const i=e._map.get(n)||null,o=t.doc,s=o.clientID;let a;if(r==null)a=new $a([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new $a([r]);break;case Uint8Array:a=new rf(r);break;case Mo:a=new of(r);break;default:if(r instanceof $n)a=new no(r);else throw new Error("Unexpected content type")}new ln(_t(s,Tn(o.store,s)),i,i&&i.lastId,null,null,e,n,a).integrate(t,0)},Z1=(t,e)=>{t.doc??hr();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},OE=t=>{const e={};return t.doc??hr(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},IE=(t,e)=>{t.doc??hr();const n=t._map.get(e);return n!==void 0&&!n.deleted},OL=(t,e)=>{const n={};return t._map.forEach((r,i)=>{let o=r;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&va(o,e)&&(n[i]=o.content.getContent()[o.length-1])}),n},Nf=t=>(t.doc??hr(),GP(t._map.entries(),e=>!e[1].deleted));class IL extends Fm{}class Kl extends $n{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new Kl;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Kl}clone(){const e=new Kl;return e.insert(0,this.toArray().map(n=>n instanceof $n?n.clone():n)),e}get length(){return this.doc??hr(),this._length}_callObserver(e,n){super._callObserver(e,n),Bm(this,e,new IL(this,e))}insert(e,n){this.doc!==null?on(this.doc,r=>{ME(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?on(this.doc,n=>{DL(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?on(this.doc,r=>{DE(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return AE(this,e)}toArray(){return CE(this)}slice(e=0,n=this.length){return _E(this,e,n)}toJSON(){return this.map(e=>e instanceof $n?e.toJSON():e)}map(e){return EE(this,e)}forEach(e){pd(this,e)}[Symbol.iterator](){return ML(this)}_write(e){e.writeTypeRef(r7)}}const RL=t=>new Kl;class NL extends Fm{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Ec extends $n{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new Ec}clone(){const e=new Ec;return this.forEach((n,r)=>{e.set(r,n instanceof $n?n.clone():n)}),e}_callObserver(e,n){Bm(this,e,new NL(this,e,n))}toJSON(){this.doc??hr();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof $n?i.toJSON():i}}),e}get size(){return[...Nf(this)].length}keys(){return Qg(Nf(this),e=>e[0])}values(){return Qg(Nf(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Qg(Nf(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??hr(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?on(this.doc,n=>{hp(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?on(this.doc,r=>{G1(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return Z1(this,e)}has(e){return IE(this,e)}clear(){this.doc!==null?on(this.doc,e=>{this.forEach(function(n,r,i){hp(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(i7)}}const PL=t=>new Ec,Hs=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&V9(t,e);class Jv{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&mr(),this.right.content.constructor){case Rn:this.right.deleted||Kc(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Qk=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Rn:e.right.deleted||Kc(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&Br(t,_t(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},Pf=(t,e,n,r)=>{const i=new Map,o=r?zm(e,n):null;if(o){const s=new Jv(o.p.left,o.p,o.index,i);return Qk(t,s,n-o.index)}else{const s=new Jv(null,e._start,0,i);return Qk(t,s,n)}},RE=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Rn&&Hs(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,o=i.clientID;r.forEach((s,a)=>{const l=n.left,c=n.right,d=new ln(_t(o,Tn(i.store,o)),l,l&&l.lastId,c,c&&c.id,e,null,new Rn(a,s));d.integrate(t,0),n.right=d,n.forward()})},Kc=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},NE=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Rn&&Hs(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},PE=(t,e,n,r)=>{const i=t.doc,o=i.clientID,s=new Map;for(const a in r){const l=r[a],c=n.currentAttributes.get(a)??null;if(!Hs(c,l)){s.set(a,c);const{left:d,right:f}=n;n.right=new ln(_t(o,Tn(i.store,o)),d,d&&d.lastId,f,f&&f.id,e,null,new Rn(a,l)),n.right.integrate(t,0),n.forward()}}return s},t0=(t,e,n,r,i)=>{n.currentAttributes.forEach((h,p)=>{i[p]===void 0&&(i[p]=null)});const o=t.doc,s=o.clientID;NE(n,i);const a=PE(t,e,n,i),l=r.constructor===String?new $i(r):r instanceof $n?new no(r):new dl(r);let{left:c,right:d,index:f}=n;e._searchMarker&&hd(e._searchMarker,n.index,l.getLength()),d=new ln(_t(s,Tn(o.store,s)),c,c&&c.lastId,d,d&&d.id,e,null,l),d.integrate(t,0),n.right=d,n.index=f,n.forward(),RE(t,e,n,a)},$k=(t,e,n,r,i)=>{const o=t.doc,s=o.clientID;NE(n,i);const a=PE(t,e,n,i);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Rn));){if(!n.right.deleted)switch(n.right.content.constructor){case Rn:{const{key:l,value:c}=n.right.content,d=i[l];if(d!==void 0){if(Hs(d,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}n.right.delete(t)}else n.currentAttributes.set(l,c);break}default:r<n.right.length&&Br(t,_t(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
73
+ `;n.right=new ln(_t(s,Tn(o.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new $i(l)),n.right.integrate(t,0),n.forward()}RE(t,e,n,a)},LE=(t,e,n,r,i)=>{let o=e;const s=Ti();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===Rn){const c=o.content;s.set(c.key,c)}o=o.right}let a=0,l=!1;for(;e!==o;){if(n===e&&(l=!0),!e.deleted){const c=e.content;switch(c.constructor){case Rn:{const{key:d,value:f}=c,h=r.get(d)??null;(s.get(d)!==c||h===f)&&(e.delete(t),a++,!l&&(i.get(d)??null)===f&&h!==f&&(h===null?i.delete(d):i.set(d,h))),!l&&!e.deleted&&Kc(i,c);break}}}e=e.right}return a},LL=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Rn){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},FL=t=>{let e=0;return on(t.doc,n=>{let r=t._start,i=t._start,o=Ti();const s=Hv(o);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Rn:Kc(s,i.content);break;default:e+=LE(n,r,i,o,s),o=Hv(s),r=i;break}i=i.right}}),e},zL=t=>{const e=new Set,n=t.doc;for(const[r,i]of t.afterState.entries()){const o=t.beforeState.get(r)||0;i!==o&&vE(t,n.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===Rn&&s.constructor!==ki&&e.add(s.parent)})}on(n,r=>{ea(t,t.deleteSet,i=>{if(i instanceof ki||!i.parent._hasFormatting||e.has(i.parent))return;const o=i.parent;i.content.constructor===Rn?e.add(o):LL(r,i)});for(const i of e)FL(i)})},ex=(t,e,n)=>{const r=n,i=Hv(e.currentAttributes),o=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case no:case dl:case $i:n<e.right.length&&Br(t,_t(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}o&&LE(t,o,e.right,i,e.currentAttributes);const s=(e.left||e.right).parent;return s._searchMarker&&hd(s._searchMarker,e.index,-r+n),e};class BL extends Fm{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];on(e,r=>{const i=new Map,o=new Map;let s=this.target._start,a=null;const l={};let c="",d=0,f=0;const h=()=>{if(a!==null){let p=null;switch(a){case"delete":f>0&&(p={delete:f}),f=0;break;case"insert":(typeof c=="object"||c.length>0)&&(p={insert:c},i.size>0&&(p.attributes={},i.forEach((m,v)=>{m!==null&&(p.attributes[v]=m)}))),c="";break;case"retain":d>0&&(p={retain:d},H9(l)||(p.attributes=z9({},l))),d=0;break}p&&n.push(p),a=null}};for(;s!==null;){switch(s.content.constructor){case no:case dl:this.adds(s)?this.deletes(s)||(h(),a="insert",c=s.content.getContent()[0],h()):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),f+=1):s.deleted||(a!=="retain"&&(h(),a="retain"),d+=1);break;case $i:this.adds(s)?this.deletes(s)||(a!=="insert"&&(h(),a="insert"),c+=s.content.str):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),f+=s.length):s.deleted||(a!=="retain"&&(h(),a="retain"),d+=s.length);break;case Rn:{const{key:p,value:m}=s.content;if(this.adds(s)){if(!this.deletes(s)){const v=i.get(p)??null;Hs(v,m)?m!==null&&s.delete(r):(a==="retain"&&h(),Hs(m,o.get(p)??null)?delete l[p]:l[p]=m)}}else if(this.deletes(s)){o.set(p,m);const v=i.get(p)??null;Hs(v,m)||(a==="retain"&&h(),l[p]=v)}else if(!s.deleted){o.set(p,m);const v=l[p];v!==void 0&&(Hs(v,m)?v!==null&&s.delete(r):(a==="retain"&&h(),m===null?delete l[p]:l[p]=m))}s.deleted||(a==="insert"&&h(),Kc(i,s.content));break}}s=s.right}for(h();n.length>0;){const p=n[n.length-1];if(p.retain!==void 0&&p.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class ta extends $n{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??hr(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ta}clone(){const e=new ta;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new BL(this,e,n);Bm(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??hr();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===$i&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?on(this.doc,r=>{const i=new Jv(null,this._start,0,new Map);for(let o=0;o<e.length;o++){const s=e[o];if(s.insert!==void 0){const a=!n&&typeof s.insert=="string"&&o===e.length-1&&i.right===null&&s.insert.slice(-1)===`
74
+ `?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&t0(r,this,i,a,s.attributes||{})}else s.retain!==void 0?$k(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&ex(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??hr();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const f={};let h=!1;o.forEach((m,v)=>{h=!0,f[v]=m});const p={insert:a};h&&(p.attributes=f),i.push(p),a=""}}const d=()=>{for(;l!==null;){if(va(l,e)||n!==void 0&&va(l,n))switch(l.content.constructor){case $i:{const f=o.get("ychange");e!==void 0&&!va(l,e)?(f===void 0||f.user!==l.id.client||f.type!=="removed")&&(c(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!va(l,n)?(f===void 0||f.user!==l.id.client||f.type!=="added")&&(c(),o.set("ychange",r?r("added",l.id):{type:"added"})):f!==void 0&&(c(),o.delete("ychange")),a+=l.content.str;break}case no:case dl:{c();const f={insert:l.content.getContent()[0]};if(o.size>0){const h={};f.attributes=h,o.forEach((p,m)=>{h[m]=p})}i.push(f);break}case Rn:va(l,e)&&(c(),Kc(o,l.content));break}l=l.right}c()};return e||n?on(s,f=>{e&&Zv(f,e),n&&Zv(f,n),d()},"cleanup"):d(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?on(i,o=>{const s=Pf(o,this,e,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),t0(o,this,s,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?on(i,o=>{const s=Pf(o,this,e,!r);t0(o,this,s,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?on(r,i=>{ex(i,Pf(i,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const i=this.doc;i!==null?on(i,o=>{const s=Pf(o,this,e,!1);s.right!==null&&$k(o,this,s,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?on(this.doc,n=>{hp(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?on(this.doc,r=>{G1(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return Z1(this,e)}getAttributes(){return OE(this)}_write(e){e.writeTypeRef(o7)}}const HL=t=>new ta;class n0{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??hr()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===bn||n.constructor===Qa)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=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})}}class Qa extends $n{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Qa}clone(){const e=new Qa;return e.insert(0,this.toArray().map(n=>n instanceof $n?n.clone():n)),e}get length(){return this.doc??hr(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new n0(this,e)}querySelector(e){e=e.toUpperCase();const r=new n0(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),$s(new n0(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Bm(this,e,new jL(this,n,e))}toString(){return EE(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),pd(this,o=>{i.insertBefore(o.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?on(this.doc,r=>{ME(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)on(this.doc,r=>{const i=e&&e instanceof $n?e._item:e;fp(r,this,i,n)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(o=>o===e)+1;if(i===0&&e!==null)throw To("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?on(this.doc,r=>{DE(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return CE(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return AE(this,e)}slice(e=0,n=this.length){return _E(this,e,n)}forEach(e){pd(this,e)}_write(e){e.writeTypeRef(a7)}}const VL=t=>new Qa;class bn extends Qa{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new bn(this.nodeName)}clone(){const e=new bn(this.nodeName),n=this.getAttributes();return B9(n,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof $n?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const a in e)r.push(a);r.sort();const i=r.length;for(let a=0;a<i;a++){const l=r[a];n.push(l+'="'+e[l]+'"')}const o=this.nodeName.toLocaleLowerCase(),s=n.length>0?" "+n.join(" "):"";return`<${o}${s}>${super.toString()}</${o}>`}removeAttribute(e){this.doc!==null?on(this.doc,n=>{hp(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?on(this.doc,r=>{G1(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return Z1(this,e)}hasAttribute(e){return IE(this,e)}getAttributes(e){return e?OL(this,e):OE(this)}toDOM(e=document,n={},r){const i=e.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const a=o[s];typeof a=="string"&&i.setAttribute(s,a)}return pd(this,s=>{i.appendChild(s.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(s7),e.writeKey(this.nodeName)}}const UL=t=>new bn(t.readKey());class jL extends Fm{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class pp extends Ec{constructor(e){super(),this.hookName=e}_copy(){return new pp(this.hookName)}clone(){const e=new pp(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const i=n[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(l7),e.writeKey(this.hookName)}}const qL=t=>new pp(t.readKey());class In extends ta{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new In}clone(){const e=new In;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const n=[];for(const i in e.attributes){const o=[];for(const s in e.attributes[i])o.push({key:s,value:e.attributes[i][s]});o.sort((s,a)=>s.key<a.key?-1:1),n.push({nodeName:i,attrs:o})}n.sort((i,o)=>i.nodeName<o.nodeName?-1:1);let r="";for(let i=0;i<n.length;i++){const o=n[i];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){const a=o.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=e.insert;for(let i=n.length-1;i>=0;i--)r+=`</${n[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(c7)}}const WL=t=>new In;class Y1{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Mi()}mergeWith(e){return!1}write(e,n,r){throw Mi()}integrate(e,n){throw Mi()}}const KL=0;class ki extends Y1{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),gE(e.doc.store,this)}write(e,n){e.writeInfo(KL),e.writeLen(this.length-n)}getMissing(e,n){return null}}class rf{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new rf(this.content)}splice(e){throw Mi()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const GL=t=>new rf(t.readBuf());class md{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new md(this.len)}splice(e){const n=new md(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){cd(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const ZL=t=>new md(t.readLen()),FE=(t,e)=>new Mo({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class of{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;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new of(FE(this.doc.guid,this.opts))}splice(e){throw Mi()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,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,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const YL=t=>new of(FE(t.readString(),t.readAny()));class dl{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new dl(this.embed)}splice(e){throw Mi()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const JL=t=>new dl(t.readJSON());class Rn{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Rn(this.key,this.value)}splice(e){throw Mi()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const XL=t=>new Rn(t.readKey(),t.readJSON());class mp{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new mp(this.arr)}splice(e){const n=new mp(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}const QL=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const i=t.readString();i==="undefined"?n.push(void 0):n.push(JSON.parse(i))}return new mp(n)},$L=sp("node_env")==="development";class $a{constructor(e){this.arr=e,$L&&O3(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new $a(this.arr)}splice(e){const n=new $a(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];e.writeAny(o)}}getRef(){return 8}}const e7=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new $a(n)};class $i{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new $i(this.str)}splice(e){const n=new $i(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const t7=t=>new $i(t.readString()),n7=[RL,PL,HL,UL,VL,qL,WL],r7=0,i7=1,o7=2,s7=3,a7=4,l7=5,c7=6;class no{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new no(this.type._copy())}splice(e){throw Mi()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const u7=t=>new no(n7[t.readTypeRef()](t)),Xv=(t,e)=>{let n=e,r=0,i;do r>0&&(n=_t(n.client,n.clock+r)),i=Wl(t,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof ln);return{item:i,diff:r}},J1=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},gp=(t,e,n)=>{const{client:r,clock:i}=e.id,o=new ln(_t(r,i+n),e,_t(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=_t(e.redone.client,e.redone.clock+n)),e.right=o,o.right!==null&&(o.right.left=o),t._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=n,o},tx=(t,e)=>E1(t,n=>qc(n.deletions,e)),zE=(t,e,n,r,i,o)=>{const s=t.doc,a=s.store,l=s.clientID,c=e.redone;if(c!==null)return Br(t,c);let d=e.parent._item,f=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!n.has(d)||zE(t,d,n,r,i,o)===null))return null;for(;d.redone!==null;)d=Br(t,d.redone)}const p=d===null?e.parent:d.content.type;if(e.parentSub===null){for(f=e.left,h=e;f!==null;){let y=f;for(;y!==null&&y.parent._item!==d;)y=y.redone===null?null:Br(t,y.redone);if(y!==null&&y.parent._item===d){f=y;break}f=f.left}for(;h!==null;){let y=h;for(;y!==null&&y.parent._item!==d;)y=y.redone===null?null:Br(t,y.redone);if(y!==null&&y.parent._item===d){h=y;break}h=h.right}}else if(h=null,e.right&&!i){for(f=e;f!==null&&f.right!==null&&(f.right.redone||qc(r,f.right.id)||tx(o.undoStack,f.right.id)||tx(o.redoStack,f.right.id));)for(f=f.right;f.redone;)f=Br(t,f.redone);if(f&&f.right!==null)return null}else f=p._map.get(e.parentSub)||null;const m=Tn(a,l),v=_t(l,m),g=new ln(v,f,f&&f.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=v,J1(g,!0),g.integrate(t,0),g};let ln=class Qv extends Y1{constructor(e,n,r,i,o,s,a,l){super(e,l.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=o,this.parent=s,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?Mk:0}set marker(e){(this.info&Gg)>0!==e&&(this.info^=Gg)}get marker(){return(this.info&Gg)>0}get keep(){return(this.info&Tk)>0}set keep(e){this.keep!==e&&(this.info^=Tk)}get countable(){return(this.info&Mk)>0}get deleted(){return(this.info&Kg)>0}set deleted(e){this.deleted!==e&&(this.info^=Kg)}markDeleted(){this.info|=Kg}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Tn(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Tn(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ql&&this.id.client!==this.parent.client&&this.parent.clock>=Tn(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Kk(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Br(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===ki||this.right&&this.right.constructor===ki)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Qv?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Qv&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ql){const r=Wl(n,this.parent);r.constructor===ki?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=Kk(e,e.doc.store,_t(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,s=new Set;for(;i!==null&&i!==this.right;){if(s.add(i),o.add(i),Pl(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(Pl(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(Wl(e.doc.store,i.origin)))o.has(Wl(e.doc.store,i.origin))||(r=i,o.clear());else break;i=i.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),gE(e.doc.store,this),this.content.integrate(e,this),Zk(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new ki(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:_t(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Pl(e.origin,this.lastId)&&this.right===e&&Pl(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)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.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){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),cd(e.deleteSet,this.id.client,this.id.clock,this.length),Zk(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw mr();this.content.gc(e),n?pL(e,this,new ki(this.id,this.length)):this.content=new md(this.length)}write(e,n){const r=n>0?_t(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&Tm|(r===null?0:Ar)|(i===null?0:rs)|(o===null?0:id);if(e.writeInfo(s),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=ud(a);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===ql?(e.writeParentInfo(!1),e.writeLeftID(a)):mr();o!==null&&e.writeString(o)}this.content.write(e,n)}};const BE=(t,e)=>d7[e&Tm](t),d7=[()=>{mr()},ZL,QL,GL,t7,JL,XL,u7,e7,YL,()=>{mr()}],f7=10;class xi extends Y1{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){mr()}write(e,n){e.writeInfo(f7),Lt(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const HE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},VE="__ $YJS$ __";HE[VE]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");HE[VE]=!0;const h7={anthropic:"Claude",openai:"GPT",gemini:"Gemini","local-ollama":"Local model","local-llamacpp":"Local model"},nx="Assistant";function p7(t){const e=t.defaultModelId?t.models.find(n=>n.id===t.defaultModelId):void 0;return e||(t.models.length===1?t.models[0]:void 0)}function $v(t,e){const n=p7(t);if(!n)return nx;const r=h7[n.provider]||nx;return e==="family"?r:n.displayName||n.modelId||r}function No(t){const e=L(()=>$v(t.settings,"family")),n=L(()=>$v(t.settings,"model"));return{get family(){return u(e)},get specific(){return u(n)}}}function UE(t){return t?t+1:0}function Hm(t){let e=0;return t.forEach(n=>{n.isText?e+=n.text.length:n.type.name==="hardBreak"&&(e+=1)}),e}function sf(t){if(t.isTextblock)return Hm(t);let e=0;for(let n=0;n<t.childCount;n++)n>0&&(e+=1),e+=sf(t.child(n));return e}function jE(t,e,n){if(t.isTextblock)return zn(n+Math.min(e,Hm(t)));let r=0,i=n;for(let o=0;o<t.childCount;o++){const s=t.child(o),a=i+1;o>0&&(r+=1);const l=sf(s);if(r+l>e)return jE(s,e-r,a);r+=l,i+=s.nodeSize}return zn(n+t.content.size)}function na(t,e){let n=0,r=0;const i=t.childCount;for(let o=0;o<i;o++){const s=t.child(o),a=r+1,l=s.type.name==="heading"?UE(s.attrs.level||1):0,c=sf(s),d=l+c;if(n+d>e){const f=e-n,h=Math.max(0,f-l);return jE(s,h,a)}if(n+=d,r+=s.nodeSize,o<i-1&&(n+=1,n>e))return zn(a+s.content.size)}return zn(t.content.size)}function qE(t,e,n){if(t.isTextblock)return Math.min(e-n,Hm(t));let r=0,i=n;for(let o=0;o<t.childCount;o++){const s=t.child(o),a=i+1;o>0&&(r+=1);const l=i+s.nodeSize;if(e<l)return e<=a?r:r+qE(s,e,a);r+=sf(s),i+=s.nodeSize}return r}function wi(t,e){let n=0,r=0;const i=t.childCount;for(let o=0;o<i;o++){const s=t.child(o),a=r+1,l=s.type.name==="heading"?UE(s.attrs.level||1):0,c=sf(s),d=r+s.nodeSize;if(e<d)return e<=a?mh(n+l):mh(n+l+qE(s,e,a));n+=l+c,r+=s.nodeSize,o<i-1&&(n+=1)}return mh(n)}function WE(t,e,n,r){if(e.isTextblock){let s=0;for(let a=0;a<t.length;a++){const l=t.get(a);if(l instanceof In){if(l===r.type)return zn(n+Math.min(s+r.index,Hm(e)));s+=l.length}}return null}let i=n;t.length!==e.childCount&&console.warn(`[positions] Y.js/PM child count mismatch: yEl(${t.nodeName}).length=${t.length} vs pmNode(${e.type.name}).childCount=${e.childCount}`);const o=Math.min(t.length,e.childCount);for(let s=0;s<o;s++){const a=t.get(s),l=e.child(s),c=i+1;if(a instanceof bn){const d=WE(a,l,c,r);if(d!==null)return d}i+=l.nodeSize}return null}function rx(t,e,n){let r=0;const i=Math.min(t.childCount,e.length);for(let o=0;o<i;o++){const s=e.get(o),a=t.child(o),l=r+1;if(s instanceof bn){const c=WE(s,a,l,n);if(c!==null)return c}r+=a.nodeSize}return null}function KE(t,e,n){let r,i;try{const l=Ha(n.fromRel),c=Ha(n.toRel);r=Gv(l,t),i=Gv(c,t)}catch(l){return console.warn("[positions] relRangeToPmPositions: failed to resolve relRange:",l),null}if(!r||!i)return null;const o=t.getXmlFragment("default"),s=rx(e,o,r),a=rx(e,o,i);return s===null||a===null?null:{from:s,to:a}}function Ac(t,e,n){if(t.relRange&&n){const r=KE(n,e,t.relRange);if(r&&r.from<=r.to)return{...r,method:"rel"};console.warn(r?`[positions] annotationToPmRange: inverted rel range for ${t.id}, falling back to flat`:`[positions] annotationToPmRange: relRange resolved to null for ${t.id}, falling back to flat`)}return t.range?{from:na(e,t.range.from),to:na(e,t.range.to),method:"flat"}:null}function GE(t,e){return{from:wi(t,e.from),to:wi(t,e.to)}}function m7(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function g7(t){const e=m7(t),n=[];let r=e.replace(/```(\w*)\n?([\s\S]*?)```/g,(i,o,s)=>{const a=n.length,l=o?` class="language-${o}"`:"";return n.push(`<pre><code${l}>${s.trimEnd()}</code></pre>`),`\0BLOCK${a}\0`});r=r.replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`([^`\n]+)`/g,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,o,s)=>{const a=s.trim();return/^(https?:\/\/|mailto:|#)/i.test(a)?`<a href="${a}" target="_blank" rel="noopener noreferrer">${o}</a>`:o}).replace(/^[*-] (.+)$/gm,"<li>$1</li>").replace(/\n\n/g,"</p><p>").replace(/\n/g,"<br>");for(let i=0;i<n.length;i++)r=r.replace(`\0BLOCK${i}\0`,n[i]);return r}var v7=T('<span style="background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill); padding: 2px 8px; font-size: var(--tandem-text-xs);"> </span>'),b7=T('<button title="Clear chat history" data-testid="clear-chat-btn" style="background: none; border: none; cursor: pointer; color: var(--tandem-fg-subtle); font-size: 13px; padding: 2px 4px; line-height: 1;">Clear</button>'),y7=T('<div style="color: var(--tandem-fg-subtle); font-size: 13px; text-align: center; margin-top: 24px;">No messages yet. Select text and send a message to your AI.</div>'),w7=T('<span style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-muted); background: var(--tandem-surface-muted); padding: 1px 6px; border-radius: var(--tandem-r-2);"> </span>'),k7=T('<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>'),x7=T('<div class="chat-markdown svelte-15oag3v"></div>'),_7=T('<div style="white-space: pre-wrap; word-break: break-word;"> </div>'),C7=T('<div><div style="display: flex; gap: 6px; align-items: center; margin-bottom: 4px;"><span> </span> <!> <span style="font-size: 10px; color: var(--tandem-fg-subtle); margin-left: auto;"> </span></div> <!> <!></div>'),S7=T("<span></span>"),E7=T('<div style="padding: var(--tandem-space-2) var(--tandem-space-3); margin-bottom: var(--tandem-space-2); font-size: 12px; color: var(--tandem-author-claude); display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="display: inline-flex; gap: 3px;"></span> <span> </span></div>'),A7=T('<div style="padding: var(--tandem-space-1) var(--tandem-space-3); background: var(--tandem-accent-bg); border-top: 1px solid var(--tandem-accent-border); font-size: 11px; color: var(--tandem-accent-fg-strong); display: flex; justify-content: space-between; align-items: center;"><span> </span> <button style="background: none; border: none; cursor: pointer; color: var(--tandem-fg-muted); font-size: 14px;">x</button></div>'),T7=T('<div style="width: 100%; display: flex; flex-direction: column; background: var(--tandem-surface-muted); flex: 1; min-height: 0;"><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); font-weight: 600; font-size: var(--tandem-text-md); display: flex; justify-content: space-between; align-items: center;">Chat <div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><!> <!></div></div> <div class="tandem-scroll-fade-y" style="flex: 1; overflow: auto; padding: var(--tandem-space-3); min-height: 0;"><!> <!> <!> <div></div></div> <!> <div class="chat-composer-outer svelte-15oag3v"><div class="chat-composer svelte-15oag3v"><textarea placeholder="Message your AI..." class="chat-composer-input svelte-15oag3v"></textarea> <button>Send</button></div></div></div>');function ix(t,e){nt(e,!0);const n=[0,.2,.4],r=No(ai());let i=Ze(e,"inputEl",15,null);const o=L(()=>e.reduceMotion?"auto":"smooth");let s=F(tt([])),a=F(""),l=F(void 0),c=F(void 0);pe(()=>{i(u(c)??null)}),pe(()=>{if(!e.ctrlYdoc)return;const q=e.ctrlYdoc.getMap(Aw),V=()=>{const re=[];q.forEach(te=>{re.push(te)}),re.sort((te,Z)=>te.timestamp-Z.timestamp||te.id.localeCompare(Z.id)),b(s,re,!0)};return q.observe(V),V(),()=>q.unobserve(V)});let d=!1;pe(()=>{var re;u(s);const q=!!e.claudeActive,V=Ct(()=>u(o));if(!q&&d){d=!1;return}d=q,(re=u(l))==null||re.scrollIntoView({behavior:V})}),pe(()=>{var re;const q=e.visible,V=Ct(()=>u(o));q&&((re=u(l))==null||re.scrollIntoView({behavior:V}))});const f=L(()=>u(s).filter(q=>q.author==="claude"&&!q.read).length);function h(){if(!e.ctrlYdoc||!u(a).trim())return;const q=e.ctrlYdoc.getMap(Aw),V={id:uO(),author:"user",text:u(a).trim(),timestamp:Date.now(),...e.activeDocId?{documentId:e.activeDocId}:{},...e.capturedAnchor?{anchor:e.capturedAnchor}:{},read:!1};q.set(V.id,V),b(a,""),e.onCapturedAnchorChange(null),window.dispatchEvent(new CustomEvent("tandem:addressed-ai",{detail:{via:"chat"}}))}function p(q){q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),h())}function m(q,V){if(!(!e.editor||V&&V!==e.activeDocId))try{const re=na(e.editor.state.doc,q.from),te=na(e.editor.state.doc,q.to);e.editor.chain().focus().setTextSelection({from:re,to:te}).scrollIntoView().run()}catch(re){console.warn("[ChatPanel] Could not scroll to anchor:",re instanceof Error?re.message:re)}}function v(q){if(!q)return null;const V=e.openDocs.find(re=>re.id===q);return(V==null?void 0:V.fileName)??null}async function g(){try{await fetch(`http://127.0.0.1:${Gi}${MO}`,{method:"DELETE"})}catch(q){console.warn("[ChatPanel] Failed to clear chat:",q)}}let y=F(tt(new Set));function C(q){const V=new Set(u(y));V.has(q)?V.delete(q):V.add(q),b(y,V,!0)}var _=T7(),S=w(_),A=k(w(S)),O=w(A);{var E=q=>{var V=v7(),re=w(V);W(()=>G(re,u(f))),x(q,V)};j(O,q=>{u(f)>0&&q(E)})}var M=k(O,2);{var R=q=>{var V=b7();P("click",V,g),x(q,V)};j(M,q=>{u(s).length>0&&q(R)})}var D=k(S,2),I=w(D);{var H=q=>{var V=y7();x(q,V)};j(I,q=>{u(s).length===0&&q(H)})}var z=k(I,2);mt(z,17,()=>u(s),q=>q.id,(q,V)=>{var re=C7(),te=w(re),Z=w(te),ge=w(Z),Ie=k(Z,2);{var Se=Re=>{var ze=w7(),Je=w(ze);W(ue=>G(Je,ue),[()=>v(u(V).documentId)??u(V).documentId]),x(Re,ze)};j(Ie,Re=>{u(V).documentId&&Re(Se)})}var fe=k(Ie,2),_e=w(fe),X=k(te,2);{var ye=Re=>{var ze=k7(),Je=w(ze);W(ue=>{Pe(ze,`background: var(--tandem-accent-bg); border: none; border-left: 3px solid var(--tandem-accent-border); padding: 4px 8px; margin-bottom: 6px; font: inherit; color: var(--tandem-accent-fg-strong); cursor: pointer; text-align: left; width: 100%; font-size: var(--tandem-text-sm); border-radius: 0 var(--tandem-r-2) var(--tandem-r-2) 0; max-height: ${ue??""}; overflow: hidden; transition: max-height 0.3s ease;`),G(Je,u(V).anchor.textSnapshot)},[()=>u(y).has(u(V).id)?"500px":"60px"]),P("click",ze,()=>m(u(V).anchor,u(V).documentId)),Qt("mouseenter",ze,()=>C(u(V).id)),Qt("mouseleave",ze,()=>C(u(V).id)),x(Re,ze)};j(X,Re=>{u(V).anchor&&Re(ye)})}var Y=k(X,2);{var se=Re=>{var ze=x7();$M(ze,()=>g7(u(V).text),!0),x(Re,ze)},Te=Re=>{var ze=_7(),Je=w(ze);W(()=>G(Je,u(V).text)),x(Re,ze)};j(Y,Re=>{u(V).author==="claude"?Re(se):Re(Te,-1)})}W(Re=>{Pe(re,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${u(V).author==="user"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; border: 1px solid ${u(V).author==="user"?"var(--tandem-accent-border)":"var(--tandem-border)"}; font-size: var(--tandem-text-base); color: var(--tandem-fg); box-shadow: var(--tandem-shadow-1);`),Pe(Z,`font-weight: 600; font-size: 11px; color: ${u(V).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"}; text-transform: uppercase;`),G(ge,u(V).author==="claude"?r.family:"You"),G(_e,Re)},[()=>new Date(u(V).timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]),x(q,re)});var Q=k(z,2);{var ie=q=>{var V=E7(),re=w(V);mt(re,20,()=>n,ge=>ge,(ge,Ie)=>{var Se=S7();W(()=>Pe(Se,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${Ie??""}s infinite;`)),x(ge,Se)});var te=k(re,2),Z=w(te);W(()=>G(Z,e.claudeStatus??"Your AI is thinking...")),x(q,V)};j(Q,q=>{e.claudeActive&&q(ie)})}var me=k(Q,2);Dt(me,q=>b(l,q),()=>u(l)),qr(D,(q,V)=>$t==null?void 0:$t(q,V),()=>"y");var le=k(D,2);{var ke=q=>{var V=A7(),re=w(V),te=w(re),Z=k(re,2);W(ge=>G(te,`with selection: “${ge??""}${e.capturedAnchor.textSnapshot.length>40?"...":""}”`),[()=>e.capturedAnchor.textSnapshot.slice(0,40)]),P("click",Z,()=>e.onCapturedAnchorChange(null)),x(q,V)};j(le,q=>{e.capturedAnchor&&q(ke)})}var ce=k(le,2),ve=w(ce),De=w(ve);U(De,"rows",2),Dt(De,q=>b(c,q),()=>u(c));var ee=k(De,2);W((q,V)=>{Vr(De,u(a)),ee.disabled=q,bt(ee,1,V,"svelte-15oag3v")},[()=>!u(a).trim(),()=>"chat-composer-send"+(u(a).trim()?" on":"")]),P("input",De,q=>b(a,q.target.value,!0)),P("keydown",De,p),P("click",ee,h),x(t,_),rt()}lt(["click","input","keydown"]);var M7=T('<button type="button" data-testid="apply-changes-btn"> </button>');function D7(t,e){nt(e,!0);let n=F(!1);const r=L(()=>e.annotations.filter(d=>d.status==="accepted")),i=L(()=>e.annotations.filter(d=>d.status==="pending")),o=L(()=>u(r).length===0||u(n));async function s(){if(u(o)||!e.documentId)return;let d=`Apply ${u(r).length} change(s) as tracked revisions?
75
+
76
+ The changes will appear as tracked revisions in Word — you can Accept or Reject each one individually.
77
+
78
+ Your original file will be backed up.`;if(u(i).length>0&&(d+=`
79
+
80
+ ⚠ ${u(i).length} annotation(s) are still pending review and will not be applied.`),!!confirm(d)){b(n,!0);try{const f=await fetch(`${nn}${wO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})}),h=await f.json().catch(m=>(console.error("[ApplyChanges] Failed to parse response JSON:",m),null));if(!f.ok){alert((h==null?void 0:h.message)??`Apply failed (HTTP ${f.status}).`);return}const p=h==null?void 0:h.data;if(p){const m=[`Applied ${p.applied??0} tracked change(s).`];p.rejected>0&&m.push(`${p.rejected} could not be applied.`),p.backupPath&&m.push(`
81
+ Backup saved to:
82
+ ${p.backupPath}`),alert(m.join(" "))}else alert("Changes applied successfully.")}catch(f){console.error("[ApplyChanges] Request failed:",f),alert(f instanceof TypeError?"Could not reach the server.":`Apply failed: ${f instanceof Error?f.message:String(f)}`)}finally{b(n,!1)}}}var a=St(),l=Ae(a);{var c=d=>{var f=M7();let h;var p=w(f);W(()=>{h=bt(f,1,"acb-btn svelte-hdlegv",null,h,{"is-disabled":u(o),"is-applying":u(n)}),f.disabled=u(o),U(f,"title",u(r).length===0?"No accepted suggestions to apply":void 0),G(p,u(n)?"Applying…":`Apply as Tracked Changes (${u(r).length})`)}),P("click",f,s),x(d,f)};j(l,d=>{e.activeDocFormat==="docx"&&d(c)})}x(t,a),rt()}lt(["click"]);function ZE(t,e){return t.id<e.id?-1:t.id>e.id?1:0}function ku(t){return[...t].sort((e,n)=>{var o,s;const r=Number.isFinite((o=e.range)==null?void 0:o.from)?e.range.from:Number.POSITIVE_INFINITY,i=Number.isFinite((s=n.range)==null?void 0:s.from)?n.range.from:Number.POSITIVE_INFINITY;return r!==i?r<i?-1:1:ZE(e,n)})}function O7(t){return[...t].sort((e,n)=>{const r=Number.isFinite(e.timestamp)?e.timestamp:0,i=Number.isFinite(n.timestamp)?n.timestamp:0,o=r-i;return o!==0?o:ZE(e,n)})}function ox(t,e){return e==="chronological"?O7(t):ku(t)}function YE(t,e){if(!e)return-1;for(let n=0;n<t.length;n++)if(t[n].id===e)return n;return-1}function sx(t,e){if(t.length===0)return null;const n=YE(t,e);return n===-1?t[0].id:t[(n+1)%t.length].id}function ax(t,e){if(t.length===0)return null;const n=YE(t,e);return n===-1?t[t.length-1].id:t[(n-1+t.length)%t.length].id}const yl={background:"var(--tandem-warning-bg)",border:"var(--tandem-warning-border)",color:"var(--tandem-warning-fg-strong)"};function X1(t,e){return t.type==="highlight"?[]:e??[]}var I7=T('<button class="aca-btn aca-btn--accept svelte-1u9ox5p">Accept</button>'),R7=T('<button class="aca-btn aca-btn--reject svelte-1u9ox5p">Reject</button>'),N7=T('<div class="aca-row svelte-1u9ox5p"><!> <!></div>'),P7=T('<button class="aca-btn aca-btn--ghost svelte-1u9ox5p">Archive</button>'),L7=T('<button class="aca-btn aca-btn--send svelte-1u9ox5p"> </button>'),F7=T('<div class="aca-row svelte-1u9ox5p"><!> <!></div>'),z7=T('<button class="aca-btn aca-btn--ghost aca-standalone svelte-1u9ox5p">Remove</button>'),B7=T(`<div class="aca-undo-error svelte-1u9ox5p">Can't undo — text has changed.</div>`),H7=T('<div class="aca-undo-row svelte-1u9ox5p"><button data-testid="undo-btn" class="aca-undo svelte-1u9ox5p">Undo</button> <!></div>');function V7(t,e){nt(e,!0);const n=No(ai());let r=F(!1),i=null;function o(){i&&(clearTimeout(i),i=null)}function s(p){if(p.stopPropagation(),!e.onUndo)return;const m=e.onUndo(e.annotationId);if(m){o(),b(r,!1);return}m||(b(r,!0),o(),i=setTimeout(()=>{b(r,!1),i=null},3e3))}Dn(o);var a=St(),l=Ae(a);{var c=p=>{var m=N7(),v=w(m);{var g=_=>{var S=I7();W(()=>U(S,"data-testid",`accept-btn-${e.annotationId??""}`)),P("click",S,A=>{A.stopPropagation(),e.onAccept(e.annotationId)}),x(_,S)};j(v,_=>{e.onAccept&&_(g)})}var y=k(v,2);{var C=_=>{var S=R7();W(()=>U(S,"data-testid",`dismiss-btn-${e.annotationId??""}`)),P("click",S,A=>{A.stopPropagation(),e.onDismiss(e.annotationId)}),x(_,S)};j(y,_=>{e.onDismiss&&_(C)})}x(p,m)},d=p=>{var m=F7(),v=w(m);{var g=_=>{var S=P7();W(()=>U(S,"data-testid",`archive-btn-${e.annotationId??""}`)),P("click",S,A=>{A.stopPropagation(),e.onRemove(e.annotationId)}),x(_,S)};j(v,_=>{e.onRemove&&_(g)})}var y=k(v,2);{var C=_=>{var S=L7(),A=w(S);W(()=>{U(S,"data-testid",`send-to-claude-btn-${e.annotationId??""}`),G(A,`Send to ${n.family??""}`)}),P("click",S,O=>{O.stopPropagation(),e.onSendToClaude(e.annotationId)}),x(_,S)};j(y,_=>{e.onSendToClaude&&_(C)})}x(p,m)},f=p=>{var m=z7();W(()=>U(m,"data-testid",`remove-btn-${e.annotationId??""}`)),P("click",m,v=>{v.stopPropagation(),e.onRemove(e.annotationId)}),x(p,m)},h=p=>{var m=H7(),v=w(m),g=k(v,2);{var y=C=>{var _=B7();x(C,_)};j(g,C=>{u(r)&&C(y)})}P("click",v,s),x(p,m)};j(l,p=>{e.isPending&&!e.isEditing&&(e.onAccept||e.onDismiss)?p(c):e.isPending&&!e.isEditing&&e.annotationType==="note"?p(d,1):e.isPending&&!e.isEditing&&e.onRemove?p(f,2):!e.isPending&&e.undoable&&e.onUndo&&p(h,3)})}x(t,a),rt()}lt(["click"]);const Sh="width: 100%; padding: 4px 6px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); resize: vertical; font-family: inherit; min-height: 40px; box-sizing: border-box; background: var(--tandem-surface); color: var(--tandem-fg);";var U7=T('<label style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); display: block; margin-bottom: 2px;">Replacement text</label> <textarea></textarea> <label style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); display: block; margin-top: 4px; margin-bottom: 2px;">Reason</label> <textarea></textarea>',1),j7=T("<textarea></textarea>"),q7=T('<div style="margin-top: 4px;"><!> <div style="display: flex; gap: 2px; margin-top: 4px;"><button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-success-bg); color: var(--tandem-success-fg-strong); cursor: pointer;">Save</button> <button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button></div></div>');function W7(t,e){nt(e,!0);let n=F(null);pe(()=>{var d;(d=u(n))==null||d.focus()});var r=q7(),i=w(r);{var o=d=>{var f=U7(),h=Ae(f),p=k(h,2);Dt(p,g=>b(n,g),()=>u(n));var m=k(p,2),v=k(m,2);W(()=>{U(h,"for",`edit-newtext-${e.annotationId??""}`),U(p,"id",`edit-newtext-${e.annotationId??""}`),U(p,"data-testid",`edit-newtext-${e.annotationId??""}`),Vr(p,e.editNewText),Pe(p,Sh),U(m,"for",`edit-reason-${e.annotationId??""}`),U(v,"id",`edit-reason-${e.annotationId??""}`),U(v,"data-testid",`edit-reason-${e.annotationId??""}`),Vr(v,e.editReason),Pe(v,Sh)}),P("input",p,g=>e.onChangeEditNewText(g.target.value)),P("keydown",p,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),P("input",v,g=>e.onChangeEditReason(g.target.value)),P("keydown",v,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),x(d,f)},s=d=>{var f=j7();Dt(f,h=>b(n,h),()=>u(n)),W(()=>{U(f,"data-testid",`edit-text-${e.annotationId??""}`),Vr(f,e.editText),Pe(f,Sh)}),P("input",f,h=>e.onChangeEditText(h.target.value)),P("keydown",f,function(...h){var p;(p=e.onKeyDown)==null||p.apply(this,h)}),x(d,f)};j(i,d=>{e.hasSuggestedText?d(o):d(s,-1)})}var a=k(i,2),l=w(a),c=k(l,2);W(()=>{U(l,"data-testid",`edit-save-btn-${e.annotationId??""}`),U(c,"data-testid",`edit-cancel-btn-${e.annotationId??""}`)}),P("click",r,d=>d.stopPropagation()),P("keydown",r,d=>d.stopPropagation()),P("click",l,d=>{d.stopPropagation(),e.onSave()}),P("click",c,d=>{d.stopPropagation(),e.onCancel()}),x(t,r),rt()}lt(["click","keydown","input"]);function K7(t,e){return t==="claude"?e??"Assistant":t==="import"?"Imported":"You"}function JE(t){return t.suggestedText!==void 0?"replacement":t.type}function G7(t,e){return t?t.length>e?t.slice(0,e-3)+"...":t:""}function Z7(t){const e=JE(t),n=G7(t.content,60);return`${t.type==="note"?"private ":""}${e} annotation${n?": "+n:""}, ${t.status}`}function Y7(t){return t.type==="highlight"&&t.color?Yu[UC(t.color)]:"var(--tandem-author-user)"}var J7=T("<span> </span>"),X7=T(`<button class="ach-edit-btn svelte-d1dbnh" title="Edit this annotation's content">✎ Edit</button>`),Q7=T('<span class="ach-edited svelte-d1dbnh">(edited)</span>'),$7=T('<span class="ach-dot svelte-d1dbnh" aria-hidden="true"></span>'),eF=T('<div class="ach-row svelte-d1dbnh"><span class="ach-type svelte-d1dbnh"><span class="ach-badge annotation-type-badge svelte-d1dbnh"> </span> <!> <!> <!></span> <span class="ach-author svelte-d1dbnh"><!> <!> </span></div>');function af(t,e){nt(e,!0);const n=No(ai()),r=L(()=>JE(e.annotation)),i=L(()=>K7(e.annotation.author,n.family)),o=L(()=>e.annotation.author==="claude"?"var(--tandem-author-claude)":"var(--tandem-author-user)");var s=eF(),a=w(s),l=w(a),c=w(l),d=k(l,2);{var f=O=>{var E=St(),M=Ae(E);Gd(M,()=>e.extraPill),x(O,E)};j(d,O=>{e.extraPill&&O(f)})}var h=k(d,2);{var p=O=>{var E=J7();let M;var R=w(E);W(()=>{M=bt(E,1,"ach-status svelte-d1dbnh",null,M,{"is-accepted":e.annotation.status==="accepted","is-rejected":e.annotation.status!=="accepted"}),G(R,e.annotation.status)}),x(O,E)};j(h,O=>{e.isPending||O(p)})}var m=k(h,2);{var v=O=>{var E=X7();W(()=>U(E,"data-testid",`edit-btn-${e.annotation.id??""}`)),P("click",E,M=>{M.stopPropagation(),e.onEnterEdit()}),x(O,E)};j(m,O=>{e.isPending&&e.canEdit&&!e.isReviewTarget&&!e.isEditing&&O(v)})}var g=k(a,2),y=w(g);{var C=O=>{var E=Q7();x(O,E)};j(y,O=>{e.annotation.editedAt&&O(C)})}var _=k(y,2);{var S=O=>{var E=$7();W(()=>Pe(E,`background: ${u(o)??""};`)),x(O,E)};j(_,O=>{e.annotation.author!=="import"&&O(S)})}var A=k(_);W(()=>{Pe(l,`background: ${e.badgeBg??""}; color: ${e.badgeFg??""};`),G(c,u(r)),G(A,` ${u(i)??""}`)}),x(t,s),rt()}lt(["click"]);var tF=T('<div style="padding: 4px 8px; margin-bottom: 6px; border-left: 3px solid var(--tandem-border-strong); color: var(--tandem-fg-muted); font-size: 12px; font-style: italic; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-1);"> </div>');function lf(t,e){nt(e,!0);const n=L(()=>e.text?e.text.length>80?e.text.slice(0,77)+"...":e.text:"");var r=St(),i=Ae(r);{var o=s=>{var a=tF(),l=w(a);W(()=>{U(a,"data-testid",`annotation-snippet-${e.annotationId??""}`),G(l,u(n))}),x(s,a)};j(i,s=>{e.text&&s(o)})}x(t,r),rt()}var nF=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),rF=T("<!> <!> <!>",1);function iF(t,e){nt(e,!0);var n=rF(),r=Ae(n);af(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);lf(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=nF(),c=w(l),d=w(c);W(()=>G(d,e.annotation.content||"(no note)")),x(a,l)};j(o,a=>{e.isEditing||a(s)})}x(t,n),rt()}var oF=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),sF=T("<!> <!> <!>",1);function aF(t,e){nt(e,!0);var n=sF(),r=Ae(n);af(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);lf(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=oF(),c=w(l),d=w(c);W(()=>G(d,e.annotation.content||"(no note)")),x(a,l)};j(o,a=>{e.isEditing||a(s)})}x(t,n),rt()}var lF=T('<input type="checkbox" style="margin-top: 4px; flex-shrink: 0; cursor: pointer;"/>'),cF=T('<div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-bottom: 4px;">From: <span style="font-weight: 500;"> </span></div>'),uF=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),dF=T('<div style="display: flex; align-items: flex-start; gap: var(--tandem-space-2);"><!> <div style="flex: 1; min-width: 0;"><!> <!> <!> <!></div></div>');function fF(t,e){nt(e,!0);let n=Ze(e,"selected",3,!1);var r=dF(),i=w(r);{var o=p=>{var m=lF();W(()=>{var v;U(m,"data-testid",`annotation-select-checkbox-${e.annotation.id??""}`),Fn(m,n()),U(m,"aria-label",`Select ${((v=e.annotation.importSource)==null?void 0:v.author)??"import"} comment for batch promote`)}),P("click",m,v=>v.stopPropagation()),P("change",m,()=>{var v;return(v=e.onToggleSelect)==null?void 0:v.call(e,e.annotation.id)}),x(p,m)};j(i,p=>{e.onToggleSelect&&p(o)})}var s=k(i,2),a=w(s);af(a,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var l=k(a,2);{var c=p=>{var m=cF(),v=k(w(m)),g=w(v);W(()=>{U(m,"data-testid",`annotation-import-byline-${e.annotation.id??""}`),G(g,e.annotation.importSource.author)}),x(p,m)};j(l,p=>{var m;(m=e.annotation.importSource)!=null&&m.author&&p(c)})}var d=k(l,2);lf(d,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var f=k(d,2);{var h=p=>{var m=uF(),v=w(m),g=w(v);W(()=>G(g,e.annotation.content||"(no note)")),x(p,m)};j(f,p=>{e.isEditing||p(h)})}x(t,r),rt()}lt(["click","change"]);var hF=T('<span data-testid="annotation-private-pill" aria-hidden="true" title="Private note" style="padding: 1px 6px; font-size: var(--tandem-text-2xs); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--tandem-warning-fg); background: var(--tandem-warning); border-radius: var(--tandem-r-2); line-height: 1;">Private</span>'),pF=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),mF=T("<!> <!> <!>",1);function gF(t,e){nt(e,!0);var n=mF(),r=Ae(n);af(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-warning-bg)",badgeFg:"var(--tandem-warning-fg-strong)",get onEnterEdit(){return e.onEnterEdit},extraPill:l=>{var c=hF();x(l,c)},$$slots:{extraPill:!0}});var i=k(r,2);lf(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=pF(),c=w(l),d=w(c);W(()=>G(d,e.annotation.content||"(no note)")),x(a,l)};j(o,a=>{e.isEditing||a(s)})}x(t,n),rt()}var vF=T('<span class="ct-author-dot ct-author-dot--claude svelte-4l0b78" aria-hidden="true"></span> ',1),bF=T("<span> </span>"),yF=T('<span class="ct-author-dot ct-author-dot--user svelte-4l0b78" aria-hidden="true"></span> You',1),wF=T('<span class="ct-edited svelte-4l0b78">(edited)</span>'),kF=T('<div class="ct-reply svelte-4l0b78"><div class="ct-reply-head svelte-4l0b78"><span><!></span> <span class="ct-time svelte-4l0b78"><!> </span></div> <p class="ct-body svelte-4l0b78"> </p></div>'),xF=T('<div class="ct-root svelte-4l0b78" data-testid="comment-thread"></div>');function _F(t,e){nt(e,!0);const n=No(ai());function r(a){const l=new Date(a),d=new Date().getTime()-l.getTime(),f=Math.floor(d/6e4);if(f<1)return"just now";if(f<60)return`${f}m ago`;const h=Math.floor(f/60);return h<24?`${h}h ago`:l.toLocaleDateString()}var i=St(),o=Ae(i);{var s=a=>{var l=xF();mt(l,21,()=>e.replies,c=>c.id,(c,d)=>{const f=L(()=>u(d).author==="claude"?"claude":u(d).author==="import"?"import":"user");var h=kF(),p=w(h),m=w(p);let v;var g=w(m);{var y=D=>{var I=vF(),H=k(Ae(I));W(()=>G(H,` ${n.family??""}`)),x(D,I)},C=D=>{var I=bF(),H=w(I);W(()=>{U(I,"data-testid",`reply-import-byline-${u(d).id??""}`),G(H,u(d).importAuthor??"Imported")}),x(D,I)},_=D=>{var I=yF();x(D,I)};j(g,D=>{u(f)==="claude"?D(y):u(f)==="import"?D(C,1):D(_,-1)})}var S=k(m,2),A=w(S);{var O=D=>{var I=wF();x(D,I)};j(A,D=>{u(d).editedAt&&D(O)})}var E=k(A),M=k(p,2),R=w(M);W(D=>{U(h,"data-testid",`reply-${u(d).id??""}`),v=bt(m,1,"ct-author svelte-4l0b78",null,v,{"is-claude":u(f)==="claude","is-import":u(f)==="import","is-user":u(f)==="user"}),G(E,` ${D??""}`),G(R,u(d).text)},[()=>r(u(d).timestamp)]),x(c,h)}),x(a,l)};j(o,a=>{e.replies.length>0&&a(s)})}x(t,i),rt()}var CF=T('<div class="art-replies svelte-155xn9n"><!></div>'),SF=T('<button type="button"><span class="art-arrow svelte-155xn9n" aria-hidden="true">›</span> </button> <!>',1),EF=T('<div><textarea placeholder="Write a reply..."></textarea> <div style="display: flex; gap: 2px; margin-top: 2px;"><button>Send</button> <button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button></div></div>'),AF=T('<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;">Reply</button>'),TF=T('<div style="margin-top: 6px;"><!></div>'),MF=T('<div class="art-root svelte-155xn9n"><!> <!></div>');function DF(t,e){nt(e,!0);let n=Ze(e,"reduceMotion",3,!1),r=Ze(e,"openNonce",3,0);const i=L(()=>X1(e.annotation,e.replies)),o=L(()=>e.annotation.id);let s=F(!1),a=F(!1),l=F(""),c=F(!1),d=F(null);const f=L(()=>!!u(l).trim());pe(()=>{var S;u(a)&&((S=u(d))==null||S.focus())});let h=Ct(()=>r());pe(()=>{r()!==h&&(h=r(),b(a,!0))});function p(S){S.key==="Escape"&&(S.stopPropagation(),b(a,!1),b(l,""))}async function m(){var A;const S=u(l).trim();if(!(!S||u(c))){b(c,!0);try{await((A=e.onReply)==null?void 0:A.call(e,u(o),S))!==!1&&(b(l,""),b(a,!1))}finally{b(c,!1)}}}var v=MF(),g=w(v);{var y=S=>{var A=SF(),O=Ae(A);let E;var M=k(w(O)),R=k(O,2);{var D=I=>{var H=CF(),z=w(H);_F(z,{get replies(){return u(i)}}),Yi(3,H,()=>ON,()=>({reduceMotion:n()})),x(I,H)};j(R,I=>{u(s)&&I(D)})}W(()=>{U(O,"data-testid",`reply-toggle-${u(o)??""}`),E=bt(O,1,"art-toggle svelte-155xn9n",null,E,{open:u(s)}),U(O,"aria-expanded",u(s)),G(M,` ${u(i).length===1?"1 reply":`${u(i).length} replies`}`)}),P("click",O,I=>{I.stopPropagation(),b(s,!u(s))}),x(S,A)};j(g,S=>{u(i).length>0&&S(y)})}var C=k(g,2);{var _=S=>{var A=TF(),O=w(A);{var E=R=>{var D=EF(),I=w(D);Dt(I,ie=>b(d,ie),()=>u(d));var H=k(I,2),z=w(H),Q=k(z,2);W(()=>{U(I,"data-testid",`reply-input-${u(o)??""}`),Vr(I,u(l)),Pe(I,Sh),U(z,"data-testid",`reply-send-btn-${u(o)??""}`),z.disabled=!u(f)||u(c),Pe(z,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${u(f)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${u(f)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${u(f)?"pointer":"default"};`),U(Q,"data-testid",`reply-cancel-btn-${u(o)??""}`)}),P("input",I,ie=>b(l,ie.target.value,!0)),P("keydown",I,p),P("click",z,m),P("click",Q,()=>{b(a,!1),b(l,"")}),x(R,D)},M=R=>{var D=AF();W(()=>U(D,"data-testid",`reply-btn-${u(o)??""}`)),P("click",D,()=>b(a,!0)),x(R,D)};j(O,R=>{u(a)?R(E):R(M,-1)})}P("click",A,R=>R.stopPropagation()),P("keydown",A,R=>R.stopPropagation()),x(S,A)};j(C,S=>{e.isPending&&e.onReply&&!e.isEditing&&S(_)})}x(t,v),rt()}lt(["click","keydown","input"]);var OF=T('<span style="text-decoration: line-through; color: var(--tandem-error); background-color: var(--tandem-error-bg); padding: 0 2px; border-radius: var(--tandem-r-1);"> </span> ',1),IF=T('<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>'),RF=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><div><!> <span style="color: var(--tandem-success-fg-strong); background-color: var(--tandem-success-bg); padding: 0 2px; border-radius: var(--tandem-r-1);"> </span></div> <!></div>'),NF=T("<!> <!> <!>",1);function PF(t,e){nt(e,!0);var n=NF(),r=Ae(n);af(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-suggestion-bg)",badgeFg:"var(--tandem-suggestion-fg-strong)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);lf(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=RF(),c=w(l),d=w(c);{var f=g=>{var y=OF(),C=Ae(y),_=w(C),S=k(C);S.nodeValue=" → ",W(()=>G(_,e.annotation.textSnapshot)),x(g,y)};j(d,g=>{e.annotation.textSnapshot&&g(f)})}var h=k(d,2),p=w(h),m=k(c,2);{var v=g=>{var y=IF(),C=w(y);W(()=>G(C,e.annotation.content)),x(g,y)};j(m,g=>{e.annotation.content&&g(v)})}W(()=>{U(c,"data-testid",`suggestion-diff-${e.annotation.id??""}`),Pe(c,`padding: 4px 8px; margin-bottom: ${e.annotation.content?"4px":"0"}; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); font-size: 12px; line-height: 1.5;`),G(p,e.annotation.suggestedText)}),x(a,l)};j(o,a=>{e.isEditing||a(s)})}x(t,n),rt()}var LF=T('<div class="tandem-claude-typing svelte-3ascys" role="status" aria-live="polite"><span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span></div>'),FF=T('<div role="listitem"><!> <!> <!> <!> <!></div>');function eb(t,e){nt(e,!0);let n=Ze(e,"replies",19,()=>[]),r=Ze(e,"claudeTyping",3,!1),i=Ze(e,"selected",3,!1),o=Ze(e,"density",3,"full"),s=Ze(e,"lifecycleMotion",3,!1),a=Ze(e,"reduceMotion",3,!1),l=Ze(e,"openRequest",3,null);const c=No(ai());let d=F(!1),f=F(""),h=F(""),p=F("");const m=L(()=>e.annotation.status==="pending"),v=L(()=>e.annotation.suggestedText!==void 0),g=L(()=>e.onEdit!==void 0),y=L(()=>Z7(e.annotation)),C=L(()=>X1(e.annotation,n())),_=L(()=>o()==="stub"?"stub":u(d)?"full":o());let S=-1,A=-1,O=F(0);pe(()=>{const Z=l();if(Z)if(Z.kind==="edit"){if(Z.nonce===S)return;S=Z.nonce,e.onEdit&&R()}else{if(Z.nonce===A)return;A=Z.nonce,b(O,Z.nonce,!0)}});const E=L(()=>e.annotation.author==="import"?"var(--tandem-surface-muted)":e.annotation.type==="highlight"?`color-mix(in srgb, ${Y7(e.annotation)} 18%, var(--tandem-surface))`:e.annotation.type==="note"?"var(--tandem-warning-bg)":e.annotation.suggestedText!==void 0?"var(--tandem-suggestion-bg)":e.annotation.author==="claude"?"var(--tandem-author-claude-bg)":"var(--tandem-author-user-bg)"),M=L(()=>e.isReviewTarget?"var(--tandem-accent-bg)":u(E));function R(){u(v)?(b(h,e.annotation.suggestedText??"",!0),b(p,e.annotation.content,!0)):b(f,e.annotation.content,!0),b(d,!0)}function D(){var ge;const Z=u(v)?JSON.stringify({suggestedText:u(h),content:u(p)}):u(f);(ge=e.onEdit)==null||ge.call(e,e.annotation.id,Z),b(d,!1)}function I(){b(d,!1)}function H(Z){Z.key==="Escape"&&(Z.stopPropagation(),I())}var z=FF();let Q;var ie=w(z);{var me=Z=>{var ge=LF();W(()=>{U(ge,"data-testid",`claude-typing-indicator-${e.annotation.id??""}`),U(ge,"aria-label",`${c.family??""} is working on this annotation`),U(ge,"title",`${c.family??""} is working on this annotation`)}),x(Z,ge)};j(ie,Z=>{r()&&Z(me)})}var le=k(ie,2);{var ke=Z=>{fF(Z,{get annotation(){return e.annotation},get isPending(){return u(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(d)},get canEdit(){return u(g)},onEnterEdit:R,get selected(){return i()},get onToggleSelect(){return e.onToggleSelect}})},ce=Z=>{aF(Z,{get annotation(){return e.annotation},get isPending(){return u(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(d)},get canEdit(){return u(g)},onEnterEdit:R})},ve=Z=>{gF(Z,{get annotation(){return e.annotation},get isPending(){return u(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(d)},get canEdit(){return u(g)},onEnterEdit:R})},De=Z=>{PF(Z,{get annotation(){return e.annotation},get isPending(){return u(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(d)},get canEdit(){return u(g)},onEnterEdit:R})},ee=Z=>{iF(Z,{get annotation(){return e.annotation},get isPending(){return u(m)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(d)},get canEdit(){return u(g)},onEnterEdit:R})};j(le,Z=>{e.annotation.author==="import"?Z(ke):e.annotation.type==="highlight"?Z(ce,1):e.annotation.type==="note"?Z(ve,2):e.annotation.suggestedText!==void 0?Z(De,3):Z(ee,-1)})}var q=k(le,2);{var V=Z=>{W7(Z,{get annotationId(){return e.annotation.id},get hasSuggestedText(){return u(v)},get editText(){return u(f)},get editNewText(){return u(h)},get editReason(){return u(p)},onChangeEditText:ge=>b(f,ge,!0),onChangeEditNewText:ge=>b(h,ge,!0),onChangeEditReason:ge=>b(p,ge,!0),onKeyDown:H,onSave:D,onCancel:I})};j(q,Z=>{u(d)&&Z(V)})}var re=k(q,2);V7(re,{get annotationId(){return e.annotation.id},get annotationType(){return e.annotation.type},get isPending(){return u(m)},get isEditing(){return u(d)},get undoable(){return e.undoable},get onAccept(){return e.onAccept},get onDismiss(){return e.onDismiss},get onUndo(){return e.onUndo},get onRemove(){return e.onRemove},get onSendToClaude(){return e.onSendToClaude}});var te=k(re,2);DF(te,{get annotation(){return e.annotation},get replies(){return u(C)},get isPending(){return u(m)},get isEditing(){return u(d)},get onReply(){return e.onReply},get reduceMotion(){return a()},get openNonce(){return u(O)}}),W(()=>{Q=bt(z,1,"tandem-annotation-card svelte-3ascys",null,Q,{"is-review-target":e.isReviewTarget,"is-density-clamped":u(_)==="clamped","is-density-stub":u(_)==="stub"}),U(z,"data-testid",`annotation-card-${e.annotation.id??""}`),U(z,"data-annotation-id",e.annotation.id),U(z,"data-annotation-type",e.annotation.type),U(z,"data-density",u(_)),U(z,"data-claude-typing",r()?"true":void 0),U(z,"aria-label",u(y)),U(z,"aria-current",e.isReviewTarget?"true":void 0),Pe(z,`background: ${u(M)??""}; opacity: ${u(m)?1:.6}; cursor: ${e.onClick?"pointer":"default"};`)}),P("click",z,function(...Z){var ge;(ge=e.onClick)==null||ge.apply(this,Z)}),Yi(1,z,()=>xN,()=>({enabled:s(),reduceMotion:a()})),Yi(2,z,()=>_N,()=>({enabled:s(),reduceMotion:a(),id:e.annotation.id,modes:e.exitModes})),x(t,z),rt()}lt(["click"]);const zF="browser";function BF(t,e,n){let r,i=!1;if(t.transact(()=>{r=e(),i=!0},n),!i)throw new Error(`origins: transact callback did not run (origin=${n})`);return r}function is(t,e){return BF(t,e,zF)}function el(t,e){const n=t,r=s=>{try{e(s)}catch(a){console.warn(`[sanitizeAnnotation] onLossy threw for ${s.kind}:`,a)}},i=n.audience==="private"||n.audience==="outbound"?n.audience:n.author==="import"||n.type==="highlight"||n.type==="note"||n.type==="flag"?"private":"outbound",o={id:n.id,author:n.author,range:n.range,content:n.content,status:n.status,timestamp:n.timestamp,...n.relRange!==void 0?{relRange:n.relRange}:{},...n.textSnapshot!==void 0?{textSnapshot:n.textSnapshot}:{},...n.editedAt!==void 0?{editedAt:n.editedAt}:{},...typeof n.rev=="number"?{rev:n.rev}:{},audience:i,...n.promotedFrom!==void 0?{promotedFrom:n.promotedFrom}:{},...n.importSource!==void 0?{importSource:n.importSource}:{}};if(o.audience==="outbound"&&n.author==="user"&&(n.type==="note"||n.type==="highlight"||n.type==="flag")&&(o.audience="private",r({kind:"audience-conflict-resolved",id:n.id})),n.type==="suggestion"){let s,a;try{const l=JSON.parse(n.content);s=l.newText,a=l.reason??""}catch{r({kind:"malformed-suggestion-json",id:n.id}),a=n.content}return{...o,type:"comment",content:a,suggestedText:s}}return n.type==="question"?(r({kind:"question-to-comment",id:n.id}),{...o,type:"comment"}):n.type==="highlight"?{...o,type:"highlight",color:n.color}:n.type==="flag"||n.type==="note"?(n.type==="flag"&&r({kind:"flag-to-note",id:n.id}),{...o,type:"note"}):n.type==="comment"?{...o,type:"comment",...n.suggestedText!==void 0?{suggestedText:n.suggestedText}:{}}:(r({kind:"unknown-type",id:n.id,rawType:n.type}),{...o,type:"comment"})}const Q1=t=>{console.warn("[sanitize]",t)};function XE(t,e,n){if(!t)return;const r=t.getMap(Ri),i=r.get(e);if(!i)return;const o=el(i,Q1);is(t,()=>{if(o.suggestedText!==void 0){try{const s=JSON.parse(n);r.set(e,{...o,suggestedText:s.suggestedText,content:s.content,editedAt:Date.now(),rev:(o.rev??0)+1})}catch{console.warn(`[annotation-actions] Failed to parse edit payload for annotation ${e}`)}return}r.set(e,{...o,content:n,editedAt:Date.now(),rev:(o.rev??0)+1})})}function QE(t){const{color:e,suggestedText:n,...r}=t;return{...r,type:"comment",author:t.author==="import"?"user":t.author,audience:"outbound",promotedFrom:"note",rev:(t.rev??0)+1}}function $E(t,e){if(!t)return;const n=t.getMap(Ri),r=n.get(e);if(!r)return;const i=el(r,Q1);i.type==="note"&&is(t,()=>{n.set(e,QE(i))})}function HF(t,e){if(!t||e.length===0)return 0;const n=t.getMap(Ri);let r=0;return is(t,()=>{for(const i of e){const o=n.get(i);if(!o)continue;const s=el(o,Q1);s.type==="note"&&(n.set(i,QE(s)),r++)}}),r}async function eA(t,e){try{const n=await fetch(`${nn}${AO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:t,documentId:e})});if(!n.ok){const r=await n.json().catch(()=>({message:"Unknown error"}));console.error("[Tandem] Remove annotation failed:",r)}}catch(n){console.error("[Tandem] Remove annotation failed:",n)}}async function tA(t,e,n){try{const r=await fetch(`${nn}${EO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:t,text:e,documentId:n})});if(!r.ok){const i=await r.json().catch(()=>({}));return console.warn(`[annotation-actions] Reply failed (${r.status}): ${i.message??"unknown error"}`),!1}return!0}catch(r){return console.error("[annotation-actions] Reply request failed:",r),!1}}const VF=["ctx:annotation:accept","ctx:annotation:dismiss","ctx:annotation:reply","ctx:annotation:edit","ctx:annotation:sendToClaude","ctx:annotation:copy","ctx:annotation:remove"],UF=new Set(VF);function jF(t){return typeof t=="string"&&UF.has(t)}const Gc=t=>t.status==="pending",Vm=t=>t.author!=="user"&&Gc(t),Um=t=>t.author!=="user"&&Gc(t),jm=t=>(t.type==="note"||t.type==="comment")&&Gc(t),qm=t=>t.author==="user"&&Gc(t),Wm=t=>t.author==="user"&&t.type==="note"&&Gc(t),Km=t=>t.author==="user"&&Gc(t),qF=t=>!0;function WF(t){return{canAccept:Vm(t),canDismiss:Um(t),canReply:jm(t),canEdit:qm(t),canSendToClaude:Wm(t),canCopy:qF(),canRemove:Km(t),isNote:t.type==="note"}}function KF(t){var n;return((n=t.content)==null?void 0:n.trim())?t.content:t.textSnapshot??""}let Eh=null;function GF(t){Eh=t}function nA(t,e,n){var r,i,o,s,a,l;switch(t){case"ctx:annotation:accept":Vm(e)&&((r=n.accept)==null||r.call(n,e.id));return;case"ctx:annotation:dismiss":Um(e)&&((i=n.dismiss)==null||i.call(n,e.id));return;case"ctx:annotation:sendToClaude":Wm(e)&&((o=n.sendToClaude)==null||o.call(n,e.id));return;case"ctx:annotation:remove":Km(e)&&((s=n.remove)==null||s.call(n,e.id));return;case"ctx:annotation:edit":qm(e)&&((a=n.openEdit)==null||a.call(n,e.id));return;case"ctx:annotation:reply":jm(e)&&((l=n.openReply)==null||l.call(n,e.id));return;case"ctx:annotation:copy":{const c=KF(e);c&&navigator.clipboard.writeText(c).catch(()=>{})}return}}async function rA(t,e){GF({run:e});try{await(await hs())("show_annotation_context_menu",{req:WF(t)})}catch{}}let Lf=0,Ff=null;function iA(){if(!Tt())return()=>{};Lf++,Lf===1&&(Ff=Zt(async()=>{const{listen:e}=await import("./event-CNdo2oXa.js");return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e("context-menu-action",n=>{var i;const r=(i=n.payload)==null?void 0:i.id;jF(r)&&(Eh==null||Eh.run(r))})),Ff.catch(()=>{}));let t=!1;return()=>{if(!t&&(t=!0,Lf--,Lf===0)){const e=Ff;Ff=null,e==null||e.then(n=>n()).catch(()=>{})}}}var ZF=T('<div data-testid="batch-promote-bar" role="region" aria-label="Batch promote imported notes" style="position: sticky; top: 0; z-index: var(--tandem-z-base); display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-4); background: var(--tandem-surface); border-bottom: 1px solid var(--tandem-border); box-shadow: var(--tandem-shadow-1);"><span data-testid="batch-promote-count" style="flex: 1; font-size: var(--tandem-text-2xs); font-weight: 500; color: var(--tandem-fg-subtle);"> </span> <button data-testid="batch-promote-clear" style="padding: 3px 10px; border: 1px solid transparent; background: none; color: var(--tandem-fg-subtle); border-radius: var(--tandem-r-pill); cursor: pointer; font-size: var(--tandem-text-xs);">Clear</button> <button data-testid="batch-promote-confirm" style="padding: 3px 12px; border: 1px solid var(--tandem-accent); background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill); cursor: pointer; font-size: var(--tandem-text-xs); font-weight: 500;"> </button></div>');function YF(t,e){nt(e,!0);let n=Ze(e,"reduceMotion",3,!1);const r=No(ai());var i=St(),o=Ae(i);{var s=a=>{var l=ZF(),c=w(l),d=w(c),f=k(c,2),h=k(f,2),p=w(h);W(()=>{G(d,`${e.selectedCount??""} selected`),G(p,`Send ${e.selectedCount??""} to ${r.family??""}`)}),P("click",f,function(...m){var v;(v=e.onClear)==null||v.apply(this,m)}),P("click",h,function(...m){var v;(v=e.onPromote)==null||v.apply(this,m)}),Yi(1,l,()=>y3,()=>({reduceMotion:n()})),Yi(2,l,()=>w3,()=>({reduceMotion:n(),exitMs:200})),x(a,l)};j(o,a=>{e.selectedCount>0&&a(s)})}x(t,i),rt()}lt(["click"]);var JF=T('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg);"> </span> <button data-testid="bulk-confirm-btn">Confirm</button> <button data-testid="bulk-cancel-btn">Cancel</button>',1),XF=T('<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>',1),QF=T('<div style="padding: 6px var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; align-items: center;"><!></div>');function $F(t,e){nt(e,!0);let n=Ze(e,"confirmRef",15,null),r=Ze(e,"reduceMotion",3,!1);const i=L(()=>e.bulkConfirm==="accept"),o=L(()=>e.pendingCount===e.allPendingCount?`${e.pendingCount} annotations?`:`${e.pendingCount} of ${e.allPendingCount} pending?`);var s=St(),a=Ae(s);{var l=c=>{var d=QF(),f=w(d);{var h=m=>{var v=JF(),g=Ae(v),y=w(g),C=k(g,2);Dt(C,S=>n(S),()=>n());var _=k(C,2);Pe(_,"padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-surface); color: var(--tandem-fg-muted);"),W(()=>{G(y,`${u(i)?"Accept":"Reject"}
83
+ ${u(o)??""}`),Pe(C,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: ${u(i)?"var(--tandem-success-bg)":"var(--tandem-error-bg)"}; color: ${u(i)?"var(--tandem-success-fg-strong)":"var(--tandem-error-fg-strong)"}; font-weight: 600;`)}),P("click",C,function(...S){var A;(A=u(i)?e.onConfirmAccept:e.onConfirmDismiss)==null||A.apply(this,S)}),P("click",_,function(...S){var A;(A=e.onCancel)==null||A.apply(this,S)}),x(m,v)},p=m=>{var v=XF(),g=Ae(v);Pe(g,"padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-success-bg); color: var(--tandem-success-fg-strong);");var y=w(g),C=k(g,2);Pe(C,"padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong);"),W(()=>G(y,`Accept All (${e.pendingCount??""})`)),P("click",g,function(..._){var S;(S=e.onRequestAccept)==null||S.apply(this,_)}),P("click",C,function(..._){var S;(S=e.onRequestDismiss)==null||S.apply(this,_)}),x(m,v)};j(f,m=>{e.bulkConfirm?m(h):m(p,-1)})}Yi(1,d,()=>y3,()=>({reduceMotion:r()})),Yi(2,d,()=>w3,()=>({reduceMotion:r(),exitMs:180})),x(c,d)};j(a,c=>{e.pendingCount>1&&c(l)})}x(t,s),rt()}lt(["click"]);function _s(t,e,n,r){return{handleKeyDown:s=>{var y;const{key:a}=s;if(a!=="ArrowLeft"&&a!=="ArrowRight"&&a!=="ArrowUp"&&a!=="ArrowDown"&&a!=="Home"&&a!=="End")return;const l=e;if(l.length===0)return;s.preventDefault();const c=t(),d=l.indexOf(c),f=l.length-1;let h;a==="Home"?h=0:a==="End"?h=f:a==="ArrowLeft"||a==="ArrowUp"?h=d<=0?f:d-1:h=d>=f?0:d+1;const p=l[h];n(p);const m=s.currentTarget,v=m==null?void 0:m.querySelectorAll('[role="radio"]'),g=e.indexOf(p);(y=v==null?void 0:v[g])==null||y.focus()},tabIndexFor:s=>{const l=t();return s===l?0:-1}}}const ez=(t,e=kn)=>{var n=St(),r=Ae(n);{var i=f=>{var h=tz();x(f,h)},o=f=>{var h=nz();x(f,h)},s=f=>{var h=rz();x(f,h)},a=f=>{var h=iz();x(f,h)},l=f=>{var h=oz();x(f,h)},c=f=>{var h=sz();x(f,h)},d=f=>{var h=az();x(f,h)};j(r,f=>{e()==="highlight"?f(i):e()==="comment"?f(o,1):e()==="lock"?f(s,2):e()==="sparkle"?f(a,3):e()==="pending"?f(l,4):e()==="check"?f(c,5):e()==="dismiss"&&f(d,6)})}x(t,n)};var tz=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="svelte-v4eg2o"><path d="M3 13h10"></path><path d="M5 11l3 1 5-5-2-2-5 5z"></path><path d="M9 4l2 2"></path></svg>'),nz=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="svelte-v4eg2o"><path d="M2.5 3h11v8h-7l-3 2.5V11H2.5z"></path></svg>'),rz=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="svelte-v4eg2o"><rect x="3" y="7" width="10" height="6" rx="1"></rect><path d="M5 7V5a3 3 0 0 1 6 0v2"></path></svg>'),iz=an('<svg class="g-suggestion svelte-v4eg2o" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v4"></path><path d="M8 10v4"></path><path d="M2 8h4"></path><path d="M10 8h4"></path><path d="M4 4l1.5 1.5"></path><path d="M10.5 10.5L12 12"></path><path d="M12 4l-1.5 1.5"></path><path d="M5.5 10.5L4 12"></path></svg>'),oz=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" class="svelte-v4eg2o"><circle cx="8" cy="8" r="5"></circle></svg>'),sz=an('<svg class="g-success svelte-v4eg2o" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8l3 3 7-7"></path></svg>'),az=an('<svg class="g-error svelte-v4eg2o" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4l8 8M12 4l-8 8"></path></svg>'),lz=T('<span class="chip-text"> </span>'),cz=T("<span></span>"),uz=T('<button type="button" role="radio"><!></button>'),dz=T('<div class="chip-bar svelte-v4eg2o" role="radiogroup" tabindex="-1"><span aria-hidden="true"></span> <!></div>');function r0(t,e){nt(e,!0);let n=Ze(e,"value",3,""),r=Ze(e,"options",19,()=>[]),i=Ze(e,"onSet",3,()=>{}),o=Ze(e,"groupAriaLabel",3,""),s=Ze(e,"groupTestId",3,"");const a=Ct(()=>r().map(g=>g.value)),l=_s(()=>n(),a,g=>i()(g));let c=F(null),d=F(tt({left:0,width:0,ready:!1}));function f(){if(!u(c))return;const g=u(c).querySelector('[aria-checked="true"]');if(!g)return;const y=g.offsetLeft,C=g.offsetWidth;u(d).ready?b(d,{left:y,width:C,ready:!0},!0):(b(d,{left:y,width:C,ready:!1},!0),requestAnimationFrame(()=>{b(d,{left:y,width:C,ready:!0},!0)}))}pe(()=>{if(n(),!u(c))return;let g=!1;return MC().then(()=>{g||requestAnimationFrame(()=>{g||f()})}),()=>{g=!0}}),pe(()=>{if(!u(c))return;const g=new ResizeObserver(()=>f());return g.observe(u(c)),()=>g.disconnect()});var h=dz(),p=w(h);let m;var v=k(p,2);mt(v,17,r,g=>g.value,(g,y)=>{const C=L(()=>u(y).value===n());var _=uz();let S;var A=w(_);{var O=R=>{var D=lz(),I=w(D);W(()=>G(I,u(y).label)),x(R,D)},E=R=>{var D=cz();W(()=>bt(D,1,`pip pip-${u(y).pip??""}`,"svelte-v4eg2o")),x(R,D)},M=R=>{ez(R,()=>u(y).icon)};j(A,R=>{u(y).kind==="text"?R(O):u(y).kind==="pip"?R(E,1):u(y).kind==="icon"&&R(M,2)})}W(R=>{S=bt(_,1,"chip svelte-v4eg2o",null,S,{"is-checked":u(C)}),U(_,"aria-checked",u(C)),U(_,"aria-label",u(y).label),U(_,"title",u(y).label),U(_,"tabindex",R),U(_,"data-testid",`${s()??""}-${u(y).value??""}`)},[()=>l.tabIndexFor(u(y).value)]),P("click",_,()=>i()(u(y).value)),x(g,_)}),Dt(h,g=>b(c,g),()=>u(c)),W(()=>{U(h,"aria-label",o()),U(h,"data-testid",s()),m=bt(p,1,"chip-thumb svelte-v4eg2o",null,m,{ready:u(d).ready}),Pe(p,`left: ${u(d).left??""}px; width: ${u(d).width??""}px;`)}),P("keydown",h,function(...g){var y;(y=l.handleKeyDown)==null||y.apply(this,g)}),x(t,h),rt()}lt(["keydown","click"]);var fz=T('<button data-testid="clear-filters-btn" style="background: none; border: none; color: var(--tandem-accent); font-size: 11px; cursor: pointer; padding: 2px 4px;">Clear</button>'),hz=T('<div style="padding: 8px 16px; border-bottom: 1px solid var(--tandem-border); display: flex; gap: 8px; flex-wrap: wrap; align-items: center;"><!> <!> <!> <!> <button style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 10px; cursor: pointer; padding: 2px 4px; margin-left: auto;" aria-label="Collapse filters">▲</button></div>');function pz(t,e){nt(e,!0);const n=No(ai()),r=[{value:"all",label:"All types",kind:"text"},{value:"highlight",label:"Highlights",kind:"icon",icon:"highlight"},{value:"comment",label:"Comments",kind:"icon",icon:"comment"},{value:"note",label:"Notes",kind:"icon",icon:"lock"},{value:"with-replacement",label:"With replacement",kind:"icon",icon:"sparkle"}],i=L(()=>[{value:"all",label:"Anyone",kind:"text"},{value:"claude",label:n.family,kind:"pip",pip:"claude"},{value:"user",label:"You",kind:"pip",pip:"user"},{value:"import",label:"Imported",kind:"pip",pip:"import"}]),o=[{value:"all",label:"Any status",kind:"text"},{value:"pending",label:"Pending",kind:"icon",icon:"pending"},{value:"accepted",label:"Accepted",kind:"icon",icon:"check"},{value:"dismissed",label:"Dismissed",kind:"icon",icon:"dismiss"}];var s=St(),a=Ae(s);{var l=c=>{var d=hz(),f=w(d);r0(f,{groupTestId:"filter-type",groupAriaLabel:"Filter by type",get value(){return e.filterType},get options(){return r},onSet:y=>e.onSetFilterType(y)});var h=k(f,2);r0(h,{groupTestId:"filter-author",groupAriaLabel:"Filter by author",get value(){return e.filterAuthor},get options(){return u(i)},onSet:y=>e.onSetFilterAuthor(y)});var p=k(h,2);r0(p,{groupTestId:"filter-status",groupAriaLabel:"Filter by status",get value(){return e.filterStatus},get options(){return o},onSet:y=>e.onSetFilterStatus(y)});var m=k(p,2);{var v=y=>{var C=fz();P("click",C,function(..._){var S;(S=e.onClearFilters)==null||S.apply(this,_)}),x(y,C)};j(m,y=>{e.hasFilters&&y(v)})}var g=k(m,2);P("click",g,function(...y){var C;(C=e.onToggleOpen)==null||C.apply(this,y)}),x(c,d)};j(a,c=>{e.open&&c(l)})}x(t,s),rt()}lt(["click"]);var mz=T('<div data-testid="store-readonly-reclaim-error" role="alert" style="font-size: var(--tandem-text-2xs); color: var(--tandem-error-fg);" class="svelte-l26r3u"> </div>'),gz=T(`<div data-testid="store-readonly-banner" class="svelte-l26r3u"><div style="display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;" class="svelte-l26r3u"><span class="svelte-l26r3u">Annotation store is read-only — another Tandem instance holds the lock. Annotations
84
+ won't be saved. Close the other instance, or reclaim the lock if no other instance is
85
+ running.</span> <div style="display: flex; flex-shrink: 0; gap: var(--tandem-space-1);" class="svelte-l26r3u"><button data-testid="store-readonly-reclaim" class="svelte-l26r3u"> </button> <button data-testid="store-readonly-dismiss" class="svelte-l26r3u">Dismiss</button></div></div> <!></div>`),vz=T('<span style="margin-left: 8px; padding: 1px 6px; font-size: var(--tandem-text-xs); background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill);" class="svelte-l26r3u"> </span>'),bz=T('<div style="padding: var(--tandem-space-3); flex: 1;" aria-live="polite" class="svelte-l26r3u"><p style="font-size: var(--tandem-text-base); color: var(--tandem-fg-subtle); margin-top: 8px;" class="svelte-l26r3u"> </p></div>'),yz=T('<details style="margin-top: 12px;" class="svelte-l26r3u"><summary style="font-size: 12px; color: var(--tandem-fg-subtle); cursor: pointer;" class="svelte-l26r3u"> </summary> <div role="list" aria-label="Resolved annotations" class="svelte-l26r3u"></div></details>'),wz=T('<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>'),kz=T('<div data-testid="annotation-list-scroll-container" class="tandem-scroll-fade-y svelte-l26r3u" style="width: 100%; background: var(--tandem-surface-muted); display: flex; flex-direction: column; overflow-y: auto;"><!> <div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);" class="svelte-l26r3u"><div style="display: flex; justify-content: space-between; align-items: center;" class="svelte-l26r3u"><h3 style="font-size: 13px; font-weight: 600; margin: 0;" class="svelte-l26r3u">Annotations <!></h3> <span aria-live="polite" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);" class="svelte-l26r3u"> </span> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-l26r3u"><button data-testid="annotation-sort-toggle" style="display: flex; align-items: center; gap: 4px; background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-pill); padding: 3px 10px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); cursor: pointer; white-space: nowrap;" class="svelte-l26r3u"><span style="font-size: 9px; opacity: 0.7;" aria-hidden="true" class="svelte-l26r3u">⇅</span> <span class="svelte-l26r3u"> </span></button> <button data-testid="filter-bar-toggle" style="display: flex; align-items: center; gap: 4px; background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-pill); padding: 3px 10px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); cursor: pointer; white-space: nowrap;" class="svelte-l26r3u"><span class="svelte-l26r3u"> </span> <span style="font-size: 9px; opacity: 0.7;" class="svelte-l26r3u">▾</span> <span class="svelte-l26r3u">Filter</span></button></div></div></div> <!> <div style="padding: var(--tandem-space-1) var(--tandem-space-4) 0;" class="svelte-l26r3u"><!></div> <!> <!> <!></div>');function lx(t,e){nt(e,!0);let n=Ze(e,"storeReadOnly",3,!1),r=Ze(e,"claudeWorkingAnnotationId",3,null);const i=L(()=>e.reduceMotion?"auto":"smooth"),o="tandem:storeReadOnlyBannerDismissed";function s(){try{return localStorage.getItem(o)==="true"}catch{return!1}}let a=F(tt(s()));pe(()=>{if(!n()){b(a,!1),b(m,null);try{localStorage.removeItem(o)}catch{}}});function l(){try{localStorage.setItem(o,"true")}catch{}b(a,!0)}const c="tandem:annotationSortMode";function d(){try{return localStorage.getItem(c)==="chronological"?"chronological":"position"}catch{return"position"}}let f=F(tt(d()));function h(){b(f,u(f)==="position"?"chronological":"position",!0);try{localStorage.setItem(c,u(f))}catch{}}let p=F(!1),m=F(null);async function v(){if(!u(p)){b(p,!0),b(m,null);try{const K=await fetch(`${nn}${TO}`,{method:"POST"});if(!K.ok){let he="Could not reclaim the annotation store lock.";try{const Me=await K.json();typeof(Me==null?void 0:Me.message)=="string"&&Me.message&&(he=Me.message)}catch{}b(m,he,!0)}}catch{b(m,"Could not reach the Tandem server.")}finally{b(p,!1)}}}let g=F("all"),y=F("all"),C=F("all"),_=F(!1),S=F(null),A=F(void 0),O=F(null);pe(()=>{var K;u(S)&&((K=u(O))==null||K.focus())}),pe(()=>{u(g),u(y),u(C),b(S,null)}),pe(()=>{var K;(K=e.onFilterChange)==null||K.call(e,u(g),u(y),u(C))});let E=F(tt(new Map));pe(()=>{if(!e.ydoc){b(E,new Map,!0);return}const K=e.ydoc.getMap(GC);function he(){const Me=new Map;K.forEach(Fe=>{const We=Fe;if(We&&typeof We=="object"&&We.annotationId){const je=Me.get(We.annotationId)??[];je.push(We),Me.set(We.annotationId,je)}});for(const Fe of Me.values())Fe.sort((We,je)=>We.timestamp-je.timestamp);b(E,Me,!0)}return he(),K.observe(he),()=>K.unobserve(he)});const M=L(()=>{const K=[],he=[];for(const Ve of e.annotations){Ve.status==="pending"&&he.push(Ve);let $e;u(g)==="all"?$e=!0:u(g)==="with-replacement"?$e=Ve.suggestedText!==void 0:$e=Ve.type===u(g);const ct=u(y)==="all"||Ve.author===u(y),dt=u(C)==="all"||Ve.status===u(C);$e&&ct&&dt&&K.push(Ve)}const Me=ox(K.filter(Ve=>Ve.status==="pending"),u(f)),Fe=K.filter(Gh),We=ox(K.filter(Ve=>Ve.status!=="pending"),u(f)),je=e.annotations.filter(Gh);return{filtered:K,pending:Me,reviewPending:Fe,resolved:We,allPending:he,reviewAllPending:je}}),R=No(ai()),D=L(()=>u(g)!=="all"||u(y)!=="all"||u(C)!=="all"),I=L(()=>{if(!u(D))return"All";const K=[];if(u(g)!=="all"){const he={all:"All",highlight:"Highlights",comment:"Comments",note:"Notes","with-replacement":"With replacement"};K.push(he[u(g)])}if(u(y)!=="all"){const he={all:"Anyone",claude:R.family,user:"You",import:"Imported"};K.push(he[u(y)])}if(u(C)!=="all"){const he={all:"Any status",pending:"Pending",accepted:"Accepted",dismissed:"Dismissed"};K.push(he[u(C)])}return K.join(" · ")||"All"});let H=!1;pe(()=>{if(u(g),u(y),u(C),!H){H=!0;return}Ct(()=>{var K;if(e.activeAnnotationId){const he=document.querySelector(`[data-testid="annotation-card-${e.activeAnnotationId}"]`);if(he){he.scrollIntoView({block:"center"});return}console.warn(`[tandem] SidePanel: active annotation ${e.activeAnnotationId} not found on filter change; scrolling to top`)}(K=u(A))==null||K.scrollTo({top:0})})}),pe(()=>{const K=e.activeAnnotationId;if(!K)return;const he=u(i),Me=e.reduceMotion||typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,Fe=setTimeout(()=>{const We=document.querySelector(`[data-testid="annotation-card-${K}"]`);if(!We){console.warn(`[tandem] SidePanel: active annotation ${K} not found after 50ms delay; scroll-to-card skipped`);return}if(We.scrollIntoView({behavior:he,block:"nearest"}),Me)return;We.classList.add("tandem-annotation-flash");const je=Ve=>{Ve.animationName.includes("tandem-annotation-flash")&&(We.classList.remove("tandem-annotation-flash"),We.removeEventListener("animationend",je))};We.addEventListener("animationend",je)},50);return()=>clearTimeout(Fe)});const z=(K,he)=>XE(e.ydoc,K,he),Q=K=>$E(e.ydoc,K),ie=K=>eA(K,e.documentId),me=(K,he)=>tA(K,he,e.documentId),le=new Map;function ke(K){le.set(K,"accept"),e.review.handleAccept(K)}function ce(K){le.set(K,"dismiss"),e.review.handleDismiss(K)}let ve=F(void 0),De=F(null),ee=0;function q(K){return e.annotations.find(he=>he.id===K)}function V(K){return he=>{const Me=q(K);Me&&nA(he,Me,{accept:ke,dismiss:ce,sendToClaude:Q,remove:ie,openEdit:Fe=>b(De,{id:Fe,kind:"edit",nonce:++ee},!0),openReply:Fe=>b(De,{id:Fe,kind:"reply",nonce:++ee},!0)})}}async function re(K){var We;if(!Tt())return;const he=(We=K.target)==null?void 0:We.closest("[data-annotation-id]"),Me=he==null?void 0:he.getAttribute("data-annotation-id");if(!Me)return;const Fe=q(Me);Fe&&(K.preventDefault(),K.stopPropagation(),await rA(Fe,V(Me)))}pe(()=>{const K=u(ve);if(K)return K.addEventListener("contextmenu",re),()=>K.removeEventListener("contextmenu",re)}),pe(()=>iA());function te(K){for(const he of u(M).reviewPending)e.review.resolveAnnotation(he.id,K);b(S,null)}let Z=F(tt(new Set));pe(()=>{const K=new Set(u(M).pending.filter(he=>he.author==="import"&&he.type==="note").map(he=>he.id));Ct(()=>{const he=new Set([...u(Z)].filter(Me=>K.has(Me)));he.size!==u(Z).size&&b(Z,he,!0)})});function ge(K){const he=new Set(u(Z));he.has(K)?he.delete(K):he.add(K),b(Z,he,!0)}function Ie(){const K=Array.from(u(Z));HF(e.ydoc,K),b(Z,new Set,!0)}function Se(){b(Z,new Set,!0)}function fe(K){K.target===K.currentTarget&&e.onActiveAnnotationChange(null)}var _e=kz(),X=w(_e);{var ye=K=>{var he=gz(),Me=w(he),Fe=k(w(Me),2),We=w(Fe),je=w(We),Ve=k(We,2),$e=k(Me,2);{var ct=dt=>{var qt=mz(),Nt=w(qt);W(()=>G(Nt,u(m))),x(dt,qt)};j($e,dt=>{u(m)&&dt(ct)})}W(()=>{Pe(he,`padding: 10px 14px; margin: 10px 14px 0; background: ${yl.background}; border: 1px solid ${yl.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${yl.color}; display: flex; flex-direction: column; gap: var(--tandem-space-2);`),We.disabled=u(p),Pe(We,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: 1px solid ${yl.border}; border-radius: var(--tandem-r-2); background: none; color: ${yl.color}; cursor: ${u(p)?"wait":"pointer"}; font-weight: 500;`),G(je,u(p)?"Reclaiming…":"Reclaim"),Pe(Ve,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${yl.color}; cursor: pointer; font-weight: 500;`)}),P("click",We,v),P("click",Ve,l),x(K,he)};j(X,K=>{n()&&!u(a)&&K(ye)})}var Y=k(X,2),se=w(Y),Te=w(se),Re=k(w(Te));{var ze=K=>{var he=vz(),Me=w(he);W(()=>G(Me,u(M).allPending.length)),x(K,he)};j(Re,K=>{u(M).allPending.length>0&&K(ze)})}var Je=k(Te,2),ue=w(Je),Ne=k(Je,2),qe=w(Ne),Xe=k(w(qe),2),ae=w(Xe),de=k(qe,2),xe=w(de),Le=w(xe),it=k(Y,2);pz(it,{get filterType(){return u(g)},get filterAuthor(){return u(y)},get filterStatus(){return u(C)},get hasFilters(){return u(D)},get open(){return u(_)},onToggleOpen:()=>b(_,!u(_)),onSetFilterType:K=>{b(g,K,!0)},onSetFilterAuthor:K=>{b(y,K,!0)},onSetFilterStatus:K=>{b(C,K,!0)},onClearFilters:()=>{b(g,"all"),b(y,"all"),b(C,"all")}});var ne=k(it,2),Ee=w(ne);D7(Ee,{get annotations(){return e.annotations},get activeDocFormat(){return e.activeDocFormat},get documentId(){return e.documentId}});var B=k(ne,2);YF(B,{get selectedCount(){return u(Z).size},onPromote:Ie,onClear:Se,get reduceMotion(){return e.reduceMotion}});var $=k(B,2);$F($,{get bulkConfirm(){return u(S)},get pendingCount(){return u(M).reviewPending.length},get allPendingCount(){return u(M).reviewAllPending.length},onConfirmAccept:()=>te("accepted"),onConfirmDismiss:()=>te("dismissed"),onCancel:()=>b(S,null),onRequestAccept:()=>b(S,"accept"),onRequestDismiss:()=>b(S,"dismiss"),get reduceMotion(){return e.reduceMotion},get confirmRef(){return u(O)},set confirmRef(K){b(O,K,!0)}});var we=k($,2);{var He=K=>{var he=bz(),Me=w(he),Fe=w(Me);W(()=>G(Fe,u(D)?"No annotations match filters.":"No annotations yet. Open a document to get started.")),P("click",he,fe),x(K,he)},Oe=K=>{var he=wz(),Me=w(he);mt(Me,17,()=>u(M).pending,je=>je.id,(je,Ve)=>{const $e=L(()=>e.activeAnnotationId===u(Ve).id);{let ct=L(()=>u(E).get(u(Ve).id)??[]),dt=L(()=>r()===u(Ve).id),qt=L(()=>Vm(u(Ve))?ke:void 0),Nt=L(()=>Um(u(Ve))?ce:void 0),Ot=L(()=>Km(u(Ve))?ie:void 0),Ft=L(()=>Wm(u(Ve))?Q:void 0),En=L(()=>qm(u(Ve))?z:void 0),Hn=L(()=>jm(u(Ve))?me:void 0),An=L(()=>{var Vn;return((Vn=u(De))==null?void 0:Vn.id)===u(Ve).id?u(De):null}),zt=L(()=>u(Z).has(u(Ve).id)),mn=L(()=>u(Ve).author==="import"&&u(Ve).type==="note"?ge:void 0);eb(je,{get annotation(){return u(Ve)},get replies(){return u(ct)},get isReviewTarget(){return u($e)},get claudeTyping(){return u(dt)},lifecycleMotion:!0,get reduceMotion(){return e.reduceMotion},get exitModes(){return le},get onAccept(){return u(qt)},get onDismiss(){return u(Nt)},get onRemove(){return u(Ot)},get onSendToClaude(){return u(Ft)},get onEdit(){return u(En)},get onReply(){return u(Hn)},get openRequest(){return u(An)},onClick:()=>e.review.scrollToAnnotation(u(Ve)),get selected(){return u(zt)},get onToggleSelect(){return u(mn)}})}});var Fe=k(Me,2);{var We=je=>{var Ve=yz(),$e=w(Ve),ct=w($e),dt=k($e,2);mt(dt,21,()=>u(M).resolved,qt=>qt.id,(qt,Nt)=>{{let Ot=L(()=>u(E).get(u(Nt).id)??[]),Ft=L(()=>e.review.getRecentlyResolved().has(u(Nt).id));eb(qt,{get annotation(){return u(Nt)},get replies(){return u(Ot)},get reduceMotion(){return e.reduceMotion},get onUndo(){return e.review.undoResolveAnnotation},get undoable(){return u(Ft)},onClick:()=>e.review.scrollToAnnotation(u(Nt))})}}),W(()=>G(ct,`${u(M).resolved.length??""} resolved`)),x(je,Ve)};j(Fe,je=>{u(M).resolved.length>0&&je(We)})}Dt(he,je=>b(ve,je),()=>u(ve)),P("click",he,fe),x(K,he)};j(we,K=>{u(M).filtered.length===0?K(He):K(Oe,-1)})}Dt(_e,K=>b(A,K),()=>u(A)),qr(_e,(K,he)=>$t==null?void 0:$t(K,he),()=>"y"),W(()=>{G(ue,`${u(M).allPending.length??""} pending annotation${u(M).allPending.length!==1?"s":""}`),U(qe,"title",u(f)==="position"?"Sorted by position in document. Click to sort oldest first.":"Sorted oldest first. Click to sort by position in document."),U(qe,"aria-label",u(f)==="position"?"Annotations sorted by position in document. Switch to oldest first.":"Annotations sorted oldest first. Switch to position in document."),G(ae,u(f)==="position"?"Position":"Oldest"),G(Le,`${u(I)??""} ${u(M).filtered.length??""}`)}),P("click",qe,h),P("click",de,()=>b(_,!u(_))),x(t,_e),rt()}lt(["click"]);var xz=T('<div style="padding: var(--tandem-space-3) var(--tandem-space-4); font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-style: italic;">No headings</div>'),_z=T(`<span style="
86
+ flex-shrink: 0;
87
+ font-family: var(--tandem-font-mono);
88
+ font-size: var(--tandem-text-2xs, 10px);
89
+ font-weight: 500;
90
+ color: var(--tandem-fg-subtle);
91
+ background: var(--tandem-surface-muted);
92
+ border-radius: var(--tandem-r-pill);
93
+ padding: 0 var(--tandem-space-1);
94
+ min-width: 16px;
95
+ text-align: center;
96
+ line-height: 16px;
97
+ "> </span>`),Cz=T('<li><button><span class="outline-tick svelte-or41wm" aria-hidden="true"></span> <span style="flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></button></li>'),Sz=T('<ul style="list-style: none; margin: 0; padding: 0;"></ul>'),Ez=T('<nav data-testid="outline-panel" aria-label="Document outline" style="display: flex; flex-direction: column; flex: 1; overflow-y: auto;"><div class="outline-header-label tandem-ui svelte-or41wm">Outline</div> <div style="padding: var(--tandem-space-3) var(--tandem-space-3) var(--tandem-space-2);"><div class="outline-search-pill svelte-or41wm"><svg class="outline-search-icon svelte-or41wm" width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="7" cy="7" r="4.3" stroke="currentColor" stroke-width="1.4" fill="none"></circle><line x1="10.2" y1="10.2" x2="13.5" y2="13.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></line></svg> <input type="search" placeholder="Search in document…" data-testid="outline-search-input" aria-label="Search document" class="outline-search-input svelte-or41wm"/></div></div> <div class="tandem-scroll-fade-y" style="flex: 1; overflow-y: auto; padding: var(--tandem-space-3) var(--tandem-space-3);"><!></div></nav>');function cx(t,e){nt(e,!0);let n=Ze(e,"annotations",19,()=>[]),r=Ze(e,"focusTrigger",3,0),i=Ze(e,"activeFilterType",3,"all"),o=Ze(e,"activeFilterAuthor",3,"all"),s=Ze(e,"activeFilterStatus",3,"all"),a=F(tt([])),l=F(-1),c=F(tt([])),d=F(""),f=F(null),h=F(-1);pe(()=>{const D=e.editor;if(!D||D.isDestroyed){b(a,[],!0);return}b(a,Bv(D),!0),Ct(()=>{b(c,u(c).slice(0,u(a).length),!0),u(l)>=u(a).length&&b(l,Math.max(0,u(a).length-1),!0)});const I=()=>{b(a,Bv(D),!0),b(c,u(c).slice(0,u(a).length),!0),u(l)>=u(a).length&&b(l,Math.max(0,u(a).length-1),!0)};return D.on("update",I),()=>{D.isDestroyed||D.off("update",I),b(a,[],!0)}}),pe(()=>{var D,I;r()>0&&((D=u(f))==null||D.focus(),(I=u(f))==null||I.select())}),pe(()=>{const D=e.editor;if(!D||D.isDestroyed)return;const I=D.view.dom.closest(".editor-scroll")??D.view.dom.parentElement;function H(){if(!D||D.isDestroyed||u(a).length===0){b(h,-1);return}const Q=((I==null?void 0:I.getBoundingClientRect().top)??0)+48;let ie=-1;for(let me=0;me<u(a).length;me++)try{D.view.coordsAtPos(u(a)[me].pos+1).top<=Q&&(ie=me)}catch{}b(h,ie,!0)}return H(),I==null||I.addEventListener("scroll",H),()=>I==null?void 0:I.removeEventListener("scroll",H)});function p(){const D=e.editor;!D||D.isDestroyed||(u(d)?D.commands.find({query:u(d),caseSensitive:!1,wholeWord:!1,regexMode:!1}):D.commands.findClose())}function m(D){var I,H,z,Q;D.key==="Enter"?(D.preventDefault(),D.shiftKey?(I=e.editor)==null||I.commands.findPrev():(H=e.editor)==null||H.commands.findNext()):D.key==="Escape"&&(D.preventDefault(),b(d,""),(z=e.editor)==null||z.commands.findClose(),(Q=u(f))==null||Q.blur())}const v=L(()=>{const D=e.editor;if(!D||D.isDestroyed||u(a).length===0)return[];const I=D.state.doc.content.size,H=[];for(const z of n()){if(i()!=="all"){if(i()==="with-replacement"){if(!z.suggestedText)continue}else if(z.type!==i())continue}if(!(o()!=="all"&&z.author!==o())&&!(s()!=="all"&&z.status!==s()))try{H.push(na(D.state.doc,z.range.from))}catch{}}return u(a).map((z,Q)=>{const ie=Q+1<u(a).length?u(a)[Q+1].pos:I;return H.filter(me=>me>=z.pos&&me<ie).length})});function g(D,I){const H=e.editor;if(!H||H.isDestroyed)return;const{state:z}=H;try{const Q=z.doc.resolve(D.pos+1),ie=ut.near(Q);H.view.dispatch(z.tr.setSelection(ie)),H.view.focus();const{node:me}=H.view.domAtPos(D.pos+1),le=me instanceof Element?me:me.parentElement,ke=H.view.dom.closest(".editor-scroll")??H.view.dom.parentElement;if(le&&ke){const ce=le.getBoundingClientRect().top,ve=ke.getBoundingClientRect().top;ke.scrollTop+=ce-ve-ke.clientHeight*.05}}catch{}b(l,I,!0)}function y(D){var I,H,z,Q;if(u(a).length!==0)if(D.key==="ArrowDown"){D.preventDefault();const ie=(u(l)+1)%u(a).length;b(l,ie),(I=u(c)[ie])==null||I.focus()}else if(D.key==="ArrowUp"){D.preventDefault();const ie=(u(l)-1+u(a).length)%u(a).length;b(l,ie),(H=u(c)[ie])==null||H.focus()}else D.key==="Home"?(D.preventDefault(),b(l,0),(z=u(c)[0])==null||z.focus()):D.key==="End"&&(D.preventDefault(),b(l,u(a).length-1),(Q=u(c)[u(a).length-1])==null||Q.focus())}var C=Ez(),_=k(w(C),2),S=w(_),A=k(w(S),2);Dt(A,D=>b(f,D),()=>u(f));var O=k(_,2),E=w(O);{var M=D=>{var I=xz();x(D,I)},R=D=>{var I=Sz();mt(I,21,()=>u(a),dc,(H,z,Q)=>{const ie=L(()=>u(h)===Q),me=L(()=>u(v)[Q]??0);var le=Cz(),ke=w(le),ce=w(ke),ve=k(ce,2),De=w(ve),ee=k(ve,2);{var q=V=>{var re=_z(),te=w(re);W(()=>{U(re,"title",`${u(me)??""} annotation${u(me)!==1?"s":""}`),G(te,u(me))}),x(V,re)};j(ee,V=>{u(me)>0&&V(q)})}Dt(ke,(V,re)=>u(c)[re]=V,V=>{var re;return(re=u(c))==null?void 0:re[V]},()=>[Q]),W(()=>{U(ke,"data-testid",`outline-heading-${u(z).level}-${Q}`),U(ke,"tabindex",u(l)===Q||u(l)===-1&&Q===0?0:-1),Pe(ke,`
98
+ display: flex; align-items: center; width: 100%; text-align: left;
99
+ padding: var(--tandem-space-1) var(--tandem-space-3);
100
+ padding-left: calc(var(--tandem-space-1) + ${(u(z).level-1)*12}px);
101
+ font-size: ${u(z).level===1?"var(--tandem-text-sm)":"var(--tandem-text-xs)"};
102
+ font-weight: ${u(z).level===1?600:u(z).level===2?500:400};
103
+ color: ${u(ie)?"var(--tandem-accent)":u(z).level===1?"var(--tandem-fg)":u(z).level===2?"var(--tandem-fg-subtle)":"var(--tandem-fg-muted)"};
104
+ background: ${u(ie)?"var(--tandem-accent-bg)":"none"};
105
+ border: none; cursor: pointer; line-height: 1.5;
106
+ transition: color 0.1s, background 0.1s;
107
+ gap: var(--tandem-space-2);
108
+ `),U(ke,"title",u(z).text),Pe(ce,u(ie)?"background-color: var(--tandem-accent); opacity: 1;":""),G(De,u(z).text||"(untitled)")}),P("click",ke,()=>g(u(z),Q)),Qt("focus",ke,()=>b(l,Q,!0)),Qt("mouseenter",ke,V=>{u(ie)||(V.currentTarget.style.background="var(--tandem-surface-hover, var(--tandem-surface-muted))")}),Qt("mouseleave",ke,V=>{u(ie)||(V.currentTarget.style.background="none")}),x(H,le)}),x(D,I)};j(E,D=>{u(a).length===0?D(M):D(R,-1)})}qr(O,(D,I)=>$t==null?void 0:$t(D,I),()=>"y"),P("keydown",C,y),P("input",A,p),P("keydown",A,m),Hr(A,()=>u(d),D=>b(d,D)),x(t,C),rt()}lt(["keydown","input","click"]);var Az=T("<div><!></div>");function i0(t,e){nt(e,!0);let n=mD(e,["$$slots","$$events","$$legacy","kind","visible"]);const r=L(()=>e.visible!==void 0?`display: ${e.visible?"flex":"none"}; flex-direction: column; flex: 1; min-height: 0;${e.kind==="outline"?" padding-bottom: var(--tandem-status-clearance-total, 88px);":""}`:void 0);var i=St(),o=Ae(i);{var s=d=>{var f=Az(),h=w(f);{var p=g=>{ix(g,mu(()=>n,{get visible(){return e.visible}}))},m=g=>{cx(g,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType},get activeFilterAuthor(){return e.activeFilterAuthor},get activeFilterStatus(){return e.activeFilterStatus}})},v=g=>{lx(g,mu(()=>n))};j(h,g=>{e.kind==="chat"?g(p):e.kind==="outline"?g(m,1):g(v,-1)})}W(()=>Pe(f,u(r))),x(d,f)},a=d=>{ix(d,mu(()=>n))},l=d=>{cx(d,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType}})},c=d=>{lx(d,mu(()=>n))};j(o,d=>{u(r)?d(s):e.kind==="chat"?d(a,1):e.kind==="outline"?d(l,2):d(c,-1)})}x(t,i),rt()}var Tz=T('<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>'),Mz=T('<button type="button" class="tandem-banner__cta" data-testid="convert-to-markdown-btn"> </button>'),Dz=T(`<div class="tandem-banner tandem-banner--info" role="status" aria-live="polite" data-testid="review-only-banner"><span class="tandem-banner__message">This document is open in review-only mode. You can add annotations and review, but cannot
109
+ edit directly.</span> <!> <!> <button type="button" class="tandem-banner__dismiss" data-testid="review-only-dismiss" aria-label="Dismiss review-only banner"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>`);function Oz(t,e){nt(e,!0);const n="tandem:reviewOnlyBannerDismissed";function r(){try{return localStorage.getItem(n)==="true"}catch{return!1}}let i=F(tt(r())),o=F(!1),s=F(null);async function a(){if(!(!e.documentId||u(o))){b(o,!0),b(s,null);try{const h=await fetch(`${nn}${yO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})});if(!h.ok){const p=await h.json().catch(()=>null);b(s,(p==null?void 0:p.message)??`Conversion failed (HTTP ${h.status}).`,!0)}}catch{b(s,"Could not reach the server.")}finally{b(o,!1)}}}function l(){try{localStorage.setItem(n,"true")}catch{}b(i,!0)}var c=St(),d=Ae(c);{var f=h=>{var p=Dz(),m=k(w(p),2);{var v=_=>{var S=Tz(),A=w(S);W(()=>G(A,u(s))),x(_,S)};j(m,_=>{u(s)&&_(v)})}var g=k(m,2);{var y=_=>{var S=Mz(),A=w(S);W(()=>{S.disabled=u(o),G(A,u(o)?"Converting…":"Convert to Markdown")}),P("click",S,a),x(_,S)};j(g,_=>{e.documentId&&_(y)})}var C=k(g,2);P("click",C,l),x(h,p)};j(d,h=>{e.visible&&!u(i)&&h(f)})}x(t,c),rt()}lt(["click"]);let o0=null;async function Iz(t){if(o0!==null)return o0;const e=await fetch(`${nn}${Ev}`,{signal:t});if(!e.ok)throw new Error(`${Ev} responded ${e.status} ${e.statusText}`);const n=await e.json();return o0=n,n}function Gm(t){let e=F(null),n=F(!1);return pe(()=>{if(!t())return;let r=!1;const i=new AbortController,o=setTimeout(()=>i.abort(),3e3);return b(n,!0),Iz(i.signal).then(s=>{r||b(e,s,!0)}).catch(s=>{s instanceof Error&&s.name!=="AbortError"&&console.warn("[useAppInfo] failed to load /api/info:",s)}).finally(()=>{clearTimeout(o),r||b(n,!1)}),()=>{r=!0,clearTimeout(o),i.abort()}}),{get info(){return u(e)},get loading(){return u(n)}}}var Rz=T('<div><div>Contrast</div> <label data-testid="high-contrast-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>High contrast</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Increases border and text contrast for improved readability.</div></div> <div><div>Annotation Patterns</div> <label data-testid="annotation-patterns-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Use pattern fills for annotations</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Adds visual patterns to annotation decorations (color-blind friendly).</div></div>',1);function oA(t,e){nt(e,!0);const n="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";var r=Rz(),i=Ae(r),o=w(i);Pe(o,n);var s=k(o,2),a=w(s),l=k(i,2),c=w(l);Pe(c,n);var d=k(c,2),f=w(d);W(()=>{Fn(a,e.settings.highContrast),Fn(f,e.settings.annotationPatterns)}),P("change",a,h=>e.onUpdate({highContrast:h.target.checked})),P("change",f,h=>e.onUpdate({annotationPatterns:h.target.checked})),x(t,r),rt()}lt(["change"]);var Nz=T('<button role="radio"> </button>'),Pz=T(`<label data-testid="appearance-system-light-warm" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5); margin-top: var(--tandem-space-2);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Use Warm when system is light</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">When your OS reports a light appearance, use the paper-tone Warm theme instead of
110
+ neutral Light. A dark OS appearance still resolves to Dark.</div>`,1),Lz=T('<button role="radio"> </button>'),Fz=T('<button role="radio"> </button>'),zz=T('<button role="radio"> </button>'),Bz=T('<div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="flex: 0 0 7rem; font-size: 11px; color: var(--tandem-fg-muted);"> </span> <div role="radiogroup" tabindex="0" style="display: flex; gap: var(--tandem-space-2); flex: 1;"></div></div>'),Hz=T('<button role="radio"> </button>'),Vz=T('<label style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span> </span></label>'),Uz=T(`<div><div id="settings-theme-label">Theme</div> <div role="radiogroup" aria-labelledby="settings-theme-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div> <!></div> <div><div id="settings-default-tab-label">Default Tab</div> <div role="radiogroup" aria-labelledby="settings-default-tab-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"><button data-testid="default-tab-chat-btn" role="radio">Chat</button> <button data-testid="default-tab-annotations-btn" role="radio">Annotations</button></div></div> <div><div id="settings-text-size-label">Text Size</div> <div role="radiogroup" aria-labelledby="settings-text-size-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Reading density only — use browser zoom (Ctrl + =/−) to scale the whole UI.</div></div> <div><div id="settings-accent-color-label">Accent Color</div> <div style="display: flex; align-items: center; gap: 8px;"><span aria-hidden="true" style="display: inline-block; width: 16px; height: 16px; background: var(--tandem-accent); border-radius: var(--tandem-r-1); flex-shrink: 0; border: 1px solid var(--tandem-border-strong);"></span> <input data-testid="accent-hue-slider" type="range" min="0" max="360" step="1" aria-labelledby="settings-accent-color-label" style="flex: 1; accent-color: var(--tandem-accent);"/></div></div> <div><div id="settings-editor-font-label">Editor Font</div> <div role="radiogroup" aria-labelledby="settings-editor-font-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div></div> <div data-testid="font-by-extension-section"><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;"><div id="settings-font-by-ext-label">Default font by file type</div> <button data-testid="font-by-extension-reset" type="button">Reset to defaults</button></div> <div style="display: flex; flex-direction: column; gap: var(--tandem-space-2);"></div> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Each file type uses this font; files with no specific choice fall back to the Editor Font above.</div></div> <div><div id="settings-density-label">Spacing Density</div> <div role="radiogroup" aria-labelledby="settings-density-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div></div> <div><div>Decorations</div> <!> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Turn a type off to hide its inline marks in the editor. Annotation cards in the
111
+ side panel stay visible. Display-only — hiding Notes never affects what Claude reads.</div></div> <div><label data-testid="reduce-motion-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Reduce motion</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Disables smooth autoscroll and the annotation flash animation.</div></div> <div><label data-testid="appearance-formatting-bar" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show formatting bar</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">The persistent toolbar above the document. When hidden, formatting stays available
112
+ in the selection popup, and Ctrl+Z / Ctrl+Y still undo and redo.</div></div> <div><label data-testid="appearance-show-raw-markdown" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show raw markdown</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Footnotes, reference-style links, and inline HTML that Tandem keeps as raw source.
113
+ When hidden they stay in the file and always save — only the on-screen markers are
114
+ hidden.</div></div> <div><label data-testid="appearance-rail-hover-reveal" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Reveal rails on hover</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Hover a closed outline or annotations rail to float it over the document without
115
+ resizing it; click its edge to pin it open. When off, rails reveal only on click.</div></div>`,1);function sA(t,e){nt(e,!0);const n=[{format:"md",label:"Markdown (.md)"},{format:"docx",label:"Word (.docx)"},{format:"html",label:"HTML (.html)"},{format:"txt",label:"Plain text (.txt)"}],r=[["sans","Sans"],["serif","Serif"],["mono","Mono"]];function i(ae){var de;return((de=e.settings.fontByExtension)==null?void 0:de[ae])??e.settings.editorFont}function o(ae,de){e.onUpdate({fontByExtension:{...e.settings.fontByExtension,[ae]:de}})}function s(){e.onUpdate({fontByExtension:{}})}const a=L(()=>Object.keys(e.settings.fontByExtension??{}).length>0),l="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",c=[["showAuthorship","appearance-show-authorship","Authorship colors"],["showComments","appearance-show-comments","Comments"],["showHighlights","appearance-show-highlights","Highlights"],["showNotes","appearance-show-notes","Notes (private)"]];function d(ae,de){return["flex: 1;","padding: var(--tandem-space-2);","min-height: 24px;",`border: 2px solid ${ae?"var(--tandem-accent)":"var(--tandem-border)"};`,"border-radius: var(--tandem-r-3);",`background: ${ae?"var(--tandem-accent-bg)":"var(--tandem-surface)"};`,"cursor: pointer;","text-align: center;","font-size: 11px;",`color: ${ae?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"};`,`font-weight: ${ae?600:400};`,"opacity: 1;","transition: border-color 0.15s, background 0.15s;"].join(" ")}const f=_s(()=>e.settings.theme,["light","warm","dark","system"],ae=>e.onUpdate({theme:ae})),h=_s(()=>e.settings.primaryTab,["chat","annotations"],ae=>e.onUpdate({primaryTab:ae})),p=_s(()=>e.settings.textSize,["s","m","l"],ae=>e.onUpdate({textSize:ae})),m=_s(()=>e.settings.editorFont,["sans","serif","mono"],ae=>e.onUpdate({editorFont:ae})),v=_s(()=>e.settings.density,["compact","cozy","spacious"],ae=>e.onUpdate({density:ae})),g={};for(const ae of n)g[ae.format]=_s(()=>i(ae.format),["sans","serif","mono"],de=>o(ae.format,de));var y=Uz(),C=Ae(y),_=w(C);Pe(_,l);var S=k(_,2);mt(S,20,()=>["light","warm","dark","system"],ae=>ae,(ae,de)=>{var xe=Nz(),Le=w(xe);W((it,ne)=>{U(xe,"data-testid",`theme-${de}-btn`),U(xe,"aria-checked",e.settings.theme===de),U(xe,"tabindex",it),Pe(xe,ne),G(Le,de==="light"?"Light":de==="warm"?"Warm":de==="dark"?"Dark":"System")},[()=>f.tabIndexFor(de),()=>d(e.settings.theme===de)]),P("click",xe,()=>e.onUpdate({theme:de})),x(ae,xe)});var A=k(S,2);{var O=ae=>{var de=Pz(),xe=Ae(de),Le=w(xe);W(()=>Fn(Le,e.settings.systemLightVariant==="warm")),P("change",Le,it=>e.onUpdate({systemLightVariant:it.target.checked?"warm":"light"})),x(ae,de)};j(A,ae=>{e.settings.theme==="system"&&ae(O)})}var E=k(C,2),M=w(E);Pe(M,l);var R=k(M,2),D=w(R),I=k(D,2),H=k(E,2),z=w(H);Pe(z,l);var Q=k(z,2);mt(Q,20,()=>["s","m","l"],ae=>ae,(ae,de)=>{var xe=Lz(),Le=w(xe);W((it,ne)=>{U(xe,"data-testid",`text-size-${de}-btn`),U(xe,"aria-checked",e.settings.textSize===de),U(xe,"tabindex",it),Pe(xe,ne),G(Le,de==="s"?"Small":de==="m"?"Medium":"Large")},[()=>p.tabIndexFor(de),()=>d(e.settings.textSize===de)]),P("click",xe,()=>e.onUpdate({textSize:de})),x(ae,xe)});var ie=k(H,2),me=w(ie);Pe(me,l);var le=k(me,2),ke=k(w(le),2),ce=k(ie,2),ve=w(ce);Pe(ve,l);var De=k(ve,2);mt(De,20,()=>[["sans","Sans-serif"],["serif","Serif (Source Serif 4)"],["mono","Monospace"]],([ae,de])=>ae,(ae,de)=>{var xe=L(()=>_f(de,2));let Le=()=>u(xe)[0],it=()=>u(xe)[1];var ne=Fz(),Ee=w(ne);W((B,$)=>{U(ne,"data-testid",`editor-font-${Le()}-btn`),U(ne,"aria-checked",e.settings.editorFont===Le()),U(ne,"tabindex",B),Pe(ne,$),G(Ee,it())},[()=>m.tabIndexFor(Le()),()=>d(e.settings.editorFont===Le())]),P("click",ne,()=>e.onUpdate({editorFont:Le()})),x(ae,ne)});var ee=k(ce,2),q=w(ee),V=w(q);Pe(V,`${l} margin-bottom: 0;`);var re=k(V,2),te=k(q,2);mt(te,21,()=>n,ae=>ae.format,(ae,de)=>{var xe=Bz(),Le=w(xe),it=w(Le),ne=k(Le,2);mt(ne,21,()=>r,([Ee,B])=>Ee,(Ee,B)=>{var $=L(()=>_f(u(B),2));let we=()=>u($)[0],He=()=>u($)[1];var Oe=zz(),K=w(Oe);W((he,Me,Fe)=>{U(Oe,"data-testid",`font-by-extension-${u(de).format}-${we()}`),U(Oe,"aria-checked",he),U(Oe,"tabindex",Me),Pe(Oe,Fe),G(K,He())},[()=>i(u(de).format)===we(),()=>g[u(de).format].tabIndexFor(we()),()=>d(i(u(de).format)===we())]),P("click",Oe,()=>o(u(de).format,we())),x(Ee,Oe)}),W(()=>{U(xe,"data-testid",`font-by-extension-row-${u(de).format}`),G(it,u(de).label),U(ne,"aria-label",`Default font for ${u(de).label}`)}),P("keydown",ne,function(...Ee){var B;(B=g[u(de).format].handleKeyDown)==null||B.apply(this,Ee)}),x(ae,xe)});var Z=k(ee,2),ge=w(Z);Pe(ge,l);var Ie=k(ge,2);mt(Ie,20,()=>[["compact","Compact"],["cozy","Cozy"],["spacious","Spacious"]],([ae,de])=>ae,(ae,de)=>{var xe=L(()=>_f(de,2));let Le=()=>u(xe)[0],it=()=>u(xe)[1];var ne=Hz(),Ee=w(ne);W((B,$)=>{U(ne,"data-testid",`density-${Le()}-btn`),U(ne,"aria-checked",e.settings.density===Le()),U(ne,"tabindex",B),Pe(ne,$),G(Ee,it())},[()=>v.tabIndexFor(Le()),()=>d(e.settings.density===Le())]),P("click",ne,()=>e.onUpdate({density:Le()})),x(ae,ne)});var Se=k(Z,2),fe=w(Se);Pe(fe,l);var _e=k(fe,2);mt(_e,17,()=>c,([ae,de,xe])=>ae,(ae,de)=>{var xe=L(()=>_f(u(de),3));let Le=()=>u(xe)[0],it=()=>u(xe)[1],ne=()=>u(xe)[2];var Ee=Vz(),B=w(Ee),$=k(B,2),we=w($);W(()=>{U(Ee,"data-testid",it()),Fn(B,e.settings[Le()]),G(we,ne())}),P("change",B,He=>e.onUpdate({[Le()]:He.target.checked,...e.settings.decorationsMuted?{decorationsMuted:!1}:{}})),x(ae,Ee)});var X=k(Se,2),ye=w(X),Y=w(ye),se=k(X,2),Te=w(se),Re=w(Te),ze=k(se,2),Je=w(ze),ue=w(Je),Ne=k(ze,2),qe=w(Ne),Xe=w(qe);W((ae,de,xe,Le)=>{U(D,"aria-checked",e.settings.primaryTab==="chat"),U(D,"tabindex",ae),Pe(D,de),U(I,"aria-checked",e.settings.primaryTab==="annotations"),U(I,"tabindex",xe),Pe(I,Le),Vr(ke,e.settings.accentHue),re.disabled=!u(a),Pe(re,`background: none; border: none; padding: 0; font-size: var(--tandem-text-2xs); color: ${u(a)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${u(a)?"pointer":"default"}; text-decoration: ${u(a)?"underline":"none"};`),Fn(Y,e.settings.reduceMotion),Fn(Re,e.settings.formattingBarVisible),Fn(ue,e.settings.showRawMarkdown),Fn(Xe,e.settings.railHoverReveal)},[()=>h.tabIndexFor("chat"),()=>d(e.settings.primaryTab==="chat"),()=>h.tabIndexFor("annotations"),()=>d(e.settings.primaryTab==="annotations")]),P("keydown",S,function(...ae){var de;(de=f.handleKeyDown)==null||de.apply(this,ae)}),P("keydown",R,function(...ae){var de;(de=h.handleKeyDown)==null||de.apply(this,ae)}),P("click",D,()=>e.onUpdate({primaryTab:"chat"})),P("click",I,()=>e.onUpdate({primaryTab:"annotations"})),P("keydown",Q,function(...ae){var de;(de=p.handleKeyDown)==null||de.apply(this,ae)}),P("input",ke,ae=>e.onUpdate({accentHue:Number(ae.target.value)})),P("keydown",De,function(...ae){var de;(de=m.handleKeyDown)==null||de.apply(this,ae)}),P("click",re,s),P("keydown",Ie,function(...ae){var de;(de=v.handleKeyDown)==null||de.apply(this,ae)}),P("change",Y,ae=>e.onUpdate({reduceMotion:ae.target.checked})),P("change",Re,ae=>e.onUpdate({formattingBarVisible:ae.target.checked})),P("change",ue,ae=>e.onUpdate({showRawMarkdown:ae.target.checked})),P("change",Xe,ae=>e.onUpdate({railHoverReveal:ae.target.checked})),x(t,y),rt()}lt(["keydown","click","change","input"]);var jz=T('<button type="button" role="radio"> </button>'),qz=T('<button type="button" data-testid="settings-default-save-folder-pick" style="padding: 6px 10px; font-size: 11px; white-space: nowrap; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer;">Choose…</button>'),Wz=T(`<div><div id="settings-measure-label">Reading Measure</div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 8px;">The line length of the editor text. A stable measure keeps lines readable
116
+ regardless of panel state.</div> <div role="radiogroup" aria-labelledby="settings-measure-label" tabindex="0" style="display: flex; gap: var(--tandem-space-1); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); padding: 2px;"></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: 6px;"> </div> <div data-testid="settings-default-save-folder" style="margin-top: var(--tandem-space-5);"><div>Default Save Folder</div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 8px;">Where new files go when you use <strong>Save As</strong> in the desktop app.
117
+ Leave empty to fall back to your AI's working directory, then your home
118
+ folder.</div> <form style="display: flex; gap: var(--tandem-space-1); align-items: center;"><input type="text" name="default-save-dir" data-testid="settings-default-save-folder-input" placeholder="(default: AI working directory, then home)" aria-label="Default save folder path" style="flex: 1; min-width: 0; padding: 6px 8px; font-size: 11px; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg);"/> <!> <button type="button" data-testid="settings-default-save-folder-reset">Reset</button></form></div></div>`);function aA(t,e){nt(e,!0);const n="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",r=Tt();function i(O){const E=O==null?void 0:O.trim();e.onUpdate({defaultSaveDirectory:E||null})}function o(O){O.preventDefault();const E=O.target.elements.namedItem("default-save-dir");i((E==null?void 0:E.value)??null)}async function s(){let O;try{({open:O}=await Zt(()=>import("./index-Dm_QtxGQ.js"),__vite__mapDeps([2,1])))}catch(E){console.warn("[Settings] Folder picker import failed:",E),e.notify("error","Folder picker plugin unavailable");return}try{const E=await O({directory:!0,multiple:!1,title:"Choose default save folder"});typeof E=="string"&&i(E)}catch(E){console.warn("[Settings] Folder picker open() failed:",E),e.notify("error","Folder picker permission denied or IPC error")}}const a=[{value:"narrow",label:"Narrow",hint:"58 characters"},{value:"comfortable",label:"Comfortable",hint:"68 characters"},{value:"wide",label:"Wide",hint:"82 characters"},{value:"full",label:"Full",hint:"Fills the editor"}],l=_s(()=>e.settings.editorMeasure,a.map(O=>O.value),O=>e.onUpdate({editorMeasure:O})),c=L(()=>{var O;return((O=a.find(E=>E.value===e.settings.editorMeasure))==null?void 0:O.hint)??""});var d=Wz(),f=w(d);Pe(f,n);var h=k(f,4);mt(h,21,()=>a,O=>O.value,(O,E)=>{const M=L(()=>e.settings.editorMeasure===u(E).value);var R=jz(),D=w(R);W(I=>{U(R,"aria-checked",u(M)),U(R,"tabindex",I),U(R,"data-testid",`editor-measure-${u(E).value}`),Pe(R,`flex: 1; padding: 6px 4px; border: none; border-radius: var(--tandem-r-1); cursor: pointer; font-size: 11px; font-weight: ${u(M)?600:400}; background: ${u(M)?"var(--tandem-accent)":"transparent"}; color: ${u(M)?"var(--tandem-accent-fg)":"var(--tandem-fg)"};`),G(D,u(E).label)},[()=>l.tabIndexFor(u(E).value)]),P("click",R,()=>e.onUpdate({editorMeasure:u(E).value})),x(O,R)});var p=k(h,2),m=w(p),v=k(p,2),g=w(v);Pe(g,n);var y=k(g,4),C=w(y),_=k(C,2);{var S=O=>{var E=qz();P("click",E,s),x(O,E)};j(_,O=>{r&&O(S)})}var A=k(_,2);W(()=>{G(m,u(c)),Vr(C,e.settings.defaultSaveDirectory??""),A.disabled=!e.settings.defaultSaveDirectory,Pe(A,`padding: 6px 10px; font-size: 11px; white-space: nowrap; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); background: transparent; color: var(--tandem-fg-muted); cursor: ${e.settings.defaultSaveDirectory?"pointer":"default"}; opacity: ${e.settings.defaultSaveDirectory?1:.5};`)}),P("keydown",h,function(...O){var E;(E=l.handleKeyDown)==null||E.apply(this,O)}),Qt("submit",y,o),Qt("blur",C,O=>i(O.currentTarget.value)),P("click",A,()=>i(null)),x(t,d),rt()}lt(["keydown","click"]);var Kz=T('<details class="cs-details svelte-x76129"><summary class="cs-summary svelte-x76129"><span class="cs-chevron svelte-x76129" aria-hidden="true">›</span> </summary> <div class="cs-body svelte-x76129"><!></div></details>');function lA(t,e){const n=Ze(e,"defaultOpen",3,!1);var r=Kz(),i=w(r),o=k(w(i)),s=k(i,2),a=w(s);Gd(a,()=>e.children),W(()=>{U(r,"data-testid",e.testid),r.open=n(),U(i,"data-testid",e.testid?`${e.testid}-toggle`:void 0),G(o,` ${e.label??""}`)}),x(t,r)}var Gz=T('<span style="color: var(--tandem-fg-subtle);"> </span>'),Zz=T('<button type="button" data-testid="network-restart-sidecar"> </button>'),Yz=T('<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop &amp;&amp; tandem start</code> to restart</span>'),Jz=T('<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>'),Xz=T("<span><strong>Host:</strong> </span>"),Qz=T('<div><div>Loopback Port</div> <div style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface-muted); font-size: 13px; color: var(--tandem-fg-subtle); display: inline-block;"> </div> <div>Port used when transport is HTTP. To change, run <code>tandem start --port &lt;N&gt;</code>.</div></div>'),$z=T("<option> </option>"),eB=T('<div><div>Token Rotation</div> <div style="font-size: 12px; color: var(--tandem-fg);"> </div> <div>To rotate: run <code>tandem rotate-token</code> in the CLI.</div></div>'),tB=T('<!> <div><div>Show degraded banner after: <span style="font-weight: 400; text-transform: none;"> </span></div> <input data-testid="network-degraded-delay-slider" type="range" min="5000" max="120000" step="5000" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Degraded banner delay"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span>5s</span> <span>120s</span></div></div> <div><div>Reconnect Strategy <span style="font-size: 10px; color: var(--tandem-fg-subtle);">(not yet active)</span></div> <select data-testid="network-retry-strategy" style="width: 100%; padding: 6px 8px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: pointer;" aria-label="Reconnect retry strategy"></select></div> <label><input type="checkbox" data-testid="network-hold-annotations-toggle" style="accent-color: var(--tandem-accent);"/> <span>Hold annotations while offline <span style="font-size: 10px; color: var(--tandem-fg-subtle);">(not yet active)</span></span></label> <div>When enabled, annotation events will queue locally and sync when the connection is restored.</div> <!>',1),nB=T('<div><div>Connection Status</div> <div style="display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface);"><span aria-hidden="true"></span> <span style="font-size: 12px; color: var(--tandem-fg); flex: 1;"> <!></span> <!></div> <!></div> <div><div>Transport</div> <div style="display: flex; gap: var(--tandem-space-4); padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface); font-size: 12px; color: var(--tandem-fg);"><span><strong>Mode:</strong> </span> <!></div></div> <!>',1);function cA(t,e){nt(e,!0);const n=Gm(()=>e.open),r=Tt();let i=F(null),o=F(!1);async function s(){if(r){b(o,!0),b(i,null);try{const{invoke:ee}=await Zt(async()=>{const{invoke:q}=await import("./core-DhEqZVGG.js");return{invoke:q}},[]);await ee("restart_sidecar")}catch(ee){b(i,ee instanceof Error?ee.message:String(ee),!0)}finally{b(o,!1)}}}const a=[{value:"exponential",label:"Exponential backoff"},{value:"constant-2s",label:"Constant (2s)"},{value:"manual",label:"Manual only"}],l="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",c="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;",d="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);",f=L(()=>{var ee;return(ee=n.info)==null?void 0:ee.transport}),h=L(()=>{var ee;return(ee=n.info)==null?void 0:ee.bindHost}),p=L(()=>{var ee;return(ee=n.info)==null?void 0:ee.bindPort}),m=L(()=>u(f)==="http"),v=L(()=>{var ee;return(ee=n.info)==null?void 0:ee.tokenRotatedAt});var g=nB(),y=Ae(g),C=w(y);Pe(C,l);var _=k(C,2),S=w(_),A=k(S,2),O=w(A),E=k(O);{var M=ee=>{var q=Gz(),V=w(q);W(()=>G(V,`· ${e.reconnectAttempts??""} retry attempt${e.reconnectAttempts===1?"":"s"}`)),x(ee,q)};j(E,ee=>{e.reconnectAttempts>0&&ee(M)})}var R=k(A,2);{var D=ee=>{var q=Zz(),V=w(q);W(()=>{q.disabled=u(o),Pe(q,`padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; opacity: ${u(o)?.5:1};`),G(V,u(o)?"Restarting…":"Restart sidecar")}),P("click",q,s),x(ee,q)},I=ee=>{var q=Yz();x(ee,q)};j(R,ee=>{r?ee(D):ee(I,-1)})}var H=k(_,2);{var z=ee=>{var q=Jz(),V=w(q);W(()=>G(V,u(i))),x(ee,q)};j(H,ee=>{u(i)&&ee(z)})}var Q=k(y,2),ie=w(Q);Pe(ie,l);var me=k(ie,2),le=w(me),ke=k(w(le)),ce=k(le,2);{var ve=ee=>{var q=Xz(),V=k(w(q));W(()=>G(V,` ${u(h)??""}`)),x(ee,q)};j(ce,ee=>{u(h)&&ee(ve)})}var De=k(Q,2);lA(De,{label:"Advanced",testid:"network-advanced",children:(ee,q)=>{var V=tB(),re=Ae(V);{var te=ue=>{var Ne=Qz(),qe=w(Ne);Pe(qe,l);var Xe=k(qe,2),ae=w(Xe),de=k(Xe,2);Pe(de,d),W(()=>G(ae,u(p)??"—")),x(ue,Ne)};j(re,ue=>{u(m)&&ue(te)})}var Z=k(re,2),ge=w(Z);Pe(ge,l);var Ie=k(w(ge)),Se=w(Ie),fe=k(ge,2),_e=k(Z,2),X=w(_e);Pe(X,l);var ye=k(X,2);mt(ye,21,()=>a,ue=>ue.value,(ue,Ne)=>{var qe=$z(),Xe=w(qe),ae={};W(()=>{G(Xe,u(Ne).label),ae!==(ae=u(Ne).value)&&(qe.value=(qe.__value=u(Ne).value)??"")}),x(ue,qe)});var Y;FC(ye);var se=k(_e,2);Pe(se,c);var Te=w(se),Re=k(se,2);Pe(Re,d);var ze=k(Re,2);{var Je=ue=>{var Ne=eB(),qe=w(Ne);Pe(qe,l);var Xe=k(qe,2),ae=w(Xe),de=k(Xe,2);Pe(de,d),W(xe=>G(ae,xe),[()=>u(v)===null?"Auth token not yet created":`Last rotated: ${new Date(u(v)).toLocaleString()}`]),x(ue,Ne)};j(ze,ue=>{u(v)!==void 0&&ue(Je)})}W(()=>{G(Se,`${e.settings.degradedBannerDelayMs/1e3}s`),Vr(fe,e.settings.degradedBannerDelayMs),Y!==(Y=e.settings.sidecarRetryStrategy)&&(ye.value=(ye.__value=e.settings.sidecarRetryStrategy)??"",a1(ye,e.settings.sidecarRetryStrategy)),Fn(Te,e.settings.holdAnnotationsWhileOffline)}),P("input",fe,ue=>e.onUpdate({degradedBannerDelayMs:Number(ue.target.value)})),P("change",ye,ue=>e.onUpdate({sidecarRetryStrategy:ue.target.value})),P("change",Te,ue=>e.onUpdate({holdAnnotationsWhileOffline:ue.target.checked})),x(ee,V)},$$slots:{default:!0}}),W(ee=>{Pe(S,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${e.connected?"var(--tandem-success)":"var(--tandem-error)"}; flex-shrink: 0;`),G(O,`${e.connected?"Connected to Tandem server":"Disconnected"} `),G(ke,` ${ee??""}`)},[()=>u(f)?u(f).toUpperCase():"—"]),x(t,g),rt()}lt(["click","input","change"]);const rB="INVALID_BODY",iB="PATH_REJECTED",oB="LAUNCHER_IN_PROGRESS",sB="LAUNCHER_NOT_AVAILABLE",aB="NO_CLAUDE_INTEGRATION";var lB=T(`<div data-testid="settings-modal-connect-ai-callout" style="display: flex; flex-direction: column; align-items: flex-start; gap: var(--tandem-space-2); padding: var(--tandem-space-3); background: var(--tandem-info-bg); border: 1px solid var(--tandem-info-border); border-radius: var(--tandem-r-3); margin-bottom: var(--tandem-space-3);"><div style="font-size: 13px; font-weight: 600; color: var(--tandem-info-fg-strong);">No AI connected yet</div> <div style="font-size: 12px; line-height: 1.5; color: var(--tandem-info-fg);">Tandem's AI works through Claude Code or Claude Desktop using your existing Claude
119
+ sign-in — no API key needed. The setup wizard connects it in one step.</div> <button type="button" data-testid="settings-modal-connect-ai-btn" style="font-size: 12px; font-weight: 500; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-accent); background: var(--tandem-accent); color: var(--tandem-accent-fg); cursor: pointer;">Connect AI…</button></div>`),cB=T('<div role="alert" data-testid="settings-modal-working-directory-load-error" style="font-size: 11px; color: var(--tandem-error-fg); background: var(--tandem-error-bg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); padding: var(--tandem-space-2);"> </div>'),uB=T('<button type="button" data-testid="settings-modal-working-directory-pick" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: pointer;">Choose folder…</button>'),dB=T('<div role="alert" style="font-size: 11px; color: var(--tandem-error-fg);"> </div>'),fB=T('<div data-testid="settings-modal-working-directory" style="display: flex; flex-direction: column; gap: var(--tandem-space-2);"><div class="settings-section-label">Claude working directory</div> <div class="settings-hint">Folder where Claude launches. Defaults to your home directory if empty.</div> <form style="display: flex; gap: var(--tandem-space-2);"><input type="text" name="wd" data-testid="settings-modal-working-directory-input" style="flex: 1; font-size: 12px; padding: var(--tandem-space-2); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface); color: var(--tandem-fg); font-family: var(--tandem-font-mono);"/> <button type="submit" data-testid="settings-modal-working-directory-save" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: pointer;">Save</button></form> <div style="display: flex; gap: var(--tandem-space-2);"><!> <button type="button" data-testid="settings-modal-working-directory-reset" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: transparent; color: var(--tandem-fg-muted); cursor: pointer;">Reset to default</button></div> <!></div>'),hB=T('<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),pB=T(`<!> <p style="font-size: 12px; line-height: 1.5; color: var(--tandem-fg-muted); margin: 0 0 var(--tandem-space-3);">Tandem connects to any MCP-capable AI client over its MCP endpoint. Claude (Claude Code and
120
+ Claude Desktop) is the default integration — auto-configured, tested, and the only client whose
121
+ channel-push, cowork, and auto-launch extras are validated today. Other clients can connect
122
+ manually using the MCP endpoint on the Network tab.</p> <div><div class="settings-section-label">Selection Sensitivity: <span style="font-weight: 400; text-transform: none;"> </span></div> <div class="settings-hint" style="margin-bottom: 6px;">How long you must hold a selection before your AI notices it</div> <input data-testid="settings-modal-dwell-time-slider" type="range" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Selection dwell time"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span> </span> <span> </span></div></div> <label data-testid="settings-modal-selection-toolbar-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show floating selection toolbar</span></label> <label data-testid="settings-modal-margin-view-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Margin annotation view (Word-style)</span></label> <div data-testid="settings-modal-margin-view-hint" style="font-size: 10px; color: var(--tandem-fg-subtle);">Margin columns appear where rails are collapsed — open rails hide that side.</div> <!> <!> <button type="button" data-testid="settings-modal-open-integration-wizard" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: pointer; align-self: flex-start;"> </button> <!>`,1);function mB(t,e){nt(e,!0);function n(Z){switch(Z){case iB:return"Working directory must be a folder inside your home directory.";case rB:return"Working directory path is invalid.";case oB:return"Another working-directory update is in progress. Try again.";case aB:return"No Claude Code integration is configured.";case sB:return"Auto-launcher is not available in this Tandem build.";default:return"Couldn't save working directory."}}function r(){window.dispatchEvent(new CustomEvent("tandem:open-integration-wizard"))}let i=F(null),o=F(!1),s=F(null),a=F(!1),l=F(!1),c=F(null);const d=L(()=>u(a)&&!u(l)&&!u(c));let f=!0;Dn(()=>{f=!1});async function h(){var Z;try{const ge=await fetch(`${nn}/api/integrations`);if(!f)return;if(!ge.ok){b(c,`Failed to load integrations (HTTP ${ge.status}).`);return}const Ie=await ge.json();if(!f)return;const Se=(Z=Ie.integrations)==null?void 0:Z.find(fe=>fe.kind==="claude-code");Se&&(b(l,!0),b(i,Se.workingDirectory??null,!0))}catch(ge){if(!f)return;console.warn("[Settings] Failed to load workingDirectory:",ge),b(c,"Couldn't load Claude working directory.")}finally{f&&b(a,!0)}}h();async function p(Z){b(o,!0),b(s,null);try{const ge=await fetch(`${nn}${LO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDirectory:Z})});if(!f)return;if(!ge.ok){const Se=await ge.json().catch(()=>({}));if(!f)return;b(s,n(Se.code),!0);return}const Ie=await ge.json();if(!f)return;b(i,Ie.workingDirectory??null,!0),e.notify("info","Working directory saved.")}catch(ge){if(!f)return;console.warn("[Settings] Failed to save workingDirectory:",ge),b(s,"Couldn't save working directory.")}finally{f&&b(o,!1)}}async function m(){let Z;try{({open:Z}=await Zt(()=>import("./index-Dm_QtxGQ.js"),__vite__mapDeps([2,1])))}catch(ge){console.warn("[Settings] Folder picker import failed:",ge),e.notify("error","Folder picker plugin unavailable");return}try{const ge=await Z({directory:!0,multiple:!1,title:"Choose Claude working directory"});typeof ge=="string"&&p(ge)}catch(ge){console.warn("[Settings] Folder picker open() failed:",ge),e.notify("error","Folder picker permission denied or IPC error")}}function v(Z){Z.preventDefault();const ge=Z.target.elements.namedItem("wd"),Ie=ge==null?void 0:ge.value.trim();p(Ie||null)}function g(){p(null)}var y=pB(),C=Ae(y);{var _=Z=>{var ge=lB(),Ie=k(w(ge),4);P("click",Ie,r),x(Z,ge)};j(C,Z=>{u(d)&&Z(_)})}var S=k(C,4),A=w(S),O=k(w(A)),E=w(O),M=k(A,4);U(M,"step",100);var R=k(M,2),D=w(R),I=w(D),H=k(D,2),z=w(H),Q=k(S,2),ie=w(Q),me=k(Q,2),le=w(me),ke=k(me,4);{var ce=Z=>{var ge=cB(),Ie=w(ge);W(()=>G(Ie,u(c))),x(Z,ge)};j(ke,Z=>{u(a)&&!u(l)&&u(c)&&Z(ce)})}var ve=k(ke,2);{var De=Z=>{var ge=fB(),Ie=k(w(ge),4),Se=w(Ie);U(Se,"placeholder","(default: home)");var fe=k(Se,2),_e=k(Ie,2),X=w(_e);{var ye=ze=>{var Je=uB();W(()=>Je.disabled=u(o)),P("click",Je,m),x(ze,Je)},Y=L(()=>Tt());j(X,ze=>{u(Y)&&ze(ye)})}var se=k(X,2),Te=k(_e,2);{var Re=ze=>{var Je=dB(),ue=w(Je);W(()=>G(ue,u(s))),x(ze,Je)};j(Te,ze=>{u(s)&&ze(Re)})}W(()=>{Vr(Se,u(i)??""),Se.disabled=u(o),fe.disabled=u(o),se.disabled=u(o)||u(i)===null}),Qt("submit",Ie,v),P("click",se,g),x(Z,ge)};j(ve,Z=>{u(a)&&u(l)&&Z(De)})}var ee=k(ve,2),q=w(ee),V=k(ee,2);{var re=Z=>{var ge=St(),Ie=Ae(ge);NC(Ie,()=>Zt(()=>import("./CoworkSettings-vFVSs4Qc.js"),__vite__mapDeps([4,5])),Se=>{var fe=hB();x(Se,fe)},(Se,fe)=>{const _e=L(()=>u(fe).default);var X=St(),ye=Ae(X);s1(ye,()=>u(_e),(Y,se)=>{se(Y,{})}),x(Se,X)}),x(Z,ge)},te=L(()=>Tt());j(V,Z=>{u(te)&&Z(re)})}W((Z,ge,Ie)=>{G(E,`${Z??""}s`),U(M,"min",fc),U(M,"max",hc),Vr(M,e.settings.selectionDwellMs),G(I,`${ge??""}s`),G(z,`${Ie??""}s`),Fn(ie,e.settings.selectionToolbar),Fn(le,e.settings.marginView),G(q,u(d)?"Open integration wizard…":"Reopen integration wizard…")},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(fc/1e3).toFixed(1),()=>(hc/1e3).toFixed(1)]),P("input",M,Z=>e.onUpdate({selectionDwellMs:Number(Z.target.value)})),P("change",ie,Z=>e.onUpdate({selectionToolbar:Z.target.checked})),P("change",le,Z=>e.onUpdate({marginView:Z.target.checked})),P("click",ee,r),x(t,y),rt()}lt(["click","input","change"]);function $1(t){const e=t==null?void 0:t.trim();return e?e.slice(0,wm):JC}function ey(){try{return $1(localStorage.getItem(u1))}catch{return JC}}function gB(t){const e=$1(t);try{localStorage.setItem(u1,e)}catch{}return typeof window<"u"&&window.dispatchEvent(new Event(yv)),e}function uA(t){const e=()=>t(ey()),n=r=>{r.key===u1&&t($1(r.newValue))};return window.addEventListener(yv,e),window.addEventListener("storage",n),()=>{window.removeEventListener(yv,e),window.removeEventListener("storage",n)}}function ty(){let t=F(tt(ey()));const e=uA(r=>{b(t,r,!0)});return Dn(e),{get userName(){return u(t)},setUserName:r=>{const i=gB(r);b(t,i,!0)}}}var vB=T(`<div><label for="settings-modal-display-name" class="settings-section-label">Display Name</label> <input id="settings-modal-display-name" data-testid="settings-modal-display-name" type="text" style="width: 100%; padding: 8px 10px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); outline: none;"/></div> <div><div id="settings-modal-default-mode-label" class="settings-section-label">Default Mode</div> <div role="radiogroup" aria-labelledby="settings-modal-default-mode-label" class="settings-mode-btns"><button type="button" data-testid="settings-modal-default-mode-tandem-btn" role="radio" class="settings-mode-btn">Tandem</button> <button type="button" data-testid="settings-modal-default-mode-solo-btn" role="radio" class="settings-mode-btn">Solo</button></div> <div class="settings-hint" style="margin-top: var(--tandem-space-1);">Sets the preferred starting mode for new sessions.</div></div> <label data-testid="settings-modal-solo-rail-hidden-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Hide side panel in Solo mode</span></label> <div class="settings-hint" style="margin-top: var(--tandem-space-1);">When enabled, the annotation panel hides automatically when you enter Solo mode and
123
+ restores when you return to Tandem.</div>`,1);function bB(t,e){nt(e,!0);const n=ty();let r=F(tt(n.userName)),i=F(void 0);pe(()=>{const m=n.userName;u(r)!==m&&document.activeElement!==u(i)&&b(r,m,!0)});var o=vB(),s=Ae(o),a=k(w(s),2);Dt(a,m=>b(i,m),()=>u(i));var l=k(s,2),c=k(w(l),2),d=w(c),f=k(d,2),h=k(l,2),p=w(h);W(()=>{Vr(a,u(r)),U(a,"maxlength",wm),U(d,"aria-checked",e.settings.defaultMode==="tandem"),U(f,"aria-checked",e.settings.defaultMode==="solo"),Fn(p,e.settings.soloRailHidden)}),P("input",a,m=>{b(r,m.target.value,!0)}),Qt("blur",a,()=>n.setUserName(u(r))),P("keydown",a,m=>{m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(b(r,n.userName,!0),m.currentTarget.blur())}),P("click",d,()=>e.onUpdate({defaultMode:"tandem"})),P("click",f,()=>e.onUpdate({defaultMode:"solo"})),P("change",p,m=>e.onUpdate({soloRailHidden:m.target.checked})),x(t,o),rt()}lt(["input","keydown","click","change"]);const tb=m3({baseUrl:`http://127.0.0.1:${Gi}`,pathFor:Y8});function s0(){const t=new Uint8Array(16);crypto.getRandomValues(t);let e="";for(const n of t)e+=String.fromCharCode(n);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function yB(){return crypto.randomUUID()}function ux(t){if(t.provider!==void 0&&!vS.includes(t.provider))throw new Error(`Invalid model provider: ${String(t.provider)}`)}async function a0(t,e){const n=await tb.set(t,e);if(n.status==="ok")return;const r=n.status==="unavailable"?"KEYCHAIN_UNAVAILABLE":"STORE_FAILED";throw new Error(`Failed to store model key (${r})`)}function wB(t){return{get models(){return t.settings.models},get defaultModelId(){return t.settings.defaultModelId},get hasLegacyKeys(){return t.settings.models.some(e=>typeof e._legacyApiKey=="string")},async addModel(e,n){ux(e);const r=yB();let i;n&&n.length>0&&(i=s0(),await a0(i,n));const o={...e,id:r,...i?{apiKeyRef:i}:{}};return t.updateSettings({models:[...t.settings.models,o]}),r},async updateModel(e,n,r){ux(n);const i=t.settings.models.find(s=>s.id===e);if(!i)return;let o;r!==void 0&&r.length>0&&(o=s0(),await Promise.all([a0(o,r),i.apiKeyRef?tb.delete(i.apiKeyRef):Promise.resolve()])),t.updateSettings({models:t.settings.models.map(s=>s.id===e?{...s,...n,...o?{apiKeyRef:o}:{}}:s)})},async deleteModel(e){const n=t.settings.models.find(r=>r.id===e);n!=null&&n.apiKeyRef&&await tb.delete(n.apiKeyRef),t.updateSettings({models:t.settings.models.filter(r=>r.id!==e),defaultModelId:t.settings.defaultModelId===e?null:t.settings.defaultModelId})},toggleEnabled(e){t.updateSettings({models:t.settings.models.map(n=>n.id===e?{...n,enabled:!n.enabled}:n)})},setDefault(e){t.updateSettings({defaultModelId:e})},async migrateLegacyKeys(){const e=t.settings.models,n=e.map((l,c)=>typeof l._legacyApiKey=="string"?c:-1).filter(l=>l>=0);if(n.length===0)return{migrated:0,failed:0};const r=n.map(()=>s0()),i=await Promise.allSettled(n.map((l,c)=>a0(r[c],e[l]._legacyApiKey))),o=e.slice();let s=0,a=0;return i.forEach((l,c)=>{const d=n[c];if(l.status==="fulfilled"){const f={...e[d],apiKeyRef:r[c]};delete f._legacyApiKey,o[d]=f,s++}else a++}),s>0&&t.updateSettings({models:o}),{migrated:s,failed:a}}}}var kB=T("<option> </option>"),xB=T('<div class="mem-key-row svelte-1pwv6ag"><span class="mem-key-preview svelte-1pwv6ag" aria-label="Existing API key (masked)"> </span> <button type="button" class="mem-key-replace-btn svelte-1pwv6ag" data-testid="model-edit-apikey-replace-btn">Replace key</button></div>'),_B=T('<input data-testid="model-edit-apikey" class="mem-input mem-input--mono svelte-1pwv6ag" type="password" autocomplete="off"/>'),CB=T('<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">API key</span> <!></label>'),SB=T('<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Endpoint</span> <input data-testid="model-edit-endpoint" class="mem-input mem-input--mono svelte-1pwv6ag" type="text" autocomplete="off" placeholder="http://localhost:11434"/></label>'),EB=T('<p class="mem-advanced-help svelte-1pwv6ag">Per-model parameter overrides (temperature, max tokens, etc.) are not editable in\n this preview. The data model accepts a `params` map for forward-compat with\n Wave 6 surfaces.</p>'),AB=T('<div role="dialog" aria-modal="true" data-testid="model-edit-modal" class="mem-scrim svelte-1pwv6ag"><form class="mem-dialog svelte-1pwv6ag"><div class="mem-header svelte-1pwv6ag"><h3 class="mem-title svelte-1pwv6ag"> </h3> <button type="button" class="mem-close svelte-1pwv6ag" data-testid="model-edit-cancel" aria-label="Close">×</button></div> <label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Provider</span> <select data-testid="model-edit-provider" class="mem-input svelte-1pwv6ag"></select></label> <label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Display name</span> <input data-testid="model-edit-displayname" class="mem-input svelte-1pwv6ag" type="text" autocomplete="off" placeholder="My Anthropic key"/></label> <label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Model ID</span> <input data-testid="model-edit-modelid" class="mem-input mem-input--mono svelte-1pwv6ag" type="text" autocomplete="off" placeholder="e.g. claude-opus-4-7"/></label> <!> <!> <label class="mem-enabled-row svelte-1pwv6ag"><input type="checkbox" class="mem-enabled-cbx svelte-1pwv6ag"/> <span>Enabled</span></label> <!> <div class="mem-actions svelte-1pwv6ag"><button type="button" class="mem-btn mem-btn--ghost svelte-1pwv6ag">Cancel</button> <button type="submit" class="mem-btn mem-btn--primary svelte-1pwv6ag" data-testid="model-edit-save"> </button></div></form></div>');function TB(t,e){nt(e,!0);const n=[{value:"anthropic",label:"Anthropic"},{value:"openai",label:"OpenAI"},{value:"gemini",label:"Gemini"},{value:"local-ollama",label:"Ollama (local)"},{value:"local-llamacpp",label:"llama.cpp (local)"}],r=Ct(()=>e.entry);let i=F(tt((r==null?void 0:r.provider)??"anthropic")),o=F(tt((r==null?void 0:r.displayName)??"")),s=F(tt((r==null?void 0:r.modelId)??"")),a=F(tt((r==null?void 0:r.endpoint)??"")),l=F(tt((r==null?void 0:r.enabled)??!0)),c=F("");const d=r!==void 0&&!!r.apiKeyRef;let f=F(tt(r===void 0||!d));const h=r!==void 0,p=L(()=>u(i)==="anthropic"||u(i)==="openai"||u(i)==="gemini"),m=L(()=>u(i).startsWith("local-")),v=r!=null&&r.apiKeyRef?r.apiKeyRef.slice(-4):"",g=L(()=>u(o).trim().length>0&&u(s).trim().length>0&&(!u(p)||!u(f)||u(c).trim().length>0));function y(te){if(te.preventDefault(),!u(g))return;const Z={provider:u(i),displayName:u(o).trim(),modelId:u(s).trim(),enabled:u(l)};u(p)&&u(f)&&u(c).trim()&&(Z.plaintextApiKey=u(c).trim()),u(m)&&u(a).trim()&&(Z.endpoint=u(a).trim()),e.onSave(Z)}function C(){b(f,!0),b(c,"")}var _=AB();U(_,"tabindex",-1);var S=w(_),A=w(S),O=w(A),E=w(O),M=k(O,2),R=k(A,2),D=k(w(R),2);mt(D,21,()=>n,te=>te.value,(te,Z)=>{var ge=kB(),Ie=w(ge),Se={};W(()=>{G(Ie,u(Z).label),Se!==(Se=u(Z).value)&&(ge.value=(ge.__value=u(Z).value)??"")}),x(te,ge)});var I=k(R,2),H=k(w(I),2),z=k(I,2),Q=k(w(z),2),ie=k(z,2);{var me=te=>{var Z=CB(),ge=k(w(Z),2);{var Ie=fe=>{var _e=xB(),X=w(_e),ye=w(X),Y=k(X,2);W(()=>G(ye,`••••••••${v??""}`)),P("click",Y,C),x(fe,_e)},Se=fe=>{var _e=_B();W(()=>U(_e,"placeholder",h?"Enter new key":"Paste your API key")),Hr(_e,()=>u(c),X=>b(c,X)),x(fe,_e)};j(ge,fe=>{h&&(r!=null&&r.apiKeyRef)&&!u(f)?fe(Ie):fe(Se,-1)})}x(te,Z)};j(ie,te=>{u(p)&&te(me)})}var le=k(ie,2);{var ke=te=>{var Z=SB(),ge=k(w(Z),2);Hr(ge,()=>u(a),Ie=>b(a,Ie)),x(te,Z)};j(le,te=>{u(m)&&te(ke)})}var ce=k(le,2),ve=w(ce),De=k(ce,2);lA(De,{label:"Advanced parameters",testid:"model-edit-advanced",children:(te,Z)=>{var ge=EB();x(te,ge)},$$slots:{default:!0}});var ee=k(De,2),q=w(ee),V=k(q,2),re=w(V);W(()=>{U(_,"aria-label",h?"Edit model":"Add model"),G(E,h?"Edit model":"Add model"),V.disabled=!u(g),G(re,h?"Save changes":"Add model")}),P("click",_,te=>{te.target===te.currentTarget&&e.onCancel()}),P("keydown",_,te=>{te.key==="Escape"&&e.onCancel()}),Qt("submit",S,y),P("click",M,function(...te){var Z;(Z=e.onCancel)==null||Z.apply(this,te)}),aD(D,()=>u(i),te=>b(i,te)),Hr(H,()=>u(o),te=>b(o,te)),Hr(Q,()=>u(s),te=>b(s,te)),ph(ve,()=>u(l),te=>b(l,te)),P("click",q,function(...te){var Z;(Z=e.onCancel)==null||Z.apply(this,te)}),x(t,_),rt()}lt(["click","keydown"]);var MB=T('<span data-testid="models-legacy-migration-status"> </span>'),DB=T(`<div data-testid="models-legacy-migration-banner" role="note" style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-3); background: var(--tandem-warning-bg); color: var(--tandem-warning-fg-strong); font-size: 12px; line-height: 1.5; display: flex; flex-direction: column; gap: var(--tandem-space-2);"><div><strong style="font-weight: 600;">Move API keys to OS keychain.</strong> Existing keys were stored unencrypted in browser storage. Move them now to
124
+ encrypt them with your operating system's credential store.</div> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><button type="button" data-testid="models-legacy-migrate-btn"> </button> <!></div></div>`),OB=T('<div data-testid="models-empty-state" style="padding: var(--tandem-space-5) var(--tandem-space-3); text-align: center; border: 1px dashed var(--tandem-border-strong); border-radius: var(--tandem-r-3); color: var(--tandem-fg-muted); font-size: 13px;"><p style="margin: 0 0 var(--tandem-space-3) 0;">No models configured.</p> <button type="button" data-testid="model-add-btn" style="padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: pointer; background: var(--tandem-accent); color: var(--tandem-accent-fg);">Add your first model</button></div>'),IB=T('<button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); cursor: pointer;">Confirm</button> <button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button>',1),RB=T('<button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-error-fg); cursor: pointer;">Delete</button>'),NB=T('<div style="display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface);"><div style="flex: 1; min-width: 0;"><div style="font-size: 13px; color: var(--tandem-fg); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </div> <div style="font-size: 11px; color: var(--tandem-fg-subtle); font-family: var(--tandem-font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </div></div> <label style="display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tandem-fg-muted);" title="Use as the default model"><input type="radio" name="default-model" style="accent-color: var(--tandem-accent);"/> <span>Default</span></label> <label style="display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tandem-fg-muted);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span> </span></label> <button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer;">Edit</button> <!></div>'),PB=T('<div><div class="settings-section-label"> </div> <div style="display: flex; flex-direction: column; gap: 4px;"></div></div>'),LB=T('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"></div> <button type="button" data-testid="model-add-btn" style="align-self: flex-start; padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-accent-border); border-radius: var(--tandem-r-2); cursor: pointer; background: var(--tandem-surface); color: var(--tandem-accent);">+ Add model</button>',1),FB=T('<div role="alert" data-testid="models-save-error" style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-3); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); font-size: 12px;"> </div>'),zB=T('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"><!> <!></div> <!> <!>',1);function BB(t,e){nt(e,!0);const n=ai(),r=wB(n),i={anthropic:"Anthropic",openai:"OpenAI",gemini:"Gemini","local-ollama":"Ollama (local)","local-llamacpp":"llama.cpp (local)"},o=["anthropic","openai","gemini","local-ollama","local-llamacpp"],s=L(()=>{const z=new Map;for(const Q of o)z.set(Q,[]);for(const Q of r.models){const ie=z.get(Q.provider);ie&&ie.push(Q)}return z});let a=F(void 0),l=F(!1),c=F(null),d=F(null),f=F(!1),h=F(null);function p(){b(a,void 0),b(d,null),b(l,!0)}function m(z){b(a,z,!0),b(d,null),b(l,!0)}async function v(z){const{plaintextApiKey:Q,...ie}=z;try{u(a)?await r.updateModel(u(a).id,ie,Q):await r.addModel(ie,Q),b(l,!1),b(a,void 0),b(d,null)}catch(me){b(d,me instanceof Error?me.message:"Failed to save",!0)}}async function g(z){await r.deleteModel(z),b(c,null)}async function y(){b(f,!0),b(h,null);try{const z=await r.migrateLegacyKeys();z.failed>0?b(h,`Migrated ${z.migrated}; ${z.failed} failed. Retry?`):z.migrated>0&&b(h,`Migrated ${z.migrated} ${z.migrated===1?"key":"keys"} to OS keychain.`)}finally{b(f,!1)}}var C=zB(),_=Ae(C),S=w(_);{var A=z=>{var Q=DB(),ie=k(w(Q),2),me=w(ie),le=w(me),ke=k(me,2);{var ce=ve=>{var De=MB(),ee=w(De);W(()=>G(ee,u(h))),x(ve,De)};j(ke,ve=>{u(h)&&ve(ce)})}W(()=>{me.disabled=u(f),Pe(me,`padding: 4px var(--tandem-space-3); font-size: 12px; font-weight: 500; border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-warning-fg-strong); cursor: ${u(f)?"wait":"pointer"};`),G(le,u(f)?"Migrating…":"Migrate keys")}),P("click",me,y),x(z,Q)};j(S,z=>{r.hasLegacyKeys&&z(A)})}var O=k(S,2);{var E=z=>{var Q=OB(),ie=k(w(Q),2);P("click",ie,p),x(z,Q)},M=z=>{var Q=LB(),ie=Ae(Q);mt(ie,20,()=>o,le=>le,(le,ke)=>{const ce=L(()=>u(s).get(ke)??[]);var ve=St(),De=Ae(ve);{var ee=q=>{var V=PB(),re=w(V),te=w(re),Z=k(re,2);mt(Z,21,()=>u(ce),ge=>ge.id,(ge,Ie)=>{var Se=NB(),fe=w(Se),_e=w(fe),X=w(_e),ye=k(_e,2),Y=w(ye),se=k(fe,2),Te=w(se),Re=k(se,2),ze=w(Re),Je=k(ze,2),ue=w(Je),Ne=k(Re,2),qe=k(Ne,2);{var Xe=de=>{var xe=IB(),Le=Ae(xe),it=k(Le,2);W(()=>U(Le,"data-testid",`model-delete-confirm-${u(Ie).id}`)),P("click",Le,()=>g(u(Ie).id)),P("click",it,()=>b(c,null)),x(de,xe)},ae=de=>{var xe=RB();W(()=>U(xe,"data-testid",`model-delete-btn-${u(Ie).id}`)),P("click",xe,()=>b(c,u(Ie).id,!0)),x(de,xe)};j(qe,de=>{u(c)===u(Ie).id?de(Xe):de(ae,-1)})}W(()=>{U(Se,"data-testid",`model-row-${u(Ie).id}`),G(X,u(Ie).displayName),G(Y,u(Ie).modelId),U(Te,"data-testid",`model-default-${u(Ie).id}`),Fn(Te,r.defaultModelId===u(Ie).id),U(ze,"data-testid",`model-toggle-${u(Ie).id}`),Fn(ze,u(Ie).enabled),G(ue,u(Ie).enabled?"On":"Off"),U(Ne,"data-testid",`model-edit-btn-${u(Ie).id}`)}),P("change",Te,()=>r.setDefault(u(Ie).id)),P("change",ze,()=>r.toggleEnabled(u(Ie).id)),P("click",Ne,()=>m(u(Ie))),x(ge,Se)}),W(()=>G(te,i[ke])),x(q,V)};j(De,q=>{u(ce).length>0&&q(ee)})}x(le,ve)});var me=k(ie,2);P("click",me,p),x(z,Q)};j(O,z=>{r.models.length===0?z(E):z(M,-1)})}var R=k(_,2);{var D=z=>{var Q=FB(),ie=w(Q);W(()=>G(ie,u(d))),x(z,Q)};j(R,z=>{u(d)&&z(D)})}var I=k(R,2);{var H=z=>{TB(z,{get entry(){return u(a)},onCancel:()=>{b(l,!1),b(a,void 0),b(d,null)},onSave:v})};j(I,z=>{u(l)&&z(H)})}x(t,C),rt()}lt(["click","change"]);var HB=T('<div data-testid="store-readonly-banner" style="font-size: 11px; color: var(--tandem-warning-fg); margin-bottom: 8px;">Settings are read-only (a newer client wrote them). Shortcut changes are disabled.</div>'),VB=T('<span style="justify-self: start; font-size: 11px; color: var(--tandem-accent-fg-strong); font-style: italic;">Press keys… (Esc to cancel)</span>'),UB=T("<kbd> </kbd>"),jB=T('<button type="button">Reset</button>'),qB=T('<div style="grid-column: 1 / -1; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),WB=T('<div style="display: grid; grid-template-columns: 1fr max-content auto; gap: 10px; align-items: center; padding: 3px 0;"><span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span> <!> <div style="display: flex; gap: 6px; justify-self: end;"><button type="button"> </button> <!></div> <!></div>'),KB=T('<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),GB=T('<section><div class="settings-section-label"> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section>'),ZB=T('<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),YB=T('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-4);"><section><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;"><div class="settings-section-label">Customizable</div> <button type="button" data-testid="shortcuts-reset-all">Reset all</button></div> <!> <div style="display: flex; flex-direction: column; gap: 4px;"></div></section> <!> <section><div class="settings-section-label">Other (fixed)</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section></div>');function dA(t,e){nt(e,!0);let n=Ze(e,"notify",3,()=>{}),r=F(null),i=F(null);const o=L(()=>e.settings._readOnly===!0),s=L(()=>mS(e.settings.customShortcuts));pe(()=>{if(u(r)===null)return;const E=u(r),M=R=>{if(R.preventDefault(),R.stopPropagation(),R.key==="Escape"){b(r,null),b(i,null);return}const D=VO(R);if(!D)return;const I=YO(D,u(s),E);if(I){b(i,{id:E,message:`Already used by ${I}`},!0);return}b(r,null),b(i,null),e.onUpdate({customShortcuts:{...e.settings.customShortcuts,[E]:D}}),n()("info",`${Av[E]} set to ${Tv(D)}`)};return window.addEventListener("keydown",M,{capture:!0}),()=>window.removeEventListener("keydown",M,{capture:!0})});function a(E){u(o)||(b(i,null),b(r,E,!0))}function l(E){var D;if(u(o))return;const{[E]:M,...R}=e.settings.customShortcuts;e.onUpdate({customShortcuts:R}),u(r)===E&&b(r,null),((D=u(i))==null?void 0:D.id)===E&&b(i,null)}function c(){u(o)||(e.onUpdate({customShortcuts:{}}),b(r,null),b(i,null))}const d=L(()=>Ga.some(E=>u(s).has(E))),f=L(()=>{const E=Yh(),M=new Map;for(const R of E.values()){if(!R.shortcut||uS[R.id])continue;const D=M.get(R.group)??[];D.push({keys:R.shortcut,description:R.label}),M.set(R.group,D)}return CS.map(R=>({title:R.charAt(0).toUpperCase()+R.slice(1),rows:M.get(R)??[]})).filter(R=>R.rows.length>0)}),h="justify-self: start; padding: 1px 6px; font-family: var(--tandem-font-mono); font-size: 11px; color: var(--tandem-fg); background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom-width: 2px; border-radius: var(--tandem-r-2);";var p=YB(),m=w(p),v=w(m),g=k(w(v),2),y=k(v,2);{var C=E=>{var M=HB();x(E,M)};j(y,E=>{u(o)&&E(C)})}var _=k(y,2);mt(_,20,()=>Ga,E=>E,(E,M)=>{const R=L(()=>u(r)===M),D=L(()=>u(s).has(M)),I=L(()=>Tv(h1(M,u(s))));var H=WB(),z=w(H),Q=w(z),ie=k(z,2);{var me=re=>{var te=VB();W(()=>U(te,"data-testid",`shortcut-recording-${M}`)),x(re,te)},le=re=>{var te=UB();Pe(te,h);var Z=w(te);W(()=>G(Z,u(I))),x(re,te)};j(ie,re=>{u(R)?re(me):re(le,-1)})}var ke=k(ie,2),ce=w(ke),ve=w(ce),De=k(ce,2);{var ee=re=>{var te=jB();W(()=>{U(te,"data-testid",`shortcut-reset-${M}`),te.disabled=u(o),Pe(te,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: ${u(o)?"not-allowed":"pointer"}; opacity: ${u(o)?.5:1};`)}),P("click",te,()=>l(M)),x(re,te)};j(De,re=>{u(D)&&re(ee)})}var q=k(ke,2);{var V=re=>{var te=qB(),Z=w(te);W(()=>{U(te,"data-testid",`shortcut-conflict-${M}`),G(Z,u(i).message)}),x(re,te)};j(q,re=>{u(i)&&u(i).id===M&&re(V)})}W(()=>{U(H,"data-testid",`shortcut-row-${M}`),G(Q,Av[M]),U(ce,"data-testid",`shortcut-edit-${M}`),ce.disabled=u(o),Pe(ce,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: ${u(R)?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: var(--tandem-fg); cursor: ${u(o)?"not-allowed":"pointer"}; opacity: ${u(o)?.5:1};`),G(ve,u(R)?"Recording…":"Change")}),P("click",ce,()=>a(M)),x(E,H)});var S=k(m,2);mt(S,17,()=>u(f),E=>E.title,(E,M)=>{var R=GB(),D=w(R),I=w(D),H=k(D,2);mt(H,21,()=>u(M).rows,z=>z.keys+z.description,(z,Q)=>{var ie=KB(),me=Ae(ie);Pe(me,h);var le=w(me),ke=k(me,2),ce=w(ke);W(()=>{G(le,u(Q).keys),G(ce,u(Q).description)}),x(z,ie)}),W(()=>G(I,`${u(M).title??""} (fixed)`)),x(E,R)});var A=k(S,2),O=k(w(A),2);mt(O,21,()=>np,E=>E.keys+E.description,(E,M)=>{var R=ZB(),D=Ae(R);Pe(D,h);var I=w(D),H=k(D,2),z=w(H);W(()=>{G(I,u(M).keys),G(z,u(M).description)}),x(E,R)}),W(()=>{g.disabled=u(o)||!u(d),Pe(g,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: ${u(o)||!u(d)?"not-allowed":"pointer"}; opacity: ${u(o)||!u(d)?.5:1};`)}),P("click",g,c),x(t,p),rt()}lt(["click"]);var JB=T('<div data-testid="settings-modal-shortcuts-list"><!></div>');function XB(t,e){var n=JB(),r=w(n);dA(r,{get settings(){return e.settings},get onUpdate(){return e.onUpdate},get notify(){return e.notify}}),x(t,n)}let vp=null;function QB(){return typeof window<"u"&&"__TAURI_INTERNALS__"in window}function $B(t){return t.replace(/sk-ant-[A-Za-z0-9_-]{8,}/g,"sk-ant-[redacted]").replace(/sk-[A-Za-z0-9_-]{16,}/g,"sk-[redacted]").replace(/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,"Bearer [redacted]")}function eH(t){return t.replace(/(\/Users\/)[^/\\]+/g,"$1[user]").replace(/(\/home\/)[^/\\]+/g,"$1[user]").replace(/([A-Za-z]:\\Users\\)[^\\]+/g,"$1[user]")}function zf(t){return eH($B(t))}async function tH(){if(QB())try{const{invoke:t}=await Zt(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]);if(!await t("sentry_enabled").catch(()=>!1))return;const n=await Zt(()=>import("./index-RV3NNz1L.js"),__vite__mapDeps([6,7])),{defaultOptions:r}=await Zt(async()=>{const{defaultOptions:i}=await import("./index-B1hpCY-M.js");return{defaultOptions:i}},__vite__mapDeps([8,7]));n.init({...r,sendDefaultPii:!1,beforeSend:i=>{var o;i.message&&(i.message=zf(i.message));for(const s of((o=i.exception)==null?void 0:o.values)??[])s.value&&(s.value=zf(s.value));return i.request&&(i.request.data=void 0,i.request.url&&(i.request.url=zf(i.request.url))),i},beforeBreadcrumb:i=>(i.message&&(i.message=zf(i.message)),(i.category==="fetch"||i.category==="xhr")&&(i.data=void 0),i)}),vp=n,window.addEventListener("error",i=>{nb(i.error??i.message,{source:"window.onerror"})}),window.addEventListener("unhandledrejection",i=>{nb(i.reason,{source:"unhandledrejection"})}),console.info("[sentry] client crash reporting initialised")}catch(t){console.warn("[sentry] client init failed (non-fatal):",t)}}function nH(){return vp!==null}function nb(t,e){if(vp)try{vp.captureException(t,e?{extra:e}:void 0)}catch{}}const rH={pass:"[ok] ",warn:"[warn]",fail:"[fail]"};function l0(t){return t.replace(/[\x00-\x08\x0b-\x1f\x7f]/g,"")}function iH(t){const e=[`Tandem v${t.version} (${t.transport}${t.tauriSidecar?", desktop":""})`,`${t.platform}/${t.arch}, Node ${t.nodeVersion}`,""];for(const n of t.report.results)e.push(`${rH[n.status]} ${n.check} — ${l0(n.message)}`),n.status!=="pass"&&n.fix&&e.push(` fix: ${l0(n.fix)}`);return e.push("",l0(t.report.summary)),e.join(`
125
+ `)}var oH=T('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),sH=T('<button type="button" data-testid="settings-modal-open-log-folder-btn">Open Log Folder</button>'),aH=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),lH=T('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere; font-family: var(--tandem-font-mono);"> </dd>',1),cH=T('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 11px;"></dl>'),uH=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),dH=T('<div><button type="button" data-testid="settings-modal-view-documentation-btn"> </button> <!></div> <div style="display: flex; gap: var(--tandem-space-2);"><button type="button" data-testid="settings-modal-copy-diagnostics-btn"> </button> <!></div> <div data-testid="settings-modal-app-info-footer" style="border-top: 1px solid var(--tandem-border); padding-top: 10px;"><div class="settings-section-label">About</div> <!></div>',1);function fH(t,e){nt(e,!0);const n=Gm(()=>e.open);let r=F(!1),i=F(null),o=F(!1);async function s(){b(o,!0);let I;try{let H;try{H=await fetch(`${nn}${hO}`)}catch{e.notify("error","Couldn't reach the server — is it running?");return}if(!H.ok){e.notify("error","Diagnostics failed on the server — try `tandem doctor` in a terminal");return}I=iH(await H.json())}catch{e.notify("error","Diagnostics failed on the server — try `tandem doctor` in a terminal");return}finally{b(o,!1)}try{await navigator.clipboard.writeText(I),e.notify("info","Diagnostics copied to clipboard")}catch{e.notify("error","Couldn't access the clipboard — run `tandem doctor` in a terminal instead")}}async function a(){try{const[{appLogDir:I},H]=await Promise.all([Zt(()=>import("./path-DpyQXOHZ.js"),__vite__mapDeps([0,1])),hs()]),z=await I();await H("show_in_file_manager",{path:z})}catch{e.notify("error","Couldn't open the log folder")}}async function l(){var z;const I=(z=n.info)==null?void 0:z.workflowsPath;if(!I){b(i,"Documentation file not found.");return}b(r,!0),b(i,null);const H=await ms(I,{readOnly:!0,notFoundMessage:"Documentation file not found.",failureMessage:"Failed to open documentation."});b(r,!1),H.ok||b(i,H.error,!0)}const c=L(()=>{var z;const I=n.info;if(!I)return[];const H=[{label:"Version",value:`Tandem v${I.version}`},{label:"Tools",value:I.toolCount===null?"Tool count unavailable":`${I.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${I.mcpSdkVersion}`},{label:"Transport",value:((z=I.transport)==null?void 0:z.toUpperCase())??"—"}];return I.storagePath&&H.push({label:"Storage",value:I.storagePath}),I.tokenRotatedAt!==void 0&&H.push({label:"Token",value:I.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(I.tokenRotatedAt).toLocaleString()}`}),I.changelogPath&&H.push({label:"Changelog",value:I.changelogPath}),H.push({label:"Crash reports",value:nH()?"On (TANDEM_SENTRY_DSN set)":"Off — opt in with TANDEM_SENTRY_DSN"}),H});var d=dH(),f=Ae(d),h=w(f),p=w(h),m=k(h,2);{var v=I=>{var H=oH(),z=w(H);W(()=>G(z,u(i))),x(I,H)};j(m,I=>{u(i)&&I(v)})}var g=k(f,2),y=w(g),C=w(y),_=k(y,2);{var S=I=>{var H=sH();Pe(H,"flex: 1; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: pointer;"),P("click",H,()=>void a()),x(I,H)},A=L(()=>Tt());j(_,I=>{u(A)&&I(S)})}var O=k(g,2),E=k(w(O),2);{var M=I=>{var H=aH();x(I,H)},R=I=>{var H=cH();mt(H,21,()=>u(c),z=>z.label,(z,Q)=>{var ie=lH(),me=Ae(ie),le=w(me),ke=k(me,2),ce=w(ke);W(()=>{G(le,u(Q).label),G(ce,u(Q).value)}),x(z,ie)}),x(I,H)},D=I=>{var H=uH();x(I,H)};j(E,I=>{n.loading?I(M):n.info?I(R,1):I(D,-1)})}W(()=>{h.disabled=u(r)||n.loading,Pe(h,`width: 100%; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: ${u(r)||n.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${u(r)||n.loading?.6:1};`),G(p,u(r)?"Opening…":"View Documentation"),y.disabled=u(o),Pe(y,`flex: 1; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: ${u(o)?"not-allowed":"pointer"}; opacity: ${u(o)?.6:1};`),G(C,u(o)?"Collecting…":"Copy Diagnostics")}),P("click",h,()=>void l()),P("click",y,()=>void s()),x(t,d),rt()}lt(["click"]);const fA={models:"models"};var hH=T('<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>'),pH=T('<button type="button" class="settings-modal-nav-btn svelte-bbu5nk"><svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path></path></svg> <span> </span></button>'),mH=T('<div role="alert" data-testid="settings-modal-changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),gH=T('<div role="button" tabindex="-1" aria-label="Close settings" data-testid="settings-modal-scrim" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); z-index: var(--tandem-z-above-titlebar);"></div> <div data-testid="settings-modal" role="dialog" aria-modal="true" class="settings-modal svelte-bbu5nk"><aside class="settings-modal-sidebar tandem-scroll-fade-y svelte-bbu5nk"><div class="settings-modal-sidebar-head svelte-bbu5nk"><div class="settings-modal-sidebar-title svelte-bbu5nk">Settings</div> <!></div> <nav aria-label="Settings sections" class="settings-modal-sidebar-nav svelte-bbu5nk"></nav> <div class="settings-modal-sidebar-foot svelte-bbu5nk" data-testid="settings-modal-sidebar-footer"><button type="button" data-testid="settings-modal-view-changelog-btn" class="settings-modal-sidebar-link svelte-bbu5nk"> </button> <!> <a target="_blank" rel="noreferrer" data-testid="settings-modal-report-bug-link" class="settings-modal-sidebar-link svelte-bbu5nk">Report a bug</a> <div class="settings-modal-sidebar-status svelte-bbu5nk" data-testid="settings-modal-mcp-status" aria-live="polite"><span class="settings-modal-status-dot svelte-bbu5nk"></span> <span class="settings-modal-status-label svelte-bbu5nk"><!></span></div></div></aside> <section class="settings-modal-content svelte-bbu5nk" data-testid="settings-modal-content"><header class="settings-modal-content-head svelte-bbu5nk"><button type="button" class="settings-modal-narrow-hamburger svelte-bbu5nk" data-testid="settings-modal-narrow-hamburger"><svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="4" y1="7" x2="20" y2="7"></line><line x1="4" y1="12" x2="20" y2="12"></line><line x1="4" y1="17" x2="20" y2="17"></line></svg></button> <h2 class="settings-modal-content-title svelte-bbu5nk"> </h2> <button type="button" data-testid="settings-modal-close-btn" class="settings-modal-close svelte-bbu5nk" aria-label="Close settings">×</button></header> <div class="settings-modal-content-body tandem-scroll-fade-y svelte-bbu5nk"><div class="settings-modal-content-inner svelte-bbu5nk"><!></div></div></section></div>',1);function vH(t,e){nt(e,!0);const n="tandem-settings-modal-heading",r='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',i=[{id:"appearance",label:"Appearance",icon:"M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z",component:sA},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16",component:aA},{id:"network",label:"Network",icon:"M3 12h18M3 12a9 9 0 0 1 18 0M3 12a9 9 0 0 0 18 0M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18",component:cA},{id:"accessibility",label:"Accessibility",icon:"M12 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4ZM4 9h16M9 9v5l-2 7M15 9v5l2 7M9 14h6",component:oA},{id:"collaboration",label:"Collaboration",icon:"M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM21 21v-2a4 4 0 0 0-3-3.87M16 3.13A4 4 0 0 1 16 11",component:bB},{id:"claude-code",label:"AI Assistant",icon:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z",component:mB},{id:"models",label:"Models",icon:"M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z",component:BB},{id:"shortcuts",label:"Shortcuts",icon:"M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z",component:XB},{id:"about",label:"About",icon:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01",component:fH}].filter(z=>z.id!==fA.models||kD);let o=Ze(e,"returnFocusEl",3,null),s=Ze(e,"triggerEl",3,null),a=Ze(e,"connected",3,!1),l=Ze(e,"reconnectAttempts",3,0),c=Ze(e,"tabs",3,i),d=Ze(e,"initialTabId",3,null),f=Ze(e,"notify",3,()=>{}),h=F(void 0);const p=Gm(()=>e.open);let m=F(!1),v=F(null),g=F(!1);pe(()=>{e.open&&b(g,!1)});let y=!1;pe(()=>{if(e.open&&!y&&d()){const z=u(_).find(Q=>Q.id===d());z&&b(S,z.id,!0)}y=e.open});let C=F(!1);pe(()=>{if(typeof window>"u"||!window.matchMedia)return;const z=window.matchMedia("(max-width: 860px)");b(C,z.matches,!0);const Q=ie=>{b(C,ie.matches,!0)};return z.addEventListener("change",Q),()=>z.removeEventListener("change",Q)});const _=L(()=>c().length>0?c():i);let S=F(tt(i[0].id));const A=L(()=>u(_).find(z=>z.id===u(S))??u(_)[0]),O=L(()=>u(A).label),E=L(()=>({open:e.open,settings:e.settings,onUpdate:e.onUpdate,connected:a(),reconnectAttempts:l(),notify:f()}));pe(()=>{u(A)&&u(A).id!==u(S)&&b(S,u(A).id,!0)}),pe(()=>{if(e.open)return Ct(()=>{var z;return(z=u(h))==null?void 0:z.focus()}),()=>{var z;(z=o())==null||z.focus()}}),pe(()=>{if(!e.open)return;const z=ie=>{var le;const me=ie.target;me&&((le=s())!=null&&le.contains(me)||u(h)&&!u(h).contains(me)&&e.onClose())},Q=setTimeout(()=>document.addEventListener("pointerdown",z),0);return()=>{clearTimeout(Q),document.removeEventListener("pointerdown",z)}}),zc(()=>{const z=Q=>{if(Q.key!=="Escape"||!e.open)return;const ie=Q.target;if(!(!u(h)||!ie||!u(h).contains(ie))){if(Q.stopPropagation(),u(C)&&u(g)){b(g,!1);return}e.onClose()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)}),pe(()=>{if(!e.open)return;const z=Q=>{if(Q.key!=="Tab"||!u(h))return;const ie=u(h).querySelectorAll(r);if(ie.length===0)return;const me=ie[0],le=ie[ie.length-1],ke=document.activeElement;if(!u(h).contains(ke)){Q.preventDefault(),me.focus();return}Q.shiftKey&&ke===me?(Q.preventDefault(),le.focus()):!Q.shiftKey&&ke===le&&(Q.preventDefault(),me.focus())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)}),pe(()=>{u(S),b(v,null)});async function M(){var ie;const z=(ie=p.info)==null?void 0:ie.changelogPath;if(!z){b(v,"Changelog file not found.");return}b(m,!0),b(v,null);const Q=await ms(z,{readOnly:!0,notFoundMessage:"Changelog file not found.",failureMessage:"Failed to open changelog."});b(m,!1),Q.ok?e.onClose():b(v,Q.error,!0)}var R={DEFAULT_SETTINGS_TABS:i},D=St(),I=Ae(D);{var H=z=>{var Q=gH(),ie=Ae(Q),me=k(ie,2);U(me,"aria-labelledby",n),U(me,"tabindex",-1);var le=w(me),ke=w(le),ce=w(ke);U(ce,"id",n);var ve=k(ce,2);{var De=ae=>{var de=hH(),xe=w(de);W(()=>G(xe,`v${p.info.version??""}`)),x(ae,de)};j(ve,ae=>{p.info&&ae(De)})}var ee=k(ke,2);mt(ee,21,()=>u(_),ae=>ae.id,(ae,de)=>{var xe=pH(),Le=w(xe),it=w(Le),ne=k(Le,2),Ee=w(ne);W(()=>{U(xe,"aria-current",u(S)===u(de).id?"page":void 0),U(xe,"data-active",u(S)===u(de).id?"true":"false"),U(xe,"data-testid",`settings-modal-tab-${u(de).id}`),U(it,"d",u(de).icon),G(Ee,u(de).label)}),P("click",xe,()=>{b(S,u(de).id,!0),b(g,!1)}),x(ae,xe)});var q=k(ee,2),V=w(q),re=w(V),te=k(V,2);{var Z=ae=>{var de=mH(),xe=w(de);W(()=>G(xe,u(v))),x(ae,de)};j(te,ae=>{u(v)&&ae(Z)})}var ge=k(te,2),Ie=k(ge,2),Se=w(Ie),fe=k(Se,2),_e=w(fe);{var X=ae=>{var de=fr("MCP connected");x(ae,de)},ye=ae=>{var de=fr("Reconnecting…");x(ae,de)},Y=ae=>{var de=fr("MCP offline");x(ae,de)};j(_e,ae=>{a()?ae(X):l()>0?ae(ye,1):ae(Y,-1)})}qr(le,(ae,de)=>$t==null?void 0:$t(ae,de),()=>"y");var se=k(le,2),Te=w(se),Re=w(Te),ze=k(Re,2),Je=w(ze),ue=k(ze,2),Ne=k(Te,2),qe=w(Ne),Xe=w(qe);Bl(Xe,()=>u(A).id,ae=>{var de=St(),xe=Ae(de);s1(xe,()=>u(A).component,(Le,it)=>{it(Le,mu(()=>u(E)))}),x(ae,de)}),qr(Ne,(ae,de)=>$t==null?void 0:$t(ae,de),()=>"y"),Dt(me,ae=>b(h,ae),()=>u(h)),W(()=>{U(me,"data-narrow-sidebar-open",u(g)?"true":"false"),le.inert=u(C)&&!u(g),V.disabled=u(m)||p.loading,G(re,u(m)?"Opening…":"Changelog"),U(ge,"href",HC),U(Se,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),U(Re,"aria-label",u(g)?"Hide sections":"Show sections"),U(Re,"aria-expanded",u(g)),G(Je,u(O))}),P("click",ie,function(...ae){var de;(de=e.onClose)==null||de.apply(this,ae)}),P("keydown",ie,ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),e.onClose())}),P("click",V,()=>void M()),P("click",Re,()=>{b(g,!u(g))}),P("click",ue,function(...ae){var de;(de=e.onClose)==null||de.apply(this,ae)}),x(z,Q)};j(I,z=>{e.open&&z(H)})}return x(t,D),rt(R)}lt(["click","keydown"]);var bH=T('<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>'),yH=T('<button type="button" class="settings-nav-btn svelte-fsutp8"><svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path></path></svg> <span> </span></button>'),wH=T('<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),kH=T(`<div><label for="settings-display-name">Display Name</label> <input id="settings-display-name" data-testid="settings-display-name" type="text" style="width: 100%; padding: 8px 10px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); outline: none;"/></div> <div><div id="settings-default-mode-label">Default Mode</div> <div role="radiogroup" aria-labelledby="settings-default-mode-label" style="display: flex; gap: var(--tandem-space-2);"><button type="button" data-testid="default-mode-tandem-btn" role="radio">Tandem</button> <button type="button" data-testid="default-mode-solo-btn" role="radio">Solo</button></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Sets the preferred starting mode for new sessions.</div></div> <label data-testid="solo-rail-hidden-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Hide side panel in Solo mode</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">When enabled, the annotation panel hides automatically when you enter Solo mode and
126
+ restores when you return to Tandem.</div>`,1),xH=T('<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),_H=T('<div><div>Selection Sensitivity: <span style="font-weight: 400; text-transform: none;"> </span></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 6px;">How long you must hold a selection before your AI notices it</div> <input data-testid="dwell-time-slider" type="range" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Selection dwell time"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span> </span> <span> </span></div></div> <label data-testid="selection-toolbar-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show floating selection toolbar</span></label> <label data-testid="margin-view-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Margin annotation view (Word-style)</span></label> <div data-testid="margin-view-hint" style="font-size: 10px; color: var(--tandem-fg-subtle);">Margin columns appear where rails are collapsed — open rails hide that side.</div> <!>',1),CH=T('<div data-testid="settings-shortcuts-list"><!></div>'),SH=T('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),EH=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),AH=T('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),TH=T('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),MH=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),DH=T('<div><button data-testid="view-documentation-btn"> </button> <!></div> <div data-testid="app-info-footer" style="border-top: 1px solid var(--tandem-border); padding-top: 10px;"><div>About</div> <!></div>',1),OH=T('<div aria-hidden="true" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); z-index: var(--tandem-z-above-titlebar);"></div> <div data-testid="settings-popover" role="dialog" aria-modal="true" class="settings-dialog svelte-fsutp8"><aside class="settings-sidebar svelte-fsutp8"><div class="settings-sidebar-head svelte-fsutp8"><div class="settings-sidebar-title svelte-fsutp8">Settings</div> <!></div> <nav aria-label="Settings sections" class="settings-sidebar-nav svelte-fsutp8"></nav> <div class="settings-sidebar-foot svelte-fsutp8" data-testid="settings-sidebar-footer"><button type="button" data-testid="view-changelog-btn" class="settings-sidebar-link svelte-fsutp8"> </button> <!> <a target="_blank" rel="noreferrer" data-testid="report-bug-link" class="settings-sidebar-link svelte-fsutp8">Report a bug</a> <div class="settings-sidebar-status svelte-fsutp8" data-testid="settings-mcp-status" aria-live="polite"><span class="settings-status-dot svelte-fsutp8"></span> <span class="settings-status-label svelte-fsutp8"><!></span></div></div></aside> <section class="settings-content svelte-fsutp8" data-testid="settings-content"><header style="display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 var(--tandem-space-5); border-bottom: 1px solid var(--tandem-border); background: var(--tandem-surface);"><h2 style="font-size: 16px; font-weight: 700; color: var(--tandem-fg); margin: 0;"> </h2> <button class="settings-close-btn svelte-fsutp8" aria-label="Close settings">×</button></header> <div style="flex: 1; overflow-y: auto; padding: var(--tandem-space-5);"><div style="display: flex; flex-direction: column; gap: var(--tandem-space-5); max-width: 620px;"><!></div></div></section></div>',1);function IH(t,e){nt(e,!0);const n="tandem-settings-heading",r='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',i=[{id:"appearance",label:"Appearance",icon:"M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z"},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16"},{id:"network",label:"Network",icon:"M3 12h18M3 12a9 9 0 0 1 18 0M3 12a9 9 0 0 0 18 0M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"},{id:"accessibility",label:"Accessibility",icon:"M12 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4ZM4 9h16M9 9v5l-2 7M15 9v5l2 7M9 14h6"},{id:"collaboration",label:"Collaboration",icon:"M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM21 21v-2a4 4 0 0 0-3-3.87M16 3.13A4 4 0 0 1 16 11"},{id:"claude-code",label:"AI Assistant",icon:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z"},{id:"shortcuts",label:"Shortcuts",icon:"M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z"},{id:"about",label:"About",icon:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01"}];let o=Ze(e,"connected",3,!1),s=Ze(e,"reconnectAttempts",3,0),a=F(void 0),l=F(void 0);const c=ty();let d=F(tt(c.userName));const f=Gm(()=>e.open);let h=F(!1),p=F(null),m=F(!1),v=F(null),g=F("appearance");pe(()=>{u(g),b(p,null),b(v,null)}),pe(()=>{const I=c.userName;u(d)!==I&&document.activeElement!==u(l)&&b(d,I,!0)}),pe(()=>{var I;if(e.open)return(I=u(a))==null||I.focus(),()=>{var H;(H=e.returnFocusEl)==null||H.focus()}}),pe(()=>{if(!e.open)return;const I=z=>{var ie;const Q=z.target;(ie=e.anchorEl)!=null&&ie.contains(Q)||u(a)&&!u(a).contains(Q)&&e.onClose()},H=setTimeout(()=>document.addEventListener("pointerdown",I),0);return()=>{clearTimeout(H),document.removeEventListener("pointerdown",I)}}),pe(()=>{if(!e.open)return;const I=H=>{if(H.key==="Escape"){H.preventDefault(),H.stopPropagation(),e.onClose();return}if(H.key!=="Tab"||!u(a))return;const z=u(a).querySelectorAll(r);if(z.length===0)return;const Q=z[0],ie=z[z.length-1],me=document.activeElement;if(!u(a).contains(me)){H.preventDefault(),Q.focus();return}H.shiftKey&&me===Q?(H.preventDefault(),ie.focus()):!H.shiftKey&&me===ie&&(H.preventDefault(),Q.focus())};return window.addEventListener("keydown",I,{capture:!0}),()=>window.removeEventListener("keydown",I,{capture:!0})});async function y(I,H,z,Q){if(!I){z(Q.notFound);return}H(!0),z(null);try{const ie=await ms(I,{readOnly:!0,notFoundMessage:Q.notFound,failureMessage:Q.failed});if(!ie.ok){z(ie.error);return}e.onClose()}finally{H(!1)}}function C(){var I;return y((I=f.info)==null?void 0:I.workflowsPath,H=>b(m,H,!0),H=>b(v,H,!0),{notFound:"Documentation file not found.",failed:"Failed to open documentation."})}function _(){var I;return y((I=f.info)==null?void 0:I.changelogPath,H=>b(h,H,!0),H=>b(p,H,!0),{notFound:"Changelog file not found.",failed:"Failed to open changelog."})}const S="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",A=()=>{};function O(I){var H;return((H=i.find(z=>z.id===I))==null?void 0:H.label)??"Settings"}function E(){var z;const I=f.info;if(!I)return[];const H=[{label:"Version",value:`Tandem v${I.version}`},{label:"Tools",value:I.toolCount===null?"Tool count unavailable":`${I.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${I.mcpSdkVersion}`},{label:"Transport",value:((z=I.transport)==null?void 0:z.toUpperCase())??"—"}];return I.storagePath&&H.push({label:"Storage",value:I.storagePath}),I.tokenRotatedAt!==void 0&&H.push({label:"Token",value:I.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(I.tokenRotatedAt).toLocaleString()}`}),I.changelogPath&&H.push({label:"Changelog",value:I.changelogPath}),H}var M=St(),R=Ae(M);{var D=I=>{var H=OH(),z=Ae(H),Q=k(z,2);U(Q,"aria-labelledby",n),U(Q,"tabindex",-1);var ie=w(Q),me=w(ie),le=w(me);U(le,"id",n);var ke=k(le,2);{var ce=ne=>{var Ee=bH(),B=w(Ee);W(()=>G(B,`v${f.info.version??""}`)),x(ne,Ee)};j(ke,ne=>{f.info&&ne(ce)})}var ve=k(me,2);mt(ve,21,()=>i,ne=>ne.id,(ne,Ee)=>{var B=yH(),$=w(B),we=w($),He=k($,2),Oe=w(He);W(()=>{U(B,"aria-current",u(g)===u(Ee).id?"page":void 0),U(B,"data-active",u(g)===u(Ee).id?"true":"false"),U(we,"d",u(Ee).icon),G(Oe,u(Ee).label)}),P("click",B,()=>b(g,u(Ee).id,!0)),x(ne,B)});var De=k(ve,2),ee=w(De),q=w(ee),V=k(ee,2);{var re=ne=>{var Ee=wH(),B=w(Ee);W(()=>G(B,u(p))),x(ne,Ee)};j(V,ne=>{u(p)&&ne(re)})}var te=k(V,2),Z=k(te,2),ge=w(Z),Ie=k(ge,2),Se=w(Ie);{var fe=ne=>{var Ee=fr("MCP connected");x(ne,Ee)},_e=ne=>{var Ee=fr("Reconnecting…");x(ne,Ee)},X=ne=>{var Ee=fr("MCP offline");x(ne,Ee)};j(Se,ne=>{o()?ne(fe):s()>0?ne(_e,1):ne(X,-1)})}var ye=k(ie,2),Y=w(ye),se=w(Y),Te=w(se),Re=k(se,2),ze=k(Y,2),Je=w(ze),ue=w(Je);{var Ne=ne=>{var Ee=kH(),B=Ae(Ee),$=w(B);Pe($,S);var we=k($,2);Dt(we,je=>b(l,je),()=>u(l));var He=k(B,2),Oe=w(He);Pe(Oe,S);var K=k(Oe,2),he=w(K),Me=k(he,2),Fe=k(He,2),We=w(Fe);W(()=>{Vr(we,u(d)),U(we,"maxlength",wm),U(he,"aria-checked",e.settings.defaultMode==="tandem"),Pe(he,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="tandem"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="tandem"?600:400}; cursor: pointer;`),U(Me,"aria-checked",e.settings.defaultMode==="solo"),Pe(Me,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="solo"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="solo"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="solo"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="solo"?600:400}; cursor: pointer;`),Fn(We,e.settings.soloRailHidden)}),P("input",we,je=>{b(d,je.target.value,!0)}),Qt("blur",we,()=>c.setUserName(u(d))),P("keydown",we,je=>{je.key==="Enter"&&je.currentTarget.blur(),je.key==="Escape"&&(b(d,c.userName,!0),je.currentTarget.blur())}),P("click",he,()=>e.onUpdate({defaultMode:"tandem"})),P("click",Me,()=>e.onUpdate({defaultMode:"solo"})),P("change",We,je=>e.onUpdate({soloRailHidden:je.target.checked})),x(ne,Ee)},qe=ne=>{sA(ne,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:A})},Xe=ne=>{aA(ne,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:A})},ae=ne=>{cA(ne,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:A})},de=ne=>{oA(ne,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return o()},get reconnectAttempts(){return s()},notify:A})},xe=ne=>{var Ee=_H(),B=Ae(Ee),$=w(B);Pe($,S);var we=k(w($)),He=w(we),Oe=k($,4);U(Oe,"step",100);var K=k(Oe,2),he=w(K),Me=w(he),Fe=k(he,2),We=w(Fe),je=k(B,2),Ve=w(je),$e=k(je,2),ct=w($e),dt=k($e,4);{var qt=Ot=>{var Ft=St(),En=Ae(Ft);NC(En,()=>Zt(()=>import("./CoworkSettings-vFVSs4Qc.js"),__vite__mapDeps([4,5])),Hn=>{var An=xH();x(Hn,An)},(Hn,An)=>{const zt=L(()=>u(An).default);var mn=St(),Vn=Ae(mn);s1(Vn,()=>u(zt),(Li,Mn)=>{Mn(Li,{})}),x(Hn,mn)}),x(Ot,Ft)},Nt=L(()=>Tt());j(dt,Ot=>{u(Nt)&&Ot(qt)})}W((Ot,Ft,En)=>{G(He,`${Ot??""}s`),U(Oe,"min",fc),U(Oe,"max",hc),Vr(Oe,e.settings.selectionDwellMs),G(Me,`${Ft??""}s`),G(We,`${En??""}s`),Fn(Ve,e.settings.selectionToolbar),Fn(ct,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(fc/1e3).toFixed(1),()=>(hc/1e3).toFixed(1)]),P("input",Oe,Ot=>e.onUpdate({selectionDwellMs:Number(Ot.target.value)})),P("change",Ve,Ot=>e.onUpdate({selectionToolbar:Ot.target.checked})),P("change",ct,Ot=>e.onUpdate({marginView:Ot.target.checked})),x(ne,Ee)},Le=ne=>{var Ee=CH(),B=w(Ee);dA(B,{get settings(){return e.settings},get onUpdate(){return e.onUpdate},notify:A}),x(ne,Ee)},it=ne=>{var Ee=DH(),B=Ae(Ee),$=w(B),we=w($),He=k($,2);{var Oe=Ve=>{var $e=SH(),ct=w($e);W(()=>G(ct,u(v))),x(Ve,$e)};j(He,Ve=>{u(v)&&Ve(Oe)})}var K=k(B,2),he=w(K);Pe(he,S);var Me=k(he,2);{var Fe=Ve=>{var $e=EH();x(Ve,$e)},We=Ve=>{var $e=TH();mt($e,21,E,ct=>ct.label,(ct,dt)=>{var qt=AH(),Nt=Ae(qt),Ot=w(Nt),Ft=k(Nt,2),En=w(Ft);W(()=>{G(Ot,u(dt).label),G(En,u(dt).value)}),x(ct,qt)}),x(Ve,$e)},je=Ve=>{var $e=MH();x(Ve,$e)};j(Me,Ve=>{f.loading?Ve(Fe):f.info?Ve(We,1):Ve(je,-1)})}W(()=>{$.disabled=u(m)||f.loading,Pe($,`width: 100%; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: ${u(m)||f.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${u(m)||f.loading?.6:1};`),G(we,u(m)?"Opening…":"View Documentation")}),P("click",$,()=>void C()),x(ne,Ee)};j(ue,ne=>{u(g)==="collaboration"?ne(Ne):u(g)==="appearance"?ne(qe,1):u(g)==="editor"?ne(Xe,2):u(g)==="network"?ne(ae,3):u(g)==="accessibility"?ne(de,4):u(g)==="claude-code"?ne(xe,5):u(g)==="shortcuts"?ne(Le,6):ne(it,-1)})}Dt(Q,ne=>b(a,ne),()=>u(a)),W(ne=>{ee.disabled=u(h)||f.loading,G(q,u(h)?"Opening…":"Changelog"),U(te,"href",HC),U(ge,"data-state",o()?"connected":s()>0?"reconnecting":"disconnected"),G(Te,ne)},[()=>O(u(g))]),P("click",z,function(...ne){var Ee;(Ee=e.onClose)==null||Ee.apply(this,ne)}),P("click",ee,()=>void _()),P("click",Re,function(...ne){var Ee;(Ee=e.onClose)==null||Ee.apply(this,ne)}),x(I,H)};j(R,I=>{e.open&&I(D)})}x(t,M),rt()}lt(["click","input","keydown","change"]);var RH=an("<path></path>"),NH=T('<span class="badge svelte-nsu1aw"> </span>'),PH=T('<button type="button" class="action svelte-nsu1aw"> </button>'),LH=T('<div><span class="glyph svelte-nsu1aw"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg></span> <div class="body svelte-nsu1aw"><span class="msg svelte-nsu1aw"> </span> <!> <!></div> <button type="button" class="dismiss svelte-nsu1aw" aria-label="Dismiss notification"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"></path><path d="M6 18L18 6"></path></svg></button></div>'),FH=T('<div data-testid="toast-container" class="toast-stack svelte-nsu1aw"></div>');function zH(t,e){nt(e,!0);var n=St(),r=Ae(n);{var i=o=>{var s=FH();mt(s,21,()=>e.toasts,a=>a.id,(a,l)=>{var c=LH(),d=w(c),f=w(d);mt(f,20,()=>DS[u(l).severity],S=>S,(S,A)=>{var O=RH();W(()=>U(O,"d",A)),x(S,O)});var h=k(d,2),p=w(h),m=w(p),v=k(p,2);{var g=S=>{var A=NH(),O=w(A);W(()=>{U(A,"data-testid",`toast-count-${u(l).id}`),G(O,`×${u(l).count??""}`)}),x(S,A)};j(v,S=>{u(l).count>1&&S(g)})}var y=k(v,2);{var C=S=>{var A=PH(),O=w(A);W(()=>{U(A,"data-testid",`toast-action-${u(l).id}`),G(O,u(l).action.label)}),P("click",A,()=>{var E;(E=u(l).action)==null||E.onClick(),e.onDismiss(u(l).id)}),x(S,A)};j(y,S=>{u(l).action&&S(C)})}var _=k(h,2);W(()=>{U(c,"role",u(l).severity==="info"?"status":"alert"),U(c,"data-testid",`toast-${u(l).id}`),bt(c,1,`toast-card ${u(l).severity??""}`,"svelte-nsu1aw"),G(m,u(l).message),U(_,"data-testid",`toast-dismiss-${u(l).id}`)}),P("click",_,()=>e.onDismiss(u(l).id)),x(a,c)}),x(o,s)};j(r,o=>{e.toasts.length>0&&o(i)})}x(t,n),rt()}lt(["click"]);var BH=T('<div class="tandem-banner tandem-banner--info" role="status" aria-live="polite" data-testid="updater-banner"><span class="tandem-banner__icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25"></path><path d="M12 12v8"></path><path d="M8 16l4 4 4-4"></path></svg></span> <span class="tandem-banner__message"> </span> <button type="button" class="tandem-banner__cta" data-testid="updater-banner-install"> </button> <button type="button" class="tandem-banner__dismiss" data-testid="updater-banner-dismiss" aria-label="Dismiss update notification"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>');function HH(t,e){const n=L(()=>e.installing?"Installing…":"Restart to install");var r=BH(),i=k(w(r),2),o=w(i),s=k(i,2),a=w(s),l=k(s,2);W(()=>{G(o,`Tandem v${e.version??""} is available.`),s.disabled=e.installing,G(a,u(n))}),P("click",s,function(...c){var d;(d=e.onInstall)==null||d.apply(this,c)}),P("click",l,function(...c){var d;(d=e.onDismiss)==null||d.apply(this,c)}),x(t,r)}lt(["click"]);const VH=Math.floor,UH=(t,e)=>t<e?t:e,jH=(t,e)=>t>e?t:e,hA=128,Ah=127,qH=Number.MAX_SAFE_INTEGER,WH=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},gd=typeof TextEncoder<"u"?new TextEncoder:null,KH=t=>gd.encode(t),GH=gd?KH:WH;let Ou=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Ou&&Ou.decode(new Uint8Array).length===1&&(Ou=null);const bp=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Zm=(t,e)=>{for(;e>Ah;)bp(t,hA|Ah&e),e=VH(e/128);bp(t,Ah&e)},rb=new Uint8Array(3e4),ZH=rb.length/3,YH=(t,e)=>{if(e.length<ZH){const n=gd.encodeInto(e,rb).written||0;Zm(t,n);for(let r=0;r<n;r++)bp(t,rb[r])}else $H(t,GH(e))},JH=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Zm(t,r);for(let i=0;i<r;i++)bp(t,n.codePointAt(i))},XH=gd&&gd.encodeInto?YH:JH,QH=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=UH(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(jH(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},$H=(t,e)=>{Zm(t,e.byteLength),QH(t,e)},pA=t=>new Error(t),eV=pA("Unexpected end of array"),tV=pA("Integer out of Range"),nV=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},rV=t=>nV(t,ny(t)),dx=t=>t.arr[t.pos++],ny=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&Ah)*n,n*=128,i<hA)return e;if(e>qH)throw tV}throw eV},iV=t=>{let e=ny(t);if(e===0)return"";{let n=String.fromCodePoint(dx(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(dx(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},oV=t=>Ou.decode(rV(t)),fx=Ou?oV:iV;var Gl;(function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"})(Gl||(Gl={}));const sV=(t,e)=>{Zm(t,Gl.Token),XH(t,e)},aV=(t,e,n,r)=>{switch(ny(t)){case Gl.Token:{e();break}case Gl.PermissionDenied:{n(fx(t));break}case Gl.Authenticated:{r(fx(t));break}}},hx=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n}));var ib;(function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"})(ib||(ib={}));function lV(t){return t||(t={}),{delay:t.delay===void 0?200:t.delay,initialDelay:t.initialDelay===void 0?0:t.initialDelay,minDelay:t.minDelay===void 0?0:t.minDelay,maxDelay:t.maxDelay===void 0?0:t.maxDelay,factor:t.factor===void 0?0:t.factor,maxAttempts:t.maxAttempts===void 0?3:t.maxAttempts,timeout:t.timeout===void 0?0:t.timeout,jitter:t.jitter===!0,initialJitter:t.initialJitter===!0,handleError:t.handleError===void 0?null:t.handleError,handleTimeout:t.handleTimeout===void 0?null:t.handleTimeout,beforeAttempt:t.beforeAttempt===void 0?null:t.beforeAttempt,calculateDelay:t.calculateDelay===void 0?null:t.calculateDelay}}async function c0(t){return new Promise(e=>setTimeout(e,t))}function cV(t,e){let n=e.delay;if(n===0)return 0;if(e.factor&&(n*=Math.pow(e.factor,t.attemptNum-1),e.maxDelay!==0&&(n=Math.min(n,e.maxDelay))),e.jitter){const r=Math.ceil(e.minDelay),i=Math.floor(n);n=Math.floor(Math.random()*(i-r+1))+r}return Math.round(n)}async function uV(t,e){const n=lV(e);for(const a of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const l=n[a];if(!Number.isInteger(l)||l<0)throw new Error(`Value for ${a} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw new Error("Value for factor must be a number greater than or equal to 0");if(n.delay<n.minDelay)throw new Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);const r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||cV;async function o(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){const l=new Error("Attempt aborted");throw l.code="ATTEMPT_ABORTED",l}const a=async l=>{if(n.handleError&&await n.handleError(l,r,n),r.aborted||r.attemptsRemaining===0)throw l;r.attemptNum++;const c=i(r,n);return c&&await c0(c),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((l,c)=>{const d=setTimeout(()=>{if(n.handleTimeout)try{l(n.handleTimeout(r,n))}catch(f){c(f)}else{const f=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);f.code="ATTEMPT_TIMEOUT",c(f)}},n.timeout);t(r,n).then(f=>{clearTimeout(d),l(f)}).catch(f=>{clearTimeout(d),a(f).then(l).catch(c)})}):t(r,n).catch(a)}const s=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(s&&await c0(s),r.attemptNum<1&&n.initialJitter){const a=i(r,n);a&&await c0(a)}return o()}const mA=Math.floor,dV=(t,e)=>t<e?t:e,fV=(t,e)=>t>e?t:e,hV=64,yp=128,pV=63,Iu=127,gA=Number.MAX_SAFE_INTEGER,mV=()=>new Set,gV=Array.from,vV=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},vd=typeof TextEncoder<"u"?new TextEncoder:null,bV=t=>vd.encode(t),yV=vd?bV:vV;let Ru=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Ru&&Ru.decode(new Uint8Array).length===1&&(Ru=null);class wV{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const ry=()=>new wV,vA=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},iy=t=>{const e=new Uint8Array(vA(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},wp=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},pr=(t,e)=>{for(;e>Iu;)wp(t,yp|Iu&e),e=mA(e/128);wp(t,Iu&e)},ob=new Uint8Array(3e4),kV=ob.length/3,xV=(t,e)=>{if(e.length<kV){const n=vd.encodeInto(e,ob).written||0;pr(t,n);for(let r=0;r<n;r++)wp(t,ob[r])}else Zc(t,yV(e))},_V=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;pr(t,r);for(let i=0;i<r;i++)wp(t,n.codePointAt(i))},ps=vd&&vd.encodeInto?xV:_V,CV=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=dV(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(fV(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},Zc=(t,e)=>{pr(t,e.byteLength),CV(t,e)},bA=t=>new Error(t),yA=bA("Unexpected end of array"),wA=bA("Integer out of Range");class SV{constructor(e){this.arr=e,this.pos=0}}const kA=t=>new SV(t),EV=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Ym=t=>EV(t,Va(t)),px=t=>t.arr[t.pos++],Va=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&Iu)*n,n*=128,i<yp)return e;if(e>gA)throw wA}throw yA},AV=t=>{let e=t.arr[t.pos++],n=e&pV,r=64;const i=(e&hV)>0?-1:1;if((e&yp)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&Iu)*r,r*=128,e<yp)return i*n;if(n>gA)throw wA}throw yA},TV=t=>{let e=Va(t);if(e===0)return"";{let n=String.fromCodePoint(px(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(px(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},MV=t=>Ru.decode(Ym(t)),bd=Ru?MV:TV,DV=t=>{const e=t.pos,n=bd(t);return t.pos=e,n},Tc=Date.now,u0=()=>new Map,OV=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r};class IV{constructor(){this._observers=u0()}on(e,n){OV(this._observers,e,mV).add(n)}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return gV((this._observers.get(e)||u0()).values()).forEach(r=>r(...n))}destroy(){this._observers=u0()}}const RV=Object.keys,mx=t=>RV(t).length,NV=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),PV=(t,e)=>t===e,Nu=(t,e)=>{if(t==null||e==null)return PV(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Nu(t.get(n),e.get(n)))return!1;break}case Object:if(mx(t)!==mx(e))return!1;for(const n in t)if(!NV(t,n)||!Nu(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Nu(t[n],e[n]))return!1;break;default:return!1}return!0},d0=3e4;class LV extends IV{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=Tc();this.getLocalState()!==null&&d0/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,o)=>{o!==this.clientID&&d0<=n-i.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&Th(this,r,"timeout")},mA(d0/10)),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){const n=this.clientID,r=this.meta.get(n),i=r===void 0?0:r.clock+1,o=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:i,lastUpdated:Tc()});const s=[],a=[],l=[],c=[];e===null?c.push(n):o==null?e!=null&&s.push(n):(a.push(n),Nu(o,e)||l.push(n)),(s.length>0||l.length>0||c.length>0)&&this.emit("change",[{added:s,updated:l,removed:c},"local"]),this.emit("update",[{added:s,updated:a,removed:c},"local"])}setLocalStateField(e,n){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:n})}getStates(){return this.states}}const Th=(t,e,n)=>{const r=[];for(let i=0;i<e.length;i++){const o=e[i];if(t.states.has(o)){if(t.states.delete(o),o===t.clientID){const s=t.meta.get(o);t.meta.set(o,{clock:s.clock+1,lastUpdated:Tc()})}r.push(o)}}r.length>0&&(t.emit("change",[{added:[],updated:[],removed:r},n]),t.emit("update",[{added:[],updated:[],removed:r},n]))},sb=(t,e,n=t.states)=>{const r=e.length,i=ry();pr(i,r);for(let o=0;o<r;o++){const s=e[o],a=n.get(s)||null,l=t.meta.get(s).clock;pr(i,s),pr(i,l),ps(i,JSON.stringify(a))}return iy(i)},FV=(t,e,n)=>{const r=kA(e),i=Tc(),o=[],s=[],a=[],l=[],c=Va(r);for(let d=0;d<c;d++){const f=Va(r);let h=Va(r);const p=JSON.parse(bd(r)),m=t.meta.get(f),v=t.states.get(f),g=m===void 0?0:m.clock;(g<h||g===h&&p===null&&t.states.has(f))&&(p===null?f===t.clientID&&t.getLocalState()!=null?h++:t.states.delete(f):t.states.set(f,p),t.meta.set(f,{clock:h,lastUpdated:i}),m===void 0&&p!==null?o.push(f):m!==void 0&&p===null?l.push(f):p!==null&&(Nu(p,v)||a.push(f),s.push(f)))}(o.length>0||a.length>0||l.length>0)&&t.emit("change",[{added:o,updated:a,removed:l},n]),(o.length>0||s.length>0||l.length>0)&&t.emit("update",[{added:o,updated:s,removed:l},n])};let xA=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};class ab{constructor(e){this.data=e,this.encoder=ry(),this.decoder=kA(new Uint8Array(this.data))}peekVarString(){return DV(this.decoder)}readVarUint(){return Va(this.decoder)}readVarString(){return bd(this.decoder)}readVarUint8Array(){return Ym(this.decoder)}writeVarUint(e){return pr(this.encoder,e)}writeVarString(e){return ps(this.encoder,e)}writeVarUint8Array(e){return Zc(this.encoder,e)}length(){return vA(this.encoder)}}var or;(function(t){t[t.Sync=0]="Sync",t[t.Awareness=1]="Awareness",t[t.Auth=2]="Auth",t[t.QueryAwareness=3]="QueryAwareness",t[t.Stateless=5]="Stateless",t[t.CLOSE=7]="CLOSE",t[t.SyncStatus=8]="SyncStatus"})(or||(or={}));var _r;(function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"})(_r||(_r={}));class fl{constructor(){this.encoder=ry()}get(e){return e.encoder}toUint8Array(){return iy(this.encoder)}}class zV extends fl{constructor(){super(...arguments),this.type=or.CLOSE,this.description="Ask the server to close the connection"}get(e){return ps(this.encoder,e.documentName),pr(this.encoder,this.type),this.encoder}}class BV extends xA{constructor(e){super(),this.messageQueue=[],this.configuration={url:"",autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=_r.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(e){this.status=_r.Connected,this.emit("status",{status:_r.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===_r.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===_r.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(zV,{documentName:e.configuration.name}),this.configuration.providerMap.delete(e.configuration.name))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===_r.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const e=()=>{let i=!1;return{retryPromise:uV(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:s=>{(!this.shouldConnect||i)&&s.abort()}}).catch(s=>{if(s&&s.code!=="ATTEMPT_ABORTED")throw s}),cancelFunc:()=>{i=!0}}},{retryPromise:n,cancelFunc:r}=e();return this.cancelWebsocketRetry=r,n}attachWebSocketListeners(e,n){const{identifier:r}=e,i=c=>this.emit("message",c),o=c=>this.emit("close",{event:c}),s=c=>this.emit("open",c),a=c=>{n(c)};this.webSocketHandlers[r]={message:i,close:o,open:s,error:a};const l=this.webSocketHandlers[e.identifier];Object.keys(l).forEach(c=>{e.addEventListener(c,l[c])})}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:e}=this.webSocket,n=this.webSocketHandlers[e];Object.keys(n).forEach(r=>{var i;(i=this.webSocket)===null||i===void 0||i.removeEventListener(r,n[r]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,n)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const r=new this.configuration.WebSocketPolyfill(this.url);r.binaryType="arraybuffer",r.identifier=this.identifier,this.attachWebSocketListeners(r,n),this.webSocket=r,this.status=_r.Connecting,this.emit("status",{status:_r.Connecting}),this.connectionAttempt={resolve:e,reject:n}})}onMessage(e){var n;this.resolveConnectionAttempt(),this.lastMessageReceived=Tc();const i=new ab(e.data).peekVarString();(n=this.configuration.providerMap.get(i))===null||n===void 0||n.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=_r.Connected,this.emit("status",{status:_r.Connected}),this.emit("connect"),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){var e;(e=this.connectionAttempt)===null||e===void 0||e.reject(),this.connectionAttempt=null}checkConnection(){var e;this.status===_r.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Tc()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):((e=this.webSocket)===null||e===void 0||e.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]==="/";)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}send(e){var n;((n=this.webSocket)===null||n===void 0?void 0:n.readyState)===ib.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=_r.Disconnected,this.emit("status",{status:_r.Disconnected}),this.emit("disconnect",{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit("destroy"),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}}const _A=0,oy=1,CA=2,HV=(t,e)=>{pr(t,_A);const n=lL(e);Zc(t,n)},VV=(t,e,n)=>{pr(t,oy),Zc(t,iL(e,n))},UV=(t,e,n)=>VV(e,n,Ym(t)),SA=(t,e,n)=>{try{tL(e,Ym(t),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},jV=(t,e)=>{pr(t,CA),Zc(t,e)},qV=SA,WV=(t,e,n,r)=>{const i=Va(t);switch(i){case _A:UV(t,e,n);break;case oy:SA(t,n,r);break;case CA:qV(t,n,r);break;default:throw new Error("Unknown message type")}return i};class KV{constructor(e){this.message=e}apply(e,n){const{message:r}=this,i=r.readVarUint(),o=r.length();switch(i){case or.Sync:this.applySyncMessage(e,n);break;case or.Awareness:this.applyAwarenessMessage(e);break;case or.Auth:this.applyAuthMessage(e);break;case or.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case or.Stateless:e.receiveStateless(bd(r.decoder));break;case or.SyncStatus:this.applySyncStatusMessage(e,AV(r.decoder)===1);break;case or.CLOSE:const s={code:1e3,reason:bd(r.decoder),target:e.configuration.websocketProvider.webSocket,type:"close"};e.onClose(),e.configuration.onClose({event:s}),e.forwardClose({event:s});break;default:throw new Error(`Can’t apply message of unknown type: ${i}`)}r.length()>o+1&&e.send(fl,{encoder:r.encoder})}applySyncMessage(e,n){const{message:r}=this;r.writeVarUint(or.Sync);const i=WV(r.decoder,r.encoder,e.document,e);n&&i===oy&&(e.synced=!0)}applySyncStatusMessage(e,n){n&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:n}=this;FV(e.awareness,n.readVarUint8Array(),e)}applyAuthMessage(e){const{message:n}=this;aV(n.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:n}=this;n.writeVarUint(or.Awareness),n.writeVarUint8Array(sb(e.awareness,Array.from(e.awareness.getStates().keys())))}}class GV{constructor(e,n={}){this.message=new e,this.encoder=this.message.get(n)}create(){return iy(this.encoder)}send(e){e==null||e.send(this.create())}}class ZV extends fl{constructor(){super(...arguments),this.type=or.Auth,this.description="Authentication"}get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return ps(this.encoder,e.documentName),pr(this.encoder,this.type),sV(this.encoder,e.token),this.encoder}}class gx extends fl{constructor(){super(...arguments),this.type=or.Awareness,this.description="Awareness states update"}get(e){if(typeof e.awareness>"u")throw new Error("The awareness message requires awareness as an argument");if(typeof e.clients>"u")throw new Error("The awareness message requires clients as an argument");ps(this.encoder,e.documentName),pr(this.encoder,this.type);let n;return e.states===void 0?n=sb(e.awareness,e.clients):n=sb(e.awareness,e.clients,e.states),Zc(this.encoder,n),this.encoder}}class YV extends fl{constructor(){super(...arguments),this.type=or.Stateless,this.description="A stateless message"}get(e){var n;return ps(this.encoder,e.documentName),pr(this.encoder,this.type),ps(this.encoder,(n=e.payload)!==null&&n!==void 0?n:""),this.encoder}}class vx extends fl{constructor(){super(...arguments),this.type=or.Sync,this.description="First sync step"}get(e){if(typeof e.document>"u")throw new Error("The sync step one message requires document as an argument");return ps(this.encoder,e.documentName),pr(this.encoder,this.type),HV(this.encoder,e.document),this.encoder}}class JV extends fl{constructor(){super(...arguments),this.type=or.Sync,this.description="A document update"}get(e){return ps(this.encoder,e.documentName),pr(this.encoder,this.type),jV(this.encoder,e.update),this.encoder}}class XV extends Error{constructor(){super(...arguments),this.code=1001}}class bx extends xA{constructor(e){var n,r,i;super(),this.configuration={name:"",document:void 0,awareness:void 0,token:null,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit("connect"),this.forwardStatus=o=>this.emit("status",o),this.forwardClose=o=>this.emit("close",o),this.forwardDisconnect=o=>this.emit("disconnect",o),this.forwardDestroy=()=>this.emit("destroy"),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Mo,this.configuration.awareness=e.awareness!==void 0?e.awareness:new LV(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("unsyncedChanges",this.configuration.onUnsyncedChanges),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),(n=this.awareness)===null||n===void 0||n.on("update",()=>{this.emit("awarenessUpdate",{states:hx(this.awareness.getStates())})}),(r=this.awareness)===null||r===void 0||r.on("change",()=>{this.emit("awarenessChange",{states:hx(this.awareness.getStates())})}),this.document.on("update",this.boundDocumentUpdateHandler),(i=this.awareness)===null||i===void 0||i.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval=="number"&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new BV(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&(this.unsyncedChanges-=1),this.unsyncedChanges===0&&(this.synced=!0),this.emit("unsyncedChanges",{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(vx,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Th(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(YV,{documentName:this.configuration.name,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(n){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${n}`);return}this.send(ZV,{token:e??"",documentName:this.configuration.name})}documentUpdateHandler(e,n){n!==this&&(this.incrementUnsyncedChanges(),this.send(JV,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:n,removed:r},i){const o=e.concat(n).concat(r);this.send(gx,{awareness:this.awareness,clients:o,documentName:this.configuration.name})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit("synced",{state:e}))}receiveStateless(e){this.emit("stateless",{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn("HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn("HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}async onOpen(e){this.isAuthenticated=!1,this.emit("open",{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token=="function"?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(vx,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(gx,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,n){if(!this._isAttached)return;const r=new GV(e,n);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const n=new ab(e.data),r=n.readVarString();n.writeVarString(r),this.emit("message",{event:e,message:new ab(e.data)}),new KV(n).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Th(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(Th(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>"u"||!("removeEventListener"in window))&&window.removeEventListener("pagehide",this.boundPageHide)}detach(){this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("status",this.forwardStatus),this.configuration.websocketProvider.off("status",this.configuration.onStatus),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||(this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("status",this.configuration.onStatus),this.configuration.websocketProvider.on("status",this.forwardStatus),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.configuration.websocketProvider.attach(this),this._isAttached=!0)}permissionDeniedHandler(e){this.emit("authenticationFailed",{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit("authenticated",{scope:e})}setAwarenessField(e,n){if(!this.awareness)throw new XV(`Cannot set awareness field "${e}" to ${JSON.stringify(n)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,n)}}const ar=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Mc=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let lb=null;const Ko=function(t,e,n){let r=lb||(lb=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},QV=function(){lb=null},tl=function(t,e,n,r){return n&&(yx(t,e,n,r,-1)||yx(t,e,n,r,1))},$V=/^(img|br|input|textarea|hr)$/i;function yx(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:_i(t))){let s=t.parentNode;if(!s||s.nodeType!=1||cf(t)||$V.test(t.nodeName)||t.contentEditable=="false")return!1;e=ar(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?_i(t):0}else return!1}}function _i(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function eU(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=_i(t)}else if(t.parentNode&&!cf(t))e=ar(t),t=t.parentNode;else return null}}function tU(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!cf(t))e=ar(t)+1,t=t.parentNode;else return null}}function nU(t,e,n){for(let r=e==0,i=e==_i(t);r||i;){if(t==n)return!0;let o=ar(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==_i(t)}}function cf(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Jm=function(t){return t.focusNode&&tl(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function ba(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function rU(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function iU(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(_i(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(_i(r.startContainer),r.startOffset)}}}const Do=typeof navigator<"u"?navigator:null,wx=typeof document<"u"?document:null,la=Do&&Do.userAgent||"",cb=/Edge\/(\d+)/.exec(la),EA=/MSIE \d/.exec(la),ub=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(la),jr=!!(EA||ub||cb),Gs=EA?document.documentMode:ub?+ub[1]:cb?+cb[1]:0,Di=!jr&&/gecko\/(\d+)/i.test(la);Di&&+(/Firefox\/(\d+)/.exec(la)||[0,0])[1];const db=!jr&&/Chrome\/(\d+)/.exec(la),cr=!!db,AA=db?+db[1]:0,gr=!jr&&!!Do&&/Apple Computer/.test(Do.vendor),Dc=gr&&(/Mobile\/\w+/.test(la)||!!Do&&Do.maxTouchPoints>2),yi=Dc||(Do?/Mac/.test(Do.platform):!1),TA=Do?/Win/.test(Do.platform):!1,Qo=/Android \d/.test(la),uf=!!wx&&"webkitFontSmoothing"in wx.documentElement.style,oU=uf?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function sU(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Bo(t,e){return typeof t=="number"?t:t[e]}function aU(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function kx(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=Mc(s);continue}let a=s,l=a==o.body,c=l?sU(o):aU(a),d=0,f=0;if(e.top<c.top+Bo(r,"top")?f=-(c.top-e.top+Bo(i,"top")):e.bottom>c.bottom-Bo(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Bo(i,"top")-c.top:e.bottom-c.bottom+Bo(i,"bottom")),e.left<c.left+Bo(r,"left")?d=-(c.left-e.left+Bo(i,"left")):e.right>c.right-Bo(r,"right")&&(d=e.right-c.right+Bo(i,"right")),d||f)if(l)o.defaultView.scrollBy(d,f);else{let p=a.scrollLeft,m=a.scrollTop;f&&(a.scrollTop+=f),d&&(a.scrollLeft+=d);let v=a.scrollLeft-p,g=a.scrollTop-m;e={left:e.left-v,top:e.top-g,right:e.right-v,bottom:e.bottom-g}}let h=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:Mc(s)}}function lU(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let a=t.root.elementFromPoint(o,s);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:MA(t.dom)}}function MA(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Mc(r));return e}function cU({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;DA(n,r==0?0:r-e)}function DA(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:o}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let wl=null;function uU(t){if(t.setActive)return t.setActive();if(wl)return t.focus(wl);let e=MA(t);t.focus(wl==null?{get preventScroll(){return wl={preventScroll:!0},!0}}:void 0),wl||(wl=!1,DA(e,0))}function OA(t,e){let n,r=2e8,i,o=0,s=e.top,a=e.top,l,c;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=Ko(d).getClientRects();else continue;for(let p=0;p<h.length;p++){let m=h[p];if(m.top<=s&&m.bottom>=a){s=Math.max(m.bottom,s),a=Math.min(m.top,a);let v=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,d.nodeType==1&&v&&(o=f+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=d,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!n&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=f+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?dU(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:OA(n,i)}function dU(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let s=ks(r,1);if(s.top!=s.bottom&&sy(e,s)){i={node:t,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function sy(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function fU(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function hU(t,e,n){let{node:r,offset:i}=OA(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function pU(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let a=t.docView.nearestDesc(o,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?i=a.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(i=a.posAfter),s=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function IA(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let s=t.childNodes[o];if(s.nodeType==1){let a=s.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(sy(e,c))return IA(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function mU(t,e){let n=t.dom.ownerDocument,r,i=0,o=iU(n,e.left,e.top);o&&({node:r,offset:i}=o);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),a;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!sy(e,c)||(s=IA(t.dom,e,c),!s))return null}if(gr)for(let c=s;r&&c;c=Mc(c))c.draggable&&(r=void 0);if(s=fU(s,e),r){if(Di&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;uf&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=pU(t,r,i,e))}a==null&&(a=hU(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function xx(t){return t.top<t.bottom||t.left<t.right}function ks(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(xx(r))return r}return Array.prototype.find.call(n,xx)||t.getBoundingClientRect()}const gU=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function RA(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=uf||Di;if(r.nodeType==3)if(s&&(gU.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=ks(Ko(r,i,i),n);if(Di&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=ks(Ko(r,i-1,i-1),-1);if(c.top==l.top){let d=ks(Ko(r,i,i+1),-1);if(d.top!=l.top)return su(d,d.left<c.left)}}return l}else{let l=i,c=i,d=n<0?1:-1;return n<0&&!i?(c++,d=-1):n>=0&&i==r.nodeValue.length?(l--,d=1):n<0?l--:c++,su(ks(Ko(r,l,c),d),d<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==_i(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return f0(l.getBoundingClientRect(),!1)}if(o==null&&i<_i(r)){let l=r.childNodes[i];if(l.nodeType==1)return f0(l.getBoundingClientRect(),!0)}return f0(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==_i(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Ko(l,_i(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return su(ks(c,1),!1)}if(o==null&&i<_i(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Ko(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return su(ks(c,-1),!0)}return su(ks(r.nodeType==3?Ko(r):r,-n),n>=0)}function su(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function f0(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function NA(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function vU(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return NA(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=RA(t,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Ko(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const bU=/[\u0590-\u08ac]/;function yU(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=t.domSelection();return a?!bU.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:s:NA(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:m,focusOffset:v}=t.domSelectionRange(),g=m&&!p.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==v;try{a.collapse(d,f),l&&(l!=d||c!=f)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let _x=null,Cx=null,Sx=!1;function wU(t,e,n){return _x==e&&Cx==n?Sx:(_x=e,Cx=n,Sx=n=="up"||n=="down"?vU(t,e,n):yU(t,e,n))}const Oi=0,Ex=1,Ca=2,Oo=3;class df{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Oi,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>ar(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let a=i.children[s];if(a.size){i=a;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],a=o+s.size;if(a>e||s instanceof LA){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof PA&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?ar(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?ar(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,a=0;;a++){let l=this.children[a],c=s+l.size;if(i==-1&&e<=c){let d=s+l.border;if(e>=d&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,d);e=s;for(let f=a;f>0;f--){let h=this.children[f-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=ar(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>n||a==this.children.length-1)){n=c;for(let d=a+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=ar(f.dom);break}n+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let o=Math.min(e,n),s=Math.max(e,n);for(let p=0,m=0;p<this.children.length;p++){let v=this.children[p],g=m+v.size;if(o>m&&s<g)return v.setSelection(e-m-v.border,n-m-v.border,r,i);m=g}let a=this.domFromPos(e,e?-1:1),l=n==e?a:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((Di||gr)&&e==n){let{node:p,offset:m}=a;if(p.nodeType==3){if(f=!!(m&&p.nodeValue[m-1]==`
127
+ `),f&&m==p.nodeValue.length)for(let v=p,g;v;v=v.parentNode){if(g=v.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:ar(g)+1});break}let y=v.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let v=p.childNodes[m-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(Di&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&gr)&&tl(a.node,a.offset,d.anchorNode,d.anchorOffset)&&tl(l.node,l.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(f&&Di)){c.collapse(a.node,a.offset);try{e!=n&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>n){let m=a;a=l,l=m}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let a=r+o.border,l=s-o.border;if(e>=a&&n<=l){this.dirty=e==r||n==s?Ca:Ex,e==a&&n==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Oo:o.markDirty(e-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ca:Oo}r=s}this.dirty=Ca}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ca:Ex;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class PA extends df{constructor(e,n,r,i){let o,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==Oi&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class kU extends df{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class nl extends df{constructor(e,n,r,i,o){super(e,[],r,i),this.mark=n,this.spec=o}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=cl.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new nl(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Oo||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Oo&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Oi){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Oi}}slice(e,n,r){let i=nl.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=hb(o,n,s,r)),e>0&&(o=hb(o,0,e,r));for(let a=0;a<o.length;a++)o[a].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Zs extends df{constructor(e,n,r,i,o,s,a,l,c){super(e,[],o,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=a}static create(e,n,r,i,o,s){let a=o.nodeViews[n.type.name],l,c=a&&a(n,o,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),d=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=cl.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let h=d;return d=BA(d,r,n),c?l=new xU(e,n,r,i,d,f||null,h,c,o,s+1):n.isText?new Xm(e,n,r,i,d,h,o):new Zs(e,n,r,i,d,f||null,h,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ce.empty)}return e}matchesNode(e,n,r){return this.dirty==Oi&&e.eq(this.node)&&kp(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new CU(this,s&&s.node,e);AU(this.node,this.innerDeco,(c,d,f)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!f&&l.syncToMarks(d==this.node.childCount?en.none:this.node.child(d).marks,r,e,d),l.placeWidget(c,e,i)},(c,d,f,h)=>{l.syncToMarks(c.marks,r,e,h);let p;l.findNodeMatch(c,d,f,h)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(p=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(c,d,f,p,e)||l.updateNextNode(c,d,f,e,h,i)||l.addNode(c,d,f,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Ca)&&(s&&this.protectLocalComposition(e,s),FA(this.contentDOM,this.children,e),Dc&&TU(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof ut)||r<n||i>n+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,a=MU(this.node.content,s,r-n,i-n);return a<0?null:{node:o,pos:a,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new kU(this,o,n,i);e.input.compositionNodes.push(s),this.children=hb(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Oo||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Oi}updateOuterDeco(e){if(kp(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=zA(this.dom,this.nodeDOM,fb(this.outerDeco,this.node,n),fb(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Ax(t,e,n,r,i){BA(r,e,t);let o=new Zs(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class Xm extends Zs{constructor(e,n,r,i,o,s,a){super(e,n,r,i,o,null,s,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Oo||this.dirty!=Oi&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Oi||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Oi,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new Xm(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Oo)}get domAtom(){return!1}isText(e){return this.node.text==e}}class LA extends df{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Oi&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class xU extends Zs{constructor(e,n,r,i,o,s,a,l,c,d){super(e,n,r,i,o,s,a,c,d),this.spec=l}update(e,n,r,i){if(this.dirty==Oo)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function FA(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=Tx(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(s instanceof nl){let l=r?r.previousSibling:t.lastChild;FA(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=Tx(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Pu=function(t){t&&(this.nodeName=t)};Pu.prototype=Object.create(null);const Sa=[new Pu];function fb(t,e,n){if(t.length==0)return Sa;let r=n?Sa[0]:new Pu,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new Pu(s.nodeName));for(let a in s){let l=s[a];l!=null&&(n&&i.length==1&&i.push(r=new Pu(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return i}function zA(t,e,n,r){if(n==Sa&&r==Sa)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],a=n[o];if(o){let l;a&&a.nodeName==s.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=Sa[0]),i=l}_U(i,a||Sa[0],s)}return i}function _U(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&t.classList.add(i[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function BA(t,e,n){return zA(t,t,Sa,fb(e,n,t.nodeType!=1))}function kp(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Tx(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class CU{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=SU(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,i){let o=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;o<a&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Oi,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let f=this.top.children[d];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){l=d;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let d=nl.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,i,o){let s=this.top.children[i];return s.dirty==Oo&&s.dom==s.contentDOM&&(s.dirty=Ca),s.update(e,n,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,o,s){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Zs){let c=this.preMatch.matched.get(l);if(c!=null&&c!=o)return!1;let d=l.dom,f,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=Oo&&kp(n,l.outerDeco));if(!h&&l.update(e,n,r,i))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(f=this.recreateWrapper(l,e,n,r,i,s)))return this.destroyBetween(this.index,a),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Ca,f.updateChildren(i,s+1),f.dirty=Oi),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,o,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!kp(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=Zs.create(this.top,n,r,i,o,s);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,n,r,i,o){let s=Zs.create(this.top,e,n,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new PA(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof nl;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Xm)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((gr||cr)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new LA(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function SU(t,e){let n=e,r=n.children.length,i=t.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof nl)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function EU(t,e){return t.type.side-e.type.side}function AU(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);r(d,i,e.forChild(o,d),c),o+=d.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,f;for(;s<i.length&&i[s].to==o;){let g=i[s++];g.widget&&(d?(f||(f=[d])).push(g):d=g)}if(d)if(f){f.sort(EU);for(let g=0;g<f.length;g++)n(f[g],c,!!l)}else n(d,c,!!l);let h,p;if(l)p=-1,h=l,l=null;else if(c<t.childCount)p=c,h=t.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=o&&a.splice(g--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let m=o+h.nodeSize;if(h.isText){let g=m;s<i.length&&i[s].from<g&&(g=i[s].from);for(let y=0;y<a.length;y++)a[y].to<g&&(g=a[y].to);g<m&&(l=h.cut(g-o),h=h.cut(0,g-o),m=g,p=-1)}else for(;s<i.length&&i[s].to<m;)s++;let v=h.isInline&&!h.isLeaf?a.filter(g=>!g.inline):a.slice();r(h,v,e.forChild(o,h),p),o=m}}function TU(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function MU(t,e,n,r){for(let i=0,o=0;i<t.childCount&&o<=r;){let s=t.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<t.childCount;){let c=t.child(i++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=n){if(o>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function hb(t,e,n,r,i){let o=[];for(let s=0,a=0;s<t.length;s++){let l=t[s],c=a,d=a+=l.size;c>=n||d<=e?o.push(l):(c<e&&o.push(l.slice(0,e-c,r)),i&&(o.push(i),i=void 0),d>n&&o.push(l.slice(n-c,l.size,r)))}return o}function ay(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(Jm(n)){for(l=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&ft.isSelectable(f)&&i.parent&&!(f.isInline&&nU(n.focusNode,n.focusOffset,i.dom))){let h=i.posBefore;c=new ft(s==h?a:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,h=s;for(let p=0;p<n.rangeCount;p++){let m=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(f<0)return null;[l,s]=h==t.state.selection.anchor?[h,f]:[f,h],a=r.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let f=e=="pointer"||t.state.selection.head<a.pos&&!o?1:-1;c=ly(t,d,a,f)}return c}function HA(t){return t.editable?t.hasFocus():UA(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ss(t,e=!1){let n=t.state.selection;if(VA(t,n),!!HA(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&cr){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&tl(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)OU(t);else{let{anchor:r,head:i}=n,o,s;Mx&&!(n instanceof ut)&&(n.$from.parent.inlineContent||(o=Dx(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=Dx(t,n.to))),t.docView.setSelection(r,i,t,e),Mx&&(o&&Ox(o),s&&Ox(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&DU(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Mx=gr||cr&&AA<63;function Dx(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(gr&&i&&i.contentEditable=="false")return h0(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return h0(i);if(o)return h0(o)}}function h0(t){return t.contentEditable="true",gr&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ox(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function DU(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!HA(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function OU(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ar(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&jr&&Gs<=11&&(n.disabled=!0,n.disabled=!1)}function VA(t,e){if(e instanceof ft){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Ix(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Ix(t)}function Ix(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function ly(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||ut.between(e,n,r)}function Rx(t){return t.editable&&!t.hasFocus()?!1:UA(t)}function UA(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function IU(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return tl(e.node,e.offset,n.anchorNode,n.anchorOffset)}function pb(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&gt.findFrom(o,e)}function Cs(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Nx(t,e,n){let r=t.state.selection;if(r instanceof ut)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Cs(t,new ut(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=pb(t.state,e);return i&&i instanceof ft?Cs(t,i):!1}else if(!(yi&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(a))&&!s.contentDOM?ft.isSelectable(o)?Cs(t,new ft(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):uf?Cs(t,new ut(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ft&&r.node.isInline)return Cs(t,new ut(e>0?r.$to:r.$from));{let i=pb(t.state,e);return i?Cs(t,i):!1}}}function xp(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Lu(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function kl(t,e){return e<0?RU(t):NU(t)}function RU(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(Di&&n.nodeType==1&&r<xp(n)&&Lu(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(Lu(a,-1))i=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(jA(n))break;{let a=n.previousSibling;for(;a&&Lu(a,-1);)i=n.parentNode,o=ar(a),a=a.previousSibling;if(a)n=a,r=xp(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?mb(t,n,r):i&&mb(t,i,o)}function NU(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=xp(n),o,s;for(;;)if(r<i){if(n.nodeType!=1)break;let a=n.childNodes[r];if(Lu(a,1))o=n,s=++r;else break}else{if(jA(n))break;{let a=n.nextSibling;for(;a&&Lu(a,1);)o=a.parentNode,s=ar(a)+1,a=a.nextSibling;if(a)n=a,r=0,i=xp(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&mb(t,o,s)}function jA(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function PU(t,e){for(;t&&e==t.childNodes.length&&!cf(t);)e=ar(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function LU(t,e){for(;t&&!e&&!cf(t);)e=ar(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function mb(t,e,n){if(e.nodeType!=3){let o,s;(s=PU(e,n))?(e=s,n=0):(o=LU(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Jm(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&ss(t)},50)}function Px(t,e){let n=t.state.doc.resolve(e);if(!(cr||TA)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Lx(t,e,n){let r=t.state.selection;if(r instanceof ut&&!r.empty||n.indexOf("s")>-1||yi&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=pb(t.state,e);if(s&&s instanceof ft)return Cs(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof Ur?gt.near(s,e):gt.findFrom(s,e);return a?Cs(t,a):!1}return!1}function Fx(t,e){if(!(t.state.selection instanceof ut))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function zx(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function FU(t){if(!gr||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;zx(t,r,"true"),setTimeout(()=>zx(t,r,"false"),20)}return!1}function zU(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function BU(t,e){let n=e.keyCode,r=zU(e);if(n==8||yi&&n==72&&r=="c")return Fx(t,-1)||kl(t,-1);if(n==46&&!e.shiftKey||yi&&n==68&&r=="c")return Fx(t,1)||kl(t,1);if(n==13||n==27)return!0;if(n==37||yi&&n==66&&r=="c"){let i=n==37?Px(t,t.state.selection.from)=="ltr"?-1:1:-1;return Nx(t,i,r)||kl(t,i)}else if(n==39||yi&&n==70&&r=="c"){let i=n==39?Px(t,t.state.selection.from)=="ltr"?1:-1:1;return Nx(t,i,r)||kl(t,i)}else{if(n==38||yi&&n==80&&r=="c")return Lx(t,-1,r)||kl(t,-1);if(n==40||yi&&n==78&&r=="c")return FU(t)||Lx(t,1,r)||kl(t,1);if(r==(yi?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function cy(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||cl.fromSchema(t.state.schema),a=YA(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,d,f=0;for(;c&&c.nodeType==1&&(d=ZA[c.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let m=a.createElement(d[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),f++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
128
+
129
+ `);return{dom:l,text:h,slice:e}}function qA(t,e,n,r,i){let o=i.parent.type.spec.code,s,a;if(!n&&!e)return null;let l=!!e&&(r||o||!n);if(l){if(t.someProp("transformPastedText",h=>{e=h(e,o||r,t)}),o)return a=new Ge(Ce.from(t.state.schema.text(e.replace(/\r\n?/g,`
130
+ `))),0,0),t.someProp("transformPasted",h=>{a=h(a,t,!0)}),a;let f=t.someProp("clipboardTextParser",h=>h(e,i,r,t));if(f)a=f;else{let h=i.marks(),{schema:p}=t.state,m=cl.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let g=s.appendChild(document.createElement("p"));v&&g.appendChild(m.serializeNode(p.text(v,h)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=jU(n),uf&&qU(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||Tu.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!HU.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)a=WU(Bx(a,+d[1],+d[2]),d[4]);else if(a=Ge.maxOpen(VU(a.content,i),!0),a.openStart||a.openEnd){let f=0,h=0;for(let p=a.content.firstChild;f<a.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=a.content.lastChild;h<a.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);a=Bx(a,f,h)}return t.someProp("transformPasted",f=>{a=f(a,t,l)}),a}const HU=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function VU(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&KA(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=GA(s[s.length-1],o.length));let d=WA(a,l);s.push(d),i=i.matchType(d.type),o=l}}),s)return Ce.from(s)}return t}function WA(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ce.from(t));return t}function KA(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=KA(t,e,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(Ce.from(WA(n,t,i+1))))}}function GA(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,GA(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Ce.empty,!0);return t.copy(n.append(r))}function gb(t,e,n,r,i,o){let s=e<0?t.firstChild:t.lastChild,a=s.content;return t.childCount>1&&(o=0),i<r-1&&(a=gb(a,e,n,r,i+1,o)),i>=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(Ce.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function Bx(t,e,n){return e<t.openStart&&(t=new Ge(gb(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ge(gb(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const ZA={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Hx=null;function YA(){return Hx||(Hx=document.implementation.createHTMLDocument("title"))}let p0=null;function UU(t){let e=window.trustedTypes;return e?(p0||(p0=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),p0.createHTML(t)):t}function jU(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=YA().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&ZA[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=UU(t),i)for(let o=0;o<i.length;o++)n=n.querySelector(i[o])||n;return n}function qU(t){let e=t.querySelectorAll(cr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function WU(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:o,openEnd:s}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=Ce.from(l.create(r[a+1],i)),o++,s++}return new Ge(i,o,s)}const Tr={},Mr={},KU={touchstart:!0,touchmove:!0};class GU{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function ZU(t){for(let e in Tr){let n=Tr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{JU(t,r)&&!uy(t,r)&&(t.editable||!(r.type in Mr))&&n(t,r)},KU[e]?{passive:!0}:void 0)}gr&&t.dom.addEventListener("input",()=>null),vb(t)}function Vs(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function YU(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function vb(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>uy(t,r))})}function uy(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function JU(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function XU(t,e){!uy(t,e)&&Tr[e.type]&&(t.editable||!(e.type in Mr))&&Tr[e.type](t,e)}Mr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!XA(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Qo&&cr&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Dc&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,ba(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||BU(t,n)?n.preventDefault():Vs(t,"key")};Mr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Mr.keypress=(t,e)=>{let n=e;if(XA(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||yi&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ut)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function Qm(t){return{left:t.clientX,top:t.clientY}}function QU(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function dy(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,a=>s>o.depth?a(t,n,o.nodeAfter,o.before(s),i,!0):a(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function Zl(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function $U(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ft.isSelectable(r)?(Zl(t,new ft(n)),!0):!1}function ej(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof ft&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(ft.isSelectable(a)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(Zl(t,ft.create(t.state.doc,i)),!0):!1}function tj(t,e,n,r,i){return dy(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?ej(t,n):$U(t,n))}function nj(t,e,n,r){return dy(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function rj(t,e,n,r){return dy(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||ij(t,n,r)}function ij(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Zl(t,ut.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)Zl(t,ut.create(r,a+1,a+1+s.content.size));else if(ft.isSelectable(s))Zl(t,ft.create(r,a));else continue;return!0}}function fy(t){return _p(t)}const JA=yi?"metaKey":"ctrlKey";Tr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=fy(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&QU(n,t.input.lastClick)&&!n[JA]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};let s=t.posAtCoords(Qm(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new oj(t,s,n,!!r)):(o=="doubleClick"?nj:rj)(t,s.pos,s.inside,n)?n.preventDefault():Vs(t,"pointer"))};class oj{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[JA],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);o=d.parent,s=d.depth?d.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof ft&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Di&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Vs(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ss(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Qm(e))),this.updateAllowDefault(e),this.allowDefault||!n?Vs(this.view,"pointer"):tj(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||gr&&this.mightDrag&&!this.mightDrag.node.isAtom||cr&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Zl(this.view,gt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Vs(this.view,"pointer")}move(e){this.updateAllowDefault(e),Vs(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Tr.touchstart=t=>{t.input.lastTouch=Date.now(),fy(t),Vs(t,"pointer")};Tr.touchmove=t=>{t.input.lastTouch=Date.now(),Vs(t,"pointer")};Tr.contextmenu=t=>fy(t);function XA(t,e){return t.composing?!0:gr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const sj=Qo?5e3:-1;Mr.compositionstart=Mr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ut&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||cr&&TA&&aj(t)))t.markCursor=t.state.storedMarks||n.marks(),_p(t,!0),t.markCursor=null;else if(_p(t,!e.selection.empty),Di&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let a=t.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}QA(t,sj)};function aj(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Mr.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,QA(t,20))};function QA(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>_p(t),e))}function $A(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=cj());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function lj(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=eU(e.focusNode,e.focusOffset),r=tU(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function cj(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function _p(t,e=!1){if(!(Qo&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),$A(t),e||t.docView&&t.docView.dirty){let n=ay(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function uj(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const yd=jr&&Gs<15||Dc&&oU<604;Tr.copy=Mr.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=yd?null:n.clipboardData,s=r.content(),{dom:a,text:l}=cy(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):uj(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function dj(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function fj(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?wd(t,r.value,null,i,e):wd(t,r.textContent,r.innerHTML,i,e)},50)}function wd(t,e,n,r,i){let o=qA(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,o||Ge.empty)))return!0;if(!o)return!1;let s=dj(o),a=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function eT(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Mr.paste=(t,e)=>{let n=e;if(t.composing&&!Qo)return;let r=yd?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&wd(t,eT(r),r.getData("text/html"),i,n)?n.preventDefault():fj(t,n)};class tT{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const hj=yi?"altKey":"ctrlKey";function nT(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[hj]}Tr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(Qm(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof ft?i.to-1:i.to))){if(r&&r.mightDrag)s=ft.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=ft.create(t.state.doc,f.posBefore))}}let a=(s||t.state.selection).content(),{dom:l,text:c,slice:d}=cy(t,a);(!n.dataTransfer.files.length||!cr||AA>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(yd?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",yd||n.dataTransfer.setData("text/plain",c),t.dragging=new tT(d,nT(t,n),s)};Tr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Mr.dragover=Mr.dragenter=(t,e)=>e.preventDefault();Mr.drop=(t,e)=>{try{pj(t,e,t.dragging)}finally{t.dragging=null}};function pj(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Qm(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",p=>{o=p(o,t,!1)}):o=qA(t,eT(e.dataTransfer),yd?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&nT(t,e));if(t.someProp("handleDrop",p=>p(t,e,o||Ge.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?n3(t.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let l=t.state.tr;if(s){let{node:p}=n;p?p.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=l.doc;if(d?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(f))return;let h=l.doc.resolve(c);if(d&&ft.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new ft(h));else{let p=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,v,g,y)=>p=y),l.setSelection(ly(t,h,l.doc.resolve(p)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}Tr.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&ss(t)},20))};Tr.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Tr.beforeinput=(t,e)=>{if(cr&&Qo&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,ba(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Mr)Tr[t]=Mr[t];function kd(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Cp{constructor(e,n){this.toDOM=e,this.spec=n||Ua,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new tn(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Cp&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&kd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ys{constructor(e,n){this.attrs=e,this.spec=n||Ua}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new tn(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ys&&kd(this.attrs,e.attrs)&&kd(this.spec,e.spec)}static is(e){return e.type instanceof Ys}destroy(){}}class hy{constructor(e,n){this.attrs=e,this.spec=n||Ua}map(e,n,r,i){let o=e.mapResult(n.from+i,1);if(o.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=o.pos?null:new tn(o.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),o;return i==n.from&&!(o=e.child(r)).isText&&i+o.nodeSize==n.to}eq(e){return this==e||e instanceof hy&&kd(this.attrs,e.attrs)&&kd(this.spec,e.spec)}destroy(){}}class tn{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new tn(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new tn(e,e,new Cp(n,r))}static inline(e,n,r,i){return new tn(e,n,new Ys(r,i))}static node(e,n,r,i){return new tn(e,n,new hy(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ys}get widget(){return this.type instanceof Cp}}const Ml=[],Ua={};class vt{constructor(e,n){this.local=e.length?e:Ml,this.children=n.length?n:Ml}static create(e,n){return n.length?Sp(n,e,0,Ua):dr}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,o){for(let s=0;s<this.local.length;s++){let a=this.local[s];a.from<=n&&a.to>=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let a=this.children[s]+1;this.children[s+2].findInner(e-a,n-a,r,i+a,o)}}map(e,n,r){return this==dr||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ua)}mapInner(e,n,r,i,o){let s;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,i);l&&l.type.valid(n,l)?(s||(s=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?mj(this.children,s||[],e,n,r,i,o):s?new vt(s.sort(ja),Ml):dr}add(e,n){return n.length?this==dr?vt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,o=0;e.forEach((a,l)=>{let c=l+r,d;if(d=iT(n,a,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<l;)o+=3;i[o]==l?i[o+2]=i[o+2].addInner(a,d,c+1):i.splice(o,0,l,l+a.nodeSize,Sp(d,a,c+1,Ua)),o+=3}});let s=rT(o?oT(n):n,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new vt(s.length?this.local.concat(s).sort(ja):this.local,i||this.children)}remove(e){return e.length==0||this==dr?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,a=r[o]+n,l=r[o+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>a&&f.to<l&&(e[d]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,a+1);c!=dr?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let a=0;a<i.length;a++)i[a].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new vt(i,r):dr}forChild(e,n){if(this==dr)return this;if(n.isLeaf)return vt.empty;let r,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,s=o+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<s&&l.to>o&&l.type instanceof Ys){let c=Math.max(o,l.from)-o,d=Math.min(s,l.to)-o;c<d&&(i||(i=[])).push(l.copy(c,d))}}if(i){let a=new vt(i.sort(ja),Ml);return r?new Ms([a,r]):a}return r||dr}eq(e){if(this==e)return!0;if(!(e instanceof vt)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return py(this.localsInner(e))}localsInner(e){if(this==dr)return Ml;if(e.inlineContent||!this.local.some(Ys.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ys||n.push(this.local[r]);return n}forEachSet(e){e(this)}}vt.empty=new vt([],[]);vt.removeOverlap=py;const dr=vt.empty;class Ms{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Ua));return Ms.from(r)}forChild(e,n){if(n.isLeaf)return vt.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=dr&&(o instanceof Ms?r=r.concat(o.members):r.push(o))}return Ms.from(r)}eq(e){if(!(e instanceof Ms)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let s=0;s<o.length;s++)n.push(o[s])}}return n?py(r?n:n.sort(ja)):Ml}static from(e){switch(e.length){case 0:return dr;case 1:return e[0];default:return new Ms(e.every(n=>n instanceof vt)?e:e.reduce((n,r)=>n.concat(r instanceof vt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function mj(t,e,n,r,i,o,s){let a=t.slice();for(let c=0,d=o;c<n.maps.length;c++){let f=0;n.maps[c].forEach((h,p,m,v)=>{let g=v-m-(p-h);for(let y=0;y<a.length;y+=3){let C=a[y+1];if(C<0||h>C+d-f)continue;let _=a[y]+d-f;p>=_?a[y+1]=h<=_?-2:-1:h>=d&&g&&(a[y]+=g,a[y+1]+=g)}f+=g}),d=n.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=n.map(t[c]+o),f=d-i;if(f<0||f>=r.content.size){l=!0;continue}let h=n.map(t[c+1]+o,-1),p=h-i,{index:m,offset:v}=r.content.findIndex(f),g=r.maybeChild(m);if(g&&v==f&&v+g.nodeSize==p){let y=a[c+2].mapInner(n,g,d+1,t[c]+o+1,s);y!=dr?(a[c]=f,a[c+1]=p,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=gj(a,t,e,n,i,o,s),d=Sp(c,r,0,s);e=d.local;for(let f=0;f<a.length;f+=3)a[f+1]<0&&(a.splice(f,3),f-=3);for(let f=0,h=0;f<d.children.length;f+=3){let p=d.children[f];for(;h<a.length&&a[h]<p;)h+=3;a.splice(h,0,d.children[f],d.children[f+1],d.children[f+2])}}return new vt(e.sort(ja),a)}function rT(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new tn(i.from+e,i.to+e,i.type))}return n}function gj(t,e,n,r,i,o,s){function a(l,c){for(let d=0;d<l.local.length;d++){let f=l.local[d].map(r,i,c);f?n.push(f):s.onRemove&&s.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+o+1);return n}function iT(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let o=0,s;o<t.length;o++)(s=t[o])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[o]=null);return i}function oT(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Sp(t,e,n,r){let i=[],o=!1;e.forEach((a,l)=>{let c=iT(t,a,l+n);if(c){o=!0;let d=Sp(c,a,n+l+1,r);d!=dr&&i.push(l,l+a.nodeSize,d)}});let s=rT(o?oT(t):t,-n).sort(ja);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||i.length?new vt(s,i):dr}function ja(t,e){return t.from-e.from||t.to-e.to}function py(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[i]=o.copy(o.from,r.to),Vx(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),Vx(e,i,r.copy(o.from,r.to)));break}}}return e}function Vx(t,e,n){for(;e<t.length&&ja(n,t[e])>0;)e++;t.splice(e,0,n)}function m0(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=dr&&e.push(r)}),t.cursorWrapper&&e.push(vt.create(t.state.doc,[t.cursorWrapper.deco])),Ms.from(e)}const vj={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},bj=jr&&Gs<=11;class yj{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class wj{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yj,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);jr&&Gs<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():gr&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),bj&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,vj)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Rx(this.view)){if(this.suppressingSelectionUpdates)return ss(this.view);if(jr&&Gs<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&tl(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=Mc(o))n.add(o);for(let o=e.anchorNode;o;o=Mc(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Rx(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],l);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(a=!0))}if(l.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of l)if(d.nodeName=="BR"&&d.parentNode){let f=d.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){d.parentNode.removeChild(d);break}f=f.firstChild}}}else if(Di&&l.length){let d=l.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,h]=d;f.parentNode&&f.parentNode.parentNode==h.parentNode?h.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let h of d){let p=h.parentNode;p&&p.nodeName=="LI"&&(!f||_j(e,f)!=p)&&h.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Jm(r)&&(c=ay(e))&&c.eq(gt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ss(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),kj(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Cj(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ss(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(jr&&Gs<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:h}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h)}let s=i&&i.parentNode==e.target?ar(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?ar(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ux=new WeakMap,jx=!1;function kj(t){if(!Ux.has(t)&&(Ux.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Di,jx)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),jx=!0}}function qx(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return tl(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function xj(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return qx(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?qx(t,n):null}function _j(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Cj(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let o of e)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let a=s;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(o,a.firstChild),r==o&&t.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function Sj(t,e,n){let{node:r,fromOffset:i,toOffset:o,from:s,to:a}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,d=l.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],Jm(l)||c.push({node:l.focusNode,offset:l.focusOffset})),cr&&t.input.lastKeyCode===8)for(let g=o;g>i;g--){let y=r.childNodes[g-1],C=y.pmViewDesc;if(y.nodeName=="BR"&&!C){o=g;break}if(!C||C.size)break}let f=t.state.doc,h=t.someProp("domParser")||Tu.fromSchema(t.state.schema),p=f.resolve(s),m=null,v=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Ej,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),m={anchor:g+s,head:y+s}}return{doc:v,sel:m,from:s,to:a}}function Ej(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(gr&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||gr&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Aj=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Tj(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let E=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,M=ay(t,E);if(M&&!t.state.selection.eq(M)){if(cr&&Qo&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,ba(13,"Enter"))))return;let R=t.state.tr.setSelection(M);E=="pointer"?R.setMeta("pointer",!0):E=="key"&&R.scrollIntoView(),o&&R.setMeta("composition",o),t.dispatch(R)}return}let s=t.state.doc.resolve(e),a=s.sharedDepth(n);e=s.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=Sj(t,e,n),d=t.state.doc,f=d.slice(c.from,c.to),h,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,p="end"):(h=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let m=Oj(f.content,c.doc.content,c.from,h,p);if(m&&t.input.domChangeCount++,(Dc&&t.input.lastIOSEnter>Date.now()-225||Qo)&&i.some(E=>E.nodeType==1&&!Aj.test(E.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",E=>E(t,ba(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof ut&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let E=Wx(t,t.state.doc,c.sel);if(E&&!E.eq(t.state.selection)){let M=t.state.tr.setSelection(E);o&&M.setMeta("composition",o),t.dispatch(M)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof ut&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),jr&&Gs<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)=="  "&&(m.start--,m.endA--,m.endB--);let v=c.doc.resolveNoCache(m.start-c.from),g=c.doc.resolveNoCache(m.endB-c.from),y=d.resolve(m.start),C=v.sameParent(g)&&v.parent.inlineContent&&y.end()>=m.endA;if((Dc&&t.input.lastIOSEnter>Date.now()-225&&(!C||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!C&&v.pos<c.doc.content.size&&(!v.sameParent(g)||!v.parent.inlineContent)&&v.pos<g.pos&&!/\S/.test(c.doc.textBetween(v.pos,g.pos,"","")))&&t.someProp("handleKeyDown",E=>E(t,ba(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&Dj(d,m.start,m.endA,v,g)&&t.someProp("handleKeyDown",E=>E(t,ba(8,"Backspace")))){Qo&&cr&&t.domObserver.suppressSelectionUpdates();return}cr&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),Qo&&!C&&v.start()!=g.start()&&g.parentOffset==0&&v.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,g=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(E){return E(t,ba(13,"Enter"))})},20));let _=m.start,S=m.endA,A=E=>{let M=E||t.state.tr.replace(_,S,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let R=Wx(t,M.doc,c.sel);R&&!(cr&&t.composing&&R.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(R.head==_||R.head==M.mapping.map(S)-1)||jr&&R.empty&&R.head==_)&&M.setSelection(R)}return o&&M.setMeta("composition",o),M.scrollIntoView()},O;if(C)if(v.pos==g.pos){jr&&Gs<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>ss(t),20));let E=A(t.state.tr.delete(_,S)),M=d.resolve(m.start).marksAcross(d.resolve(m.endA));M&&E.ensureMarks(M),t.dispatch(E)}else if(m.endA==m.endB&&(O=Mj(v.parent.content.cut(v.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let E=A(t.state.tr);O.type=="add"?E.addMark(_,S,O.mark):E.removeMark(_,S,O.mark),t.dispatch(E)}else if(v.parent.child(v.index()).isText&&v.index()==g.index()-(g.textOffset?0:1)){let E=v.parent.textBetween(v.parentOffset,g.parentOffset),M=()=>A(t.state.tr.insertText(E,_,S));t.someProp("handleTextInput",R=>R(t,_,S,E,M))||t.dispatch(M())}else t.dispatch(A());else t.dispatch(A())}function Wx(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:ly(t,e.resolve(n.anchor),e.resolve(n.head))}function Mj(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,a,l;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)o=n[d].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",l=d=>d.mark(a.addToSet(d.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(Ce.from(c).eq(t))return{mark:a,type:s}}function Dj(t,e,n,r,i){if(n-e<=i.pos-r.pos||g0(r,!0,!1)<i.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let a=o.nodeAfter;return a!=null&&n==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=t.resolve(g0(o,!0,!0));return!s.parent.isTextblock||s.pos>n||g0(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function g0(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Oj(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:s,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s<o&&t.size<e.size){let l=r<=o&&r>=s?o-r:0;o-=l,o&&o<e.size&&Kx(e.textBetween(o-1,o+1))&&(o+=l?1:-1),a=o+(a-s),s=o}else if(a<o){let l=r<=o&&r>=a?o-r:0;o-=l,o&&o<t.size&&Kx(t.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function Kx(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class sT{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new GU,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Xx),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Yx(this),Zx(this),this.nodeViews=Jx(this),this.docView=Ax(this.state.doc,Gx(this),m0(this),this.dom,this),this.domObserver=new wj(this,(r,i,o,s)=>Tj(this,r,i,o,s)),this.domObserver.start(),ZU(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&vb(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Xx),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&($A(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=Jx(this);Rj(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&vb(this),this.editable=Yx(this),Zx(this);let l=m0(this),c=Gx(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,l);(f||!e.selection.eq(i.selection))&&(s=!0);let h=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&lU(this);if(s){this.domObserver.stop();let p=f&&(jr||cr)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Ij(i.selection,e.selection);if(f){let m=cr?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=lj(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ax(e.doc,c,l,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&IU(this))?ss(this,p):(VA(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&cU(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof ft){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&kx(this,n.getBoundingClientRect(),e)}else kx(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new tT(e.slice,e.move,i<0?void 0:ft.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let a=this.directPlugins[s].props[e];if(a!=null&&(i=n?n(a):a))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let a=o[s].props[e];if(a!=null&&(i=n?n(a):a))return i}}hasFocus(){if(jr){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&uU(this.dom),ss(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return mU(this,e)}coordsAtPos(e,n=1){return RA(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return wU(this,n||this.state,e)}pasteHTML(e,n){return wd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return wd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return cy(this,e)}destroy(){this.docView&&(YU(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],m0(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,QV())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return XU(this,e)}domSelectionRange(){let e=this.domSelection();return e?gr&&this.root.nodeType===11&&rU(this.dom.ownerDocument)==this.dom&&xj(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}sT.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Gx(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[tn.node(0,t.state.doc.content.size,e)]}function Zx(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:tn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Yx(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Ij(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Jx(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Rj(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Xx(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var ra={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ep={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nj=typeof navigator<"u"&&/Mac/.test(navigator.platform),Pj=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var lr=0;lr<10;lr++)ra[48+lr]=ra[96+lr]=String(lr);for(var lr=1;lr<=24;lr++)ra[lr+111]="F"+lr;for(var lr=65;lr<=90;lr++)ra[lr]=String.fromCharCode(lr+32),Ep[lr]=String.fromCharCode(lr);for(var v0 in ra)Ep.hasOwnProperty(v0)||(Ep[v0]=ra[v0]);function Lj(t){var e=Nj&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Pj&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ep:ra)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Fj=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),zj=typeof navigator<"u"&&/Win/.test(navigator.platform);function Bj(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))Fj?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Hj(t){let e=Object.create(null);for(let n in t)e[Bj(n)]=t[n];return e}function b0(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Vj(t){return new Vt({props:{handleKeyDown:my(t)}})}function my(t){let e=Hj(t);return function(n,r){let i=Lj(r),o,s=e[b0(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[b0(i,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(zj&&r.ctrlKey&&r.altKey)&&(o=ra[r.keyCode])&&o!=i){let a=e[b0(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const gy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function aT(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const lT=(t,e,n)=>{let r=aT(t,n);if(!r)return!1;let i=vy(r);if(!i){let s=r.blockRange(),a=s&&Bc(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(vT(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Oc(o,"end")||ft.isSelectable(o)))for(let s=r.depth;;s--){let a=Em(t.doc,r.before(s),r.after(s),Ge.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(Oc(o,"end")?gt.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):ft.create(l.doc,i.pos-o.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},Uj=(t,e,n)=>{let r=aT(t,n);if(!r)return!1;let i=vy(r);return i?cT(t,i,e):!1},jj=(t,e,n)=>{let r=dT(t,n);if(!r)return!1;let i=by(r);return i?cT(t,i,e):!1};function cT(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=Em(t.doc,o,l,Ge.empty);if(!c||c.from!=o||c instanceof Yn&&c.slice.size>=l-o)return!1;if(n){let d=t.tr.step(c);d.setSelection(ut.create(d.doc,o)),n(d.scrollIntoView())}return!0}function Oc(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const uT=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=vy(r)}let s=o&&o.nodeBefore;return!s||!ft.isSelectable(s)?!1:(e&&e(t.tr.setSelection(ft.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function vy(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function dT(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const fT=(t,e,n)=>{let r=dT(t,n);if(!r)return!1;let i=by(r);if(!i)return!1;let o=i.nodeAfter;if(vT(t,i,e,1))return!0;if(r.parent.content.size==0&&(Oc(o,"start")||ft.isSelectable(o))){let s=Em(t.doc,r.before(),r.after(),Ge.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=t.tr.step(s);a.setSelection(Oc(o,"start")?gt.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):ft.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},hT=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=by(r)}let s=o&&o.nodeAfter;return!s||!ft.isSelectable(s)?!1:(e&&e(t.tr.setSelection(ft.create(t.doc,o.pos)).scrollIntoView()),!0)};function by(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const qj=(t,e)=>{let n=t.selection,r=n instanceof ft,i;if(r){if(n.node.isTextblock||!aa(t.doc,n.from))return!1;i=n.from}else if(i=Sm(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(ft.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Wj=(t,e)=>{let n=t.selection,r;if(n instanceof ft){if(n.node.isTextblock||!aa(t.doc,n.to))return!1;r=n.to}else if(r=Sm(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Kj=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&Bc(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},pT=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
131
+ `).scrollIntoView()),!0)};function yy(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Gj=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=yy(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,s.createAndFill());l.setSelection(gt.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},mT=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ur||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=yy(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,a=t.tr.insert(s,o.createAndFill());a.setSelection(ut.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},gT=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(ts(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Bc(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Zj(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof ft&&e.selection.node.isBlock)return!r.parentOffset||!ts(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,a,l=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),a=yy(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),o.unshift(l&&a?{type:a}:null),s=p;break}else{if(p==1)return!1;o.unshift(null)}let d=e.tr;(e.selection instanceof ut||e.selection instanceof Ur)&&d.deleteSelection();let f=d.mapping.map(r.pos),h=ts(d.doc,f,o.length,o);if(h||(o[0]=a?{type:a}:null,h=ts(d.doc,f,o.length,o)),!h)return!1;if(d.split(f,o.length,o),!l&&c&&r.node(s).type!=a){let p=d.mapping.map(r.before(s)),m=d.doc.resolve(p);a&&r.node(s-1).canReplaceWith(m.index(),m.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(s)),a)}return n&&n(d.scrollIntoView()),!0}}const Yj=Zj(),Jj=(t,e)=>{let{$from:n,to:r}=t.selection,i,o=n.sharedDepth(r);return o==0?!1:(i=n.before(o),e&&e(t.tr.setSelection(ft.create(t.doc,i))),!0)};function Xj(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||aa(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function vT(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&Xj(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(a=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&a.matchType(s[0]||o.type).validEnd){if(n){let p=e.pos+o.nodeSize,m=Ce.empty;for(let y=s.length-1;y>=0;y--)m=Ce.from(s[y].create(null,m));m=Ce.from(i.copy(m));let v=t.tr.step(new Qn(e.pos-1,p,e.pos,p,new Ge(m,1,0),s.length,!0)),g=v.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&aa(v.doc,g.pos)&&v.join(g.pos),n(v.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&l?null:gt.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),h=f&&Bc(f);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(f,h).scrollIntoView()),!0;if(c&&Oc(o,"start",!0)&&Oc(i,"end")){let p=i,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let v=o,g=1;for(;!v.isTextblock;v=v.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(n){let y=Ce.empty;for(let _=m.length-1;_>=0;_--)y=Ce.from(m[_].copy(y));let C=t.tr.step(new Qn(e.pos-m.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new Ge(y,m.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function bT(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(ut.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const Qj=bT(-1),$j=bT(1);function eq(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&b1(s,t,e);return a?(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0):!1}}function Qx(t,e=null){return function(n,r){let i=!1;for(let o=0;o<n.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:a}}=n.selection.ranges[o];n.doc.nodesBetween(s,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let d=n.doc.resolve(c),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[s];o.setBlockType(a,l,t,e)}r(o.scrollIntoView())}return!0}}function wy(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}wy(gy,lT,uT);wy(gy,fT,hT);wy(pT,mT,gT,Yj);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function tq(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o);if(!s)return!1;let a=r?n.tr:null;return nq(a,s,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function nq(t,e,n,r=null){let i=!1,o=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=s.resolve(e.start-2);o=new ep(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new ep(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=b1(o,n,r,e);return a?(t&&rq(t,e,a,i,n),!0):!1}function rq(t,e,n,r,i){let o=Ce.empty;for(let d=n.length-1;d>=0;d--)o=Ce.from(n[d].type.create(n[d].attrs,o));t.step(new Qn(e.start-(r?2:0),e.end,e.start,e.end,new Ge(o,0,0),n.length,!0));let s=0;for(let d=0;d<n.length;d++)n[d].type==i&&(s=d+1);let a=n.length-s,l=e.start+n.length-(r?2:0),c=e.parent;for(let d=e.startIndex,f=e.endIndex,h=!0;d<f;d++,h=!1)!h&&ts(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return t}function iq(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?oq(e,n,t,o):sq(e,n,o):!0:!1}}function oq(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new Qn(o-1,s,o,s,new Ge(Ce.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ep(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=Bc(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return aa(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function sq(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,m=n.endIndex-1,v=n.startIndex;m>v;m--)p-=i.child(m).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?Ce.empty:Ce.from(i))))return!1;let f=o.pos,h=f+s.nodeSize;return r.step(new Qn(f-(a?1:0),h+(l?1:0),f+1,h-1,new Ge((a?Ce.empty:Ce.from(i.copy(Ce.empty))).append(l?Ce.empty:Ce.from(i.copy(Ce.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function aq(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,d=Ce.from(c?t.create():null),f=new Ge(Ce.from(t.create(null,Ce.from(a.type.create(null,d)))),c?3:1,0),h=o.start,p=o.end;n(e.tr.step(new Qn(h-(c?3:1),p,h,p,f,1,!0)).scrollIntoView())}return!0}}function $m(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}}}class eg{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...d)=>{const f=l(...d)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a=[],l=!!e,c=e||o.tr,d=()=>(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),a.every(h=>h===!0)),f={...Object.fromEntries(Object.entries(r).map(([h,p])=>[h,(...v)=>{const g=this.buildProps(c,n),y=p(...v)(g);return a.push(y),f}])),run:d};return f}createCan(e){const{rawCommands:n,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...d)=>c(...d)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a={tr:e,editor:i,view:s,state:$m({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...d)=>c(...d)(a)]))}};return a}}class lq{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}once(e,n){const r=(...i)=>{this.off(e,r),n.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function ot(t,e,n){return t.config[e]===void 0&&t.parent?ot(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?ot(t.parent,e,n):null}):t.config[e]}function tg(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function yT(t){const e=[],{nodeExtensions:n,markExtensions:r}=tg(t),i=[...n,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage,extensions:i},l=ot(s,"addGlobalAttributes",a);if(!l)return;l().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([h,p])=>{e.push({type:f,name:h,attribute:{...o,...p}})})})})}),i.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage},l=ot(s,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([d,f])=>{const h={...o,...f};typeof(h==null?void 0:h.default)=="function"&&(h.default=h.default()),h!=null&&h.isRequired&&(h==null?void 0:h.default)===void 0&&delete h.default,e.push({type:s.name,name:d,attribute:h})})}),e}function tr(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function pn(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){const a=o?String(o).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(d=>!l.includes(d));r[i]=[...l,...c].join(" ")}else if(i==="style"){const a=o?o.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;l.forEach(d=>{const[f,h]=d.split(":").map(p=>p.trim());c.set(f,h)}),a.forEach(d=>{const[f,h]=d.split(":").map(p=>p.trim());c.set(f,h)}),r[i]=Array.from(c.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=o}),r},{})}function bb(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>pn(n,r),{})}function wT(t){return typeof t=="function"}function At(t,e=void 0,...n){return wT(t)?e?t.bind(e)(...n):t(...n):t}function cq(t={}){return Object.keys(t).length===0&&t.constructor===Object}function uq(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function $x(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((o,s)=>{const a=s.attribute.parseHTML?s.attribute.parseHTML(n):uq(n.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function e2(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&cq(n)?!1:n!=null))}function dq(t,e){var n;const r=yT(t),{nodeExtensions:i,markExtensions:o}=tg(t),s=(n=i.find(c=>ot(c,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(i.map(c=>{const d=r.filter(y=>y.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,C)=>{const _=ot(C,"extendNodeSchema",f);return{...y,..._?_(c):{}}},{}),p=e2({...h,content:At(ot(c,"content",f)),marks:At(ot(c,"marks",f)),group:At(ot(c,"group",f)),inline:At(ot(c,"inline",f)),atom:At(ot(c,"atom",f)),selectable:At(ot(c,"selectable",f)),draggable:At(ot(c,"draggable",f)),code:At(ot(c,"code",f)),whitespace:At(ot(c,"whitespace",f)),linebreakReplacement:At(ot(c,"linebreakReplacement",f)),defining:At(ot(c,"defining",f)),isolating:At(ot(c,"isolating",f)),attrs:Object.fromEntries(d.map(y=>{var C;return[y.name,{default:(C=y==null?void 0:y.attribute)===null||C===void 0?void 0:C.default}]}))}),m=At(ot(c,"parseHTML",f));m&&(p.parseDOM=m.map(y=>$x(y,d)));const v=ot(c,"renderHTML",f);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:bb(y,d)}));const g=ot(c,"renderText",f);return g&&(p.toText=g),[c.name,p]})),l=Object.fromEntries(o.map(c=>{const d=r.filter(g=>g.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((g,y)=>{const C=ot(y,"extendMarkSchema",f);return{...g,...C?C(c):{}}},{}),p=e2({...h,inclusive:At(ot(c,"inclusive",f)),excludes:At(ot(c,"excludes",f)),group:At(ot(c,"group",f)),spanning:At(ot(c,"spanning",f)),code:At(ot(c,"code",f)),attrs:Object.fromEntries(d.map(g=>{var y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))}),m=At(ot(c,"parseHTML",f));m&&(p.parseDOM=m.map(g=>$x(g,d)));const v=ot(c,"renderHTML",f);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:bb(g,d)})),[c.name,p]}));return new m1({topNode:s,nodes:a,marks:l})}function y0(t,e){return e.nodes[t]||e.marks[t]||null}function t2(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function ky(t,e){const n=cl.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}const fq=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,a)=>{var l,c;const d=((c=(l=i.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:i,pos:o,parent:s,index:a}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-o))}),n};function xy(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class ff{constructor(e){this.find=e.find,this.handler=e.handler}}const hq=(t,e)=>{if(xy(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Bf(t){var e;const{editor:n,from:r,to:i,text:o,rules:s,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(h=>h.type.spec.code))return!1;let d=!1;const f=fq(c)+o;return s.forEach(h=>{if(d)return;const p=hq(f,h.find);if(!p)return;const m=l.state.tr,v=$m({state:l.state,transaction:m}),g={from:r-(p[0].length-o.length),to:i},{commands:y,chain:C,can:_}=new eg({editor:n,state:v});h.handler({state:v,range:g,match:p,commands:y,chain:C,can:_})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:i,text:o}),l.dispatch(m),d=!0)}),d}function pq(t){const{editor:e,rules:n}=t,r=new Vt({state:{init(){return null},apply(i,o,s){const a=i.getMeta(r);if(a)return a;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=ky(Ce.from(d),s.schema);const{from:f}=l,h=f+d.length;Bf({editor:e,from:f,to:h,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,a){return Bf({editor:e,from:o,to:s,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&Bf({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?Bf({editor:e,from:s.pos,to:s.pos,text:`
132
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function mq(t){return Object.prototype.toString.call(t).slice(8,-1)}function Hf(t){return mq(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function ng(t,e){const n={...t};return Hf(t)&&Hf(e)&&Object.keys(e).forEach(r=>{Hf(e[r])&&Hf(t[r])?n[r]=ng(t[r],e[r]):n[r]=e[r]}),n}class eo{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=At(ot(this,"addOptions",{name:this.name}))),this.storage=At(ot(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new eo(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>ng(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new eo(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=At(ot(n,"addOptions",{name:n.name})),n.storage=At(ot(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const l=s.find(c=>(c==null?void 0:c.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function gq(t){return typeof t=="number"}class vq{constructor(e){this.find=e.find,this.handler=e.handler}}const bq=(t,e,n)=>{if(xy(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const o=[i.text];return o.index=i.index,o.input=t,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function yq(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:d}=new eg({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,m)=>{if(!p.isTextblock||p.type.spec.code)return;const v=Math.max(r,m),g=Math.min(i,m+p.content.size),y=p.textBetween(v-m,g-m,void 0,"");bq(y,o.find,s).forEach(_=>{if(_.index===void 0)return;const S=v+_.index+1,A=S+_[0].length,O={from:n.tr.mapping.map(S),to:n.tr.mapping.map(A)},E=o.handler({state:n,range:O,match:_,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});f.push(E)})}),f.every(p=>p!==null)}let Vf=null;const wq=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function kq(t){const{editor:e,rules:n}=t;let r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:d,from:f,to:h,rule:p,pasteEvt:m})=>{const v=d.tr,g=$m({state:d,transaction:v});if(!(!yq({editor:e,state:g,from:Math.max(f-1,0),to:h.b-1,rule:p,pasteEvent:m,dropEvent:a})||!v.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new Vt({view(f){const h=m=>{var v;r=!((v=f.dom.parentElement)===null||v===void 0)&&v.contains(m.target)?f.dom.parentElement:null,r&&(Vf=e)},p=()=>{Vf&&(Vf=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,h)=>{if(o=r===f.dom.parentElement,a=h,!o){const p=Vf;p!=null&&p.isEditable&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(f,h)=>{var p;const m=(p=h.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=h,i=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(f,h,p)=>{const m=f[0],v=m.getMeta("uiEvent")==="paste"&&!i,g=m.getMeta("uiEvent")==="drop"&&!o,y=m.getMeta("applyPasteRules"),C=!!y;if(!v&&!g&&!C)return;if(C){let{text:A}=y;typeof A=="string"?A=A:A=ky(Ce.from(A),p.schema);const{from:O}=y,E=O+A.length,M=wq(A);return l({rule:d,state:p,from:O,to:{b:E},pasteEvt:M})}const _=h.doc.content.findDiffStart(p.doc.content),S=h.doc.content.findDiffEnd(p.doc.content);if(!(!gq(_)||!S||_===S.b))return l({rule:d,state:p,from:_,to:S,pasteEvt:s})}}))}function xq(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}class Ll{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=Ll.resolve(e),this.schema=dq(this.extensions,n),this.setupExtensions()}static resolve(e){const n=Ll.sort(Ll.flatten(e)),r=xq(n.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},i=ot(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{const o=ot(r,"priority")||100,s=ot(i,"priority")||100;return o>s?-1:o<s?1:0})}get commands(){return this.extensions.reduce((e,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:y0(n.name,this.schema)},i=ot(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,n=Ll.sort([...this.extensions].reverse()),r=[],i=[],o=n.map(s=>{const a={name:s.name,options:s.options,storage:s.storage,editor:e,type:y0(s.name,this.schema)},l=[],c=ot(s,"addKeyboardShortcuts",a);let d={};if(s.type==="mark"&&ot(s,"exitable",a)&&(d.ArrowRight=()=>eo.handleExit({editor:e,mark:s})),c){const v=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));d={...d,...v}}const f=Vj(d);l.push(f);const h=ot(s,"addInputRules",a);t2(s,e.options.enableInputRules)&&h&&r.push(...h());const p=ot(s,"addPasteRules",a);t2(s,e.options.enablePasteRules)&&p&&i.push(...p());const m=ot(s,"addProseMirrorPlugins",a);if(m){const v=m();l.push(...v)}return l}).flat();return[pq({editor:e,rules:r}),...kq({editor:e,rules:i}),...o]}get attributes(){return yT(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:n}=tg(this.extensions);return Object.fromEntries(n.filter(r=>!!ot(r,"addNodeView")).map(r=>{const i=this.attributes.filter(l=>l.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:e,type:tr(r.name,this.schema)},s=ot(r,"addNodeView",o);if(!s)return[];const a=(l,c,d,f,h)=>{const p=bb(l,i);return s()({node:l,view:c,getPos:d,decorations:f,innerDecorations:h,editor:e,extension:r,HTMLAttributes:p})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var n;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:y0(e.name,this.schema)};e.type==="mark"&&(!((n=At(ot(e,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(e.name);const i=ot(e,"onBeforeCreate",r),o=ot(e,"onCreate",r),s=ot(e,"onUpdate",r),a=ot(e,"onSelectionUpdate",r),l=ot(e,"onTransaction",r),c=ot(e,"onFocus",r),d=ot(e,"onBlur",r),f=ot(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),s&&this.editor.on("update",s),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}}class sn{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=At(ot(this,"addOptions",{name:this.name}))),this.storage=At(ot(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new sn(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>ng(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new sn({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=At(ot(n,"addOptions",{name:n.name})),n.storage=At(ot(n,"addStorage",{name:n.name,options:n.options})),n}}function kT(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=`
133
+
134
+ `,textSerializers:s={}}=n||{};let a="";return t.nodesBetween(r,i,(l,c,d,f)=>{var h;l.isBlock&&c>r&&(a+=o);const p=s==null?void 0:s[l.type.name];if(p)return d&&(a+=p({node:l,pos:c,parent:d,index:f,range:e})),!1;l.isText&&(a+=(h=l==null?void 0:l.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,i-c))}),a}function xT(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const _q=sn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Vt({key:new Yt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(d=>d.$from.pos)),a=Math.max(...o.map(d=>d.$to.pos)),l=xT(n);return kT(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Cq=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),Sq=(t=!1)=>({commands:e})=>e.setContent("",t),Eq=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:s})=>{t.doc.nodesBetween(o.pos,s.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,f=c.resolve(d.map(l)),h=c.resolve(d.map(l+a.nodeSize)),p=f.blockRange(h);if(!p)return;const m=Bc(p);if(a.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,v)}(m||m===0)&&e.lift(p,m)})}),!0},Aq=t=>e=>t(e),Tq=()=>({state:t,dispatch:e})=>mT(t,e),Mq=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new ut(r.doc.resolve(Math.max(s-1,0)))),!0},Dq=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){const a=i.before(o),l=i.after(o);t.delete(a,l).scrollIntoView()}return!0}return!1},Oq=t=>({tr:e,state:n,dispatch:r})=>{const i=tr(t,n.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){const l=o.before(s),c=o.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},Iq=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},Rq=()=>({state:t,dispatch:e})=>gy(t,e),Nq=()=>({commands:t})=>t.keyboardShortcut("Enter"),Pq=()=>({state:t,dispatch:e})=>Gj(t,e);function Ap(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:xy(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function _T(t,e,n={}){return t.find(r=>r.type===e&&Ap(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function n2(t,e,n={}){return!!_T(t,e,n)}function _y(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!_T([...i.node.marks],e,n)))return;let s=i.index,a=t.start()+i.offset,l=s+1,c=a+i.node.nodeSize;for(;s>0&&n2([...t.parent.child(s-1).marks],e,n);)s-=1,a-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&n2([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function ca(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}const Lq=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const o=ca(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a;if(i){const f=_y(l,o,e);if(f&&f.from<=c&&f.to>=d){const h=ut.create(s,f.from,f.to);n.setSelection(h)}}return!0},Fq=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function CT(t){return t instanceof ut}function Ea(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ST(t,e=null){if(!e)return null;const n=gt.atStart(t),r=gt.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,o=r.to;return e==="all"?ut.create(t,Ea(0,i,o),Ea(t.content.size,i,o)):ut.create(t,Ea(e,i,o),Ea(e,i,o))}function r2(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Tp(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function zq(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const Bq=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(Tp()||r2())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),zq()&&!Tp()&&!r2()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!CT(n.state.selection))return s(),!0;const a=ST(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},Hq=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),Vq=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ET=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&ET(r)}return t};function Uf(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return ET(n)}function xd(t,e,n){if(t instanceof Ks||t instanceof Ce)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return Ce.fromArray(t.map(a=>e.nodeFromJSON(a)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),xd("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,a="";const l=new m1({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Tu.fromSchema(l).parseSlice(Uf(t),n.parseOptions):Tu.fromSchema(l).parse(Uf(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=Tu.fromSchema(e);return n.slice?o.parseSlice(Uf(t),n.parseOptions).content:o.parse(Uf(t),n.parseOptions)}return xd("",e,n)}function Uq(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Yn||i instanceof Qn))return;const o=t.mapping.maps[r];let s=0;o.forEach((a,l,c,d)=>{s===0&&(s=d)}),t.setSelection(gt.near(t.doc.resolve(s),n))}const jq=t=>!("type"in t),qq=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{xd(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=xd(e,o.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(g){return l(g),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,p=!0;if((jq(a)?a:[a]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),d===f&&p){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,f+=1)}let v;if(h){if(Array.isArray(e))v=e.map(g=>g.text||"").join("");else if(e instanceof Ce){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),v=g}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else v=a,r.replaceWith(d,f,v);n.updateSelection&&Uq(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},Wq=()=>({state:t,dispatch:e})=>qj(t,e),Kq=()=>({state:t,dispatch:e})=>Wj(t,e),Gq=()=>({state:t,dispatch:e})=>lT(t,e),Zq=()=>({state:t,dispatch:e})=>fT(t,e),Yq=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Sm(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Jq=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Sm(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Xq=()=>({state:t,dispatch:e})=>Uj(t,e),Qq=()=>({state:t,dispatch:e})=>jj(t,e);function AT(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function $q(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,o,s;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))Tp()||AT()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const eW=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const o=$q(t).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l==null||l.steps.forEach(c=>{const d=c.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function _d(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,s=e?tr(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(f,h)=>{if(f.isText)return;const p=Math.max(r,h),m=Math.min(i,h+f.nodeSize);a.push({node:f,from:p,to:m})});const l=i-r,c=a.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>Ap(f.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((f,h)=>f+h.to-h.from,0)>=l}const tW=(t,e={})=>({state:n,dispatch:r})=>{const i=tr(t,n.schema);return _d(n,i,e)?Kj(n,r):!1},nW=()=>({state:t,dispatch:e})=>gT(t,e),rW=t=>({state:e,dispatch:n})=>{const r=tr(t,e.schema);return iq(r)(e,n)},iW=()=>({state:t,dispatch:e})=>pT(t,e);function rg(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function i2(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const oW=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=rg(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=tr(t,r.schema)),a==="mark"&&(s=ca(t,r.schema)),i&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,d)=>{o&&o===c.type&&n.setNodeMarkup(d,void 0,i2(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(f=>{s===f.type&&n.addMark(d,d+c.nodeSize,s.create(i2(f.attrs,e)))})})}),!0):!1},sW=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),aW=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ur(t.doc);t.setSelection(n)}return!0},lW=()=>({state:t,dispatch:e})=>uT(t,e),cW=()=>({state:t,dispatch:e})=>hT(t,e),uW=()=>({state:t,dispatch:e})=>Jj(t,e),dW=()=>({state:t,dispatch:e})=>$j(t,e),fW=()=>({state:t,dispatch:e})=>Qj(t,e);function yb(t,e,n={},r={}){return xd(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const hW=(t,e=!1,n={},r={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{var l,c;const{doc:d}=o;if(n.preserveWhitespace!=="full"){const f=yb(t,i.schema,n,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:i.options.enableContentCheck});return s&&o.replaceWith(0,d.content.size,f).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:d.content.size},t,{parseOptions:n,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function TT(t,e){const n=ca(e,t.schema),{from:r,to:i,empty:o}=t.selection,s=[];o?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});const a=s.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function pW(t,e){const n=new y1(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function mW(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function gW(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function MT(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Cy(t){return e=>MT(e.$from,t)}function vW(t,e){const n={from:0,to:t.content.size};return kT(t,n,e)}function bW(t,e){const n=tr(e,t.schema),{from:r,to:i}=t.selection,o=[];t.doc.nodesBetween(r,i,a=>{o.push(a)});const s=o.reverse().find(a=>a.type.name===n.name);return s?{...s.attrs}:{}}function DT(t,e){const n=rg(typeof e=="string"?e:e.name,t.schema);return n==="node"?bW(t,e):n==="mark"?TT(t,e):{}}function yW(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function wW(t){const e=yW(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,s)=>s!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function kW(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,o)=>{const s=[];if(i.ranges.length)i.forEach((a,l)=>{s.push({from:a,to:l})});else{const{from:a,to:l}=n[o];if(a===void 0||l===void 0)return;s.push({from:a,to:l})}s.forEach(({from:a,to:l})=>{const c=e.slice(o).map(a,-1),d=e.slice(o).map(l),f=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:f,to:h},newRange:{from:c,to:d}})})}),wW(r)}function Sy(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=n.resolve(t),s=_y(o,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,o)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function Mh(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function wb(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?ca(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>Ap(f.attrs,n,{strict:!1}));let s=0;const a=[];if(i.forEach(({$from:f,$to:h})=>{const p=f.pos,m=h.pos;t.doc.nodesBetween(p,m,(v,g)=>{if(!v.isText&&!v.marks.length)return;const y=Math.max(p,g),C=Math.min(m,g+v.nodeSize),_=C-y;s+=_,a.push(...v.marks.map(S=>({mark:S,from:y,to:C})))})}),s===0)return!1;const l=a.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>Ap(f.mark.attrs,n,{strict:!1})).reduce((f,h)=>f+h.to-h.from,0),c=a.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,h)=>f+h.to-h.from,0);return(l>0?l+c:l)>=s}function xW(t,e,n={}){if(!e)return _d(t,null,n)||wb(t,null,n);const r=rg(e,t.schema);return r==="node"?_d(t,e,n):r==="mark"?wb(t,e,n):!1}function o2(t,e){const{nodeExtensions:n}=tg(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=At(ot(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function ig(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!==null&&r!==void 0?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(o=>{i!==!1&&(ig(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function _W(t){return t instanceof ft}function CW(t,e,n){var r;const{selection:i}=e;let o=null;if(CT(i)&&(o=i.$cursor),o){const a=(r=t.storedMarks)!==null&&r!==void 0?r:o.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}const{ranges:s}=i;return s.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(d,f,h)=>{if(c)return!1;if(d.isInline){const p=!h||h.type.allowsMarkType(n),m=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));c=p&&m}return!c}),c})}const SW=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=ca(t,r.schema);if(i)if(s){const c=TT(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(d,f,(h,p)=>{const m=Math.max(p,d),v=Math.min(p+h.nodeSize,f);h.marks.find(y=>y.type===l)?h.marks.forEach(y=>{l===y.type&&n.addMark(m,v,l.create({...y.attrs,...e}))}):n.addMark(m,v,l.create(e))})});return CW(r,n,l)},EW=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),AW=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=tr(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:a})=>Qx(o,{...s,...e})(n)?!0:a.clearNodes()).command(({state:a})=>Qx(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},TW=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Ea(t,0,r.content.size),o=ft.create(r,i);e.setSelection(o)}return!0},MW=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=ut.atStart(r).from,a=ut.atEnd(r).to,l=Ea(i,s,a),c=Ea(o,s,a),d=ut.create(r,l,c);e.setSelection(d)}return!0},DW=t=>({state:e,dispatch:n})=>{const r=tr(t,e.schema);return aq(r)(e,n)};function s2(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const OW=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=e,{$from:a,$to:l}=o,c=i.extensionManager.attributes,d=Mh(c,a.node().type.name,a.node().attrs);if(o instanceof ft&&o.node.isBlock)return!a.parentOffset||!ts(s,a.pos)?!1:(r&&(t&&s2(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const f=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:mW(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=f&&h?[{type:h,attrs:d}]:void 0,m=ts(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&ts(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(m=!0,p=h?[{type:h,attrs:d}]:void 0),r){if(m&&(o instanceof ut&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),h&&!f&&!a.parentOffset&&a.parent.type!==h)){const v=e.mapping.map(a.before()),g=e.doc.resolve(v);a.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}t&&s2(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},IW=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=tr(t,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const f=l.node(-1);if(f.type!==a)return!1;const h=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let y=Ce.empty;const C=l.index(-1)?1:l.index(-2)?2:3;for(let M=l.depth-C;M>=l.depth-3;M-=1)y=Ce.from(l.node(M).copy(y));const _=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,S={...Mh(h,l.node().type.name,l.node().attrs),...e},A=((s=a.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(S))||void 0;y=y.append(Ce.from(a.createAndFill(null,A)||void 0));const O=l.before(l.depth-(C-1));n.replace(O,l.after(-_),new Ge(y,4-C,0));let E=-1;n.doc.nodesBetween(O,n.doc.content.size,(M,R)=>{if(E>-1)return!1;M.isTextblock&&M.content.size===0&&(E=R+1)}),E>-1&&n.setSelection(ut.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const p=c.pos===l.end()?f.contentMatchAt(0).defaultType:null,m={...Mh(h,f.type.name,f.attrs),...e},v={...Mh(h,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const g=p?[{type:a,attrs:m},{type:p,attrs:v}]:[{type:a,attrs:m}];if(!ts(n.doc,l.pos,2))return!1;if(i){const{selection:y,storedMarks:C}=r,{splittableMarks:_}=o.extensionManager,S=C||y.$to.parentOffset&&y.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!S||!i)return!0;const A=S.filter(O=>_.includes(O.type.name));n.ensureMarks(A)}return!0},w0=(t,e)=>{const n=Cy(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&aa(t.doc,n.pos)&&t.join(n.pos),!0},k0=(t,e)=>{const n=Cy(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&aa(t.doc,r)&&t.join(r),!0},RW=(t,e,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:f,splittableMarks:h}=i.extensionManager,p=tr(t,s.schema),m=tr(e,s.schema),{selection:v,storedMarks:g}=s,{$from:y,$to:C}=v,_=y.blockRange(C),S=g||v.$to.parentOffset&&v.$from.marks();if(!_)return!1;const A=Cy(O=>o2(O.type.name,f))(v);if(_.depth>=1&&A&&_.depth-A.depth<=1){if(A.node.type===p)return c.liftListItem(m);if(o2(A.node.type.name,f)&&p.validContent(A.node.content)&&a)return l().command(()=>(o.setNodeMarkup(A.pos,p),!0)).command(()=>w0(o,p)).command(()=>k0(o,p)).run()}return!n||!S||!a?l().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>w0(o,p)).command(()=>k0(o,p)).run():l().command(()=>{const O=d().wrapInList(p,r),E=S.filter(M=>h.includes(M.type.name));return o.ensureMarks(E),O?!0:c.clearNodes()}).wrapInList(p,r).command(()=>w0(o,p)).command(()=>k0(o,p)).run()},NW=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=ca(t,r.schema);return wb(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},PW=(t,e,n={})=>({state:r,commands:i})=>{const o=tr(t,r.schema),s=tr(e,r.schema),a=_d(r,o,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(s,l):i.setNode(o,{...l,...n})},LW=(t,e={})=>({state:n,commands:r})=>{const i=tr(t,n.schema);return _d(n,i,e)?r.lift(i):r.wrapIn(i,e)},FW=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let o;if(i.spec.isInputRules&&(o=i.getState(t))){if(e){const s=t.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l-=1)s.step(a.steps[l].invert(a.docs[l]));if(o.text){const l=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,t.schema.text(o.text,l))}else s.delete(o.from,o.to)}return!0}}return!1},zW=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},BW=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=ca(t,r.schema),{$from:c,empty:d,ranges:f}=a;if(!i)return!0;if(d&&s){let{from:h,to:p}=a;const m=(o=c.marks().find(g=>g.type===l))===null||o===void 0?void 0:o.attrs,v=_y(c,l,m);v&&(h=v.from,p=v.to),n.removeMark(h,p,l)}else f.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,l)});return n.removeStoredMark(l),!0},HW=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=rg(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=tr(t,r.schema)),a==="mark"&&(s=ca(t,r.schema)),i&&n.selection.ranges.forEach(l=>{const c=l.$from.pos,d=l.$to.pos;let f,h,p,m;n.selection.empty?r.doc.nodesBetween(c,d,(v,g)=>{o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,d),f=g,h=v)}):r.doc.nodesBetween(c,d,(v,g)=>{g<c&&o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,d),f=g,h=v),g>=c&&g<=d&&(o&&o===v.type&&n.setNodeMarkup(g,void 0,{...v.attrs,...e}),s&&v.marks.length&&v.marks.forEach(y=>{if(s===y.type){const C=Math.max(g,c),_=Math.min(g+v.nodeSize,d);n.addMark(C,_,s.create({...y.attrs,...e}))}}))}),h&&(f!==void 0&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(v=>{s===v.type&&n.addMark(p,m,s.create({...v.attrs,...e}))}))}),!0):!1},VW=(t,e={})=>({state:n,dispatch:r})=>{const i=tr(t,n.schema);return eq(i,e)(n,r)},UW=(t,e={})=>({state:n,dispatch:r})=>{const i=tr(t,n.schema);return tq(i,e)(n,r)};var jW=Object.freeze({__proto__:null,blur:Cq,clearContent:Sq,clearNodes:Eq,command:Aq,createParagraphNear:Tq,cut:Mq,deleteCurrentNode:Dq,deleteNode:Oq,deleteRange:Iq,deleteSelection:Rq,enter:Nq,exitCode:Pq,extendMarkRange:Lq,first:Fq,focus:Bq,forEach:Hq,insertContent:Vq,insertContentAt:qq,joinBackward:Gq,joinDown:Kq,joinForward:Zq,joinItemBackward:Yq,joinItemForward:Jq,joinTextblockBackward:Xq,joinTextblockForward:Qq,joinUp:Wq,keyboardShortcut:eW,lift:tW,liftEmptyBlock:nW,liftListItem:rW,newlineInCode:iW,resetAttributes:oW,scrollIntoView:sW,selectAll:aW,selectNodeBackward:lW,selectNodeForward:cW,selectParentNode:uW,selectTextblockEnd:dW,selectTextblockStart:fW,setContent:hW,setMark:SW,setMeta:EW,setNode:AW,setNodeSelection:TW,setTextSelection:MW,sinkListItem:DW,splitBlock:OW,splitListItem:IW,toggleList:RW,toggleMark:NW,toggleNode:PW,toggleWrap:LW,undoInputRule:FW,unsetAllMarks:zW,unsetMark:BW,updateAttributes:HW,wrapIn:VW,wrapInList:UW});const qW=sn.create({name:"commands",addCommands(){return{...jW}}}),WW=sn.create({name:"drop",addProseMirrorPlugins(){return[new Vt({key:new Yt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),KW=sn.create({name:"editable",addProseMirrorPlugins(){return[new Vt({key:new Yt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),GW=new Yt("focusEvents"),ZW=sn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Vt({key:GW,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),YW=sn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:d,$anchor:f}=l,{pos:h,parent:p}=f,m=f.parent.isTextblock&&h>0?a.doc.resolve(h-1):f,v=m.parent.type.spec.isolating,g=f.pos-f.parentOffset,y=v&&m.parent.childCount===1?g===f.pos:gt.atStart(c).from===h;return!d||!p.type.isTextblock||p.textContent.length||!y||y&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Tp()||AT()?o:i},addProseMirrorPlugins(){return[new Vt({key:new Yt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:a}=e.selection,l=gt.atStart(e.doc).from,c=gt.atEnd(e.doc).to;if(o||!(s===l&&a===c)||!ig(n.doc))return;const h=n.tr,p=$m({state:n,transaction:h}),{commands:m}=new eg({editor:this.editor,state:p});if(m.clearNodes(),!!h.steps.length)return h}})]}}),JW=sn.create({name:"paste",addProseMirrorPlugins(){return[new Vt({key:new Yt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),XW=sn.create({name:"tabindex",addProseMirrorPlugins(){return[new Vt({key:new Yt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class ya{get name(){return this.node.type.name}constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new ya(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new ya(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new ya(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,s=this.pos+r+(o?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(s);if(!i&&a.depth<=this.depth)return;const l=new ya(a,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new ya(a,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const o=i.node.attrs,s=Object.keys(n);for(let a=0;a<s.length;a+=1){const l=s[a];if(o[l]!==n[l])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const o=Object.keys(n);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&o.every(l=>n[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}}const QW=`.ProseMirror {
135
+ position: relative;
136
+ }
137
+
138
+ .ProseMirror {
139
+ word-wrap: break-word;
140
+ white-space: pre-wrap;
141
+ white-space: break-spaces;
142
+ -webkit-font-variant-ligatures: none;
143
+ font-variant-ligatures: none;
144
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
145
+ }
146
+
147
+ .ProseMirror [contenteditable="false"] {
148
+ white-space: normal;
149
+ }
150
+
151
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
152
+ white-space: pre-wrap;
153
+ }
154
+
155
+ .ProseMirror pre {
156
+ white-space: pre-wrap;
157
+ }
158
+
159
+ img.ProseMirror-separator {
160
+ display: inline !important;
161
+ border: none !important;
162
+ margin: 0 !important;
163
+ width: 0 !important;
164
+ height: 0 !important;
165
+ }
166
+
167
+ .ProseMirror-gapcursor {
168
+ display: none;
169
+ pointer-events: none;
170
+ position: absolute;
171
+ margin: 0;
172
+ }
173
+
174
+ .ProseMirror-gapcursor:after {
175
+ content: "";
176
+ display: block;
177
+ position: absolute;
178
+ top: -2px;
179
+ width: 20px;
180
+ border-top: 1px solid black;
181
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
182
+ }
183
+
184
+ @keyframes ProseMirror-cursor-blink {
185
+ to {
186
+ visibility: hidden;
187
+ }
188
+ }
189
+
190
+ .ProseMirror-hideselection *::selection {
191
+ background: transparent;
192
+ }
193
+
194
+ .ProseMirror-hideselection *::-moz-selection {
195
+ background: transparent;
196
+ }
197
+
198
+ .ProseMirror-hideselection * {
199
+ caret-color: transparent;
200
+ }
201
+
202
+ .ProseMirror-focused .ProseMirror-gapcursor {
203
+ display: block;
204
+ }
205
+
206
+ .tippy-box[data-animation=fade][data-state=hidden] {
207
+ opacity: 0
208
+ }`;function $W(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}let eK=class extends lq{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:i})=>this.options.onDrop(n,r,i)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=$W(QW,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,n){const r=wT(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(e).forEach(o=>{const s=typeof o=="string"?`${o}$`:o.key;r=r.filter(a=>!a.key.startsWith(s))}),n.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,n;const i=[...this.options.enableCoreExtensions?[KW,_q.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),qW,ZW,YW,XW,WW,JW].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new Ll(i,this)}createCommandManager(){this.commandManager=new eg({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let n;try{n=yb(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),n=yb(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=ST(n,this.options.autofocus);this.view=new sT(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:Nl.create({doc:n,selection:r||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(s)});return}const n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:n}),this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return DT(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return xW(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ky(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
209
+
210
+ `,textSerializers:r={}}=e||{};return vW(this.state.doc,{blockSeparator:n,textSerializers:{...xT(this.schema),...r}})}get isEmpty(){return ig(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new ya(n,this)}get $doc(){return this.$pos(0)}};function rl(t){return new ff({find:t.find,handler:({state:e,range:n,match:r})=>{const i=At(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:o}=e,s=r[r.length-1],a=r[0];if(s){const l=a.search(/\S/),c=n.from+a.indexOf(s),d=c+s.length;if(Sy(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>c).length)return null;d<n.to&&o.delete(d,n.to),c>n.from&&o.delete(n.from+l,c);const h=n.from+l+s.length;o.addMark(n.from+l,h,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}function OT(t){return new ff({find:t.find,handler:({state:e,range:n,match:r})=>{const i=At(t.getAttributes,void 0,r)||{},{tr:o}=e,s=n.from;let a=n.to;const l=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=s+c;d>a?d=a:a=d+r[1].length;const f=r[0][r[0].length-1];o.insertText(f,s+r[0].length-1),o.replaceWith(d,a,l)}else if(r[0]){const c=t.type.isInline?s:s-1;o.insert(c,t.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()}})}function kb(t){return new ff({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),o=At(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)}})}function Cd(t){return new ff({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const o=At(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),c=l&&b1(l,t.type,o);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){const{selection:f,storedMarks:h}=e,{splittableMarks:p}=t.editor.extensionManager,m=h||f.$to.parentOffset&&f.$from.marks();if(m){const v=m.filter(g=>p.includes(g.type.name));s.ensureMarks(v)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,o).run()}const d=s.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&aa(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)}})}let wr=class xb{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=At(ot(this,"addOptions",{name:this.name}))),this.storage=At(ot(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new xb(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>ng(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new xb(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=At(ot(n,"addOptions",{name:n.name})),n.storage=At(ot(n,"addStorage",{name:n.name,options:n.options})),n}};function ia(t){return new vq({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const o=At(t.getAttributes,void 0,r,i);if(o===!1||o===null)return null;const{tr:s}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const d=l.search(/\S/),f=n.from+l.indexOf(a),h=f+a.length;if(Sy(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(g=>g===t.type&&g!==m.mark.type)).filter(m=>m.to>f).length)return null;h<n.to&&s.delete(h,n.to),f>n.from&&s.delete(n.from+d,f),c=n.from+d+a.length,s.addMark(n.from+d,c,t.type.create(o||{})),s.removeStoredMark(t.type)}}})}function tK(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof ft){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let i=r.depth;for(;i>=0;){const o=r.index(i);if(r.node(i).contentMatchAt(o).matchType(e))return!0;i-=1}return!1}const nK=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},rK=/[\uD800-\uDBFF]/,iK=/[\uDC00-\uDFFF]/,oK=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&rK.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&iK.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},sK=oK,vn=new Yt("y-sync"),Co=new Yt("y-undo"),jf=new Yt("yjs-cursor"),So=(t,e)=>t>>>e|t<<32-e,aK=t=>So(t,2)^So(t,13)^So(t,22),lK=t=>So(t,6)^So(t,11)^So(t,25),cK=t=>So(t,7)^So(t,18)^t>>>3,uK=t=>So(t,17)^So(t,19)^t>>>10,dK=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),fK=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class hK{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(fK),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let f=16;f<64;f++)n[f]=uK(n[f-2])+n[f-7]+cK(n[f-15])+n[f-16];let r=e[0],i=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],d=e[7];for(let f=0,h,p;f<64;f++)h=d+lK(a)+(a&l^~a&c)+dK[f]+n[f]>>>0,p=aK(r)+(r&i^r&o^i&o)>>>0,d=c,c=l,l=a,a=s+h>>>0,s=o,o=i,i=r,r=h+p>>>0;e[0]+=r,e[1]+=i,e[2]+=o,e[3]+=s,e[4]+=a,e[5]+=l,e[6]+=c,e[7]+=d}digest(e){let n=0;for(;n+56<=e.length;){let s=0;for(;s<16&&n+3<e.length;s++)this._W[s]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,s,16);n<e.length;)this._W[s]|=e[n]<<(3-n%4)*8,n++;this._W[s]|=Ar<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let i=0;for(;n<e.length;i++)for(let s=3;s>=0&&n<e.length;s--)this._W[i]|=e[n++]<<s*8;r||(this._W[i-(n%4===0?0:1)]|=Ar<<(3-n%4)*8),this._W[14]=e.byteLength/XN,this._W[15]=e.byteLength*8,this._updateHash();const o=new Uint8Array(32);for(let s=0;s<this._H.length;s++)for(let a=0;a<4;a++)o[s*4+a]=this._H[s]>>>(3-a)*8;return o}}const pK=t=>new hK().digest(t),mK=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},gK=t=>Q9(mK(pK(eP(t)))),Mp=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!qc(e.ds,t.id),vK=[{light:"#ecd44433",dark:"#ecd444"}],bK=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Ja();t.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}t.set(n,D9(e))}return t.get(n)},yK=(t,{colors:e=vK,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let s=!1;const a=new kK(t,o),l=new Vt({props:{editable:c=>{const d=vn.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:vn,state:{init:(c,d)=>({type:t,doc:t.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,d)=>{const f=c.getMeta(vn);if(f!==void 0){d=Object.assign({},d);for(const h in f)d[h]=f[h]}return d.addToHistory=c.getMeta("addToHistory")!==!1,d.isChangeOrigin=f!==void 0&&!!f.isChangeOrigin,d.isUndoRedoOperation=f!==void 0&&!!f.isChangeOrigin&&!!f.isUndoRedoOperation,a.prosemirrorView!==null&&f!==void 0&&(f.snapshot!=null||f.prevSnapshot!=null)&&F1(0,()=>{a.prosemirrorView!=null&&(f.restore==null?a._renderSnapshot(f.snapshot,f.prevSnapshot,d):(a._renderSnapshot(f.snapshot,f.snapshot,d),delete d.restore,delete d.snapshot,delete d.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),d}},view:c=>(a.initView(c),o==null&&a._forceRerender(),i(),{update:()=>{const d=l.getState(c.state);if(d.snapshot==null&&d.prevSnapshot==null&&(s||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(s=!0,d.addToHistory===!1&&!d.isChangeOrigin){const f=Co.getState(c.state),h=f&&f.undoManager;h&&h.stopCapturing()}a.mux(()=>{d.doc.transact(f=>{f.meta.set("addToHistory",d.addToHistory),a._prosemirrorChanged(c.state.doc)},vn)})}},destroy:()=>{a.destroy()}})});return l},wK=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new Ur(t.doc));else if(e.type==="node"){const r=Yl(n.doc,n.type,e.anchor,n.mapping);t.setSelection(ft.create(t.doc,r))}else{const r=Yl(n.doc,n.type,e.anchor,n.mapping),i=Yl(n.doc,n.type,e.head,n.mapping);if(r!==null&&i!==null){const o=ut.between(t.doc.resolve(r),t.doc.resolve(i));t.setSelection(o)}}},_b=(t,e)=>({type:e.selection.jsonID,anchor:Op(e.selection.anchor,t.type,t.mapping),head:Op(e.selection.head,t.type,t.mapping)});class kK{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=nK(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=_b(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(R3&&this._domSelectionInView===null&&(F1(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const i=n.getBoundingClientRect(),o=ef.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||o.clientWidth||0)&&i.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(e,n){n||(n=pE(iE(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(vn,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Dh(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Ge(Ce.from(e),0,0));n.setMeta(vn,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(i=>Dh(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Ge(Ce.from(n),0,0));if(e){const i=ns(Xi(e.anchor,0),r.doc.content.size),o=ns(Xi(e.head,0),r.doc.content.size);r.setSelection(ut.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(vn,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let i=this.doc,o=this.type;if(e||(e=e0(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&mr(),i=new Mo({gc:!1}),up(i,n),n=e0(i),up(i,e),e=e0(i),o._item===null){const s=Array.from(this.doc.share.keys()).find(a=>this.doc.share.get(a)===this.type);o=i.getXmlFragment(s)}else{const s=i.store.clients.get(o._item.id.client)??[],a=Qi(s,o._item.id.clock);o=s[a].content.type}this.mapping.clear(),this.mux(()=>{i.transact(s=>{const a=r.permanentUserData;a&&a.dss.forEach(f=>{ea(s,f,h=>{})});const l=(f,h)=>{const p=f==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:p,type:f,color:bK(r.colorMapping,r.colors,p)}},c=SE(o,new U1(n.ds,e.sv)).map(f=>!f._item.deleted||Mp(f._item,e)||Mp(f._item,n)?Dh(f,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,l):null).filter(f=>f!==null),d=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Ge(Ce.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(vn,{isChangeOrigin:!0}))},vn)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=vn.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const i=(a,l)=>this.mapping.delete(l);ea(n,n.deleteSet,a=>{if(a.constructor===ln){const l=a.content.type;l&&this.mapping.delete(l)}}),n.changed.forEach(i),n.changedParentTypes.forEach(i);const o=this.type.toArray().map(a=>IT(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Ge(Ce.from(o),0,0));wK(s,this.beforeTransactionSelection,this),s=s.setMeta(vn,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof yE}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{Sb(this.doc,this.type,e,this),this.beforeTransactionSelection=_b(this,this.prosemirrorView.state)},vn)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const IT=(t,e,n,r,i,o)=>{const s=n.mapping.get(t);if(s===void 0){if(t instanceof bn)return Dh(t,e,n,r,i,o);throw Mi()}return s},Dh=(t,e,n,r,i,o)=>{const s=[],a=l=>{var c,d;if(l instanceof bn){const f=IT(l,e,n,r,i,o);f!==null&&s.push(f)}else{const f=(d=(c=l._item.right)==null?void 0:c.content)==null?void 0:d.type;f instanceof ta&&!f._item.deleted&&f._item.id.client===f.doc.clientID&&(l.applyDelta([{retain:l.length},...f.toDelta()]),f.doc.transact(p=>{f._item.delete(p)}));const h=xK(l,e,n,r,i,o);h!==null&&h.forEach(p=>{p!==null&&s.push(p)})}};r===void 0||i===void 0?t.toArray().forEach(a):SE(t,new U1(i.ds,r.sv)).forEach(a);try{const l=t.getAttributes(r);r!==void 0&&(Mp(t._item,r)?Mp(t._item,i)||(l.ychange=o?o("added",t._item.id):{type:"added"}):l.ychange=o?o("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,l,s);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},vn),n.mapping.delete(t),null}},xK=(t,e,n,r,i,o)=>{const s=[],a=t.toDelta(r,i,o);try{for(let l=0;l<a.length;l++){const c=a[l];s.push(e.text(c.insert,TK(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},vn),null}return s},_K=(t,e)=>{const n=new In,r=t.map(i=>({insert:i.text,attributes:NT(i.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},CK=(t,e)=>{const n=new bn(t.type.name);for(const r in t.attrs){const i=t.attrs[r];i!==null&&r!=="ychange"&&n.setAttribute(r,i)}return n.insert(0,og(t).map(r=>Cb(r,e))),e.mapping.set(n,t),n},Cb=(t,e)=>t instanceof Array?_K(t,e):CK(t,e),a2=t=>typeof t=="object"&&t!==null,Ey=(t,e)=>{const n=Object.keys(t).filter(i=>t[i]!==null);let r=n.length===(e==null?0:Object.keys(e).filter(i=>e[i]!==null).length);for(let i=0;i<n.length&&r;i++){const o=n[i],s=t[o],a=e[o];r=o==="ychange"||s===a||a2(s)&&a2(a)&&Ey(s,a)}return r},og=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const i=e[r];if(i.isText){const o=[];for(let s=e[r];r<e.length&&s.isText;s=e[++r])o.push(s);r--,n.push(o)}else n.push(i)}return n},RT=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,i)=>r.insert===e[i].text&&D3(r.attributes||{}).length===e[i].marks.length&&Vc(r.attributes,(o,s)=>{var c;const a=Ay(s),l=e[i].marks;return Ey(o,(c=l.find(d=>d.type.name===a))==null?void 0:c.attrs)}))},Sd=(t,e)=>{if(t instanceof bn&&!(e instanceof Array)&&Eb(t,e)){const n=og(e);return t._length===n.length&&Ey(t.getAttributes(),e.attrs)&&t.toArray().every((r,i)=>Sd(r,n[i]))}return t instanceof In&&e instanceof Array&&RT(t,e)},Dp=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),l2=(t,e,n)=>{const r=t.toArray(),i=og(e),o=i.length,s=r.length,a=ns(s,o);let l=0,c=0,d=!1;for(;l<a;l++){const f=r[l],h=i[l];if(Dp(n.mapping.get(f),h))d=!0;else if(!Sd(f,h))break}for(;l+c<a;c++){const f=r[s-c-1],h=i[o-c-1];if(Dp(n.mapping.get(f),h))d=!0;else if(!Sd(f,h))break}return{equalityFactor:l+c,foundMappedChild:d}},SK=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof $i?e+=n.content.str:n.content instanceof Rn&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},EK=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:i}=SK(t),o=e.map(c=>({insert:c.text,attributes:Object.assign({},r,NT(c.marks,n))})),{insert:s,remove:a,index:l}=sK(i,o.map(c=>c.insert).join(""));t.delete(l,a),t.insert(l,s),t.applyDelta(o.map(c=>({retain:c.insert.length,attributes:c.attributes})))},AK=/(.*)(--[a-zA-Z0-9+/=]{8})$/,Ay=t=>{var e;return((e=AK.exec(t))==null?void 0:e[1])??t},TK=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(Ay(r),t[r]));return n},NT=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const i=Ro(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[i?`${r.type.name}--${gK(r.toJSON())}`:r.type.name]=r.attrs}}),n},Sb=(t,e,n,r)=>{if(e instanceof bn&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof bn){const f=e.getAttributes(),h=n.attrs;for(const p in h)h[p]!==null?f[p]!==h[p]&&p!=="ychange"&&e.setAttribute(p,h[p]):e.removeAttribute(p);for(const p in f)h[p]===void 0&&e.removeAttribute(p)}const i=og(n),o=i.length,s=e.toArray(),a=s.length,l=ns(o,a);let c=0,d=0;for(;c<l;c++){const f=s[c],h=i[c];if(!Dp(r.mapping.get(f),h))if(Sd(f,h))r.mapping.set(f,h);else break}for(;d+c<l;d++){const f=s[a-d-1],h=i[o-d-1];if(!Dp(r.mapping.get(f),h))if(Sd(f,h))r.mapping.set(f,h);else break}t.transact(()=>{for(;a-c-d>0&&o-c-d>0;){const h=s[c],p=i[c],m=s[a-d-1],v=i[o-d-1];if(h instanceof In&&p instanceof Array)RT(h,p)||EK(h,p,r),c+=1;else{let g=h instanceof bn&&Eb(h,p),y=m instanceof bn&&Eb(m,v);if(g&&y){const C=l2(h,p,r),_=l2(m,v,r);C.foundMappedChild&&!_.foundMappedChild?y=!1:!C.foundMappedChild&&_.foundMappedChild||C.equalityFactor<_.equalityFactor?g=!1:y=!1}g?(Sb(t,h,p,r),c+=1):y?(Sb(t,m,v,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[Cb(p,r)]),c+=1)}}const f=a-c-d;if(a===1&&o===0&&s[0]instanceof In?(r.mapping.delete(s[0]),s[0].delete(0,s[0].length)):f>0&&(e.slice(c,c+f).forEach(h=>r.mapping.delete(h)),e.delete(c,f)),c+d<o){const h=[];for(let p=c;p<o-d;p++)h.push(Cb(i[p],r));e.insert(c,h)}},vn)},Eb=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let Fu=null;const MK=()=>{const t=Fu;Fu=null,t.forEach((e,n)=>{const r=n.state.tr,i=vn.getState(n.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((o,s)=>{r.setMeta(s,o)}),n.dispatch(r))})},DK=(t,e,n)=>{Fu||(Fu=new Map,F1(0,MK)),Ro(Fu,t,Ti).set(e,n)},Op=(t,e,n)=>{if(t===0)return $g(e,0,e.length===0?-1:0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof In){if(r._length>=t)return $g(r,t,e.length===0?-1:0);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<i)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&i>1)return new fd(r._item===null?null:r._item.id,r._item===null?ud(r):null,null);if(t-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new fd(r._item===null?null:r._item.id,r._item===null?ud(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw mr();if(t===0&&r.constructor!==In&&r!==e)return OK(r._item.parent,r._item)}return $g(e,e._length,e.length===0?-1:0)},OK=(t,e)=>{let n=null,r=null;return t._item===null?r=ud(t):n=_t(t._item.id.client,t._item.id.clock),new fd(n,r,e.id)},Yl=(t,e,n,r)=>{const i=Gv(n,t);if(i===null||i.type!==e&&!dd(e,i.type._item))return null;let o=i.type,s=0;if(o.constructor===In)s=i.index;else if(o._item===null||!o._item.deleted){let a=o._first,l=0;for(;l<o._length&&l<i.index&&a!==null;){if(!a.deleted){const c=a.content.type;l++,c instanceof In?s+=c._length:s+=r.get(c).nodeSize}a=a.right}s+=1}for(;o!==e&&o._item!==null;){const a=o._item.parent;if(a._item===null||!a._item.deleted){s+=1;let l=a._first;for(;l!==null;){const c=l.content.type;if(c===o)break;l.deleted||(c instanceof In?s+=c._length:s+=r.get(c).nodeSize),l=l.right}}o=a}return s-1};function IK(t){const e=t.toArray(),n=r=>{let i;if(r instanceof In)i=r.toDelta().map(s=>{const a={type:"text",text:s.insert};return s.attributes&&(a.marks=Object.keys(s.attributes).map(l=>{const c=s.attributes[l],f={type:Ay(l)};return Object.keys(c)&&(f.attrs=c),f})),a});else if(r instanceof bn){i={type:r.nodeName};const o=r.getAttributes();Object.keys(o).length&&(i.attrs=o);const s=r.toArray();s.length&&(i.content=s.map(n).flat())}else mr();return i};return{type:"doc",content:e.map(n)}}const RK=(t,e,n)=>t!==e,NK=t=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null);const r=document.createTextNode("⁠"),i=document.createTextNode("⁠");return e.insertBefore(r,null),e.insertBefore(n,null),e.insertBefore(i,null),e},PT=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),PK=/^#[0-9a-fA-F]{6}$/,c2=(t,e,n,r,i)=>{const o=vn.getState(t),s=o.doc,a=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?vt.create(t.doc,[]):(e.getStates().forEach((l,c)=>{if(n(s.clientID,c,l)&&l.cursor!=null){const d=l.user||{};d.color==null?d.color="#ffa500":PK.test(d.color)||console.warn("A user uses an unsupported color format",d),d.name==null&&(d.name=`User: ${c}`);let f=Yl(s,o.type,Ha(l.cursor.anchor),o.binding.mapping),h=Yl(s,o.type,Ha(l.cursor.head),o.binding.mapping);if(f!==null&&h!==null){const p=Xi(t.doc.content.size-1,0);f=ns(f,p),h=ns(h,p),a.push(tn.widget(h,()=>r(d,c),{key:c+"",side:10}));const m=ns(f,h),v=Xi(f,h);a.push(tn.inline(m,v,i(d,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),vt.create(t.doc,a))},LK=(t,{awarenessStateFilter:e=RK,cursorBuilder:n=NK,selectionBuilder:r=PT,getSelection:i=s=>s.selection}={},o="cursor")=>new Vt({key:jf,state:{init(s,a){return c2(a,t,e,n,r)},apply(s,a,l,c){const d=vn.getState(c),f=s.getMeta(jf);return d&&d.isChangeOrigin||f&&f.awarenessUpdated?c2(c,t,e,n,r):a.map(s.mapping,s.doc)}},props:{decorations:s=>jf.getState(s)},view:s=>{const a=()=>{s.docView&&DK(s,jf,{awarenessUpdated:!0})},l=()=>{const c=vn.getState(s.state),d=t.getLocalState()||{};if(s.hasFocus()){const f=i(s.state),h=Op(f.anchor,c.type,c.binding.mapping),p=Op(f.head,c.type,c.binding.mapping);(d.cursor==null||!Wk(Ha(d.cursor.anchor),h)||!Wk(Ha(d.cursor.head),p))&&t.setLocalStateField(o,{anchor:h,head:p})}else d.cursor!=null&&Yl(c.doc,c.type,Ha(d.cursor.anchor),c.binding.mapping)!==null&&t.setLocalStateField(o,null)};return t.on("change",a),s.dom.addEventListener("focusin",l),s.dom.addEventListener("focusout",l),{update:l,destroy:()=>{s.dom.removeEventListener("focusin",l),s.dom.removeEventListener("focusout",l),t.off("change",a),t.setLocalStateField(o,null)}}}}),FK=t=>{var e,n;return((n=(e=Co.getState(t))==null?void 0:e.undoManager)==null?void 0:n.undo())!=null},zK=t=>{var e,n;return((n=(e=Co.getState(t))==null?void 0:e.undoManager)==null?void 0:n.redo())!=null},BK=new Set(["paragraph"]),HK=(t,e)=>!(t instanceof ln)||!(t.content instanceof no)||!(t.content.type instanceof ta||t.content.type instanceof bn&&e.has(t.content.type.nodeName))||t.content.type._length===0,VK=({protectedNodes:t=BK,trackedOrigins:e=[],undoManager:n=null}={})=>new Vt({key:Co,state:{init:(r,i)=>{const o=vn.getState(i),s=n||new yE(o.type,{trackedOrigins:new Set([vn].concat(e)),deleteFilter:a=>HK(a,t),captureTransaction:a=>a.meta.get("addToHistory")!==!1});return{undoManager:s,prevSel:null,hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0}},apply:(r,i,o,s)=>{const a=vn.getState(s).binding,l=i.undoManager,c=l.undoStack.length>0,d=l.redoStack.length>0;return a?{undoManager:l,prevSel:_b(a,o),hasUndoOps:c,hasRedoOps:d}:c!==i.hasUndoOps||d!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):i}},view:r=>{const i=vn.getState(r.state),o=Co.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:s})=>{const a=i.binding;a&&s.meta.set(a,Co.getState(r.state).prevSel)}),o.on("stack-item-popped",({stackItem:s})=>{const a=i.binding;a&&(a.beforeTransactionSelection=s.meta.get(a)||a.beforeTransactionSelection)}),{destroy:()=>{o.destroy()}}}}),UK=sn.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="history")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Co.getState(e).undoManager.undoStack.length===0?!1:n?FK(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Co.getState(e).undoManager.redoStack.length===0?!1:n?zK(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=VK(this.options.yUndoOptions),r=n.spec.view;n.spec.view=s=>{const{undoManager:a}=Co.getState(s.state);a.restore&&(a.restore(),a.restore=()=>{});const l=r?r(s):void 0;return{destroy:()=>{const c=a.trackedOrigins.has(a),d=a._observers;a.restore=()=>{c&&a.trackedOrigins.add(a),a.doc.on("afterTransaction",a.afterTransactionHandler),a._observers=d},l!=null&&l.destroy&&l.destroy()}}};const i={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=yK(e,i);return this.editor.options.enableContentCheck&&((t=e.doc)===null||t===void 0||t.on("beforeTransaction",()=>{try{const s=IK(e);if(s.content.length===0)return;this.editor.schema.nodeFromJSON(s).check()}catch(s){return this.editor.emit("contentError",{error:s,editor:this.editor,disableCollaboration:()=>{var a;(a=e.doc)===null||a===void 0||a.destroy(),this.storage.isDisabled=!0}}),!1}})),[o,n,this.editor.options.enableContentCheck&&new Vt({key:new Yt("filterInvalidContent"),filterTransaction:()=>{var s;return this.storage.isDisabled&&((s=e.doc)===null||s===void 0||s.destroy()),!0}})].filter(Boolean)}}),u2=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n.user})),d2=()=>null,jK=sn.create({name:"collaborationCursor",priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:t=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");return n.classList.add("collaboration-cursor__label"),n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null),e.insertBefore(n,null),e},selectionRender:PT,onUpdate:d2}},onCreate(){if(this.options.onUpdate!==d2&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),!this.options.provider)throw new Error('The "provider" option is required for the CollaborationCursor extension')},addStorage(){return{users:[]}},addCommands(){return{updateUser:t=>()=>(this.options.user=t,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:t=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),e.commands.updateUser(t))}},addProseMirrorPlugins(){return[LK((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=u2(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=u2(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),qK=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,WK=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,KK=eo.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",pn(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[rl({find:qK,type:this.type})]},addPasteRules(){return[ia({find:WK,type:this.type})]}}),GK=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,ZK=wr.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",pn(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[OT({find:GK,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),YK="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",JK="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Ab="numeric",Tb="ascii",Mb="alpha",zu="asciinumeric",xu="alphanumeric",Db="domain",LT="emoji",XK="scheme",QK="slashscheme",x0="whitespace";function $K(t,e){return t in e||(e[t]=[]),e[t]}function Aa(t,e,n){e[Ab]&&(e[zu]=!0,e[xu]=!0),e[Tb]&&(e[zu]=!0,e[Mb]=!0),e[zu]&&(e[xu]=!0),e[Mb]&&(e[xu]=!0),e[xu]&&(e[Db]=!0),e[LT]&&(e[Db]=!0);for(const r in e){const i=$K(r,n);i.indexOf(t)<0&&i.push(t)}}function eG(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function zr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}zr.groups={};zr.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],o=e.jr[r][1];if(o&&i.test(t))return o}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||zr.groups;let i;return e&&e.j?i=e:(i=new zr(e),n&&r&&Aa(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const o=t.length;if(!o)return i;for(let s=0;s<o-1;s++)i=i.tt(t[s]);return i.tt(t[o-1],e,n,r)},tt(t,e,n,r){r=r||zr.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const o=e;let s,a=i.go(t);if(a?(s=new zr,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new zr,o){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(eG(s.t,r),n);Aa(o,l,r)}else n&&Aa(o,n,r);s.t=o}return i.j[t]=s,s}};const Et=(t,e,n,r,i)=>t.ta(e,n,r,i),yn=(t,e,n,r,i)=>t.tr(e,n,r,i),f2=(t,e,n,r,i)=>t.ts(e,n,r,i),Be=(t,e,n,r,i)=>t.tt(e,n,r,i),jo="WORD",Ob="UWORD",FT="ASCIINUMERICAL",zT="ALPHANUMERICAL",Ed="LOCALHOST",Ib="TLD",Rb="UTLD",Oh="SCHEME",Dl="SLASH_SCHEME",Ty="NUM",Nb="WS",My="NL",Bu="OPENBRACE",Hu="CLOSEBRACE",Ip="OPENBRACKET",Rp="CLOSEBRACKET",Np="OPENPAREN",Pp="CLOSEPAREN",Lp="OPENANGLEBRACKET",Fp="CLOSEANGLEBRACKET",zp="FULLWIDTHLEFTPAREN",Bp="FULLWIDTHRIGHTPAREN",Hp="LEFTCORNERBRACKET",Vp="RIGHTCORNERBRACKET",Up="LEFTWHITECORNERBRACKET",jp="RIGHTWHITECORNERBRACKET",qp="FULLWIDTHLESSTHAN",Wp="FULLWIDTHGREATERTHAN",Kp="AMPERSAND",Gp="APOSTROPHE",Zp="ASTERISK",Ss="AT",Yp="BACKSLASH",Jp="BACKTICK",Xp="CARET",Ds="COLON",Dy="COMMA",Qp="DOLLAR",uo="DOT",$p="EQUALS",Oy="EXCLAMATION",hi="HYPHEN",Vu="PERCENT",em="PIPE",tm="PLUS",nm="POUND",Uu="QUERY",Iy="QUOTE",BT="FULLWIDTHMIDDLEDOT",Ry="SEMI",fo="SLASH",ju="TILDE",rm="UNDERSCORE",HT="EMOJI",im="SYM";var VT=Object.freeze({__proto__:null,ALPHANUMERICAL:zT,AMPERSAND:Kp,APOSTROPHE:Gp,ASCIINUMERICAL:FT,ASTERISK:Zp,AT:Ss,BACKSLASH:Yp,BACKTICK:Jp,CARET:Xp,CLOSEANGLEBRACKET:Fp,CLOSEBRACE:Hu,CLOSEBRACKET:Rp,CLOSEPAREN:Pp,COLON:Ds,COMMA:Dy,DOLLAR:Qp,DOT:uo,EMOJI:HT,EQUALS:$p,EXCLAMATION:Oy,FULLWIDTHGREATERTHAN:Wp,FULLWIDTHLEFTPAREN:zp,FULLWIDTHLESSTHAN:qp,FULLWIDTHMIDDLEDOT:BT,FULLWIDTHRIGHTPAREN:Bp,HYPHEN:hi,LEFTCORNERBRACKET:Hp,LEFTWHITECORNERBRACKET:Up,LOCALHOST:Ed,NL:My,NUM:Ty,OPENANGLEBRACKET:Lp,OPENBRACE:Bu,OPENBRACKET:Ip,OPENPAREN:Np,PERCENT:Vu,PIPE:em,PLUS:tm,POUND:nm,QUERY:Uu,QUOTE:Iy,RIGHTCORNERBRACKET:Vp,RIGHTWHITECORNERBRACKET:jp,SCHEME:Oh,SEMI:Ry,SLASH:fo,SLASH_SCHEME:Dl,SYM:im,TILDE:ju,TLD:Ib,UNDERSCORE:rm,UTLD:Rb,UWORD:Ob,WORD:jo,WS:Nb});const Ho=/[a-z]/,au=new RegExp("\\p{L}","u"),_0=new RegExp("\\p{Emoji}","u"),Vo=/\d/,C0=/\s/,h2="\r",S0=`
211
+ `,tG="️",nG="‍",E0="";let qf=null,Wf=null;function rG(t=[]){const e={};zr.groups=e;const n=new zr;qf==null&&(qf=p2(YK)),Wf==null&&(Wf=p2(JK)),Be(n,"'",Gp),Be(n,"{",Bu),Be(n,"}",Hu),Be(n,"[",Ip),Be(n,"]",Rp),Be(n,"(",Np),Be(n,")",Pp),Be(n,"<",Lp),Be(n,">",Fp),Be(n,"(",zp),Be(n,")",Bp),Be(n,"「",Hp),Be(n,"」",Vp),Be(n,"『",Up),Be(n,"』",jp),Be(n,"<",qp),Be(n,">",Wp),Be(n,"&",Kp),Be(n,"*",Zp),Be(n,"@",Ss),Be(n,"`",Jp),Be(n,"^",Xp),Be(n,":",Ds),Be(n,",",Dy),Be(n,"$",Qp),Be(n,".",uo),Be(n,"=",$p),Be(n,"!",Oy),Be(n,"-",hi),Be(n,"%",Vu),Be(n,"|",em),Be(n,"+",tm),Be(n,"#",nm),Be(n,"?",Uu),Be(n,'"',Iy),Be(n,"/",fo),Be(n,";",Ry),Be(n,"~",ju),Be(n,"_",rm),Be(n,"\\",Yp),Be(n,"・",BT);const r=yn(n,Vo,Ty,{[Ab]:!0});yn(r,Vo,r);const i=yn(r,Ho,FT,{[zu]:!0}),o=yn(r,au,zT,{[xu]:!0}),s=yn(n,Ho,jo,{[Tb]:!0});yn(s,Vo,i),yn(s,Ho,s),yn(i,Vo,i),yn(i,Ho,i);const a=yn(n,au,Ob,{[Mb]:!0});yn(a,Ho),yn(a,Vo,o),yn(a,au,a),yn(o,Vo,o),yn(o,Ho),yn(o,au,o);const l=Be(n,S0,My,{[x0]:!0}),c=Be(n,h2,Nb,{[x0]:!0}),d=yn(n,C0,Nb,{[x0]:!0});Be(n,E0,d),Be(c,S0,l),Be(c,E0,d),yn(c,C0,d),Be(d,h2),Be(d,S0),yn(d,C0,d),Be(d,E0,d);const f=yn(n,_0,HT,{[LT]:!0});Be(f,"#"),yn(f,_0,f),Be(f,tG,f);const h=Be(f,nG);Be(h,"#"),yn(h,_0,f);const p=[[Ho,s],[Vo,i]],m=[[Ho,null],[au,a],[Vo,o]];for(let v=0;v<qf.length;v++)ws(n,qf[v],Ib,jo,p);for(let v=0;v<Wf.length;v++)ws(n,Wf[v],Rb,Ob,m);Aa(Ib,{tld:!0,ascii:!0},e),Aa(Rb,{utld:!0,alpha:!0},e),ws(n,"file",Oh,jo,p),ws(n,"mailto",Oh,jo,p),ws(n,"http",Dl,jo,p),ws(n,"https",Dl,jo,p),ws(n,"ftp",Dl,jo,p),ws(n,"ftps",Dl,jo,p),Aa(Oh,{scheme:!0,ascii:!0},e),Aa(Dl,{slashscheme:!0,ascii:!0},e),t=t.sort((v,g)=>v[0]>g[0]?1:-1);for(let v=0;v<t.length;v++){const g=t[v][0],C=t[v][1]?{[XK]:!0}:{[QK]:!0};g.indexOf("-")>=0?C[Db]=!0:Ho.test(g)?Vo.test(g)?C[zu]=!0:C[Tb]=!0:C[Ab]=!0,f2(n,g,g,C)}return f2(n,"localhost",Ed,{ascii:!0}),n.jd=new zr(im),{start:n,tokens:Object.assign({groups:e},VT)}}function UT(t,e){const n=iG(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,i=[];let o=0,s=0;for(;s<r;){let a=t,l=null,c=0,d=null,f=-1,h=-1;for(;s<r&&(l=a.go(n[s]));)a=l,a.accepts()?(f=0,h=0,d=a):f>=0&&(f+=n[s].length,h++),c+=n[s].length,o+=n[s].length,s++;o-=f,s-=h,c-=f,i.push({t:d.t,v:e.slice(o-c,o),s:o-c,e:o})}return i}function iG(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),o,s=i<55296||i>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function ws(t,e,n,r,i){let o;const s=e.length;for(let a=0;a<s-1;a++){const l=e[a];t.j[l]?o=t.j[l]:(o=new zr(r),o.jr=i.slice(),t.j[l]=o),t=o}return o=new zr(n),o.jr=i.slice(),t.j[e[s-1]]=o,o}function p2(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let o=0;for(;i.indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+o),10);s>0;s--)n.pop();r+=o}else n.push(t[r]),r++}return e}const Ad={defaultProtocol:"http",events:null,format:m2,formatHref:m2,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ny(t,e=null){let n=Object.assign({},Ad);t&&(n=Object.assign(n,t instanceof Ny?t.o:t));const r=n.ignoreTags,i=[];for(let o=0;o<r.length;o++)i.push(r[o].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}Ny.prototype={o:Ad,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:Ad[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function m2(t){return t}function jT(t,e){this.t="token",this.v=t,this.tk=e}jT.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Ad.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),o=this.toFormattedString(t),s={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:i,attributes:s,content:o,eventListeners:f}}};function sg(t,e){class n extends jT{constructor(i,o){super(i,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const g2=sg("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),v2=sg("text"),oG=sg("nl"),Kf=sg("url",{isLink:!0,toHref(t=Ad.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ed&&t[1].t===Ds}}),di=t=>new zr(t);function sG({groups:t}){const e=t.domain.concat([Kp,Zp,Ss,Yp,Jp,Xp,Qp,$p,hi,Ty,Vu,em,tm,nm,fo,im,ju,rm]),n=[Gp,Ds,Dy,uo,Oy,Vu,Uu,Iy,Ry,Lp,Fp,Bu,Hu,Rp,Ip,Np,Pp,zp,Bp,Hp,Vp,Up,jp,qp,Wp],r=[Kp,Gp,Zp,Yp,Jp,Xp,Qp,$p,hi,Bu,Hu,Vu,em,tm,nm,Uu,fo,im,ju,rm],i=di(),o=Be(i,ju);Et(o,r,o),Et(o,t.domain,o);const s=di(),a=di(),l=di();Et(i,t.domain,s),Et(i,t.scheme,a),Et(i,t.slashscheme,l),Et(s,r,o),Et(s,t.domain,s);const c=Be(s,Ss);Be(o,Ss,c),Be(a,Ss,c),Be(l,Ss,c);const d=Be(o,uo);Et(d,r,o),Et(d,t.domain,o);const f=di();Et(c,t.domain,f),Et(f,t.domain,f);const h=Be(f,uo);Et(h,t.domain,f);const p=di(g2);Et(h,t.tld,p),Et(h,t.utld,p),Be(c,Ed,p);const m=Be(f,hi);Be(m,hi,m),Et(m,t.domain,f),Et(p,t.domain,f),Be(p,uo,h),Be(p,hi,m);const v=Be(p,Ds);Et(v,t.numeric,g2);const g=Be(s,hi),y=Be(s,uo);Be(g,hi,g),Et(g,t.domain,s),Et(y,r,o),Et(y,t.domain,s);const C=di(Kf);Et(y,t.tld,C),Et(y,t.utld,C),Et(C,t.domain,s),Et(C,r,o),Be(C,uo,y),Be(C,hi,g),Be(C,Ss,c);const _=Be(C,Ds),S=di(Kf);Et(_,t.numeric,S);const A=di(Kf),O=di();Et(A,e,A),Et(A,n,O),Et(O,e,A),Et(O,n,O),Be(C,fo,A),Be(S,fo,A);const E=Be(a,Ds),M=Be(l,Ds),R=Be(M,fo),D=Be(R,fo);Et(a,t.domain,s),Be(a,uo,y),Be(a,hi,g),Et(l,t.domain,s),Be(l,uo,y),Be(l,hi,g),Et(E,t.domain,A),Be(E,fo,A),Be(E,Uu,A),Et(D,t.domain,A),Et(D,e,A),Be(D,fo,A);const I=[[Bu,Hu],[Ip,Rp],[Np,Pp],[Lp,Fp],[zp,Bp],[Hp,Vp],[Up,jp],[qp,Wp]];for(let H=0;H<I.length;H++){const[z,Q]=I[H],ie=Be(A,z);Be(O,z,ie),Be(ie,Q,A);const me=di(Kf);Et(ie,e,me);const le=di();Et(ie,n),Et(me,e,me),Et(me,n,le),Et(le,e,me),Et(le,n,le),Be(me,Q,A),Be(le,Q,A)}return Be(i,Ed,C),Be(i,My,oG),{start:i,tokens:VT}}function aG(t,e,n){let r=n.length,i=0,o=[],s=[];for(;i<r;){let a=t,l=null,c=null,d=0,f=null,h=-1;for(;i<r&&!(l=a.go(n[i].t));)s.push(n[i++]);for(;i<r&&(c=l||a.go(n[i].t));)l=null,a=c,a.accepts()?(h=0,f=a):h>=0&&h++,i++,d++;if(h<0)i-=d,i<r&&(s.push(n[i]),i++);else{s.length>0&&(o.push(A0(v2,e,s)),s=[]),i-=h,d-=h;const p=f.t,m=n.slice(i-d,i);o.push(A0(p,e,m))}}return s.length>0&&o.push(A0(v2,e,s)),o}function A0(t,e,n){const r=n[0].s,i=n[n.length-1].e,o=e.slice(r,i);return new t(o,n)}const lG=typeof console<"u"&&console&&console.warn||(()=>{}),cG="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",dn={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function uG(){return zr.groups={},dn.scanner=null,dn.parser=null,dn.tokenQueue=[],dn.pluginQueue=[],dn.customSchemes=[],dn.initialized=!1,dn}function b2(t,e=!1){if(dn.initialized&&lG(`linkifyjs: already initialized - will not register custom scheme "${t}" ${cG}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
212
+ 1. Must only contain digits, lowercase ASCII letters or "-"
213
+ 2. Cannot start or end with "-"
214
+ 3. "-" cannot repeat`);dn.customSchemes.push([t,e])}function dG(){dn.scanner=rG(dn.customSchemes);for(let t=0;t<dn.tokenQueue.length;t++)dn.tokenQueue[t][1]({scanner:dn.scanner});dn.parser=sG(dn.scanner.tokens);for(let t=0;t<dn.pluginQueue.length;t++)dn.pluginQueue[t][1]({scanner:dn.scanner,parser:dn.parser});return dn.initialized=!0,dn}function Py(t){return dn.initialized||dG(),aG(dn.parser.start,t,UT(dn.scanner.start,t))}Py.scan=UT;function qT(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Ny(n),i=Py(t),o=[];for(let s=0;s<i.length;s++){const a=i[s];a.isLink&&(!e||a.t===e)&&r.check(a)&&o.push(a.toFormattedObject(r))}return o}const Ly="[\0-   ᠎ -\u2029  ]",fG=new RegExp(Ly),hG=new RegExp(`${Ly}$`),pG=new RegExp(Ly,"g");function mG(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function gG(t){return new Vt({key:new Yt("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!i||o)return;const{tr:s}=r,a=pW(n.doc,[...e]);if(kW(a).forEach(({newRange:c})=>{const d=gW(r.doc,c,p=>p.isTextblock);let f,h;if(d.length>1)f=d[0],h=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(c.from,c.to," "," ");if(!hG.test(p))return;f=d[0],h=r.doc.textBetween(f.pos,c.to,void 0," ")}if(f&&h){const p=h.split(fG).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],v=f.pos+h.lastIndexOf(m);if(!m)return!1;const g=Py(m).map(y=>y.toObject(t.defaultProtocol));if(!mG(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:v+y.start+1,to:v+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{Sy(y.from,y.to,r.doc).some(C=>C.mark.type===t.type)||s.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function vG(t){return new Vt({key:new Yt("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let s=r.target;const a=[];for(;s.nodeName!=="DIV";)a.push(s),s=s.parentNode;if(!a.find(h=>h.nodeName==="A"))return!1;const l=DT(e.state,t.type.name),c=r.target,d=(i=c==null?void 0:c.href)!==null&&i!==void 0?i:l.href,f=(o=c==null?void 0:c.target)!==null&&o!==void 0?o:l.target;return c&&d?(window.open(d,f),!0):!1}}})}function bG(t){return new Vt({key:new Yt("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:i}=e,{selection:o}=i,{empty:s}=o;if(s)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=qT(a,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!l?!1:t.editor.commands.setMark(t.type,{href:l.href})}}})}function pa(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(pG,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const yG=eo.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){b2(t);return}b2(t.scheme,t.optionalSlashes)})},onDestroy(){uG()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!pa(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!pa(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!pa(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",pn(this.options.HTMLAttributes,t),0]:["a",pn(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!pa(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!pa(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[ia({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=qT(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!pa(s,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(gG({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!pa(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(vG({type:this.type})),this.options.linkOnPaste&&t.push(bG({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),wG=sn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Vt({key:new Yt("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const o=this.editor.isEmpty;return t.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,c=!s.isLeaf&&ig(s);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const f=tn.node(a,a+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),vt.create(t,i)}}})]}});let Pb,Lb;if(typeof WeakMap<"u"){let t=new WeakMap;Pb=e=>t.get(e),Lb=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Pb=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},Lb=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var _n=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,i=e/this.width|0;let o=r+1,s=i+1;for(let a=1;o<this.width&&this.map[e+a]==n;a++)o++;for(let a=1;s<this.height&&this.map[e+this.width*a]==n;a++)s++;return{left:r,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:i,top:o,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:s==this.height)?null:this.map[r+this.width*(n<0?o-1:s)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:o}=this.findCell(t),{left:s,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(i,l),right:Math.max(r,a),bottom:Math.max(o,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const o=r*this.width+i,s=this.map[o];n[s]||(n[s]=!0,!(i==t.left&&i&&this.map[o-1]==s||r==t.top&&r&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const a=(t+1)*this.width;for(;s<a&&this.map[s]<i;)s++;return s==a?o-1:this.map[s]}i=o}}static get(t){return Pb(t)||Lb(t,kG(t))}};function kG(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=xG(t),n=t.childCount,r=[];let i=0,o=null;const s=[];for(let c=0,d=e*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){const f=t.child(c);d++;for(let m=0;;m++){for(;i<r.length&&r[i]!=0;)i++;if(m==f.childCount)break;const v=f.child(m),{colspan:g,rowspan:y,colwidth:C}=v.attrs;for(let _=0;_<y;_++){if(_+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:y-_});break}const S=i+_*e;for(let A=0;A<g;A++){r[S+A]==0?r[S+A]=d:(o||(o=[])).push({type:"collision",row:c,pos:d,n:g-A});const O=C&&C[A];if(O){const E=(S+A)%e*2,M=s[E];M==null||M!=O&&s[E+1]==1?(s[E]=O,s[E+1]=1):M==O&&s[E+1]++}}}i+=g,d+=v.nodeSize}const h=(c+1)*e;let p=0;for(;i<h;)r[i++]==0&&p++;p&&(o||(o=[])).push({type:"missing",row:c,n:p}),d++}(e===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new _n(e,n,r,o);let l=!1;for(let c=0;!l&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(l=!0);return l&&_G(a,s,t),a}function xG(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let o=0;if(n)for(let s=0;s<r;s++){const a=t.child(s);for(let l=0;l<a.childCount;l++){const c=a.child(l);s+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const a=i.child(s);o+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function _G(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const o=t.map[i];if(r[o])continue;r[o]=!0;const s=n.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let a=null;const l=s.attrs;for(let c=0;c<l.colspan;c++){const d=e[(i+c)%t.width*2];d!=null&&(!l.colwidth||l.colwidth[c]!=d)&&((a||(a=CG(l)))[c]=d)}a&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function CG(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function vr(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Os=new Yt("selectingCells");function il(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function SG(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function ro(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ag(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=il(e.$head)||EG(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function EG(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Fb(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function AG(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Fy(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function WT(t,e,n){const r=t.node(-1),i=_n.get(r),o=t.start(-1),s=i.nextCell(t.pos-o,e,n);return s==null?null:t.node(0).resolve(o+s)}function ol(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function KT(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function TG(t,e,n){const r=vr(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}var un=class qo extends gt{constructor(e,n=e){const r=e.node(-1),i=_n.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,n.pos-o),a=e.node(0),l=i.cellsInRect(s).filter(d=>d!=n.pos-o);l.unshift(n.pos-o);const c=l.map(d=>{const f=r.nodeAt(d);if(!f)throw new RangeError(`No cell with offset ${d} found`);const h=o+d+1;return new a3(a.resolve(h),a.resolve(h+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(Fb(r)&&Fb(i)&&Fy(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?qo.rowSelection(r,i):o&&this.isColSelection()?qo.colSelection(r,i):new qo(r,i)}return ut.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=_n.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let d=l*n.width+i.left,f=i.left;f<i.right;f++,d++){const h=n.map[d];if(o[h])continue;o[h]=!0;const p=n.findCell(h);let m=e.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const v=i.left-p.left,g=p.right-i.right;if(v>0||g>0){let y=m.attrs;if(v>0&&(y=ol(y,0,v)),g>0&&(y=ol(y,y.colspan-g,g)),p.left<i.left){if(m=m.type.createAndFill(y),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else m=m.type.create(y,m.content)}if(p.top<i.top||p.bottom>i.bottom){const y={...m.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top<i.top?m=m.type.createAndFill(y):m=m.type.create(y,m.content)}c.push(m)}s.push(e.child(l).copy(Ce.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Ge(Ce.from(a),1,1)}replace(e,n=Ge.empty){const r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:a,$to:l}=i[s],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),s?Ge.empty:n)}const o=gt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new Ge(Ce.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=_n.get(n),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(n.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=_n.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(n.pos-o),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(n=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(e=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new qo(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=_n.get(e),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==n.width}eq(e){return e instanceof qo&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=_n.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(n.pos-o),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(n=l.resolve(o+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(e=l.resolve(o+i.map[i.width*(s.top+1)-1]))),new qo(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new qo(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new qo(e.resolve(n),e.resolve(r))}getBookmark(){return new MG(this.$anchorCell.pos,this.$headCell.pos)}};un.prototype.visible=!1;gt.jsonID("cell",un);var MG=class GT{constructor(e,n){this.anchor=e,this.head=n}map(e){return new GT(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Fy(n,r)?new un(n,r):gt.near(r,1)}};function DG(t){if(!(t.selection instanceof un))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(tn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),vt.create(t.doc,e)}function OG({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function IG({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function RG(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,s;if(r instanceof ft&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=un.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=un.rowSelection(a,a)}else if(!n){const a=_n.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];o=un.create(i,l+1,c)}}else r instanceof ut&&OG(r)?o=ut.create(i,r.from):r instanceof ut&&IG(r)&&(o=ut.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}const NG=new Yt("fix-tables");function ZT(t,e,n,r){const i=t.childCount,o=e.childCount;e:for(let s=0,a=0;s<o;s++){const l=e.child(s);for(let c=a,d=Math.min(i,s+3);c<d;c++)if(t.child(c)==l){a=c+1,n+=l.nodeSize;continue e}r(l,n),a<i&&t.child(a).sameMarkup(l)?ZT(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function YT(t,e){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=PG(t,i,o,n))};return e?e.doc!=t.doc&&ZT(e.doc,t.doc,0,r):t.doc.descendants(r),n}function PG(t,e,n,r){const i=_n.get(e);if(!i.problems)return r;r||(r=t.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const f=d.attrs;for(let h=0;h<f.rowspan;h++)o[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,ol(f,f.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+e.nodeSize)}}let s,a;for(let l=0;l<o.length;l++)o[l]&&(s==null&&(s=l),a=l);for(let l=0,c=n+1;l<i.height;l++){const d=e.child(l),f=c+d.nodeSize,h=o[l];if(h>0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);const m=[];for(let g=0;g<h;g++){const y=vr(t.schema)[p].createAndFill();y&&m.push(y)}const v=(l==0||s==l-1)&&a==l?c+1:f-1;r.insert(r.mapping.map(v),m)}c=f}return r.setMeta(NG,{fixTables:!0})}function Po(t){const e=t.selection,n=ag(t),r=n.node(-1),i=n.start(-1),o=_n.get(r);return{...e instanceof un?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function JT(t,{map:e,tableStart:n,table:r},i){let o=i>0?-1:0;TG(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+i;if(i>0&&i<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],c=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,KT(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?vr(r.type.schema).cell:r.nodeAt(e.map[a+o]).type,c=e.positionAt(s,i,r);t.insert(t.mapping.map(n+c),l.createAndFill())}}return t}function LG(t,e){if(!ro(t))return!1;if(e){const n=Po(t);e(JT(t.tr,n,n.left))}return!0}function FG(t,e){if(!ro(t))return!1;if(e){const n=Po(t);e(JT(t.tr,n,n.right))}return!0}function zG(t,{map:e,table:n,tableStart:r},i){const o=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+i,l=e.map[a],c=n.nodeAt(l),d=c.attrs;if(i>0&&e.map[a-1]==l||i<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(o).map(r+l),null,ol(d,i-e.colCount(l)));else{const f=t.mapping.slice(o).map(r+l);t.delete(f,f+c.nodeSize)}s+=d.rowspan}}function BG(t,e){if(!ro(t))return!1;if(e){const n=Po(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;zG(r,n,i),i!=n.left;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=_n.get(o)}e(r)}return!0}function HG(t,e,n){var r;const i=vr(e.type.schema).header_cell;for(let o=0;o<t.width;o++)if(((r=e.nodeAt(t.map[o+n*t.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function XT(t,{map:e,tableStart:n,table:r},i){let o=n;for(let c=0;c<i;c++)o+=r.child(c).nodeSize;const s=[];let a=i>0?-1:0;HG(e,r,i+a)&&(a=i==0||i==e.height?null:0);for(let c=0,d=e.width*i;c<e.width;c++,d++)if(i>0&&i<e.height&&e.map[d]==e.map[d-e.width]){const f=e.map[d],h=r.nodeAt(f).attrs;t.setNodeMarkup(n+f,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var l;const f=a==null?vr(r.type.schema).cell:(l=r.nodeAt(e.map[d+a*e.width]))===null||l===void 0?void 0:l.type,h=f==null?void 0:f.createAndFill();h&&s.push(h)}return t.insert(o,vr(r.type.schema).row.create(null,s)),t}function VG(t,e){if(!ro(t))return!1;if(e){const n=Po(t);e(XT(t.tr,n,n.top))}return!0}function UG(t,e){if(!ro(t))return!1;if(e){const n=Po(t);e(XT(t.tr,n,n.bottom))}return!0}function jG(t,{map:e,table:n,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;const s=o+n.child(i).nodeSize,a=t.mapping.maps.length;t.delete(o+r,s+r);const l=new Set;for(let c=0,d=i*e.width;c<e.width;c++,d++){const f=e.map[d];if(!l.has(f)){if(l.add(f),i>0&&f==e.map[d-e.width]){const h=n.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(a).map(f+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<e.height&&f==e.map[d+e.width]){const h=n.nodeAt(f),p=h.attrs,m=h.type.create({...p,rowspan:h.attrs.rowspan-1},h.content),v=e.positionAt(i+1,c,n);t.insert(t.mapping.slice(a).map(r+v),m),c+=p.colspan-1}}}}function qG(t,e){if(!ro(t))return!1;if(e){const n=Po(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;jG(r,n,i),i!=n.top;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=_n.get(n.table)}e(r)}return!0}function y2(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function WG({width:t,height:e,map:n},r){let i=r.top*t+r.left,o=i,s=(r.bottom-1)*t+r.left,a=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[o]==n[o-1]||r.right<t&&n[a]==n[a+1])return!0;o+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[s]==n[s+t])return!0;i++,s++}return!1}function w2(t,e){const n=t.selection;if(!(n instanceof un)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Po(t),{map:i}=r;if(WG(i,r))return!1;if(e){const o=t.tr,s={};let a=Ce.empty,l,c;for(let d=r.top;d<r.bottom;d++)for(let f=r.left;f<r.right;f++){const h=i.map[d*i.width+f],p=r.table.nodeAt(h);if(!(s[h]||!p))if(s[h]=!0,l==null)l=h,c=p;else{y2(p)||(a=a.append(p.content));const m=o.mapping.map(h+r.tableStart);o.delete(m,m+p.nodeSize)}}if(l==null||c==null)return!0;if(o.setNodeMarkup(l+r.tableStart,null,{...KT(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const d=l+1+c.content.size,f=y2(c)?l+1:d;o.replaceWith(f+r.tableStart,d+r.tableStart,a)}o.setSelection(new un(o.doc.resolve(l+r.tableStart))),e(o)}return!0}function k2(t,e){const n=vr(t.schema);return KG(({node:r})=>n[r.type.spec.tableRole])(t,e)}function KG(t){return(e,n)=>{const r=e.selection;let i,o;if(r instanceof un){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var s;if(i=SG(r.$from),!i)return!1;o=(s=il(r.$from))===null||s===void 0?void 0:s.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let a=i.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const d=Po(e),f=e.tr;for(let p=0;p<d.right-d.left;p++)l.push(c?{...a,colwidth:c&&c[p]?[c[p]]:null}:a);let h;for(let p=d.top;p<d.bottom;p++){let m=d.map.positionAt(p,d.left,d.table);p==d.top&&(m+=i.nodeSize);for(let v=d.left,g=0;v<d.right;v++,g++)v==d.left&&p==d.top||f.insert(h=f.mapping.map(m+d.tableStart,1),t({node:i,row:p,col:v}).createAndFill(l[g]))}f.setNodeMarkup(o,t({node:i,row:d.top,col:d.left}),l[0]),r instanceof un&&f.setSelection(new un(f.doc.resolve(r.$anchorCell.pos),h?f.doc.resolve(h):void 0)),n(f)}return!0}}function GG(t,e){return function(n,r){if(!ro(n))return!1;const i=ag(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const o=n.tr;n.selection instanceof un?n.selection.forEachCell((s,a)=>{s.attrs[t]!==e&&o.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(o)}return!0}}function ZG(t){return function(e,n){if(!ro(e))return!1;if(n){const r=vr(e.schema),i=Po(e),o=e.tr,s=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=s.map(l=>i.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&o.setNodeMarkup(i.tableStart+s[l],r.cell,a[l].attrs);if(o.steps.length===0)for(let l=0;l<s.length;l++)o.setNodeMarkup(i.tableStart+s[l],r.header_cell,a[l].attrs);n(o)}return!0}}function x2(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const o=e.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}function Td(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?ZG(t):function(n,r){if(!ro(n))return!1;if(r){const i=vr(n.schema),o=Po(n),s=n.tr,a=x2("row",o,i),l=x2("column",o,i),c=(t==="column"?a:t==="row"&&l)?1:0,d=t=="column"?{left:0,top:c,right:1,bottom:o.map.height}:t=="row"?{left:c,top:0,right:o.map.width,bottom:1}:o,f=t=="column"?l?i.cell:i.header_cell:t=="row"?a?i.cell:i.header_cell:i.cell;o.map.cellsInRect(d).forEach(h=>{const p=h+o.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,f,m.attrs)}),r(s)}return!0}}Td("row",{useDeprecatedLogic:!0});Td("column",{useDeprecatedLogic:!0});const YG=Td("cell",{useDeprecatedLogic:!0});function JG(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const o=t.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),i=t.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function _2(t){return function(e,n){if(!ro(e))return!1;const r=JG(ag(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(ut.between(i,AG(i))).scrollIntoView())}return!0}}function XG(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Gf(t,e){const n=t.selection;if(!(n instanceof un))return!1;if(e){const r=t.tr,i=vr(t.schema).cell.createAndFill().content;n.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new Ge(i,0,0))}),r.docChanged&&e(r)}return!0}function QG(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if(o=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const d=l?0:Math.max(0,n-1),f=l<e.childCount-1?0:Math.max(0,r-1);(d||f)&&(c=zb(vr(s).row,new Ge(c,d,f)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(n||r?zb(vr(s).row,new Ge(e,n,r)).content:e);else return null;return $G(s,a)}function $G(t,e){const n=[];for(let i=0;i<e.length;i++){const o=e[i];for(let s=o.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=o.child(s).attrs;for(let c=i;c<i+a;c++)n[c]=(n[c]||0)+l}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(Ce.empty),n[i]<r){const o=vr(t).cell.createAndFill(),s=[];for(let a=n[i];a<r;a++)s.push(o);e[i]=e[i].append(Ce.from(s))}return{height:e.length,width:r,rows:e}}function zb(t,e){const n=t.createAndFill();return new y1(n).replace(0,n.content.size,e).doc}function eZ({width:t,height:e,rows:n},r,i){if(t!=r){const o=[],s=[];for(let a=0;a<n.length;a++){const l=n[a],c=[];for(let d=o[a]||0,f=0;d<r;f++){let h=l.child(f%l.childCount);d+h.attrs.colspan>r&&(h=h.type.createChecked(ol(h.attrs,h.attrs.colspan,d+h.attrs.colspan-r),h.content)),c.push(h),d+=h.attrs.colspan;for(let p=1;p<h.attrs.rowspan;p++)o[a+p]=(o[a+p]||0)+h.attrs.colspan}s.push(Ce.from(c))}n=s,t=r}if(e!=i){const o=[];for(let s=0,a=0;s<i;s++,a++){const l=[],c=n[a%e];for(let d=0;d<c.childCount;d++){let f=c.child(d);s+f.attrs.rowspan>i&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),l.push(f)}o.push(Ce.from(l))}n=o,e=i}return{width:t,height:e,rows:n}}function tZ(t,e,n,r,i,o,s){const a=t.doc.type.schema,l=vr(a);let c,d;if(i>e.width)for(let f=0,h=0;f<e.height;f++){const p=n.child(f);h+=p.nodeSize;const m=[];let v;p.lastChild==null||p.lastChild.type==l.cell?v=c||(c=l.cell.createAndFill()):v=d||(d=l.header_cell.createAndFill());for(let g=e.width;g<i;g++)m.push(v);t.insert(t.mapping.slice(s).map(h-1+r),m)}if(o>e.height){const f=[];for(let m=0,v=(e.height-1)*e.width;m<Math.max(e.width,i);m++){const g=m>=e.width?!1:n.nodeAt(e.map[v+m]).type==l.header_cell;f.push(g?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,Ce.from(f)),p=[];for(let m=e.height;m<o;m++)p.push(h);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),p)}return!!(c||d)}function C2(t,e,n,r,i,o,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let c=i;c<o;c++){const d=s*e.width+c,f=e.map[d];if(e.map[d-e.width]==f){l=!0;const h=n.nodeAt(f),{top:p,left:m}=e.findCell(f);t.setNodeMarkup(t.mapping.slice(a).map(f+r),null,{...h.attrs,rowspan:s-p}),t.insert(t.mapping.slice(a).map(e.positionAt(s,m,n)),h.type.createAndFill({...h.attrs,rowspan:p+h.attrs.rowspan-s})),c+=h.attrs.colspan-1}}return l}function S2(t,e,n,r,i,o,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let c=i;c<o;c++){const d=c*e.width+s,f=e.map[d];if(e.map[d-1]==f){l=!0;const h=n.nodeAt(f),p=e.colCount(f),m=t.mapping.slice(a).map(f+r);t.setNodeMarkup(m,null,ol(h.attrs,s-p,h.attrs.colspan-(s-p))),t.insert(m+h.nodeSize,h.type.createAndFill(ol(h.attrs,0,s-p))),c+=h.attrs.rowspan-1}}return l}function E2(t,e,n,r,i){let o=n?t.doc.nodeAt(n-1):t.doc;if(!o)throw new Error("No table found");let s=_n.get(o);const{top:a,left:l}=r,c=l+i.width,d=a+i.height,f=t.tr;let h=0;function p(){if(o=n?f.doc.nodeAt(n-1):f.doc,!o)throw new Error("No table found");s=_n.get(o),h=f.mapping.maps.length}tZ(f,s,o,n,c,d,h)&&p(),C2(f,s,o,n,l,c,a,h)&&p(),C2(f,s,o,n,l,c,d,h)&&p(),S2(f,s,o,n,a,d,l,h)&&p(),S2(f,s,o,n,a,d,c,h)&&p();for(let m=a;m<d;m++){const v=s.positionAt(m,l,o),g=s.positionAt(m,c,o);f.replace(f.mapping.slice(h).map(v+n),f.mapping.slice(h).map(g+n),new Ge(i.rows[m-a],0,0))}p(),f.setSelection(new un(f.doc.resolve(n+s.positionAt(a,l,o)),f.doc.resolve(n+s.positionAt(d-1,c-1,o)))),e(f)}const nZ=my({ArrowLeft:Zf("horiz",-1),ArrowRight:Zf("horiz",1),ArrowUp:Zf("vert",-1),ArrowDown:Zf("vert",1),"Shift-ArrowLeft":Yf("horiz",-1),"Shift-ArrowRight":Yf("horiz",1),"Shift-ArrowUp":Yf("vert",-1),"Shift-ArrowDown":Yf("vert",1),Backspace:Gf,"Mod-Backspace":Gf,Delete:Gf,"Mod-Delete":Gf});function Ih(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Zf(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof un)return Ih(n,r,gt.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=QT(i,t,e);if(s==null)return!1;if(t=="horiz")return Ih(n,r,gt.near(n.doc.resolve(o.head+e),e));{const a=n.doc.resolve(s),l=WT(a,t,e);let c;return l?c=gt.near(l,1):e<0?c=gt.near(n.doc.resolve(a.before(-1)),-1):c=gt.near(n.doc.resolve(a.after(-1)),1),Ih(n,r,c)}}}function Yf(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof un)s=o;else{const l=QT(i,t,e);if(l==null)return!1;s=new un(n.doc.resolve(l))}const a=WT(s.$headCell,t,e);return a?Ih(n,r,new un(s.$anchorCell,a)):!1}}function rZ(t,e){const n=t.state.doc,r=il(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new un(r))),!0):!1}function iZ(t,e,n){if(!ro(t.state))return!1;let r=QG(n);const i=t.state.selection;if(i instanceof un){r||(r={width:1,height:1,rows:[Ce.from(zb(vr(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=_n.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=eZ(r,a.right-a.left,a.bottom-a.top),E2(t.state,t.dispatch,s,a,r),!0}else if(r){const o=ag(t.state),s=o.start(-1);return E2(t.state,t.dispatch,s,_n.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function oZ(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=A2(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof un)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=il(t.state.selection.$anchor))!=null&&((n=T0(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(l,c){let d=T0(t,c);const f=Os.getState(t.state)==null;if(!d||!Fy(l,d))if(f)d=l;else return;const h=new un(l,d);if(f||!t.state.selection.eq(h)){const p=t.state.tr.setSelection(h);f&&p.setMeta(Os,l.pos),t.dispatch(p)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),Os.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Os,-1))}function a(l){const c=l,d=Os.getState(t.state);let f;if(d!=null)f=t.state.doc.resolve(d);else if(A2(t,c.target)!=r&&(f=T0(t,e),!f))return s();f&&o(f,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function QT(t,e,n){if(!(t.state.selection instanceof ut))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?s:null}}return null}function A2(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function T0(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&il(t.state.doc.resolve(r))||il(t.state.doc.resolve(i))}var sZ=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Bb(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Bb(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Bb(t,e,n,r,i,o){let s=0,a=!0,l=e.firstChild;const c=t.firstChild;if(c){for(let f=0,h=0;f<c.childCount;f++){const{colspan:p,colwidth:m}=c.child(f).attrs;for(let v=0;v<p;v++,h++){const g=i==h?o:m&&m[v],y=g?g+"px":"";if(s+=g||r,g||(a=!1),l)l.style.width!=y&&(l.style.width=y),l=l.nextSibling;else{const C=document.createElement("col");C.style.width=y,e.appendChild(C)}}}for(;l;){var d;const f=l.nextSibling;(d=l.parentNode)===null||d===void 0||d.removeChild(l),l=f}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const ri=new Yt("tableColumnResizing");function aZ({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=sZ,lastColumnResizable:i=!0}={}){const o=new Vt({key:ri,state:{init(s,a){var l;const c=(l=o.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,d=vr(a.schema).table.name;return r&&c&&(c[d]=(f,h)=>new r(f,n,h)),new lZ(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=ri.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{cZ(s,a,t,i)},mouseleave:s=>{uZ(s)},mousedown:(s,a)=>{dZ(s,a,e,n)}},decorations:s=>{const a=ri.getState(s);if(a&&a.activeHandle>-1)return gZ(s,a.activeHandle)},nodeViews:{}}});return o}var lZ=class Rh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(ri);if(r&&r.setHandle!=null)return new Rh(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Rh(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return Fb(e.doc.resolve(i))||(i=-1),new Rh(i,n.dragging)}return n}};function cZ(t,e,n,r){if(!t.editable)return;const i=ri.getState(t.state);if(i&&!i.dragging){const o=hZ(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=n?s=T2(t,e,"left",n):l-e.clientX<=n&&(s=T2(t,e,"right",n))}if(s!=i.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),c=_n.get(l),d=a.start(-1);if(c.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==c.width-1)return}$T(t,s)}}}function uZ(t){if(!t.editable)return;const e=ri.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&$T(t,-1)}function dZ(t,e,n,r){var i;if(!t.editable)return!1;const o=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=ri.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=fZ(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(ri,{setDragging:{startX:e.clientX,startWidth:l}}));function c(f){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",d);const h=ri.getState(t.state);h!=null&&h.dragging&&(pZ(t,h.activeHandle,M2(h.dragging,f,n)),t.dispatch(t.state.tr.setMeta(ri,{setDragging:null})))}function d(f){if(!f.which)return c(f);const h=ri.getState(t.state);if(h&&h.dragging){const p=M2(h.dragging,f,n);D2(t,h.activeHandle,p,r)}}return D2(t,s.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",d),e.preventDefault(),!0}function fZ(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=t.domAtPos(e);let s=o.node.childNodes[o.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(s-=r[l],a--);return s/a}function hZ(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function T2(t,e,n,r){const i=n=="right"?-r:r,o=t.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,a=il(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=_n.get(a.node(-1)),c=a.start(-1),d=l.map.indexOf(a.pos-c);return d%l.width==0?-1:c+l.map[d-1]}function M2(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function $T(t,e){t.dispatch(t.state.tr.setMeta(ri,{setHandle:e}))}function pZ(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),o=_n.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let c=0;c<o.height;c++){const d=c*o.width+a;if(c&&o.map[d]==o.map[d-o.width])continue;const f=o.map[d],h=i.nodeAt(f).attrs,p=h.colspan==1?0:a-o.colCount(f);if(h.colwidth&&h.colwidth[p]==n)continue;const m=h.colwidth?h.colwidth.slice():mZ(h.colspan);m[p]=n,l.setNodeMarkup(s+f,null,{...h,colwidth:m})}l.docChanged&&t.dispatch(l)}function D2(t,e,n,r){const i=t.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=_n.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let l=t.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Bb(o,l.firstChild,l,r,a,n)}function mZ(t){return Array(t).fill(0)}function gZ(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return vt.empty;const o=_n.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const d=a+c*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(c==0||o.map[d]!=o.map[d-o.width])){var l;const f=o.map[d],h=s+f+i.nodeAt(f).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((l=ri.getState(t))===null||l===void 0)&&l.dragging&&n.push(tn.node(s+f,s+f+i.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),n.push(tn.widget(h,p))}}return vt.create(t.doc,n)}function vZ({allowTableNodeSelection:t=!1}={}){return new Vt({key:Os,state:{init(){return null},apply(e,n){const r=e.getMeta(Os);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:o}=e.mapping.mapResult(n);return i?null:o}},props:{decorations:DG,handleDOMEvents:{mousedown:oZ},createSelectionBetween(e){return Os.getState(e.state)!=null?e.state.selection:null},handleTripleClick:rZ,handleKeyDown:nZ,handlePaste:iZ},appendTransaction(e,n,r){return RG(r,YT(r,n),t)}})}function Hb(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function O2(t,e,n,r,i,o){var s;let a=0,l=!0,c=e.firstChild;const d=t.firstChild;if(d!==null)for(let f=0,h=0;f<d.childCount;f+=1){const{colspan:p,colwidth:m}=d.child(f).attrs;for(let v=0;v<p;v+=1,h+=1){const g=i===h?o:m&&m[v],y=g?`${g}px`:"";if(a+=g||r,g||(l=!1),c){if(c.style.width!==y){const[C,_]=Hb(r,g);c.style.setProperty(C,_)}c=c.nextSibling}else{const C=document.createElement("col"),[_,S]=Hb(r,g);C.style.setProperty(_,S),e.appendChild(C)}}}for(;c;){const f=c.nextSibling;(s=c.parentNode)===null||s===void 0||s.removeChild(c),c=f}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class bZ{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),O2(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,O2(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function yZ(t,e,n,r){let i=0,o=!0;const s=[],a=t.firstChild;if(!a)return{};for(let f=0,h=0;f<a.childCount;f+=1){const{colspan:p,colwidth:m}=a.child(f).attrs;for(let v=0;v<p;v+=1,h+=1){const g=n===h?r:m&&m[v];i+=g||e,g||(o=!1);const[y,C]=Hb(e,g);s.push(["col",{style:`${y}: ${C}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:c}}function I2(t,e){return t.createAndFill()}function wZ(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function kZ(t,e,n,r,i){const o=wZ(t),s=[],a=[];for(let c=0;c<n;c+=1){const d=I2(o.cell);if(d&&a.push(d),r){const f=I2(o.header_cell);f&&s.push(f)}}const l=[];for(let c=0;c<e;c+=1)l.push(o.row.createChecked(null,r&&c===0?s:a));return o.table.createChecked(null,l)}function xZ(t){return t instanceof un}const Jf=({editor:t})=>{const{selection:e}=t.state;if(!xZ(e))return!1;let n=0;const r=MT(e.ranges[0].$from,o=>o.type.name==="table");return r==null||r.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},_Z=wr.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:bZ,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=yZ(t,this.options.cellMinWidth),o=["table",pn(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${i}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const s=kZ(o.schema,t,e,n);if(i){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(ut.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>LG(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>FG(t,e),deleteColumn:()=>({state:t,dispatch:e})=>BG(t,e),addRowBefore:()=>({state:t,dispatch:e})=>VG(t,e),addRowAfter:()=>({state:t,dispatch:e})=>UG(t,e),deleteRow:()=>({state:t,dispatch:e})=>qG(t,e),deleteTable:()=>({state:t,dispatch:e})=>XG(t,e),mergeCells:()=>({state:t,dispatch:e})=>w2(t,e),splitCell:()=>({state:t,dispatch:e})=>k2(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Td("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Td("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>YG(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>w2(t,e)?!0:k2(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>GG(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>_2(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>_2(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&YT(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=un.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Jf,"Mod-Backspace":Jf,Delete:Jf,"Mod-Delete":Jf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[aZ({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],vZ({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:At(ot(t,"tableRole",e))}}}),CZ=wr.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",pn(this.options.HTMLAttributes,t),0]}}),SZ=wr.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",pn(this.options.HTMLAttributes,t),0]}}),EZ=wr.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",pn(this.options.HTMLAttributes,t),0]}}),AZ=/^\s*>\s$/,TZ=wr.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",pn(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Cd({find:AZ,type:this.type})]}}),MZ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,DZ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,OZ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,IZ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,RZ=eo.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",pn(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[rl({find:MZ,type:this.type}),rl({find:OZ,type:this.type})]},addPasteRules(){return[ia({find:DZ,type:this.type}),ia({find:IZ,type:this.type})]}}),NZ="listItem",R2="textStyle",N2=/^\s*([-+*])\s$/,PZ=wr.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",pn(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(NZ,this.editor.getAttributes(R2)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Cd({find:N2,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Cd({find:N2,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(R2),editor:this.editor})),[t]}}),LZ=/(^|[^`])`([^`]+)`(?!`)/,FZ=/(^|[^`])`([^`]+)`(?!`)/g,zZ=eo.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",pn(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[rl({find:LZ,type:this.type})]},addPasteRules(){return[ia({find:FZ,type:this.type})]}}),BZ=/^```([a-z]+)?[\s\n]$/,HZ=/^~~~([a-z]+)?[\s\n]$/,VZ=wr.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,o=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",pn(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
215
+
216
+ `);return!o||!s?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const a=i.after();return a===void 0?!1:r.nodeAt(a)?t.commands.command(({tr:c})=>(c.setSelection(gt.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[kb({find:BZ,type:this.type,getAttributes:t=>({language:t[1]})}),kb({find:HZ,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Vt({key:new Yt("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i==null?void 0:i.mode;if(!n||!o)return!1;const{tr:s,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,`
217
+ `));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(ut.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),UZ=wr.create({name:"doc",topNode:!0,content:"block+"});function jZ(t={}){return new Vt({view(e){return new qZ(e,t)}})}class qZ{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,a=o.height/i.offsetHeight;if(n){let f=e.nodeBefore,h=e.nodeAfter;if(f||h){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let m=p.getBoundingClientRect(),v=f?m.bottom:m.top;f&&h&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:m.left,right:m.right,top:v-g,bottom:v+g}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;r={left:f.left-h,right:f.left+h,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let f=l.getBoundingClientRect(),h=f.width/l.offsetWidth,p=f.height/l.offsetHeight;c=f.left-l.scrollLeft*h,d=f.top-l.scrollTop*p}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/a+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!o){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=n3(this.editorView.state.doc,s,this.editorView.dragging.slice);a!=null&&(s=a)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const WZ=sn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[jZ(this.options)]}});class wn extends gt{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return wn.valid(r)?new wn(r):gt.near(r)}content(){return Ge.empty}eq(e){return e instanceof wn&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new wn(e.resolve(n.pos))}getBookmark(){return new zy(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!KZ(e)||!GZ(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&wn.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(n>0?e.indexAfter(s)<a.childCount:e.index(s)>0){o=a.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(wn.valid(l))return l}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!ft.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let a=e.doc.resolve(i);if(wn.valid(a))return a}return null}}}wn.prototype.visible=!1;wn.findFrom=wn.findGapCursorFrom;gt.jsonID("gapcursor",wn);class zy{constructor(e){this.pos=e}map(e){return new zy(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return wn.valid(n)?new wn(n):gt.near(n)}}function e4(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function KZ(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||e4(i.type))return!0;if(i.inlineContent)return!1}}return!0}function GZ(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||e4(i.type))return!0;if(i.inlineContent)return!1}}return!0}function ZZ(){return new Vt({props:{decorations:QZ,createSelectionBetween(t,e,n){return e.pos==n.pos&&wn.valid(n)?new wn(n):null},handleClick:JZ,handleKeyDown:YZ,handleDOMEvents:{beforeinput:XZ}}})}const YZ=my({ArrowLeft:Xf("horiz",-1),ArrowRight:Xf("horiz",1),ArrowUp:Xf("vert",-1),ArrowDown:Xf("vert",1)});function Xf(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,a=e>0?s.$to:s.$from,l=s.empty;if(s instanceof ut){if(!o.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=wn.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new wn(c))),!0):!1}}function JZ(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!wn.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&ft.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new wn(r))),!0)}function XZ(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof wn))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=Ce.empty;for(let s=r.length-1;s>=0;s--)i=Ce.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new Ge(i,0,0));return o.setSelection(ut.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function QZ(t){if(!(t.selection instanceof wn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",vt.create(t.doc,[tn.widget(t.selection.head,e,{key:"gapcursor"})])}const $Z=sn.create({name:"gapCursor",addProseMirrorPlugins(){return[ZZ()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=At(ot(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),eY=wr.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",pn(this.options.HTMLAttributes,t)]},renderText(){return`
218
+ `},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:o}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:a}=r.extensionManager,l=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&s){const f=l.filter(h=>a.includes(h.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),tY=wr.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,pn(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>kb({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var om=200,er=function(){};er.prototype.append=function(e){return e.length?(e=er.from(e),!this.length&&e||e.length<om&&this.leafAppend(e)||this.length<om&&e.leafPrepend(this)||this.appendInner(e)):this};er.prototype.prepend=function(e){return e.length?er.from(e).append(this):this};er.prototype.appendInner=function(e){return new nY(this,e)};er.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?er.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};er.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};er.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};er.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},n,r),i};er.from=function(e){return e instanceof er?e:e&&e.length?new t4(e):er.empty};var t4=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,a){for(var l=o;l<s;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,a){for(var l=o-1;l>=s;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=om)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=om)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(er);er.empty=new t4([]);var nY=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var a=this.left.length;if(i<a&&this.left.forEachInner(r,i,Math.min(o,a),s)===!1||o>a&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,o)-a,s+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(o,a)-a,s+a)===!1||o<a&&this.left.forEachInvertedInner(r,Math.min(i,a),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(er);const rY=500;class ji{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],d=[];return this.items.forEach((f,h)=>{if(!f.step){i||(i=this.remapping(r,h+1),o=i.maps.length),o--,d.push(f);return}if(i){d.push(new ho(f.map));let p=f.step.map(i.slice(o)),m;p&&s.maybeStep(p).doc&&(m=s.mapping.maps[s.mapping.maps.length-1],c.push(new ho(m,void 0,void 0,c.length+d.length))),o--,m&&i.appendMap(m,o)}else s.maybeStep(f.step);if(f.selection)return a=i?f.selection.map(i.slice(o)):f.selection,l=new ji(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,n,r,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),h=new ho(e.mapping.maps[d],f,n),p;(p=l&&l.merge(h))&&(h=p,d?o.pop():a=a.slice(0,a.length-1)),o.push(h),n&&(s++,n=void 0),i||(l=h)}let c=s-r.depth;return c>oY&&(a=iY(a,c),s-=c),new ji(a.append(o),s)}remapping(e,n){let r=new nd;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new ji(this.items.append(e.map(n=>new ho(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},i);let l=n;this.items.forEach(h=>{let p=o.getMirror(--l);if(p==null)return;s=Math.min(s,p);let m=o.maps[p];if(h.step){let v=e.steps[p].invert(e.docs[p]),g=h.selection&&h.selection.map(o.slice(l+1,p));g&&a++,r.push(new ho(m,v,g))}else r.push(new ho(m))},i);let c=[];for(let h=n;h<s;h++)c.push(new ho(o.maps[h]));let d=this.items.slice(0,i).append(c).append(r),f=new ji(d,a);return f.emptyItemCount()>rY&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((s,a)=>{if(a>=e)i.push(s),s.selection&&o++;else if(s.step){let l=s.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let d=s.selection&&s.selection.map(n.slice(r));d&&o++;let f=new ho(c.invert(),l,d),h,p=i.length-1;(h=i.length&&i[p].merge(f))?i[p]=h:i.push(f)}}else s.map&&r--},this.items.length,0),new ji(er.from(i.reverse()),o)}}ji.empty=new ji(er.empty,0);function iY(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class ho{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new ho(n.getMap().invert(),n,this.selection)}}}class Es{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const oY=20;function sY(t,e,n,r){let i=n.getMeta(qa),o;if(i)return i.historyState;n.getMeta(cY)&&(t=new Es(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(qa))return s.getMeta(qa).redo?new Es(t.done.addTransform(n,void 0,r,Nh(e)),t.undone,P2(n.mapping.maps),t.prevTime,t.prevComposition):new Es(t.done,t.undone.addTransform(n,void 0,r,Nh(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!aY(n,t.prevRanges)),c=s?M0(t.prevRanges,n.mapping):P2(n.mapping.maps);return new Es(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,Nh(e)),ji.empty,c,n.time,a??t.prevComposition)}else return(o=n.getMeta("rebased"))?new Es(t.done.rebased(n,o),t.undone.rebased(n,o),M0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Es(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),M0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function aY(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(n=!0)}),n}function P2(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,o,s)=>e.push(o,s));return e}function M0(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),o=e.map(t[r+1],-1);i<=o&&n.push(i,o)}return n}function lY(t,e,n){let r=Nh(e),i=qa.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),l=new Es(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(qa,{redo:n,historyState:l})}let D0=!1,L2=null;function Nh(t){let e=t.plugins;if(L2!=e){D0=!1,L2=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){D0=!0;break}}return D0}const qa=new Yt("history"),cY=new Yt("closeHistory");function uY(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Vt({key:qa,state:{init(){return new Es(ji.empty,ji.empty,null,0,-1)},apply(e,n,r){return sY(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?r4:r=="historyRedo"?i4:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function n4(t,e){return(n,r)=>{let i=qa.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=lY(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const r4=n4(!1,!0),i4=n4(!0,!0),dY=sn.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>r4(t,e),redo:()=>({state:t,dispatch:e})=>i4(t,e)}},addProseMirrorPlugins(){return[uY(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),fY=wr.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",pn(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!tK(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$from:r,$to:i}=n,o=t();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):_W(n)?o.insertContentAt(i.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:s,dispatch:a})=>{var l;if(a){const{$to:c}=s.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(ut.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(ft.create(s.doc,c.pos)):s.setSelection(ut.create(s.doc,c.pos));else{const f=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();f&&(s.insert(d,f),s.setSelection(ut.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[OT({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),hY=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,pY=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,mY=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,gY=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,vY=eo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",pn(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[rl({find:hY,type:this.type}),rl({find:mY,type:this.type})]},addPasteRules(){return[ia({find:pY,type:this.type}),ia({find:gY,type:this.type})]}}),o4=wr.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",pn(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),bY="listItem",F2="textStyle",z2=/^(\d+)\.\s$/,yY=wr.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",pn(this.options.HTMLAttributes,n),0]:["ol",pn(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(bY,this.editor.getAttributes(F2)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Cd({find:z2,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Cd({find:z2,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(F2)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),wY=wr.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",pn(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),kY=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,xY=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,_Y=eo.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",pn(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[rl({find:kY,type:this.type})]},addPasteRules(){return[ia({find:xY,type:this.type})]}}),CY=wr.create({name:"text",group:"inline"}),SY=sn.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(RZ.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(TZ.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(PZ.configure(this.options.bulletList)),this.options.code!==!1&&t.push(zZ.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(VZ.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(UZ.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(WZ.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push($Z.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(eY.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(tY.configure(this.options.heading)),this.options.history!==!1&&t.push(dY.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(fY.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(vY.configure(this.options.italic)),this.options.listItem!==!1&&t.push(o4.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(yY.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(wY.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(_Y.configure(this.options.strike)),this.options.text!==!1&&t.push(CY.configure(this.options.text)),t}});function EY(t){const{targetEl:e,platform:n,hasSelection:r,isEditable:i}=t,o=e.closest("a[href]")!=null,s=e.closest("td, th")!=null,a={hasSelection:r,isEditable:i,overLink:o,canMergeCells:!1,canSplitCell:!1};return o?{kind:"link",...a}:s?{kind:"tableCell",...a}:n==="macos"?null:{kind:"editorText",...a}}function AY(t){const e=t.toLowerCase();return e.includes("mac")||e==="darwin"?"macos":e.includes("win")?"windows":"linux"}function s4(t,e,n){const r=t.split(/(?:\r\n?|\n)+/).map(i=>e.nodes.paragraph.create(null,i?e.text(i,n):void 0));return Ge.maxOpen(Ce.fromArray(r))}const TY=["http://","https://","mailto:","ftp://","//"];function a4(t){const e=t.toLowerCase();return TY.some(n=>e.startsWith(n))}function l4(t){if(!t)return null;const e=t.trim();if(!e)return null;if(a4(e)||e.startsWith("#"))return e;const n=e.indexOf(":");if(n===-1)return e;const r=Math.min(...["/","#","?"].map(i=>e.indexOf(i)).filter(i=>i!==-1));return Number.isFinite(r)&&r<n?e:null}function fi(t){return t.chain().focus()}async function MY(t,e){const{editor:n}=e;switch(t){case"ctx:undo":fi(n).undo().run();return;case"ctx:redo":fi(n).redo().run();return;case"ctx:pastePlain":{const r=await e.readClipboardText();if(!r)return;const{state:i,view:o}=n,s=s4(r,i.schema,i.selection.$from.marks());o.dispatch(i.tr.replaceSelection(s).scrollIntoView()),o.focus();return}case"ctx:table:insertRowAbove":fi(n).addRowBefore().run();return;case"ctx:table:insertRowBelow":fi(n).addRowAfter().run();return;case"ctx:table:insertColLeft":fi(n).addColumnBefore().run();return;case"ctx:table:insertColRight":fi(n).addColumnAfter().run();return;case"ctx:table:deleteRow":fi(n).deleteRow().run();return;case"ctx:table:deleteCol":fi(n).deleteColumn().run();return;case"ctx:table:mergeCells":fi(n).mergeCells().run();return;case"ctx:table:splitCell":fi(n).splitCell().run();return;case"ctx:table:deleteTable":fi(n).deleteTable().run();return;case"ctx:link:open":{const r=e.getLinkHref();r&&e.openHref(r);return}case"ctx:link:copy":{const r=e.getLinkHref();if(!r)return;const i=l4(r);i&&await e.writeClipboardText(i);return}case"ctx:link:remove":fi(n).extendMarkRange("link").unsetLink().run();return;default:return}}const DY=["ctx:undo","ctx:redo","ctx:pastePlain","ctx:table:insertRowAbove","ctx:table:insertRowBelow","ctx:table:insertColLeft","ctx:table:insertColRight","ctx:table:deleteRow","ctx:table:deleteCol","ctx:table:mergeCells","ctx:table:splitCell","ctx:table:deleteTable","ctx:link:open","ctx:link:copy","ctx:link:remove"],OY=new Set(DY);function IY(t){return typeof t=="string"&&OY.has(t)}async function RY(){try{return await navigator.clipboard.readText()}catch{return null}}async function NY(t){try{await navigator.clipboard.writeText(t)}catch{}}function PY(t,e){if(!Tt())return()=>{};const n=t.view.dom,r=e.platform??AY(typeof navigator<"u"?navigator.platform||navigator.userAgent:"");let i=null;const o=async a=>{var f;const l=a.target;if(!l)return;const c=EY({targetEl:l,platform:r,hasSelection:!1,isEditable:t.isEditable});if(!c)return;a.preventDefault();const d=t.view.posAtCoords({left:a.clientX,top:a.clientY});if(d){const{from:h,to:p}=t.state.selection;(d.pos<h||d.pos>p)&&t.commands.setTextSelection(d.pos)}if(c.hasSelection=!t.state.selection.empty,i=((f=l.closest("a[href]"))==null?void 0:f.getAttribute("href"))??null,c.kind==="tableCell"){const h=t.can();c.canMergeCells=h.mergeCells(),c.canSplitCell=h.splitCell()}t.view.focus();try{await(await hs())("show_context_menu",{req:c})}catch{}};n.addEventListener("contextmenu",o);const s=Zt(async()=>{const{listen:a}=await import("./event-CNdo2oXa.js");return{listen:a}},__vite__mapDeps([3,1])).then(({listen:a})=>a("context-menu-action",l=>{var d;const c=(d=l.payload)==null?void 0:d.id;IY(c)&&MY(c,{editor:t,openHref:e.openHref,getLinkHref:()=>i,readClipboardText:RY,writeClipboardText:NY})}));return s.catch(()=>{}),()=>{n.removeEventListener("contextmenu",o),s.then(a=>a()).catch(()=>{})}}const _u=new Yt("tandemAnnotations"),B2={comment:!0,highlight:!0,note:!0};function c4(){try{const t=localStorage.getItem(YC);if(!t)return{...B2};const e=JSON.parse(t);return{comment:e.comment!==!1,highlight:e.highlight!==!1,note:e.note!==!1}}catch(t){return console.warn("[annotation] localStorage unavailable",t),{...B2}}}function H2(){return $v(_m(),"family")}function u4(t){return t==="highlight"?"highlight":t==="note"||t==="flag"?"note":"comment"}function O0(t,e,n,r,i){const o=[],s=t.content.size;return e.forEach(a=>{const l=el(a,p=>{console.warn("[sanitize]",p)});if(l.status!=="pending"||!r[l.type]||!l.range&&!l.relRange)return;const c=Ac(l,t,n);if(!c)return;l.relRange&&c.method==="flat"&&console.warn("[annotation] relRange-equipped annotation %s fell back to flat offsets",l.id);const{from:d,to:f}=c;if(d>=f||d<0||f>s)return;let h={};switch(l.type){case"highlight":{const p=UC(l.color),m=Yu[p];h={class:`tandem-highlight tandem-highlight--${p}`,style:`background: ${m}; border-radius: var(--tandem-r-1); padding: 1px 0;`,"data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":`Highlight annotation (${p})`};break}case"comment":l.suggestedText!==void 0?h={class:"tandem-suggestion",style:"background: var(--tandem-suggestion-bg); text-decoration: underline wavy var(--tandem-suggestion); text-underline-offset: 3px;","data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":"Replacement annotation"}:l.author==="claude"?h={class:"tandem-comment tandem-comment--claude",style:"border-bottom: 2px solid var(--tandem-author-claude); padding-bottom: 1px;","data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":`${i} comment annotation`}:h={class:"tandem-comment",style:"border-bottom: 2px dashed var(--tandem-author-user); padding-bottom: 1px;","data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":"Comment annotation"};break;case"note":h={class:"tandem-note",style:"border-bottom: 2px dotted var(--tandem-fg-muted); padding-bottom: 1px;","data-annotation-id":l.id,"data-annotation-type":l.type,"data-annotation-author":l.author,"aria-label":"Note annotation"};break;default:{console.warn("[annotation] Unhandled annotation type in buildDecorations, skipping");return}}try{o.push(tn.inline(d,f,h))}catch(p){if(!(p instanceof RangeError))throw p;console.debug("[annotation] RangeError for %s (from=%d, to=%d), skipping",l.id,d,f)}}),vt.create(t,o)}const LY=sn.create({name:"tandemAnnotations",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Ri);let n=c4(),r=H2();function i(){for(const a of e.values()){const l=a;if(l&&l.status==="pending"&&n[u4(l.type)])return!0}return!1}let o=i(),s=!1;return[new Vt({key:_u,state:{init(a,l){return o?O0(l.doc,e,t,n,r):vt.empty},apply(a,l,c,d){const f=a.getMeta(_u);if(f&&typeof f=="object"&&f.type==="toggle-decorations"&&(n=f.visible,o=i(),s=!1),f)return r=H2(),o?O0(d.doc,e,t,n,r):vt.empty;if(!o)return vt.empty;if(a.docChanged){if(!s&&l===vt.empty&&o){const h=O0(d.doc,e,t,n,r);return h!==vt.empty&&(s=!0),h}return l.map(a.mapping,a.doc)}return l}},props:{decorations(a){return _u.getState(a)}},view(a){let l=null,c=!1;function d(){l===null&&(l=requestAnimationFrame(()=>{l=null,c=!0;const p=a.state.tr.setMeta(_u,!0);a.dispatch(p)}))}const f=()=>{o=i(),s=!1,d()};e.observe(f);const h=setTimeout(()=>{!c&&l===null&&e.size>0&&f()},500);return{destroy(){clearTimeout(h),l!==null&&cancelAnimationFrame(l),e.unobserve(f)}}}})]}}),lu=new Yt("tandemAnnotationPing"),FY=700,zY=500,BY="tandem-annotation-ping";function HY(t,e){return!(!e.isLive||e.alreadySeen||!t||t.status!=="pending"||!e.visible[u4(t.type)])}function VY(){try{if(_m().reduceMotion)return!0}catch{}return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const UY=sn.create({name:"tandemAnnotationPing",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Ri),n=new Set;let r=!1;return[new Vt({key:lu,state:{init:()=>vt.empty,apply(i,o){let s=o.map(i.mapping,i.doc);const a=i.getMeta(lu);if((a==null?void 0:a.type)==="add")s=s.add(i.doc,[a.deco]);else if((a==null?void 0:a.type)==="remove"){const l=s.find(void 0,void 0,c=>c.pingId===a.id);l.length&&(s=s.remove(l))}return s}},props:{decorations(i){return lu.getState(i)}},view(i){const o=new Map;let s=!1;function a(h,p){if(VY())return;const m=Ac(p,i.state.doc,t);if(m)try{const v=i.state.doc.resolve(m.from),g=v.depth;if(g<1)return;const y=v.before(g),C=v.after(g),_=tn.node(y,C,{class:BY},{pingId:h});i.dispatch(i.state.tr.setMeta(lu,{type:"add",deco:_}));const S=setTimeout(()=>{o.delete(h),!s&&i.dispatch(i.state.tr.setMeta(lu,{type:"remove",id:h}))},FY);o.set(h,S)}catch(v){if(!(v instanceof RangeError))throw v}}let l;const c=()=>{for(const h of e.keys())n.add(h);r=!0},d=()=>{clearTimeout(l),l=setTimeout(c,zY)},f=h=>{r||d();const p=c4();for(const m of h.keysChanged){const v=e.get(m),g=HY(v,{isLive:r,alreadySeen:n.has(m),visible:p});n.add(m),g&&v&&a(m,v)}};return e.observe(f),d(),{destroy(){s=!0,clearTimeout(l);for(const h of o.values())clearTimeout(h);o.clear(),e.unobserve(f)}}}})]}}),Ol=new Yt("tandemAuthorship"),jY=new Set(["paragraph","heading"]);function qY(t,e,n){if(t.relRange){const r=KE(n,e,t.relRange);if(r&&r.from<r.to)return r}if(t.range){console.warn("[authorship] Falling back to flat offsets for range",t.id);const r=na(e,t.range.from),i=na(e,t.range.to);if(r<i)return{from:r,to:i}}return null}function I0(t,e,n,r){if(!r)return vt.empty;const i=[],o=t.content.size,s=[];return e.forEach(a=>{const l=a;if(!l.author||!l.range||l.author!=="user"&&l.author!=="claude")return;const c=qY(l,t,n);if(!c)return;const{from:d,to:f}=c;if(!(d>=f||d<0||f>o)){try{i.push(tn.inline(d,f,{"data-tandem-author":l.author}))}catch(h){if(!(h instanceof RangeError))throw h;console.warn("[authorship] Decoration RangeError for entry",l.id,h)}s.push({author:l.author,from:d,to:f})}}),t.descendants((a,l)=>{if(!jY.has(a.type.name))return;const c=l,d=l+a.nodeSize;let f=0,h=0;for(const m of s){const v=Math.max(m.from,c),g=Math.min(m.to,d);if(g<=v)continue;const y=g-v;m.author==="user"?f+=y:h+=y}if(f===0&&h===0||a.content.size===0)return;const p=f>=h?"user":"claude";try{i.push(tn.node(c,d,{"data-tandem-author-block":p}))}catch(m){if(!(m instanceof RangeError))throw m;console.warn("[authorship] node Decoration RangeError at offset",l,m)}}),vt.create(t,i)}const WY=sn.create({name:"tandemAuthorship",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Mw);let n=!1;try{n=localStorage.getItem(ZC)==="true"}catch(r){console.warn("[authorship] localStorage unavailable",r)}return[new Vt({key:Ol,state:{init(r,i){return{visible:n,decorations:I0(i.doc,e,t,n)}},apply(r,i,o,s){const a=r.getMeta(Ol);if((a==null?void 0:a.type)==="toggle"){const l=a.visible;return{visible:l,decorations:I0(s.doc,e,t,l)}}return(a==null?void 0:a.type)==="rebuild"?{visible:i.visible,decorations:I0(s.doc,e,t,i.visible)}:r.docChanged&&i.visible?{visible:i.visible,decorations:i.decorations.map(r.mapping,r.doc)}:i}},props:{decorations(r){var i;return((i=Ol.getState(r))==null?void 0:i.decorations)??vt.empty}},view(r){const i=()=>{const s=r.state.tr.setMeta(Ol,{type:"rebuild"});r.dispatch(s)};e.observe(i);const o=setTimeout(()=>{e.size>0&&i()},500);return{destroy(){clearTimeout(o),e.unobserve(i)}}}})]},onTransaction({transaction:t}){const e=this.options.ydoc;if(!e||t.getMeta("y-sync$")||t.getMeta(Ol)||!t.docChanged)return;const n=e.getMap(Mw),r=t.doc;t.steps.forEach(i=>{i.getMap().forEach((s,a,l,c)=>{if(c-l-(a-s)>0)try{const f=wi(r,zn(l)),h=wi(r,zn(c));if(h<=f)return;const p=dO("user"),m={id:p,author:"user",range:{from:f,to:h},timestamp:Date.now()};n.set(p,m)}catch(f){console.warn("[authorship] Position conversion failed during user attribution",f)}})})}}),Qf=new Yt("tandemAwareness");function V2(t,e){if(!e)return vt.empty;const n=[],{focusParagraph:r,focusOffset:i,active:o}=e;if(r!==null&&r>=0){let s=0;t.forEach((a,l)=>{s===r&&n.push(tn.node(l,l+a.nodeSize,{class:"tandem-claude-focus",style:"background: var(--tandem-claude-focus-bg); border-left: 3px solid var(--tandem-claude-focus-border); padding-left: 8px; transition: background 0.3s ease, border-color 0.3s ease;"})),s++})}if(i!==null&&i>=0)try{const s=na(t,mh(i)),a=o===!1?" tandem-claude-cursor-idle":"";n.push(tn.widget(s,()=>{const l=document.createElement("span");l.className=`tandem-claude-cursor${a}`,l.setAttribute("aria-hidden","true");const c=document.createElement("span");return c.className="tandem-claude-cursor-label",c.textContent="AI",l.appendChild(c),l}))}catch(s){console.warn("[awareness] cursor decoration failed, falling back to gutter-only:",s)}return n.length===0?vt.empty:vt.create(t,n)}const KY=sn.create({name:"tandemAwareness",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(KC),n=t.getMap(vv);return[new Vt({key:Qf,state:{init(r,i){const o=e.get(bv);return V2(i.doc,o??null)},apply(r,i,o,s){if(r.getMeta(Qf)){const a=e.get(bv);return V2(s.doc,a??null)}return r.docChanged?i.map(r.mapping,r.doc):i}},props:{decorations(r){return Qf.getState(r)}},view(r){const i=()=>{const o=r.state.tr.setMeta(Qf,!0);r.dispatch(o)};return e.observe(i),{destroy(){e.unobserve(i)}}}}),new Vt({key:new Yt("tandemUserAwareness"),view(){let r=null,i=null,o=null,s=!1,a=-1;return{update(l,c){const{state:d}=l;if(!d.selection.eq(c.selection)){const f=GE(d.doc,{from:zn(d.selection.from),to:zn(d.selection.to)});if(d.selection.from===d.selection.to)o&&(clearTimeout(o),o=null),n.set(Dw,{...f,timestamp:Date.now()});else{const h=d.doc.textBetween(d.selection.from,d.selection.to,`
219
+ `),p=h.length>200?h.slice(0,197)+"...":h;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n.set(Dw,{...f,selectedText:p,timestamp:Date.now()})},150)}}d.doc!==c.doc&&(a=d.selection.from,s=!0,i||(i=setTimeout(()=>{i=null,s&&n.set(Ow,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200)),r&&clearTimeout(r),r=setTimeout(()=>{s=!1,n.set(Ow,{isTyping:!1,cursor:l.state.selection.from,lastEdit:Date.now()})},xD))},destroy(){r&&clearTimeout(r),i&&clearTimeout(i),o&&clearTimeout(o)}}}})]}}),po=new Yt("tandemFindReplace"),d4={query:"",caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:vt.empty};function GY(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ZY(t){if(!t.query)return null;try{const e=t.regexMode?t.query:GY(t.query),n=t.caseSensitive?"g":"gi",r=t.wholeWord?`\\b${e}\\b`:e;return new RegExp(r,n)}catch{return null}}function f4(t,e){const n=ZY(e);if(!n)return[];const r=[];return t.descendants((i,o)=>{if(!i.isTextblock)return;const s=i.textContent;for(const a of s.matchAll(n)){const l=a.index??0;r.push({from:o+1+l,to:o+1+l+a[0].length})}}),r}function qu(t,e,n){if(e.length===0)return vt.empty;const r=[];for(let i=0;i<e.length;i++){const{from:o,to:s}=e[i];try{r.push(tn.inline(o,s,{class:i===n?"tandem-find-active":"tandem-find-match"}))}catch{}}return vt.create(t,r)}function Vb(t,e){if(t.length===0)return-1;for(let n=0;n<t.length;n++)if(t[n].from<=e&&e<=t[n].to)return n;for(let n=0;n<t.length;n++)if(t[n].from>e)return n;return 0}function YY(t,e,n){if(t.type==="close")return d4;if(t.type==="find"){const i=t.opts,o=f4(n.doc,i),s=n.selection.from,a=Vb(o,s);return{...i,matches:o,activeIndex:a,decoSet:qu(n.doc,o,a)}}if(t.type==="next"){const i=e.matches.length===0?-1:(e.activeIndex+1)%e.matches.length;return{...e,activeIndex:i,decoSet:qu(n.doc,e.matches,i)}}if(t.type==="prev"){const i=e.matches.length===0?-1:(e.activeIndex-1+e.matches.length)%e.matches.length;return{...e,activeIndex:i,decoSet:qu(n.doc,e.matches,i)}}return t}const JY=sn.create({name:"tandemFindReplace",addProseMirrorPlugins(){return[new Vt({key:po,state:{init:()=>d4,apply(t,e,n,r){const i=t.getMeta(po);if(i)return YY(i,e,r);if(!e.query)return e;if(t.docChanged){const a=f4(r.doc,e),l=r.selection.from,c=Vb(a,l);return{...e,matches:a,activeIndex:c,decoSet:qu(r.doc,a,c)}}const o=r.selection.from,s=Vb(e.matches,o);return s===e.activeIndex?e:{...e,activeIndex:s,decoSet:qu(r.doc,e.matches,s)}}},props:{decorations(t){var e;return((e=po.getState(t))==null?void 0:e.decoSet)??vt.empty}}})]},addCommands(){return{find:t=>({dispatch:e,tr:n})=>(e&&e(n.setMeta(po,{type:"find",opts:t})),!0),findNext:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(po,{type:"next"})),!0),findPrev:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(po,{type:"prev"})),!0),findClose:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(po,{type:"close"})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:t})=>{const e=po.getState(t.state);return e!=null&&e.query?(t.commands.findClose(),!0):!1}}}});function Jl(t){return po.getState(t)}function XY(t,e){const n=Jl(t.state);if(!n||n.activeIndex<0||n.matches.length===0)return!1;const{from:r,to:i}=n.matches[n.activeIndex],o=t.state.tr.insertText(e,r,i).setMeta(po,{type:"next"});return t.dispatch(o),!0}async function QY(t,e,n){let i=0,o=!1;for(let s=0;s<50;s++){const a=Jl(t.state);if(!(a!=null&&a.query)||a.matches.length===0)break;const l=a.matches.slice(0,100);try{let c=t.state.tr;for(let d=l.length-1;d>=0;d--){const{from:f,to:h}=l[d];c=c.insertText(e,f,h)}t.dispatch(c),i+=l.length,n==null||n(i,i+(a.matches.length-l.length))}catch(c){o=!0,console.warn("[find-replace] replaceAll chunk failed at pass",s,c);break}if(l.length<100)break;await new Promise(c=>setTimeout(c,0))}return{replaced:i,partial:o}}const ga=new Yt("tandemHeadingCollapse"),$Y="tandem:headingCollapse:";function h4(t){return!t||t.startsWith("upload://")?null:$Y+t}function U2(t){const e=h4(t);if(!e)return new Set;try{const n=window.localStorage.getItem(e);if(!n)return new Set;const r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(i=>typeof i=="string")):new Set}catch{return new Set}}function sm(t,e){const n=h4(t);if(n)try{e.size===0?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(Array.from(e)))}catch{}}function eJ(t){return t.trim().toLowerCase().replace(/\s+/g," ")}function R0(t){const e=[],n=new Map;return t.descendants((r,i,o)=>{if(r.type.name!=="heading")return!0;if(o!==t)return!1;const s=r.attrs.level??1,a=eJ(r.textContent),l=`${s}::${a}`,c=n.get(l)??0;n.set(l,c+1);const d=`${l}::${c}`;return e.push({pos:i,level:s,hash:d}),!1}),e}function tJ(t,e,n,r){if(n.size===0)return n;const i=new Set(e.map(a=>a.hash));if(t.length===e.length){const a=[];for(let h=0;h<t.length;h++)t[h].hash!==e[h].hash&&a.push(h);if(a.length!==1)return n;const l=a[0],c=t[l].hash,d=e[l].hash;if(!n.has(c))return n;const f=new Set(n);return f.delete(c),f.add(d),sm(r,f),f}if(e.length>t.length||e.length===0)return n;let o=!1;const s=new Set;for(const a of n)i.has(a)?s.add(a):o=!0;return o?(sm(r,s),s):n}function nJ(t,e,n){return tn.widget(t+1,r=>{const i=document.createElement("button");return i.type="button",i.className="tandem-heading-chevron",i.dataset.testid="heading-chevron",i.dataset.headingHash=e,i.dataset.collapsed=String(n),i.setAttribute("aria-label",n?"Expand section":"Collapse section"),i.setAttribute("aria-expanded",String(!n)),i.contentEditable="false",i.textContent=n?"▶":"▼",i.addEventListener("mousedown",o=>{o.preventDefault()}),i.addEventListener("click",o=>{o.stopPropagation(),o.preventDefault();const s=r.state.tr.setMeta(ga,{type:"toggle",hash:e});r.dispatch(s)}),i},{side:-1,ignoreSelection:!0,stopEvent:()=>!0,key:`chevron:${e}:${n?"c":"e"}`})}function rJ(t,e,n){const r=e[n];let i=t.content.size;for(let s=n+1;s<e.length;s++)if(e[s].level<=r.level){i=e[s].pos;break}const o=[];return t.forEach((s,a)=>{if(a>r.pos&&a<i){const l=a,c=a+s.nodeSize;o.push(tn.node(l,c,{class:"tandem-heading-collapsed-hidden",style:"display: none;"}))}}),o}function $f(t,e,n){const r=[];for(let i=0;i<e.length;i++){const o=e[i],s=n.has(o.hash);try{r.push(nJ(o.pos,o.hash,s)),s&&r.push(...rJ(t,e,i))}catch{}}return r.length===0?vt.empty:vt.create(t,r)}const iJ=sn.create({name:"tandemHeadingCollapse",addOptions(){return{filePath:null}},addProseMirrorPlugins(){const t=this.options.filePath;return[new Vt({key:ga,state:{init(e,n){const r=U2(t),i=R0(n.doc);return{collapsed:r,headings:i,decoSet:$f(n.doc,i,r),hasSeenContent:i.length>0}},apply(e,n,r,i){const o=e.getMeta(ga);if((o==null?void 0:o.type)==="toggle"){const c=new Set(n.collapsed);return c.has(o.hash)?c.delete(o.hash):c.add(o.hash),sm(t,c),{collapsed:c,headings:n.headings,decoSet:$f(i.doc,n.headings,c),hasSeenContent:n.hasSeenContent}}if((o==null?void 0:o.type)==="rehydrate"){const c=R0(i.doc),d=U2(t),f=new Set(c.map(p=>p.hash)),h=new Set;for(const p of d)f.has(p)&&h.add(p);return h.size!==d.size&&sm(t,h),{collapsed:h,headings:c,decoSet:$f(i.doc,c,h),hasSeenContent:!0}}if(!e.docChanged)return n;const s=R0(i.doc),a=n.hasSeenContent||s.length>0;let l=n.collapsed;return n.hasSeenContent&&(l=tJ(n.headings,s,n.collapsed,t)),{collapsed:l,headings:s,decoSet:$f(i.doc,s,l),hasSeenContent:a}}},view(e){let n=!1,r=null;function i(){n||r!==null||(r=requestAnimationFrame(()=>{if(r=null,n)return;const o=ga.getState(e.state);if(!o||o.headings.length===0)return;n=!0;const s=e.state.tr.setMeta(ga,{type:"rehydrate"}).setMeta("addToHistory",!1);e.dispatch(s)}))}return i(),{update(o){if(n)return;const s=ga.getState(o.state);!s||s.headings.length===0||i()},destroy(){r!==null&&cancelAnimationFrame(r)}}},props:{decorations(e){var n;return((n=ga.getState(e))==null?void 0:n.decoSet)??vt.empty}}})]}}),oJ=new Yt("listItemCheckbox"),sJ=/^\[([ xX])\]\s$/,aJ=o4.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),checked:{default:null,keepOnSplit:!1,parseHTML:e=>{const n=e.getAttribute("data-checked");return n==="true"?!0:n==="false"?!1:null},renderHTML:e=>e.checked===null||e.checked===void 0?{}:{"data-checked":String(e.checked)}}}},addInputRules(){const t=this.type;return[new ff({find:sJ,handler:({state:e,range:n,match:r})=>{const i=r[1]!==" ",o=e.doc.resolve(n.from);let s=-1,a={};for(let c=o.depth;c>0;c--){const d=o.node(c);if(d.type===t){s=o.before(c),a=d.attrs;break}}if(s<0)return null;const l=e.tr;l.delete(n.from,n.to),l.setNodeMarkup(s,void 0,{...a,checked:i})}})]},addProseMirrorPlugins(){var n;const t=this.type;return[...((n=this.parent)==null?void 0:n.call(this))??[],new Vt({key:oJ,props:{decorations:r=>{const i=[];return r.doc.descendants((o,s)=>{if(o.type!==t||o.attrs.checked===null||o.attrs.checked===void 0)return;const a=o.attrs.checked===!0;i.push(tn.widget(s+1,(l,c)=>lJ(l,c,a,t),{side:-1,key:`tandem-checkbox-${s}:${a}`,stopEvent:()=>!0,ignoreSelection:!0}))}),vt.create(r.doc,i)}}})]}});function lJ(t,e,n,r){const i=document.createElement("label");i.className="tandem-list-checkbox",i.contentEditable="false";const o=document.createElement("input");return o.type="checkbox",o.checked=n,o.setAttribute("aria-label",n?"Checked task":"Unchecked task"),o.addEventListener("mousedown",s=>s.preventDefault()),o.addEventListener("change",()=>{if(!t.editable){o.checked=n;return}const s=e();if(s==null)return;const a=s-1,l=t.state.doc.resolve(a).nodeAfter;!l||l.type!==r||t.dispatch(t.state.tr.setNodeMarkup(a,void 0,{...l.attrs,checked:!l.attrs.checked}))}),i.appendChild(o),i}const cJ=sn.create({name:"markdownHtml",addGlobalAttributes(){return[{types:["paragraph"],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})},markdownRaw:{default:null,parseHTML:()=>null,renderHTML:t=>t.markdownRaw?{"data-markdown-raw":""}:{}}}}]}}),uJ=eo.create({name:"rawMarkdown",parseHTML(){return[]},renderHTML(){return["span",{class:"tandem-raw-md"},0]}}),dJ=new Yt("tandemSelectionDecoration"),fJ=sn.create({name:"tandemSelectionDecoration",addProseMirrorPlugins(){return[new Vt({key:dJ,props:{decorations(t){const{selection:e}=t;if(!(e instanceof ut))return vt.empty;const{from:n,to:r}=e;return n===r?vt.empty:vt.create(t.doc,[tn.inline(n,r,{class:"tandem-selection-blurred"})])}}})]}});function Uo(t){return t.chain().focus()}const j2={tag:"path",attrs:{d:"M6 4.5h7M6 8h7M6 11.5h7"}},q2=[{id:"heading-1",label:"Heading 1",keywords:["h1","heading","title"],hint:"h1",icon:{kind:"glyph",glyph:"H¹"},run:t=>Uo(t).toggleHeading({level:1}).run()},{id:"heading-2",label:"Heading 2",keywords:["h2","heading","subtitle"],hint:"h2",icon:{kind:"glyph",glyph:"H²"},run:t=>Uo(t).toggleHeading({level:2}).run()},{id:"heading-3",label:"Heading 3",keywords:["h3","heading","subheading"],hint:"h3",icon:{kind:"glyph",glyph:"H³"},run:t=>Uo(t).toggleHeading({level:3}).run()},{id:"bullet-list",label:"Bullet list",keywords:["bullet","ul","list"],hint:"ul",icon:{kind:"svg",els:[{tag:"circle",attrs:{cx:"3",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}},{tag:"circle",attrs:{cx:"3",cy:"8",r:"0.7",fill:"currentColor",stroke:"none"}},{tag:"circle",attrs:{cx:"3",cy:"11.5",r:"0.7",fill:"currentColor",stroke:"none"}},j2]},run:t=>Uo(t).toggleBulletList().run()},{id:"numbered-list",label:"Numbered list",keywords:["numbered","ordered","ol","list"],hint:"ol",icon:{kind:"svg",els:[{tag:"path",attrs:{d:"M2 3.5h1V6M2 6h2M2 9.5c0-.5.5-1 1-1s1 .5 1 1c0 1-2 1.3-2 2.5h2"}},j2]},run:t=>Uo(t).toggleOrderedList().run()},{id:"task-list",label:"Task list",keywords:["task","todo","checkbox","check","checklist"],hint:"todo",icon:{kind:"svg",els:[{tag:"path",attrs:{d:"M3 3h10v10H3z"}},{tag:"path",attrs:{d:"M5.5 8l2 2 3.5-4"}}]},run:t=>Uo(t).toggleBulletList().updateAttributes("listItem",{checked:!1}).run()},{id:"quote",label:"Quote",keywords:["blockquote","quote"],hint:"q",icon:{kind:"svg",els:[{tag:"path",attrs:{d:"M3 6c0-1.5 1-2.5 2-2.5"}},{tag:"path",attrs:{d:"M3 6v3h3V6z"}},{tag:"path",attrs:{d:"M9 6c0-1.5 1-2.5 2-2.5"}},{tag:"path",attrs:{d:"M9 6v3h3V6z"}}]},run:t=>Uo(t).toggleBlockquote().run()},{id:"code-block",label:"Code block",keywords:["code","pre","snippet"],hint:"code",icon:{kind:"svg",els:[{tag:"path",attrs:{d:"M5 4l-3 4 3 4"}},{tag:"path",attrs:{d:"M11 4l3 4-3 4"}}]},run:t=>Uo(t).toggleCodeBlock().run()},{id:"horizontal-rule",label:"Horizontal rule",keywords:["hr","divider","rule","separator"],hint:"hr",icon:{kind:"glyph",glyph:"—"},run:t=>Uo(t).setHorizontalRule().run()}];function hJ(t){const e=/(?:^|\s)\/([A-Za-z0-9 -]*)$/.exec(t);if(!e)return null;const n=e[1]??"";return{fromOffset:t.length-n.length-1,query:n}}function lg(t){const e=t.trim().toLowerCase();return e?q2.filter(n=>[n.label,...n.keywords].join(" ").toLowerCase().includes(e)):q2}const pJ=["popup-annotation-input","popup-note-submit","popup-comment-submit","popup-highlight-yellow","popup-highlight-green","popup-highlight-blue","popup-highlight-pink"];function mJ(t){const e=document.querySelector(`[data-testid="${t}"]`);return e?document.activeElement===e:!1}function gJ(t){for(const e of t)if(document.querySelector(`[data-testid="${e}"]`))return!0;return!1}function vJ(){return typeof document>"u"?!1:!!(mJ("find-input")||document.querySelector('[data-testid="command-palette"]')||gJ(pJ))}const W2="http://www.w3.org/2000/svg",Wo=new Yt("tandemSlashCommand");function p4(t){return`${t.from}:${t.to}:${t.query}`}function bJ(t){if(!t.docChanged||t.getMeta("y-sync$"))return!1;const e=t.getMeta("uiEvent");if(e==="paste"||e==="drop"||t.getMeta("paste"))return!1;const n=t.selection.from;let r=!1;return t.mapping.maps.forEach((i,o)=>{i.forEach((s,a,l,c)=>{if(c<=l)return;t.mapping.slice(o+1).map(c,-1)===n&&(r=!0)})}),r}function yJ(t,e=0){if(vJ())return null;const{selection:n}=t;if(!n.empty)return null;const r=n.$from,i=r.parent.textBetween(0,r.parentOffset,`
220
+ `,`
221
+ `),o=hJ(i);if(!o)return null;const s=r.start()+o.fromOffset,a=r.pos,l=lg(o.query);return l.length===0?null:{from:s,to:a,query:o.query,selectedIndex:Math.min(e,l.length-1)}}function wJ(t,e){const n=t.getMeta(Wo);return n?n.type==="close"?{active:null,dismissedKey:e.active?p4(e.active):e.dismissedKey}:n.type==="select"&&e.active?{...e,active:{...e.active,selectedIndex:n.selectedIndex??e.active.selectedIndex}}:e:null}function m4(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function kJ(){const t=document.createElement("div");t.className="tandem-slash-menu__hint";const e=[["↑↓","navigate"],["↵","insert"],["esc","close"]];for(const[n,r]of e){const i=document.createElement("span"),o=document.createElement("kbd");o.textContent=n,i.appendChild(o),i.appendChild(document.createTextNode(` ${r}`)),t.appendChild(i)}return t}function xJ(t){const e=document.createElement("span");if(e.className="tandem-slash-menu__icon",e.setAttribute("aria-hidden","true"),t.kind==="glyph")return e.textContent=t.glyph,e;const n=document.createElementNS(W2,"svg");n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.6"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round");for(const r of t.els){const i=document.createElementNS(W2,r.tag);for(const[o,s]of Object.entries(r.attrs))i.setAttribute(o,s);n.appendChild(i)}return e.appendChild(n),e}function _J(t,e,n,r,i){const o=lg(e.query);m4(t),t.className="tandem-floating-pill tandem-slash-menu";const s=document.createElement("div");s.setAttribute("role","listbox"),s.setAttribute("aria-label","Slash commands"),o.forEach((l,c)=>{const d=document.createElement("button");d.type="button",d.role="option",d.id=`slash-command-${l.id}`,d.className="tandem-slash-menu__item",d.setAttribute("aria-selected",String(c===e.selectedIndex)),d.setAttribute("aria-label",l.label),d.dataset.commandId=l.id,d.appendChild(xJ(l.icon));const f=document.createElement("span");f.className="tandem-slash-menu__label",f.textContent=l.label,d.appendChild(f);const h=document.createElement("span");h.className="tandem-slash-menu__shortcut",h.setAttribute("aria-hidden","true"),h.textContent=l.hint,d.appendChild(h),d.addEventListener("mouseenter",()=>r(c)),d.addEventListener("mousedown",p=>{p.preventDefault(),i(l)}),s.appendChild(d)}),t.appendChild(s),t.appendChild(kJ());const a=n.view.coordsAtPos(e.from);t.style.display="block",t.style.position="fixed",t.style.left=`${Math.max(8,a.left)}px`,t.style.top=`${a.bottom+8}px`}function CJ(t,e){const n=lg(e.query)[e.selectedIndex];return n?(t.chain().focus().deleteRange({from:e.from,to:e.to}).run(),n.run(t),!0):!1}const SJ=sn.create({name:"slashCommand",addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){const t=this.editor,e=this.options.onOpenChange;return[new Vt({key:Wo,state:{init:()=>({active:null,dismissedKey:null}),apply(n,r,i,o){var l;const s=wJ(n,r);if(s)return s;const a=yJ(o,((l=r.active)==null?void 0:l.selectedIndex)??0);return a&&!r.active&&!bJ(n)?{active:null,dismissedKey:r.dismissedKey}:a&&p4(a)===r.dismissedKey?{active:null,dismissedKey:r.dismissedKey}:{active:a,dismissedKey:a?null:r.dismissedKey}}},props:{handleKeyDown(n,r){const i=Wo.getState(n.state),o=i==null?void 0:i.active;if(!o)return!1;const s=lg(o.query);if(r.key==="ArrowDown"){r.preventDefault();const a=(o.selectedIndex+1)%s.length;return n.dispatch(n.state.tr.setMeta(Wo,{type:"select",selectedIndex:a})),!0}if(r.key==="ArrowUp"){r.preventDefault();const a=(o.selectedIndex-1+s.length)%s.length;return n.dispatch(n.state.tr.setMeta(Wo,{type:"select",selectedIndex:a})),!0}return r.key==="Enter"?(r.preventDefault(),CJ(t,o)):r.key==="Escape"?(r.preventDefault(),n.dispatch(n.state.tr.setMeta(Wo,{type:"close"})),!0):!1}},view(n){const r=document.createElement("div");r.dataset.testid="slash-command-menu",r.style.display="none",document.body.appendChild(r);let i=!1;const o=l=>{l!==i&&(i=l,e==null||e(l))},s=()=>{r.style.display="none",m4(r),o(!1)},a=()=>{var c;const l=(c=Wo.getState(n.state))==null?void 0:c.active;if(!l){s();return}_J(r,l,t,d=>{n.dispatch(n.state.tr.setMeta(Wo,{type:"select",selectedIndex:d}))},d=>{t.chain().focus().deleteRange({from:l.from,to:l.to}).run(),d.run(t),s(),n.dispatch(n.state.tr.setMeta(Wo,{type:"close"}))}),o(!0)};return a(),{update:a,destroy(){o(!1),r.remove()}}}})]}}),K2={};function EJ(t){let e=K2[t];if(e)return e;e=K2[t]=[];for(let n=0;n<128;n++){const r=String.fromCharCode(n);e.push(r)}for(let n=0;n<t.length;n++){const r=t.charCodeAt(n);e[r]="%"+("0"+r.toString(16).toUpperCase()).slice(-2)}return e}function Ic(t,e){typeof e!="string"&&(e=Ic.defaultChars);const n=EJ(e);return t.replace(/(%[a-f0-9]{2})+/gi,function(r){let i="";for(let o=0,s=r.length;o<s;o+=3){const a=parseInt(r.slice(o+1,o+3),16);if(a<128){i+=n[a];continue}if((a&224)===192&&o+3<s){const l=parseInt(r.slice(o+4,o+6),16);if((l&192)===128){const c=a<<6&1984|l&63;c<128?i+="��":i+=String.fromCharCode(c),o+=3;continue}}if((a&240)===224&&o+6<s){const l=parseInt(r.slice(o+4,o+6),16),c=parseInt(r.slice(o+7,o+9),16);if((l&192)===128&&(c&192)===128){const d=a<<12&61440|l<<6&4032|c&63;d<2048||d>=55296&&d<=57343?i+="���":i+=String.fromCharCode(d),o+=6;continue}}if((a&248)===240&&o+9<s){const l=parseInt(r.slice(o+4,o+6),16),c=parseInt(r.slice(o+7,o+9),16),d=parseInt(r.slice(o+10,o+12),16);if((l&192)===128&&(c&192)===128&&(d&192)===128){let f=a<<18&1835008|l<<12&258048|c<<6&4032|d&63;f<65536||f>1114111?i+="����":(f-=65536,i+=String.fromCharCode(55296+(f>>10),56320+(f&1023))),o+=9;continue}}i+="�"}return i})}Ic.defaultChars=";/?:@&=+$,#";Ic.componentChars="";const G2={};function AJ(t){let e=G2[t];if(e)return e;e=G2[t]=[];for(let n=0;n<128;n++){const r=String.fromCharCode(n);/^[0-9a-z]$/i.test(r)?e.push(r):e.push("%"+("0"+n.toString(16).toUpperCase()).slice(-2))}for(let n=0;n<t.length;n++)e[t.charCodeAt(n)]=t[n];return e}function hf(t,e,n){typeof e!="string"&&(n=e,e=hf.defaultChars),typeof n>"u"&&(n=!0);const r=AJ(e);let i="";for(let o=0,s=t.length;o<s;o++){const a=t.charCodeAt(o);if(n&&a===37&&o+2<s&&/^[0-9a-f]{2}$/i.test(t.slice(o+1,o+3))){i+=t.slice(o,o+3),o+=2;continue}if(a<128){i+=r[a];continue}if(a>=55296&&a<=57343){if(a>=55296&&a<=56319&&o+1<s){const l=t.charCodeAt(o+1);if(l>=56320&&l<=57343){i+=encodeURIComponent(t[o]+t[o+1]),o++;continue}}i+="%EF%BF%BD";continue}i+=encodeURIComponent(t[o])}return i}hf.defaultChars=";/?:@&=+$,-_.!~*'()#";hf.componentChars="-_.!~*'()";function By(t){let e="";return e+=t.protocol||"",e+=t.slashes?"//":"",e+=t.auth?t.auth+"@":"",t.hostname&&t.hostname.indexOf(":")!==-1?e+="["+t.hostname+"]":e+=t.hostname||"",e+=t.port?":"+t.port:"",e+=t.pathname||"",e+=t.search||"",e+=t.hash||"",e}function am(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}const TJ=/^([a-z0-9.+-]+:)/i,MJ=/:[0-9]*$/,DJ=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,OJ=["<",">",'"',"`"," ","\r",`
222
+ `," "],IJ=["{","}","|","\\","^","`"].concat(OJ),RJ=["'"].concat(IJ),Z2=["%","/","?",";","#"].concat(RJ),Y2=["/","?","#"],NJ=255,J2=/^[+a-z0-9A-Z_-]{0,63}$/,PJ=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,X2={javascript:!0,"javascript:":!0},Q2={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Hy(t,e){if(t&&t instanceof am)return t;const n=new am;return n.parse(t,e),n}am.prototype.parse=function(t,e){let n,r,i,o=t;if(o=o.trim(),!e&&t.split("#").length===1){const c=DJ.exec(o);if(c)return this.pathname=c[1],c[2]&&(this.search=c[2]),this}let s=TJ.exec(o);if(s&&(s=s[0],n=s.toLowerCase(),this.protocol=s,o=o.substr(s.length)),(e||s||o.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i=o.substr(0,2)==="//",i&&!(s&&X2[s])&&(o=o.substr(2),this.slashes=!0)),!X2[s]&&(i||s&&!Q2[s])){let c=-1;for(let m=0;m<Y2.length;m++)r=o.indexOf(Y2[m]),r!==-1&&(c===-1||r<c)&&(c=r);let d,f;c===-1?f=o.lastIndexOf("@"):f=o.lastIndexOf("@",c),f!==-1&&(d=o.slice(0,f),o=o.slice(f+1),this.auth=d),c=-1;for(let m=0;m<Z2.length;m++)r=o.indexOf(Z2[m]),r!==-1&&(c===-1||r<c)&&(c=r);c===-1&&(c=o.length),o[c-1]===":"&&c--;const h=o.slice(0,c);o=o.slice(c),this.parseHost(h),this.hostname=this.hostname||"";const p=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!p){const m=this.hostname.split(/\./);for(let v=0,g=m.length;v<g;v++){const y=m[v];if(y&&!y.match(J2)){let C="";for(let _=0,S=y.length;_<S;_++)y.charCodeAt(_)>127?C+="x":C+=y[_];if(!C.match(J2)){const _=m.slice(0,v),S=m.slice(v+1),A=y.match(PJ);A&&(_.push(A[1]),S.unshift(A[2])),S.length&&(o=S.join(".")+o),this.hostname=_.join(".");break}}}}this.hostname.length>NJ&&(this.hostname=""),p&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const a=o.indexOf("#");a!==-1&&(this.hash=o.substr(a),o=o.slice(0,a));const l=o.indexOf("?");return l!==-1&&(this.search=o.substr(l),o=o.slice(0,l)),o&&(this.pathname=o),Q2[n]&&this.hostname&&!this.pathname&&(this.pathname=""),this};am.prototype.parseHost=function(t){let e=MJ.exec(t);e&&(e=e[0],e!==":"&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)};const LJ=Object.freeze(Object.defineProperty({__proto__:null,decode:Ic,encode:hf,format:By,parse:Hy},Symbol.toStringTag,{value:"Module"})),g4=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,v4=/[\0-\x1F\x7F-\x9F]/,FJ=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,Vy=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,b4=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,y4=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,zJ=Object.freeze(Object.defineProperty({__proto__:null,Any:g4,Cc:v4,Cf:FJ,P:Vy,S:b4,Z:y4},Symbol.toStringTag,{value:"Module"})),BJ=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(t=>t.charCodeAt(0))),HJ=new Uint16Array("Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map(t=>t.charCodeAt(0)));var N0;const VJ=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),UJ=(N0=String.fromCodePoint)!==null&&N0!==void 0?N0:function(t){let e="";return t>65535&&(t-=65536,e+=String.fromCharCode(t>>>10&1023|55296),t=56320|t&1023),e+=String.fromCharCode(t),e};function jJ(t){var e;return t>=55296&&t<=57343||t>1114111?65533:(e=VJ.get(t))!==null&&e!==void 0?e:t}var Jn;(function(t){t[t.NUM=35]="NUM",t[t.SEMI=59]="SEMI",t[t.EQUALS=61]="EQUALS",t[t.ZERO=48]="ZERO",t[t.NINE=57]="NINE",t[t.LOWER_A=97]="LOWER_A",t[t.LOWER_F=102]="LOWER_F",t[t.LOWER_X=120]="LOWER_X",t[t.LOWER_Z=122]="LOWER_Z",t[t.UPPER_A=65]="UPPER_A",t[t.UPPER_F=70]="UPPER_F",t[t.UPPER_Z=90]="UPPER_Z"})(Jn||(Jn={}));const qJ=32;var Us;(function(t){t[t.VALUE_LENGTH=49152]="VALUE_LENGTH",t[t.BRANCH_LENGTH=16256]="BRANCH_LENGTH",t[t.JUMP_TABLE=127]="JUMP_TABLE"})(Us||(Us={}));function Ub(t){return t>=Jn.ZERO&&t<=Jn.NINE}function WJ(t){return t>=Jn.UPPER_A&&t<=Jn.UPPER_F||t>=Jn.LOWER_A&&t<=Jn.LOWER_F}function KJ(t){return t>=Jn.UPPER_A&&t<=Jn.UPPER_Z||t>=Jn.LOWER_A&&t<=Jn.LOWER_Z||Ub(t)}function GJ(t){return t===Jn.EQUALS||KJ(t)}var Gn;(function(t){t[t.EntityStart=0]="EntityStart",t[t.NumericStart=1]="NumericStart",t[t.NumericDecimal=2]="NumericDecimal",t[t.NumericHex=3]="NumericHex",t[t.NamedEntity=4]="NamedEntity"})(Gn||(Gn={}));var Is;(function(t){t[t.Legacy=0]="Legacy",t[t.Strict=1]="Strict",t[t.Attribute=2]="Attribute"})(Is||(Is={}));class ZJ{constructor(e,n,r){this.decodeTree=e,this.emitCodePoint=n,this.errors=r,this.state=Gn.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Is.Strict}startEntity(e){this.decodeMode=e,this.state=Gn.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,n){switch(this.state){case Gn.EntityStart:return e.charCodeAt(n)===Jn.NUM?(this.state=Gn.NumericStart,this.consumed+=1,this.stateNumericStart(e,n+1)):(this.state=Gn.NamedEntity,this.stateNamedEntity(e,n));case Gn.NumericStart:return this.stateNumericStart(e,n);case Gn.NumericDecimal:return this.stateNumericDecimal(e,n);case Gn.NumericHex:return this.stateNumericHex(e,n);case Gn.NamedEntity:return this.stateNamedEntity(e,n)}}stateNumericStart(e,n){return n>=e.length?-1:(e.charCodeAt(n)|qJ)===Jn.LOWER_X?(this.state=Gn.NumericHex,this.consumed+=1,this.stateNumericHex(e,n+1)):(this.state=Gn.NumericDecimal,this.stateNumericDecimal(e,n))}addToNumericResult(e,n,r,i){if(n!==r){const o=r-n;this.result=this.result*Math.pow(i,o)+parseInt(e.substr(n,o),i),this.consumed+=o}}stateNumericHex(e,n){const r=n;for(;n<e.length;){const i=e.charCodeAt(n);if(Ub(i)||WJ(i))n+=1;else return this.addToNumericResult(e,r,n,16),this.emitNumericEntity(i,3)}return this.addToNumericResult(e,r,n,16),-1}stateNumericDecimal(e,n){const r=n;for(;n<e.length;){const i=e.charCodeAt(n);if(Ub(i))n+=1;else return this.addToNumericResult(e,r,n,10),this.emitNumericEntity(i,2)}return this.addToNumericResult(e,r,n,10),-1}emitNumericEntity(e,n){var r;if(this.consumed<=n)return(r=this.errors)===null||r===void 0||r.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===Jn.SEMI)this.consumed+=1;else if(this.decodeMode===Is.Strict)return 0;return this.emitCodePoint(jJ(this.result),this.consumed),this.errors&&(e!==Jn.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,n){const{decodeTree:r}=this;let i=r[this.treeIndex],o=(i&Us.VALUE_LENGTH)>>14;for(;n<e.length;n++,this.excess++){const s=e.charCodeAt(n);if(this.treeIndex=YJ(r,i,this.treeIndex+Math.max(1,o),s),this.treeIndex<0)return this.result===0||this.decodeMode===Is.Attribute&&(o===0||GJ(s))?0:this.emitNotTerminatedNamedEntity();if(i=r[this.treeIndex],o=(i&Us.VALUE_LENGTH)>>14,o!==0){if(s===Jn.SEMI)return this.emitNamedEntityData(this.treeIndex,o,this.consumed+this.excess);this.decodeMode!==Is.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;const{result:n,decodeTree:r}=this,i=(r[n]&Us.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,i,this.consumed),(e=this.errors)===null||e===void 0||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,n,r){const{decodeTree:i}=this;return this.emitCodePoint(n===1?i[e]&~Us.VALUE_LENGTH:i[e+1],r),n===3&&this.emitCodePoint(i[e+2],r),r}end(){var e;switch(this.state){case Gn.NamedEntity:return this.result!==0&&(this.decodeMode!==Is.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Gn.NumericDecimal:return this.emitNumericEntity(0,2);case Gn.NumericHex:return this.emitNumericEntity(0,3);case Gn.NumericStart:return(e=this.errors)===null||e===void 0||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Gn.EntityStart:return 0}}}function w4(t){let e="";const n=new ZJ(t,r=>e+=UJ(r));return function(i,o){let s=0,a=0;for(;(a=i.indexOf("&",a))>=0;){e+=i.slice(s,a),n.startEntity(o);const c=n.write(i,a+1);if(c<0){s=a+n.end();break}s=a+c,a=c===0?s+1:s}const l=e+i.slice(s);return e="",l}}function YJ(t,e,n,r){const i=(e&Us.BRANCH_LENGTH)>>7,o=e&Us.JUMP_TABLE;if(i===0)return o!==0&&r===o?n:-1;if(o){const l=r-o;return l<0||l>=i?-1:t[n+l]-1}let s=n,a=s+i-1;for(;s<=a;){const l=s+a>>>1,c=t[l];if(c<r)s=l+1;else if(c>r)a=l-1;else return t[l+i]}return-1}const JJ=w4(BJ);w4(HJ);function k4(t,e=Is.Legacy){return JJ(t,e)}function XJ(t){return Object.prototype.toString.call(t)}function Uy(t){return XJ(t)==="[object String]"}const QJ=Object.prototype.hasOwnProperty;function $J(t,e){return QJ.call(t,e)}function cg(t){return Array.prototype.slice.call(arguments,1).forEach(function(n){if(n){if(typeof n!="object")throw new TypeError(n+"must be object");Object.keys(n).forEach(function(r){t[r]=n[r]})}}),t}function x4(t,e,n){return[].concat(t.slice(0,e),n,t.slice(e+1))}function jy(t){return!(t>=55296&&t<=57343||t>=64976&&t<=65007||(t&65535)===65535||(t&65535)===65534||t>=0&&t<=8||t===11||t>=14&&t<=31||t>=127&&t<=159||t>1114111)}function lm(t){if(t>65535){t-=65536;const e=55296+(t>>10),n=56320+(t&1023);return String.fromCharCode(e,n)}return String.fromCharCode(t)}const _4=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,eX=/&([a-z#][a-z0-9]{1,31});/gi,tX=new RegExp(_4.source+"|"+eX.source,"gi"),nX=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function rX(t,e){if(e.charCodeAt(0)===35&&nX.test(e)){const r=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return jy(r)?lm(r):t}const n=k4(t);return n!==t?n:t}function iX(t){return t.indexOf("\\")<0?t:t.replace(_4,"$1")}function Rc(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(tX,function(e,n,r){return n||rX(e,r)})}const oX=/[&<>"]/,sX=/[&<>"]/g,aX={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function lX(t){return aX[t]}function oa(t){return oX.test(t)?t.replace(sX,lX):t}const cX=/[.?*+^$[\]\\(){}|-]/g;function uX(t){return t.replace(cX,"\\$&")}function cn(t){switch(t){case 9:case 32:return!0}return!1}function Md(t){if(t>=8192&&t<=8202)return!0;switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function Dd(t){return Vy.test(t)||b4.test(t)}function Od(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function ug(t){return t=t.trim().replace(/\s+/g," "),"ẞ".toLowerCase()==="Ṿ"&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}const dX={mdurl:LJ,ucmicro:zJ},fX=Object.freeze(Object.defineProperty({__proto__:null,arrayReplaceAt:x4,assign:cg,escapeHtml:oa,escapeRE:uX,fromCodePoint:lm,has:$J,isMdAsciiPunct:Od,isPunctChar:Dd,isSpace:cn,isString:Uy,isValidEntityCode:jy,isWhiteSpace:Md,lib:dX,normalizeReference:ug,unescapeAll:Rc,unescapeMd:iX},Symbol.toStringTag,{value:"Module"}));function hX(t,e,n){let r,i,o,s;const a=t.posMax,l=t.pos;for(t.pos=e+1,r=1;t.pos<a;){if(o=t.src.charCodeAt(t.pos),o===93&&(r--,r===0)){i=!0;break}if(s=t.pos,t.md.inline.skipToken(t),o===91){if(s===t.pos-1)r++;else if(n)return t.pos=l,-1}}let c=-1;return i&&(c=t.pos),t.pos=l,c}function pX(t,e,n){let r,i=e;const o={ok:!1,pos:0,str:""};if(t.charCodeAt(i)===60){for(i++;i<n;){if(r=t.charCodeAt(i),r===10||r===60)return o;if(r===62)return o.pos=i+1,o.str=Rc(t.slice(e+1,i)),o.ok=!0,o;if(r===92&&i+1<n){i+=2;continue}i++}return o}let s=0;for(;i<n&&(r=t.charCodeAt(i),!(r===32||r<32||r===127));){if(r===92&&i+1<n){if(t.charCodeAt(i+1)===32)break;i+=2;continue}if(r===40&&(s++,s>32))return o;if(r===41){if(s===0)break;s--}i++}return e===i||s!==0||(o.str=Rc(t.slice(e,i)),o.pos=i,o.ok=!0),o}function mX(t,e,n,r){let i,o=e;const s={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(r)s.str=r.str,s.marker=r.marker;else{if(o>=n)return s;let a=t.charCodeAt(o);if(a!==34&&a!==39&&a!==40)return s;e++,o++,a===40&&(a=41),s.marker=a}for(;o<n;){if(i=t.charCodeAt(o),i===s.marker)return s.pos=o+1,s.str+=Rc(t.slice(e,o)),s.ok=!0,s;if(i===40&&s.marker===41)return s;i===92&&o+1<n&&o++,o++}return s.can_continue=!0,s.str+=Rc(t.slice(e,o)),s}const gX=Object.freeze(Object.defineProperty({__proto__:null,parseLinkDestination:pX,parseLinkLabel:hX,parseLinkTitle:mX},Symbol.toStringTag,{value:"Module"})),Lo={};Lo.code_inline=function(t,e,n,r,i){const o=t[e];return"<code"+i.renderAttrs(o)+">"+oa(o.content)+"</code>"};Lo.code_block=function(t,e,n,r,i){const o=t[e];return"<pre"+i.renderAttrs(o)+"><code>"+oa(t[e].content)+`</code></pre>
223
+ `};Lo.fence=function(t,e,n,r,i){const o=t[e],s=o.info?Rc(o.info).trim():"";let a="",l="";if(s){const d=s.split(/(\s+)/g);a=d[0],l=d.slice(2).join("")}let c;if(n.highlight?c=n.highlight(o.content,a,l)||oa(o.content):c=oa(o.content),c.indexOf("<pre")===0)return c+`
224
+ `;if(s){const d=o.attrIndex("class"),f=o.attrs?o.attrs.slice():[];d<0?f.push(["class",n.langPrefix+a]):(f[d]=f[d].slice(),f[d][1]+=" "+n.langPrefix+a);const h={attrs:f};return`<pre><code${i.renderAttrs(h)}>${c}</code></pre>
225
+ `}return`<pre><code${i.renderAttrs(o)}>${c}</code></pre>
226
+ `};Lo.image=function(t,e,n,r,i){const o=t[e];return o.attrs[o.attrIndex("alt")][1]=i.renderInlineAsText(o.children,n,r),i.renderToken(t,e,n)};Lo.hardbreak=function(t,e,n){return n.xhtmlOut?`<br />
227
+ `:`<br>
228
+ `};Lo.softbreak=function(t,e,n){return n.breaks?n.xhtmlOut?`<br />
229
+ `:`<br>
230
+ `:`
231
+ `};Lo.text=function(t,e){return oa(t[e].content)};Lo.html_block=function(t,e){return t[e].content};Lo.html_inline=function(t,e){return t[e].content};function Yc(){this.rules=cg({},Lo)}Yc.prototype.renderAttrs=function(e){let n,r,i;if(!e.attrs)return"";for(i="",n=0,r=e.attrs.length;n<r;n++)i+=" "+oa(e.attrs[n][0])+'="'+oa(e.attrs[n][1])+'"';return i};Yc.prototype.renderToken=function(e,n,r){const i=e[n];let o="";if(i.hidden)return"";i.block&&i.nesting!==-1&&n&&e[n-1].hidden&&(o+=`
232
+ `),o+=(i.nesting===-1?"</":"<")+i.tag,o+=this.renderAttrs(i),i.nesting===0&&r.xhtmlOut&&(o+=" /");let s=!1;if(i.block&&(s=!0,i.nesting===1&&n+1<e.length)){const a=e[n+1];(a.type==="inline"||a.hidden||a.nesting===-1&&a.tag===i.tag)&&(s=!1)}return o+=s?`>
233
+ `:">",o};Yc.prototype.renderInline=function(t,e,n){let r="";const i=this.rules;for(let o=0,s=t.length;o<s;o++){const a=t[o].type;typeof i[a]<"u"?r+=i[a](t,o,e,n,this):r+=this.renderToken(t,o,e)}return r};Yc.prototype.renderInlineAsText=function(t,e,n){let r="";for(let i=0,o=t.length;i<o;i++)switch(t[i].type){case"text":r+=t[i].content;break;case"image":r+=this.renderInlineAsText(t[i].children,e,n);break;case"html_inline":case"html_block":r+=t[i].content;break;case"softbreak":case"hardbreak":r+=`
234
+ `;break}return r};Yc.prototype.render=function(t,e,n){let r="";const i=this.rules;for(let o=0,s=t.length;o<s;o++){const a=t[o].type;a==="inline"?r+=this.renderInline(t[o].children,e,n):typeof i[a]<"u"?r+=i[a](t,o,e,n,this):r+=this.renderToken(t,o,e,n)}return r};function Wr(){this.__rules__=[],this.__cache__=null}Wr.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===t)return e;return-1};Wr.prototype.__compile__=function(){const t=this,e=[""];t.__rules__.forEach(function(n){n.enabled&&n.alt.forEach(function(r){e.indexOf(r)<0&&e.push(r)})}),t.__cache__={},e.forEach(function(n){t.__cache__[n]=[],t.__rules__.forEach(function(r){r.enabled&&(n&&r.alt.indexOf(n)<0||t.__cache__[n].push(r.fn))})})};Wr.prototype.at=function(t,e,n){const r=this.__find__(t),i=n||{};if(r===-1)throw new Error("Parser rule not found: "+t);this.__rules__[r].fn=e,this.__rules__[r].alt=i.alt||[],this.__cache__=null};Wr.prototype.before=function(t,e,n,r){const i=this.__find__(t),o=r||{};if(i===-1)throw new Error("Parser rule not found: "+t);this.__rules__.splice(i,0,{name:e,enabled:!0,fn:n,alt:o.alt||[]}),this.__cache__=null};Wr.prototype.after=function(t,e,n,r){const i=this.__find__(t),o=r||{};if(i===-1)throw new Error("Parser rule not found: "+t);this.__rules__.splice(i+1,0,{name:e,enabled:!0,fn:n,alt:o.alt||[]}),this.__cache__=null};Wr.prototype.push=function(t,e,n){const r=n||{};this.__rules__.push({name:t,enabled:!0,fn:e,alt:r.alt||[]}),this.__cache__=null};Wr.prototype.enable=function(t,e){Array.isArray(t)||(t=[t]);const n=[];return t.forEach(function(r){const i=this.__find__(r);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+r)}this.__rules__[i].enabled=!0,n.push(r)},this),this.__cache__=null,n};Wr.prototype.enableOnly=function(t,e){Array.isArray(t)||(t=[t]),this.__rules__.forEach(function(n){n.enabled=!1}),this.enable(t,e)};Wr.prototype.disable=function(t,e){Array.isArray(t)||(t=[t]);const n=[];return t.forEach(function(r){const i=this.__find__(r);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+r)}this.__rules__[i].enabled=!1,n.push(r)},this),this.__cache__=null,n};Wr.prototype.getRules=function(t){return this.__cache__===null&&this.__compile__(),this.__cache__[t]||[]};function io(t,e,n){this.type=t,this.tag=e,this.attrs=null,this.map=null,this.nesting=n,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}io.prototype.attrIndex=function(e){if(!this.attrs)return-1;const n=this.attrs;for(let r=0,i=n.length;r<i;r++)if(n[r][0]===e)return r;return-1};io.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};io.prototype.attrSet=function(e,n){const r=this.attrIndex(e),i=[e,n];r<0?this.attrPush(i):this.attrs[r]=i};io.prototype.attrGet=function(e){const n=this.attrIndex(e);let r=null;return n>=0&&(r=this.attrs[n][1]),r};io.prototype.attrJoin=function(e,n){const r=this.attrIndex(e);r<0?this.attrPush([e,n]):this.attrs[r][1]=this.attrs[r][1]+" "+n};function C4(t,e,n){this.src=t,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=e}C4.prototype.Token=io;const vX=/\r\n?|\n/g,bX=/\0/g;function yX(t){let e;e=t.src.replace(vX,`
235
+ `),e=e.replace(bX,"�"),t.src=e}function wX(t){let e;t.inlineMode?(e=new t.Token("inline","",0),e.content=t.src,e.map=[0,1],e.children=[],t.tokens.push(e)):t.md.block.parse(t.src,t.md,t.env,t.tokens)}function kX(t){const e=t.tokens;for(let n=0,r=e.length;n<r;n++){const i=e[n];i.type==="inline"&&t.md.inline.parse(i.content,t.md,t.env,i.children)}}function xX(t){return/^<a[>\s]/i.test(t)}function _X(t){return/^<\/a\s*>/i.test(t)}function CX(t){const e=t.tokens;if(t.md.options.linkify)for(let n=0,r=e.length;n<r;n++){if(e[n].type!=="inline"||!t.md.linkify.pretest(e[n].content))continue;let i=e[n].children,o=0;for(let s=i.length-1;s>=0;s--){const a=i[s];if(a.type==="link_close"){for(s--;i[s].level!==a.level&&i[s].type!=="link_open";)s--;continue}if(a.type==="html_inline"&&(xX(a.content)&&o>0&&o--,_X(a.content)&&o++),!(o>0)&&a.type==="text"&&t.md.linkify.test(a.content)){const l=a.content;let c=t.md.linkify.match(l);const d=[];let f=a.level,h=0;c.length>0&&c[0].index===0&&s>0&&i[s-1].type==="text_special"&&(c=c.slice(1));for(let p=0;p<c.length;p++){const m=c[p].url,v=t.md.normalizeLink(m);if(!t.md.validateLink(v))continue;let g=c[p].text;c[p].schema?c[p].schema==="mailto:"&&!/^mailto:/i.test(g)?g=t.md.normalizeLinkText("mailto:"+g).replace(/^mailto:/,""):g=t.md.normalizeLinkText(g):g=t.md.normalizeLinkText("http://"+g).replace(/^http:\/\//,"");const y=c[p].index;if(y>h){const A=new t.Token("text","",0);A.content=l.slice(h,y),A.level=f,d.push(A)}const C=new t.Token("link_open","a",1);C.attrs=[["href",v]],C.level=f++,C.markup="linkify",C.info="auto",d.push(C);const _=new t.Token("text","",0);_.content=g,_.level=f,d.push(_);const S=new t.Token("link_close","a",-1);S.level=--f,S.markup="linkify",S.info="auto",d.push(S),h=c[p].lastIndex}if(h<l.length){const p=new t.Token("text","",0);p.content=l.slice(h),p.level=f,d.push(p)}e[n].children=i=x4(i,s,d)}}}}const S4=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,SX=/\((c|tm|r)\)/i,EX=/\((c|tm|r)\)/ig,AX={c:"©",r:"®",tm:"™"};function TX(t,e){return AX[e.toLowerCase()]}function MX(t){let e=0;for(let n=t.length-1;n>=0;n--){const r=t[n];r.type==="text"&&!e&&(r.content=r.content.replace(EX,TX)),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function DX(t){let e=0;for(let n=t.length-1;n>=0;n--){const r=t[n];r.type==="text"&&!e&&S4.test(r.content)&&(r.content=r.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/mg,"$1—").replace(/(^|\s)--(?=\s|$)/mg,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1–")),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function OX(t){let e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)t.tokens[e].type==="inline"&&(SX.test(t.tokens[e].content)&&MX(t.tokens[e].children),S4.test(t.tokens[e].content)&&DX(t.tokens[e].children))}const IX=/['"]/,$2=/['"]/g,e_="’";function eh(t,e,n){return t.slice(0,e)+n+t.slice(e+1)}function RX(t,e){let n;const r=[];for(let i=0;i<t.length;i++){const o=t[i],s=t[i].level;for(n=r.length-1;n>=0&&!(r[n].level<=s);n--);if(r.length=n+1,o.type!=="text")continue;let a=o.content,l=0,c=a.length;e:for(;l<c;){$2.lastIndex=l;const d=$2.exec(a);if(!d)break;let f=!0,h=!0;l=d.index+1;const p=d[0]==="'";let m=32;if(d.index-1>=0)m=a.charCodeAt(d.index-1);else for(n=i-1;n>=0&&!(t[n].type==="softbreak"||t[n].type==="hardbreak");n--)if(t[n].content){m=t[n].content.charCodeAt(t[n].content.length-1);break}let v=32;if(l<c)v=a.charCodeAt(l);else for(n=i+1;n<t.length&&!(t[n].type==="softbreak"||t[n].type==="hardbreak");n++)if(t[n].content){v=t[n].content.charCodeAt(0);break}const g=Od(m)||Dd(String.fromCharCode(m)),y=Od(v)||Dd(String.fromCharCode(v)),C=Md(m),_=Md(v);if(_?f=!1:y&&(C||g||(f=!1)),C?h=!1:g&&(_||y||(h=!1)),v===34&&d[0]==='"'&&m>=48&&m<=57&&(h=f=!1),f&&h&&(f=g,h=y),!f&&!h){p&&(o.content=eh(o.content,d.index,e_));continue}if(h)for(n=r.length-1;n>=0;n--){let S=r[n];if(r[n].level<s)break;if(S.single===p&&r[n].level===s){S=r[n];let A,O;p?(A=e.md.options.quotes[2],O=e.md.options.quotes[3]):(A=e.md.options.quotes[0],O=e.md.options.quotes[1]),o.content=eh(o.content,d.index,O),t[S.token].content=eh(t[S.token].content,S.pos,A),l+=O.length-1,S.token===i&&(l+=A.length-1),a=o.content,c=a.length,r.length=n;continue e}}f?r.push({token:i,pos:d.index,single:p,level:s}):h&&p&&(o.content=eh(o.content,d.index,e_))}}}function NX(t){if(t.md.options.typographer)for(let e=t.tokens.length-1;e>=0;e--)t.tokens[e].type!=="inline"||!IX.test(t.tokens[e].content)||RX(t.tokens[e].children,t)}function PX(t){let e,n;const r=t.tokens,i=r.length;for(let o=0;o<i;o++){if(r[o].type!=="inline")continue;const s=r[o].children,a=s.length;for(e=0;e<a;e++)s[e].type==="text_special"&&(s[e].type="text");for(e=n=0;e<a;e++)s[e].type==="text"&&e+1<a&&s[e+1].type==="text"?s[e+1].content=s[e].content+s[e+1].content:(e!==n&&(s[n]=s[e]),n++);e!==n&&(s.length=n)}}const P0=[["normalize",yX],["block",wX],["inline",kX],["linkify",CX],["replacements",OX],["smartquotes",NX],["text_join",PX]];function qy(){this.ruler=new Wr;for(let t=0;t<P0.length;t++)this.ruler.push(P0[t][0],P0[t][1])}qy.prototype.process=function(t){const e=this.ruler.getRules("");for(let n=0,r=e.length;n<r;n++)e[n](t)};qy.prototype.State=C4;function Fo(t,e,n,r){this.src=t,this.md=e,this.env=n,this.tokens=r,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const i=this.src;for(let o=0,s=0,a=0,l=0,c=i.length,d=!1;s<c;s++){const f=i.charCodeAt(s);if(!d)if(cn(f)){a++,f===9?l+=4-l%4:l++;continue}else d=!0;(f===10||s===c-1)&&(f!==10&&s++,this.bMarks.push(o),this.eMarks.push(s),this.tShift.push(a),this.sCount.push(l),this.bsCount.push(0),d=!1,a=0,l=0,o=s+1)}this.bMarks.push(i.length),this.eMarks.push(i.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}Fo.prototype.push=function(t,e,n){const r=new io(t,e,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r};Fo.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Fo.prototype.skipEmptyLines=function(e){for(let n=this.lineMax;e<n&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};Fo.prototype.skipSpaces=function(e){for(let n=this.src.length;e<n;e++){const r=this.src.charCodeAt(e);if(!cn(r))break}return e};Fo.prototype.skipSpacesBack=function(e,n){if(e<=n)return e;for(;e>n;)if(!cn(this.src.charCodeAt(--e)))return e+1;return e};Fo.prototype.skipChars=function(e,n){for(let r=this.src.length;e<r&&this.src.charCodeAt(e)===n;e++);return e};Fo.prototype.skipCharsBack=function(e,n,r){if(e<=r)return e;for(;e>r;)if(n!==this.src.charCodeAt(--e))return e+1;return e};Fo.prototype.getLines=function(e,n,r,i){if(e>=n)return"";const o=new Array(n-e);for(let s=0,a=e;a<n;a++,s++){let l=0;const c=this.bMarks[a];let d=c,f;for(a+1<n||i?f=this.eMarks[a]+1:f=this.eMarks[a];d<f&&l<r;){const h=this.src.charCodeAt(d);if(cn(h))h===9?l+=4-(l+this.bsCount[a])%4:l++;else if(d-c<this.tShift[a])l++;else break;d++}l>r?o[s]=new Array(l-r+1).join(" ")+this.src.slice(d,f):o[s]=this.src.slice(d,f)}return o.join("")};Fo.prototype.Token=io;const LX=65536;function L0(t,e){const n=t.bMarks[e]+t.tShift[e],r=t.eMarks[e];return t.src.slice(n,r)}function t_(t){const e=[],n=t.length;let r=0,i=t.charCodeAt(r),o=!1,s=0,a="";for(;r<n;)i===124&&(o?(a+=t.substring(s,r-1),s=r):(e.push(a+t.substring(s,r)),a="",s=r+1)),o=i===92,r++,i=t.charCodeAt(r);return e.push(a+t.substring(s)),e}function FX(t,e,n,r){if(e+2>n)return!1;let i=e+1;if(t.sCount[i]<t.blkIndent||t.sCount[i]-t.blkIndent>=4)return!1;let o=t.bMarks[i]+t.tShift[i];if(o>=t.eMarks[i])return!1;const s=t.src.charCodeAt(o++);if(s!==124&&s!==45&&s!==58||o>=t.eMarks[i])return!1;const a=t.src.charCodeAt(o++);if(a!==124&&a!==45&&a!==58&&!cn(a)||s===45&&cn(a))return!1;for(;o<t.eMarks[i];){const S=t.src.charCodeAt(o);if(S!==124&&S!==45&&S!==58&&!cn(S))return!1;o++}let l=L0(t,e+1),c=l.split("|");const d=[];for(let S=0;S<c.length;S++){const A=c[S].trim();if(!A){if(S===0||S===c.length-1)continue;return!1}if(!/^:?-+:?$/.test(A))return!1;A.charCodeAt(A.length-1)===58?d.push(A.charCodeAt(0)===58?"center":"right"):A.charCodeAt(0)===58?d.push("left"):d.push("")}if(l=L0(t,e).trim(),l.indexOf("|")===-1||t.sCount[e]-t.blkIndent>=4)return!1;c=t_(l),c.length&&c[0]===""&&c.shift(),c.length&&c[c.length-1]===""&&c.pop();const f=c.length;if(f===0||f!==d.length)return!1;if(r)return!0;const h=t.parentType;t.parentType="table";const p=t.md.block.ruler.getRules("blockquote"),m=t.push("table_open","table",1),v=[e,0];m.map=v;const g=t.push("thead_open","thead",1);g.map=[e,e+1];const y=t.push("tr_open","tr",1);y.map=[e,e+1];for(let S=0;S<c.length;S++){const A=t.push("th_open","th",1);d[S]&&(A.attrs=[["style","text-align:"+d[S]]]);const O=t.push("inline","",0);O.content=c[S].trim(),O.children=[],t.push("th_close","th",-1)}t.push("tr_close","tr",-1),t.push("thead_close","thead",-1);let C,_=0;for(i=e+2;i<n&&!(t.sCount[i]<t.blkIndent);i++){let S=!1;for(let O=0,E=p.length;O<E;O++)if(p[O](t,i,n,!0)){S=!0;break}if(S||(l=L0(t,i).trim(),!l)||t.sCount[i]-t.blkIndent>=4||(c=t_(l),c.length&&c[0]===""&&c.shift(),c.length&&c[c.length-1]===""&&c.pop(),_+=f-c.length,_>LX))break;if(i===e+2){const O=t.push("tbody_open","tbody",1);O.map=C=[e+2,0]}const A=t.push("tr_open","tr",1);A.map=[i,i+1];for(let O=0;O<f;O++){const E=t.push("td_open","td",1);d[O]&&(E.attrs=[["style","text-align:"+d[O]]]);const M=t.push("inline","",0);M.content=c[O]?c[O].trim():"",M.children=[],t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}return C&&(t.push("tbody_close","tbody",-1),C[1]=i),t.push("table_close","table",-1),v[1]=i,t.parentType=h,t.line=i,!0}function zX(t,e,n){if(t.sCount[e]-t.blkIndent<4)return!1;let r=e+1,i=r;for(;r<n;){if(t.isEmpty(r)){r++;continue}if(t.sCount[r]-t.blkIndent>=4){r++,i=r;continue}break}t.line=i;const o=t.push("code_block","code",0);return o.content=t.getLines(e,i,4+t.blkIndent,!1)+`
236
+ `,o.map=[e,t.line],!0}function BX(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4||i+3>o)return!1;const s=t.src.charCodeAt(i);if(s!==126&&s!==96)return!1;let a=i;i=t.skipChars(i,s);let l=i-a;if(l<3)return!1;const c=t.src.slice(a,i),d=t.src.slice(i,o);if(s===96&&d.indexOf(String.fromCharCode(s))>=0)return!1;if(r)return!0;let f=e,h=!1;for(;f++,!(f>=n||(i=a=t.bMarks[f]+t.tShift[f],o=t.eMarks[f],i<o&&t.sCount[f]<t.blkIndent));)if(t.src.charCodeAt(i)===s&&!(t.sCount[f]-t.blkIndent>=4)&&(i=t.skipChars(i,s),!(i-a<l)&&(i=t.skipSpaces(i),!(i<o)))){h=!0;break}l=t.sCount[e],t.line=f+(h?1:0);const p=t.push("fence","code",0);return p.info=d,p.content=t.getLines(e+1,f,l,!0),p.markup=c,p.map=[e,t.line],!0}function HX(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];const s=t.lineMax;if(t.sCount[e]-t.blkIndent>=4||t.src.charCodeAt(i)!==62)return!1;if(r)return!0;const a=[],l=[],c=[],d=[],f=t.md.block.ruler.getRules("blockquote"),h=t.parentType;t.parentType="blockquote";let p=!1,m;for(m=e;m<n;m++){const _=t.sCount[m]<t.blkIndent;if(i=t.bMarks[m]+t.tShift[m],o=t.eMarks[m],i>=o)break;if(t.src.charCodeAt(i++)===62&&!_){let A=t.sCount[m]+1,O,E;t.src.charCodeAt(i)===32?(i++,A++,E=!1,O=!0):t.src.charCodeAt(i)===9?(O=!0,(t.bsCount[m]+A)%4===3?(i++,A++,E=!1):E=!0):O=!1;let M=A;for(a.push(t.bMarks[m]),t.bMarks[m]=i;i<o;){const R=t.src.charCodeAt(i);if(cn(R))R===9?M+=4-(M+t.bsCount[m]+(E?1:0))%4:M++;else break;i++}p=i>=o,l.push(t.bsCount[m]),t.bsCount[m]=t.sCount[m]+1+(O?1:0),c.push(t.sCount[m]),t.sCount[m]=M-A,d.push(t.tShift[m]),t.tShift[m]=i-t.bMarks[m];continue}if(p)break;let S=!1;for(let A=0,O=f.length;A<O;A++)if(f[A](t,m,n,!0)){S=!0;break}if(S){t.lineMax=m,t.blkIndent!==0&&(a.push(t.bMarks[m]),l.push(t.bsCount[m]),d.push(t.tShift[m]),c.push(t.sCount[m]),t.sCount[m]-=t.blkIndent);break}a.push(t.bMarks[m]),l.push(t.bsCount[m]),d.push(t.tShift[m]),c.push(t.sCount[m]),t.sCount[m]=-1}const v=t.blkIndent;t.blkIndent=0;const g=t.push("blockquote_open","blockquote",1);g.markup=">";const y=[e,0];g.map=y,t.md.block.tokenize(t,e,m);const C=t.push("blockquote_close","blockquote",-1);C.markup=">",t.lineMax=s,t.parentType=h,y[1]=t.line;for(let _=0;_<d.length;_++)t.bMarks[_+e]=a[_],t.tShift[_+e]=d[_],t.sCount[_+e]=c[_],t.bsCount[_+e]=l[_];return t.blkIndent=v,!0}function VX(t,e,n,r){const i=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let o=t.bMarks[e]+t.tShift[e];const s=t.src.charCodeAt(o++);if(s!==42&&s!==45&&s!==95)return!1;let a=1;for(;o<i;){const c=t.src.charCodeAt(o++);if(c!==s&&!cn(c))return!1;c===s&&a++}if(a<3)return!1;if(r)return!0;t.line=e+1;const l=t.push("hr","hr",0);return l.map=[e,t.line],l.markup=Array(a+1).join(String.fromCharCode(s)),!0}function n_(t,e){const n=t.eMarks[e];let r=t.bMarks[e]+t.tShift[e];const i=t.src.charCodeAt(r++);if(i!==42&&i!==45&&i!==43)return-1;if(r<n){const o=t.src.charCodeAt(r);if(!cn(o))return-1}return r}function r_(t,e){const n=t.bMarks[e]+t.tShift[e],r=t.eMarks[e];let i=n;if(i+1>=r)return-1;let o=t.src.charCodeAt(i++);if(o<48||o>57)return-1;for(;;){if(i>=r)return-1;if(o=t.src.charCodeAt(i++),o>=48&&o<=57){if(i-n>=10)return-1;continue}if(o===41||o===46)break;return-1}return i<r&&(o=t.src.charCodeAt(i),!cn(o))?-1:i}function UX(t,e){const n=t.level+2;for(let r=e+2,i=t.tokens.length-2;r<i;r++)t.tokens[r].level===n&&t.tokens[r].type==="paragraph_open"&&(t.tokens[r+2].hidden=!0,t.tokens[r].hidden=!0,r+=2)}function jX(t,e,n,r){let i,o,s,a,l=e,c=!0;if(t.sCount[l]-t.blkIndent>=4||t.listIndent>=0&&t.sCount[l]-t.listIndent>=4&&t.sCount[l]<t.blkIndent)return!1;let d=!1;r&&t.parentType==="paragraph"&&t.sCount[l]>=t.blkIndent&&(d=!0);let f,h,p;if((p=r_(t,l))>=0){if(f=!0,s=t.bMarks[l]+t.tShift[l],h=Number(t.src.slice(s,p-1)),d&&h!==1)return!1}else if((p=n_(t,l))>=0)f=!1;else return!1;if(d&&t.skipSpaces(p)>=t.eMarks[l])return!1;if(r)return!0;const m=t.src.charCodeAt(p-1),v=t.tokens.length;f?(a=t.push("ordered_list_open","ol",1),h!==1&&(a.attrs=[["start",h]])):a=t.push("bullet_list_open","ul",1);const g=[l,0];a.map=g,a.markup=String.fromCharCode(m);let y=!1;const C=t.md.block.ruler.getRules("list"),_=t.parentType;for(t.parentType="list";l<n;){o=p,i=t.eMarks[l];const S=t.sCount[l]+p-(t.bMarks[l]+t.tShift[l]);let A=S;for(;o<i;){const ie=t.src.charCodeAt(o);if(ie===9)A+=4-(A+t.bsCount[l])%4;else if(ie===32)A++;else break;o++}const O=o;let E;O>=i?E=1:E=A-S,E>4&&(E=1);const M=S+E;a=t.push("list_item_open","li",1),a.markup=String.fromCharCode(m);const R=[l,0];a.map=R,f&&(a.info=t.src.slice(s,p-1));const D=t.tight,I=t.tShift[l],H=t.sCount[l],z=t.listIndent;if(t.listIndent=t.blkIndent,t.blkIndent=M,t.tight=!0,t.tShift[l]=O-t.bMarks[l],t.sCount[l]=A,O>=i&&t.isEmpty(l+1)?t.line=Math.min(t.line+2,n):t.md.block.tokenize(t,l,n,!0),(!t.tight||y)&&(c=!1),y=t.line-l>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=z,t.tShift[l]=I,t.sCount[l]=H,t.tight=D,a=t.push("list_item_close","li",-1),a.markup=String.fromCharCode(m),l=t.line,R[1]=l,l>=n||t.sCount[l]<t.blkIndent||t.sCount[l]-t.blkIndent>=4)break;let Q=!1;for(let ie=0,me=C.length;ie<me;ie++)if(C[ie](t,l,n,!0)){Q=!0;break}if(Q)break;if(f){if(p=r_(t,l),p<0)break;s=t.bMarks[l]+t.tShift[l]}else if(p=n_(t,l),p<0)break;if(m!==t.src.charCodeAt(p-1))break}return f?a=t.push("ordered_list_close","ol",-1):a=t.push("bullet_list_close","ul",-1),a.markup=String.fromCharCode(m),g[1]=l,t.line=l,t.parentType=_,c&&UX(t,v),!0}function qX(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e],s=e+1;if(t.sCount[e]-t.blkIndent>=4||t.src.charCodeAt(i)!==91)return!1;function a(C){const _=t.lineMax;if(C>=_||t.isEmpty(C))return null;let S=!1;if(t.sCount[C]-t.blkIndent>3&&(S=!0),t.sCount[C]<0&&(S=!0),!S){const E=t.md.block.ruler.getRules("reference"),M=t.parentType;t.parentType="reference";let R=!1;for(let D=0,I=E.length;D<I;D++)if(E[D](t,C,_,!0)){R=!0;break}if(t.parentType=M,R)return null}const A=t.bMarks[C]+t.tShift[C],O=t.eMarks[C];return t.src.slice(A,O+1)}let l=t.src.slice(i,o+1);o=l.length;let c=-1;for(i=1;i<o;i++){const C=l.charCodeAt(i);if(C===91)return!1;if(C===93){c=i;break}else if(C===10){const _=a(s);_!==null&&(l+=_,o=l.length,s++)}else if(C===92&&(i++,i<o&&l.charCodeAt(i)===10)){const _=a(s);_!==null&&(l+=_,o=l.length,s++)}}if(c<0||l.charCodeAt(c+1)!==58)return!1;for(i=c+2;i<o;i++){const C=l.charCodeAt(i);if(C===10){const _=a(s);_!==null&&(l+=_,o=l.length,s++)}else if(!cn(C))break}const d=t.md.helpers.parseLinkDestination(l,i,o);if(!d.ok)return!1;const f=t.md.normalizeLink(d.str);if(!t.md.validateLink(f))return!1;i=d.pos;const h=i,p=s,m=i;for(;i<o;i++){const C=l.charCodeAt(i);if(C===10){const _=a(s);_!==null&&(l+=_,o=l.length,s++)}else if(!cn(C))break}let v=t.md.helpers.parseLinkTitle(l,i,o);for(;v.can_continue;){const C=a(s);if(C===null)break;l+=C,i=o,o=l.length,s++,v=t.md.helpers.parseLinkTitle(l,i,o,v)}let g;for(i<o&&m!==i&&v.ok?(g=v.str,i=v.pos):(g="",i=h,s=p);i<o;){const C=l.charCodeAt(i);if(!cn(C))break;i++}if(i<o&&l.charCodeAt(i)!==10&&g)for(g="",i=h,s=p;i<o;){const C=l.charCodeAt(i);if(!cn(C))break;i++}if(i<o&&l.charCodeAt(i)!==10)return!1;const y=ug(l.slice(1,c));return y?(r||(typeof t.env.references>"u"&&(t.env.references={}),typeof t.env.references[y]>"u"&&(t.env.references[y]={title:g,href:f}),t.line=s),!0):!1}const WX=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],KX="[a-zA-Z_:][a-zA-Z0-9:._-]*",GX="[^\"'=<>`\\x00-\\x20]+",ZX="'[^']*'",YX='"[^"]*"',JX="(?:"+GX+"|"+ZX+"|"+YX+")",XX="(?:\\s+"+KX+"(?:\\s*=\\s*"+JX+")?)",E4="<[A-Za-z][A-Za-z0-9\\-]*"+XX+"*\\s*\\/?>",A4="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",QX="<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->",$X="<[?][\\s\\S]*?[?]>",eQ="<![A-Za-z][^>]*>",tQ="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",nQ=new RegExp("^(?:"+E4+"|"+A4+"|"+QX+"|"+$X+"|"+eQ+"|"+tQ+")"),rQ=new RegExp("^(?:"+E4+"|"+A4+")"),xl=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+WX.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(rQ.source+"\\s*$"),/^$/,!1]];function iQ(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4||!t.md.options.html||t.src.charCodeAt(i)!==60)return!1;let s=t.src.slice(i,o),a=0;for(;a<xl.length&&!xl[a][0].test(s);a++);if(a===xl.length)return!1;if(r)return xl[a][2];let l=e+1;if(!xl[a][1].test(s)){for(;l<n&&!(t.sCount[l]<t.blkIndent);l++)if(i=t.bMarks[l]+t.tShift[l],o=t.eMarks[l],s=t.src.slice(i,o),xl[a][1].test(s)){s.length!==0&&l++;break}}t.line=l;const c=t.push("html_block","",0);return c.map=[e,l],c.content=t.getLines(e,l,t.blkIndent,!0),!0}function oQ(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let s=t.src.charCodeAt(i);if(s!==35||i>=o)return!1;let a=1;for(s=t.src.charCodeAt(++i);s===35&&i<o&&a<=6;)a++,s=t.src.charCodeAt(++i);if(a>6||i<o&&!cn(s))return!1;if(r)return!0;o=t.skipSpacesBack(o,i);const l=t.skipCharsBack(o,35,i);l>i&&cn(t.src.charCodeAt(l-1))&&(o=l),t.line=e+1;const c=t.push("heading_open","h"+String(a),1);c.markup="########".slice(0,a),c.map=[e,t.line];const d=t.push("inline","",0);d.content=t.src.slice(i,o).trim(),d.map=[e,t.line],d.children=[];const f=t.push("heading_close","h"+String(a),-1);return f.markup="########".slice(0,a),!0}function sQ(t,e,n){const r=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;const i=t.parentType;t.parentType="paragraph";let o=0,s,a=e+1;for(;a<n&&!t.isEmpty(a);a++){if(t.sCount[a]-t.blkIndent>3)continue;if(t.sCount[a]>=t.blkIndent){let p=t.bMarks[a]+t.tShift[a];const m=t.eMarks[a];if(p<m&&(s=t.src.charCodeAt(p),(s===45||s===61)&&(p=t.skipChars(p,s),p=t.skipSpaces(p),p>=m))){o=s===61?1:2;break}}if(t.sCount[a]<0)continue;let h=!1;for(let p=0,m=r.length;p<m;p++)if(r[p](t,a,n,!0)){h=!0;break}if(h)break}if(!o)return!1;const l=t.getLines(e,a,t.blkIndent,!1).trim();t.line=a+1;const c=t.push("heading_open","h"+String(o),1);c.markup=String.fromCharCode(s),c.map=[e,t.line];const d=t.push("inline","",0);d.content=l,d.map=[e,t.line-1],d.children=[];const f=t.push("heading_close","h"+String(o),-1);return f.markup=String.fromCharCode(s),t.parentType=i,!0}function aQ(t,e,n){const r=t.md.block.ruler.getRules("paragraph"),i=t.parentType;let o=e+1;for(t.parentType="paragraph";o<n&&!t.isEmpty(o);o++){if(t.sCount[o]-t.blkIndent>3||t.sCount[o]<0)continue;let c=!1;for(let d=0,f=r.length;d<f;d++)if(r[d](t,o,n,!0)){c=!0;break}if(c)break}const s=t.getLines(e,o,t.blkIndent,!1).trim();t.line=o;const a=t.push("paragraph_open","p",1);a.map=[e,t.line];const l=t.push("inline","",0);return l.content=s,l.map=[e,t.line],l.children=[],t.push("paragraph_close","p",-1),t.parentType=i,!0}const th=[["table",FX,["paragraph","reference"]],["code",zX],["fence",BX,["paragraph","reference","blockquote","list"]],["blockquote",HX,["paragraph","reference","blockquote","list"]],["hr",VX,["paragraph","reference","blockquote","list"]],["list",jX,["paragraph","reference","blockquote"]],["reference",qX],["html_block",iQ,["paragraph","reference","blockquote"]],["heading",oQ,["paragraph","reference","blockquote"]],["lheading",sQ],["paragraph",aQ]];function dg(){this.ruler=new Wr;for(let t=0;t<th.length;t++)this.ruler.push(th[t][0],th[t][1],{alt:(th[t][2]||[]).slice()})}dg.prototype.tokenize=function(t,e,n){const r=this.ruler.getRules(""),i=r.length,o=t.md.options.maxNesting;let s=e,a=!1;for(;s<n&&(t.line=s=t.skipEmptyLines(s),!(s>=n||t.sCount[s]<t.blkIndent));){if(t.level>=o){t.line=n;break}const l=t.line;let c=!1;for(let d=0;d<i;d++)if(c=r[d](t,s,n,!1),c){if(l>=t.line)throw new Error("block rule didn't increment state.line");break}if(!c)throw new Error("none of the block rules matched");t.tight=!a,t.isEmpty(t.line-1)&&(a=!0),s=t.line,s<n&&t.isEmpty(s)&&(a=!0,s++,t.line=s)}};dg.prototype.parse=function(t,e,n,r){if(!t)return;const i=new this.State(t,e,n,r);this.tokenize(i,i.line,i.lineMax)};dg.prototype.State=Fo;function pf(t,e,n,r){this.src=t,this.env=n,this.md=e,this.tokens=r,this.tokens_meta=Array(r.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}pf.prototype.pushPending=function(){const t=new io("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t};pf.prototype.push=function(t,e,n){this.pending&&this.pushPending();const r=new io(t,e,n);let i=null;return n<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),r.level=this.level,n>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(i),r};pf.prototype.scanDelims=function(t,e){const n=this.posMax,r=this.src.charCodeAt(t),i=t>0?this.src.charCodeAt(t-1):32;let o=t;for(;o<n&&this.src.charCodeAt(o)===r;)o++;const s=o-t,a=o<n?this.src.charCodeAt(o):32,l=Od(i)||Dd(String.fromCharCode(i)),c=Od(a)||Dd(String.fromCharCode(a)),d=Md(i),f=Md(a),h=!f&&(!c||d||l),p=!d&&(!l||f||c);return{can_open:h&&(e||!p||l),can_close:p&&(e||!h||c),length:s}};pf.prototype.Token=io;function lQ(t){switch(t){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}function cQ(t,e){let n=t.pos;for(;n<t.posMax&&!lQ(t.src.charCodeAt(n));)n++;return n===t.pos?!1:(e||(t.pending+=t.src.slice(t.pos,n)),t.pos=n,!0)}const uQ=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function dQ(t,e){if(!t.md.options.linkify||t.linkLevel>0)return!1;const n=t.pos,r=t.posMax;if(n+3>r||t.src.charCodeAt(n)!==58||t.src.charCodeAt(n+1)!==47||t.src.charCodeAt(n+2)!==47)return!1;const i=t.pending.match(uQ);if(!i)return!1;const o=i[1],s=t.md.linkify.matchAtStart(t.src.slice(n-o.length));if(!s)return!1;let a=s.url;if(a.length<=o.length)return!1;let l=a.length;for(;l>0&&a.charCodeAt(l-1)===42;)l--;l!==a.length&&(a=a.slice(0,l));const c=t.md.normalizeLink(a);if(!t.md.validateLink(c))return!1;if(!e){t.pending=t.pending.slice(0,-o.length);const d=t.push("link_open","a",1);d.attrs=[["href",c]],d.markup="linkify",d.info="auto";const f=t.push("text","",0);f.content=t.md.normalizeLinkText(a);const h=t.push("link_close","a",-1);h.markup="linkify",h.info="auto"}return t.pos+=a.length-o.length,!0}function fQ(t,e){let n=t.pos;if(t.src.charCodeAt(n)!==10)return!1;const r=t.pending.length-1,i=t.posMax;if(!e)if(r>=0&&t.pending.charCodeAt(r)===32)if(r>=1&&t.pending.charCodeAt(r-1)===32){let o=r-1;for(;o>=1&&t.pending.charCodeAt(o-1)===32;)o--;t.pending=t.pending.slice(0,o),t.push("hardbreak","br",0)}else t.pending=t.pending.slice(0,-1),t.push("softbreak","br",0);else t.push("softbreak","br",0);for(n++;n<i&&cn(t.src.charCodeAt(n));)n++;return t.pos=n,!0}const Wy=[];for(let t=0;t<256;t++)Wy.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t){Wy[t.charCodeAt(0)]=1});function hQ(t,e){let n=t.pos;const r=t.posMax;if(t.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=t.src.charCodeAt(n);if(i===10){for(e||t.push("hardbreak","br",0),n++;n<r&&(i=t.src.charCodeAt(n),!!cn(i));)n++;return t.pos=n,!0}let o=t.src[n];if(i>=55296&&i<=56319&&n+1<r){const a=t.src.charCodeAt(n+1);a>=56320&&a<=57343&&(o+=t.src[n+1],n++)}const s="\\"+o;if(!e){const a=t.push("text_special","",0);i<256&&Wy[i]!==0?a.content=o:a.content=s,a.markup=s,a.info="escape"}return t.pos=n+1,!0}function pQ(t,e){let n=t.pos;if(t.src.charCodeAt(n)!==96)return!1;const i=n;n++;const o=t.posMax;for(;n<o&&t.src.charCodeAt(n)===96;)n++;const s=t.src.slice(i,n),a=s.length;if(t.backticksScanned&&(t.backticks[a]||0)<=i)return e||(t.pending+=s),t.pos+=a,!0;let l=n,c;for(;(c=t.src.indexOf("`",l))!==-1;){for(l=c+1;l<o&&t.src.charCodeAt(l)===96;)l++;const d=l-c;if(d===a){if(!e){const f=t.push("code_inline","code",0);f.markup=s,f.content=t.src.slice(n,c).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return t.pos=l,!0}t.backticks[d]=c}return t.backticksScanned=!0,e||(t.pending+=s),t.pos+=a,!0}function mQ(t,e){const n=t.pos,r=t.src.charCodeAt(n);if(e||r!==126)return!1;const i=t.scanDelims(t.pos,!0);let o=i.length;const s=String.fromCharCode(r);if(o<2)return!1;let a;o%2&&(a=t.push("text","",0),a.content=s,o--);for(let l=0;l<o;l+=2)a=t.push("text","",0),a.content=s+s,t.delimiters.push({marker:r,length:0,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return t.pos+=i.length,!0}function i_(t,e){let n;const r=[],i=e.length;for(let o=0;o<i;o++){const s=e[o];if(s.marker!==126||s.end===-1)continue;const a=e[s.end];n=t.tokens[s.token],n.type="s_open",n.tag="s",n.nesting=1,n.markup="~~",n.content="",n=t.tokens[a.token],n.type="s_close",n.tag="s",n.nesting=-1,n.markup="~~",n.content="",t.tokens[a.token-1].type==="text"&&t.tokens[a.token-1].content==="~"&&r.push(a.token-1)}for(;r.length;){const o=r.pop();let s=o+1;for(;s<t.tokens.length&&t.tokens[s].type==="s_close";)s++;s--,o!==s&&(n=t.tokens[s],t.tokens[s]=t.tokens[o],t.tokens[o]=n)}}function gQ(t){const e=t.tokens_meta,n=t.tokens_meta.length;i_(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&i_(t,e[r].delimiters)}const T4={tokenize:mQ,postProcess:gQ};function vQ(t,e){const n=t.pos,r=t.src.charCodeAt(n);if(e||r!==95&&r!==42)return!1;const i=t.scanDelims(t.pos,r===42);for(let o=0;o<i.length;o++){const s=t.push("text","",0);s.content=String.fromCharCode(r),t.delimiters.push({marker:r,length:i.length,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return t.pos+=i.length,!0}function o_(t,e){const n=e.length;for(let r=n-1;r>=0;r--){const i=e[r];if(i.marker!==95&&i.marker!==42||i.end===-1)continue;const o=e[i.end],s=r>0&&e[r-1].end===i.end+1&&e[r-1].marker===i.marker&&e[r-1].token===i.token-1&&e[i.end+1].token===o.token+1,a=String.fromCharCode(i.marker),l=t.tokens[i.token];l.type=s?"strong_open":"em_open",l.tag=s?"strong":"em",l.nesting=1,l.markup=s?a+a:a,l.content="";const c=t.tokens[o.token];c.type=s?"strong_close":"em_close",c.tag=s?"strong":"em",c.nesting=-1,c.markup=s?a+a:a,c.content="",s&&(t.tokens[e[r-1].token].content="",t.tokens[e[i.end+1].token].content="",r--)}}function bQ(t){const e=t.tokens_meta,n=t.tokens_meta.length;o_(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&o_(t,e[r].delimiters)}const M4={tokenize:vQ,postProcess:bQ};function yQ(t,e){let n,r,i,o,s="",a="",l=t.pos,c=!0;if(t.src.charCodeAt(t.pos)!==91)return!1;const d=t.pos,f=t.posMax,h=t.pos+1,p=t.md.helpers.parseLinkLabel(t,t.pos,!0);if(p<0)return!1;let m=p+1;if(m<f&&t.src.charCodeAt(m)===40){for(c=!1,m++;m<f&&(n=t.src.charCodeAt(m),!(!cn(n)&&n!==10));m++);if(m>=f)return!1;if(l=m,i=t.md.helpers.parseLinkDestination(t.src,m,t.posMax),i.ok){for(s=t.md.normalizeLink(i.str),t.md.validateLink(s)?m=i.pos:s="",l=m;m<f&&(n=t.src.charCodeAt(m),!(!cn(n)&&n!==10));m++);if(i=t.md.helpers.parseLinkTitle(t.src,m,t.posMax),m<f&&l!==m&&i.ok)for(a=i.str,m=i.pos;m<f&&(n=t.src.charCodeAt(m),!(!cn(n)&&n!==10));m++);}(m>=f||t.src.charCodeAt(m)!==41)&&(c=!0),m++}if(c){if(typeof t.env.references>"u")return!1;if(m<f&&t.src.charCodeAt(m)===91?(l=m+1,m=t.md.helpers.parseLinkLabel(t,m),m>=0?r=t.src.slice(l,m++):m=p+1):m=p+1,r||(r=t.src.slice(h,p)),o=t.env.references[ug(r)],!o)return t.pos=d,!1;s=o.href,a=o.title}if(!e){t.pos=h,t.posMax=p;const v=t.push("link_open","a",1),g=[["href",s]];v.attrs=g,a&&g.push(["title",a]),t.linkLevel++,t.md.inline.tokenize(t),t.linkLevel--,t.push("link_close","a",-1)}return t.pos=m,t.posMax=f,!0}function wQ(t,e){let n,r,i,o,s,a,l,c,d="";const f=t.pos,h=t.posMax;if(t.src.charCodeAt(t.pos)!==33||t.src.charCodeAt(t.pos+1)!==91)return!1;const p=t.pos+2,m=t.md.helpers.parseLinkLabel(t,t.pos+1,!1);if(m<0)return!1;if(o=m+1,o<h&&t.src.charCodeAt(o)===40){for(o++;o<h&&(n=t.src.charCodeAt(o),!(!cn(n)&&n!==10));o++);if(o>=h)return!1;for(c=o,a=t.md.helpers.parseLinkDestination(t.src,o,t.posMax),a.ok&&(d=t.md.normalizeLink(a.str),t.md.validateLink(d)?o=a.pos:d=""),c=o;o<h&&(n=t.src.charCodeAt(o),!(!cn(n)&&n!==10));o++);if(a=t.md.helpers.parseLinkTitle(t.src,o,t.posMax),o<h&&c!==o&&a.ok)for(l=a.str,o=a.pos;o<h&&(n=t.src.charCodeAt(o),!(!cn(n)&&n!==10));o++);else l="";if(o>=h||t.src.charCodeAt(o)!==41)return t.pos=f,!1;o++}else{if(typeof t.env.references>"u")return!1;if(o<h&&t.src.charCodeAt(o)===91?(c=o+1,o=t.md.helpers.parseLinkLabel(t,o),o>=0?i=t.src.slice(c,o++):o=m+1):o=m+1,i||(i=t.src.slice(p,m)),s=t.env.references[ug(i)],!s)return t.pos=f,!1;d=s.href,l=s.title}if(!e){r=t.src.slice(p,m);const v=[];t.md.inline.parse(r,t.md,t.env,v);const g=t.push("image","img",0),y=[["src",d],["alt",""]];g.attrs=y,g.children=v,g.content=r,l&&y.push(["title",l])}return t.pos=o,t.posMax=h,!0}const kQ=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,xQ=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function _Q(t,e){let n=t.pos;if(t.src.charCodeAt(n)!==60)return!1;const r=t.pos,i=t.posMax;for(;;){if(++n>=i)return!1;const s=t.src.charCodeAt(n);if(s===60)return!1;if(s===62)break}const o=t.src.slice(r+1,n);if(xQ.test(o)){const s=t.md.normalizeLink(o);if(!t.md.validateLink(s))return!1;if(!e){const a=t.push("link_open","a",1);a.attrs=[["href",s]],a.markup="autolink",a.info="auto";const l=t.push("text","",0);l.content=t.md.normalizeLinkText(o);const c=t.push("link_close","a",-1);c.markup="autolink",c.info="auto"}return t.pos+=o.length+2,!0}if(kQ.test(o)){const s=t.md.normalizeLink("mailto:"+o);if(!t.md.validateLink(s))return!1;if(!e){const a=t.push("link_open","a",1);a.attrs=[["href",s]],a.markup="autolink",a.info="auto";const l=t.push("text","",0);l.content=t.md.normalizeLinkText(o);const c=t.push("link_close","a",-1);c.markup="autolink",c.info="auto"}return t.pos+=o.length+2,!0}return!1}function CQ(t){return/^<a[>\s]/i.test(t)}function SQ(t){return/^<\/a\s*>/i.test(t)}function EQ(t){const e=t|32;return e>=97&&e<=122}function AQ(t,e){if(!t.md.options.html)return!1;const n=t.posMax,r=t.pos;if(t.src.charCodeAt(r)!==60||r+2>=n)return!1;const i=t.src.charCodeAt(r+1);if(i!==33&&i!==63&&i!==47&&!EQ(i))return!1;const o=t.src.slice(r).match(nQ);if(!o)return!1;if(!e){const s=t.push("html_inline","",0);s.content=o[0],CQ(s.content)&&t.linkLevel++,SQ(s.content)&&t.linkLevel--}return t.pos+=o[0].length,!0}const TQ=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,MQ=/^&([a-z][a-z0-9]{1,31});/i;function DQ(t,e){const n=t.pos,r=t.posMax;if(t.src.charCodeAt(n)!==38||n+1>=r)return!1;if(t.src.charCodeAt(n+1)===35){const o=t.src.slice(n).match(TQ);if(o){if(!e){const s=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),a=t.push("text_special","",0);a.content=jy(s)?lm(s):lm(65533),a.markup=o[0],a.info="entity"}return t.pos+=o[0].length,!0}}else{const o=t.src.slice(n).match(MQ);if(o){const s=k4(o[0]);if(s!==o[0]){if(!e){const a=t.push("text_special","",0);a.content=s,a.markup=o[0],a.info="entity"}return t.pos+=o[0].length,!0}}}return!1}function s_(t){const e={},n=t.length;if(!n)return;let r=0,i=-2;const o=[];for(let s=0;s<n;s++){const a=t[s];if(o.push(0),(t[r].marker!==a.marker||i!==a.token-1)&&(r=s),i=a.token,a.length=a.length||0,!a.close)continue;e.hasOwnProperty(a.marker)||(e[a.marker]=[-1,-1,-1,-1,-1,-1]);const l=e[a.marker][(a.open?3:0)+a.length%3];let c=r-o[r]-1,d=c;for(;c>l;c-=o[c]+1){const f=t[c];if(f.marker===a.marker&&f.open&&f.end<0){let h=!1;if((f.close||a.open)&&(f.length+a.length)%3===0&&(f.length%3!==0||a.length%3!==0)&&(h=!0),!h){const p=c>0&&!t[c-1].open?o[c-1]+1:0;o[s]=s-c+p,o[c]=p,a.open=!1,f.end=s,f.close=!1,d=-1,i=-2;break}}}d!==-1&&(e[a.marker][(a.open?3:0)+(a.length||0)%3]=d)}}function OQ(t){const e=t.tokens_meta,n=t.tokens_meta.length;s_(t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&s_(e[r].delimiters)}function IQ(t){let e,n,r=0;const i=t.tokens,o=t.tokens.length;for(e=n=0;e<o;e++)i[e].nesting<0&&r--,i[e].level=r,i[e].nesting>0&&r++,i[e].type==="text"&&e+1<o&&i[e+1].type==="text"?i[e+1].content=i[e].content+i[e+1].content:(e!==n&&(i[n]=i[e]),n++);e!==n&&(i.length=n)}const F0=[["text",cQ],["linkify",dQ],["newline",fQ],["escape",hQ],["backticks",pQ],["strikethrough",T4.tokenize],["emphasis",M4.tokenize],["link",yQ],["image",wQ],["autolink",_Q],["html_inline",AQ],["entity",DQ]],z0=[["balance_pairs",OQ],["strikethrough",T4.postProcess],["emphasis",M4.postProcess],["fragments_join",IQ]];function mf(){this.ruler=new Wr;for(let t=0;t<F0.length;t++)this.ruler.push(F0[t][0],F0[t][1]);this.ruler2=new Wr;for(let t=0;t<z0.length;t++)this.ruler2.push(z0[t][0],z0[t][1])}mf.prototype.skipToken=function(t){const e=t.pos,n=this.ruler.getRules(""),r=n.length,i=t.md.options.maxNesting,o=t.cache;if(typeof o[e]<"u"){t.pos=o[e];return}let s=!1;if(t.level<i){for(let a=0;a<r;a++)if(t.level++,s=n[a](t,!0),t.level--,s){if(e>=t.pos)throw new Error("inline rule didn't increment state.pos");break}}else t.pos=t.posMax;s||t.pos++,o[e]=t.pos};mf.prototype.tokenize=function(t){const e=this.ruler.getRules(""),n=e.length,r=t.posMax,i=t.md.options.maxNesting;for(;t.pos<r;){const o=t.pos;let s=!1;if(t.level<i){for(let a=0;a<n;a++)if(s=e[a](t,!1),s){if(o>=t.pos)throw new Error("inline rule didn't increment state.pos");break}}if(s){if(t.pos>=r)break;continue}t.pending+=t.src[t.pos++]}t.pending&&t.pushPending()};mf.prototype.parse=function(t,e,n,r){const i=new this.State(t,e,n,r);this.tokenize(i);const o=this.ruler2.getRules(""),s=o.length;for(let a=0;a<s;a++)o[a](i)};mf.prototype.State=pf;function RQ(t){const e={};t=t||{},e.src_Any=g4.source,e.src_Cc=v4.source,e.src_Z=y4.source,e.src_P=Vy.source,e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|"),e.src_ZCc=[e.src_Z,e.src_Cc].join("|");const n="[><|]";return e.src_pseudo_letter="(?:(?!"+n+"|"+e.src_ZPCc+")"+e.src_Any+")",e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?",e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",e.src_host_terminator="(?=$|"+n+"|"+e.src_ZPCc+")(?!"+(t["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))",e.src_path="(?:[/?#](?:(?!"+e.src_ZCc+"|"+n+`|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+e.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+e.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+e.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+e.src_ZCc+"|[']).)+\\'|\\'(?="+e.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+e.src_ZCc+"|[.]|$)|"+(t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|;(?!"+e.src_ZCc+"|$)|\\!+(?!"+e.src_ZCc+"|[!]|$)|\\?(?!"+e.src_ZCc+"|[?]|$))+|\\/)?",e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',e.src_xn="xn--[a-z0-9\\-]{1,59}",e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63})",e.src_domain="(?:"+e.src_xn+"|(?:"+e.src_pseudo_letter+")|(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+"))",e.src_host="(?:(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+"))",e.tpl_host_fuzzy="(?:"+e.src_ip4+"|(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%)))",e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))",e.src_host_strict=e.src_host+e.src_host_terminator,e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator,e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator,e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator,e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))",e.tpl_email_fuzzy="(^|"+n+'|"|\\(|'+e.src_ZCc+")("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")",e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")",e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")",e}function jb(t){return Array.prototype.slice.call(arguments,1).forEach(function(n){n&&Object.keys(n).forEach(function(r){t[r]=n[r]})}),t}function fg(t){return Object.prototype.toString.call(t)}function NQ(t){return fg(t)==="[object String]"}function PQ(t){return fg(t)==="[object Object]"}function LQ(t){return fg(t)==="[object RegExp]"}function a_(t){return fg(t)==="[object Function]"}function FQ(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const D4={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function zQ(t){return Object.keys(t||{}).reduce(function(e,n){return e||D4.hasOwnProperty(n)},!1)}const BQ={"http:":{validate:function(t,e,n){const r=t.slice(e);return n.re.http||(n.re.http=new RegExp("^\\/\\/"+n.re.src_auth+n.re.src_host_port_strict+n.re.src_path,"i")),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,n){const r=t.slice(e);return n.re.no_http||(n.re.no_http=new RegExp("^"+n.re.src_auth+"(?:localhost|(?:(?:"+n.re.src_domain+")\\.)+"+n.re.src_domain_root+")"+n.re.src_port+n.re.src_host_terminator+n.re.src_path,"i")),n.re.no_http.test(r)?e>=3&&t[e-3]===":"||e>=3&&t[e-3]==="/"?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(t,e,n){const r=t.slice(e);return n.re.mailto||(n.re.mailto=new RegExp("^"+n.re.src_email_name+"@"+n.re.src_host_strict,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},HQ="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",VQ="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function UQ(t){t.__index__=-1,t.__text_cache__=""}function jQ(t){return function(e,n){const r=e.slice(n);return t.test(r)?r.match(t)[0].length:0}}function l_(){return function(t,e){e.normalize(t)}}function cm(t){const e=t.re=RQ(t.__opts__),n=t.__tlds__.slice();t.onCompile(),t.__tlds_replaced__||n.push(HQ),n.push(e.src_xn),e.src_tlds=n.join("|");function r(a){return a.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(r(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(r(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(r(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(r(e.tpl_host_fuzzy_test),"i");const i=[];t.__compiled__={};function o(a,l){throw new Error('(LinkifyIt) Invalid schema "'+a+'": '+l)}Object.keys(t.__schemas__).forEach(function(a){const l=t.__schemas__[a];if(l===null)return;const c={validate:null,link:null};if(t.__compiled__[a]=c,PQ(l)){LQ(l.validate)?c.validate=jQ(l.validate):a_(l.validate)?c.validate=l.validate:o(a,l),a_(l.normalize)?c.normalize=l.normalize:l.normalize?o(a,l):c.normalize=l_();return}if(NQ(l)){i.push(a);return}o(a,l)}),i.forEach(function(a){t.__compiled__[t.__schemas__[a]]&&(t.__compiled__[a].validate=t.__compiled__[t.__schemas__[a]].validate,t.__compiled__[a].normalize=t.__compiled__[t.__schemas__[a]].normalize)}),t.__compiled__[""]={validate:null,normalize:l_()};const s=Object.keys(t.__compiled__).filter(function(a){return a.length>0&&t.__compiled__[a]}).map(FQ).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+s+")","i"),t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+s+")","ig"),t.re.schema_at_start=RegExp("^"+t.re.schema_search.source,"i"),t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i"),UQ(t)}function qQ(t,e){const n=t.__index__,r=t.__last_index__,i=t.__text_cache__.slice(n,r);this.schema=t.__schema__.toLowerCase(),this.index=n+e,this.lastIndex=r+e,this.raw=i,this.text=i,this.url=i}function qb(t,e){const n=new qQ(t,e);return t.__compiled__[n.schema].normalize(n,t),n}function oi(t,e){if(!(this instanceof oi))return new oi(t,e);e||zQ(t)&&(e=t,t={}),this.__opts__=jb({},D4,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=jb({},BQ,t),this.__compiled__={},this.__tlds__=VQ,this.__tlds_replaced__=!1,this.re={},cm(this)}oi.prototype.add=function(e,n){return this.__schemas__[e]=n,cm(this),this};oi.prototype.set=function(e){return this.__opts__=jb(this.__opts__,e),this};oi.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;let n,r,i,o,s,a,l,c,d;if(this.re.schema_test.test(e)){for(l=this.re.schema_search,l.lastIndex=0;(n=l.exec(e))!==null;)if(o=this.testSchemaAt(e,n[2],l.lastIndex),o){this.__schema__=n[2],this.__index__=n.index+n[1].length,this.__last_index__=n.index+n[0].length+o;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(c=e.search(this.re.host_fuzzy_test),c>=0&&(this.__index__<0||c<this.__index__)&&(r=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null&&(s=r.index+r[1].length,(this.__index__<0||s<this.__index__)&&(this.__schema__="",this.__index__=s,this.__last_index__=r.index+r[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(d=e.indexOf("@"),d>=0&&(i=e.match(this.re.email_fuzzy))!==null&&(s=i.index+i[1].length,a=i.index+i[0].length,(this.__index__<0||s<this.__index__||s===this.__index__&&a>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=s,this.__last_index__=a))),this.__index__>=0};oi.prototype.pretest=function(e){return this.re.pretest.test(e)};oi.prototype.testSchemaAt=function(e,n,r){return this.__compiled__[n.toLowerCase()]?this.__compiled__[n.toLowerCase()].validate(e,r,this):0};oi.prototype.match=function(e){const n=[];let r=0;this.__index__>=0&&this.__text_cache__===e&&(n.push(qb(this,r)),r=this.__last_index__);let i=r?e.slice(r):e;for(;this.test(i);)n.push(qb(this,r)),i=i.slice(this.__last_index__),r+=this.__last_index__;return n.length?n:null};oi.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;const n=this.re.schema_at_start.exec(e);if(!n)return null;const r=this.testSchemaAt(e,n[2],n[0].length);return r?(this.__schema__=n[2],this.__index__=n.index+n[1].length,this.__last_index__=n.index+n[0].length+r,qb(this,0)):null};oi.prototype.tlds=function(e,n){return e=Array.isArray(e)?e:[e],n?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(r,i,o){return r!==o[i-1]}).reverse(),cm(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,cm(this),this)};oi.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};oi.prototype.onCompile=function(){};const Xl=2147483647,wo=36,Ky=1,Id=26,WQ=38,KQ=700,O4=72,I4=128,R4="-",GQ=/^xn--/,ZQ=/[^\0-\x7F]/,YQ=/[\x2E\u3002\uFF0E\uFF61]/g,JQ={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},B0=wo-Ky,ko=Math.floor,H0=String.fromCharCode;function As(t){throw new RangeError(JQ[t])}function XQ(t,e){const n=[];let r=t.length;for(;r--;)n[r]=e(t[r]);return n}function N4(t,e){const n=t.split("@");let r="";n.length>1&&(r=n[0]+"@",t=n[1]),t=t.replace(YQ,".");const i=t.split("."),o=XQ(i,e).join(".");return r+o}function P4(t){const e=[];let n=0;const r=t.length;for(;n<r;){const i=t.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){const o=t.charCodeAt(n++);(o&64512)==56320?e.push(((i&1023)<<10)+(o&1023)+65536):(e.push(i),n--)}else e.push(i)}return e}const QQ=t=>String.fromCodePoint(...t),$Q=function(t){return t>=48&&t<58?26+(t-48):t>=65&&t<91?t-65:t>=97&&t<123?t-97:wo},c_=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)},L4=function(t,e,n){let r=0;for(t=n?ko(t/KQ):t>>1,t+=ko(t/e);t>B0*Id>>1;r+=wo)t=ko(t/B0);return ko(r+(B0+1)*t/(t+WQ))},F4=function(t){const e=[],n=t.length;let r=0,i=I4,o=O4,s=t.lastIndexOf(R4);s<0&&(s=0);for(let a=0;a<s;++a)t.charCodeAt(a)>=128&&As("not-basic"),e.push(t.charCodeAt(a));for(let a=s>0?s+1:0;a<n;){const l=r;for(let d=1,f=wo;;f+=wo){a>=n&&As("invalid-input");const h=$Q(t.charCodeAt(a++));h>=wo&&As("invalid-input"),h>ko((Xl-r)/d)&&As("overflow"),r+=h*d;const p=f<=o?Ky:f>=o+Id?Id:f-o;if(h<p)break;const m=wo-p;d>ko(Xl/m)&&As("overflow"),d*=m}const c=e.length+1;o=L4(r-l,c,l==0),ko(r/c)>Xl-i&&As("overflow"),i+=ko(r/c),r%=c,e.splice(r++,0,i)}return String.fromCodePoint(...e)},z4=function(t){const e=[];t=P4(t);const n=t.length;let r=I4,i=0,o=O4;for(const l of t)l<128&&e.push(H0(l));const s=e.length;let a=s;for(s&&e.push(R4);a<n;){let l=Xl;for(const d of t)d>=r&&d<l&&(l=d);const c=a+1;l-r>ko((Xl-i)/c)&&As("overflow"),i+=(l-r)*c,r=l;for(const d of t)if(d<r&&++i>Xl&&As("overflow"),d===r){let f=i;for(let h=wo;;h+=wo){const p=h<=o?Ky:h>=o+Id?Id:h-o;if(f<p)break;const m=f-p,v=wo-p;e.push(H0(c_(p+m%v,0))),f=ko(m/v)}e.push(H0(c_(f,0))),o=L4(i,c,a===s),i=0,++a}++i,++r}return e.join("")},e$=function(t){return N4(t,function(e){return GQ.test(e)?F4(e.slice(4).toLowerCase()):e})},t$=function(t){return N4(t,function(e){return ZQ.test(e)?"xn--"+z4(e):e})},B4={version:"2.3.1",ucs2:{decode:P4,encode:QQ},decode:F4,encode:z4,toASCII:t$,toUnicode:e$},n$={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},r$={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},i$={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}},o$={default:n$,zero:r$,commonmark:i$},s$=/^(vbscript|javascript|file|data):/,a$=/^data:image\/(gif|png|jpeg|webp);/;function l$(t){const e=t.trim().toLowerCase();return s$.test(e)?a$.test(e):!0}const H4=["http:","https:","mailto:"];function c$(t){const e=Hy(t,!0);if(e.hostname&&(!e.protocol||H4.indexOf(e.protocol)>=0))try{e.hostname=B4.toASCII(e.hostname)}catch{}return hf(By(e))}function u$(t){const e=Hy(t,!0);if(e.hostname&&(!e.protocol||H4.indexOf(e.protocol)>=0))try{e.hostname=B4.toUnicode(e.hostname)}catch{}return Ic(By(e),Ic.defaultChars+"%")}function si(t,e){if(!(this instanceof si))return new si(t,e);e||Uy(t)||(e=t||{},t="default"),this.inline=new mf,this.block=new dg,this.core=new qy,this.renderer=new Yc,this.linkify=new oi,this.validateLink=l$,this.normalizeLink=c$,this.normalizeLinkText=u$,this.utils=fX,this.helpers=cg({},gX),this.options={},this.configure(t),e&&this.set(e)}si.prototype.set=function(t){return cg(this.options,t),this};si.prototype.configure=function(t){const e=this;if(Uy(t)){const n=t;if(t=o$[n],!t)throw new Error('Wrong `markdown-it` preset "'+n+'", check name')}if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");return t.options&&e.set(t.options),t.components&&Object.keys(t.components).forEach(function(n){t.components[n].rules&&e[n].ruler.enableOnly(t.components[n].rules),t.components[n].rules2&&e[n].ruler2.enableOnly(t.components[n].rules2)}),this};si.prototype.enable=function(t,e){let n=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.enable(t,!0))},this),n=n.concat(this.inline.ruler2.enable(t,!0));const r=t.filter(function(i){return n.indexOf(i)<0});if(r.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+r);return this};si.prototype.disable=function(t,e){let n=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.disable(t,!0))},this),n=n.concat(this.inline.ruler2.disable(t,!0));const r=t.filter(function(i){return n.indexOf(i)<0});if(r.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+r);return this};si.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this};si.prototype.parse=function(t,e){if(typeof t!="string")throw new Error("Input data should be a String");const n=new this.core.State(t,this,e);return this.core.process(n),n.tokens};si.prototype.render=function(t,e){return e=e||{},this.renderer.render(this.parse(t,e),this.options,e)};si.prototype.parseInline=function(t,e){const n=new this.core.State(t,this,e);return n.inlineMode=!0,this.core.process(n),n.tokens};si.prototype.renderInline=function(t,e){return e=e||{},this.renderer.render(this.parseInline(t,e),this.options,e)};const d$=new m1({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return["p",0]}},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return["div",["hr"]]}},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:!0,defining:!0,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({params:t.getAttribute("data-params")||""})}],toDOM(t){return["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]}},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")}}}],toDOM(t){return["ol",{start:t.attrs.order==1?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]}},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:!1}},parseDOM:[{tag:"ul",getAttrs:t=>({tight:t.hasAttribute("data-tight")})}],toDOM(t){return["ul",{"data-tight":t.attrs.tight?"true":null},0]}},list_item:{content:"block+",defining:!0,parseDOM:[{tag:"li"}],toDOM(){return["li",0]}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){return["img",t.attrs]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return["br"]}}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return["em"]}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return["strong"]}},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){return["a",t.attrs]}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return["code"]}}}});function f$(t,e){if(t.isText&&e.isText&&en.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}class h${constructor(e,n){this.schema=e,this.tokenHandlers=n,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:en.none}]}top(){return this.stack[this.stack.length-1]}push(e){this.stack.length&&this.top().content.push(e)}addText(e){if(!e)return;let n=this.top(),r=n.content,i=r[r.length-1],o=this.schema.text(e,n.marks),s;i&&(s=f$(i,o))?r[r.length-1]=s:r.push(o)}openMark(e){let n=this.top();n.marks=e.addToSet(n.marks)}closeMark(e){let n=this.top();n.marks=e.removeFromSet(n.marks)}parseTokens(e){for(let n=0;n<e.length;n++){let r=e[n],i=this.tokenHandlers[r.type];if(!i)throw new Error("Token type `"+r.type+"` not supported by Markdown parser");i(this,r,e,n)}}addNode(e,n,r){let i=this.top(),o=e.createAndFill(n,r,i?i.marks:[]);return o?(this.push(o),o):null}openNode(e,n){this.stack.push({type:e,attrs:n,content:[],marks:en.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}}function cu(t,e,n,r){return t.getAttrs?t.getAttrs(e,n,r):t.attrs instanceof Function?t.attrs(e):t.attrs}function V0(t,e){return t.noCloseToken||e=="code_inline"||e=="code_block"||e=="fence"}function u_(t){return t[t.length-1]==`
237
+ `?t.slice(0,t.length-1):t}function U0(){}function p$(t,e){let n=Object.create(null);for(let r in e){let i=e[r];if(i.block){let o=t.nodeType(i.block);V0(i,r)?n[r]=(s,a,l,c)=>{s.openNode(o,cu(i,a,l,c)),s.addText(u_(a.content)),s.closeNode()}:(n[r+"_open"]=(s,a,l,c)=>s.openNode(o,cu(i,a,l,c)),n[r+"_close"]=s=>s.closeNode())}else if(i.node){let o=t.nodeType(i.node);n[r]=(s,a,l,c)=>s.addNode(o,cu(i,a,l,c))}else if(i.mark){let o=t.marks[i.mark];V0(i,r)?n[r]=(s,a,l,c)=>{s.openMark(o.create(cu(i,a,l,c))),s.addText(u_(a.content)),s.closeMark(o)}:(n[r+"_open"]=(s,a,l,c)=>s.openMark(o.create(cu(i,a,l,c))),n[r+"_close"]=s=>s.closeMark(o))}else if(i.ignore)V0(i,r)?n[r]=U0:(n[r+"_open"]=U0,n[r+"_close"]=U0);else throw new RangeError("Unrecognized parsing spec "+JSON.stringify(i))}return n.text=(r,i)=>r.addText(i.content),n.inline=(r,i)=>r.parseTokens(i.children),n.softbreak=n.softbreak||(r=>r.addText(" ")),n}class V4{constructor(e,n,r){this.schema=e,this.tokenizer=n,this.tokens=r,this.tokenHandlers=p$(e,r)}parse(e,n={}){let r=new h$(this.schema,this.tokenHandlers),i;r.parseTokens(this.tokenizer.parse(e,n));do i=r.closeNode();while(r.stack.length);return i||this.schema.topNodeType.createAndFill()}}function d_(t,e){for(;++e<t.length;)if(t[e].type!="list_item_open")return t[e].hidden;return!1}new V4(d$,si("commonmark",{html:!1}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,n)=>({tight:d_(e,n)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,n)=>({order:+t.attrGet("start")||1,tight:d_(e,n)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:!0},fence:{block:"code_block",getAttrs:t=>({params:t.info||""}),noCloseToken:!0},hr:{node:"horizontal_rule"},image:{node:"image",getAttrs:t=>({src:t.attrGet("src"),title:t.attrGet("title")||null,alt:t.children[0]&&t.children[0].content||null})},hardbreak:{node:"hard_break"},em:{mark:"em"},strong:{mark:"strong"},link:{mark:"link",getAttrs:t=>({href:t.attrGet("href"),title:t.attrGet("title")||null})},code_inline:{mark:"code",noCloseToken:!0}});function m$(t){const e={blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"listItem"},bullet_list:{block:"bulletList"},ordered_list:{block:"orderedList",getAttrs:r=>({start:+(r.attrGet("start")??1)||1})},heading:{block:"heading",getAttrs:r=>({level:+r.tag.slice(1)})},code_block:{block:"codeBlock",noCloseToken:!0,getAttrs:r=>{var i;return{language:((i=r.info)==null?void 0:i.trim())||null}}},fence:{block:"codeBlock",noCloseToken:!0,getAttrs:r=>{var i;return{language:((i=r.info)==null?void 0:i.trim())||null}}},hr:{node:"horizontalRule"},hardbreak:{node:"hardBreak"},softbreak:{ignore:!0,noCloseToken:!0},html_block:{ignore:!0,noCloseToken:!0},html_inline:{ignore:!0,noCloseToken:!0},image:{ignore:!0,noCloseToken:!0},em:{mark:"italic"},strong:{mark:"bold"},s:{mark:"strike"},code_inline:{mark:"code",noCloseToken:!0},link:{mark:"link",getAttrs:r=>({href:l4(r.attrGet("href")),title:r.attrGet("title")||null})}},n={};for(const[r,i]of Object.entries(e))i.node&&!t.nodes[i.node]||i.block&&!t.nodes[i.block]||i.mark&&!t.marks[i.mark]||(n[r]=i);return n}function g$(t){const e=si("commonmark",{html:!1}).enable(["strikethrough","linkify"]);return new V4(t,e,m$(t))}function v$(t){return t?!!(/^\s{0,3}(#{1,6}\s|[-*+]\s|\d+[.)]\s|>\s|```|~~~|-{3,}\s*$|\*{3,}\s*$|_{3,}\s*$)/m.test(t)||/(\*\*\S(?:[^*\n]*\S)?\*\*|__\S(?:[^_\n]*\S)?__|\*\S(?:[^*\n]*\S)?\*|`[^`\n]+`|~~\S(?:[^~\n]*\S)?~~|\[[^\]\n]+\]\([^)\n]+\))/.test(t)):!1}function b$(t,e){if(!v$(t))return null;let n;try{const i=g$(e).parse(t);if(!i)return null;n=i}catch{return null}return n.childCount===0?null:Ge.maxOpen(n.content)}var y$=T('<div role="presentation" data-testid="editor-root"></div>');function w$(t,e){nt(e,!0);const n=new Set([...Zd].filter(p=>p!==".docx")),r=yG.extend({renderHTML(p){var v;const m=((v=this.parent)==null?void 0:v.call(this,p))??["a",pn(this.options.HTMLAttributes,p.HTMLAttributes),0];if(Array.isArray(m)&&m.length>=2&&m[1]&&typeof m[1]=="object"){const g=m[1],y=g.href;typeof y=="string"&&y.length>0&&g.title==null&&(m[1]={...g,title:y})}return m}});function i(p,m){const v=m.includes("\\")?"\\":"/",g=p.indexOf("#"),y=g>=0?p.slice(0,g):p;if(!y)return null;const C=y.match(/\.[^./\\]+$/),_=C?C[0].toLowerCase():"";if(!n.has(_))return null;const S=m.split(v);S.pop();const O=y.replace(/\//g,v).split(v),E=[...S];for(const M of O)M===".."?E.length>0&&E.pop():M!=="."&&E.push(M);return E.join(v)}let o=F(null),s=null;const a=L(()=>e.format==="docx");pe(()=>{if(e.ydoc,e.provider,!s)return;const p=new eK({element:s,extensions:[SY.configure({history:!1,listItem:!1}),aJ,KK.configure({multicolor:!0}),r.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),ZK.configure({allowBase64:!0}),wG.configure({placeholder:"Start typing…"}),_Z.configure({resizable:!0}),EZ,CZ,SZ,cJ,uJ,UK.configure({document:e.ydoc}),jK.configure({provider:e.provider,user:{name:ey(),color:"var(--tandem-warning)"}}),LY.configure({ydoc:e.ydoc}),UY.configure({ydoc:e.ydoc}),iJ.configure({filePath:Ct(()=>e.currentFilePath??null)}),WY.configure({ydoc:e.ydoc}),KY.configure({ydoc:e.ydoc}),SJ.configure({onOpenChange:e.onSlashCommandMenuChange}),JY,fJ],editorProps:{attributes:{class:"tandem-editor",style:"outline: none; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;"},clipboardTextParser:(v,g,y,C)=>{if(!y){const _=b$(v,C.state.schema);if(_)return _}return s4(v,C.state.schema,g.marks())}},editable:Ct(()=>!e.readOnly),autofocus:Ct(()=>!e.readOnly)});b(o,p,!0),Ct(()=>{var v;return(v=e.onEditorReady)==null?void 0:v.call(e,p)});const m=PY(p,{openHref:v=>{c(v)}});return()=>{Ct(()=>{var v;return(v=e.onEditorReady)==null?void 0:v.call(e,null)}),m(),p.destroy(),u(o)===p&&b(o,null)}});let l;pe(()=>{const p=u(o);if(!p)return;const m=e.readOnly;l!==m&&(l=m,p.setEditable(!m))}),pe(()=>{const p=u(o);if(p)return uA(m=>p.commands.updateUser({name:m}))}),pe(()=>{const p=u(o);if(!p)return;const m=p.view.dom;m.querySelectorAll(".tandem-annotation-active").forEach(v=>{v.classList.remove("tandem-annotation-active")}),e.activeAnnotationId&&m.querySelectorAll(`[data-annotation-id="${CSS.escape(e.activeAnnotationId)}"]`).forEach(v=>{v.classList.add("tandem-annotation-active")})});async function c(p){if(!(!p||p.startsWith("#"))){if(a4(p)){window.open(p,"_blank","noopener,noreferrer");return}if(e.currentFilePath){const m=i(p,e.currentFilePath);if(m){const v=await ms(m);v.ok||console.warn(`[tandem] Could not open linked file "${m}": ${v.error}`)}}}}async function d(p){var _;const m=p.target.closest("a[href]");if(m){const S=m.getAttribute("href")??"";if(!S||S.startsWith("#"))return;p.preventDefault(),await c(S);return}const v={highlight:2,comment:1,note:0};let g=p.target.closest("[data-annotation-id]"),y=null,C=Number.NEGATIVE_INFINITY;for(;g;){const S=g.getAttribute("data-annotation-id");if(S){const O=g.getAttribute("data-annotation-type")??"",E=v[O]??-1;E>C&&(C=E,y=S)}const A=g.parentElement;g=A?A.closest("[data-annotation-id]"):null}y&&e.onAnnotationClick?e.onAnnotationClick(y):y||(_=e.onClearAnnotation)==null||_.call(e)}var f=y$();let h;Dt(f,p=>s=p,()=>s),W(()=>h=bt(f,1,"",null,h,{"tandem-paged":u(a)})),P("click",f,d),x(t,f),rt()}lt(["click"]);var k$=T('<div data-testid="find-scope-pills" class="fr-scope-row svelte-1q9bff2"><button data-testid="find-scope-doc">This document</button> <button data-testid="find-scope-tabs">Open tabs</button></div>'),x$=T('<div class="fr-error svelte-1q9bff2" role="alert"> </div>'),_$=T('<div class="fr-warning svelte-1q9bff2" role="status"> </div>'),C$=T('<div class="fr-xdoc-status svelte-1q9bff2">Searching…</div>'),S$=T('<div class="fr-xdoc-status svelte-1q9bff2">No matches in open tabs</div>'),E$=T('<div class="fr-xdoc-snip svelte-1q9bff2"> </div>'),A$=T('<div class="fr-xdoc-row svelte-1q9bff2"><div class="fr-xdoc-name svelte-1q9bff2"> <span class="fr-xdoc-count svelte-1q9bff2"> </span></div> <!></div>'),T$=T('<div data-testid="find-cross-doc-results" class="fr-xdoc svelte-1q9bff2"><!></div>'),M$=T('<div data-testid="find-replace-bar" role="dialog" tabindex="-1" aria-modal="false" aria-label="Find and replace" class="fr-bar svelte-1q9bff2"><!> <div class="fr-row svelte-1q9bff2"><input data-testid="find-input" type="text" placeholder="Find…" aria-label="Find"/> <span data-testid="find-match-count" class="fr-count svelte-1q9bff2"><!></span> <button data-testid="find-prev-btn" class="fr-nav svelte-1q9bff2" title="Previous match (Shift+Enter)" aria-label="Previous match">↑</button> <button data-testid="find-next-btn" class="fr-nav svelte-1q9bff2" title="Next match (Enter)" aria-label="Next match">↓</button> <button data-testid="find-close-btn" class="fr-close svelte-1q9bff2" title="Close (Esc)" aria-label="Close find bar">×</button></div> <!> <div class="fr-options svelte-1q9bff2"><label class="fr-toggle svelte-1q9bff2"><input data-testid="find-case-toggle" type="checkbox"/> Aa</label> <label class="fr-toggle svelte-1q9bff2"><input data-testid="find-word-toggle" type="checkbox"/> \\b</label> <label class="fr-toggle svelte-1q9bff2"><input data-testid="find-regex-toggle" type="checkbox"/> .*</label></div> <div class="fr-row svelte-1q9bff2"><input data-testid="replace-input" type="text" placeholder="Replace with…" aria-label="Replace with" class="fr-input svelte-1q9bff2"/> <button data-testid="replace-btn" class="fr-replace-btn svelte-1q9bff2">Replace</button> <button data-testid="replace-all-btn" class="fr-replace-btn svelte-1q9bff2"><!></button></div> <!> <!></div>');function D$(t,e){nt(e,!0);let n=Ze(e,"tabs",19,()=>[]),r=F("doc"),i=F(tt([])),o=F(!1);pe(()=>{n().length<=1&&u(r)==="tabs"&&(b(r,"doc"),b(i,[],!0),b(o,!1))});function s(le){const ke=le.getXmlFragment("default"),ce=[];function ve(De){if(De instanceof In)ce.push(De.toString());else{for(let ee=0;ee<De.length;ee++){const q=De.get(ee);(q instanceof In||q instanceof bn)&&ve(q)}De instanceof bn&&De.nodeName!=="text"&&ce.push(" ")}}return ve(ke),ce.join("")}function a(le,ke,ce){const ve=s(le),De=ce?ke:ke.toLowerCase(),ee=ce?ve:ve.toLowerCase(),q=[];let V=0,re=0;for(;(re=ee.indexOf(De,re))!==-1;){if(V++,q.length<3){const te=Math.max(0,re-30),Z=Math.min(ve.length,re+De.length+30),ge=ve.slice(te,Z).replace(/\s+/g," ").trim();q.push((te>0?"…":"")+ge+(Z<ve.length?"…":""))}re+=De.length}return{count:V,snippets:q}}let l;Dn(()=>clearTimeout(l));function c(le,ke){if(clearTimeout(l),!le){b(i,[],!0),b(o,!1);return}b(o,!0),l=setTimeout(()=>{const ce=[];for(const ve of n()){if(!ve.ydoc)continue;const{count:De,snippets:ee}=a(ve.ydoc,le,ke);De>0&&ce.push({tabId:ve.id,fileName:ve.fileName,count:De,snippets:ee})}b(i,ce,!0),b(o,!1)},300)}let d=F(""),f=F(""),h=F(!1),p=F(!1),m=F(!1),v=F(null),g=F(!1),y=F(null),C=F(null),_=F(0);const S=L(()=>(u(_),e.editor?Jl(e.editor.state):void 0)),A=L(()=>{var le;return((le=u(S))==null?void 0:le.matches.length)??0}),O=L(()=>{var le;return((le=u(S))==null?void 0:le.activeIndex)??-1});let E=F(null);pe(()=>{var le;e.open&&((le=u(E))==null||le.focus())});let M=!1;pe(()=>{const le=e.open&&!M;M=e.open,!(!le||!e.forceScope)&&(e.forceScope==="tabs"&&n().length>1?(b(r,"tabs"),c(u(d),u(h))):b(r,"doc"))}),pe(()=>{const le=e.editor;if(!le||le.isDestroyed)return;const ke=()=>Gu(_);return le.on("update",ke),le.on("selectionUpdate",ke),()=>{le.isDestroyed||(le.off("update",ke),le.off("selectionUpdate",ke))}});function R(){if(u(r)==="tabs"){c(u(d),u(h));return}const le=e.editor;if(!le||!u(d)){b(v,null),le==null||le.commands.findClose();return}if(u(m))try{new RegExp(u(d)),b(v,null)}catch(ce){b(v,ce instanceof Error?ce.message:"Invalid regex",!0);return}else b(v,null);const ke={query:u(d),caseSensitive:u(h),wholeWord:u(p),regexMode:u(m)};le.commands.find(ke)}function D(le){var ke;b(r,le,!0),le==="tabs"?((ke=e.editor)==null||ke.commands.findClose(),c(u(d),u(h))):(b(i,[],!0),clearTimeout(l),R())}function I(le){var ke,ce;if(le.key==="Enter"){le.preventDefault(),le.shiftKey?(ke=e.editor)==null||ke.commands.findPrev():(ce=e.editor)==null||ce.commands.findNext();return}le.key==="Escape"&&H()}function H(){var le;(le=e.editor)==null||le.commands.findClose(),e.onClose()}async function z(){const le=e.editor;if(!le||!u(d)||u(g))return;const ke=u(A);if(ke>500&&!window.confirm(`Replace all ${ke} occurrences? This cannot be undone as a single action.`))return;b(g,!0),b(C,null),b(y,{replaced:0,total:ke},!0);const{replaced:ce,partial:ve}=await QY(le.view,u(f),(De,ee)=>{b(y,{replaced:De,total:ee},!0)});b(y,null),b(g,!1),ve&&b(C,`Replaced ${ce} of ${ke}; re-run to continue`)}var Q=St(),ie=Ae(Q);{var me=le=>{var ke=M$(),ce=w(ke);{var ve=ne=>{var Ee=k$(),B=w(Ee);let $;var we=k(B,2);let He;W(()=>{$=bt(B,1,"fr-scope-pill svelte-1q9bff2",null,$,{on:u(r)==="doc"}),U(B,"aria-pressed",u(r)==="doc"),He=bt(we,1,"fr-scope-pill svelte-1q9bff2",null,He,{on:u(r)==="tabs"}),U(we,"aria-pressed",u(r)==="tabs")}),P("click",B,()=>D("doc")),P("click",we,()=>D("tabs")),x(ne,Ee)};j(ce,ne=>{n().length>1&&ne(ve)})}var De=k(ce,2),ee=w(De);let q;Dt(ee,ne=>b(E,ne),()=>u(E));var V=k(ee,2),re=w(V);{var te=ne=>{var Ee=fr();W(()=>G(Ee,u(A)===0?"No matches":`${u(O)+1} / ${u(A)}`)),x(ne,Ee)};j(re,ne=>{u(d)&&ne(te)})}var Z=k(V,2),ge=k(Z,2),Ie=k(ge,2),Se=k(De,2);{var fe=ne=>{var Ee=x$(),B=w(Ee);W(()=>G(B,u(v))),x(ne,Ee)};j(Se,ne=>{u(v)&&ne(fe)})}var _e=k(Se,2),X=w(_e),ye=w(X),Y=k(X,2),se=w(Y),Te=k(Y,2),Re=w(Te),ze=k(_e,2),Je=w(ze),ue=k(Je,2),Ne=k(ue,2),qe=w(Ne);{var Xe=ne=>{var Ee=fr();W(()=>G(Ee,`${u(y).replaced??""}/${u(y).total??""}`)),x(ne,Ee)},ae=ne=>{var Ee=fr("All");x(ne,Ee)};j(qe,ne=>{u(g)&&u(y)?ne(Xe):ne(ae,-1)})}var de=k(ze,2);{var xe=ne=>{var Ee=_$(),B=w(Ee);W(()=>G(B,u(C))),x(ne,Ee)};j(de,ne=>{u(C)&&ne(xe)})}var Le=k(de,2);{var it=ne=>{var Ee=T$(),B=w(Ee);{var $=Oe=>{var K=C$();x(Oe,K)},we=Oe=>{var K=S$();x(Oe,K)},He=Oe=>{var K=St(),he=Ae(K);mt(he,17,()=>u(i),dc,(Me,Fe)=>{var We=A$(),je=w(We),Ve=w(je),$e=k(Ve),ct=w($e),dt=k(je,2);mt(dt,17,()=>u(Fe).snippets,dc,(qt,Nt)=>{var Ot=E$(),Ft=w(Ot);W(()=>G(Ft,u(Nt))),x(qt,Ot)}),W(()=>{G(Ve,`${u(Fe).fileName??""} `),G(ct,`(${u(Fe).count??""} ${u(Fe).count===1?"match":"matches"})`)}),x(Me,We)}),x(Oe,K)};j(B,Oe=>{u(o)?Oe($):u(d)&&u(i).length===0?Oe(we,1):Oe(He,-1)})}x(ne,Ee)};j(Le,ne=>{u(r)==="tabs"&&ne(it)})}W(()=>{q=bt(ee,1,"fr-input svelte-1q9bff2",null,q,{"has-error":!!u(v)}),Z.disabled=u(A)===0,ge.disabled=u(A)===0,ue.disabled=u(A)===0||u(g)||u(r)==="tabs",U(ue,"title",u(r)==="tabs"?"Replace is not available in Open tabs mode":void 0),Ne.disabled=u(A)===0||u(g)||u(r)==="tabs",U(Ne,"title",u(r)==="tabs"?"Replace All is not available in Open tabs mode":void 0)}),P("keydown",ke,I),P("input",ee,R),Hr(ee,()=>u(d),ne=>b(d,ne)),P("click",Z,()=>{var ne;return(ne=e.editor)==null?void 0:ne.commands.findPrev()}),P("click",ge,()=>{var ne;return(ne=e.editor)==null?void 0:ne.commands.findNext()}),P("click",Ie,H),P("change",ye,R),ph(ye,()=>u(h),ne=>b(h,ne)),P("change",se,R),ph(se,()=>u(p),ne=>b(p,ne)),P("change",Re,R),ph(Re,()=>u(m),ne=>b(m,ne)),Hr(Je,()=>u(f),ne=>b(f,ne)),P("click",ue,()=>{e.editor&&(XY(e.editor.view,u(f)),Gu(_))}),P("click",Ne,z),x(le,ke)};j(ie,le=>{e.open&&le(me)})}x(t,Q),rt()}lt(["keydown","click","input","change"]);var O$=T('<div class="source-view-warning svelte-fwjuih" data-testid="source-view-annotation-warning" role="status"> </div>'),I$=T('<div class="source-view-error svelte-fwjuih" data-testid="source-view-error" role="alert"> </div>'),R$=T('<div class="source-view-loading svelte-fwjuih">Loading source…</div>'),N$=T('<textarea class="source-view-textarea svelte-fwjuih" data-testid="source-view-textarea" spellcheck="false" autocomplete="off" autocapitalize="off" aria-label="Markdown source"></textarea>'),P$=T('<div class="source-view svelte-fwjuih" data-testid="source-view-container"><div class="source-view-toolbar svelte-fwjuih"><button type="button" class="source-view-btn source-view-exit svelte-fwjuih" data-testid="source-view-exit-btn">← WYSIWYG</button> <span class="source-view-title svelte-fwjuih">Markdown source</span> <button type="button" class="source-view-btn svelte-fwjuih" data-testid="source-view-copy-btn">Copy</button></div> <!> <!> <!></div>');function L$(t,e){nt(e,!0);const n=Ct(()=>e.initialDraft);let r=F(""),i=F(""),o=F(!0),s=F(!1),a=F(null);const l=L(()=>!u(o)&&u(i)!==u(r));let c=F(0);pe(()=>{const D=e.ydoc.getMap(Ri),I=()=>{b(c,D.size,!0)};return I(),D.observe(I),()=>D.unobserve(I)}),pe(()=>{const D=e.documentId;let I=!1;return b(o,!0),b(a,null),(async()=>{try{const H=await fetch(`${nn}${kO}?documentId=${encodeURIComponent(D)}`);if(!H.ok){const Q=await H.json().catch(()=>({}));throw new Error(Q.message??H.statusText)}const z=await H.json();if(I)return;b(r,z.markdown??"",!0),b(i,n??u(r),!0)}catch(H){if(I)return;b(a,H instanceof Error?H.message:"Failed to load markdown source.",!0)}finally{I||b(o,!1)}})(),()=>{I=!0}});async function d(){b(s,!0),b(a,null);try{const D=await fetch(`${nn}${xO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId,markdown:u(i)})});if(!D.ok){const I=await D.json().catch(()=>({}));throw new Error(I.message??D.statusText)}return b(r,u(i),!0),e.onDraftChange(u(i),!1),!0}catch(D){return b(a,D instanceof Error?D.message:"Failed to apply markdown changes.",!0),!1}finally{b(s,!1)}}function f(D){const I=D.target.value;e.onDraftChange(I,I!==u(r))}async function h(){u(l)&&!await d()||e.onExit()}async function p(D){(D.ctrlKey||D.metaKey)&&D.key.toLowerCase()==="s"&&(D.preventDefault(),D.stopPropagation(),u(l)&&!u(s)&&await d())}async function m(){try{await navigator.clipboard.writeText(u(i))}catch{}}var v=P$(),g=w(v),y=w(g),C=k(y,4),_=k(g,2);{var S=D=>{var I=O$(),H=w(I);W(()=>G(H,`Editing the source clears this document's ${u(c)??""} annotation${u(c)===1?"":"s"} when you return to the editor.`)),x(D,I)};j(_,D=>{u(c)>0&&D(S)})}var A=k(_,2);{var O=D=>{var I=I$(),H=w(I);W(()=>G(H,u(a))),x(D,I)};j(A,D=>{u(a)&&D(O)})}var E=k(A,2);{var M=D=>{var I=R$();x(D,I)},R=D=>{var I=N$();P("input",I,f),P("keydown",I,p),Hr(I,()=>u(i),H=>b(i,H)),x(D,I)};j(E,D=>{u(o)?D(M):D(R,-1)})}W(()=>{y.disabled=u(s),C.disabled=u(o)}),P("click",y,h),P("click",C,m),x(t,v),rt()}lt(["click","input","keydown"]);function Go(t,e){function n(r){t.contains(r.target)||e(r)}return document.addEventListener("mousedown",n),{destroy(){document.removeEventListener("mousedown",n)}}}var F$=T('<div class="menu-div svelte-94a7fq" role="separator"></div> <button type="button" class="mi link svelte-94a7fq" data-testid="decorations-settings-link" role="menuitem"><span>Appearance settings…</span> <kbd class="svelte-94a7fq">Ctrl+,</kbd></button>',1),z$=T(`<div class="menu svelte-94a7fq" role="menu" aria-label="Decorations"><div class="menu-head svelte-94a7fq">Decorations</div> <p class="menu-help svelte-94a7fq">Inline editor overlays — author colors, comment, highlight, and note
238
+ marks. Toggle a type to hide its marks in the document; side-panel cards
239
+ stay.</p> <button type="button" data-testid="decorations-row-authorship" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" aria-hidden="true" class="svelte-94a7fq"><circle cx="9.5" cy="12" r="5" fill="var(--tandem-author-user)"></circle><circle cx="14.5" cy="12" r="5" fill="var(--tandem-author-claude)"></circle></svg></span> <span class="mi-label svelte-94a7fq">Authorship colors</span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <button type="button" data-testid="decorations-row-comments" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="M21 11.5a8.5 8.5 0 0 1-12.5 7.5L3 21l1.6-5A8.5 8.5 0 1 1 21 11.5z"></path></svg></span> <span class="mi-label svelte-94a7fq">Comments</span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <button type="button" data-testid="decorations-row-highlights" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><rect x="3" y="9" width="18" height="6" rx="2" fill="currentColor" opacity="0.25" stroke="none"></rect><path d="M4 6h16M4 18h11"></path></svg></span> <span class="mi-label svelte-94a7fq">Highlights</span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <button type="button" data-testid="decorations-row-notes" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8z"></path><path d="M14 3v5h5"></path><path d="M8 13h7M8 17h4"></path></svg></span> <span class="mi-label svelte-94a7fq">Notes <span class="mi-tag svelte-94a7fq">· private</span></span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <!></div>`),B$=T('<div data-testid="decorations-menu" data-tauri-drag-region="false"><button type="button" data-testid="decorations-mute-toggle"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"></path><circle cx="12" cy="12" r="3"></circle></svg></button> <span class="split-div svelte-94a7fq" aria-hidden="true"></span> <button type="button" class="ib half-caret svelte-94a7fq" data-testid="decorations-menu-caret" aria-haspopup="menu" title="Decoration options" aria-label="Decoration options"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="m6 9 6 6 6-6"></path></svg></button> <!></div>');function U4(t,e){nt(e,!0);let n=F(!1),r=F(null);function i(){e.onUpdate({decorationsMuted:!e.decorationsMuted})}function o(g,y){e.onUpdate({[g]:!y,...e.decorationsMuted?{decorationsMuted:!1}:{}})}function s(){var g;b(n,!1),(g=u(r))==null||g.focus()}function a(g){g.key==="Escape"&&u(n)&&(g.stopPropagation(),s())}function l(){var g;(g=e.onOpenSettings)==null||g.call(e),b(n,!1)}var c=B$();let d;var f=w(c);let h;var p=k(f,4);Dt(p,g=>b(r,g),()=>u(r));var m=k(p,2);{var v=g=>{var y=z$(),C=k(w(y),4);let _;var S=k(C,2);let A;var O=k(S,2);let E;var M=k(O,2);let R;var D=k(M,2);{var I=H=>{var z=F$(),Q=k(Ae(z),2);P("click",Q,l),x(H,z)};j(D,H=>{e.onOpenSettings&&H(I)})}W(()=>{_=bt(C,1,"mi svelte-94a7fq",null,_,{on:e.showAuthorship}),U(C,"aria-checked",e.showAuthorship),A=bt(S,1,"mi svelte-94a7fq",null,A,{on:e.showComments}),U(S,"aria-checked",e.showComments),E=bt(O,1,"mi svelte-94a7fq",null,E,{on:e.showHighlights}),U(O,"aria-checked",e.showHighlights),R=bt(M,1,"mi svelte-94a7fq",null,R,{on:e.showNotes}),U(M,"aria-checked",e.showNotes)}),P("click",C,()=>o("showAuthorship",e.showAuthorship)),P("click",S,()=>o("showComments",e.showComments)),P("click",O,()=>o("showHighlights",e.showHighlights)),P("click",M,()=>o("showNotes",e.showNotes)),x(g,y)};j(m,g=>{u(n)&&g(v)})}qr(c,(g,y)=>Go==null?void 0:Go(g,y),()=>()=>b(n,!1)),W(()=>{d=bt(c,1,"split menu-wrap svelte-94a7fq",null,d,{open:u(n)}),h=bt(f,1,"ib half-main svelte-94a7fq",null,h,{on:!e.decorationsMuted}),U(f,"aria-pressed",!e.decorationsMuted),U(f,"title",e.decorationsMuted?"Restore decorations":"Mute decorations"),U(f,"aria-label",e.decorationsMuted?"Restore decorations":"Mute decorations"),U(p,"aria-expanded",u(n))}),P("keydown",c,a),P("click",f,i),P("click",p,()=>b(n,!u(n))),x(t,c),rt()}lt(["keydown","click"]);function Gy(t,e,n,r={}){const{capture:i=!0}=r;function o(s){const a=t();a&&(s.target instanceof Node&&a.contains(s.target)||n(s))}for(const s of e)document.addEventListener(s,o,i);return()=>{for(const s of e)document.removeEventListener(s,o,i)}}function H$(t){var n;const e=(n=t.closest)==null?void 0:n.call(t,"[data-tauri-drag-region]");return!!e&&e.getAttribute("data-tauri-drag-region")!=="false"}function Hi(t){return e=>{e.preventDefault(),t()}}function V$(t){const e=t.getAttributes("link").href;return e===void 0?"":typeof e=="string"?e:(console.warn("[tandem] getInitialLinkHref: non-string href attribute",{href:e}),"")}function U$(t,e){const n=e.trim();n?t.chain().focus().setLink({href:n}).run():t.isActive("link")&&t.chain().focus().unsetLink().run()}var j$=T('<button type="button"><!></button>');function Pr(t,e){const n=Ze(e,"disabled",3,!1),r=Ze(e,"active",3,!1),i=Ze(e,"style",3,""),o=L(()=>e.ariaLabel??(typeof e.label=="string"?e.label:void 0)),s=L(()=>u(o)??""),a=L(()=>n()&&e.disabledTitle?e.disabledTitle:e.shortcut?`${u(s)} (${e.shortcut})`:u(s));var l=j$();let c;var d=w(l);{var f=p=>{var m=St(),v=Ae(m);Gd(v,()=>e.children),x(p,m)},h=p=>{var m=fr();W(()=>G(m,e.label)),x(p,m)};j(d,p=>{e.children?p(f):p(h,-1)})}W(()=>{c=bt(l,1,"toolbar-btn svelte-xw5pw0",null,c,{"is-active":r()}),U(l,"data-testid",e.testId),l.disabled=n(),U(l,"title",u(a)),U(l,"aria-label",u(o)),U(l,"aria-pressed",e.ariaPressed),U(l,"aria-haspopup",e.ariaHasPopup),U(l,"aria-expanded",e.ariaExpanded),Pe(l,i())}),P("mousedown",l,function(...p){var m;(m=e.onMouseDown)==null||m.apply(this,p)}),P("click",l,function(...p){var m;(m=e.onClick)==null||m.apply(this,p)}),x(t,l)}lt(["mousedown","click"]);var q$=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M4 7L1 4l3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M1 4h9a5 5 0 0 1 0 10H7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),W$=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M12 7l3-3-3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M15 4H6a5 5 0 0 0 0 10h3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),K$=T('<!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div>',1),G$=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 8.5a3.5 3.5 0 0 0 5 0l2-2a3.5 3.5 0 0 0-5-5l-1 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.5 7.5a3.5 3.5 0 0 0-5 0l-2 2a3.5 3.5 0 0 0 5 5l1-1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),Z$=T(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
240
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
241
+ border-radius: var(--tandem-r-3); padding: 6px;
242
+ display: flex; align-items: center; gap: 4px;
243
+ z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1); min-width: 240px;"><input data-testid="toolbar-link-input" type="url" placeholder="https://" style="flex: 1; height: 26px; padding: 2px 6px; font-size: 12px;
244
+ border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
245
+ background: var(--tandem-surface); color: var(--tandem-fg);
246
+ outline: none; font-family: inherit;"/> <button type="button" data-testid="toolbar-link-submit" style="height: 26px; padding: 0 8px; font-size: 12px; font-weight: 500;
247
+ border: 1px solid var(--tandem-accent-border); background: transparent;
248
+ color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
249
+ white-space: nowrap;">Apply</button> <button type="button" data-testid="toolbar-link-cancel" style="height: 26px; padding: 0 8px; font-size: 12px; font-weight: 500;
250
+ border: 1px solid var(--tandem-border); background: transparent;
251
+ color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),Y$=T('<span style="font-family: var(--tandem-font-serif); font-weight: 600; font-size: 13.5px; line-height: 1;"> </span> <span aria-hidden="true" style="color: var(--tandem-fg-faint); font-size: 10px; line-height: 1;">▾</span>',1),J$=T('<button type="button" role="menuitemradio"> </button>'),X$=T(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
252
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
253
+ border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
254
+ gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),Q$=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="4" r="1.5" fill="currentColor"></circle><circle cx="2" cy="8" r="1.5" fill="currentColor"></circle><circle cx="2" cy="12" r="1.5" fill="currentColor"></circle><rect x="5" y="3" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="7" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="11" width="9" height="2" rx="1" fill="currentColor"></rect></svg>'),$$=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="5" y="3" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="7" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="11" width="9" height="2" rx="1" fill="currentColor"></rect><text x="0" y="5.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">1.</text><text x="0" y="9.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">2.</text><text x="0" y="13.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">3.</text></svg>'),eee=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="2" width="3" height="12" rx="1.5" fill="currentColor"></rect><rect x="5" y="4" width="9" height="2" rx="1" fill="currentColor" opacity="0.7"></rect><rect x="5" y="8" width="7" height="2" rx="1" fill="currentColor" opacity="0.7"></rect><rect x="5" y="12" width="8" height="2" rx="1" fill="currentColor" opacity="0.7"></rect></svg>'),tee=an('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M5 4L1 8l4 4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11 4l4 4-4 4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9 2l-2 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>'),nee=T('<div style="display: flex; align-items: center; gap: 1px;"><!> <!> <!> <!> <!> <div style="position: relative;" role="presentation"><!> <!></div> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <div style="position: relative;" role="presentation"><!> <!></div> <!> <!> <!> <!> <!></div>');function j4(t,e){nt(e,!0);const n=Ze(e,"disabled",3,!1),r=Ze(e,"variant",3,"bar"),i=L(()=>r()==="bar"),o=L(()=>r()==="bar"),s=[1,2,3],a={1:700,2:600,3:500};let l=F(0),c=F(!1),d=F(!1),f=F(""),h=F(null);pe(()=>{const Y=e.editor;if(!Y||Y.isDestroyed)return;const se=()=>{Y.isDestroyed||Gu(l)};return Y.on("transaction",se),()=>{Y.isDestroyed||Y.off("transaction",se)}}),pe(()=>{var Y,se;u(d)&&((Y=u(h))==null||Y.focus(),(se=u(h))==null||se.select())});function p(Y){for(const se of s)if(Y.isActive("heading",{level:se}))return se;return null}const m=L(()=>e.editor?e.editor.isEditable:!1),v=L(()=>!u(m)||!!n()),g=L(()=>(u(l),e.editor?Co.getState(e.editor.state):null)),y=L(()=>{var Y,se;return!u(v)&&(((se=(Y=u(g))==null?void 0:Y.undoManager)==null?void 0:se.undoStack.length)??0)>0}),C=L(()=>{var Y,se;return!u(v)&&(((se=(Y=u(g))==null?void 0:Y.undoManager)==null?void 0:se.redoStack.length)??0)>0}),_=L(()=>(u(l),e.editor?p(e.editor):null)),S=L(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("bold"))}),A=L(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("italic"))}),O=L(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("strike"))}),E=L(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("code"))}),M=L(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("bulletList"))}),R=L(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("orderedList"))}),D=L(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("blockquote"))}),I=L(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("codeBlock"))}),H=L(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("link"))}),z=L(()=>(u(l),e.editor?u(v)||!e.editor.isActive("link")&&e.editor.state.selection.from===e.editor.state.selection.to:!0)),Q=L(()=>u(_)?`H${u(_)}`:"H"),ie=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.commands.undo()})),me=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.commands.redo()})),le=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleBold().run()})),ke=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleItalic().run()})),ce=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleStrike().run()})),ve=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleCode().run()})),De=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleBulletList().run()})),ee=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleOrderedList().run()})),q=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleBlockquote().run()})),V=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().setHorizontalRule().run()})),re=L(()=>Hi(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleCodeBlock().run()}));function te(Y){return se=>{se.detail===0&&Y(se)}}function Z(Y){return se=>{se.preventDefault(),!(!e.editor||e.editor.isDestroyed)&&(e.editor.chain().focus().toggleHeading({level:Y}).run(),b(c,!1))}}function ge(Y){Y.preventDefault(),e.editor&&(b(f,V$(e.editor),!0),b(d,!0))}function Ie(){e.editor&&(U$(e.editor,u(f)),Se())}function Se(){b(d,!1),b(f,"")}function fe(Y){Y.key==="Enter"?(Y.preventDefault(),Y.stopPropagation(),Ie()):Y.key==="Escape"&&(Y.preventDefault(),Y.stopPropagation(),Se())}var _e=St(),X=Ae(_e);{var ye=Y=>{var se=nee(),Te=w(se);{var Re=K=>{var he=K$(),Me=Ae(he);{const We=$e=>{var ct=q$();x($e,ct)};let je=L(()=>!u(y)),Ve=L(()=>te(u(ie)));Pr(Me,{ariaLabel:"Undo",shortcut:"Ctrl+Z",get disabled(){return u(je)},get onMouseDown(){return u(ie)},get onClick(){return u(Ve)},children:We,$$slots:{default:!0}})}var Fe=k(Me,2);{const We=$e=>{var ct=W$();x($e,ct)};let je=L(()=>!u(C)),Ve=L(()=>te(u(me)));Pr(Fe,{ariaLabel:"Redo",shortcut:"Ctrl+Shift+Z",get disabled(){return u(je)},get onMouseDown(){return u(me)},get onClick(){return u(Ve)},children:We,$$slots:{default:!0}})}x(K,he)};j(Te,K=>{u(i)&&K(Re)})}var ze=k(Te,2);{let K=L(()=>te(u(le)));Pr(ze,{label:"B",shortcut:"Ctrl+B",get disabled(){return u(v)},get active(){return u(S)},get onMouseDown(){return u(le)},get onClick(){return u(K)},style:"font-weight: 700;"})}var Je=k(ze,2);{let K=L(()=>te(u(ke)));Pr(Je,{label:"I",shortcut:"Ctrl+I",get disabled(){return u(v)},get active(){return u(A)},get onMouseDown(){return u(ke)},get onClick(){return u(K)},style:"font-style: italic;"})}var ue=k(Je,2);{let K=L(()=>te(u(ce)));Pr(ue,{label:"S",shortcut:"Ctrl+Shift+X",get disabled(){return u(v)},get active(){return u(O)},get onMouseDown(){return u(ce)},get onClick(){return u(K)},style:"text-decoration: line-through;"})}var Ne=k(ue,2);{let K=L(()=>te(u(ve)));Pr(Ne,{label:"<>",shortcut:"Ctrl+E",get disabled(){return u(v)},get active(){return u(E)},get onMouseDown(){return u(ve)},get onClick(){return u(K)},style:"font-family: monospace;"})}var qe=k(Ne,2),Xe=w(qe);{const K=Fe=>{var We=G$();x(Fe,We)};let he=L(()=>u(H)||u(d)),Me=L(()=>te(ge));Pr(Xe,{ariaLabel:"Link",shortcut:"Ctrl+K",get disabled(){return u(z)},get active(){return u(he)},ariaHasPopup:"dialog",get ariaExpanded(){return u(d)},onMouseDown:ge,get onClick(){return u(Me)},children:K,$$slots:{default:!0}})}var ae=k(Xe,2);{var de=K=>{var he=Z$(),Me=w(he);Dt(Me,$e=>b(h,$e),()=>u(h));var Fe=k(Me,2),We=L(()=>te($e=>{$e.preventDefault(),Ie()})),je=k(Fe,2),Ve=L(()=>te($e=>{$e.preventDefault(),Se()}));P("keydown",Me,fe),Hr(Me,()=>u(f),$e=>b(f,$e)),P("mousedown",Fe,$e=>{$e.preventDefault(),Ie()}),P("click",Fe,function(...$e){var ct;(ct=u(We))==null||ct.apply(this,$e)}),P("mousedown",je,$e=>{$e.preventDefault(),Se()}),P("click",je,function(...$e){var ct;(ct=u(Ve))==null||ct.apply(this,$e)}),x(K,he)};j(ae,K=>{u(d)&&K(de)})}qr(qe,(K,he)=>Go==null?void 0:Go(K,he),()=>Se);var xe=k(qe,4),Le=w(xe);{const K=We=>{var je=Y$(),Ve=Ae(je),$e=w(Ve);W(()=>G($e,u(Q))),x(We,je)};let he=L(()=>u(_)?`Heading ${u(_)}`:"Heading"),Me=L(()=>u(_)!==null),Fe=L(()=>te(We=>{We.preventDefault(),b(c,!u(c))}));Pr(Le,{get ariaLabel(){return u(he)},get disabled(){return u(v)},get active(){return u(Me)},ariaHasPopup:"menu",get ariaExpanded(){return u(c)},style:"gap: 2px; padding-right: 4px;",onMouseDown:We=>{We.preventDefault(),b(c,!u(c))},get onClick(){return u(Fe)},children:K,$$slots:{default:!0}})}var it=k(Le,2);{var ne=K=>{var he=X$();mt(he,20,()=>s,Me=>Me,(Me,Fe)=>{const We=L(()=>Z(Fe));var je=J$(),Ve=L(()=>te(u(We))),$e=w(je);W(()=>{U(je,"aria-checked",u(_)===Fe),Pe(je,`padding: 4px 12px; font-size: 13px; border: none;
255
+ border-radius: var(--tandem-r-2);
256
+ background: ${u(_)===Fe?"var(--tandem-accent-bg)":"transparent"};
257
+ color: ${u(_)===Fe?"var(--tandem-accent)":"var(--tandem-fg)"};
258
+ cursor: pointer; text-align: left;
259
+ font-weight: ${a[Fe]??""}; white-space: nowrap;`),G($e,`Heading ${Fe??""}`)}),P("mousedown",je,function(...ct){var dt;(dt=u(We))==null||dt.apply(this,ct)}),P("click",je,function(...ct){var dt;(dt=u(Ve))==null||dt.apply(this,ct)}),x(Me,je)}),x(K,he)};j(it,K=>{u(c)&&K(ne)})}qr(xe,(K,he)=>Go==null?void 0:Go(K,he),()=>()=>b(c,!1));var Ee=k(xe,2);{const K=Me=>{var Fe=Q$();x(Me,Fe)};let he=L(()=>te(u(De)));Pr(Ee,{ariaLabel:"Bullet list",shortcut:"Ctrl+Shift+8",get disabled(){return u(v)},get active(){return u(M)},get onMouseDown(){return u(De)},get onClick(){return u(he)},children:K,$$slots:{default:!0}})}var B=k(Ee,2);{const K=Me=>{var Fe=$$();x(Me,Fe)};let he=L(()=>te(u(ee)));Pr(B,{ariaLabel:"Ordered list",shortcut:"Ctrl+Shift+7",get disabled(){return u(v)},get active(){return u(R)},get onMouseDown(){return u(ee)},get onClick(){return u(he)},children:K,$$slots:{default:!0}})}var $=k(B,2);{const K=Me=>{var Fe=eee();x(Me,Fe)};let he=L(()=>te(u(q)));Pr($,{ariaLabel:"Blockquote",shortcut:"Ctrl+Shift+B",get disabled(){return u(v)},get active(){return u(D)},get onMouseDown(){return u(q)},get onClick(){return u(he)},children:K,$$slots:{default:!0}})}var we=k($,2);{var He=K=>{{let he=L(()=>te(u(V)));Pr(K,{label:"—",ariaLabel:"Horizontal rule",get disabled(){return u(v)},get onMouseDown(){return u(V)},get onClick(){return u(he)}})}};j(we,K=>{u(o)&&K(He)})}var Oe=k(we,2);{const K=Me=>{var Fe=tee();x(Me,Fe)};let he=L(()=>te(u(re)));Pr(Oe,{ariaLabel:"Code block",get disabled(){return u(v)},get active(){return u(I)},get onMouseDown(){return u(re)},get onClick(){return u(he)},children:K,$$slots:{default:!0}})}P("keydown",qe,K=>{K.key==="Escape"&&Se()}),P("keydown",xe,K=>{K.key==="Escape"&&b(c,!1)}),x(Y,se)};j(X,Y=>{e.editor&&Y(ye)})}x(t,_e),rt()}lt(["keydown","mousedown","click"]);function q4(t,e,n){const r=t.getMap(Ri);let i=null,o;for(const[l,c]of r.entries())if(c.type==="highlight"&&c.range.from===e.from&&c.range.to===e.to&&c.author==="user"&&c.status==="pending"&&c.content===""){i=l,o=c.color;break}if(i===null){const l=Sv(),c={id:l,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:n};return is(t,()=>r.set(l,c)),"added"}if(o===n)return is(t,()=>r.delete(i)),"removed";const s=Sv(),a={id:s,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:n};return is(t,()=>{r.delete(i),r.set(s,a)}),"recolored"}function ree(t,e){const n=t.getMap(Ri),r=[];for(const[i,o]of n.entries())o.type==="highlight"&&o.range.from===e.from&&o.range.to===e.to&&o.author==="user"&&o.status==="pending"&&o.content===""&&r.push(i);return r.length===0?"noop":(is(t,()=>{for(const i of r)n.delete(i)}),"removed")}const j0=48,nh=8,q0=6,f_=4,iee=200;function oee({anchorX:t,anchorY:e,toolbarHeight:n,toolbarWidth:r,viewportHeight:i,viewportWidth:o,previousPlacement:s}){const a=nh,l=Math.max(a,o-nh-r),c=e+q0,d=c+n,f=e-q0-n,h=i-nh,p=s==="below"?h+f_:h-f_,m=d<=p,v=f>=j0,g=Math.max(j0,i-n-nh);let y,C;m?(y=c,C="below"):v?(y=f,C="above"):(y=g,C="below");const _=i-(e-q0);return{left:Math.min(Math.max(t,a),l),top:Math.min(Math.max(y,j0),g),bottom:_,placement:C}}function see(t,e){return t.on("selectionUpdate",e),()=>t.off("selectionUpdate",e)}var aee=T('<div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px; flex-shrink: 0;"></div> <div style="display: inline-flex; align-items: center;" role="presentation"><!></div>',1),lee=T('<div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px; flex-shrink: 0;"></div> <button type="button" data-testid="popup-show-formatbar-btn" style="height: 26px; min-width: 26px; padding: 0 6px; border: 1px solid transparent; background: transparent; color: var(--tandem-fg-muted); border-radius: var(--tandem-r-pill); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path></path></svg></button>',1),cee=T('<button type="button"></button>'),uee=T('<div role="toolbar" aria-label="Selection tools"><div><div class="morph-block-inner svelte-1tvmluw"><div class="popup-format-col svelte-1tvmluw" role="presentation"><div class="pill-row tandem-floating-pill svelte-1tvmluw" data-testid="popup-format-row"><!> <!> <!></div> <div class="pill-row tandem-floating-pill svelte-1tvmluw" data-testid="popup-annotate-row"><div style="display: inline-flex; gap: 3px; padding: 0 4px;" aria-label="Highlight colors"><button type="button" data-testid="popup-highlight-none" aria-label="No highlight" title="No highlight" style="width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface); cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center;"><svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><line x1="3.5" y1="12.5" x2="12.5" y2="3.5" stroke="var(--tandem-fg-muted)" stroke-width="1.5" stroke-linecap="round"></line></svg></button> <!></div> <div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px;"></div> <button type="button" data-testid="popup-annotate-btn" aria-label="Annotate" style="height: 24px; padding: 0 12px; border: 1px solid var(--tandem-author-user); background: transparent; color: var(--tandem-author-user); border-radius: var(--tandem-r-pill); font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;"><svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"></path></svg> Annotate</button></div></div></div></div> <div><div class="morph-block-inner svelte-1tvmluw"><div class="composer-card svelte-1tvmluw"><textarea data-testid="popup-annotation-input" aria-label="Annotation text" placeholder="Write a note or instruction..." class="composer-input svelte-1tvmluw"></textarea> <div class="composer-actions svelte-1tvmluw"><button type="button" class="composer-btn composer-btn-note svelte-1tvmluw" data-testid="popup-note-submit" aria-label="Note to self (Alt+Enter)">Note to self <kbd class="composer-kbd svelte-1tvmluw"> </kbd></button> <button type="button" class="composer-btn composer-btn-send svelte-1tvmluw" data-testid="popup-comment-submit"> <kbd class="composer-kbd svelte-1tvmluw"> </kbd></button></div></div></div></div></div>');function dee(t,e){nt(e,!0);let n=Ze(e,"selectionToolbar",3,!0),r=Ze(e,"suppressSelectionToolbar",3,!1),i=Ze(e,"requestCommentFocus",3,0),o=Ze(e,"showAuthorship",3,!0),s=Ze(e,"showComments",3,!0),a=Ze(e,"showHighlights",3,!0),l=Ze(e,"showNotes",3,!0),c=Ze(e,"decorationsMuted",3,!1),d=Ze(e,"formattingBarVisible",3,!0),f=Ze(e,"reduceMotion",3,!1);const h=No(ai());let p=F(!1),m=F(null),v=F(null),g=F(""),y=F(null),C=F(null),_=F(!1);const S=100;let A=F(!1),O=F(!1),E,M,R=-1,D=-1,I=!1,H=0,z=0,Q=0,ie=0,me=null,le=null,ke=!1;function ce(){me=I?H:Q,le=I?z:ie,!to(f())&&(b(O,!0),clearTimeout(M),M=setTimeout(()=>{b(O,!1)},k3))}function ve(){clearTimeout(E),clearTimeout(M),b(A,!1),b(O,!1),R=-1,D=-1,me=null,le=null,I=!1}function De(B,$,we){R=B,D=$,I=we,clearTimeout(E),E=setTimeout(()=>{ce(),b(A,!0)},S)}const ee=fS(),q=ee?"⌥⏎":"Alt+⏎",V=ee?"⌘⏎":"Ctrl+⏎",re=L(()=>{const B=u(m);if(!B)return"";const $=B.placement==="above"?`bottom: ${B.bottom}px; top: auto;`:`top: ${B.top}px; bottom: auto;`;return`left: ${B.left}px; ${$}`});let te=F(0),Z=F(tt(window.innerHeight)),ge=F(tt(window.innerWidth));const Ie=Object.keys(VC),Se=L(()=>!!e.editor&&!!e.ydoc&&u(p)),fe=L(()=>n()&&!r()&&u(Se)&&u(m)!==null&&u(A)),_e=L(()=>u(g).trim());let X,ye=0,Y=0;const se=3;function Te(B){const{from:$,to:we}=B.state.selection,He=$!==we;if(b(p,He),!He){b(m,null),X=void 0,Y=0,ve(),document.activeElement!==u(C)&&b(_,!1);return}!u(A)&&!ke&&($!==R||we!==D)&&De($,we,!1);try{const Oe=B.view.coordsAtPos(B.state.selection.head);Q=Oe.left,ie=Oe.bottom;const K=oee({anchorX:me??Q,anchorY:le??ie,toolbarHeight:iee,toolbarWidth:u(te),viewportHeight:u(Z),viewportWidth:u(ge),previousPlacement:X});if(X=K.placement,Y=0,u(m)&&u(m).left===K.left&&u(m).top===K.top&&u(m).bottom===K.bottom&&u(m).placement===K.placement)return;b(m,{left:K.left,top:K.top,bottom:K.bottom,placement:K.placement},!0)}catch{if(Y>=se){Y=0,b(m,null),X=void 0;return}Y+=1,cancelAnimationFrame(ye),ye=requestAnimationFrame(()=>{B.isDestroyed||Te(B)})}}pe(()=>{if(!e.editor)return;const B=e.editor;function $(){Te(B)}const we=B.view.dom,He=we.ownerDocument;function Oe(Fe){Fe.button!==0||!Fe.isPrimary||(ke=!0)}function K(Fe){if(!ke)return;ke=!1,H=Fe.clientX,z=Fe.clientY;const{from:We,to:je}=B.state.selection;We!==je&&!u(A)&&De(We,je,!0)}function he(){ke=!1}we.addEventListener("pointerdown",Oe),He.addEventListener("pointerup",K),He.addEventListener("pointercancel",he);const Me=see(B,$);return $(),()=>{we.removeEventListener("pointerdown",Oe),He.removeEventListener("pointerup",K),He.removeEventListener("pointercancel",he),cancelAnimationFrame(ye),ye=0,clearTimeout(E),clearTimeout(M),Me()}}),pe(()=>{if(!e.editor||!u(m))return;const B=e.editor;let $=0;function we(){cancelAnimationFrame($),$=requestAnimationFrame(()=>{b(Z,window.innerHeight,!0),b(ge,window.innerWidth,!0),Te(B)})}window.addEventListener("resize",we);let He=!1;requestAnimationFrame(()=>{He=!0});const Oe=Gy(()=>u(v),["scroll"],()=>{He&&document.activeElement!==u(C)&&Xe()});return()=>{cancelAnimationFrame($),window.removeEventListener("resize",we),Oe()}}),pe(()=>{const B=e.editor,$=u(v);if(!B||!$||!u(m))return;const we=u(O),He=()=>{if(document.activeElement===u(C))return;if(u(O)){u(te)===0&&(b(te,$.scrollWidth,!0),Te(B));return}const K=$.getBoundingClientRect();b(te,K.width,!0),Te(B)};we||He();const Oe=new ResizeObserver(He);return Oe.observe($),()=>Oe.disconnect()}),pe(()=>{u(fe)&&!u(y)&&Je(),u(fe)||(b(y,null),document.activeElement!==u(C)&&b(g,""))});let Re=0;pe(()=>{if(i()===Re||(Re=i(),i()===0||!e.editor))return;const{from:B,to:$}=e.editor.state.selection;B!==$&&(Ct(()=>Je()),b(_,!0),b(A,!0),ce(),requestAnimationFrame(()=>{var we;return(we=u(C))==null?void 0:we.focus()}))}),pe(()=>{if(!e.editor||!u(fe))return;const B=e.editor,$=()=>{document.activeElement!==u(C)&&Je()};return B.on("selectionUpdate",$),()=>{B.isDestroyed||B.off("selectionUpdate",$)}}),pe(()=>{if(!u(fe))return;function B($){$.key==="Escape"&&($.preventDefault(),$.stopPropagation(),Xe())}return window.addEventListener("keydown",B,{capture:!0}),()=>window.removeEventListener("keydown",B,{capture:!0})});function ze(B,$,we){if(!e.editor||!e.ydoc||B!=="highlight"&&!$.trim())return;const He=u(y)??e.editor.state.selection,{from:Oe,to:K}=He;if(Oe===K)return;const he=wi(e.editor.state.doc,zn(Oe)),Me=wi(e.editor.state.doc,zn(K)),Fe=Sv(),je={id:Fe,author:"user",type:B,audience:B==="highlight"||B==="note"?"private":"outbound",range:{from:he,to:Me},content:$,status:"pending",timestamp:Date.now()};return is(e.ydoc,()=>e.ydoc.getMap(Ri).set(Fe,je)),b(y,null),Fe}function Je(){if(!e.editor)return;const{from:B,to:$}=e.editor.state.selection;b(y,{from:B,to:$},!0)}function ue(B){if(!e.editor||!e.ydoc)return;const $=u(y)??e.editor.state.selection,{from:we,to:He}=$;if(we===He)return;const Oe=wi(e.editor.state.doc,zn(we)),K=wi(e.editor.state.doc,zn(He));q4(e.ydoc,{from:Oe,to:K},B),b(y,null),e.editor.chain().setTextSelection(He).run()}function Ne(){if(!e.editor||!e.ydoc)return;const B=u(y)??e.editor.state.selection,{from:$,to:we}=B;if($===we)return;const He=wi(e.editor.state.doc,zn($)),Oe=wi(e.editor.state.doc,zn(we));ree(e.ydoc,{from:He,to:Oe}),b(y,null),e.editor.chain().setTextSelection(we).run()}function qe(B){return $=>{$.detail===0&&B($)}}function Xe(){var B;b(p,!1),b(m,null),b(y,null),b(g,""),b(_,!1),ve(),(B=e.editor)==null||B.chain().focus().run()}function ae(){b(_,!0),requestAnimationFrame(()=>{var B;return(B=u(C))==null?void 0:B.focus()})}function de(){var we;if(!u(_e))return;const B=(we=u(v))==null?void 0:we.getBoundingClientRect(),$=ze("comment",u(_e));$&&B&&Ak($,B),window.dispatchEvent(new CustomEvent("tandem:addressed-ai",{detail:{via:"comment"}})),Xe()}function xe(){var we;if(!u(_e))return;const B=(we=u(v))==null?void 0:we.getBoundingClientRect(),$=ze("note",u(_e));$&&B&&Ak($,B),Xe()}function Le(B){B.key==="Enter"&&B.altKey?(B.preventDefault(),xe()):B.key==="Enter"&&(B.metaKey||B.ctrlKey)?(B.preventDefault(),de()):B.key==="Escape"&&(B.preventDefault(),Xe())}var it=St(),ne=Ae(it);{var Ee=B=>{var $=uee();let we;var He=w($);let Oe;var K=w(He),he=w(K),Me=w(he),Fe=w(Me);j4(Fe,{get editor(){return e.editor},variant:"popup"});var We=k(Fe,2);{var je=Wt=>{var fn=aee(),Un=k(Ae(fn),2),jn=w(Un);U4(jn,{get showAuthorship(){return o()},get showComments(){return s()},get showHighlights(){return a()},get showNotes(){return l()},get decorationsMuted(){return c()},get onUpdate(){return e.onUpdateDecorations},get onOpenSettings(){return e.onOpenSettings}}),P("mousedown",Un,ui=>ui.preventDefault()),x(Wt,fn)};j(We,Wt=>{e.onUpdateDecorations&&Wt(je)})}var Ve=k(We,2);{var $e=Wt=>{var fn=lee(),Un=k(Ae(fn),2),jn=L(()=>qe(()=>{var ht;return(ht=e.onToggleFormattingBar)==null?void 0:ht.call(e)})),ui=w(Un),Fi=w(ui);W(()=>{U(Un,"aria-label",d()?"Hide formatting bar":"Show formatting bar"),U(Un,"title",d()?"Hide formatting bar":"Show formatting bar"),U(Fi,"d",d()?"m18 15-6-6-6 6":"m6 9 6 6 6-6")}),P("mousedown",Un,ht=>{var so;ht.preventDefault(),(so=e.onToggleFormattingBar)==null||so.call(e)}),P("click",Un,function(...ht){var so;(so=u(jn))==null||so.apply(this,ht)}),x(Wt,fn)};j(Ve,Wt=>{e.onToggleFormattingBar&&Wt($e)})}var ct=k(Me,2),dt=w(ct),qt=w(dt),Nt=L(()=>qe(()=>{var Wt;Ne(),(Wt=e.editor)==null||Wt.chain().focus().run()})),Ot=k(qt,2);mt(Ot,17,()=>Ie,dc,(Wt,fn)=>{var Un=cee(),jn=L(()=>qe(()=>{var ui;ue(u(fn)),(ui=e.editor)==null||ui.chain().focus().run()}));W(()=>{U(Un,"data-testid",`popup-highlight-${u(fn)}`),U(Un,"aria-label",`Highlight ${u(fn)}`),U(Un,"title",`Highlight ${u(fn)}`),Pe(Un,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${Yu[u(fn)]}; cursor: pointer; padding: 0;`)}),P("mousedown",Un,ui=>{var Fi;ui.preventDefault(),ue(u(fn)),(Fi=e.editor)==null||Fi.chain().focus().run()}),P("click",Un,function(...ui){var Fi;(Fi=u(jn))==null||Fi.apply(this,ui)}),x(Wt,Un)});var Ft=k(dt,4),En=L(()=>qe(()=>ae())),Hn=k(He,2);let An;var zt=w(Hn),mn=w(zt),Vn=w(mn);U(Vn,"rows",1),Dt(Vn,Wt=>b(C,Wt),()=>u(C));var Li=k(Vn,2),Mn=w(Li),li=k(w(Mn)),oo=w(li),ci=k(Mn,2),ua=w(ci),gf=k(ua),vf=w(gf);Dt($,Wt=>b(v,Wt),()=>u(v)),W(()=>{we=bt($,1,"tandem-floating-pill selection-popup svelte-1tvmluw",null,we,{"is-annotate":u(_),"is-below":u(m).placement==="below"}),Pe($,u(re)),Oe=bt(He,1,"morph-block morph-format svelte-1tvmluw",null,Oe,{"is-active":!u(_)}),He.inert=u(_),An=bt(Hn,1,"morph-block morph-annotate svelte-1tvmluw",null,An,{"is-active":u(_)}),Hn.inert=!u(_),U(Mn,"title",`Note to self — private, not sent to ${h.family??""} (Alt+Enter)`),Mn.disabled=!u(_e),G(oo,q),U(ci,"aria-label",`Send to ${h.family??""} (Ctrl+Enter)`),U(ci,"title",`Send to ${h.family??""} — outbound comment (Ctrl/Cmd+Enter)`),ci.disabled=!u(_e),G(ua,`Send to ${h.family??""} `),G(vf,V)}),P("mousedown",he,Wt=>Wt.preventDefault()),P("mousedown",qt,Wt=>{var fn;Wt.preventDefault(),Ne(),(fn=e.editor)==null||fn.chain().focus().run()}),P("click",qt,function(...Wt){var fn;(fn=u(Nt))==null||fn.apply(this,Wt)}),P("mousedown",Ft,Wt=>{Wt.preventDefault(),ae()}),P("click",Ft,function(...Wt){var fn;(fn=u(En))==null||fn.apply(this,Wt)}),P("keydown",Vn,Le),Hr(Vn,()=>u(g),Wt=>b(g,Wt)),P("click",Mn,xe),P("click",ci,de),Yi(1,$,()=>MN,()=>({reduceMotion:f()})),x(B,$)};j(ne,B=>{u(fe)&&u(m)&&B(Ee)})}x(t,it),rt()}lt(["mousedown","click","keydown"]);function fee(t,e=document.documentElement){const n=Math.max(0,Math.min(360,Math.round(t)));return e.style.setProperty("--tandem-accent-h",`${n}deg`),()=>e.style.removeProperty("--tandem-accent-h")}function hee(t){pe(()=>fee(t()))}const pee=8e3;function mee(t){let e=F(null),n=F(!1),r=F(!1),i=0,o=0,s=!1;async function a(v){let g;try{g=await fetch(`${nn}${aS}`)}catch{return}if(v===i&&g.ok)try{b(e,await g.json(),!0),b(r,!0)}catch{}}async function l(){let v;try{v=await fetch(`${nn}${pO}`)}catch{return null}if(!v.ok)return null;try{const g=await v.json();return typeof g.hasSession=="boolean"?g.hasSession:null}catch{return null}}async function c(){const v=++o,g=await l();return g!==null&&v===o&&!s&&b(n,g,!0),g}async function d(){return await c()??u(n)}function f(){const v=++i;a(v),c()}f();const h=setInterval(()=>f(),pee);Dn(()=>{i++,s=!0,clearInterval(h)});const p=L(()=>!t.firstRunSettled()||!t.connected()||!u(r)||u(e)===null?"booting":u(n)?"ready":u(e).available===!1?"unconfigured":u(e).running===!0?"ready":"stopped"),m=L(()=>t.soloMode()?null:u(p)==="unconfigured"?"connect":u(p)==="stopped"?"restart":null);return{get state(){return u(p)},get chip(){return u(m)},refresh:()=>f(),probeSession:d}}function gee(t,e=document.documentElement){return t?e.setAttribute("data-annotation-patterns","true"):e.removeAttribute("data-annotation-patterns"),()=>e.removeAttribute("data-annotation-patterns")}function vee(t){pe(()=>gee(t()))}function bee(t){let e=F(tt(new Map));return pe(()=>{const n=t.getYdoc();if(!n){u(e).size>0&&b(e,new Map,!0);return}const r=n.getMap(GC),i=()=>{b(e,yee(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return u(e)}}}function yee(t){const e=new Map;t.forEach(n=>{const r=n;if(!r||typeof r!="object"||!r.annotationId)return;const i=e.get(r.annotationId)??[];i.push(r),e.set(r.annotationId,i)});for(const n of e.values())n.sort((r,i)=>r.timestamp-i.timestamp);return e}const wee=25;function kee(t=wee){const e=tt([]);return{push(n){if(!(e.length&&e[e.length-1].filePath===n.filePath))for(e.push(n);e.length>t;)e.shift()},pop(){return e.pop()??null},peek(){return e.length?e[e.length-1]:null},get top(){return e.length?e[e.length-1]:null},size(){return e.length},clear(){e.length=0}}}function xee(t,e=()=>CD){let n=F(!1),r=F(!1);return pe(()=>{const i=t();if(i==null){b(n,!1),b(r,!1);return}const o=Date.now()-i,s=e()-o;if(s<=0){b(n,!0);return}const a=setTimeout(()=>{b(n,!0)},s);return()=>clearTimeout(a)}),{get showBanner(){return u(n)&&!u(r)},dismiss(){b(r,!0)}}}function _ee(t,e=document.documentElement){return e.setAttribute("data-density",t),()=>e.removeAttribute("data-density")}function Cee(t){pe(()=>_ee(t()))}const Ql=200,Rd=600,See=300;function h_(t){const e=qC[t];try{const n=localStorage.getItem(e);if(n){const r=parseInt(n,10);if(Number.isFinite(r))return Math.max(Ql,Math.min(Rd,r));console.warn(`[tandem] ignoring non-numeric panel width for ${e}: ${n}`)}}catch(n){console.warn(`[tandem] localStorage unavailable reading ${e}:`,n)}return See}function p_(t){const{side:e}=t,n=qC[e];let r=F(tt(t.initialWidth)),i=null;return pe(()=>{!t.getVisible()&&i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),i=null,document.body.style.userSelect="",document.body.style.cursor="")}),pe(()=>()=>{i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),document.body.style.userSelect="",document.body.style.cursor="",i=null)}),{get width(){return u(r)},handleResizeStart:a=>{a.preventDefault();const l=a.clientX,c=u(r);let d=c;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const f=p=>{const m=p.clientX-l,v=e==="left"?c+m:c-m;d=Math.max(Ql,Math.min(Rd,v)),b(r,d,!0)},h=()=>{if(document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",h),i=null,document.body.style.userSelect="",document.body.style.cursor="",t.getVisible())try{localStorage.setItem(n,String(d))}catch(p){console.warn(`[tandem] failed to persist ${n}:`,p)}};i={move:f,up:h},document.addEventListener("mousemove",f),document.addEventListener("mouseup",h)},handleResizeStep:a=>{const l=Math.max(Ql,Math.min(Rd,u(r)+a));if(b(r,l,!0),t.getVisible())try{localStorage.setItem(n,String(l))}catch(c){console.warn(`[tandem] failed to persist ${n}:`,c)}}}}const Eee={sans:'var(--tandem-font-sans), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',serif:'var(--tandem-font-serif), Georgia, "Times New Roman", Times, serif',mono:'var(--tandem-font-mono), "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace'};function Aee(t){const e=document.documentElement;return e.style.setProperty("--tandem-editor-font-family",Eee[t]),()=>e.style.removeProperty("--tandem-editor-font-family")}function Tee(t){pe(()=>Aee(t()))}function Mee(){let t=F(!1);return{get fileDragOver(){return u(t)},handleEditorDragOver:i=>{var o;Tt()||(o=i.dataTransfer)!=null&&o.types.includes("Files")&&(i.preventDefault(),b(t,!0))},handleEditorDragLeave:i=>{Tt()||(i.currentTarget===i.target||!i.currentTarget.contains(i.relatedTarget))&&b(t,!1)},handleEditorDrop:async i=>{var a;if(Tt()||(b(t,!1),!((a=i.dataTransfer)!=null&&a.files.length)))return;i.preventDefault();const o=i.dataTransfer.files[0],s=await kS(o);try{const l=await fetch(`${nn}${sS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:o.name,content:s})});if(!l.ok){const c=await l.json().catch(()=>({message:"Upload failed"}));console.error("[useFileDrop] Upload failed:",l.status,c.message??c.error)}}catch{console.error("[useFileDrop] Server unreachable — file drop ignored")}}}}function W0(t){return!!(t!=null&&t.query)}function Dee(){let t=F(null),e=F(null),n=F(null),r=F(!1),i=0;async function o(){const s=++i;try{const a=await fetch(G8,{credentials:"same-origin"});if(!a.ok){if(s!==i)return;b(t,!1),b(e,null),b(n,null),b(r,!0);return}const l=await a.json();if(s!==i)return;b(t,l.needed===!0),b(e,typeof l.serverVersion=="string"?l.serverVersion:null,!0),b(n,typeof l.confirmationNonce=="string"?l.confirmationNonce:null,!0),b(r,!0)}catch{if(s!==i)return;b(t,!1),b(e,null),b(n,null),b(r,!0)}}return o(),{get needed(){return u(t)},get serverVersion(){return u(e)},get confirmationNonce(){return u(n)},get settled(){return u(r)},refetch:o}}function Oee(t,e=document.documentElement){return t?e.setAttribute("data-high-contrast","true"):e.removeAttribute("data-high-contrast"),()=>e.removeAttribute("data-high-contrast")}function Iee(t){pe(()=>Oee(t()))}function Ree(t,e,n,r){const i=new Map;let o=0,s=0;for(const a of t){const l=e(a);if(l){o++;try{const c=n(l.from);if(!Number.isFinite(c.top))continue;i.set(a.id,c.top-r())}catch{s++}}}return{positions:i,attempted:o,thrown:s}}function Nee(t){let e=null;return{schedule(){e===null&&(e=requestAnimationFrame(()=>{e=null,t()}))},cancel(){e!==null&&(cancelAnimationFrame(e),e=null)}}}function Pee(t){let e=F(tt(new Map));function n(){if(!t.getEnabled()){u(e).size>0&&b(e,new Map,!0);return}const i=t.getEditor(),o=t.getLayerEl(),s=t.getYdoc();if(!i||!o||!s){u(e).size>0&&b(e,new Map,!0);return}const a=t.getAnnotations(),{positions:l,attempted:c,thrown:d}=Ree(a,f=>Ac(f,i.state.doc,s),f=>i.view.coordsAtPos(f),()=>o.getBoundingClientRect().top);c>0&&d===c&&console.warn(`[margin] coordsAtPos threw for all ${c} annotations — view may be detached`),!Lee(u(e),l)&&b(e,l,!0)}const r=Nee(n);return pe(()=>{if(!t.getEnabled())return;const i=t.getEditor(),o=t.getLayerEl();if(!i||!o)return;const s=()=>r.schedule();i.on("transaction",s);const a=new ResizeObserver(()=>r.schedule());return a.observe(o),r.schedule(),()=>{i.off("transaction",s),a.disconnect(),r.cancel()}}),pe(()=>{t.getAnnotations(),r.schedule()}),{get byId(){return u(e)}}}function Lee(t,e){if(t.size!==e.size)return!1;for(const[n,r]of t){const i=e.get(n);if(i===void 0||Math.abs(i-r)>.5)return!1}return!0}const W4=RD,Fee=250;function zee(t,e){return t.severity==="info"&&e-t.timestamp>=W4}function Bee(t){try{const e=localStorage.getItem(t);if(!e)return[];const n=JSON.parse(e);if(!Array.isArray(n))return[];const r=Date.now();return n.filter(o=>o!==null&&typeof o=="object"&&typeof o.id=="string"&&typeof o.message=="string"&&typeof o.timestamp=="number"&&["info","warning","error"].includes(o.severity)).filter(o=>!zee(o,r)).slice(-XC)}catch(e){return console.warn("[useNotifications] failed to load activity history:",e),[]}}function Hee(t={}){const e=t.persist??!0,n=t.storageKey??ID;let r=F(tt([])),i=F(tt(e?Bee(n):[]));const o=new Map,s=new Map;let a=null;const l=()=>{if(e){a=null;try{localStorage.setItem(n,JSON.stringify(u(i)))}catch{}}},c=()=>{e&&(a&&clearTimeout(a),a=setTimeout(l,Fee))},d=E=>{const M=o.get(E);M&&(clearTimeout(M),o.delete(E))},f=(E,M)=>{d(E);const R=Rw[M]??Rw.info;o.set(E,setTimeout(()=>{b(r,u(r).filter(D=>D.id!==E),!0),o.delete(E)},R))},h=(E,M)=>{if(E.dedupKey){const I=u(r).findIndex(H=>H.dedupKey===E.dedupKey);if(I!==-1){const H=u(r)[I];d(H.id);const z={...E,count:H.count+1,action:M},Q=[...u(r)];Q[I]=z,b(r,Q,!0),f(z.id,z.severity);return}}const R={...E,count:1,action:M},D=[...u(r),R];for(;D.length>OD;){const I=D.shift();d(I.id)}b(r,D,!0),f(R.id,R.severity)},p=E=>{const M=s.get(E);M&&(clearTimeout(M),s.delete(E))},m=(E,M)=>{p(E);const R=Math.max(0,W4-(Date.now()-M));s.set(E,setTimeout(()=>{s.delete(E),u(i).some(D=>D.id===E)&&(b(i,u(i).filter(D=>D.id!==E),!0),b(r,u(r).filter(D=>D.id!==E),!0),c())},R))},v=E=>{if(E.dedupKey){const D=u(i).findIndex(I=>I.dedupKey===E.dedupKey);if(D!==-1){const I=u(i)[D],H={...E,id:I.id,count:I.count+1},z=[...u(i)];z[D]=H,b(i,z,!0),H.severity==="info"?m(H.id,H.timestamp):p(H.id),c();return}}const M={...E,count:1},R=[...u(i),M];for(;R.length>XC;)R.shift();b(i,R,!0),M.severity==="info"&&m(M.id,M.timestamp),c()},g=(E,M,R)=>{v(E),(E.severity!=="info"||M)&&h(E,R)},y=E=>{b(r,u(r).filter(M=>M.id!==E),!0),d(E)},C=E=>{b(i,u(i).filter(M=>M.id!==E),!0),p(E),c()},_=()=>{b(i,[],!0);for(const E of s.values())clearTimeout(E);s.clear(),c()};for(const E of u(i))E.severity==="info"&&m(E.id,E.timestamp);const S=(E,M)=>g(E,!0,M),A=`http://127.0.0.1:${Gi}${fO}`,O=new EventSource(A);return O.onmessage=E=>{let M;try{M=JSON.parse(E.data)}catch{console.warn("[useNotifications] Malformed SSE data:",E.data);return}g(M,!1)},O.onerror=()=>{O.readyState===EventSource.CLOSED&&console.warn("[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?")},Dn(()=>{O.close();for(const E of o.values())clearTimeout(E);o.clear();for(const E of s.values())clearTimeout(E);s.clear(),a&&(clearTimeout(a),l())}),{get toasts(){return u(r)},get activity(){return u(i)},get total(){return u(i).length},dismiss:y,dismissActivity:C,clearActivity:_,push:S}}function m_(t,e){let n=null,r=null;const i=(...o)=>{r=o,n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null;const s=r;r=null,s&&t(...s)},e)};return i.cancel=()=>{n!==null&&(clearTimeout(n),n=null),r=null},i.flush=()=>{n!==null&&(clearTimeout(n),n=null);const o=r;r=null,o&&t(...o)},i}function _l(t){return`tandem:scratchpad:${t}`}const ma="tandem:scratchpad:latest",g_=500;function v_(t){const e=[],n=r=>{if(r instanceof In)return r.toString();if(r instanceof bn){let i="";for(let o=0;o<r.length;o++)i+=n(r.get(o));return i}return""};for(let r=0;r<t.length;r++){const i=t.get(r);(i instanceof bn||i instanceof In)&&e.push(n(i))}return e.join(`
260
+ `).replace(/\n+$/,"")}function uu(t){try{return localStorage.getItem(t)}catch{return null}}function rh(t,e){try{localStorage.setItem(t,e)}catch{}}function du(t){try{localStorage.removeItem(t)}catch{}}function Vee(t){const e=new Map,n=tt({}),r=()=>Object.values(n).some(Boolean),i=d=>{const f=d.ydoc.getXmlFragment("default"),h=v_(f),p=_l(d.uuid);if(h.length===0){du(p),uu(ma)===d.uuid&&du(ma),n[d.uuid]=!1;return}rh(p,h),rh(ma,d.uuid),n[d.uuid]=!0},o=(d,f,h)=>{if(e.has(d))return;const p={uuid:d,ydoc:f,provider:h,updateHandler:()=>{},syncedHandler:null,persist:m_(()=>{},g_)};if(p.persist=m_(()=>i(p),g_),p.updateHandler=()=>p.persist(),f.on("update",p.updateHandler),e.set(d,p),h.synced)s(p);else{const m=()=>{p.syncedHandler=null,h.off("synced",m),e.get(d)===p&&s(p)};p.syncedHandler=m,h.on("synced",m)}},s=d=>{const f=d.ydoc.getXmlFragment("default");if(v_(f).length>0)return;let h=d.uuid,p=uu(_l(h));if(p===null&&e.size===1){const g=uu(ma);g&&g!==d.uuid&&(p=uu(_l(g)),h=g)}if(p===null||p.length===0)return;const v=p.split(`
261
+ `).map(g=>{const y=new bn("paragraph");return g.length>0&&y.insert(0,[new In(g)]),y});is(d.ydoc,()=>{f.length>0&&f.delete(0,f.length),f.insert(0,v)}),rh(_l(d.uuid),p),rh(ma,d.uuid),h!==d.uuid&&du(_l(h)),n[d.uuid]=!0},a=d=>{const f=e.get(d);f&&(f.persist.flush(),f.ydoc.off("update",f.updateHandler),f.syncedHandler&&f.provider.off("synced",f.syncedHandler),e.delete(d))},l=d=>{var f;du(_l(d)),uu(ma)===d&&du(ma),(f=e.get(d))==null||f.persist.cancel(),n[d]=!1},c=bC(()=>{pe(()=>{const d=t(),f=new Set;for(const h of d){if(!km(h.filePath))continue;const p=nS(h.filePath);p&&(f.add(p),o(p,h.ydoc,h.provider))}for(const h of[...e.keys()])f.has(h)||a(h)}),pe(()=>{const d=f=>{if(r()){for(const h of e.values())h.persist.flush();return f.preventDefault(),f.returnValue="You have unsaved scratchpad content.","You have unsaved scratchpad content."}};return window.addEventListener("beforeunload",d),()=>window.removeEventListener("beforeunload",d)})});return{hasUnsavedContent:d=>n[d]===!0,clearUnsaved:l,destroy:()=>{c();for(const d of[...e.keys()])a(d)}}}function Uee(t,e,n){if(t.length<2)return null;const o=(t.findIndex(s=>s.id===e)+(n?-1:1)+t.length)%t.length;return t[o].id}function jee(t,e,n){let r=null;zc(()=>{r=i=>{if(!i.ctrlKey&&!i.metaKey||i.key!=="Tab")return;const o=Uee(t(),e(),i.shiftKey);o&&(i.preventDefault(),n(o))},window.addEventListener("keydown",r)}),Dn(()=>{r&&window.removeEventListener("keydown",r)})}function qee(t,e){if(t.length===0||e<1||e>9)return null;const n=Math.min(e-1,t.length-1);return t[n].id}function Nr(t){if(t.isComposing)return!0;const e=t.target;return e?e.tagName==="INPUT"||e.tagName==="TEXTAREA":!1}function b_(t,e){const n=new Set(e),r=t.filter(s=>n.has(s)),i=new Set(r),o=e.filter(s=>!i.has(s));return[...r,...o]}function Wee(t,e,n,r,i="left"){const o=t.filter(f=>r.has(f)),s=o.indexOf(e),a=o.indexOf(n);if(s===-1||a===-1)return o;const l=[...o];l.splice(s,1);const c=l.indexOf(n),d=i==="right"?c+1:c;return l.splice(d,0,e),l}function Kee(t){let e=F(tt([]));pe(()=>{const o=t().map(a=>a.id),s=b_(u(e),o);(u(e).length!==s.length||u(e).some((a,l)=>a!==s[l]))&&b(e,s,!0)});const n=L(()=>{const i=t(),o=new Map(i.map(l=>[l.id,l])),s=i.map(l=>l.id);return b_(u(e),s).map(l=>o.get(l)).filter(Boolean)});return{get orderedTabs(){return u(n)},reorder:(i,o,s="left")=>{if(i===o)return;const a=t(),l=new Set(a.map(c=>c.id));b(e,Wee(u(e),i,o,l,s),!0)}}}function Gee(t,e){let n=F(tt((()=>{try{const r=localStorage.getItem(Tf),i=lO.safeParse(r);return i.success?i.data:Ew}catch(r){return console.warn(`[tandem] localStorage unavailable reading ${Tf}:`,r),Ew}})()));return pe(()=>{const r=u(n);try{localStorage.setItem(Tf,r)}catch(i){console.warn(`[tandem] failed to persist ${Tf}:`,i)}}),pe(()=>{const r=t(),i=u(n);if(r)try{r.getMap(vv).set(TD,i)}catch(o){console.warn("[tandem] failed to broadcast tandem mode to Y.Map:",o)}}),pe(()=>{const r=t(),i=e();if(r)try{r.getMap(vv).set(MD,i)}catch(o){console.warn("[tandem] failed to broadcast dwell ms to Y.Map:",o)}}),{get tandemMode(){return u(n)},setTandemMode(r){b(n,r,!0)}}}let Ph=F(!1),K0=!1,K4=()=>{};const G0={get fileDragOver(){return u(Ph)}};function Zee(t){const e=t.split(/[/\\]/).at(-1)??"",n=e.lastIndexOf(".");return n<=0?!1:Zd.has(e.slice(n).toLowerCase())}const Yee=(()=>{const t=Array.from(Zd).sort();return t.length<=1?t[0]??"":t.length===2?`${t[0]} or ${t[1]}`:`${t.slice(0,-1).join(", ")}, or ${t.at(-1)}`})();function ih(t,e,n){K4({id:`tauri-drop-${n}-${Date.now()}`,type:"general-error",severity:e,message:t,dedupKey:n,timestamp:Date.now()})}function Jee(t){K4=t,!K0&&Tt()&&(K0=!0,Zt(()=>import("./webview-KiZyy_pC.js"),__vite__mapDeps([9,10,1,3])).then(async({getCurrentWebview:e})=>{await e().onDragDropEvent(n=>{try{const r=n.payload;switch(r.type){case"enter":b(Ph,!0);return;case"drop":b(Ph,!1);for(const i of r.paths)if(Zee(i)){(async()=>{const o=await ms(i);o.ok||ih(`Couldn't open ${i}: ${o.error}`,"error","tauri-drop-open-failed")})();return}ih(`Tandem can only open ${Yee} files`,"warning","tauri-drop-unsupported");return;case"leave":b(Ph,!1);return;default:console.warn("[useTauriFileDrop] unknown payload type:",r)}}catch(r){console.error("[useTauriFileDrop] callback threw:",r),ih("Drag-and-drop encountered an error — try the Open File dialog","error","tauri-drop-callback-error")}})}).catch(e=>{K0=!1,console.error("[useTauriFileDrop] Failed to attach onDragDropEvent:",e),ih("Drag-and-drop unavailable — use the Open File dialog instead","warning","tauri-drop-unavailable")}))}var Ud;class Xee{constructor(){yt(this,Ud,F(tt(Tt()?window.__TANDEM_INITIAL_THEME__??null:null)))}get current(){return u(oe(this,Ud))}set current(e){b(oe(this,Ud),e,!0)}}Ud=new WeakMap;const hg=new Xee;let y_=!1;function Z0(t){hg.current=t,typeof window<"u"&&(window.__TANDEM_INITIAL_THEME__=t)}function Qee(){if(y_||!Tt())return;y_=!0;let t=null;Zt(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]).then(({invoke:i})=>{t=i,i("get_app_theme").then(o=>{Z0(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] get_app_theme failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri API import failed:",i)}),Zt(async()=>{const{getCurrentWindow:i}=await import("./window-DePn7tLG.js").then(o=>o.w);return{getCurrentWindow:i}},__vite__mapDeps([10,1,3])).then(({getCurrentWindow:i})=>{i().onThemeChanged(({payload:o})=>{Z0(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] onThemeChanged subscribe failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri window API import failed:",i)});let e=!1;const n=setInterval(()=>{!document.hasFocus()||!t||t("get_app_theme").then(i=>{const o=i==="dark"?"dark":"light";hg.current!==o&&(Z0(o),e=!1)}).catch(i=>{e||(console.warn("[useTauriTheme] theme poll failed (further errors suppressed):",i),e=!0)})},3e3),r=()=>clearInterval(n);window.addEventListener("pagehide",r,{once:!0})}function G4(t="light"){const e=t==="warm"?"warm":"light";try{if(typeof window>"u")return e;if(Tt()){const n=hg.current;if(n==="dark")return"dark";if(n==="light")return e;const r=window.__TANDEM_INITIAL_THEME__;if(r==="dark")return"dark";if(r==="light")return e}return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":e}catch(n){return console.warn("[Tandem] Theme detection failed, defaulting to light:",n),e}}function $ee(t,e="light"){return t==="system"?G4(e):t}function w_(t){try{const e=document.querySelector('meta[name="theme-color"]');e&&(e.content=t==="dark"?"#1c1c24":t==="warm"?"#f1ead9":"#fafaf9")}catch{}}function ete(t,e="light"){const n=document.documentElement,r=$ee(t,e);if(n.setAttribute("data-theme",r),w_(r),t!=="system")return()=>n.removeAttribute("data-theme");if(Tt())return()=>n.removeAttribute("data-theme");const i=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>{const s=G4(e);n.setAttribute("data-theme",s),w_(s)};return i.addEventListener("change",o),()=>{i.removeEventListener("change",o),n.removeAttribute("data-theme")}}function tte(t,e=()=>"light"){Qee(),pe(()=>{const n=t(),r=e();return hg.current,ete(n,r)})}function nte(){try{return localStorage.getItem(QC)==="true"}catch{return!1}}function rte(t){return t.author==="user"&&!t.id.startsWith($C)}function k_(){try{localStorage.setItem(QC,"true")}catch{}}function ite(t,e,n){let r=F(tt(nte())),i=F(0),o=0;const s=d3(),a=L(()=>n()==="welcome.md"),l=L(()=>!u(r)&&u(a)),c=Tt(),d=_1(()=>c&&u(l)),f=L(()=>!c||d.status!==null||d.error!==null),h=L(()=>c&&u3(d.status,s)),p=L(()=>u(f)?u(h)?4:3:1/0);return pe(()=>{if(!u(l)||u(i)!==0)return;const y=t().filter(_=>_.id.startsWith($C));if(y.length===0)return;y.some(_=>_.status!=="pending")&&(o=Date.now(),b(i,1))}),pe(()=>{if(!u(l)||u(i)!==1)return;t().some(rte)&&(o=Date.now(),b(i,2))}),pe(()=>{if(!u(l)||u(i)!==2||!isFinite(u(p)))return;const g=e();if(!g)return;const y=()=>{Date.now()-o<2e3||g.isFocused&&(o=Date.now(),b(i,3))};return g.on("update",y),()=>{g.off("update",y)}}),pe(()=>{if(!u(l)||!isFinite(u(p))||u(i)!==u(p))return;const g=setTimeout(()=>{k_(),b(r,!0)},3e3);return()=>clearTimeout(g)}),pe(()=>{isFinite(u(p))&&u(i)>u(p)&&b(i,u(p),!0)}),{get tutorialActive(){return u(l)},get currentStep(){return u(i)},get coworkStatus(){return d.status},dismissTutorial:()=>{k_(),b(r,!0)},nextStep:()=>{o=Date.now(),b(i,Math.min(u(i)+1,u(p)),!0)}}}const ote="tandem://update-available",ste="tandem:updater-dismissed-v";function Z4(t){return`${ste}${t}`}function Y4(t){try{return window.localStorage.getItem(Z4(t))==="1"}catch{return!1}}function ate(t){try{window.localStorage.setItem(Z4(t),"1")}catch{}}let J4=F(null),um=F(null),Il=0,Y0=null,oh=!1,J0=0;function x_(){return Il}function Ta(){return u(J4)}function X4(){return u(um)}function Q4(t){t&&(ate(t),b(um,t,!0))}function $4(){if(Il+=1,Il===1&&Tt()){oh=!1;const e=++J0;(async()=>{try{const{listen:n}=await Zt(async()=>{const{listen:i}=await import("./event-CNdo2oXa.js");return{listen:i}},__vite__mapDeps([3,1]));if(oh||e!==J0||x_()===0)return;const r=await n(ote,i=>{var s;const o=((s=i.payload)==null?void 0:s.version)??null;o&&(b(J4,o,!0),u(um)!==o&&b(um,null))});if(oh||e!==J0||x_()===0){r();return}Y0=r}catch(n){console.warn("[useUpdaterChannel] listen() failed:",n)}})()}let t=!1;return()=>{if(!t&&(t=!0,Il=Math.max(0,Il-1),Il===0)){oh=!0;const e=Y0;if(Y0=null,e)try{e()}catch(n){console.warn("[useUpdaterChannel] unlisten threw:",n)}}}}function lte(){return pe(()=>$4()),{get availableVersion(){return Ta()},get showDot(){const t=Ta();return!(!t||X4()===t||Y4(t))},acknowledge(){Q4(Ta())}}}const __=3e4;function cte(){let t=F(!1),e=null;function n(){e!==null&&(clearTimeout(e),e=null)}pe(()=>{const i=$4();return()=>{n(),i()}});async function r(){if(!(!Ta()||u(t))){b(t,!0),n(),e=setTimeout(()=>{e=null,b(t,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${__}ms; re-arming CTA`)},__);try{const{invoke:o}=await Zt(async()=>{const{invoke:s}=await import("./core-DhEqZVGG.js");return{invoke:s}},[]);await o("install_update"),n(),b(t,!1)}catch(o){console.warn("[useUpdaterBanner] install_update failed:",o),n(),b(t,!1)}}}return{get availableVersion(){return Ta()},get installing(){return u(t)},get showBanner(){const i=Ta();return!(!i||X4()===i||Y4(i))},dismiss(){Q4(Ta())},install:r}}function ute(){let t=F(tt(window.innerWidth));return pe(()=>{let e=null;const n=()=>{e===null&&(e=requestAnimationFrame(()=>{b(t,window.innerWidth,!0),e=null}))};return window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n),e!==null&&cancelAnimationFrame(e)}}),{get width(){return u(t)}}}function dte(){let t=null;zc(()=>{let e=!1,n;Zt(async()=>{const{getCurrentWebview:r}=await import("./webview-KiZyy_pC.js");return{getCurrentWebview:r}},__vite__mapDeps([9,10,1,3])).then(({getCurrentWebview:r})=>{if(e)return;const i=r();let o=iu;try{const d=localStorage.getItem(Nw);if(d!==null){const f=Number(d);Number.isFinite(f)?o=Math.max(Pw,Math.min(Lw,f)):console.warn(`[tandem] ignoring invalid stored zoom: ${d}`)}}catch{}o!==iu&&i.setZoom(o).catch(d=>{console.warn("[tandem] failed to restore zoom level:",d)});function s(d){try{localStorage.setItem(Nw,String(d))}catch{}}const a=d=>{!(d.metaKey||d.ctrlKey)||d.key!=="0"||(d.preventDefault(),d.stopPropagation(),o=iu,i.setZoom(iu).catch(h=>{console.warn("[tandem] failed to reset zoom:",h)}),s(iu))},l=.1,c=d=>{if(!(d.metaKey||d.ctrlKey))return;const h=d.key==="+"||d.key==="=",p=d.key==="-"||d.key==="_";if(!h&&!p)return;const m=h?o+l:o-l;o=Math.max(Pw,Math.min(Lw,Math.round(m*100)/100)),s(o)};window.addEventListener("keydown",a,{capture:!0}),window.addEventListener("keydown",c,{capture:!0}),n=()=>{window.removeEventListener("keydown",a,{capture:!0}),window.removeEventListener("keydown",c,{capture:!0})}}).catch(()=>{}),t=()=>{e=!0,n==null||n()}}),Dn(()=>{t==null||t()})}const fte=1e3;function hte(t){let e=!1;return function(){t.isDestroyed()||e||(e=!0,queueMicrotask(async()=>{try{for(;!t.isDestroyed();){const r=await t.fetchGenerationId();if(t.isDestroyed())return;if(r&&r===t.getPinnedGeneration()){t.onGenerationUnchanged();return}if(r){t.rebuild(r);return}await t.sleep(fte)}}finally{e=!1}}))}}function pte(t){const{prev:e,serverActiveId:n,serverIds:r,removedCount:i,serverEpoch:o,lastAppliedEpoch:s}=t;return e===null||!r.has(e)?n:i>0&&n===e?e:o!==s?n:e}function mte(t,e,n){return t.filter(r=>!e.has(r.id)&&!n.has(r.id))}function gte(){let t=F(tt([])),e=F(null),n=F(!1),r=F("connecting"),i=F(0),o=F(null),s=F(tt([])),a=F(null),l=F(!1),c=F(null),d=F(!1),f=F(!1),h=F(!1),p=F(null),m=null,v=!1,g=null,y=null;const C=new Set,_=new Map,S=new Map,A=new Map;let O=!1;const E=q=>{const{ydoc:V}=q,re=V.getMap(Ri),te=()=>{const X=[];re.forEach(ye=>{X.push(el(ye,Y=>{console.warn("[sanitize]",Y)}))}),b(s,X,!0)};re.observe(te),te();const Z=V.getMap(KC);let ge=null,Ie=!1,Se=null;const fe=X=>X?`${X.tool} ${X.annotationId??""} ${X.token??X.startedAt}`:null,_e=()=>{const X=Z.get(bv),ye=(X==null?void 0:X.status)??null,Y=(X==null?void 0:X.active)??!1,se=(X==null?void 0:X.working)??null;ye!==ge&&(ge=ye,b(a,ye,!0)),Y!==Ie&&(Ie=Y,b(l,Y,!0));const Te=fe(se);Te!==Se&&(Se=Te,b(c,se,!0))};return Z.observe(_e),_e(),()=>{re.unobserve(te),Z.unobserve(_e)}},M=q=>new Promise(V=>setTimeout(V,q)),R=async()=>{try{const q=await fetch(`http://127.0.0.1:${Gi}${Ev}`,{signal:AbortSignal.timeout(5e3)});return q.ok?(await q.json()).generationId??null:null}catch{return null}},D=()=>{for(const q of S.values())q.cleanup();S.clear();for(const q of A.values())q();A.clear();for(const q of _.values())q.provider.destroy(),q.ydoc.destroy();_.clear(),C.clear();for(const q of u(t))q.provider.destroy(),q.ydoc.destroy();b(t,[],!0)},I=hte({isDestroyed:()=>O,fetchGenerationId:R,getPinnedGeneration:()=>g,onGenerationUnchanged:()=>{console.warn("[Tandem] Provider auth failed without a generation change")},rebuild:q=>{console.warn("[Tandem] Server restarted — resyncing documents"),D(),z==null||z(),b(h,!0),y=null,m=setTimeout(()=>{b(h,!1)},5e3),ie(q)},sleep:M}),H=(q,V,re)=>{var ye,Y;const te=u(t),Z=new Set(te.map(se=>se.id)),ge=new Set(q.map(se=>se.id));for(const se of te)C.delete(se.id),_.delete(se.id);for(const[se,Te]of _)ge.has(se)||((ye=A.get(se))==null||ye(),A.delete(se),Te.provider.destroy(),Te.ydoc.destroy(),_.delete(se),C.delete(se));const Ie=mte(q,Z,C),Se=[];for(const se of Ie){C.add(se.id);const Te=new Mo,Re=new bx({url:`ws://127.0.0.1:${Sw}`,name:se.id,document:Te,token:g});Re.on("authenticationFailed",I),_.set(se.id,{ydoc:Te,provider:Re});const ze=Te.getMap(Vh),Je=ue=>{if(!ue.keysChanged.has(tu)&&!ue.keysChanged.has(nu)&&!ue.keysChanged.has(ru))return;const Ne=ze.get(tu),qe=ze.get(nu),Xe=ze.get(ru);Ne&&H(Ne,qe??null,Xe??null)};ze.observe(Je),A.set(se.id,()=>ze.unobserve(Je)),Se.push({...se,ydoc:Te,provider:Re})}const fe=te.filter(se=>!ge.has(se.id));for(const se of fe){const Te=S.get(se.id);Te&&(Te.cleanup(),S.delete(se.id)),(Y=A.get(se.id))==null||Y(),A.delete(se.id),C.delete(se.id),_.delete(se.id),se.provider.destroy(),se.ydoc.destroy()}const _e=new Map(q.map(se=>[se.id,se])),X=te.filter(se=>ge.has(se.id)).map(se=>{const Te=_e.get(se.id);return!Te||Te.fileName===se.fileName&&Te.filePath===se.filePath&&Te.format===se.format&&Te.readOnly===se.readOnly&&Te.source===se.source?se:{...se,fileName:Te.fileName,filePath:Te.filePath,format:Te.format,readOnly:Te.readOnly,source:Te.source}});b(t,[...X,...Se],!0),V!==null&&(b(e,pte({prev:u(e),serverActiveId:V,serverIds:ge,removedCount:fe.length,serverEpoch:re,lastAppliedEpoch:y}),!0),y=re)};let z=null,Q=null;function ie(q){g=q;const V=new Mo,re=new bx({url:`ws://127.0.0.1:${Sw}`,name:AD,document:V,token:q});b(p,V,!0),Q=re,re.on("authenticationFailed",I),re.on("status",({status:fe})=>{b(n,fe==="connected"),b(r,["connected","connecting","disconnected"].includes(fe)?fe:"connecting",!0),fe==="connected"?(v=!0,b(i,0),b(o,null)):fe==="disconnected"?u(o)===null&&b(o,Date.now(),!0):fe==="connecting"&&(v&&b(i,u(i)+1),u(o)===null&&b(o,Date.now(),!0))});const te=V.getMap(Vh),Z=fe=>{if(fe.keysChanged.has(tu)||fe.keysChanged.has(nu)||fe.keysChanged.has(ru)){const _e=te.get(tu),X=te.get(nu),ye=te.get(ru);_e&&H(_e,X??null,ye??null)}fe.keysChanged.has(Dg)&&b(d,te.get(Dg)===!0)};te.observe(Z);const ge=te.get(tu),Ie=te.get(nu),Se=te.get(ru);ge&&H(ge,Ie??null,Se??null),b(d,te.get(Dg)===!0),z=()=>{te.unobserve(Z),m&&(clearTimeout(m),m=null),re.destroy(),V.destroy(),b(p,null),Q=null,z=null},b(f,!0)}(async()=>{for(;!O;){const q=await R();if(O)return;if(q){ie(q);return}b(f,!0),b(r,"disconnected"),b(n,!1),u(o)===null&&b(o,Date.now(),!0),await M(1e3)}})();const me=L(()=>u(t).find(q=>q.id===u(e))??null),le=L(()=>{var q;return((q=u(me))==null?void 0:q.ydoc)??null}),ke=bC(()=>{pe(()=>{u(le);const q=u(me);for(const V of S.values())V.cleanup();if(S.clear(),q){const V=E(q);S.set(q.id,{cleanup:V})}else b(s,[],!0),b(a,null),b(l,!1),b(c,null)})});return{get tabs(){return u(t)},get activeTabId(){return u(e)},setActiveTabId:q=>{b(e,q,!0)},handleTabClose:q=>{if(u(e)===q){const V=u(t),re=V.findIndex(Z=>Z.id===q),te=V.filter(Z=>Z.id!==q);te.length===0?b(e,null):b(e,te[Math.min(re,te.length-1)].id,!0)}fetch(`http://127.0.0.1:${Gi}${gO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:q})}).then(V=>{V.ok||console.warn("[Tandem] Server rejected close:",V.status)}).catch(V=>{console.warn("[Tandem] Failed to close document on server:",V)})},handleTabRename:(q,V,re)=>{const te=u(t).find(Se=>Se.id===q);if(!te)return;const Z=te.fileName,ge=Se=>u(t).map(fe=>fe.id===q?{...fe,fileName:Se}:fe);b(t,ge(V),!0);const Ie=Se=>{b(t,ge(Z),!0),re==null||re(Se)};fetch(`http://127.0.0.1:${Gi}${vO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:q,newName:V})}).then(async Se=>{if(Se.ok)return;let fe=`Rename failed (${Se.status}).`;try{const _e=await Se.json();_e!=null&&_e.message&&(fe=_e.message)}catch{}console.warn("[Tandem] Server rejected rename:",Se.status,fe),Ie(fe)}).catch(Se=>{console.warn("[Tandem] Failed to rename document on server:",Se),Ie("Rename failed: could not reach the server.")})},get connected(){return u(n)},get connectionStatus(){return u(r)},get reconnectAttempts(){return u(i)},get disconnectedSince(){return u(o)},get annotations(){return u(s)},get claudeStatus(){return u(a)},get claudeActive(){return u(l)},get claudeWorking(){return u(c)},get storeReadOnly(){return u(d)},get bootstrapYdoc(){return u(p)},get ready(){return u(f)},get serverRestarted(){return u(h)},destroy:()=>{O||(O=!0,ke(),D(),z==null||z(),b(s,[],!0),b(e,null),b(f,!1))},reconnect(){Q==null||Q.connect();for(const q of u(t))q.provider.connect()}}}const Nc={full:{column:240,inset:8,gap:24},narrow:{column:160,inset:8,gap:24},stub:{column:28,inset:8,gap:24},off:{column:0,inset:0,gap:0}};function Nd(t){return t.column+t.inset+t.gap}Nc.full.column;const vte=Nd(Nc.full),e6=480,bte=32;function yte(t){return 2*vte+t+e6}function wte(t){const e=t+e6;return{t1:yte(t),t2:2*Nd(Nc.narrow)+e,t3:2*Nd(Nc.stub)+e}}const sh={off:0,stub:1,narrow:2,full:3};function kte(t,e,n,r){const{t1:i,t2:o,t3:s}=n,a=e,l=r,c=a<s?"off":a<o?"stub":a<i?"narrow":"full",d=a>i+l?"full":a>o+l?"narrow":a>s+l?"stub":"off";return sh[t]>sh[c]?c:sh[t]<sh[d]?d:t}function xte(t,e,n){return t?e&&n==="full"?"full":"off":e?n:"off"}function C_(t,e,n){return!e&&!n?"off":t}function _te(t){return t.isDocx?t.effectivelyOn?"position: relative;":"display: contents;":`--editor-measure: ${t.measure}; --margin-left-track: ${t.leftReservePx}px; --margin-right-track: ${t.rightReservePx}px; display: grid; align-items: stretch; grid-template-columns: minmax(0, 1fr) var(--margin-left-track) minmax(0, var(--editor-measure)) var(--margin-right-track) minmax(0, 1fr);`}function Cte(t){const e=L(()=>(t.getLeftRailVisible()?t.leftRailWidthPx:0)+(t.getRightRailVisible()?t.rightRailWidthPx:0)),n=L(()=>wte(u(e)));let r=F("full");pe(()=>{const v=t.getViewportWidth(),g=u(n),y=Ct(()=>u(r)),C=kte(y,v,g,bte);C!==y&&b(r,C,!0)});const i=L(()=>t.getFormat()==="docx"),o=L(()=>xte(u(i),t.getMarginView(),u(r))),s=L(()=>C_(u(o),u(i),t.getLeftHasPending())),a=L(()=>C_(u(o),u(i),t.getRightHasPending())),l=L(()=>u(s)!=="off"),c=L(()=>u(a)!=="off"),d=L(()=>u(l)||u(c)),f=L(()=>Nc[u(s)]),h=L(()=>Nc[u(a)]),p=new Set,m=L(()=>_te({isDocx:u(i),effectivelyOn:u(d),leftReservePx:Nd(u(f)),rightReservePx:Nd(u(h)),measure:(()=>{const v=t.getEditorMeasure(),g=$w[v];return g===void 0&&!p.has(v)&&(p.add(v),console.warn(`[tandem] editorMeasure=${JSON.stringify(v)} not in EDITOR_MEASURE_CH; falling back to comfortable. Both useTandemSettings validators should have coerced this upstream — a TS-violating cast slipped past them.`)),g??$w.comfortable})()}));return{get effectivelyOn(){return u(d)},get leftVisible(){return u(l)},get rightVisible(){return u(c)},get leftMode(){return u(s)},get rightMode(){return u(a)},get leftGeometry(){return u(f)},get rightGeometry(){return u(h)},get layerStyle(){return u(m)}}}function Ste(t,e){const n=L(()=>t.settings.leftPanelVisible),r=L(()=>t.settings.rightPanelVisible&&!(e.tandemMode==="solo"&&t.settings.soloRailHidden));function i(){t.updateSettings({leftPanelVisible:!t.settings.leftPanelVisible})}function o(){if(u(r)){t.updateSettings({rightPanelVisible:!1});return}t.updateSettings({rightPanelVisible:!0,...e.tandemMode==="solo"?{soloRailHidden:!1}:{}})}return{get leftVisible(){return u(n)},get rightVisible(){return u(r)},toggleLeft:i,toggleRight:o}}function Ete(t){return t.mode==="stub"?"stub":t.isActive?"full":t.mode==="narrow"?"clamped":"full"}const Ate=6;function Tte(t,e={}){const n=e.gap??Ate,r=new Map;if(t.length===0)return r;const i=t.map((s,a)=>({...s,idx:a})).sort((s,a)=>s.top-a.top||s.idx-a.idx);let o=Number.NEGATIVE_INFINITY;for(const s of i){if(!Number.isFinite(s.top))continue;const a=Math.max(s.top,o);r.set(s.id,a),typeof s.height=="number"&&Number.isFinite(s.height)&&s.height>0&&(o=a+s.height+n)}return r}function Mte(t,e){const n=[];for(const r of t.keys())e.has(r)||n.push(r);for(const r of n)t.delete(r);return n.length}const S_=.62;function Dte(t){const e=t.endX-t.startX,n=t.startX+e*S_,r=t.endX-e*S_;return`M ${t.startX.toFixed(1)},${t.startY.toFixed(1)} C ${n.toFixed(1)},${t.startY.toFixed(1)} ${r.toFixed(1)},${t.endY.toFixed(1)} ${t.endX.toFixed(1)},${t.endY.toFixed(1)}`}function Ote(t){throw new Error(`unhandled annotation author: ${String(t)}`)}function Ite(t){switch(t){case"claude":return"var(--tandem-author-claude)";case"user":return"var(--tandem-author-user)";case"import":return"var(--tandem-fg-subtle)";default:return Ote(t)}}var Rte=an('<path stroke-linecap="round" fill="none"></path><circle data-testid="margin-anchor-dot"></circle>',1),Nte=T('<div class="margin-bubble svelte-lzz9jv"><!></div>'),Pte=T('<svg aria-hidden="true"></svg> <div></div>',1);function Lte(t,e){nt(e,!0);let n=Ze(e,"reduceMotion",3,!1);const r=12,i=L(()=>e.side==="right"?0:e.gap),o=L(()=>e.side==="right"?e.gap:0),s=L(()=>`position: absolute; top: 0; bottom: 0; ${e.side}: ${e.edgeInset+e.width}px; width: ${e.gap}px; pointer-events: none;`),a=L(()=>e.annotations.filter(A=>e.positions.has(A.id)&&A.status==="pending"));let l=F(tt(new Map));const c=L(()=>new Map(u(a).map(A=>[A.id,Ete({mode:e.mode,isActive:A.id===e.activeAnnotationId})]))),d=L(()=>{const A=u(a).map(O=>({id:O.id,top:e.positions.get(O.id)??0,height:u(c).get(O.id)==="stub"?void 0:u(l).get(O.id)}));return Tte(A)});pe(()=>{const A=new Set(u(a).map(O=>O.id));Ct(()=>{Mte(u(l),A)>0&&b(l,new Map(u(l)),!0)})});function f(A,O){if(!Number.isFinite(O)||O<=0)return;const E=u(l).get(A);if(E!==void 0&&Math.abs(E-O)<.5)return;const M=new Map(u(l));M.set(A,O),b(l,M,!0)}let h=F(void 0),p=F(null),m=0;function v(A){return e.annotations.find(O=>O.id===A)}function g(A){return O=>{const E=v(A);E&&nA(O,E,{accept:e.onAccept,dismiss:e.onDismiss,sendToClaude:e.onSendToClaude,remove:e.onRemove,openEdit:M=>b(p,{id:M,kind:"edit",nonce:++m},!0),openReply:M=>b(p,{id:M,kind:"reply",nonce:++m},!0)})}}async function y(A){var R;if(!Tt())return;const O=(R=A.target)==null?void 0:R.closest("[data-annotation-id]"),E=O==null?void 0:O.getAttribute("data-annotation-id");if(!E)return;const M=v(E);M&&(A.preventDefault(),A.stopPropagation(),await rA(M,g(E)))}pe(()=>{const A=u(h);if(A)return A.addEventListener("contextmenu",y),()=>A.removeEventListener("contextmenu",y)}),pe(()=>iA());var C=Pte(),_=Ae(C);mt(_,21,()=>u(a),A=>A.id,(A,O)=>{const E=L(()=>e.positions.get(u(O).id)),M=L(()=>u(d).get(u(O).id));var R=St(),D=Ae(R);{var I=H=>{const z=L(()=>u(O).id===e.activeAnnotationId),Q=L(()=>u(M)??u(E)),ie=L(()=>u(Q)+r),me=L(()=>Ite(u(O).author)),le=L(()=>Dte({startX:u(i),startY:u(E),endX:u(o),endY:u(ie)}));var ke=Rte(),ce=Ae(ke),ve=k(ce);W(()=>{U(ce,"data-annotation-id",u(O).id),U(ce,"data-tandem-author",u(O).author),U(ce,"d",u(le)),U(ce,"stroke",u(me)),U(ce,"stroke-width",u(z)?1.8:1.1),U(ce,"stroke-opacity",u(z)?.82:.38),U(ve,"data-annotation-id",u(O).id),U(ve,"data-tandem-author",u(O).author),U(ve,"cx",u(i)),U(ve,"cy",u(E)),U(ve,"r",u(z)?3:2),U(ve,"fill",u(me)),U(ve,"fill-opacity",u(z)?.72:.42)}),x(H,ke)};j(D,H=>{u(E)!==void 0&&H(I)})}x(A,R)});var S=k(_,2);mt(S,21,()=>u(a),A=>A.id,(A,O)=>{const E=L(()=>u(d).get(u(O).id)??e.positions.get(u(O).id)??0),M=L(()=>X1(u(O),e.repliesById.get(u(O).id))),R=L(()=>u(c).get(u(O).id)??"full");var D=Nte(),I=w(D);{let H=L(()=>u(O).id===e.activeAnnotationId),z=L(()=>Vm(u(O))?e.onAccept:void 0),Q=L(()=>Um(u(O))?e.onDismiss:void 0),ie=L(()=>Km(u(O))?e.onRemove:void 0),me=L(()=>Wm(u(O))?e.onSendToClaude:void 0),le=L(()=>qm(u(O))?e.onEdit:void 0),ke=L(()=>jm(u(O))?e.onReply:void 0),ce=L(()=>{var ve;return((ve=u(p))==null?void 0:ve.id)===u(O).id?u(p):null});eb(I,{get annotation(){return u(O)},get replies(){return u(M)},get isReviewTarget(){return u(H)},get density(){return u(R)},get reduceMotion(){return n()},onClick:()=>e.onClick(u(O)),get onAccept(){return u(z)},get onDismiss(){return u(Q)},get onRemove(){return u(ie)},get onSendToClaude(){return u(me)},get onEdit(){return u(le)},get onReply(){return u(ke)},get openRequest(){return u(ce)}})}W(()=>{U(D,"data-testid",`margin-bubble-${u(O).id??""}`),U(D,"data-margin-bubble-reply-count",u(M).length),Pe(D,`position: absolute; top: ${u(E)??""}px; ${e.side??""}: 0; width: ${e.width??""}px; pointer-events: auto;`)}),Yi(1,D,()=>EN,()=>({id:u(O).id,reduceMotion:n()})),hD(D,"clientHeight",H=>f(u(O).id,H)),x(A,D)}),Dt(S,A=>b(h,A),()=>u(h)),W(()=>{U(_,"data-testid",`margin-leaders-${e.side??""}`),Pe(_,u(s)),U(S,"data-testid",`margin-column-${e.side??""}`),U(S,"aria-label",e.side==="left"?"Note bubbles":"Comment bubbles"),Pe(S,`position: absolute; top: 0; ${e.side??""}: ${e.edgeInset??""}px; width: ${e.width??""}px; pointer-events: none;`)}),x(t,C),rt()}function E_(t){return t.type==="note"}function A_(t){return t.author==="import"||t.type==="comment"}var Fte=T('<span class="peek-tick h1 svelte-1mwvi22"></span> <span class="peek-tick h2 svelte-1mwvi22"></span> <span class="peek-tick h2 svelte-1mwvi22"></span> <span class="peek-tick h3 svelte-1mwvi22"></span> <span class="peek-tick h2 svelte-1mwvi22"></span>',1),zte=T("<span></span>"),Bte=T('<button type="button" tabindex="-1"><span class="peek-chevron svelte-1mwvi22" aria-hidden="true"> </span> <div class="peek-content svelte-1mwvi22" aria-hidden="true"><!></div> <span class="peek-label svelte-1mwvi22" aria-hidden="true"> </span></button>');function T_(t,e){nt(e,!0);const n=Ze(e,"annotations",19,()=>[]),r=L(()=>e.side==="left"?"Outline":"Annotations");function i(v){return v.type==="highlight"?"hl":v.type==="comment"&&v.suggestedText!=null?"suggest":v.author==="claude"?"claude":v.author==="import"?"import":"user"}function o(v){(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),e.onActivate())}var s=Bte(),a=w(s),l=w(a),c=k(a,2),d=w(c);{var f=v=>{var g=Fte();x(v,g)},h=v=>{var g=St(),y=Ae(g);mt(y,17,n,C=>C.id,(C,_)=>{var S=zte();W(A=>bt(S,1,`peek-dot ${A??""}`,"svelte-1mwvi22"),[()=>i(u(_))]),x(C,S)}),x(v,g)};j(d,v=>{e.kind==="outline"?v(f):v(h,-1)})}var p=k(c,2),m=w(p);W(()=>{bt(s,1,`peek-strip peek-strip-${e.side??""}`,"svelte-1mwvi22"),U(s,"data-testid",`peek-strip-${e.side}`),U(s,"aria-label",e.side==="left"?"Show left panel":"Show right panel"),U(s,"aria-expanded",!e.collapsed),Pe(s,e.collapsed?"":"display: none;"),G(l,e.side==="left"?"›":"‹"),G(m,u(r))}),P("click",s,function(...v){var g;(g=e.onActivate)==null||g.apply(this,v)}),P("keydown",s,o),x(t,s),rt()}lt(["click","keydown"]);const M_=t=>{console.warn("[sanitize]",t)};function Hte(t,e,n){if(t.suggestedText===void 0)return!1;const r=t.suggestedText,i=Ac(t,e.state.doc,n);if(!i)return console.warn("[SidePanel] Could not resolve range for suggestion",t.id),!1;try{e.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,r).run()}catch(o){return console.error("[SidePanel] Editor mutation failed for suggestion",t.id,o),!1}return!0}function Vte({getYdoc:t,getEditor:e,getAnnotations:n,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:o}){let s=F(0),a=F(tt(new Set));const l=new Map;Dn(()=>{for(const y of l.values())clearTimeout(y);l.clear()});function c(){return n().filter(Gh)}function d(y,C){const _=t();if(!_)return;const S=_.getMap(Ri),A=S.get(y);if(!A||A.status!=="pending")return;const O=el(A,M_);if(S.set(y,{...O,status:C}),C==="accepted"&&O.suggestedText!==void 0){const E=e();if(E&&!Hte(O,E,_)){S.set(y,{...O,status:"pending"});return}}b(a,new Set(u(a)).add(y),!0)}function f(y){const C=l.get(y);C&&clearTimeout(C),l.set(y,setTimeout(()=>{l.delete(y);const _=new Set(u(a));_.delete(y),b(a,_,!0)},3e3))}function h(y){const C=l.get(y);C&&(clearTimeout(C),l.delete(y));const _=new Set(u(a));_.delete(y),b(a,_,!0)}function p(y){const C=t();if(!C)return!1;const _=C.getMap(Ri),S=_.get(y);if(!S||S.status==="pending")return h(y),!1;const A=el(S,M_),O=e();if(A.status==="accepted"&&A.suggestedText!==void 0&&O)try{const E=A.suggestedText,M=A.textSnapshot;if(typeof E=="string"&&typeof M=="string"){const R=Ac(A,O.state.doc,C);if(!R)return console.warn(`[undo] Cannot resolve range for annotation ${y}, skipping`),f(y),!1;if(O.state.doc.textBetween(R.from,R.to)!==E)return console.warn(`[undo] Text changed since accept for annotation ${y}, skipping`),f(y),!1;O.chain().focus().deleteRange({from:R.from,to:R.to}).insertContentAt(R.from,M).run()}}catch(E){return console.warn(`[undo] Failed to revert text for annotation ${y}:`,E),f(y),!1}return _.set(y,{...A,status:"pending"}),h(y),!0}function m(y){d(y,"accepted")}function v(y){d(y,"dismissed")}function g(y){const C=e();if(!C)return;const _=Ac(y,C.state.doc,t());if(!_)return;C.chain().focus().setTextSelection({from:_.from,to:_.to}).run();const S=C.view.domAtPos(_.from),A=S.node instanceof HTMLElement?S.node:S.node.parentElement;A==null||A.scrollIntoView({behavior:i(),block:"center"})}return pe(()=>{var _;const y=(o==null?void 0:o())??null;if(y===null)return;if(!n().some(S=>S.id===y&&S.status==="pending")){const S=c();r(((_=S[u(s)])==null?void 0:_.id)??null)}}),pe(()=>{const y=c();u(s)>=y.length&&b(s,Math.max(0,y.length-1),!0)}),{resolveAnnotation:d,undoResolveAnnotation:p,handleAccept:m,handleDismiss:v,scrollToAnnotation:g,getRecentlyResolved:()=>u(a),getReviewIndex:()=>u(s),getReviewTargets:c}}var Ute=T('<button type="button"><span class="highlight-picker-swatch-inner svelte-1d240y8"></span> <svg class="highlight-picker-swatch-check svelte-1d240y8" width="10" height="10" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 11l3 3 7-9"></path></svg></button>'),jte=T('<div class="highlight-picker-popover svelte-1d240y8"><!> <button type="button" data-testid="color-picker-close" title="Close" aria-label="Close color picker" class="highlight-picker-close svelte-1d240y8">✕</button></div>'),qte=T('<div class="highlight-picker-wrap svelte-1d240y8"><!> <button type="button" class="highlight-swatch-toggle svelte-1d240y8" data-testid="toolbar-highlight-color-toggle" title="Choose highlight color"><span class="highlight-swatch-preview svelte-1d240y8"></span></button> <!></div>');function Wte(t,e){nt(e,!0);const n=[{value:"yellow",label:"Yellow"},{value:"green",label:"Green"},{value:"blue",label:"Blue"},{value:"pink",label:"Pink"}],r=Ze(e,"disabled",3,!1);let i=F("yellow"),o=F(!1),s=F(null);pe(()=>{var g;(g=e.onOpenChange)==null||g.call(e,u(o))}),pe(()=>{if(u(o))return Gy(()=>u(s),["mousedown"],()=>{b(o,!1)},{capture:!1})});function a(g){g.preventDefault(),e.onHighlight(u(i))}function l(g){g.preventDefault(),b(o,!u(o))}function c(g){b(i,g,!0),b(o,!1)}var d=qte(),f=w(d);Pr(f,{label:"Highlight",testId:"toolbar-highlight-btn",get disabled(){return r()},disabledTitle:"Select text first",onMouseDown:a});var h=k(f,2),p=w(h),m=k(h,2);{var v=g=>{var y=jte(),C=w(y);mt(C,17,()=>n,({value:S,label:A})=>S,(S,A)=>{let O=()=>u(A).value,E=()=>u(A).label;var M=Ute();let R;var D=w(M);W(()=>{U(M,"data-testid",`toolbar-highlight-color-${O()}`),U(M,"title",E()),U(M,"aria-label",E()),R=bt(M,1,"highlight-picker-swatch svelte-1d240y8",null,R,{"is-selected":O()===u(i)}),Pe(D,`background: ${Yu[O()]??""};`)}),P("click",M,()=>c(O())),x(S,M)});var _=k(C,2);Dt(y,S=>b(s,S),()=>u(s)),P("click",_,()=>b(o,!1)),x(g,y)};j(m,g=>{u(o)&&g(v)})}W(()=>{h.disabled=r(),Pe(p,`background: ${Yu[u(i)]??""};`)}),P("mousedown",h,l),x(t,d),rt()}lt(["mousedown","click"]);var Kte=T('<div class="fmtbar-divider svelte-1lcxsnm"></div> <!>',1),Gte=T('<div class="fmtbar-divider svelte-1lcxsnm"></div> <button type="button" class="fmtbar-hide svelte-1lcxsnm" data-testid="formatbar-hide-btn" title="Hide formatting bar" aria-label="Hide formatting bar"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-1lcxsnm"><path d="m18 15-6-6-6 6"></path></svg></button>',1),Zte=T('<div class="tandem-fmtbar-wrap"><div data-testid="formatting-bar" class="tandem-floating-pill" style="display: inline-flex; align-items: center; padding: var(--tandem-space-1); user-select: none; pointer-events: auto; -webkit-app-region: no-drag; max-width: calc(100% - var(--tandem-space-6));"><div style="display: flex; align-items: center; gap: 1px; overflow: hidden; min-width: 0;"><!> <div class="fmtbar-divider svelte-1lcxsnm"></div> <!></div> <!> <!></div></div>');function Yte(t,e){nt(e,!0);const n=Ze(e,"showAuthorship",3,!0),r=Ze(e,"showComments",3,!0),i=Ze(e,"showHighlights",3,!0),o=Ze(e,"showNotes",3,!0),s=Ze(e,"decorationsMuted",3,!1);let a=F(0);pe(()=>{const S=e.editor;if(!S||S.isDestroyed)return;const A=()=>{S.isDestroyed||Gu(a)};return S.on("selectionUpdate",A),S.on("transaction",A),()=>{S.off("selectionUpdate",A),S.off("transaction",A)}});const l=L(()=>(u(a),!e.editor||e.editor.isDestroyed||!e.ydoc?!1:!e.editor.state.selection.empty));let c=F(!1);function d(S){if(!e.editor||!e.ydoc||e.editor.isDestroyed)return;const{state:A}=e.editor,{from:O,to:E}=A.selection;if(O===E)return;const M=wi(A.doc,zn(O)),R=wi(A.doc,zn(E));if(M===null||R===null){console.warn("[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded",{from:O,to:E});return}q4(e.ydoc,{from:M,to:R},S)}var f=Zte(),h=w(f),p=w(h),m=w(p);j4(m,{get editor(){return e.editor}});var v=k(m,4);{let S=L(()=>!u(l));Wte(v,{get disabled(){return u(S)},onHighlight:d,onOpenChange:A=>b(c,A,!0)})}var g=k(p,2);{var y=S=>{var A=Kte(),O=k(Ae(A),2);U4(O,{get showAuthorship(){return n()},get showComments(){return r()},get showHighlights(){return i()},get showNotes(){return o()},get decorationsMuted(){return s()},get onUpdate(){return e.onUpdateDecorations},get onOpenSettings(){return e.onOpenSettings}}),x(S,A)};j(g,S=>{e.onUpdateDecorations&&S(y)})}var C=k(g,2);{var _=S=>{var A=Gte(),O=k(Ae(A),2);P("click",O,function(...E){var M;(M=e.onHide)==null||M.apply(this,E)}),x(S,A)};j(C,S=>{e.onHide&&S(_)})}W(()=>Pe(f,`position: fixed; top: var(--tandem-fmtbar-top, 52px); left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; z-index: ${u(c)?"var(--tandem-z-toast)":"var(--tandem-z-sticky)"};`)),x(t,f),rt()}lt(["click"]);var Jte=T('<div data-testid="mode-toggle" data-tauri-drag-region="false" class="mode-toggle svelte-14q5edy" role="group" aria-label="AI collaboration mode"><span aria-hidden="true"></span> <button data-testid="mode-solo-btn" title="Write undisturbed — your AI only responds when you message">Solo</button> <button data-testid="mode-tandem-btn" title="Full collaboration — your AI reacts to selections and document changes">Tandem</button></div>');function Xte(t,e){nt(e,!0);var n=Jte(),r=w(n);let i;var o=k(r,2),s=k(o,2);W(()=>{i=bt(r,1,"thumb svelte-14q5edy",null,i,{tandem:e.tandemMode==="tandem"}),bt(o,1,Hh(e.tandemMode==="solo"?"on":""),"svelte-14q5edy"),U(o,"aria-pressed",e.tandemMode==="solo"),bt(s,1,Hh(e.tandemMode==="tandem"?"on":""),"svelte-14q5edy"),U(s,"aria-pressed",e.tandemMode==="tandem")}),P("click",o,()=>e.onModeChange("solo")),P("click",s,()=>e.onModeChange("tandem")),x(t,n),rt()}lt(["click"]);const Qte=[{value:"system",label:"Match system"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"warm",label:"Warm"}];var $te=T('<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>'),ene=T('<button type="button" role="menuitemradio"><span class="brand-theme-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="brand-theme-label svelte-12l7ydf"> </span></button>'),tne=T('<div class="brand-menu-divider svelte-12l7ydf" role="separator"></div>'),nne=T('<div class="brand-menu-heading svelte-12l7ydf">Color scheme</div> <div class="brand-theme-grid svelte-12l7ydf" role="group" aria-label="Color scheme"></div> <!>',1),rne=T('<button type="button" class="brand-menu-item svelte-12l7ydf" data-testid="brand-menu-settings" role="menuitem"><span>Settings…</span> <kbd class="brand-menu-kbd svelte-12l7ydf">Ctrl+,</kbd></button>'),ine=T('<button type="button" class="brand-menu-item svelte-12l7ydf" data-testid="brand-menu-shortcuts" role="menuitem"><span>Keyboard Shortcuts</span> <kbd class="brand-menu-kbd svelte-12l7ydf">?</kbd></button>'),one=T('<div class="brand-menu tandem-floating-pill svelte-12l7ydf" data-testid="titlebar-brand-menu-popover" data-tauri-drag-region="false" role="menu" tabindex="-1" aria-label="Tandem menu"><!> <!> <!></div>'),sne=T('<div class="title-bar-center svelte-12l7ydf" data-tauri-drag-region="false"><!></div>'),ane=T('<button type="button" data-testid="titlebar-source-toggle" data-tauri-drag-region="false"><span aria-hidden="true">&lt;/&gt;</span></button>'),lne=T('<span class="status-dot svelte-12l7ydf" data-tauri-drag-region="false" title="AI assistant is connected" aria-label="AI assistant is connected"></span>'),cne=T(`<button type="button" class="model-chip ai-chip ai-chip-connect svelte-12l7ydf" data-testid="titlebar-connect-ai" data-ai-chip="connect" aria-label="AI isn't set up. Connect Claude Code." title="AI isn't set up — click to connect Claude Code"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf">Connect AI</span></button>`),une=T('<button type="button" class="model-chip ai-chip ai-chip-restart svelte-12l7ydf" data-testid="titlebar-connect-ai" data-ai-chip="restart" aria-label="Claude Code has stopped. Restart it." title="Claude Code stopped — click to restart"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf">Restart Claude Code</span></button>'),dne=T('<button type="button" class="model-chip svelte-12l7ydf" data-testid="titlebar-default-model"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf"> </span></button>'),fne=an('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M3 0H10V7H7V10H0V3H3V0ZM3 3H1V9H6V7H3V3ZM4 1V6H9V1H4Z" fill="currentColor"></path></svg>'),hne=an('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>'),pne=T('<div class="title-bar-spacer-sm svelte-12l7ydf" data-tauri-drag-region=""></div> <div class="title-bar-controls svelte-12l7ydf" data-tauri-drag-region="false"><button type="button" class="title-bar-btn svelte-12l7ydf" aria-label="Minimize"><svg width="10" height="1" viewBox="0 0 10 1" aria-hidden="true" focusable="false"><rect width="10" height="1" fill="currentColor"></rect></svg></button> <button type="button" class="title-bar-btn svelte-12l7ydf"><!></button> <button type="button" class="title-bar-btn title-bar-close svelte-12l7ydf" aria-label="Close"><svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M1 0L0 1L4 5L0 9L1 10L5 6L9 10L10 9L6 5L10 1L9 0L5 4L1 0Z" fill="currentColor"></path></svg></button></div>',1),mne=T('<div class="title-bar svelte-12l7ydf" data-testid="title-bar" data-tauri-drag-region=""><div class="title-bar-left svelte-12l7ydf"><button type="button" class="brand-btn svelte-12l7ydf" data-testid="titlebar-brand-menu" data-tauri-drag-region="false" aria-label="Tandem menu" aria-haspopup="menu"><img class="brand-mark svelte-12l7ydf" src="/logo.png" alt="" width="32" height="32"/> <!></button> <!></div> <div class="title-bar-spacer title-bar-spacer-fixed svelte-12l7ydf" data-tauri-drag-region=""></div> <!> <div class="title-bar-spacer svelte-12l7ydf" data-tauri-drag-region=""></div> <div class="title-bar-actions svelte-12l7ydf"><!> <!> <!> <!></div> <!></div>');function gne(t,e){nt(e,!0);let n=Ze(e,"claudeActive",3,!1),r=Ze(e,"theme",3,"system"),i=Ze(e,"settingsBtn",15,null),o=Ze(e,"updateAvailable",3,!1),s=Ze(e,"defaultModelLabel",3,null),a=Ze(e,"aiChip",3,null),l=Ze(e,"sourceViewActive",3,!1),c=Ze(e,"onToggleSourceView",3,null),d=F(null),f=F(!1),h=[],p=!0;zc(async()=>{if(Tt())try{const[{invoke:X},{getCurrentWindow:ye}]=await Promise.all([Zt(()=>import("./core-DhEqZVGG.js"),[]),Zt(()=>import("./window-DePn7tLG.js").then(Re=>Re.w),__vite__mapDeps([10,1,3]))]);if(!p||(await X("setup_overlay_titlebar").catch(Re=>{console.error("[TitleBar] setup_overlay_titlebar failed:",Re)}),!p))return;const Y=ye();if(b(d,Y,!0),b(f,await Y.isMaximized(),!0),!p)return;const se=await Y.onResized(async()=>{try{b(f,await Y.isMaximized(),!0)}catch(Re){console.warn("[TitleBar] isMaximized check failed on resize:",Re)}});if(!p){se();return}h.push(se);const Te=await Y.onMoved(async()=>{try{b(f,await Y.isMaximized(),!0)}catch(Re){console.warn("[TitleBar] isMaximized check failed on move:",Re)}});if(!p){Te();return}h.push(Te)}catch(X){console.error("[TitleBar] Window API initialization failed:",X)}}),Dn(()=>{p=!1,h.forEach(X=>X())});async function m(){var X;try{await((X=u(d))==null?void 0:X.minimize())}catch(ye){console.error("[TitleBar] minimize failed:",ye)}}async function v(){var X;try{await((X=u(d))==null?void 0:X.toggleMaximize())}catch(ye){console.error("[TitleBar] toggleMaximize failed:",ye)}}async function g(){var X;try{await((X=u(d))==null?void 0:X.close())}catch(ye){console.error("[TitleBar] close failed:",ye)}}let y=F(!1),C=F(null);pe(()=>{if(u(y))return Gy(()=>u(C)??i(),["mousedown"],()=>{b(y,!1)})});function _(){b(y,!u(y))}function S(){var X;b(y,!1),(X=i())==null||X.focus()}function A(X){X.key==="Escape"&&(X.stopPropagation(),S())}function O(X){var ye;(ye=e.onSetTheme)==null||ye.call(e,X),S()}function E(){var X;(X=e.onOpenSettings)==null||X.call(e),b(y,!1)}function M(){var X;(X=e.onOpenHelp)==null||X.call(e),b(y,!1)}var R=mne(),D=w(R),I=w(D),H=k(w(I),2);{var z=X=>{var ye=$te();x(X,ye)},Q=L(()=>Tt()&&o());j(H,X=>{u(Q)&&X(z)})}Dt(I,X=>i(X),()=>i());var ie=k(I,2);{var me=X=>{var ye=one(),Y=w(ye);{var se=ue=>{var Ne=nne(),qe=k(Ae(Ne),2);mt(qe,21,()=>Qte,de=>de.value,(de,xe)=>{var Le=ene();let it;var ne=k(w(Le),2),Ee=w(ne);W(()=>{it=bt(Le,1,"brand-theme-sw svelte-12l7ydf",null,it,{on:r()===u(xe).value}),U(Le,"data-testid",`brand-menu-theme-${u(xe).value??""}`),U(Le,"data-theme-swatch",u(xe).value),U(Le,"aria-checked",r()===u(xe).value),G(Ee,u(xe).label)}),P("click",Le,()=>O(u(xe).value)),x(de,Le)});var Xe=k(qe,2);{var ae=de=>{var xe=tne();x(de,xe)};j(Xe,de=>{(e.onOpenSettings||e.onOpenHelp)&&de(ae)})}x(ue,Ne)};j(Y,ue=>{e.onSetTheme&&ue(se)})}var Te=k(Y,2);{var Re=ue=>{var Ne=rne();P("click",Ne,E),x(ue,Ne)};j(Te,ue=>{e.onOpenSettings&&ue(Re)})}var ze=k(Te,2);{var Je=ue=>{var Ne=ine();P("click",Ne,M),x(ue,Ne)};j(ze,ue=>{e.onOpenHelp&&ue(Je)})}Dt(ye,ue=>b(C,ue),()=>u(C)),P("keydown",ye,A),x(X,ye)};j(ie,X=>{u(y)&&X(me)})}var le=k(D,4);{var ke=X=>{var ye=sne(),Y=w(ye);Gd(Y,()=>e.center),x(X,ye)};j(le,X=>{e.center&&X(ke)})}var ce=k(le,4),ve=w(ce);{var De=X=>{var ye=ane();let Y;W(()=>{Y=bt(ye,1,"source-toggle-btn svelte-12l7ydf",null,Y,{on:l()}),U(ye,"aria-label",l()?"Switch to formatted editor":"View markdown source"),U(ye,"aria-pressed",l()),U(ye,"title",l()?"Switch to formatted editor":"View markdown source")}),P("click",ye,function(...se){var Te;(Te=c())==null||Te.apply(this,se)}),x(X,ye)};j(ve,X=>{c()&&X(De)})}var ee=k(ve,2);{var q=X=>{Xte(X,{get tandemMode(){return e.tandemMode},get onModeChange(){return e.onModeChange}})};j(ee,X=>{e.tandemMode&&e.onModeChange&&X(q)})}var V=k(ee,2);{var re=X=>{var ye=lne();x(X,ye)};j(V,X=>{n()&&X(re)})}var te=k(V,2);{var Z=X=>{var ye=cne();P("click",ye,function(...Y){var se;(se=e.onConnectAi)==null||se.apply(this,Y)}),x(X,ye)},ge=X=>{var ye=une();P("click",ye,function(...Y){var se;(se=e.onRestartClaude)==null||se.apply(this,Y)}),x(X,ye)},Ie=X=>{var ye=dne(),Y=k(w(ye),2),se=w(Y);W(()=>{U(ye,"aria-label",`Default model: ${s()}. Open Settings → Models.`),U(ye,"title",`Default model: ${s()}`),G(se,s())}),P("click",ye,function(...Te){var Re;(Re=e.onOpenModelsSettings)==null||Re.apply(this,Te)}),x(X,ye)};j(te,X=>{a()==="connect"?X(Z):a()==="restart"?X(ge,1):s()&&e.onOpenModelsSettings&&X(Ie,2)})}var Se=k(ce,2);{var fe=X=>{var ye=pne(),Y=k(Ae(ye),2),se=w(Y),Te=k(se,2),Re=w(Te);{var ze=Ne=>{var qe=fne();x(Ne,qe)},Je=Ne=>{var qe=hne();x(Ne,qe)};j(Re,Ne=>{u(f)?Ne(ze):Ne(Je,-1)})}var ue=k(Te,2);W(()=>{se.disabled=u(d)===null,U(Te,"aria-label",u(f)?"Restore":"Maximize"),Te.disabled=u(d)===null,ue.disabled=u(d)===null}),P("click",se,m),P("click",Te,v),P("click",ue,g),x(X,ye)},_e=L(()=>Tt());j(Se,X=>{u(_e)&&X(fe)})}W(()=>U(I,"aria-expanded",u(y))),P("click",I,_),x(t,R),rt()}lt(["click","keydown"]);const t6="tandem-status-count-mode",Lh=["words","characters","sentences","paragraphs","pages"],vne={words:"words",characters:"chars",sentences:"sentences",paragraphs:"paragraphs",pages:"pages"},bne=250;function D_(t){const e=t.trim();return e?e.split(/\s+/).length:0}function O_(t){const e=Lh.indexOf(t);return Lh[(e+1)%Lh.length]??"words"}function X0(t){return vne[t]}function yne(){try{const t=localStorage.getItem(t6);if(t&&Lh.includes(t))return t}catch{}return"words"}function wne(t){try{localStorage.setItem(t6,t)}catch{}}function kne(t,e){if(!t||t.isDestroyed)return 0;const n=t.state.doc.textContent;switch(e){case"characters":return n.length;case"words":return D_(n);case"sentences":{const r=n.match(/[^.!?]+[.!?]+(?:\s|$)/g);return(r==null?void 0:r.length)??(n.trim()?1:0)}case"paragraphs":{let r=0;return t.state.doc.forEach(i=>{i.type.name==="paragraph"&&i.textContent.trim()&&r++}),r}case"pages":return Math.ceil(D_(n)/bne)}}var xne=T('<button type="button" data-testid="status-word-count" style="background: none; border: none; padding: 0; margin: 0; cursor: pointer; color: var(--tandem-fg-subtle); font: inherit; font-family: var(--tandem-font-mono);" class="svelte-1esxubl"> </button>'),_ne=T('<span data-testid="save-indicator" style="color: var(--tandem-accent);" class="svelte-1esxubl">Saving...</span>'),Cne=T('<span style="padding: 1px 8px; font-size: var(--tandem-text-2xs); font-weight: 600; color: var(--tandem-warning-fg-strong); background: var(--tandem-warning-bg); border-radius: var(--tandem-r-pill); border: 1px solid var(--tandem-warning-border);" class="svelte-1esxubl">Review Only</span>'),Sne=T('<span data-testid="claude-working-indicator" class="claude-working-pill svelte-1esxubl" role="status" aria-live="polite"><span class="claude-working-dot svelte-1esxubl"></span> <span class="claude-working-dot svelte-1esxubl"></span> <span class="claude-working-dot svelte-1esxubl"></span> <span style="margin-left: 4px;" class="svelte-1esxubl"> </span></span>'),Ene=T('<div class="tandem-floating-pill tandem-status-pill svelte-1esxubl" style="position: fixed; bottom: var(--tandem-space-3, 12px); left: var(--tandem-space-5, 22px); max-width: calc(100% - var(--tandem-space-7, 44px)); display: inline-flex; align-items: center; padding: 6px var(--tandem-space-3); font-family: var(--tandem-font-mono); font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); user-select: none; gap: var(--tandem-space-3); z-index: var(--tandem-z-sticky); overflow: hidden;"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-1esxubl"><span class="status-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </span> <!> <!></div> <div style="display: flex; align-items: center; gap: var(--tandem-space-1); font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);" class="svelte-1esxubl"><span class="svelte-1esxubl">You:</span> <input data-testid="user-name-input" type="text" aria-label="Display name" title="Your display name" style="background: transparent; border: none; border-bottom: 1px dashed transparent; color: var(--tandem-fg-muted); font: inherit; font-family: var(--tandem-font-sans); font-size: var(--tandem-text-xs); width: 80px; outline: none; padding: 0 2px;" class="svelte-1esxubl"/></div> <!> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-1esxubl"><span class="claude-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </span> <!></div></div>');function Ane(t,e){nt(e,!0);let n=Ze(e,"claudeWorkingTool",3,null),r=Ze(e,"saving",3,!1);function i(V){return{tandem_edit:"editing",tandem_comment:"commenting",tandem_reply:"replying",tandem_annotationReply:"replying"}[V]??V.replace(/^tandem_/,"")}const o=2e3,s=ty(),a=No(ai());let l=F(tt(s.userName)),c=F(void 0);pe(()=>{const V=s.userName;u(l)!==V&&document.activeElement!==u(c)&&b(l,V,!0)});let d=F(!1),f=F(0),h=Ct(()=>e.connected);pe(()=>{const V=h;if(h=e.connected,e.connected&&!V){b(d,!0);const re=setTimeout(()=>{b(d,!1)},o);return()=>clearTimeout(re)}}),pe(()=>{if(e.disconnectedSince==null){b(f,0);return}b(f,Math.floor((Date.now()-e.disconnectedSince)/1e3),!0);const V=setInterval(()=>{b(f,Math.floor((Date.now()-(e.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(V)});const p=L(()=>e.connectionStatus==="connecting"),m=L(()=>e.connected?"var(--tandem-success)":u(p)?"var(--tandem-warning)":"var(--tandem-error)"),v=L(()=>u(d)?"Reconnected":e.connectionStatus==="connected"?"Synced":e.connectionStatus==="connecting"?(()=>{const V=["Reconnecting…"];if(e.reconnectAttempts>0||u(f)>0){const re=[];e.reconnectAttempts>0&&re.push(`attempt ${e.reconnectAttempts}`),u(f)>0&&re.push(`${u(f)}s`),V.push(`(${re.join(", ")})`)}return V.join(" ")})():"Disconnected — check that the server is running");function g(){s.setUserName(u(l))}let y=F(tt(yne())),C=F(0);pe(()=>{const V=e.editor;if(!V||V.isDestroyed)return;const re=()=>{V.isDestroyed||Gu(C)};return V.on("update",re),V.on("transaction",re),()=>{V.off("update",re),V.off("transaction",re)}});const _=L(()=>(u(C),kne(e.editor??null,u(y))));function S(){const V=O_(u(y));b(y,V,!0),wne(V)}var A=Ene(),O=w(A),E=w(O),M=k(E,2),R=w(M),D=k(M,2);{var I=V=>{var re=xne(),te=w(re);W((Z,ge,Ie,Se)=>{U(re,"title",Z),U(re,"aria-label",ge),G(te,`${Ie??""} ${Se??""}`)},[()=>`Click to cycle: ${X0(O_(u(y)))}`,()=>`${u(_)} ${X0(u(y))} (click to change unit)`,()=>u(_).toLocaleString(),()=>X0(u(y))]),P("click",re,S),x(V,re)};j(D,V=>{e.editor&&V(I)})}var H=k(D,2);{var z=V=>{var re=_ne();x(V,re)};j(H,V=>{r()&&V(z)})}var Q=k(O,2),ie=k(w(Q),2);Dt(ie,V=>b(c,V),()=>u(c));var me=k(Q,2);{var le=V=>{var re=Cne();x(V,re)};j(me,V=>{e.readOnly&&V(le)})}var ke=k(me,2),ce=w(ke),ve=k(ce,2),De=w(ve),ee=k(ve,2);{var q=V=>{var re=Sne(),te=k(w(re),6),Z=w(te);W(ge=>G(Z,`${a.specific??""} is ${ge??""}…`),[()=>i(n())]),x(V,re)};j(ee,V=>{n()&&V(q)})}W(()=>{Pe(E,`width: 7px; height: 7px; border-radius: 50%; background: ${u(m)??""}; display: inline-block; animation: ${e.connected&&u(d)?"tandem-conn-bloom 500ms var(--tandem-ease-out)":u(p)?"tandem-conn-pulse 900ms ease-in-out infinite":"none"};`),G(R,u(v)),Vr(ie,u(l)),U(ie,"maxlength",wm),Pe(ce,`width: 7px; height: 7px; border-radius: 50%; background: var(--tandem-author-claude); opacity: ${e.claudeActive?1:.4}; display: inline-block; transition: opacity 0.3s ease; animation: ${e.claudeActive?"tandem-status-pulse 1.5s ease-in-out infinite":"none"};`),Pe(ve,`transition: color 0.3s ease; color: ${e.claudeActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"};`),G(De,e.claudeStatus?`${a.specific} · ${e.claudeStatus}`:`${a.specific} · idle`)}),P("input",ie,V=>{b(l,V.target.value,!0)}),Qt("blur",ie,g),P("keydown",ie,V=>{V.key==="Enter"&&V.currentTarget.blur(),V.key==="Escape"&&(b(l,s.userName,!0),V.currentTarget.blur())}),x(t,A),rt()}lt(["click","input","keydown"]);function Zy(t){return t.source==="file"&&!t.readOnly}const Tne={md:"md",markdown:"md",docx:"docx",doc:"docx",txt:"txt",text:"txt",html:"html",htm:"html"};function Mne(t){const e=t.lastIndexOf(".");return e<=0||e===t.length-1?"other":Tne[t.slice(e+1).toLowerCase()]??"other"}function Dne(t){const e=t.split(/[/\\]/);return{name:e.at(-1)??t,dir:e.slice(0,-1).join("/")}}function One(t,e=Date.now()){const{dir:n,name:r}=Dne(t.path);return{path:t.path,name:r,dir:n,when:u5(t.openedAt,e),pip:Mne(r)}}function Ine(t,e){const n=e.trim().toLowerCase();return n?t.name.toLowerCase().includes(n)||t.dir.toLowerCase().includes(n):!0}function Rne(t,e){const n=e.trim();if(!n)return[{text:t,match:!1}];const r=t.toLowerCase(),i=n.toLowerCase(),o=[];let s=0;for(;s<t.length;){const a=r.indexOf(i,s);if(a===-1){o.push({text:t.slice(s),match:!1});break}a>s&&o.push({text:t.slice(s,a),match:!1}),o.push({text:t.slice(a,a+i.length),match:!0}),s=a+i.length}return o}var Nne=an("<path></path>"),Pne=an('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg>'),Lne=T('<button class="ntl-search-clr svelte-7c4il0" type="button" aria-label="Clear search"><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button>'),Fne=T('<span class="ntl-count svelte-7c4il0" aria-hidden="true"> </span>'),zne=T(`<div class="ntl-empty svelte-7c4il0" data-testid="new-tab-empty"><div class="ntl-empty-ic svelte-7c4il0"><!></div> No recent files yet. <div class="ntl-sub svelte-7c4il0">Open something and it'll appear here.</div></div>`),Bne=T('<div class="ntl-no-match svelte-7c4il0" data-testid="new-tab-no-match"> <div class="ntl-sub svelte-7c4il0">Try a different name, or create a scratchpad.</div></div>'),Hne=T('<mark class="svelte-7c4il0"> </mark>'),Vne=T('<span class="ntl-path svelte-7c4il0"> </span>'),Une=T('<span class="ntl-when svelte-7c4il0"> </span>'),jne=T('<button type="button" data-nav-item="" class="ntl-recent svelte-7c4il0"><span></span> <span class="ntl-body svelte-7c4il0"><span class="ntl-name svelte-7c4il0"></span> <!></span> <!></button>'),qne=T('<div class="ntl-recents svelte-7c4il0"></div>'),Wne=T('<button type="button" data-nav-item="" class="ntl-action svelte-7c4il0" data-testid="new-tab-reopen-closed"><span class="ntl-glyph svelte-7c4il0"><!></span> <span class="ntl-lbl svelte-7c4il0">Reopen last closed</span> <span class="ntl-kbd svelte-7c4il0" aria-hidden="true">Ctrl+Alt+T</span></button>'),Kne=T('<div role="dialog" aria-label="New tab" tabindex="-1" class="new-tab-menu svelte-7c4il0"><div class="ntl-search svelte-7c4il0"><span class="ntl-search-ic svelte-7c4il0"><!></span> <input type="text" placeholder="Search recent files…" aria-label="Search recent files" data-testid="new-tab-search" class="svelte-7c4il0"/> <!> <!> <span class="ntl-esc svelte-7c4il0" aria-hidden="true">Esc</span></div> <div class="ntl-cols svelte-7c4il0"><div class="ntl-col ntl-left svelte-7c4il0"><!></div> <div class="ntl-col ntl-right svelte-7c4il0"><div class="ntl-colhead svelte-7c4il0"><span class="ntl-colhead-label svelte-7c4il0">Create</span></div> <button type="button" data-nav-item="" class="ntl-action ntl-action-primary svelte-7c4il0" data-testid="palette-item-new-scratchpad"><span class="ntl-glyph svelte-7c4il0"><!></span> <span class="ntl-lbl svelte-7c4il0">New scratchpad</span> <span class="ntl-kbd svelte-7c4il0" aria-hidden="true">Ctrl+N</span></button> <div class="ntl-colhead svelte-7c4il0"><span class="ntl-colhead-label svelte-7c4il0">Open</span></div> <button type="button" data-nav-item="" class="ntl-action svelte-7c4il0" data-testid="new-tab-browse"><span class="ntl-glyph svelte-7c4il0"><!></span> <span class="ntl-lbl svelte-7c4il0">Browse files…</span> <span class="ntl-kbd svelte-7c4il0" aria-hidden="true">Ctrl+O</span></button> <!></div></div> <div class="ntl-footer svelte-7c4il0"><span class="ntl-kgrp svelte-7c4il0"><span class="ntl-key svelte-7c4il0" aria-hidden="true">↑</span><span class="ntl-key svelte-7c4il0" aria-hidden="true">↓</span>navigate</span> <span class="ntl-kgrp svelte-7c4il0"><span class="ntl-key svelte-7c4il0" aria-hidden="true">↵</span>open</span> <span class="ntl-spacer svelte-7c4il0"></span> <span class="ntl-kgrp svelte-7c4il0">type to filter</span></div></div>');function Gne(t,e){nt(e,!0);const n=(ee,q=kn,V=kn,re=kn)=>{var te=Pne();mt(te,21,()=>d[q()]??[],dc,(Z,ge)=>{var Ie=Nne();W(()=>U(Ie,"d",u(ge))),x(Z,Ie)}),W(()=>{U(te,"width",V()),U(te,"height",V()),U(te,"stroke-width",re())}),x(ee,te)};let r=F(""),i=F(null),o=F(null);const s=L(()=>e.recentFiles.map(ee=>One(ee))),a=L(()=>u(s).filter(ee=>Ine(ee,u(r)))),l=L(()=>u(s).length>0),c=L(()=>u(r).trim().length>0),d={plus:["M12 5v14","M5 12h14"],folder:["M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z","M14 3v6h6"],undo:["M3 7v6h6","M3 13a9 9 0 1 0 3-7"],search:["M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14z","m20 20-3.5-3.5"],inbox:["M3 7l9 6 9-6","M3 7v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-9-4-9 4z"]};function f(){var ee;return Array.from(((ee=u(i))==null?void 0:ee.querySelectorAll("[data-nav-item]"))??[])}function h(ee){var re,te;const q=f();if(q.length===0)return;const V=q.indexOf(document.activeElement);if(V===-1){(re=ee>0?q[0]:q[q.length-1])==null||re.focus();return}(te=q[(V+ee+q.length)%q.length])==null||te.focus()}function p(ee){ee.key==="Escape"?(ee.preventDefault(),e.onClose()):ee.key==="ArrowDown"?(ee.preventDefault(),h(1)):ee.key==="ArrowUp"&&(ee.preventDefault(),h(-1))}pe(()=>{var ee;u(i)&&((ee=u(o))==null||ee.focus({preventScroll:!0}))});var m=Kne(),v=w(m),g=w(v),y=w(g);n(y,()=>"search",()=>13,()=>1.7);var C=k(g,2);Dt(C,ee=>b(o,ee),()=>u(o));var _=k(C,2);{var S=ee=>{var q=Lne();P("click",q,()=>b(r,"")),x(ee,q)};j(_,ee=>{u(c)&&ee(S)})}var A=k(_,2);{var O=ee=>{var q=Fne(),V=w(q);W(()=>G(V,`${u(a).length??""} of ${u(s).length??""}`)),x(ee,q)};j(A,ee=>{u(l)&&ee(O)})}var E=k(v,2),M=w(E),R=w(M);{var D=ee=>{var q=zne(),V=w(q),re=w(V);n(re,()=>"inbox",()=>16,()=>1.6),x(ee,q)},I=ee=>{var q=Bne(),V=w(q);W(re=>G(V,`No matches for “${re??""}”. `),[()=>u(r).trim()]),x(ee,q)},H=ee=>{var q=qne();mt(q,23,()=>u(a),V=>V.path,(V,re,te)=>{var Z=jne(),ge=w(Z),Ie=k(ge,2),Se=w(Ie);mt(Se,21,()=>Rne(u(re).name,u(r)),dc,(Y,se)=>{var Te=St(),Re=Ae(Te);{var ze=ue=>{var Ne=Hne(),qe=w(Ne);W(()=>G(qe,u(se).text)),x(ue,Ne)},Je=ue=>{var Ne=fr();W(()=>G(Ne,u(se).text)),x(ue,Ne)};j(Re,ue=>{u(se).match?ue(ze):ue(Je,-1)})}x(Y,Te)});var fe=k(Se,2);{var _e=Y=>{var se=Vne(),Te=w(se);W(()=>G(Te,u(re).dir)),x(Y,se)};j(fe,Y=>{u(re).dir&&Y(_e)})}var X=k(Ie,2);{var ye=Y=>{var se=Une(),Te=w(se);W(()=>G(Te,u(re).when)),x(Y,se)};j(X,Y=>{u(re).when&&Y(ye)})}W(()=>{U(Z,"data-testid",`new-tab-recent-${u(te)}`),U(Z,"title",u(re).path),bt(ge,1,`ntl-pip ntl-pip-${u(re).pip??""}`,"svelte-7c4il0")}),P("click",Z,()=>e.onOpen(u(re).path)),x(V,Z)}),x(ee,q)};j(R,ee=>{u(l)?u(a).length===0?ee(I,1):ee(H,-1):ee(D)})}var z=k(M,2),Q=k(w(z),2),ie=w(Q),me=w(ie);n(me,()=>"plus",()=>14,()=>1.9);var le=k(Q,4),ke=w(le),ce=w(ke);n(ce,()=>"folder",()=>13,()=>1.7);var ve=k(le,2);{var De=ee=>{var q=Wne(),V=w(q),re=w(V);n(re,()=>"undo",()=>13,()=>1.7),W(()=>U(q,"title",e.closedTabTop.filePath)),P("click",q,function(...te){var Z;(Z=e.onReopenClosed)==null||Z.apply(this,te)}),x(ee,q)};j(ve,ee=>{e.closedTabTop&&ee(De)})}Dt(m,ee=>b(i,ee),()=>u(i)),P("keydown",m,p),Hr(C,()=>u(r),ee=>b(r,ee)),P("click",Q,function(...ee){var q;(q=e.onNewScratchpad)==null||q.apply(this,ee)}),P("click",le,function(...ee){var q;(q=e.onBrowse)==null||q.apply(this,ee)}),x(t,m),rt()}lt(["keydown","click"]);var Zne=T('<input type="text" spellcheck="false" autocomplete="off" aria-label="Rename file" style="min-width: 80px; max-width: 160px; font-size: var(--tandem-text-sm); padding: 0 4px; height: 20px; border: 1px solid var(--tandem-accent); border-radius: var(--tandem-r-1); background: var(--tandem-bg); color: var(--tandem-fg); outline: none;"/>');function Yne(t,e){nt(e,!0);let n=F(tt(Ct(()=>e.initial))),r=!1;function i(l){if(r)return;r=!0;const c=u(n).trim();l&&c.length>0&&c!==e.initial?e.oncommit(c):e.oncancel()}function o(l){l.focus();const c=e.initial.lastIndexOf(".");l.setSelectionRange(0,c>0?c:e.initial.length)}function s(l){l.stopPropagation(),l.key==="Enter"?(l.preventDefault(),i(!0)):l.key==="Escape"&&(l.preventDefault(),i(!1))}var a=Zne();Fc(()=>Hr(a,()=>u(n),l=>b(n,l))),qr(a,l=>o==null?void 0:o(l)),W(()=>U(a,"data-testid",e.testId)),P("keydown",a,s),Qt("blur",a,()=>i(!1)),P("pointerdown",a,l=>l.stopPropagation()),P("click",a,l=>l.stopPropagation()),P("dblclick",a,l=>l.stopPropagation()),x(t,a),rt()}lt(["keydown","pointerdown","click","dblclick"]);var Jne=T('<span class="dot svelte-1btt0ja" aria-hidden="true">●</span>'),Xne=T('<span class="saved-check svelte-1btt0ja" aria-hidden="true">✓</span>'),Qne=T('<span class="svelte-1btt0ja"> </span>'),$ne=T('<span class="tab-ro-badge svelte-1btt0ja" aria-label="Read-only">RO</span>'),ere=T('<div role="tab" class="svelte-1btt0ja"><span class="save-indicator svelte-1btt0ja"><!></span> <!> <!> <button style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-md); line-height: 1; color: var(--tandem-fg-muted); padding: 0 2px; border-radius: var(--tandem-r-1);" title="Close document" class="svelte-1btt0ja">×</button></div>');function tre(t,e){nt(e,!0);const n=Ze(e,"reduceMotion",3,!1),r=Ze(e,"isRenaming",3,!1),i=L(()=>Zy(e.tab));let o=F(!1),s=null;pe(()=>{const{ydoc:R,readOnly:D}=e.tab;if(D){b(o,!1);return}const I=R.getXmlFragment("default"),H=R.getMap(Vh);let z=!1;const Q=setTimeout(()=>{z=!0,s=H.get(Tw)??0,b(o,!1)},500),ie=()=>{z&&b(o,!0)};I.observeDeep(ie);const me=()=>{if(!z)return;const le=H.get(Tw);le!==void 0&&le!==s&&(s=le,b(o,!1))};return H.observe(me),()=>{clearTimeout(Q),I.unobserveDeep(ie),H.unobserve(me)}});const a=600;let l=F(!1),c=!1;pe(()=>{const R=c;if(c=u(o),!u(o)&&R){b(l,!0);const D=setTimeout(()=>{b(l,!1)},a);return()=>clearTimeout(D)}b(l,!1)});const d=L(()=>["display: flex","align-items: center","gap: 6px","padding: 0 10px 0 12px","height: 26px","font-size: var(--tandem-text-sm)","cursor: pointer",`background: ${e.isActive?"var(--tandem-surface)":"transparent"}`,`color: ${e.isActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}`,`border: 1px solid ${e.isActive?"var(--tandem-border)":"transparent"}`,`border-left: ${e.dropIndicator==="left"?"2px solid var(--tandem-accent)":e.isActive?"1px solid var(--tandem-border)":"2px solid transparent"}`,`border-right: ${e.dropIndicator==="right"?"2px solid var(--tandem-accent)":e.isActive?"1px solid var(--tandem-border)":"2px solid transparent"}`,"border-radius: var(--tandem-r-pill)",`box-shadow: ${e.isActive?"var(--tandem-shadow-1)":"0 1px 3px rgba(0, 0, 0, 0.08)"}`,"user-select: none","touch-action: none","white-space: nowrap","transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s","flex-shrink: 0"].join("; "));let f=F(void 0);function h(){u(f)&&(u(f).style.color="var(--tandem-error)")}function p(){u(f)&&(u(f).style.color="var(--tandem-fg-muted)")}var m=ere();U(m,"tabindex",0);var v=w(m),g=w(v);{var y=R=>{var D=Jne();x(R,D)},C=R=>{var D=Xne();x(R,D)};j(g,R=>{u(o)?R(y):u(l)&&R(C,1)})}var _=k(v,2);{var S=R=>{{let D=L(()=>`tab-rename-input-${e.tab.id}`);Yne(R,{get initial(){return e.tab.fileName},get testId(){return u(D)},oncommit:I=>{var H;return(H=e.onrename)==null?void 0:H.call(e,e.tab.id,I)},oncancel:()=>{var I;return(I=e.onrenamecancel)==null?void 0:I.call(e)}})}},A=R=>{var D=Qne(),I=w(D);W(()=>{U(D,"data-testid",`tab-name-${e.tab.id}`),U(D,"title",u(i)?`${e.tab.filePath} — double-click or F2 to rename`:e.tab.filePath),Pe(D,`font-weight: ${e.isActive?500:400}; min-width: 80px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),G(I,e.tab.fileName)}),P("dblclick",D,H=>{var z;u(i)&&(H.stopPropagation(),(z=e.onstartrename)==null||z.call(e,e.tab.id))}),x(R,D)};j(_,R=>{r()?R(S):R(A,-1)})}var O=k(_,2);{var E=R=>{var D=$ne();x(R,D)};j(O,R=>{e.tab.readOnly&&R(E)})}var M=k(O,2);Dt(M,R=>b(f,R),()=>u(f)),W(()=>{U(m,"data-testid",`tab-${e.tab.id}`),U(m,"data-active",e.isActive),U(m,"aria-selected",e.isActive),U(m,"aria-label",e.tab.fileName),Pe(m,u(d)),U(v,"data-testid",`unsaved-indicator-${e.tab.id}`),U(v,"aria-hidden",!u(o)),U(M,"aria-label",`Close ${e.tab.fileName}`)}),P("click",m,()=>e.onswitch(e.tab.id)),P("pointerdown",m,R=>e.onpointerdown(R,e.tab.id)),P("keydown",m,R=>e.onkeydown(R,e.tab.id)),P("click",M,R=>{R.stopPropagation(),e.onclose(e.tab.id)}),P("pointerdown",M,R=>R.stopPropagation()),Qt("mouseenter",M,h),Qt("mouseleave",M,p),Yi(2,m,()=>TN,()=>({reduceMotion:n()})),x(t,m),rt()}lt(["click","pointerdown","keydown","dblclick"]);const nre=["ctx:tab:close","ctx:tab:closeOthers","ctx:tab:closeRight","ctx:tab:copyPath","ctx:tab:reveal"],rre=new Set(nre);function ire(t){return typeof t=="string"&&rre.has(t)}function Wb(t){return!km(t)&&!El(t)}function ore(t,e){const n=t.findIndex(i=>i.id===e),r=n>=0?t[n]:void 0;return{canCloseOthers:t.length>1,canCloseRight:n>=0&&n<t.length-1,hasPath:!!r&&Wb(r.filePath)}}function sre(t,e){return t.some(n=>n.id===e)?t.filter(n=>n.id!==e).map(n=>n.id):[]}function are(t,e){const n=t.findIndex(r=>r.id===e);return n<0?[]:t.slice(n+1).map(r=>r.id)}var lre=T('<div style="position: relative; display: flex; align-items: center; background: transparent; min-height: 32px; z-index: var(--tandem-z-base); width: 100%; min-width: 0;"><div data-testid="tab-scroll-container" role="tablist" aria-label="Open documents" style="display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 6px 8px;"></div> <div class="nt-wrap svelte-urrc8n"><div><button data-testid="open-file-btn" class="tandem-floating-pill tab-add-pill svelte-urrc8n" title="Open file" aria-label="Open file" aria-haspopup="dialog">+</button> <div class="nt-grid svelte-urrc8n"><div class="nt-cell svelte-urrc8n"><!></div></div></div></div></div>');function cre(t,e){nt(e,!0);const n=Ze(e,"reduceMotion",3,!1),r=Ze(e,"openMenuTrigger",3,0),i=Ze(e,"renameTrigger",3,0),o=Ze(e,"closedTabTop",3,null);let s=F(null);function a(B){b(s,B,!0)}function l(B,$){var we;b(s,null),(we=e.onTabRename)==null||we.call(e,B,$)}function c(){b(s,null)}const d=L(()=>n()?"auto":"smooth");let f=F(!1),h=F(tt([])),p=F(null),m=F(!1),v=F(!1),g=F(null),y=new Set;pe(()=>{const B=new Set(e.tabs.map($=>$.id));for(const $ of y)B.has($)||y.delete($)});function C(B){y.has(B)||(y.add(B),e.onTabClose(B))}let _=null,S=null;async function A(B){var Oe;if(!Tt())return;const $=(Oe=B.target)==null?void 0:Oe.closest('[data-testid^="tab-"][role="tab"]'),we=te($);if(!we)return;const He=e.tabs.find(K=>K.id===we);if(He){_=we,S=He.filePath,B.preventDefault();try{await(await hs())("show_tab_context_menu",{req:ore(e.tabs,we)})}catch{}}}async function O(B){var He,Oe;const $=_,we=S;if($)switch(B){case"ctx:tab:close":C($);return;case"ctx:tab:closeOthers":(He=e.onCloseOthers)==null||He.call(e,$);return;case"ctx:tab:closeRight":(Oe=e.onCloseToRight)==null||Oe.call(e,$);return;case"ctx:tab:copyPath":if(we&&Wb(we))try{await navigator.clipboard.writeText(we)}catch{}return;case"ctx:tab:reveal":if(we&&Wb(we))try{await(await hs())("show_in_file_manager",{path:we})}catch{}return}}let E=F(void 0),M=F(!1),R=F(!1),D=F(null),I=F(null),H=null,z=0,Q=0,ie=!1,me=null;const le=5;function ke(B){Z(B)}function ce(B){ge(B)}function ve(B){H!==null&&B.pointerId===H&&ee()}function De(B){B.key==="Escape"&&ee()}function ee(){if(me&&H!==null)try{me.releasePointerCapture(H)}catch{}window.removeEventListener("pointermove",ke),window.removeEventListener("pointerup",ce),window.removeEventListener("pointercancel",ve),window.removeEventListener("keydown",De),b(D,null),b(I,null),H=null,ie=!1,me=null}Dn(ee),pe(()=>{if(!u(D)&&!u(I))return;const B=new Set(e.tabs.map($=>$.id));u(D)&&!B.has(u(D))&&b(D,null),u(I)&&!B.has(u(I).id)&&b(I,null)});function q(){const B=u(E);B&&(b(M,B.scrollLeft>0),b(R,B.scrollLeft+B.clientWidth<B.scrollWidth-1))}pe(()=>{const B=u(E);if(!B)return;q(),B.addEventListener("scroll",q,{passive:!0});const $=new ResizeObserver(q);return $.observe(B),()=>{B.removeEventListener("scroll",q),$.disconnect()}}),pe(()=>{const B=u(E);if(B)return B.addEventListener("contextmenu",A),()=>B.removeEventListener("contextmenu",A)}),pe(()=>{if(!Tt())return;const B=Zt(async()=>{const{listen:$}=await import("./event-CNdo2oXa.js");return{listen:$}},__vite__mapDeps([3,1])).then(({listen:$})=>$("context-menu-action",we=>{var Oe;const He=(Oe=we.payload)==null?void 0:Oe.id;ire(He)&&O(He)}));return B.catch(()=>{}),()=>{B.then($=>$()).catch(()=>{})}}),pe(()=>{e.tabs.length,q()}),pe(()=>{if(!e.activeTabId||!u(E))return;const B=u(E).querySelector(`[data-testid="tab-${e.activeTabId}"]`);B&&B.scrollIntoView({inline:"nearest",block:"nearest",behavior:u(d)})});function V(B,$){if(!(B.button!==0||u(Se))){H=B.pointerId,z=B.clientX,Q=B.clientY,ie=!1,b(D,$,!0),me=B.currentTarget;try{me.setPointerCapture(B.pointerId)}catch{}window.addEventListener("pointermove",ke),window.addEventListener("pointerup",ce),window.addEventListener("pointercancel",ve),window.addEventListener("keydown",De)}}function re(B,$){var He;return((He=document.elementFromPoint(B,$))==null?void 0:He.closest('[data-testid^="tab-"][role="tab"]'))??null}function te(B){var $;return(($=B==null?void 0:B.getAttribute("data-testid"))==null?void 0:$.slice(4))??null}function Z(B){if(H===null||B.pointerId!==H||!u(D))return;if(!ie){const he=B.clientX-z,Me=B.clientY-Q;if(Math.hypot(he,Me)<le)return;ie=!0}B.preventDefault();const $=re(B.clientX,B.clientY),we=te($);if(!$||!we||we===u(D)){b(I,null);return}const He=$.getBoundingClientRect(),Oe=He.left+He.width/2,K=B.clientX<Oe?"left":"right";b(I,{id:we,side:K},!0)}function ge(B){if(H===null||B.pointerId!==H)return;const $=ie,we=u(I);if($&&u(D)&&we&&we.id!==u(D)&&e.reorder&&e.tabs.some(He=>He.id===u(D))&&e.tabs.some(He=>He.id===we.id)&&e.reorder(u(D),we.id,we.side),$){let He;const Oe=K=>{K.stopPropagation(),K.preventDefault(),window.removeEventListener("click",Oe,!0),clearTimeout(He)};window.addEventListener("click",Oe,!0),He=setTimeout(()=>window.removeEventListener("click",Oe,!0),0)}ee()}function Ie(B,$){if(!B.altKey||!e.reorder||B.key!=="ArrowLeft"&&B.key!=="ArrowRight")return;B.preventDefault();const we=e.tabs.findIndex(He=>He.id===$);we!==-1&&(B.key==="ArrowLeft"&&we>0?e.reorder($,e.tabs[we-1].id):B.key==="ArrowRight"&&we<e.tabs.length-1&&e.reorder(e.tabs[we+1].id,$))}const Se=L(()=>e.tabs.length<=1);function fe(){const B=!u(f);if(B)b(h,nk(),!0),Je=document.activeElement,b(m,Y(),!0);else{_e();return}b(f,B)}function _e(){var $;const B=document.activeElement;B&&(($=u(g))!=null&&$.contains(B))&&B.blur(),b(f,!1)}const X=460,ye=8;function Y(){if(!u(p))return!1;const B=u(p).getBoundingClientRect(),$=window.innerWidth,we=Math.min(X,$-2*ye);return B.right-we>=ye?!1:B.left+we<=$-ye?!0:$-B.left>B.right}let se=null;function Te(B){if(!u(g))return Number.NaN;const $=getComputedStyle(u(g)).getPropertyValue(B).trim();return $.endsWith("ms")?parseFloat($):$.endsWith("s")?parseFloat($)*1e3:parseFloat($)}function Re(){if(!u(g))return 0;const B=Te("--morph-p1")+Te("--morph-p2");return Number.isFinite(B)&&B>0?B+40:0}pe(()=>{if(u(f)){se&&(clearTimeout(se),se=null),b(v,!0);return}if(!Ct(()=>u(v)))return;se&&clearTimeout(se);const B=Re();if(B<=0){b(v,!1);return}se=setTimeout(()=>{b(v,!1),se=null},B)}),Dn(()=>{se&&clearTimeout(se)});let ze=!1,Je=null;pe(()=>{if(!u(f))return;function B($){var He,Oe;const we=$.target;we&&((He=u(p))!=null&&He.contains(we)||(Oe=we.closest)!=null&&Oe.call(we,".new-tab-menu")||H$(we)||(ze=!0,_e()))}return window.addEventListener("pointerdown",B,!0),()=>window.removeEventListener("pointerdown",B,!0)});let ue=!1;pe(()=>{var $;if(u(f)){ue=!0;return}if(!ue)return;ue=!1;const B=Je;if(Je=null,ze){ze=!1;return}B&&B.isConnected&&B!==u(p)&&!(($=u(g))!=null&&$.contains(B))&&B.focus({preventScroll:!0})}),pe(()=>{r()>0&&Ct(fe)}),pe(()=>{i()>0&&Ct(()=>{const B=e.tabs.find($=>$.id===e.activeTabId);B&&Zy(B)&&b(s,B.id,!0)})});var Ne=lre(),qe=w(Ne);mt(qe,21,()=>e.tabs,B=>B.id,(B,$)=>{{let we=L(()=>u($).id===e.activeTabId),He=L(()=>{var K;return((K=u(I))==null?void 0:K.id)===u($).id?u(I).side:null}),Oe=L(()=>u(s)===u($).id);tre(B,{get tab(){return u($)},get isActive(){return u(we)},get onswitch(){return e.onTabSwitch},onclose:C,onpointerdown:V,get dropIndicator(){return u(He)},onkeydown:Ie,get reduceMotion(){return n()},get isRenaming(){return u(Oe)},onstartrename:a,onrename:l,onrenamecancel:c})}}),Dt(qe,B=>b(E,B),()=>u(E));var Xe=k(qe,2),ae=w(Xe);let de;var xe=w(ae);Dt(xe,B=>b(p,B),()=>u(p));var Le=k(xe,2),it=w(Le),ne=w(it);{var Ee=B=>{Gne(B,{get recentFiles(){return u(h)},get closedTabTop(){return o()},onOpen:async $=>{_e();const we=await ms($);we.ok?Jd(Yd(nk(),$)):console.warn("[tandem] failed to open recent file:",we.error)},onNewScratchpad:()=>{_e(),Jh()},onBrowse:()=>{var $;_e(),($=e.onRequestOpenDialog)==null||$.call(e)},onReopenClosed:()=>{var $;_e(),($=e.onReopenClosed)==null||$.call(e)},onClose:_e})};j(ne,B=>{u(v)&&B(Ee)})}Dt(ae,B=>b(g,B),()=>u(g)),W(()=>{bt(qe,1,Hh(["tab-scroll-hide","tab-scroll-mask",u(M)&&u(R)&&"has-overflow",u(M)&&!u(R)&&"overflow-left",!u(M)&&u(R)&&"overflow-right"])),de=bt(ae,1,"nt-morph svelte-urrc8n",null,de,{open:u(f),filled:u(f)||u(v),"grow-right":u(m)}),U(xe,"aria-expanded",u(f)),it.inert=!u(f)}),P("click",xe,fe),x(t,Ne),rt()}lt(["click"]);const I_=(t,e=kn,n=kn)=>{var r=dre();W(()=>{bt(r,1,`panel-edge-collapse panel-edge-collapse-${e()}`,"svelte-y74n0s"),U(r,"data-testid",`panel-edge-collapse-${e()}`),U(r,"aria-label",e()==="left"?"Hide left panel":"Hide right panel")}),P("click",r,function(...i){var o;(o=n())==null||o.apply(this,i)}),x(t,r)};var ure=T('<div role="slider" aria-orientation="horizontal" tabindex="0" style="width: 4px; cursor: col-resize; background: transparent; flex-shrink: 0; transition: background 0.15s; position: relative; z-index: var(--tandem-z-base);"></div>'),dre=T('<div role="button" tabindex="-1"></div>'),fre=T("<!> <!> <!>",1),hre=T('<div class="margin-track svelte-y74n0s" style="grid-column: 2; grid-row: 1;"><!></div>'),pre=T('<div class="margin-track svelte-y74n0s" style="grid-column: 4; grid-row: 1;"><!></div>'),mre=T('<div class="editor-content-track svelte-y74n0s" style="grid-column: 3; grid-row: 1;"><!></div> <!> <!>',1),gre=T('<div class="editor-end-marker svelte-y74n0s" aria-hidden="true"><span class="editor-end-pill svelte-y74n0s">End of document</span></div>'),vre=T('<div data-testid="editor-stage"><!></div> <!>',1),bre=T('<div data-testid="editor-scroll-container" role="region" aria-label="Document editor"><!> <!> <!> <!></div>'),yre=T('<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>'),wre=T('<div style="padding: var(--tandem-space-2) var(--tandem-space-4); background: var(--tandem-warning-bg); border-bottom: 1px solid var(--tandem-warning-border); font-size: 13px; color: var(--tandem-warning-fg-strong); text-align: center;">Server restarted — refreshing documents</div>'),kre=T('<div class="rail-float-shadow rail-float-shadow-left svelte-y74n0s" aria-hidden="true"></div>'),xre=T('<div class="rail-float-shadow rail-float-shadow-right svelte-y74n0s" aria-hidden="true"></div>'),_re=T('<span class="rail-tab-badge svelte-y74n0s"> </span>'),Cre=T('<!> <!> <!> <!> <!> <div style="position: relative; display: flex; flex: 1; overflow: hidden; background: var(--tandem-bg);"><div><!> <div data-testid="left-outline-rail" class="rail-full rail-full-left svelte-y74n0s"><!> <!></div> <!></div> <!> <!> <!> <div><!> <div class="rail-full rail-full-right svelte-y74n0s"><!> <div class="rail-tabs-row svelte-y74n0s"><div class="rail-tabs-track svelte-y74n0s"><button data-testid="annotations-tab">Annotations <!></button> <button data-testid="chat-tab">Chat</button></div></div> <!> <!></div> <!></div></div> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>',1),Sre=T('<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>');function Ere(t,e){nt(e,!0);const n=N=>{cre(N,{get tabs(){return p.orderedTabs},get activeTabId(){return o.activeTabId},get onTabSwitch(){return o.setActiveTabId},onTabClose:c,onCloseOthers:d,onCloseToRight:f,get reorder(){return p.reorder},get reduceMotion(){return m.settings.reduceMotion},onRequestOpenDialog:()=>void te(),get openMenuTrigger(){return u($)},onTabRename:(J,be)=>o.handleTabRename(J,be,Ke=>E.push({id:gl(),type:"launcher",severity:"error",message:Ke,timestamp:Date.now()})),get renameTrigger(){return u(we)},get closedTabTop(){return a.top},onReopenClosed:h})},r=(N,J=kn,be=kn,Ke=kn,et=kn)=>{var Pt=ure();U(Pt,"aria-valuemin",0),U(Pt,"aria-valuemax",100),W(Jt=>{U(Pt,"data-testid",Ke()??`${J()}-panel-resize-handle`),U(Pt,"aria-label",J()==="left"?"Resize left panel":"Resize right panel"),U(Pt,"aria-valuenow",Jt)},[()=>et()!==void 0?Math.round((et()-Ql)/(Rd-Ql)*100):50]),P("mousedown",Pt,function(...Jt){var vs;(vs=be())==null||vs.apply(this,Jt)}),P("keydown",Pt,Jt=>{let Dr=null;Jt.key==="ArrowRight"||Jt.key==="ArrowUp"?Dr=16:Jt.key==="ArrowLeft"||Jt.key==="ArrowDown"?Dr=-16:Jt.key==="PageUp"?Dr=80:Jt.key==="PageDown"?Dr=-80:Jt.key==="Home"?Dr=Ql-(J()==="left"?K.width:he.width):Jt.key==="End"&&(Dr=Rd-(J()==="left"?K.width:he.width)),Dr!==null&&(Jt.preventDefault(),Jt.stopPropagation(),J()==="left"?K.handleResizeStep(Dr):he.handleResizeStep(Dr))}),P("keyup",Pt,()=>{}),Qt("mouseenter",Pt,Jt=>{Jt.currentTarget.style.background="var(--tandem-border-strong)"}),Qt("mouseleave",Pt,Jt=>{Jt.currentTarget.style.background="transparent"}),x(N,Pt)},i=N=>{var J=bre();let be;{const zi=hn=>{w$(hn,{get ydoc(){return u(ht).ydoc},get provider(){return u(ht).provider},get readOnly(){return u(Xc)},get currentFilePath(){return u(ht).filePath},get format(){return u(ht).format},get activeAnnotationId(){return u(Re)},onEditorReady:Xt=>b(ue,Xt,!0),onAnnotationClick:Xt=>{b(se,"annotations"),b(Re,Xt,!0)},onClearAnnotation:()=>{b(Re,null)},onSlashCommandMenuChange:Xt=>b(qe,Xt,!0)})},kr=(hn,Xt=kn,rr=kn)=>{const ao=L(()=>Xt()==="left"?jn.leftGeometry:jn.rightGeometry),da=L(()=>Xt()==="left"?jn.leftMode:jn.rightMode);Lte(hn,{get side(){return Xt()},get annotations(){return rr()},get positions(){return r6.byId},get width(){return u(ao).column},get edgeInset(){return u(ao).inset},get gap(){return u(ao).gap},get mode(){return u(da)},get activeAnnotationId(){return u(Re)},get repliesById(){return i6.byId},get reduceMotion(){return m.settings.reduceMotion},onClick:lo=>{b(Re,lo.id,!0),Kr.scrollToAnnotation(lo)},get onAccept(){return Kr.handleAccept},get onDismiss(){return Kr.handleDismiss},get onRemove(){return u(yf).onRemove},get onEdit(){return u(yf).onEdit},get onReply(){return u(yf).onReply},get onSendToClaude(){return u(yf).onSendToClaude}})};var Ke=w(J);{let hn=L(()=>{var rr;return u(Xc)&&((rr=u(ht))==null?void 0:rr.format)==="docx"}),Xt=L(()=>{var rr;return(rr=u(ht))==null?void 0:rr.id});Oz(Ke,{get visible(){return u(hn)},get documentId(){return u(Xt)}})}var et=k(Ke,2);{var Pt=hn=>{f8(hn,{get ydoc(){return u(ht).ydoc},get documentId(){return u(ht).id},get fileName(){return u(ht).fileName}})};j(et,hn=>{u(ht)&&u(ht).format==="docx"&&hn(Pt)})}var Jt=k(et,2);{var vs=hn=>{var Xt=St(),rr=Ae(Xt);Bl(rr,()=>u(ht).id,ao=>{{let da=L(()=>u(xe).get(u(ht).id));L$(ao,{get documentId(){return u(ht).id},get ydoc(){return u(ht).ydoc},get initialDraft(){return u(da)},onDraftChange:(lo,hl)=>it(u(ht).id,lo,hl),onExit:()=>n6(u(ht).id)})}}),x(hn,Xt)},wf=hn=>{var Xt=vre(),rr=Ae(Xt),ao=w(rr);{var da=Or=>{var Gr=fre(),fa=Ae(Gr);Bl(fa,()=>u(ht).id,Rr=>{zi(Rr)});var ha=k(fa,2);{var pl=Rr=>{kr(Rr,()=>"left",()=>u(gg))};j(ha,Rr=>{jn.leftVisible&&u(ht)&&Rr(pl)})}var $c=k(ha,2);{var Ir=Rr=>{kr(Rr,()=>"right",()=>u(vg))};j($c,Rr=>{jn.rightVisible&&u(ht)&&Rr(Ir)})}x(Or,Gr)},lo=Or=>{var Gr=mre(),fa=Ae(Gr),ha=w(fa);{var pl=qn=>{var Bi=St(),bs=Ae(Bi);Bl(bs,()=>u(ht).id,kg=>{zi(kg)}),x(qn,Bi)},$c=qn=>{y8(qn,{get connected(){return o.connected},get aiChip(){return z.chip},onOpenFile:()=>b(re,!0),onRetry:()=>o.reconnect(),onOpenSettings:Ie,onConnectAi:Q,onRestartClaude:ie})};j(ha,qn=>{u(ht)?qn(pl):qn($c,-1)})}var Ir=k(fa,2);{var Rr=qn=>{var Bi=hre(),bs=w(Bi);kr(bs,()=>"left",()=>u(gg)),x(qn,Bi)};j(Ir,qn=>{jn.leftVisible&&u(ht)&&qn(Rr)})}var kf=k(Ir,2);{var wg=qn=>{var Bi=pre(),bs=w(Bi);kr(bs,()=>"right",()=>u(vg)),x(qn,Bi)};j(kf,qn=>{jn.rightVisible&&u(ht)&&qn(wg)})}x(Or,Gr)};j(ao,Or=>{var Gr;((Gr=u(ht))==null?void 0:Gr.format)==="docx"?Or(da):Or(lo,-1)})}Dt(rr,Or=>b(Ne,Or),()=>u(Ne));var hl=k(rr,2);{var yg=Or=>{var Gr=gre();x(Or,Gr)};j(hl,Or=>{u(ht)&&Or(yg)})}W(()=>Pe(rr,jn.layerStyle)),x(hn,Xt)};j(Jt,hn=>{u(bf)&&u(ht)?hn(vs):hn(wf,-1)})}var Dr=k(Jt,2);D$(Dr,{get editor(){return u(ue)},get open(){return u(Xe)},onClose:()=>b(Xe,!1),get tabs(){return o.tabs},get forceScope(){return u(ae)}}),Dt(J,hn=>b(so,hn),()=>u(so)),qr(J,(hn,Xt)=>$t==null?void 0:$t(hn,Xt),()=>"y")}W(()=>{be=bt(J,1,"editor-scroll tandem-scroll-fade-y",null,be,{"hide-raw-md":!m.settings.showRawMarkdown}),Pe(J,`position: relative; flex: 1; overflow: auto; padding: max(var(--tandem-space-7), 52px) var(--tandem-space-5) var(--tandem-space-7) var(--tandem-space-5); border: ${R.fileDragOver||G0.fileDragOver?"2px dashed var(--tandem-accent)":"2px solid transparent"}; background: ${R.fileDragOver||G0.fileDragOver?"var(--tandem-accent-bg)":"var(--tandem-bg)"}; transition: border-color 0.15s, background 0.15s; border-radius: ${R.fileDragOver||G0.fileDragOver?"var(--tandem-r-5)":"0"};`)}),Qt("dragover",J,function(...zi){var kr;(kr=R.handleEditorDragOver)==null||kr.apply(this,zi)}),Qt("dragleave",J,function(...zi){var kr;(kr=R.handleEditorDragLeave)==null||kr.apply(this,zi)}),Qt("drop",J,function(...zi){var kr;(kr=R.handleEditorDrop)==null||kr.apply(this,zi)}),x(N,J)},o=gte();Dn(()=>o.destroy());const s=Vee(()=>o.tabs);Dn(()=>s.destroy());const a=kee(),l=new Set;function c(N){const J=o.tabs.find(be=>be.id===N);if(J&&km(J.filePath)){const be=nS(J.filePath);if(be&&s.hasUnsavedContent(be)){if(!window.confirm("This scratchpad has unsaved content that will be lost. Close it anyway?"))return;s.clearUnsaved(be)}}if(!(u(Le).has(N)&&!window.confirm("This document has unsaved markdown-source edits that will be lost. Close it anyway?"))){if(J&&!El(J.filePath)&&a.push({filePath:J.filePath,closedAt:Date.now()}),u(de).has(N)){const be=new Set(u(de));be.delete(N),b(de,be,!0)}ne(N),pg.delete(N),o.handleTabClose(N)}}function d(N){for(const J of sre(p.orderedTabs,N))c(J)}function f(N){for(const J of are(p.orderedTabs,N))c(J)}async function h(){const N=a.pop();if(!N)return;const J=o.tabs.find(Ke=>Ke.filePath===N.filePath);if(J){o.setActiveTabId(J.id);return}if(l.has(N.filePath))return;l.add(N.filePath);const be=Ke=>{a.push(N);const et=N.filePath.split(/[\\/]/).pop()||N.filePath;E.push({id:`reopen-failed-${Date.now()}`,type:"general-error",severity:"error",message:`Couldn't reopen ${et}: ${Ke}`,dedupKey:`reopen-failed:${N.filePath}`,timestamp:Date.now()})};try{const Ke=await ms(N.filePath);Ke.ok||be(Ke.error)}finally{l.delete(N.filePath)}}const p=Kee(()=>o.tabs);jee(()=>p.orderedTabs,()=>o.activeTabId,N=>o.setActiveTabId(N)),pe(()=>{const N=o.tabs;if(N.length!==0)try{const J=bc();let be=J;for(const Ke of N)El(Ke.filePath)||(be=Yd(be,Ke.filePath));(be.length!==J.length||be.some((Ke,et)=>Ke!==J[et]))&&Jd(be)}catch(J){console.warn("[tandem] failed to sync recent files:",J)}});const m=ai(),v=Gee(()=>o.bootstrapYdoc,()=>m.settings.selectionDwellMs),g=Ste(m,v),y=L(()=>mS(m.settings.customShortcuts)),C=L(()=>WO(u(y))),_=L(()=>o.annotations),S=xee(()=>o.disconnectedSince,()=>m.settings.degradedBannerDelayMs),A=cte();dte();const O=L(()=>o.tabs.map(N=>({id:N.id,fileName:N.fileName}))),E=Hee();let M=F(!1);const R=Mee();if(Jee(E.push),Tt()){let N=null,J=!1;Zt(async()=>{const{listen:be}=await import("./event-CNdo2oXa.js");return{listen:be}},__vite__mapDeps([3,1])).then(({listen:be})=>be("sidecar-restart-failed",()=>{E.push({id:`sidecar-restart-failed-${Date.now()}`,type:"general-error",severity:"error",message:"Sidecar failed to restart — see logs",dedupKey:"sidecar-restart-failed",timestamp:Date.now(),errorCode:"SIDECAR_RESTART_FAILED"})})).then(be=>{J?be():N=be}).catch(be=>{console.warn("[App] Failed to wire sidecar-restart-failed listener:",be)}),Dn(()=>{J=!0,N==null||N()})}if(Tt()){let N=null,J=!1;Zt(async()=>{const{listen:be}=await import("./event-CNdo2oXa.js");return{listen:be}},__vite__mapDeps([3,1])).then(({listen:be})=>be("open-integration-wizard",()=>{window.dispatchEvent(new CustomEvent("tandem:open-integration-wizard"))})).then(be=>{J?be():N=be}).catch(be=>{console.warn("[App] Failed to wire open-integration-wizard listener:",be),E.push({id:`open-wizard-listener-failed-${Date.now()}`,type:"launcher",severity:"warning",message:"Couldn't enable the Setup shortcut. Open Settings → Reopen wizard to configure integrations.",dedupKey:"open-wizard-listener-failed",timestamp:Date.now()})}),Dn(()=>{J=!0,N==null||N()})}if(Tt()){const N=et=>{switch(et){case"unsupported-extension":return"That file type can't be opened in Tandem.";case"not-a-file":case"non-file-url":return"That file couldn't be opened — it may have moved or been deleted.";case"suspicious-path":return"That file path was rejected for safety reasons.";default:return"That file couldn't be opened in Tandem."}},J=et=>{E.push({id:`startup-file-rejected-${Date.now()}`,type:"general-error",severity:"warning",message:N(et),dedupKey:"startup-file-rejected",timestamp:Date.now(),errorCode:"STARTUP_FILE_REJECTED"})};let be=null,Ke=!1;Zt(async()=>{const{listen:et}=await import("./event-CNdo2oXa.js");return{listen:et}},__vite__mapDeps([3,1])).then(({listen:et})=>et("startup-file-rejected",Pt=>{J(typeof Pt.payload=="string"?Pt.payload:"")})).then(et=>{Ke?et():be=et}).catch(et=>{console.warn("[App] Failed to wire startup-file-rejected listener:",et)}),Zt(async()=>{const{invoke:et}=await import("./core-DhEqZVGG.js");return{invoke:et}},[]).then(({invoke:et})=>et("get_startup_rejection")).then(et=>{et&&J(et)}).catch(et=>{console.warn("[App] Failed to poll buffered startup rejection:",et)}),Dn(()=>{Ke=!0,be==null||be()})}let D=F(!1),I=F(!1);const H=Dee(),z=mee({connected:()=>o.connected,firstRunSettled:()=>H.settled,soloMode:()=>v.tandemMode==="solo"});function Q(){window.dispatchEvent(new CustomEvent("tandem:open-integration-wizard"))}function ie(){E5(),setTimeout(()=>z.refresh(),2e3),setTimeout(()=>z.refresh(),5e3)}pe(()=>{const N=async J=>{var Pt;const be=(Pt=J.detail)==null?void 0:Pt.via;if(z.chip===null||await z.probeSession())return;const Ke=z.chip;if(Ke===null)return;const et=be==="comment"?"Comment":"Message";E.push({id:`ai-not-ready-${be??"chat"}-${Date.now()}`,type:"launcher",severity:"warning",message:`${et} saved — no AI is connected yet. It'll be seen when AI connects.`,dedupKey:`ai-not-ready-${be??"chat"}`,timestamp:Date.now()},{label:Ke==="connect"?"Connect AI":"Restart Claude Code",onClick:Ke==="connect"?Q:ie})};return window.addEventListener("tandem:addressed-ai",N),()=>window.removeEventListener("tandem:addressed-ai",N)});const me="tandem:wizard-dismissed";let le=F(tt(ce())),ke=F(!1);function ce(){try{return localStorage.getItem(me)}catch{return null}}const ve=L(()=>H.needed===!0&&H.serverVersion!==null&&u(le)!==H.serverVersion),De=L(()=>u(ke)||u(ve));function ee(){if(u(ve)&&H.serverVersion!==null)try{localStorage.setItem(me,H.serverVersion),b(le,H.serverVersion,!0)}catch{}b(ke,!1)}pe(()=>{const N=J=>{J.key===me&&b(le,J.newValue,!0)};return window.addEventListener("storage",N),()=>window.removeEventListener("storage",N)}),pe(()=>{const N=()=>{b(ke,!0),b(I,!1),H.refetch()};return window.addEventListener("tandem:open-integration-wizard",N),()=>window.removeEventListener("tandem:open-integration-wizard",N)});let q=F(null),V=F(!1),re=F(!1);function te(){return x8({isTauri:Tt(),openModal:()=>{b(re,!0)},onError:N=>E.push({id:gl(),type:"general-error",severity:"error",message:N,timestamp:Date.now()})})}const Z=lte();function ge(){u(D)||Z.acknowledge(),b(D,!u(D))}function Ie(){Z.acknowledge(),b(I,!0)}let Se=F(null);function fe(){u(I)||b(Se,fA.models,!0),Ie()}function _e(){Z.acknowledge(),b(D,!0)}p5({getActiveTabId:()=>o.activeTabId,getActiveDocumentPath:()=>{const N=o.tabs.find(J=>J.id===o.activeTabId);return N&&!El(N.filePath)?N.filePath:null},notify:(N,J)=>{E.push({id:`launcher-${Date.now()}`,type:"launcher",severity:N,message:J,timestamp:Date.now()})},openSettings:_e,openSettingsModal:Ie,toggleSoloMode:()=>v.setTandemMode(v.tandemMode==="solo"?"tandem":"solo"),openFindBar:()=>{b(ae,"doc"),b(Xe,!0)},openFindBarTabs:()=>{b(ae,"tabs"),b(Xe,!0)},findNext:()=>{const N=u(ue),J=N?Jl(N.state):void 0;N&&W0(J)?N.commands.findNext():(b(ae,"doc"),b(Xe,!0))},findPrev:()=>{const N=u(ue),J=N?Jl(N.state):void 0;N&&W0(J)?N.commands.findPrev():(b(ae,"doc"),b(Xe,!0))},closeActiveTab:()=>{const N=o.activeTabId;N&&c(N)},openFileDialog:()=>void te(),toggleLeftPanel:()=>je(),toggleRightPanel:()=>Ve(),reopenClosedTab:()=>void h(),annotationNext:()=>{const N=ku(u(_)),J=sx(N,u(Re));if(J){b(Re,J,!0);const be=N.find(Ke=>Ke.id===J);be&&Kr.scrollToAnnotation(be)}},annotationPrev:()=>{const N=ku(u(_)),J=ax(N,u(Re));if(J){b(Re,J,!0);const be=N.find(Ke=>Ke.id===J);be&&Kr.scrollToAnnotation(be)}},annotationAccept:()=>{const N=mg();N&&N.author!=="user"&&Kr.handleAccept(N.id)},annotationDismiss:()=>{const N=mg();N&&N.author!=="user"&&Kr.handleDismiss(N.id)},selectBlock:()=>{var N;return(N=u(ue))==null?void 0:N.chain().focus().selectParentNode().run()},toggleAuthorship:()=>X(!m.settings.showAuthorship),toggleFormattingBar:()=>m.updateSettings({formattingBarVisible:!m.settings.formattingBarVisible}),toggleSourceView:()=>Jy(),saveAs:async()=>{const N=o.tabs.find(Ke=>Ke.id===o.activeTabId);if(!N||!El(N.filePath)){E.push({id:gl(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const J=Math.max(N.filePath.lastIndexOf("/"),N.filePath.lastIndexOf("\\")),be=N.filePath.slice(J+1);await rk({activeDocId:o.activeTabId,defaultName:be,sourceFormat:N.format,notify:(Ke,et)=>E.push({id:gl(),type:"launcher",severity:Ke,message:et,timestamp:Date.now()})})}});function X(N){m.updateSettings({showAuthorship:N,...m.settings.decorationsMuted?{decorationsMuted:!1}:{}})}let ye=null;pe(()=>{const N=u(ue);if(!N)return;const J=m.settings,be=!J.decorationsMuted&&J.showAuthorship;if(ye===be)return;const Ke=ye===null;ye=be,!Ke&&Ct(()=>{const et=N.state.tr.setMeta(Ol,{type:"toggle",visible:be});N.view.dispatch(et)})});let Y=null;pe(()=>{const N=u(ue);if(!N)return;const J=m.settings,be=J.decorationsMuted,Ke={comment:!be&&J.showComments,highlight:!be&&J.showHighlights,note:!be&&J.showNotes},et=`${Ke.comment?1:0}${Ke.highlight?1:0}${Ke.note?1:0}`;if(Y===et)return;const Pt=Y===null;Y=et,!Pt&&Ct(()=>{const Jt=N.state.tr.setMeta(_u,{type:"toggle-decorations",visible:Ke});N.view.dispatch(Jt)})}),pe(()=>(document.body.classList.toggle("tandem-reduce-motion",m.settings.reduceMotion),()=>document.body.classList.remove("tandem-reduce-motion"))),pe(()=>(document.body.classList.toggle("tandem-rail-hover-reveal",m.settings.railHoverReveal),()=>document.body.classList.remove("tandem-rail-hover-reveal"))),tte(()=>m.settings.theme,()=>m.settings.systemLightVariant),hee(()=>m.settings.accentHue),Tee(()=>{var N;return i5(m.settings,(N=u(ht))==null?void 0:N.format)}),Cee(()=>m.settings.density),Iee(()=>m.settings.highContrast),vee(()=>m.settings.annotationPatterns),pe(()=>{const N=$O[m.settings.textSize];return document.documentElement.style.setProperty("--tandem-editor-font-size",`${N}px`),()=>document.documentElement.style.removeProperty("--tandem-editor-font-size")});let se=F(tt(m.settings.primaryTab==="chat"?"chat":"annotations"));const Te=L(()=>u(se)==="annotations"?0:u(_).filter(Gh).length);let Re=F(null),ze=F(!1),Je=F(null),ue=F(null),Ne=F(null),qe=F(!1),Xe=F(!1),ae=F("doc"),de=F(tt(new Set)),xe=F(tt(new Map)),Le=F(tt(new Set));function it(N,J,be){const Ke=new Map(u(xe)),et=new Set(u(Le));be?(Ke.set(N,J),et.add(N)):(Ke.delete(N),et.delete(N)),b(xe,Ke,!0),b(Le,et,!0)}function ne(N){if(!u(xe).has(N)&&!u(Le).has(N))return;const J=new Map(u(xe)),be=new Set(u(Le));J.delete(N),be.delete(N),b(xe,J,!0),b(Le,be,!0)}let Ee=F(0),B=F(0),$=F(0),we=F(0);const He=h_("left"),Oe=h_("right"),K=p_({side:"left",initialWidth:He,getVisible:()=>u(Me)}),he=p_({side:"right",initialWidth:Oe,getVisible:()=>u(Fe)}),Me=L(()=>g.leftVisible),Fe=L(()=>g.rightVisible);function We(N,J){queueMicrotask(()=>{const be=J?`panel-edge-collapse-${N}`:`peek-strip-${N}`,Ke=document.querySelector(`[data-testid="${be}"]`);Ke?Ke.focus():console.warn(`[tandem] focusToggleTarget: ${be} not mounted; focus dropped to body`)})}const je=()=>{$e("left"),dt.left=!1;const N=!g.leftVisible;g.toggleLeft(),We("left",N)},Ve=()=>{$e("right"),dt.right=!1;const N=!g.rightVisible;g.toggleRight(),We("right",N)};function $e(N){dt[N]&&(qt[N]=!0,requestAnimationFrame(()=>{qt[N]=!1}))}const ct=tt({left:!1,right:!1}),dt=tt({left:!1,right:!1}),qt=tt({left:!1,right:!1}),Nt=tt({left:!1,right:!1}),Ot=120,Ft=180,En=400,Hn=300,An={left:void 0,right:void 0},zt={left:void 0,right:void 0},mn={left:void 0,right:void 0},Vn={left:!1,right:!1},Li={left:!1,right:!1},Mn=N=>u(N==="left"?Me:Fe);function li(N){if(Vn[N]=!0,!(Mn(N)||!m.settings.railHoverReveal)){if(clearTimeout(An[N]),Nt[N]){clearTimeout(zt[N]),Nt[N]=!1,dt[N]=!0;return}An[N]=setTimeout(()=>{dt[N]=!0},Ot)}}function oo(N){if(!(Vn[N]||Li[N])&&dt[N]){if(dt[N]=!1,Mn(N)||to(m.settings.reduceMotion)){Nt[N]=!1;return}Nt[N]=!0,clearTimeout(zt[N]),zt[N]=setTimeout(()=>{Nt[N]=!1},Hn)}}function ci(N){Vn[N]=!1,clearTimeout(An[N]),An[N]=setTimeout(()=>oo(N),Ft)}function ua(N){Li[N]=!0}function gf(N,J){const be=J.currentTarget,Ke=J.relatedTarget;Ke&&be.contains(Ke)||(Li[N]=!1,oo(N))}function vf(N,J){J.propertyName!=="width"||J.target!==J.currentTarget||(ct[N]=!1,clearTimeout(mn[N]))}const Wt=Ct(()=>({left:u(Me),right:u(Fe)}));pe(()=>{const N=u(Me),J=u(Fe);Ct(()=>{fn("left",N),fn("right",J)})});function fn(N,J){if(J===Wt[N])return;const be=Wt[N]&&!J;Wt[N]=J,!(!be||m.settings.reduceMotion)&&(ct[N]=!0,clearTimeout(mn[N]),mn[N]=setTimeout(()=>{ct[N]=!1},En))}pe(()=>()=>{clearTimeout(An.left),clearTimeout(An.right),clearTimeout(mn.left),clearTimeout(mn.right),clearTimeout(zt.left),clearTimeout(zt.right)});const Un=ute(),jn=Cte({getFormat:()=>{var N;return(N=u(ht))==null?void 0:N.format},getMarginView:()=>m.settings.marginView,getEditorMeasure:()=>m.settings.editorMeasure,getLeftRailVisible:()=>u(Me),getRightRailVisible:()=>u(Fe),getViewportWidth:()=>Un.width,getLeftHasPending:()=>u(_).some(N=>N.status==="pending"&&E_(N)),getRightHasPending:()=>u(_).some(N=>N.status==="pending"&&A_(N)),leftRailWidthPx:He,rightRailWidthPx:Oe});function ui(){if(u(se)==="chat"||!u(ue))return;const{from:N,to:J}=u(ue).state.selection;if(N===J)return;const be=GE(u(ue).state.doc,{from:zn(N),to:zn(J)}),Ke=u(ue).state.doc.textBetween(N,J,`
262
+ `);b(Je,{...be,textSnapshot:Ke.length>200?Ke.slice(0,197)+"...":Ke},!0)}const Fi={"toggle-help":N=>{const J=N.target;J&&(J.tagName==="INPUT"||J.tagName==="TEXTAREA"||J.isContentEditable)||(N.preventDefault(),b(ze,Ct(()=>!u(ze)),!0))},"select-all":N=>{var be,Ke;const J=document.activeElement;J instanceof HTMLInputElement||J instanceof HTMLTextAreaElement||(be=J==null?void 0:J.closest)!=null&&be.call(J,".ProseMirror")||(N.preventDefault(),(Ke=u(ue))==null||Ke.commands.selectAll())},save:N=>{N.preventDefault(),!u(bf)&&Ov(o.activeTabId)},"save-as":N=>{const J=N.target;if(J&&(J.tagName==="INPUT"||J.tagName==="TEXTAREA"||J.isContentEditable))return;N.preventDefault();const be=o.tabs.find(Pt=>Pt.id===o.activeTabId);if(!be||!El(be.filePath)){E.push({id:gl(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const Ke=Math.max(be.filePath.lastIndexOf("/"),be.filePath.lastIndexOf("\\")),et=be.filePath.slice(Ke+1);rk({activeDocId:o.activeTabId,defaultName:et,sourceFormat:be.format,notify:(Pt,Jt)=>E.push({id:gl(),type:"launcher",severity:Pt,message:Jt,timestamp:Date.now()})})},"settings-modal":N=>{N.preventDefault(),Ie()},settings:N=>{N.preventDefault(),_e()},"toggle-palette":N=>{N.preventDefault(),b(V,!Ct(()=>u(V)))},"new-scratchpad":N=>{const J=N.target;J&&(J.tagName==="INPUT"||J.tagName==="TEXTAREA")||(N.preventDefault(),Jh())},"close-tab":N=>{if(Nr(N))return;N.preventDefault();const J=o.activeTabId;J&&c(J)},"open-file":N=>{Nr(N)||(N.preventDefault(),te())},"pick-tab":(N,J)=>{if(Nr(N))return;const be=J==null?void 0:J.tabIndex;if(be===void 0)return;const Ke=qee(o.tabs,be);Ke&&(N.preventDefault(),o.setActiveTabId(Ke))},"toggle-mode":N=>{Nr(N)||(N.preventDefault(),v.setTandemMode(v.tandemMode==="solo"?"tandem":"solo"))},"reopen-closed-tab":N=>{Nr(N)||(N.preventDefault(),h())},"new-tab-menu":N=>{Nr(N)||(N.preventDefault(),b($,u($)+1))},find:(N,J)=>{if(N.preventDefault(),J!=null&&J.shift){b(ae,"tabs"),b(Xe,!0);return}u(Me)?b(Ee,u(Ee)+1):(b(ae,"doc"),b(Xe,!0))},"find-nav":(N,J)=>{if(Nr(N))return;N.preventDefault();const be=u(ue),Ke=be?Jl(be.state):void 0;be&&W0(Ke)?J!=null&&J.shift?be.commands.findPrev():be.commands.findNext():(b(ae,"doc"),b(Xe,!0))},"annotation-accept-or-dismiss":(N,J)=>{if(Nr(N))return;N.preventDefault();const be=mg();be&&be.author!=="user"&&(J!=null&&J.shift?Kr.handleDismiss(be.id):Kr.handleAccept(be.id))},"comment-on-selection":N=>{N.preventDefault();const J=!!u(ue)&&u(ue).state.selection.from!==u(ue).state.selection.to,be=u(Xc);if(!(u(qe)||u(Xe)||u(V))){if(!J){E.push({id:`comment-shortcut-no-selection-${Date.now()}`,type:"general-error",severity:"info",message:"Select text to comment",dedupKey:"comment-shortcut-no-selection",timestamp:Date.now()});return}if(be){E.push({id:`comment-shortcut-readonly-${Date.now()}`,type:"general-error",severity:"info",message:"Document is read-only",dedupKey:"comment-shortcut-readonly",timestamp:Date.now()});return}if(!m.settings.selectionToolbar){E.push({id:`comment-shortcut-toolbar-off-${Date.now()}`,type:"general-error",severity:"info",message:"Enable selection toolbar in Settings to comment via keyboard",dedupKey:"comment-shortcut-toolbar-off",timestamp:Date.now()});return}b(B,u(B)+1)}},"toggle-authorship":N=>{N.preventDefault(),X(!m.settings.showAuthorship)},"toggle-left-panel":N=>{Nr(N)||(N.preventDefault(),je())},"toggle-right-panel":N=>{Nr(N)||(N.preventDefault(),Ve())},"annotation-next":N=>{if(Nr(N))return;N.preventDefault();const J=ku(u(_)),be=sx(J,u(Re));if(be){b(Re,be,!0);const Ke=J.find(et=>et.id===be);Ke&&Kr.scrollToAnnotation(Ke)}},"annotation-prev":N=>{if(Nr(N))return;N.preventDefault();const J=ku(u(_)),be=ax(J,u(Re));if(be){b(Re,be,!0);const Ke=J.find(et=>et.id===be);Ke&&Kr.scrollToAnnotation(Ke)}},"select-block":N=>{Nr(N)||(N.preventDefault(),u(ue)&&u(ue).chain().focus().selectParentNode().run())}};pe(()=>{function N(J){var Ke;if(J.key==="F2"&&!J.ctrlKey&&!J.metaKey&&!J.altKey&&!J.shiftKey){if(Nr(J))return;const et=o.tabs.find(Pt=>Pt.id===o.activeTabId);et&&Zy(et)&&(J.preventDefault(),b(we,u(we)+1));return}const be=hS(J,Ct(()=>u(y)));be&&((Ke=Fi[be.id])==null||Ke.call(Fi,J,be.context))}return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)}),pe(()=>{function N(J){if(J.key!=="Escape"||J.defaultPrevented||u(Re)===null||u(Xe))return;const be=document.activeElement;be instanceof HTMLInputElement||be instanceof HTMLTextAreaElement||!(!be||be===document.body||be.closest('.ProseMirror, [data-testid="editor-root"], [data-testid="annotation-list-scroll-container"]'))||(J.preventDefault(),b(Re,null))}return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)});const ht=L(()=>o.tabs.find(N=>N.id===o.activeTabId));let so=F(null);const pg=new Map;let Jc;pe(()=>{const N=u(so);if(!N)return;const J=()=>{Jc!==void 0&&pg.set(Jc,N.scrollTop)};return N.addEventListener("scroll",J,{passive:!0}),()=>N.removeEventListener("scroll",J)}),pe(()=>{var Jt;const N=u(so),J=(Jt=u(ht))==null?void 0:Jt.id;if(!N||J===Jc||(Jc=J,J===void 0))return;const be=pg.get(J)??0;let Ke=0,et=!1;const Pt=()=>{et||Jc!==J||(N.scrollTop=be,N.scrollTop<be&&Ke<30&&(Ke+=1,requestAnimationFrame(Pt)))};return requestAnimationFrame(Pt),()=>{et=!0}});const Xc=L(()=>{var N;return((N=u(ht))==null?void 0:N.readOnly)===!0}),Yy=L(()=>!!u(ht)&&u(ht).format==="md"&&!u(Xc)),bf=L(()=>!!u(ht)&&u(de).has(u(ht).id));function Jy(){if(!u(ht))return;const N=u(ht).id,J=new Set(u(de));if(J.has(N))J.delete(N);else{if(!u(Yy))return;J.add(N),b(Xe,!1),b(qe,!1),b(V,!1)}b(de,J,!0)}function n6(N){if(!u(de).has(N))return;const J=new Set(u(de));J.delete(N),b(de,J,!0),ne(N)}pe(()=>{const N=J=>{u(Le).size!==0&&(J.preventDefault(),J.returnValue="You have unsaved markdown-source edits.")};return window.addEventListener("beforeunload",N),()=>window.removeEventListener("beforeunload",N)}),pe(()=>{if(!v5({connected:o.connected,tabCount:o.tabs.length,activeTabId:o.activeTabId}))return;const N=setTimeout(()=>{Jh()},g5);return()=>clearTimeout(N)});const Kr=Vte({getYdoc:()=>{var N;return((N=u(ht))==null?void 0:N.ydoc)??null},getEditor:()=>u(ue),getAnnotations:()=>u(_),onActiveAnnotationChange:N=>{b(Re,N,!0)},getScrollBehavior:()=>m.settings.reduceMotion?"auto":"smooth",getActiveAnnotationId:()=>u(Re)});function mg(){return u(Re)?u(_).find(N=>N.id===u(Re)):Kr.getReviewTargets()[0]}const gg=L(()=>jn.effectivelyOn?u(_).filter(E_):[]),vg=L(()=>jn.effectivelyOn?u(_).filter(A_):[]),r6=Pee({getEditor:()=>u(ue),getYdoc:()=>{var N;return((N=u(ht))==null?void 0:N.ydoc)??null},getAnnotations:()=>[...u(gg),...u(vg)],getLayerEl:()=>u(Ne),getEnabled:()=>jn.effectivelyOn}),i6=bee({getYdoc:()=>{var N;return((N=u(ht))==null?void 0:N.ydoc)??null}}),yf=L(()=>{var be,Ke;const N=((be=u(ht))==null?void 0:be.ydoc)??null,J=(Ke=u(ht))==null?void 0:Ke.id;return{ydoc:N,docId:J,onEdit:(et,Pt)=>XE(N,et,Pt),onReply:(et,Pt)=>tA(et,Pt,J),onRemove:et=>eA(et,J),onSendToClaude:et=>$E(N,et)}}),Qc=ite(()=>u(_),()=>u(ue),()=>{var N;return(N=u(ht))==null?void 0:N.fileName});var bg=Sre(),Xy=w(bg);{let N=L(()=>null),J=L(()=>u(Yy)||u(bf)?Jy:null);gne(Xy,{get tandemMode(){return v.tandemMode},get onModeChange(){return v.setTandemMode},get claudeActive(){return o.claudeActive},get theme(){return m.settings.theme},onSetTheme:be=>m.updateSettings({theme:be}),onOpenHelp:()=>b(ze,!0),onOpenSettings:ge,onOpenSettingsModal:Ie,get updateAvailable(){return Z.showDot},get defaultModelLabel(){return u(N)},onOpenModelsSettings:fe,get aiChip(){return z.chip},onConnectAi:Q,onRestartClaude:ie,get sourceViewActive(){return u(bf)},get onToggleSourceView(){return u(J)},get center(){return n},get settingsBtn(){return u(q)},set settingsBtn(be){b(q,be,!0)}})}var o6=k(Xy,2);{var s6=N=>{var J=yre();x(N,J)},a6=N=>{var J=Cre(),be=Ae(J);{var Ke=Ye=>{var Ut=wre();x(Ye,Ut)};j(be,Ye=>{o.serverRestarted&&Ye(Ke)})}var et=k(be,2);{var Pt=Ye=>{HH(Ye,{get version(){return A.availableVersion},get installing(){return A.installing},onInstall:()=>{A.install()},get onDismiss(){return A.dismiss}})},Jt=L(()=>Tt()&&A.showBanner&&A.availableVersion);j(et,Ye=>{u(Jt)&&Ye(Pt)})}var vs=k(et,2);{var wf=Ye=>{JI(Ye,{get onDismiss(){return S.dismiss},onRetry:()=>{o.reconnect()}})};j(vs,Ye=>{S.showBanner&&Ye(wf)})}var Dr=k(vs,2);{let Ye=L(()=>{var xr;return((xr=u(ht))==null?void 0:xr.ydoc)??null}),Ut=L(()=>u(qe)||u(Xe)||u(V));dee(Dr,{get editor(){return u(ue)},get ydoc(){return u(Ye)},get selectionToolbar(){return m.settings.selectionToolbar},get suppressSelectionToolbar(){return u(Ut)},get requestCommentFocus(){return u(B)},get showAuthorship(){return m.settings.showAuthorship},get showComments(){return m.settings.showComments},get showHighlights(){return m.settings.showHighlights},get showNotes(){return m.settings.showNotes},get decorationsMuted(){return m.settings.decorationsMuted},onUpdateDecorations:xr=>m.updateSettings(xr),onOpenSettings:ge,get formattingBarVisible(){return m.settings.formattingBarVisible},onToggleFormattingBar:()=>m.updateSettings({formattingBarVisible:!m.settings.formattingBarVisible}),get reduceMotion(){return m.settings.reduceMotion}})}var zi=k(Dr,2);{var kr=Ye=>{{let Ut=L(()=>{var xr;return((xr=u(ht))==null?void 0:xr.ydoc)??null});Yte(Ye,{get editor(){return u(ue)},get ydoc(){return u(Ut)},get showAuthorship(){return m.settings.showAuthorship},get showComments(){return m.settings.showComments},get showHighlights(){return m.settings.showHighlights},get showNotes(){return m.settings.showNotes},get decorationsMuted(){return m.settings.decorationsMuted},onUpdateDecorations:xr=>m.updateSettings(xr),onOpenSettings:ge,onHide:()=>m.updateSettings({formattingBarVisible:!1})})}};j(zi,Ye=>{m.settings.formattingBarVisible&&Ye(kr)})}var hn=k(zi,2),Xt=w(hn);let rr;var ao=w(Xt);{var da=Ye=>{var Ut=kre();W(()=>Pe(Ut,`width: ${K.width}px;`)),x(Ye,Ut)};j(ao,Ye=>{(dt.left||Nt.left)&&Ye(da)})}var lo=k(ao,2),hl=w(lo);i0(hl,{kind:"outline",get focusTrigger(){return u(Ee)},get editor(){return u(ue)},visible:!0});var yg=k(hl,2);I_(yg,()=>"left",()=>je);var Or=k(lo,2);{let Ye=L(()=>!u(Me));T_(Or,{side:"left",get collapsed(){return u(Ye)},kind:"outline",onActivate:je})}var Gr=k(Xt,2);{var fa=Ye=>{r(Ye,()=>"left",()=>Ut=>K.handleResizeStart(Ut),()=>{},()=>K.width)};j(Gr,Ye=>{u(Me)&&Ye(fa)})}var ha=k(Gr,2);i(ha);var pl=k(ha,2);{var $c=Ye=>{r(Ye,()=>"right",()=>Ut=>he.handleResizeStart(Ut),()=>"panel-resize-handle",()=>he.width)};j(pl,Ye=>{u(Fe)&&Ye($c)})}var Ir=k(pl,2);let Rr;var kf=w(Ir);{var wg=Ye=>{var Ut=xre();W(()=>Pe(Ut,`width: ${he.width}px;`)),x(Ye,Ut)};j(kf,Ye=>{(dt.right||Nt.right)&&Ye(wg)})}var qn=k(kf,2),Bi=w(qn);I_(Bi,()=>"right",()=>Ve);var bs=k(Bi,2),kg=w(bs),xf=w(kg),l6=k(w(xf));{var c6=Ye=>{var Ut=_re(),xr=w(Ut);W(()=>G(xr,u(Te)>9?"9+":u(Te))),x(Ye,Ut)};j(l6,Ye=>{u(se)!=="annotations"&&u(Te)>0&&Ye(c6)})}var xg=k(xf,2),Qy=k(bs,2);{let Ye=L(()=>u(se)==="chat");i0(Qy,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return u(ue)},get activeDocId(){return o.activeTabId},get openDocs(){return u(O)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return u(Je)},onCapturedAnchorChange:Ut=>b(Je,Ut,!0),get reduceMotion(){return m.settings.reduceMotion},get visible(){return u(Ye)}})}var u6=k(Qy,2);{let Ye=L(()=>{var Zr;return((Zr=u(ht))==null?void 0:Zr.ydoc)??null}),Ut=L(()=>{var Zr;return(Zr=u(ht))==null?void 0:Zr.format}),xr=L(()=>{var Zr;return(Zr=u(ht))==null?void 0:Zr.id}),b6=L(()=>{var Zr;return((Zr=o.claudeWorking)==null?void 0:Zr.annotationId)??null}),y6=L(()=>u(se)==="annotations");i0(u6,{kind:"side",get annotations(){return u(_)},get editor(){return u(ue)},get ydoc(){return u(Ye)},get activeDocFormat(){return u(Ut)},get documentId(){return u(xr)},get activeAnnotationId(){return u(Re)},onActiveAnnotationChange:Zr=>b(Re,Zr,!0),get reduceMotion(){return m.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get claudeWorkingAnnotationId(){return u(b6)},get review(){return Kr},get visible(){return u(y6)}})}var d6=k(qn,2);{let Ye=L(()=>!u(Fe));T_(d6,{side:"right",get collapsed(){return u(Ye)},kind:"annotations",get annotations(){return u(_)},onActivate:Ve})}var $y=k(hn,2);{let Ye=L(()=>{var Ut;return((Ut=o.claudeWorking)==null?void 0:Ut.tool)??null});Ane($y,{get connected(){return o.connected},get connectionStatus(){return o.connectionStatus},get reconnectAttempts(){return o.reconnectAttempts},get disconnectedSince(){return o.disconnectedSince},get claudeStatus(){return o.claudeStatus},get claudeActive(){return o.claudeActive},get claudeWorkingTool(){return u(Ye)},get readOnly(){return u(Xc)},get saving(){return m5.saving},get editor(){return u(ue)}})}var ew=k($y,2);IH(ew,{get open(){return u(D)},onClose:()=>b(D,!1),get settings(){return m.settings},get onUpdate(){return m.updateSettings},get returnFocusEl(){return u(q)},get anchorEl(){return u(q)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts}});var tw=k(ew,2);vH(tw,{get open(){return u(I)},onClose:()=>{b(I,!1),b(Se,null)},get settings(){return m.settings},get onUpdate(){return m.updateSettings},get returnFocusEl(){return u(q)},get triggerEl(){return u(q)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts},get initialTabId(){return u(Se)},notify:(Ye,Ut)=>E.push({id:`settings-${Date.now()}`,type:"launcher",severity:Ye,message:Ut,timestamp:Date.now()})});var nw=k(tw,2);j8(nw,{get open(){return u(ze)},onClose:()=>b(ze,!1),get effectiveShortcutLabels(){return u(C)}});var rw=k(nw,2);{var f6=Ye=>{mN(Ye,{open:!0,onClose:ee})};j(rw,Ye=>{u(De)&&Ye(f6)})}var iw=k(rw,2);{var h6=Ye=>{z8(Ye,{onClose:()=>b(re,!1)})};j(iw,Ye=>{u(re)&&Ye(h6)})}var ow=k(iw,2);ZI(ow,{get open(){return u(V)},onClose:()=>b(V,!1),get editor(){return u(ue)},get annotations(){return u(_)},onFocusAnnotation:Ye=>{b(Re,Ye,!0)}});var sw=k(ow,2);zH(sw,{get toasts(){return E.toasts},get onDismiss(){return E.dismiss}});var aw=k(sw,2);j5(aw,{get items(){return E.activity},get open(){return u(M)},onToggle:()=>b(M,!u(M)),get onDismiss(){return E.dismissActivity},get onClear(){return E.clearActivity},onAction:Ye=>{const Ut=MS(Ye);Ut&&(o.tabs.some(xr=>xr.id===Ut.documentId)?Ov(Ut.documentId):E.push({id:`retry-unavailable-${Ut.documentId}`,type:"general-error",severity:"warning",message:"Reopen the document to retry the save.",dedupKey:`retry-unavailable:${Ut.documentId}`,timestamp:Date.now()}))}});var lw=k(aw,2);{var p6=Ye=>{c8(Ye,{})},m6=L(()=>Tt()&&!u(De));j(lw,Ye=>{u(m6)&&Ye(p6)})}var g6=k(lw,2);{var v6=Ye=>{KN(Ye,{get currentStep(){return Qc.currentStep},get onNext(){return Qc.nextStep},get onDismiss(){return Qc.dismissTutorial},get coworkStatus(){return Qc.coworkStatus}})};j(g6,Ye=>{Qc.tutorialActive&&Ye(v6)})}W(()=>{rr=bt(Xt,1,"rail-shell rail-shell-left svelte-y74n0s",null,rr,{collapsed:!u(Me),animating:ct.left,"rail-floating-chrome":dt.left||Nt.left,floating:dt.left,"float-closing":Nt.left,"pin-snap":qt.left}),U(Xt,"data-testid",dt.left?"rail-float-left":void 0),Pe(Xt,u(Me)?`width: ${K.width}px;`:""),Pe(lo,`width: ${K.width}px;`),Rr=bt(Ir,1,"rail-shell rail-shell-right svelte-y74n0s",null,Rr,{collapsed:!u(Fe),animating:ct.right,"rail-floating-chrome":dt.right||Nt.right,floating:dt.right,"float-closing":Nt.right,"pin-snap":qt.right}),U(Ir,"data-testid",dt.right?"rail-float-right":void 0),Pe(Ir,u(Fe)?`width: ${he.width}px;`:""),Pe(qn,`width: ${he.width}px;`),bt(xf,1,"rail-tab"+(u(se)==="annotations"?" on":""),"svelte-y74n0s"),bt(xg,1,"rail-tab"+(u(se)==="chat"?" on":""),"svelte-y74n0s")}),Qt("scroll",hn,Ye=>{Ye.currentTarget.scrollLeft=0}),Qt("mouseenter",Xt,()=>li("left")),Qt("mouseleave",Xt,()=>ci("left")),P("focusin",Xt,()=>ua("left")),P("focusout",Xt,Ye=>gf("left",Ye)),Qt("transitionend",Xt,Ye=>vf("left",Ye)),Qt("mouseenter",Ir,()=>li("right")),Qt("mouseleave",Ir,()=>ci("right")),P("focusin",Ir,()=>ua("right")),P("focusout",Ir,Ye=>gf("right",Ye)),Qt("transitionend",Ir,Ye=>vf("right",Ye)),P("click",xf,()=>{b(se,"annotations")}),P("mousedown",xg,ui),P("click",xg,()=>{b(se,"chat")}),x(N,J)};j(o6,N=>{o.ready?N(a6,-1):N(s6)})}W(()=>U(bg,"data-tandem-mode",v.tandemMode)),x(t,bg),rt()}lt(["mousedown","keydown","keyup","click","focusin","focusout"]);const R_=3,Are="error-boundary-recover-btn",Tre="error-boundary-reload-btn";function Mre(t,e){nt(e,!0),pe(()=>{e.onSuccess()}),rt()}var Dre=T('<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>'),Ore=T(`<div role="alert" class="error-boundary svelte-1bcl6yi"><h2 class="svelte-1bcl6yi">Something didn't go as planned</h2> <p class="message svelte-1bcl6yi"> </p> <pre class="detail svelte-1bcl6yi"> </pre> <!> <button class="btn btn-secondary svelte-1bcl6yi">Reload</button></div>`),Ire=T("<!> <!>",1);function Rre(t,e){nt(e,!0);let n=F(0),r=F(0);var i=St(),o=Ae(i);oC(o,{onerror:a=>{nb(a,{source:"ErrorBoundary"}),b(r,u(r)+1)},failed:(a,l=kn,c=kn)=>{var d=St(),f=Ae(d);Bl(f,()=>u(r),h=>{var p=Ore(),m=k(w(p),2),v=w(m),g=k(m,2),y=w(g),C=k(g,2);{var _=A=>{var O=Dre();W(()=>U(O,"data-testid",Are)),P("click",O,()=>{b(n,u(n)+1),c()()}),x(A,O)};j(C,A=>{u(n)<R_&&A(_)})}var S=k(C,2);W(A=>{G(v,u(n)>=R_?"We weren't able to recover this time — reloading the page should get you going again.":"The editor ran into an unexpected hiccup."),G(y,A),U(S,"data-testid",Tre)},[()=>l()instanceof Error?l().message:String(l())]),P("click",S,()=>window.location.reload()),x(h,p)}),x(a,d)}},a=>{var l=Ire(),c=Ae(l);Gd(c,()=>e.children);var d=k(c,2);Mre(d,{onSuccess:()=>{b(n,0)}}),x(a,l)}),x(t,i),rt()}lt(["click"]);function Nre(t){Rre(t,{children:(e,n)=>{Ere(e,{})},$$slots:{default:!0}})}tH();qM(Nre,{target:document.getElementById("root")});export{qre as A,fr as B,Fre as C,mt as D,Pe as E,Ure as F,Hre as G,lt as H,Wre as I,Vre as J,BC as T,w as a,x as b,_1 as c,rt as d,F as e,XI as f,u as g,U as h,j as i,Ae as j,bt as k,Fn as l,jre as m,G as n,Dn as o,nt as p,P as q,b as r,k as s,W as t,L as u,T as v,QI as w,hs as x,k1 as y,x1 as z};