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.
@@ -1,261 +0,0 @@
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-DyolPw-M.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 G4=Object.defineProperty;var qy=t=>{throw TypeError(t)};var Z4=(t,e,n)=>e in t?G4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Vn=(t,e,n)=>Z4(t,typeof e!="symbol"?e+"":e,n),ag=(t,e,n)=>e.has(t)||qy("Cannot "+n);var oe=(t,e,n)=>(ag(t,e,"read from private field"),n?n.call(t):e.get(t)),bt=(t,e,n)=>e.has(t)?qy("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),yt=(t,e,n,r)=>(ag(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Bt=(t,e,n)=>(ag(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 b_=!1;var Ob=Array.isArray,Y4=Array.prototype.indexOf,oc=Array.prototype.includes,cm=Array.from,J4=Object.defineProperty,Bs=Object.getOwnPropertyDescriptor,y_=Object.getOwnPropertyDescriptors,X4=Object.prototype,Q4=Array.prototype,Ib=Object.getPrototypeOf,Wy=Object.isExtensible;function xl(t){return typeof t=="function"}const kn=()=>{};function $4(t){return typeof(t==null?void 0:t.then)=="function"}function e6(t){for(var e=0;e<t.length;e++)t[e]()}function w_(){var t,e,n=new Promise((r,i)=>{t=r,e=i});return{promise:n,resolve:t,reject:e}}function mf(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 lr=2,sc=4,um=8,k_=1<<24,wi=16,qi=32,$o=64,L0=128,ki=512,Bn=1024,Zn=2048,bo=4096,Cr=8192,xi=16384,na=32768,F0=1<<25,es=65536,Mh=1<<17,t6=1<<18,nl=1<<19,n6=1<<20,co=1<<25,Va=65536,Dh=1<<21,Pl=1<<22,Hs=1<<23,po=Symbol("$state"),x_=Symbol("legacy props"),r6=Symbol(""),$f=Symbol("attributes"),z0=Symbol("class"),B0=Symbol("style"),lu=Symbol("text"),eh=Symbol("form reset"),dm=new class extends Error{constructor(){super(...arguments);Vn(this,"name","StaleReactionError");Vn(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var m_;const i6=!!((m_=globalThis.document)!=null&&m_.contentType)&&globalThis.document.contentType.includes("xml");function __(t){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function o6(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function s6(t,e,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function a6(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function l6(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function c6(t){throw new Error("https://svelte.dev/e/effect_orphan")}function u6(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function d6(t){throw new Error("https://svelte.dev/e/props_invalid_value")}function f6(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function h6(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function p6(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function m6(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const g6=1,v6=2,C_=4,b6=8,y6=16,w6=1,k6=2,x6=4,_6=8,C6=16,S6=1,E6=2,A6=4,S_=1,T6=2,Ln=Symbol(),E_="http://www.w3.org/1999/xhtml",M6="http://www.w3.org/2000/svg",D6="http://www.w3.org/1998/Math/MathML";function O6(){console.warn("https://svelte.dev/e/derived_inert")}function I6(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function R6(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function A_(t){return t===this.v}function T_(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function M_(t){return!T_(t,this.v)}let Rc=!1,N6=!1;function P6(){Rc=!0}let Cn=null;function ac(t){Cn=t}function et(t,e=!1,n){Cn={p:Cn,i:!1,c:null,e:null,s:t,x:null,r:Dt,l:Rc&&!e?{s:null,u:null,$:[]}:null}}function tt(t){var e=Cn,n=e.e;if(n!==null){e.e=null;for(var r of n)Q_(r)}return t!==void 0&&(e.x=t),e.i=!0,Cn=e.p,t??{}}function rl(){return!Rc||Cn!==null&&Cn.l===null}let ga=[];function D_(){var t=ga;ga=[],e6(t)}function Ui(t){if(ga.length===0&&!Ll){var e=ga;queueMicrotask(()=>{e===ga&&D_()})}ga.push(t)}function L6(){for(;ga.length>0;)D_()}function O_(t){var e=Dt;if(e===null)return Ft.f|=Hs,t;if((e.f&na)===0&&(e.f&sc)===0)throw t;Rs(t,e)}function Rs(t,e){for(;e!==null;){if((e.f&L0)!==0){if((e.f&na)===0)throw t;try{e.b.error(t);return}catch(n){t=n}}e=e.parent}throw t}const F6=-7169;function xn(t,e){t.f=t.f&F6|e}function Rb(t){(t.f&ki)!==0||t.deps===null?xn(t,Bn):xn(t,bo)}function I_(t){if(t!==null)for(const e of t)(e.f&lr)===0||(e.f&Va)===0||(e.f^=Va,I_(e.deps))}function R_(t,e,n){(t.f&Zn)!==0?e.add(t):(t.f&bo)!==0&&n.add(t),I_(t.deps),xn(t,Bn)}let gf=!1;function z6(t){var e=gf;try{return gf=!1,[t(),gf]}finally{gf=e}}let lg=null,hl=null,ht=null,wu=null,ir=null,H0=null,Ll=!1,cg=!1,Ol=null,th=null;var Ky=0;let B6=1;var Xl,Ms,Sa,Ql,$l,Ea,ec,Vo,Od,Jr,Id,Ds,so,ao,tc,nc,Wt,V0,cu,U0,N_,P_,nh,H6,j0,_l;const rm=class rm{constructor(){bt(this,Wt);Vn(this,"id",B6++);bt(this,Xl,!1);Vn(this,"linked",!0);bt(this,Ms,null);bt(this,Sa,null);Vn(this,"async_deriveds",new Map);Vn(this,"current",new Map);Vn(this,"previous",new Map);Vn(this,"unblocked",new Set);bt(this,Ql,new Set);bt(this,$l,new Set);bt(this,Ea,new Set);bt(this,ec,0);bt(this,Vo,new Map);bt(this,Od,null);bt(this,Jr,[]);bt(this,Id,[]);bt(this,Ds,new Set);bt(this,so,new Set);bt(this,ao,new Map);bt(this,tc,new Set);Vn(this,"is_fork",!1);bt(this,nc,!1)}skip_effect(e){oe(this,ao).has(e)||oe(this,ao).set(e,{d:[],m:[]}),oe(this,tc).delete(e)}unskip_effect(e,n=r=>this.schedule(r)){var r=oe(this,ao).get(e);if(r){oe(this,ao).delete(e);for(var i of r.d)xn(i,Zn),n(i);for(i of r.m)xn(i,bo),n(i)}oe(this,tc).add(e)}capture(e,n,r=!1){e.v!==Ln&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&Hs)===0&&(this.current.set(e,[n,r]),ir==null||ir.set(e,n)),this.is_fork||(e.v=n)}activate(){ht=this}deactivate(){ht=null,ir=null}flush(){try{cg=!0,ht=this,Bt(this,Wt,cu).call(this)}finally{Ky=0,H0=null,Ol=null,th=null,cg=!1,ht=null,ir=null,Da.clear()}}discard(){for(const e of oe(this,$l))e(this);oe(this,$l).clear(),oe(this,Ea).clear(),Bt(this,Wt,_l).call(this)}register_created_effect(e){oe(this,Id).push(e)}increment(e,n){if(yt(this,ec,oe(this,ec)+1),e){let r=oe(this,Vo).get(n)??0;oe(this,Vo).set(n,r+1)}}decrement(e,n){if(yt(this,ec,oe(this,ec)-1),e){let r=oe(this,Vo).get(n)??0;r===1?oe(this,Vo).delete(n):oe(this,Vo).set(n,r-1)}oe(this,nc)||(yt(this,nc,!0),Ui(()=>{yt(this,nc,!1),this.linked&&this.flush()}))}transfer_effects(e,n){for(const r of e)oe(this,Ds).add(r);for(const r of n)oe(this,so).add(r);e.clear(),n.clear()}oncommit(e){oe(this,Ql).add(e)}ondiscard(e){oe(this,$l).add(e)}on_fork_commit(e){oe(this,Ea).add(e)}run_fork_commit_callbacks(){for(const e of oe(this,Ea))e(this);oe(this,Ea).clear()}settled(){return(oe(this,Od)??yt(this,Od,w_())).promise}static ensure(){var e;if(ht===null){const n=ht=new rm;Bt(e=n,Wt,j0).call(e),!cg&&!Ll&&Ui(()=>{oe(n,Xl)||n.flush()})}return ht}apply(){{ir=null;return}}schedule(e){var i;if(H0=e,(i=e.b)!=null&&i.is_pending&&(e.f&(sc|um|k_))!==0&&(e.f&na)===0){e.b.defer_effect(e);return}for(var n=e;n.parent!==null;){n=n.parent;var r=n.f;if(Ol!==null&&n===Dt&&(Ft===null||(Ft.f&lr)===0))return;if((r&($o|qi))!==0){if((r&Bn)===0)return;n.f^=Bn}}oe(this,Jr).push(n)}};Xl=new WeakMap,Ms=new WeakMap,Sa=new WeakMap,Ql=new WeakMap,$l=new WeakMap,Ea=new WeakMap,ec=new WeakMap,Vo=new WeakMap,Od=new WeakMap,Jr=new WeakMap,Id=new WeakMap,Ds=new WeakMap,so=new WeakMap,ao=new WeakMap,tc=new WeakMap,nc=new WeakMap,Wt=new WeakSet,V0=function(){if(this.is_fork)return!0;for(const r of oe(this,Vo).keys()){for(var e=r,n=!1;e.parent!==null;){if(oe(this,ao).has(e)){n=!0;break}e=e.parent}if(!n)return!0}return!1},cu=function(){var l,c,d,f;if(yt(this,Xl,!0),Ky++>1e3&&(Bt(this,Wt,_l).call(this),V6()),!Bt(this,Wt,V0).call(this)){for(const h of oe(this,Ds))oe(this,so).delete(h),xn(h,Zn),this.schedule(h);for(const h of oe(this,so))xn(h,bo),this.schedule(h)}const e=oe(this,Jr);yt(this,Jr,[]),this.apply();var n=Ol=[],r=[],i=th=[];for(const h of e)try{Bt(this,Wt,U0).call(this,h,n,r)}catch(p){throw B_(h),p}if(ht=null,i.length>0){var o=rm.ensure();for(const h of i)o.schedule(h)}if(Ol=null,th=null,Bt(this,Wt,V0).call(this)){Bt(this,Wt,nh).call(this,r),Bt(this,Wt,nh).call(this,n);for(const[h,p]of oe(this,ao))z_(h,p);i.length>0&&Bt(l=ht,Wt,cu).call(l);return}const s=Bt(this,Wt,N_).call(this);if(s){Bt(c=s,Wt,P_).call(c,this);return}oe(this,Ds).clear(),oe(this,so).clear();for(const h of oe(this,Ql))h(this);oe(this,Ql).clear(),wu=this,Gy(r),Gy(n),wu=null,(d=oe(this,Od))==null||d.resolve();var a=ht;if(this.linked&&oe(this,ec)===0&&Bt(this,Wt,_l).call(this),oe(this,Jr).length>0){a===null&&(a=this,Bt(this,Wt,j0).call(this));const h=a;oe(h,Jr).push(...oe(this,Jr).filter(p=>!oe(h,Jr).includes(p)))}a!==null&&Bt(f=a,Wt,cu).call(f)},U0=function(e,n,r){e.f^=Bn;for(var i=e.first;i!==null;){var o=i.f,s=(o&(qi|$o))!==0,a=s&&(o&Bn)!==0,l=a||(o&Cr)!==0||oe(this,ao).has(i);if(!l&&i.fn!==null){s?i.f^=Bn:(o&sc)!==0?n.push(i):Vd(i)&&((o&wi)!==0&&oe(this,so).add(i),lc(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}}},N_=function(){for(var e=oe(this,Ms);e!==null;){if(!e.is_fork){for(const[n,[,r]]of this.current)if(e.current.has(n)&&!r)return e}e=oe(e,Ms)}return null},P_=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&lr)!==0)n(l);else{var a=l;s&(Pl|wi)&&!this.async_deriveds.has(a)&&(oe(this,so).delete(a),xn(a,Zn),this.schedule(a))}}};for(const i of this.current.keys())n(i);this.oncommit(()=>e.discard()),Bt(r=e,Wt,_l).call(r),ht=this,Bt(this,Wt,cu).call(this)},nh=function(e){for(var n=0;n<e.length;n+=1)R_(e[n],oe(this,Ds),oe(this,so))},H6=function(){var d;Bt(this,Wt,_l).call(this);for(let f=lg;f!==null;f=oe(f,Sa)){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,Xl)){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,tc))f.unskip_effect(h,p=>{var m;(p.f&(wi|Pl))!==0?f.schedule(p):Bt(m=f,Wt,nh).call(m,[p])});f.activate();var o=new Set,s=new Map;for(var a of n)F_(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,Id))(h.f&(xi|Cr|Mh))===0&&Nb(h,l,s)&&((h.f&(Pl|wi))!==0?(xn(h,Zn),f.schedule(h)):oe(f,Ds).add(h));if(oe(f,Jr).length>0){f.apply();for(var c of oe(f,Jr))Bt(d=f,Wt,U0).call(d,c,[],[]);yt(f,Jr,[])}f.deactivate()}}}},j0=function(){hl===null?lg=hl=this:(yt(hl,Sa,this),yt(this,Ms,hl)),hl=this},_l=function(){var e=oe(this,Ms),n=oe(this,Sa);e===null?lg=n:yt(e,Sa,n),n===null?hl=e:yt(n,Ms,e),this.linked=!1};let ts=rm;function L_(t){var e=Ll;Ll=!0;try{for(var n;;){if(L6(),ht===null)return n;ht.flush()}}finally{Ll=e}}function V6(){try{u6()}catch(t){Rs(t,H0)}}let Fi=null;function Gy(t){var e=t.length;if(e!==0){for(var n=0;n<e;){var r=t[n++];if((r.f&(xi|Cr))===0&&Vd(r)&&(Fi=new Set,lc(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&nC(r),(Fi==null?void 0:Fi.size)>0)){Da.clear();for(const i of Fi){if((i.f&(xi|Cr))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)Fi.has(s)&&(Fi.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){const l=o[a];(l.f&(xi|Cr))===0&&lc(l)}}Fi.clear()}}Fi=null}}function F_(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&lr)!==0?F_(i,e,n,r):(o&(Pl|wi))!==0&&(o&Zn)===0&&Nb(i,e,r)&&(xn(i,Zn),Pb(i))}}function Nb(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(oc.call(e,i))return!0;if((i.f&lr)!==0&&Nb(i,e,n))return n.set(i,!0),!0}return n.set(t,!1),!1}function Pb(t){ht.schedule(t)}function z_(t,e){if(!((t.f&qi)!==0&&(t.f&Bn)!==0)){(t.f&Zn)!==0?e.d.push(t):(t.f&bo)!==0&&e.m.push(t),xn(t,Bn);for(var n=t.first;n!==null;)z_(n,e),n=n.next}}function B_(t){xn(t,Bn);for(var e=t.first;e!==null;)B_(e),e=e.next}function U6(t){let e=0,n=ns(0),r;return()=>{Bb()&&(u(n),Hd(()=>(e===0&&(r=Mt(()=>t(()=>ku(n)))),e+=1,()=>{Ui(()=>{e-=1,e===0&&(r==null||r(),r=void 0,ku(n))})})))}}var j6=es|nl;function H_(t,e,n,r){new q6(t,e,n,r)}var di,Db,fi,Aa,Nr,hi,_r,Xr,Uo,Ta,Os,rc,Rd,Nd,jo,im,Sn,W6,K6,G6,q0,rh,ih,W0,K0;class q6{constructor(e,n,r,i){bt(this,Sn);Vn(this,"parent");Vn(this,"is_pending",!1);Vn(this,"transform_error");bt(this,di);bt(this,Db,null);bt(this,fi);bt(this,Aa);bt(this,Nr);bt(this,hi,null);bt(this,_r,null);bt(this,Xr,null);bt(this,Uo,null);bt(this,Ta,0);bt(this,Os,0);bt(this,rc,!1);bt(this,Rd,new Set);bt(this,Nd,new Set);bt(this,jo,null);bt(this,im,U6(()=>(yt(this,jo,ns(oe(this,Ta))),()=>{yt(this,jo,null)})));var o;yt(this,di,e),yt(this,fi,n),yt(this,Aa,s=>{var a=Dt;a.b=this,a.f|=L0,r(s)}),this.parent=Dt.b,this.transform_error=i??((o=this.parent)==null?void 0:o.transform_error)??(s=>s),yt(this,Nr,il(()=>{Bt(this,Sn,q0).call(this)},j6))}defer_effect(e){R_(e,oe(this,Rd),oe(this,Nd))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!oe(this,fi).pending}update_pending_count(e,n){Bt(this,Sn,W0).call(this,e,n),yt(this,Ta,oe(this,Ta)+e),!(!oe(this,jo)||oe(this,rc))&&(yt(this,rc,!0),Ui(()=>{yt(this,rc,!1),oe(this,jo)&&Ko(oe(this,jo),oe(this,Ta))}))}get_effect_pending(){return oe(this,im).call(this),u(oe(this,jo))}error(e){if(!oe(this,fi).onerror&&!oe(this,fi).failed)throw e;ht!=null&&ht.is_fork?(oe(this,hi)&&ht.skip_effect(oe(this,hi)),oe(this,_r)&&ht.skip_effect(oe(this,_r)),oe(this,Xr)&&ht.skip_effect(oe(this,Xr)),ht.on_fork_commit(()=>{Bt(this,Sn,K0).call(this,e)})):Bt(this,Sn,K0).call(this,e)}}di=new WeakMap,Db=new WeakMap,fi=new WeakMap,Aa=new WeakMap,Nr=new WeakMap,hi=new WeakMap,_r=new WeakMap,Xr=new WeakMap,Uo=new WeakMap,Ta=new WeakMap,Os=new WeakMap,rc=new WeakMap,Rd=new WeakMap,Nd=new WeakMap,jo=new WeakMap,im=new WeakMap,Sn=new WeakSet,W6=function(){try{yt(this,hi,pi(()=>oe(this,Aa).call(this,oe(this,di))))}catch(e){this.error(e)}},K6=function(e){const n=oe(this,fi).failed;n&&yt(this,Xr,pi(()=>{n(oe(this,di),()=>e,()=>()=>{})}))},G6=function(){const e=oe(this,fi).pending;e&&(this.is_pending=!0,yt(this,_r,pi(()=>e(oe(this,di)))),Ui(()=>{var n=yt(this,Uo,document.createDocumentFragment()),r=Go();n.append(r),yt(this,hi,Bt(this,Sn,ih).call(this,()=>pi(()=>oe(this,Aa).call(this,r)))),oe(this,Os)===0&&(oe(this,di).before(n),yt(this,Uo,null),Oa(oe(this,_r),()=>{yt(this,_r,null)}),Bt(this,Sn,rh).call(this,ht))}))},q0=function(){try{if(this.is_pending=this.has_pending_snippet(),yt(this,Os,0),yt(this,Ta,0),yt(this,hi,pi(()=>{oe(this,Aa).call(this,oe(this,di))})),oe(this,Os)>0){var e=yt(this,Uo,document.createDocumentFragment());jb(oe(this,hi),e);const n=oe(this,fi).pending;yt(this,_r,pi(()=>n(oe(this,di))))}else Bt(this,Sn,rh).call(this,ht)}catch(n){this.error(n)}},rh=function(e){this.is_pending=!1,e.transfer_effects(oe(this,Rd),oe(this,Nd))},ih=function(e){var n=Dt,r=Ft,i=Cn;yo(oe(this,Nr)),Ti(oe(this,Nr)),ac(oe(this,Nr).ctx);try{return ts.ensure(),e()}catch(o){return O_(o),null}finally{yo(n),Ti(r),ac(i)}},W0=function(e,n){var r;if(!this.has_pending_snippet()){this.parent&&Bt(r=this.parent,Sn,W0).call(r,e,n);return}yt(this,Os,oe(this,Os)+e),oe(this,Os)===0&&(Bt(this,Sn,rh).call(this,n),oe(this,_r)&&Oa(oe(this,_r),()=>{yt(this,_r,null)}),oe(this,Uo)&&(oe(this,di).before(oe(this,Uo)),yt(this,Uo,null)))},K0=function(e){oe(this,hi)&&(Sr(oe(this,hi)),yt(this,hi,null)),oe(this,_r)&&(Sr(oe(this,_r)),yt(this,_r,null)),oe(this,Xr)&&(Sr(oe(this,Xr)),yt(this,Xr,null));var n=oe(this,fi).onerror;let r=oe(this,fi).failed;var i=!1,o=!1;const s=()=>{if(i){R6();return}i=!0,o&&m6(),oe(this,Xr)!==null&&Oa(oe(this,Xr),()=>{yt(this,Xr,null)}),Bt(this,Sn,ih).call(this,()=>{Bt(this,Sn,q0).call(this)})},a=l=>{try{o=!0,n==null||n(l,s),o=!1}catch(c){Rs(c,oe(this,Nr)&&oe(this,Nr).parent)}r&&yt(this,Xr,Bt(this,Sn,ih).call(this,()=>{try{return pi(()=>{var c=Dt;c.b=this,c.f|=L0,r(oe(this,di),()=>l,()=>s)})}catch(c){return Rs(c,oe(this,Nr).parent),null}}))};Ui(()=>{var l;try{l=this.transform_error(e)}catch(c){Rs(c,oe(this,Nr)&&oe(this,Nr).parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(a,c=>Rs(c,oe(this,Nr)&&oe(this,Nr).parent)):a(l)})};function Z6(t,e,n,r){const i=rl()?Uu:Lb;var o=t.filter(h=>!h.settled);if(n.length===0&&o.length===0){r(e.map(i));return}var s=Dt,a=V_(),l=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(h=>h.promise)):null;function c(h){if((s.f&xi)===0){a();try{r(h)}catch(p){Rs(p,s)}Vu()}}var d=U_();if(n.length===0){l.then(()=>c(e.map(i))).finally(d);return}function f(){Promise.all(n.map(h=>Y6(h))).then(h=>c([...e.map(i),...h])).catch(h=>Rs(h,s)).finally(d)}l?l.then(()=>{a(),f(),Vu()}):f()}function V_(){var t=Dt,e=Ft,n=Cn,r=ht;return function(o=!0){yo(t),Ti(e),ac(n),o&&(t.f&xi)===0&&(r==null||r.activate(),r==null||r.apply())}}function Vu(t=!0){yo(null),Ti(null),ac(null),t&&(ht==null||ht.deactivate())}function U_(){var t=Dt,e=t.b,n=ht,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 Uu(t){var e=lr|Zn;return Dt!==null&&(Dt.f|=nl),{ctx:Cn,deps:null,effects:null,equals:A_,f:e,fn:t,reactions:null,rv:0,v:Ln,wv:0,parent:Dt,ac:null}}const vf=Symbol("obsolete");function Y6(t,e,n){let r=Dt;r===null&&o6();var i=void 0,o=ns(Ln),s=!Ft,a=new Set;return aM(()=>{var p;var l=Dt,c=w_();i=c.promise;try{Promise.resolve(t()).then(c.resolve,m=>{m!==dm&&c.reject(m)}).finally(Vu)}catch(m){c.reject(m),Vu()}var d=ht;if(s){if((l.f&na)!==0)var f=U_();if(r.b.is_rendered())(p=d.async_deriveds.get(l))==null||p.reject(vf);else for(const m of a.values())m.reject(vf);a.add(c),d.async_deriveds.set(l,c)}const h=(m,v=void 0)=>{f==null||f(),a.delete(c),v!==vf&&(d.activate(),v?(o.f|=Hs,Ko(o,v)):((o.f&Hs)!==0&&(o.f^=Hs),Ko(o,m)),d.deactivate())};c.promise.then(h,m=>h(null,m||"unknown"))}),Hb(()=>{for(const l of a)l.reject(vf)}),new Promise(l=>{function c(d){function f(){d===i?l(o):c(i)}d.then(f,f)}c(i)})}function N(t){const e=Uu(t);return oC(e),e}function Lb(t){const e=Uu(t);return e.equals=M_,e}function J6(t){var e=t.effects;if(e!==null){t.effects=null;for(var n=0;n<e.length;n+=1)Sr(e[n])}}function Fb(t){var e,n=Dt,r=t.parent;if(!rs&&r!==null&&(r.f&(xi|Cr))!==0)return O6(),t.v;yo(r);try{t.f&=~Va,J6(t),e=cC(t)}finally{yo(n)}return e}function j_(t){var e=Fb(t);if(!t.equals(e)&&(t.wv=aC(),(!(ht!=null&&ht.is_fork)||t.deps===null)&&(ht!==null?(ht.capture(t,e,!0),wu==null||wu.capture(t,e,!0)):t.v=e,t.deps===null))){xn(t,Bn);return}rs||(ir!==null?(Bb()||ht!=null&&ht.is_fork)&&ir.set(t,e):Rb(t))}function X6(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(dm),r.teardown=kn,r.ac=null,qu(r,0),Vb(r))}function q_(t){if(t.effects!==null)for(const e of t.effects)e.teardown&&lc(e)}let Oh=new Set;const Da=new Map;let W_=!1;function ns(t,e){var n={f:0,v:t,reactions:null,equals:A_,rv:0,wv:0};return n}function L(t,e){const n=ns(t);return oC(n),n}function G0(t,e=!1,n=!0){var i;const r=ns(t);return e||(r.equals=M_),Rc&&n&&Cn!==null&&Cn.l!==null&&((i=Cn.l).s??(i.s=[])).push(r),r}function b(t,e,n=!1){Ft!==null&&(!Hi||(Ft.f&Mh)!==0)&&rl()&&(Ft.f&(lr|wi|Pl|Mh))!==0&&(_i===null||!oc.call(_i,t))&&p6();let r=n?at(e):e;return Ko(t,r,th)}function Ko(t,e,n=null){if(!t.equals(e)){Da.set(t,rs?e:t.v);var r=ts.ensure();if(r.capture(t,e),(t.f&lr)!==0){const i=t;(t.f&Zn)!==0&&Fb(i),ir===null&&Rb(i)}t.wv=aC(),K_(t,Zn,n),rl()&&Dt!==null&&(Dt.f&Bn)!==0&&(Dt.f&(qi|$o))===0&&(ui===null?cM([t]):ui.push(t)),!r.is_fork&&Oh.size>0&&!W_&&Q6()}return e}function Q6(){W_=!1;for(const t of Oh){(t.f&Bn)!==0&&xn(t,bo);let e;try{e=Vd(t)}catch{e=!0}e&&lc(t)}Oh.clear()}function ju(t,e=1){var n=u(t),r=e===1?n++:n--;return b(t,n),r}function ku(t){b(t,t.v+1)}function K_(t,e,n){var r=t.reactions;if(r!==null)for(var i=rl(),o=r.length,s=0;s<o;s++){var a=r[s],l=a.f;if(!(!i&&a===Dt)){var c=(l&Zn)===0;if(c&&xn(a,e),(l&Mh)!==0)Oh.add(a);else if((l&lr)!==0){var d=a;ir==null||ir.delete(d),(l&Va)===0&&(l&ki&&(Dt===null||(Dt.f&Dh)===0)&&(a.f|=Va),K_(d,bo,n))}else if(c){var f=a;(l&wi)!==0&&Fi!==null&&Fi.add(f),n!==null?n.push(f):Pb(f)}}}}function at(t){if(typeof t!="object"||t===null||po in t)return t;const e=Ib(t);if(e!==X4&&e!==Q4)return t;var n=new Map,r=Ob(t),i=L(0),o=Ia,s=a=>{if(Ia===o)return a();var l=Ft,c=Ia;Ti(null),Qy(o);var d=a();return Ti(l),Qy(c),d};return r&&n.set("length",L(t.length)),new Proxy(t,{defineProperty(a,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&f6();var d=n.get(l);return d===void 0?s(()=>{var f=L(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(()=>L(Ln));n.set(l,d),ku(i)}}else b(c,Ln),ku(i);return!0},get(a,l,c){var p;if(l===po)return t;var d=n.get(l),f=l in a;if(d===void 0&&(!f||(p=Bs(a,l))!=null&&p.writable)&&(d=s(()=>{var m=at(f?a[l]:Ln),v=L(m);return v}),n.set(l,d)),d!==void 0){var h=u(d);return h===Ln?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!==Ln)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(a,l){var h;if(l===po)return!0;var c=n.get(l),d=c!==void 0&&c.v!==Ln||Reflect.has(a,l);if(c!==void 0||Dt!==null&&(!d||(h=Bs(a,l))!=null&&h.writable)){c===void 0&&(c=s(()=>{var p=d?at(a[l]):Ln,m=L(p);return m}),n.set(l,c));var f=u(c);if(f===Ln)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,Ln):p in a&&(m=s(()=>L(Ln)),n.set(p+"",m))}if(f===void 0)(!h||(_=Bs(a,l))!=null&&_.writable)&&(f=s(()=>L(void 0)),b(f,at(c)),n.set(l,f));else{h=f.v!==Ln;var v=s(()=>at(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)}ku(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!==Ln});for(var[c,d]of n)d.v!==Ln&&!(c in a)&&l.push(c);return l},setPrototypeOf(){h6()}})}function Zy(t){try{if(t!==null&&typeof t=="object"&&po in t)return t[po]}catch{}return t}function $6(t,e){return Object.is(Zy(t),Zy(e))}var Yy,G_,Z_,Y_;function eM(){if(Yy===void 0){Yy=window,G_=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,n=Text.prototype;Z_=Bs(e,"firstChild").get,Y_=Bs(e,"nextSibling").get,Wy(t)&&(t[z0]=void 0,t[$f]=null,t[B0]=void 0,t.__e=void 0),Wy(n)&&(n[lu]=void 0)}}function Go(t=""){return document.createTextNode(t)}function $r(t){return Z_.call(t)}function Bd(t){return Y_.call(t)}function w(t,e){return $r(t)}function Ae(t,e=!1){{var n=$r(t);return n instanceof Comment&&n.data===""?Bd(n):n}}function k(t,e=1,n=!1){let r=t;for(;e--;)r=Bd(r);return r}function tM(t){t.textContent=""}function J_(){return!1}function X_(t,e,n){return document.createElementNS(e??E_,t,void 0)}function nM(t,e){{const n=document.body;t.autofocus=!0,Ui(()=>{document.activeElement===n&&t.focus()})}}let Jy=!1;function rM(){Jy||(Jy=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{var e;if(!t.defaultPrevented)for(const n of t.target.elements)(e=n[eh])==null||e.call(n)})},{capture:!0}))}function Nc(t){var e=Ft,n=Dt;Ti(null),yo(null);try{return t()}finally{Ti(e),yo(n)}}function zb(t,e,n,r=n){t.addEventListener(e,()=>Nc(n));const i=t[eh];i?t[eh]=()=>{i(),r(!0)}:t[eh]=()=>r(!0),rM()}function iM(t){Dt===null&&(Ft===null&&c6(),l6()),rs&&a6()}function oM(t,e){var n=e.last;n===null?e.last=e.first=t:(n.next=t,t.prev=n,e.last=t)}function Co(t,e){var n=Dt;n!==null&&(n.f&Cr)!==0&&(t|=Cr);var r={ctx:Cn,deps:null,nodes:null,f:t|Zn|ki,first:null,fn:e,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};ht==null||ht.register_created_effect(r);var i=r;if((t&sc)!==0)Ol!==null?Ol.push(r):ts.ensure().schedule(r);else if(e!==null){try{lc(r)}catch(s){throw Sr(r),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&nl)===0&&(i=i.first,(t&wi)!==0&&(t&es)!==0&&i!==null&&(i.f|=es))}if(i!==null&&(i.parent=n,n!==null&&oM(i,n),Ft!==null&&(Ft.f&lr)!==0&&(t&$o)===0)){var o=Ft;(o.effects??(o.effects=[])).push(i)}return r}function Bb(){return Ft!==null&&!Hi}function Hb(t){const e=Co(um,null);return xn(e,Bn),e.teardown=t,e}function me(t){iM();var e=Dt.f,n=!Ft&&(e&qi)!==0&&(e&na)===0;if(n){var r=Cn;(r.e??(r.e=[])).push(t)}else return Q_(t)}function Q_(t){return Co(sc|n6,t)}function $_(t){ts.ensure();const e=Co($o|nl,t);return()=>{Sr(e)}}function sM(t){ts.ensure();const e=Co($o|nl,t);return(n={})=>new Promise(r=>{n.outro?Oa(e,()=>{Sr(e),r(void 0)}):(Sr(e),r(void 0))})}function Pc(t){return Co(sc,t)}function aM(t){return Co(Pl|nl,t)}function Hd(t,e=0){return Co(um|e,t)}function W(t,e=[],n=[],r=[]){Z6(r,e,n,i=>{Co(um,()=>t(...i.map(u)))})}function il(t,e=0){var n=Co(wi|e,t);return n}function pi(t){return Co(qi|nl,t)}function eC(t){var e=t.teardown;if(e!==null){const n=rs,r=Ft;Xy(!0),Ti(null);try{e.call(null)}finally{Xy(n),Ti(r)}}}function Vb(t,e=!1){var n=t.first;for(t.first=t.last=null;n!==null;){const i=n.ac;i!==null&&Nc(()=>{i.abort(dm)});var r=n.next;(n.f&$o)!==0?n.parent=null:Sr(n,e),n=r}}function lM(t){for(var e=t.first;e!==null;){var n=e.next;(e.f&qi)===0&&Sr(e),e=n}}function Sr(t,e=!0){var n=!1;(e||(t.f&t6)!==0)&&t.nodes!==null&&t.nodes.end!==null&&(tC(t.nodes.start,t.nodes.end),n=!0),xn(t,F0),Vb(t,e&&!n),qu(t,0);var r=t.nodes&&t.nodes.t;if(r!==null)for(const o of r)o.stop();eC(t),t.f^=F0,t.f|=xi;var i=t.parent;i!==null&&i.first!==null&&nC(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes=t.ac=t.b=null}function tC(t,e){for(;t!==null;){var n=t===e?null:Bd(t);t.remove(),t=n}}function nC(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 Oa(t,e,n=!0){var r=[];rC(t,r,!0);var i=()=>{n&&Sr(t),e&&e()},o=r.length;if(o>0){var s=()=>--o||i();for(var a of r)a.out(s)}else i()}function rC(t,e,n){if((t.f&Cr)===0){t.f^=Cr;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&$o)===0){var s=(i.f&es)!==0||(i.f&qi)!==0&&(t.f&wi)!==0;rC(i,e,s?n:!1)}i=o}}}function Ub(t){iC(t,!0)}function iC(t,e){if((t.f&Cr)!==0){t.f^=Cr,(t.f&Bn)===0&&(xn(t,Zn),ts.ensure().schedule(t));for(var n=t.first;n!==null;){var r=n.next,i=(n.f&es)!==0||(n.f&qi)!==0;iC(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 jb(t,e){if(t.nodes)for(var n=t.nodes.start,r=t.nodes.end;n!==null;){var i=n===r?null:Bd(n);e.append(n),n=i}}let oh=!1,rs=!1;function Xy(t){rs=t}let Ft=null,Hi=!1;function Ti(t){Ft=t}let Dt=null;function yo(t){Dt=t}let _i=null;function oC(t){Ft!==null&&(_i===null?_i=[t]:_i.push(t))}let Pr=null,Gr=0,ui=null;function cM(t){ui=t}let sC=1,va=0,Ia=va;function Qy(t){Ia=t}function aC(){return++sC}function Vd(t){var e=t.f;if((e&Zn)!==0)return!0;if(e&lr&&(t.f&=~Va),(e&bo)!==0){for(var n=t.deps,r=n.length,i=0;i<r;i++){var o=n[i];if(Vd(o)&&j_(o),o.wv>t.wv)return!0}(e&ki)!==0&&ir===null&&xn(t,Bn)}return!1}function lC(t,e,n=!0){var r=t.reactions;if(r!==null&&!(_i!==null&&oc.call(_i,t)))for(var i=0;i<r.length;i++){var o=r[i];(o.f&lr)!==0?lC(o,e,!1):e===o&&(n?xn(o,Zn):(o.f&Bn)!==0&&xn(o,bo),Pb(o))}}function cC(t){var v;var e=Pr,n=Gr,r=ui,i=Ft,o=_i,s=Cn,a=Hi,l=Ia,c=t.f;Pr=null,Gr=0,ui=null,Ft=(c&(qi|$o))===0?t:null,_i=null,ac(t.ctx),Hi=!1,Ia=++va,t.ac!==null&&(Nc(()=>{t.ac.abort(dm)}),t.ac=null);try{t.f|=Dh;var d=t.fn,f=d();t.f|=na;var h=t.deps,p=ht==null?void 0:ht.is_fork;if(Pr!==null){var m;if(p||qu(t,Gr),h!==null&&Gr>0)for(h.length=Gr+Pr.length,m=0;m<Pr.length;m++)h[Gr+m]=Pr[m];else t.deps=h=Pr;if(Bb()&&(t.f&ki)!==0)for(m=Gr;m<h.length;m++)((v=h[m]).reactions??(v.reactions=[])).push(t)}else!p&&h!==null&&Gr<h.length&&(qu(t,Gr),h.length=Gr);if(rl()&&ui!==null&&!Hi&&h!==null&&(t.f&(lr|bo|Zn))===0)for(m=0;m<ui.length;m++)lC(ui[m],t);if(i!==null&&i!==t){if(va++,i.deps!==null)for(let g=0;g<n;g+=1)i.deps[g].rv=va;if(e!==null)for(const g of e)g.rv=va;ui!==null&&(r===null?r=ui:r.push(...ui))}return(t.f&Hs)!==0&&(t.f^=Hs),f}catch(g){return O_(g)}finally{t.f^=Dh,Pr=e,Gr=n,ui=r,Ft=i,_i=o,ac(s),Hi=a,Ia=l}}function uM(t,e){let n=e.reactions;if(n!==null){var r=Y4.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&lr)!==0&&(Pr===null||!oc.call(Pr,e))){var o=e;(o.f&ki)!==0&&(o.f^=ki,o.f&=~Va),o.v!==Ln&&Rb(o),X6(o),qu(o,0)}}function qu(t,e){var n=t.deps;if(n!==null)for(var r=e;r<n.length;r++)uM(t,n[r])}function lc(t){var e=t.f;if((e&xi)===0){xn(t,Bn);var n=Dt,r=oh;Dt=t,oh=!0;try{(e&(wi|k_))!==0?lM(t):Vb(t),eC(t);var i=cC(t);t.teardown=typeof i=="function"?i:null,t.wv=sC;var o;b_&&N6&&(t.f&Zn)!==0&&t.deps}finally{oh=r,Dt=n}}}async function uC(){await Promise.resolve(),L_()}function u(t){var e=t.f,n=(e&lr)!==0;if(Ft!==null&&!Hi){var r=Dt!==null&&(Dt.f&xi)!==0;if(!r&&(_i===null||!oc.call(_i,t))){var i=Ft.deps;if((Ft.f&Dh)!==0)t.rv<va&&(t.rv=va,Pr===null&&i!==null&&i[Gr]===t?Gr++:Pr===null?Pr=[t]:Pr.push(t));else{(Ft.deps??(Ft.deps=[])).push(t);var o=t.reactions;o===null?t.reactions=[Ft]:oc.call(o,Ft)||o.push(Ft)}}}if(rs&&Da.has(t))return Da.get(t);if(n){var s=t;if(rs){var a=s.v;return((s.f&Bn)===0&&s.reactions!==null||fC(s))&&(a=Fb(s)),Da.set(s,a),a}var l=(s.f&ki)===0&&!Hi&&Ft!==null&&(oh||(Ft.f&ki)!==0),c=(s.f&na)===0;Vd(s)&&(l&&(s.f|=ki),j_(s)),l&&!c&&(q_(s),dC(s))}if(ir!=null&&ir.has(t))return ir.get(t);if((t.f&Hs)!==0)throw t.v;return t.v}function dC(t){if(t.f|=ki,t.deps!==null)for(const e of t.deps)(e.reactions??(e.reactions=[])).push(t),(e.f&lr)!==0&&(e.f&ki)===0&&(q_(e),dC(e))}function fC(t){if(t.v===Ln)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(Da.has(e)||(e.f&lr)!==0&&fC(e))return!0;return!1}function Mt(t){var e=Hi;try{return Hi=!0,t()}finally{Hi=e}}function dM(t){if(!(typeof t!="object"||!t||t instanceof EventTarget)){if(po in t)Z0(t);else if(!Array.isArray(t))for(let e in t){const n=t[e];typeof n=="object"&&n&&po in n&&Z0(n)}}}function Z0(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{Z0(t[r],e)}catch{}const n=Ib(t);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const r=y_(n);for(let i in r){const o=r[i].get;if(o)try{o.call(t)}catch{}}}}}const fM=["touchstart","touchmove"];function hM(t){return fM.includes(t)}const ba=Symbol("events"),hC=new Set,Y0=new Set;function pM(t,e,n,r={}){function i(o){if(r.capture||J0.call(e,o),!o.cancelBubble)return Nc(()=>n==null?void 0:n.call(this,o))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?Ui(()=>{e.addEventListener(t,i,r)}):e.addEventListener(t,i,r),i}function hn(t,e,n,r,i){var o={capture:r,passive:i},s=pM(t,e,n,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Hb(()=>{e.removeEventListener(t,s,o)})}function P(t,e,n){(e[ba]??(e[ba]={}))[t]=n}function ut(t){for(var e=0;e<t.length;e++)hC.add(t[e]);for(var n of Y0)n(t)}let $y=null;function J0(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;$y=t;var s=0,a=$y===t&&t[ba];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){t[ba]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||t.target,o!==e){J4(t,"currentTarget",{configurable:!0,get(){return o||n}});var d=Ft,f=Dt;Ti(null),yo(null);try{for(var h,p=[];o!==null;){var m=o.assignedSlot||o.parentNode||o.host||null;try{var v=(y=o[ba])==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[ba]=e,delete t.currentTarget,Ti(d),yo(f)}}}var g_;const ug=((g_=globalThis==null?void 0:globalThis.window)==null?void 0:g_.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:t=>t});function mM(t){return(ug==null?void 0:ug.createHTML(t))??t}function pC(t){var e=X_("template");return e.innerHTML=mM(t.replaceAll("<!>","<!---->")),e.content}function Ks(t,e){var n=Dt;n.nodes===null&&(n.nodes={start:t,end:e,a:null,t:null})}function T(t,e){var n=(e&S_)!==0,r=(e&T6)!==0,i,o=!t.startsWith("<!>");return()=>{i===void 0&&(i=pC(o?t:"<!>"+t),n||(i=$r(i)));var s=r||G_?document.importNode(i,!0):i.cloneNode(!0);if(n){var a=$r(s),l=s.lastChild;Ks(a,l)}else Ks(s,s);return s}}function gM(t,e,n="svg"){var r=!t.startsWith("<!>"),i=(e&S_)!==0,o=`<${n}>${r?t:"<!>"+t}</${n}>`,s;return()=>{if(!s){var a=pC(o),l=$r(a);if(i)for(s=document.createDocumentFragment();$r(l);)s.appendChild($r(l));else s=$r(l)}var c=s.cloneNode(!0);if(i){var d=$r(c),f=c.lastChild;Ks(d,f)}else Ks(c,c);return c}}function rn(t,e){return gM(t,e,"svg")}function dr(t=""){{var e=Go(t+"");return Ks(e,e),e}}function St(){var t=document.createDocumentFragment(),e=document.createComment(""),n=Go();return t.append(e,n),Ks(e,n),t}function x(t,e){t!==null&&t.before(e)}let X0=!0;function G(t,e){var n=e==null?"":typeof e=="object"?`${e}`:e;n!==(t[lu]??(t[lu]=t.nodeValue))&&(t[lu]=n,t.nodeValue=`${n}`)}function vM(t,e){return bM(t,e)}const bf=new Map;function bM(t,{target:e,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:a}){eM();var l=void 0,c=sM(()=>{var d=n??e.appendChild(Go());H_(d,{pending:()=>{}},p=>{et({});var m=Cn;o&&(m.c=o),i&&(r.$$events=i),X0=s,l=t(p,r)||{},X0=!0,tt()},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=bf.get(_);y===void 0&&(y=new Map,bf.set(_,y));var C=y.get(v);C===void 0?(_.addEventListener(v,J0,{passive:g}),y.set(v,1)):y.set(v,C+1)}}}};return h(cm(hC)),Y0.add(h),()=>{var g;for(var p of f)for(const y of[e,document]){var m=bf.get(y),v=m.get(p);--v==0?(y.removeEventListener(p,J0),m.delete(p),m.size===0&&bf.delete(y)):m.set(p,v)}Y0.delete(h),d!==n&&((g=d.parentNode)==null||g.removeChild(d))}});return yM.set(l,c),l}let yM=new WeakMap;var zi,lo,Qr,Ma,Pd,Ld,om;class Ud{constructor(e,n=!0){Vn(this,"anchor");bt(this,zi,new Map);bt(this,lo,new Map);bt(this,Qr,new Map);bt(this,Ma,new Set);bt(this,Pd,!0);bt(this,Ld,e=>{if(oe(this,zi).has(e)){var n=oe(this,zi).get(e),r=oe(this,lo).get(n);if(r)Ub(r),oe(this,Ma).delete(n);else{var i=oe(this,Qr).get(n);i&&(oe(this,lo).set(n,i.effect),oe(this,Qr).delete(n),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[o,s]of oe(this,zi)){if(oe(this,zi).delete(o),o===e)break;const a=oe(this,Qr).get(s);a&&(Sr(a.effect),oe(this,Qr).delete(s))}for(const[o,s]of oe(this,lo)){if(o===n||oe(this,Ma).has(o))continue;const a=()=>{if(Array.from(oe(this,zi).values()).includes(o)){var c=document.createDocumentFragment();jb(s,c),c.append(Go()),oe(this,Qr).set(o,{effect:s,fragment:c})}else Sr(s);oe(this,Ma).delete(o),oe(this,lo).delete(o)};oe(this,Pd)||!r?(oe(this,Ma).add(o),Oa(s,a,!1)):a()}}});bt(this,om,e=>{oe(this,zi).delete(e);const n=Array.from(oe(this,zi).values());for(const[r,i]of oe(this,Qr))n.includes(r)||(Sr(i.effect),oe(this,Qr).delete(r))});this.anchor=e,yt(this,Pd,n)}ensure(e,n){var r=ht,i=J_();if(n&&!oe(this,lo).has(e)&&!oe(this,Qr).has(e))if(i){var o=document.createDocumentFragment(),s=Go();o.append(s),oe(this,Qr).set(e,{effect:pi(()=>n(s)),fragment:o})}else oe(this,lo).set(e,pi(()=>n(this.anchor)));if(oe(this,zi).set(r,e),i){for(const[a,l]of oe(this,lo))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of oe(this,Qr))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(oe(this,Ld)),r.ondiscard(oe(this,om))}else oe(this,Ld).call(this,r)}}zi=new WeakMap,lo=new WeakMap,Qr=new WeakMap,Ma=new WeakMap,Pd=new WeakMap,Ld=new WeakMap,om=new WeakMap;const wM=0,ew=1,kM=2;function mC(t,e,n,r,i){var o=rl(),s=Ln,a=o?ns(s):G0(s,!1,!1),l=o?ns(s):G0(s,!1,!1),c=new Ud(t);il(()=>{var d=ht;d.deactivate();var f=e();d.activate();var h=!1;if($4(f)){var p=V_(),m=!1;const v=g=>{if(!h){m=!0,p(!1),ts.ensure();try{g()}finally{Vu(!1),Ll||L_()}}};f.then(g=>{v(()=>{Ko(a,g),c.ensure(ew,r&&(y=>r(y,a)))})},g=>{v(()=>{if(Ko(l,g),c.ensure(kM,i&&(y=>i(y,l))),!i)throw l.v})}),Ui(()=>{m||v(()=>{c.ensure(wM,n)})})}else Ko(a,f),c.ensure(ew,r&&(v=>r(v,a)));return()=>{h=!0}})}function j(t,e,n=!1){var r=new Ud(t),i=n?es:0;function o(s,a){r.ensure(s,a)}il(()=>{var s=!1;e((a,l=0)=>{s=!0,o(l,a)}),s||o(-1,null)},i)}const xM=Symbol("NaN");function Fl(t,e,n){var r=new Ud(t),i=!rl();il(()=>{var o=e();o!==o&&(o=xM),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,n)})}function cc(t,e){return e}function _M(t,e,n){for(var r=[],i=e.length,o,s=e.length,a=0;a<i;a++){let f=e[a];Oa(f,()=>{if(o){if(o.pending.delete(f),o.done.add(f),o.pending.size===0){var h=t.outrogroups;Q0(t,cm(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()}Q0(t,e,!l)}else o={pending:new Set(e),done:new Set},(t.outrogroups??(t.outrogroups=new Set)).add(o)}function Q0(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|=co;const s=document.createDocumentFragment();jb(o,s)}else Sr(e[i],n)}}var tw;function pt(t,e,n,r,i,o=null){var s=t,a=new Map,l=(e&C_)!==0;if(l){var c=t;s=c.appendChild(Go())}var d=null,f=Lb(()=>{var _=n();return Ob(_)?_:_==null?[]:cm(_)}),h,p=new Map,m=!0;function v(_){(C.effect.f&xi)===0&&(C.pending.delete(_),C.fallback=d,CM(C,h,s,e,r),d!==null&&(h.length===0?(d.f&co)===0?Ub(d):(d.f^=co,uu(d,null,s)):Oa(d,()=>{d=null})))}function g(_){C.pending.delete(_)}var y=il(()=>{h=u(f);for(var _=h.length,S=new Set,A=ht,O=J_(),E=0;E<_;E+=1){var M=h[E],R=r(M,E),D=m?null:a.get(R);D?(D.v&&Ko(D.v,M),D.i&&Ko(D.i,E),O&&A.unskip_effect(D.e)):(D=SM(a,m?s:tw??(tw=Go()),M,R,E,i,e,n),m||(D.e.f|=co),a.set(R,D)),S.add(R)}if(_===0&&o&&!d&&(m?d=pi(()=>o(s)):(d=pi(()=>o(tw??(tw=Go()))),d.f|=co)),_>S.size&&s6(),!m)if(p.set(A,S),O){for(const[I,B]of a)S.has(I)||A.skip_effect(B.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 Jc(t){for(;t!==null&&(t.f&qi)===0;)t=t.next;return t}function CM(t,e,n,r,i){var D,I,B,z,Q,ie,he,ae,ke;var o=(r&b6)!==0,s=e.length,a=t.items,l=Jc(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&co)===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 le of t.outrogroups)le.pending.delete(g),le.done.delete(g);if((g.f&Cr)!==0&&(Ub(g),o&&((z=(B=g.nodes)==null?void 0:B.a)==null||z.unfix(),(f??(f=new Set)).delete(g))),(g.f&co)!==0)if(g.f^=co,g===l)uu(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),ms(t,d,g),ms(t,g,C),uu(g,C,n),d=g,h=[],p=[],l=Jc(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)uu(h[S],_,n);for(S=0;S<p.length;S+=1)c.delete(p[S]);ms(t,A.prev,O.next),ms(t,d,A),ms(t,O,_),l=_,d=O,y-=1,h=[],p=[]}else c.delete(g),uu(g,l,n),ms(t,g.prev,g.next),ms(t,g,d===null?t.effect.first:d.next),ms(t,d,g),d=g;continue}for(h=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=Jc(l.next);if(l===null)continue}(g.f&co)===0&&h.push(g),d=g,l=Jc(g.next)}if(t.outrogroups!==null){for(const le of t.outrogroups)le.pending.size===0&&(Q0(t,cm(le.done)),(Q=t.outrogroups)==null||Q.delete(le));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&Cr)===0&&E.push(g);for(;l!==null;)(l.f&Cr)===0&&l!==t.fallback&&E.push(l),l=Jc(l.next);var M=E.length;if(M>0){var R=(r&C_)!==0&&s===0?n:null;if(o){for(y=0;y<M;y+=1)(he=(ie=E[y].nodes)==null?void 0:ie.a)==null||he.measure();for(y=0;y<M;y+=1)(ke=(ae=E[y].nodes)==null?void 0:ae.a)==null||ke.fix()}_M(t,E,R)}}o&&Ui(()=>{var le,be;if(f!==void 0)for(g of f)(be=(le=g.nodes)==null?void 0:le.a)==null||be.apply()})}function SM(t,e,n,r,i,o,s,a){var l=(s&g6)!==0?(s&y6)===0?G0(n,!1,!1):ns(n):null,c=(s&v6)!==0?ns(i):null;return{v:l,i:c,e:pi(()=>(o(e,l??n,c??i,a),()=>{t.delete(r)}))}}function uu(t,e,n){if(t.nodes)for(var r=t.nodes.start,i=t.nodes.end,o=e&&(e.f&co)===0?e.nodes.start:n;r!==null;){var s=Bd(r);if(o.before(r),r===i)return;r=s}}function ms(t,e,n){e===null?t.effect.first=n:e.next=n,n===null?t.effect.last=e:n.prev=e}function EM(t,e,n=!1,r=!1,i=!1,o=!1){var s=t,a="";if(n)var l=t;W(()=>{var c=Dt;if(a!==(a=e()??"")){if(n){c.nodes=null,l.innerHTML=a,a!==""&&Ks($r(l),l.lastChild);return}if(c.nodes!==null&&(tC(c.nodes.start,c.nodes.end),c.nodes=null),a!==""){var d=r?M6:i?D6:void 0,f=X_(r?"svg":i?"math":"template",d);f.innerHTML=a;var h=r||i?f:f.content;if(Ks($r(h),h.lastChild),r||i)for(;$r(h);)s.before($r(h));else s.before(h)}}})}function jd(t,e,...n){var r=new Ud(t);il(()=>{const i=e()??null;r.ensure(i,i&&(o=>i(o,...n)))},es)}function qb(t,e,n){var r=new Ud(t);il(()=>{var i=e()??null;r.ensure(i,i&&(o=>n(o,i)))},es)}const AM=()=>performance.now(),qo={tick:t=>requestAnimationFrame(t),now:()=>AM(),tasks:new Set};function gC(){const t=qo.now();qo.tasks.forEach(e=>{e.c(t)||(qo.tasks.delete(e),e.f())}),qo.tasks.size!==0&&qo.tick(gC)}function TM(t){let e;return qo.tasks.size===0&&qo.tick(gC),{promise:new Promise(n=>{qo.tasks.add(e={c:t,f:n})}),abort(){qo.tasks.delete(e)}}}function yf(t,e){Nc(()=>{t.dispatchEvent(new CustomEvent(e))})}function MM(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 nw(t){const e={},n=t.split(";");for(const r of n){const[i,o]=r.split(":");if(!i||o===void 0)break;const s=MM(i.trim());e[s]=o.trim()}return e}const DM=t=>t;function Wi(t,e,n,r){var _;var i=(t&S6)!==0,o=(t&E6)!==0,s=i&&o,a=(t&A6)!==0,l=s?"both":i?"in":"out",c,d=e.inert,f=e.style.overflow,h,p;function m(){return Nc(()=>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=$0(e,m(),p,1,()=>{yf(e,"introstart")},()=>{yf(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=$0(e,m(),h,0,()=>{yf(e,"outrostart")},()=>{yf(e,"outroend"),S==null||S()})},stop:()=>{h==null||h.abort(),p==null||p.abort()}},g=Dt;if(((_=g.nodes).t??(_.t=[])).push(v),i&&X0){var y=a;if(!y){for(var C=g.parent;C&&(C.f&es)!==0;)for(;(C=C.parent)&&(C.f&wi)===0;);y=!C||(C.f&na)!==0}y&&Pc(()=>{Mt(()=>v.in())})}}function $0(t,e,n,r,i,o){var s=r===1;if(xl(e)){var a,l=!1;return Ui(()=>{if(!l){var y=e({direction:s?"in":"out"});a=$0(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=DM}=e;var p=[];if(s&&n===void 0&&(f&&f(0,1),d)){var m=nw(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=nw(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&&TM(()=>{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 Ur(t,e,n){Pc(()=>{var r=Mt(()=>e(t,n==null?void 0:n())||{});if(n&&(r!=null&&r.update)){var i=!1,o={};Hd(()=>{var s=n();dM(s),i&&T_(o,s)&&(o=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}function vC(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=vC(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function OM(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=vC(t))&&(r&&(r+=" "),r+=e);return r}function Ih(t){return typeof t=="object"?OM(t):t??""}const rw=[...`
3
- \r\f \v\uFEFF`];function IM(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||rw.includes(r[s-1]))&&(a===r.length||rw.includes(r[a]))?r=(s===0?"":r.substring(0,s))+r.substring(a+1):s=a}}return r===""?null:r}function RM(t,e){return t==null?null:String(t)}function vt(t,e,n,r,i,o){var s=t[z0];if(s!==n||s===void 0){var a=IM(n,r,o);a==null?t.removeAttribute("class"):e?t.className=a:t.setAttribute("class",a),t[z0]=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 Le(t,e,n,r){var i=t[B0];if(i!==e){var o=RM(e);o==null?t.removeAttribute("style"):t.style.cssText=o,t[B0]=e}return r}function Wb(t,e,n=!1){if(t.multiple){if(e==null)return;if(!Ob(e))return I6();for(var r of t.options)r.selected=e.includes(xu(r));return}for(r of t.options){var i=xu(r);if($6(i,e)){r.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function bC(t){var e=new MutationObserver(()=>{Wb(t,t.__value)});e.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Hb(()=>{e.disconnect()})}function NM(t,e,n=e){var r=new WeakSet,i=!0;zb(t,"change",o=>{var s=o?"[selected]":":checked",a;if(t.multiple)a=[].map.call(t.querySelectorAll(s),xu);else{var l=t.querySelector(s)??t.querySelector("option:not([disabled])");a=l&&xu(l)}n(a),t.__value=a,ht!==null&&r.add(ht)}),Pc(()=>{var o=e();if(t===document.activeElement){var s=ht;if(r.has(s))return}if(Wb(t,o,i),i&&o===void 0){var a=t.querySelector(":checked");a!==null&&(o=xu(a),n(o))}t.__value=o,i=!1}),bC(t)}function xu(t){return"__value"in t?t.__value:t.value}const PM=Symbol("is custom element"),LM=Symbol("is html"),FM=i6?"progress":"PROGRESS";function Br(t,e){var n=Kb(t);n.value===(n.value=e??void 0)||t.value===e&&(e!==0||t.nodeName!==FM)||(t.value=e??"")}function Kn(t,e){var n=Kb(t);n.checked!==(n.checked=e??void 0)&&(t.checked=e)}function U(t,e,n,r){var i=Kb(t);i[e]!==(i[e]=n)&&(e==="loading"&&(t[r6]=n),n==null?t.removeAttribute(e):typeof n!="string"&&zM(t).includes(e)?t[e]=n:t.setAttribute(e,n))}function Kb(t){return t[$f]??(t[$f]={[PM]:t.nodeName.includes("-"),[LM]:t.namespaceURI===E_})}var iw=new Map;function zM(t){var e=t.getAttribute("is")||t.nodeName,n=iw.get(e);if(n)return n;iw.set(e,n=[]);for(var r,i=t,o=Element.prototype;o!==i;){r=y_(i);for(var s in r)r[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&n.push(s);i=Ib(i)}return n}function zr(t,e,n=e){var r=new WeakSet;zb(t,"input",async i=>{var o=i?t.defaultValue:t.value;if(o=dg(t)?fg(o):o,n(o),ht!==null&&r.add(ht),await uC(),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))}}}),Mt(e)==null&&t.value&&(n(dg(t)?fg(t.value):t.value),ht!==null&&r.add(ht)),Hd(()=>{var i=e();if(t===document.activeElement){var o=ht;if(r.has(o))return}dg(t)&&i===fg(t.value)||t.type==="date"&&!i&&!t.value||i!==t.value&&(t.value=i??"")})}function sh(t,e,n=e){zb(t,"change",r=>{var i=r?t.defaultChecked:t.checked;n(i)}),Mt(e)==null&&n(t.checked),Hd(()=>{var r=e();t.checked=!!r})}function dg(t){var e=t.type;return e==="number"||e==="range"}function fg(t){return t===""?null:+t}var Is,ic,Fd,sm,yC;const am=class am{constructor(e){bt(this,sm);bt(this,Is,new WeakMap);bt(this,ic);bt(this,Fd);yt(this,Fd,e)}observe(e,n){var r=oe(this,Is).get(e)||new Set;return r.add(n),oe(this,Is).set(e,r),Bt(this,sm,yC).call(this).observe(e,oe(this,Fd)),()=>{var i=oe(this,Is).get(e);i.delete(n),i.size===0&&(oe(this,Is).delete(e),oe(this,ic).unobserve(e))}}};Is=new WeakMap,ic=new WeakMap,Fd=new WeakMap,sm=new WeakSet,yC=function(){return oe(this,ic)??yt(this,ic,new ResizeObserver(e=>{for(var n of e){am.entries.set(n.target,n);for(var r of oe(this,Is).get(n.target)||[])r(n)}}))},Vn(am,"entries",new WeakMap);let ev=am;var BM=new ev({box:"border-box"});function HM(t,e,n){var r=BM.observe(t,()=>n(t[e]));Pc(()=>(Mt(()=>n(t[e])),r))}function hg(t,e){return t===e||(t==null?void 0:t[po])===e}function Ot(t={},e,n,r){var i=Cn.r,o=Dt;return Pc(()=>{var s,a;return Hd(()=>{s=a,a=(r==null?void 0:r())||[],Mt(()=>{hg(n(...a),t)||(e(t,...a),s&&hg(n(...s),t)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&F0;)l=l.parent;const c=()=>{a&&hg(n(...a),t)&&e(null,...a)},d=l.teardown;l.teardown=()=>{c(),d==null||d()}}}),t}const VM={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 UM(t,e,n){return new Proxy({props:t,exclude:e},VM)}const jM={get(t,e){let n=t.props.length;for(;n--;){let r=t.props[n];if(xl(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];xl(i)&&(i=i());const o=Bs(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(xl(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r){const i=Bs(r,e);return i&&!i.configurable&&(i.configurable=!0),i}}},has(t,e){if(e===po||e===x_)return!1;for(let n of t.props)if(xl(n)&&(n=n()),n!=null&&e in n)return!0;return!1},ownKeys(t){const e=[];for(let n of t.props)if(xl(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 du(...t){return new Proxy({props:t},jM)}function Ye(t,e,n,r){var S;var i=!Rc||(n&k6)!==0,o=(n&_6)!==0,s=(n&C6)!==0,a=r,l=!0,c=void 0,d=()=>s&&i?(c??(c=Uu(r)),u(c)):(l&&(l=!1,a=s?Mt(r):r),a);let f;if(o){var h=po in t||x_ in t;f=((S=Bs(t,e))==null?void 0:S.set)??(h&&e in t?A=>t[e]=A:void 0)}var p,m=!1;o?[p,m]=z6(()=>t[e]):p=t[e],p===void 0&&r!==void 0&&(p=d(),f&&(i&&d6(),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&x6)===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&w6)!==0?Uu:Lb)(()=>(y=!1,v()));o&&u(C);var _=Dt;return(function(A,O){if(arguments.length>0){const E=O?u(C):i&&o?at(A):A;return b(C,E),y=!0,a!==void 0&&(a=E),A}return rs&&y||(_.f&xi)!==0?C.v:u(C)})}function Lc(t){Cn===null&&__(),Rc&&Cn.l!==null?qM(Cn).m.push(t):me(()=>{const e=Mt(t);if(typeof e=="function")return e})}function Dn(t){Cn===null&&__(),Lc(()=>()=>Mt(t))}function qM(t){var e=t.l;return e.u??(e.u={a:[],b:[],m:[]})}const WM="5";var v_;typeof window<"u"&&((v_=window.__svelte??(window.__svelte={})).v??(v_.v=new Set)).add(WM);P6();const KM="modulepreload",GM=function(t){return"/"+t},ow={},Kt=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=GM(c),c in ow)return;ow[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":KM,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,ji=3479,wC="https://github.com/bloknayrb/tandem",kC=`${wC}/issues/new`,ZM=!1,qd=new Set([".md",".txt",".html",".htm",".docx"]),YM=3e3,JM=3e3,XM=3e4,xC={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)"},Wu={yellow:"var(--tandem-highlight-yellow)",green:"var(--tandem-highlight-green)",blue:"var(--tandem-highlight-blue)",pink:"var(--tandem-highlight-pink)"};function _C(t){return t&&t in xC?t:"yellow"}const aw="tandem",wf="tandem:mode",CC="tandem:settings",QM="tandem-panel-width",$M="tandem-left-panel-width",SC={left:$M,right:QM},EC=1e3,uc=500,dc=3e3,eD="__tandem_ctrl__",Mi="annotations",AC="awareness",tv="userAwareness",tD="mode",nD="selectionDwellMs",lw="chat",Rh="documentMeta",TC="annotationReplies",cw="savedAtVersion",uw="authorship",dw="selection",fw="activity",nv="claude",Xc="openDocuments",Qc="activeDocumentId",$c="activeDocumentEpoch",pg="storeReadOnly",hw="externalConflict",MC="tandem:showAuthorship",DC="tandem:decorationVisibility",Gb="tandem:recentFiles",rD=20,Zb="tandem:userName",OC="You",rv="tandem:user-name-changed",fm=40,pw={error:8e3,warning:6e3,info:4e3},iD=5,oD="tandem:activityHistory",IC=50,sD=5*6e4,RC="tandem:tutorialCompleted",NC="tutorial-",PC="tandem:coworkOnboardingSkipped",aD=3e4,are=2e3,mw="tandem:zoomLevel",gw=.5,vw=2,eu=1,lD="upload://",LC="upload://scratchpad/";function Cl(t){return t.startsWith(lD)}function hm(t){return t.startsWith(LC)}function FC(t){if(!hm(t))return null;const n=t.slice(LC.length).split("/")[0];return n.length>0?n:null}const ah=t=>t,zn=t=>t;var jt;(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})(jt||(jt={}));var bw;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(bw||(bw={}));const lt=jt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),bs=t=>{switch(typeof t){case"undefined":return lt.undefined;case"string":return lt.string;case"number":return Number.isNaN(t)?lt.nan:lt.number;case"boolean":return lt.boolean;case"function":return lt.function;case"bigint":return lt.bigint;case"symbol":return lt.symbol;case"object":return Array.isArray(t)?lt.array:t===null?lt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?lt.promise:typeof Map<"u"&&t instanceof Map?lt.map:typeof Set<"u"&&t instanceof Set?lt.set:typeof Date<"u"&&t instanceof Date?lt.date:lt.object;default:return lt.unknown}},je=jt.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 is 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 is))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,jt.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()}}is.create=t=>new is(t);const iv=(t,e)=>{let n;switch(t.code){case je.invalid_type:t.received===lt.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case je.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,jt.jsonStringifyReplacer)}`;break;case je.unrecognized_keys:n=`Unrecognized key(s) in object: ${jt.joinValues(t.keys,", ")}`;break;case je.invalid_union:n="Invalid input";break;case je.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${jt.joinValues(t.options)}`;break;case je.invalid_enum_value:n=`Invalid enum value. Expected ${jt.joinValues(t.options)}, received '${t.received}'`;break;case je.invalid_arguments:n="Invalid function arguments";break;case je.invalid_return_type:n="Invalid function return type";break;case je.invalid_date:n="Invalid date";break;case je.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}"`:jt.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case je.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 je.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 je.custom:n="Invalid input";break;case je.invalid_intersection_types:n="Intersection results could not be merged";break;case je.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case je.not_finite:n="Number must be finite";break;default:n=e.defaultError,jt.assertNever(t)}return{message:n}};let cD=iv;function uD(){return cD}const dD=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=uD(),r=dD({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===iv?void 0:iv].filter(i=>!!i)});t.common.issues.push(r)}class ni{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 wt;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 ni.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 wt;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 wt=Object.freeze({status:"aborted"}),fu=t=>({status:"dirty",value:t}),Di=t=>({status:"valid",value:t}),yw=t=>t.status==="aborted",ww=t=>t.status==="dirty",fc=t=>t.status==="valid",Nh=t=>typeof Promise<"u"&&t instanceof Promise;var ct;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ct||(ct={}));class Gs{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 kw=(t,e)=>{if(fc(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 is(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 Vt{get description(){return this._def.description}_getType(e){return bs(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ni,ctx:{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Nh(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:bs(e)},i=this._parseSync({data:e,path:r.path,parent:r});return kw(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:bs(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:n});return fc(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=>fc(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:bs(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(Nh(i)?i:Promise.resolve(i));return kw(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:je.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 pc({schema:this,typeName:kt.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 Vs.create(this,this._def)}nullable(){return mc.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return mo.create(this)}promise(){return zh.create(this,this._def)}or(e){return Lh.create([this,e],this._def)}and(e){return Fh.create(this,e,this._def)}transform(e){return new pc({...Rt(this._def),schema:this,typeName:kt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new sv({...Rt(this._def),innerType:this,defaultValue:n,typeName:kt.ZodDefault})}brand(){return new ND({typeName:kt.ZodBranded,type:this,...Rt(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new av({...Rt(this._def),innerType:this,catchValue:n,typeName:kt.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Yb.create(this,e)}readonly(){return lv.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const fD=/^c[^\s-]{8,}$/i,hD=/^[0-9a-z]+$/,pD=/^[0-9A-HJKMNP-TV-Z]{26}$/i,mD=/^[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,gD=/^[a-z0-9_-]{21}$/i,vD=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,bD=/^[-+]?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)?)??$/,yD=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wD="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mg;const kD=/^(?:(?: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])$/,xD=/^(?:(?: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])$/,_D=/^(([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]))$/,CD=/^(([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])$/,SD=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ED=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zC="((\\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])))",AD=new RegExp(`^${zC}$`);function BC(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 TD(t){return new RegExp(`^${BC(t)}$`)}function MD(t){let e=`${zC}T${BC(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 DD(t,e){return!!((e==="v4"||!e)&&kD.test(t)||(e==="v6"||!e)&&_D.test(t))}function OD(t,e){if(!vD.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 ID(t,e){return!!((e==="v4"||!e)&&xD.test(t)||(e==="v6"||!e)&&CD.test(t))}class ya extends Vt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==lt.string){const o=this._getOrReturnCtx(e);return Qe(o,{code:je.invalid_type,expected:lt.string,received:o.parsedType}),wt}const r=new ni;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:je.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:je.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:je.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&Qe(i,{code:je.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")yD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"email",code:je.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")mg||(mg=new RegExp(wD,"u")),mg.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"emoji",code:je.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")mD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"uuid",code:je.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")gD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"nanoid",code:je.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")fD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"cuid",code:je.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:je.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")pD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"ulid",code:je.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:je.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:je.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:je.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:je.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:je.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?MD(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{code:je.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?AD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{code:je.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?TD(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{code:je.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?bD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"duration",code:je.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?DD(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"ip",code:je.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?OD(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"jwt",code:je.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?ID(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"cidr",code:je.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?SD.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"base64",code:je.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?ED.test(e.data)||(i=this._getOrReturnCtx(e,i),Qe(i,{validation:"base64url",code:je.invalid_string,message:o.message}),r.dirty()):jt.assertNever(o);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:je.invalid_string,...ct.errToObj(r)})}_addCheck(e){return new ya({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ct.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ct.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ct.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ct.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ct.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ct.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ct.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ct.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ct.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ct.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ct.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ct.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ct.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,...ct.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,...ct.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ct.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...ct.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...ct.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...ct.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...ct.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...ct.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...ct.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...ct.errToObj(n)})}nonempty(e){return this.min(1,ct.errToObj(e))}trim(){return new ya({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ya({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ya({...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}}ya.create=t=>new ya({checks:[],typeName:kt.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Rt(t)});function RD(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 Ku extends Vt{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)!==lt.number){const o=this._getOrReturnCtx(e);return Qe(o,{code:je.invalid_type,expected:lt.number,received:o.parsedType}),wt}let r;const i=new ni;for(const o of this._def.checks)o.kind==="int"?jt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),Qe(r,{code:je.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:je.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:je.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?RD(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),Qe(r,{code:je.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:je.not_finite,message:o.message}),i.dirty()):jt.assertNever(o);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,ct.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ct.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ct.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ct.toString(n))}setLimit(e,n,r,i){return new Ku({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ct.toString(i)}]})}_addCheck(e){return new Ku({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ct.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ct.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ct.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ct.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ct.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ct.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:ct.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ct.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ct.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"&&jt.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)}}Ku.create=t=>new Ku({checks:[],typeName:kt.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Rt(t)});class Gu extends Vt{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)!==lt.bigint)return this._getInvalidInput(e);let r;const i=new ni;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:je.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:je.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:je.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):jt.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return Qe(n,{code:je.invalid_type,expected:lt.bigint,received:n.parsedType}),wt}gte(e,n){return this.setLimit("min",e,!0,ct.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ct.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ct.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ct.toString(n))}setLimit(e,n,r,i){return new Gu({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ct.toString(i)}]})}_addCheck(e){return new Gu({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ct.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ct.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ct.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ct.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ct.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}}Gu.create=t=>new Gu({checks:[],typeName:kt.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Rt(t)});class xw extends Vt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==lt.boolean){const r=this._getOrReturnCtx(e);return Qe(r,{code:je.invalid_type,expected:lt.boolean,received:r.parsedType}),wt}return Di(e.data)}}xw.create=t=>new xw({typeName:kt.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Rt(t)});class Ph extends Vt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==lt.date){const o=this._getOrReturnCtx(e);return Qe(o,{code:je.invalid_type,expected:lt.date,received:o.parsedType}),wt}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return Qe(o,{code:je.invalid_date}),wt}const r=new ni;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:je.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:je.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):jt.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ph({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:ct.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:ct.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}}Ph.create=t=>new Ph({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:kt.ZodDate,...Rt(t)});class _w extends Vt{_parse(e){if(this._getType(e)!==lt.symbol){const r=this._getOrReturnCtx(e);return Qe(r,{code:je.invalid_type,expected:lt.symbol,received:r.parsedType}),wt}return Di(e.data)}}_w.create=t=>new _w({typeName:kt.ZodSymbol,...Rt(t)});class Cw extends Vt{_parse(e){if(this._getType(e)!==lt.undefined){const r=this._getOrReturnCtx(e);return Qe(r,{code:je.invalid_type,expected:lt.undefined,received:r.parsedType}),wt}return Di(e.data)}}Cw.create=t=>new Cw({typeName:kt.ZodUndefined,...Rt(t)});class Sw extends Vt{_parse(e){if(this._getType(e)!==lt.null){const r=this._getOrReturnCtx(e);return Qe(r,{code:je.invalid_type,expected:lt.null,received:r.parsedType}),wt}return Di(e.data)}}Sw.create=t=>new Sw({typeName:kt.ZodNull,...Rt(t)});class Ew extends Vt{constructor(){super(...arguments),this._any=!0}_parse(e){return Di(e.data)}}Ew.create=t=>new Ew({typeName:kt.ZodAny,...Rt(t)});class Aw extends Vt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Di(e.data)}}Aw.create=t=>new Aw({typeName:kt.ZodUnknown,...Rt(t)});class Zs extends Vt{_parse(e){const n=this._getOrReturnCtx(e);return Qe(n,{code:je.invalid_type,expected:lt.never,received:n.parsedType}),wt}}Zs.create=t=>new Zs({typeName:kt.ZodNever,...Rt(t)});class Tw extends Vt{_parse(e){if(this._getType(e)!==lt.undefined){const r=this._getOrReturnCtx(e);return Qe(r,{code:je.invalid_type,expected:lt.void,received:r.parsedType}),wt}return Di(e.data)}}Tw.create=t=>new Tw({typeName:kt.ZodVoid,...Rt(t)});class mo extends Vt{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==lt.array)return Qe(n,{code:je.invalid_type,expected:lt.array,received:n.parsedType}),wt;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?je.too_big:je.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:je.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:je.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 Gs(n,s,n.path,a)))).then(s=>ni.mergeArray(r,s));const o=[...n.data].map((s,a)=>i.type._parseSync(new Gs(n,s,n.path,a)));return ni.mergeArray(r,o)}get element(){return this._def.type}min(e,n){return new mo({...this._def,minLength:{value:e,message:ct.toString(n)}})}max(e,n){return new mo({...this._def,maxLength:{value:e,message:ct.toString(n)}})}length(e,n){return new mo({...this._def,exactLength:{value:e,message:ct.toString(n)}})}nonempty(e){return this.min(1,e)}}mo.create=(t,e)=>new mo({type:t,minLength:null,maxLength:null,exactLength:null,typeName:kt.ZodArray,...Rt(e)});function Sl(t){if(t instanceof Fn){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Vs.create(Sl(r))}return new Fn({...t._def,shape:()=>e})}else return t instanceof mo?new mo({...t._def,type:Sl(t.element)}):t instanceof Vs?Vs.create(Sl(t.unwrap())):t instanceof mc?mc.create(Sl(t.unwrap())):t instanceof Ua?Ua.create(t.items.map(e=>Sl(e))):t}class Fn extends Vt{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=jt.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==lt.object){const c=this._getOrReturnCtx(e);return Qe(c,{code:je.invalid_type,expected:lt.object,received:c.parsedType}),wt}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Zs&&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 Gs(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Zs){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:je.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 Gs(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=>ni.mergeObjectSync(r,c)):ni.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return ct.errToObj,new Fn({...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:ct.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new Fn({...this._def,unknownKeys:"strip"})}passthrough(){return new Fn({...this._def,unknownKeys:"passthrough"})}extend(e){return new Fn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Fn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:kt.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Fn({...this._def,catchall:e})}pick(e){const n={};for(const r of jt.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Fn({...this._def,shape:()=>n})}omit(e){const n={};for(const r of jt.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new Fn({...this._def,shape:()=>n})}deepPartial(){return Sl(this)}partial(e){const n={};for(const r of jt.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new Fn({...this._def,shape:()=>n})}required(e){const n={};for(const r of jt.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof Vs;)o=o._def.innerType;n[r]=o}return new Fn({...this._def,shape:()=>n})}keyof(){return HC(jt.objectKeys(this.shape))}}Fn.create=(t,e)=>new Fn({shape:()=>t,unknownKeys:"strip",catchall:Zs.create(),typeName:kt.ZodObject,...Rt(e)});Fn.strictCreate=(t,e)=>new Fn({shape:()=>t,unknownKeys:"strict",catchall:Zs.create(),typeName:kt.ZodObject,...Rt(e)});Fn.lazycreate=(t,e)=>new Fn({shape:t,unknownKeys:"strip",catchall:Zs.create(),typeName:kt.ZodObject,...Rt(e)});class Lh extends Vt{_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 is(a.ctx.common.issues));return Qe(n,{code:je.invalid_union,unionErrors:s}),wt}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 is(l));return Qe(n,{code:je.invalid_union,unionErrors:a}),wt}}get options(){return this._def.options}}Lh.create=(t,e)=>new Lh({options:t,typeName:kt.ZodUnion,...Rt(e)});function ov(t,e){const n=bs(t),r=bs(e);if(t===e)return{valid:!0,data:t};if(n===lt.object&&r===lt.object){const i=jt.objectKeys(e),o=jt.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...e};for(const a of o){const l=ov(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===lt.array&&r===lt.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=ov(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===lt.date&&r===lt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Fh extends Vt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(yw(o)||yw(s))return wt;const a=ov(o.value,s.value);return a.valid?((ww(o)||ww(s))&&n.dirty(),{status:n.value,value:a.data}):(Qe(r,{code:je.invalid_intersection_types}),wt)};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}))}}Fh.create=(t,e,n)=>new Fh({left:t,right:e,typeName:kt.ZodIntersection,...Rt(n)});class Ua extends Vt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==lt.array)return Qe(r,{code:je.invalid_type,expected:lt.array,received:r.parsedType}),wt;if(r.data.length<this._def.items.length)return Qe(r,{code:je.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),wt;!this._def.rest&&r.data.length>this._def.items.length&&(Qe(r,{code:je.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 Gs(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>ni.mergeArray(n,s)):ni.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new Ua({...this._def,rest:e})}}Ua.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ua({items:t,typeName:kt.ZodTuple,rest:null,...Rt(e)})};class Mw extends Vt{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!==lt.map)return Qe(r,{code:je.invalid_type,expected:lt.map,received:r.parsedType}),wt;const i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new Gs(r,a,r.path,[c,"key"])),value:o._parse(new Gs(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 wt;(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 wt;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}}}}Mw.create=(t,e,n)=>new Mw({valueType:e,keyType:t,typeName:kt.ZodMap,...Rt(n)});class Zu extends Vt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==lt.set)return Qe(r,{code:je.invalid_type,expected:lt.set,received:r.parsedType}),wt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Qe(r,{code:je.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:je.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 wt;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 Gs(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,n){return new Zu({...this._def,minSize:{value:e,message:ct.toString(n)}})}max(e,n){return new Zu({...this._def,maxSize:{value:e,message:ct.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Zu.create=(t,e)=>new Zu({valueType:t,minSize:null,maxSize:null,typeName:kt.ZodSet,...Rt(e)});class Dw extends Vt{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})}}Dw.create=(t,e)=>new Dw({getter:t,typeName:kt.ZodLazy,...Rt(e)});class Ow extends Vt{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return Qe(n,{received:n.data,code:je.invalid_literal,expected:this._def.value}),wt}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ow.create=(t,e)=>new Ow({value:t,typeName:kt.ZodLiteral,...Rt(e)});function HC(t,e){return new hc({values:t,typeName:kt.ZodEnum,...Rt(e)})}class hc extends Vt{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return Qe(n,{expected:jt.joinValues(r),received:n.parsedType,code:je.invalid_type}),wt}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:je.invalid_enum_value,options:r}),wt}return Di(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 hc.create(e,{...this._def,...n})}exclude(e,n=this._def){return hc.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}hc.create=HC;class Iw extends Vt{_parse(e){const n=jt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==lt.string&&r.parsedType!==lt.number){const i=jt.objectValues(n);return Qe(r,{expected:jt.joinValues(i),received:r.parsedType,code:je.invalid_type}),wt}if(this._cache||(this._cache=new Set(jt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=jt.objectValues(n);return Qe(r,{received:r.data,code:je.invalid_enum_value,options:i}),wt}return Di(e.data)}get enum(){return this._def.values}}Iw.create=(t,e)=>new Iw({values:t,typeName:kt.ZodNativeEnum,...Rt(e)});class zh extends Vt{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==lt.promise&&n.common.async===!1)return Qe(n,{code:je.invalid_type,expected:lt.promise,received:n.parsedType}),wt;const r=n.parsedType===lt.promise?n.data:Promise.resolve(n.data);return Di(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}zh.create=(t,e)=>new zh({type:t,typeName:kt.ZodPromise,...Rt(e)});class pc extends Vt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===kt.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 wt;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?wt:l.status==="dirty"||n.value==="dirty"?fu(l.value):l});{if(n.value==="aborted")return wt;const a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?wt:a.status==="dirty"||n.value==="dirty"?fu(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"?wt:(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"?wt:(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(!fc(s))return wt;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=>fc(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:n.value,value:a})):wt);jt.assertNever(i)}}pc.create=(t,e,n)=>new pc({schema:t,typeName:kt.ZodEffects,effect:e,...Rt(n)});pc.createWithPreprocess=(t,e,n)=>new pc({schema:e,effect:{type:"preprocess",transform:t},typeName:kt.ZodEffects,...Rt(n)});class Vs extends Vt{_parse(e){return this._getType(e)===lt.undefined?Di(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Vs.create=(t,e)=>new Vs({innerType:t,typeName:kt.ZodOptional,...Rt(e)});class mc extends Vt{_parse(e){return this._getType(e)===lt.null?Di(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mc.create=(t,e)=>new mc({innerType:t,typeName:kt.ZodNullable,...Rt(e)});class sv extends Vt{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===lt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}sv.create=(t,e)=>new sv({innerType:t,typeName:kt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Rt(e)});class av extends Vt{_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 Nh(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new is(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new is(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}av.create=(t,e)=>new av({innerType:t,typeName:kt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Rt(e)});class Rw extends Vt{_parse(e){if(this._getType(e)!==lt.nan){const r=this._getOrReturnCtx(e);return Qe(r,{code:je.invalid_type,expected:lt.nan,received:r.parsedType}),wt}return{status:"valid",value:e.data}}}Rw.create=t=>new Rw({typeName:kt.ZodNaN,...Rt(t)});class ND extends Vt{_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 Yb extends Vt{_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"?wt:o.status==="dirty"?(n.dirty(),fu(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"?wt: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 Yb({in:e,out:n,typeName:kt.ZodPipeline})}}class lv extends Vt{_parse(e){const n=this._def.innerType._parse(e),r=i=>(fc(i)&&(i.value=Object.freeze(i.value)),i);return Nh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}lv.create=(t,e)=>new lv({innerType:t,typeName:kt.ZodReadonly,...Rt(e)});var kt;(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"})(kt||(kt={}));Zs.create;mo.create;Lh.create;Fh.create;Ua.create;const Oi=hc.create;zh.create;Vs.create;mc.create;Oi(["highlight","note","comment"]);Oi(["pending","accepted","dismissed"]);Oi(["yellow","green","blue","pink"]);Oi(["info","warning","error","success"]);const PD=Oi(["solo","tandem"]);Oi(["user","claude","import"]);Oi(["user","claude","import"]);Oi(["accept","dismiss"]);Oi(["markdown","json"]);Oi(["md","txt","html","docx"]);Oi(["RANGE_GONE","RANGE_MOVED","FILE_LOCKED","FILE_NOT_FOUND","NO_DOCUMENT","INVALID_RANGE","INVALID_ARGUMENT","NOT_FOUND","ANNOTATION_RESOLVED","FORMAT_ERROR","PERMISSION_DENIED"]);Oi(["CHANNEL_CONNECT_FAILED","MONITOR_CONNECT_FAILED"]);function LD(t){return t.author!=="user"}function Bh(t){return t.status==="pending"&&LD(t)}function pm(t){return`${t}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function cv(){return pm("ann")}function FD(){return pm("msg")}function pl(){return pm("ntf")}function zD(t){return pm(t)}const BD="/api/notify-stream",uv="/api/info",HD="/api/diagnostics",VD="/health",UD="/api/open",jD="/api/close",Jb="/api/save",qD="/api/rename",VC="/api/upload",WD="/api/scratchpad",KD="/api/convert",GD="/api/apply-changes",ZD="/api/document/raw",YD="/api/document/reload",JD="/api/backups",XD="/api/backups/restore",QD="/api/docx-conflict/resolve",$D="/api/annotation-reply",eO="/api/remove-annotation",tO="/api/store/reclaim-lock",nO="/api/chat",rO="/api/sessions",iO="/api/sessions/delete",oO="/api/sessions/clear",UC="/api/launcher/status",sO="/api/launcher/nonce",aO="/api/launcher/relaunch",lO="/api/launcher/start-fresh",cO="/api/launcher/working-directory",ja=["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"],uO=new Set(ja);function jC(t){return uO.has(t)}const dv={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"},dO={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"}},qC=[{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"}],WC={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"},fO=/^(Control|Shift|Alt|Meta|OS)/,hO=new Set(["Tab","Escape","Enter","NumpadEnter","NumLock","CapsLock","ContextMenu","Insert"]);function KC(t){return fO.test(t.code)||t.code.startsWith("Numpad")||hO.has(t.code)?!1:t.ctrlOrMeta||t.alt}function pO(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 KC(e)?e:null}function mO(t,e){return t.ctrlOrMeta===(e.ctrlKey||e.metaKey)&&t.alt===e.altKey&&t.shift===e.shiftKey&&t.code===e.code}function Hh(t,e){return t.ctrlOrMeta===e.ctrlOrMeta&&t.alt===e.alt&&t.shift===e.shift&&t.code===e.code}function gO(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 GC(){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 vO(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 fv(t){const e=GC(),n=[];return t.ctrlOrMeta&&n.push(e?"⌘":"Ctrl"),t.alt&&n.push(e?"⌥":"Alt"),t.shift&&n.push(e?"⇧":"Shift"),n.push(vO(t.code)),e?n.join(""):n.join("+")}function Xb(t,e){return e.get(t)??dO[t]}function bO(t){const e=new Map;for(const n of ja)e.set(n,fv(Xb(n,t)));return e}function Un(t,e){return e?e.has(t):!1}function ZC(t,e){if(t.isComposing)return null;if(e&&e.size>0)for(const r of ja){const i=e.get(r);if(i&&mO(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"&&!Un("settings-modal",e))return{id:"settings-modal"};if(!t.shiftKey&&t.code==="Comma"&&!Un("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"&&!Un("save-as",e))return{id:"save-as"};if(t.code==="KeyS"&&!Un("save",e))return{id:"save"};if(t.shiftKey&&t.code==="KeyP"&&!Un("toggle-palette",e))return{id:"toggle-palette"};if(t.code==="KeyN"&&!Un("new-scratchpad",e))return{id:"new-scratchpad"};if(t.code==="KeyW"&&!Un("close-tab",e))return{id:"close-tab"};if(t.code==="KeyO"&&!Un("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"&&!Un("toggle-mode",e))return{id:"toggle-mode"};if(t.altKey&&t.code==="KeyT"&&!Un("reopen-closed-tab",e))return{id:"reopen-closed-tab"};if(!t.altKey&&!t.shiftKey&&t.code==="KeyT"&&!Un("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"&&!Un("comment-on-selection",e))return{id:"comment-on-selection"};if(t.altKey&&t.code==="KeyA"&&!Un("toggle-authorship",e))return{id:"toggle-authorship"}}if(t.altKey&&!t.ctrlKey&&!t.metaKey){if(t.shiftKey){if(t.code==="ArrowLeft"&&!Un("toggle-left-panel",e))return{id:"toggle-left-panel"};if(t.code==="ArrowRight"&&!Un("toggle-right-panel",e))return{id:"toggle-right-panel"}}if(!t.shiftKey){if(t.code==="BracketRight"&&!Un("annotation-next",e))return{id:"annotation-next"};if(t.code==="BracketLeft"&&!Un("annotation-prev",e))return{id:"annotation-prev"}}if(!t.shiftKey&&t.code==="KeyL"&&!Un("select-block",e))return{id:"select-block"}}return null}function yO(t){return t.code==="Slash"?t.shift?"?":"/":t.code==="Enter"||t.code==="NumpadEnter"?"Enter":""}function wO(t){return{key:yO(t),code:t.code,ctrlKey:t.ctrlOrMeta,metaKey:!1,altKey:t.alt,shiftKey:t.shift,isComposing:!1}}function kO(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 YC(t){const e=ZC(wO(t));return!e||jC(e.id)?null:kO(e.id,e.context)||null}function xO(t,e,n){for(const i of ja)if(i!==n&&Hh(Xb(i,e),t))return dv[i];const r=YC(t);if(r)return r;for(const i of qC)if(Hh(i.chord,t))return i.label;return null}function _O(t){return qC.some(e=>Hh(e.chord,t))}function Qb(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[i,o]of Object.entries(t))jC(i)&&gO(o)&&KC(o)&&(_O(o)||YC(o)||(e[i]=o));const n={},r=[];for(const i of ja){const o=e[i];o&&(r.some(s=>Hh(s,o))||(r.push(o),n[i]=o))}return n}function JC(t){const e=new Map;for(const[n,r]of Object.entries(Qb(t)))e.set(n,r);return e}const CO=["narrow","comfortable","wide","full"],Nw={narrow:"58ch",comfortable:"68ch",wide:"82ch",full:"100%"};function XC(t){return typeof t=="string"&&CO.includes(t)}const QC=["anthropic","openai","gemini","local-ollama","local-llamacpp"],SO=50,EO={s:14,m:16,l:18};function $C(){try{return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}const yn={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:14,primaryTab:"annotations",panelOrder:"chat-editor-annotations",editorMeasure:"comfortable",selectionDwellMs:EC,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,soloRailHidden:!0,degradedBannerDelayMs:3e4,sidecarRetryStrategy:"exponential",holdAnnotationsWhileOffline:!0,marginView:!1,showComments:!0,showHighlights:!0,showNotes:!0,showRawMarkdown:!0,decorationsMuted:!1,models:[],defaultModelId:null,customShortcuts:{}},AO=64,TO=512;function eS(t){if(!Array.isArray(t))return[];const e=[];for(const n of t){if(e.length>=SO)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"||!QC.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<=AO&&/^[A-Za-z0-9_-]+$/.test(r.apiKeyRef)?i.apiKeyRef=r.apiKeyRef:typeof r.apiKey=="string"&&r.apiKey.length<=TO&&(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 MO=["serif","sans","mono"];function tS(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"&&MO.includes(r)&&(e[n]=r);return e}const lh=14;function Pw(t){return{leftPanelVisible:t.leftPanelVisible===!0,rightPanelVisible:t.rightPanelVisible!==!1,schemaVersion:lh,primaryTab:t.primaryTab==="annotations"?"annotations":"chat",panelOrder:t.panelOrder==="annotations-editor-chat"?"annotations-editor-chat":"chat-editor-annotations",editorMeasure:XC(t.editorMeasure)?t.editorMeasure:yn.editorMeasure,selectionDwellMs:Math.max(uc,Math.min(dc,Number(t.selectionDwellMs)||EC)),showAuthorship:t.showAuthorship===!1?!1:yn.showAuthorship,reduceMotion:typeof t.reduceMotion=="boolean"?t.reduceMotion:$C(),textSize:t.textSize==="s"||t.textSize==="m"||t.textSize==="l"?t.textSize:yn.textSize,theme:t.theme==="light"||t.theme==="dark"||t.theme==="warm"||t.theme==="system"?t.theme:yn.theme,systemLightVariant:t.systemLightVariant==="warm"?"warm":yn.systemLightVariant,accentHue:typeof t.accentHue=="number"&&t.accentHue>=0&&t.accentHue<=360?t.accentHue:yn.accentHue,editorFont:t.editorFont==="serif"||t.editorFont==="sans"||t.editorFont==="mono"?t.editorFont:yn.editorFont,fontByExtension:tS(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:yn.density,defaultMode:t.defaultMode==="solo"||t.defaultMode==="tandem"?t.defaultMode:yn.defaultMode,highContrast:t.highContrast===!0,annotationPatterns:t.annotationPatterns===!0,selectionToolbar:t.selectionToolbar===!1?!1:yn.selectionToolbar,formattingBarVisible:t.formattingBarVisible===!1?!1:yn.formattingBarVisible,soloRailHidden:t.soloRailHidden===!1?!1:yn.soloRailHidden,degradedBannerDelayMs:typeof t.degradedBannerDelayMs=="number"&&t.degradedBannerDelayMs>=5e3&&t.degradedBannerDelayMs<=12e4?t.degradedBannerDelayMs:yn.degradedBannerDelayMs,sidecarRetryStrategy:t.sidecarRetryStrategy==="exponential"||t.sidecarRetryStrategy==="constant-2s"||t.sidecarRetryStrategy==="manual"?t.sidecarRetryStrategy:yn.sidecarRetryStrategy,holdAnnotationsWhileOffline:typeof t.holdAnnotationsWhileOffline=="boolean"?t.holdAnnotationsWhileOffline:yn.holdAnnotationsWhileOffline,marginView:t.marginView===!0,showComments:t.showComments===!1?!1:yn.showComments,showHighlights:t.showHighlights===!1?!1:yn.showHighlights,showNotes:t.showNotes===!1?!1:yn.showNotes,showRawMarkdown:t.showRawMarkdown===!1?!1:yn.showRawMarkdown,decorationsMuted:t.decorationsMuted===!0,models:eS(t.models),defaultModelId:typeof t.defaultModelId=="string"&&t.defaultModelId.length>0?t.defaultModelId:null,customShortcuts:Qb(t.customShortcuts)}}function mm(){let t;try{t=localStorage.getItem(CC)}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}),typeof e.schemaVersion=="number"&&e.schemaVersion>lh){console.warn(`[tandem] settings schemaVersion=${e.schemaVersion} is newer than v${lh}; loading defensively without writing.`);const r=e.editorMeasure,i=Pw(e);typeof r=="string"&&r!==i.editorMeasure&&console.warn(`[tandem] editorMeasure=${JSON.stringify(r)} from newer client is unknown to v${lh}; 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 Pw(e)}catch(e){console.warn("[tandem] settings JSON is corrupt, resetting to defaults:",e)}return{...yn,reduceMotion:$C()}}function DO(t,e){const n={...t,...e},r=eS(n.models);return{...n,customShortcuts:Qb(n.customShortcuts),fontByExtension:tS(n.fontByExtension),defaultSaveDirectory:typeof n.defaultSaveDirectory=="string"&&n.defaultSaveDirectory.trim()?n.defaultSaveDirectory.trim():null,selectionDwellMs:Math.max(uc,Math.min(dc,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):yn.accentHue,editorMeasure:XC(n.editorMeasure)?n.editorMeasure:yn.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 OO(t,e){var n;if(e){const r=(n=t.fontByExtension)==null?void 0:n[e];if(r)return r}return t.editorFont}const Qt=`http://127.0.0.1:${ji}`;function IO(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 RO(t){return t.toLowerCase().endsWith(".docx")}async function nS(t){if(RO(t.name)){const e=await t.arrayBuffer();return IO(e)}return t.text()}function NO(){try{return mm().defaultSaveDirectory}catch{return null}}async function PO(){var n,r;const t=new AbortController,e=setTimeout(()=>t.abort(),250);try{const i=await fetch(`${Qt}/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 LO(){try{const{homeDir:t}=await Kt(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 rS(){return NO()||await PO()||await LO()}function Wd(t,e,n=Date.now(),r=rD){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 Lw(t){return t.map(e=>e.path)}function FO(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 gc(){try{const t=localStorage.getItem(Gb);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 Kd(t){try{localStorage.setItem(Gb,JSON.stringify(t)),iS()}catch(e){console.warn("[tandem] failed to save recent files:",e)}}function zO(){try{localStorage.removeItem(Gb),iS()}catch(t){console.warn("[tandem] failed to clear recent files:",t)}}const BO=3e4;let hu=null;function Fw(){const t=Date.now();if(hu&&t-hu.ts<BO)return hu.files;const e=gc();return hu={files:e,ts:t},e}function iS(){hu=null}const oS=["editor","navigation","view","document","annotations","claude"];let ch=L(at(new Map));function HO(t,e={}){if(u(ch).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(ch,new Map(u(ch)).set(t.id,t),!0),!0}function Vh(){return u(ch)}let hv=null;function VO(t){hv=t}function en(t,e){if(!hv){console.warn(`[actions] "${t}" invoked before App mounted — deps not wired yet`);return}e(hv)}let pv=L(!1);const UO={get saving(){return u(pv)}};let gg=!1,vg=!1;const jO=400;function qO(t){return t.connected&&t.tabCount===0&&t.activeTabId===null}async function Uh(){if(!vg){vg=!0;try{const t=await fetch(`${Qt}${WD}`,{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{vg=!1}}}function sS(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}let bg=!1;async function WO(t){const e=await rS();if(!e)return t;try{const{join:n}=await Kt(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 KO(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 GO(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 zw(t){if(bg)return;const{activeDocId:e,notify:n,defaultName:r,sourceFormat:i}=t;if(!e){n("warning","No active document to save.");return}bg=!0;try{sS()?await ZO(e,n,r??"Scratchpad.md"):await YO(e,n,i)}finally{bg=!1}}async function ZO(t,e,n){var a,l;let r;try{const{save:c}=await Kt(async()=>{const{save:f}=await import("./index-Dm_QtxGQ.js");return{save:f}},__vite__mapDeps([2,1])),d=await WO(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=KO(r,o);s!==r&&e("info",`Saving as ${o.toUpperCase()} — only .md and .txt are supported.`);try{const c=await fetch(`${Qt}${Jb}`,{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;Kd(Wd(gc(),h)),e("info",`Saved to ${f}.`)}catch(c){e("error",`Save As request failed: ${c instanceof Error?c.message:c}`)}}async function YO(t,e,n){var i,o;const r=n==="txt"?"txt":"md";try{const s=await fetch(`${Qt}${Jb}`,{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}GO(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 mv(t){if(!(!t||gg)){gg=!0,b(pv,!0);try{const e=await fetch(`${Qt}${Jb}`,{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{gg=!1,b(pv,!1)}}}let Yu=!1;async function JO(){let t;try{t=await fetch(`${Qt}${UC}`)}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 XO(){let t;try{t=await fetch(`${Qt}${sO}`,{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 QO(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 aS(t,e,n,r){const i=await XO();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(`${Qt}${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 lS(t){if(Yu)return!1;const e=await JO();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 cS(t){if(!await lS(t))return;const e=QO(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.`)){Yu=!0;try{await aS(t,aO,{cwd:e},{failPrefix:"Relaunch failed",requestFailPrefix:"Relaunch request failed",successMessage:`Claude restarting in ${e}.`})}finally{Yu=!1}}}function $O(){en("launcher-relaunch-here",t=>void cS(t))}async function e5(t){if(await lS(t)&&confirm("Drop Claude's saved conversation and restart fresh. This cannot be undone.")){Yu=!0;try{await aS(t,lO,{},{failPrefix:"Start fresh failed",requestFailPrefix:"Start-fresh request failed",successMessage:"Claude restarting with a fresh conversation."})}finally{Yu=!1}}}let yg=!1;function wg(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}async function t5(t){var n;if(yg)return;const e=t.getActiveTabId();if(!e){t.notify("warning","No active document.");return}yg=!0;try{const r=await fetch(`${Qt}${JD}?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}. ${wg(d.timestamp)}`).join(`
7
- `);if(!confirm(`Available backups (newest first):
8
- ${a}
9
-
10
- Restore the most recent backup (${wg(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(`${Qt}${XD}`,{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 ${wg(s.timestamp)}.`)}catch(r){t.notify("error",`Restore request failed: ${r instanceof Error?r.message:r}`)}finally{yg=!1}}async function n5(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 Kt(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 r5=[{id:"save",label:"Save document",group:"document",shortcut:"Ctrl+S",run(){en("save",t=>void mv(t.getActiveTabId()))}},{id:"settings",label:"Open settings",group:"view",shortcut:"Ctrl+,",run(){en("settings",t=>t.openSettings())}},{id:"settings-modal",label:"Open settings (new)",group:"view",shortcut:"Ctrl+Shift+,",run(){en("settings-modal",t=>t.openSettingsModal())}},{id:"toggle-mode",label:"Toggle Solo / Tandem mode",group:"document",shortcut:"Ctrl+Shift+M",run(){en("toggle-mode",t=>t.toggleSoloMode())}},{id:"new-scratchpad",label:"New Scratchpad",group:"document",shortcut:"Ctrl+N",run(){Uh()}},{id:"save-as",label:"Save As…",group:"document",shortcut:"Ctrl+Shift+S",run(){en("save-as",t=>void t.saveAs())}},{id:"close-tab",label:"Close active tab",group:"document",shortcut:"Ctrl+W",run(){en("close-tab",t=>t.closeActiveTab())}},{id:"open-file",label:"Open file…",group:"document",shortcut:"Ctrl+O",run(){en("open-file",t=>t.openFileDialog())}},{id:"find",label:"Find / Replace",group:"navigation",shortcut:"Ctrl+F",run(){en("find",t=>t.openFindBar())}},{id:"find-in-tabs",label:"Find in open tabs",group:"navigation",shortcut:"Ctrl+Shift+F",run(){en("find-in-tabs",t=>t.openFindBarTabs())}},{id:"find-next",label:"Find next match",group:"navigation",shortcut:"Ctrl+G",run(){en("find-next",t=>t.findNext())}},{id:"find-previous",label:"Find previous match",group:"navigation",shortcut:"Ctrl+Shift+G",run(){en("find-previous",t=>t.findPrev())}},{id:"toggle-left-panel",label:"Toggle left panel",group:"view",shortcut:"Alt+Shift+Left",run(){en("toggle-left-panel",t=>t.toggleLeftPanel())}},{id:"toggle-right-panel",label:"Toggle right panel",group:"view",shortcut:"Alt+Shift+Right",run(){en("toggle-right-panel",t=>t.toggleRightPanel())}},{id:"reopen-closed-tab",label:"Reopen closed tab (this session)",group:"document",shortcut:"Ctrl+Alt+T",run(){en("reopen-closed-tab",t=>t.reopenClosedTab())}},{id:"annotation-next",label:"Next annotation",group:"annotations",shortcut:"Alt+]",run(){en("annotation-next",t=>t.annotationNext())}},{id:"annotation-previous",label:"Previous annotation",group:"annotations",shortcut:"Alt+[",run(){en("annotation-previous",t=>t.annotationPrev())}},{id:"annotation-accept",label:"Accept focused annotation",group:"annotations",shortcut:"Ctrl+Enter",run(){en("annotation-accept",t=>t.annotationAccept())}},{id:"annotation-dismiss",label:"Dismiss focused annotation",group:"annotations",shortcut:"Ctrl+Shift+Enter",run(){en("annotation-dismiss",t=>t.annotationDismiss())}},{id:"select-block",label:"Select containing block",group:"editor",shortcut:"Alt+L",run(){en("select-block",t=>t.selectBlock())}},{id:"toggle-authorship",label:"Toggle authorship colors",group:"view",shortcut:"Ctrl+Alt+A",run(){en("toggle-authorship",t=>t.toggleAuthorship())}},{id:"toggle-formatting-bar",label:"Toggle formatting bar",group:"view",run(){en("toggle-formatting-bar",t=>t.toggleFormattingBar())}},{id:"toggle-source-view",label:"Toggle markdown source view",group:"view",run(){en("toggle-source-view",t=>t.toggleSourceView())}},{id:"restore-backup",label:"Restore a backup of this document…",group:"document",run(){en("restore-backup",t=>void t5(t))}},{id:"launcher-relaunch-here",label:"Relaunch Claude in this folder",group:"claude",run(){en("launcher-relaunch-here",t=>void cS(t))}},{id:"launcher-start-fresh",label:"Start fresh Claude conversation",group:"claude",run(){en("launcher-start-fresh",t=>void e5(t))}},...sS()?[{id:"show-in-file-explorer",label:"Show in file explorer",group:"document",run(){en("show-in-file-explorer",t=>void n5(t))}}]:[]];for(const t of r5)HO(t);function Yt(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 uS(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 i5(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 o5=T('<button type="button" data-testid="activity-clear-all" class="svelte-bf7dij">Clear all</button>'),s5=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>'),a5=rn('<path class="svelte-bf7dij"></path>'),l5=T('<span class="badge svelte-bf7dij"> </span>'),c5=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>'),u5=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>'),d5=T("<div></div>"),f5=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>'),p5=T('<span class="svelte-bf7dij">Activity</span> <span class="count svelte-bf7dij"> </span>',1),m5=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 g5(t,e){et(e,!0);const n=N(()=>e.items.length),r=N(()=>e.items.some(_=>_.severity==="error")?"has-error":e.items.some(_=>_.severity==="warning")?"has-warning":e.items.some(_=>_.severity==="info")?"has-info":"idle");let i=L(at(Date.now()));const o=setInterval(()=>{b(i,Date.now(),!0)},3e4);let s=L(!1),a=!1,l;me(()=>{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=m5(),d=w(c);let f;var h=w(d),p=w(h);{var m=_=>{var S=f5(),A=w(S),O=k(w(A),2),E=w(O),M=k(O,4);{var R=z=>{var Q=o5();P("click",Q,function(...ie){var he;(he=e.onClear)==null||he.apply(this,ie)}),x(z,Q)};j(M,z=>{u(n)>0&&z(R)})}var D=k(A,2);{var I=z=>{var Q=s5();x(z,Q)},B=z=>{var Q=d5();let ie;pt(Q,21,()=>e.items,he=>he.id,(he,ae)=>{const ke=N(()=>uS(u(ae)));var le=u5(),be=w(le),Re=w(be);pt(Re,20,()=>dS[u(ae).severity],J=>J,(J,ye)=>{var Y=a5();W(()=>U(Y,"d",ye)),x(J,Y)});var $=k(be,2),q=w($),H=w(q),ne=w(H),te=k(H,2);{var Z=J=>{var ye=l5(),Y=w(ye);W(()=>G(Y,`×${u(ae).count??""}`)),x(J,ye)};j(te,J=>{u(ae).count>1&&J(Z)})}var ge=k(te,2),De=w(ge),Ee=k(q,2);{var de=J=>{var ye=c5(),Y=k(w(ye));W(()=>{U(ye,"data-testid",`activity-action-${u(ae).id}`),G(Y,` ${u(ke).label??""}`)}),P("click",ye,()=>e.onAction(u(ae))),x(J,ye)};j(Ee,J=>{u(ke)&&J(de)})}var _e=k($,2);W(J=>{vt(le,1,`toast-row ${u(ae).severity??""}`,"svelte-bf7dij"),U(le,"data-testid",`activity-row-${u(ae).id}`),G(ne,u(ae).message),G(De,J),U(_e,"data-testid",`activity-dismiss-${u(ae).id}`)},[()=>i5(u(ae).timestamp,u(i))]),P("click",_e,()=>e.onDismiss(u(ae).id)),x(he,le)}),W(()=>ie=vt(Q,1,"tray-list svelte-bf7dij",null,ie,{cascade:u(s)})),x(z,Q)};j(D,z=>{u(n)===0?z(I):z(B,-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=p5(),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=vt(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),tt()}ut(["click"]);function nr(t){this.content=t}nr.prototype={constructor:nr,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 nr(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 nr(n)},addToStart:function(t,e){return new nr([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new nr(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 nr(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=nr.from(t),t.size?new nr(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=nr.from(t),t.size?new nr(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=nr.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}};nr.from=function(t){if(t instanceof nr)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new nr(e)};function fS(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=fS(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function hS(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=hS(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 fS(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return hS(this,e,n,r)}findIndex(e){if(e==0)return kf(0,e);if(e==this.size)return kf(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?kf(n+1,o):kf(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 kg={index:0,offset:0};function kf(t,e){return kg.index=t,kg.offset=e,kg}function jh(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(!jh(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!jh(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Jt=class gv{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&&jh(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 gv.none;if(e instanceof gv)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Jt.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=mS(this.content,e+this.openStart,n);return r&&new Ge(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ge(pS(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 pS(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(pS(o.content,e-i-1,n-i-1)))}function mS(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=mS(s.content,e-o-1,n,s);return a&&t.replaceChild(i,s.copy(a))}function v5(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 gS(t,e,n,0)}function gS(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=gS(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 Na(s,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=b5(n,t);return Na(o,bS(t,s,a,e,r))}else return Na(o,Wh(t,e,r))}function vS(t,e){if(!e.type.compatibleContent(t.type))throw new qh("Cannot join "+e.type.name+" onto "+t.type.name)}function vv(t,e,n){let r=t.node(n);return vS(r,e.node(n)),r}function Ra(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 _u(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&&(Ra(t.nodeAfter,r),o++));for(let a=o;a<s;a++)Ra(i.child(a),r);e&&e.depth==n&&e.textOffset&&Ra(e.nodeBefore,r)}function Na(t,e){return t.type.checkContent(e),t.copy(e)}function bS(t,e,n,r,i){let o=t.depth>i&&vv(t,e,i+1),s=r.depth>i&&vv(n,r,i+1),a=[];return _u(null,t,i,a),o&&s&&e.index(i)==n.index(i)?(vS(o,s),Ra(Na(o,bS(t,e,n,r,i+1)),a)):(o&&Ra(Na(o,Wh(t,e,i+1)),a),_u(e,n,i,a),s&&Ra(Na(s,Wh(n,r,i+1)),a)),_u(r,null,i,a),new Ce(a)}function Wh(t,e,n){let r=[];if(_u(null,t,n,r),t.depth>n){let i=vv(t,e,n+1);Ra(Na(i,Wh(t,e,n+1)),r)}return _u(e,null,n,r),new Ce(r)}function b5(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 Ju{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 Jt.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 Kh(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 Ju(n,r,o)}static resolveCached(e,n){let r=Bw.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 Bw.set(e,r=new y5);let i=r.elts[r.i]=Ju.resolve(e,n);return r.i=(r.i+1)%w5,i}}class y5{constructor(){this.elts=[],this.i=0}}const w5=12,Bw=new WeakMap;class Kh{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 k5=Object.create(null);let Us=class bv{constructor(e,n,r,i=Jt.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&&jh(this.attrs,n||e.defaultAttrs||k5)&&Jt.sameSet(this.marks,r||Jt.none)}copy(e=null){return e==this.content?this:new bv(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new bv(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 v5(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 Ju.resolveCached(this,e)}resolveNoCache(e){return Ju.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()+")"),yS(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=Jt.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(!Jt.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}};Us.prototype.text=void 0;class Gh extends Us{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):yS(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 Gh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Gh(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 yS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class qa{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new x5(e,n);if(r.next==null)return qa.empty;let i=wS(r);r.next&&r.err("Unexpected trailing text");let o=M5(T5(i));return D5(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
- `)}}qa.empty=new qa(!0);class x5{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 wS(t){let e=[];do e.push(_5(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function _5(t){let e=[];do e.push(C5(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function C5(t){let e=A5(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=S5(t,e);else break;return e}function Hw(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function S5(t,e){let n=Hw(t),r=n;return t.eat(",")&&(t.next!="}"?r=Hw(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function E5(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 A5(t){if(t.eat("(")){let e=wS(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=E5(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 T5(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 kS(t,e){return e-t}function Vw(t,e){let n=[];return r(e),n.sort(kS);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 M5(t){let e=Object.create(null);return n(Vw(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]);Vw(t,l).forEach(d=>{c||i.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new qa(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(kS);o.next.push({type:i[s][0],next:e[a.join(",")]||n(a)})}return o}}function D5(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 xS(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 _S(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 CS(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 SS(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new I5(t,r,e[r]);return n}let Uw=class ES{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=SS(e,r.attrs),this.defaultAttrs=xS(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==qa.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:_S(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Us(this,this.computeAttrs(e),Ce.from(n),Jt.setFrom(r))}createChecked(e=null,n,r){return n=Ce.from(n),this.checkContent(n),new Us(this,this.computeAttrs(e),n,Jt.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 Us(this,e,n.append(o),Jt.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){CS(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:Jt.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new ES(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 O5(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 I5{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?O5(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class gm{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=SS(e,i.attrs),this.excluded=null;let o=xS(this.attrs);this.instance=o?new Jt(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Jt(this,_S(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new gm(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){CS(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let $b=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=nr.from(e.nodes),n.marks=nr.from(e.marks||{}),this.nodes=Uw.compile(this.spec.nodes,this),this.marks=gm.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]=qa.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?jw(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==""?[]:jw(this,s.split(" "))}this.nodeFromJSON=i=>Us.fromJSON(this,i),this.markFromJSON=i=>Jt.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 Uw){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 Gh(r,r.defaultAttrs,e,Jt.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 jw(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 R5(t){return t.tag!=null}function N5(t){return t.style!=null}let Cu=class yv{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(R5(i))this.tags.push(i);else if(N5(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 Ww(this,n,!1);return r.addAll(e,Jt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Ww(this,n,!0);return r.addAll(e,Jt.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(F5(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=Kw(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=Kw(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new yv(e,yv.schemaRules(e)))}};const AS={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},P5={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},TS={ol:!0,ul:!0},Xu=1,wv=2,Su=4;function qw(t,e,n){return e!=null?(e?Xu:0)|(e==="full"?wv:0):t&&t.whitespace=="pre"?Xu|wv:n&~Su}class xf{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=Jt.none,this.match=o||(s&Su?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&Xu)){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&&!AS.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ww{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=qw(null,n.preserveWhitespace,0)|(r?Su:0);i?o=new xf(i.type,i.attrs,Jt.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new xf(null,null,Jt.none,!0,null,s):o=new xf(e.schema.topNodeType,null,Jt.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&wv?"full":this.localPreserveWS||(i.options&Xu)>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;TS.hasOwnProperty(s)&&this.parser.normalizeLists&&L5(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:P5.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(AS.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=Jt.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):Gw(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=qw(e,o,s.options);s.options&Su&&s.content.length==0&&(a|=Su);let l=Jt.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Gw(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new xf(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|=Xu)}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 L5(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&TS.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function F5(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Kw(t){let e={};for(let n in t)e[n]=t[n];return e}function Gw(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 ol{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=xg(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}=uh(xg(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&&uh(xg(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return uh(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ol(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Zw(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Zw(e.marks)}}function Zw(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function xg(t){return t.document||window.document}const Yw=new WeakMap;function z5(t){let e=Yw.get(t);return e===void 0&&Yw.set(t,e=B5(t)),e}function B5(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 uh(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=z5(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}=uh(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 MS=65535,DS=Math.pow(2,16);function H5(t,e){return t+e*DS}function Jw(t){return t&MS}function V5(t){return(t-(t&MS))/DS}const OS=1,IS=2,dh=4,RS=8;class kv{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&RS)>0}get deletedBefore(){return(this.delInfo&(OS|dh))>0}get deletedAfter(){return(this.delInfo&(IS|dh))>0}get deletedAcross(){return(this.delInfo&dh)>0}}class ei{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ei.empty)return ei.empty}recover(e){let n=0,r=Jw(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+V5(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:H5(a/3,e-l),v=e==l?IS:e==f?OS:dh;return(n<0?e!=l:e!=f)&&(v|=RS),new kv(p,v,m)}i+=d-c}return r?e+i:new kv(e+i,0,null)}touches(e,n){let r=0,i=Jw(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 ei(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ei.empty:new ei(e<0?[0,-e,0]:[0,0,e])}}ei.empty=new ei([]);class Qu{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 Qu(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 Qu;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 kv(e,i,null)}}const _g=Object.create(null);class vr{getMap(){return ei.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=_g[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 _g)throw new RangeError("Duplicate use of step JSON ID "+e);return _g[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 e1(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(e1(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return Ce.fromArray(r)}class Ns extends vr{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(e1(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 uo(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 Ns(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ns&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ns(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 Ns(n.from,n.to,e.markFromJSON(n.mark))}}vr.jsonID("addMark",Ns);class uo extends vr{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(e1(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 Ns(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 uo(n.pos,r.pos,this.mark)}merge(e){return e instanceof uo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new uo(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 uo(n.from,n.to,e.markFromJSON(n.mark))}}vr.jsonID("removeMark",uo);class Ps extends vr{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 Ps(this.pos,n.marks[i]);return new Ps(this.pos,this.mark)}}return new Wa(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ps(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 Ps(n.pos,e.markFromJSON(n.mark))}}vr.jsonID("addNodeMark",Ps);class Wa extends vr{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 Ps(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Wa(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 Wa(n.pos,e.markFromJSON(n.mark))}}vr.jsonID("removeNodeMark",Wa);class Wn extends vr{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&xv(e,this.from,this.to)?On.fail("Structure replace would overwrite content"):On.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ei([this.from,this.to-this.from,this.slice.size])}invert(e){return new Wn(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 Wn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Wn)||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 Wn(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 Wn(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 Wn(n.from,n.to,Ge.fromJSON(e,n.slice),!!n.structure)}}vr.jsonID("replace",Wn);class Yn extends vr{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&&(xv(e,this.from,this.gapFrom)||xv(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 ei([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 Yn(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 Yn(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 Yn(n.from,n.to,n.gapFrom,n.gapTo,Ge.fromJSON(e,n.slice),n.insert,!!n.structure)}}vr.jsonID("replaceAround",Yn);function xv(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 U5(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 uo(h,p,f[v])));a&&a.to==h?a.to=p:o.push(a=new Ns(h,p,r))}}),i.forEach(l=>t.step(l)),o.forEach(l=>t.step(l))}function j5(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 gm){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 uo(s.from,s.to,s.style)))}function t1(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 Wn(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 uo(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 Wn(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 q5(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Fc(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||!q5(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function W5(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 Yn(l,c,s,a,new Ge(d.append(h),f,p),d.size-f,!0))}function n1(t,e,n=null,r=t){let i=K5(t,e),o=i&&G5(r,e);return o?i.map(Xw).concat({type:e,attrs:n}).concat(o.map(Xw)):null}function Xw(t){return{type:t,attrs:null}}function K5(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 G5(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 Z5(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 Yn(i,o,i,o,new Ge(r,0,0),n.length,!0))}function Y5(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)&&J5(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&&PS(t,s,a,o),t1(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 Yn(f,h,f+1,h-1,new Ge(Ce.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&NS(t,s,a,o),!1}})}function NS(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 PS(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 J5(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function X5(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 Yn(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new Ge(Ce.from(s),0,0),1,!0))}function Zo(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 Q5(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 Wn(e,e,new Ge(o.append(s),n,n),!0))}function ra(t,e){let n=t.resolve(e),r=n.index();return LS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function $5(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 LS(t,e){return!!(t&&e&&!t.isLeaf&&$5(t,e))}function vm(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&&LS(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 eI(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);PS(t,d.node(),d.before(),a)}s.inlineContent&&t1(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 Wn(c,l.map(e+n,-1),Ge.empty,!0)),r===!0){let d=t.doc.resolve(c);NS(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 FS(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 bm(t,e,n=e,r=Ge.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return zS(i,o,r)?new Wn(e,n,r):new nI(i,o,r).fit()}function zS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class nI{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 Yn(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Wn(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=Cg(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=Cg(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=Cg(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new Ge(pu(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new Ge(pu(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(BS(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=mu(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(pu(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new Ge(pu(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||!Sg(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=Sg(e,n,i,r,o);if(s){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=Sg(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=mu(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=mu(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=mu(this.placed,this.frontier.length,n))}}function pu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(pu(t.firstChild.content,e-1,n)))}function mu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(mu(t.lastChild.content,e-1,n)))}function Cg(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function BS(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,BS(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 Sg(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&&!rI(n,o.content,s)?a:null}function rI(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function iI(t){return t.spec.defining||t.spec.definingForContent}function oI(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(zS(i,o,r))return t.step(new Wn(e,n,r));let s=VS(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=iI(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(HS(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 HS(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(HS(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 sI(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 aI(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=VS(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 VS(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 zl extends vr{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 ei.empty}invert(e){return new zl(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 zl(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 zl(n.pos,n.attr,n.value)}}vr.jsonID("attr",zl);class $u extends vr{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 ei.empty}invert(e){return new $u(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 $u(n.attr,n.value)}}vr.jsonID("docAttr",$u);let vc=class extends Error{};vc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};vc.prototype=Object.create(Error.prototype);vc.prototype.constructor=vc;vc.prototype.name="TransformError";class r1{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Qu}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new vc(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=bm(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 oI(this,e,n,r),this}replaceRangeWith(e,n,r){return sI(this,e,n,r),this}deleteRange(e,n){return aI(this,e,n),this}lift(e,n){return W5(this,e,n),this}join(e,n=1){return eI(this,e,n),this}wrap(e,n){return Z5(this,e,n),this}setBlockType(e,n=e,r,i=null){return Y5(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return X5(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new zl(e,n,r)),this}setDocAttribute(e,n){return this.step(new $u(e,n)),this}addNodeMark(e,n){return this.step(new Ps(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 Jt)n.isInSet(r.marks)&&this.step(new Wa(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Wa(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 Q5(this,e,n,r),this}addMark(e,n,r){return U5(this,e,n,r),this}removeMark(e,n,r){return j5(this,e,n,r),this}clearIncompatible(e,n,r){return t1(this,e,n,r),this}}const Eg=Object.create(null);class mt{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new US(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&&ek(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),ek(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new dt(e):El(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?El(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):El(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 Hr(e.node(0))}static atStart(e){return El(e,e,0,0,1)||new Hr(e)}static atEnd(e){return El(e,e,e.content.size,e.childCount,-1)||new Hr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Eg[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 Eg)throw new RangeError("Duplicate use of selection JSON ID "+e);return Eg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return dt.between(this.$anchor,this.$head).getBookmark()}}mt.prototype.visible=!0;class US{constructor(e,n){this.$from=e,this.$to=n}}let Qw=!1;function $w(t){!Qw&&!t.parent.inlineContent&&(Qw=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class dt extends mt{constructor(e,n=e){$w(e),$w(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 mt.near(r);let i=e.resolve(n.map(this.anchor));return new dt(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 dt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ym(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 dt(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=mt.findFrom(n,r,!0)||mt.findFrom(n,-r,!0);if(o)n=o.$head;else return mt.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(mt.findFrom(e,-r,!0)||mt.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new dt(e,n)}}mt.jsonID("text",dt);class ym{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ym(e.map(this.anchor),e.map(this.head))}resolve(e){return dt.between(e.resolve(this.anchor),e.resolve(this.head))}}class ft extends mt{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?mt.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 i1(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;mt.jsonID("node",ft);class i1{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ym(r,r):new i1(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ft.isSelectable(r)?new ft(n):mt.near(n)}}class Hr extends mt{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=mt.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Hr(e)}map(e){return new Hr(e)}eq(e){return e instanceof Hr}getBookmark(){return lI}}mt.jsonID("all",Hr);const lI={map(){return this},resolve(t){return new Hr(t)}};function El(t,e,n,r,i,o=!1){if(e.inlineContent)return dt.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=El(t,a,n+i,i<0?a.childCount:0,i,o);if(l)return l}n+=a.nodeSize*i}return null}function ek(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Wn||i instanceof Yn))return;let o=t.mapping.maps[r],s;o.forEach((a,l,c,d)=>{s==null&&(s=d)}),t.setSelection(mt.near(t.doc.resolve(s),n))}const tk=1,_f=2,nk=4;let cI=class extends r1{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|tk)&~_f,this.storedMarks=null,this}get selectionSet(){return(this.updated&tk)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=_f,this}ensureMarks(e){return Jt.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&_f)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~_f,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)||Jt.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(mt.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|=nk,this}get scrolledIntoView(){return(this.updated&nk)>0}};function rk(t,e){return!e||!t?t:t.bind(e)}class gu{constructor(e,n,r){this.name=e,this.init=rk(n.init,r),this.apply=rk(n.apply,r)}}const uI=[new gu("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new gu("selection",{init(t,e){return t.selection||mt.atStart(e.doc)},apply(t){return t.selection}}),new gu("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new gu("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Ag{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=uI.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 gu(r.key,r.spec.state,r))})}}class Il{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 Il(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 cI(this)}static create(e){let n=new Ag(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Il(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 Ag(this.schema,e.plugins),r=n.fields,i=new Il(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 Ag(e.schema,e.plugins),o=new Il(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Us.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=mt.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 jS(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=jS(i,e,{})),n[r]=i}return n}class Ht{constructor(e){this.spec=e,this.props={},e.props&&jS(e.props,this,this.props),this.key=e.key?e.key.key:qS("plugin")}getState(e){return e[this.key]}}const Tg=Object.create(null);function qS(t){return t in Tg?t+"$"+ ++Tg[t]:(Tg[t]=0,t+"$")}class Gt{constructor(e="key"){this.key=qS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Zh=[{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 _v(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 dI=T('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>'),fI=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>'),pI=T('<span style="font-size: var(--tandem-text-sm);"> </span> <!>',1),mI=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>`),gI=T('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>'),vI=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),bI=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),yI=T('<li role="option"><!></li>'),wI=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 kI(t,e){et(e,!0);let n=Ye(e,"editor",3,null),r=Ye(e,"annotations",19,()=>[]),i=L(""),o=L(0),s=L(null);const a=["#","@","?",">"],l=N(()=>a.find(M=>u(i).startsWith(M))??null),c=N(()=>(u(l)?u(i).slice(1):u(i)).trim().toLowerCase()),d=N(()=>{var I;if(u(l)!==null&&u(l)!==">")return[];const M=Vh(),R=u(c),D=[];for(const B of M.values())(!R||B.label.toLowerCase().includes(R)||B.group.toLowerCase().includes(R)||(((I=B.shortcut)==null?void 0:I.toLowerCase().includes(R))??!1))&&D.push({kind:"action",id:B.id,action:B});return D}),f=N(()=>{if(u(l)!=="#")return[];const M=n();if(!M||M.isDestroyed)return[];const R=u(c);return _v(M).filter(D=>!R||D.text.toLowerCase().includes(R)).map((D,I)=>({kind:"heading",id:`heading-${I}`,...D}))}),h=N(()=>{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=N(()=>{if(u(l)!=="?")return[];const M=u(c),R=Vh(),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<Zh.length;I++){const B=Zh[I];(!M||B.description.toLowerCase().includes(M)||B.keys.toLowerCase().includes(M))&&D.push({kind:"shortcut",id:`shortcut-static-${I}`,keys:B.keys,description:B.description,group:"other"})}return D}),m=N(()=>[...u(d),...u(f),...u(h),...u(p)]);me(()=>{u(m),b(o,0)}),me(()=>{e.open&&(b(i,""),b(o,0),Promise.resolve().then(()=>{var M;return(M=u(s))==null?void 0:M.focus()}))}),Lc(()=>{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=N(()=>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 B=D.state.doc.resolve(I+1),z=dt.near(B);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=wI(),D=w(R),I=w(D),B=w(I),z=k(w(B),2);Ot(z,be=>b(s,be),()=>u(s));var Q=k(B,2);{var ie=be=>{var Re=dI(),$=w(Re);{var q=Ee=>{var de=dr("Searching document headings");x(Ee,de)};j($,Ee=>{u(l)==="#"&&Ee(q)})}var H=k($,2);{var ne=Ee=>{var de=dr("Searching annotations");x(Ee,de)};j(H,Ee=>{u(l)==="@"&&Ee(ne)})}var te=k(H,2);{var Z=Ee=>{var de=dr("Showing keyboard shortcuts");x(Ee,de)};j(te,Ee=>{u(l)==="?"&&Ee(Z)})}var ge=k(te,2);{var De=Ee=>{var de=dr("Filtering commands");x(Ee,de)};j(ge,Ee=>{u(l)===">"&&Ee(De)})}x(be,Re)};j(Q,be=>{u(l)&&be(ie)})}var he=k(I,2),ae=w(he);{var ke=be=>{var Re=fI(),$=w(Re);W(()=>G($,u(l)==="#"?"No headings found":u(l)==="@"?"No annotations found":u(l)==="?"?"No shortcuts found":"No commands match")),x(be,Re)},le=be=>{var Re=St(),$=Ae(Re);pt($,19,()=>u(m),q=>q.id,(q,H,ne)=>{const te=N(()=>u(ne)===u(o));var Z=yI(),ge=w(Z);{var De=J=>{var ye=pI(),Y=Ae(ye),se=w(Y),Te=k(Y,2);{var Oe=ze=>{var Xe=hI(),ue=w(Xe);W(()=>G(ue,u(H).action.shortcut)),x(ze,Xe)};j(Te,ze=>{u(H).action.shortcut&&ze(Oe)})}W(()=>G(se,u(H).action.label)),x(J,ye)},Ee=J=>{var ye=mI(),Y=w(ye),se=w(Y),Te=k(Y,2),Oe=w(Te);W(()=>{G(se,`H${u(H).level??""}`),Le(Te,`font-size: var(--tandem-text-sm); padding-left: calc(${u(H).level-1} * var(--tandem-space-2));`),G(Oe,u(H).text)}),x(J,ye)},de=J=>{var ye=vI(),Y=Ae(ye),se=w(Y),Te=w(se),Oe=k(se,2);{var ze=re=>{var pe=gI(),Ne=w(pe);W(()=>G(Ne,`"${u(H).snippet??""}"`)),x(re,pe)};j(Oe,re=>{u(H).snippet&&re(ze)})}var Xe=k(Y,2),ue=w(Xe);W(re=>{G(Te,u(H).label),G(ue,re)},[()=>u(H).annotationType.charAt(0).toUpperCase()+u(H).annotationType.slice(1)]),x(J,ye)},_e=J=>{var ye=bI(),Y=Ae(ye),se=w(Y),Te=k(Y,2),Oe=w(Te);W(()=>{G(se,u(H).description),G(Oe,u(H).keys)}),x(J,ye)};j(ge,J=>{u(H).kind==="action"?J(De):u(H).kind==="heading"?J(Ee,1):u(H).kind==="annotation"?J(de,2):u(H).kind==="shortcut"&&J(_e,3)})}W(()=>{U(Z,"id",`palette-item-${u(H).id}`),U(Z,"data-testid",`palette-item-${u(H).id}`),U(Z,"aria-selected",u(te)),Le(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(H).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(H))),hn("mouseenter",Z,()=>b(o,u(ne),!0)),x(q,Z)}),x(be,Re)};j(ae,be=>{u(m).length===0?be(ke):be(le,-1)})}Ur(he,(be,Re)=>Yt==null?void 0:Yt(be,Re),()=>"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,be=>{be.key==="Escape"&&y()}),P("keydown",D,_),zr(z,()=>u(i),be=>b(i,be)),x(M,R)};j(O,M=>{e.open&&M(E)})}x(t,A),tt()}ut(["click","keydown"]);var xI=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 _I(t,e){var n=xI(),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)}ut(["click"]);function CI(t){return t?t.osSupported?t.coworkDetected?"normal":"undetected":"unsupported":"loading"}function SI(t){switch(t.kind){case"adminDeclined":return"Admin permission was denied. Retry with admin, or disable Cowork integration.";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: ${EI(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 EI(t){const e=t.trim();return e.length===0?"(no output)":e.length<=200?e:`${e.slice(0,197)}...`}function o1(t){try{const e=JSON.parse(t);if(typeof e=="object"&&e!==null&&"kind"in e&&typeof e.kind=="string")try{return SI(e)}catch(n){return console.error("[cowork] firewallErrorHint failed for:",e,n),t}return t}catch{return t}}function ure(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"}}function dre(t){switch(t){case"ok":case"alreadyPresent":return"success";case"locked":return"warning";case"schemaDrift":case"insecureAcl":case"failed":return"error"}}function fre(t){const e=["failed","schemaDrift","insecureAcl","locked","alreadyPresent","ok"],n=[t.installedPlugins,t.knownMarketplaces,t.coworkSettings];for(const r of e)if(n.includes(r))return r;return"ok"}function WS(t,e){return!(!t||e||!t.osSupported||!t.coworkDetected||t.enabled)}function KS(){try{return localStorage.getItem(PC)==="true"}catch{return!1}}function AI(){try{localStorage.setItem(PC,"true")}catch{}}function Tt(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}function hre(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 GS="Tauri runtime not available";async function ss(){try{return(await Kt(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Tt()&&console.error("[cowork] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(GS)))}}function TI(t){return t("cowork_get_status")}function s1(t,e){return t("cowork_toggle_integration",{enabled:e})}function pre(t){return t("cowork_rescan")}function mre(t,e){return t("cowork_set_lan_ip_override",{enabled:e})}function MI(t){return t("cowork_retry_admin_elevation")}function a1(t){let e=L(null),n=L(!1),r=L(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 TI(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===GS){o=!0,a!==null&&(clearInterval(a),a=null),b(n,!1);return}b(r,f,!0)}finally{s&&b(n,!1)}};return me(()=>{if(!t()){b(n,!1);return}let d=!1;return ss().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()},aD),()=>{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 DI=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>`),OI=T('<div class="cad-error svelte-cbdwov" data-testid="cowork-admin-declined-error" role="alert"> </div>'),II=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>'),RI=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>'),NI=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 PI(t,e){et(e,!0);const n='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',r=a1(()=>!0),i=N(()=>{var g;return((g=r.status)==null?void 0:g.uacDeclined)===!0});let o=L(void 0),s=L(!1),a=L(!1),l=L(null);me(()=>{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)}}),me(()=>{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)}),me(()=>{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 ss();await g(C)}catch(C){const _=C instanceof Error?C.message:String(C),S=o1(_);b(l,`${y}: ${S}`)}finally{b(a,!1)}}async function d(){await c(async g=>{await MI(g),await r.refetch()},"Retry failed")}async function f(){await c(async g=>{await s1(g,!1),await r.refetch()},"Failed to disable Cowork"),b(s,!1)}var h=St(),p=Ae(h);{var m=g=>{var y=DI();x(g,y)},v=g=>{var y=NI(),C=w(y);U(C,"tabindex",-1);var _=k(w(C),4);{var S=M=>{var R=OI(),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=II(),D=k(w(R),4),I=w(D),B=k(I,2);W(()=>{I.disabled=u(a),B.disabled=u(a)}),P("click",I,()=>void f()),P("click",B,()=>{b(s,!1)}),x(M,R)},E=M=>{var R=RI(),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)})}Ot(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),tt()}ut(["click"]);var LI=T('<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>'),FI=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 zI(t,e){et(e,!0);let n=L(null),r=L(null),i=L(null);me(()=>{const d=e.ydoc.getMap(Rh),f=()=>{b(n,d.get(hw)??null,!0)};f();const h=p=>{p.keysChanged.has(hw)&&f()};return d.observe(h),()=>{d.unobserve(h),b(n,null),b(i,null),b(r,null)}});const o=N(()=>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(`${Qt}${QD}`,{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=FI(),h=w(f),p=w(h),m=k(h,2);{var v=S=>{var A=LI(),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),tt()}ut(["click"]);var BI=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),HI=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),VI=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),UI=T('<p class="empty-sub empty-sub-secondary svelte-16uow3k">Tandem works alongside Claude (the default integration) or any MCP-capable AI client.</p>'),jI=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),qI=T('<div class="empty-state svelte-16uow3k"><!></div>');function WI(t,e){et(e,!0);let n=Ye(e,"aiChip",3,null),r=L(!1);me(()=>{if(e.connected){b(r,!1);return}const l=setTimeout(()=>{b(r,!0)},JM);return()=>clearTimeout(l)});var i=qI(),o=w(i);{var s=l=>{var c=BI(),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=jI(),d=k(Ae(c),6),f=w(d),h=k(d,2);{var p=g=>{var y=HI(),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=VI(),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=UI();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),tt()}ut(["click"]);async function ls(t,e={}){const{readOnly:n=!1,notFoundMessage:r="File not found.",failureMessage:i="Failed to open file."}=e;try{const o=await fetch(`${Qt}${UD}`,{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 KI=Array.from(qd).sort().map(t=>t.replace(/^\./,""));async function ZS(){const{open:t}=await Kt(async()=>{const{open:r}=await import("./index-Dm_QtxGQ.js");return{open:r}},__vite__mapDeps([2,1])),e=await rS()??void 0,n=await t({multiple:!1,directory:!1,title:"Open file in Tandem",defaultPath:e,filters:[{name:"Documents",extensions:KI}]});return typeof n=="string"?n:null}async function GI(t={}){var r,i;let e;try{e=await ZS()}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 ls(e);if(!n.ok){(i=t.onError)==null||i.call(t,n.error);return}Kd(Wd(gc(),e))}async function ZI(t){t.isTauri?await GI({onError:t.onError}):t.openModal()}async function YS(t,e){try{const n=await fetch(`${Qt}${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 YI(){var t;try{const e=await fetch(`${Qt}${rO}`),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 JI(t){return YS(iO,{filePath:t})}async function XI(){return YS(oO,{})}var QI=T('<input type="file" style="display: none;"/>'),$I=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>'),e8=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>'),t8=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>'),n8=T('<p data-testid="sessions-loading" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">Loading…</p>'),r8=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>'),o8=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),s8=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>'),a8=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>'),c8=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 u8(t,e){et(e,!0);let n=L(null),r=L(!1),i=L(void 0),o=L(at(Lw(gc()))),s=L(at([])),a=L(!1),l=L(!1),c=L(!1),d=L(null);async function f(){b(l,!0),b(d,null);const de=await YI();de.ok?(b(s,de.data,!0),b(c,!0)):b(d,de.error,!0),b(l,!1)}function h(){b(a,!u(a)),u(a)&&!u(c)&&!u(l)&&f()}async function p(de){b(d,null);const _e=await JI(de);_e.ok?b(s,u(s).filter(J=>J.filePath!==de),!0):b(d,_e.error,!0)}async function m(){b(d,null);const de=await XI();de.ok?b(s,[],!0):b(d,de.error,!0)}function v(de){if(!de)return"unknown";const _e=Date.now()-de,J=Math.floor(_e/6e4);if(J<1)return"just now";if(J<60)return`${J}m ago`;const ye=Math.floor(J/60);return ye<24?`${ye}h ago`:`${Math.floor(ye/24)}d ago`}const y=Array.from(qd).sort().join(",");function C(de){const _e=Wd(gc(),de);Kd(_e),b(o,Lw(_e),!0)}function _(){zO(),b(o,[],!0)}async function S(de){if(!u(r)){b(n,null),b(r,!0);try{const _e=await ls(de);if(!_e.ok){b(n,_e.error,!0);return}C(de),e.onClose()}finally{b(r,!1)}}}async function A(){if(!u(r))try{const de=await ZS();de&&await S(de)}catch(de){b(n,`File picker unavailable: ${de instanceof Error?de.message:de}`)}}async function O(de){if(!u(r)){b(n,null),b(r,!0);try{const _e=await nS(de),J=await fetch(`${Qt}${VC}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:de.name,content:_e})}),ye=await J.json();if(!J.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(de){var ye;const J=(ye=de.target.files)==null?void 0:ye[0];J&&O(J)}function M(){var de;Tt()?A():(de=u(i))==null||de.click()}var R=c8();U(R,"tabindex",-1);var D=w(R),I=w(D),B=k(w(I),2),z=k(I,2);nM(z);var Q=w(z),ie=k(z,2);{var he=de=>{var _e=QI();Ot(_e,J=>b(i,J),()=>u(i)),W(()=>U(_e,"accept",y)),P("change",_e,E),x(de,_e)},ae=N(()=>!Tt());j(ie,de=>{u(ae)&&de(he)})}var ke=k(ie,2);{var le=de=>{var _e=$I();x(de,_e)},be=N(()=>Tt());j(ke,de=>{u(be)&&de(le)})}var Re=k(ke,2);{var $=de=>{var _e=t8(),J=w(_e),ye=k(w(J),2),Y=k(J,2);pt(Y,22,()=>u(o),se=>se,(se,Te,Oe)=>{const ze=N(()=>Te.split(/[/\\]/)),Xe=N(()=>u(ze).at(-1)??Te),ue=N(()=>u(ze).slice(0,-1).join("/")||"/");var re=e8(),pe=w(re),Ne=w(pe),xe=k(pe,2),Me=w(xe);W(()=>{U(re,"data-testid",`recent-file-${u(Oe)}`),G(Ne,u(Xe)),G(Me,u(ue))}),P("click",re,()=>S(Te)),hn("mouseenter",re,Se=>{Se.currentTarget.style.background="var(--tandem-surface-muted)"}),hn("mouseleave",re,Se=>{Se.currentTarget.style.background="transparent"}),x(se,re)}),Ur(Y,(se,Te)=>Yt==null?void 0:Yt(se,Te),()=>"y"),P("click",ye,_),x(de,_e)};j(Re,de=>{u(o).length>0&&de($)})}var q=k(Re,2),H=w(q),ne=k(w(H),2),te=w(ne),Z=k(H,2);{var ge=de=>{var _e=a8(),J=Ae(_e);{var ye=ze=>{var Xe=n8();x(ze,Xe)},Y=ze=>{var Xe=r8();x(ze,Xe)},se=ze=>{var Xe=o8(),ue=Ae(Xe),re=w(ue),pe=k(ue,2);pt(pe,21,()=>u(s),Ne=>Ne.filePath,(Ne,xe)=>{const Me=N(()=>u(xe).filePath.split(/[/\\]/)),Se=N(()=>u(Me).at(-1)??u(xe).filePath),qe=N(()=>u(Me).slice(0,-1).join("/")||"/");var it=i8(),ce=w(it),Ie=w(ce),V=w(Ie),ee=k(Ie,2),we=w(ee),Ve=k(ee,2),Fe=w(Ve),K=k(ce,2);W(fe=>{U(ce,"title",u(xe).filePath),G(V,u(Se)),G(we,u(qe)),G(Fe,`${fe??""} · ${u(xe).annotationCount??""} annotation${u(xe).annotationCount===1?"":"s"}`),U(K,"aria-label",`Delete session for ${u(Se)}`)},[()=>v(u(xe).lastAccessed)]),P("click",ce,()=>S(u(xe).filePath)),P("click",K,()=>p(u(xe).filePath)),x(Ne,it)}),Ur(pe,(Ne,xe)=>Yt==null?void 0:Yt(Ne,xe),()=>"y"),P("click",re,m),x(ze,Xe)};j(J,ze=>{u(l)?ze(ye):u(s).length===0?ze(Y,1):ze(se,-1)})}var Te=k(J,2);{var Oe=ze=>{var Xe=s8(),ue=w(Xe);W(()=>G(ue,u(d))),x(ze,Xe)};j(Te,ze=>{u(d)&&ze(Oe)})}x(de,_e)};j(Z,de=>{u(a)&&de(ge)})}var De=k(q,2);{var Ee=de=>{var _e=l8(),J=w(_e);W(()=>G(J,u(n))),x(de,_e)};j(De,de=>{u(n)&&de(Ee)})}W(()=>{z.disabled=u(r),Le(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(H,"aria-expanded",u(a)),G(te,u(a)?"▾":"▸")}),P("click",R,de=>{de.target===de.currentTarget&&e.onClose()}),P("keydown",R,de=>{de.key==="Escape"&&e.onClose()}),P("click",B,function(...de){var _e;(_e=e.onClose)==null||_e.apply(this,de)}),P("click",z,M),P("click",H,h),x(t,R),tt()}ut(["click","keydown","change"]);var d8=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),f8=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>'),h8=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),p8=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 m8(t,e){et(e,!0);const n=N(()=>{const l=Vh(),c=e.effectiveShortcutLabels,d=new Map;for(const f of l.values()){if(!f.shortcut)continue;const h=WC[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 oS.map(f=>({title:f.charAt(0).toUpperCase()+f.slice(1),rows:d.get(f)??[]})).filter(f=>f.rows.length>0)});let r=L(null),i=null;me(()=>{if(!e.open)return;const l=Mt(()=>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()}}),me(()=>{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=p8(),d=w(c),f=w(d),h=k(w(f),2),p=k(f,2);pt(p,17,()=>u(n),g=>g.title,(g,y)=>{var C=f8(),_=w(C),S=w(_),A=k(_,2);pt(A,21,()=>u(y).rows,O=>O.description,(O,E)=>{var M=d8(),R=Ae(M),D=w(R),I=w(D),B=k(R,2),z=w(B);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);pt(v,21,()=>Zh,g=>g.description,(g,y)=>{var C=h8(),_=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)}),Ot(d,g=>b(r,g),()=>u(r)),Ur(d,(g,y)=>Yt==null?void 0:Yt(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),tt()}ut(["click","keydown"]);const g8="/api/integrations/existing",v8="/api/integrations",b8="/api/integrations/apply",y8="/api/integrations/first-run-needed";function w8(t){return`/api/integrations/secrets/${encodeURIComponent(t)}`}function k8(t){return`/api/models/secrets/${encodeURIComponent(t)}`}const x8=3,_8="KEYCHAIN_UNAVAILABLE",C8="/api/integrations/claude-cli-status",S8="/api/integrations/install-claude-code";function E8(t,e="",n=globalThis.fetch.bind(globalThis)){let r=L(null),i=L(!1),o=L(null),s=L(!1),a=L(null),l=!0;Dn(()=>{l=!1});const c=async h=>{try{const p=await n(`${e}${C8}`);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}${S8}`,{method:"POST"});if(!l)return null;if(!h.ok){const m=await h.json().catch(()=>null);return l&&b(a,A8(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 me(()=>{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 A8(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 T8="Tauri runtime not available";async function M8(){try{return(await Kt(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Tt()&&console.error("[keychain] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(T8)))}}function D8(t,e,n){return t("keychain_set",{account:e,secret:n})}function O8(t,e){return t("keychain_delete",{account:e})}function I8(t={}){const e=t.fetchFn??((...i)=>globalThis.fetch(...i)),n=t.baseUrl??"",r=t.pathFor??w8;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)===_8)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 R8=["keychain-init","Platform secure storage failure","Couldn't access platform secure storage"];function N8(t){return R8.some(e=>t.includes(e))}function P8(t={}){const e=()=>t.invoke?Promise.resolve(t.invoke):M8();return{async set(n,r){try{const i=await e();return await D8(i,n,r),{status:"ok"}}catch(i){const o=i instanceof Error?i.message:String(i);return N8(o)?{status:"unavailable"}:{status:"error",message:o}}},async delete(n){try{const r=await e();await O8(r,n)}catch{}}}}function JS(t={}){return t.force==="tauri"||t.force!=="http"&&Tt()?P8({invoke:t.invoke}):I8({fetchFn:t.fetchFn,baseUrl:t.baseUrl,pathFor:t.pathFor})}function l1(t){return t.tandemValidation!==void 0&&t.tandemValidation.status!=="valid"}function XS(t){return(t.status==="ok"||t.status==="missing")&&!l1(t)}function L8(t){const e=crypto.randomUUID().replace(/-/g,"").slice(0,12);return`${t}-${e}`}function ik(t){return`${t}-${crypto.randomUUID().slice(0,8)}`}function QS(t){var e;if(t.target.kind==="claude-code"){const n=((e=t.tandemEntry)==null?void 0:e.url)??`http://127.0.0.1:${ji}`,r=ik("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=ik("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 F8(t={}){const e=t.fetchFn??globalThis.fetch.bind(globalThis),n=t.baseUrl??"",r=t.keychainBackend??JS({fetchFn:e,baseUrl:n});let i=L("connect"),o=L(!0),s=L(at([])),a=L(at([])),l=L(null),c=L(at([])),d=L(!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}${g8}`);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(XS).map(QS).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=L8(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&&l1(R);return{...E.config,apply:D?"skip":"create"}}),A={schemaVersion:x8,integrations:S};let O=!1;try{const E=await e(`${n}${v8}`,{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}${b8}`,{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 z8=rn('<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>'),B8=rn('<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>'),H8=rn('<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>'),V8=T('<span class="itc-check-empty svelte-q7klwd"></span>'),U8=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 j8(t,e){et(e,!0);const n=N(()=>XS(e.install)),r=N(()=>e.install.target.configPath.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()),i=N(()=>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?l1(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=U8();let s;var a=w(o),l=k(a,2),c=w(l);{var d=O=>{var E=z8();x(O,E)},f=O=>{var E=B8();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 B=H8();x(I,B)},D=I=>{var B=V8();x(I,B)};j(M,I=>{e.selected?I(R):I(D,-1)})}x(O,E)};j(S,O=>{u(n)&&O(A)})}W(()=>{s=vt(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)??""}`),Kn(a,e.selected),a.disabled=!u(n),U(a,"data-testid",`integration-wizard-pick-${u(r)??""}`),G(m,e.install.target.label),vt(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),tt()}ut(["change"]);const ml=(t,e=kn)=>{var n=q8();W(()=>vt(n,0,Ih(e()),"svelte-bt94ms")),x(t,n)},tu=t=>{var e=W8();x(t,e)},ok=t=>{var e=K8();x(t,e)},sk=(t,e=kn)=>{var n=G8(),r=k(w(n));W(()=>G(r,` ${e()??""}`)),x(t,n)};var q8=rn('<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>'),W8=rn('<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>'),K8=rn('<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>'),G8=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>'),Z8=T('<p class="iw-subtitle svelte-bt94ms">Connect your AI assistant.</p>'),Y8=T(`<p class="iw-subtitle svelte-bt94ms">Let a teammate's Claude join from the Cowork VM.</p>`),J8=T(`<div class="iw-whats-next svelte-bt94ms"><!> <span class="svelte-bt94ms">Cowork is enabled and a token is provisioned. Manage workspaces in
59
- Settings&nbsp;→&nbsp;Network.</span></div>`),X8=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>'),Q8=T('<p class="iw-hint-text svelte-bt94ms">Admin permission was declined earlier — enabling will prompt again.</p>'),$8=T(`<div class="iw-banner-warning svelte-bt94ms"><!> <span class="svelte-bt94ms">Windows will ask for admin permission to update firewall rules — this is
60
- expected. Tandem writes plugin entries to every detected Cowork workspace so a
61
- teammate's Claude can reach the documents you have open.</span></div> <!> <!>`,1),eR=T('<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-cowork-error"><!> <span class="svelte-bt94ms"> </span></div>'),tR=T('<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-cowork-step"><!> <!></section>'),nR=T('<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-install-error"><!> <span class="svelte-bt94ms"> </span></div>'),rR=T(`<p class="iw-hint-text svelte-bt94ms">Don't have Claude Code yet? Install it now — a small, signed download
62
- 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>'),oR=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
63
- connect a different MCP-compatible app manually, point it at:</p> <code class="iw-code svelte-bt94ms"> </code></div>`),sR=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
64
- build, so tokens entered here can't be saved. Set the environment
65
- 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>`),aR=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>'),cR=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>'),uR=T('<div class="iw-secret-row svelte-bt94ms"><span class="iw-secret-label svelte-bt94ms"> </span> <!></div>'),dR=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
66
- just this computer. Most people can skip this. Tokens are stored in your
67
- operating system's secure storage.</p> <!> <!></div></details>`),fR=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
68
- documents you have open in Tandem. Nothing else is touched, and you can undo this
69
- any time.</p> <div class="iw-cards svelte-bt94ms"></div> <!>`,1),hR=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>'),pR=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>`),mR=T('<span class="iw-result-detail svelte-bt94ms">Connected</span>'),gR=T(`<span class="iw-result-detail svelte-bt94ms">Left unchanged (already set up, or couldn't be safely edited)</span>`),vR=T('<span class="iw-result-detail svelte-bt94ms"> </span>'),bR=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>'),yR=T('<div class="iw-results svelte-bt94ms"></div>'),wR=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 —
70
- or just ask Claude to open a document.</span></div></section>`),kR=T('<p class="iw-hint-text svelte-bt94ms"> </p>'),xR=T('<details class="iw-tech-details svelte-bt94ms"><summary class="svelte-bt94ms"><!> Technical details</summary> <pre class="iw-tech-text svelte-bt94ms"> </pre></details>'),_R=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>'),CR=T('<span class="iw-more-badge svelte-bt94ms"><!> Enabled</span>'),SR=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>'),ER=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>'),AR=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>'),TR=T('<section class="iw-more svelte-bt94ms" data-testid="integration-wizard-more"><div class="iw-more-label svelte-bt94ms">More integrations</div> <!> <!></section>'),MR=T("<!> <!>",1),DR=T('<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms">Done</button>'),OR=T('<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="cowork-enable-confirm-btn"> </button>'),IR=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-cowork-back">Back</button> <!>',1),RR=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Cancel</button>'),NR=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),PR=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),LR=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" disabled="">Connecting…</button>'),FR=T('<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-done-retry">Try again</button>'),zR=T('<!> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-done-close">Done</button>',1),BR=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),HR=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 VR(t,e){et(e,!0);const n=F8({baseUrl:`http://127.0.0.1:${ji}`}),r=a1(()=>Tt()),i=N(()=>CI(r.status)),o=E8(()=>e.open&&n.step==="connect",`http://127.0.0.1:${ji}`),s=N(()=>o.presence==="NOT_INSTALLED"),a=N(()=>o.presence==="INSTALLED_NOT_ON_PATH");let l=L("main"),c=L(!1),d=L(null),f=L(null),h=null,p=L(at({}));me(()=>{if(!e.open)return;const le=Mt(()=>u(f));if(le)return h=document.activeElement,le.focus(),()=>{h instanceof HTMLElement&&document.contains(h)&&h.focus()}}),me(()=>{e.open&&(b(l,"main"),n.begin())});async function m(){b(c,!0),b(d,null);try{const le=await ss();await s1(le,!0),await r.refetch(),b(l,"main")}catch(le){const be=le instanceof Error?le.message:String(le);b(d,o1(be),!0)}finally{b(c,!1)}}const v=N(()=>{if(u(i)==="loading")return"Checking…";if(u(i)==="unsupported")return"Coming soon to macOS & Linux";if(u(i)==="undetected")return"Not detected on this computer";const le=r.status;return le!=null&&le.enabled?"Connected — token provisioned":le!=null&&le.uacDeclined?"Admin permission declined — set up to retry":"Let a teammate's Claude join from the Cowork VM"});me(()=>{if(!e.open)return;const le=be=>{be.key==="Escape"&&g()};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)});function g(){n.cleanupUnsavedSecrets().catch(()=>{}),n.reset(),b(p,{},!0),e.onClose()}function y(){n.reset(),b(p,{},!0),n.begin(),o.refetch()}async function C(){const le=await o.install();le&&le!=="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(le){if(le.key!=="Tab"||!u(f))return;const be=Array.from(u(f).querySelectorAll(_)).filter(H=>H.offsetParent!==null);if(be.length===0)return;const Re=be[0],$=be[be.length-1],q=document.activeElement;le.shiftKey&&(q===Re||q===u(f))?(le.preventDefault(),$.focus()):!le.shiftKey&&q===$&&(le.preventDefault(),Re.focus())}function A(le){const be=n.picked.findIndex($=>$.config.configPath===le.target.configPath);if(be>=0){n.setPicked(n.picked.filter(($,q)=>q!==be));return}const Re=QS(le);Re&&n.setPicked([...n.picked,Re])}function O(le){return n.picked.some(be=>be.config.configPath===le.target.configPath)}async function E(le){const be=u(p)[le.id]??"";be.length!==0&&(await n.submitSecret(le,be),u(p)[le.id]="")}const M=/HTTP 5\d\d/,R=/HTTP 4\d\d/,D=/fetch|network|Failed to/i,I=N(()=>n.picked.length===1?`Connect ${n.picked[0].config.label}`:"Connect selected");function B(le){var be;return((be=n.picked.find(Re=>Re.id===le.id))==null?void 0:be.config.label)??"Unknown"}function z(le){switch(le.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 le.message??"Something went wrong applying this one."}}const Q=N(()=>{const le=n.errorMessage??"";return M.test(le)?"Tandem's helper isn't responding. Make sure Tandem is running, then try again.":R.test(le)?"Tandem couldn't save the connection. Try again in a moment.":D.test(le)?"Couldn't reach Tandem — is it still running?":null}),ie=N(()=>n.applyResults.some(le=>le.status==="error"));var he=St(),ae=Ae(he);{var ke=le=>{var be=HR(),Re=w(be),$=w(Re),q=w($),H=w(q),ne=w(H),te=k(H,2);{var Z=ue=>{var re=Z8();x(ue,re)},ge=ue=>{var re=Y8();x(ue,re)};j(te,ue=>{u(l)==="main"&&n.step==="connect"?ue(Z):u(l)==="cowork"&&ue(ge,1)})}var De=k(q,2),Ee=k($,2),de=w(Ee);{var _e=ue=>{var re=tR(),pe=w(re);{var Ne=qe=>{var it=J8(),ce=w(it);tu(ce),x(qe,it)},xe=qe=>{var it=$8(),ce=Ae(it),Ie=w(ce);ml(Ie);var V=k(ce,2);{var ee=Fe=>{var K=X8(),fe=k(w(K)),Pe=w(fe);W(()=>G(Pe,r.status.vethernetCidr)),x(Fe,K)};j(V,Fe=>{var K;(K=r.status)!=null&&K.vethernetCidr&&Fe(ee)})}var we=k(V,2);{var Ve=Fe=>{var K=Q8();x(Fe,K)};j(we,Fe=>{var K;(K=r.status)!=null&&K.uacDeclined&&Fe(Ve)})}x(qe,it)};j(pe,qe=>{var it;(it=r.status)!=null&&it.enabled?qe(Ne):qe(xe,-1)})}var Me=k(pe,2);{var Se=qe=>{var it=eR(),ce=w(it);ml(ce);var Ie=k(ce,2),V=w(Ie);W(()=>G(V,u(d))),x(qe,it)};j(Me,qe=>{u(d)&&qe(Se)})}x(ue,re)},J=ue=>{var re=MR(),pe=Ae(re);{var Ne=ce=>{var Ie=hR(),V=w(Ie);{var ee=Fe=>{sk(Fe,()=>"Looking for Claude on your computer…")},we=Fe=>{var K=oR(),fe=k(w(K),2);{var Pe=Ue=>{var nt=rR(),rt=k(Ae(nt),2),xt=w(rt),qt=k(rt,2);{var Je=Ct=>{var Nt=nR(),ln=w(Nt);ml(ln);var vn=k(ln,2),er=w(vn);W(()=>G(er,o.installError)),x(Ct,Nt)};j(qt,Ct=>{o.installError&&Ct(Je)})}W(()=>{rt.disabled=o.installing,G(xt,o.installing?"Installing…":"Install Claude Code")}),P("click",rt,C),x(Ue,nt)},Be=Ue=>{var nt=iR(),rt=w(nt);tu(rt),x(Ue,nt)};j(fe,Ue=>{u(s)?Ue(Pe):u(a)&&Ue(Be,1)})}var Ke=k(fe,4),We=w(Ke);W(()=>G(We,`http://127.0.0.1:${ji}/mcp`)),x(Fe,K)},Ve=Fe=>{var K=fR(),fe=k(Ae(K),2);pt(fe,21,()=>n.existing,Ke=>Ke.target.configPath,(Ke,We)=>{{let Ue=N(()=>O(u(We)));j8(Ke,{get install(){return u(We)},get selected(){return u(Ue)},onToggle:()=>A(u(We))})}});var Pe=k(fe,2);{var Be=Ke=>{var We=dR(),Ue=w(We),nt=w(Ue);ok(nt);var rt=k(Ue,2),xt=k(w(rt),2);{var qt=Ct=>{var Nt=sR(),ln=w(Nt);ml(ln),x(Ct,Nt)};j(xt,Ct=>{n.keychainUnavailable&&Ct(qt)})}var Je=k(xt,2);pt(Je,17,()=>n.picked,Ct=>Ct.id,(Ct,Nt)=>{var ln=uR(),vn=w(ln),er=w(vn),zt=k(vn,2);{var Mn=An=>{var qr=aR(),Ii=w(qr);tu(Ii),x(An,qr)},cr=An=>{var qr=lR();x(An,qr)},En=An=>{var qr=cR(),Ii=w(qr),Ri=k(Ii,2);W(()=>{U(Ii,"data-testid",`integration-wizard-secret-input-${u(Nt).id??""}`),Ri.disabled=!u(p)[u(Nt).id],U(Ri,"data-testid",`integration-wizard-secret-submit-${u(Nt).id??""}`)}),zr(Ii,()=>u(p)[u(Nt).id],cl=>u(p)[u(Nt).id]=cl),P("click",Ri,()=>E(u(Nt))),x(An,qr)};j(zt,An=>{u(Nt).hasStoredSecret?An(Mn):u(Nt).keychainUnavailable?An(cr,1):An(En,-1)})}W(()=>G(er,u(Nt).config.label)),x(Ct,ln)}),x(Ke,We)};j(Pe,Ke=>{n.picked.length>0&&Ke(Be)})}x(Fe,K)};j(V,Fe=>{n.detecting?Fe(ee):n.existing.length===0?Fe(we,1):Fe(Ve,-1)})}x(ce,Ie)},xe=ce=>{var Ie=pR(),V=w(Ie);sk(V,()=>"Connecting Claude…"),x(ce,Ie)},Me=ce=>{var Ie=wR(),V=w(Ie),ee=k(w(V),2),we=w(ee),Ve=k(V,2);{var Fe=K=>{var fe=yR();pt(fe,21,()=>n.applyResults,Pe=>Pe.id,(Pe,Be)=>{var Ke=bR(),We=w(Ke),Ue=w(We);{var nt=zt=>{tu(zt)},rt=zt=>{var Mn=dr("—");x(zt,Mn)},xt=zt=>{ml(zt)};j(Ue,zt=>{u(Be).status==="applied"?zt(nt):u(Be).status==="skipped"?zt(rt,1):zt(xt,-1)})}var qt=k(We,2),Je=w(qt),Ct=w(Je),Nt=k(Je,2);{var ln=zt=>{var Mn=mR();x(zt,Mn)},vn=zt=>{var Mn=gR();x(zt,Mn)},er=zt=>{var Mn=vR(),cr=w(Mn);W(En=>G(cr,En),[()=>z(u(Be))]),x(zt,Mn)};j(Nt,zt=>{u(Be).status==="applied"?zt(ln):u(Be).status==="skipped"?zt(vn,1):zt(er,-1)})}W(zt=>{vt(Ke,1,`iw-result iw-result-${u(Be).status??""}`,"svelte-bt94ms"),U(Ke,"data-testid",`integration-wizard-apply-result-${u(Be).id??""}`),G(Ct,zt)},[()=>B(u(Be))]),x(Pe,Ke)}),x(K,fe)};j(Ve,K=>{n.applyResults.length>0&&K(Fe)})}W(()=>G(we,u(ie)?"Partly connected":"Claude is connected to Tandem")),x(ce,Ie)},Se=ce=>{var Ie=_R(),V=w(Ie);ml(V,()=>"iw-error-icon");var ee=k(V,4);{var we=K=>{var fe=kR(),Pe=w(fe);W(()=>G(Pe,u(Q))),x(K,fe)};j(ee,K=>{u(Q)&&K(we)})}var Ve=k(ee,2);{var Fe=K=>{var fe=xR(),Pe=w(fe),Be=w(Pe);ok(Be);var Ke=k(Pe,2),We=w(Ke);W(()=>G(We,n.errorMessage)),x(K,fe)};j(Ve,K=>{n.errorMessage&&K(Fe)})}x(ce,Ie)};j(pe,ce=>{n.step==="connect"?ce(Ne):n.step==="applying"?ce(xe,1):n.step==="done"?ce(Me,2):n.step==="error"&&ce(Se,3)})}var qe=k(pe,2);{var it=ce=>{var Ie=TR(),V=k(w(Ie),2);{var ee=K=>{var fe=ER(),Pe=w(fe),Be=k(w(Pe),2),Ke=w(Be),We=k(Pe,2);{var Ue=rt=>{var xt=CR(),qt=w(xt);tu(qt),x(rt,xt)},nt=rt=>{var xt=SR();P("click",xt,()=>{b(d,null),b(c,!1),b(l,"cowork")}),x(rt,xt)};j(We,rt=>{var xt;(xt=r.status)!=null&&xt.enabled?rt(Ue):u(i)==="normal"&&rt(nt,1)})}W(()=>G(Ke,u(v))),x(K,fe)},we=N(()=>Tt());j(V,K=>{u(we)&&K(ee)})}var Ve=k(V,2);{var Fe=K=>{var fe=AR();x(K,fe)};j(Ve,K=>{K(Fe)})}x(ce,Ie)};j(qe,ce=>{(n.step==="connect"||n.step==="done")&&ce(it)})}x(ue,re)};j(de,ue=>{u(l)==="cowork"?ue(_e):ue(J,-1)})}var ye=k(Ee,2),Y=w(ye);{var se=ue=>{var re=IR(),pe=Ae(re),Ne=k(pe,2);{var xe=Se=>{var qe=DR();P("click",qe,()=>b(l,"main")),x(Se,qe)},Me=Se=>{var qe=OR(),it=w(qe);W(()=>{qe.disabled=u(c),G(it,u(c)?"Enabling…":"Enable Cowork")}),P("click",qe,m),x(Se,qe)};j(Ne,Se=>{var qe;(qe=r.status)!=null&&qe.enabled?Se(xe):Se(Me,-1)})}W(()=>pe.disabled=u(c)),P("click",pe,()=>b(l,"main")),x(ue,re)},Te=ue=>{var re=St(),pe=Ae(re);{var Ne=Se=>{var qe=RR();P("click",qe,g),x(Se,qe)},xe=Se=>{var qe=NR(),it=Ae(qe),ce=k(it,2);P("click",it,g),P("click",ce,y),x(Se,qe)},Me=Se=>{var qe=PR(),it=Ae(qe),ce=k(it,2),Ie=w(ce);W(()=>{ce.disabled=n.picked.length===0,G(Ie,u(I))}),P("click",it,g),P("click",ce,()=>n.save()),x(Se,qe)};j(pe,Se=>{n.detecting?Se(Ne):n.existing.length===0?Se(xe,1):Se(Me,-1)})}x(ue,re)},Oe=ue=>{var re=LR();x(ue,re)},ze=ue=>{var re=zR(),pe=Ae(re);{var Ne=Me=>{var Se=FR();P("click",Se,y),x(Me,Se)};j(pe,Me=>{u(ie)&&Me(Ne)})}var xe=k(pe,2);P("click",xe,g),x(ue,re)},Xe=ue=>{var re=BR(),pe=Ae(re),Ne=k(pe,2);P("click",pe,g),P("click",Ne,y),x(ue,re)};j(Y,ue=>{u(l)==="cowork"?ue(se):n.step==="connect"?ue(Te,1):n.step==="applying"?ue(Oe,2):n.step==="done"?ue(ze,3):n.step==="error"&&ue(Xe,4)})}Ot(Re,ue=>b(f,ue),()=>u(f)),W(()=>G(ne,u(l)==="cowork"?"Set up Cowork":"Connect Claude to Tandem")),P("click",be,ue=>{ue.target===ue.currentTarget&&g()}),P("keydown",Re,ue=>{if(ue.key==="Escape"){ue.stopPropagation(),g();return}if(ue.key==="Tab"){S(ue);return}ue.stopPropagation()}),P("click",De,g),x(le,be)};j(ae,le=>{e.open&&le(ke)})}x(t,he),tt()}ut(["click","keydown"]);const UR=t=>t;function jR(t,{delay:e=0,duration:n=400,easing:r=UR}={}){const i=+getComputedStyle(t).opacity;return{delay:e,duration:n,easing:r,css:o=>`opacity: ${o*i}`}}let Cf=null;function ak(t){const e=t.decorationsMuted;try{localStorage.setItem(MC,String(!e&&t.showAuthorship)),localStorage.setItem(DC,JSON.stringify({comment:!e&&t.showComments,highlight:!e&&t.showHighlights,note:!e&&t.showNotes}))}catch{}}function oi(){if(Cf)return Cf;const t=mm();let e=L(at(t));return ak(t),Cf={get settings(){return u(e)},updateSettings:r=>{if(u(e)._readOnly)return;const i=DO(u(e),r);try{localStorage.setItem(CC,JSON.stringify(i))}catch{}ak(i),b(e,i,!0)}},Cf}function $S(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 sl=$S(.2,.8,.2,1),qR=$S(.4,0,.2,1),WR=260,KR=260,GR=280;function So(t){return t?!0:typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Gd(t){return{h:t.offsetHeight,mb:Number.parseFloat(getComputedStyle(t).marginBottom)||0}}function ZR(t,{enabled:e,reduceMotion:n}){if(!e||So(n))return{duration:0};const{h:r,mb:i}=Gd(t);return{duration:WR,easing:sl,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 YR(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||So(n))return{duration:0};const{h:s,mb:a}=Gd(t),l=c=>o==="accept"?`translateY(${-8*c}px)`:o==="dismiss"?`translateX(${40*c}px) scale(${1-.04*c})`:"none";return{duration:KR,easing:sl,css:(c,d)=>`opacity:${c}; height:${c*s}px; margin-bottom:${c*a}px; transform:${l(d)}; overflow:clip; box-sizing:border-box;`}}function e3(t,{reduceMotion:e}){if(So(e))return{duration:0};const{h:n,mb:r}=Gd(t);return{duration:GR,easing:sl,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 t3(t,{reduceMotion:e,exitMs:n=200}){if(So(e))return{duration:0};const{h:r,mb:i}=Gd(t);return{duration:n,easing:qR,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 Yh=new Map,JR=480,XR=1e3;function lk(t,e){Yh.set(t,e),setTimeout(()=>Yh.delete(t),XR)}function QR(t,{id:e,reduceMotion:n}){const r=Yh.get(e);if(Yh.delete(e),!r||So(n))return{duration:0};const i=t.getBoundingClientRect(),o=r.left-i.left,s=r.top-i.top;return{duration:JR,easing:sl,css:(a,l)=>`transform:translate(${o*l}px, ${s*l}px); opacity:${.2+.8*a};`}}const $R=200;function eN(t,{reduceMotion:e}){if(So(e))return{duration:0};const n=t.offsetWidth;return{duration:$R,easing:sl,css:r=>`opacity:${r}; width:${r*n}px; min-width:0; overflow:clip; box-sizing:border-box; pointer-events:none;`}}const n3=440;function tN(t,{reduceMotion:e}){if(So(e))return{duration:0};const n=t.offsetWidth,r=t.offsetHeight;return{duration:n3,easing:sl,css:i=>`opacity:${i}; width:${i*n}px; height:${i*r}px; overflow:clip; box-sizing:border-box;`}}const nN=380;function rN(t,{reduceMotion:e}){if(So(e))return{duration:0};const{h:n,mb:r}=Gd(t);return{duration:nN,easing:sl,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),oN=T('<div class="cos-error svelte-1h0desi" data-testid="cowork-onboarding-error" role="alert"> </div>'),sN=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">Windows will prompt for admin permission to modify firewall rules. This is expected.</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>'),aN=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>'),cN=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>'),uN=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 dN(t,e){et(e,!0);let n=L(!1),r=L(!1),i=L(null);async function o(y,C){b(r,!0),b(i,null);try{const _=await ss();return await y(_),!0}catch(_){const S=_ instanceof Error?_.message:String(_),A=o1(S);return b(i,`${C}: ${A}`),!1}finally{b(r,!1)}}async function s(){await o(async C=>{await s1(C,!0)},"Failed to enable Cowork")&&e.onAdvance()}function a(){AI(),e.onAdvance()}var l=uN(),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=oN(),_=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=sN(),_=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=cN(),_=w(C),S=k(_,2),A=k(S,2);{var O=M=>{var R=aN();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",`${wC}#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),tt()}ut(["click"]);var fN=T("<div></div>"),hN=T('<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);" class="svelte-1us4jmd"></div>'),pN=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),mN=T('<div class="svelte-1us4jmd"><!></div>'),gN=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>'),vN=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 bN(t,e){et(e,!0);const n=oi(),r=N(()=>So(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=KS(),a=N(()=>o&&WS(e.coworkStatus,s)),l=N(()=>i.filter(g=>g.id!=="cowork"||u(a))),c=N(()=>u(l).length-1),d=N(()=>u(l)[e.currentStep]),f=N(()=>e.currentStep>=u(c)),h=N(()=>{var g;return((g=u(d))==null?void 0:g.id)==="cowork"});var p=St(),m=Ae(p);{var v=g=>{var y=vN(),C=w(y);{var _=E=>{var M=hN();pt(M,20,()=>Array.from({length:u(c)},(R,D)=>D),R=>R,(R,D)=>{var I=fN();let B;W(()=>{B=vt(I,1,"tut-dot svelte-1us4jmd",null,B,{"is-current":D===e.currentStep}),Le(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);Fl(S,()=>u(d).id,E=>{var M=mN(),R=w(M);{var D=B=>{dN(B,{get status(){return e.coworkStatus},get onAdvance(){return e.onNext}})},I=B=>{var z=pN(),Q=Ae(z),ie=w(Q),he=k(Q,2),ae=w(he);W(()=>{G(ie,u(d).title),Le(he,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${u(f)?0:14}px;`),G(ae,u(d).text)}),x(B,z)};j(R,B=>{u(h)&&e.coworkStatus!==null?B(D):B(I,-1)})}Wi(1,M,()=>jR,()=>({duration:u(r)})),x(E,M)});var A=k(S,2);{var O=E=>{var M=gN(),R=w(M),D=w(R),I=k(R,2),B=w(I),z=k(B,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",B,function(...ie){var he;(he=e.onDismiss)==null||he.apply(this,ie)}),P("click",z,function(...ie){var he;(he=e.onNext)==null||he.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),tt()}ut(["click"]);const Ci=()=>new Map,Cv=t=>{const e=Ci();return t.forEach((n,r)=>{e.set(r,n)}),e},Eo=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},yN=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},wN=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Ka=()=>new Set,Mg=t=>t[t.length-1],kN=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Ys=Array.from,c1=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},u1=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},xN=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},bc=Array.isArray;class r3{constructor(){this._observers=Ci()}on(e,n){return Eo(this._observers,e,Ka).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 Ys((this._observers.get(e)||Ci()).values()).forEach(r=>r(...n))}destroy(){this._observers=Ci()}}const Ki=Math.floor,fh=Math.abs,Yo=(t,e)=>t<e?t:e,Gi=(t,e)=>t>e?t:e,i3=t=>t!==0?t<0:1/t<0,ck=1,uk=2,Dg=4,Og=8,ed=32,Jo=64,Er=128,_N=1<<29,wm=31,Sv=63,Pa=127,CN=2147483647,Jh=Number.MAX_SAFE_INTEGER,dk=Number.MIN_SAFE_INTEGER,SN=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Ki(t)===t),o3=String.fromCharCode,EN=t=>t.toLowerCase(),AN=/^\s*/g,TN=t=>t.replace(AN,""),MN=/([A-Z])/g,fk=(t,e)=>TN(t.replace(MN,n=>`${e}${EN(n)}`)),DN=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},td=typeof TextEncoder<"u"?new TextEncoder:null,ON=t=>td.encode(t),IN=td?ON:DN;let Eu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Eu&&Eu.decode(new Uint8Array).length===1&&(Eu=null);const RN=(t,e)=>xN(e,()=>t).join("");let Zd=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};const Yd=()=>new Zd,NN=t=>{const e=Yd();return t(e),Vi(e)},PN=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Vi=t=>{const e=new Uint8Array(PN(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},LN=(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(Gi(n,e)*2),t.cpos=0)},qn=(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},Ev=qn,Lt=(t,e)=>{for(;e>Pa;)qn(t,Er|Pa&e),e=Ki(e/128);qn(t,Pa&e)},d1=(t,e)=>{const n=i3(e);for(n&&(e=-e),qn(t,(e>Sv?Er:0)|(n?Jo:0)|Sv&e),e=Ki(e/64);e>0;)qn(t,(e>Pa?Er:0)|Pa&e),e=Ki(e/128)},Av=new Uint8Array(3e4),FN=Av.length/3,zN=(t,e)=>{if(e.length<FN){const n=td.encodeInto(e,Av).written||0;Lt(t,n);for(let r=0;r<n;r++)qn(t,Av[r])}else Zr(t,IN(e))},BN=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Lt(t,r);for(let i=0;i<r;i++)qn(t,n.codePointAt(i))},Bl=td&&td.encodeInto?zN:BN,km=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=Yo(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(Gi(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},Zr=(t,e)=>{Lt(t,e.byteLength),km(t,e)},f1=(t,e)=>{LN(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},HN=(t,e)=>f1(t,4).setFloat32(0,e,!1),VN=(t,e)=>f1(t,8).setFloat64(0,e,!1),UN=(t,e)=>f1(t,8).setBigInt64(0,e,!1),hk=new DataView(new ArrayBuffer(4)),jN=t=>(hk.setFloat32(0,t),hk.getFloat32(0)===t),yc=(t,e)=>{switch(typeof e){case"string":qn(t,119),Bl(t,e);break;case"number":SN(e)&&fh(e)<=CN?(qn(t,125),d1(t,e)):jN(e)?(qn(t,124),HN(t,e)):(qn(t,123),VN(t,e));break;case"bigint":qn(t,122),UN(t,e);break;case"object":if(e===null)qn(t,126);else if(bc(e)){qn(t,117),Lt(t,e.length);for(let n=0;n<e.length;n++)yc(t,e[n])}else if(e instanceof Uint8Array)qn(t,116),Zr(t,e);else{qn(t,118);const n=Object.keys(e);Lt(t,n.length);for(let r=0;r<n.length;r++){const i=n[r];Bl(t,i),yc(t,e[i])}}break;case"boolean":qn(t,e?120:121);break;default:qn(t,127)}};class pk extends Zd{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 mk=t=>{t.count>0&&(d1(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Lt(t.encoder,t.count-2))};class hh{constructor(){this.encoder=new Zd,this.s=0,this.count=0}write(e){this.s===e?this.count++:(mk(this),this.count=1,this.s=e)}toUint8Array(){return mk(this),Vi(this.encoder)}}const gk=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);d1(t.encoder,e),t.count>1&&Lt(t.encoder,t.count-2)}};class Ig{constructor(){this.encoder=new Zd,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(gk(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return gk(this),Vi(this.encoder)}}class qN{constructor(){this.sarr=[],this.s="",this.lensE=new hh}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 Zd;return this.sarr.push(this.s),this.s="",Bl(e,this.sarr.join("")),km(e,this.lensE.toUint8Array()),Vi(e)}}const wo=t=>new Error(t),Si=()=>{throw wo("Method unimplemented")},pr=()=>{throw wo("Unexpected case")},s3=wo("Unexpected end of array"),a3=wo("Integer out of Range");let xm=class{constructor(e){this.arr=e,this.pos=0}};const zc=t=>new xm(t),WN=t=>t.pos!==t.arr.length,KN=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Yr=t=>KN(t,It(t)),wc=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&Pa)*n,n*=128,i<Er)return e;if(e>Jh)throw a3}throw s3},h1=t=>{let e=t.arr[t.pos++],n=e&Sv,r=64;const i=(e&Jo)>0?-1:1;if((e&Er)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&Pa)*r,r*=128,e<Er)return i*n;if(n>Jh)throw a3}throw s3},GN=t=>{let e=It(t);if(e===0)return"";{let n=String.fromCodePoint(wc(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(wc(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))}},ZN=t=>Eu.decode(Yr(t)),Hl=Eu?ZN:GN,p1=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},YN=t=>p1(t,4).getFloat32(0,!1),JN=t=>p1(t,8).getFloat64(0,!1),XN=t=>p1(t,8).getBigInt64(0,!1),QN=[t=>{},t=>null,h1,YN,JN,XN,t=>!1,t=>!0,Hl,t=>{const e=It(t),n={};for(let r=0;r<e;r++){const i=Hl(t);n[i]=nd(t)}return n},t=>{const e=It(t),n=[];for(let r=0;r<e;r++)n.push(nd(t));return n},Yr],nd=t=>QN[127-wc(t)](t);class vk extends xm{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),WN(this)?this.count=It(this)+1:this.count=-1),this.count--,this.s}}class ph extends xm{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=h1(this);const e=i3(this.s);this.count=1,e&&(this.s=-this.s,this.count=It(this)+2)}return this.count--,this.s}}class Rg extends xm{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=h1(this),n=e&1;this.diff=Ki(e/2),this.count=1,n&&(this.count=It(this)+2)}return this.s+=this.diff,this.count--,this.s}}class $N{constructor(e){this.decoder=new ph(e),this.str=Hl(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 e9=crypto.getRandomValues.bind(crypto),t9=Math.random,l3=()=>e9(new Uint32Array(1))[0],n9=t=>t[Ki(t9()*t.length)],r9="10000000-1000-4000-8000"+-1e11,i9=()=>r9.replace(/[018]/g,t=>(t^l3()&15>>t/4).toString(16)),o9=Date.now,bk=t=>new Promise(t);Promise.all.bind(Promise);const yk=t=>t===void 0?null:t;class s9{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let c3=new s9,a9=!0;try{typeof localStorage<"u"&&localStorage&&(c3=localStorage,a9=!1)}catch{}const l9=c3,rd=Symbol("Equality"),u3=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[rd])!=null&&n.call(t,e))||!1},c9=t=>typeof t=="object",u9=Object.assign,d3=Object.keys,d9=(t,e)=>{for(const n in t)e(t[n],n)},Xh=t=>d3(t).length,f9=t=>{for(const e in t)return!1;return!0},Bc=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},m1=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),h9=(t,e)=>t===e||Xh(t)===Xh(e)&&Bc(t,(n,r)=>(n!==void 0||m1(e,r))&&u3(e[r],n)),p9=Object.freeze,f3=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&f3(t[e])}return p9(t)},g1=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&g1(t,e,n+1)}},m9=t=>t,mh=(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[rd]!=null)return t[rd](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)||!mh(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(Xh(t)!==Xh(e))return!1;for(const n in t)if(!m1(t,n)||!mh(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(!mh(t[n],e[n]))return!1;break;default:return!1}return!0},g9=(t,e)=>e.includes(t);var h3={};const kc=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",p3=typeof window<"u"&&typeof document<"u"&&!kc;let to;const v9=()=>{if(to===void 0)if(kc){to=Ci();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&to.set(e,""),e=r):e!==null&&(to.set(e,r),e=null)}e!==null&&to.set(e,"")}else typeof location=="object"?(to=Ci(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");to.set(`--${fk(e,"-")}`,n),to.set(`-${fk(e,"-")}`,n)}})):to=Ci();return to},Tv=t=>v9().has(t),Qh=t=>yk(kc?h3[t.toUpperCase().replaceAll("-","_")]:l9.getItem(t)),m3=t=>Tv("--"+t)||Qh(t)!==null,b9=m3("production"),y9=kc&&g9(h3.FORCE_COLOR,["true","1","2"]),w9=y9||!Tv("--no-colors")&&!m3("no-color")&&(!kc||process.stdout.isTTY)&&(!kc||Tv("--color")||Qh("COLORTERM")!==null||(Qh("TERM")||"").includes("color")),k9=t=>new Uint8Array(t),x9=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=o3(t[n]);return btoa(e)},_9=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),C9=p3?x9:_9,S9=t=>{const e=k9(t.byteLength);return e.set(t),e},E9=t=>NN(e=>yc(e,t));class A9{constructor(e,n){this.left=e,this.right=n}}const Oo=(t,e)=>new A9(t,e),wk=t=>t.next()>=.5,Ng=(t,e,n)=>Ki(t.next()*(n+1-e)+e),g3=(t,e,n)=>Ki(t.next()*(n+1-e)+e),v1=(t,e,n)=>g3(t,e,n),T9=t=>o3(v1(t,97,122)),M9=(t,e=0,n=20)=>{const r=v1(t,e,n);let i="";for(let o=0;o<r;o++)i+=T9(t);return i},Pg=(t,e)=>e[v1(t,0,e.length-1)],D9=Symbol("0schema");class O9{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(RN(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
71
- `)}}const Mv=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[rd]?u3(t,e):bc(t)?c1(t,n=>u1(e,r=>Mv(n,r))):c9(t)?Bc(t,(n,r)=>Mv(n,e[r])):!1;class br{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),Mv(n,r)}equals(e){return this.constructor===e.constructor&&mh(this.shape,e.shape)}[D9](){return!0}[rd](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Si()}get nullable(){return Hc(this,Am)}get optional(){return new y3(this)}cast(e){return kk(e,this),e}expect(e){return kk(e,this),e}}Vn(br,"_dilutes",!1);class b1 extends br{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 b1(t,e);Nn(b1);class y1 extends br{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 $n=t=>new y1(t);Nn(y1);class _m extends br{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 Cm=(...t)=>new _m(t),v3=Nn(_m),I9=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),b3=t=>{if(xc.check(t))return[I9(t)];if(v3.check(t))return t.shape.map(e=>e+"");if(T3.check(t))return["[+-]?\\d+.?\\d*"];if(M3.check(t))return[".*"];if(ep.check(t))return t.shape.map(b3).flat(1);pr()};class R9 extends br{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(b3).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(R9);const N9=Symbol("optional");class y3 extends br{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[N9](){return!0}}const P9=Nn(y3);class L9 extends br{check(e,n){return n==null||n.extend(null,"never",typeof e),!1}}Nn(L9);const lm=class lm extends br{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new lm(this.shape,!0)}check(e,n){return e==null?(n==null||n.extend(null,"object","null"),!1):Bc(this.shape,(r,i)=>{const o=this._isPartial&&!m1(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})}};Vn(lm,"_dilutes",!0);let $h=lm;const F9=t=>new $h(t),z9=Nn($h),B9=$n(t=>t!=null&&(t.constructor===Object||t.constructor==null));class w3 extends br{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&Bc(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 k3=(t,e)=>new w3(t,e),H9=Nn(w3);class x3 extends br{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&Bc(this.shape,(r,i)=>{const o=r.check(e[i],n);return!o&&(n==null||n.extend(i.toString(),"Tuple",typeof r)),o})}}const V9=(...t)=>new x3(t);Nn(x3);class _3 extends br{constructor(e){super(),this.shape=e.length===1?e[0]:new Sm(e)}check(e,n){const r=bc(e)&&c1(e,i=>this.shape.check(i));return!r&&(n==null||n.extend(null,"Array","")),r}}const C3=(...t)=>new _3(t),U9=Nn(_3),j9=$n(t=>bc(t));class S3 extends br{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 q9=(t,e=null)=>new S3(t,e);Nn(S3);const W9=q9(br);class K9 extends br{constructor(e){super(),this.len=e.length-1,this.args=V9(...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 G9=Nn(K9),Z9=$n(t=>typeof t=="function");class Y9 extends br{constructor(e){super(),this.shape=e}check(e,n){const r=c1(this.shape,i=>i.check(e,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof e)),r}}Nn(Y9,t=>t.shape.length>0);class Sm extends br{constructor(e){super(),this.shape=e}check(e,n){const r=u1(this.shape,i=>i.check(e,n));return n==null||n.extend(null,"Union",typeof e),r}}Vn(Sm,"_dilutes",!0);const Hc=(...t)=>t.findIndex(e=>ep.check(e))>=0?Hc(...t.map(e=>id(e)).map(e=>ep.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Sm(t),ep=Nn(Sm),E3=()=>!0,tp=$n(E3),J9=Nn(y1,t=>t.shape===E3),w1=$n(t=>typeof t=="bigint"),X9=$n(t=>t===w1),A3=$n(t=>typeof t=="symbol");$n(t=>t===A3);const Vl=$n(t=>typeof t=="number"),T3=$n(t=>t===Vl),xc=$n(t=>typeof t=="string"),M3=$n(t=>t===xc),Em=$n(t=>typeof t=="boolean"),Q9=$n(t=>t===Em),D3=Cm(void 0);Nn(_m,t=>t.shape.length===1&&t.shape[0]===void 0);Cm(void 0);const Am=Cm(null),$9=Nn(_m,t=>t.shape.length===1&&t.shape[0]===null);Nn(Uint8Array);Nn(b1,t=>t.shape===Uint8Array);const eP=Hc(Vl,xc,Am,D3,w1,Em,A3);(()=>{const t=C3(tp),e=k3(xc,tp),n=Hc(Vl,xc,Am,Em,t,e);return t.shape=n,e.shape.values=n,n})();const id=t=>{if(W9.check(t))return t;if(B9.check(t)){const e={};for(const n in t)e[n]=id(t[n]);return F9(e)}else{if(j9.check(t))return Hc(...t.map(id));if(eP.check(t))return Cm(t);if(Z9.check(t))return Nn(t)}pr()},kk=b9?()=>{}:(t,e)=>{const n=new O9;if(!e.check(t,n))throw wo(`Expected value to be of type ${e.constructor.name}.
72
- ${n.toString()}`)};class tP{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:id(e),h:n}),this}else(e){return this.if(tp,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 wo("Unhandled pattern")}}}const nP=t=>new tP(t),O3=nP(tp).if(T3,(t,e)=>Ng(e,dk,Jh)).if(M3,(t,e)=>M9(e)).if(Q9,(t,e)=>wk(e)).if(X9,(t,e)=>BigInt(Ng(e,dk,Jh))).if(ep,(t,e)=>gl(e,Pg(e,t.shape))).if(z9,(t,e)=>{const n={};for(const r in t.shape){let i=t.shape[r];if(P9.check(i)){if(wk(e))continue;i=i.shape}n[r]=O3(i,e)}return n}).if(U9,(t,e)=>{const n=[],r=g3(e,0,42);for(let i=0;i<r;i++)n.push(gl(e,t.shape));return n}).if(v3,(t,e)=>Pg(e,t.shape)).if($9,(t,e)=>null).if(G9,(t,e)=>{const n=gl(e,t.res);return()=>n}).if(J9,(t,e)=>gl(e,Pg(e,[Vl,xc,Am,D3,w1,Em,C3(Vl),k3(Hc("a","b","c"),Vl)]))).if(H9,(t,e)=>{const n={},r=Ng(e,0,3);for(let i=0;i<r;i++){const o=gl(e,t.shape.keys),s=gl(e,t.shape.values);n[o]=s}return n}).done(),gl=(t,e)=>O3(id(e),t),Jd=typeof document<"u"?document:{};$n(t=>t.nodeType===aP);typeof DOMParser<"u"&&new DOMParser;$n(t=>t.nodeType===iP);$n(t=>t.nodeType===oP);const rP=t=>yN(t,(e,n)=>`${n}:${e};`).join(""),iP=Jd.ELEMENT_NODE,oP=Jd.TEXT_NODE,sP=Jd.DOCUMENT_NODE,aP=Jd.DOCUMENT_FRAGMENT_NODE;$n(t=>t.nodeType===sP);const lP=t=>class{constructor(n){this._=n}destroy(){t(this._)}},cP=lP(clearTimeout),k1=(t,e)=>new cP(setTimeout(e,t)),cs=Symbol,I3=cs(),R3=cs(),uP=cs(),dP=cs(),fP=cs(),N3=cs(),hP=cs(),x1=cs(),pP=cs(),mP=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},gP={[I3]:Oo("font-weight","bold"),[R3]:Oo("font-weight","normal"),[uP]:Oo("color","blue"),[fP]:Oo("color","green"),[dP]:Oo("color","grey"),[N3]:Oo("color","red"),[hP]:Oo("color","purple"),[x1]:Oo("color","orange"),[pP]:Oo("color","black")},vP=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[],r=Ci();let i=[],o=0;for(;o<t.length;o++){const a=t[o],l=gP[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=rP(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},P3=w9?vP:mP,bP=(...t)=>{console.log(...P3(t)),F3.forEach(e=>e.print(t))},L3=(...t)=>{console.warn(...P3(t)),t.unshift(x1),F3.forEach(e=>e.print(t))},F3=Ka(),z3=t=>({[Symbol.iterator](){return this},next:t}),yP=(t,e)=>z3(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Lg=(t,e)=>z3(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Tm{constructor(e,n){this.clock=e,this.len=n}}class Vc{constructor(){this.clients=new Map}}const Js=(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])Q3(t,o,c.clock,c.len,n)}}),wP=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const i=Ki((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},Uc=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&wP(n,e.clock)!==null},_1=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 Tm(i.clock,Gi(i.len,o.clock+o.len-i.clock)):(r<n&&(e[r]=o),r++)}e.length=r})},Dv=t=>{const e=new Vc;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++)kN(o,t[s].clients.get(i)||[]);e.clients.set(i,o)}});return _1(e),e},od=(t,e,n,r)=>{Eo(t.clients,e,()=>[]).push(new Tm(n,r))},B3=()=>new Vc,H3=t=>{const e=B3();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 Tm(a,l))}}i.length>0&&e.clients.set(r,i)}),e},jc=(t,e)=>{Lt(t.restEncoder,e.clients.size),Ys(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)}})},C1=t=>{const e=new Vc,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=Eo(e.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new Tm(t.readDsClock(),t.readDsLen()))}}return e},xk=(t,e,n)=>{const r=new Vc,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&&od(r,s,c,h-c);let p=Zi(l,f),m=l[p];for(!m.deleted&&m.id.clock<f&&(l.splice(p+1,0,lp(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,lp(e,m,h-m.id.clock)),m.delete(e))}else od(r,s,f,h-f)}}if(r.clients.size>0){const o=new Ga;return Lt(o.restEncoder,0),jc(o,r),o.toUint8Array()}return null},V3=l3;class ko extends r3{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=V3(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new J3,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=bk(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>bk(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&&tn(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ys(this.subdocs).map(e=>e.guid))}transact(e,n=null){return tn(this,e,n)}get(e,n=Jn){const r=Eo(this.share,e,()=>{const o=new n;return o._integrate(this,null),o}),i=r.constructor;if(n!==Jn&&i!==n)if(i===Jn){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,ql)}getText(e=""){return this.get(e,Xs)}getMap(e=""){return this.get(e,Cc)}getXmlElement(e=""){return this.get(e,gn)}getXmlFragment(e=""){return this.get(e,Za)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Ys(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new ko({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,tn(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 U3{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return It(this.restDecoder)}readDsLen(){return It(this.restDecoder)}}class j3 extends U3{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 wc(this.restDecoder)}readString(){return Hl(this.restDecoder)}readParentInfo(){return It(this.restDecoder)===1}readTypeRef(){return It(this.restDecoder)}readLen(){return It(this.restDecoder)}readAny(){return nd(this.restDecoder)}readBuf(){return S9(Yr(this.restDecoder))}readJSON(){return JSON.parse(Hl(this.restDecoder))}readKey(){return Hl(this.restDecoder)}}class kP{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 _c extends kP{constructor(e){super(e),this.keys=[],It(e),this.keyClockDecoder=new Rg(Yr(e)),this.clientDecoder=new ph(Yr(e)),this.leftClockDecoder=new Rg(Yr(e)),this.rightClockDecoder=new Rg(Yr(e)),this.infoDecoder=new vk(Yr(e),wc),this.stringDecoder=new $N(Yr(e)),this.parentInfoDecoder=new vk(Yr(e),wc),this.typeRefDecoder=new ph(Yr(e)),this.lenDecoder=new ph(Yr(e))}readLeftID(){return new Ul(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ul(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 nd(this.restDecoder)}readBuf(){return Yr(this.restDecoder)}readJSON(){return nd(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 q3{constructor(){this.restEncoder=Yd()}toUint8Array(){return Vi(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Lt(this.restEncoder,e)}writeDsLen(e){Lt(this.restEncoder,e)}}class Xd extends q3{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){Ev(this.restEncoder,e)}writeString(e){Bl(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){yc(this.restEncoder,e)}writeBuf(e){Zr(this.restEncoder,e)}writeJSON(e){Bl(this.restEncoder,JSON.stringify(e))}writeKey(e){Bl(this.restEncoder,e)}}class W3{constructor(){this.restEncoder=Yd(),this.dsCurrVal=0}toUint8Array(){return Vi(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,Lt(this.restEncoder,n)}writeDsLen(e){e===0&&pr(),Lt(this.restEncoder,e-1),this.dsCurrVal+=e}}class Ga extends W3{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ig,this.clientEncoder=new hh,this.leftClockEncoder=new Ig,this.rightClockEncoder=new Ig,this.infoEncoder=new pk(Ev),this.stringEncoder=new qN,this.parentInfoEncoder=new pk(Ev),this.typeRefEncoder=new hh,this.lenEncoder=new hh}toUint8Array(){const e=Yd();return Lt(e,0),Zr(e,this.keyClockEncoder.toUint8Array()),Zr(e,this.clientEncoder.toUint8Array()),Zr(e,this.leftClockEncoder.toUint8Array()),Zr(e,this.rightClockEncoder.toUint8Array()),Zr(e,Vi(this.infoEncoder)),Zr(e,this.stringEncoder.toUint8Array()),Zr(e,Vi(this.parentInfoEncoder)),Zr(e,this.typeRefEncoder.toUint8Array()),Zr(e,this.lenEncoder.toUint8Array()),km(e,Vi(this.restEncoder)),Vi(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){yc(this.restEncoder,e)}writeBuf(e){Zr(this.restEncoder,e)}writeJSON(e){yc(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 xP=(t,e,n,r)=>{r=Gi(r,e[0].id.clock);const i=Zi(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)},S1=(t,e,n)=>{const r=new Map;n.forEach((i,o)=>{Tn(e,o)>i&&r.set(o,i)}),Qd(e).forEach((i,o)=>{n.has(o)||r.set(o,0)}),Lt(t.restEncoder,r.size),Ys(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{xP(t,e.clients.get(i),i,o)})},_P=(t,e)=>{const n=Ci(),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(wm&d){case 0:{const f=t.readLen();s[c]=new vi(_t(a,l),f),l+=f;break}case 10:{const f=It(t.restDecoder);s[c]=new bi(_t(a,l),f),l+=f;break}default:{const f=(d&(Jo|Er))===0,h=new on(_t(a,l),null,(d&Er)===Er?t.readLeftID():null,null,(d&Jo)===Jo?t.readRightID():null,f?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,f&&(d&ed)===ed?t.readString():null,wE(t,d));s[c]=h,l+=h.length}}}}return n},CP=(t,e,n)=>{const r=[];let i=Ys(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 J3,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!==bi){const m=Eo(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 Ga;return S1(p,a,new Map),Lt(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},SP=(t,e)=>S1(t,e.doc.store,e.beforeState),EP=(t,e,n,r=new _c(t))=>tn(e,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=_P(r,s),c=CP(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=rp([d.update,c.update])}}else a.pendingStructs=c;const f=xk(r,i,a);if(a.pendingDs){const h=new _c(zc(a.pendingDs));It(h.restDecoder);const p=xk(h,i,a);f&&p?a.pendingDs=rp([f,p]):a.pendingDs=f||p}else a.pendingDs=f;if(o){const h=a.pendingStructs.update;a.pendingStructs=null,np(i.doc,h)}},n,!1),np=(t,e,n,r=_c)=>{const i=zc(e);EP(i,t,n,new r(i))},AP=(t,e,n)=>np(t,e,n,j3),TP=(t,e,n=new Map)=>{S1(t,e.store,n),jc(t,H3(e.store))},MP=(t,e=new Uint8Array([0]),n=new Ga)=>{const r=K3(e);TP(n,t,r);const i=[n.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(ZP(t.store.pendingStructs.update,e)),i.length>1){if(n.constructor===Xd)return KP(i.map((o,s)=>s===0?o:JP(o)));if(n.constructor===Ga)return rp(i)}return i[0]},DP=(t,e)=>MP(t,e,new Xd),OP=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},K3=t=>OP(new U3(zc(t))),G3=(t,e)=>(Lt(t.restEncoder,e.size),Ys(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{Lt(t.restEncoder,n),Lt(t.restEncoder,r)}),t),IP=(t,e)=>G3(t,Qd(e.store)),RP=(t,e=new W3)=>(t instanceof Map?G3(e,t):IP(e,t),e.toUint8Array()),NP=t=>RP(t,new q3);class PP{constructor(){this.l=[]}}const _k=()=>new PP,Ck=(t,e)=>t.l.push(e),Sk=(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.")},Z3=(t,e,n)=>g1(t.l,[e,n]);class Ul{constructor(e,n){this.client=e,this.clock=n}}const Rl=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,_t=(t,e)=>new Ul(t,e),sd=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw pr()},ad=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class ld{constructor(e,n,r,i=0){this.type=e,this.tname=n,this.item=r,this.assoc=i}}const La=t=>new ld(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 LP{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const FP=(t,e,n=0)=>new LP(t,e,n),Sf=(t,e,n)=>{let r=null,i=null;return t._item===null?i=sd(t):r=_t(t._item.id.client,t._item.id.clock),new ld(r,i,e,n)},Fg=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Sf(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Sf(t,_t(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Sf(t,r.lastId,n);r=r.right}return Sf(t,null,n)},zP=(t,e)=>{const n=jl(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},Ov=(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?Pv(r,i):zP(r,i),f=d.item;if(!(f instanceof on))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?Pv(r,o):{item:jl(r,o)};if(d instanceof on&&d.content instanceof Xi)l=d.content.type;else return null}else throw pr();a>=0?c=l._length:c=0}return FP(l,c,t.assoc)},Ek=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&Rl(t.item,e.item)&&Rl(t.type,e.type)&&t.assoc===e.assoc;class E1{constructor(e,n){this.ds=e,this.sv=n}}const Y3=(t,e)=>new E1(t,e),zg=t=>Y3(H3(t.store),Qd(t.store)),ha=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Uc(e.ds,t.id),Iv=(t,e)=>{const n=Eo(t.meta,Iv,Ka),r=t.doc.store;n.has(e)||(e.sv.forEach((i,o)=>{i<Tn(r,o)&&Fr(t,_t(o,i))}),Js(t,e.ds,i=>{}),n.add(e))};class J3{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Qd=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},X3=(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 pr()}n.push(e)},Zi=(t,e)=>{let n=0,r=t.length-1,i=t[r],o=i.id.clock;if(o===e)return r;let s=Ki(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=Ki((n+r)/2)}throw pr()},BP=(t,e)=>{const n=t.clients.get(e.client);return n[Zi(n,e.clock)]},jl=BP,Rv=(t,e,n)=>{const r=Zi(e,n),i=e[r];return i.id.clock<n&&i instanceof on?(e.splice(r+1,0,lp(t,i,n-i.id.clock)),r+1):r},Fr=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Rv(t,n,e.clock)]},Ak=(t,e,n)=>{const r=e.clients.get(n.client),i=Zi(r,n.clock),o=r[i];return n.clock!==o.id.clock+o.length-1&&o.constructor!==vi&&r.splice(i+1,0,lp(t,o,n.clock-o.id.clock+1)),o},HP=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Zi(r,e.id.clock)]=n},Q3=(t,e,n,r,i)=>{if(r===0)return;const o=n+r;let s=Rv(t,e,n),a;do a=e[s++],o<a.id.clock+a.length&&Rv(t,e,o),i(a);while(s<e.length&&e[s].id.clock<o)};class VP{constructor(e,n,r){this.doc=e,this.deleteSet=new Vc,this.beforeState=Qd(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 Tk=(t,e)=>e.deleteSet.clients.size===0&&!wN(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(_1(e.deleteSet),SP(t,e),jc(t,e.deleteSet),!0),Mk=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Eo(t.changed,e,Ka).add(n)},gh=(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 on&&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},UP=(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=Zi(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 on&&f.deleted&&!f.keep&&n(f)&&f.gc(e,!1)}}}},jP=(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=Yo(i.length-1,1+Zi(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+gh(i,l)}})},$3=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,i=r.store,o=n.deleteSet,s=n._mergeStructs;try{_1(o),n.afterState=Qd(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(()=>{Z3(c._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&uL(n)})}),g1(a,[])}finally{r.gc&&UP(o,i,r.gcFilter),jP(o,i),n.afterState.forEach((d,f)=>{const h=n.beforeState.get(f)||0;if(h!==d){const p=i.clients.get(f),m=Gi(Zi(p,h),1);for(let v=p.length-1;v>=m;)v-=1+gh(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=Zi(p,h);m+1<p.length&&gh(p,m+1)>1||m>0&&gh(p,m)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(bP(x1,I3,"[yjs] ",R3,N3,"Changed the client-id because another client seems to be using it."),r.clientID=V3()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const d=new Xd;Tk(d,n)&&r.emit("update",[d.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const d=new Ga;Tk(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])):$3(t,e+1)}}},tn=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let o=!1,s=null;t._transaction===null&&(o=!0,t._transaction=new VP(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&&$3(i,0)}}return s};class qP{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Dk=(t,e,n)=>{Js(t,n.deletions,r=>{r instanceof on&&e.scope.some(i=>i===t.doc||ad(i,r))&&N1(r,!1)})},Ok=(t,e,n)=>{let r=null;const i=t.doc,o=t.scope;tn(i,a=>{for(;e.length>0&&t.currStackItem===null;){const l=i.store,c=e.pop(),d=new Set,f=[];let h=!1;Js(a,c.insertions,p=>{if(p instanceof on){if(p.redone!==null){let{item:m,diff:v}=Pv(l,p.id);v>0&&(m=Fr(a,_t(m.id.client,m.id.clock+v))),p=m}!p.deleted&&o.some(m=>m===a.doc||ad(m,p))&&f.push(p)}}),Js(a,c.deletions,p=>{p instanceof on&&o.some(m=>m===a.doc||ad(m,p))&&!Uc(c.insertions,p.id)&&d.add(p)}),d.forEach(p=>{h=yE(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 eE extends r3{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:a=bc(e)?e[0].doc:e instanceof ko?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 Vc;l.afterState.forEach((g,y)=>{const C=l.beforeState.get(y)||0,_=g-C;_>0&&od(h,y,C,_)});const p=o9();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=Dv([g.deletions,l.deleteSet]),g.insertions=Dv([g.insertions,h])}else f.push(new qP(l.deleteSet,h)),m=!0;!c&&!d&&(this.lastChange=p),Js(l,l.deleteSet,g=>{g instanceof on&&this.scope.some(y=>y===l.doc||ad(y,g))&&N1(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=bc(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof Jn?r.doc!==this.doc:r!==this.doc)&&L3("[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=>Dk(r,this,i)),this.undoStack=[]),n&&(this.redoStack.forEach(i=>Dk(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=Ok(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ok(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*WP(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 bi(_t(i,o),l),o+=l}else if((wm&a)!==0){const l=(a&(Jo|Er))===0,c=new on(_t(i,o),null,(a&Er)===Er?t.readLeftID():null,null,(a&Jo)===Jo?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(a&ed)===ed?t.readString():null,wE(t,a));yield c,o+=c.length}else{const l=t.readLen();yield new vi(_t(i,o),l),o+=l}}}}class A1{constructor(e,n){this.gen=WP(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===bi);return this.curr}}class T1{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const KP=t=>rp(t,j3,Xd),GP=(t,e)=>{if(t.constructor===vi){const{client:n,clock:r}=t.id;return new vi(_t(n,r+e),t.length-e)}else if(t.constructor===bi){const{client:n,clock:r}=t.id;return new bi(_t(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new on(_t(r,i+e),null,_t(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},rp=(t,e=_c,n=Ga)=>{if(t.length===1)return t[0];const r=t.map(d=>new e(zc(d)));let i=r.map(d=>new A1(d,!0)),o=null;const s=new n,a=new T1(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===bi?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)Cs(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===bi)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{Cs(a,o.struct,o.offset);const m=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new bi(_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===bi?o.struct.length-=m:h=GP(h,m)),o.struct.mergeWith(h)||(Cs(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!==bi;h=d.next())Cs(a,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(Cs(a,o.struct,o.offset),o=null),M1(a);const l=r.map(d=>C1(d)),c=Dv(l);return jc(s,c),s.toUint8Array()},ZP=(t,e,n=_c,r=Ga)=>{const i=K3(e),o=new r,s=new T1(o),a=new n(zc(t)),l=new A1(a,!1);for(;l.curr;){const d=l.curr,f=d.id.client,h=i.get(f)||0;if(l.curr.constructor===bi){l.next();continue}if(d.id.clock+d.length>h)for(Cs(s,d,Gi(h-d.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)Cs(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()}M1(s);const c=C1(a);return jc(o,c),o.toUint8Array()},tE=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Vi(t.encoder.restEncoder)}),t.encoder.restEncoder=Yd(),t.written=0)},Cs=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&tE(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++},M1=t=>{tE(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),km(e,r.restEncoder)}},YP=(t,e,n,r)=>{const i=new n(zc(t)),o=new A1(i,!1),s=new r,a=new T1(s);for(let c=o.curr;c!==null;c=o.next())Cs(a,e(c),0);M1(a);const l=C1(i);return jc(s,l),s.toUint8Array()},JP=t=>YP(t,m9,_c,Xd),Ik="You must not compute changes after the event-handler fired.";class Mm{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=XP(this.currentTarget,this.target))}deletes(e){return Uc(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw wo(Ik);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=Mg(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",a=Mg(l.content.getContent())):(s="add",a=void 0)}else if(this.deletes(o))s="delete",a=Mg(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 wo(Ik);const n=this.target,r=Ka(),i=Ka(),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 XP=(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},fr=()=>{L3("Invalid access: Add Yjs type to a document before reading data.")},nE=80;let D1=0;class QP{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=D1++}}const $P=t=>{t.timestamp=D1++},rE=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=D1++},eL=(t,e,n)=>{if(t.length>=nE){const r=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return rE(r,e,n),r}else{const r=new QP(e,n);return t.push(r),r}},Dm=(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)=>fh(e-o.index)<fh(e-s.index)?o:s);let r=t._start,i=0;for(n!==null&&(r=n.p,i=n.index,$P(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&&fh(n.index-i)<r.parent.length/nE?(rE(n,r,i),n):eL(t._searchMarker,r,i)},cd=(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=Gi(e,i.index+n))}},Om=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;Eo(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;Z3(r._eH,n,e)};class Jn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=_k(),this._dEH=_k(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Si()}clone(){throw Si()}_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){Ck(this._eH,e)}observeDeep(e){Ck(this._dEH,e)}unobserve(e){Sk(this._eH,e)}unobserveDeep(e){Sk(this._dEH,e)}toJSON(){}}const iE=(t,e,n)=>{t.doc??fr(),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},oE=t=>{t.doc??fr();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&&ha(r,e)){const i=r.content.getContent();for(let o=0;o<i.length;o++)n.push(i[o])}r=r.right}return n},ud=(t,e)=>{let n=0,r=t._start;for(t.doc??fr();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}},aE=(t,e)=>{const n=[];return ud(t,(r,i)=>{n.push(e(r,i,t))}),n},tL=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}}}},lE=(t,e)=>{t.doc??fr();const n=Dm(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}},ip=(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 on(_t(s,Tn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Ya(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 on(_t(s,Tn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new $d(new Uint8Array(f))),i.integrate(t,0);break;case ko:i=new on(_t(s,Tn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new ef(f)),i.integrate(t,0);break;default:if(f instanceof Jn)i=new on(_t(s,Tn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Xi(f)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},cE=()=>wo("Length exceeded!"),uE=(t,e,n,r)=>{if(n>e._length)throw cE();if(n===0)return e._searchMarker&&cd(e._searchMarker,n,r.length),ip(t,e,null,r);const i=n,o=Dm(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&&Fr(t,_t(s.id.client,s.id.clock+n));break}n-=s.length}return e._searchMarker&&cd(e._searchMarker,i,r.length),ip(t,e,s,r)},nL=(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 ip(t,e,i,n)},dE=(t,e,n,r)=>{if(r===0)return;const i=n,o=r,s=Dm(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&&Fr(t,_t(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Fr(t,_t(a.id.client,a.id.clock+r)),a.delete(t),r-=a.length),a=a.right;if(r>0)throw cE();e._searchMarker&&cd(e._searchMarker,i,-o+r)},op=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},O1=(t,e,n,r)=>{const i=e._map.get(n)||null,o=t.doc,s=o.clientID;let a;if(r==null)a=new Ya([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new Ya([r]);break;case Uint8Array:a=new $d(r);break;case ko:a=new ef(r);break;default:if(r instanceof Jn)a=new Xi(r);else throw new Error("Unexpected content type")}new on(_t(s,Tn(o.store,s)),i,i&&i.lastId,null,null,e,n,a).integrate(t,0)},I1=(t,e)=>{t.doc??fr();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},fE=t=>{const e={};return t.doc??fr(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},hE=(t,e)=>{t.doc??fr();const n=t._map.get(e);return n!==void 0&&!n.deleted},rL=(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&&ha(o,e)&&(n[i]=o.content.getContent()[o.length-1])}),n},Ef=t=>(t.doc??fr(),yP(t._map.entries(),e=>!e[1].deleted));class iL extends Mm{}class ql extends Jn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ql;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ql}clone(){const e=new ql;return e.insert(0,this.toArray().map(n=>n instanceof Jn?n.clone():n)),e}get length(){return this.doc??fr(),this._length}_callObserver(e,n){super._callObserver(e,n),Om(this,e,new iL(this,e))}insert(e,n){this.doc!==null?tn(this.doc,r=>{uE(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?tn(this.doc,n=>{nL(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?tn(this.doc,r=>{dE(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return lE(this,e)}toArray(){return oE(this)}slice(e=0,n=this.length){return iE(this,e,n)}toJSON(){return this.map(e=>e instanceof Jn?e.toJSON():e)}map(e){return aE(this,e)}forEach(e){ud(this,e)}[Symbol.iterator](){return tL(this)}_write(e){e.writeTypeRef(ML)}}const oL=t=>new ql;class sL extends Mm{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Cc extends Jn{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 Cc}clone(){const e=new Cc;return this.forEach((n,r)=>{e.set(r,n instanceof Jn?n.clone():n)}),e}_callObserver(e,n){Om(this,e,new sL(this,e,n))}toJSON(){this.doc??fr();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof Jn?i.toJSON():i}}),e}get size(){return[...Ef(this)].length}keys(){return Lg(Ef(this),e=>e[0])}values(){return Lg(Ef(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Lg(Ef(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??fr(),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?tn(this.doc,n=>{op(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?tn(this.doc,r=>{O1(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return I1(this,e)}has(e){return hE(this,e)}clear(){this.doc!==null?tn(this.doc,e=>{this.forEach(function(n,r,i){op(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(DL)}}const aL=t=>new Cc,Ls=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&h9(t,e);class Nv{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&pr(),this.right.content.constructor){case Rn:this.right.deleted||qc(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 Rk=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Rn:e.right.deleted||qc(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&Fr(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},Af=(t,e,n,r)=>{const i=new Map,o=r?Dm(e,n):null;if(o){const s=new Nv(o.p.left,o.p,o.index,i);return Rk(t,s,n-o.index)}else{const s=new Nv(null,e._start,0,i);return Rk(t,s,n)}},pE=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Rn&&Ls(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 on(_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()})},qc=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},mE=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Rn&&Ls(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},gE=(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(!Ls(c,l)){s.set(a,c);const{left:d,right:f}=n;n.right=new on(_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},Bg=(t,e,n,r,i)=>{n.currentAttributes.forEach((h,p)=>{i[p]===void 0&&(i[p]=null)});const o=t.doc,s=o.clientID;mE(n,i);const a=gE(t,e,n,i),l=r.constructor===String?new Yi(r):r instanceof Jn?new Xi(r):new al(r);let{left:c,right:d,index:f}=n;e._searchMarker&&cd(e._searchMarker,n.index,l.getLength()),d=new on(_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(),pE(t,e,n,a)},Nk=(t,e,n,r,i)=>{const o=t.doc,s=o.clientID;mE(n,i);const a=gE(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(Ls(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&&Fr(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 on(_t(s,Tn(o.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Yi(l)),n.right.integrate(t,0),n.forward()}pE(t,e,n,a)},vE=(t,e,n,r,i)=>{let o=e;const s=Ci();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&&qc(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}},cL=t=>{let e=0;return tn(t.doc,n=>{let r=t._start,i=t._start,o=Ci();const s=Cv(o);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Rn:qc(s,i.content);break;default:e+=vE(n,r,i,o,s),o=Cv(s),r=i;break}i=i.right}}),e},uL=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&&Q3(t,n.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===Rn&&s.constructor!==vi&&e.add(s.parent)})}tn(n,r=>{Js(t,t.deleteSet,i=>{if(i instanceof vi||!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)cL(i)})},Pk=(t,e,n)=>{const r=n,i=Cv(e.currentAttributes),o=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Xi:case al:case Yi:n<e.right.length&&Fr(t,_t(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}o&&vE(t,o,e.right,i,e.currentAttributes);const s=(e.left||e.right).parent;return s._searchMarker&&cd(s._searchMarker,e.index,-r+n),e};class dL extends Mm{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=[];tn(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},f9(l)||(p.attributes=u9({},l))),d=0;break}p&&n.push(p),a=null}};for(;s!==null;){switch(s.content.constructor){case Xi:case al: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 Yi: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;Ls(v,m)?m!==null&&s.delete(r):(a==="retain"&&h(),Ls(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;Ls(v,m)||(a==="retain"&&h(),l[p]=v)}else if(!s.deleted){o.set(p,m);const v=l[p];v!==void 0&&(Ls(v,m)?v!==null&&s.delete(r):(a==="retain"&&h(),m===null?delete l[p]:l[p]=m))}s.deleted||(a==="insert"&&h(),qc(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 Xs extends Jn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??fr(),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 Xs}clone(){const e=new Xs;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new dL(this,e,n);Om(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??fr();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Yi&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?tn(this.doc,r=>{const i=new Nv(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)&&Bg(r,this,i,a,s.attributes||{})}else s.retain!==void 0?Nk(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&Pk(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??fr();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(ha(l,e)||n!==void 0&&ha(l,n))switch(l.content.constructor){case Yi:{const f=o.get("ychange");e!==void 0&&!ha(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&&!ha(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 Xi:case al:{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:ha(l,e)&&(c(),qc(o,l.content));break}l=l.right}c()};return e||n?tn(s,f=>{e&&Iv(f,e),n&&Iv(f,n),d()},"cleanup"):d(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?tn(i,o=>{const s=Af(o,this,e,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),Bg(o,this,s,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?tn(i,o=>{const s=Af(o,this,e,!r);Bg(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?tn(r,i=>{Pk(i,Af(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?tn(i,o=>{const s=Af(o,this,e,!1);s.right!==null&&Nk(o,this,s,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?tn(this.doc,n=>{op(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?tn(this.doc,r=>{O1(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return I1(this,e)}getAttributes(){return fE(this)}_write(e){e.writeTypeRef(OL)}}const fL=t=>new Xs;class Hg{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??fr()}[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===gn||n.constructor===Za)&&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 Za extends Jn{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 Za}clone(){const e=new Za;return e.insert(0,this.toArray().map(n=>n instanceof Jn?n.clone():n)),e}get length(){return this.doc??fr(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Hg(this,e)}querySelector(e){e=e.toUpperCase();const r=new Hg(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Ys(new Hg(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Om(this,e,new mL(this,n,e))}toString(){return aE(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),ud(this,o=>{i.insertBefore(o.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?tn(this.doc,r=>{uE(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)tn(this.doc,r=>{const i=e&&e instanceof Jn?e._item:e;ip(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 wo("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?tn(this.doc,r=>{dE(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return oE(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return lE(this,e)}slice(e=0,n=this.length){return iE(this,e,n)}forEach(e){ud(this,e)}_write(e){e.writeTypeRef(RL)}}const hL=t=>new Za;class gn extends Za{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 gn(this.nodeName)}clone(){const e=new gn(this.nodeName),n=this.getAttributes();return d9(n,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof Jn?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?tn(this.doc,n=>{op(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?tn(this.doc,r=>{O1(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return I1(this,e)}hasAttribute(e){return hE(this,e)}getAttributes(e){return e?rL(this,e):fE(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 ud(this,s=>{i.appendChild(s.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(IL),e.writeKey(this.nodeName)}}const pL=t=>new gn(t.readKey());class mL extends Mm{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 sp extends Cc{constructor(e){super(),this.hookName=e}_copy(){return new sp(this.hookName)}clone(){const e=new sp(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(NL),e.writeKey(this.hookName)}}const gL=t=>new sp(t.readKey());class In extends Xs{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(PL)}}const vL=t=>new In;class R1{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Si()}mergeWith(e){return!1}write(e,n,r){throw Si()}integrate(e,n){throw Si()}}const bL=0;class vi extends R1{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),X3(e.doc.store,this)}write(e,n){e.writeInfo(bL),e.writeLen(this.length-n)}getMissing(e,n){return null}}class $d{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new $d(this.content)}splice(e){throw Si()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const yL=t=>new $d(t.readBuf());class dd{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new dd(this.len)}splice(e){const n=new dd(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){od(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 wL=t=>new dd(t.readLen()),bE=(t,e)=>new ko({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class ef{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 ef(bE(this.doc.guid,this.opts))}splice(e){throw Si()}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 kL=t=>new ef(bE(t.readString(),t.readAny()));class al{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new al(this.embed)}splice(e){throw Si()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const xL=t=>new al(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 Si()}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 _L=t=>new Rn(t.readKey(),t.readJSON());class ap{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ap(this.arr)}splice(e){const n=new ap(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 CL=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 ap(n)},SL=Qh("node_env")==="development";class Ya{constructor(e){this.arr=e,SL&&f3(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ya(this.arr)}splice(e){const n=new Ya(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 EL=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Ya(n)};class Yi{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Yi(this.str)}splice(e){const n=new Yi(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 AL=t=>new Yi(t.readString()),TL=[oL,aL,fL,pL,hL,gL,vL],ML=0,DL=1,OL=2,IL=3,RL=4,NL=5,PL=6;class Xi{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Xi(this.type._copy())}splice(e){throw Si()}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 LL=t=>new Xi(TL[t.readTypeRef()](t)),Pv=(t,e)=>{let n=e,r=0,i;do r>0&&(n=_t(n.client,n.clock+r)),i=jl(t,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof on);return{item:i,diff:r}},N1=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},lp=(t,e,n)=>{const{client:r,clock:i}=e.id,o=new on(_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},Lk=(t,e)=>u1(t,n=>Uc(n.deletions,e)),yE=(t,e,n,r,i,o)=>{const s=t.doc,a=s.store,l=s.clientID,c=e.redone;if(c!==null)return Fr(t,c);let d=e.parent._item,f=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!n.has(d)||yE(t,d,n,r,i,o)===null))return null;for(;d.redone!==null;)d=Fr(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:Fr(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:Fr(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||Uc(r,f.right.id)||Lk(o.undoStack,f.right.id)||Lk(o.redoStack,f.right.id));)for(f=f.right;f.redone;)f=Fr(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 on(v,f,f&&f.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=v,N1(g,!0),g.integrate(t,0),g};let on=class Lv extends R1{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()?uk:0}set marker(e){(this.info&Og)>0!==e&&(this.info^=Og)}get marker(){return(this.info&Og)>0}get keep(){return(this.info&ck)>0}set keep(e){this.keep!==e&&(this.info^=ck)}get countable(){return(this.info&uk)>0}get deleted(){return(this.info&Dg)>0}set deleted(e){this.deleted!==e&&(this.info^=Dg)}markDeleted(){this.info|=Dg}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===Ul&&this.id.client!==this.parent.client&&this.parent.clock>=Tn(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Ak(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Fr(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===vi||this.right&&this.right.constructor===vi)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Lv?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Lv&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Ul){const r=jl(n,this.parent);r.constructor===vi?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=Ak(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),Rl(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(Rl(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(jl(e.doc.store,i.origin)))o.has(jl(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),X3(e.doc.store,this),this.content.integrate(e,this),Mk(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new vi(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&&Rl(e.origin,this.lastId)&&this.right===e&&Rl(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(),od(e.deleteSet,this.id.client,this.id.clock,this.length),Mk(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw pr();this.content.gc(e),n?HP(e,this,new vi(this.id,this.length)):this.content=new dd(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()&wm|(r===null?0:Er)|(i===null?0:Jo)|(o===null?0:ed);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=sd(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===Ul?(e.writeParentInfo(!1),e.writeLeftID(a)):pr();o!==null&&e.writeString(o)}this.content.write(e,n)}};const wE=(t,e)=>FL[e&wm](t),FL=[()=>{pr()},wL,CL,yL,AL,xL,_L,LL,EL,kL,()=>{pr()}],zL=10;class bi extends R1{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){pr()}write(e,n){e.writeInfo(zL),Lt(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const kE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},xE="__ $YJS$ __";kE[xE]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");kE[xE]=!0;const BL={anthropic:"Claude",openai:"GPT",gemini:"Gemini","local-ollama":"Local model","local-llamacpp":"Local model"},Fk="Assistant";function HL(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 Fv(t,e){const n=HL(t);if(!n)return Fk;const r=BL[n.provider]||Fk;return e==="family"?r:n.displayName||n.modelId||r}function Ao(t){const e=N(()=>Fv(t.settings,"family")),n=N(()=>Fv(t.settings,"model"));return{get family(){return u(e)},get specific(){return u(n)}}}function _E(t){return t?t+1:0}function Im(t){let e=0;return t.forEach(n=>{n.isText?e+=n.text.length:n.type.name==="hardBreak"&&(e+=1)}),e}function tf(t){if(t.isTextblock)return Im(t);let e=0;for(let n=0;n<t.childCount;n++)n>0&&(e+=1),e+=tf(t.child(n));return e}function CE(t,e,n){if(t.isTextblock)return zn(n+Math.min(e,Im(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=tf(s);if(r+l>e)return CE(s,e-r,a);r+=l,i+=s.nodeSize}return zn(n+t.content.size)}function Qs(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"?_E(s.attrs.level||1):0,c=tf(s),d=l+c;if(n+d>e){const f=e-n,h=Math.max(0,f-l);return CE(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 SE(t,e,n){if(t.isTextblock)return Math.min(e-n,Im(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+SE(s,e,a);r+=tf(s),i+=s.nodeSize}return r}function gi(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"?_E(s.attrs.level||1):0,c=tf(s),d=r+s.nodeSize;if(e<d)return e<=a?ah(n+l):ah(n+l+SE(s,e,a));n+=l+c,r+=s.nodeSize,o<i-1&&(n+=1)}return ah(n)}function EE(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,Im(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 gn){const d=EE(a,l,c,r);if(d!==null)return d}i+=l.nodeSize}return null}function zk(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 gn){const c=EE(s,a,l,n);if(c!==null)return c}r+=a.nodeSize}return null}function AE(t,e,n){let r,i;try{const l=La(n.fromRel),c=La(n.toRel);r=Ov(l,t),i=Ov(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=zk(e,o,r),a=zk(e,o,i);return s===null||a===null?null:{from:s,to:a}}function Sc(t,e,n){if(t.relRange&&n){const r=AE(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:Qs(e,t.range.from),to:Qs(e,t.range.to),method:"flat"}:null}function TE(t,e){return{from:gi(t,e.from),to:gi(t,e.to)}}function VL(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function UL(t){const e=VL(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 jL=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>'),qL=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>'),WL=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>'),KL=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>'),GL=T('<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>'),ZL=T('<div class="chat-markdown svelte-15oag3v"></div>'),YL=T('<div style="white-space: pre-wrap; word-break: break-word;"> </div>'),JL=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>'),XL=T("<span></span>"),QL=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>'),$L=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>'),e7=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 Bk(t,e){et(e,!0);const n=[0,.2,.4],r=Ao(oi());let i=Ye(e,"inputEl",15,null);const o=N(()=>e.reduceMotion?"auto":"smooth");let s=L(at([])),a=L(""),l=L(void 0),c=L(void 0);me(()=>{i(u(c)??null)}),me(()=>{if(!e.ctrlYdoc)return;const q=e.ctrlYdoc.getMap(lw),H=()=>{const ne=[];q.forEach(te=>{ne.push(te)}),ne.sort((te,Z)=>te.timestamp-Z.timestamp||te.id.localeCompare(Z.id)),b(s,ne,!0)};return q.observe(H),H(),()=>q.unobserve(H)});let d=!1;me(()=>{var ne;u(s);const q=!!e.claudeActive,H=Mt(()=>u(o));if(!q&&d){d=!1;return}d=q,(ne=u(l))==null||ne.scrollIntoView({behavior:H})}),me(()=>{var ne;const q=e.visible,H=Mt(()=>u(o));q&&((ne=u(l))==null||ne.scrollIntoView({behavior:H}))});const f=N(()=>u(s).filter(q=>q.author==="claude"&&!q.read).length);function h(){if(!e.ctrlYdoc||!u(a).trim())return;const q=e.ctrlYdoc.getMap(lw),H={id:FD(),author:"user",text:u(a).trim(),timestamp:Date.now(),...e.activeDocId?{documentId:e.activeDocId}:{},...e.capturedAnchor?{anchor:e.capturedAnchor}:{},read:!1};q.set(H.id,H),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,H){if(!(!e.editor||H&&H!==e.activeDocId))try{const ne=Qs(e.editor.state.doc,q.from),te=Qs(e.editor.state.doc,q.to);e.editor.chain().focus().setTextSelection({from:ne,to:te}).scrollIntoView().run()}catch(ne){console.warn("[ChatPanel] Could not scroll to anchor:",ne instanceof Error?ne.message:ne)}}function v(q){if(!q)return null;const H=e.openDocs.find(ne=>ne.id===q);return(H==null?void 0:H.fileName)??null}async function g(){try{await fetch(`http://127.0.0.1:${ji}${nO}`,{method:"DELETE"})}catch(q){console.warn("[ChatPanel] Failed to clear chat:",q)}}let y=L(at(new Set));function C(q){const H=new Set(u(y));H.has(q)?H.delete(q):H.add(q),b(y,H,!0)}var _=e7(),S=w(_),A=k(w(S)),O=w(A);{var E=q=>{var H=jL(),ne=w(H);W(()=>G(ne,u(f))),x(q,H)};j(O,q=>{u(f)>0&&q(E)})}var M=k(O,2);{var R=q=>{var H=qL();P("click",H,g),x(q,H)};j(M,q=>{u(s).length>0&&q(R)})}var D=k(S,2),I=w(D);{var B=q=>{var H=WL();x(q,H)};j(I,q=>{u(s).length===0&&q(B)})}var z=k(I,2);pt(z,17,()=>u(s),q=>q.id,(q,H)=>{var ne=JL(),te=w(ne),Z=w(te),ge=w(Z),De=k(Z,2);{var Ee=Oe=>{var ze=KL(),Xe=w(ze);W(ue=>G(Xe,ue),[()=>v(u(H).documentId)??u(H).documentId]),x(Oe,ze)};j(De,Oe=>{u(H).documentId&&Oe(Ee)})}var de=k(De,2),_e=w(de),J=k(te,2);{var ye=Oe=>{var ze=GL(),Xe=w(ze);W(ue=>{Le(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(Xe,u(H).anchor.textSnapshot)},[()=>u(y).has(u(H).id)?"500px":"60px"]),P("click",ze,()=>m(u(H).anchor,u(H).documentId)),hn("mouseenter",ze,()=>C(u(H).id)),hn("mouseleave",ze,()=>C(u(H).id)),x(Oe,ze)};j(J,Oe=>{u(H).anchor&&Oe(ye)})}var Y=k(J,2);{var se=Oe=>{var ze=ZL();EM(ze,()=>UL(u(H).text),!0),x(Oe,ze)},Te=Oe=>{var ze=YL(),Xe=w(ze);W(()=>G(Xe,u(H).text)),x(Oe,ze)};j(Y,Oe=>{u(H).author==="claude"?Oe(se):Oe(Te,-1)})}W(Oe=>{Le(ne,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${u(H).author==="user"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; border: 1px solid ${u(H).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);`),Le(Z,`font-weight: 600; font-size: 11px; color: ${u(H).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"}; text-transform: uppercase;`),G(ge,u(H).author==="claude"?r.family:"You"),G(_e,Oe)},[()=>new Date(u(H).timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]),x(q,ne)});var Q=k(z,2);{var ie=q=>{var H=QL(),ne=w(H);pt(ne,20,()=>n,ge=>ge,(ge,De)=>{var Ee=XL();W(()=>Le(Ee,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${De??""}s infinite;`)),x(ge,Ee)});var te=k(ne,2),Z=w(te);W(()=>G(Z,e.claudeStatus??"Your AI is thinking...")),x(q,H)};j(Q,q=>{e.claudeActive&&q(ie)})}var he=k(Q,2);Ot(he,q=>b(l,q),()=>u(l)),Ur(D,(q,H)=>Yt==null?void 0:Yt(q,H),()=>"y");var ae=k(D,2);{var ke=q=>{var H=$L(),ne=w(H),te=w(ne),Z=k(ne,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,H)};j(ae,q=>{e.capturedAnchor&&q(ke)})}var le=k(ae,2),be=w(le),Re=w(be);U(Re,"rows",2),Ot(Re,q=>b(c,q),()=>u(c));var $=k(Re,2);W((q,H)=>{Br(Re,u(a)),$.disabled=q,vt($,1,H,"svelte-15oag3v")},[()=>!u(a).trim(),()=>"chat-composer-send"+(u(a).trim()?" on":"")]),P("input",Re,q=>b(a,q.target.value,!0)),P("keydown",Re,p),P("click",$,h),x(t,_),tt()}ut(["click","input","keydown"]);var t7=T('<button type="button" data-testid="apply-changes-btn"> </button>');function n7(t,e){et(e,!0);let n=L(!1);const r=N(()=>e.annotations.filter(d=>d.status==="accepted")),i=N(()=>e.annotations.filter(d=>d.status==="pending")),o=N(()=>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(`${Qt}${GD}`,{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=t7();let h;var p=w(f);W(()=>{h=vt(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),tt()}ut(["click"]);function ME(t,e){return t.id<e.id?-1:t.id>e.id?1:0}function vu(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:ME(e,n)})}function r7(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:ME(e,n)})}function Hk(t,e){return e==="chronological"?r7(t):vu(t)}function DE(t,e){if(!e)return-1;for(let n=0;n<t.length;n++)if(t[n].id===e)return n;return-1}function Vk(t,e){if(t.length===0)return null;const n=DE(t,e);return n===-1?t[0].id:t[(n+1)%t.length].id}function Uk(t,e){if(t.length===0)return null;const n=DE(t,e);return n===-1?t[t.length-1].id:t[(n-1+t.length)%t.length].id}const vl={background:"var(--tandem-warning-bg)",border:"var(--tandem-warning-border)",color:"var(--tandem-warning-fg-strong)"};function P1(t,e){return t.type==="highlight"?[]:e??[]}var i7=T('<button class="aca-btn aca-btn--accept svelte-1u9ox5p">Accept</button>'),o7=T('<button class="aca-btn aca-btn--reject svelte-1u9ox5p">Reject</button>'),s7=T('<div class="aca-row svelte-1u9ox5p"><!> <!></div>'),a7=T('<button class="aca-btn aca-btn--ghost svelte-1u9ox5p">Archive</button>'),l7=T('<button class="aca-btn aca-btn--send svelte-1u9ox5p"> </button>'),c7=T('<div class="aca-row svelte-1u9ox5p"><!> <!></div>'),u7=T('<button class="aca-btn aca-btn--ghost aca-standalone svelte-1u9ox5p">Remove</button>'),d7=T(`<div class="aca-undo-error svelte-1u9ox5p">Can't undo — text has changed.</div>`),f7=T('<div class="aca-undo-row svelte-1u9ox5p"><button data-testid="undo-btn" class="aca-undo svelte-1u9ox5p">Undo</button> <!></div>');function h7(t,e){et(e,!0);const n=Ao(oi());let r=L(!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=s7(),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=o7();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=c7(),v=w(m);{var g=_=>{var S=a7();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=u7();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=f7(),v=w(m),g=k(v,2);{var y=C=>{var _=d7();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),tt()}ut(["click"]);const vh="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 p7=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),m7=T("<textarea></textarea>"),g7=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 v7(t,e){et(e,!0);let n=L(null);me(()=>{var d;(d=u(n))==null||d.focus()});var r=g7(),i=w(r);{var o=d=>{var f=p7(),h=Ae(f),p=k(h,2);Ot(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??""}`),Br(p,e.editNewText),Le(p,vh),U(m,"for",`edit-reason-${e.annotationId??""}`),U(v,"id",`edit-reason-${e.annotationId??""}`),U(v,"data-testid",`edit-reason-${e.annotationId??""}`),Br(v,e.editReason),Le(v,vh)}),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=m7();Ot(f,h=>b(n,h),()=>u(n)),W(()=>{U(f,"data-testid",`edit-text-${e.annotationId??""}`),Br(f,e.editText),Le(f,vh)}),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),tt()}ut(["click","keydown","input"]);function b7(t,e){return t==="claude"?e??"Assistant":t==="import"?"Imported":"You"}function OE(t){return t.suggestedText!==void 0?"replacement":t.type}function y7(t,e){return t?t.length>e?t.slice(0,e-3)+"...":t:""}function w7(t){const e=OE(t),n=y7(t.content,60);return`${t.type==="note"?"private ":""}${e} annotation${n?": "+n:""}, ${t.status}`}function k7(t){return t.type==="highlight"&&t.color?Wu[_C(t.color)]:"var(--tandem-author-user)"}var x7=T("<span> </span>"),_7=T(`<button class="ach-edit-btn svelte-d1dbnh" title="Edit this annotation's content">✎ Edit</button>`),C7=T('<span class="ach-edited svelte-d1dbnh">(edited)</span>'),S7=T('<span class="ach-dot svelte-d1dbnh" aria-hidden="true"></span>'),E7=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 nf(t,e){et(e,!0);const n=Ao(oi()),r=N(()=>OE(e.annotation)),i=N(()=>b7(e.annotation.author,n.family)),o=N(()=>e.annotation.author==="claude"?"var(--tandem-author-claude)":"var(--tandem-author-user)");var s=E7(),a=w(s),l=w(a),c=w(l),d=k(l,2);{var f=O=>{var E=St(),M=Ae(E);jd(M,()=>e.extraPill),x(O,E)};j(d,O=>{e.extraPill&&O(f)})}var h=k(d,2);{var p=O=>{var E=x7();let M;var R=w(E);W(()=>{M=vt(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=_7();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=C7();x(O,E)};j(y,O=>{e.annotation.editedAt&&O(C)})}var _=k(y,2);{var S=O=>{var E=S7();W(()=>Le(E,`background: ${u(o)??""};`)),x(O,E)};j(_,O=>{e.annotation.author!=="import"&&O(S)})}var A=k(_);W(()=>{Le(l,`background: ${e.badgeBg??""}; color: ${e.badgeFg??""};`),G(c,u(r)),G(A,` ${u(i)??""}`)}),x(t,s),tt()}ut(["click"]);var A7=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 rf(t,e){et(e,!0);const n=N(()=>e.text?e.text.length>80?e.text.slice(0,77)+"...":e.text:"");var r=St(),i=Ae(r);{var o=s=>{var a=A7(),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),tt()}var T7=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),M7=T("<!> <!> <!>",1);function D7(t,e){et(e,!0);var n=M7(),r=Ae(n);nf(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);rf(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=T7(),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),tt()}var O7=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),I7=T("<!> <!> <!>",1);function R7(t,e){et(e,!0);var n=I7(),r=Ae(n);nf(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);rf(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=O7(),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),tt()}var N7=T('<input type="checkbox" style="margin-top: 4px; flex-shrink: 0; cursor: pointer;"/>'),P7=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>'),L7=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),F7=T('<div style="display: flex; align-items: flex-start; gap: var(--tandem-space-2);"><!> <div style="flex: 1; min-width: 0;"><!> <!> <!> <!></div></div>');function z7(t,e){et(e,!0);let n=Ye(e,"selected",3,!1);var r=F7(),i=w(r);{var o=p=>{var m=N7();W(()=>{var v;U(m,"data-testid",`annotation-select-checkbox-${e.annotation.id??""}`),Kn(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);nf(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=P7(),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);rf(d,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var f=k(d,2);{var h=p=>{var m=L7(),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),tt()}ut(["click","change"]);var B7=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>'),H7=T('<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),V7=T("<!> <!> <!>",1);function U7(t,e){et(e,!0);var n=V7(),r=Ae(n);nf(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=B7();x(l,c)},$$slots:{extraPill:!0}});var i=k(r,2);rf(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=H7(),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),tt()}var j7=T('<span class="ct-author-dot ct-author-dot--claude svelte-4l0b78" aria-hidden="true"></span> ',1),q7=T("<span> </span>"),W7=T('<span class="ct-author-dot ct-author-dot--user svelte-4l0b78" aria-hidden="true"></span> You',1),K7=T('<span class="ct-edited svelte-4l0b78">(edited)</span>'),G7=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>'),Z7=T('<div class="ct-root svelte-4l0b78" data-testid="comment-thread"></div>');function Y7(t,e){et(e,!0);const n=Ao(oi());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=Z7();pt(l,21,()=>e.replies,c=>c.id,(c,d)=>{const f=N(()=>u(d).author==="claude"?"claude":u(d).author==="import"?"import":"user");var h=G7(),p=w(h),m=w(p);let v;var g=w(m);{var y=D=>{var I=j7(),B=k(Ae(I));W(()=>G(B,` ${n.family??""}`)),x(D,I)},C=D=>{var I=q7(),B=w(I);W(()=>{U(I,"data-testid",`reply-import-byline-${u(d).id??""}`),G(B,u(d).importAuthor??"Imported")}),x(D,I)},_=D=>{var I=W7();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=K7();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=vt(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),tt()}var J7=T('<div class="art-replies svelte-155xn9n"><!></div>'),X7=T('<button type="button"><span class="art-arrow svelte-155xn9n" aria-hidden="true">›</span> </button> <!>',1),Q7=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>'),$7=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>'),eF=T('<div style="margin-top: 6px;"><!></div>'),tF=T('<div class="art-root svelte-155xn9n"><!> <!></div>');function nF(t,e){et(e,!0);let n=Ye(e,"reduceMotion",3,!1),r=Ye(e,"openNonce",3,0);const i=N(()=>P1(e.annotation,e.replies)),o=N(()=>e.annotation.id);let s=L(!1),a=L(!1),l=L(""),c=L(!1),d=L(null);const f=N(()=>!!u(l).trim());me(()=>{var S;u(a)&&((S=u(d))==null||S.focus())});let h=Mt(()=>r());me(()=>{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=tF(),g=w(v);{var y=S=>{var A=X7(),O=Ae(A);let E;var M=k(w(O)),R=k(O,2);{var D=I=>{var B=J7(),z=w(B);Y7(z,{get replies(){return u(i)}}),Wi(3,B,()=>rN,()=>({reduceMotion:n()})),x(I,B)};j(R,I=>{u(s)&&I(D)})}W(()=>{U(O,"data-testid",`reply-toggle-${u(o)??""}`),E=vt(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=eF(),O=w(A);{var E=R=>{var D=Q7(),I=w(D);Ot(I,ie=>b(d,ie),()=>u(d));var B=k(I,2),z=w(B),Q=k(z,2);W(()=>{U(I,"data-testid",`reply-input-${u(o)??""}`),Br(I,u(l)),Le(I,vh),U(z,"data-testid",`reply-send-btn-${u(o)??""}`),z.disabled=!u(f)||u(c),Le(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=$7();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),tt()}ut(["click","keydown","input"]);var rF=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>'),oF=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>'),sF=T("<!> <!> <!>",1);function aF(t,e){et(e,!0);var n=sF(),r=Ae(n);nf(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);rf(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);{var f=g=>{var y=rF(),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??""}`),Le(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),tt()}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>'),cF=T('<div role="listitem"><!> <!> <!> <!> <!></div>');function zv(t,e){et(e,!0);let n=Ye(e,"replies",19,()=>[]),r=Ye(e,"claudeTyping",3,!1),i=Ye(e,"selected",3,!1),o=Ye(e,"density",3,"full"),s=Ye(e,"lifecycleMotion",3,!1),a=Ye(e,"reduceMotion",3,!1),l=Ye(e,"openRequest",3,null);const c=Ao(oi());let d=L(!1),f=L(""),h=L(""),p=L("");const m=N(()=>e.annotation.status==="pending"),v=N(()=>e.annotation.suggestedText!==void 0),g=N(()=>e.onEdit!==void 0),y=N(()=>w7(e.annotation)),C=N(()=>P1(e.annotation,n())),_=N(()=>o()==="stub"?"stub":u(d)?"full":o());let S=-1,A=-1,O=L(0);me(()=>{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=N(()=>e.annotation.author==="import"?"var(--tandem-surface-muted)":e.annotation.type==="highlight"?`color-mix(in srgb, ${k7(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=N(()=>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 B(Z){Z.key==="Escape"&&(Z.stopPropagation(),I())}var z=cF();let Q;var ie=w(z);{var he=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(he)})}var ae=k(ie,2);{var ke=Z=>{z7(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}})},le=Z=>{R7(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})},be=Z=>{U7(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})},Re=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})},$=Z=>{D7(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(ae,Z=>{e.annotation.author==="import"?Z(ke):e.annotation.type==="highlight"?Z(le,1):e.annotation.type==="note"?Z(be,2):e.annotation.suggestedText!==void 0?Z(Re,3):Z($,-1)})}var q=k(ae,2);{var H=Z=>{v7(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:B,onSave:D,onCancel:I})};j(q,Z=>{u(d)&&Z(H)})}var ne=k(q,2);h7(ne,{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(ne,2);nF(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=vt(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),Le(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)}),Wi(1,z,()=>ZR,()=>({enabled:s(),reduceMotion:a()})),Wi(2,z,()=>YR,()=>({enabled:s(),reduceMotion:a(),id:e.annotation.id,modes:e.exitModes})),x(t,z),tt()}ut(["click"]);const uF="browser";function dF(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 Xo(t,e){return dF(t,e,uF)}function Ja(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 L1=t=>{console.warn("[sanitize]",t)};function IE(t,e,n){if(!t)return;const r=t.getMap(Mi),i=r.get(e);if(!i)return;const o=Ja(i,L1);Xo(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 RE(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 NE(t,e){if(!t)return;const n=t.getMap(Mi),r=n.get(e);if(!r)return;const i=Ja(r,L1);i.type==="note"&&Xo(t,()=>{n.set(e,RE(i))})}function fF(t,e){if(!t||e.length===0)return 0;const n=t.getMap(Mi);let r=0;return Xo(t,()=>{for(const i of e){const o=n.get(i);if(!o)continue;const s=Ja(o,L1);s.type==="note"&&(n.set(i,RE(s)),r++)}}),r}async function PE(t,e){try{const n=await fetch(`${Qt}${eO}`,{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 LE(t,e,n){try{const r=await fetch(`${Qt}${$D}`,{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 hF=["ctx:annotation:accept","ctx:annotation:dismiss","ctx:annotation:reply","ctx:annotation:edit","ctx:annotation:sendToClaude","ctx:annotation:copy","ctx:annotation:remove"],pF=new Set(hF);function mF(t){return typeof t=="string"&&pF.has(t)}const Wc=t=>t.status==="pending",Rm=t=>t.author!=="user"&&Wc(t),Nm=t=>t.author!=="user"&&Wc(t),Pm=t=>(t.type==="note"||t.type==="comment")&&Wc(t),Lm=t=>t.author==="user"&&Wc(t),Fm=t=>t.author==="user"&&t.type==="note"&&Wc(t),zm=t=>t.author==="user"&&Wc(t),gF=t=>!0;function vF(t){return{canAccept:Rm(t),canDismiss:Nm(t),canReply:Pm(t),canEdit:Lm(t),canSendToClaude:Fm(t),canCopy:gF(),canRemove:zm(t),isNote:t.type==="note"}}function bF(t){var n;return((n=t.content)==null?void 0:n.trim())?t.content:t.textSnapshot??""}let bh=null;function yF(t){bh=t}function FE(t,e,n){var r,i,o,s,a,l;switch(t){case"ctx:annotation:accept":Rm(e)&&((r=n.accept)==null||r.call(n,e.id));return;case"ctx:annotation:dismiss":Nm(e)&&((i=n.dismiss)==null||i.call(n,e.id));return;case"ctx:annotation:sendToClaude":Fm(e)&&((o=n.sendToClaude)==null||o.call(n,e.id));return;case"ctx:annotation:remove":zm(e)&&((s=n.remove)==null||s.call(n,e.id));return;case"ctx:annotation:edit":Lm(e)&&((a=n.openEdit)==null||a.call(n,e.id));return;case"ctx:annotation:reply":Pm(e)&&((l=n.openReply)==null||l.call(n,e.id));return;case"ctx:annotation:copy":{const c=bF(e);c&&navigator.clipboard.writeText(c).catch(()=>{})}return}}async function zE(t,e){yF({run:e});try{await(await ss())("show_annotation_context_menu",{req:vF(t)})}catch{}}let Tf=0,Mf=null;function BE(){if(!Tt())return()=>{};Tf++,Tf===1&&(Mf=Kt(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;mF(r)&&(bh==null||bh.run(r))})),Mf.catch(()=>{}));let t=!1;return()=>{if(!t&&(t=!0,Tf--,Tf===0)){const e=Mf;Mf=null,e==null||e.then(n=>n()).catch(()=>{})}}}var wF=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 kF(t,e){et(e,!0);let n=Ye(e,"reduceMotion",3,!1);const r=Ao(oi());var i=St(),o=Ae(i);{var s=a=>{var l=wF(),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)}),Wi(1,l,()=>e3,()=>({reduceMotion:n()})),Wi(2,l,()=>t3,()=>({reduceMotion:n(),exitMs:200})),x(a,l)};j(o,a=>{e.selectedCount>0&&a(s)})}x(t,i),tt()}ut(["click"]);var xF=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),_F=T('<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>',1),CF=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 SF(t,e){et(e,!0);let n=Ye(e,"confirmRef",15,null),r=Ye(e,"reduceMotion",3,!1);const i=N(()=>e.bulkConfirm==="accept"),o=N(()=>e.pendingCount===e.allPendingCount?`${e.pendingCount} annotations?`:`${e.pendingCount} of ${e.allPendingCount} pending?`);var s=St(),a=Ae(s);{var l=c=>{var d=CF(),f=w(d);{var h=m=>{var v=xF(),g=Ae(v),y=w(g),C=k(g,2);Ot(C,S=>n(S),()=>n());var _=k(C,2);Le(_,"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)??""}`),Le(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=_F(),g=Ae(v);Le(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);Le(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)})}Wi(1,d,()=>e3,()=>({reduceMotion:r()})),Wi(2,d,()=>t3,()=>({reduceMotion:r(),exitMs:180})),x(c,d)};j(a,c=>{e.pendingCount>1&&c(l)})}x(t,s),tt()}ut(["click"]);function ys(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 EF=(t,e=kn)=>{var n=St(),r=Ae(n);{var i=f=>{var h=AF();x(f,h)},o=f=>{var h=TF();x(f,h)},s=f=>{var h=MF();x(f,h)},a=f=>{var h=DF();x(f,h)},l=f=>{var h=OF();x(f,h)},c=f=>{var h=IF();x(f,h)},d=f=>{var h=RF();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 AF=rn('<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>'),TF=rn('<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>'),MF=rn('<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>'),DF=rn('<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>'),OF=rn('<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>'),IF=rn('<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>'),RF=rn('<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>'),NF=T('<span class="chip-text"> </span>'),PF=T("<span></span>"),LF=T('<button type="button" role="radio"><!></button>'),FF=T('<div class="chip-bar svelte-v4eg2o" role="radiogroup" tabindex="-1"><span aria-hidden="true"></span> <!></div>');function Vg(t,e){et(e,!0);let n=Ye(e,"value",3,""),r=Ye(e,"options",19,()=>[]),i=Ye(e,"onSet",3,()=>{}),o=Ye(e,"groupAriaLabel",3,""),s=Ye(e,"groupTestId",3,"");const a=Mt(()=>r().map(g=>g.value)),l=ys(()=>n(),a,g=>i()(g));let c=L(null),d=L(at({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)}))}me(()=>{if(n(),!u(c))return;let g=!1;return uC().then(()=>{g||requestAnimationFrame(()=>{g||f()})}),()=>{g=!0}}),me(()=>{if(!u(c))return;const g=new ResizeObserver(()=>f());return g.observe(u(c)),()=>g.disconnect()});var h=FF(),p=w(h);let m;var v=k(p,2);pt(v,17,r,g=>g.value,(g,y)=>{const C=N(()=>u(y).value===n());var _=LF();let S;var A=w(_);{var O=R=>{var D=NF(),I=w(D);W(()=>G(I,u(y).label)),x(R,D)},E=R=>{var D=PF();W(()=>vt(D,1,`pip pip-${u(y).pip??""}`,"svelte-v4eg2o")),x(R,D)},M=R=>{EF(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=vt(_,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,_)}),Ot(h,g=>b(c,g),()=>u(c)),W(()=>{U(h,"aria-label",o()),U(h,"data-testid",s()),m=vt(p,1,"chip-thumb svelte-v4eg2o",null,m,{ready:u(d).ready}),Le(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),tt()}ut(["keydown","click"]);var zF=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>'),BF=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 HF(t,e){et(e,!0);const n=Ao(oi()),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=N(()=>[{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=BF(),f=w(d);Vg(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);Vg(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);Vg(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=zF();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),tt()}ut(["click"]);var VF=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>'),UF=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>`),jF=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>'),qF=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>'),WF=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>'),KF=T('<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>'),GF=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 jk(t,e){et(e,!0);let n=Ye(e,"storeReadOnly",3,!1),r=Ye(e,"claudeWorkingAnnotationId",3,null);const i=N(()=>e.reduceMotion?"auto":"smooth"),o="tandem:storeReadOnlyBannerDismissed";function s(){try{return localStorage.getItem(o)==="true"}catch{return!1}}let a=L(at(s()));me(()=>{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=L(at(d()));function h(){b(f,u(f)==="position"?"chronological":"position",!0);try{localStorage.setItem(c,u(f))}catch{}}let p=L(!1),m=L(null);async function v(){if(!u(p)){b(p,!0),b(m,null);try{const K=await fetch(`${Qt}${tO}`,{method:"POST"});if(!K.ok){let fe="Could not reclaim the annotation store lock.";try{const Pe=await K.json();typeof(Pe==null?void 0:Pe.message)=="string"&&Pe.message&&(fe=Pe.message)}catch{}b(m,fe,!0)}}catch{b(m,"Could not reach the Tandem server.")}finally{b(p,!1)}}}let g=L("all"),y=L("all"),C=L("all"),_=L(!1),S=L(null),A=L(void 0),O=L(null);me(()=>{var K;u(S)&&((K=u(O))==null||K.focus())}),me(()=>{u(g),u(y),u(C),b(S,null)}),me(()=>{var K;(K=e.onFilterChange)==null||K.call(e,u(g),u(y),u(C))});let E=L(at(new Map));me(()=>{if(!e.ydoc){b(E,new Map,!0);return}const K=e.ydoc.getMap(TC);function fe(){const Pe=new Map;K.forEach(Be=>{const Ke=Be;if(Ke&&typeof Ke=="object"&&Ke.annotationId){const We=Pe.get(Ke.annotationId)??[];We.push(Ke),Pe.set(Ke.annotationId,We)}});for(const Be of Pe.values())Be.sort((Ke,We)=>Ke.timestamp-We.timestamp);b(E,Pe,!0)}return fe(),K.observe(fe),()=>K.unobserve(fe)});const M=N(()=>{const K=[],fe=[];for(const Ue of e.annotations){Ue.status==="pending"&&fe.push(Ue);let nt;u(g)==="all"?nt=!0:u(g)==="with-replacement"?nt=Ue.suggestedText!==void 0:nt=Ue.type===u(g);const rt=u(y)==="all"||Ue.author===u(y),xt=u(C)==="all"||Ue.status===u(C);nt&&rt&&xt&&K.push(Ue)}const Pe=Hk(K.filter(Ue=>Ue.status==="pending"),u(f)),Be=K.filter(Bh),Ke=Hk(K.filter(Ue=>Ue.status!=="pending"),u(f)),We=e.annotations.filter(Bh);return{filtered:K,pending:Pe,reviewPending:Be,resolved:Ke,allPending:fe,reviewAllPending:We}}),R=Ao(oi()),D=N(()=>u(g)!=="all"||u(y)!=="all"||u(C)!=="all"),I=N(()=>{if(!u(D))return"All";const K=[];if(u(g)!=="all"){const fe={all:"All",highlight:"Highlights",comment:"Comments",note:"Notes","with-replacement":"With replacement"};K.push(fe[u(g)])}if(u(y)!=="all"){const fe={all:"Anyone",claude:R.family,user:"You",import:"Imported"};K.push(fe[u(y)])}if(u(C)!=="all"){const fe={all:"Any status",pending:"Pending",accepted:"Accepted",dismissed:"Dismissed"};K.push(fe[u(C)])}return K.join(" · ")||"All"});let B=!1;me(()=>{if(u(g),u(y),u(C),!B){B=!0;return}Mt(()=>{var K;if(e.activeAnnotationId){const fe=document.querySelector(`[data-testid="annotation-card-${e.activeAnnotationId}"]`);if(fe){fe.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})})}),me(()=>{const K=e.activeAnnotationId;if(!K)return;const fe=u(i),Pe=e.reduceMotion||typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,Be=setTimeout(()=>{const Ke=document.querySelector(`[data-testid="annotation-card-${K}"]`);if(!Ke){console.warn(`[tandem] SidePanel: active annotation ${K} not found after 50ms delay; scroll-to-card skipped`);return}if(Ke.scrollIntoView({behavior:fe,block:"nearest"}),Pe)return;Ke.classList.add("tandem-annotation-flash");const We=Ue=>{Ue.animationName.includes("tandem-annotation-flash")&&(Ke.classList.remove("tandem-annotation-flash"),Ke.removeEventListener("animationend",We))};Ke.addEventListener("animationend",We)},50);return()=>clearTimeout(Be)});const z=(K,fe)=>IE(e.ydoc,K,fe),Q=K=>NE(e.ydoc,K),ie=K=>PE(K,e.documentId),he=(K,fe)=>LE(K,fe,e.documentId),ae=new Map;function ke(K){ae.set(K,"accept"),e.review.handleAccept(K)}function le(K){ae.set(K,"dismiss"),e.review.handleDismiss(K)}let be=L(void 0),Re=L(null),$=0;function q(K){return e.annotations.find(fe=>fe.id===K)}function H(K){return fe=>{const Pe=q(K);Pe&&FE(fe,Pe,{accept:ke,dismiss:le,sendToClaude:Q,remove:ie,openEdit:Be=>b(Re,{id:Be,kind:"edit",nonce:++$},!0),openReply:Be=>b(Re,{id:Be,kind:"reply",nonce:++$},!0)})}}async function ne(K){var Ke;if(!Tt())return;const fe=(Ke=K.target)==null?void 0:Ke.closest("[data-annotation-id]"),Pe=fe==null?void 0:fe.getAttribute("data-annotation-id");if(!Pe)return;const Be=q(Pe);Be&&(K.preventDefault(),K.stopPropagation(),await zE(Be,H(Pe)))}me(()=>{const K=u(be);if(K)return K.addEventListener("contextmenu",ne),()=>K.removeEventListener("contextmenu",ne)}),me(()=>BE());function te(K){for(const fe of u(M).reviewPending)e.review.resolveAnnotation(fe.id,K);b(S,null)}let Z=L(at(new Set));me(()=>{const K=new Set(u(M).pending.filter(fe=>fe.author==="import"&&fe.type==="note").map(fe=>fe.id));Mt(()=>{const fe=new Set([...u(Z)].filter(Pe=>K.has(Pe)));fe.size!==u(Z).size&&b(Z,fe,!0)})});function ge(K){const fe=new Set(u(Z));fe.has(K)?fe.delete(K):fe.add(K),b(Z,fe,!0)}function De(){const K=Array.from(u(Z));fF(e.ydoc,K),b(Z,new Set,!0)}function Ee(){b(Z,new Set,!0)}function de(K){K.target===K.currentTarget&&e.onActiveAnnotationChange(null)}var _e=GF(),J=w(_e);{var ye=K=>{var fe=UF(),Pe=w(fe),Be=k(w(Pe),2),Ke=w(Be),We=w(Ke),Ue=k(Ke,2),nt=k(Pe,2);{var rt=xt=>{var qt=VF(),Je=w(qt);W(()=>G(Je,u(m))),x(xt,qt)};j(nt,xt=>{u(m)&&xt(rt)})}W(()=>{Le(fe,`padding: 10px 14px; margin: 10px 14px 0; background: ${vl.background}; border: 1px solid ${vl.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${vl.color}; display: flex; flex-direction: column; gap: var(--tandem-space-2);`),Ke.disabled=u(p),Le(Ke,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: 1px solid ${vl.border}; border-radius: var(--tandem-r-2); background: none; color: ${vl.color}; cursor: ${u(p)?"wait":"pointer"}; font-weight: 500;`),G(We,u(p)?"Reclaiming…":"Reclaim"),Le(Ue,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${vl.color}; cursor: pointer; font-weight: 500;`)}),P("click",Ke,v),P("click",Ue,l),x(K,fe)};j(J,K=>{n()&&!u(a)&&K(ye)})}var Y=k(J,2),se=w(Y),Te=w(se),Oe=k(w(Te));{var ze=K=>{var fe=jF(),Pe=w(fe);W(()=>G(Pe,u(M).allPending.length)),x(K,fe)};j(Oe,K=>{u(M).allPending.length>0&&K(ze)})}var Xe=k(Te,2),ue=w(Xe),re=k(Xe,2),pe=w(re),Ne=k(w(pe),2),xe=w(Ne),Me=k(pe,2),Se=w(Me),qe=w(Se),it=k(Y,2);HF(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 ce=k(it,2),Ie=w(ce);n7(Ie,{get annotations(){return e.annotations},get activeDocFormat(){return e.activeDocFormat},get documentId(){return e.documentId}});var V=k(ce,2);kF(V,{get selectedCount(){return u(Z).size},onPromote:De,onClear:Ee,get reduceMotion(){return e.reduceMotion}});var ee=k(V,2);SF(ee,{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(ee,2);{var Ve=K=>{var fe=qF(),Pe=w(fe),Be=w(Pe);W(()=>G(Be,u(D)?"No annotations match filters.":"No annotations yet. Open a document to get started.")),P("click",fe,de),x(K,fe)},Fe=K=>{var fe=KF(),Pe=w(fe);pt(Pe,17,()=>u(M).pending,We=>We.id,(We,Ue)=>{const nt=N(()=>e.activeAnnotationId===u(Ue).id);{let rt=N(()=>u(E).get(u(Ue).id)??[]),xt=N(()=>r()===u(Ue).id),qt=N(()=>Rm(u(Ue))?ke:void 0),Je=N(()=>Nm(u(Ue))?le:void 0),Ct=N(()=>zm(u(Ue))?ie:void 0),Nt=N(()=>Fm(u(Ue))?Q:void 0),ln=N(()=>Lm(u(Ue))?z:void 0),vn=N(()=>Pm(u(Ue))?he:void 0),er=N(()=>{var cr;return((cr=u(Re))==null?void 0:cr.id)===u(Ue).id?u(Re):null}),zt=N(()=>u(Z).has(u(Ue).id)),Mn=N(()=>u(Ue).author==="import"&&u(Ue).type==="note"?ge:void 0);zv(We,{get annotation(){return u(Ue)},get replies(){return u(rt)},get isReviewTarget(){return u(nt)},get claudeTyping(){return u(xt)},lifecycleMotion:!0,get reduceMotion(){return e.reduceMotion},get exitModes(){return ae},get onAccept(){return u(qt)},get onDismiss(){return u(Je)},get onRemove(){return u(Ct)},get onSendToClaude(){return u(Nt)},get onEdit(){return u(ln)},get onReply(){return u(vn)},get openRequest(){return u(er)},onClick:()=>e.review.scrollToAnnotation(u(Ue)),get selected(){return u(zt)},get onToggleSelect(){return u(Mn)}})}});var Be=k(Pe,2);{var Ke=We=>{var Ue=WF(),nt=w(Ue),rt=w(nt),xt=k(nt,2);pt(xt,21,()=>u(M).resolved,qt=>qt.id,(qt,Je)=>{{let Ct=N(()=>u(E).get(u(Je).id)??[]),Nt=N(()=>e.review.getRecentlyResolved().has(u(Je).id));zv(qt,{get annotation(){return u(Je)},get replies(){return u(Ct)},get reduceMotion(){return e.reduceMotion},get onUndo(){return e.review.undoResolveAnnotation},get undoable(){return u(Nt)},onClick:()=>e.review.scrollToAnnotation(u(Je))})}}),W(()=>G(rt,`${u(M).resolved.length??""} resolved`)),x(We,Ue)};j(Be,We=>{u(M).resolved.length>0&&We(Ke)})}Ot(fe,We=>b(be,We),()=>u(be)),P("click",fe,de),x(K,fe)};j(we,K=>{u(M).filtered.length===0?K(Ve):K(Fe,-1)})}Ot(_e,K=>b(A,K),()=>u(A)),Ur(_e,(K,fe)=>Yt==null?void 0:Yt(K,fe),()=>"y"),W(()=>{G(ue,`${u(M).allPending.length??""} pending annotation${u(M).allPending.length!==1?"s":""}`),U(pe,"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(pe,"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(xe,u(f)==="position"?"Position":"Oldest"),G(qe,`${u(I)??""} ${u(M).filtered.length??""}`)}),P("click",pe,h),P("click",Me,()=>b(_,!u(_))),x(t,_e),tt()}ut(["click"]);var ZF=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>'),YF=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>`),JF=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>'),XF=T('<ul style="list-style: none; margin: 0; padding: 0;"></ul>'),QF=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 qk(t,e){et(e,!0);let n=Ye(e,"annotations",19,()=>[]),r=Ye(e,"focusTrigger",3,0),i=Ye(e,"activeFilterType",3,"all"),o=Ye(e,"activeFilterAuthor",3,"all"),s=Ye(e,"activeFilterStatus",3,"all"),a=L(at([])),l=L(-1),c=L(at([])),d=L(""),f=L(null),h=L(-1);me(()=>{const D=e.editor;if(!D||D.isDestroyed){b(a,[],!0);return}b(a,_v(D),!0),Mt(()=>{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,_v(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)}}),me(()=>{var D,I;r()>0&&((D=u(f))==null||D.focus(),(I=u(f))==null||I.select())}),me(()=>{const D=e.editor;if(!D||D.isDestroyed)return;const I=D.view.dom.closest(".editor-scroll")??D.view.dom.parentElement;function B(){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 he=0;he<u(a).length;he++)try{D.view.coordsAtPos(u(a)[he].pos+1).top<=Q&&(ie=he)}catch{}b(h,ie,!0)}return B(),I==null||I.addEventListener("scroll",B),()=>I==null?void 0:I.removeEventListener("scroll",B)});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,B,z,Q;D.key==="Enter"?(D.preventDefault(),D.shiftKey?(I=e.editor)==null||I.commands.findPrev():(B=e.editor)==null||B.commands.findNext()):D.key==="Escape"&&(D.preventDefault(),b(d,""),(z=e.editor)==null||z.commands.findClose(),(Q=u(f))==null||Q.blur())}const v=N(()=>{const D=e.editor;if(!D||D.isDestroyed||u(a).length===0)return[];const I=D.state.doc.content.size,B=[];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{B.push(Qs(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 B.filter(he=>he>=z.pos&&he<ie).length})});function g(D,I){const B=e.editor;if(!B||B.isDestroyed)return;const{state:z}=B;try{const Q=z.doc.resolve(D.pos+1),ie=dt.near(Q);B.view.dispatch(z.tr.setSelection(ie)),B.view.focus();const{node:he}=B.view.domAtPos(D.pos+1),ae=he instanceof Element?he:he.parentElement,ke=B.view.dom.closest(".editor-scroll")??B.view.dom.parentElement;if(ae&&ke){const le=ae.getBoundingClientRect().top,be=ke.getBoundingClientRect().top;ke.scrollTop+=le-be-ke.clientHeight*.05}}catch{}b(l,I,!0)}function y(D){var I,B,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),(B=u(c)[ie])==null||B.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=QF(),_=k(w(C),2),S=w(_),A=k(w(S),2);Ot(A,D=>b(f,D),()=>u(f));var O=k(_,2),E=w(O);{var M=D=>{var I=ZF();x(D,I)},R=D=>{var I=XF();pt(I,21,()=>u(a),cc,(B,z,Q)=>{const ie=N(()=>u(h)===Q),he=N(()=>u(v)[Q]??0);var ae=JF(),ke=w(ae),le=w(ke),be=k(le,2),Re=w(be),$=k(be,2);{var q=H=>{var ne=YF(),te=w(ne);W(()=>{U(ne,"title",`${u(he)??""} annotation${u(he)!==1?"s":""}`),G(te,u(he))}),x(H,ne)};j($,H=>{u(he)>0&&H(q)})}Ot(ke,(H,ne)=>u(c)[ne]=H,H=>{var ne;return(ne=u(c))==null?void 0:ne[H]},()=>[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),Le(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),Le(le,u(ie)?"background-color: var(--tandem-accent); opacity: 1;":""),G(Re,u(z).text||"(untitled)")}),P("click",ke,()=>g(u(z),Q)),hn("focus",ke,()=>b(l,Q,!0)),hn("mouseenter",ke,H=>{u(ie)||(H.currentTarget.style.background="var(--tandem-surface-hover, var(--tandem-surface-muted))")}),hn("mouseleave",ke,H=>{u(ie)||(H.currentTarget.style.background="none")}),x(B,ae)}),x(D,I)};j(E,D=>{u(a).length===0?D(M):D(R,-1)})}Ur(O,(D,I)=>Yt==null?void 0:Yt(D,I),()=>"y"),P("keydown",C,y),P("input",A,p),P("keydown",A,m),zr(A,()=>u(d),D=>b(d,D)),x(t,C),tt()}ut(["keydown","input","click"]);var $F=T("<div><!></div>");function Ug(t,e){et(e,!0);let n=UM(e,["$$slots","$$events","$$legacy","kind","visible"]);const r=N(()=>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=$F(),h=w(f);{var p=g=>{Bk(g,du(()=>n,{get visible(){return e.visible}}))},m=g=>{qk(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=>{jk(g,du(()=>n))};j(h,g=>{e.kind==="chat"?g(p):e.kind==="outline"?g(m,1):g(v,-1)})}W(()=>Le(f,u(r))),x(d,f)},a=d=>{Bk(d,du(()=>n))},l=d=>{qk(d,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType}})},c=d=>{jk(d,du(()=>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),tt()}var ez=T('<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>'),tz=T('<button type="button" class="tandem-banner__cta" data-testid="convert-to-markdown-btn"> </button>'),nz=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 rz(t,e){et(e,!0);const n="tandem:reviewOnlyBannerDismissed";function r(){try{return localStorage.getItem(n)==="true"}catch{return!1}}let i=L(at(r())),o=L(!1),s=L(null);async function a(){if(!(!e.documentId||u(o))){b(o,!0),b(s,null);try{const h=await fetch(`${Qt}${KD}`,{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=nz(),m=k(w(p),2);{var v=_=>{var S=ez(),A=w(S);W(()=>G(A,u(s))),x(_,S)};j(m,_=>{u(s)&&_(v)})}var g=k(m,2);{var y=_=>{var S=tz(),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),tt()}ut(["click"]);let jg=null;async function iz(t){if(jg!==null)return jg;const e=await fetch(`${Qt}${uv}`,{signal:t});if(!e.ok)throw new Error(`${uv} responded ${e.status} ${e.statusText}`);const n=await e.json();return jg=n,n}function Bm(t){let e=L(null),n=L(!1);return me(()=>{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 oz=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 HE(t,e){et(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=oz(),i=Ae(r),o=w(i);Le(o,n);var s=k(o,2),a=w(s),l=k(i,2),c=w(l);Le(c,n);var d=k(c,2),f=w(d);W(()=>{Kn(a,e.settings.highContrast),Kn(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),tt()}ut(["change"]);var sz=T('<button role="radio"> </button>'),az=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>'),cz=T('<button role="radio"> </button>'),uz=T('<button role="radio"> </button>'),dz=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>'),fz=T('<button role="radio"> </button>'),hz=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>'),pz=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>`,1);function VE(t,e){et(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(re){var pe;return((pe=e.settings.fontByExtension)==null?void 0:pe[re])??e.settings.editorFont}function o(re,pe){e.onUpdate({fontByExtension:{...e.settings.fontByExtension,[re]:pe}})}function s(){e.onUpdate({fontByExtension:{}})}const a=N(()=>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(re,pe){return["flex: 1;","padding: var(--tandem-space-2);","min-height: 24px;",`border: 2px solid ${re?"var(--tandem-accent)":"var(--tandem-border)"};`,"border-radius: var(--tandem-r-3);",`background: ${re?"var(--tandem-accent-bg)":"var(--tandem-surface)"};`,"cursor: pointer;","text-align: center;","font-size: 11px;",`color: ${re?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"};`,`font-weight: ${re?600:400};`,"opacity: 1;","transition: border-color 0.15s, background 0.15s;"].join(" ")}const f=ys(()=>e.settings.theme,["light","warm","dark","system"],re=>e.onUpdate({theme:re})),h=ys(()=>e.settings.primaryTab,["chat","annotations"],re=>e.onUpdate({primaryTab:re})),p=ys(()=>e.settings.textSize,["s","m","l"],re=>e.onUpdate({textSize:re})),m=ys(()=>e.settings.editorFont,["sans","serif","mono"],re=>e.onUpdate({editorFont:re})),v=ys(()=>e.settings.density,["compact","cozy","spacious"],re=>e.onUpdate({density:re})),g={};for(const re of n)g[re.format]=ys(()=>i(re.format),["sans","serif","mono"],pe=>o(re.format,pe));var y=pz(),C=Ae(y),_=w(C);Le(_,l);var S=k(_,2);pt(S,20,()=>["light","warm","dark","system"],re=>re,(re,pe)=>{var Ne=sz(),xe=w(Ne);W((Me,Se)=>{U(Ne,"data-testid",`theme-${pe}-btn`),U(Ne,"aria-checked",e.settings.theme===pe),U(Ne,"tabindex",Me),Le(Ne,Se),G(xe,pe==="light"?"Light":pe==="warm"?"Warm":pe==="dark"?"Dark":"System")},[()=>f.tabIndexFor(pe),()=>d(e.settings.theme===pe)]),P("click",Ne,()=>e.onUpdate({theme:pe})),x(re,Ne)});var A=k(S,2);{var O=re=>{var pe=az(),Ne=Ae(pe),xe=w(Ne);W(()=>Kn(xe,e.settings.systemLightVariant==="warm")),P("change",xe,Me=>e.onUpdate({systemLightVariant:Me.target.checked?"warm":"light"})),x(re,pe)};j(A,re=>{e.settings.theme==="system"&&re(O)})}var E=k(C,2),M=w(E);Le(M,l);var R=k(M,2),D=w(R),I=k(D,2),B=k(E,2),z=w(B);Le(z,l);var Q=k(z,2);pt(Q,20,()=>["s","m","l"],re=>re,(re,pe)=>{var Ne=lz(),xe=w(Ne);W((Me,Se)=>{U(Ne,"data-testid",`text-size-${pe}-btn`),U(Ne,"aria-checked",e.settings.textSize===pe),U(Ne,"tabindex",Me),Le(Ne,Se),G(xe,pe==="s"?"Small":pe==="m"?"Medium":"Large")},[()=>p.tabIndexFor(pe),()=>d(e.settings.textSize===pe)]),P("click",Ne,()=>e.onUpdate({textSize:pe})),x(re,Ne)});var ie=k(B,2),he=w(ie);Le(he,l);var ae=k(he,2),ke=k(w(ae),2),le=k(ie,2),be=w(le);Le(be,l);var Re=k(be,2);pt(Re,20,()=>[["sans","Sans-serif"],["serif","Serif (Source Serif 4)"],["mono","Monospace"]],([re,pe])=>re,(re,pe)=>{var Ne=N(()=>mf(pe,2));let xe=()=>u(Ne)[0],Me=()=>u(Ne)[1];var Se=cz(),qe=w(Se);W((it,ce)=>{U(Se,"data-testid",`editor-font-${xe()}-btn`),U(Se,"aria-checked",e.settings.editorFont===xe()),U(Se,"tabindex",it),Le(Se,ce),G(qe,Me())},[()=>m.tabIndexFor(xe()),()=>d(e.settings.editorFont===xe())]),P("click",Se,()=>e.onUpdate({editorFont:xe()})),x(re,Se)});var $=k(le,2),q=w($),H=w(q);Le(H,`${l} margin-bottom: 0;`);var ne=k(H,2),te=k(q,2);pt(te,21,()=>n,re=>re.format,(re,pe)=>{var Ne=dz(),xe=w(Ne),Me=w(xe),Se=k(xe,2);pt(Se,21,()=>r,([qe,it])=>qe,(qe,it)=>{var ce=N(()=>mf(u(it),2));let Ie=()=>u(ce)[0],V=()=>u(ce)[1];var ee=uz(),we=w(ee);W((Ve,Fe,K)=>{U(ee,"data-testid",`font-by-extension-${u(pe).format}-${Ie()}`),U(ee,"aria-checked",Ve),U(ee,"tabindex",Fe),Le(ee,K),G(we,V())},[()=>i(u(pe).format)===Ie(),()=>g[u(pe).format].tabIndexFor(Ie()),()=>d(i(u(pe).format)===Ie())]),P("click",ee,()=>o(u(pe).format,Ie())),x(qe,ee)}),W(()=>{U(Ne,"data-testid",`font-by-extension-row-${u(pe).format}`),G(Me,u(pe).label),U(Se,"aria-label",`Default font for ${u(pe).label}`)}),P("keydown",Se,function(...qe){var it;(it=g[u(pe).format].handleKeyDown)==null||it.apply(this,qe)}),x(re,Ne)});var Z=k($,2),ge=w(Z);Le(ge,l);var De=k(ge,2);pt(De,20,()=>[["compact","Compact"],["cozy","Cozy"],["spacious","Spacious"]],([re,pe])=>re,(re,pe)=>{var Ne=N(()=>mf(pe,2));let xe=()=>u(Ne)[0],Me=()=>u(Ne)[1];var Se=fz(),qe=w(Se);W((it,ce)=>{U(Se,"data-testid",`density-${xe()}-btn`),U(Se,"aria-checked",e.settings.density===xe()),U(Se,"tabindex",it),Le(Se,ce),G(qe,Me())},[()=>v.tabIndexFor(xe()),()=>d(e.settings.density===xe())]),P("click",Se,()=>e.onUpdate({density:xe()})),x(re,Se)});var Ee=k(Z,2),de=w(Ee);Le(de,l);var _e=k(de,2);pt(_e,17,()=>c,([re,pe,Ne])=>re,(re,pe)=>{var Ne=N(()=>mf(u(pe),3));let xe=()=>u(Ne)[0],Me=()=>u(Ne)[1],Se=()=>u(Ne)[2];var qe=hz(),it=w(qe),ce=k(it,2),Ie=w(ce);W(()=>{U(qe,"data-testid",Me()),Kn(it,e.settings[xe()]),G(Ie,Se())}),P("change",it,V=>e.onUpdate({[xe()]:V.target.checked,...e.settings.decorationsMuted?{decorationsMuted:!1}:{}})),x(re,qe)});var J=k(Ee,2),ye=w(J),Y=w(ye),se=k(J,2),Te=w(se),Oe=w(Te),ze=k(se,2),Xe=w(ze),ue=w(Xe);W((re,pe,Ne,xe)=>{U(D,"aria-checked",e.settings.primaryTab==="chat"),U(D,"tabindex",re),Le(D,pe),U(I,"aria-checked",e.settings.primaryTab==="annotations"),U(I,"tabindex",Ne),Le(I,xe),Br(ke,e.settings.accentHue),ne.disabled=!u(a),Le(ne,`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"};`),Kn(Y,e.settings.reduceMotion),Kn(Oe,e.settings.formattingBarVisible),Kn(ue,e.settings.showRawMarkdown)},[()=>h.tabIndexFor("chat"),()=>d(e.settings.primaryTab==="chat"),()=>h.tabIndexFor("annotations"),()=>d(e.settings.primaryTab==="annotations")]),P("keydown",S,function(...re){var pe;(pe=f.handleKeyDown)==null||pe.apply(this,re)}),P("keydown",R,function(...re){var pe;(pe=h.handleKeyDown)==null||pe.apply(this,re)}),P("click",D,()=>e.onUpdate({primaryTab:"chat"})),P("click",I,()=>e.onUpdate({primaryTab:"annotations"})),P("keydown",Q,function(...re){var pe;(pe=p.handleKeyDown)==null||pe.apply(this,re)}),P("input",ke,re=>e.onUpdate({accentHue:Number(re.target.value)})),P("keydown",Re,function(...re){var pe;(pe=m.handleKeyDown)==null||pe.apply(this,re)}),P("click",ne,s),P("keydown",De,function(...re){var pe;(pe=v.handleKeyDown)==null||pe.apply(this,re)}),P("change",Y,re=>e.onUpdate({reduceMotion:re.target.checked})),P("change",Oe,re=>e.onUpdate({formattingBarVisible:re.target.checked})),P("change",ue,re=>e.onUpdate({showRawMarkdown:re.target.checked})),x(t,y),tt()}ut(["keydown","click","change","input"]);var mz=T('<button type="button" role="radio"> </button>'),gz=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>'),vz=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
115
- 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.
116
- Leave empty to fall back to your AI's working directory, then your home
117
- 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 UE(t,e){et(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 Kt(()=>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=ys(()=>e.settings.editorMeasure,a.map(O=>O.value),O=>e.onUpdate({editorMeasure:O})),c=N(()=>{var O;return((O=a.find(E=>E.value===e.settings.editorMeasure))==null?void 0:O.hint)??""});var d=vz(),f=w(d);Le(f,n);var h=k(f,4);pt(h,21,()=>a,O=>O.value,(O,E)=>{const M=N(()=>e.settings.editorMeasure===u(E).value);var R=mz(),D=w(R);W(I=>{U(R,"aria-checked",u(M)),U(R,"tabindex",I),U(R,"data-testid",`editor-measure-${u(E).value}`),Le(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);Le(g,n);var y=k(g,4),C=w(y),_=k(C,2);{var S=O=>{var E=gz();P("click",E,s),x(O,E)};j(_,O=>{r&&O(S)})}var A=k(_,2);W(()=>{G(m,u(c)),Br(C,e.settings.defaultSaveDirectory??""),A.disabled=!e.settings.defaultSaveDirectory,Le(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)}),hn("submit",y,o),hn("blur",C,O=>i(O.currentTarget.value)),P("click",A,()=>i(null)),x(t,d),tt()}ut(["keydown","click"]);var bz=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 jE(t,e){const n=Ye(e,"defaultOpen",3,!1);var r=bz(),i=w(r),o=k(w(i)),s=k(i,2),a=w(s);jd(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 yz=T('<span style="color: var(--tandem-fg-subtle);"> </span>'),wz=T('<button type="button" data-testid="network-restart-sidecar"> </button>'),kz=T('<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop &amp;&amp; tandem start</code> to restart</span>'),xz=T('<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>'),_z=T("<span><strong>Host:</strong> </span>"),Cz=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>'),Sz=T("<option> </option>"),Ez=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>'),Az=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),Tz=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 qE(t,e){et(e,!0);const n=Bm(()=>e.open),r=Tt();let i=L(null),o=L(!1);async function s(){if(r){b(o,!0),b(i,null);try{const{invoke:$}=await Kt(async()=>{const{invoke:q}=await import("./core-DhEqZVGG.js");return{invoke:q}},[]);await $("restart_sidecar")}catch($){b(i,$ instanceof Error?$.message:String($),!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=N(()=>{var $;return($=n.info)==null?void 0:$.transport}),h=N(()=>{var $;return($=n.info)==null?void 0:$.bindHost}),p=N(()=>{var $;return($=n.info)==null?void 0:$.bindPort}),m=N(()=>u(f)==="http"),v=N(()=>{var $;return($=n.info)==null?void 0:$.tokenRotatedAt});var g=Tz(),y=Ae(g),C=w(y);Le(C,l);var _=k(C,2),S=w(_),A=k(S,2),O=w(A),E=k(O);{var M=$=>{var q=yz(),H=w(q);W(()=>G(H,`· ${e.reconnectAttempts??""} retry attempt${e.reconnectAttempts===1?"":"s"}`)),x($,q)};j(E,$=>{e.reconnectAttempts>0&&$(M)})}var R=k(A,2);{var D=$=>{var q=wz(),H=w(q);W(()=>{q.disabled=u(o),Le(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(H,u(o)?"Restarting…":"Restart sidecar")}),P("click",q,s),x($,q)},I=$=>{var q=kz();x($,q)};j(R,$=>{r?$(D):$(I,-1)})}var B=k(_,2);{var z=$=>{var q=xz(),H=w(q);W(()=>G(H,u(i))),x($,q)};j(B,$=>{u(i)&&$(z)})}var Q=k(y,2),ie=w(Q);Le(ie,l);var he=k(ie,2),ae=w(he),ke=k(w(ae)),le=k(ae,2);{var be=$=>{var q=_z(),H=k(w(q));W(()=>G(H,` ${u(h)??""}`)),x($,q)};j(le,$=>{u(h)&&$(be)})}var Re=k(Q,2);jE(Re,{label:"Advanced",testid:"network-advanced",children:($,q)=>{var H=Az(),ne=Ae(H);{var te=ue=>{var re=Cz(),pe=w(re);Le(pe,l);var Ne=k(pe,2),xe=w(Ne),Me=k(Ne,2);Le(Me,d),W(()=>G(xe,u(p)??"—")),x(ue,re)};j(ne,ue=>{u(m)&&ue(te)})}var Z=k(ne,2),ge=w(Z);Le(ge,l);var De=k(w(ge)),Ee=w(De),de=k(ge,2),_e=k(Z,2),J=w(_e);Le(J,l);var ye=k(J,2);pt(ye,21,()=>a,ue=>ue.value,(ue,re)=>{var pe=Sz(),Ne=w(pe),xe={};W(()=>{G(Ne,u(re).label),xe!==(xe=u(re).value)&&(pe.value=(pe.__value=u(re).value)??"")}),x(ue,pe)});var Y;bC(ye);var se=k(_e,2);Le(se,c);var Te=w(se),Oe=k(se,2);Le(Oe,d);var ze=k(Oe,2);{var Xe=ue=>{var re=Ez(),pe=w(re);Le(pe,l);var Ne=k(pe,2),xe=w(Ne),Me=k(Ne,2);Le(Me,d),W(Se=>G(xe,Se),[()=>u(v)===null?"Auth token not yet created":`Last rotated: ${new Date(u(v)).toLocaleString()}`]),x(ue,re)};j(ze,ue=>{u(v)!==void 0&&ue(Xe)})}W(()=>{G(Ee,`${e.settings.degradedBannerDelayMs/1e3}s`),Br(de,e.settings.degradedBannerDelayMs),Y!==(Y=e.settings.sidecarRetryStrategy)&&(ye.value=(ye.__value=e.settings.sidecarRetryStrategy)??"",Wb(ye,e.settings.sidecarRetryStrategy)),Kn(Te,e.settings.holdAnnotationsWhileOffline)}),P("input",de,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($,H)},$$slots:{default:!0}}),W($=>{Le(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,` ${$??""}`)},[()=>u(f)?u(f).toUpperCase():"—"]),x(t,g),tt()}ut(["click","input","change"]);const Mz="INVALID_BODY",Dz="PATH_REJECTED",Oz="LAUNCHER_IN_PROGRESS",Iz="LAUNCHER_NOT_AVAILABLE",Rz="NO_CLAUDE_INTEGRATION";var Nz=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
118
- 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>`),Pz=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>'),Lz=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>'),Fz=T('<div role="alert" style="font-size: 11px; color: var(--tandem-error-fg);"> </div>'),zz=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>'),Bz=T('<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),Hz=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
119
- Claude Desktop) is the default integration — auto-configured, tested, and the only client whose
120
- channel-push, cowork, and auto-launch extras are validated today. Other clients can connect
121
- 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 Vz(t,e){et(e,!0);function n(Z){switch(Z){case Dz:return"Working directory must be a folder inside your home directory.";case Mz:return"Working directory path is invalid.";case Oz:return"Another working-directory update is in progress. Try again.";case Rz:return"No Claude Code integration is configured.";case Iz: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=L(null),o=L(!1),s=L(null),a=L(!1),l=L(!1),c=L(null);const d=N(()=>u(a)&&!u(l)&&!u(c));let f=!0;Dn(()=>{f=!1});async function h(){var Z;try{const ge=await fetch(`${Qt}/api/integrations`);if(!f)return;if(!ge.ok){b(c,`Failed to load integrations (HTTP ${ge.status}).`);return}const De=await ge.json();if(!f)return;const Ee=(Z=De.integrations)==null?void 0:Z.find(de=>de.kind==="claude-code");Ee&&(b(l,!0),b(i,Ee.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(`${Qt}${cO}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDirectory:Z})});if(!f)return;if(!ge.ok){const Ee=await ge.json().catch(()=>({}));if(!f)return;b(s,n(Ee.code),!0);return}const De=await ge.json();if(!f)return;b(i,De.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 Kt(()=>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"),De=ge==null?void 0:ge.value.trim();p(De||null)}function g(){p(null)}var y=Hz(),C=Ae(y);{var _=Z=>{var ge=Nz(),De=k(w(ge),4);P("click",De,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),B=k(D,2),z=w(B),Q=k(S,2),ie=w(Q),he=k(Q,2),ae=w(he),ke=k(he,4);{var le=Z=>{var ge=Pz(),De=w(ge);W(()=>G(De,u(c))),x(Z,ge)};j(ke,Z=>{u(a)&&!u(l)&&u(c)&&Z(le)})}var be=k(ke,2);{var Re=Z=>{var ge=zz(),De=k(w(ge),4),Ee=w(De);U(Ee,"placeholder","(default: home)");var de=k(Ee,2),_e=k(De,2),J=w(_e);{var ye=ze=>{var Xe=Lz();W(()=>Xe.disabled=u(o)),P("click",Xe,m),x(ze,Xe)},Y=N(()=>Tt());j(J,ze=>{u(Y)&&ze(ye)})}var se=k(J,2),Te=k(_e,2);{var Oe=ze=>{var Xe=Fz(),ue=w(Xe);W(()=>G(ue,u(s))),x(ze,Xe)};j(Te,ze=>{u(s)&&ze(Oe)})}W(()=>{Br(Ee,u(i)??""),Ee.disabled=u(o),de.disabled=u(o),se.disabled=u(o)||u(i)===null}),hn("submit",De,v),P("click",se,g),x(Z,ge)};j(be,Z=>{u(a)&&u(l)&&Z(Re)})}var $=k(be,2),q=w($),H=k($,2);{var ne=Z=>{var ge=St(),De=Ae(ge);mC(De,()=>Kt(()=>import("./CoworkSettings-DyolPw-M.js"),__vite__mapDeps([4,5])),Ee=>{var de=Bz();x(Ee,de)},(Ee,de)=>{const _e=N(()=>u(de).default);var J=St(),ye=Ae(J);qb(ye,()=>u(_e),(Y,se)=>{se(Y,{})}),x(Ee,J)}),x(Z,ge)},te=N(()=>Tt());j(H,Z=>{u(te)&&Z(ne)})}W((Z,ge,De)=>{G(E,`${Z??""}s`),U(M,"min",uc),U(M,"max",dc),Br(M,e.settings.selectionDwellMs),G(I,`${ge??""}s`),G(z,`${De??""}s`),Kn(ie,e.settings.selectionToolbar),Kn(ae,e.settings.marginView),G(q,u(d)?"Open integration wizard…":"Reopen integration wizard…")},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(uc/1e3).toFixed(1),()=>(dc/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",ae,Z=>e.onUpdate({marginView:Z.target.checked})),P("click",$,r),x(t,y),tt()}ut(["click","input","change"]);function F1(t){const e=t==null?void 0:t.trim();return e?e.slice(0,fm):OC}function z1(){try{return F1(localStorage.getItem(Zb))}catch{return OC}}function Uz(t){const e=F1(t);try{localStorage.setItem(Zb,e)}catch{}return typeof window<"u"&&window.dispatchEvent(new Event(rv)),e}function WE(t){const e=()=>t(z1()),n=r=>{r.key===Zb&&t(F1(r.newValue))};return window.addEventListener(rv,e),window.addEventListener("storage",n),()=>{window.removeEventListener(rv,e),window.removeEventListener("storage",n)}}function B1(){let t=L(at(z1()));const e=WE(r=>{b(t,r,!0)});return Dn(e),{get userName(){return u(t)},setUserName:r=>{const i=Uz(r);b(t,i,!0)}}}var jz=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
122
- restores when you return to Tandem.</div>`,1);function qz(t,e){et(e,!0);const n=B1();let r=L(at(n.userName)),i=L(void 0);me(()=>{const m=n.userName;u(r)!==m&&document.activeElement!==u(i)&&b(r,m,!0)});var o=jz(),s=Ae(o),a=k(w(s),2);Ot(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(()=>{Br(a,u(r)),U(a,"maxlength",fm),U(d,"aria-checked",e.settings.defaultMode==="tandem"),U(f,"aria-checked",e.settings.defaultMode==="solo"),Kn(p,e.settings.soloRailHidden)}),P("input",a,m=>{b(r,m.target.value,!0)}),hn("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),tt()}ut(["input","keydown","click","change"]);const Bv=JS({baseUrl:`http://127.0.0.1:${ji}`,pathFor:k8});function qg(){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 Wz(){return crypto.randomUUID()}function Wk(t){if(t.provider!==void 0&&!QC.includes(t.provider))throw new Error(`Invalid model provider: ${String(t.provider)}`)}async function Wg(t,e){const n=await Bv.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 Kz(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){Wk(e);const r=Wz();let i;n&&n.length>0&&(i=qg(),await Wg(i,n));const o={...e,id:r,...i?{apiKeyRef:i}:{}};return t.updateSettings({models:[...t.settings.models,o]}),r},async updateModel(e,n,r){Wk(n);const i=t.settings.models.find(s=>s.id===e);if(!i)return;let o;r!==void 0&&r.length>0&&(o=qg(),await Promise.all([Wg(o,r),i.apiKeyRef?Bv.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 Bv.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(()=>qg()),i=await Promise.allSettled(n.map((l,c)=>Wg(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 Gz=T("<option> </option>"),Zz=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>'),Yz=T('<input data-testid="model-edit-apikey" class="mem-input mem-input--mono svelte-1pwv6ag" type="password" autocomplete="off"/>'),Jz=T('<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">API key</span> <!></label>'),Xz=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>'),Qz=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>'),$z=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 eB(t,e){et(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=Mt(()=>e.entry);let i=L(at((r==null?void 0:r.provider)??"anthropic")),o=L(at((r==null?void 0:r.displayName)??"")),s=L(at((r==null?void 0:r.modelId)??"")),a=L(at((r==null?void 0:r.endpoint)??"")),l=L(at((r==null?void 0:r.enabled)??!0)),c=L("");const d=r!==void 0&&!!r.apiKeyRef;let f=L(at(r===void 0||!d));const h=r!==void 0,p=N(()=>u(i)==="anthropic"||u(i)==="openai"||u(i)==="gemini"),m=N(()=>u(i).startsWith("local-")),v=r!=null&&r.apiKeyRef?r.apiKeyRef.slice(-4):"",g=N(()=>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 _=$z();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);pt(D,21,()=>n,te=>te.value,(te,Z)=>{var ge=Gz(),De=w(ge),Ee={};W(()=>{G(De,u(Z).label),Ee!==(Ee=u(Z).value)&&(ge.value=(ge.__value=u(Z).value)??"")}),x(te,ge)});var I=k(R,2),B=k(w(I),2),z=k(I,2),Q=k(w(z),2),ie=k(z,2);{var he=te=>{var Z=Jz(),ge=k(w(Z),2);{var De=de=>{var _e=Zz(),J=w(_e),ye=w(J),Y=k(J,2);W(()=>G(ye,`••••••••${v??""}`)),P("click",Y,C),x(de,_e)},Ee=de=>{var _e=Yz();W(()=>U(_e,"placeholder",h?"Enter new key":"Paste your API key")),zr(_e,()=>u(c),J=>b(c,J)),x(de,_e)};j(ge,de=>{h&&(r!=null&&r.apiKeyRef)&&!u(f)?de(De):de(Ee,-1)})}x(te,Z)};j(ie,te=>{u(p)&&te(he)})}var ae=k(ie,2);{var ke=te=>{var Z=Xz(),ge=k(w(Z),2);zr(ge,()=>u(a),De=>b(a,De)),x(te,Z)};j(ae,te=>{u(m)&&te(ke)})}var le=k(ae,2),be=w(le),Re=k(le,2);jE(Re,{label:"Advanced parameters",testid:"model-edit-advanced",children:(te,Z)=>{var ge=Qz();x(te,ge)},$$slots:{default:!0}});var $=k(Re,2),q=w($),H=k(q,2),ne=w(H);W(()=>{U(_,"aria-label",h?"Edit model":"Add model"),G(E,h?"Edit model":"Add model"),H.disabled=!u(g),G(ne,h?"Save changes":"Add model")}),P("click",_,te=>{te.target===te.currentTarget&&e.onCancel()}),P("keydown",_,te=>{te.key==="Escape"&&e.onCancel()}),hn("submit",S,y),P("click",M,function(...te){var Z;(Z=e.onCancel)==null||Z.apply(this,te)}),NM(D,()=>u(i),te=>b(i,te)),zr(B,()=>u(o),te=>b(o,te)),zr(Q,()=>u(s),te=>b(s,te)),sh(be,()=>u(l),te=>b(l,te)),P("click",q,function(...te){var Z;(Z=e.onCancel)==null||Z.apply(this,te)}),x(t,_),tt()}ut(["click","keydown"]);var tB=T('<span data-testid="models-legacy-migration-status"> </span>'),nB=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
123
- 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>`),rB=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),oB=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>'),sB=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>'),aB=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),cB=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>'),uB=T('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"><!> <!></div> <!> <!>',1);function dB(t,e){et(e,!0);const n=oi(),r=Kz(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=N(()=>{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=L(void 0),l=L(!1),c=L(null),d=L(null),f=L(!1),h=L(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(he){b(d,he instanceof Error?he.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=uB(),_=Ae(C),S=w(_);{var A=z=>{var Q=nB(),ie=k(w(Q),2),he=w(ie),ae=w(he),ke=k(he,2);{var le=be=>{var Re=tB(),$=w(Re);W(()=>G($,u(h))),x(be,Re)};j(ke,be=>{u(h)&&be(le)})}W(()=>{he.disabled=u(f),Le(he,`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(ae,u(f)?"Migrating…":"Migrate keys")}),P("click",he,y),x(z,Q)};j(S,z=>{r.hasLegacyKeys&&z(A)})}var O=k(S,2);{var E=z=>{var Q=rB(),ie=k(w(Q),2);P("click",ie,p),x(z,Q)},M=z=>{var Q=lB(),ie=Ae(Q);pt(ie,20,()=>o,ae=>ae,(ae,ke)=>{const le=N(()=>u(s).get(ke)??[]);var be=St(),Re=Ae(be);{var $=q=>{var H=aB(),ne=w(H),te=w(ne),Z=k(ne,2);pt(Z,21,()=>u(le),ge=>ge.id,(ge,De)=>{var Ee=sB(),de=w(Ee),_e=w(de),J=w(_e),ye=k(_e,2),Y=w(ye),se=k(de,2),Te=w(se),Oe=k(se,2),ze=w(Oe),Xe=k(ze,2),ue=w(Xe),re=k(Oe,2),pe=k(re,2);{var Ne=Me=>{var Se=iB(),qe=Ae(Se),it=k(qe,2);W(()=>U(qe,"data-testid",`model-delete-confirm-${u(De).id}`)),P("click",qe,()=>g(u(De).id)),P("click",it,()=>b(c,null)),x(Me,Se)},xe=Me=>{var Se=oB();W(()=>U(Se,"data-testid",`model-delete-btn-${u(De).id}`)),P("click",Se,()=>b(c,u(De).id,!0)),x(Me,Se)};j(pe,Me=>{u(c)===u(De).id?Me(Ne):Me(xe,-1)})}W(()=>{U(Ee,"data-testid",`model-row-${u(De).id}`),G(J,u(De).displayName),G(Y,u(De).modelId),U(Te,"data-testid",`model-default-${u(De).id}`),Kn(Te,r.defaultModelId===u(De).id),U(ze,"data-testid",`model-toggle-${u(De).id}`),Kn(ze,u(De).enabled),G(ue,u(De).enabled?"On":"Off"),U(re,"data-testid",`model-edit-btn-${u(De).id}`)}),P("change",Te,()=>r.setDefault(u(De).id)),P("change",ze,()=>r.toggleEnabled(u(De).id)),P("click",re,()=>m(u(De))),x(ge,Ee)}),W(()=>G(te,i[ke])),x(q,H)};j(Re,q=>{u(le).length>0&&q($)})}x(ae,be)});var he=k(ie,2);P("click",he,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=cB(),ie=w(Q);W(()=>G(ie,u(d))),x(z,Q)};j(R,z=>{u(d)&&z(D)})}var I=k(R,2);{var B=z=>{eB(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(B)})}x(t,C),tt()}ut(["click","change"]);var fB=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>'),hB=T('<span style="justify-self: start; font-size: 11px; color: var(--tandem-accent-fg-strong); font-style: italic;">Press keys… (Esc to cancel)</span>'),pB=T("<kbd> </kbd>"),mB=T('<button type="button">Reset</button>'),gB=T('<div style="grid-column: 1 / -1; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),vB=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>'),bB=T('<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),yB=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>'),wB=T('<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),kB=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 KE(t,e){et(e,!0);let n=Ye(e,"notify",3,()=>{}),r=L(null),i=L(null);const o=N(()=>e.settings._readOnly===!0),s=N(()=>JC(e.settings.customShortcuts));me(()=>{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=pO(R);if(!D)return;const I=xO(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",`${dv[E]} set to ${fv(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=N(()=>ja.some(E=>u(s).has(E))),f=N(()=>{const E=Vh(),M=new Map;for(const R of E.values()){if(!R.shortcut||WC[R.id])continue;const D=M.get(R.group)??[];D.push({keys:R.shortcut,description:R.label}),M.set(R.group,D)}return oS.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=kB(),m=w(p),v=w(m),g=k(w(v),2),y=k(v,2);{var C=E=>{var M=fB();x(E,M)};j(y,E=>{u(o)&&E(C)})}var _=k(y,2);pt(_,20,()=>ja,E=>E,(E,M)=>{const R=N(()=>u(r)===M),D=N(()=>u(s).has(M)),I=N(()=>fv(Xb(M,u(s))));var B=vB(),z=w(B),Q=w(z),ie=k(z,2);{var he=ne=>{var te=hB();W(()=>U(te,"data-testid",`shortcut-recording-${M}`)),x(ne,te)},ae=ne=>{var te=pB();Le(te,h);var Z=w(te);W(()=>G(Z,u(I))),x(ne,te)};j(ie,ne=>{u(R)?ne(he):ne(ae,-1)})}var ke=k(ie,2),le=w(ke),be=w(le),Re=k(le,2);{var $=ne=>{var te=mB();W(()=>{U(te,"data-testid",`shortcut-reset-${M}`),te.disabled=u(o),Le(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(ne,te)};j(Re,ne=>{u(D)&&ne($)})}var q=k(ke,2);{var H=ne=>{var te=gB(),Z=w(te);W(()=>{U(te,"data-testid",`shortcut-conflict-${M}`),G(Z,u(i).message)}),x(ne,te)};j(q,ne=>{u(i)&&u(i).id===M&&ne(H)})}W(()=>{U(B,"data-testid",`shortcut-row-${M}`),G(Q,dv[M]),U(le,"data-testid",`shortcut-edit-${M}`),le.disabled=u(o),Le(le,`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(be,u(R)?"Recording…":"Change")}),P("click",le,()=>a(M)),x(E,B)});var S=k(m,2);pt(S,17,()=>u(f),E=>E.title,(E,M)=>{var R=yB(),D=w(R),I=w(D),B=k(D,2);pt(B,21,()=>u(M).rows,z=>z.keys+z.description,(z,Q)=>{var ie=bB(),he=Ae(ie);Le(he,h);var ae=w(he),ke=k(he,2),le=w(ke);W(()=>{G(ae,u(Q).keys),G(le,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);pt(O,21,()=>Zh,E=>E.keys+E.description,(E,M)=>{var R=wB(),D=Ae(R);Le(D,h);var I=w(D),B=k(D,2),z=w(B);W(()=>{G(I,u(M).keys),G(z,u(M).description)}),x(E,R)}),W(()=>{g.disabled=u(o)||!u(d),Le(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),tt()}ut(["click"]);var xB=T('<div data-testid="settings-modal-shortcuts-list"><!></div>');function _B(t,e){var n=xB(),r=w(n);KE(r,{get settings(){return e.settings},get onUpdate(){return e.onUpdate},get notify(){return e.notify}}),x(t,n)}let cp=null;function CB(){return typeof window<"u"&&"__TAURI_INTERNALS__"in window}function SB(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 EB(t){return t.replace(/(\/Users\/)[^/\\]+/g,"$1[user]").replace(/(\/home\/)[^/\\]+/g,"$1[user]").replace(/([A-Za-z]:\\Users\\)[^\\]+/g,"$1[user]")}function Df(t){return EB(SB(t))}async function AB(){if(CB())try{const{invoke:t}=await Kt(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]);if(!await t("sentry_enabled").catch(()=>!1))return;const n=await Kt(()=>import("./index-RV3NNz1L.js"),__vite__mapDeps([6,7])),{defaultOptions:r}=await Kt(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=Df(i.message));for(const s of((o=i.exception)==null?void 0:o.values)??[])s.value&&(s.value=Df(s.value));return i.request&&(i.request.data=void 0,i.request.url&&(i.request.url=Df(i.request.url))),i},beforeBreadcrumb:i=>(i.message&&(i.message=Df(i.message)),(i.category==="fetch"||i.category==="xhr")&&(i.data=void 0),i)}),cp=n,window.addEventListener("error",i=>{Hv(i.error??i.message,{source:"window.onerror"})}),window.addEventListener("unhandledrejection",i=>{Hv(i.reason,{source:"unhandledrejection"})}),console.info("[sentry] client crash reporting initialised")}catch(t){console.warn("[sentry] client init failed (non-fatal):",t)}}function TB(){return cp!==null}function Hv(t,e){if(cp)try{cp.captureException(t,e?{extra:e}:void 0)}catch{}}const MB={pass:"[ok] ",warn:"[warn]",fail:"[fail]"};function Kg(t){return t.replace(/[\x00-\x08\x0b-\x1f\x7f]/g,"")}function DB(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(`${MB[n.status]} ${n.check} — ${Kg(n.message)}`),n.status!=="pass"&&n.fix&&e.push(` fix: ${Kg(n.fix)}`);return e.push("",Kg(t.report.summary)),e.join(`
124
- `)}var OB=T('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),IB=T('<button type="button" data-testid="settings-modal-open-log-folder-btn">Open Log Folder</button>'),RB=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),NB=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),PB=T('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 11px;"></dl>'),LB=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),FB=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 zB(t,e){et(e,!0);const n=Bm(()=>e.open);let r=L(!1),i=L(null),o=L(!1);async function s(){b(o,!0);let I;try{let B;try{B=await fetch(`${Qt}${HD}`)}catch{e.notify("error","Couldn't reach the server — is it running?");return}if(!B.ok){e.notify("error","Diagnostics failed on the server — try `tandem doctor` in a terminal");return}I=DB(await B.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},B]=await Promise.all([Kt(()=>import("./path-DpyQXOHZ.js"),__vite__mapDeps([0,1])),ss()]),z=await I();await B("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 B=await ls(I,{readOnly:!0,notFoundMessage:"Documentation file not found.",failureMessage:"Failed to open documentation."});b(r,!1),B.ok||b(i,B.error,!0)}const c=N(()=>{var z;const I=n.info;if(!I)return[];const B=[{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&&B.push({label:"Storage",value:I.storagePath}),I.tokenRotatedAt!==void 0&&B.push({label:"Token",value:I.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(I.tokenRotatedAt).toLocaleString()}`}),I.changelogPath&&B.push({label:"Changelog",value:I.changelogPath}),B.push({label:"Crash reports",value:TB()?"On (TANDEM_SENTRY_DSN set)":"Off — opt in with TANDEM_SENTRY_DSN"}),B});var d=FB(),f=Ae(d),h=w(f),p=w(h),m=k(h,2);{var v=I=>{var B=OB(),z=w(B);W(()=>G(z,u(i))),x(I,B)};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 B=IB();Le(B,"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",B,()=>void a()),x(I,B)},A=N(()=>Tt());j(_,I=>{u(A)&&I(S)})}var O=k(g,2),E=k(w(O),2);{var M=I=>{var B=RB();x(I,B)},R=I=>{var B=PB();pt(B,21,()=>u(c),z=>z.label,(z,Q)=>{var ie=NB(),he=Ae(ie),ae=w(he),ke=k(he,2),le=w(ke);W(()=>{G(ae,u(Q).label),G(le,u(Q).value)}),x(z,ie)}),x(I,B)},D=I=>{var B=LB();x(I,B)};j(E,I=>{n.loading?I(M):n.info?I(R,1):I(D,-1)})}W(()=>{h.disabled=u(r)||n.loading,Le(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),Le(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),tt()}ut(["click"]);const GE={models:"models"};var BB=T('<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>'),HB=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>'),VB=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>'),UB=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 jB(t,e){et(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:VE},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16",component:UE},{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:qE},{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:HE},{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:qz},{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:Vz},{id:"models",label:"Models",icon:"M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z",component:dB},{id:"shortcuts",label:"Shortcuts",icon:"M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z",component:_B},{id:"about",label:"About",icon:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01",component:zB}].filter(z=>z.id!==GE.models||ZM);let o=Ye(e,"returnFocusEl",3,null),s=Ye(e,"triggerEl",3,null),a=Ye(e,"connected",3,!1),l=Ye(e,"reconnectAttempts",3,0),c=Ye(e,"tabs",3,i),d=Ye(e,"initialTabId",3,null),f=Ye(e,"notify",3,()=>{}),h=L(void 0);const p=Bm(()=>e.open);let m=L(!1),v=L(null),g=L(!1);me(()=>{e.open&&b(g,!1)});let y=!1;me(()=>{if(e.open&&!y&&d()){const z=u(_).find(Q=>Q.id===d());z&&b(S,z.id,!0)}y=e.open});let C=L(!1);me(()=>{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 _=N(()=>c().length>0?c():i);let S=L(at(i[0].id));const A=N(()=>u(_).find(z=>z.id===u(S))??u(_)[0]),O=N(()=>u(A).label),E=N(()=>({open:e.open,settings:e.settings,onUpdate:e.onUpdate,connected:a(),reconnectAttempts:l(),notify:f()}));me(()=>{u(A)&&u(A).id!==u(S)&&b(S,u(A).id,!0)}),me(()=>{if(e.open)return Mt(()=>{var z;return(z=u(h))==null?void 0:z.focus()}),()=>{var z;(z=o())==null||z.focus()}}),me(()=>{if(!e.open)return;const z=ie=>{var ae;const he=ie.target;he&&((ae=s())!=null&&ae.contains(he)||u(h)&&!u(h).contains(he)&&e.onClose())},Q=setTimeout(()=>document.addEventListener("pointerdown",z),0);return()=>{clearTimeout(Q),document.removeEventListener("pointerdown",z)}}),Lc(()=>{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)}),me(()=>{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 he=ie[0],ae=ie[ie.length-1],ke=document.activeElement;if(!u(h).contains(ke)){Q.preventDefault(),he.focus();return}Q.shiftKey&&ke===he?(Q.preventDefault(),ae.focus()):!Q.shiftKey&&ke===ae&&(Q.preventDefault(),he.focus())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)}),me(()=>{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 ls(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 B=z=>{var Q=UB(),ie=Ae(Q),he=k(ie,2);U(he,"aria-labelledby",n),U(he,"tabindex",-1);var ae=w(he),ke=w(ae),le=w(ke);U(le,"id",n);var be=k(le,2);{var Re=xe=>{var Me=BB(),Se=w(Me);W(()=>G(Se,`v${p.info.version??""}`)),x(xe,Me)};j(be,xe=>{p.info&&xe(Re)})}var $=k(ke,2);pt($,21,()=>u(_),xe=>xe.id,(xe,Me)=>{var Se=HB(),qe=w(Se),it=w(qe),ce=k(qe,2),Ie=w(ce);W(()=>{U(Se,"aria-current",u(S)===u(Me).id?"page":void 0),U(Se,"data-active",u(S)===u(Me).id?"true":"false"),U(Se,"data-testid",`settings-modal-tab-${u(Me).id}`),U(it,"d",u(Me).icon),G(Ie,u(Me).label)}),P("click",Se,()=>{b(S,u(Me).id,!0),b(g,!1)}),x(xe,Se)});var q=k($,2),H=w(q),ne=w(H),te=k(H,2);{var Z=xe=>{var Me=VB(),Se=w(Me);W(()=>G(Se,u(v))),x(xe,Me)};j(te,xe=>{u(v)&&xe(Z)})}var ge=k(te,2),De=k(ge,2),Ee=w(De),de=k(Ee,2),_e=w(de);{var J=xe=>{var Me=dr("MCP connected");x(xe,Me)},ye=xe=>{var Me=dr("Reconnecting…");x(xe,Me)},Y=xe=>{var Me=dr("MCP offline");x(xe,Me)};j(_e,xe=>{a()?xe(J):l()>0?xe(ye,1):xe(Y,-1)})}Ur(ae,(xe,Me)=>Yt==null?void 0:Yt(xe,Me),()=>"y");var se=k(ae,2),Te=w(se),Oe=w(Te),ze=k(Oe,2),Xe=w(ze),ue=k(ze,2),re=k(Te,2),pe=w(re),Ne=w(pe);Fl(Ne,()=>u(A).id,xe=>{var Me=St(),Se=Ae(Me);qb(Se,()=>u(A).component,(qe,it)=>{it(qe,du(()=>u(E)))}),x(xe,Me)}),Ur(re,(xe,Me)=>Yt==null?void 0:Yt(xe,Me),()=>"y"),Ot(he,xe=>b(h,xe),()=>u(h)),W(()=>{U(he,"data-narrow-sidebar-open",u(g)?"true":"false"),ae.inert=u(C)&&!u(g),H.disabled=u(m)||p.loading,G(ne,u(m)?"Opening…":"Changelog"),U(ge,"href",kC),U(Ee,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),U(Oe,"aria-label",u(g)?"Hide sections":"Show sections"),U(Oe,"aria-expanded",u(g)),G(Xe,u(O))}),P("click",ie,function(...xe){var Me;(Me=e.onClose)==null||Me.apply(this,xe)}),P("keydown",ie,xe=>{(xe.key==="Enter"||xe.key===" ")&&(xe.preventDefault(),e.onClose())}),P("click",H,()=>void M()),P("click",Oe,()=>{b(g,!u(g))}),P("click",ue,function(...xe){var Me;(Me=e.onClose)==null||Me.apply(this,xe)}),x(z,Q)};j(I,z=>{e.open&&z(B)})}return x(t,D),tt(R)}ut(["click","keydown"]);var qB=T('<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>'),WB=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>'),KB=T('<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),GB=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
125
- restores when you return to Tandem.</div>`,1),ZB=T('<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),YB=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),JB=T('<div data-testid="settings-shortcuts-list"><!></div>'),XB=T('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),QB=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),$B=T('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),eH=T('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),tH=T('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),nH=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),rH=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){et(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=Ye(e,"connected",3,!1),s=Ye(e,"reconnectAttempts",3,0),a=L(void 0),l=L(void 0);const c=B1();let d=L(at(c.userName));const f=Bm(()=>e.open);let h=L(!1),p=L(null),m=L(!1),v=L(null),g=L("appearance");me(()=>{u(g),b(p,null),b(v,null)}),me(()=>{const I=c.userName;u(d)!==I&&document.activeElement!==u(l)&&b(d,I,!0)}),me(()=>{var I;if(e.open)return(I=u(a))==null||I.focus(),()=>{var B;(B=e.returnFocusEl)==null||B.focus()}}),me(()=>{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()},B=setTimeout(()=>document.addEventListener("pointerdown",I),0);return()=>{clearTimeout(B),document.removeEventListener("pointerdown",I)}}),me(()=>{if(!e.open)return;const I=B=>{if(B.key==="Escape"){B.preventDefault(),B.stopPropagation(),e.onClose();return}if(B.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],he=document.activeElement;if(!u(a).contains(he)){B.preventDefault(),Q.focus();return}B.shiftKey&&he===Q?(B.preventDefault(),ie.focus()):!B.shiftKey&&he===ie&&(B.preventDefault(),Q.focus())};return window.addEventListener("keydown",I,{capture:!0}),()=>window.removeEventListener("keydown",I,{capture:!0})});async function y(I,B,z,Q){if(!I){z(Q.notFound);return}B(!0),z(null);try{const ie=await ls(I,{readOnly:!0,notFoundMessage:Q.notFound,failureMessage:Q.failed});if(!ie.ok){z(ie.error);return}e.onClose()}finally{B(!1)}}function C(){var I;return y((I=f.info)==null?void 0:I.workflowsPath,B=>b(m,B,!0),B=>b(v,B,!0),{notFound:"Documentation file not found.",failed:"Failed to open documentation."})}function _(){var I;return y((I=f.info)==null?void 0:I.changelogPath,B=>b(h,B,!0),B=>b(p,B,!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 B;return((B=i.find(z=>z.id===I))==null?void 0:B.label)??"Settings"}function E(){var z;const I=f.info;if(!I)return[];const B=[{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&&B.push({label:"Storage",value:I.storagePath}),I.tokenRotatedAt!==void 0&&B.push({label:"Token",value:I.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(I.tokenRotatedAt).toLocaleString()}`}),I.changelogPath&&B.push({label:"Changelog",value:I.changelogPath}),B}var M=St(),R=Ae(M);{var D=I=>{var B=rH(),z=Ae(B),Q=k(z,2);U(Q,"aria-labelledby",n),U(Q,"tabindex",-1);var ie=w(Q),he=w(ie),ae=w(he);U(ae,"id",n);var ke=k(ae,2);{var le=ce=>{var Ie=qB(),V=w(Ie);W(()=>G(V,`v${f.info.version??""}`)),x(ce,Ie)};j(ke,ce=>{f.info&&ce(le)})}var be=k(he,2);pt(be,21,()=>i,ce=>ce.id,(ce,Ie)=>{var V=WB(),ee=w(V),we=w(ee),Ve=k(ee,2),Fe=w(Ve);W(()=>{U(V,"aria-current",u(g)===u(Ie).id?"page":void 0),U(V,"data-active",u(g)===u(Ie).id?"true":"false"),U(we,"d",u(Ie).icon),G(Fe,u(Ie).label)}),P("click",V,()=>b(g,u(Ie).id,!0)),x(ce,V)});var Re=k(be,2),$=w(Re),q=w($),H=k($,2);{var ne=ce=>{var Ie=KB(),V=w(Ie);W(()=>G(V,u(p))),x(ce,Ie)};j(H,ce=>{u(p)&&ce(ne)})}var te=k(H,2),Z=k(te,2),ge=w(Z),De=k(ge,2),Ee=w(De);{var de=ce=>{var Ie=dr("MCP connected");x(ce,Ie)},_e=ce=>{var Ie=dr("Reconnecting…");x(ce,Ie)},J=ce=>{var Ie=dr("MCP offline");x(ce,Ie)};j(Ee,ce=>{o()?ce(de):s()>0?ce(_e,1):ce(J,-1)})}var ye=k(ie,2),Y=w(ye),se=w(Y),Te=w(se),Oe=k(se,2),ze=k(Y,2),Xe=w(ze),ue=w(Xe);{var re=ce=>{var Ie=GB(),V=Ae(Ie),ee=w(V);Le(ee,S);var we=k(ee,2);Ot(we,We=>b(l,We),()=>u(l));var Ve=k(V,2),Fe=w(Ve);Le(Fe,S);var K=k(Fe,2),fe=w(K),Pe=k(fe,2),Be=k(Ve,2),Ke=w(Be);W(()=>{Br(we,u(d)),U(we,"maxlength",fm),U(fe,"aria-checked",e.settings.defaultMode==="tandem"),Le(fe,`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(Pe,"aria-checked",e.settings.defaultMode==="solo"),Le(Pe,`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;`),Kn(Ke,e.settings.soloRailHidden)}),P("input",we,We=>{b(d,We.target.value,!0)}),hn("blur",we,()=>c.setUserName(u(d))),P("keydown",we,We=>{We.key==="Enter"&&We.currentTarget.blur(),We.key==="Escape"&&(b(d,c.userName,!0),We.currentTarget.blur())}),P("click",fe,()=>e.onUpdate({defaultMode:"tandem"})),P("click",Pe,()=>e.onUpdate({defaultMode:"solo"})),P("change",Ke,We=>e.onUpdate({soloRailHidden:We.target.checked})),x(ce,Ie)},pe=ce=>{VE(ce,{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})},Ne=ce=>{UE(ce,{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=ce=>{qE(ce,{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})},Me=ce=>{HE(ce,{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})},Se=ce=>{var Ie=YB(),V=Ae(Ie),ee=w(V);Le(ee,S);var we=k(w(ee)),Ve=w(we),Fe=k(ee,4);U(Fe,"step",100);var K=k(Fe,2),fe=w(K),Pe=w(fe),Be=k(fe,2),Ke=w(Be),We=k(V,2),Ue=w(We),nt=k(We,2),rt=w(nt),xt=k(nt,4);{var qt=Ct=>{var Nt=St(),ln=Ae(Nt);mC(ln,()=>Kt(()=>import("./CoworkSettings-DyolPw-M.js"),__vite__mapDeps([4,5])),vn=>{var er=ZB();x(vn,er)},(vn,er)=>{const zt=N(()=>u(er).default);var Mn=St(),cr=Ae(Mn);qb(cr,()=>u(zt),(En,An)=>{An(En,{})}),x(vn,Mn)}),x(Ct,Nt)},Je=N(()=>Tt());j(xt,Ct=>{u(Je)&&Ct(qt)})}W((Ct,Nt,ln)=>{G(Ve,`${Ct??""}s`),U(Fe,"min",uc),U(Fe,"max",dc),Br(Fe,e.settings.selectionDwellMs),G(Pe,`${Nt??""}s`),G(Ke,`${ln??""}s`),Kn(Ue,e.settings.selectionToolbar),Kn(rt,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(uc/1e3).toFixed(1),()=>(dc/1e3).toFixed(1)]),P("input",Fe,Ct=>e.onUpdate({selectionDwellMs:Number(Ct.target.value)})),P("change",Ue,Ct=>e.onUpdate({selectionToolbar:Ct.target.checked})),P("change",rt,Ct=>e.onUpdate({marginView:Ct.target.checked})),x(ce,Ie)},qe=ce=>{var Ie=JB(),V=w(Ie);KE(V,{get settings(){return e.settings},get onUpdate(){return e.onUpdate},notify:A}),x(ce,Ie)},it=ce=>{var Ie=nH(),V=Ae(Ie),ee=w(V),we=w(ee),Ve=k(ee,2);{var Fe=Ue=>{var nt=XB(),rt=w(nt);W(()=>G(rt,u(v))),x(Ue,nt)};j(Ve,Ue=>{u(v)&&Ue(Fe)})}var K=k(V,2),fe=w(K);Le(fe,S);var Pe=k(fe,2);{var Be=Ue=>{var nt=QB();x(Ue,nt)},Ke=Ue=>{var nt=eH();pt(nt,21,E,rt=>rt.label,(rt,xt)=>{var qt=$B(),Je=Ae(qt),Ct=w(Je),Nt=k(Je,2),ln=w(Nt);W(()=>{G(Ct,u(xt).label),G(ln,u(xt).value)}),x(rt,qt)}),x(Ue,nt)},We=Ue=>{var nt=tH();x(Ue,nt)};j(Pe,Ue=>{f.loading?Ue(Be):f.info?Ue(Ke,1):Ue(We,-1)})}W(()=>{ee.disabled=u(m)||f.loading,Le(ee,`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",ee,()=>void C()),x(ce,Ie)};j(ue,ce=>{u(g)==="collaboration"?ce(re):u(g)==="appearance"?ce(pe,1):u(g)==="editor"?ce(Ne,2):u(g)==="network"?ce(xe,3):u(g)==="accessibility"?ce(Me,4):u(g)==="claude-code"?ce(Se,5):u(g)==="shortcuts"?ce(qe,6):ce(it,-1)})}Ot(Q,ce=>b(a,ce),()=>u(a)),W(ce=>{$.disabled=u(h)||f.loading,G(q,u(h)?"Opening…":"Changelog"),U(te,"href",kC),U(ge,"data-state",o()?"connected":s()>0?"reconnecting":"disconnected"),G(Te,ce)},[()=>O(u(g))]),P("click",z,function(...ce){var Ie;(Ie=e.onClose)==null||Ie.apply(this,ce)}),P("click",$,()=>void _()),P("click",Oe,function(...ce){var Ie;(Ie=e.onClose)==null||Ie.apply(this,ce)}),x(I,B)};j(R,I=>{e.open&&I(D)})}x(t,M),tt()}ut(["click","input","keydown","change"]);var oH=rn("<path></path>"),sH=T('<span class="badge svelte-nsu1aw"> </span>'),aH=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>'),cH=T('<div data-testid="toast-container" class="toast-stack svelte-nsu1aw"></div>');function uH(t,e){et(e,!0);var n=St(),r=Ae(n);{var i=o=>{var s=cH();pt(s,21,()=>e.toasts,a=>a.id,(a,l)=>{var c=lH(),d=w(c),f=w(d);pt(f,20,()=>dS[u(l).severity],S=>S,(S,A)=>{var O=oH();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=sH(),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=aH(),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}`),vt(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),tt()}ut(["click"]);var dH=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 fH(t,e){const n=N(()=>e.installing?"Installing…":"Restart to install");var r=dH(),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)}ut(["click"]);const hH=Math.floor,pH=(t,e)=>t<e?t:e,mH=(t,e)=>t>e?t:e,ZE=128,yh=127,gH=Number.MAX_SAFE_INTEGER,vH=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},fd=typeof TextEncoder<"u"?new TextEncoder:null,bH=t=>fd.encode(t),yH=fd?bH:vH;let Au=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Au&&Au.decode(new Uint8Array).length===1&&(Au=null);const up=(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},Hm=(t,e)=>{for(;e>yh;)up(t,ZE|yh&e),e=hH(e/128);up(t,yh&e)},Vv=new Uint8Array(3e4),wH=Vv.length/3,kH=(t,e)=>{if(e.length<wH){const n=fd.encodeInto(e,Vv).written||0;Hm(t,n);for(let r=0;r<n;r++)up(t,Vv[r])}else SH(t,yH(e))},xH=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Hm(t,r);for(let i=0;i<r;i++)up(t,n.codePointAt(i))},_H=fd&&fd.encodeInto?kH:xH,CH=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=pH(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(mH(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},SH=(t,e)=>{Hm(t,e.byteLength),CH(t,e)},YE=t=>new Error(t),EH=YE("Unexpected end of array"),AH=YE("Integer out of Range"),TH=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},MH=t=>TH(t,H1(t)),Kk=t=>t.arr[t.pos++],H1=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&yh)*n,n*=128,i<ZE)return e;if(e>gH)throw AH}throw EH},DH=t=>{let e=H1(t);if(e===0)return"";{let n=String.fromCodePoint(Kk(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Kk(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))}},OH=t=>Au.decode(MH(t)),Gk=Au?OH:DH;var Wl;(function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"})(Wl||(Wl={}));const IH=(t,e)=>{Hm(t,Wl.Token),_H(t,e)},RH=(t,e,n,r)=>{switch(H1(t)){case Wl.Token:{e();break}case Wl.PermissionDenied:{n(Gk(t));break}case Wl.Authenticated:{r(Gk(t));break}}},Zk=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n}));var Uv;(function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"})(Uv||(Uv={}));function NH(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 Gg(t){return new Promise(e=>setTimeout(e,t))}function PH(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 LH(t,e){const n=NH(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||PH;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 Gg(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 Gg(s),r.attemptNum<1&&n.initialJitter){const a=i(r,n);a&&await Gg(a)}return o()}const JE=Math.floor,FH=(t,e)=>t<e?t:e,zH=(t,e)=>t>e?t:e,BH=64,dp=128,HH=63,Tu=127,XE=Number.MAX_SAFE_INTEGER,VH=()=>new Set,UH=Array.from,jH=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},hd=typeof TextEncoder<"u"?new TextEncoder:null,qH=t=>hd.encode(t),WH=hd?qH:jH;let Mu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Mu&&Mu.decode(new Uint8Array).length===1&&(Mu=null);class KH{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const V1=()=>new KH,QE=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},U1=t=>{const e=new Uint8Array(QE(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},fp=(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},hr=(t,e)=>{for(;e>Tu;)fp(t,dp|Tu&e),e=JE(e/128);fp(t,Tu&e)},jv=new Uint8Array(3e4),GH=jv.length/3,ZH=(t,e)=>{if(e.length<GH){const n=hd.encodeInto(e,jv).written||0;hr(t,n);for(let r=0;r<n;r++)fp(t,jv[r])}else Kc(t,WH(e))},YH=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;hr(t,r);for(let i=0;i<r;i++)fp(t,n.codePointAt(i))},as=hd&&hd.encodeInto?ZH:YH,JH=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=FH(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(zH(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},Kc=(t,e)=>{hr(t,e.byteLength),JH(t,e)},$E=t=>new Error(t),eA=$E("Unexpected end of array"),tA=$E("Integer out of Range");class XH{constructor(e){this.arr=e,this.pos=0}}const nA=t=>new XH(t),QH=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Vm=t=>QH(t,Fa(t)),Yk=t=>t.arr[t.pos++],Fa=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&Tu)*n,n*=128,i<dp)return e;if(e>XE)throw tA}throw eA},$H=t=>{let e=t.arr[t.pos++],n=e&HH,r=64;const i=(e&BH)>0?-1:1;if((e&dp)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&Tu)*r,r*=128,e<dp)return i*n;if(n>XE)throw tA}throw eA},eV=t=>{let e=Fa(t);if(e===0)return"";{let n=String.fromCodePoint(Yk(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Yk(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))}},tV=t=>Mu.decode(Vm(t)),pd=Mu?tV:eV,nV=t=>{const e=t.pos,n=pd(t);return t.pos=e,n},Ec=Date.now,Zg=()=>new Map,rV=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r};class iV{constructor(){this._observers=Zg()}on(e,n){rV(this._observers,e,VH).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 UH((this._observers.get(e)||Zg()).values()).forEach(r=>r(...n))}destroy(){this._observers=Zg()}}const oV=Object.keys,Jk=t=>oV(t).length,sV=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),aV=(t,e)=>t===e,Du=(t,e)=>{if(t==null||e==null)return aV(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)||!Du(t.get(n),e.get(n)))return!1;break}case Object:if(Jk(t)!==Jk(e))return!1;for(const n in t)if(!sV(t,n)||!Du(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(!Du(t[n],e[n]))return!1;break;default:return!1}return!0},Yg=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=Ec();this.getLocalState()!==null&&Yg/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,o)=>{o!==this.clientID&&Yg<=n-i.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&wh(this,r,"timeout")},JE(Yg/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:Ec()});const s=[],a=[],l=[],c=[];e===null?c.push(n):o==null?e!=null&&s.push(n):(a.push(n),Du(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 wh=(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:Ec()})}r.push(o)}}r.length>0&&(t.emit("change",[{added:[],updated:[],removed:r},n]),t.emit("update",[{added:[],updated:[],removed:r},n]))},qv=(t,e,n=t.states)=>{const r=e.length,i=V1();hr(i,r);for(let o=0;o<r;o++){const s=e[o],a=n.get(s)||null,l=t.meta.get(s).clock;hr(i,s),hr(i,l),as(i,JSON.stringify(a))}return U1(i)},cV=(t,e,n)=>{const r=nA(e),i=Ec(),o=[],s=[],a=[],l=[],c=Fa(r);for(let d=0;d<c;d++){const f=Fa(r);let h=Fa(r);const p=JSON.parse(pd(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&&(Du(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 rA=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 Wv{constructor(e){this.data=e,this.encoder=V1(),this.decoder=nA(new Uint8Array(this.data))}peekVarString(){return nV(this.decoder)}readVarUint(){return Fa(this.decoder)}readVarString(){return pd(this.decoder)}readVarUint8Array(){return Vm(this.decoder)}writeVarUint(e){return hr(this.encoder,e)}writeVarString(e){return as(this.encoder,e)}writeVarUint8Array(e){return Kc(this.encoder,e)}length(){return QE(this.encoder)}}var rr;(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"})(rr||(rr={}));var xr;(function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"})(xr||(xr={}));class ll{constructor(){this.encoder=V1()}get(e){return e.encoder}toUint8Array(){return U1(this.encoder)}}class uV extends ll{constructor(){super(...arguments),this.type=rr.CLOSE,this.description="Ask the server to close the connection"}get(e){return as(this.encoder,e.documentName),hr(this.encoder,this.type),this.encoder}}class dV extends rA{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=xr.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=xr.Connected,this.emit("status",{status:xr.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===xr.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===xr.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(uV,{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===xr.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const e=()=>{let i=!1;return{retryPromise:LH(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=xr.Connecting,this.emit("status",{status:xr.Connecting}),this.connectionAttempt={resolve:e,reject:n}})}onMessage(e){var n;this.resolveConnectionAttempt(),this.lastMessageReceived=Ec();const i=new Wv(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=xr.Connected,this.emit("status",{status:xr.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===xr.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Ec()-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)===Uv.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=xr.Disconnected,this.emit("status",{status:xr.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 iA=0,j1=1,oA=2,fV=(t,e)=>{hr(t,iA);const n=NP(e);Kc(t,n)},hV=(t,e,n)=>{hr(t,j1),Kc(t,DP(e,n))},pV=(t,e,n)=>hV(e,n,Vm(t)),sA=(t,e,n)=>{try{AP(e,Vm(t),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},mV=(t,e)=>{hr(t,oA),Kc(t,e)},gV=sA,vV=(t,e,n,r)=>{const i=Fa(t);switch(i){case iA:pV(t,e,n);break;case j1:sA(t,n,r);break;case oA:gV(t,n,r);break;default:throw new Error("Unknown message type")}return i};class bV{constructor(e){this.message=e}apply(e,n){const{message:r}=this,i=r.readVarUint(),o=r.length();switch(i){case rr.Sync:this.applySyncMessage(e,n);break;case rr.Awareness:this.applyAwarenessMessage(e);break;case rr.Auth:this.applyAuthMessage(e);break;case rr.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case rr.Stateless:e.receiveStateless(pd(r.decoder));break;case rr.SyncStatus:this.applySyncStatusMessage(e,$H(r.decoder)===1);break;case rr.CLOSE:const s={code:1e3,reason:pd(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(ll,{encoder:r.encoder})}applySyncMessage(e,n){const{message:r}=this;r.writeVarUint(rr.Sync);const i=vV(r.decoder,r.encoder,e.document,e);n&&i===j1&&(e.synced=!0)}applySyncStatusMessage(e,n){n&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:n}=this;cV(e.awareness,n.readVarUint8Array(),e)}applyAuthMessage(e){const{message:n}=this;RH(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(rr.Awareness),n.writeVarUint8Array(qv(e.awareness,Array.from(e.awareness.getStates().keys())))}}class yV{constructor(e,n={}){this.message=new e,this.encoder=this.message.get(n)}create(){return U1(this.encoder)}send(e){e==null||e.send(this.create())}}class wV extends ll{constructor(){super(...arguments),this.type=rr.Auth,this.description="Authentication"}get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return as(this.encoder,e.documentName),hr(this.encoder,this.type),IH(this.encoder,e.token),this.encoder}}class Xk extends ll{constructor(){super(...arguments),this.type=rr.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");as(this.encoder,e.documentName),hr(this.encoder,this.type);let n;return e.states===void 0?n=qv(e.awareness,e.clients):n=qv(e.awareness,e.clients,e.states),Kc(this.encoder,n),this.encoder}}class kV extends ll{constructor(){super(...arguments),this.type=rr.Stateless,this.description="A stateless message"}get(e){var n;return as(this.encoder,e.documentName),hr(this.encoder,this.type),as(this.encoder,(n=e.payload)!==null&&n!==void 0?n:""),this.encoder}}class Qk extends ll{constructor(){super(...arguments),this.type=rr.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 as(this.encoder,e.documentName),hr(this.encoder,this.type),fV(this.encoder,e.document),this.encoder}}class xV extends ll{constructor(){super(...arguments),this.type=rr.Sync,this.description="A document update"}get(e){return as(this.encoder,e.documentName),hr(this.encoder,this.type),mV(this.encoder,e.update),this.encoder}}class _V extends Error{constructor(){super(...arguments),this.code=1001}}class $k extends rA{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 ko,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:Zk(this.awareness.getStates())})}),(r=this.awareness)===null||r===void 0||r.on("change",()=>{this.emit("awarenessChange",{states:Zk(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 dV(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(Qk,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&wh(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(kV,{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(wV,{token:e??"",documentName:this.configuration.name})}documentUpdateHandler(e,n){n!==this&&(this.incrementUnsyncedChanges(),this.send(xV,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:n,removed:r},i){const o=e.concat(n).concat(r);this.send(Xk,{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(Qk,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Xk,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,n){if(!this._isAttached)return;const r=new yV(e,n);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const n=new Wv(e.data),r=n.readVarString();n.writeVarString(r),this.emit("message",{event:e,message:new Wv(e.data)}),new bV(n).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&wh(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&&(wh(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 _V(`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 or=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ac=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Kv=null;const Bo=function(t,e,n){let r=Kv||(Kv=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},CV=function(){Kv=null},Xa=function(t,e,n,r){return n&&(ex(t,e,n,r,-1)||ex(t,e,n,r,1))},SV=/^(img|br|input|textarea|hr)$/i;function ex(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:yi(t))){let s=t.parentNode;if(!s||s.nodeType!=1||of(t)||SV.test(t.nodeName)||t.contentEditable=="false")return!1;e=or(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?yi(t):0}else return!1}}function yi(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function EV(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=yi(t)}else if(t.parentNode&&!of(t))e=or(t),t=t.parentNode;else return null}}function AV(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&&!of(t))e=or(t)+1,t=t.parentNode;else return null}}function TV(t,e,n){for(let r=e==0,i=e==yi(t);r||i;){if(t==n)return!0;let o=or(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==yi(t)}}function of(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 Um=function(t){return t.focusNode&&Xa(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function pa(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function MV(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function DV(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(yi(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(yi(r.startContainer),r.startOffset)}}}const xo=typeof navigator<"u"?navigator:null,tx=typeof document<"u"?document:null,ia=xo&&xo.userAgent||"",Gv=/Edge\/(\d+)/.exec(ia),aA=/MSIE \d/.exec(ia),Zv=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ia),Vr=!!(aA||Zv||Gv),js=aA?document.documentMode:Zv?+Zv[1]:Gv?+Gv[1]:0,Ei=!Vr&&/gecko\/(\d+)/i.test(ia);Ei&&+(/Firefox\/(\d+)/.exec(ia)||[0,0])[1];const Yv=!Vr&&/Chrome\/(\d+)/.exec(ia),ar=!!Yv,lA=Yv?+Yv[1]:0,mr=!Vr&&!!xo&&/Apple Computer/.test(xo.vendor),Tc=mr&&(/Mobile\/\w+/.test(ia)||!!xo&&xo.maxTouchPoints>2),mi=Tc||(xo?/Mac/.test(xo.platform):!1),cA=xo?/Win/.test(xo.platform):!1,Wo=/Android \d/.test(ia),sf=!!tx&&"webkitFontSmoothing"in tx.documentElement.style,OV=sf?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function IV(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 Io(t,e){return typeof t=="number"?t:t[e]}function RV(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 nx(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=Ac(s);continue}let a=s,l=a==o.body,c=l?IV(o):RV(a),d=0,f=0;if(e.top<c.top+Io(r,"top")?f=-(c.top-e.top+Io(i,"top")):e.bottom>c.bottom-Io(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Io(i,"top")-c.top:e.bottom-c.bottom+Io(i,"bottom")),e.left<c.left+Io(r,"left")?d=-(c.left-e.left+Io(i,"left")):e.right>c.right-Io(r,"right")&&(d=e.right-c.right+Io(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:Ac(s)}}function NV(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:uA(t.dom)}}function uA(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ac(r));return e}function PV({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 bl=null;function LV(t){if(t.setActive)return t.setActive();if(bl)return t.focus(bl);let e=uA(t);t.focus(bl==null?{get preventScroll(){return bl={preventScroll:!0},!0}}:void 0),bl||(bl=!1,dA(e,0))}function fA(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=Bo(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?FV(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:fA(n,i)}function FV(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=vs(r,1);if(s.top!=s.bottom&&q1(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 q1(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function zV(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function BV(t,e,n){let{node:r,offset:i}=fA(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 HV(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 hA(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(q1(e,c))return hA(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function VV(t,e){let n=t.dom.ownerDocument,r,i=0,o=DV(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(!q1(e,c)||(s=hA(t.dom,e,c),!s))return null}if(mr)for(let c=s;r&&c;c=Ac(c))c.draggable&&(r=void 0);if(s=zV(s,e),r){if(Ei&&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;sf&&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=HV(t,r,i,e))}a==null&&(a=BV(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function rx(t){return t.top<t.bottom||t.left<t.right}function vs(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(rx(r))return r}return Array.prototype.find.call(n,rx)||t.getBoundingClientRect()}const UV=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function pA(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=sf||Ei;if(r.nodeType==3)if(s&&(UV.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=vs(Bo(r,i,i),n);if(Ei&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=vs(Bo(r,i-1,i-1),-1);if(c.top==l.top){let d=vs(Bo(r,i,i+1),-1);if(d.top!=l.top)return nu(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++,nu(vs(Bo(r,l,c),d),d<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==yi(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return Jg(l.getBoundingClientRect(),!1)}if(o==null&&i<yi(r)){let l=r.childNodes[i];if(l.nodeType==1)return Jg(l.getBoundingClientRect(),!0)}return Jg(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==yi(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Bo(l,yi(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return nu(vs(c,1),!1)}if(o==null&&i<yi(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Bo(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return nu(vs(c,-1),!0)}return nu(vs(r.nodeType==3?Bo(r):r,-n),n>=0)}function nu(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 Jg(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 mA(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 jV(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return mA(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=pA(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=Bo(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 qV=/[\u0590-\u08ac]/;function WV(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?!qV.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:s:mA(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 ix=null,ox=null,sx=!1;function KV(t,e,n){return ix==e&&ox==n?sx:(ix=e,ox=n,sx=n=="up"||n=="down"?jV(t,e,n):WV(t,e,n))}const Ai=0,ax=1,wa=2,_o=3;class af{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Ai,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>or(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 vA){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 gA&&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?or(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?or(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=or(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=or(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((Ei||mr)&&e==n){let{node:p,offset:m}=a;if(p.nodeType==3){if(f=!!(m&&p.nodeValue[m-1]==`
126
- `),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:or(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(Ei&&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&&mr)&&Xa(a.node,a.offset,d.anchorNode,d.anchorOffset)&&Xa(l.node,l.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(f&&Ei)){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?wa:ax,e==a&&n==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=_o:o.markDirty(e-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?wa:_o}r=s}this.dirty=wa}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?wa:ax;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class gA extends af{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==Ai&&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 GV extends af{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 Qa extends af{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=ol.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Qa(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&_o||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=_o&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ai){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ai}}slice(e,n,r){let i=Qa.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Xv(o,n,s,r)),e>0&&(o=Xv(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 qs extends af{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}=ol.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=wA(d,r,n),c?l=new ZV(e,n,r,i,d,f||null,h,c,o,s+1):n.isText?new jm(e,n,r,i,d,h,o):new qs(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==Ai&&e.eq(this.node)&&hp(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 JV(this,s&&s.node,e);$V(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?Jt.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==wa)&&(s&&this.protectLocalComposition(e,s),bA(this.contentDOM,this.children,e),Tc&&eU(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof dt)||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=tU(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 GV(this,o,n,i);e.input.compositionNodes.push(s),this.children=Xv(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==_o||!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=Ai}updateOuterDeco(e){if(hp(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=yA(this.dom,this.nodeDOM,Jv(this.outerDeco,this.node,n),Jv(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 lx(t,e,n,r,i){wA(r,e,t);let o=new qs(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class jm extends qs{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==_o||this.dirty!=Ai&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ai||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=Ai,!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 jm(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=_o)}get domAtom(){return!1}isText(e){return this.node.text==e}}class vA extends af{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ai&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ZV extends qs{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==_o)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 bA(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=cx(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(s instanceof Qa){let l=r?r.previousSibling:t.lastChild;bA(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=cx(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Ou=function(t){t&&(this.nodeName=t)};Ou.prototype=Object.create(null);const ka=[new Ou];function Jv(t,e,n){if(t.length==0)return ka;let r=n?ka[0]:new Ou,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new Ou(s.nodeName));for(let a in s){let l=s[a];l!=null&&(n&&i.length==1&&i.push(r=new Ou(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 yA(t,e,n,r){if(n==ka&&r==ka)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=ka[0]),i=l}YV(i,a||ka[0],s)}return i}function YV(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 wA(t,e,n){return yA(t,t,ka,Jv(e,n,t.nodeType!=1))}function hp(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 cx(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class JV{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=XV(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=Ai,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=Qa.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==_o&&s.dom==s.contentDOM&&(s.dirty=wa),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 qs){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!=_o&&hp(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=wa,f.updateChildren(i,s+1),f.dirty=Ai),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)||!hp(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=qs.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=qs.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 gA(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 Qa;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof jm)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((mr||ar)&&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 vA(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 XV(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 Qa)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 QV(t,e){return t.type.side-e.type.side}function $V(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(QV);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 eU(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 tU(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 Xv(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 W1(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(Um(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&&TV(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=K1(t,d,a,f)}return c}function kA(t){return t.editable?t.hasFocus():_A(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Qo(t,e=!1){let n=t.state.selection;if(xA(t,n),!!kA(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ar){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Xa(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)rU(t);else{let{anchor:r,head:i}=n,o,s;ux&&!(n instanceof dt)&&(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),ux&&(o&&fx(o),s&&fx(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&nU(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const ux=mr||ar&&lA<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(mr&&i&&i.contentEditable=="false")return Xg(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Xg(i);if(o)return Xg(o)}}function Xg(t){return t.contentEditable="true",mr&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function fx(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function nU(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(()=>{(!kA(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function rU(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,or(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Vr&&js<=11&&(n.disabled=!0,n.disabled=!1)}function xA(t,e){if(e instanceof ft){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(hx(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else hx(t)}function hx(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function K1(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||dt.between(e,n,r)}function px(t){return t.editable&&!t.hasFocus()?!1:_A(t)}function _A(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 Xa(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Qv(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&&mt.findFrom(o,e)}function ws(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function mx(t,e,n){let r=t.state.selection;if(r instanceof dt)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 ws(t,new dt(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Qv(t.state,e);return i&&i instanceof ft?ws(t,i):!1}else if(!(mi&&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)?ws(t,new ft(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):sf?ws(t,new dt(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ft&&r.node.isInline)return ws(t,new dt(e>0?r.$to:r.$from));{let i=Qv(t.state,e);return i?ws(t,i):!1}}}function pp(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Iu(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function yl(t,e){return e<0?oU(t):sU(t)}function oU(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(Ei&&n.nodeType==1&&r<pp(n)&&Iu(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(Iu(a,-1))i=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(CA(n))break;{let a=n.previousSibling;for(;a&&Iu(a,-1);)i=n.parentNode,o=or(a),a=a.previousSibling;if(a)n=a,r=pp(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?$v(t,n,r):i&&$v(t,i,o)}function sU(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=pp(n),o,s;for(;;)if(r<i){if(n.nodeType!=1)break;let a=n.childNodes[r];if(Iu(a,1))o=n,s=++r;else break}else{if(CA(n))break;{let a=n.nextSibling;for(;a&&Iu(a,1);)o=a.parentNode,s=or(a)+1,a=a.nextSibling;if(a)n=a,r=0,i=pp(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&$v(t,o,s)}function CA(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function aU(t,e){for(;t&&e==t.childNodes.length&&!of(t);)e=or(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&&!of(t);)e=or(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 $v(t,e,n){if(e.nodeType!=3){let o,s;(s=aU(e,n))?(e=s,n=0):(o=lU(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Um(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&&Qo(t)},50)}function gx(t,e){let n=t.state.doc.resolve(e);if(!(ar||cA)&&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 vx(t,e,n){let r=t.state.selection;if(r instanceof dt&&!r.empty||n.indexOf("s")>-1||mi&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Qv(t.state,e);if(s&&s instanceof ft)return ws(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof Hr?mt.near(s,e):mt.findFrom(s,e);return a?ws(t,a):!1}return!1}function bx(t,e){if(!(t.state.selection instanceof dt))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 yx(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function cU(t){if(!mr||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;yx(t,r,"true"),setTimeout(()=>yx(t,r,"false"),20)}return!1}function uU(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function dU(t,e){let n=e.keyCode,r=uU(e);if(n==8||mi&&n==72&&r=="c")return bx(t,-1)||yl(t,-1);if(n==46&&!e.shiftKey||mi&&n==68&&r=="c")return bx(t,1)||yl(t,1);if(n==13||n==27)return!0;if(n==37||mi&&n==66&&r=="c"){let i=n==37?gx(t,t.state.selection.from)=="ltr"?-1:1:-1;return mx(t,i,r)||yl(t,i)}else if(n==39||mi&&n==70&&r=="c"){let i=n==39?gx(t,t.state.selection.from)=="ltr"?1:-1:1;return mx(t,i,r)||yl(t,i)}else{if(n==38||mi&&n==80&&r=="c")return vx(t,-1,r)||yl(t,-1);if(n==40||mi&&n==78&&r=="c")return cU(t)||vx(t,1,r)||yl(t,1);if(r==(mi?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function G1(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")||ol.fromSchema(t.state.schema),a=DA(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,d,f=0;for(;c&&c.nodeType==1&&(d=MA[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,`
127
-
128
- `);return{dom:l,text:h,slice:e}}function SA(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,`
129
- `))),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=ol.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=mU(n),sf&&gU(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")||Cu.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!fU.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)a=vU(wx(a,+d[1],+d[2]),d[4]);else if(a=Ge.maxOpen(hU(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=wx(a,f,h)}return t.someProp("transformPasted",f=>{a=f(a,t,l)}),a}const fU=/^(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 hU(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&&AA(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=TA(s[s.length-1],o.length));let d=EA(a,l);s.push(d),i=i.matchType(d.type),o=l}}),s)return Ce.from(s)}return t}function EA(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Ce.from(t));return t}function AA(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=AA(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(EA(n,t,i+1))))}}function TA(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,TA(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Ce.empty,!0);return t.copy(n.append(r))}function eb(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=eb(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 wx(t,e,n){return e<t.openStart&&(t=new Ge(eb(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ge(eb(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const MA={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 kx=null;function DA(){return kx||(kx=document.implementation.createHTMLDocument("title"))}let Qg=null;function pU(t){let e=window.trustedTypes;return e?(Qg||(Qg=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Qg.createHTML(t)):t}function mU(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=DA().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&MA[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=pU(t),i)for(let o=0;o<i.length;o++)n=n.querySelector(i[o])||n;return n}function gU(t){let e=t.querySelectorAll(ar?"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 vU(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 Ar={},Tr={},bU={touchstart:!0,touchmove:!0};class yU{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 wU(t){for(let e in Ar){let n=Ar[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{xU(t,r)&&!Z1(t,r)&&(t.editable||!(r.type in Tr))&&n(t,r)},bU[e]?{passive:!0}:void 0)}mr&&t.dom.addEventListener("input",()=>null),tb(t)}function Fs(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function kU(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 tb(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Z1(t,r))})}function Z1(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function xU(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 _U(t,e){!Z1(t,e)&&Ar[e.type]&&(t.editable||!(e.type in Tr))&&Ar[e.type](t,e)}Tr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!IA(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Wo&&ar&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Tc&&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,pa(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||dU(t,n)?n.preventDefault():Fs(t,"key")};Tr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Tr.keypress=(t,e)=>{let n=e;if(IA(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||mi&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof dt)||!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 CU(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Y1(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 Kl(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 SU(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ft.isSelectable(r)?(Kl(t,new ft(n)),!0):!1}function EU(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?(Kl(t,ft.create(t.state.doc,i)),!0):!1}function AU(t,e,n,r,i){return Y1(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?EU(t,n):SU(t,n))}function TU(t,e,n,r){return Y1(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function MU(t,e,n,r){return Y1(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||DU(t,n,r)}function DU(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Kl(t,dt.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)Kl(t,dt.create(r,a+1,a+1+s.content.size));else if(ft.isSelectable(s))Kl(t,ft.create(r,a));else continue;return!0}}function J1(t){return mp(t)}const OA=mi?"metaKey":"ctrlKey";Ar.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=J1(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&CU(n,t.input.lastClick)&&!n[OA]&&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 OU(t,s,n,!!r)):(o=="doubleClick"?TU:MU)(t,s.pos,s.inside,n)?n.preventDefault():Fs(t,"pointer"))};class OU{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[OA],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&&Ei&&!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)),Fs(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(()=>Qo(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?Fs(this.view,"pointer"):AU(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||mr&&this.mightDrag&&!this.mightDrag.node.isAtom||ar&&!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)?(Kl(this.view,mt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Fs(this.view,"pointer")}move(e){this.updateAllowDefault(e),Fs(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)}}Ar.touchstart=t=>{t.input.lastTouch=Date.now(),J1(t),Fs(t,"pointer")};Ar.touchmove=t=>{t.input.lastTouch=Date.now(),Fs(t,"pointer")};Ar.contextmenu=t=>J1(t);function IA(t,e){return t.composing?!0:mr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const IU=Wo?5e3:-1;Tr.compositionstart=Tr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof dt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ar&&cA&&RU(t)))t.markCursor=t.state.storedMarks||n.marks(),mp(t,!0),t.markCursor=null;else if(mp(t,!e.selection.empty),Ei&&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}RA(t,IU)};function RU(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"}Tr.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++,RA(t,20))};function RA(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>mp(t),e))}function NA(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=PU());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function NU(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=EV(e.focusNode,e.focusOffset),r=AV(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 PU(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function mp(t,e=!1){if(!(Wo&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),NA(t),e||t.docView&&t.docView.dirty){let n=W1(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 LU(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 md=Vr&&js<15||Tc&&OV<604;Ar.copy=Tr.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=md?null:n.clipboardData,s=r.content(),{dom:a,text:l}=G1(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):LU(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function FU(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function zU(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?gd(t,r.value,null,i,e):gd(t,r.textContent,r.innerHTML,i,e)},50)}function gd(t,e,n,r,i){let o=SA(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=FU(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 PA(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," "):""}Tr.paste=(t,e)=>{let n=e;if(t.composing&&!Wo)return;let r=md?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&gd(t,PA(r),r.getData("text/html"),i,n)?n.preventDefault():zU(t,n)};class LA{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const BU=mi?"altKey":"ctrlKey";function FA(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[BU]}Ar.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}=G1(t,a);(!n.dataTransfer.files.length||!ar||lA>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(md?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",md||n.dataTransfer.setData("text/plain",c),t.dragging=new LA(d,FA(t,n),s)};Ar.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Tr.dragover=Tr.dragenter=(t,e)=>e.preventDefault();Tr.drop=(t,e)=>{try{HU(t,e,t.dragging)}finally{t.dragging=null}};function HU(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=SA(t,PA(e.dataTransfer),md?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&FA(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?FS(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(K1(t,h,l.doc.resolve(p)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}Ar.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())&&Qo(t)},20))};Ar.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)};Ar.beforeinput=(t,e)=>{if(ar&&Wo&&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,pa(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 Tr)Ar[t]=Tr[t];function vd(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 gp{constructor(e,n){this.toDOM=e,this.spec=n||za,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 Xt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof gp&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&vd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ws{constructor(e,n){this.attrs=e,this.spec=n||za}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 Xt(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ws&&vd(this.attrs,e.attrs)&&vd(this.spec,e.spec)}static is(e){return e.type instanceof Ws}destroy(){}}class X1{constructor(e,n){this.attrs=e,this.spec=n||za}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 Xt(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 X1&&vd(this.attrs,e.attrs)&&vd(this.spec,e.spec)}destroy(){}}class Xt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Xt(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 Xt(e,e,new gp(n,r))}static inline(e,n,r,i){return new Xt(e,n,new Ws(r,i))}static node(e,n,r,i){return new Xt(e,n,new X1(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ws}get widget(){return this.type instanceof gp}}const Al=[],za={};class gt{constructor(e,n){this.local=e.length?e:Al,this.children=n.length?n:Al}static create(e,n){return n.length?vp(n,e,0,za):ur}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==ur||e.maps.length==0?this:this.mapInner(e,n,0,0,r||za)}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?VU(this.children,s||[],e,n,r,i,o):s?new gt(s.sort(Ba),Al):ur}add(e,n){return n.length?this==ur?gt.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=BA(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,vp(d,a,c+1,za)),o+=3}});let s=zA(o?HA(n):n,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new gt(s.length?this.local.concat(s).sort(Ba):this.local,i||this.children)}remove(e){return e.length==0||this==ur?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!=ur?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 gt(i,r):ur}forChild(e,n){if(this==ur)return this;if(n.isLeaf)return gt.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 Ws){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 gt(i.sort(Ba),Al);return r?new Ss([a,r]):a}return r||ur}eq(e){if(this==e)return!0;if(!(e instanceof gt)||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 Q1(this.localsInner(e))}localsInner(e){if(this==ur)return Al;if(e.inlineContent||!this.local.some(Ws.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ws||n.push(this.local[r]);return n}forEachSet(e){e(this)}}gt.empty=new gt([],[]);gt.removeOverlap=Q1;const ur=gt.empty;class Ss{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,za));return Ss.from(r)}forChild(e,n){if(n.isLeaf)return gt.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=ur&&(o instanceof Ss?r=r.concat(o.members):r.push(o))}return Ss.from(r)}eq(e){if(!(e instanceof Ss)||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?Q1(r?n:n.sort(Ba)):Al}static from(e){switch(e.length){case 0:return ur;case 1:return e[0];default:return new Ss(e.every(n=>n instanceof gt)?e:e.reduce((n,r)=>n.concat(r instanceof gt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function VU(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!=ur?(a[c]=f,a[c+1]=p,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=UU(a,t,e,n,i,o,s),d=vp(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 gt(e.sort(Ba),a)}function zA(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 Xt(i.from+e,i.to+e,i.type))}return n}function UU(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 BA(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 HA(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function vp(t,e,n,r){let i=[],o=!1;e.forEach((a,l)=>{let c=BA(t,a,l+n);if(c){o=!0;let d=vp(c,a,n+l+1,r);d!=ur&&i.push(l,l+a.nodeSize,d)}});let s=zA(o?HA(t):t,-n).sort(Ba);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 gt(s,i):ur}function Ba(t,e){return t.from-e.from||t.to-e.to}function Q1(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),xx(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),xx(e,i,r.copy(o.from,r.to)));break}}}return e}function xx(t,e,n){for(;e<t.length&&Ba(n,t[e])>0;)e++;t.splice(e,0,n)}function $g(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ur&&e.push(r)}),t.cursorWrapper&&e.push(gt.create(t.state.doc,[t.cursorWrapper.deco])),Ss.from(e)}const jU={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},qU=Vr&&js<=11;class WU{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 KU{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new WU,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]);Vr&&js<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():mr&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),qU&&(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,jU)),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(px(this.view)){if(this.suppressingSelectionUpdates)return Qo(this.view);if(Vr&&js<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Xa(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=Ac(o))n.add(o);for(let o=e.anchorNode;o;o=Ac(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)&&px(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(Ei&&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||YU(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&&Um(r)&&(c=W1(e))&&c.eq(mt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qo(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),GU(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,JU(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Qo(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(Vr&&js<=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?or(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?or(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 _x=new WeakMap,Cx=!1;function GU(t){if(!_x.has(t)&&(_x.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Ei,Cx)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."),Cx=!0}}function Sx(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Xa(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function ZU(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Sx(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?Sx(t,n):null}function YU(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 JU(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 XU(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}],Um(l)||c.push({node:l.focusNode,offset:l.focusOffset})),ar&&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")||Cu.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:QU,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 QU(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(mr&&/^(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||mr&&/^(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 $U=/^(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 ej(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=W1(t,E);if(M&&!t.state.selection.eq(M)){if(ar&&Wo&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,pa(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=XU(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=rj(f.content,c.doc.content,c.from,h,p);if(m&&t.input.domChangeCount++,(Tc&&t.input.lastIOSEnter>Date.now()-225||Wo)&&i.some(E=>E.nodeType==1&&!$U.test(E.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",E=>E(t,pa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof dt&&!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=Ex(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 dt&&(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)),Vr&&js<=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((Tc&&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,pa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&nj(d,m.start,m.endA,v,g)&&t.someProp("handleKeyDown",E=>E(t,pa(8,"Backspace")))){Wo&&ar&&t.domObserver.suppressSelectionUpdates();return}ar&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),Wo&&!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,pa(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=Ex(t,M.doc,c.sel);R&&!(ar&&t.composing&&R.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(R.head==_||R.head==M.mapping.map(S)-1)||Vr&&R.empty&&R.head==_)&&M.setSelection(R)}return o&&M.setMeta("composition",o),M.scrollIntoView()},O;if(C)if(v.pos==g.pos){Vr&&js<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qo(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=tj(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 Ex(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:K1(t,e.resolve(n.anchor),e.resolve(n.head))}function tj(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 nj(t,e,n,r,i){if(n-e<=i.pos-r.pos||e0(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(e0(o,!0,!0));return!s.parent.isTextblock||s.pos>n||e0(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function e0(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 rj(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&&Ax(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&&Ax(t.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function Ax(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 VA{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 yU,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Ix),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=Dx(this),Mx(this),this.nodeViews=Ox(this),this.docView=lx(this.state.doc,Tx(this),$g(this),this.dom,this),this.domObserver=new KU(this,(r,i,o,s)=>ej(this,r,i,o,s)),this.domObserver.start(),wU(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&&tb(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ix),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&&(NA(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=Ox(this);oj(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&tb(this),this.editable=Dx(this),Mx(this);let l=$g(this),c=Tx(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&&NV(this);if(s){this.domObserver.stop();let p=f&&(Vr||ar)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&ij(i.selection,e.selection);if(f){let m=ar?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=NU(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=lx(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))?Qo(this,p):(xA(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&&PV(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&&nx(this,n.getBoundingClientRect(),e)}else nx(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 LA(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(Vr){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&&LV(this.dom),Qo(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 VV(this,e)}coordsAtPos(e,n=1){return pA(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 KV(this,n||this.state,e)}pasteHTML(e,n){return gd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return gd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return G1(this,e)}destroy(){this.docView&&(kU(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],$g(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,CV())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return _U(this,e)}domSelectionRange(){let e=this.domSelection();return e?mr&&this.root.nodeType===11&&MV(this.dom.ownerDocument)==this.dom&&ZU(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}VA.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Tx(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"),[Xt.node(0,t.state.doc.content.size,e)]}function Mx(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:Xt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Dx(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 Ox(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 oj(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 Ix(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 $s={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:"'"},bp={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},sj=typeof navigator<"u"&&/Mac/.test(navigator.platform),aj=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var sr=0;sr<10;sr++)$s[48+sr]=$s[96+sr]=String(sr);for(var sr=1;sr<=24;sr++)$s[sr+111]="F"+sr;for(var sr=65;sr<=90;sr++)$s[sr]=String.fromCharCode(sr+32),bp[sr]=String.fromCharCode(sr);for(var t0 in $s)bp.hasOwnProperty(t0)||(bp[t0]=$s[t0]);function lj(t){var e=sj&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||aj&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?bp:$s)[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 cj=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),uj=typeof navigator<"u"&&/Win/.test(navigator.platform);function dj(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))cj?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 fj(t){let e=Object.create(null);for(let n in t)e[dj(n)]=t[n];return e}function n0(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 hj(t){return new Ht({props:{handleKeyDown:$1(t)}})}function $1(t){let e=fj(t);return function(n,r){let i=lj(r),o,s=e[n0(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[n0(i,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(uj&&r.ctrlKey&&r.altKey)&&(o=$s[r.keyCode])&&o!=i){let a=e[n0(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const ey=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function UA(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const jA=(t,e,n)=>{let r=UA(t,n);if(!r)return!1;let i=ty(r);if(!i){let s=r.blockRange(),a=s&&Fc(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(QA(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Mc(o,"end")||ft.isSelectable(o)))for(let s=r.depth;;s--){let a=bm(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(Mc(o,"end")?mt.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},pj=(t,e,n)=>{let r=UA(t,n);if(!r)return!1;let i=ty(r);return i?qA(t,i,e):!1},mj=(t,e,n)=>{let r=KA(t,n);if(!r)return!1;let i=ny(r);return i?qA(t,i,e):!1};function qA(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=bm(t.doc,o,l,Ge.empty);if(!c||c.from!=o||c instanceof Wn&&c.slice.size>=l-o)return!1;if(n){let d=t.tr.step(c);d.setSelection(dt.create(d.doc,o)),n(d.scrollIntoView())}return!0}function Mc(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 WA=(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=ty(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 ty(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 KA(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const GA=(t,e,n)=>{let r=KA(t,n);if(!r)return!1;let i=ny(r);if(!i)return!1;let o=i.nodeAfter;if(QA(t,i,e,1))return!0;if(r.parent.content.size==0&&(Mc(o,"start")||ft.isSelectable(o))){let s=bm(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(Mc(o,"start")?mt.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},ZA=(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=ny(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 ny(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 gj=(t,e)=>{let n=t.selection,r=n instanceof ft,i;if(r){if(n.node.isTextblock||!ra(t.doc,n.from))return!1;i=n.from}else if(i=vm(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},vj=(t,e)=>{let n=t.selection,r;if(n instanceof ft){if(n.node.isTextblock||!ra(t.doc,n.to))return!1;r=n.to}else if(r=vm(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},bj=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&Fc(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},YA=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
130
- `).scrollIntoView()),!0)};function ry(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 yj=(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=ry(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(mt.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},JA=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Hr||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=ry(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(dt.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},XA=(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(Zo(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Fc(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function wj(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof ft&&e.selection.node.isBlock)return!r.parentOffset||!Zo(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=ry(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 dt||e.selection instanceof Hr)&&d.deleteSelection();let f=d.mapping.map(r.pos),h=Zo(d.doc,f,o.length,o);if(h||(o[0]=a?{type:a}:null,h=Zo(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 kj=wj(),xj=(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 _j(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||ra(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function QA(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&_j(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 Yn(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&&ra(v.doc,g.pos)&&v.join(g.pos),n(v.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&l?null:mt.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),h=f&&Fc(f);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(f,h).scrollIntoView()),!0;if(c&&Mc(o,"start",!0)&&Mc(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 Yn(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 $A(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(dt.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const Cj=$A(-1),Sj=$A(1);function Ej(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&n1(s,t,e);return a?(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0):!1}}function Rx(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 iy(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}iy(ey,jA,WA);iy(ey,GA,ZA);iy(YA,JA,XA,kj);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Aj(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 Tj(a,s,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function Tj(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 Kh(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Kh(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=n1(o,n,r,e);return a?(t&&Mj(t,e,a,i,n),!0):!1}function Mj(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 Yn(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&&Zo(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return t}function Dj(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?Oj(e,n,t,o):Ij(e,n,o):!0:!1}}function Oj(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new Yn(o-1,s,o,s,new Ge(Ce.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Kh(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=Fc(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return ra(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function Ij(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 Yn(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 Rj(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 Yn(h-(c?3:1),p,h,p,f,1,!0)).scrollIntoView())}return!0}}function Wm(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 Km{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:Wm({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 Nj{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 Gm(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 eT(t){const e=[],{nodeExtensions:n,markExtensions:r}=Gm(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 Qn(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 nb(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 tT(t){return typeof t=="function"}function At(t,e=void 0,...n){return tT(t)?e?t.bind(e)(...n):t(...n):t}function Pj(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Lj(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Nx(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):Lj(n.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function Px(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Pj(n)?!1:n!=null))}function Fj(t,e){var n;const r=eT(t),{nodeExtensions:i,markExtensions:o}=Gm(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=Px({...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=>Nx(y,d)));const v=ot(c,"renderHTML",f);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:nb(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=Px({...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=>Nx(g,d)));const v=ot(c,"renderHTML",f);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:nb(g,d)})),[c.name,p]}));return new $b({topNode:s,nodes:a,marks:l})}function r0(t,e){return e.nodes[t]||e.marks[t]||null}function Lx(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function oy(t,e){const n=ol.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}const zj=(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 sy(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class lf{constructor(e){this.find=e.find,this.handler=e.handler}}const Bj=(t,e)=>{if(sy(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 Of(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=zj(c)+o;return s.forEach(h=>{if(d)return;const p=Bj(f,h.find);if(!p)return;const m=l.state.tr,v=Wm({state:l.state,transaction:m}),g={from:r-(p[0].length-o.length),to:i},{commands:y,chain:C,can:_}=new Km({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 Hj(t){const{editor:e,rules:n}=t,r=new Ht({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=oy(Ce.from(d),s.schema);const{from:f}=l,h=f+d.length;Of({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 Of({editor:e,from:o,to:s,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&Of({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?Of({editor:e,from:s.pos,to:s.pos,text:`
131
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Vj(t){return Object.prototype.toString.call(t).slice(8,-1)}function If(t){return Vj(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Zm(t,e){const n={...t};return If(t)&&If(e)&&Object.keys(e).forEach(r=>{If(e[r])&&If(t[r])?n[r]=Zm(t[r],e[r]):n[r]=e[r]}),n}class Ji{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 Ji(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>Zm(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new Ji(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 Uj(t){return typeof t=="number"}class jj{constructor(e){this.find=e.find,this.handler=e.handler}}const qj=(t,e,n)=>{if(sy(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 Wj(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:d}=new Km({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,"");qj(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 Rf=null;const Kj=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 Gj(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=Wm({state:d,transaction:v});if(!(!Wj({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 Ht({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&&(Rf=e)},p=()=>{Rf&&(Rf=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=Rf;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=oy(Ce.from(A),p.schema);const{from:O}=y,E=O+A.length,M=Kj(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(!(!Uj(_)||!S||_===S.b))return l({rule:d,state:p,from:_,to:S,pasteEvt:s})}}))}function Zj(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}class Nl{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=Nl.resolve(e),this.schema=Fj(this.extensions,n),this.setupExtensions()}static resolve(e){const n=Nl.sort(Nl.flatten(e)),r=Zj(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:r0(n.name,this.schema)},i=ot(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,n=Nl.sort([...this.extensions].reverse()),r=[],i=[],o=n.map(s=>{const a={name:s.name,options:s.options,storage:s.storage,editor:e,type:r0(s.name,this.schema)},l=[],c=ot(s,"addKeyboardShortcuts",a);let d={};if(s.type==="mark"&&ot(s,"exitable",a)&&(d.ArrowRight=()=>Ji.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=hj(d);l.push(f);const h=ot(s,"addInputRules",a);Lx(s,e.options.enableInputRules)&&h&&r.push(...h());const p=ot(s,"addPasteRules",a);Lx(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[Hj({editor:e,rules:r}),...Gj({editor:e,rules:i}),...o]}get attributes(){return eT(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:n}=Gm(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:Qn(r.name,this.schema)},s=ot(r,"addNodeView",o);if(!s)return[];const a=(l,c,d,f,h)=>{const p=nb(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:r0(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 nn{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 nn(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>Zm(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new nn({...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 nT(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=`
132
-
133
- `,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 rT(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const Yj=nn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ht({key:new Gt("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=rT(n);return nT(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Jj=()=>({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),Xj=(t=!1)=>({commands:e})=>e.setContent("",t),Qj=()=>({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=Fc(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},$j=t=>e=>t(e),eq=()=>({state:t,dispatch:e})=>JA(t,e),tq=(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 dt(r.doc.resolve(Math.max(s-1,0)))),!0},nq=()=>({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},rq=t=>({tr:e,state:n,dispatch:r})=>{const i=Qn(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},oq=()=>({state:t,dispatch:e})=>ey(t,e),sq=()=>({commands:t})=>t.keyboardShortcut("Enter"),aq=()=>({state:t,dispatch:e})=>yj(t,e);function yp(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:sy(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function iT(t,e,n={}){return t.find(r=>r.type===e&&yp(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function Fx(t,e,n={}){return!!iT(t,e,n)}function ay(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),!iT([...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&&Fx([...t.parent.child(s-1).marks],e,n);)s-=1,a-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&Fx([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function oa(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=oa(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a;if(i){const f=ay(l,o,e);if(f&&f.from<=c&&f.to>=d){const h=dt.create(s,f.from,f.to);n.setSelection(h)}}return!0},cq=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 oT(t){return t instanceof dt}function xa(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=mt.atStart(t),r=mt.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,o=r.to;return e==="all"?dt.create(t,xa(0,i,o),xa(t.content.size,i,o)):dt.create(t,xa(e,i,o),xa(e,i,o))}function zx(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function wp(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function uq(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const dq=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(wp()||zx())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),uq()&&!wp()&&!zx()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!oT(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},fq=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),hq=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),aT=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&&aT(r)}return t};function Nf(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return aT(n)}function bd(t,e,n){if(t instanceof Us||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),bd("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,a="";const l=new $b({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?Cu.fromSchema(l).parseSlice(Nf(t),n.parseOptions):Cu.fromSchema(l).parse(Nf(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=Cu.fromSchema(e);return n.slice?o.parseSlice(Nf(t),n.parseOptions).content:o.parse(Nf(t),n.parseOptions)}return bd("",e,n)}function pq(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Wn||i instanceof Yn))return;const o=t.mapping.maps[r];let s=0;o.forEach((a,l,c,d)=>{s===0&&(s=d)}),t.setSelection(mt.near(t.doc.resolve(s),n))}const mq=t=>!("type"in t),gq=(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{bd(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=bd(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((mq(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&&pq(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},vq=()=>({state:t,dispatch:e})=>gj(t,e),bq=()=>({state:t,dispatch:e})=>vj(t,e),yq=()=>({state:t,dispatch:e})=>jA(t,e),wq=()=>({state:t,dispatch:e})=>GA(t,e),kq=()=>({state:t,dispatch:e,tr:n})=>{try{const r=vm(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,tr:n})=>{try{const r=vm(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},_q=()=>({state:t,dispatch:e})=>pj(t,e),Cq=()=>({state:t,dispatch:e})=>mj(t,e);function lT(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Sq(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))wp()||lT()?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 Eq=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const o=Sq(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 yd(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,s=e?Qn(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=>yp(f.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((f,h)=>f+h.to-h.from,0)>=l}const Aq=(t,e={})=>({state:n,dispatch:r})=>{const i=Qn(t,n.schema);return yd(n,i,e)?bj(n,r):!1},Tq=()=>({state:t,dispatch:e})=>XA(t,e),Mq=t=>({state:e,dispatch:n})=>{const r=Qn(t,e.schema);return Dj(r)(e,n)},Dq=()=>({state:t,dispatch:e})=>YA(t,e);function Ym(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Bx(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 Oq=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Ym(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=Qn(t,r.schema)),a==="mark"&&(s=oa(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,Bx(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(f=>{s===f.type&&n.addMark(d,d+c.nodeSize,s.create(Bx(f.attrs,e)))})})}),!0):!1},Iq=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Rq=()=>({tr:t,dispatch:e})=>{if(e){const n=new Hr(t.doc);t.setSelection(n)}return!0},Nq=()=>({state:t,dispatch:e})=>WA(t,e),Pq=()=>({state:t,dispatch:e})=>ZA(t,e),Lq=()=>({state:t,dispatch:e})=>xj(t,e),Fq=()=>({state:t,dispatch:e})=>Sj(t,e),zq=()=>({state:t,dispatch:e})=>Cj(t,e);function rb(t,e,n={},r={}){return bd(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const Bq=(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=rb(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 cT(t,e){const n=oa(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 Hq(t,e){const n=new r1(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function Vq(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 Uq(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function uT(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 ly(t){return e=>uT(e.$from,t)}function jq(t,e){const n={from:0,to:t.content.size};return nT(t,n,e)}function qq(t,e){const n=Qn(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=Ym(typeof e=="string"?e:e.name,t.schema);return n==="node"?qq(t,e):n==="mark"?cT(t,e):{}}function Wq(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 Kq(t){const e=Wq(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 Gq(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}})})}),Kq(r)}function cy(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=n.resolve(t),s=ay(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 kh(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 ib(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?oa(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>yp(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=>yp(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 Zq(t,e,n={}){if(!e)return yd(t,null,n)||ib(t,null,n);const r=Ym(e,t.schema);return r==="node"?yd(t,e,n):r==="mark"?ib(t,e,n):!1}function Hx(t,e){const{nodeExtensions:n}=Gm(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 Jm(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&&(Jm(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Yq(t){return t instanceof ft}function Jq(t,e,n){var r;const{selection:i}=e;let o=null;if(oT(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 Xq=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=oa(t,r.schema);if(i)if(s){const c=cT(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 Jq(r,n,l)},Qq=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),$q=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=Qn(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})=>Rx(o,{...s,...e})(n)?!0:a.clearNodes()).command(({state:a})=>Rx(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},eW=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=xa(t,0,r.content.size),o=ft.create(r,i);e.setSelection(o)}return!0},tW=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=dt.atStart(r).from,a=dt.atEnd(r).to,l=xa(i,s,a),c=xa(o,s,a),d=dt.create(r,l,c);e.setSelection(d)}return!0},nW=t=>({state:e,dispatch:n})=>{const r=Qn(t,e.schema);return Rj(r)(e,n)};function Vx(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 rW=({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=kh(c,a.node().type.name,a.node().attrs);if(o instanceof ft&&o.node.isBlock)return!a.parentOffset||!Zo(s,a.pos)?!1:(r&&(t&&Vx(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:Vq(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=f&&h?[{type:h,attrs:d}]:void 0,m=Zo(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&Zo(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 dt&&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&&Vx(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},iW=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=Qn(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={...kh(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(dt.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const p=c.pos===l.end()?f.contentMatchAt(0).defaultType:null,m={...kh(h,f.type.name,f.attrs),...e},v={...kh(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(!Zo(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},i0=(t,e)=>{const n=ly(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)&&ra(t.doc,n.pos)&&t.join(n.pos),!0},o0=(t,e)=>{const n=ly(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)&&ra(t.doc,r)&&t.join(r),!0},oW=(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=Qn(t,s.schema),m=Qn(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=ly(O=>Hx(O.type.name,f))(v);if(_.depth>=1&&A&&_.depth-A.depth<=1){if(A.node.type===p)return c.liftListItem(m);if(Hx(A.node.type.name,f)&&p.validContent(A.node.content)&&a)return l().command(()=>(o.setNodeMarkup(A.pos,p),!0)).command(()=>i0(o,p)).command(()=>o0(o,p)).run()}return!n||!S||!a?l().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>i0(o,p)).command(()=>o0(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(()=>i0(o,p)).command(()=>o0(o,p)).run()},sW=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=oa(t,r.schema);return ib(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},aW=(t,e,n={})=>({state:r,commands:i})=>{const o=Qn(t,r.schema),s=Qn(e,r.schema),a=yd(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=Qn(t,n.schema);return yd(n,i,e)?r.lift(i):r.wrapIn(i,e)},cW=()=>({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},uW=()=>({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},dW=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=oa(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=ay(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},fW=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=Ym(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=Qn(t,r.schema)),a==="mark"&&(s=oa(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},hW=(t,e={})=>({state:n,dispatch:r})=>{const i=Qn(t,n.schema);return Ej(i,e)(n,r)},pW=(t,e={})=>({state:n,dispatch:r})=>{const i=Qn(t,n.schema);return Aj(i,e)(n,r)};var mW=Object.freeze({__proto__:null,blur:Jj,clearContent:Xj,clearNodes:Qj,command:$j,createParagraphNear:eq,cut:tq,deleteCurrentNode:nq,deleteNode:rq,deleteRange:iq,deleteSelection:oq,enter:sq,exitCode:aq,extendMarkRange:lq,first:cq,focus:dq,forEach:fq,insertContent:hq,insertContentAt:gq,joinBackward:yq,joinDown:bq,joinForward:wq,joinItemBackward:kq,joinItemForward:xq,joinTextblockBackward:_q,joinTextblockForward:Cq,joinUp:vq,keyboardShortcut:Eq,lift:Aq,liftEmptyBlock:Tq,liftListItem:Mq,newlineInCode:Dq,resetAttributes:Oq,scrollIntoView:Iq,selectAll:Rq,selectNodeBackward:Nq,selectNodeForward:Pq,selectParentNode:Lq,selectTextblockEnd:Fq,selectTextblockStart:zq,setContent:Bq,setMark:Xq,setMeta:Qq,setNode:$q,setNodeSelection:eW,setTextSelection:tW,sinkListItem:nW,splitBlock:rW,splitListItem:iW,toggleList:oW,toggleMark:sW,toggleNode:aW,toggleWrap:lW,undoInputRule:cW,unsetAllMarks:uW,unsetMark:dW,updateAttributes:fW,wrapIn:hW,wrapInList:pW});const gW=nn.create({name:"commands",addCommands(){return{...mW}}}),vW=nn.create({name:"drop",addProseMirrorPlugins(){return[new Ht({key:new Gt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),bW=nn.create({name:"editable",addProseMirrorPlugins(){return[new Ht({key:new Gt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),yW=new Gt("focusEvents"),wW=nn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ht({key:yW,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}}}})]}}),kW=nn.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:mt.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 wp()||lT()?o:i},addProseMirrorPlugins(){return[new Ht({key:new Gt("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=mt.atStart(e.doc).from,c=mt.atEnd(e.doc).to;if(o||!(s===l&&a===c)||!Jm(n.doc))return;const h=n.tr,p=Wm({state:n,transaction:h}),{commands:m}=new Km({editor:this.editor,state:p});if(m.clearNodes(),!!h.steps.length)return h}})]}}),xW=nn.create({name:"paste",addProseMirrorPlugins(){return[new Ht({key:new Gt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),_W=nn.create({name:"tabindex",addProseMirrorPlugins(){return[new Ht({key:new Gt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class ma{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 ma(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 ma(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 ma(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 ma(a,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new ma(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 CW=`.ProseMirror {
134
- position: relative;
135
- }
136
-
137
- .ProseMirror {
138
- word-wrap: break-word;
139
- white-space: pre-wrap;
140
- white-space: break-spaces;
141
- -webkit-font-variant-ligatures: none;
142
- font-variant-ligatures: none;
143
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
144
- }
145
-
146
- .ProseMirror [contenteditable="false"] {
147
- white-space: normal;
148
- }
149
-
150
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
151
- white-space: pre-wrap;
152
- }
153
-
154
- .ProseMirror pre {
155
- white-space: pre-wrap;
156
- }
157
-
158
- img.ProseMirror-separator {
159
- display: inline !important;
160
- border: none !important;
161
- margin: 0 !important;
162
- width: 0 !important;
163
- height: 0 !important;
164
- }
165
-
166
- .ProseMirror-gapcursor {
167
- display: none;
168
- pointer-events: none;
169
- position: absolute;
170
- margin: 0;
171
- }
172
-
173
- .ProseMirror-gapcursor:after {
174
- content: "";
175
- display: block;
176
- position: absolute;
177
- top: -2px;
178
- width: 20px;
179
- border-top: 1px solid black;
180
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
181
- }
182
-
183
- @keyframes ProseMirror-cursor-blink {
184
- to {
185
- visibility: hidden;
186
- }
187
- }
188
-
189
- .ProseMirror-hideselection *::selection {
190
- background: transparent;
191
- }
192
-
193
- .ProseMirror-hideselection *::-moz-selection {
194
- background: transparent;
195
- }
196
-
197
- .ProseMirror-hideselection * {
198
- caret-color: transparent;
199
- }
200
-
201
- .ProseMirror-focused .ProseMirror-gapcursor {
202
- display: block;
203
- }
204
-
205
- .tippy-box[data-animation=fade][data-state=hidden] {
206
- opacity: 0
207
- }`;function SW(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 EW=class extends Nj{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=SW(CW,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=tT(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?[bW,Yj.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),gW,wW,kW,_W,vW,xW].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 Nl(i,this)}createCommandManager(){this.commandManager=new Km({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let n;try{n=rb(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=rb(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=sT(n,this.options.autofocus);this.view=new VA(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:Il.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 Zq(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return oy(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
208
-
209
- `,textSerializers:r={}}=e||{};return jq(this.state.doc,{blockSeparator:n,textSerializers:{...rT(this.schema),...r}})}get isEmpty(){return Jm(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 ma(n,this)}get $doc(){return this.$pos(0)}};function $a(t){return new lf({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(cy(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 fT(t){return new lf({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 ob(t){return new lf({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 wd(t){return new lf({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&&n1(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&&ra(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)}})}let yr=class sb{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 sb(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>Zm(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new sb(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 ea(t){return new jj({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(cy(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 AW(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 TW=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},MW=/[\uD800-\uDBFF]/,DW=/[\uDC00-\uDFFF]/,OW=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&MW.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&&DW.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},IW=OW,mn=new Gt("y-sync"),go=new Gt("y-undo"),Pf=new Gt("yjs-cursor"),vo=(t,e)=>t>>>e|t<<32-e,RW=t=>vo(t,2)^vo(t,13)^vo(t,22),NW=t=>vo(t,6)^vo(t,11)^vo(t,25),PW=t=>vo(t,7)^vo(t,18)^t>>>3,LW=t=>vo(t,17)^vo(t,19)^t>>>10,FW=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]),zW=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class BW{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(zW),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let f=16;f<64;f++)n[f]=LW(n[f-2])+n[f-7]+PW(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+NW(a)+(a&l^~a&c)+FW[f]+n[f]>>>0,p=RW(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]|=Er<<(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)]|=Er<<(3-n%4)*8),this._W[14]=e.byteLength/_N,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 HW=t=>new BW().digest(t),VW=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},UW=t=>C9(VW(HW(E9(t)))),kp=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Uc(e.ds,t.id),jW=[{light:"#ecd44433",dark:"#ecd444"}],qW=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Ka();t.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}t.set(n,n9(e))}return t.get(n)},WW=(t,{colors:e=jW,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let s=!1;const a=new GW(t,o),l=new Ht({props:{editable:c=>{const d=mn.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:mn,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(mn);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)&&k1(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=go.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)},mn)})}},destroy:()=>{a.destroy()}})});return l},KW=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new Hr(t.doc));else if(e.type==="node"){const r=Gl(n.doc,n.type,e.anchor,n.mapping);t.setSelection(ft.create(t.doc,r))}else{const r=Gl(n.doc,n.type,e.anchor,n.mapping),i=Gl(n.doc,n.type,e.head,n.mapping);if(r!==null&&i!==null){const o=dt.between(t.doc.resolve(r),t.doc.resolve(i));t.setSelection(o)}}},ab=(t,e)=>({type:e.selection.jsonID,anchor:_p(e.selection.anchor,t.type,t.mapping),head:_p(e.selection.head,t.type,t.mapping)});class GW{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=TW(),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=ab(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()?(p3&&this._domSelectionInView===null&&(k1(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=Jd.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=Y3(B3(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(mn,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>xh(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(mn,{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=>xh(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=Yo(Gi(e.anchor,0),r.doc.content.size),o=Yo(Gi(e.head,0),r.doc.content.size);r.setSelection(dt.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(mn,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let i=this.doc,o=this.type;if(e||(e=zg(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&pr(),i=new ko({gc:!1}),np(i,n),n=zg(i),np(i,e),e=zg(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=Zi(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=>{Js(s,f,h=>{})});const l=(f,h)=>{const p=f==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:p,type:f,color:qW(r.colorMapping,r.colors,p)}},c=sE(o,new E1(n.ds,e.sv)).map(f=>!f._item.deleted||kp(f._item,e)||kp(f._item,n)?xh(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(mn,{isChangeOrigin:!0}))},mn)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=mn.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);Js(n,n.deleteSet,a=>{if(a.constructor===on){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=>hT(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));KW(s,this.beforeTransactionSelection,this),s=s.setMeta(mn,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof eE}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{cb(this.doc,this.type,e,this),this.beforeTransactionSelection=ab(this,this.prosemirrorView.state)},mn)}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 hT=(t,e,n,r,i,o)=>{const s=n.mapping.get(t);if(s===void 0){if(t instanceof gn)return xh(t,e,n,r,i,o);throw Si()}return s},xh=(t,e,n,r,i,o)=>{const s=[],a=l=>{var c,d;if(l instanceof gn){const f=hT(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 Xs&&!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=ZW(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 E1(i.ds,r.sv)).forEach(a);try{const l=t.getAttributes(r);r!==void 0&&(kp(t._item,r)?kp(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)},mn),n.mapping.delete(t),null}},ZW=(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,eK(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},mn),null}return s},YW=(t,e)=>{const n=new In,r=t.map(i=>({insert:i.text,attributes:mT(i.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},JW=(t,e)=>{const n=new gn(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,Xm(t).map(r=>lb(r,e))),e.mapping.set(n,t),n},lb=(t,e)=>t instanceof Array?YW(t,e):JW(t,e),Ux=t=>typeof t=="object"&&t!==null,uy=(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||Ux(s)&&Ux(a)&&uy(s,a)}return r},Xm=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},pT=(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&&Bc(r.attributes,(o,s)=>{var c;const a=dy(s),l=e[i].marks;return uy(o,(c=l.find(d=>d.type.name===a))==null?void 0:c.attrs)}))},kd=(t,e)=>{if(t instanceof gn&&!(e instanceof Array)&&ub(t,e)){const n=Xm(e);return t._length===n.length&&uy(t.getAttributes(),e.attrs)&&t.toArray().every((r,i)=>kd(r,n[i]))}return t instanceof In&&e instanceof Array&&pT(t,e)},xp=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),jx=(t,e,n)=>{const r=t.toArray(),i=Xm(e),o=i.length,s=r.length,a=Yo(s,o);let l=0,c=0,d=!1;for(;l<a;l++){const f=r[l],h=i[l];if(xp(n.mapping.get(f),h))d=!0;else if(!kd(f,h))break}for(;l+c<a;c++){const f=r[s-c-1],h=i[o-c-1];if(xp(n.mapping.get(f),h))d=!0;else if(!kd(f,h))break}return{equalityFactor:l+c,foundMappedChild:d}},XW=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Yi?e+=n.content.str:n.content instanceof Rn&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},QW=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:i}=XW(t),o=e.map(c=>({insert:c.text,attributes:Object.assign({},r,mT(c.marks,n))})),{insert:s,remove:a,index:l}=IW(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})))},$W=/(.*)(--[a-zA-Z0-9+/=]{8})$/,dy=t=>{var e;return((e=$W.exec(t))==null?void 0:e[1])??t},eK=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(dy(r),t[r]));return n},mT=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const i=Eo(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[i?`${r.type.name}--${UW(r.toJSON())}`:r.type.name]=r.attrs}}),n},cb=(t,e,n,r)=>{if(e instanceof gn&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof gn){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=Xm(n),o=i.length,s=e.toArray(),a=s.length,l=Yo(o,a);let c=0,d=0;for(;c<l;c++){const f=s[c],h=i[c];if(!xp(r.mapping.get(f),h))if(kd(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(!xp(r.mapping.get(f),h))if(kd(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)pT(h,p)||QW(h,p,r),c+=1;else{let g=h instanceof gn&&ub(h,p),y=m instanceof gn&&ub(m,v);if(g&&y){const C=jx(h,p,r),_=jx(m,v,r);C.foundMappedChild&&!_.foundMappedChild?y=!1:!C.foundMappedChild&&_.foundMappedChild||C.equalityFactor<_.equalityFactor?g=!1:y=!1}g?(cb(t,h,p,r),c+=1):y?(cb(t,m,v,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[lb(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(lb(i[p],r));e.insert(c,h)}},mn)},ub=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let Ru=null;const tK=()=>{const t=Ru;Ru=null,t.forEach((e,n)=>{const r=n.state.tr,i=mn.getState(n.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((o,s)=>{r.setMeta(s,o)}),n.dispatch(r))})},nK=(t,e,n)=>{Ru||(Ru=new Map,k1(0,tK)),Eo(Ru,t,Ci).set(e,n)},_p=(t,e,n)=>{if(t===0)return Fg(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 Fg(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 ld(r._item===null?null:r._item.id,r._item===null?sd(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 ld(r._item===null?null:r._item.id,r._item===null?sd(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 pr();if(t===0&&r.constructor!==In&&r!==e)return rK(r._item.parent,r._item)}return Fg(e,e._length,e.length===0?-1:0)},rK=(t,e)=>{let n=null,r=null;return t._item===null?r=sd(t):n=_t(t._item.id.client,t._item.id.clock),new ld(n,r,e.id)},Gl=(t,e,n,r)=>{const i=Ov(n,t);if(i===null||i.type!==e&&!ad(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:dy(l)};return Object.keys(c)&&(f.attrs=c),f})),a});else if(r instanceof gn){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 pr();return i};return{type:"doc",content:e.map(n)}}const oK=(t,e,n)=>t!==e,sK=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},gT=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),aK=/^#[0-9a-fA-F]{6}$/,qx=(t,e,n,r,i)=>{const o=mn.getState(t),s=o.doc,a=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?gt.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":aK.test(d.color)||console.warn("A user uses an unsupported color format",d),d.name==null&&(d.name=`User: ${c}`);let f=Gl(s,o.type,La(l.cursor.anchor),o.binding.mapping),h=Gl(s,o.type,La(l.cursor.head),o.binding.mapping);if(f!==null&&h!==null){const p=Gi(t.doc.content.size-1,0);f=Yo(f,p),h=Yo(h,p),a.push(Xt.widget(h,()=>r(d,c),{key:c+"",side:10}));const m=Yo(f,h),v=Gi(f,h);a.push(Xt.inline(m,v,i(d,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),gt.create(t.doc,a))},lK=(t,{awarenessStateFilter:e=oK,cursorBuilder:n=sK,selectionBuilder:r=gT,getSelection:i=s=>s.selection}={},o="cursor")=>new Ht({key:Pf,state:{init(s,a){return qx(a,t,e,n,r)},apply(s,a,l,c){const d=mn.getState(c),f=s.getMeta(Pf);return d&&d.isChangeOrigin||f&&f.awarenessUpdated?qx(c,t,e,n,r):a.map(s.mapping,s.doc)}},props:{decorations:s=>Pf.getState(s)},view:s=>{const a=()=>{s.docView&&nK(s,Pf,{awarenessUpdated:!0})},l=()=>{const c=mn.getState(s.state),d=t.getLocalState()||{};if(s.hasFocus()){const f=i(s.state),h=_p(f.anchor,c.type,c.binding.mapping),p=_p(f.head,c.type,c.binding.mapping);(d.cursor==null||!Ek(La(d.cursor.anchor),h)||!Ek(La(d.cursor.head),p))&&t.setLocalStateField(o,{anchor:h,head:p})}else d.cursor!=null&&Gl(c.doc,c.type,La(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)}}}}),cK=t=>{var e,n;return((n=(e=go.getState(t))==null?void 0:e.undoManager)==null?void 0:n.undo())!=null},uK=t=>{var e,n;return((n=(e=go.getState(t))==null?void 0:e.undoManager)==null?void 0:n.redo())!=null},dK=new Set(["paragraph"]),fK=(t,e)=>!(t instanceof on)||!(t.content instanceof Xi)||!(t.content.type instanceof Xs||t.content.type instanceof gn&&e.has(t.content.type.nodeName))||t.content.type._length===0,hK=({protectedNodes:t=dK,trackedOrigins:e=[],undoManager:n=null}={})=>new Ht({key:go,state:{init:(r,i)=>{const o=mn.getState(i),s=n||new eE(o.type,{trackedOrigins:new Set([mn].concat(e)),deleteFilter:a=>fK(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=mn.getState(s).binding,l=i.undoManager,c=l.undoStack.length>0,d=l.redoStack.length>0;return a?{undoManager:l,prevSel:ab(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=mn.getState(r.state),o=go.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:s})=>{const a=i.binding;a&&s.meta.set(a,go.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()}}}}),pK=nn.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),go.getState(e).undoManager.undoStack.length===0?!1:n?cK(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),go.getState(e).undoManager.redoStack.length===0?!1:n?uK(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=hK(this.options.yUndoOptions),r=n.spec.view;n.spec.view=s=>{const{undoManager:a}=go.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=WW(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 Ht({key:new Gt("filterInvalidContent"),filterTransaction:()=>{var s;return this.storage.isDisabled&&((s=e.doc)===null||s===void 0||s.destroy()),!0}})].filter(Boolean)}}),Wx=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n.user})),Kx=()=>null,mK=nn.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:gT,onUpdate:Kx}},onCreate(){if(this.options.onUpdate!==Kx&&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=Wx(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=Wx(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),gK=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,vK=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,bK=Ji.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[$a({find:gK,type:this.type})]},addPasteRules(){return[ea({find:vK,type:this.type})]}}),yK=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,wK=yr.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[fT({find:yK,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),kK="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",xK="ελ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",db="numeric",fb="ascii",hb="alpha",Nu="asciinumeric",bu="alphanumeric",pb="domain",vT="emoji",_K="scheme",CK="slashscheme",s0="whitespace";function SK(t,e){return t in e||(e[t]=[]),e[t]}function _a(t,e,n){e[db]&&(e[Nu]=!0,e[bu]=!0),e[fb]&&(e[Nu]=!0,e[hb]=!0),e[Nu]&&(e[bu]=!0),e[hb]&&(e[bu]=!0),e[bu]&&(e[pb]=!0),e[vT]&&(e[pb]=!0);for(const r in e){const i=SK(r,n);i.indexOf(t)<0&&i.push(t)}}function EK(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Lr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Lr.groups={};Lr.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||Lr.groups;let i;return e&&e.j?i=e:(i=new Lr(e),n&&r&&_a(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||Lr.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 Lr,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new Lr,o){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(EK(s.t,r),n);_a(o,l,r)}else n&&_a(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),bn=(t,e,n,r,i)=>t.tr(e,n,r,i),Gx=(t,e,n,r,i)=>t.ts(e,n,r,i),He=(t,e,n,r,i)=>t.tt(e,n,r,i),Lo="WORD",mb="UWORD",bT="ASCIINUMERICAL",yT="ALPHANUMERICAL",xd="LOCALHOST",gb="TLD",vb="UTLD",_h="SCHEME",Tl="SLASH_SCHEME",fy="NUM",bb="WS",hy="NL",Pu="OPENBRACE",Lu="CLOSEBRACE",Cp="OPENBRACKET",Sp="CLOSEBRACKET",Ep="OPENPAREN",Ap="CLOSEPAREN",Tp="OPENANGLEBRACKET",Mp="CLOSEANGLEBRACKET",Dp="FULLWIDTHLEFTPAREN",Op="FULLWIDTHRIGHTPAREN",Ip="LEFTCORNERBRACKET",Rp="RIGHTCORNERBRACKET",Np="LEFTWHITECORNERBRACKET",Pp="RIGHTWHITECORNERBRACKET",Lp="FULLWIDTHLESSTHAN",Fp="FULLWIDTHGREATERTHAN",zp="AMPERSAND",Bp="APOSTROPHE",Hp="ASTERISK",ks="AT",Vp="BACKSLASH",Up="BACKTICK",jp="CARET",Es="COLON",py="COMMA",qp="DOLLAR",no="DOT",Wp="EQUALS",my="EXCLAMATION",ci="HYPHEN",Fu="PERCENT",Kp="PIPE",Gp="PLUS",Zp="POUND",zu="QUERY",gy="QUOTE",wT="FULLWIDTHMIDDLEDOT",vy="SEMI",ro="SLASH",Bu="TILDE",Yp="UNDERSCORE",kT="EMOJI",Jp="SYM";var xT=Object.freeze({__proto__:null,ALPHANUMERICAL:yT,AMPERSAND:zp,APOSTROPHE:Bp,ASCIINUMERICAL:bT,ASTERISK:Hp,AT:ks,BACKSLASH:Vp,BACKTICK:Up,CARET:jp,CLOSEANGLEBRACKET:Mp,CLOSEBRACE:Lu,CLOSEBRACKET:Sp,CLOSEPAREN:Ap,COLON:Es,COMMA:py,DOLLAR:qp,DOT:no,EMOJI:kT,EQUALS:Wp,EXCLAMATION:my,FULLWIDTHGREATERTHAN:Fp,FULLWIDTHLEFTPAREN:Dp,FULLWIDTHLESSTHAN:Lp,FULLWIDTHMIDDLEDOT:wT,FULLWIDTHRIGHTPAREN:Op,HYPHEN:ci,LEFTCORNERBRACKET:Ip,LEFTWHITECORNERBRACKET:Np,LOCALHOST:xd,NL:hy,NUM:fy,OPENANGLEBRACKET:Tp,OPENBRACE:Pu,OPENBRACKET:Cp,OPENPAREN:Ep,PERCENT:Fu,PIPE:Kp,PLUS:Gp,POUND:Zp,QUERY:zu,QUOTE:gy,RIGHTCORNERBRACKET:Rp,RIGHTWHITECORNERBRACKET:Pp,SCHEME:_h,SEMI:vy,SLASH:ro,SLASH_SCHEME:Tl,SYM:Jp,TILDE:Bu,TLD:gb,UNDERSCORE:Yp,UTLD:vb,UWORD:mb,WORD:Lo,WS:bb});const Ro=/[a-z]/,ru=new RegExp("\\p{L}","u"),a0=new RegExp("\\p{Emoji}","u"),No=/\d/,l0=/\s/,Zx="\r",c0=`
210
- `,AK="️",TK="‍",u0="";let Lf=null,Ff=null;function MK(t=[]){const e={};Lr.groups=e;const n=new Lr;Lf==null&&(Lf=Yx(kK)),Ff==null&&(Ff=Yx(xK)),He(n,"'",Bp),He(n,"{",Pu),He(n,"}",Lu),He(n,"[",Cp),He(n,"]",Sp),He(n,"(",Ep),He(n,")",Ap),He(n,"<",Tp),He(n,">",Mp),He(n,"(",Dp),He(n,")",Op),He(n,"「",Ip),He(n,"」",Rp),He(n,"『",Np),He(n,"』",Pp),He(n,"<",Lp),He(n,">",Fp),He(n,"&",zp),He(n,"*",Hp),He(n,"@",ks),He(n,"`",Up),He(n,"^",jp),He(n,":",Es),He(n,",",py),He(n,"$",qp),He(n,".",no),He(n,"=",Wp),He(n,"!",my),He(n,"-",ci),He(n,"%",Fu),He(n,"|",Kp),He(n,"+",Gp),He(n,"#",Zp),He(n,"?",zu),He(n,'"',gy),He(n,"/",ro),He(n,";",vy),He(n,"~",Bu),He(n,"_",Yp),He(n,"\\",Vp),He(n,"・",wT);const r=bn(n,No,fy,{[db]:!0});bn(r,No,r);const i=bn(r,Ro,bT,{[Nu]:!0}),o=bn(r,ru,yT,{[bu]:!0}),s=bn(n,Ro,Lo,{[fb]:!0});bn(s,No,i),bn(s,Ro,s),bn(i,No,i),bn(i,Ro,i);const a=bn(n,ru,mb,{[hb]:!0});bn(a,Ro),bn(a,No,o),bn(a,ru,a),bn(o,No,o),bn(o,Ro),bn(o,ru,o);const l=He(n,c0,hy,{[s0]:!0}),c=He(n,Zx,bb,{[s0]:!0}),d=bn(n,l0,bb,{[s0]:!0});He(n,u0,d),He(c,c0,l),He(c,u0,d),bn(c,l0,d),He(d,Zx),He(d,c0),bn(d,l0,d),He(d,u0,d);const f=bn(n,a0,kT,{[vT]:!0});He(f,"#"),bn(f,a0,f),He(f,AK,f);const h=He(f,TK);He(h,"#"),bn(h,a0,f);const p=[[Ro,s],[No,i]],m=[[Ro,null],[ru,a],[No,o]];for(let v=0;v<Lf.length;v++)gs(n,Lf[v],gb,Lo,p);for(let v=0;v<Ff.length;v++)gs(n,Ff[v],vb,mb,m);_a(gb,{tld:!0,ascii:!0},e),_a(vb,{utld:!0,alpha:!0},e),gs(n,"file",_h,Lo,p),gs(n,"mailto",_h,Lo,p),gs(n,"http",Tl,Lo,p),gs(n,"https",Tl,Lo,p),gs(n,"ftp",Tl,Lo,p),gs(n,"ftps",Tl,Lo,p),_a(_h,{scheme:!0,ascii:!0},e),_a(Tl,{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]?{[_K]:!0}:{[CK]:!0};g.indexOf("-")>=0?C[pb]=!0:Ro.test(g)?No.test(g)?C[Nu]=!0:C[fb]=!0:C[db]=!0,Gx(n,g,g,C)}return Gx(n,"localhost",xd,{ascii:!0}),n.jd=new Lr(Jp),{start:n,tokens:Object.assign({groups:e},xT)}}function _T(t,e){const n=DK(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 DK(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 gs(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 Lr(r),o.jr=i.slice(),t.j[l]=o),t=o}return o=new Lr(n),o.jr=i.slice(),t.j[e[s-1]]=o,o}function Yx(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 _d={defaultProtocol:"http",events:null,format:Jx,formatHref:Jx,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function by(t,e=null){let n=Object.assign({},_d);t&&(n=Object.assign(n,t instanceof by?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}by.prototype={o:_d,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]:_d[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 Jx(t){return t}function CT(t,e){this.t="token",this.v=t,this.tk=e}CT.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=_d.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 Qm(t,e){class n extends CT{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 Xx=Qm("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Qx=Qm("text"),OK=Qm("nl"),zf=Qm("url",{isLink:!0,toHref(t=_d.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==xd&&t[1].t===Es}}),ai=t=>new Lr(t);function IK({groups:t}){const e=t.domain.concat([zp,Hp,ks,Vp,Up,jp,qp,Wp,ci,fy,Fu,Kp,Gp,Zp,ro,Jp,Bu,Yp]),n=[Bp,Es,py,no,my,Fu,zu,gy,vy,Tp,Mp,Pu,Lu,Sp,Cp,Ep,Ap,Dp,Op,Ip,Rp,Np,Pp,Lp,Fp],r=[zp,Bp,Hp,Vp,Up,jp,qp,Wp,ci,Pu,Lu,Fu,Kp,Gp,Zp,zu,ro,Jp,Bu,Yp],i=ai(),o=He(i,Bu);Et(o,r,o),Et(o,t.domain,o);const s=ai(),a=ai(),l=ai();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=He(s,ks);He(o,ks,c),He(a,ks,c),He(l,ks,c);const d=He(o,no);Et(d,r,o),Et(d,t.domain,o);const f=ai();Et(c,t.domain,f),Et(f,t.domain,f);const h=He(f,no);Et(h,t.domain,f);const p=ai(Xx);Et(h,t.tld,p),Et(h,t.utld,p),He(c,xd,p);const m=He(f,ci);He(m,ci,m),Et(m,t.domain,f),Et(p,t.domain,f),He(p,no,h),He(p,ci,m);const v=He(p,Es);Et(v,t.numeric,Xx);const g=He(s,ci),y=He(s,no);He(g,ci,g),Et(g,t.domain,s),Et(y,r,o),Et(y,t.domain,s);const C=ai(zf);Et(y,t.tld,C),Et(y,t.utld,C),Et(C,t.domain,s),Et(C,r,o),He(C,no,y),He(C,ci,g),He(C,ks,c);const _=He(C,Es),S=ai(zf);Et(_,t.numeric,S);const A=ai(zf),O=ai();Et(A,e,A),Et(A,n,O),Et(O,e,A),Et(O,n,O),He(C,ro,A),He(S,ro,A);const E=He(a,Es),M=He(l,Es),R=He(M,ro),D=He(R,ro);Et(a,t.domain,s),He(a,no,y),He(a,ci,g),Et(l,t.domain,s),He(l,no,y),He(l,ci,g),Et(E,t.domain,A),He(E,ro,A),He(E,zu,A),Et(D,t.domain,A),Et(D,e,A),He(D,ro,A);const I=[[Pu,Lu],[Cp,Sp],[Ep,Ap],[Tp,Mp],[Dp,Op],[Ip,Rp],[Np,Pp],[Lp,Fp]];for(let B=0;B<I.length;B++){const[z,Q]=I[B],ie=He(A,z);He(O,z,ie),He(ie,Q,A);const he=ai(zf);Et(ie,e,he);const ae=ai();Et(ie,n),Et(he,e,he),Et(he,n,ae),Et(ae,e,he),Et(ae,n,ae),He(he,Q,A),He(ae,Q,A)}return He(i,xd,C),He(i,hy,OK),{start:i,tokens:xT}}function RK(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(d0(Qx,e,s)),s=[]),i-=h,d-=h;const p=f.t,m=n.slice(i-d,i);o.push(d0(p,e,m))}}return s.length>0&&o.push(d0(Qx,e,s)),o}function d0(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 NK=typeof console<"u"&&console&&console.warn||(()=>{}),PK="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",cn={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function LK(){return Lr.groups={},cn.scanner=null,cn.parser=null,cn.tokenQueue=[],cn.pluginQueue=[],cn.customSchemes=[],cn.initialized=!1,cn}function $x(t,e=!1){if(cn.initialized&&NK(`linkifyjs: already initialized - will not register custom scheme "${t}" ${PK}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
211
- 1. Must only contain digits, lowercase ASCII letters or "-"
212
- 2. Cannot start or end with "-"
213
- 3. "-" cannot repeat`);cn.customSchemes.push([t,e])}function FK(){cn.scanner=MK(cn.customSchemes);for(let t=0;t<cn.tokenQueue.length;t++)cn.tokenQueue[t][1]({scanner:cn.scanner});cn.parser=IK(cn.scanner.tokens);for(let t=0;t<cn.pluginQueue.length;t++)cn.pluginQueue[t][1]({scanner:cn.scanner,parser:cn.parser});return cn.initialized=!0,cn}function yy(t){return cn.initialized||FK(),RK(cn.parser.start,t,_T(cn.scanner.start,t))}yy.scan=_T;function ST(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 by(n),i=yy(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 wy="[\0-   ᠎ -\u2029  ]",zK=new RegExp(wy),BK=new RegExp(`${wy}$`),HK=new RegExp(wy,"g");function VK(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function UK(t){return new Ht({key:new Gt("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=Hq(n.doc,[...e]);if(Gq(a).forEach(({newRange:c})=>{const d=Uq(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(!BK.test(p))return;f=d[0],h=r.doc.textBetween(f.pos,c.to,void 0," ")}if(f&&h){const p=h.split(zK).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=yy(m).map(y=>y.toObject(t.defaultProtocol));if(!VK(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=>{cy(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 jK(t){return new Ht({key:new Gt("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 qK(t){return new Ht({key:new Gt("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=ST(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 ua(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(HK,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const WK=Ji.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"){$x(t);return}$x(t.scheme,t.optionalSlashes)})},onDestroy(){LK()},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)=>!!ua(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=>!!ua(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=>!!ua(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=>!!ua(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=>!!ua(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[ea({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=ST(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!ua(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(UK({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!ua(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(jK({type:this.type})),this.options.linkOnPaste&&t.push(qK({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),KK=nn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Ht({key:new Gt("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&&Jm(s);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const f=Xt.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}),gt.create(t,i)}}})]}});let yb,wb;if(typeof WeakMap<"u"){let t=new WeakMap;yb=e=>t.get(e),wb=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;yb=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},wb=(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 yb(t)||wb(t,GK(t))}};function GK(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=ZK(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&&YK(a,s,t),a}function ZK(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 YK(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=JK(l)))[c]=d)}a&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function JK(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function gr(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 As=new Gt("selectingCells");function el(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 XK(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 Qi(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 $m(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=el(e.$head)||QK(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function QK(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 kb(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function $K(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function ky(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function ET(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 tl(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 AT(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 eG(t,e,n){const r=gr(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 an=class Fo extends mt{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 US(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(kb(r)&&kb(i)&&ky(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Fo.rowSelection(r,i):o&&this.isColSelection()?Fo.colSelection(r,i):new Fo(r,i)}return dt.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=tl(y,0,v)),g>0&&(y=tl(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=mt.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 Fo(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 Fo&&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 Fo(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Fo(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Fo(e.resolve(n),e.resolve(r))}getBookmark(){return new tG(this.$anchorCell.pos,this.$headCell.pos)}};an.prototype.visible=!1;mt.jsonID("cell",an);var tG=class TT{constructor(e,n){this.anchor=e,this.head=n}map(e){return new TT(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&&ky(n,r)?new an(n,r):mt.near(r,1)}};function nG(t){if(!(t.selection instanceof an))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Xt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),gt.create(t.doc,e)}function rG({$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 oG(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=an.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=an.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=an.create(i,l+1,c)}}else r instanceof dt&&rG(r)?o=dt.create(i,r.from):r instanceof dt&&iG(r)&&(o=dt.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}const sG=new Gt("fix-tables");function MT(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)?MT(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function DT(t,e){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=aG(t,i,o,n))};return e?e.doc!=t.doc&&MT(e.doc,t.doc,0,r):t.doc.descendants(r),n}function aG(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,tl(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=gr(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(sG,{fixTables:!0})}function To(t){const e=t.selection,n=$m(t),r=n.node(-1),i=n.start(-1),o=_n.get(r);return{...e instanceof an?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function OT(t,{map:e,tableStart:n,table:r},i){let o=i>0?-1:0;eG(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,AT(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?gr(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(!Qi(t))return!1;if(e){const n=To(t);e(OT(t.tr,n,n.left))}return!0}function cG(t,e){if(!Qi(t))return!1;if(e){const n=To(t);e(OT(t.tr,n,n.right))}return!0}function uG(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,tl(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 dG(t,e){if(!Qi(t))return!1;if(e){const n=To(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;uG(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 fG(t,e,n){var r;const i=gr(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 IT(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;fG(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?gr(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,gr(r.type.schema).row.create(null,s)),t}function hG(t,e){if(!Qi(t))return!1;if(e){const n=To(t);e(IT(t.tr,n,n.top))}return!0}function pG(t,e){if(!Qi(t))return!1;if(e){const n=To(t);e(IT(t.tr,n,n.bottom))}return!0}function mG(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 gG(t,e){if(!Qi(t))return!1;if(e){const n=To(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;mG(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 e2(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function vG({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 t2(t,e){const n=t.selection;if(!(n instanceof an)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=To(t),{map:i}=r;if(vG(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{e2(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,{...AT(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=e2(c)?l+1:d;o.replaceWith(f+r.tableStart,d+r.tableStart,a)}o.setSelection(new an(o.doc.resolve(l+r.tableStart))),e(o)}return!0}function n2(t,e){const n=gr(t.schema);return bG(({node:r})=>n[r.type.spec.tableRole])(t,e)}function bG(t){return(e,n)=>{const r=e.selection;let i,o;if(r instanceof an){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var s;if(i=XK(r.$from),!i)return!1;o=(s=el(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=To(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 an&&f.setSelection(new an(f.doc.resolve(r.$anchorCell.pos),h?f.doc.resolve(h):void 0)),n(f)}return!0}}function yG(t,e){return function(n,r){if(!Qi(n))return!1;const i=$m(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const o=n.tr;n.selection instanceof an?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 wG(t){return function(e,n){if(!Qi(e))return!1;if(n){const r=gr(e.schema),i=To(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 r2(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 Cd(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?wG(t):function(n,r){if(!Qi(n))return!1;if(r){const i=gr(n.schema),o=To(n),s=n.tr,a=r2("row",o,i),l=r2("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}}Cd("row",{useDeprecatedLogic:!0});Cd("column",{useDeprecatedLogic:!0});const kG=Cd("cell",{useDeprecatedLogic:!0});function xG(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 i2(t){return function(e,n){if(!Qi(e))return!1;const r=xG($m(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(dt.between(i,$K(i))).scrollIntoView())}return!0}}function _G(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 Bf(t,e){const n=t.selection;if(!(n instanceof an))return!1;if(e){const r=t.tr,i=gr(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 CG(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=xb(gr(s).row,new Ge(c,d,f)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(n||r?xb(gr(s).row,new Ge(e,n,r)).content:e);else return null;return SG(s,a)}function SG(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=gr(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 xb(t,e){const n=t.createAndFill();return new r1(n).replace(0,n.content.size,e).doc}function EG({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(tl(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 AG(t,e,n,r,i,o,s){const a=t.doc.type.schema,l=gr(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 o2(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,tl(h.attrs,s-p,h.attrs.colspan-(s-p))),t.insert(m+h.nodeSize,h.type.createAndFill(tl(h.attrs,0,s-p))),c+=h.attrs.rowspan-1}}return l}function a2(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}AG(f,s,o,n,c,d,h)&&p(),o2(f,s,o,n,l,c,a,h)&&p(),o2(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 an(f.doc.resolve(n+s.positionAt(a,l,o)),f.doc.resolve(n+s.positionAt(d-1,c-1,o)))),e(f)}const TG=$1({ArrowLeft:Hf("horiz",-1),ArrowRight:Hf("horiz",1),ArrowUp:Hf("vert",-1),ArrowDown:Hf("vert",1),"Shift-ArrowLeft":Vf("horiz",-1),"Shift-ArrowRight":Vf("horiz",1),"Shift-ArrowUp":Vf("vert",-1),"Shift-ArrowDown":Vf("vert",1),Backspace:Bf,"Mod-Backspace":Bf,Delete:Bf,"Mod-Delete":Bf});function Ch(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Hf(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof an)return Ch(n,r,mt.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=RT(i,t,e);if(s==null)return!1;if(t=="horiz")return Ch(n,r,mt.near(n.doc.resolve(o.head+e),e));{const a=n.doc.resolve(s),l=ET(a,t,e);let c;return l?c=mt.near(l,1):e<0?c=mt.near(n.doc.resolve(a.before(-1)),-1):c=mt.near(n.doc.resolve(a.after(-1)),1),Ch(n,r,c)}}}function Vf(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof an)s=o;else{const l=RT(i,t,e);if(l==null)return!1;s=new an(n.doc.resolve(l))}const a=ET(s.$headCell,t,e);return a?Ch(n,r,new an(s.$anchorCell,a)):!1}}function MG(t,e){const n=t.state.doc,r=el(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new an(r))),!0):!1}function DG(t,e,n){if(!Qi(t.state))return!1;let r=CG(n);const i=t.state.selection;if(i instanceof an){r||(r={width:1,height:1,rows:[Ce.from(xb(gr(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=EG(r,a.right-a.left,a.bottom-a.top),a2(t.state,t.dispatch,s,a,r),!0}else if(r){const o=$m(t.state),s=o.start(-1);return a2(t.state,t.dispatch,s,_n.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function OG(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=l2(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof an)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=el(t.state.selection.$anchor))!=null&&((n=f0(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=f0(t,c);const f=As.getState(t.state)==null;if(!d||!ky(l,d))if(f)d=l;else return;const h=new an(l,d);if(f||!t.state.selection.eq(h)){const p=t.state.tr.setSelection(h);f&&p.setMeta(As,l.pos),t.dispatch(p)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),As.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(As,-1))}function a(l){const c=l,d=As.getState(t.state);let f;if(d!=null)f=t.state.doc.resolve(d);else if(l2(t,c.target)!=r&&(f=f0(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 RT(t,e,n){if(!(t.state.selection instanceof dt))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 l2(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function f0(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&&el(t.state.doc.resolve(r))||el(t.state.doc.resolve(i))}var IG=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")),_b(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,_b(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function _b(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 ti=new Gt("tableColumnResizing");function RG({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=IG,lastColumnResizable:i=!0}={}){const o=new Ht({key:ti,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=gr(a.schema).table.name;return r&&c&&(c[d]=(f,h)=>new r(f,n,h)),new NG(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=ti.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{PG(s,a,t,i)},mouseleave:s=>{LG(s)},mousedown:(s,a)=>{FG(s,a,e,n)}},decorations:s=>{const a=ti.getState(s);if(a&&a.activeHandle>-1)return UG(s,a.activeHandle)},nodeViews:{}}});return o}var NG=class Sh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(ti);if(r&&r.setHandle!=null)return new Sh(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Sh(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return kb(e.doc.resolve(i))||(i=-1),new Sh(i,n.dragging)}return n}};function PG(t,e,n,r){if(!t.editable)return;const i=ti.getState(t.state);if(i&&!i.dragging){const o=BG(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=n?s=c2(t,e,"left",n):l-e.clientX<=n&&(s=c2(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}NT(t,s)}}}function LG(t){if(!t.editable)return;const e=ti.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&NT(t,-1)}function FG(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=ti.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=zG(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(ti,{setDragging:{startX:e.clientX,startWidth:l}}));function c(f){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",d);const h=ti.getState(t.state);h!=null&&h.dragging&&(HG(t,h.activeHandle,u2(h.dragging,f,n)),t.dispatch(t.state.tr.setMeta(ti,{setDragging:null})))}function d(f){if(!f.which)return c(f);const h=ti.getState(t.state);if(h&&h.dragging){const p=u2(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 zG(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 BG(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function c2(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=el(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 u2(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function NT(t,e){t.dispatch(t.state.tr.setMeta(ti,{setHandle:e}))}function HG(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():VG(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&&_b(o,l.firstChild,l,r,a,n)}function VG(t){return Array(t).fill(0)}function UG(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return gt.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=ti.getState(t))===null||l===void 0)&&l.dragging&&n.push(Xt.node(s+f,s+f+i.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),n.push(Xt.widget(h,p))}}return gt.create(t.doc,n)}function jG({allowTableNodeSelection:t=!1}={}){return new Ht({key:As,state:{init(){return null},apply(e,n){const r=e.getMeta(As);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:nG,handleDOMEvents:{mousedown:OG},createSelectionBetween(e){return As.getState(e.state)!=null?e.state.selection:null},handleTripleClick:MG,handleKeyDown:TG,handlePaste:DG},appendTransaction(e,n,r){return oG(r,DT(r,n),t)}})}function Cb(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function f2(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,_]=Cb(r,g);c.style.setProperty(C,_)}c=c.nextSibling}else{const C=document.createElement("col"),[_,S]=Cb(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 qG{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")),f2(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,f2(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function WG(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]=Cb(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 h2(t,e){return t.createAndFill()}function KG(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 GG(t,e,n,r,i){const o=KG(t),s=[],a=[];for(let c=0;c<n;c+=1){const d=h2(o.cell);if(d&&a.push(d),r){const f=h2(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 ZG(t){return t instanceof an}const Uf=({editor:t})=>{const{selection:e}=t.state;if(!ZG(e))return!1;let n=0;const r=uT(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},YG=yr.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:qG,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}=WG(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=GG(o.schema,t,e,n);if(i){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(dt.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>lG(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>cG(t,e),deleteColumn:()=>({state:t,dispatch:e})=>dG(t,e),addRowBefore:()=>({state:t,dispatch:e})=>hG(t,e),addRowAfter:()=>({state:t,dispatch:e})=>pG(t,e),deleteRow:()=>({state:t,dispatch:e})=>gG(t,e),deleteTable:()=>({state:t,dispatch:e})=>_G(t,e),mergeCells:()=>({state:t,dispatch:e})=>t2(t,e),splitCell:()=>({state:t,dispatch:e})=>n2(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Cd("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Cd("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>kG(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>t2(t,e)?!0:n2(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>yG(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>i2(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>i2(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&DT(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=an.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:Uf,"Mod-Backspace":Uf,Delete:Uf,"Mod-Delete":Uf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[RG({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],jG({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:At(ot(t,"tableRole",e))}}}),JG=yr.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]}}),XG=yr.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]}}),QG=yr.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]}}),$G=/^\s*>\s$/,eZ=yr.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[wd({find:$G,type:this.type})]}}),tZ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,nZ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,rZ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,iZ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,oZ=Ji.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[$a({find:tZ,type:this.type}),$a({find:rZ,type:this.type})]},addPasteRules(){return[ea({find:nZ,type:this.type}),ea({find:iZ,type:this.type})]}}),sZ="listItem",p2="textStyle",m2=/^\s*([-+*])\s$/,aZ=yr.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(sZ,this.editor.getAttributes(p2)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=wd({find:m2,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=wd({find:m2,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(p2),editor:this.editor})),[t]}}),lZ=/(^|[^`])`([^`]+)`(?!`)/,cZ=/(^|[^`])`([^`]+)`(?!`)/g,uZ=Ji.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[$a({find:lZ,type:this.type})]},addPasteRules(){return[ea({find:cZ,type:this.type})]}}),dZ=/^```([a-z]+)?[\s\n]$/,fZ=/^~~~([a-z]+)?[\s\n]$/,hZ=yr.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(`
214
-
215
- `);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(mt.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[ob({find:dZ,type:this.type,getAttributes:t=>({language:t[1]})}),ob({find:fZ,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ht({key:new Gt("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,`
216
- `));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(dt.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),pZ=yr.create({name:"doc",topNode:!0,content:"block+"});function mZ(t={}){return new Ht({view(e){return new gZ(e,t)}})}class gZ{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=FS(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 vZ=nn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[mZ(this.options)]}});class wn extends mt{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return wn.valid(r)?new wn(r):mt.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 xy(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!bZ(e)||!yZ(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;mt.jsonID("gapcursor",wn);class xy{constructor(e){this.pos=e}map(e){return new xy(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return wn.valid(n)?new wn(n):mt.near(n)}}function PT(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function bZ(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||PT(i.type))return!0;if(i.inlineContent)return!1}}return!0}function yZ(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||PT(i.type))return!0;if(i.inlineContent)return!1}}return!0}function wZ(){return new Ht({props:{decorations:CZ,createSelectionBetween(t,e,n){return e.pos==n.pos&&wn.valid(n)?new wn(n):null},handleClick:xZ,handleKeyDown:kZ,handleDOMEvents:{beforeinput:_Z}}})}const kZ=$1({ArrowLeft:jf("horiz",-1),ArrowRight:jf("horiz",1),ArrowUp:jf("vert",-1),ArrowDown:jf("vert",1)});function jf(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 dt){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 xZ(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 _Z(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(dt.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function CZ(t){if(!(t.selection instanceof wn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",gt.create(t.doc,[Xt.widget(t.selection.head,e,{key:"gapcursor"})])}const SZ=nn.create({name:"gapCursor",addProseMirrorPlugins(){return[wZ()]},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}}}),EZ=yr.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`
217
- `},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()}}}),AZ=yr.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=>ob({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Xp=200,Xn=function(){};Xn.prototype.append=function(e){return e.length?(e=Xn.from(e),!this.length&&e||e.length<Xp&&this.leafAppend(e)||this.length<Xp&&e.leafPrepend(this)||this.appendInner(e)):this};Xn.prototype.prepend=function(e){return e.length?Xn.from(e).append(this):this};Xn.prototype.appendInner=function(e){return new TZ(this,e)};Xn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Xn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Xn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Xn.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)};Xn.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};Xn.from=function(e){return e instanceof Xn?e:e&&e.length?new LT(e):Xn.empty};var LT=(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<=Xp)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Xp)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})(Xn);Xn.empty=new LT([]);var TZ=(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})(Xn);const MZ=500;class Bi{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 io(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 io(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 Bi(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 io(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>OZ&&(a=DZ(a,c),s-=c),new Bi(a.append(o),s)}remapping(e,n){let r=new Qu;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 Bi(this.items.append(e.map(n=>new io(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 io(m,v,g))}else r.push(new io(m))},i);let c=[];for(let h=n;h<s;h++)c.push(new io(o.maps[h]));let d=this.items.slice(0,i).append(c).append(r),f=new Bi(d,a);return f.emptyItemCount()>MZ&&(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 io(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 Bi(Xn.from(i.reverse()),o)}}Bi.empty=new Bi(Xn.empty,0);function DZ(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class io{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 io(n.getMap().invert(),n,this.selection)}}}class xs{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const OZ=20;function IZ(t,e,n,r){let i=n.getMeta(Ha),o;if(i)return i.historyState;n.getMeta(PZ)&&(t=new xs(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Ha))return s.getMeta(Ha).redo?new xs(t.done.addTransform(n,void 0,r,Eh(e)),t.undone,g2(n.mapping.maps),t.prevTime,t.prevComposition):new xs(t.done,t.undone.addTransform(n,void 0,r,Eh(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||!RZ(n,t.prevRanges)),c=s?h0(t.prevRanges,n.mapping):g2(n.mapping.maps);return new xs(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,Eh(e)),Bi.empty,c,n.time,a??t.prevComposition)}else return(o=n.getMeta("rebased"))?new xs(t.done.rebased(n,o),t.undone.rebased(n,o),h0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new xs(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),h0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function RZ(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 g2(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 h0(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 NZ(t,e,n){let r=Eh(e),i=Ha.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 xs(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(Ha,{redo:n,historyState:l})}let p0=!1,v2=null;function Eh(t){let e=t.plugins;if(v2!=e){p0=!1,v2=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){p0=!0;break}}return p0}const Ha=new Gt("history"),PZ=new Gt("closeHistory");function LZ(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ht({key:Ha,state:{init(){return new xs(Bi.empty,Bi.empty,null,0,-1)},apply(e,n,r){return IZ(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?zT:r=="historyRedo"?BT:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function FT(t,e){return(n,r)=>{let i=Ha.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=NZ(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const zT=FT(!1,!0),BT=FT(!0,!0),FZ=nn.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>zT(t,e),redo:()=>({state:t,dispatch:e})=>BT(t,e)}},addProseMirrorPlugins(){return[LZ(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()}}}),zZ=yr.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(!AW(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}):Yq(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(dt.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(ft.create(s.doc,c.pos)):s.setSelection(dt.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(dt.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[fT({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),BZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,HZ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,VZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,UZ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,jZ=Ji.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[$a({find:BZ,type:this.type}),$a({find:VZ,type:this.type})]},addPasteRules(){return[ea({find:HZ,type:this.type}),ea({find:UZ,type:this.type})]}}),HT=yr.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)}}}),qZ="listItem",b2="textStyle",y2=/^(\d+)\.\s$/,WZ=yr.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(qZ,this.editor.getAttributes(b2)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=wd({find:y2,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=wd({find:y2,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(b2)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),KZ=yr.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()}}}),GZ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,ZZ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,YZ=Ji.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[$a({find:GZ,type:this.type})]},addPasteRules(){return[ea({find:ZZ,type:this.type})]}}),JZ=yr.create({name:"text",group:"inline"}),XZ=nn.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(oZ.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(eZ.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(aZ.configure(this.options.bulletList)),this.options.code!==!1&&t.push(uZ.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(hZ.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(pZ.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(vZ.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(SZ.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(EZ.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(AZ.configure(this.options.heading)),this.options.history!==!1&&t.push(FZ.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(zZ.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(jZ.configure(this.options.italic)),this.options.listItem!==!1&&t.push(HT.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(WZ.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(KZ.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(YZ.configure(this.options.strike)),this.options.text!==!1&&t.push(JZ.configure(this.options.text)),t}});function QZ(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 $Z(t){const e=t.toLowerCase();return e.includes("mac")||e==="darwin"?"macos":e.includes("win")?"windows":"linux"}function VT(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 eY=["http://","https://","mailto:","ftp://","//"];function UT(t){const e=t.toLowerCase();return eY.some(n=>e.startsWith(n))}function jT(t){if(!t)return null;const e=t.trim();if(!e)return null;if(UT(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 li(t){return t.chain().focus()}async function tY(t,e){const{editor:n}=e;switch(t){case"ctx:undo":li(n).undo().run();return;case"ctx:redo":li(n).redo().run();return;case"ctx:pastePlain":{const r=await e.readClipboardText();if(!r)return;const{state:i,view:o}=n,s=VT(r,i.schema,i.selection.$from.marks());o.dispatch(i.tr.replaceSelection(s).scrollIntoView()),o.focus();return}case"ctx:table:insertRowAbove":li(n).addRowBefore().run();return;case"ctx:table:insertRowBelow":li(n).addRowAfter().run();return;case"ctx:table:insertColLeft":li(n).addColumnBefore().run();return;case"ctx:table:insertColRight":li(n).addColumnAfter().run();return;case"ctx:table:deleteRow":li(n).deleteRow().run();return;case"ctx:table:deleteCol":li(n).deleteColumn().run();return;case"ctx:table:mergeCells":li(n).mergeCells().run();return;case"ctx:table:splitCell":li(n).splitCell().run();return;case"ctx:table:deleteTable":li(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=jT(r);i&&await e.writeClipboardText(i);return}case"ctx:link:remove":li(n).extendMarkRange("link").unsetLink().run();return;default:return}}const nY=["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"],rY=new Set(nY);function iY(t){return typeof t=="string"&&rY.has(t)}async function oY(){try{return await navigator.clipboard.readText()}catch{return null}}async function sY(t){try{await navigator.clipboard.writeText(t)}catch{}}function aY(t,e){if(!Tt())return()=>{};const n=t.view.dom,r=e.platform??$Z(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=QZ({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 ss())("show_context_menu",{req:c})}catch{}};n.addEventListener("contextmenu",o);const s=Kt(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)&&tY(c,{editor:t,openHref:e.openHref,getLinkHref:()=>i,readClipboardText:oY,writeClipboardText:sY})}));return s.catch(()=>{}),()=>{n.removeEventListener("contextmenu",o),s.then(a=>a()).catch(()=>{})}}const yu=new Gt("tandemAnnotations"),w2={comment:!0,highlight:!0,note:!0};function qT(){try{const t=localStorage.getItem(DC);if(!t)return{...w2};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),{...w2}}}function k2(){return Fv(mm(),"family")}function WT(t){return t==="highlight"?"highlight":t==="note"||t==="flag"?"note":"comment"}function m0(t,e,n,r,i){const o=[],s=t.content.size;return e.forEach(a=>{const l=Ja(a,p=>{console.warn("[sanitize]",p)});if(l.status!=="pending"||!r[l.type]||!l.range&&!l.relRange)return;const c=Sc(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=_C(l.color),m=Wu[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(Xt.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)}}),gt.create(t,o)}const lY=nn.create({name:"tandemAnnotations",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Mi);let n=qT(),r=k2();function i(){for(const a of e.values()){const l=a;if(l&&l.status==="pending"&&n[WT(l.type)])return!0}return!1}let o=i(),s=!1;return[new Ht({key:yu,state:{init(a,l){return o?m0(l.doc,e,t,n,r):gt.empty},apply(a,l,c,d){const f=a.getMeta(yu);if(f&&typeof f=="object"&&f.type==="toggle-decorations"&&(n=f.visible,o=i(),s=!1),f)return r=k2(),o?m0(d.doc,e,t,n,r):gt.empty;if(!o)return gt.empty;if(a.docChanged){if(!s&&l===gt.empty&&o){const h=m0(d.doc,e,t,n,r);return h!==gt.empty&&(s=!0),h}return l.map(a.mapping,a.doc)}return l}},props:{decorations(a){return yu.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(yu,!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)}}}})]}}),iu=new Gt("tandemAnnotationPing"),cY=700,uY=500,dY="tandem-annotation-ping";function fY(t,e){return!(!e.isLive||e.alreadySeen||!t||t.status!=="pending"||!e.visible[WT(t.type)])}function hY(){try{if(mm().reduceMotion)return!0}catch{}return typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const pY=nn.create({name:"tandemAnnotationPing",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Mi),n=new Set;let r=!1;return[new Ht({key:iu,state:{init:()=>gt.empty,apply(i,o){let s=o.map(i.mapping,i.doc);const a=i.getMeta(iu);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 iu.getState(i)}},view(i){const o=new Map;let s=!1;function a(h,p){if(hY())return;const m=Sc(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),_=Xt.node(y,C,{class:dY},{pingId:h});i.dispatch(i.state.tr.setMeta(iu,{type:"add",deco:_}));const S=setTimeout(()=>{o.delete(h),!s&&i.dispatch(i.state.tr.setMeta(iu,{type:"remove",id:h}))},cY);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,uY)},f=h=>{r||d();const p=qT();for(const m of h.keysChanged){const v=e.get(m),g=fY(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)}}}})]}}),Ml=new Gt("tandemAuthorship"),mY=new Set(["paragraph","heading"]);function gY(t,e,n){if(t.relRange){const r=AE(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=Qs(e,t.range.from),i=Qs(e,t.range.to);if(r<i)return{from:r,to:i}}return null}function g0(t,e,n,r){if(!r)return gt.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=gY(l,t,n);if(!c)return;const{from:d,to:f}=c;if(!(d>=f||d<0||f>o)){try{i.push(Xt.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(!mY.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(Xt.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)}}),gt.create(t,i)}const vY=nn.create({name:"tandemAuthorship",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(uw);let n=!1;try{n=localStorage.getItem(MC)==="true"}catch(r){console.warn("[authorship] localStorage unavailable",r)}return[new Ht({key:Ml,state:{init(r,i){return{visible:n,decorations:g0(i.doc,e,t,n)}},apply(r,i,o,s){const a=r.getMeta(Ml);if((a==null?void 0:a.type)==="toggle"){const l=a.visible;return{visible:l,decorations:g0(s.doc,e,t,l)}}return(a==null?void 0:a.type)==="rebuild"?{visible:i.visible,decorations:g0(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=Ml.getState(r))==null?void 0:i.decorations)??gt.empty}},view(r){const i=()=>{const s=r.state.tr.setMeta(Ml,{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(Ml)||!t.docChanged)return;const n=e.getMap(uw),r=t.doc;t.steps.forEach(i=>{i.getMap().forEach((s,a,l,c)=>{if(c-l-(a-s)>0)try{const f=gi(r,zn(l)),h=gi(r,zn(c));if(h<=f)return;const p=zD("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 Gt("tandemAwareness");function x2(t,e){if(!e)return gt.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(Xt.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=Qs(t,ah(i)),a=o===!1?" tandem-claude-cursor-idle":"";n.push(Xt.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?gt.empty:gt.create(t,n)}const bY=nn.create({name:"tandemAwareness",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(AC),n=t.getMap(tv);return[new Ht({key:qf,state:{init(r,i){const o=e.get(nv);return x2(i.doc,o??null)},apply(r,i,o,s){if(r.getMeta(qf)){const a=e.get(nv);return x2(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 Ht({key:new Gt("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=TE(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,`
218
- `),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(fw,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200)),r&&clearTimeout(r),r=setTimeout(()=>{s=!1,n.set(fw,{isTyping:!1,cursor:l.state.selection.from,lastEdit:Date.now()})},YM))},destroy(){r&&clearTimeout(r),i&&clearTimeout(i),o&&clearTimeout(o)}}}})]}}),oo=new Gt("tandemFindReplace"),KT={query:"",caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:gt.empty};function yY(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wY(t){if(!t.query)return null;try{const e=t.regexMode?t.query:yY(t.query),n=t.caseSensitive?"g":"gi",r=t.wholeWord?`\\b${e}\\b`:e;return new RegExp(r,n)}catch{return null}}function GT(t,e){const n=wY(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 Hu(t,e,n){if(e.length===0)return gt.empty;const r=[];for(let i=0;i<e.length;i++){const{from:o,to:s}=e[i];try{r.push(Xt.inline(o,s,{class:i===n?"tandem-find-active":"tandem-find-match"}))}catch{}}return gt.create(t,r)}function Sb(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 kY(t,e,n){if(t.type==="close")return KT;if(t.type==="find"){const i=t.opts,o=GT(n.doc,i),s=n.selection.from,a=Sb(o,s);return{...i,matches:o,activeIndex:a,decoSet:Hu(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:Hu(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:Hu(n.doc,e.matches,i)}}return t}const xY=nn.create({name:"tandemFindReplace",addProseMirrorPlugins(){return[new Ht({key:oo,state:{init:()=>KT,apply(t,e,n,r){const i=t.getMeta(oo);if(i)return kY(i,e,r);if(!e.query)return e;if(t.docChanged){const a=GT(r.doc,e),l=r.selection.from,c=Sb(a,l);return{...e,matches:a,activeIndex:c,decoSet:Hu(r.doc,a,c)}}const o=r.selection.from,s=Sb(e.matches,o);return s===e.activeIndex?e:{...e,activeIndex:s,decoSet:Hu(r.doc,e.matches,s)}}},props:{decorations(t){var e;return((e=oo.getState(t))==null?void 0:e.decoSet)??gt.empty}}})]},addCommands(){return{find:t=>({dispatch:e,tr:n})=>(e&&e(n.setMeta(oo,{type:"find",opts:t})),!0),findNext:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(oo,{type:"next"})),!0),findPrev:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(oo,{type:"prev"})),!0),findClose:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(oo,{type:"close"})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:t})=>{const e=oo.getState(t.state);return e!=null&&e.query?(t.commands.findClose(),!0):!1}}}});function Zl(t){return oo.getState(t)}function _Y(t,e){const n=Zl(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(oo,{type:"next"});return t.dispatch(o),!0}async function CY(t,e,n){let i=0,o=!1;for(let s=0;s<50;s++){const a=Zl(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 fa=new Gt("tandemHeadingCollapse"),SY="tandem:headingCollapse:";function ZT(t){return!t||t.startsWith("upload://")?null:SY+t}function _2(t){const e=ZT(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 Qp(t,e){const n=ZT(t);if(n)try{e.size===0?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(Array.from(e)))}catch{}}function EY(t){return t.trim().toLowerCase().replace(/\s+/g," ")}function v0(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=EY(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 AY(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),Qp(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?(Qp(r,s),s):n}function TY(t,e,n){return Xt.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(fa,{type:"toggle",hash:e});r.dispatch(s)}),i},{side:-1,ignoreSelection:!0,stopEvent:()=>!0,key:`chevron:${e}:${n?"c":"e"}`})}function MY(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(Xt.node(l,c,{class:"tandem-heading-collapsed-hidden",style:"display: none;"}))}}),o}function Wf(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(TY(o.pos,o.hash,s)),s&&r.push(...MY(t,e,i))}catch{}}return r.length===0?gt.empty:gt.create(t,r)}const DY=nn.create({name:"tandemHeadingCollapse",addOptions(){return{filePath:null}},addProseMirrorPlugins(){const t=this.options.filePath;return[new Ht({key:fa,state:{init(e,n){const r=_2(t),i=v0(n.doc);return{collapsed:r,headings:i,decoSet:Wf(n.doc,i,r),hasSeenContent:i.length>0}},apply(e,n,r,i){const o=e.getMeta(fa);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),Qp(t,c),{collapsed:c,headings:n.headings,decoSet:Wf(i.doc,n.headings,c),hasSeenContent:n.hasSeenContent}}if((o==null?void 0:o.type)==="rehydrate"){const c=v0(i.doc),d=_2(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&&Qp(t,h),{collapsed:h,headings:c,decoSet:Wf(i.doc,c,h),hasSeenContent:!0}}if(!e.docChanged)return n;const s=v0(i.doc),a=n.hasSeenContent||s.length>0;let l=n.collapsed;return n.hasSeenContent&&(l=AY(n.headings,s,n.collapsed,t)),{collapsed:l,headings:s,decoSet:Wf(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=fa.getState(e.state);if(!o||o.headings.length===0)return;n=!0;const s=e.state.tr.setMeta(fa,{type:"rehydrate"}).setMeta("addToHistory",!1);e.dispatch(s)}))}return i(),{update(o){if(n)return;const s=fa.getState(o.state);!s||s.headings.length===0||i()},destroy(){r!==null&&cancelAnimationFrame(r)}}},props:{decorations(e){var n;return((n=fa.getState(e))==null?void 0:n.decoSet)??gt.empty}}})]}}),OY=new Gt("listItemCheckbox"),IY=/^\[([ xX])\]\s$/,RY=HT.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 lf({find:IY,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 Ht({key:OY,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(Xt.widget(s+1,(l,c)=>NY(l,c,a,t),{side:-1,key:`tandem-checkbox-${s}:${a}`,stopEvent:()=>!0,ignoreSelection:!0}))}),gt.create(r.doc,i)}}})]}});function NY(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 PY=nn.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":""}:{}}}}]}}),LY=Ji.create({name:"rawMarkdown",parseHTML(){return[]},renderHTML(){return["span",{class:"tandem-raw-md"},0]}}),FY=new Gt("tandemSelectionDecoration"),zY=nn.create({name:"tandemSelectionDecoration",addProseMirrorPlugins(){return[new Ht({key:FY,props:{decorations(t){const{selection:e}=t;if(!(e instanceof dt))return gt.empty;const{from:n,to:r}=e;return n===r?gt.empty:gt.create(t.doc,[Xt.inline(n,r,{class:"tandem-selection-blurred"})])}}})]}});function Po(t){return t.chain().focus()}const C2={tag:"path",attrs:{d:"M6 4.5h7M6 8h7M6 11.5h7"}},S2=[{id:"heading-1",label:"Heading 1",keywords:["h1","heading","title"],hint:"h1",icon:{kind:"glyph",glyph:"H¹"},run:t=>Po(t).toggleHeading({level:1}).run()},{id:"heading-2",label:"Heading 2",keywords:["h2","heading","subtitle"],hint:"h2",icon:{kind:"glyph",glyph:"H²"},run:t=>Po(t).toggleHeading({level:2}).run()},{id:"heading-3",label:"Heading 3",keywords:["h3","heading","subheading"],hint:"h3",icon:{kind:"glyph",glyph:"H³"},run:t=>Po(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"}},C2]},run:t=>Po(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"}},C2]},run:t=>Po(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=>Po(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=>Po(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=>Po(t).toggleCodeBlock().run()},{id:"horizontal-rule",label:"Horizontal rule",keywords:["hr","divider","rule","separator"],hint:"hr",icon:{kind:"glyph",glyph:"—"},run:t=>Po(t).setHorizontalRule().run()}];function BY(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 eg(t){const e=t.trim().toLowerCase();return e?S2.filter(n=>[n.label,...n.keywords].join(" ").toLowerCase().includes(e)):S2}const HY=["popup-annotation-input","popup-note-submit","popup-comment-submit","popup-highlight-yellow","popup-highlight-green","popup-highlight-blue","popup-highlight-pink"];function VY(t){const e=document.querySelector(`[data-testid="${t}"]`);return e?document.activeElement===e:!1}function UY(t){for(const e of t)if(document.querySelector(`[data-testid="${e}"]`))return!0;return!1}function jY(){return typeof document>"u"?!1:!!(VY("find-input")||document.querySelector('[data-testid="command-palette"]')||UY(HY))}const E2="http://www.w3.org/2000/svg",zo=new Gt("tandemSlashCommand");function YT(t){return`${t.from}:${t.to}:${t.query}`}function qY(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 WY(t,e=0){if(jY())return null;const{selection:n}=t;if(!n.empty)return null;const r=n.$from,i=r.parent.textBetween(0,r.parentOffset,`
219
- `,`
220
- `),o=BY(i);if(!o)return null;const s=r.start()+o.fromOffset,a=r.pos,l=eg(o.query);return l.length===0?null:{from:s,to:a,query:o.query,selectedIndex:Math.min(e,l.length-1)}}function KY(t,e){const n=t.getMeta(zo);return n?n.type==="close"?{active:null,dismissedKey:e.active?YT(e.active):e.dismissedKey}:n.type==="select"&&e.active?{...e,active:{...e.active,selectedIndex:n.selectedIndex??e.active.selectedIndex}}:e:null}function JT(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function GY(){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 ZY(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(E2,"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(E2,r.tag);for(const[o,s]of Object.entries(r.attrs))i.setAttribute(o,s);n.appendChild(i)}return e.appendChild(n),e}function YY(t,e,n,r,i){const o=eg(e.query);JT(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(ZY(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(GY());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 JY(t,e){const n=eg(e.query)[e.selectedIndex];return n?(t.chain().focus().deleteRange({from:e.from,to:e.to}).run(),n.run(t),!0):!1}const XY=nn.create({name:"slashCommand",addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){const t=this.editor,e=this.options.onOpenChange;return[new Ht({key:zo,state:{init:()=>({active:null,dismissedKey:null}),apply(n,r,i,o){var l;const s=KY(n,r);if(s)return s;const a=WY(o,((l=r.active)==null?void 0:l.selectedIndex)??0);return a&&!r.active&&!qY(n)?{active:null,dismissedKey:r.dismissedKey}:a&&YT(a)===r.dismissedKey?{active:null,dismissedKey:r.dismissedKey}:{active:a,dismissedKey:a?null:r.dismissedKey}}},props:{handleKeyDown(n,r){const i=zo.getState(n.state),o=i==null?void 0:i.active;if(!o)return!1;const s=eg(o.query);if(r.key==="ArrowDown"){r.preventDefault();const a=(o.selectedIndex+1)%s.length;return n.dispatch(n.state.tr.setMeta(zo,{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(zo,{type:"select",selectedIndex:a})),!0}return r.key==="Enter"?(r.preventDefault(),JY(t,o)):r.key==="Escape"?(r.preventDefault(),n.dispatch(n.state.tr.setMeta(zo,{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",JT(r),o(!1)},a=()=>{var c;const l=(c=zo.getState(n.state))==null?void 0:c.active;if(!l){s();return}YY(r,l,t,d=>{n.dispatch(n.state.tr.setMeta(zo,{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(zo,{type:"close"}))}),o(!0)};return a(),{update:a,destroy(){o(!1),r.remove()}}}})]}}),A2={};function QY(t){let e=A2[t];if(e)return e;e=A2[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 Dc(t,e){typeof e!="string"&&(e=Dc.defaultChars);const n=QY(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})}Dc.defaultChars=";/?:@&=+$,#";Dc.componentChars="";const T2={};function $Y(t){let e=T2[t];if(e)return e;e=T2[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 cf(t,e,n){typeof e!="string"&&(n=e,e=cf.defaultChars),typeof n>"u"&&(n=!0);const r=$Y(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}cf.defaultChars=";/?:@&=+$,-_.!~*'()#";cf.componentChars="-_.!~*'()";function _y(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 $p(){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 eJ=/^([a-z0-9.+-]+:)/i,tJ=/:[0-9]*$/,nJ=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,rJ=["<",">",'"',"`"," ","\r",`
221
- `," "],iJ=["{","}","|","\\","^","`"].concat(rJ),oJ=["'"].concat(iJ),M2=["%","/","?",";","#"].concat(oJ),D2=["/","?","#"],sJ=255,O2=/^[+a-z0-9A-Z_-]{0,63}$/,aJ=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,I2={javascript:!0,"javascript:":!0},R2={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Cy(t,e){if(t&&t instanceof $p)return t;const n=new $p;return n.parse(t,e),n}$p.prototype.parse=function(t,e){let n,r,i,o=t;if(o=o.trim(),!e&&t.split("#").length===1){const c=nJ.exec(o);if(c)return this.pathname=c[1],c[2]&&(this.search=c[2]),this}let s=eJ.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&&I2[s])&&(o=o.substr(2),this.slashes=!0)),!I2[s]&&(i||s&&!R2[s])){let c=-1;for(let m=0;m<D2.length;m++)r=o.indexOf(D2[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<M2.length;m++)r=o.indexOf(M2[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(O2)){let C="";for(let _=0,S=y.length;_<S;_++)y.charCodeAt(_)>127?C+="x":C+=y[_];if(!C.match(O2)){const _=m.slice(0,v),S=m.slice(v+1),A=y.match(aJ);A&&(_.push(A[1]),S.unshift(A[2])),S.length&&(o=S.join(".")+o),this.hostname=_.join(".");break}}}}this.hostname.length>sJ&&(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),R2[n]&&this.hostname&&!this.pathname&&(this.pathname=""),this};$p.prototype.parseHost=function(t){let e=tJ.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:Dc,encode:cf,format:_y,parse:Cy},Symbol.toStringTag,{value:"Module"})),XT=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,QT=/[\0-\x1F\x7F-\x9F]/,cJ=/[\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]/,Sy=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\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]/,$T=/[\$\+<->\^`\|~\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]/,e4=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,uJ=Object.freeze(Object.defineProperty({__proto__:null,Any:XT,Cc:QT,Cf:cJ,P:Sy,S:$T,Z:e4},Symbol.toStringTag,{value:"Module"})),dJ=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))),fJ=new Uint16Array("Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map(t=>t.charCodeAt(0)));var b0;const hJ=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]]),pJ=(b0=String.fromCodePoint)!==null&&b0!==void 0?b0: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 mJ(t){var e;return t>=55296&&t<=57343||t>1114111?65533:(e=hJ.get(t))!==null&&e!==void 0?e:t}var Gn;(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"})(Gn||(Gn={}));const gJ=32;var zs;(function(t){t[t.VALUE_LENGTH=49152]="VALUE_LENGTH",t[t.BRANCH_LENGTH=16256]="BRANCH_LENGTH",t[t.JUMP_TABLE=127]="JUMP_TABLE"})(zs||(zs={}));function Eb(t){return t>=Gn.ZERO&&t<=Gn.NINE}function vJ(t){return t>=Gn.UPPER_A&&t<=Gn.UPPER_F||t>=Gn.LOWER_A&&t<=Gn.LOWER_F}function bJ(t){return t>=Gn.UPPER_A&&t<=Gn.UPPER_Z||t>=Gn.LOWER_A&&t<=Gn.LOWER_Z||Eb(t)}function yJ(t){return t===Gn.EQUALS||bJ(t)}var jn;(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"})(jn||(jn={}));var Ts;(function(t){t[t.Legacy=0]="Legacy",t[t.Strict=1]="Strict",t[t.Attribute=2]="Attribute"})(Ts||(Ts={}));class wJ{constructor(e,n,r){this.decodeTree=e,this.emitCodePoint=n,this.errors=r,this.state=jn.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Ts.Strict}startEntity(e){this.decodeMode=e,this.state=jn.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,n){switch(this.state){case jn.EntityStart:return e.charCodeAt(n)===Gn.NUM?(this.state=jn.NumericStart,this.consumed+=1,this.stateNumericStart(e,n+1)):(this.state=jn.NamedEntity,this.stateNamedEntity(e,n));case jn.NumericStart:return this.stateNumericStart(e,n);case jn.NumericDecimal:return this.stateNumericDecimal(e,n);case jn.NumericHex:return this.stateNumericHex(e,n);case jn.NamedEntity:return this.stateNamedEntity(e,n)}}stateNumericStart(e,n){return n>=e.length?-1:(e.charCodeAt(n)|gJ)===Gn.LOWER_X?(this.state=jn.NumericHex,this.consumed+=1,this.stateNumericHex(e,n+1)):(this.state=jn.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(Eb(i)||vJ(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(Eb(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===Gn.SEMI)this.consumed+=1;else if(this.decodeMode===Ts.Strict)return 0;return this.emitCodePoint(mJ(this.result),this.consumed),this.errors&&(e!==Gn.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&zs.VALUE_LENGTH)>>14;for(;n<e.length;n++,this.excess++){const s=e.charCodeAt(n);if(this.treeIndex=kJ(r,i,this.treeIndex+Math.max(1,o),s),this.treeIndex<0)return this.result===0||this.decodeMode===Ts.Attribute&&(o===0||yJ(s))?0:this.emitNotTerminatedNamedEntity();if(i=r[this.treeIndex],o=(i&zs.VALUE_LENGTH)>>14,o!==0){if(s===Gn.SEMI)return this.emitNamedEntityData(this.treeIndex,o,this.consumed+this.excess);this.decodeMode!==Ts.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]&zs.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]&~zs.VALUE_LENGTH:i[e+1],r),n===3&&this.emitCodePoint(i[e+2],r),r}end(){var e;switch(this.state){case jn.NamedEntity:return this.result!==0&&(this.decodeMode!==Ts.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case jn.NumericDecimal:return this.emitNumericEntity(0,2);case jn.NumericHex:return this.emitNumericEntity(0,3);case jn.NumericStart:return(e=this.errors)===null||e===void 0||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case jn.EntityStart:return 0}}}function t4(t){let e="";const n=new wJ(t,r=>e+=pJ(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 kJ(t,e,n,r){const i=(e&zs.BRANCH_LENGTH)>>7,o=e&zs.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 xJ=t4(dJ);t4(fJ);function n4(t,e=Ts.Legacy){return xJ(t,e)}function _J(t){return Object.prototype.toString.call(t)}function Ey(t){return _J(t)==="[object String]"}const CJ=Object.prototype.hasOwnProperty;function SJ(t,e){return CJ.call(t,e)}function tg(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 r4(t,e,n){return[].concat(t.slice(0,e),n,t.slice(e+1))}function Ay(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 em(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 i4=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,EJ=/&([a-z#][a-z0-9]{1,31});/gi,AJ=new RegExp(i4.source+"|"+EJ.source,"gi"),TJ=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function MJ(t,e){if(e.charCodeAt(0)===35&&TJ.test(e)){const r=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return Ay(r)?em(r):t}const n=n4(t);return n!==t?n:t}function DJ(t){return t.indexOf("\\")<0?t:t.replace(i4,"$1")}function Oc(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(AJ,function(e,n,r){return n||MJ(e,r)})}const OJ=/[&<>"]/,IJ=/[&<>"]/g,RJ={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function NJ(t){return RJ[t]}function ta(t){return OJ.test(t)?t.replace(IJ,NJ):t}const PJ=/[.?*+^$[\]\\(){}|-]/g;function LJ(t){return t.replace(PJ,"\\$&")}function sn(t){switch(t){case 9:case 32:return!0}return!1}function Sd(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 Ed(t){return Sy.test(t)||$T.test(t)}function Ad(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 ng(t){return t=t.trim().replace(/\s+/g," "),"ẞ".toLowerCase()==="Ṿ"&&(t=t.replace(/ẞ/g,"ß")),t.toLowerCase().toUpperCase()}const FJ={mdurl:lJ,ucmicro:uJ},zJ=Object.freeze(Object.defineProperty({__proto__:null,arrayReplaceAt:r4,assign:tg,escapeHtml:ta,escapeRE:LJ,fromCodePoint:em,has:SJ,isMdAsciiPunct:Ad,isPunctChar:Ed,isSpace:sn,isString:Ey,isValidEntityCode:Ay,isWhiteSpace:Sd,lib:FJ,normalizeReference:ng,unescapeAll:Oc,unescapeMd:DJ},Symbol.toStringTag,{value:"Module"}));function BJ(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 HJ(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=Oc(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=Oc(t.slice(e,i)),o.pos=i,o.ok=!0),o}function VJ(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+=Oc(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+=Oc(t.slice(e,o)),s}const UJ=Object.freeze(Object.defineProperty({__proto__:null,parseLinkDestination:HJ,parseLinkLabel:BJ,parseLinkTitle:VJ},Symbol.toStringTag,{value:"Module"})),Mo={};Mo.code_inline=function(t,e,n,r,i){const o=t[e];return"<code"+i.renderAttrs(o)+">"+ta(o.content)+"</code>"};Mo.code_block=function(t,e,n,r,i){const o=t[e];return"<pre"+i.renderAttrs(o)+"><code>"+ta(t[e].content)+`</code></pre>
222
- `};Mo.fence=function(t,e,n,r,i){const o=t[e],s=o.info?Oc(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)||ta(o.content):c=ta(o.content),c.indexOf("<pre")===0)return c+`
223
- `;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>
224
- `}return`<pre><code${i.renderAttrs(o)}>${c}</code></pre>
225
- `};Mo.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)};Mo.hardbreak=function(t,e,n){return n.xhtmlOut?`<br />
226
- `:`<br>
227
- `};Mo.softbreak=function(t,e,n){return n.breaks?n.xhtmlOut?`<br />
228
- `:`<br>
229
- `:`
230
- `};Mo.text=function(t,e){return ta(t[e].content)};Mo.html_block=function(t,e){return t[e].content};Mo.html_inline=function(t,e){return t[e].content};function Gc(){this.rules=tg({},Mo)}Gc.prototype.renderAttrs=function(e){let n,r,i;if(!e.attrs)return"";for(i="",n=0,r=e.attrs.length;n<r;n++)i+=" "+ta(e.attrs[n][0])+'="'+ta(e.attrs[n][1])+'"';return i};Gc.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+=`
231
- `),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?`>
232
- `:">",o};Gc.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};Gc.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+=`
233
- `;break}return r};Gc.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 jr(){this.__rules__=[],this.__cache__=null}jr.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===t)return e;return-1};jr.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))})})};jr.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};jr.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};jr.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};jr.prototype.push=function(t,e,n){const r=n||{};this.__rules__.push({name:t,enabled:!0,fn:e,alt:r.alt||[]}),this.__cache__=null};jr.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};jr.prototype.enableOnly=function(t,e){Array.isArray(t)||(t=[t]),this.__rules__.forEach(function(n){n.enabled=!1}),this.enable(t,e)};jr.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};jr.prototype.getRules=function(t){return this.__cache__===null&&this.__compile__(),this.__cache__[t]||[]};function $i(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}$i.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};$i.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};$i.prototype.attrSet=function(e,n){const r=this.attrIndex(e),i=[e,n];r<0?this.attrPush(i):this.attrs[r]=i};$i.prototype.attrGet=function(e){const n=this.attrIndex(e);let r=null;return n>=0&&(r=this.attrs[n][1]),r};$i.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 o4(t,e,n){this.src=t,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=e}o4.prototype.Token=$i;const jJ=/\r\n?|\n/g,qJ=/\0/g;function WJ(t){let e;e=t.src.replace(jJ,`
234
- `),e=e.replace(qJ,"�"),t.src=e}function KJ(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 GJ(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 ZJ(t){return/^<a[>\s]/i.test(t)}function YJ(t){return/^<\/a\s*>/i.test(t)}function JJ(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"&&(ZJ(a.content)&&o>0&&o--,YJ(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=r4(i,s,d)}}}}const s4=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,XJ=/\((c|tm|r)\)/i,QJ=/\((c|tm|r)\)/ig,$J={c:"©",r:"®",tm:"™"};function eX(t,e){return $J[e.toLowerCase()]}function tX(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(QJ,eX)),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function nX(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 rX(t){let e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)t.tokens[e].type==="inline"&&(XJ.test(t.tokens[e].content)&&tX(t.tokens[e].children),s4.test(t.tokens[e].content)&&nX(t.tokens[e].children))}const iX=/['"]/,N2=/['"]/g,P2="’";function Kf(t,e,n){return t.slice(0,e)+n+t.slice(e+1)}function oX(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;){N2.lastIndex=l;const d=N2.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=Ad(m)||Ed(String.fromCharCode(m)),y=Ad(v)||Ed(String.fromCharCode(v)),C=Sd(m),_=Sd(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=Kf(o.content,d.index,P2));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=Kf(o.content,d.index,O),t[S.token].content=Kf(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=Kf(o.content,d.index,P2))}}}function sX(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)||oX(t.tokens[e].children,t)}function aX(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 y0=[["normalize",WJ],["block",KJ],["inline",GJ],["linkify",JJ],["replacements",rX],["smartquotes",sX],["text_join",aX]];function Ty(){this.ruler=new jr;for(let t=0;t<y0.length;t++)this.ruler.push(y0[t][0],y0[t][1])}Ty.prototype.process=function(t){const e=this.ruler.getRules("");for(let n=0,r=e.length;n<r;n++)e[n](t)};Ty.prototype.State=o4;function Do(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(sn(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}Do.prototype.push=function(t,e,n){const r=new $i(t,e,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r};Do.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};Do.prototype.skipEmptyLines=function(e){for(let n=this.lineMax;e<n&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};Do.prototype.skipSpaces=function(e){for(let n=this.src.length;e<n;e++){const r=this.src.charCodeAt(e);if(!sn(r))break}return e};Do.prototype.skipSpacesBack=function(e,n){if(e<=n)return e;for(;e>n;)if(!sn(this.src.charCodeAt(--e)))return e+1;return e};Do.prototype.skipChars=function(e,n){for(let r=this.src.length;e<r&&this.src.charCodeAt(e)===n;e++);return e};Do.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};Do.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(sn(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("")};Do.prototype.Token=$i;const lX=65536;function w0(t,e){const n=t.bMarks[e]+t.tShift[e],r=t.eMarks[e];return t.src.slice(n,r)}function L2(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 cX(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&&!sn(a)||s===45&&sn(a))return!1;for(;o<t.eMarks[i];){const S=t.src.charCodeAt(o);if(S!==124&&S!==45&&S!==58&&!sn(S))return!1;o++}let l=w0(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=w0(t,e).trim(),l.indexOf("|")===-1||t.sCount[e]-t.blkIndent>=4)return!1;c=L2(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=w0(t,i).trim(),!l)||t.sCount[i]-t.blkIndent>=4||(c=L2(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 uX(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)+`
235
- `,o.map=[e,t.line],!0}function dX(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 fX(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(sn(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 hX(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&&!sn(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 F2(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(!sn(o))return-1}return r}function z2(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),!sn(o))?-1:i}function pX(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 mX(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=z2(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=F2(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],B=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]=B,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,he=C.length;ie<he;ie++)if(C[ie](t,l,n,!0)){Q=!0;break}if(Q)break;if(f){if(p=z2(t,l),p<0)break;s=t.bMarks[l]+t.tShift[l]}else if(p=F2(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&&pX(t,v),!0}function gX(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(!sn(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(!sn(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(!sn(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(!sn(C))break;i++}if(i<o&&l.charCodeAt(i)!==10)return!1;const y=ng(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 vX=["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"],bX="[a-zA-Z_:][a-zA-Z0-9:._-]*",yX="[^\"'=<>`\\x00-\\x20]+",wX="'[^']*'",kX='"[^"]*"',xX="(?:"+yX+"|"+wX+"|"+kX+")",_X="(?:\\s+"+bX+"(?:\\s*=\\s*"+xX+")?)",a4="<[A-Za-z][A-Za-z0-9\\-]*"+_X+"*\\s*\\/?>",l4="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",CX="<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->",SX="<[?][\\s\\S]*?[?]>",EX="<![A-Za-z][^>]*>",AX="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",TX=new RegExp("^(?:"+a4+"|"+l4+"|"+CX+"|"+SX+"|"+EX+"|"+AX+")"),MX=new RegExp("^(?:"+a4+"|"+l4+")"),wl=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+vX.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(MX.source+"\\s*$"),/^$/,!1]];function DX(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<wl.length&&!wl[a][0].test(s);a++);if(a===wl.length)return!1;if(r)return wl[a][2];let l=e+1;if(!wl[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),wl[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 OX(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&&!sn(s))return!1;if(r)return!0;o=t.skipSpacesBack(o,i);const l=t.skipCharsBack(o,35,i);l>i&&sn(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 IX(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 RX(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 Gf=[["table",cX,["paragraph","reference"]],["code",uX],["fence",dX,["paragraph","reference","blockquote","list"]],["blockquote",fX,["paragraph","reference","blockquote","list"]],["hr",hX,["paragraph","reference","blockquote","list"]],["list",mX,["paragraph","reference","blockquote"]],["reference",gX],["html_block",DX,["paragraph","reference","blockquote"]],["heading",OX,["paragraph","reference","blockquote"]],["lheading",IX],["paragraph",RX]];function rg(){this.ruler=new jr;for(let t=0;t<Gf.length;t++)this.ruler.push(Gf[t][0],Gf[t][1],{alt:(Gf[t][2]||[]).slice()})}rg.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)}};rg.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)};rg.prototype.State=Do;function uf(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}uf.prototype.pushPending=function(){const t=new $i("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t};uf.prototype.push=function(t,e,n){this.pending&&this.pushPending();const r=new $i(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};uf.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=Ad(i)||Ed(String.fromCharCode(i)),c=Ad(a)||Ed(String.fromCharCode(a)),d=Sd(i),f=Sd(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}};uf.prototype.Token=$i;function NX(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 PX(t,e){let n=t.pos;for(;n<t.posMax&&!NX(t.src.charCodeAt(n));)n++;return n===t.pos?!1:(e||(t.pending+=t.src.slice(t.pos,n)),t.pos=n,!0)}const LX=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function FX(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(LX);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 zX(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&&sn(t.src.charCodeAt(n));)n++;return t.pos=n,!0}const My=[];for(let t=0;t<256;t++)My.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t){My[t.charCodeAt(0)]=1});function BX(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),!!sn(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&&My[i]!==0?a.content=o:a.content=s,a.markup=s,a.info="escape"}return t.pos=n+1,!0}function HX(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 VX(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 B2(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 UX(t){const e=t.tokens_meta,n=t.tokens_meta.length;B2(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&B2(t,e[r].delimiters)}const c4={tokenize:VX,postProcess:UX};function jX(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 H2(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 qX(t){const e=t.tokens_meta,n=t.tokens_meta.length;H2(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&H2(t,e[r].delimiters)}const u4={tokenize:jX,postProcess:qX};function WX(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),!(!sn(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),!(!sn(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),!(!sn(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[ng(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 KX(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),!(!sn(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),!(!sn(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),!(!sn(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[ng(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 GX=/^([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])?)*)$/,ZX=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function YX(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(ZX.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(GX.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 JX(t){return/^<a[>\s]/i.test(t)}function XX(t){return/^<\/a\s*>/i.test(t)}function QX(t){const e=t|32;return e>=97&&e<=122}function $X(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&&!QX(i))return!1;const o=t.src.slice(r).match(TX);if(!o)return!1;if(!e){const s=t.push("html_inline","",0);s.content=o[0],JX(s.content)&&t.linkLevel++,XX(s.content)&&t.linkLevel--}return t.pos+=o[0].length,!0}const eQ=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,tQ=/^&([a-z][a-z0-9]{1,31});/i;function nQ(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(eQ);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=Ay(s)?em(s):em(65533),a.markup=o[0],a.info="entity"}return t.pos+=o[0].length,!0}}else{const o=t.src.slice(n).match(tQ);if(o){const s=n4(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 V2(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 rQ(t){const e=t.tokens_meta,n=t.tokens_meta.length;V2(t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&V2(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 k0=[["text",PX],["linkify",FX],["newline",zX],["escape",BX],["backticks",HX],["strikethrough",c4.tokenize],["emphasis",u4.tokenize],["link",WX],["image",KX],["autolink",YX],["html_inline",$X],["entity",nQ]],x0=[["balance_pairs",rQ],["strikethrough",c4.postProcess],["emphasis",u4.postProcess],["fragments_join",iQ]];function df(){this.ruler=new jr;for(let t=0;t<k0.length;t++)this.ruler.push(k0[t][0],k0[t][1]);this.ruler2=new jr;for(let t=0;t<x0.length;t++)this.ruler2.push(x0[t][0],x0[t][1])}df.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};df.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()};df.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)};df.prototype.State=uf;function oQ(t){const e={};t=t||{},e.src_Any=XT.source,e.src_Cc=QT.source,e.src_Z=e4.source,e.src_P=Sy.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 Ab(t){return Array.prototype.slice.call(arguments,1).forEach(function(n){n&&Object.keys(n).forEach(function(r){t[r]=n[r]})}),t}function ig(t){return Object.prototype.toString.call(t)}function sQ(t){return ig(t)==="[object String]"}function aQ(t){return ig(t)==="[object Object]"}function lQ(t){return ig(t)==="[object RegExp]"}function U2(t){return ig(t)==="[object Function]"}function cQ(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const d4={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function uQ(t){return Object.keys(t||{}).reduce(function(e,n){return e||d4.hasOwnProperty(n)},!1)}const dQ={"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}}},fQ="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]",hQ="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function pQ(t){t.__index__=-1,t.__text_cache__=""}function mQ(t){return function(e,n){const r=e.slice(n);return t.test(r)?r.match(t)[0].length:0}}function j2(){return function(t,e){e.normalize(t)}}function tm(t){const e=t.re=oQ(t.__opts__),n=t.__tlds__.slice();t.onCompile(),t.__tlds_replaced__||n.push(fQ),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,aQ(l)){lQ(l.validate)?c.validate=mQ(l.validate):U2(l.validate)?c.validate=l.validate:o(a,l),U2(l.normalize)?c.normalize=l.normalize:l.normalize?o(a,l):c.normalize=j2();return}if(sQ(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:j2()};const s=Object.keys(t.__compiled__).filter(function(a){return a.length>0&&t.__compiled__[a]}).map(cQ).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"),pQ(t)}function gQ(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 Tb(t,e){const n=new gQ(t,e);return t.__compiled__[n.schema].normalize(n,t),n}function ri(t,e){if(!(this instanceof ri))return new ri(t,e);e||uQ(t)&&(e=t,t={}),this.__opts__=Ab({},d4,e),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=Ab({},dQ,t),this.__compiled__={},this.__tlds__=hQ,this.__tlds_replaced__=!1,this.re={},tm(this)}ri.prototype.add=function(e,n){return this.__schemas__[e]=n,tm(this),this};ri.prototype.set=function(e){return this.__opts__=Ab(this.__opts__,e),this};ri.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};ri.prototype.pretest=function(e){return this.re.pretest.test(e)};ri.prototype.testSchemaAt=function(e,n,r){return this.__compiled__[n.toLowerCase()]?this.__compiled__[n.toLowerCase()].validate(e,r,this):0};ri.prototype.match=function(e){const n=[];let r=0;this.__index__>=0&&this.__text_cache__===e&&(n.push(Tb(this,r)),r=this.__last_index__);let i=r?e.slice(r):e;for(;this.test(i);)n.push(Tb(this,r)),i=i.slice(this.__last_index__),r+=this.__last_index__;return n.length?n:null};ri.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,Tb(this,0)):null};ri.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(),tm(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,tm(this),this)};ri.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url="mailto:"+e.url)};ri.prototype.onCompile=function(){};const Yl=2147483647,fo=36,Dy=1,Td=26,vQ=38,bQ=700,f4=72,h4=128,p4="-",yQ=/^xn--/,wQ=/[^\0-\x7F]/,kQ=/[\x2E\u3002\uFF0E\uFF61]/g,xQ={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_0=fo-Dy,ho=Math.floor,C0=String.fromCharCode;function _s(t){throw new RangeError(xQ[t])}function _Q(t,e){const n=[];let r=t.length;for(;r--;)n[r]=e(t[r]);return n}function m4(t,e){const n=t.split("@");let r="";n.length>1&&(r=n[0]+"@",t=n[1]),t=t.replace(kQ,".");const i=t.split("."),o=_Q(i,e).join(".");return r+o}function g4(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 CQ=t=>String.fromCodePoint(...t),SQ=function(t){return t>=48&&t<58?26+(t-48):t>=65&&t<91?t-65:t>=97&&t<123?t-97:fo},q2=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)},v4=function(t,e,n){let r=0;for(t=n?ho(t/bQ):t>>1,t+=ho(t/e);t>_0*Td>>1;r+=fo)t=ho(t/_0);return ho(r+(_0+1)*t/(t+vQ))},b4=function(t){const e=[],n=t.length;let r=0,i=h4,o=f4,s=t.lastIndexOf(p4);s<0&&(s=0);for(let a=0;a<s;++a)t.charCodeAt(a)>=128&&_s("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=fo;;f+=fo){a>=n&&_s("invalid-input");const h=SQ(t.charCodeAt(a++));h>=fo&&_s("invalid-input"),h>ho((Yl-r)/d)&&_s("overflow"),r+=h*d;const p=f<=o?Dy:f>=o+Td?Td:f-o;if(h<p)break;const m=fo-p;d>ho(Yl/m)&&_s("overflow"),d*=m}const c=e.length+1;o=v4(r-l,c,l==0),ho(r/c)>Yl-i&&_s("overflow"),i+=ho(r/c),r%=c,e.splice(r++,0,i)}return String.fromCodePoint(...e)},y4=function(t){const e=[];t=g4(t);const n=t.length;let r=h4,i=0,o=f4;for(const l of t)l<128&&e.push(C0(l));const s=e.length;let a=s;for(s&&e.push(p4);a<n;){let l=Yl;for(const d of t)d>=r&&d<l&&(l=d);const c=a+1;l-r>ho((Yl-i)/c)&&_s("overflow"),i+=(l-r)*c,r=l;for(const d of t)if(d<r&&++i>Yl&&_s("overflow"),d===r){let f=i;for(let h=fo;;h+=fo){const p=h<=o?Dy:h>=o+Td?Td:h-o;if(f<p)break;const m=f-p,v=fo-p;e.push(C0(q2(p+m%v,0))),f=ho(m/v)}e.push(C0(q2(f,0))),o=v4(i,c,a===s),i=0,++a}++i,++r}return e.join("")},EQ=function(t){return m4(t,function(e){return yQ.test(e)?b4(e.slice(4).toLowerCase()):e})},AQ=function(t){return m4(t,function(e){return wQ.test(e)?"xn--"+y4(e):e})},w4={version:"2.3.1",ucs2:{decode:g4,encode:CQ},decode:b4,encode:y4,toASCII:AQ,toUnicode:EQ},TQ={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},MQ={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"]}}},DQ={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"]}}},OQ={default:TQ,zero:MQ,commonmark:DQ},IQ=/^(vbscript|javascript|file|data):/,RQ=/^data:image\/(gif|png|jpeg|webp);/;function NQ(t){const e=t.trim().toLowerCase();return IQ.test(e)?RQ.test(e):!0}const k4=["http:","https:","mailto:"];function PQ(t){const e=Cy(t,!0);if(e.hostname&&(!e.protocol||k4.indexOf(e.protocol)>=0))try{e.hostname=w4.toASCII(e.hostname)}catch{}return cf(_y(e))}function LQ(t){const e=Cy(t,!0);if(e.hostname&&(!e.protocol||k4.indexOf(e.protocol)>=0))try{e.hostname=w4.toUnicode(e.hostname)}catch{}return Dc(_y(e),Dc.defaultChars+"%")}function ii(t,e){if(!(this instanceof ii))return new ii(t,e);e||Ey(t)||(e=t||{},t="default"),this.inline=new df,this.block=new rg,this.core=new Ty,this.renderer=new Gc,this.linkify=new ri,this.validateLink=NQ,this.normalizeLink=PQ,this.normalizeLinkText=LQ,this.utils=zJ,this.helpers=tg({},UJ),this.options={},this.configure(t),e&&this.set(e)}ii.prototype.set=function(t){return tg(this.options,t),this};ii.prototype.configure=function(t){const e=this;if(Ey(t)){const n=t;if(t=OQ[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};ii.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};ii.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};ii.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this};ii.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};ii.prototype.render=function(t,e){return e=e||{},this.renderer.render(this.parse(t,e),this.options,e)};ii.prototype.parseInline=function(t,e){const n=new this.core.State(t,this,e);return n.inlineMode=!0,this.core.process(n),n.tokens};ii.prototype.renderInline=function(t,e){return e=e||{},this.renderer.render(this.parseInline(t,e),this.options,e)};const FQ=new $b({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 zQ(t,e){if(t.isText&&e.isText&&Jt.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}class BQ{constructor(e,n){this.schema=e,this.tokenHandlers=n,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:Jt.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=zQ(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:Jt.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}}function ou(t,e,n,r){return t.getAttrs?t.getAttrs(e,n,r):t.attrs instanceof Function?t.attrs(e):t.attrs}function S0(t,e){return t.noCloseToken||e=="code_inline"||e=="code_block"||e=="fence"}function W2(t){return t[t.length-1]==`
236
- `?t.slice(0,t.length-1):t}function E0(){}function HQ(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);S0(i,r)?n[r]=(s,a,l,c)=>{s.openNode(o,ou(i,a,l,c)),s.addText(W2(a.content)),s.closeNode()}:(n[r+"_open"]=(s,a,l,c)=>s.openNode(o,ou(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,ou(i,a,l,c))}else if(i.mark){let o=t.marks[i.mark];S0(i,r)?n[r]=(s,a,l,c)=>{s.openMark(o.create(ou(i,a,l,c))),s.addText(W2(a.content)),s.closeMark(o)}:(n[r+"_open"]=(s,a,l,c)=>s.openMark(o.create(ou(i,a,l,c))),n[r+"_close"]=s=>s.closeMark(o))}else if(i.ignore)S0(i,r)?n[r]=E0:(n[r+"_open"]=E0,n[r+"_close"]=E0);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 x4{constructor(e,n,r){this.schema=e,this.tokenizer=n,this.tokens=r,this.tokenHandlers=HQ(e,r)}parse(e,n={}){let r=new BQ(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 K2(t,e){for(;++e<t.length;)if(t[e].type!="list_item_open")return t[e].hidden;return!1}new x4(FQ,ii("commonmark",{html:!1}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,n)=>({tight:K2(e,n)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,n)=>({order:+t.attrGet("start")||1,tight:K2(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 VQ(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:jT(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 UQ(t){const e=ii("commonmark",{html:!1}).enable(["strikethrough","linkify"]);return new x4(t,e,VQ(t))}function jQ(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 qQ(t,e){if(!jQ(t))return null;let n;try{const i=UQ(e).parse(t);if(!i)return null;n=i}catch{return null}return n.childCount===0?null:Ge.maxOpen(n.content)}var WQ=T('<div role="presentation" data-testid="editor-root"></div>');function KQ(t,e){et(e,!0);const n=new Set([...qd].filter(p=>p!==".docx")),r=WK.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=L(null),s=null;const a=N(()=>e.format==="docx");me(()=>{if(e.ydoc,e.provider,!s)return;const p=new EW({element:s,extensions:[XZ.configure({history:!1,listItem:!1}),RY,bK.configure({multicolor:!0}),r.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),wK.configure({allowBase64:!0}),KK.configure({placeholder:"Start typing…"}),YG.configure({resizable:!0}),QG,JG,XG,PY,LY,pK.configure({document:e.ydoc}),mK.configure({provider:e.provider,user:{name:z1(),color:"var(--tandem-warning)"}}),lY.configure({ydoc:e.ydoc}),pY.configure({ydoc:e.ydoc}),DY.configure({filePath:Mt(()=>e.currentFilePath??null)}),vY.configure({ydoc:e.ydoc}),bY.configure({ydoc:e.ydoc}),XY.configure({onOpenChange:e.onSlashCommandMenuChange}),xY,zY],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 _=qQ(v,C.state.schema);if(_)return _}return VT(v,C.state.schema,g.marks())}},editable:Mt(()=>!e.readOnly),autofocus:Mt(()=>!e.readOnly)});b(o,p,!0),Mt(()=>{var v;return(v=e.onEditorReady)==null?void 0:v.call(e,p)});const m=aY(p,{openHref:v=>{c(v)}});return()=>{Mt(()=>{var v;return(v=e.onEditorReady)==null?void 0:v.call(e,null)}),m(),p.destroy(),u(o)===p&&b(o,null)}});let l;me(()=>{const p=u(o);if(!p)return;const m=e.readOnly;l!==m&&(l=m,p.setEditable(!m))}),me(()=>{const p=u(o);if(p)return WE(m=>p.commands.updateUser({name:m}))}),me(()=>{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(UT(p)){window.open(p,"_blank","noopener,noreferrer");return}if(e.currentFilePath){const m=i(p,e.currentFilePath);if(m){const v=await ls(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=WQ();let h;Ot(f,p=>s=p,()=>s),W(()=>h=vt(f,1,"",null,h,{"tandem-paged":u(a)})),P("click",f,d),x(t,f),tt()}ut(["click"]);var GQ=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>'),ZQ=T('<div class="fr-error svelte-1q9bff2" role="alert"> </div>'),YQ=T('<div class="fr-warning svelte-1q9bff2" role="status"> </div>'),JQ=T('<div class="fr-xdoc-status svelte-1q9bff2">Searching…</div>'),XQ=T('<div class="fr-xdoc-status svelte-1q9bff2">No matches in open tabs</div>'),QQ=T('<div class="fr-xdoc-snip svelte-1q9bff2"> </div>'),$Q=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>'),e$=T('<div data-testid="find-cross-doc-results" class="fr-xdoc svelte-1q9bff2"><!></div>'),t$=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 n$(t,e){et(e,!0);let n=Ye(e,"tabs",19,()=>[]),r=L("doc"),i=L(at([])),o=L(!1);me(()=>{n().length<=1&&u(r)==="tabs"&&(b(r,"doc"),b(i,[],!0),b(o,!1))});function s(ae){const ke=ae.getXmlFragment("default"),le=[];function be(Re){if(Re instanceof In)le.push(Re.toString());else{for(let $=0;$<Re.length;$++){const q=Re.get($);(q instanceof In||q instanceof gn)&&be(q)}Re instanceof gn&&Re.nodeName!=="text"&&le.push(" ")}}return be(ke),le.join("")}function a(ae,ke,le){const be=s(ae),Re=le?ke:ke.toLowerCase(),$=le?be:be.toLowerCase(),q=[];let H=0,ne=0;for(;(ne=$.indexOf(Re,ne))!==-1;){if(H++,q.length<3){const te=Math.max(0,ne-30),Z=Math.min(be.length,ne+Re.length+30),ge=be.slice(te,Z).replace(/\s+/g," ").trim();q.push((te>0?"…":"")+ge+(Z<be.length?"…":""))}ne+=Re.length}return{count:H,snippets:q}}let l;Dn(()=>clearTimeout(l));function c(ae,ke){if(clearTimeout(l),!ae){b(i,[],!0),b(o,!1);return}b(o,!0),l=setTimeout(()=>{const le=[];for(const be of n()){if(!be.ydoc)continue;const{count:Re,snippets:$}=a(be.ydoc,ae,ke);Re>0&&le.push({tabId:be.id,fileName:be.fileName,count:Re,snippets:$})}b(i,le,!0),b(o,!1)},300)}let d=L(""),f=L(""),h=L(!1),p=L(!1),m=L(!1),v=L(null),g=L(!1),y=L(null),C=L(null),_=L(0);const S=N(()=>(u(_),e.editor?Zl(e.editor.state):void 0)),A=N(()=>{var ae;return((ae=u(S))==null?void 0:ae.matches.length)??0}),O=N(()=>{var ae;return((ae=u(S))==null?void 0:ae.activeIndex)??-1});let E=L(null);me(()=>{var ae;e.open&&((ae=u(E))==null||ae.focus())});let M=!1;me(()=>{const ae=e.open&&!M;M=e.open,!(!ae||!e.forceScope)&&(e.forceScope==="tabs"&&n().length>1?(b(r,"tabs"),c(u(d),u(h))):b(r,"doc"))}),me(()=>{const ae=e.editor;if(!ae||ae.isDestroyed)return;const ke=()=>ju(_);return ae.on("update",ke),ae.on("selectionUpdate",ke),()=>{ae.isDestroyed||(ae.off("update",ke),ae.off("selectionUpdate",ke))}});function R(){if(u(r)==="tabs"){c(u(d),u(h));return}const ae=e.editor;if(!ae||!u(d)){b(v,null),ae==null||ae.commands.findClose();return}if(u(m))try{new RegExp(u(d)),b(v,null)}catch(le){b(v,le instanceof Error?le.message:"Invalid regex",!0);return}else b(v,null);const ke={query:u(d),caseSensitive:u(h),wholeWord:u(p),regexMode:u(m)};ae.commands.find(ke)}function D(ae){var ke;b(r,ae,!0),ae==="tabs"?((ke=e.editor)==null||ke.commands.findClose(),c(u(d),u(h))):(b(i,[],!0),clearTimeout(l),R())}function I(ae){var ke,le;if(ae.key==="Enter"){ae.preventDefault(),ae.shiftKey?(ke=e.editor)==null||ke.commands.findPrev():(le=e.editor)==null||le.commands.findNext();return}ae.key==="Escape"&&B()}function B(){var ae;(ae=e.editor)==null||ae.commands.findClose(),e.onClose()}async function z(){const ae=e.editor;if(!ae||!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:le,partial:be}=await CY(ae.view,u(f),(Re,$)=>{b(y,{replaced:Re,total:$},!0)});b(y,null),b(g,!1),be&&b(C,`Replaced ${le} of ${ke}; re-run to continue`)}var Q=St(),ie=Ae(Q);{var he=ae=>{var ke=t$(),le=w(ke);{var be=ce=>{var Ie=GQ(),V=w(Ie);let ee;var we=k(V,2);let Ve;W(()=>{ee=vt(V,1,"fr-scope-pill svelte-1q9bff2",null,ee,{on:u(r)==="doc"}),U(V,"aria-pressed",u(r)==="doc"),Ve=vt(we,1,"fr-scope-pill svelte-1q9bff2",null,Ve,{on:u(r)==="tabs"}),U(we,"aria-pressed",u(r)==="tabs")}),P("click",V,()=>D("doc")),P("click",we,()=>D("tabs")),x(ce,Ie)};j(le,ce=>{n().length>1&&ce(be)})}var Re=k(le,2),$=w(Re);let q;Ot($,ce=>b(E,ce),()=>u(E));var H=k($,2),ne=w(H);{var te=ce=>{var Ie=dr();W(()=>G(Ie,u(A)===0?"No matches":`${u(O)+1} / ${u(A)}`)),x(ce,Ie)};j(ne,ce=>{u(d)&&ce(te)})}var Z=k(H,2),ge=k(Z,2),De=k(ge,2),Ee=k(Re,2);{var de=ce=>{var Ie=ZQ(),V=w(Ie);W(()=>G(V,u(v))),x(ce,Ie)};j(Ee,ce=>{u(v)&&ce(de)})}var _e=k(Ee,2),J=w(_e),ye=w(J),Y=k(J,2),se=w(Y),Te=k(Y,2),Oe=w(Te),ze=k(_e,2),Xe=w(ze),ue=k(Xe,2),re=k(ue,2),pe=w(re);{var Ne=ce=>{var Ie=dr();W(()=>G(Ie,`${u(y).replaced??""}/${u(y).total??""}`)),x(ce,Ie)},xe=ce=>{var Ie=dr("All");x(ce,Ie)};j(pe,ce=>{u(g)&&u(y)?ce(Ne):ce(xe,-1)})}var Me=k(ze,2);{var Se=ce=>{var Ie=YQ(),V=w(Ie);W(()=>G(V,u(C))),x(ce,Ie)};j(Me,ce=>{u(C)&&ce(Se)})}var qe=k(Me,2);{var it=ce=>{var Ie=e$(),V=w(Ie);{var ee=Fe=>{var K=JQ();x(Fe,K)},we=Fe=>{var K=XQ();x(Fe,K)},Ve=Fe=>{var K=St(),fe=Ae(K);pt(fe,17,()=>u(i),cc,(Pe,Be)=>{var Ke=$Q(),We=w(Ke),Ue=w(We),nt=k(Ue),rt=w(nt),xt=k(We,2);pt(xt,17,()=>u(Be).snippets,cc,(qt,Je)=>{var Ct=QQ(),Nt=w(Ct);W(()=>G(Nt,u(Je))),x(qt,Ct)}),W(()=>{G(Ue,`${u(Be).fileName??""} `),G(rt,`(${u(Be).count??""} ${u(Be).count===1?"match":"matches"})`)}),x(Pe,Ke)}),x(Fe,K)};j(V,Fe=>{u(o)?Fe(ee):u(d)&&u(i).length===0?Fe(we,1):Fe(Ve,-1)})}x(ce,Ie)};j(qe,ce=>{u(r)==="tabs"&&ce(it)})}W(()=>{q=vt($,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),re.disabled=u(A)===0||u(g)||u(r)==="tabs",U(re,"title",u(r)==="tabs"?"Replace All is not available in Open tabs mode":void 0)}),P("keydown",ke,I),P("input",$,R),zr($,()=>u(d),ce=>b(d,ce)),P("click",Z,()=>{var ce;return(ce=e.editor)==null?void 0:ce.commands.findPrev()}),P("click",ge,()=>{var ce;return(ce=e.editor)==null?void 0:ce.commands.findNext()}),P("click",De,B),P("change",ye,R),sh(ye,()=>u(h),ce=>b(h,ce)),P("change",se,R),sh(se,()=>u(p),ce=>b(p,ce)),P("change",Oe,R),sh(Oe,()=>u(m),ce=>b(m,ce)),zr(Xe,()=>u(f),ce=>b(f,ce)),P("click",ue,()=>{e.editor&&(_Y(e.editor.view,u(f)),ju(_))}),P("click",re,z),x(ae,ke)};j(ie,ae=>{e.open&&ae(he)})}x(t,Q),tt()}ut(["keydown","click","input","change"]);var r$=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>'),o$=T('<div class="source-view-loading svelte-fwjuih">Loading source…</div>'),s$=T('<textarea class="source-view-textarea svelte-fwjuih" data-testid="source-view-textarea" spellcheck="false" autocomplete="off" autocapitalize="off" aria-label="Markdown source"></textarea>'),a$=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){et(e,!0);const n=Mt(()=>e.initialDraft);let r=L(""),i=L(""),o=L(!0),s=L(!1),a=L(null);const l=N(()=>!u(o)&&u(i)!==u(r));let c=L(0);me(()=>{const D=e.ydoc.getMap(Mi),I=()=>{b(c,D.size,!0)};return I(),D.observe(I),()=>D.unobserve(I)}),me(()=>{const D=e.documentId;let I=!1;return b(o,!0),b(a,null),(async()=>{try{const B=await fetch(`${Qt}${ZD}?documentId=${encodeURIComponent(D)}`);if(!B.ok){const Q=await B.json().catch(()=>({}));throw new Error(Q.message??B.statusText)}const z=await B.json();if(I)return;b(r,z.markdown??"",!0),b(i,n??u(r),!0)}catch(B){if(I)return;b(a,B instanceof Error?B.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(`${Qt}${YD}`,{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=a$(),g=w(v),y=w(g),C=k(y,4),_=k(g,2);{var S=D=>{var I=r$(),B=w(I);W(()=>G(B,`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$(),B=w(I);W(()=>G(B,u(a))),x(D,I)};j(A,D=>{u(a)&&D(O)})}var E=k(A,2);{var M=D=>{var I=o$();x(D,I)},R=D=>{var I=s$();P("input",I,f),P("keydown",I,p),zr(I,()=>u(i),B=>b(i,B)),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),tt()}ut(["click","input","keydown"]);function Ho(t,e){function n(r){t.contains(r.target)||e(r)}return document.addEventListener("mousedown",n),{destroy(){document.removeEventListener("mousedown",n)}}}var c$=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),u$=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
237
- marks. Toggle a type to hide its marks in the document; side-panel cards
238
- 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>`),d$=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 _4(t,e){et(e,!0);let n=L(!1),r=L(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=d$();let d;var f=w(c);let h;var p=k(f,4);Ot(p,g=>b(r,g),()=>u(r));var m=k(p,2);{var v=g=>{var y=u$(),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=B=>{var z=c$(),Q=k(Ae(z),2);P("click",Q,l),x(B,z)};j(D,B=>{e.onOpenSettings&&B(I)})}W(()=>{_=vt(C,1,"mi svelte-94a7fq",null,_,{on:e.showAuthorship}),U(C,"aria-checked",e.showAuthorship),A=vt(S,1,"mi svelte-94a7fq",null,A,{on:e.showComments}),U(S,"aria-checked",e.showComments),E=vt(O,1,"mi svelte-94a7fq",null,E,{on:e.showHighlights}),U(O,"aria-checked",e.showHighlights),R=vt(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)})}Ur(c,(g,y)=>Ho==null?void 0:Ho(g,y),()=>()=>b(n,!1)),W(()=>{d=vt(c,1,"split menu-wrap svelte-94a7fq",null,d,{open:u(n)}),h=vt(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),tt()}ut(["keydown","click"]);function Oy(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 f$(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 Li(t){return e=>{e.preventDefault(),t()}}function h$(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 p$(t,e){const n=e.trim();n?t.chain().focus().setLink({href:n}).run():t.isActive("link")&&t.chain().focus().unsetLink().run()}var m$=T('<button type="button"><!></button>');function Rr(t,e){const n=Ye(e,"disabled",3,!1),r=Ye(e,"active",3,!1),i=Ye(e,"style",3,""),o=N(()=>e.ariaLabel??(typeof e.label=="string"?e.label:void 0)),s=N(()=>u(o)??""),a=N(()=>n()&&e.disabledTitle?e.disabledTitle:e.shortcut?`${u(s)} (${e.shortcut})`:u(s));var l=m$();let c;var d=w(l);{var f=p=>{var m=St(),v=Ae(m);jd(v,()=>e.children),x(p,m)},h=p=>{var m=dr();W(()=>G(m,e.label)),x(p,m)};j(d,p=>{e.children?p(f):p(h,-1)})}W(()=>{c=vt(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),Le(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)}ut(["mousedown","click"]);var g$=rn('<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>'),v$=rn('<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>'),b$=T('<!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div>',1),y$=rn('<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>'),w$=T(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
239
- background: var(--tandem-surface); border: 1px solid var(--tandem-border);
240
- border-radius: var(--tandem-r-3); padding: 6px;
241
- display: flex; align-items: center; gap: 4px;
242
- 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;
243
- border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
244
- background: var(--tandem-surface); color: var(--tandem-fg);
245
- 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;
246
- border: 1px solid var(--tandem-accent-border); background: transparent;
247
- color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
248
- 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;
249
- border: 1px solid var(--tandem-border); background: transparent;
250
- color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),k$=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),x$=T('<button type="button" role="menuitemradio"> </button>'),_$=T(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
251
- background: var(--tandem-surface); border: 1px solid var(--tandem-border);
252
- border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
253
- gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),C$=rn('<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>'),S$=rn('<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>'),E$=rn('<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>'),A$=rn('<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>'),T$=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 C4(t,e){et(e,!0);const n=Ye(e,"disabled",3,!1),r=Ye(e,"variant",3,"bar"),i=N(()=>r()==="bar"),o=N(()=>r()==="bar"),s=[1,2,3],a={1:700,2:600,3:500};let l=L(0),c=L(!1),d=L(!1),f=L(""),h=L(null);me(()=>{const Y=e.editor;if(!Y||Y.isDestroyed)return;const se=()=>{Y.isDestroyed||ju(l)};return Y.on("transaction",se),()=>{Y.isDestroyed||Y.off("transaction",se)}}),me(()=>{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=N(()=>e.editor?e.editor.isEditable:!1),v=N(()=>!u(m)||!!n()),g=N(()=>(u(l),e.editor?go.getState(e.editor.state):null)),y=N(()=>{var Y,se;return!u(v)&&(((se=(Y=u(g))==null?void 0:Y.undoManager)==null?void 0:se.undoStack.length)??0)>0}),C=N(()=>{var Y,se;return!u(v)&&(((se=(Y=u(g))==null?void 0:Y.undoManager)==null?void 0:se.redoStack.length)??0)>0}),_=N(()=>(u(l),e.editor?p(e.editor):null)),S=N(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("bold"))}),A=N(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("italic"))}),O=N(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("strike"))}),E=N(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("code"))}),M=N(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("bulletList"))}),R=N(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("orderedList"))}),D=N(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("blockquote"))}),I=N(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("codeBlock"))}),B=N(()=>{var Y;return u(l),!!((Y=e.editor)!=null&&Y.isActive("link"))}),z=N(()=>(u(l),e.editor?u(v)||!e.editor.isActive("link")&&e.editor.state.selection.from===e.editor.state.selection.to:!0)),Q=N(()=>u(_)?`H${u(_)}`:"H"),ie=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.commands.undo()})),he=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.commands.redo()})),ae=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleBold().run()})),ke=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleItalic().run()})),le=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleStrike().run()})),be=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleCode().run()})),Re=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleBulletList().run()})),$=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleOrderedList().run()})),q=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().toggleBlockquote().run()})),H=N(()=>Li(()=>{var Y;return(Y=e.editor)==null?void 0:Y.chain().focus().setHorizontalRule().run()})),ne=N(()=>Li(()=>{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,h$(e.editor),!0),b(d,!0))}function De(){e.editor&&(p$(e.editor,u(f)),Ee())}function Ee(){b(d,!1),b(f,"")}function de(Y){Y.key==="Enter"?(Y.preventDefault(),Y.stopPropagation(),De()):Y.key==="Escape"&&(Y.preventDefault(),Y.stopPropagation(),Ee())}var _e=St(),J=Ae(_e);{var ye=Y=>{var se=T$(),Te=w(se);{var Oe=K=>{var fe=b$(),Pe=Ae(fe);{const Ke=nt=>{var rt=g$();x(nt,rt)};let We=N(()=>!u(y)),Ue=N(()=>te(u(ie)));Rr(Pe,{ariaLabel:"Undo",shortcut:"Ctrl+Z",get disabled(){return u(We)},get onMouseDown(){return u(ie)},get onClick(){return u(Ue)},children:Ke,$$slots:{default:!0}})}var Be=k(Pe,2);{const Ke=nt=>{var rt=v$();x(nt,rt)};let We=N(()=>!u(C)),Ue=N(()=>te(u(he)));Rr(Be,{ariaLabel:"Redo",shortcut:"Ctrl+Shift+Z",get disabled(){return u(We)},get onMouseDown(){return u(he)},get onClick(){return u(Ue)},children:Ke,$$slots:{default:!0}})}x(K,fe)};j(Te,K=>{u(i)&&K(Oe)})}var ze=k(Te,2);{let K=N(()=>te(u(ae)));Rr(ze,{label:"B",shortcut:"Ctrl+B",get disabled(){return u(v)},get active(){return u(S)},get onMouseDown(){return u(ae)},get onClick(){return u(K)},style:"font-weight: 700;"})}var Xe=k(ze,2);{let K=N(()=>te(u(ke)));Rr(Xe,{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(Xe,2);{let K=N(()=>te(u(le)));Rr(ue,{label:"S",shortcut:"Ctrl+Shift+X",get disabled(){return u(v)},get active(){return u(O)},get onMouseDown(){return u(le)},get onClick(){return u(K)},style:"text-decoration: line-through;"})}var re=k(ue,2);{let K=N(()=>te(u(be)));Rr(re,{label:"<>",shortcut:"Ctrl+E",get disabled(){return u(v)},get active(){return u(E)},get onMouseDown(){return u(be)},get onClick(){return u(K)},style:"font-family: monospace;"})}var pe=k(re,2),Ne=w(pe);{const K=Be=>{var Ke=y$();x(Be,Ke)};let fe=N(()=>u(B)||u(d)),Pe=N(()=>te(ge));Rr(Ne,{ariaLabel:"Link",shortcut:"Ctrl+K",get disabled(){return u(z)},get active(){return u(fe)},ariaHasPopup:"dialog",get ariaExpanded(){return u(d)},onMouseDown:ge,get onClick(){return u(Pe)},children:K,$$slots:{default:!0}})}var xe=k(Ne,2);{var Me=K=>{var fe=w$(),Pe=w(fe);Ot(Pe,nt=>b(h,nt),()=>u(h));var Be=k(Pe,2),Ke=N(()=>te(nt=>{nt.preventDefault(),De()})),We=k(Be,2),Ue=N(()=>te(nt=>{nt.preventDefault(),Ee()}));P("keydown",Pe,de),zr(Pe,()=>u(f),nt=>b(f,nt)),P("mousedown",Be,nt=>{nt.preventDefault(),De()}),P("click",Be,function(...nt){var rt;(rt=u(Ke))==null||rt.apply(this,nt)}),P("mousedown",We,nt=>{nt.preventDefault(),Ee()}),P("click",We,function(...nt){var rt;(rt=u(Ue))==null||rt.apply(this,nt)}),x(K,fe)};j(xe,K=>{u(d)&&K(Me)})}Ur(pe,(K,fe)=>Ho==null?void 0:Ho(K,fe),()=>Ee);var Se=k(pe,4),qe=w(Se);{const K=Ke=>{var We=k$(),Ue=Ae(We),nt=w(Ue);W(()=>G(nt,u(Q))),x(Ke,We)};let fe=N(()=>u(_)?`Heading ${u(_)}`:"Heading"),Pe=N(()=>u(_)!==null),Be=N(()=>te(Ke=>{Ke.preventDefault(),b(c,!u(c))}));Rr(qe,{get ariaLabel(){return u(fe)},get disabled(){return u(v)},get active(){return u(Pe)},ariaHasPopup:"menu",get ariaExpanded(){return u(c)},style:"gap: 2px; padding-right: 4px;",onMouseDown:Ke=>{Ke.preventDefault(),b(c,!u(c))},get onClick(){return u(Be)},children:K,$$slots:{default:!0}})}var it=k(qe,2);{var ce=K=>{var fe=_$();pt(fe,20,()=>s,Pe=>Pe,(Pe,Be)=>{const Ke=N(()=>Z(Be));var We=x$(),Ue=N(()=>te(u(Ke))),nt=w(We);W(()=>{U(We,"aria-checked",u(_)===Be),Le(We,`padding: 4px 12px; font-size: 13px; border: none;
254
- border-radius: var(--tandem-r-2);
255
- background: ${u(_)===Be?"var(--tandem-accent-bg)":"transparent"};
256
- color: ${u(_)===Be?"var(--tandem-accent)":"var(--tandem-fg)"};
257
- cursor: pointer; text-align: left;
258
- font-weight: ${a[Be]??""}; white-space: nowrap;`),G(nt,`Heading ${Be??""}`)}),P("mousedown",We,function(...rt){var xt;(xt=u(Ke))==null||xt.apply(this,rt)}),P("click",We,function(...rt){var xt;(xt=u(Ue))==null||xt.apply(this,rt)}),x(Pe,We)}),x(K,fe)};j(it,K=>{u(c)&&K(ce)})}Ur(Se,(K,fe)=>Ho==null?void 0:Ho(K,fe),()=>()=>b(c,!1));var Ie=k(Se,2);{const K=Pe=>{var Be=C$();x(Pe,Be)};let fe=N(()=>te(u(Re)));Rr(Ie,{ariaLabel:"Bullet list",shortcut:"Ctrl+Shift+8",get disabled(){return u(v)},get active(){return u(M)},get onMouseDown(){return u(Re)},get onClick(){return u(fe)},children:K,$$slots:{default:!0}})}var V=k(Ie,2);{const K=Pe=>{var Be=S$();x(Pe,Be)};let fe=N(()=>te(u($)));Rr(V,{ariaLabel:"Ordered list",shortcut:"Ctrl+Shift+7",get disabled(){return u(v)},get active(){return u(R)},get onMouseDown(){return u($)},get onClick(){return u(fe)},children:K,$$slots:{default:!0}})}var ee=k(V,2);{const K=Pe=>{var Be=E$();x(Pe,Be)};let fe=N(()=>te(u(q)));Rr(ee,{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(fe)},children:K,$$slots:{default:!0}})}var we=k(ee,2);{var Ve=K=>{{let fe=N(()=>te(u(H)));Rr(K,{label:"—",ariaLabel:"Horizontal rule",get disabled(){return u(v)},get onMouseDown(){return u(H)},get onClick(){return u(fe)}})}};j(we,K=>{u(o)&&K(Ve)})}var Fe=k(we,2);{const K=Pe=>{var Be=A$();x(Pe,Be)};let fe=N(()=>te(u(ne)));Rr(Fe,{ariaLabel:"Code block",get disabled(){return u(v)},get active(){return u(I)},get onMouseDown(){return u(ne)},get onClick(){return u(fe)},children:K,$$slots:{default:!0}})}P("keydown",pe,K=>{K.key==="Escape"&&Ee()}),P("keydown",Se,K=>{K.key==="Escape"&&b(c,!1)}),x(Y,se)};j(J,Y=>{e.editor&&Y(ye)})}x(t,_e),tt()}ut(["keydown","mousedown","click"]);function S4(t,e,n){const r=t.getMap(Mi);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=cv(),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 Xo(t,()=>r.set(l,c)),"added"}if(o===n)return Xo(t,()=>r.delete(i)),"removed";const s=cv(),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 Xo(t,()=>{r.delete(i),r.set(s,a)}),"recolored"}function M$(t,e){const n=t.getMap(Mi),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":(Xo(t,()=>{for(const i of r)n.delete(i)}),"removed")}const A0=48,Zf=8,T0=6,G2=4,D$=200;function O$({anchorX:t,anchorY:e,toolbarHeight:n,toolbarWidth:r,viewportHeight:i,viewportWidth:o,previousPlacement:s}){const a=Zf,l=Math.max(a,o-Zf-r),c=e+T0,d=c+n,f=e-T0-n,h=i-Zf,p=s==="below"?h+G2:h-G2,m=d<=p,v=f>=A0,g=Math.max(A0,i-n-Zf);let y,C;m?(y=c,C="below"):v?(y=f,C="above"):(y=g,C="below");const _=i-(e-T0);return{left:Math.min(Math.max(t,a),l),top:Math.min(Math.max(y,A0),g),bottom:_,placement:C}}function I$(t,e){return t.on("selectionUpdate",e),()=>t.off("selectionUpdate",e)}var R$=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),N$=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),P$=T('<button type="button"></button>'),L$=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 F$(t,e){et(e,!0);let n=Ye(e,"selectionToolbar",3,!0),r=Ye(e,"suppressSelectionToolbar",3,!1),i=Ye(e,"requestCommentFocus",3,0),o=Ye(e,"showAuthorship",3,!0),s=Ye(e,"showComments",3,!0),a=Ye(e,"showHighlights",3,!0),l=Ye(e,"showNotes",3,!0),c=Ye(e,"decorationsMuted",3,!1),d=Ye(e,"formattingBarVisible",3,!0),f=Ye(e,"reduceMotion",3,!1);const h=Ao(oi());let p=L(!1),m=L(null),v=L(null),g=L(""),y=L(null),C=L(null),_=L(!1);const S=100;let A=L(!1),O=L(!1),E,M,R=-1,D=-1,I=!1,B=0,z=0,Q=0,ie=0,he=null,ae=null,ke=!1;function le(){he=I?B:Q,ae=I?z:ie,!So(f())&&(b(O,!0),clearTimeout(M),M=setTimeout(()=>{b(O,!1)},n3))}function be(){clearTimeout(E),clearTimeout(M),b(A,!1),b(O,!1),R=-1,D=-1,he=null,ae=null,I=!1}function Re(V,ee,we){R=V,D=ee,I=we,clearTimeout(E),E=setTimeout(()=>{le(),b(A,!0)},S)}const $=GC(),q=$?"⌥⏎":"Alt+⏎",H=$?"⌘⏎":"Ctrl+⏎",ne=N(()=>{const V=u(m);if(!V)return"";const ee=V.placement==="above"?`bottom: ${V.bottom}px; top: auto;`:`top: ${V.top}px; bottom: auto;`;return`left: ${V.left}px; ${ee}`});let te=L(0),Z=L(at(window.innerHeight)),ge=L(at(window.innerWidth));const De=Object.keys(xC),Ee=N(()=>!!e.editor&&!!e.ydoc&&u(p)),de=N(()=>n()&&!r()&&u(Ee)&&u(m)!==null&&u(A)),_e=N(()=>u(g).trim());let J,ye=0,Y=0;const se=3;function Te(V){const{from:ee,to:we}=V.state.selection,Ve=ee!==we;if(b(p,Ve),!Ve){b(m,null),J=void 0,Y=0,be(),document.activeElement!==u(C)&&b(_,!1);return}!u(A)&&!ke&&(ee!==R||we!==D)&&Re(ee,we,!1);try{const Fe=V.view.coordsAtPos(V.state.selection.head);Q=Fe.left,ie=Fe.bottom;const K=O$({anchorX:he??Q,anchorY:ae??ie,toolbarHeight:D$,toolbarWidth:u(te),viewportHeight:u(Z),viewportWidth:u(ge),previousPlacement:J});if(J=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),J=void 0;return}Y+=1,cancelAnimationFrame(ye),ye=requestAnimationFrame(()=>{V.isDestroyed||Te(V)})}}me(()=>{if(!e.editor)return;const V=e.editor;function ee(){Te(V)}const we=V.view.dom,Ve=we.ownerDocument;function Fe(Be){Be.button!==0||!Be.isPrimary||(ke=!0)}function K(Be){if(!ke)return;ke=!1,B=Be.clientX,z=Be.clientY;const{from:Ke,to:We}=V.state.selection;Ke!==We&&!u(A)&&Re(Ke,We,!0)}function fe(){ke=!1}we.addEventListener("pointerdown",Fe),Ve.addEventListener("pointerup",K),Ve.addEventListener("pointercancel",fe);const Pe=I$(V,ee);return ee(),()=>{we.removeEventListener("pointerdown",Fe),Ve.removeEventListener("pointerup",K),Ve.removeEventListener("pointercancel",fe),cancelAnimationFrame(ye),ye=0,clearTimeout(E),clearTimeout(M),Pe()}}),me(()=>{if(!e.editor||!u(m))return;const V=e.editor;let ee=0;function we(){cancelAnimationFrame(ee),ee=requestAnimationFrame(()=>{b(Z,window.innerHeight,!0),b(ge,window.innerWidth,!0),Te(V)})}window.addEventListener("resize",we);let Ve=!1;requestAnimationFrame(()=>{Ve=!0});const Fe=Oy(()=>u(v),["scroll"],()=>{Ve&&document.activeElement!==u(C)&&Ne()});return()=>{cancelAnimationFrame(ee),window.removeEventListener("resize",we),Fe()}}),me(()=>{const V=e.editor,ee=u(v);if(!V||!ee||!u(m))return;const we=u(O),Ve=()=>{if(document.activeElement===u(C))return;if(u(O)){u(te)===0&&(b(te,ee.scrollWidth,!0),Te(V));return}const K=ee.getBoundingClientRect();b(te,K.width,!0),Te(V)};we||Ve();const Fe=new ResizeObserver(Ve);return Fe.observe(ee),()=>Fe.disconnect()}),me(()=>{u(de)&&!u(y)&&Xe(),u(de)||(b(y,null),document.activeElement!==u(C)&&b(g,""))});let Oe=0;me(()=>{if(i()===Oe||(Oe=i(),i()===0||!e.editor))return;const{from:V,to:ee}=e.editor.state.selection;V!==ee&&(Mt(()=>Xe()),b(_,!0),b(A,!0),le(),requestAnimationFrame(()=>{var we;return(we=u(C))==null?void 0:we.focus()}))}),me(()=>{if(!e.editor||!u(de))return;const V=e.editor,ee=()=>{document.activeElement!==u(C)&&Xe()};return V.on("selectionUpdate",ee),()=>{V.isDestroyed||V.off("selectionUpdate",ee)}}),me(()=>{if(!u(de))return;function V(ee){ee.key==="Escape"&&(ee.preventDefault(),ee.stopPropagation(),Ne())}return window.addEventListener("keydown",V,{capture:!0}),()=>window.removeEventListener("keydown",V,{capture:!0})});function ze(V,ee,we){if(!e.editor||!e.ydoc||V!=="highlight"&&!ee.trim())return;const Ve=u(y)??e.editor.state.selection,{from:Fe,to:K}=Ve;if(Fe===K)return;const fe=gi(e.editor.state.doc,zn(Fe)),Pe=gi(e.editor.state.doc,zn(K)),Be=cv(),We={id:Be,author:"user",type:V,audience:V==="highlight"||V==="note"?"private":"outbound",range:{from:fe,to:Pe},content:ee,status:"pending",timestamp:Date.now()};return Xo(e.ydoc,()=>e.ydoc.getMap(Mi).set(Be,We)),b(y,null),Be}function Xe(){if(!e.editor)return;const{from:V,to:ee}=e.editor.state.selection;b(y,{from:V,to:ee},!0)}function ue(V){if(!e.editor||!e.ydoc)return;const ee=u(y)??e.editor.state.selection,{from:we,to:Ve}=ee;if(we===Ve)return;const Fe=gi(e.editor.state.doc,zn(we)),K=gi(e.editor.state.doc,zn(Ve));S4(e.ydoc,{from:Fe,to:K},V),b(y,null),e.editor.chain().setTextSelection(Ve).run()}function re(){if(!e.editor||!e.ydoc)return;const V=u(y)??e.editor.state.selection,{from:ee,to:we}=V;if(ee===we)return;const Ve=gi(e.editor.state.doc,zn(ee)),Fe=gi(e.editor.state.doc,zn(we));M$(e.ydoc,{from:Ve,to:Fe}),b(y,null),e.editor.chain().setTextSelection(we).run()}function pe(V){return ee=>{ee.detail===0&&V(ee)}}function Ne(){var V;b(p,!1),b(m,null),b(y,null),b(g,""),b(_,!1),be(),(V=e.editor)==null||V.chain().focus().run()}function xe(){b(_,!0),requestAnimationFrame(()=>{var V;return(V=u(C))==null?void 0:V.focus()})}function Me(){var we;if(!u(_e))return;const V=(we=u(v))==null?void 0:we.getBoundingClientRect(),ee=ze("comment",u(_e));ee&&V&&lk(ee,V),window.dispatchEvent(new CustomEvent("tandem:addressed-ai",{detail:{via:"comment"}})),Ne()}function Se(){var we;if(!u(_e))return;const V=(we=u(v))==null?void 0:we.getBoundingClientRect(),ee=ze("note",u(_e));ee&&V&&lk(ee,V),Ne()}function qe(V){V.key==="Enter"&&V.altKey?(V.preventDefault(),Se()):V.key==="Enter"&&(V.metaKey||V.ctrlKey)?(V.preventDefault(),Me()):V.key==="Escape"&&(V.preventDefault(),Ne())}var it=St(),ce=Ae(it);{var Ie=V=>{var ee=L$();let we;var Ve=w(ee);let Fe;var K=w(Ve),fe=w(K),Pe=w(fe),Be=w(Pe);C4(Be,{get editor(){return e.editor},variant:"popup"});var Ke=k(Be,2);{var We=Ut=>{var un=R$(),Hn=k(Ae(un),2),aa=w(Hn);_4(aa,{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",Hn,si=>si.preventDefault()),x(Ut,un)};j(Ke,Ut=>{e.onUpdateDecorations&&Ut(We)})}var Ue=k(Ke,2);{var nt=Ut=>{var un=N$(),Hn=k(Ae(un),2),aa=N(()=>pe(()=>{var X;return(X=e.onToggleFormattingBar)==null?void 0:X.call(e)})),si=w(Hn),F=w(si);W(()=>{U(Hn,"aria-label",d()?"Hide formatting bar":"Show formatting bar"),U(Hn,"title",d()?"Hide formatting bar":"Show formatting bar"),U(F,"d",d()?"m18 15-6-6-6 6":"m6 9 6 6 6-6")}),P("mousedown",Hn,X=>{var ve;X.preventDefault(),(ve=e.onToggleFormattingBar)==null||ve.call(e)}),P("click",Hn,function(...X){var ve;(ve=u(aa))==null||ve.apply(this,X)}),x(Ut,un)};j(Ue,Ut=>{e.onToggleFormattingBar&&Ut(nt)})}var rt=k(Pe,2),xt=w(rt),qt=w(xt),Je=N(()=>pe(()=>{var Ut;re(),(Ut=e.editor)==null||Ut.chain().focus().run()})),Ct=k(qt,2);pt(Ct,17,()=>De,cc,(Ut,un)=>{var Hn=P$(),aa=N(()=>pe(()=>{var si;ue(u(un)),(si=e.editor)==null||si.chain().focus().run()}));W(()=>{U(Hn,"data-testid",`popup-highlight-${u(un)}`),U(Hn,"aria-label",`Highlight ${u(un)}`),U(Hn,"title",`Highlight ${u(un)}`),Le(Hn,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${Wu[u(un)]}; cursor: pointer; padding: 0;`)}),P("mousedown",Hn,si=>{var F;si.preventDefault(),ue(u(un)),(F=e.editor)==null||F.chain().focus().run()}),P("click",Hn,function(...si){var F;(F=u(aa))==null||F.apply(this,si)}),x(Ut,Hn)});var Nt=k(xt,4),ln=N(()=>pe(()=>xe())),vn=k(Ve,2);let er;var zt=w(vn),Mn=w(zt),cr=w(Mn);U(cr,"rows",1),Ot(cr,Ut=>b(C,Ut),()=>u(C));var En=k(cr,2),An=w(En),qr=k(w(An)),Ii=w(qr),Ri=k(An,2),cl=w(Ri),ul=k(cl),sa=w(ul);Ot(ee,Ut=>b(v,Ut),()=>u(v)),W(()=>{we=vt(ee,1,"tandem-floating-pill selection-popup svelte-1tvmluw",null,we,{"is-annotate":u(_),"is-below":u(m).placement==="below"}),Le(ee,u(ne)),Fe=vt(Ve,1,"morph-block morph-format svelte-1tvmluw",null,Fe,{"is-active":!u(_)}),Ve.inert=u(_),er=vt(vn,1,"morph-block morph-annotate svelte-1tvmluw",null,er,{"is-active":u(_)}),vn.inert=!u(_),U(An,"title",`Note to self — private, not sent to ${h.family??""} (Alt+Enter)`),An.disabled=!u(_e),G(Ii,q),U(Ri,"aria-label",`Send to ${h.family??""} (Ctrl+Enter)`),U(Ri,"title",`Send to ${h.family??""} — outbound comment (Ctrl/Cmd+Enter)`),Ri.disabled=!u(_e),G(cl,`Send to ${h.family??""} `),G(sa,H)}),P("mousedown",fe,Ut=>Ut.preventDefault()),P("mousedown",qt,Ut=>{var un;Ut.preventDefault(),re(),(un=e.editor)==null||un.chain().focus().run()}),P("click",qt,function(...Ut){var un;(un=u(Je))==null||un.apply(this,Ut)}),P("mousedown",Nt,Ut=>{Ut.preventDefault(),xe()}),P("click",Nt,function(...Ut){var un;(un=u(ln))==null||un.apply(this,Ut)}),P("keydown",cr,qe),zr(cr,()=>u(g),Ut=>b(g,Ut)),P("click",An,Se),P("click",Ri,Me),Wi(1,ee,()=>tN,()=>({reduceMotion:f()})),x(V,ee)};j(ce,V=>{u(de)&&u(m)&&V(Ie)})}x(t,it),tt()}ut(["mousedown","click","keydown"]);function z$(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 B$(t){me(()=>z$(t()))}const H$=8e3;function V$(t){let e=L(null),n=L(!1),r=L(!1),i=0,o=0,s=!1;async function a(v){let g;try{g=await fetch(`${Qt}${UC}`)}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(`${Qt}${VD}`)}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(),H$);Dn(()=>{i++,s=!0,clearInterval(h)});const p=N(()=>!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=N(()=>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 U$(t,e=document.documentElement){return t?e.setAttribute("data-annotation-patterns","true"):e.removeAttribute("data-annotation-patterns"),()=>e.removeAttribute("data-annotation-patterns")}function j$(t){me(()=>U$(t()))}function q$(t){let e=L(at(new Map));return me(()=>{const n=t.getYdoc();if(!n){u(e).size>0&&b(e,new Map,!0);return}const r=n.getMap(TC),i=()=>{b(e,W$(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return u(e)}}}function W$(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 K$=25;function G$(t=K$){const e=at([]);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 Z$(t,e=()=>XM){let n=L(!1),r=L(!1);return me(()=>{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 Y$(t,e=document.documentElement){return e.setAttribute("data-density",t),()=>e.removeAttribute("data-density")}function J$(t){me(()=>Y$(t()))}const Jl=200,Md=600,X$=300;function Z2(t){const e=SC[t];try{const n=localStorage.getItem(e);if(n){const r=parseInt(n,10);if(Number.isFinite(r))return Math.max(Jl,Math.min(Md,r));console.warn(`[tandem] ignoring non-numeric panel width for ${e}: ${n}`)}}catch(n){console.warn(`[tandem] localStorage unavailable reading ${e}:`,n)}return X$}function Y2(t){const{side:e}=t,n=SC[e];let r=L(at(t.initialWidth)),i=null;return me(()=>{!t.getVisible()&&i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),i=null,document.body.style.userSelect="",document.body.style.cursor="")}),me(()=>()=>{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(Jl,Math.min(Md,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(Jl,Math.min(Md,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 Q$={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 $$(t){const e=document.documentElement;return e.style.setProperty("--tandem-editor-font-family",Q$[t]),()=>e.style.removeProperty("--tandem-editor-font-family")}function eee(t){me(()=>$$(t()))}function tee(){let t=L(!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 nS(o);try{const l=await fetch(`${Qt}${VC}`,{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 M0(t){return!!(t!=null&&t.query)}function nee(){let t=L(null),e=L(null),n=L(null),r=L(!1),i=0;async function o(){const s=++i;try{const a=await fetch(y8,{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 ree(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){me(()=>ree(t()))}function oee(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 see(t){let e=null;return{schedule(){e===null&&(e=requestAnimationFrame(()=>{e=null,t()}))},cancel(){e!==null&&(cancelAnimationFrame(e),e=null)}}}function aee(t){let e=L(at(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}=oee(a,f=>Sc(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=see(n);return me(()=>{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()}}),me(()=>{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 E4=sD,cee=250;function uee(t,e){return t.severity==="info"&&e-t.timestamp>=E4}function dee(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=>!uee(o,r)).slice(-IC)}catch(e){return console.warn("[useNotifications] failed to load activity history:",e),[]}}function fee(t={}){const e=t.persist??!0,n=t.storageKey??oD;let r=L(at([])),i=L(at(e?dee(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,cee))},d=E=>{const M=o.get(E);M&&(clearTimeout(M),o.delete(E))},f=(E,M)=>{d(E);const R=pw[M]??pw.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(B=>B.dedupKey===E.dedupKey);if(I!==-1){const B=u(r)[I];d(B.id);const z={...E,count:B.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>iD;){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,E4-(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],B={...E,id:I.id,count:I.count+1},z=[...u(i)];z[D]=B,b(i,z,!0),B.severity==="info"?m(B.id,B.timestamp):p(B.id),c();return}}const M={...E,count:1},R=[...u(i),M];for(;R.length>IC;)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:${ji}${BD}`,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 J2(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 kl(t){return`tandem:scratchpad:${t}`}const da="tandem:scratchpad:latest",X2=500;function Q2(t){const e=[],n=r=>{if(r instanceof In)return r.toString();if(r instanceof gn){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 gn||i instanceof In)&&e.push(n(i))}return e.join(`
259
- `).replace(/\n+$/,"")}function su(t){try{return localStorage.getItem(t)}catch{return null}}function Yf(t,e){try{localStorage.setItem(t,e)}catch{}}function au(t){try{localStorage.removeItem(t)}catch{}}function hee(t){const e=new Map,n=at({}),r=()=>Object.values(n).some(Boolean),i=d=>{const f=d.ydoc.getXmlFragment("default"),h=Q2(f),p=kl(d.uuid);if(h.length===0){au(p),su(da)===d.uuid&&au(da),n[d.uuid]=!1;return}Yf(p,h),Yf(da,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:J2(()=>{},X2)};if(p.persist=J2(()=>i(p),X2),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(Q2(f).length>0)return;let h=d.uuid,p=su(kl(h));if(p===null&&e.size===1){const g=su(da);g&&g!==d.uuid&&(p=su(kl(g)),h=g)}if(p===null||p.length===0)return;const v=p.split(`
260
- `).map(g=>{const y=new gn("paragraph");return g.length>0&&y.insert(0,[new In(g)]),y});Xo(d.ydoc,()=>{f.length>0&&f.delete(0,f.length),f.insert(0,v)}),Yf(kl(d.uuid),p),Yf(da,d.uuid),h!==d.uuid&&au(kl(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;au(kl(d)),su(da)===d&&au(da),(f=e.get(d))==null||f.persist.cancel(),n[d]=!1},c=$_(()=>{me(()=>{const d=t(),f=new Set;for(const h of d){if(!hm(h.filePath))continue;const p=FC(h.filePath);p&&(f.add(p),o(p,h.ydoc,h.provider))}for(const h of[...e.keys()])f.has(h)||a(h)}),me(()=>{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 pee(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 mee(t,e,n){let r=null;Lc(()=>{r=i=>{if(!i.ctrlKey&&!i.metaKey||i.key!=="Tab")return;const o=pee(t(),e(),i.shiftKey);o&&(i.preventDefault(),n(o))},window.addEventListener("keydown",r)}),Dn(()=>{r&&window.removeEventListener("keydown",r)})}function gee(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 Ir(t){if(t.isComposing)return!0;const e=t.target;return e?e.tagName==="INPUT"||e.tagName==="TEXTAREA":!1}function $2(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 vee(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 bee(t){let e=L(at([]));me(()=>{const o=t().map(a=>a.id),s=$2(u(e),o);(u(e).length!==s.length||u(e).some((a,l)=>a!==s[l]))&&b(e,s,!0)});const n=N(()=>{const i=t(),o=new Map(i.map(l=>[l.id,l])),s=i.map(l=>l.id);return $2(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,vee(u(e),i,o,l,s),!0)}}}function yee(t,e){let n=L(at((()=>{try{const r=localStorage.getItem(wf),i=PD.safeParse(r);return i.success?i.data:aw}catch(r){return console.warn(`[tandem] localStorage unavailable reading ${wf}:`,r),aw}})()));return me(()=>{const r=u(n);try{localStorage.setItem(wf,r)}catch(i){console.warn(`[tandem] failed to persist ${wf}:`,i)}}),me(()=>{const r=t(),i=u(n);if(r)try{r.getMap(tv).set(tD,i)}catch(o){console.warn("[tandem] failed to broadcast tandem mode to Y.Map:",o)}}),me(()=>{const r=t(),i=e();if(r)try{r.getMap(tv).set(nD,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 Ah=L(!1),D0=!1,A4=()=>{};const O0={get fileDragOver(){return u(Ah)}};function wee(t){const e=t.split(/[/\\]/).at(-1)??"",n=e.lastIndexOf(".");return n<=0?!1:qd.has(e.slice(n).toLowerCase())}const kee=(()=>{const t=Array.from(qd).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 Jf(t,e,n){A4({id:`tauri-drop-${n}-${Date.now()}`,type:"general-error",severity:e,message:t,dedupKey:n,timestamp:Date.now()})}function xee(t){A4=t,!D0&&Tt()&&(D0=!0,Kt(()=>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(Ah,!0);return;case"drop":b(Ah,!1);for(const i of r.paths)if(wee(i)){(async()=>{const o=await ls(i);o.ok||Jf(`Couldn't open ${i}: ${o.error}`,"error","tauri-drop-open-failed")})();return}Jf(`Tandem can only open ${kee} files`,"warning","tauri-drop-unsupported");return;case"leave":b(Ah,!1);return;default:console.warn("[useTauriFileDrop] unknown payload type:",r)}}catch(r){console.error("[useTauriFileDrop] callback threw:",r),Jf("Drag-and-drop encountered an error — try the Open File dialog","error","tauri-drop-callback-error")}})}).catch(e=>{D0=!1,console.error("[useTauriFileDrop] Failed to attach onDragDropEvent:",e),Jf("Drag-and-drop unavailable — use the Open File dialog instead","warning","tauri-drop-unavailable")}))}var zd;class _ee{constructor(){bt(this,zd,L(at(Tt()?window.__TANDEM_INITIAL_THEME__??null:null)))}get current(){return u(oe(this,zd))}set current(e){b(oe(this,zd),e,!0)}}zd=new WeakMap;const og=new _ee;let e_=!1;function I0(t){og.current=t,typeof window<"u"&&(window.__TANDEM_INITIAL_THEME__=t)}function Cee(){if(e_||!Tt())return;e_=!0;let t=null;Kt(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]).then(({invoke:i})=>{t=i,i("get_app_theme").then(o=>{I0(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] get_app_theme failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri API import failed:",i)}),Kt(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})=>{I0(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";og.current!==o&&(I0(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 T4(t="light"){const e=t==="warm"?"warm":"light";try{if(typeof window>"u")return e;if(Tt()){const n=og.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 See(t,e="light"){return t==="system"?T4(e):t}function t_(t){try{const e=document.querySelector('meta[name="theme-color"]');e&&(e.content=t==="dark"?"#1c1c24":t==="warm"?"#f1ead9":"#fafaf9")}catch{}}function Eee(t,e="light"){const n=document.documentElement,r=See(t,e);if(n.setAttribute("data-theme",r),t_(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=T4(e);n.setAttribute("data-theme",s),t_(s)};return i.addEventListener("change",o),()=>{i.removeEventListener("change",o),n.removeAttribute("data-theme")}}function Aee(t,e=()=>"light"){Cee(),me(()=>{const n=t(),r=e();return og.current,Eee(n,r)})}function Tee(){try{return localStorage.getItem(RC)==="true"}catch{return!1}}function Mee(t){return t.author==="user"&&!t.id.startsWith(NC)}function n_(){try{localStorage.setItem(RC,"true")}catch{}}function Dee(t,e,n){let r=L(at(Tee())),i=L(0),o=0;const s=KS(),a=N(()=>n()==="welcome.md"),l=N(()=>!u(r)&&u(a)),c=Tt(),d=a1(()=>c&&u(l)),f=N(()=>!c||d.status!==null||d.error!==null),h=N(()=>c&&WS(d.status,s)),p=N(()=>u(f)?u(h)?4:3:1/0);return me(()=>{if(!u(l)||u(i)!==0)return;const y=t().filter(_=>_.id.startsWith(NC));if(y.length===0)return;y.some(_=>_.status!=="pending")&&(o=Date.now(),b(i,1))}),me(()=>{if(!u(l)||u(i)!==1)return;t().some(Mee)&&(o=Date.now(),b(i,2))}),me(()=>{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)}}),me(()=>{if(!u(l)||!isFinite(u(p))||u(i)!==u(p))return;const g=setTimeout(()=>{n_(),b(r,!0)},3e3);return()=>clearTimeout(g)}),me(()=>{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:()=>{n_(),b(r,!0)},nextStep:()=>{o=Date.now(),b(i,Math.min(u(i)+1,u(p)),!0)}}}const Oee="tandem://update-available",Iee="tandem:updater-dismissed-v";function M4(t){return`${Iee}${t}`}function D4(t){try{return window.localStorage.getItem(M4(t))==="1"}catch{return!1}}function Ree(t){try{window.localStorage.setItem(M4(t),"1")}catch{}}let O4=L(null),nm=L(null),Dl=0,R0=null,Xf=!1,N0=0;function r_(){return Dl}function Ca(){return u(O4)}function I4(){return u(nm)}function R4(t){t&&(Ree(t),b(nm,t,!0))}function N4(){if(Dl+=1,Dl===1&&Tt()){Xf=!1;const e=++N0;(async()=>{try{const{listen:n}=await Kt(async()=>{const{listen:i}=await import("./event-CNdo2oXa.js");return{listen:i}},__vite__mapDeps([3,1]));if(Xf||e!==N0||r_()===0)return;const r=await n(Oee,i=>{var s;const o=((s=i.payload)==null?void 0:s.version)??null;o&&(b(O4,o,!0),u(nm)!==o&&b(nm,null))});if(Xf||e!==N0||r_()===0){r();return}R0=r}catch(n){console.warn("[useUpdaterChannel] listen() failed:",n)}})()}let t=!1;return()=>{if(!t&&(t=!0,Dl=Math.max(0,Dl-1),Dl===0)){Xf=!0;const e=R0;if(R0=null,e)try{e()}catch(n){console.warn("[useUpdaterChannel] unlisten threw:",n)}}}}function Nee(){return me(()=>N4()),{get availableVersion(){return Ca()},get showDot(){const t=Ca();return!(!t||I4()===t||D4(t))},acknowledge(){R4(Ca())}}}const i_=3e4;function Pee(){let t=L(!1),e=null;function n(){e!==null&&(clearTimeout(e),e=null)}me(()=>{const i=N4();return()=>{n(),i()}});async function r(){if(!(!Ca()||u(t))){b(t,!0),n(),e=setTimeout(()=>{e=null,b(t,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${i_}ms; re-arming CTA`)},i_);try{const{invoke:o}=await Kt(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 Ca()},get installing(){return u(t)},get showBanner(){const i=Ca();return!(!i||I4()===i||D4(i))},dismiss(){R4(Ca())},install:r}}function Lee(){let t=L(at(window.innerWidth));return me(()=>{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 Fee(){let t=null;Lc(()=>{let e=!1,n;Kt(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=eu;try{const d=localStorage.getItem(mw);if(d!==null){const f=Number(d);Number.isFinite(f)?o=Math.max(gw,Math.min(vw,f)):console.warn(`[tandem] ignoring invalid stored zoom: ${d}`)}}catch{}o!==eu&&i.setZoom(o).catch(d=>{console.warn("[tandem] failed to restore zoom level:",d)});function s(d){try{localStorage.setItem(mw,String(d))}catch{}}const a=d=>{!(d.metaKey||d.ctrlKey)||d.key!=="0"||(d.preventDefault(),d.stopPropagation(),o=eu,i.setZoom(eu).catch(h=>{console.warn("[tandem] failed to reset zoom:",h)}),s(eu))},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(gw,Math.min(vw,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 zee=1e3;function Bee(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(zee)}}finally{e=!1}}))}}function Hee(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 Vee(t,e,n){return t.filter(r=>!e.has(r.id)&&!n.has(r.id))}function Uee(){let t=L(at([])),e=L(null),n=L(!1),r=L("connecting"),i=L(0),o=L(null),s=L(at([])),a=L(null),l=L(!1),c=L(null),d=L(!1),f=L(!1),h=L(!1),p=L(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:H}=q,ne=H.getMap(Mi),te=()=>{const J=[];ne.forEach(ye=>{J.push(Ja(ye,Y=>{console.warn("[sanitize]",Y)}))}),b(s,J,!0)};ne.observe(te),te();const Z=H.getMap(AC);let ge=null,De=!1,Ee=null;const de=J=>J?`${J.tool} ${J.annotationId??""} ${J.token??J.startedAt}`:null,_e=()=>{const J=Z.get(nv),ye=(J==null?void 0:J.status)??null,Y=(J==null?void 0:J.active)??!1,se=(J==null?void 0:J.working)??null;ye!==ge&&(ge=ye,b(a,ye,!0)),Y!==De&&(De=Y,b(l,Y,!0));const Te=de(se);Te!==Ee&&(Ee=Te,b(c,se,!0))};return Z.observe(_e),_e(),()=>{ne.unobserve(te),Z.unobserve(_e)}},M=q=>new Promise(H=>setTimeout(H,q)),R=async()=>{try{const q=await fetch(`http://127.0.0.1:${ji}${uv}`,{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=Bee({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}),B=(q,H,ne)=>{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 De=Vee(q,Z,C),Ee=[];for(const se of De){C.add(se.id);const Te=new ko,Oe=new $k({url:`ws://127.0.0.1:${sw}`,name:se.id,document:Te,token:g});Oe.on("authenticationFailed",I),_.set(se.id,{ydoc:Te,provider:Oe});const ze=Te.getMap(Rh),Xe=ue=>{if(!ue.keysChanged.has(Xc)&&!ue.keysChanged.has(Qc)&&!ue.keysChanged.has($c))return;const re=ze.get(Xc),pe=ze.get(Qc),Ne=ze.get($c);re&&B(re,pe??null,Ne??null)};ze.observe(Xe),A.set(se.id,()=>ze.unobserve(Xe)),Ee.push({...se,ydoc:Te,provider:Oe})}const de=te.filter(se=>!ge.has(se.id));for(const se of de){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])),J=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,[...J,...Ee],!0),H!==null&&(b(e,Hee({prev:u(e),serverActiveId:H,serverIds:ge,removedCount:de.length,serverEpoch:ne,lastAppliedEpoch:y}),!0),y=ne)};let z=null,Q=null;function ie(q){g=q;const H=new ko,ne=new $k({url:`ws://127.0.0.1:${sw}`,name:eD,document:H,token:q});b(p,H,!0),Q=ne,ne.on("authenticationFailed",I),ne.on("status",({status:de})=>{b(n,de==="connected"),b(r,["connected","connecting","disconnected"].includes(de)?de:"connecting",!0),de==="connected"?(v=!0,b(i,0),b(o,null)):de==="disconnected"?u(o)===null&&b(o,Date.now(),!0):de==="connecting"&&(v&&b(i,u(i)+1),u(o)===null&&b(o,Date.now(),!0))});const te=H.getMap(Rh),Z=de=>{if(de.keysChanged.has(Xc)||de.keysChanged.has(Qc)||de.keysChanged.has($c)){const _e=te.get(Xc),J=te.get(Qc),ye=te.get($c);_e&&B(_e,J??null,ye??null)}de.keysChanged.has(pg)&&b(d,te.get(pg)===!0)};te.observe(Z);const ge=te.get(Xc),De=te.get(Qc),Ee=te.get($c);ge&&B(ge,De??null,Ee??null),b(d,te.get(pg)===!0),z=()=>{te.unobserve(Z),m&&(clearTimeout(m),m=null),ne.destroy(),H.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 he=N(()=>u(t).find(q=>q.id===u(e))??null),ae=N(()=>{var q;return((q=u(he))==null?void 0:q.ydoc)??null}),ke=$_(()=>{me(()=>{u(ae);const q=u(he);for(const H of S.values())H.cleanup();if(S.clear(),q){const H=E(q);S.set(q.id,{cleanup:H})}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 H=u(t),ne=H.findIndex(Z=>Z.id===q),te=H.filter(Z=>Z.id!==q);te.length===0?b(e,null):b(e,te[Math.min(ne,te.length-1)].id,!0)}fetch(`http://127.0.0.1:${ji}${jD}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:q})}).then(H=>{H.ok||console.warn("[Tandem] Server rejected close:",H.status)}).catch(H=>{console.warn("[Tandem] Failed to close document on server:",H)})},handleTabRename:(q,H,ne)=>{const te=u(t).find(Ee=>Ee.id===q);if(!te)return;const Z=te.fileName,ge=Ee=>u(t).map(de=>de.id===q?{...de,fileName:Ee}:de);b(t,ge(H),!0);const De=Ee=>{b(t,ge(Z),!0),ne==null||ne(Ee)};fetch(`http://127.0.0.1:${ji}${qD}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:q,newName:H})}).then(async Ee=>{if(Ee.ok)return;let de=`Rename failed (${Ee.status}).`;try{const _e=await Ee.json();_e!=null&&_e.message&&(de=_e.message)}catch{}console.warn("[Tandem] Server rejected rename:",Ee.status,de),De(de)}).catch(Ee=>{console.warn("[Tandem] Failed to rename document on server:",Ee),De("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 Ic={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 Dd(t){return t.column+t.inset+t.gap}Ic.full.column;const jee=Dd(Ic.full),P4=480,qee=32;function Wee(t){return 2*jee+t+P4}function Kee(t){const e=t+P4;return{t1:Wee(t),t2:2*Dd(Ic.narrow)+e,t3:2*Dd(Ic.stub)+e}}const Qf={off:0,stub:1,narrow:2,full:3};function Gee(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 Qf[t]>Qf[c]?c:Qf[t]<Qf[d]?d:t}function Zee(t,e,n){return t?e&&n==="full"?"full":"off":e?n:"off"}function o_(t,e,n){return!e&&!n?"off":t}function Yee(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 Jee(t){const e=N(()=>(t.getLeftRailVisible()?t.leftRailWidthPx:0)+(t.getRightRailVisible()?t.rightRailWidthPx:0)),n=N(()=>Kee(u(e)));let r=L("full");me(()=>{const v=t.getViewportWidth(),g=u(n),y=Mt(()=>u(r)),C=Gee(y,v,g,qee);C!==y&&b(r,C,!0)});const i=N(()=>t.getFormat()==="docx"),o=N(()=>Zee(u(i),t.getMarginView(),u(r))),s=N(()=>o_(u(o),u(i),t.getLeftHasPending())),a=N(()=>o_(u(o),u(i),t.getRightHasPending())),l=N(()=>u(s)!=="off"),c=N(()=>u(a)!=="off"),d=N(()=>u(l)||u(c)),f=N(()=>Ic[u(s)]),h=N(()=>Ic[u(a)]),p=new Set,m=N(()=>Yee({isDocx:u(i),effectivelyOn:u(d),leftReservePx:Dd(u(f)),rightReservePx:Dd(u(h)),measure:(()=>{const v=t.getEditorMeasure(),g=Nw[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??Nw.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 Xee(t,e){const n=N(()=>t.settings.leftPanelVisible),r=N(()=>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 Qee(t){return t.mode==="stub"?"stub":t.isActive?"full":t.mode==="narrow"?"clamped":"full"}const $ee=6;function ete(t,e={}){const n=e.gap??$ee,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 tte(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 nte(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 rte(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 rte(t)}}var ote=rn('<path stroke-linecap="round" fill="none"></path><circle data-testid="margin-anchor-dot"></circle>',1),ste=T('<div class="margin-bubble svelte-lzz9jv"><!></div>'),ate=T('<svg aria-hidden="true"></svg> <div></div>',1);function lte(t,e){et(e,!0);let n=Ye(e,"reduceMotion",3,!1);const r=12,i=N(()=>e.side==="right"?0:e.gap),o=N(()=>e.side==="right"?e.gap:0),s=N(()=>`position: absolute; top: 0; bottom: 0; ${e.side}: ${e.edgeInset+e.width}px; width: ${e.gap}px; pointer-events: none;`),a=N(()=>e.annotations.filter(A=>e.positions.has(A.id)&&A.status==="pending"));let l=L(at(new Map));const c=N(()=>new Map(u(a).map(A=>[A.id,Qee({mode:e.mode,isActive:A.id===e.activeAnnotationId})]))),d=N(()=>{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 ete(A)});me(()=>{const A=new Set(u(a).map(O=>O.id));Mt(()=>{tte(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=L(void 0),p=L(null),m=0;function v(A){return e.annotations.find(O=>O.id===A)}function g(A){return O=>{const E=v(A);E&&FE(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 zE(M,g(E)))}me(()=>{const A=u(h);if(A)return A.addEventListener("contextmenu",y),()=>A.removeEventListener("contextmenu",y)}),me(()=>BE());var C=ate(),_=Ae(C);pt(_,21,()=>u(a),A=>A.id,(A,O)=>{const E=N(()=>e.positions.get(u(O).id)),M=N(()=>u(d).get(u(O).id));var R=St(),D=Ae(R);{var I=B=>{const z=N(()=>u(O).id===e.activeAnnotationId),Q=N(()=>u(M)??u(E)),ie=N(()=>u(Q)+r),he=N(()=>ite(u(O).author)),ae=N(()=>nte({startX:u(i),startY:u(E),endX:u(o),endY:u(ie)}));var ke=ote(),le=Ae(ke),be=k(le);W(()=>{U(le,"data-annotation-id",u(O).id),U(le,"data-tandem-author",u(O).author),U(le,"d",u(ae)),U(le,"stroke",u(he)),U(le,"stroke-width",u(z)?1.8:1.1),U(le,"stroke-opacity",u(z)?.82:.38),U(be,"data-annotation-id",u(O).id),U(be,"data-tandem-author",u(O).author),U(be,"cx",u(i)),U(be,"cy",u(E)),U(be,"r",u(z)?3:2),U(be,"fill",u(he)),U(be,"fill-opacity",u(z)?.72:.42)}),x(B,ke)};j(D,B=>{u(E)!==void 0&&B(I)})}x(A,R)});var S=k(_,2);pt(S,21,()=>u(a),A=>A.id,(A,O)=>{const E=N(()=>u(d).get(u(O).id)??e.positions.get(u(O).id)??0),M=N(()=>P1(u(O),e.repliesById.get(u(O).id))),R=N(()=>u(c).get(u(O).id)??"full");var D=ste(),I=w(D);{let B=N(()=>u(O).id===e.activeAnnotationId),z=N(()=>Rm(u(O))?e.onAccept:void 0),Q=N(()=>Nm(u(O))?e.onDismiss:void 0),ie=N(()=>zm(u(O))?e.onRemove:void 0),he=N(()=>Fm(u(O))?e.onSendToClaude:void 0),ae=N(()=>Lm(u(O))?e.onEdit:void 0),ke=N(()=>Pm(u(O))?e.onReply:void 0),le=N(()=>{var be;return((be=u(p))==null?void 0:be.id)===u(O).id?u(p):null});zv(I,{get annotation(){return u(O)},get replies(){return u(M)},get isReviewTarget(){return u(B)},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(he)},get onEdit(){return u(ae)},get onReply(){return u(ke)},get openRequest(){return u(le)}})}W(()=>{U(D,"data-testid",`margin-bubble-${u(O).id??""}`),U(D,"data-margin-bubble-reply-count",u(M).length),Le(D,`position: absolute; top: ${u(E)??""}px; ${e.side??""}: 0; width: ${e.width??""}px; pointer-events: auto;`)}),Wi(1,D,()=>QR,()=>({id:u(O).id,reduceMotion:n()})),HM(D,"clientHeight",B=>f(u(O).id,B)),x(A,D)}),Ot(S,A=>b(h,A),()=>u(h)),W(()=>{U(_,"data-testid",`margin-leaders-${e.side??""}`),Le(_,u(s)),U(S,"data-testid",`margin-column-${e.side??""}`),U(S,"aria-label",e.side==="left"?"Note bubbles":"Comment bubbles"),Le(S,`position: absolute; top: 0; ${e.side??""}: ${e.edgeInset??""}px; width: ${e.width??""}px; pointer-events: none;`)}),x(t,C),tt()}function a_(t){return t.type==="note"}function l_(t){return t.author==="import"||t.type==="comment"}var cte=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),ute=T("<span></span>"),dte=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 c_(t,e){et(e,!0);const n=Ye(e,"annotations",19,()=>[]),r=N(()=>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=dte(),a=w(s),l=w(a),c=k(a,2),d=w(c);{var f=v=>{var g=cte();x(v,g)},h=v=>{var g=St(),y=Ae(g);pt(y,17,n,C=>C.id,(C,_)=>{var S=ute();W(A=>vt(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(()=>{vt(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),Le(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),tt()}ut(["click","keydown"]);const u_=t=>{console.warn("[sanitize]",t)};function fte(t,e,n){if(t.suggestedText===void 0)return!1;const r=t.suggestedText,i=Sc(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 hte({getYdoc:t,getEditor:e,getAnnotations:n,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:o}){let s=L(0),a=L(at(new Set));const l=new Map;Dn(()=>{for(const y of l.values())clearTimeout(y);l.clear()});function c(){return n().filter(Bh)}function d(y,C){const _=t();if(!_)return;const S=_.getMap(Mi),A=S.get(y);if(!A||A.status!=="pending")return;const O=Ja(A,u_);if(S.set(y,{...O,status:C}),C==="accepted"&&O.suggestedText!==void 0){const E=e();if(E&&!fte(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(Mi),S=_.get(y);if(!S||S.status==="pending")return h(y),!1;const A=Ja(S,u_),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=Sc(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 _=Sc(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 me(()=>{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)}}),me(()=>{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 pte=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>'),mte=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>'),gte=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 vte(t,e){et(e,!0);const n=[{value:"yellow",label:"Yellow"},{value:"green",label:"Green"},{value:"blue",label:"Blue"},{value:"pink",label:"Pink"}],r=Ye(e,"disabled",3,!1);let i=L("yellow"),o=L(!1),s=L(null);me(()=>{var g;(g=e.onOpenChange)==null||g.call(e,u(o))}),me(()=>{if(u(o))return Oy(()=>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=gte(),f=w(d);Rr(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=mte(),C=w(y);pt(C,17,()=>n,({value:S,label:A})=>S,(S,A)=>{let O=()=>u(A).value,E=()=>u(A).label;var M=pte();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=vt(M,1,"highlight-picker-swatch svelte-1d240y8",null,R,{"is-selected":O()===u(i)}),Le(D,`background: ${Wu[O()]??""};`)}),P("click",M,()=>c(O())),x(S,M)});var _=k(C,2);Ot(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(),Le(p,`background: ${Wu[u(i)]??""};`)}),P("mousedown",h,l),x(t,d),tt()}ut(["mousedown","click"]);var bte=T('<div class="fmtbar-divider svelte-1lcxsnm"></div> <!>',1),yte=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),wte=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 kte(t,e){et(e,!0);const n=Ye(e,"showAuthorship",3,!0),r=Ye(e,"showComments",3,!0),i=Ye(e,"showHighlights",3,!0),o=Ye(e,"showNotes",3,!0),s=Ye(e,"decorationsMuted",3,!1);let a=L(0);me(()=>{const S=e.editor;if(!S||S.isDestroyed)return;const A=()=>{S.isDestroyed||ju(a)};return S.on("selectionUpdate",A),S.on("transaction",A),()=>{S.off("selectionUpdate",A),S.off("transaction",A)}});const l=N(()=>(u(a),!e.editor||e.editor.isDestroyed||!e.ydoc?!1:!e.editor.state.selection.empty));let c=L(!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=gi(A.doc,zn(O)),R=gi(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}S4(e.ydoc,{from:M,to:R},S)}var f=wte(),h=w(f),p=w(h),m=w(p);C4(m,{get editor(){return e.editor}});var v=k(m,4);{let S=N(()=>!u(l));vte(v,{get disabled(){return u(S)},onHighlight:d,onOpenChange:A=>b(c,A,!0)})}var g=k(p,2);{var y=S=>{var A=bte(),O=k(Ae(A),2);_4(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=yte(),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(()=>Le(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),tt()}ut(["click"]);var xte=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 _te(t,e){et(e,!0);var n=xte(),r=w(n);let i;var o=k(r,2),s=k(o,2);W(()=>{i=vt(r,1,"thumb svelte-14q5edy",null,i,{tandem:e.tandemMode==="tandem"}),vt(o,1,Ih(e.tandemMode==="solo"?"on":""),"svelte-14q5edy"),U(o,"aria-pressed",e.tandemMode==="solo"),vt(s,1,Ih(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),tt()}ut(["click"]);const Cte=[{value:"system",label:"Match system"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"warm",label:"Warm"}];var Ste=T('<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>'),Ete=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>'),Ate=T('<div class="brand-menu-divider svelte-12l7ydf" role="separator"></div>'),Tte=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),Mte=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>'),Dte=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>'),Ote=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>'),Ite=T('<div class="title-bar-center svelte-12l7ydf" data-tauri-drag-region="false"><!></div>'),Rte=T('<button type="button" data-testid="titlebar-source-toggle" data-tauri-drag-region="false"><span aria-hidden="true">&lt;/&gt;</span></button>'),Nte=T('<span class="status-dot svelte-12l7ydf" data-tauri-drag-region="false" title="AI assistant is connected" aria-label="AI assistant is connected"></span>'),Pte=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>`),Lte=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>'),Fte=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>'),zte=rn('<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>'),Bte=rn('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>'),Hte=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),Vte=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 Ute(t,e){et(e,!0);let n=Ye(e,"claudeActive",3,!1),r=Ye(e,"theme",3,"system"),i=Ye(e,"settingsBtn",15,null),o=Ye(e,"updateAvailable",3,!1),s=Ye(e,"defaultModelLabel",3,null),a=Ye(e,"aiChip",3,null),l=Ye(e,"sourceViewActive",3,!1),c=Ye(e,"onToggleSourceView",3,null),d=L(null),f=L(!1),h=[],p=!0;Lc(async()=>{if(Tt())try{const[{invoke:J},{getCurrentWindow:ye}]=await Promise.all([Kt(()=>import("./core-DhEqZVGG.js"),[]),Kt(()=>import("./window-DePn7tLG.js").then(Oe=>Oe.w),__vite__mapDeps([10,1,3]))]);if(!p||(await J("setup_overlay_titlebar").catch(Oe=>{console.error("[TitleBar] setup_overlay_titlebar failed:",Oe)}),!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(Oe){console.warn("[TitleBar] isMaximized check failed on resize:",Oe)}});if(!p){se();return}h.push(se);const Te=await Y.onMoved(async()=>{try{b(f,await Y.isMaximized(),!0)}catch(Oe){console.warn("[TitleBar] isMaximized check failed on move:",Oe)}});if(!p){Te();return}h.push(Te)}catch(J){console.error("[TitleBar] Window API initialization failed:",J)}}),Dn(()=>{p=!1,h.forEach(J=>J())});async function m(){var J;try{await((J=u(d))==null?void 0:J.minimize())}catch(ye){console.error("[TitleBar] minimize failed:",ye)}}async function v(){var J;try{await((J=u(d))==null?void 0:J.toggleMaximize())}catch(ye){console.error("[TitleBar] toggleMaximize failed:",ye)}}async function g(){var J;try{await((J=u(d))==null?void 0:J.close())}catch(ye){console.error("[TitleBar] close failed:",ye)}}let y=L(!1),C=L(null);me(()=>{if(u(y))return Oy(()=>u(C)??i(),["mousedown"],()=>{b(y,!1)})});function _(){b(y,!u(y))}function S(){var J;b(y,!1),(J=i())==null||J.focus()}function A(J){J.key==="Escape"&&(J.stopPropagation(),S())}function O(J){var ye;(ye=e.onSetTheme)==null||ye.call(e,J),S()}function E(){var J;(J=e.onOpenSettings)==null||J.call(e),b(y,!1)}function M(){var J;(J=e.onOpenHelp)==null||J.call(e),b(y,!1)}var R=Vte(),D=w(R),I=w(D),B=k(w(I),2);{var z=J=>{var ye=Ste();x(J,ye)},Q=N(()=>Tt()&&o());j(B,J=>{u(Q)&&J(z)})}Ot(I,J=>i(J),()=>i());var ie=k(I,2);{var he=J=>{var ye=Ote(),Y=w(ye);{var se=ue=>{var re=Tte(),pe=k(Ae(re),2);pt(pe,21,()=>Cte,Me=>Me.value,(Me,Se)=>{var qe=Ete();let it;var ce=k(w(qe),2),Ie=w(ce);W(()=>{it=vt(qe,1,"brand-theme-sw svelte-12l7ydf",null,it,{on:r()===u(Se).value}),U(qe,"data-testid",`brand-menu-theme-${u(Se).value??""}`),U(qe,"data-theme-swatch",u(Se).value),U(qe,"aria-checked",r()===u(Se).value),G(Ie,u(Se).label)}),P("click",qe,()=>O(u(Se).value)),x(Me,qe)});var Ne=k(pe,2);{var xe=Me=>{var Se=Ate();x(Me,Se)};j(Ne,Me=>{(e.onOpenSettings||e.onOpenHelp)&&Me(xe)})}x(ue,re)};j(Y,ue=>{e.onSetTheme&&ue(se)})}var Te=k(Y,2);{var Oe=ue=>{var re=Mte();P("click",re,E),x(ue,re)};j(Te,ue=>{e.onOpenSettings&&ue(Oe)})}var ze=k(Te,2);{var Xe=ue=>{var re=Dte();P("click",re,M),x(ue,re)};j(ze,ue=>{e.onOpenHelp&&ue(Xe)})}Ot(ye,ue=>b(C,ue),()=>u(C)),P("keydown",ye,A),x(J,ye)};j(ie,J=>{u(y)&&J(he)})}var ae=k(D,4);{var ke=J=>{var ye=Ite(),Y=w(ye);jd(Y,()=>e.center),x(J,ye)};j(ae,J=>{e.center&&J(ke)})}var le=k(ae,4),be=w(le);{var Re=J=>{var ye=Rte();let Y;W(()=>{Y=vt(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(J,ye)};j(be,J=>{c()&&J(Re)})}var $=k(be,2);{var q=J=>{_te(J,{get tandemMode(){return e.tandemMode},get onModeChange(){return e.onModeChange}})};j($,J=>{e.tandemMode&&e.onModeChange&&J(q)})}var H=k($,2);{var ne=J=>{var ye=Nte();x(J,ye)};j(H,J=>{n()&&J(ne)})}var te=k(H,2);{var Z=J=>{var ye=Pte();P("click",ye,function(...Y){var se;(se=e.onConnectAi)==null||se.apply(this,Y)}),x(J,ye)},ge=J=>{var ye=Lte();P("click",ye,function(...Y){var se;(se=e.onRestartClaude)==null||se.apply(this,Y)}),x(J,ye)},De=J=>{var ye=Fte(),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 Oe;(Oe=e.onOpenModelsSettings)==null||Oe.apply(this,Te)}),x(J,ye)};j(te,J=>{a()==="connect"?J(Z):a()==="restart"?J(ge,1):s()&&e.onOpenModelsSettings&&J(De,2)})}var Ee=k(le,2);{var de=J=>{var ye=Hte(),Y=k(Ae(ye),2),se=w(Y),Te=k(se,2),Oe=w(Te);{var ze=re=>{var pe=zte();x(re,pe)},Xe=re=>{var pe=Bte();x(re,pe)};j(Oe,re=>{u(f)?re(ze):re(Xe,-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(J,ye)},_e=N(()=>Tt());j(Ee,J=>{u(_e)&&J(de)})}W(()=>U(I,"aria-expanded",u(y))),P("click",I,_),x(t,R),tt()}ut(["click","keydown"]);const L4="tandem-status-count-mode",Th=["words","characters","sentences","paragraphs","pages"],jte={words:"words",characters:"chars",sentences:"sentences",paragraphs:"paragraphs",pages:"pages"},qte=250;function d_(t){const e=t.trim();return e?e.split(/\s+/).length:0}function f_(t){const e=Th.indexOf(t);return Th[(e+1)%Th.length]??"words"}function P0(t){return jte[t]}function Wte(){try{const t=localStorage.getItem(L4);if(t&&Th.includes(t))return t}catch{}return"words"}function Kte(t){try{localStorage.setItem(L4,t)}catch{}}function Gte(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)/qte)}}var Zte=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>'),Yte=T('<span data-testid="save-indicator" style="color: var(--tandem-accent);" class="svelte-1esxubl">Saving...</span>'),Jte=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>'),Xte=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>'),Qte=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 $te(t,e){et(e,!0);let n=Ye(e,"claudeWorkingTool",3,null),r=Ye(e,"saving",3,!1);function i(H){return{tandem_edit:"editing",tandem_comment:"commenting",tandem_reply:"replying",tandem_annotationReply:"replying"}[H]??H.replace(/^tandem_/,"")}const o=2e3,s=B1(),a=Ao(oi());let l=L(at(s.userName)),c=L(void 0);me(()=>{const H=s.userName;u(l)!==H&&document.activeElement!==u(c)&&b(l,H,!0)});let d=L(!1),f=L(0),h=Mt(()=>e.connected);me(()=>{const H=h;if(h=e.connected,e.connected&&!H){b(d,!0);const ne=setTimeout(()=>{b(d,!1)},o);return()=>clearTimeout(ne)}}),me(()=>{if(e.disconnectedSince==null){b(f,0);return}b(f,Math.floor((Date.now()-e.disconnectedSince)/1e3),!0);const H=setInterval(()=>{b(f,Math.floor((Date.now()-(e.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(H)});const p=N(()=>e.connectionStatus==="connecting"),m=N(()=>e.connected?"var(--tandem-success)":u(p)?"var(--tandem-warning)":"var(--tandem-error)"),v=N(()=>u(d)?"Reconnected":e.connectionStatus==="connected"?"Synced":e.connectionStatus==="connecting"?(()=>{const H=["Reconnecting…"];if(e.reconnectAttempts>0||u(f)>0){const ne=[];e.reconnectAttempts>0&&ne.push(`attempt ${e.reconnectAttempts}`),u(f)>0&&ne.push(`${u(f)}s`),H.push(`(${ne.join(", ")})`)}return H.join(" ")})():"Disconnected — check that the server is running");function g(){s.setUserName(u(l))}let y=L(at(Wte())),C=L(0);me(()=>{const H=e.editor;if(!H||H.isDestroyed)return;const ne=()=>{H.isDestroyed||ju(C)};return H.on("update",ne),H.on("transaction",ne),()=>{H.off("update",ne),H.off("transaction",ne)}});const _=N(()=>(u(C),Gte(e.editor??null,u(y))));function S(){const H=f_(u(y));b(y,H,!0),Kte(H)}var A=Qte(),O=w(A),E=w(O),M=k(E,2),R=w(M),D=k(M,2);{var I=H=>{var ne=Zte(),te=w(ne);W((Z,ge,De,Ee)=>{U(ne,"title",Z),U(ne,"aria-label",ge),G(te,`${De??""} ${Ee??""}`)},[()=>`Click to cycle: ${P0(f_(u(y)))}`,()=>`${u(_)} ${P0(u(y))} (click to change unit)`,()=>u(_).toLocaleString(),()=>P0(u(y))]),P("click",ne,S),x(H,ne)};j(D,H=>{e.editor&&H(I)})}var B=k(D,2);{var z=H=>{var ne=Yte();x(H,ne)};j(B,H=>{r()&&H(z)})}var Q=k(O,2),ie=k(w(Q),2);Ot(ie,H=>b(c,H),()=>u(c));var he=k(Q,2);{var ae=H=>{var ne=Jte();x(H,ne)};j(he,H=>{e.readOnly&&H(ae)})}var ke=k(he,2),le=w(ke),be=k(le,2),Re=w(be),$=k(be,2);{var q=H=>{var ne=Xte(),te=k(w(ne),6),Z=w(te);W(ge=>G(Z,`${a.specific??""} is ${ge??""}…`),[()=>i(n())]),x(H,ne)};j($,H=>{n()&&H(q)})}W(()=>{Le(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)),Br(ie,u(l)),U(ie,"maxlength",fm),Le(le,`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"};`),Le(be,`transition: color 0.3s ease; color: ${e.claudeActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"};`),G(Re,e.claudeStatus?`${a.specific} · ${e.claudeStatus}`:`${a.specific} · idle`)}),P("input",ie,H=>{b(l,H.target.value,!0)}),hn("blur",ie,g),P("keydown",ie,H=>{H.key==="Enter"&&H.currentTarget.blur(),H.key==="Escape"&&(b(l,s.userName,!0),H.currentTarget.blur())}),x(t,A),tt()}ut(["click","input","keydown"]);function Iy(t){return t.source==="file"&&!t.readOnly}const ene={md:"md",markdown:"md",docx:"docx",doc:"docx",txt:"txt",text:"txt",html:"html",htm:"html"};function tne(t){const e=t.lastIndexOf(".");return e<=0||e===t.length-1?"other":ene[t.slice(e+1).toLowerCase()]??"other"}function nne(t){const e=t.split(/[/\\]/);return{name:e.at(-1)??t,dir:e.slice(0,-1).join("/")}}function rne(t,e=Date.now()){const{dir:n,name:r}=nne(t.path);return{path:t.path,name:r,dir:n,when:FO(t.openedAt,e),pip:tne(r)}}function ine(t,e){const n=e.trim().toLowerCase();return n?t.name.toLowerCase().includes(n)||t.dir.toLowerCase().includes(n):!0}function one(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 sne=rn("<path></path>"),ane=rn('<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>'),cne=T('<span class="ntl-count svelte-7c4il0" aria-hidden="true"> </span>'),une=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>`),dne=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>'),fne=T('<mark class="svelte-7c4il0"> </mark>'),hne=T('<span class="ntl-path svelte-7c4il0"> </span>'),pne=T('<span class="ntl-when svelte-7c4il0"> </span>'),mne=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>'),gne=T('<div class="ntl-recents svelte-7c4il0"></div>'),vne=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>'),bne=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 yne(t,e){et(e,!0);const n=($,q=kn,H=kn,ne=kn)=>{var te=ane();pt(te,21,()=>d[q()]??[],cc,(Z,ge)=>{var De=sne();W(()=>U(De,"d",u(ge))),x(Z,De)}),W(()=>{U(te,"width",H()),U(te,"height",H()),U(te,"stroke-width",ne())}),x($,te)};let r=L(""),i=L(null),o=L(null);const s=N(()=>e.recentFiles.map($=>rne($))),a=N(()=>u(s).filter($=>ine($,u(r)))),l=N(()=>u(s).length>0),c=N(()=>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 $;return Array.from((($=u(i))==null?void 0:$.querySelectorAll("[data-nav-item]"))??[])}function h($){var ne,te;const q=f();if(q.length===0)return;const H=q.indexOf(document.activeElement);if(H===-1){(ne=$>0?q[0]:q[q.length-1])==null||ne.focus();return}(te=q[(H+$+q.length)%q.length])==null||te.focus()}function p($){$.key==="Escape"?($.preventDefault(),e.onClose()):$.key==="ArrowDown"?($.preventDefault(),h(1)):$.key==="ArrowUp"&&($.preventDefault(),h(-1))}me(()=>{var $;u(i)&&(($=u(o))==null||$.focus({preventScroll:!0}))});var m=bne(),v=w(m),g=w(v),y=w(g);n(y,()=>"search",()=>13,()=>1.7);var C=k(g,2);Ot(C,$=>b(o,$),()=>u(o));var _=k(C,2);{var S=$=>{var q=lne();P("click",q,()=>b(r,"")),x($,q)};j(_,$=>{u(c)&&$(S)})}var A=k(_,2);{var O=$=>{var q=cne(),H=w(q);W(()=>G(H,`${u(a).length??""} of ${u(s).length??""}`)),x($,q)};j(A,$=>{u(l)&&$(O)})}var E=k(v,2),M=w(E),R=w(M);{var D=$=>{var q=une(),H=w(q),ne=w(H);n(ne,()=>"inbox",()=>16,()=>1.6),x($,q)},I=$=>{var q=dne(),H=w(q);W(ne=>G(H,`No matches for “${ne??""}”. `),[()=>u(r).trim()]),x($,q)},B=$=>{var q=gne();pt(q,23,()=>u(a),H=>H.path,(H,ne,te)=>{var Z=mne(),ge=w(Z),De=k(ge,2),Ee=w(De);pt(Ee,21,()=>one(u(ne).name,u(r)),cc,(Y,se)=>{var Te=St(),Oe=Ae(Te);{var ze=ue=>{var re=fne(),pe=w(re);W(()=>G(pe,u(se).text)),x(ue,re)},Xe=ue=>{var re=dr();W(()=>G(re,u(se).text)),x(ue,re)};j(Oe,ue=>{u(se).match?ue(ze):ue(Xe,-1)})}x(Y,Te)});var de=k(Ee,2);{var _e=Y=>{var se=hne(),Te=w(se);W(()=>G(Te,u(ne).dir)),x(Y,se)};j(de,Y=>{u(ne).dir&&Y(_e)})}var J=k(De,2);{var ye=Y=>{var se=pne(),Te=w(se);W(()=>G(Te,u(ne).when)),x(Y,se)};j(J,Y=>{u(ne).when&&Y(ye)})}W(()=>{U(Z,"data-testid",`new-tab-recent-${u(te)}`),U(Z,"title",u(ne).path),vt(ge,1,`ntl-pip ntl-pip-${u(ne).pip??""}`,"svelte-7c4il0")}),P("click",Z,()=>e.onOpen(u(ne).path)),x(H,Z)}),x($,q)};j(R,$=>{u(l)?u(a).length===0?$(I,1):$(B,-1):$(D)})}var z=k(M,2),Q=k(w(z),2),ie=w(Q),he=w(ie);n(he,()=>"plus",()=>14,()=>1.9);var ae=k(Q,4),ke=w(ae),le=w(ke);n(le,()=>"folder",()=>13,()=>1.7);var be=k(ae,2);{var Re=$=>{var q=vne(),H=w(q),ne=w(H);n(ne,()=>"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($,q)};j(be,$=>{e.closedTabTop&&$(Re)})}Ot(m,$=>b(i,$),()=>u(i)),P("keydown",m,p),zr(C,()=>u(r),$=>b(r,$)),P("click",Q,function(...$){var q;(q=e.onNewScratchpad)==null||q.apply(this,$)}),P("click",ae,function(...$){var q;(q=e.onBrowse)==null||q.apply(this,$)}),x(t,m),tt()}ut(["keydown","click"]);var wne=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 kne(t,e){et(e,!0);let n=L(at(Mt(()=>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=wne();Pc(()=>zr(a,()=>u(n),l=>b(n,l))),Ur(a,l=>o==null?void 0:o(l)),W(()=>U(a,"data-testid",e.testId)),P("keydown",a,s),hn("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),tt()}ut(["keydown","pointerdown","click","dblclick"]);var xne=T('<span class="dot svelte-1btt0ja" aria-hidden="true">●</span>'),_ne=T('<span class="saved-check svelte-1btt0ja" aria-hidden="true">✓</span>'),Cne=T('<span class="svelte-1btt0ja"> </span>'),Sne=T('<span class="tab-ro-badge svelte-1btt0ja" aria-label="Read-only">RO</span>'),Ene=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 Ane(t,e){et(e,!0);const n=Ye(e,"reduceMotion",3,!1),r=Ye(e,"isRenaming",3,!1),i=N(()=>Iy(e.tab));let o=L(!1),s=null;me(()=>{const{ydoc:R,readOnly:D}=e.tab;if(D){b(o,!1);return}const I=R.getXmlFragment("default"),B=R.getMap(Rh);let z=!1;const Q=setTimeout(()=>{z=!0,s=B.get(cw)??0,b(o,!1)},500),ie=()=>{z&&b(o,!0)};I.observeDeep(ie);const he=()=>{if(!z)return;const ae=B.get(cw);ae!==void 0&&ae!==s&&(s=ae,b(o,!1))};return B.observe(he),()=>{clearTimeout(Q),I.unobserveDeep(ie),B.unobserve(he)}});const a=600;let l=L(!1),c=!1;me(()=>{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=N(()=>["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=L(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=Ene();U(m,"tabindex",0);var v=w(m),g=w(v);{var y=R=>{var D=xne();x(R,D)},C=R=>{var D=_ne();x(R,D)};j(g,R=>{u(o)?R(y):u(l)&&R(C,1)})}var _=k(v,2);{var S=R=>{{let D=N(()=>`tab-rename-input-${e.tab.id}`);kne(R,{get initial(){return e.tab.fileName},get testId(){return u(D)},oncommit:I=>{var B;return(B=e.onrename)==null?void 0:B.call(e,e.tab.id,I)},oncancel:()=>{var I;return(I=e.onrenamecancel)==null?void 0:I.call(e)}})}},A=R=>{var D=Cne(),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),Le(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,B=>{var z;u(i)&&(B.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=Sne();x(R,D)};j(O,R=>{e.tab.readOnly&&R(E)})}var M=k(O,2);Ot(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),Le(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()),hn("mouseenter",M,h),hn("mouseleave",M,p),Wi(2,m,()=>eN,()=>({reduceMotion:n()})),x(t,m),tt()}ut(["click","pointerdown","keydown","dblclick"]);const Tne=["ctx:tab:close","ctx:tab:closeOthers","ctx:tab:closeRight","ctx:tab:copyPath","ctx:tab:reveal"],Mne=new Set(Tne);function Dne(t){return typeof t=="string"&&Mne.has(t)}function Mb(t){return!hm(t)&&!Cl(t)}function One(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&&Mb(r.filePath)}}function Ine(t,e){return t.some(n=>n.id===e)?t.filter(n=>n.id!==e).map(n=>n.id):[]}function Rne(t,e){const n=t.findIndex(r=>r.id===e);return n<0?[]:t.slice(n+1).map(r=>r.id)}var Nne=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 Pne(t,e){et(e,!0);const n=Ye(e,"reduceMotion",3,!1),r=Ye(e,"openMenuTrigger",3,0),i=Ye(e,"renameTrigger",3,0),o=Ye(e,"closedTabTop",3,null);let s=L(null);function a(V){b(s,V,!0)}function l(V,ee){var we;b(s,null),(we=e.onTabRename)==null||we.call(e,V,ee)}function c(){b(s,null)}const d=N(()=>n()?"auto":"smooth");let f=L(!1),h=L(at([])),p=L(null),m=L(!1),v=L(!1),g=L(null),y=new Set;me(()=>{const V=new Set(e.tabs.map(ee=>ee.id));for(const ee of y)V.has(ee)||y.delete(ee)});function C(V){y.has(V)||(y.add(V),e.onTabClose(V))}let _=null,S=null;async function A(V){var Fe;if(!Tt())return;const ee=(Fe=V.target)==null?void 0:Fe.closest('[data-testid^="tab-"][role="tab"]'),we=te(ee);if(!we)return;const Ve=e.tabs.find(K=>K.id===we);if(Ve){_=we,S=Ve.filePath,V.preventDefault();try{await(await ss())("show_tab_context_menu",{req:One(e.tabs,we)})}catch{}}}async function O(V){var Ve,Fe;const ee=_,we=S;if(ee)switch(V){case"ctx:tab:close":C(ee);return;case"ctx:tab:closeOthers":(Ve=e.onCloseOthers)==null||Ve.call(e,ee);return;case"ctx:tab:closeRight":(Fe=e.onCloseToRight)==null||Fe.call(e,ee);return;case"ctx:tab:copyPath":if(we&&Mb(we))try{await navigator.clipboard.writeText(we)}catch{}return;case"ctx:tab:reveal":if(we&&Mb(we))try{await(await ss())("show_in_file_manager",{path:we})}catch{}return}}let E=L(void 0),M=L(!1),R=L(!1),D=L(null),I=L(null),B=null,z=0,Q=0,ie=!1,he=null;const ae=5;function ke(V){Z(V)}function le(V){ge(V)}function be(V){B!==null&&V.pointerId===B&&$()}function Re(V){V.key==="Escape"&&$()}function $(){if(he&&B!==null)try{he.releasePointerCapture(B)}catch{}window.removeEventListener("pointermove",ke),window.removeEventListener("pointerup",le),window.removeEventListener("pointercancel",be),window.removeEventListener("keydown",Re),b(D,null),b(I,null),B=null,ie=!1,he=null}Dn($),me(()=>{if(!u(D)&&!u(I))return;const V=new Set(e.tabs.map(ee=>ee.id));u(D)&&!V.has(u(D))&&b(D,null),u(I)&&!V.has(u(I).id)&&b(I,null)});function q(){const V=u(E);V&&(b(M,V.scrollLeft>0),b(R,V.scrollLeft+V.clientWidth<V.scrollWidth-1))}me(()=>{const V=u(E);if(!V)return;q(),V.addEventListener("scroll",q,{passive:!0});const ee=new ResizeObserver(q);return ee.observe(V),()=>{V.removeEventListener("scroll",q),ee.disconnect()}}),me(()=>{const V=u(E);if(V)return V.addEventListener("contextmenu",A),()=>V.removeEventListener("contextmenu",A)}),me(()=>{if(!Tt())return;const V=Kt(async()=>{const{listen:ee}=await import("./event-CNdo2oXa.js");return{listen:ee}},__vite__mapDeps([3,1])).then(({listen:ee})=>ee("context-menu-action",we=>{var Fe;const Ve=(Fe=we.payload)==null?void 0:Fe.id;Dne(Ve)&&O(Ve)}));return V.catch(()=>{}),()=>{V.then(ee=>ee()).catch(()=>{})}}),me(()=>{e.tabs.length,q()}),me(()=>{if(!e.activeTabId||!u(E))return;const V=u(E).querySelector(`[data-testid="tab-${e.activeTabId}"]`);V&&V.scrollIntoView({inline:"nearest",block:"nearest",behavior:u(d)})});function H(V,ee){if(!(V.button!==0||u(Ee))){B=V.pointerId,z=V.clientX,Q=V.clientY,ie=!1,b(D,ee,!0),he=V.currentTarget;try{he.setPointerCapture(V.pointerId)}catch{}window.addEventListener("pointermove",ke),window.addEventListener("pointerup",le),window.addEventListener("pointercancel",be),window.addEventListener("keydown",Re)}}function ne(V,ee){var Ve;return((Ve=document.elementFromPoint(V,ee))==null?void 0:Ve.closest('[data-testid^="tab-"][role="tab"]'))??null}function te(V){var ee;return((ee=V==null?void 0:V.getAttribute("data-testid"))==null?void 0:ee.slice(4))??null}function Z(V){if(B===null||V.pointerId!==B||!u(D))return;if(!ie){const fe=V.clientX-z,Pe=V.clientY-Q;if(Math.hypot(fe,Pe)<ae)return;ie=!0}V.preventDefault();const ee=ne(V.clientX,V.clientY),we=te(ee);if(!ee||!we||we===u(D)){b(I,null);return}const Ve=ee.getBoundingClientRect(),Fe=Ve.left+Ve.width/2,K=V.clientX<Fe?"left":"right";b(I,{id:we,side:K},!0)}function ge(V){if(B===null||V.pointerId!==B)return;const ee=ie,we=u(I);if(ee&&u(D)&&we&&we.id!==u(D)&&e.reorder&&e.tabs.some(Ve=>Ve.id===u(D))&&e.tabs.some(Ve=>Ve.id===we.id)&&e.reorder(u(D),we.id,we.side),ee){let Ve;const Fe=K=>{K.stopPropagation(),K.preventDefault(),window.removeEventListener("click",Fe,!0),clearTimeout(Ve)};window.addEventListener("click",Fe,!0),Ve=setTimeout(()=>window.removeEventListener("click",Fe,!0),0)}$()}function De(V,ee){if(!V.altKey||!e.reorder||V.key!=="ArrowLeft"&&V.key!=="ArrowRight")return;V.preventDefault();const we=e.tabs.findIndex(Ve=>Ve.id===ee);we!==-1&&(V.key==="ArrowLeft"&&we>0?e.reorder(ee,e.tabs[we-1].id):V.key==="ArrowRight"&&we<e.tabs.length-1&&e.reorder(e.tabs[we+1].id,ee))}const Ee=N(()=>e.tabs.length<=1);function de(){const V=!u(f);if(V)b(h,Fw(),!0),Xe=document.activeElement,b(m,Y(),!0);else{_e();return}b(f,V)}function _e(){var ee;const V=document.activeElement;V&&((ee=u(g))!=null&&ee.contains(V))&&V.blur(),b(f,!1)}const J=460,ye=8;function Y(){if(!u(p))return!1;const V=u(p).getBoundingClientRect(),ee=window.innerWidth,we=Math.min(J,ee-2*ye);return V.right-we>=ye?!1:V.left+we<=ee-ye?!0:ee-V.left>V.right}let se=null;function Te(V){if(!u(g))return Number.NaN;const ee=getComputedStyle(u(g)).getPropertyValue(V).trim();return ee.endsWith("ms")?parseFloat(ee):ee.endsWith("s")?parseFloat(ee)*1e3:parseFloat(ee)}function Oe(){if(!u(g))return 0;const V=Te("--morph-p1")+Te("--morph-p2");return Number.isFinite(V)&&V>0?V+40:0}me(()=>{if(u(f)){se&&(clearTimeout(se),se=null),b(v,!0);return}if(!Mt(()=>u(v)))return;se&&clearTimeout(se);const V=Oe();if(V<=0){b(v,!1);return}se=setTimeout(()=>{b(v,!1),se=null},V)}),Dn(()=>{se&&clearTimeout(se)});let ze=!1,Xe=null;me(()=>{if(!u(f))return;function V(ee){var Ve,Fe;const we=ee.target;we&&((Ve=u(p))!=null&&Ve.contains(we)||(Fe=we.closest)!=null&&Fe.call(we,".new-tab-menu")||f$(we)||(ze=!0,_e()))}return window.addEventListener("pointerdown",V,!0),()=>window.removeEventListener("pointerdown",V,!0)});let ue=!1;me(()=>{var ee;if(u(f)){ue=!0;return}if(!ue)return;ue=!1;const V=Xe;if(Xe=null,ze){ze=!1;return}V&&V.isConnected&&V!==u(p)&&!((ee=u(g))!=null&&ee.contains(V))&&V.focus({preventScroll:!0})}),me(()=>{r()>0&&Mt(de)}),me(()=>{i()>0&&Mt(()=>{const V=e.tabs.find(ee=>ee.id===e.activeTabId);V&&Iy(V)&&b(s,V.id,!0)})});var re=Nne(),pe=w(re);pt(pe,21,()=>e.tabs,V=>V.id,(V,ee)=>{{let we=N(()=>u(ee).id===e.activeTabId),Ve=N(()=>{var K;return((K=u(I))==null?void 0:K.id)===u(ee).id?u(I).side:null}),Fe=N(()=>u(s)===u(ee).id);Ane(V,{get tab(){return u(ee)},get isActive(){return u(we)},get onswitch(){return e.onTabSwitch},onclose:C,onpointerdown:H,get dropIndicator(){return u(Ve)},onkeydown:De,get reduceMotion(){return n()},get isRenaming(){return u(Fe)},onstartrename:a,onrename:l,onrenamecancel:c})}}),Ot(pe,V=>b(E,V),()=>u(E));var Ne=k(pe,2),xe=w(Ne);let Me;var Se=w(xe);Ot(Se,V=>b(p,V),()=>u(p));var qe=k(Se,2),it=w(qe),ce=w(it);{var Ie=V=>{yne(V,{get recentFiles(){return u(h)},get closedTabTop(){return o()},onOpen:async ee=>{_e();const we=await ls(ee);we.ok?Kd(Wd(Fw(),ee)):console.warn("[tandem] failed to open recent file:",we.error)},onNewScratchpad:()=>{_e(),Uh()},onBrowse:()=>{var ee;_e(),(ee=e.onRequestOpenDialog)==null||ee.call(e)},onReopenClosed:()=>{var ee;_e(),(ee=e.onReopenClosed)==null||ee.call(e)},onClose:_e})};j(ce,V=>{u(v)&&V(Ie)})}Ot(xe,V=>b(g,V),()=>u(g)),W(()=>{vt(pe,1,Ih(["tab-scroll-hide","tab-scroll-mask",u(M)&&u(R)&&"has-overflow",u(M)&&!u(R)&&"overflow-left",!u(M)&&u(R)&&"overflow-right"])),Me=vt(xe,1,"nt-morph svelte-urrc8n",null,Me,{open:u(f),filled:u(f)||u(v),"grow-right":u(m)}),U(Se,"aria-expanded",u(f)),it.inert=!u(f)}),P("click",Se,de),x(t,re),tt()}ut(["click"]);const h_=(t,e=kn,n=kn)=>{var r=Fne();W(()=>{vt(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 Lne=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>'),Fne=T('<div role="button" tabindex="-1"></div>'),zne=T("<!> <!> <!>",1),Bne=T('<div class="margin-track svelte-y74n0s" style="grid-column: 2; grid-row: 1;"><!></div>'),Hne=T('<div class="margin-track svelte-y74n0s" style="grid-column: 4; grid-row: 1;"><!></div>'),Vne=T('<div class="editor-content-track svelte-y74n0s" style="grid-column: 3; grid-row: 1;"><!></div> <!> <!>',1),Une=T('<div class="editor-end-marker svelte-y74n0s" aria-hidden="true"><span class="editor-end-pill svelte-y74n0s">End of document</span></div>'),jne=T('<div data-testid="editor-stage"><!></div> <!>',1),qne=T('<div data-testid="editor-scroll-container" role="region" aria-label="Document editor"><!> <!> <!> <!></div>'),Wne=T('<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>'),Kne=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>'),Gne=T('<span class="rail-tab-badge svelte-y74n0s"> </span>'),Zne=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),Yne=T('<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>');function Jne(t,e){et(e,!0);const n=F=>{Pne(F,{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(ee)},onTabRename:(X,ve)=>o.handleTabRename(X,ve,Ze=>E.push({id:pl(),type:"launcher",severity:"error",message:Ze,timestamp:Date.now()})),get renameTrigger(){return u(we)},get closedTabTop(){return a.top},onReopenClosed:h})},r=(F,X=kn,ve=kn,Ze=kn,$e=kn)=>{var Pt=Lne();U(Pt,"aria-valuemin",0),U(Pt,"aria-valuemax",100),W(Zt=>{U(Pt,"data-testid",Ze()??`${X()}-panel-resize-handle`),U(Pt,"aria-label",X()==="left"?"Resize left panel":"Resize right panel"),U(Pt,"aria-valuenow",Zt)},[()=>$e()!==void 0?Math.round(($e()-Jl)/(Md-Jl)*100):50]),P("mousedown",Pt,function(...Zt){var us;(us=ve())==null||us.apply(this,Zt)}),P("keydown",Pt,Zt=>{let Mr=null;Zt.key==="ArrowRight"||Zt.key==="ArrowUp"?Mr=16:Zt.key==="ArrowLeft"||Zt.key==="ArrowDown"?Mr=-16:Zt.key==="PageUp"?Mr=80:Zt.key==="PageDown"?Mr=-80:Zt.key==="Home"?Mr=Jl-(X()==="left"?K.width:fe.width):Zt.key==="End"&&(Mr=Md-(X()==="left"?K.width:fe.width)),Mr!==null&&(Zt.preventDefault(),Zt.stopPropagation(),X()==="left"?K.handleResizeStep(Mr):fe.handleResizeStep(Mr))}),P("keyup",Pt,()=>{}),hn("mouseenter",Pt,Zt=>{Zt.currentTarget.style.background="var(--tandem-border-strong)"}),hn("mouseleave",Pt,Zt=>{Zt.currentTarget.style.background="transparent"}),x(F,Pt)},i=F=>{var X=qne();let ve;{const Ni=dn=>{KQ(dn,{get ydoc(){return u(Je).ydoc},get provider(){return u(Je).provider},get readOnly(){return u(vn)},get currentFilePath(){return u(Je).filePath},get format(){return u(Je).format},get activeAnnotationId(){return u(Oe)},onEditorReady:fn=>b(ue,fn,!0),onAnnotationClick:fn=>{b(se,"annotations"),b(Oe,fn,!0)},onClearAnnotation:()=>{b(Oe,null)},onSlashCommandMenuChange:fn=>b(pe,fn,!0)})},wr=(dn,fn=kn,tr=kn)=>{const Pi=N(()=>fn()==="left"?rt.leftGeometry:rt.rightGeometry),ds=N(()=>fn()==="left"?rt.leftMode:rt.rightMode);lte(dn,{get side(){return fn()},get annotations(){return tr()},get positions(){return Ri.byId},get width(){return u(Pi).column},get edgeInset(){return u(Pi).inset},get gap(){return u(Pi).gap},get mode(){return u(ds)},get activeAnnotationId(){return u(Oe)},get repliesById(){return cl.byId},get reduceMotion(){return m.settings.reduceMotion},onClick:fs=>{b(Oe,fs.id,!0),En.scrollToAnnotation(fs)},get onAccept(){return En.handleAccept},get onDismiss(){return En.handleDismiss},get onRemove(){return u(ul).onRemove},get onEdit(){return u(ul).onEdit},get onReply(){return u(ul).onReply},get onSendToClaude(){return u(ul).onSendToClaude}})};var Ze=w(X);{let dn=N(()=>{var tr;return u(vn)&&((tr=u(Je))==null?void 0:tr.format)==="docx"}),fn=N(()=>{var tr;return(tr=u(Je))==null?void 0:tr.id});rz(Ze,{get visible(){return u(dn)},get documentId(){return u(fn)}})}var $e=k(Ze,2);{var Pt=dn=>{zI(dn,{get ydoc(){return u(Je).ydoc},get documentId(){return u(Je).id},get fileName(){return u(Je).fileName}})};j($e,dn=>{u(Je)&&u(Je).format==="docx"&&dn(Pt)})}var Zt=k($e,2);{var us=dn=>{var fn=St(),tr=Ae(fn);Fl(tr,()=>u(Je).id,Pi=>{{let ds=N(()=>u(Se).get(u(Je).id));l$(Pi,{get documentId(){return u(Je).id},get ydoc(){return u(Je).ydoc},get initialDraft(){return u(ds)},onDraftChange:(fs,Zc)=>it(u(Je).id,fs,Zc),onExit:()=>cr(u(Je).id)})}}),x(dn,fn)},ff=dn=>{var fn=jne(),tr=Ae(fn),Pi=w(tr);{var ds=Dr=>{var Wr=zne(),hs=Ae(Wr);Fl(hs,()=>u(Je).id,Or=>{Ni(Or)});var dl=k(hs,2);{var la=Or=>{wr(Or,()=>"left",()=>u(qr))};j(dl,Or=>{rt.leftVisible&&u(Je)&&Or(la)})}var fl=k(dl,2);{var ps=Or=>{wr(Or,()=>"right",()=>u(Ii))};j(fl,Or=>{rt.rightVisible&&u(Je)&&Or(ps)})}x(Dr,Wr)},fs=Dr=>{var Wr=Vne(),hs=Ae(Wr),dl=w(hs);{var la=Pn=>{var eo=St(),ca=Ae(eo);Fl(ca,()=>u(Je).id,Yc=>{Ni(Yc)}),x(Pn,eo)},fl=Pn=>{WI(Pn,{get connected(){return o.connected},get aiChip(){return z.chip},onOpenFile:()=>b(ne,!0),onRetry:()=>o.reconnect(),onOpenSettings:De,onConnectAi:Q,onRestartClaude:ie})};j(dl,Pn=>{u(Je)?Pn(la):Pn(fl,-1)})}var ps=k(hs,2);{var Or=Pn=>{var eo=Bne(),ca=w(eo);wr(ca,()=>"left",()=>u(qr)),x(Pn,eo)};j(ps,Pn=>{rt.leftVisible&&u(Je)&&Pn(Or)})}var pf=k(ps,2);{var sg=Pn=>{var eo=Hne(),ca=w(eo);wr(ca,()=>"right",()=>u(Ii)),x(Pn,eo)};j(pf,Pn=>{rt.rightVisible&&u(Je)&&Pn(sg)})}x(Dr,Wr)};j(Pi,Dr=>{var Wr;((Wr=u(Je))==null?void 0:Wr.format)==="docx"?Dr(ds):Dr(fs,-1)})}Ot(tr,Dr=>b(re,Dr),()=>u(re));var Zc=k(tr,2);{var hf=Dr=>{var Wr=Une();x(Dr,Wr)};j(Zc,Dr=>{u(Je)&&Dr(hf)})}W(()=>Le(tr,rt.layerStyle)),x(dn,fn)};j(Zt,dn=>{u(zt)&&u(Je)?dn(us):dn(ff,-1)})}var Mr=k(Zt,2);n$(Mr,{get editor(){return u(ue)},get open(){return u(Ne)},onClose:()=>b(Ne,!1),get tabs(){return o.tabs},get forceScope(){return u(xe)}}),Ot(X,dn=>b(Ct,dn),()=>u(Ct)),Ur(X,(dn,fn)=>Yt==null?void 0:Yt(dn,fn),()=>"y")}W(()=>{ve=vt(X,1,"editor-scroll tandem-scroll-fade-y",null,ve,{"hide-raw-md":!m.settings.showRawMarkdown}),Le(X,`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||O0.fileDragOver?"2px dashed var(--tandem-accent)":"2px solid transparent"}; background: ${R.fileDragOver||O0.fileDragOver?"var(--tandem-accent-bg)":"var(--tandem-bg)"}; transition: border-color 0.15s, background 0.15s; border-radius: ${R.fileDragOver||O0.fileDragOver?"var(--tandem-r-5)":"0"};`)}),hn("dragover",X,function(...Ni){var wr;(wr=R.handleEditorDragOver)==null||wr.apply(this,Ni)}),hn("dragleave",X,function(...Ni){var wr;(wr=R.handleEditorDragLeave)==null||wr.apply(this,Ni)}),hn("drop",X,function(...Ni){var wr;(wr=R.handleEditorDrop)==null||wr.apply(this,Ni)}),x(F,X)},o=Uee();Dn(()=>o.destroy());const s=hee(()=>o.tabs);Dn(()=>s.destroy());const a=G$(),l=new Set;function c(F){const X=o.tabs.find(ve=>ve.id===F);if(X&&hm(X.filePath)){const ve=FC(X.filePath);if(ve&&s.hasUnsavedContent(ve)){if(!window.confirm("This scratchpad has unsaved content that will be lost. Close it anyway?"))return;s.clearUnsaved(ve)}}if(!(u(qe).has(F)&&!window.confirm("This document has unsaved markdown-source edits that will be lost. Close it anyway?"))){if(X&&!Cl(X.filePath)&&a.push({filePath:X.filePath,closedAt:Date.now()}),u(Me).has(F)){const ve=new Set(u(Me));ve.delete(F),b(Me,ve,!0)}ce(F),Nt.delete(F),o.handleTabClose(F)}}function d(F){for(const X of Ine(p.orderedTabs,F))c(X)}function f(F){for(const X of Rne(p.orderedTabs,F))c(X)}async function h(){const F=a.pop();if(!F)return;const X=o.tabs.find(Ze=>Ze.filePath===F.filePath);if(X){o.setActiveTabId(X.id);return}if(l.has(F.filePath))return;l.add(F.filePath);const ve=Ze=>{a.push(F);const $e=F.filePath.split(/[\\/]/).pop()||F.filePath;E.push({id:`reopen-failed-${Date.now()}`,type:"general-error",severity:"error",message:`Couldn't reopen ${$e}: ${Ze}`,dedupKey:`reopen-failed:${F.filePath}`,timestamp:Date.now()})};try{const Ze=await ls(F.filePath);Ze.ok||ve(Ze.error)}finally{l.delete(F.filePath)}}const p=bee(()=>o.tabs);mee(()=>p.orderedTabs,()=>o.activeTabId,F=>o.setActiveTabId(F)),me(()=>{const F=o.tabs;if(F.length!==0)try{const X=gc();let ve=X;for(const Ze of F)Cl(Ze.filePath)||(ve=Wd(ve,Ze.filePath));(ve.length!==X.length||ve.some((Ze,$e)=>Ze!==X[$e]))&&Kd(ve)}catch(X){console.warn("[tandem] failed to sync recent files:",X)}});const m=oi(),v=yee(()=>o.bootstrapYdoc,()=>m.settings.selectionDwellMs),g=Xee(m,v),y=N(()=>JC(m.settings.customShortcuts)),C=N(()=>bO(u(y))),_=N(()=>o.annotations),S=Z$(()=>o.disconnectedSince,()=>m.settings.degradedBannerDelayMs),A=Pee();Fee();const O=N(()=>o.tabs.map(F=>({id:F.id,fileName:F.fileName}))),E=fee();let M=L(!1);const R=tee();if(xee(E.push),Tt()){let F=null,X=!1;Kt(async()=>{const{listen:ve}=await import("./event-CNdo2oXa.js");return{listen:ve}},__vite__mapDeps([3,1])).then(({listen:ve})=>ve("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(ve=>{X?ve():F=ve}).catch(ve=>{console.warn("[App] Failed to wire sidecar-restart-failed listener:",ve)}),Dn(()=>{X=!0,F==null||F()})}if(Tt()){let F=null,X=!1;Kt(async()=>{const{listen:ve}=await import("./event-CNdo2oXa.js");return{listen:ve}},__vite__mapDeps([3,1])).then(({listen:ve})=>ve("open-integration-wizard",()=>{window.dispatchEvent(new CustomEvent("tandem:open-integration-wizard"))})).then(ve=>{X?ve():F=ve}).catch(ve=>{console.warn("[App] Failed to wire open-integration-wizard listener:",ve),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(()=>{X=!0,F==null||F()})}if(Tt()){const F=$e=>{switch($e){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."}},X=$e=>{E.push({id:`startup-file-rejected-${Date.now()}`,type:"general-error",severity:"warning",message:F($e),dedupKey:"startup-file-rejected",timestamp:Date.now(),errorCode:"STARTUP_FILE_REJECTED"})};let ve=null,Ze=!1;Kt(async()=>{const{listen:$e}=await import("./event-CNdo2oXa.js");return{listen:$e}},__vite__mapDeps([3,1])).then(({listen:$e})=>$e("startup-file-rejected",Pt=>{X(typeof Pt.payload=="string"?Pt.payload:"")})).then($e=>{Ze?$e():ve=$e}).catch($e=>{console.warn("[App] Failed to wire startup-file-rejected listener:",$e)}),Kt(async()=>{const{invoke:$e}=await import("./core-DhEqZVGG.js");return{invoke:$e}},[]).then(({invoke:$e})=>$e("get_startup_rejection")).then($e=>{$e&&X($e)}).catch($e=>{console.warn("[App] Failed to poll buffered startup rejection:",$e)}),Dn(()=>{Ze=!0,ve==null||ve()})}let D=L(!1),I=L(!1);const B=nee(),z=V$({connected:()=>o.connected,firstRunSettled:()=>B.settled,soloMode:()=>v.tandemMode==="solo"});function Q(){window.dispatchEvent(new CustomEvent("tandem:open-integration-wizard"))}function ie(){$O(),setTimeout(()=>z.refresh(),2e3),setTimeout(()=>z.refresh(),5e3)}me(()=>{const F=async X=>{var Pt;const ve=(Pt=X.detail)==null?void 0:Pt.via;if(z.chip===null||await z.probeSession())return;const Ze=z.chip;if(Ze===null)return;const $e=ve==="comment"?"Comment":"Message";E.push({id:`ai-not-ready-${ve??"chat"}-${Date.now()}`,type:"launcher",severity:"warning",message:`${$e} saved — no AI is connected yet. It'll be seen when AI connects.`,dedupKey:`ai-not-ready-${ve??"chat"}`,timestamp:Date.now()},{label:Ze==="connect"?"Connect AI":"Restart Claude Code",onClick:Ze==="connect"?Q:ie})};return window.addEventListener("tandem:addressed-ai",F),()=>window.removeEventListener("tandem:addressed-ai",F)});const he="tandem:wizard-dismissed";let ae=L(at(le())),ke=L(!1);function le(){try{return localStorage.getItem(he)}catch{return null}}const be=N(()=>B.needed===!0&&B.serverVersion!==null&&u(ae)!==B.serverVersion),Re=N(()=>u(ke)||u(be));function $(){if(u(be)&&B.serverVersion!==null)try{localStorage.setItem(he,B.serverVersion),b(ae,B.serverVersion,!0)}catch{}b(ke,!1)}me(()=>{const F=X=>{X.key===he&&b(ae,X.newValue,!0)};return window.addEventListener("storage",F),()=>window.removeEventListener("storage",F)}),me(()=>{const F=()=>{b(ke,!0),b(I,!1),B.refetch()};return window.addEventListener("tandem:open-integration-wizard",F),()=>window.removeEventListener("tandem:open-integration-wizard",F)});let q=L(null),H=L(!1),ne=L(!1);function te(){return ZI({isTauri:Tt(),openModal:()=>{b(ne,!0)},onError:F=>E.push({id:pl(),type:"general-error",severity:"error",message:F,timestamp:Date.now()})})}const Z=Nee();function ge(){u(D)||Z.acknowledge(),b(D,!u(D))}function De(){Z.acknowledge(),b(I,!0)}let Ee=L(null);function de(){u(I)||b(Ee,GE.models,!0),De()}function _e(){Z.acknowledge(),b(D,!0)}VO({getActiveTabId:()=>o.activeTabId,getActiveDocumentPath:()=>{const F=o.tabs.find(X=>X.id===o.activeTabId);return F&&!Cl(F.filePath)?F.filePath:null},notify:(F,X)=>{E.push({id:`launcher-${Date.now()}`,type:"launcher",severity:F,message:X,timestamp:Date.now()})},openSettings:_e,openSettingsModal:De,toggleSoloMode:()=>v.setTandemMode(v.tandemMode==="solo"?"tandem":"solo"),openFindBar:()=>{b(xe,"doc"),b(Ne,!0)},openFindBarTabs:()=>{b(xe,"tabs"),b(Ne,!0)},findNext:()=>{const F=u(ue),X=F?Zl(F.state):void 0;F&&M0(X)?F.commands.findNext():(b(xe,"doc"),b(Ne,!0))},findPrev:()=>{const F=u(ue),X=F?Zl(F.state):void 0;F&&M0(X)?F.commands.findPrev():(b(xe,"doc"),b(Ne,!0))},closeActiveTab:()=>{const F=o.activeTabId;F&&c(F)},openFileDialog:()=>void te(),toggleLeftPanel:()=>We(),toggleRightPanel:()=>Ue(),reopenClosedTab:()=>void h(),annotationNext:()=>{const F=vu(u(_)),X=Vk(F,u(Oe));if(X){b(Oe,X,!0);const ve=F.find(Ze=>Ze.id===X);ve&&En.scrollToAnnotation(ve)}},annotationPrev:()=>{const F=vu(u(_)),X=Uk(F,u(Oe));if(X){b(Oe,X,!0);const ve=F.find(Ze=>Ze.id===X);ve&&En.scrollToAnnotation(ve)}},annotationAccept:()=>{const F=An();F&&F.author!=="user"&&En.handleAccept(F.id)},annotationDismiss:()=>{const F=An();F&&F.author!=="user"&&En.handleDismiss(F.id)},selectBlock:()=>{var F;return(F=u(ue))==null?void 0:F.chain().focus().selectParentNode().run()},toggleAuthorship:()=>J(!m.settings.showAuthorship),toggleFormattingBar:()=>m.updateSettings({formattingBarVisible:!m.settings.formattingBarVisible}),toggleSourceView:()=>Mn(),saveAs:async()=>{const F=o.tabs.find(Ze=>Ze.id===o.activeTabId);if(!F||!Cl(F.filePath)){E.push({id:pl(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const X=Math.max(F.filePath.lastIndexOf("/"),F.filePath.lastIndexOf("\\")),ve=F.filePath.slice(X+1);await zw({activeDocId:o.activeTabId,defaultName:ve,sourceFormat:F.format,notify:(Ze,$e)=>E.push({id:pl(),type:"launcher",severity:Ze,message:$e,timestamp:Date.now()})})}});function J(F){m.updateSettings({showAuthorship:F,...m.settings.decorationsMuted?{decorationsMuted:!1}:{}})}let ye=null;me(()=>{const F=u(ue);if(!F)return;const X=m.settings,ve=!X.decorationsMuted&&X.showAuthorship;if(ye===ve)return;const Ze=ye===null;ye=ve,!Ze&&Mt(()=>{const $e=F.state.tr.setMeta(Ml,{type:"toggle",visible:ve});F.view.dispatch($e)})});let Y=null;me(()=>{const F=u(ue);if(!F)return;const X=m.settings,ve=X.decorationsMuted,Ze={comment:!ve&&X.showComments,highlight:!ve&&X.showHighlights,note:!ve&&X.showNotes},$e=`${Ze.comment?1:0}${Ze.highlight?1:0}${Ze.note?1:0}`;if(Y===$e)return;const Pt=Y===null;Y=$e,!Pt&&Mt(()=>{const Zt=F.state.tr.setMeta(yu,{type:"toggle-decorations",visible:Ze});F.view.dispatch(Zt)})}),me(()=>(document.body.classList.toggle("tandem-reduce-motion",m.settings.reduceMotion),()=>document.body.classList.remove("tandem-reduce-motion"))),Aee(()=>m.settings.theme,()=>m.settings.systemLightVariant),B$(()=>m.settings.accentHue),eee(()=>{var F;return OO(m.settings,(F=u(Je))==null?void 0:F.format)}),J$(()=>m.settings.density),iee(()=>m.settings.highContrast),j$(()=>m.settings.annotationPatterns),me(()=>{const F=EO[m.settings.textSize];return document.documentElement.style.setProperty("--tandem-editor-font-size",`${F}px`),()=>document.documentElement.style.removeProperty("--tandem-editor-font-size")});let se=L(at(m.settings.primaryTab==="chat"?"chat":"annotations"));const Te=N(()=>u(se)==="annotations"?0:u(_).filter(Bh).length);let Oe=L(null),ze=L(!1),Xe=L(null),ue=L(null),re=L(null),pe=L(!1),Ne=L(!1),xe=L("doc"),Me=L(at(new Set)),Se=L(at(new Map)),qe=L(at(new Set));function it(F,X,ve){const Ze=new Map(u(Se)),$e=new Set(u(qe));ve?(Ze.set(F,X),$e.add(F)):(Ze.delete(F),$e.delete(F)),b(Se,Ze,!0),b(qe,$e,!0)}function ce(F){if(!u(Se).has(F)&&!u(qe).has(F))return;const X=new Map(u(Se)),ve=new Set(u(qe));X.delete(F),ve.delete(F),b(Se,X,!0),b(qe,ve,!0)}let Ie=L(0),V=L(0),ee=L(0),we=L(0);const Ve=Z2("left"),Fe=Z2("right"),K=Y2({side:"left",initialWidth:Ve,getVisible:()=>u(Pe)}),fe=Y2({side:"right",initialWidth:Fe,getVisible:()=>u(Be)}),Pe=N(()=>g.leftVisible),Be=N(()=>g.rightVisible);function Ke(F,X){queueMicrotask(()=>{const ve=X?`panel-edge-collapse-${F}`:`peek-strip-${F}`,Ze=document.querySelector(`[data-testid="${ve}"]`);Ze?Ze.focus():console.warn(`[tandem] focusToggleTarget: ${ve} not mounted; focus dropped to body`)})}const We=()=>{const F=!g.leftVisible;g.toggleLeft(),Ke("left",F)},Ue=()=>{const F=!g.rightVisible;g.toggleRight(),Ke("right",F)},nt=Lee(),rt=Jee({getFormat:()=>{var F;return(F=u(Je))==null?void 0:F.format},getMarginView:()=>m.settings.marginView,getEditorMeasure:()=>m.settings.editorMeasure,getLeftRailVisible:()=>u(Pe),getRightRailVisible:()=>u(Be),getViewportWidth:()=>nt.width,getLeftHasPending:()=>u(_).some(F=>F.status==="pending"&&a_(F)),getRightHasPending:()=>u(_).some(F=>F.status==="pending"&&l_(F)),leftRailWidthPx:Ve,rightRailWidthPx:Fe});function xt(){if(u(se)==="chat"||!u(ue))return;const{from:F,to:X}=u(ue).state.selection;if(F===X)return;const ve=TE(u(ue).state.doc,{from:zn(F),to:zn(X)}),Ze=u(ue).state.doc.textBetween(F,X,`
261
- `);b(Xe,{...ve,textSnapshot:Ze.length>200?Ze.slice(0,197)+"...":Ze},!0)}const qt={"toggle-help":F=>{const X=F.target;X&&(X.tagName==="INPUT"||X.tagName==="TEXTAREA"||X.isContentEditable)||(F.preventDefault(),b(ze,Mt(()=>!u(ze)),!0))},"select-all":F=>{var ve,Ze;const X=document.activeElement;X instanceof HTMLInputElement||X instanceof HTMLTextAreaElement||(ve=X==null?void 0:X.closest)!=null&&ve.call(X,".ProseMirror")||(F.preventDefault(),(Ze=u(ue))==null||Ze.commands.selectAll())},save:F=>{F.preventDefault(),!u(zt)&&mv(o.activeTabId)},"save-as":F=>{const X=F.target;if(X&&(X.tagName==="INPUT"||X.tagName==="TEXTAREA"||X.isContentEditable))return;F.preventDefault();const ve=o.tabs.find(Pt=>Pt.id===o.activeTabId);if(!ve||!Cl(ve.filePath)){E.push({id:pl(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const Ze=Math.max(ve.filePath.lastIndexOf("/"),ve.filePath.lastIndexOf("\\")),$e=ve.filePath.slice(Ze+1);zw({activeDocId:o.activeTabId,defaultName:$e,sourceFormat:ve.format,notify:(Pt,Zt)=>E.push({id:pl(),type:"launcher",severity:Pt,message:Zt,timestamp:Date.now()})})},"settings-modal":F=>{F.preventDefault(),De()},settings:F=>{F.preventDefault(),_e()},"toggle-palette":F=>{F.preventDefault(),b(H,!Mt(()=>u(H)))},"new-scratchpad":F=>{const X=F.target;X&&(X.tagName==="INPUT"||X.tagName==="TEXTAREA")||(F.preventDefault(),Uh())},"close-tab":F=>{if(Ir(F))return;F.preventDefault();const X=o.activeTabId;X&&c(X)},"open-file":F=>{Ir(F)||(F.preventDefault(),te())},"pick-tab":(F,X)=>{if(Ir(F))return;const ve=X==null?void 0:X.tabIndex;if(ve===void 0)return;const Ze=gee(o.tabs,ve);Ze&&(F.preventDefault(),o.setActiveTabId(Ze))},"toggle-mode":F=>{Ir(F)||(F.preventDefault(),v.setTandemMode(v.tandemMode==="solo"?"tandem":"solo"))},"reopen-closed-tab":F=>{Ir(F)||(F.preventDefault(),h())},"new-tab-menu":F=>{Ir(F)||(F.preventDefault(),b(ee,u(ee)+1))},find:(F,X)=>{if(F.preventDefault(),X!=null&&X.shift){b(xe,"tabs"),b(Ne,!0);return}u(Pe)?b(Ie,u(Ie)+1):(b(xe,"doc"),b(Ne,!0))},"find-nav":(F,X)=>{if(Ir(F))return;F.preventDefault();const ve=u(ue),Ze=ve?Zl(ve.state):void 0;ve&&M0(Ze)?X!=null&&X.shift?ve.commands.findPrev():ve.commands.findNext():(b(xe,"doc"),b(Ne,!0))},"annotation-accept-or-dismiss":(F,X)=>{if(Ir(F))return;F.preventDefault();const ve=An();ve&&ve.author!=="user"&&(X!=null&&X.shift?En.handleDismiss(ve.id):En.handleAccept(ve.id))},"comment-on-selection":F=>{F.preventDefault();const X=!!u(ue)&&u(ue).state.selection.from!==u(ue).state.selection.to,ve=u(vn);if(!(u(pe)||u(Ne)||u(H))){if(!X){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(ve){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(V,u(V)+1)}},"toggle-authorship":F=>{F.preventDefault(),J(!m.settings.showAuthorship)},"toggle-left-panel":F=>{Ir(F)||(F.preventDefault(),We())},"toggle-right-panel":F=>{Ir(F)||(F.preventDefault(),Ue())},"annotation-next":F=>{if(Ir(F))return;F.preventDefault();const X=vu(u(_)),ve=Vk(X,u(Oe));if(ve){b(Oe,ve,!0);const Ze=X.find($e=>$e.id===ve);Ze&&En.scrollToAnnotation(Ze)}},"annotation-prev":F=>{if(Ir(F))return;F.preventDefault();const X=vu(u(_)),ve=Uk(X,u(Oe));if(ve){b(Oe,ve,!0);const Ze=X.find($e=>$e.id===ve);Ze&&En.scrollToAnnotation(Ze)}},"select-block":F=>{Ir(F)||(F.preventDefault(),u(ue)&&u(ue).chain().focus().selectParentNode().run())}};me(()=>{function F(X){var Ze;if(X.key==="F2"&&!X.ctrlKey&&!X.metaKey&&!X.altKey&&!X.shiftKey){if(Ir(X))return;const $e=o.tabs.find(Pt=>Pt.id===o.activeTabId);$e&&Iy($e)&&(X.preventDefault(),b(we,u(we)+1));return}const ve=ZC(X,Mt(()=>u(y)));ve&&((Ze=qt[ve.id])==null||Ze.call(qt,X,ve.context))}return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)}),me(()=>{function F(X){if(X.key!=="Escape"||X.defaultPrevented||u(Oe)===null||u(Ne))return;const ve=document.activeElement;ve instanceof HTMLInputElement||ve instanceof HTMLTextAreaElement||!(!ve||ve===document.body||ve.closest('.ProseMirror, [data-testid="editor-root"], [data-testid="annotation-list-scroll-container"]'))||(X.preventDefault(),b(Oe,null))}return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)});const Je=N(()=>o.tabs.find(F=>F.id===o.activeTabId));let Ct=L(null);const Nt=new Map;let ln;me(()=>{const F=u(Ct);if(!F)return;const X=()=>{ln!==void 0&&Nt.set(ln,F.scrollTop)};return F.addEventListener("scroll",X,{passive:!0}),()=>F.removeEventListener("scroll",X)}),me(()=>{var Zt;const F=u(Ct),X=(Zt=u(Je))==null?void 0:Zt.id;if(!F||X===ln||(ln=X,X===void 0))return;const ve=Nt.get(X)??0;let Ze=0,$e=!1;const Pt=()=>{$e||ln!==X||(F.scrollTop=ve,F.scrollTop<ve&&Ze<30&&(Ze+=1,requestAnimationFrame(Pt)))};return requestAnimationFrame(Pt),()=>{$e=!0}});const vn=N(()=>{var F;return((F=u(Je))==null?void 0:F.readOnly)===!0}),er=N(()=>!!u(Je)&&u(Je).format==="md"&&!u(vn)),zt=N(()=>!!u(Je)&&u(Me).has(u(Je).id));function Mn(){if(!u(Je))return;const F=u(Je).id,X=new Set(u(Me));if(X.has(F))X.delete(F);else{if(!u(er))return;X.add(F),b(Ne,!1),b(pe,!1),b(H,!1)}b(Me,X,!0)}function cr(F){if(!u(Me).has(F))return;const X=new Set(u(Me));X.delete(F),b(Me,X,!0),ce(F)}me(()=>{const F=X=>{u(qe).size!==0&&(X.preventDefault(),X.returnValue="You have unsaved markdown-source edits.")};return window.addEventListener("beforeunload",F),()=>window.removeEventListener("beforeunload",F)}),me(()=>{if(!qO({connected:o.connected,tabCount:o.tabs.length,activeTabId:o.activeTabId}))return;const F=setTimeout(()=>{Uh()},jO);return()=>clearTimeout(F)});const En=hte({getYdoc:()=>{var F;return((F=u(Je))==null?void 0:F.ydoc)??null},getEditor:()=>u(ue),getAnnotations:()=>u(_),onActiveAnnotationChange:F=>{b(Oe,F,!0)},getScrollBehavior:()=>m.settings.reduceMotion?"auto":"smooth",getActiveAnnotationId:()=>u(Oe)});function An(){return u(Oe)?u(_).find(F=>F.id===u(Oe)):En.getReviewTargets()[0]}const qr=N(()=>rt.effectivelyOn?u(_).filter(a_):[]),Ii=N(()=>rt.effectivelyOn?u(_).filter(l_):[]),Ri=aee({getEditor:()=>u(ue),getYdoc:()=>{var F;return((F=u(Je))==null?void 0:F.ydoc)??null},getAnnotations:()=>[...u(qr),...u(Ii)],getLayerEl:()=>u(re),getEnabled:()=>rt.effectivelyOn}),cl=q$({getYdoc:()=>{var F;return((F=u(Je))==null?void 0:F.ydoc)??null}}),ul=N(()=>{var ve,Ze;const F=((ve=u(Je))==null?void 0:ve.ydoc)??null,X=(Ze=u(Je))==null?void 0:Ze.id;return{ydoc:F,docId:X,onEdit:($e,Pt)=>IE(F,$e,Pt),onReply:($e,Pt)=>LE($e,Pt,X),onRemove:$e=>PE($e,X),onSendToClaude:$e=>NE(F,$e)}}),sa=Dee(()=>u(_),()=>u(ue),()=>{var F;return(F=u(Je))==null?void 0:F.fileName});var Ut=Yne(),un=w(Ut);{let F=N(()=>null),X=N(()=>u(er)||u(zt)?Mn:null);Ute(un,{get tandemMode(){return v.tandemMode},get onModeChange(){return v.setTandemMode},get claudeActive(){return o.claudeActive},get theme(){return m.settings.theme},onSetTheme:ve=>m.updateSettings({theme:ve}),onOpenHelp:()=>b(ze,!0),onOpenSettings:ge,onOpenSettingsModal:De,get updateAvailable(){return Z.showDot},get defaultModelLabel(){return u(F)},onOpenModelsSettings:de,get aiChip(){return z.chip},onConnectAi:Q,onRestartClaude:ie,get sourceViewActive(){return u(zt)},get onToggleSourceView(){return u(X)},get center(){return n},get settingsBtn(){return u(q)},set settingsBtn(ve){b(q,ve,!0)}})}var Hn=k(un,2);{var aa=F=>{var X=Wne();x(F,X)},si=F=>{var X=Zne(),ve=Ae(X);{var Ze=st=>{var $t=Kne();x(st,$t)};j(ve,st=>{o.serverRestarted&&st(Ze)})}var $e=k(ve,2);{var Pt=st=>{fH(st,{get version(){return A.availableVersion},get installing(){return A.installing},onInstall:()=>{A.install()},get onDismiss(){return A.dismiss}})},Zt=N(()=>Tt()&&A.showBanner&&A.availableVersion);j($e,st=>{u(Zt)&&st(Pt)})}var us=k($e,2);{var ff=st=>{_I(st,{get onDismiss(){return S.dismiss},onRetry:()=>{o.reconnect()}})};j(us,st=>{S.showBanner&&st(ff)})}var Mr=k(us,2);{let st=N(()=>{var kr;return((kr=u(Je))==null?void 0:kr.ydoc)??null}),$t=N(()=>u(pe)||u(Ne)||u(H));F$(Mr,{get editor(){return u(ue)},get ydoc(){return u(st)},get selectionToolbar(){return m.settings.selectionToolbar},get suppressSelectionToolbar(){return u($t)},get requestCommentFocus(){return u(V)},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:kr=>m.updateSettings(kr),onOpenSettings:ge,get formattingBarVisible(){return m.settings.formattingBarVisible},onToggleFormattingBar:()=>m.updateSettings({formattingBarVisible:!m.settings.formattingBarVisible}),get reduceMotion(){return m.settings.reduceMotion}})}var Ni=k(Mr,2);{var wr=st=>{{let $t=N(()=>{var kr;return((kr=u(Je))==null?void 0:kr.ydoc)??null});kte(st,{get editor(){return u(ue)},get ydoc(){return u($t)},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:kr=>m.updateSettings(kr),onOpenSettings:ge,onHide:()=>m.updateSettings({formattingBarVisible:!1})})}};j(Ni,st=>{m.settings.formattingBarVisible&&st(wr)})}var dn=k(Ni,2),fn=w(dn);let tr;var Pi=w(fn),ds=w(Pi);Ug(ds,{kind:"outline",get focusTrigger(){return u(Ie)},get editor(){return u(ue)},visible:!0});var fs=k(ds,2);h_(fs,()=>"left",()=>We);var Zc=k(Pi,2);{let st=N(()=>!u(Pe));c_(Zc,{side:"left",get collapsed(){return u(st)},kind:"outline",onActivate:We})}var hf=k(fn,2);{var Dr=st=>{r(st,()=>"left",()=>$t=>K.handleResizeStart($t),()=>{},()=>K.width)};j(hf,st=>{u(Pe)&&st(Dr)})}var Wr=k(hf,2);i(Wr);var hs=k(Wr,2);{var dl=st=>{r(st,()=>"right",()=>$t=>fe.handleResizeStart($t),()=>"panel-resize-handle",()=>fe.width)};j(hs,st=>{u(Be)&&st(dl)})}var la=k(hs,2);let fl;var ps=w(la),Or=w(ps);h_(Or,()=>"right",()=>Ue);var pf=k(Or,2),sg=w(pf),Pn=w(sg),eo=k(w(Pn));{var ca=st=>{var $t=Gne(),kr=w($t);W(()=>G(kr,u(Te)>9?"9+":u(Te))),x(st,$t)};j(eo,st=>{u(se)!=="annotations"&&u(Te)>0&&st(ca)})}var Yc=k(Pn,2),Ry=k(pf,2);{let st=N(()=>u(se)==="chat");Ug(Ry,{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(Xe)},onCapturedAnchorChange:$t=>b(Xe,$t,!0),get reduceMotion(){return m.settings.reduceMotion},get visible(){return u(st)}})}var F4=k(Ry,2);{let st=N(()=>{var Kr;return((Kr=u(Je))==null?void 0:Kr.ydoc)??null}),$t=N(()=>{var Kr;return(Kr=u(Je))==null?void 0:Kr.format}),kr=N(()=>{var Kr;return(Kr=u(Je))==null?void 0:Kr.id}),W4=N(()=>{var Kr;return((Kr=o.claudeWorking)==null?void 0:Kr.annotationId)??null}),K4=N(()=>u(se)==="annotations");Ug(F4,{kind:"side",get annotations(){return u(_)},get editor(){return u(ue)},get ydoc(){return u(st)},get activeDocFormat(){return u($t)},get documentId(){return u(kr)},get activeAnnotationId(){return u(Oe)},onActiveAnnotationChange:Kr=>b(Oe,Kr,!0),get reduceMotion(){return m.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get claudeWorkingAnnotationId(){return u(W4)},get review(){return En},get visible(){return u(K4)}})}var z4=k(ps,2);{let st=N(()=>!u(Be));c_(z4,{side:"right",get collapsed(){return u(st)},kind:"annotations",get annotations(){return u(_)},onActivate:Ue})}var Ny=k(dn,2);{let st=N(()=>{var $t;return(($t=o.claudeWorking)==null?void 0:$t.tool)??null});$te(Ny,{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(st)},get readOnly(){return u(vn)},get saving(){return UO.saving},get editor(){return u(ue)}})}var Py=k(Ny,2);iH(Py,{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 Ly=k(Py,2);jB(Ly,{get open(){return u(I)},onClose:()=>{b(I,!1),b(Ee,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(Ee)},notify:(st,$t)=>E.push({id:`settings-${Date.now()}`,type:"launcher",severity:st,message:$t,timestamp:Date.now()})});var Fy=k(Ly,2);m8(Fy,{get open(){return u(ze)},onClose:()=>b(ze,!1),get effectiveShortcutLabels(){return u(C)}});var zy=k(Fy,2);{var B4=st=>{VR(st,{open:!0,onClose:$})};j(zy,st=>{u(Re)&&st(B4)})}var By=k(zy,2);{var H4=st=>{u8(st,{onClose:()=>b(ne,!1)})};j(By,st=>{u(ne)&&st(H4)})}var Hy=k(By,2);kI(Hy,{get open(){return u(H)},onClose:()=>b(H,!1),get editor(){return u(ue)},get annotations(){return u(_)},onFocusAnnotation:st=>{b(Oe,st,!0)}});var Vy=k(Hy,2);uH(Vy,{get toasts(){return E.toasts},get onDismiss(){return E.dismiss}});var Uy=k(Vy,2);g5(Uy,{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:st=>{const $t=uS(st);$t&&(o.tabs.some(kr=>kr.id===$t.documentId)?mv($t.documentId):E.push({id:`retry-unavailable-${$t.documentId}`,type:"general-error",severity:"warning",message:"Reopen the document to retry the save.",dedupKey:`retry-unavailable:${$t.documentId}`,timestamp:Date.now()}))}});var jy=k(Uy,2);{var V4=st=>{PI(st,{})},U4=N(()=>Tt()&&!u(Re));j(jy,st=>{u(U4)&&st(V4)})}var j4=k(jy,2);{var q4=st=>{bN(st,{get currentStep(){return sa.currentStep},get onNext(){return sa.nextStep},get onDismiss(){return sa.dismissTutorial},get coworkStatus(){return sa.coworkStatus}})};j(j4,st=>{sa.tutorialActive&&st(q4)})}W(()=>{tr=vt(fn,1,"rail-shell rail-shell-left svelte-y74n0s",null,tr,{collapsed:!u(Pe)}),Le(fn,u(Pe)?`width: ${K.width}px;`:""),Le(Pi,`width: ${K.width}px;`),fl=vt(la,1,"rail-shell rail-shell-right svelte-y74n0s",null,fl,{collapsed:!u(Be)}),Le(la,u(Be)?`width: ${fe.width}px;`:""),Le(ps,`width: ${fe.width}px;`),vt(Pn,1,"rail-tab"+(u(se)==="annotations"?" on":""),"svelte-y74n0s"),vt(Yc,1,"rail-tab"+(u(se)==="chat"?" on":""),"svelte-y74n0s")}),hn("scroll",dn,st=>{st.currentTarget.scrollLeft=0}),P("click",Pn,()=>{b(se,"annotations")}),P("mousedown",Yc,xt),P("click",Yc,()=>{b(se,"chat")}),x(F,X)};j(Hn,F=>{o.ready?F(si,-1):F(aa)})}W(()=>U(Ut,"data-tandem-mode",v.tandemMode)),x(t,Ut),tt()}ut(["mousedown","keydown","keyup","click"]);const p_=3,Xne="error-boundary-recover-btn",Qne="error-boundary-reload-btn";function $ne(t,e){et(e,!0),me(()=>{e.onSuccess()}),tt()}var ere=T('<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>'),tre=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>`),nre=T("<!> <!>",1);function rre(t,e){et(e,!0);let n=L(0),r=L(0);var i=St(),o=Ae(i);H_(o,{onerror:a=>{Hv(a,{source:"ErrorBoundary"}),b(r,u(r)+1)},failed:(a,l=kn,c=kn)=>{var d=St(),f=Ae(d);Fl(f,()=>u(r),h=>{var p=tre(),m=k(w(p),2),v=w(m),g=k(m,2),y=w(g),C=k(g,2);{var _=A=>{var O=ere();W(()=>U(O,"data-testid",Xne)),P("click",O,()=>{b(n,u(n)+1),c()()}),x(A,O)};j(C,A=>{u(n)<p_&&A(_)})}var S=k(C,2);W(A=>{G(v,u(n)>=p_?"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",Qne)},[()=>l()instanceof Error?l().message:String(l())]),P("click",S,()=>window.location.reload()),x(h,p)}),x(a,d)}},a=>{var l=nre(),c=Ae(l);jd(c,()=>e.children);var d=k(c,2);$ne(d,{onSuccess:()=>{b(n,0)}}),x(a,l)}),x(t,i),tt()}ut(["click"]);function ire(t){rre(t,{children:(e,n)=>{Jne(e,{})},$$slots:{default:!0}})}AB();vM(ire,{target:document.getElementById("root")});export{pt as A,Le as B,are as C,fre as D,ure as E,ut as F,mre as G,dre as H,wC as T,w as a,x as b,a1 as c,tt as d,L as e,CI as f,u as g,U as h,j as i,Ae as j,vt as k,Kn as l,hre as m,G as n,Dn as o,et as p,P as q,b as r,k as s,W as t,N as u,T as v,ss as w,o1 as x,s1 as y,pre as z};