tandem-editor 0.14.3 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,270 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/path-49-uTKly.js","assets/core-SwWLTXZB.js","assets/dist-js-BWAGOggB.js","assets/event-wL_2RBc7.js","assets/CoworkSettings-BWtK14Nl.js","assets/CoworkSettings-C0m1IhNy.css","assets/dist-BIC2phzY.js","assets/prod-Bv0q-mQu.js","assets/webview-C-97RVRf.js","assets/window-CR0qpD8C.js"])))=>i.map(i=>d[i]);
2
+ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=Array.isArray,r=Array.prototype.indexOf,i=Array.prototype.includes,a=Array.from,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyDescriptors,l=Object.prototype,u=Array.prototype,d=Object.getPrototypeOf,f=Object.isExtensible;function p(e){return typeof e==`function`}var m=()=>{};function h(e){return typeof e?.then==`function`}function g(e){for(var t=0;t<e.length;t++)e[t]()}function _(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function v(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var y=1024,b=2048,x=4096,S=8192,ee=16384,C=32768,te=1<<25,w=65536,ne=1<<19,re=1<<20,T=1<<25,ie=65536,ae=1<<21,oe=1<<22,se=1<<23,ce=Symbol(`$state`),le=Symbol(`legacy props`),ue=Symbol(``),de=Symbol(`attributes`),fe=Symbol(`class`),pe=Symbol(`style`),me=Symbol(`text`),he=Symbol(`form reset`),ge=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},_e=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ve(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ye(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function be(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function xe(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Se(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Ce(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function we(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Te(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Ee(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Oe(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function ke(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Ae={},je=Symbol(),Me=`http://www.w3.org/1999/xhtml`,Ne=`http://www.w3.org/2000/svg`,Pe=`http://www.w3.org/1998/Math/MathML`;function Fe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Ie(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Le(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Re(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var ze=!1;function Be(e){ze=e}var Ve;function He(e){if(e===null)throw Ie(),Ae;return Ve=e}function Ue(){return He(bn(Ve))}function E(e){if(ze){if(bn(Ve)!==null)throw Ie(),Ae;Ve=e}}function D(e=1){if(ze){for(var t=e,n=Ve;t--;)n=bn(n);Ve=n}}function We(e=!0){for(var t=0,n=Ve;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=bn(n);e&&n.remove(),n=i}}function Ge(e){if(!e||e.nodeType!==8)throw Ie(),Ae;return e.data}function Ke(e){return e===this.v}function qe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Je(e){return!qe(e,this.v)}var Ye=!1,Xe=!1;function Ze(){Xe=!0}var Qe=null;function $e(e){Qe=e}function O(e,t=!1,n){Qe={p:Qe,i:!1,c:null,e:null,s:e,x:null,r:cr,l:Xe&&!t?{s:null,u:null,$:[]}:null}}function k(e){var t=Qe,n=t.e;if(n!==null){t.e=null;for(var r of n)In(r)}return e!==void 0&&(t.x=e),t.i=!0,Qe=t.p,e??{}}function et(){return!Xe||Qe!==null&&Qe.l===null}var tt=[];function nt(){var e=tt;tt=[],g(e)}function rt(e){if(tt.length===0&&!xt){var t=tt;queueMicrotask(()=>{t===tt&&nt()})}tt.push(e)}function it(){for(;tt.length>0;)nt()}function at(e){var t=cr;if(t===null)return ar.f|=se,e;if(!(t.f&32768)&&!(t.f&4))throw e;ot(e,t)}function ot(e,t){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}var st=~(b|x|y);function ct(e,t){e.f=e.f&st|t}function lt(e){e.f&512||e.deps===null?ct(e,y):ct(e,x)}function ut(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ie,ut(t.deps))}function dt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),ut(e.deps),ct(e,y)}var ft=!1,pt=!1;function mt(e){var t=pt;try{return pt=!1,[e(),pt]}finally{pt=t}}var ht=null,gt=null,_t=null,vt=null,yt=null,bt=null,xt=!1,St=!1,Ct=null,wt=null,Tt=0,Et=1,Dt=class e{id=Et++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;unblocked=new Set;#r=new Set;#i=new Set;#a=new Set;#o=0;#s=new Map;#c=null;#l=[];#u=[];#d=new Set;#f=new Set;#p=new Map;#m=new Set;is_fork=!1;#h=!1;#g(){if(this.is_fork)return!0;for(let n of this.#s.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#p.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#p.has(e)||this.#p.set(e,{d:[],m:[]}),this.#m.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#p.get(e);if(n){this.#p.delete(e);for(var r of n.d)ct(r,b),t(r);for(r of n.m)ct(r,x),t(r)}this.#m.add(e)}#_(){if(this.#e=!0,Tt++>1e3&&(this.#w(),kt()),!this.#g()){for(let e of this.#d)this.#f.delete(e),ct(e,b),this.schedule(e);for(let e of this.#f)ct(e,x),this.schedule(e)}let t=this.#l;this.#l=[],this.apply();var n=Ct=[],r=[],i=wt=[];for(let e of t)try{this.#v(e,n,r)}catch(t){throw It(e),t}if(_t=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Ct=null,wt=null,this.#g()){this.#x(r),this.#x(n);for(let[e,t]of this.#p)Ft(e,t);i.length>0&&_t.#_();return}let o=this.#y();if(o){o.#b(this);return}this.#d.clear(),this.#f.clear();for(let e of this.#r)e(this);this.#r.clear(),vt=this,jt(r),jt(n),vt=null,this.#c?.resolve();var s=_t;if(this.linked&&this.#o===0&&this.#w(),Ye&&!this.linked&&(this.#S(),_t=s),this.#l.length>0){s===null&&(s=this,this.#C());let e=s;e.#l.push(...this.#l.filter(t=>!e.#l.includes(t)))}s!==null&&s.#_()}#v(e,t,n){e.f^=y;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#p.has(r))&&r.fn!==null){a?r.f^=y:i&4?t.push(r):Ye&&i&16777224?n.push(r):xr(r)&&(i&16&&this.#f.add(r),Er(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve)}let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#f.delete(i),ct(i,b),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#w(),_t=this,this.#_()}#x(e){for(var t=0;t<e.length;t+=1)dt(e[t],this.#d,this.#f)}capture(e,t,n=!1){e.v!==je&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),yt?.set(e,t)),this.is_fork||(e.v=t)}activate(){_t=this}deactivate(){_t=null,yt=null}flush(){try{St=!0,_t=this,this.#_()}finally{Tt=0,bt=null,Ct=null,wt=null,St=!1,_t=null,yt=null,tn.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear(),this.#a.clear(),this.#w()}register_created_effect(e){this.#u.push(e)}#S(){this.#w();for(let l=ht;l!==null;l=l.#n){var e=l.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(l.current.has(r)){var n=l.current.get(r)[0];if(e&&i!==n)l.current.set(r,[i,a]);else continue}t.push(r)}if(e)for(let[e,t]of this.async_deriveds){let n=l.async_deriveds.get(e);n&&t.promise.then(n.resolve)}if(l.#e){var r=[...l.current.keys()].filter(e=>!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#m)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#x([e])});l.activate();var i=new Set,a=new Map;for(var o of t)Mt(o,r,i,a);a=new Map;var s=[...l.current.keys()].filter(e=>this.current.has(e)?this.current.get(e)[0]!==e.v:!0);if(s.length>0)for(let e of this.#u)!(e.f&155648)&&Nt(e,s,a)&&(e.f&4194320?(ct(e,b),l.schedule(e)):l.#d.add(e));if(l.#l.length>0){l.apply();for(var c of l.#l)l.#v(c,[],[]);l.#l=[]}l.deactivate()}}}}increment(e,t){if(this.#o+=1,e){let e=this.#s.get(t)??0;this.#s.set(t,e+1)}}decrement(e,t){if(--this.#o,e){let e=this.#s.get(t)??0;e===1?this.#s.delete(t):this.#s.set(t,e-1)}this.#h||(this.#h=!0,rt(()=>{this.#h=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#d.add(t);for(let e of t)this.#f.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}on_fork_commit(e){this.#a.add(e)}run_fork_commit_callbacks(){for(let e of this.#a)e(this);this.#a.clear()}settled(){return(this.#c??=_()).promise}static ensure(){if(_t===null){let t=_t=new e;t.#C(),!St&&!xt&&rt(()=>{t.#e||t.flush()})}return _t}apply(){if(!Ye||!this.is_fork&&this.#t===null&&this.#n===null){yt=null;return}yt=new Map;for(let[e,[t]]of this.current)yt.set(e,t);for(let t=ht;t!==null;t=t.#n)if(!(t===this||t.is_fork)){var e=!1;if(t.id<this.id){for(let[n,[,r]]of t.current)if(!r&&this.current.has(n)){e=!0;break}}if(!e)for(let[e,n]of t.previous)yt.has(e)||yt.set(e,n)}}schedule(e){if(bt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Ct!==null&&t===cr&&(Ye||(ar===null||!(ar.f&2))&&!ft))return;if(n&96){if(!(n&1024))return;t.f^=y}}this.#l.push(t)}#C(){gt===null?ht=gt=this:(gt.#n=this,this.#t=gt),gt=this}#w(){var e=this.#t,t=this.#n;e===null?ht=t:e.#n=t,t===null?gt=e:t.#t=e,this.linked=!1}};function Ot(e){var t=xt;xt=!0;try{var n;for(e&&(_t!==null&&!_t.is_fork&&_t.flush(),n=e());;){if(it(),_t===null)return n;_t.flush()}}finally{xt=t}}function kt(){try{we()}catch(e){ot(e,bt)}}var At=null;function jt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&xr(r)&&(At=new Set,Er(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Yn(r),At?.size>0)){tn.clear();for(let e of At){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)At.has(n)&&(At.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Er(n)}}At.clear()}}At=null}}function Mt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?Mt(i,t,n,r):e&4194320&&!(e&2048)&&Nt(i,t,r)&&(ct(i,b),Pt(i))}}function Nt(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(i.call(t,r))return!0;if(r.f&2&&Nt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Pt(e){_t.schedule(e)}function Ft(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),ct(e,y);for(var n=e.first;n!==null;)Ft(n,t),n=n.next}}function It(e){ct(e,y);for(var t=e.first;t!==null;)It(t),t=t.next}function Lt(e){let t=0,n=rn(0),r;return()=>{Pn()&&(z(n),Vn(()=>(t===0&&(r=Ar(()=>e(()=>ln(n)))),t+=1,()=>{rt(()=>{--t,t===0&&(r?.(),r=void 0,ln(n))})})))}}var Rt=w|ne;function zt(e,t,n,r){new Bt(e,t,n,r)}var Bt=class{parent;is_pending=!1;transform_error;#e;#t=ze?Ve:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Lt(()=>(this.#m=rn(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=cr;t.b=this,t.f|=128,n(e)},this.parent=cr.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Hn(()=>{if(ze){let e=this.#t;Ue();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},Rt),ze&&(this.#e=Ve)}#g(){try{this.#a=Un(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Un(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Un(()=>e(this.#e)),rt(()=>{var e=this.#c=document.createDocumentFragment(),t=vn();e.append(t),this.#a=this.#x(()=>Un(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Xn(this.#o,()=>{this.#o=null}),this.#b(_t))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Un(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();er(this.#a,e);let t=this.#n.pending;this.#o=Un(()=>t(this.#e))}else this.#b(_t)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){dt(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=cr,n=ar,r=Qe;lr(this.#i),sr(this.#i),$e(this.#i.ctx);try{return Dt.ensure(),e()}catch(e){return at(e),null}finally{lr(t),sr(n),$e(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Xn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,rt(()=>{this.#d=!1,this.#m&&on(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),z(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;_t?.is_fork?(this.#a&&_t.skip_effect(this.#a),this.#o&&_t.skip_effect(this.#o),this.#s&&_t.skip_effect(this.#s),_t.on_fork_commit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(qn(this.#a),null),this.#o&&=(qn(this.#o),null),this.#s&&=(qn(this.#s),null),ze&&(He(this.#t),D(),He(We()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Re();return}r=!0,i&&ke(),this.#s!==null&&Xn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){ot(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Un(()=>{var t=cr;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return ot(e,this.#i.parent),null}}))};rt(()=>{var t;try{t=this.transform_error(e)}catch(e){ot(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>ot(e,this.#i&&this.#i.parent)):o(t)})}};function Vt(e,t,n,r){let i=et()?Gt:Jt;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=cr,s=Ht(),c=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function l(e){if(!(o.f&16384)){s();try{r(e)}catch(e){ot(e,o)}Ut()}}var u=Wt();if(n.length===0){c.then(()=>l(t.map(i))).finally(u);return}function d(){Promise.all(n.map(e=>qt(e))).then(e=>l([...t.map(i),...e])).catch(e=>ot(e,o)).finally(u)}c?c.then(()=>{s(),d(),Ut()}):d()}function Ht(){var e=cr,t=ar,n=Qe,r=_t;return function(i=!0){lr(e),sr(t),$e(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ut(e=!0){lr(null),sr(null),$e(null),e&&_t?.deactivate()}function Wt(){var e=cr,t=e.b,n=_t,r=t.is_rendered();return t.update_pending_count(1,n),n.increment(r,e),()=>{t.update_pending_count(-1,n),n.decrement(r,e)}}function Gt(e){var t=2|b;return cr!==null&&(cr.f|=ne),{ctx:Qe,deps:null,effects:null,equals:Ke,f:t,fn:e,reactions:null,rv:0,v:je,wv:0,parent:cr,ac:null}}var Kt=Symbol(`obsolete`);function qt(e,t,n){let r=cr;r===null&&ye();var i=void 0,a=rn(je),o=!ar,s=new Set;return Bn(()=>{var t=cr,n=_();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ge&&n.reject(e)}).finally(Ut)}catch(e){n.reject(e),Ut()}var c=_t;if(o){if(t.f&32768)var l=Wt();if(r.b.is_rendered())c.async_deriveds.get(t)?.reject(Kt);else for(let e of s.values())e.reject(Kt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Kt&&(c.activate(),t?(a.f|=se,on(a,t)):(a.f&8388608&&(a.f^=se),on(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Fn(()=>{for(let e of s)e.reject(Kt)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function A(e){let t=Gt(e);return Ye||dr(t),t}function Jt(e){let t=Gt(e);return t.equals=Je,t}function Yt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)qn(t[n])}}function Xt(e){var t,n=cr,r=e.parent;if(!rr&&r!==null&&r.f&24576)return Fe(),e.v;lr(r);try{e.f&=~ie,Yt(e),t=Cr(e)}finally{lr(n)}return t}function Zt(e){var t=Xt(e);if(!e.equals(t)&&(e.wv=br(),(!_t?.is_fork||e.deps===null)&&(_t===null?e.v=t:(_t.capture(e,t,!0),vt?.capture(e,t,!0)),e.deps===null))){ct(e,y);return}rr||(yt===null?lt(e):(Pn()||_t?.is_fork)&&yt.set(e,t))}function Qt(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(ge),t.teardown=m,t.ac=null,Tr(t,0),Gn(t))}function $t(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&Er(t)}var en=new Set,tn=new Map,nn=!1;function rn(e,t){return{f:0,v:e,reactions:null,equals:Ke,rv:0,wv:0}}function j(e,t){let n=rn(e,t);return dr(n),n}function an(e,t=!1,n=!0){let r=rn(e);return t||(r.equals=Je),Xe&&n&&Qe!==null&&Qe.l!==null&&(Qe.l.s??=[]).push(r),r}function M(e,t,n=!1){return ar!==null&&(!or||ar.f&131072)&&et()&&ar.f&4325394&&(ur===null||!i.call(ur,e))&&Oe(),on(e,n?N(t):t,wt)}function on(e,t,n=null){if(!e.equals(t)){tn.set(e,rr?t:e.v);var r=Dt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Xt(t),yt===null&&lt(t)}e.wv=br(),un(e,b,n),et()&&cr!==null&&cr.f&1024&&!(cr.f&96)&&(mr===null?hr([e]):mr.push(e)),!r.is_fork&&en.size>0&&!nn&&sn()}return t}function sn(){nn=!1;for(let e of en){e.f&1024&&ct(e,x);let t;try{t=xr(e)}catch{t=!0}t&&Er(e)}en.clear()}function cn(e,t=1){var n=z(e),r=t===1?n++:n--;return M(e,n),r}function ln(e){M(e,e.v+1)}function un(e,t,n){var r=e.reactions;if(r!==null)for(var i=et(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===cr)){var l=(c&b)===0;if(l&&ct(s,t),c&131072)en.add(s);else if(c&2){var u=s;yt?.delete(u),c&65536||(c&512&&(cr===null||!(cr.f&2097152))&&(s.f|=ie),un(u,x,n))}else if(l){var d=s;c&16&&At!==null&&At.add(d),n===null?Pt(d):n.push(d)}}}}function N(e){if(typeof e!=`object`||!e||ce in e)return e;let t=d(e);if(t!==l&&t!==u)return e;var r=new Map,i=n(e),a=j(0),o=null,c=vr,f=e=>{if(vr===c)return e();var t=ar,n=vr;sr(null),yr(c);var r=e();return sr(t),yr(n),r};return i&&r.set(`length`,j(e.length,o)),new Proxy(e,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Ee();var i=r.get(t);return i===void 0?f(()=>{var e=j(n.value,o);return r.set(t,e),e}):M(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>j(je,o));r.set(t,e),ln(a)}}else M(n,je),ln(a);return!0},get(t,n,i){if(n===ce)return e;var a=r.get(n),c=n in t;if(a===void 0&&(!c||s(t,n)?.writable)&&(a=f(()=>j(N(c?t[n]:je),o)),r.set(n,a)),a!==void 0){var l=z(a);return l===je?void 0:l}return Reflect.get(t,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var i=r.get(t);i&&(n.value=z(i))}else if(n===void 0){var a=r.get(t),o=a?.v;if(a!==void 0&&o!==je)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===ce)return!0;var n=r.get(t),i=n!==void 0&&n.v!==je||Reflect.has(e,t);return(n!==void 0||cr!==null&&(!i||s(e,t)?.writable))&&(n===void 0&&(n=f(()=>j(i?N(e[t]):je,o)),r.set(t,n)),z(n)===je)?!1:i},set(e,t,n,c){var l=r.get(t),u=t in e;if(i&&t===`length`)for(var d=n;d<l.v;d+=1){var p=r.get(d+``);p===void 0?d in e&&(p=f(()=>j(je,o)),r.set(d+``,p)):M(p,je)}if(l===void 0)(!u||s(e,t)?.writable)&&(l=f(()=>j(void 0,o)),M(l,N(n)),r.set(t,l));else{u=l.v!==je;var m=f(()=>N(n));M(l,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(c,n),!u){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&M(g,_+1)}ln(a)}return!0},ownKeys(e){z(a);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==je});for(var[n,i]of r)i.v!==je&&!(n in e)&&t.push(n);return t},setPrototypeOf(){De()}})}function dn(e){try{if(typeof e==`object`&&e&&ce in e)return e[ce]}catch{}return e}function fn(e,t){return Object.is(dn(e),dn(t))}new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);var pn,mn,hn,gn;function _n(){if(pn===void 0){pn=window,mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hn=s(t,`firstChild`).get,gn=s(t,`nextSibling`).get,f(e)&&(e[fe]=void 0,e[de]=null,e[pe]=void 0,e.__e=void 0),f(n)&&(n[me]=void 0)}}function vn(e=``){return document.createTextNode(e)}function yn(e){return hn.call(e)}function bn(e){return gn.call(e)}function P(e,t){if(!ze)return yn(e);var n=yn(Ve);if(n===null)n=Ve.appendChild(vn());else if(t&&n.nodeType!==3){var r=vn();return n?.before(r),He(r),r}return t&&wn(n),He(n),n}function F(e,t=!1){if(!ze){var n=yn(e);return n instanceof Comment&&n.data===``?bn(n):n}if(t){if(Ve?.nodeType!==3){var r=vn();return Ve?.before(r),He(r),r}wn(Ve)}return Ve}function I(e,t=1,n=!1){let r=ze?Ve:e;for(var i;t--;)i=r,r=bn(r);if(!ze)return r;if(n){if(r?.nodeType!==3){var a=vn();return r===null?i?.after(a):r.before(a),He(a),a}wn(r)}return He(r),r}function xn(e){e.textContent=``}function Sn(){return!Ye||At!==null?!1:(cr.f&C)!==0}function Cn(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}function wn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Tn(e,t){if(t){let t=document.body;e.autofocus=!0,rt(()=>{document.activeElement===t&&e.focus()})}}function En(e){ze&&yn(e)!==null&&xn(e)}var Dn=!1;function On(){Dn||(Dn=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[he]?.()})},{capture:!0}))}function kn(e){var t=ar,n=cr;sr(null),lr(null);try{return e()}finally{sr(t),lr(n)}}function An(e,t,n,r=n){e.addEventListener(t,()=>kn(n));let i=e[he];i?e[he]=()=>{i(),r(!0)}:e[he]=()=>r(!0),On()}function jn(e){cr===null&&(ar===null&&Ce(e),Se()),rr&&xe(e)}function Mn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Nn(e,t){var n=cr;n!==null&&n.f&8192&&(e|=S);var r={ctx:Qe,deps:null,nodes:null,f:e|b|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};_t?.register_created_effect(r);var i=r;if(e&4)Ct===null?Dt.ensure().schedule(r):Ct.push(r);else if(t!==null){try{Er(r)}catch(e){throw qn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=w))}if(i!==null&&(i.parent=n,n!==null&&Mn(i,n),ar!==null&&ar.f&2&&!(e&64))){var a=ar;(a.effects??=[]).push(i)}return r}function Pn(){return ar!==null&&!or}function Fn(e){let t=Nn(8,null);return ct(t,y),t.teardown=e,t}function L(e){jn(`$effect`);var t=cr.f;if(!ar&&t&32&&!(t&32768)){var n=Qe;(n.e??=[]).push(e)}else return In(e)}function In(e){return Nn(4|re,e)}function Ln(e){Dt.ensure();let t=Nn(64|ne,e);return()=>{qn(t)}}function Rn(e){Dt.ensure();let t=Nn(64|ne,e);return(e={})=>new Promise(n=>{e.outro?Xn(t,()=>{qn(t),n(void 0)}):(qn(t),n(void 0))})}function zn(e){return Nn(4,e)}function Bn(e){return Nn(oe|ne,e)}function Vn(e,t=0){return Nn(8|t,e)}function R(e,t=[],n=[],r=[]){Vt(r,t,n,t=>{Nn(8,()=>e(...t.map(z)))})}function Hn(e,t=0){return Nn(16|t,e)}function Un(e){return Nn(32|ne,e)}function Wn(e){var t=e.teardown;if(t!==null){let e=rr,n=ar;ir(!0),sr(null);try{t.call(null)}finally{ir(e),sr(n)}}}function Gn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&kn(()=>{e.abort(ge)});var r=n.next;n.f&64?n.parent=null:qn(n,t),n=r}}function Kn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||qn(t),t=n}}function qn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Jn(e.nodes.start,e.nodes.end),n=!0),ct(e,te),Gn(e,t&&!n),Tr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Wn(e),e.f^=te,e.f|=ee;var i=e.parent;i!==null&&i.first!==null&&Yn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Jn(e,t){for(;e!==null;){var n=e===t?null:bn(e);e.remove(),e=n}}function Yn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Xn(e,t,n=!0){var r=[];Zn(e,r,!0);var i=()=>{n&&qn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Zn(e,t,n){if(!(e.f&8192)){e.f^=S;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;Zn(i,t,o?n:!1)}i=a}}}function Qn(e){$n(e,!0)}function $n(e,t){if(e.f&8192){e.f^=S,e.f&1024||(ct(e,b),Dt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;$n(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function er(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:bn(n);t.append(n),n=i}}var tr=null,nr=!1,rr=!1;function ir(e){rr=e}var ar=null,or=!1;function sr(e){ar=e}var cr=null;function lr(e){cr=e}var ur=null;function dr(e){ar!==null&&(!Ye||ar.f&2)&&(ur===null?ur=[e]:ur.push(e))}var fr=null,pr=0,mr=null;function hr(e){mr=e}var gr=1,_r=0,vr=_r;function yr(e){vr=e}function br(){return++gr}function xr(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ie),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(xr(a)&&Zt(a),a.wv>e.wv)return!0}t&512&&yt===null&&ct(e,y)}return!1}function Sr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Ye&&ur!==null&&i.call(ur,e)))for(var a=0;a<r.length;a++){var o=r[a];o.f&2?Sr(o,t,!1):t===o&&(n?ct(o,b):o.f&1024&&ct(o,x),Pt(o))}}function Cr(e){var t=fr,n=pr,r=mr,i=ar,a=ur,o=Qe,s=or,c=vr,l=e.f;fr=null,pr=0,mr=null,ar=l&96?null:e,ur=null,$e(e.ctx),or=!1,vr=++_r,e.ac!==null&&(kn(()=>{e.ac.abort(ge)}),e.ac=null);try{e.f|=ae;var u=e.fn,d=u();e.f|=C;var f=e.deps,p=_t?.is_fork;if(fr!==null){var m;if(p||Tr(e,pr),f!==null&&pr>0)for(f.length=pr+fr.length,m=0;m<fr.length;m++)f[pr+m]=fr[m];else e.deps=f=fr;if(Pn()&&e.f&512)for(m=pr;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&pr<f.length&&(Tr(e,pr),f.length=pr);if(et()&&mr!==null&&!or&&f!==null&&!(e.f&6146))for(m=0;m<mr.length;m++)Sr(mr[m],e);if(i!==null&&i!==e){if(_r++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=_r;if(t!==null)for(let e of t)e.rv=_r;mr!==null&&(r===null?r=mr:r.push(...mr))}return e.f&8388608&&(e.f^=se),d}catch(e){return at(e)}finally{e.f^=ae,fr=t,pr=n,mr=r,ar=i,ur=a,$e(o),or=s,vr=c}}function wr(e,t){let n=t.reactions;if(n!==null){var a=r.call(n,e);if(a!==-1){var o=n.length-1;o===0?n=t.reactions=null:(n[a]=n[o],n.pop())}}if(n===null&&t.f&2&&(fr===null||!i.call(fr,t))){var s=t;s.f&512&&(s.f^=512,s.f&=~ie),s.v!==je&&lt(s),Qt(s),Tr(s,0)}}function Tr(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)wr(e,n[r])}function Er(e){var t=e.f;if(!(t&16384)){ct(e,y);var n=cr,r=nr;cr=e,nr=!0;try{t&16777232?Kn(e):Gn(e),Wn(e);var i=Cr(e);e.teardown=typeof i==`function`?i:null,e.wv=gr}finally{nr=r,cr=n}}}async function Dr(){if(Ye)return new Promise(e=>{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),Ot()}function z(e){var t=(e.f&2)!=0;if(tr?.add(e),ar!==null&&!or&&!(cr!==null&&cr.f&16384)&&(ur===null||!i.call(ur,e))){var n=ar.deps;if(ar.f&2097152)e.rv<_r&&(e.rv=_r,fr===null&&n!==null&&n[pr]===e?pr++:fr===null?fr=[e]:fr.push(e));else{(ar.deps??=[]).push(e);var r=e.reactions;r===null?e.reactions=[ar]:i.call(r,ar)||r.push(ar)}}if(rr&&tn.has(e))return tn.get(e);if(t){var a=e;if(rr){var o=a.v;return(!(a.f&1024)&&a.reactions!==null||kr(a))&&(o=Xt(a)),tn.set(a,o),o}var s=(a.f&512)==0&&!or&&ar!==null&&(nr||(ar.f&512)!=0),c=(a.f&C)===0;xr(a)&&(s&&(a.f|=512),Zt(a)),s&&!c&&($t(a),Or(a))}if(yt?.has(e))return yt.get(e);if(e.f&8388608)throw e.v;return e.v}function Or(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&($t(t),Or(t))}function kr(e){if(e.v===je)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(tn.has(t)||t.f&2&&kr(t))return!0;return!1}function Ar(e){var t=or;try{return or=!0,e()}finally{or=t}}function jr(e){if(!(typeof e!=`object`||!e||e instanceof EventTarget)){if(ce in e)Mr(e);else if(!Array.isArray(e))for(let t in e){let n=e[t];typeof n==`object`&&n&&ce in n&&Mr(n)}}}function Mr(e,t=new Set){if(typeof e==`object`&&e&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let n in e)try{Mr(e[n],t)}catch{}let n=d(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){let t=c(n);for(let n in t){let r=t[n].get;if(r)try{r.call(e)}catch{}}}}}[...`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`)];var Nr=[`touchstart`,`touchmove`];function Pr(e){return Nr.includes(e)}var Fr=Symbol(`events`),Ir=new Set,Lr=new Set;function Rr(e,t,n,r={}){function i(e){if(r.capture||Hr.call(t,e),!e.cancelBubble)return kn(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?rt(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function zr(e,t,n,r,i){var a={capture:r,passive:i},o=Rr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Fn(()=>{t.removeEventListener(e,o,a)})}function B(e,t,n){(t[Fr]??={})[e]=n}function Br(e){for(var t=0;t<e.length;t++)Ir.add(e[t]);for(var n of Lr)n(e)}var Vr=null;function Hr(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;Vr=e;var s=0,c=Vr===e&&e[Fr];if(c){var l=i.indexOf(c);if(l!==-1&&(t===document||t===window)){e[Fr]=t;return}var u=i.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(a=i[s]||e.target,a!==t){o(e,`currentTarget`,{configurable:!0,get(){return a||n}});var d=ar,f=cr;sr(null),lr(null);try{for(var p,m=[];a!==null;){var h=a.assignedSlot||a.parentNode||a.host||null;try{var g=a[Fr]?.[r];g!=null&&(!a.disabled||e.target===a)&&g.call(a,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble||h===t||h===null)break;a=h}if(p){for(let e of m)queueMicrotask(()=>{throw e});throw p}}finally{e[Fr]=t,delete e.currentTarget,sr(d),lr(f)}}}var Ur=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Wr(e){return Ur?.createHTML(e)??e}function Gr(e){var t=Cn(`template`);return t.innerHTML=Wr(e.replaceAll(`<!>`,`<!---->`)),t.content}function Kr(e,t){var n=cr;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function V(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(ze)return Kr(Ve,null),Ve;i===void 0&&(i=Gr(a?e:`<!>`+e),n||(i=yn(i)));var t=r||mn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yn(t),s=t.lastChild;Kr(o,s)}else Kr(t,t);return t}}function qr(e,t,n=`svg`){var r=!e.startsWith(`<!>`),i=(t&1)!=0,a=`<${n}>${r?e:`<!>`+e}</${n}>`,o;return()=>{if(ze)return Kr(Ve,null),Ve;if(!o){var e=yn(Gr(a));if(i)for(o=document.createDocumentFragment();yn(e);)o.appendChild(yn(e));else o=yn(e)}var t=o.cloneNode(!0);if(i){var n=yn(t),r=t.lastChild;Kr(n,r)}else Kr(t,t);return t}}function Jr(e,t){return qr(e,t,`svg`)}function Yr(e=``){if(!ze){var t=vn(e+``);return Kr(t,t),t}var n=Ve;return n.nodeType===3?wn(n):(n.before(n=vn()),He(n)),Kr(n,n),n}function Xr(){if(ze)return Kr(Ve,null),Ve;var e=document.createDocumentFragment(),t=document.createComment(``),n=vn();return e.append(t,n),Kr(t,n),e}function H(e,t){if(ze){var n=cr;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Ve),Ue();return}e!==null&&e.before(t)}var Zr=!0;function U(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[me]??=e.nodeValue)&&(e[me]=n,e.nodeValue=`${n}`)}function Qr(e,t){return ei(e,t)}var $r=new Map;function ei(e,{target:t,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:c}){_n();var l=void 0,u=Rn(()=>{var u=n??t.appendChild(vn());zt(u,{pending:()=>{}},t=>{O({});var n=Qe;if(o&&(n.c=o),i&&(r.$$events=i),ze&&Kr(t,null),Zr=s,l=e(t,r)||{},Zr=!0,ze&&(cr.nodes.end=Ve,Ve===null||Ve.nodeType!==8||Ve.data!==`]`))throw Ie(),Ae;k()},c);var d=new Set,f=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!d.has(r)){d.add(r);var i=Pr(r);for(let e of[t,document]){var a=$r.get(e);a===void 0&&(a=new Map,$r.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,Hr,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return f(a(Ir)),Lr.add(f),()=>{for(var e of d)for(let n of[t,document]){var r=$r.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Hr),r.delete(e),r.size===0&&$r.delete(n)):r.set(e,i)}Lr.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ti.set(l,u),l}var ti=new WeakMap,ni=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)Qn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(qn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();er(r,t),t.append(vn()),this.#n.set(e,{effect:r,fragment:t})}else qn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Xn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(qn(n.effect),this.#n.delete(e))};ensure(e,t){var n=_t,r=Sn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=vn();i.append(a),this.#n.set(e,{effect:Un(()=>t(a)),fragment:i})}else this.#t.set(e,Un(()=>t(this.anchor)));if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else ze&&(this.anchor=Ve),this.#a(n)}},ri=0,ii=1,ai=2;function oi(e,t,n,r,i){ze&&Ue();var a=et(),o=je,s=a?rn(o):an(o,!1,!1),c=a?rn(o):an(o,!1,!1),l=new ni(e);Hn(()=>{var a=_t;a.deactivate();var o=t();a.activate();var u=!1;let d=ze&&h(o)===(e.data===`[!`);if(d&&(He(We()),Be(!1)),h(o)){var f=Ht(),p=!1;let e=e=>{if(!u){p=!0,f(!1),Dt.ensure(),ze&&Be(!1);try{e()}finally{Ut(!1),xt||Ot()}}};o.then(t=>{e(()=>{on(s,t),l.ensure(ii,r&&(e=>r(e,s)))})},t=>{e(()=>{if(on(c,t),l.ensure(ai,i&&(e=>i(e,c))),!i)throw c.v})}),ze?l.ensure(ri,n):rt(()=>{p||e(()=>{l.ensure(ri,n)})})}else on(s,o),l.ensure(ii,r&&(e=>r(e,s)));return d&&Be(!0),()=>{u=!0}})}function W(e,t,n=!1){var r;ze&&(r=Ve,Ue());var i=new ni(e),a=n?w:0;function o(e,t){if(ze){var n=Ge(r);if(e!==parseInt(n.substring(1))){var a=We();He(a),i.anchor=a,Be(!1),i.ensure(e,t),Be(!0);return}}i.ensure(e,t)}Hn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var si=Symbol(`NaN`);function ci(e,t,n){ze&&Ue();var r=new ni(e),i=!et();Hn(()=>{var e=t();e!==e&&(e=si),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function li(e,t){return t}function ui(e,t,n){for(var r=[],i=t.length,o,s=t.length,c=0;c<i;c++){let n=t[c];Xn(n,()=>{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;di(e,a(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else --s},!1)}if(s===0){var l=r.length===0&&n!==null;if(l){var u=n,d=u.parentNode;xn(d),d.append(u),e.items.clear()}di(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function di(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i<t.length;i++){var a=t[i];r?.has(a)?(a.f|=T,er(a,document.createDocumentFragment())):qn(t[i],n)}}var fi;function pi(e,t,r,i,o,s=null){var c=e,l=new Map;if(t&4){var u=e;c=ze?He(yn(u)):u.appendChild(vn())}ze&&Ue();var d=null,f=Jt(()=>{var e=r();return n(e)?e:e==null?[]:a(e)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,hi(v,p,c,t,i),d!==null&&(p.length===0?d.f&33554432?(d.f^=T,_i(d,null,c)):Qn(d):Xn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Hn(()=>{p=z(f);var e=p.length;let n=!1;ze&&Ge(c)===`[!`!=(e===0)&&(c=We(),He(c),Be(!1),n=!0);for(var a=new Set,u=_t,v=Sn(),y=0;y<e;y+=1){ze&&Ve.nodeType===8&&Ve.data===`]`&&(c=Ve,n=!0,Be(!1));var b=p[y],x=i(b,y),S=h?null:l.get(x);S?(S.v&&on(S.v,b),S.i&&on(S.i,y),v&&u.unskip_effect(S.e)):(S=gi(l,h?c:fi??=vn(),b,x,y,o,t,r),h||(S.e.f|=T),l.set(x,S)),a.add(x)}if(e===0&&s&&!d&&(h?d=Un(()=>s(c)):(d=Un(()=>s(fi??=vn())),d.f|=T)),e>a.size&&be(``,``,``),ze&&e>0&&He(We()),!h)if(m.set(u,a),v){for(let[e,t]of l)a.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u);n&&Be(!0),z(f)}),flags:t,items:l,pending:m,outrogroups:null,fallback:d};h=!1,ze&&(c=Ve)}function mi(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function hi(e,t,n,r,i){var o=(r&8)!=0,s=t.length,c=e.items,l=mi(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v<s;v+=1)h=t[v],g=i(h,v),_=c.get(g).e,_.f&33554432||(_.nodes?.a?.measure(),(f??=new Set).add(_));for(v=0;v<s;v+=1){if(h=t[v],g=i(h,v),_=c.get(g).e,e.outrogroups!==null)for(let t of e.outrogroups)t.pending.delete(_),t.done.delete(_);if(_.f&8192&&(Qn(_),o&&(_.nodes?.a?.unfix(),(f??=new Set).delete(_))),_.f&33554432)if(_.f^=T,_===l)_i(_,null,n);else{var y=d?d.next:l;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),vi(e,d,_),vi(e,_,y),_i(_,y,n),d=_,p=[],m=[],l=mi(d.next);continue}if(_!==l){if(u!==void 0&&u.has(_)){if(p.length<m.length){var b=m[0],x;d=b.prev;var S=p[0],ee=p[p.length-1];for(x=0;x<p.length;x+=1)_i(p[x],b,n);for(x=0;x<m.length;x+=1)u.delete(m[x]);vi(e,S.prev,ee.next),vi(e,d,S),vi(e,ee,b),l=b,d=ee,--v,p=[],m=[]}else u.delete(_),_i(_,l,n),vi(e,_.prev,_.next),vi(e,_,d===null?e.effect.first:d.next),vi(e,d,_),d=_;continue}for(p=[],m=[];l!==null&&l!==_;)(u??=new Set).add(l),m.push(l),l=mi(l.next);if(l===null)continue}_.f&33554432||p.push(_),d=_,l=mi(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(di(e,a(t.done)),e.outrogroups?.delete(t));e.outrogroups.size===0&&(e.outrogroups=null)}if(l!==null||u!==void 0){var C=[];if(u!==void 0)for(_ of u)_.f&8192||C.push(_);for(;l!==null;)!(l.f&8192)&&l!==e.fallback&&C.push(l),l=mi(l.next);var te=C.length;if(te>0){var w=r&4&&s===0?n:null;if(o){for(v=0;v<te;v+=1)C[v].nodes?.a?.measure();for(v=0;v<te;v+=1)C[v].nodes?.a?.fix()}ui(e,C,w)}}o&&rt(()=>{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function gi(e,t,n,r,i,a,o,s){var c=o&1?o&16?rn(n):an(n,!1,!1):null,l=o&2?rn(i):null;return{v:c,i:l,e:Un(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function _i(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=bn(r);if(a.before(r),r===i)return;r=o}}function vi(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function yi(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;ze&&(o=He(yn(c)))}R(()=>{var e=cr;if(s===(s=t()??``)){ze&&Ue();return}if(n&&!ze){e.nodes=null,c.innerHTML=s,s!==``&&Kr(yn(c),c.lastChild);return}if(e.nodes!==null&&(Jn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(ze){for(var a=Ve.data,l=Ue(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=bn(l);if(l===null)throw Ie(),Ae;Kr(Ve,u),o=He(l);return}var d=Cn(r?`svg`:i?`math`:`template`,r?Ne:i?Pe:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Kr(yn(f),f.lastChild),r||i)for(;yn(f);)o.before(yn(f));else o.before(f)}})}function bi(e,t,...n){var r=new ni(e);Hn(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},w)}function xi(e,t,n){var r;ze&&(r=Ve,Ue());var i=new ni(e);Hn(()=>{var e=t()??null;if(ze&&Ge(r)===`[`!=(e!==null)){var a=We();He(a),i.anchor=a,Be(!1),i.ensure(e,e&&(t=>n(t,e))),Be(!0);return}i.ensure(e,e&&(t=>n(t,e)))},w)}var Si=()=>performance.now(),Ci={tick:e=>requestAnimationFrame(e),now:()=>Si(),tasks:new Set};function wi(){let e=Ci.now();Ci.tasks.forEach(t=>{t.c(e)||(Ci.tasks.delete(t),t.f())}),Ci.tasks.size!==0&&Ci.tick(wi)}function Ti(e){let t;return Ci.tasks.size===0&&Ci.tick(wi),{promise:new Promise(n=>{Ci.tasks.add(t={c:e,f:n})}),abort(){Ci.tasks.delete(t)}}}function Ei(e,t){kn(()=>{e.dispatchEvent(new CustomEvent(t))})}function Di(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function Oi(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Di(n.trim());t[i]=r.trim()}return t}var ki=e=>e,Ai=null;function ji(e,t,n){var r=(Ai??cr).nodes,i,a,o,s=null;r.a??={element:e,measure(){i=this.element.getBoundingClientRect()},apply(){if(o?.abort(),a=this.element.getBoundingClientRect(),i.left!==a.left||i.right!==a.right||i.top!==a.top||i.bottom!==a.bottom){let e=t()(this.element,{from:i,to:a},n?.());o=Ni(this.element,e,void 0,1,()=>{},()=>{o?.abort(),o=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var a=e.style;s={position:a.position,width:a.width,height:a.height,transform:a.transform},a.position=`absolute`,a.width=n,a.height=r;var o=e.getBoundingClientRect();if(i.left!==o.left||i.top!==o.top){var c=`translate(${i.left-o.left}px, ${i.top-o.top}px)`;a.transform=a.transform?`${a.transform} ${c}`:c}}}},unfix(){if(s){var t=e.style;t.position=s.position,t.width=s.width,t.height=s.height,t.transform=s.transform}}},r.a.element=e}function Mi(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return kn(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Ni(t,m(),p,1,()=>{Ei(t,`introstart`)},()=>{Ei(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Ni(t,m(),f,0,()=>{Ei(t,`outrostart`)},()=>{Ei(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=cr;if((g.nodes.t??=[]).push(h),i&&Zr){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&zn(()=>{Ar(()=>h.in())})}}function Ni(e,t,n,r,i,a){var o=r===1;if(p(t)){var s,c=!1;return rt(()=>{c||(s=Ni(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:m,deactivate:m,reset:m,t:()=>r};let{delay:l=0,css:u,tick:d,easing:f=ki}=t;var h=[];if(o&&n===void 0&&(d&&d(0,1),u)){var g=Oi(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{v.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var p=!1;if(u)for(var m=Math.ceil(c/(1e3/60)),h=0;h<=m;h+=1){var g=o+s*f(h/m),y=Oi(u(g,1-g));l.push(y),p||=y.overflow===`hidden`}p&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return o+s*f(e/c)},d&&Ti(()=>{if(v.playState!==`running`)return!1;var e=_();return d(e,1-e),!0})}v=e.animate(l,{duration:c,fill:`forwards`}),v.onfinish=()=>{_=()=>r,d?.(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=m)},deactivate:()=>{a=m},reset:()=>{r===0&&d?.(1,0)},t:()=>_()}}function Pi(e,t,n){zn(()=>{var r=Ar(()=>t(e,n?.())||{});if(n&&r?.update){var i=!1,a={};Vn(()=>{var e=n();jr(e),i&&qe(a,e)&&(a=e,r.update(e))}),i=!0}if(r?.destroy)return()=>r.destroy()})}function Fi(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Fi(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Ii(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Fi(e))&&(r&&(r+=` `),r+=t);return r}function Li(e){return typeof e==`object`?Ii(e):e??``}var Ri=[...`
3
+ \r\f\xA0\v`];function zi(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||Ri.includes(r[o-1]))&&(s===r.length||Ri.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Bi(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function Vi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Hi(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(Vi)),i&&c.push(...Object.keys(i).map(Vi));var l=0,u=-1;let t=e.length;for(var d=0;d<t;d++){var f=e[d];if(s?f===`/`&&e[d-1]===`*`&&(s=!1):a?a===f&&(a=!1):f===`/`&&e[d+1]===`*`?s=!0:f===`"`||f===`'`?a=f:f===`(`?o++:f===`)`&&o--,!s&&a===!1&&o===0){if(f===`:`&&u===-1)u=d;else if(f===`;`||d===t-1){if(u!==-1){var p=Vi(e.substring(l,u).trim());if(!c.includes(p)){f!==`;`&&d++;var m=e.substring(l,d).trim();n+=` `+m+`;`}}l=d+1,u=-1}}}}return r&&(n+=Bi(r)),i&&(n+=Bi(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function Ui(e,t,n,r,i,a){var o=e[fe];if(ze||o!==n||o===void 0){var s=zi(n,r,a);(!ze||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e[fe]=n}else if(a&&i!==a)for(var c in a){var l=!!a[c];(i==null||l!==!!i[c])&&e.classList.toggle(c,l)}return a}function Wi(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,a,r))}}function G(e,t,n,r){var i=e[pe];if(ze||i!==t){var a=Hi(t,r);(!ze||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e[pe]=t}else r&&(Array.isArray(r)?(Wi(e,n?.[0],r[0]),Wi(e,n?.[1],r[1],`important`)):Wi(e,n,r));return r}function Gi(e,t,r=!1){if(e.multiple){if(t==null)return;if(!n(t))return Le();for(var i of e.options)i.selected=t.includes(Ji(i));return}for(i of e.options)if(fn(Ji(i),t)){i.selected=!0;return}(!r||t!==void 0)&&(e.selectedIndex=-1)}function Ki(e){var t=new MutationObserver(()=>{Gi(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),Fn(()=>{t.disconnect()})}function qi(e,t,n=t){var r=new WeakSet,i=!0;An(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Ji);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Ji(o)}n(a),e.__value=a,_t!==null&&r.add(_t)}),zn(()=>{var a=t();if(e===document.activeElement){var o=Ye?vt:_t;if(r.has(o))return}if(Gi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Ji(s),n(a))}e.__value=a,i=!1}),Ki(e)}function Ji(e){return`__value`in e?e.__value:e.value}var Yi=Symbol(`is custom element`),Xi=Symbol(`is html`),Zi=_e?`link`:`LINK`,Qi=_e?`progress`:`PROGRESS`;function $i(e){if(ze){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;K(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;K(e,`checked`,null),e.checked=r}}};e[he]=n,rt(n),On()}}function ea(e,t){var n=na(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==Qi)||(e.value=t??``)}function ta(e,t){var n=na(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function K(e,t,n,r){var i=na(e);ze&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Zi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ue]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&ia(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function na(e){return e[de]??={[Yi]:e.nodeName.includes(`-`),[Xi]:e.namespaceURI===Me}}var ra=new Map;function ia(e){var t=e.getAttribute(`is`)||e.nodeName,n=ra.get(t);if(n)return n;ra.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=c(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=d(i)}return n}function aa(e,t,n=t){var r=new WeakSet;An(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=sa(e)?ca(a):a,n(a),_t!==null&&r.add(_t),await Dr(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(ze&&e.defaultValue!==e.value||Ar(t)==null&&e.value)&&(n(sa(e)?ca(e.value):e.value),_t!==null&&r.add(_t)),Vn(()=>{var n=t();if(e===document.activeElement){var i=Ye?vt:_t;if(r.has(i))return}sa(e)&&n===ca(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function oa(e,t,n=t){An(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(ze&&e.defaultChecked!==e.checked||Ar(t)==null)&&n(e.checked),Vn(()=>{e.checked=!!t()})}function sa(e){var t=e.type;return t===`number`||t===`range`}function ca(e){return e===``?null:+e}var la=new class e{#e=new WeakMap;#t;#n;static entries=new WeakMap;constructor(e){this.#n=e}observe(e,t){var n=this.#e.get(e)||new Set;return n.add(t),this.#e.set(e,n),this.#r().observe(e,this.#n),()=>{var n=this.#e.get(e);n.delete(t),n.size===0&&(this.#e.delete(e),this.#t.unobserve(e))}}#r(){return this.#t??=new ResizeObserver(t=>{for(var n of t){e.entries.set(n.target,n);for(var r of this.#e.get(n.target)||[])r(n)}})}}({box:`border-box`});function ua(e,t,n){var r=la.observe(e,()=>n(e[t]));zn(()=>(Ar(()=>n(e[t])),r))}function da(e,t){return e===t||e?.[ce]===t}function fa(e={},t,n,r){var i=Qe.r,a=cr;return zn(()=>{var o,s;return Vn(()=>{o=s,s=r?.()||[],Ar(()=>{da(n(...s),e)||(t(e,...s),o&&da(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&da(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var pa={get(e,t){if(!e.exclude.includes(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.includes(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return e.exclude.includes(t)?!1:t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.includes(t))}};function ma(e,t,n){return new Proxy({props:e,exclude:t},pa)}var ha={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(p(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];p(i)&&(i=i());let a=s(i,t);if(a&&a.set)return a.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(p(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=s(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===ce||t===le)return!1;for(let n of e.props)if(p(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(p(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function ga(...e){return new Proxy({props:e},ha)}function q(e,t,n,r){var i=!Xe||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>o&&i?(u??=Gt(r),z(u)):(l&&(l=!1,c=o?Ar(r):r),c);let f;if(a){var p=ce in e||le in e;f=s(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;a?[m,h]=mt(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Te(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?Gt:Jt)(()=>(v=!1,g()));a&&z(y);var b=cr;return(function(e,t){if(arguments.length>0){let n=t?z(y):i&&a?N(e):e;return M(y,n),v=!0,c!==void 0&&(c=n),e}return rr&&v||b.f&16384?y.v:z(y)})}function _a(e){Qe===null&&ve(`onMount`),Xe&&Qe.l!==null?ya(Qe).m.push(e):L(()=>{let t=Ar(e);if(typeof t==`function`)return t})}function va(e){Qe===null&&ve(`onDestroy`),_a(()=>()=>Ar(e))}function ya(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`),Ze();var ba=3478,xa=3479,Sa=`https://github.com/bloknayrb/tandem`,Ca=`${Sa}/issues/new`,wa=new Set([`.md`,`.txt`,`.html`,`.htm`,`.docx`]),Ta=3e3,Ea=3e3,Da=3e4,Oa={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)`},ka={yellow:`var(--tandem-highlight-yellow)`,green:`var(--tandem-highlight-green)`,blue:`var(--tandem-highlight-blue)`,pink:`var(--tandem-highlight-pink)`};function Aa(e){return e&&e in Oa?e:`yellow`}var ja=`tandem`,Ma=`tandem:mode`,Na=`tandem:settings`,Pa={left:`tandem-left-panel-width`,right:`tandem-panel-width`},Fa=1e3,Ia=3e3,La=`__tandem_ctrl__`,Ra=`annotations`,za=`awareness`,Ba=`userAwareness`,Va=`mode`,Ha=`selectionDwellMs`,Ua=`chat`,Wa=`documentMeta`,Ga=`annotationReplies`,Ka=`savedAtVersion`,qa=`authorship`,Ja=`selection`,Ya=`activity`,Xa=`claude`,Za=`openDocuments`,Qa=`activeDocumentId`,$a=`activeDocumentEpoch`,eo=`storeReadOnly`,to=`fidelityReport`,no=`tandem:showAuthorship`,ro=`tandem:decorationVisibility`,io=`tandem:recentFiles`,ao=`tandem:userName`,oo=`tandem:user-name-changed`,so={error:8e3,warning:6e3,info:4e3},co=5*6e4,lo=`tandem:tutorialCompleted`,uo=`tutorial-`,fo=`tandem:coworkOnboardingSkipped`,po=3e4,mo=2e3,ho=`tandem:zoomLevel`,go=.5,_o=`upload://`,vo=`upload://scratchpad/`;function yo(e){return e.startsWith(_o)}function bo(e){return e.startsWith(vo)}function xo(e){if(!bo(e))return null;let t=e.slice(20).split(`/`)[0];return t.length>0?t:null}var So=e=>e,Co=e=>e,wo;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(wo||={});var To;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(To||={});var J=wo.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Eo=e=>{switch(typeof e){case`undefined`:return J.undefined;case`string`:return J.string;case`number`:return Number.isNaN(e)?J.nan:J.number;case`boolean`:return J.boolean;case`function`:return J.function;case`bigint`:return J.bigint;case`symbol`:return J.symbol;case`object`:return Array.isArray(e)?J.array:e===null?J.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?J.promise:typeof Map<`u`&&e instanceof Map?J.map:typeof Set<`u`&&e instanceof Set?J.set:typeof Date<`u`&&e instanceof Date?J.date:J.object;default:return J.unknown}},Y=wo.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`]),Do=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,wo.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Do.create=e=>new Do(e);var Oo=(e,t)=>{let n;switch(e.code){case Y.invalid_type:n=e.received===J.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,wo.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${wo.joinValues(e.keys,`, `)}`;break;case Y.invalid_union:n=`Invalid input`;break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${wo.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${wo.joinValues(e.options)}, received '${e.received}'`;break;case Y.invalid_arguments:n=`Invalid function arguments`;break;case Y.invalid_return_type:n=`Invalid function return type`;break;case Y.invalid_date:n=`Invalid date`;break;case Y.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:wo.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case Y.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case Y.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case Y.custom:n=`Invalid input`;break;case Y.invalid_intersection_types:n=`Intersection results could not be merged`;break;case Y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Y.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,wo.assertNever(e)}return{message:n}},ko=Oo;function Ao(){return ko}var jo=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function X(e,t){let n=Ao(),r=jo({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Oo?void 0:Oo].filter(e=>!!e)});e.common.issues.push(r)}var Mo=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return No;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return No;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},No=Object.freeze({status:`aborted`}),Po=e=>({status:`dirty`,value:e}),Fo=e=>({status:`valid`,value:e}),Io=e=>e.status===`aborted`,Lo=e=>e.status===`dirty`,Ro=e=>e.status===`valid`,zo=e=>typeof Promise<`u`&&e instanceof Promise,Bo;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Bo||={});var Vo=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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}},Ho=(e,t)=>{if(Ro(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Do(e.common.issues);return this._error=t,this._error}}};function Uo(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var Wo=class{get description(){return this._def.description}_getType(e){return Eo(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Eo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Mo,ctx:{common:e.parent.common,data:e.data,parsedType:Eo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(zo(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Eo(e)};return Ho(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Eo(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ro(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Ro(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Eo(e)},r=this._parse({data:e,path:n.path,parent:n});return Ho(n,await(zo(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:Y.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Js({schema:this,typeName:rc.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:e=>this[`~validate`](e)}}optional(){return Ys.create(this,this._def)}nullable(){return Xs.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ks.create(this)}promise(){return qs.create(this,this._def)}or(e){return Ms.create([this,e],this._def)}and(e){return Is.create(this,e,this._def)}transform(e){return new Js({...Uo(this._def),schema:this,typeName:rc.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Zs({...Uo(this._def),innerType:this,defaultValue:t,typeName:rc.ZodDefault})}brand(){return new ec({typeName:rc.ZodBranded,type:this,...Uo(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Qs({...Uo(this._def),innerType:this,catchValue:t,typeName:rc.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return tc.create(this,e)}readonly(){return nc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Go=/^c[^\s-]{8,}$/i,Ko=/^[0-9a-z]+$/,qo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Jo=/^[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,Yo=/^[a-z0-9_-]{21}$/i,Xo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Zo=/^[-+]?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)?)??$/,Qo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$o=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,es,ts=/^(?:(?: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])$/,ns=/^(?:(?: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])$/,rs=/^(([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]))$/,is=/^(([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])$/,as=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ss=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,cs=`((\\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])))`,ls=RegExp(`^${cs}$`);function us(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function ds(e){return RegExp(`^${us(e)}$`)}function fs(e){let t=`${cs}T${us(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ps(e,t){return!!((t===`v4`||!t)&&ts.test(e)||(t===`v6`||!t)&&rs.test(e))}function ms(e,t){if(!Xo.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function hs(e,t){return!!((t===`v4`||!t)&&ns.test(e)||(t===`v6`||!t)&&is.test(e))}var gs=class e extends Wo{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.string,received:t.parsedType}),No}let t=new Mo,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?X(n,{code:Y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&X(n,{code:Y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Qo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`email`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)es||=new RegExp($o,`u`),es.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`emoji`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Jo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`uuid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Yo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`nanoid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Go.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`cuid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Ko.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`cuid2`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)qo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`ulid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),X(n,{validation:`url`,code:Y.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`regex`,code:Y.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?fs(r).test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?ls.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?ds(r).test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Zo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`duration`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?ps(e.data,r.version)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`ip`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?ms(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`jwt`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?hs(e.data,r.version)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`cidr`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?as.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`base64`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?ss.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`base64url`,code:Y.invalid_string,message:r.message}),t.dirty()):wo.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:Y.invalid_string,...Bo.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Bo.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Bo.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Bo.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Bo.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Bo.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Bo.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Bo.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Bo.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Bo.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Bo.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Bo.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Bo.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Bo.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:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Bo.errToObj(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:e?.precision===void 0?null:e?.precision,...Bo.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Bo.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Bo.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Bo.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Bo.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Bo.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Bo.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Bo.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Bo.errToObj(t)})}nonempty(e){return this.min(1,Bo.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...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(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};gs.create=e=>new gs({checks:[],typeName:rc.ZodString,coerce:e?.coerce??!1,...Uo(e)});function _s(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var vs=class e extends Wo{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)!==J.number){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.number,received:t.parsedType}),No}let t,n=new Mo;for(let r of this._def.checks)r.kind===`int`?wo.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),X(t,{code:Y.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?_s(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),X(t,{code:Y.not_finite,message:r.message}),n.dirty()):wo.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Bo.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Bo.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Bo.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Bo.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Bo.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Bo.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Bo.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Bo.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Bo.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Bo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Bo.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Bo.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Bo.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Bo.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&wo.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};vs.create=e=>new vs({checks:[],typeName:rc.ZodNumber,coerce:e?.coerce||!1,...Uo(e)});var ys=class e extends Wo{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)!==J.bigint)return this._getInvalidInput(e);let t,n=new Mo;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):wo.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.bigint,received:t.parsedType}),No}gte(e,t){return this.setLimit(`min`,e,!0,Bo.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Bo.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Bo.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Bo.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Bo.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:Bo.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Bo.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Bo.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Bo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Bo.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};ys.create=e=>new ys({checks:[],typeName:rc.ZodBigInt,coerce:e?.coerce??!1,...Uo(e)});var bs=class extends Wo{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.boolean,received:t.parsedType}),No}return Fo(e.data)}};bs.create=e=>new bs({typeName:rc.ZodBoolean,coerce:e?.coerce||!1,...Uo(e)});var xs=class e extends Wo{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.date,received:t.parsedType}),No}if(Number.isNaN(e.data.getTime()))return X(this._getOrReturnCtx(e),{code:Y.invalid_date}),No;let t=new Mo,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):wo.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:Bo.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Bo.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};xs.create=e=>new xs({checks:[],coerce:e?.coerce||!1,typeName:rc.ZodDate,...Uo(e)});var Ss=class extends Wo{_parse(e){if(this._getType(e)!==J.symbol){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.symbol,received:t.parsedType}),No}return Fo(e.data)}};Ss.create=e=>new Ss({typeName:rc.ZodSymbol,...Uo(e)});var Cs=class extends Wo{_parse(e){if(this._getType(e)!==J.undefined){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.undefined,received:t.parsedType}),No}return Fo(e.data)}};Cs.create=e=>new Cs({typeName:rc.ZodUndefined,...Uo(e)});var ws=class extends Wo{_parse(e){if(this._getType(e)!==J.null){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.null,received:t.parsedType}),No}return Fo(e.data)}};ws.create=e=>new ws({typeName:rc.ZodNull,...Uo(e)});var Ts=class extends Wo{constructor(){super(...arguments),this._any=!0}_parse(e){return Fo(e.data)}};Ts.create=e=>new Ts({typeName:rc.ZodAny,...Uo(e)});var Es=class extends Wo{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Fo(e.data)}};Es.create=e=>new Es({typeName:rc.ZodUnknown,...Uo(e)});var Ds=class extends Wo{_parse(e){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.never,received:t.parsedType}),No}};Ds.create=e=>new Ds({typeName:rc.ZodNever,...Uo(e)});var Os=class extends Wo{_parse(e){if(this._getType(e)!==J.undefined){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.void,received:t.parsedType}),No}return Fo(e.data)}};Os.create=e=>new Os({typeName:rc.ZodVoid,...Uo(e)});var ks=class e extends Wo{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==J.array)return X(t,{code:Y.invalid_type,expected:J.array,received:t.parsedType}),No;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(X(t,{code:e?Y.too_big:Y.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(X(t,{code:Y.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(X(t,{code:Y.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Vo(t,e,t.path,n)))).then(e=>Mo.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Vo(t,e,t.path,n)));return Mo.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Bo.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Bo.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Bo.toString(n)}})}nonempty(e){return this.min(1,e)}};ks.create=(e,t)=>new ks({type:e,minLength:null,maxLength:null,exactLength:null,typeName:rc.ZodArray,...Uo(t)});function As(e){if(e instanceof js){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Ys.create(As(r))}return new js({...e._def,shape:()=>t})}else if(e instanceof ks)return new ks({...e._def,type:As(e.element)});else if(e instanceof Ys)return Ys.create(As(e.unwrap()));else if(e instanceof Xs)return Xs.create(As(e.unwrap()));else if(e instanceof Ls)return Ls.create(e.items.map(e=>As(e)));else return e}var js=class e extends Wo{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=wo.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==J.object){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.object,received:t.parsedType}),No}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ds&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Vo(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Ds){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(X(n,{code:Y.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Vo(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>Mo.mergeObjectSync(t,e)):Mo.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Bo.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:Bo.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:rc.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of wo.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of wo.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return As(this)}partial(t){let n={};for(let e of wo.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of wo.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ys;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Ws(wo.objectKeys(this.shape))}};js.create=(e,t)=>new js({shape:()=>e,unknownKeys:`strip`,catchall:Ds.create(),typeName:rc.ZodObject,...Uo(t)}),js.strictCreate=(e,t)=>new js({shape:()=>e,unknownKeys:`strict`,catchall:Ds.create(),typeName:rc.ZodObject,...Uo(t)}),js.lazycreate=(e,t)=>new js({shape:e,unknownKeys:`strip`,catchall:Ds.create(),typeName:rc.ZodObject,...Uo(t)});var Ms=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Do(e.ctx.common.issues));return X(t,{code:Y.invalid_union,unionErrors:n}),No}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Do(e));return X(t,{code:Y.invalid_union,unionErrors:i}),No}}get options(){return this._def.options}};Ms.create=(e,t)=>new Ms({options:e,typeName:rc.ZodUnion,...Uo(t)});var Ns=e=>e instanceof Hs?Ns(e.schema):e instanceof Js?Ns(e.innerType()):e instanceof Us?[e.value]:e instanceof Gs?e.options:e instanceof Ks?wo.objectValues(e.enum):e instanceof Zs?Ns(e._def.innerType):e instanceof Cs?[void 0]:e instanceof ws?[null]:e instanceof Ys?[void 0,...Ns(e.unwrap())]:e instanceof Xs?[null,...Ns(e.unwrap())]:e instanceof ec||e instanceof nc?Ns(e.unwrap()):e instanceof Qs?Ns(e._def.innerType):[],Ps=class e extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return X(t,{code:Y.invalid_type,expected:J.object,received:t.parsedType}),No;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(X(t,{code:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),No)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ns(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:rc.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Uo(r)})}};function Fs(e,t){let n=Eo(e),r=Eo(t);if(e===t)return{valid:!0,data:e};if(n===J.object&&r===J.object){let n=wo.objectKeys(t),r=wo.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Fs(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===J.array&&r===J.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Fs(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===J.date&&r===J.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Is=class extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Io(e)||Io(r))return No;let i=Fs(e.value,r.value);return i.valid?((Lo(e)||Lo(r))&&t.dirty(),{status:t.value,value:i.data}):(X(n,{code:Y.invalid_intersection_types}),No)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Is.create=(e,t,n)=>new Is({left:e,right:t,typeName:rc.ZodIntersection,...Uo(n)});var Ls=class e extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return X(n,{code:Y.invalid_type,expected:J.array,received:n.parsedType}),No;if(n.data.length<this._def.items.length)return X(n,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),No;!this._def.rest&&n.data.length>this._def.items.length&&(X(n,{code:Y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Vo(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Mo.mergeArray(t,e)):Mo.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ls.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ls({items:e,typeName:rc.ZodTuple,rest:null,...Uo(t)})};var Rs=class e extends Wo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.object)return X(n,{code:Y.invalid_type,expected:J.object,received:n.parsedType}),No;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Vo(n,e,n.path,e)),value:a._parse(new Vo(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Mo.mergeObjectAsync(t,r):Mo.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Wo?new e({keyType:t,valueType:n,typeName:rc.ZodRecord,...Uo(r)}):new e({keyType:gs.create(),valueType:t,typeName:rc.ZodRecord,...Uo(n)})}},zs=class extends Wo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.map)return X(n,{code:Y.invalid_type,expected:J.map,received:n.parsedType}),No;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Vo(n,e,n.path,[a,`key`])),value:i._parse(new Vo(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return No;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return No;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};zs.create=(e,t,n)=>new zs({valueType:t,keyType:e,typeName:rc.ZodMap,...Uo(n)});var Bs=class e extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return X(n,{code:Y.invalid_type,expected:J.set,received:n.parsedType}),No;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(X(n,{code:Y.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(X(n,{code:Y.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return No;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Vo(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:Bo.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Bo.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Bs.create=(e,t)=>new Bs({valueType:e,minSize:null,maxSize:null,typeName:rc.ZodSet,...Uo(t)});var Vs=class e extends Wo{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return X(t,{code:Y.invalid_type,expected:J.function,received:t.parsedType}),No;function n(e,n){return jo({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ao(),Oo].filter(e=>!!e),issueData:{code:Y.invalid_arguments,argumentsError:n}})}function r(e,n){return jo({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ao(),Oo].filter(e=>!!e),issueData:{code:Y.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qs){let e=this;return Fo(async function(...t){let o=new Do([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Fo(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Do([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Do([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ls.create(t).rest(Es.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ls.create([]).rest(Es.create()),returns:n||Es.create(),typeName:rc.ZodFunction,...Uo(r)})}},Hs=class extends Wo{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Hs.create=(e,t)=>new Hs({getter:e,typeName:rc.ZodLazy,...Uo(t)});var Us=class extends Wo{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return X(t,{received:t.data,code:Y.invalid_literal,expected:this._def.value}),No}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Us.create=(e,t)=>new Us({value:e,typeName:rc.ZodLiteral,...Uo(t)});function Ws(e,t){return new Gs({values:e,typeName:rc.ZodEnum,...Uo(t)})}var Gs=class e extends Wo{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{expected:wo.joinValues(n),received:t.parsedType,code:Y.invalid_type}),No}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{received:t.data,code:Y.invalid_enum_value,options:n}),No}return Fo(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Gs.create=Ws;var Ks=class extends Wo{_parse(e){let t=wo.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){let e=wo.objectValues(t);return X(n,{expected:wo.joinValues(e),received:n.parsedType,code:Y.invalid_type}),No}if(this._cache||=new Set(wo.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=wo.objectValues(t);return X(n,{received:n.data,code:Y.invalid_enum_value,options:e}),No}return Fo(e.data)}get enum(){return this._def.values}};Ks.create=(e,t)=>new Ks({values:e,typeName:rc.ZodNativeEnum,...Uo(t)});var qs=class extends Wo{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==J.promise&&t.common.async===!1?(X(t,{code:Y.invalid_type,expected:J.promise,received:t.parsedType}),No):Fo((t.parsedType===J.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qs.create=(e,t)=>new qs({type:e,typeName:rc.ZodPromise,...Uo(t)});var Js=class extends Wo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===rc.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{X(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return No;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?No:r.status===`dirty`||t.value===`dirty`?Po(r.value):r});{if(t.value===`aborted`)return No;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?No:r.status===`dirty`||t.value===`dirty`?Po(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?No:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?No:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ro(e))return No;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Ro(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):No);wo.assertNever(r)}};Js.create=(e,t,n)=>new Js({schema:e,typeName:rc.ZodEffects,effect:t,...Uo(n)}),Js.createWithPreprocess=(e,t,n)=>new Js({schema:t,effect:{type:`preprocess`,transform:e},typeName:rc.ZodEffects,...Uo(n)});var Ys=class extends Wo{_parse(e){return this._getType(e)===J.undefined?Fo(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ys.create=(e,t)=>new Ys({innerType:e,typeName:rc.ZodOptional,...Uo(t)});var Xs=class extends Wo{_parse(e){return this._getType(e)===J.null?Fo(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Xs.create=(e,t)=>new Xs({innerType:e,typeName:rc.ZodNullable,...Uo(t)});var Zs=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===J.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Zs.create=(e,t)=>new Zs({innerType:e,typeName:rc.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...Uo(t)});var Qs=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return zo(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Do(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Do(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Qs.create=(e,t)=>new Qs({innerType:e,typeName:rc.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...Uo(t)});var $s=class extends Wo{_parse(e){if(this._getType(e)!==J.nan){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.nan,received:t.parsedType}),No}return{status:`valid`,value:e.data}}};$s.create=e=>new $s({typeName:rc.ZodNaN,...Uo(e)});var ec=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},tc=class e extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?No:e.status===`dirty`?(t.dirty(),Po(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?No:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:rc.ZodPipeline})}},nc=class extends Wo{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ro(e)&&(e.value=Object.freeze(e.value)),e);return zo(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};nc.create=(e,t)=>new nc({innerType:e,typeName:rc.ZodReadonly,...Uo(t)}),js.lazycreate;var rc;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(rc||={}),gs.create,vs.create,$s.create,ys.create,bs.create,xs.create,Ss.create,Cs.create,ws.create,Ts.create,Es.create,Ds.create,Os.create,ks.create,js.create,js.strictCreate,Ms.create,Ps.create,Is.create,Ls.create,Rs.create,zs.create,Bs.create,Vs.create,Hs.create,Us.create;var ic=Gs.create;Ks.create,qs.create,Js.create,Ys.create,Xs.create,Js.createWithPreprocess,tc.create,ic([`highlight`,`note`,`comment`]),ic([`pending`,`accepted`,`dismissed`]),ic([`yellow`,`green`,`blue`,`pink`]),ic([`info`,`warning`,`error`,`success`]);var ac=ic([`solo`,`tandem`]);ic([`user`,`claude`,`import`]),ic([`user`,`claude`,`import`]),ic([`accept`,`dismiss`]),ic([`markdown`,`json`]),ic([`md`,`txt`,`html`,`docx`]),ic([`RANGE_GONE`,`RANGE_MOVED`,`FILE_LOCKED`,`FILE_NOT_FOUND`,`NO_DOCUMENT`,`INVALID_RANGE`,`INVALID_ARGUMENT`,`NOT_FOUND`,`ANNOTATION_RESOLVED`,`FORMAT_ERROR`,`PERMISSION_DENIED`]),ic([`CHANNEL_CONNECT_FAILED`,`MONITOR_CONNECT_FAILED`]);function oc(e){return e.author!==`user`}function sc(e){return e.status===`pending`&&oc(e)}function cc(e){return`${e}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function lc(){return cc(`ann`)}function uc(){return cc(`msg`)}function dc(){return cc(`ntf`)}function fc(e){return cc(e)}var pc=`/api/notify-stream`,mc=`/api/info`,hc=`/api/diagnostics`,gc=`/health`,_c=`/api/open`,vc=`/api/close`,yc=`/api/save`,bc=`/api/rename`,xc=`/api/upload`,Sc=`/api/scratchpad`,Cc=`/api/convert`,wc=`/api/apply-changes`,Tc=`/api/document/raw`,Ec=`/api/document/reload`,Dc=`/api/backups`,Oc=`/api/backups/restore`,kc=`/api/docx-conflict/resolve`,Ac=`/api/annotation-reply`,jc=`/api/remove-annotation`,Mc=`/api/store/reclaim-lock`,Nc=`/api/chat`,Pc=`/api/sessions`,Fc=`/api/sessions/delete`,Ic=`/api/sessions/clear`,Lc=`/api/license/status`,Rc=`/api/license/activate`,zc=`/api/launcher/status`,Bc=`/api/launcher/nonce`,Vc=`/api/launcher/relaunch`,Hc=`/api/launcher/start-fresh`,Uc=`/api/launcher/working-directory`,Wc=[`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`],Gc=new Set(Wc);function Kc(e){return Gc.has(e)}var qc={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`},Jc={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`}},Yc=[{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`}],Xc={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`},Zc=/^(Control|Shift|Alt|Meta|OS)/,Qc=new Set([`Tab`,`Escape`,`Enter`,`NumpadEnter`,`NumLock`,`CapsLock`,`ContextMenu`,`Insert`]);function $c(e){return Zc.test(e.code)||e.code.startsWith(`Numpad`)||Qc.has(e.code)?!1:e.ctrlOrMeta||e.alt}function el(e){if(!e.code||e.key===`Dead`)return null;let t={ctrlOrMeta:e.ctrlKey||e.metaKey,alt:e.altKey,shift:e.shiftKey,code:e.code};return $c(t)?t:null}function tl(e,t){return e.ctrlOrMeta===(t.ctrlKey||t.metaKey)&&e.alt===t.altKey&&e.shift===t.shiftKey&&e.code===t.code}function nl(e,t){return e.ctrlOrMeta===t.ctrlOrMeta&&e.alt===t.alt&&e.shift===t.shift&&e.code===t.code}function rl(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.ctrlOrMeta==`boolean`&&typeof t.alt==`boolean`&&typeof t.shift==`boolean`&&typeof t.code==`string`&&t.code.length>0&&t.code.length<=32}function il(){try{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform;return/Mac|iPhone|iPad|iPod/i.test(e??``)}catch{return!1}}function al(e){return e.startsWith(`Key`)?e.slice(3):e.startsWith(`Digit`)?e.slice(5):{Comma:`,`,Period:`.`,Slash:`/`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,BracketLeft:`[`,BracketRight:`]`,Backquote:"`",Minus:`-`,Equal:`=`,Space:`Space`,Tab:`Tab`,Enter:`Enter`,ArrowLeft:`←`,ArrowRight:`→`,ArrowUp:`↑`,ArrowDown:`↓`}[e]??e}function ol(e){let t=il(),n=[];return e.ctrlOrMeta&&n.push(t?`⌘`:`Ctrl`),e.alt&&n.push(t?`⌥`:`Alt`),e.shift&&n.push(t?`⇧`:`Shift`),n.push(al(e.code)),t?n.join(``):n.join(`+`)}function sl(e,t){return t.get(e)??Jc[e]}function cl(e){let t=new Map;for(let n of Wc)t.set(n,ol(sl(n,e)));return t}function ll(e,t){return t?t.has(e):!1}function ul(e,t){if(e.isComposing)return null;if(t&&t.size>0)for(let n of Wc){let r=t.get(n);if(r&&tl(r,e))return{id:n}}let n=e.ctrlKey||e.metaKey;if(e.key===`?`)return{id:`toggle-help`};if(n){if(e.shiftKey&&e.code===`Comma`&&!ll(`settings-modal`,t))return{id:`settings-modal`};if(!e.shiftKey&&e.code===`Comma`&&!ll(`settings`,t))return{id:`settings`};if(e.key===`/`)return{id:`toggle-help`};if(!e.altKey&&!e.shiftKey&&e.code===`KeyA`)return{id:`select-all`};if(e.shiftKey&&!e.altKey&&e.code===`KeyS`&&!ll(`save-as`,t))return{id:`save-as`};if(e.code===`KeyS`&&!ll(`save`,t))return{id:`save`};if(e.shiftKey&&e.code===`KeyP`&&!ll(`toggle-palette`,t))return{id:`toggle-palette`};if(e.code===`KeyN`&&!ll(`new-scratchpad`,t))return{id:`new-scratchpad`};if(e.code===`KeyW`&&!ll(`close-tab`,t))return{id:`close-tab`};if(e.code===`KeyO`&&!ll(`open-file`,t))return{id:`open-file`};if(/^Digit[1-9]$/.test(e.code))return{id:`pick-tab`,context:{tabIndex:Number(e.code.slice(5))}};if(e.shiftKey&&!e.altKey&&e.code===`KeyM`&&!ll(`toggle-mode`,t))return{id:`toggle-mode`};if(e.altKey&&e.code===`KeyT`&&!ll(`reopen-closed-tab`,t))return{id:`reopen-closed-tab`};if(!e.altKey&&!e.shiftKey&&e.code===`KeyT`&&!ll(`new-tab-menu`,t))return{id:`new-tab-menu`};if(e.code===`KeyF`)return{id:`find`,context:{shift:e.shiftKey}};if(e.code===`KeyG`)return{id:`find-nav`,context:{shift:e.shiftKey}};if(e.key===`Enter`)return{id:`annotation-accept-or-dismiss`,context:{shift:e.shiftKey}};if(e.altKey&&e.code===`KeyM`&&!ll(`comment-on-selection`,t))return{id:`comment-on-selection`};if(e.altKey&&e.code===`KeyA`&&!ll(`toggle-authorship`,t))return{id:`toggle-authorship`}}if(e.altKey&&!e.ctrlKey&&!e.metaKey){if(e.shiftKey){if(e.code===`ArrowLeft`&&!ll(`toggle-left-panel`,t))return{id:`toggle-left-panel`};if(e.code===`ArrowRight`&&!ll(`toggle-right-panel`,t))return{id:`toggle-right-panel`}}if(!e.shiftKey){if(e.code===`BracketRight`&&!ll(`annotation-next`,t))return{id:`annotation-next`};if(e.code===`BracketLeft`&&!ll(`annotation-prev`,t))return{id:`annotation-prev`}}if(!e.shiftKey&&e.code===`KeyL`&&!ll(`select-block`,t))return{id:`select-block`}}return null}function dl(e){return e.code===`Slash`?e.shift?`?`:`/`:e.code===`Enter`||e.code===`NumpadEnter`?`Enter`:``}function fl(e){return{key:dl(e),code:e.code,ctrlKey:e.ctrlOrMeta,metaKey:!1,altKey:e.alt,shiftKey:e.shift,isComposing:!1}}function pl(e,t){switch(e){case`toggle-help`:return`Show keyboard shortcuts`;case`select-all`:return`Select all`;case`find`:return t?.shift?`Find in open tabs`:`Find / Replace`;case`find-nav`:return t?.shift?`Find previous`:`Find next`;case`annotation-accept-or-dismiss`:return t?.shift?`Dismiss annotation`:`Accept annotation`;case`pick-tab`:return t?.tabIndex?`Jump to tab ${t.tabIndex}`:`Jump to tab`;default:return``}}function ml(e){let t=ul(fl(e));return!t||Kc(t.id)?null:pl(t.id,t.context)||null}function hl(e,t,n){for(let r of Wc)if(r!==n&&nl(sl(r,t),e))return qc[r];let r=ml(e);if(r)return r;for(let t of Yc)if(nl(t.chord,e))return t.label;return null}function gl(e){return Yc.some(t=>nl(t.chord,e))}function _l(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Kc(n)&&rl(r)&&$c(r)&&(gl(r)||ml(r)||(t[n]=r));let n={},r=[];for(let e of Wc){let i=t[e];i&&(r.some(e=>nl(e,i))||(r.push(i),n[e]=i))}return n}function vl(e){let t=new Map;for(let[n,r]of Object.entries(_l(e)))t.set(n,r);return t}var yl=[`narrow`,`comfortable`,`wide`,`full`],bl={narrow:`58ch`,comfortable:`68ch`,wide:`82ch`,full:`100%`};function xl(e){return typeof e==`string`&&yl.includes(e)}var Sl=[`anthropic`,`openai`,`gemini`,`local-ollama`,`local-llamacpp`],Cl=50,wl={s:14,m:16,l:18};function Tl(){try{return typeof window>`u`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}var El={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:16,primaryTab:`annotations`,panelOrder:`chat-editor-annotations`,editorMeasure:`comfortable`,selectionDwellMs:Fa,showAuthorship:!0,reduceMotion:!1,textSize:`m`,theme:`system`,systemLightVariant:`light`,accentHue:275,editorFont:`sans`,fontByExtension:{},defaultSaveDirectory:null,density:`cozy`,defaultMode:`tandem`,highContrast:!1,annotationPatterns:!1,selectionToolbar:!0,formattingBarVisible:!0,railHoverReveal:!0,soloRailHidden:!0,degradedBannerDelayMs:3e4,sidecarRetryStrategy:`exponential`,marginView:!1,showComments:!0,showHighlights:!0,showNotes:!0,showRawMarkdown:!0,decorationsMuted:!1,models:[],defaultModelId:null,customShortcuts:{}},Dl=64,Ol=512;function kl(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(t.length>=Cl)break;if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.id!=`string`||e.id.length===0||e.id.length>64||typeof e.provider!=`string`||!Sl.includes(e.provider)||typeof e.displayName!=`string`||e.displayName.length>256||typeof e.modelId!=`string`||e.modelId.length===0||e.modelId.length>256||typeof e.enabled!=`boolean`)continue;let r={id:e.id,provider:e.provider,displayName:e.displayName,modelId:e.modelId,enabled:e.enabled};if(typeof e.apiKeyRef==`string`&&e.apiKeyRef.length>0&&e.apiKeyRef.length<=Dl&&/^[A-Za-z0-9_-]+$/.test(e.apiKeyRef)?r.apiKeyRef=e.apiKeyRef:typeof e.apiKey==`string`&&e.apiKey.length<=Ol&&(r._legacyApiKey=e.apiKey),typeof e.endpoint==`string`&&e.endpoint.length<=2048&&(r.endpoint=e.endpoint),e.params&&typeof e.params==`object`&&!Array.isArray(e.params)){let t={};for(let[n,r]of Object.entries(e.params))(typeof r==`number`||typeof r==`string`||typeof r==`boolean`)&&(t[n]=r);r.params=t}t.push(r)}return t}var Al=[`serif`,`sans`,`mono`];function jl(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))n===`__proto__`||n===`constructor`||n===`prototype`||typeof n!=`string`||n.length===0||n.length>32||typeof r==`string`&&Al.includes(r)&&(t[n]=r);return t}function Ml(e){return{leftPanelVisible:e.leftPanelVisible===!0,rightPanelVisible:e.rightPanelVisible!==!1,schemaVersion:16,primaryTab:e.primaryTab===`annotations`?`annotations`:`chat`,panelOrder:e.panelOrder===`annotations-editor-chat`?`annotations-editor-chat`:`chat-editor-annotations`,editorMeasure:xl(e.editorMeasure)?e.editorMeasure:El.editorMeasure,selectionDwellMs:Math.max(500,Math.min(Ia,Number(e.selectionDwellMs)||1e3)),showAuthorship:e.showAuthorship===!1?!1:El.showAuthorship,reduceMotion:typeof e.reduceMotion==`boolean`?e.reduceMotion:Tl(),textSize:e.textSize===`s`||e.textSize===`m`||e.textSize===`l`?e.textSize:El.textSize,theme:e.theme===`light`||e.theme===`dark`||e.theme===`warm`||e.theme===`system`?e.theme:El.theme,systemLightVariant:e.systemLightVariant===`warm`?`warm`:El.systemLightVariant,accentHue:typeof e.accentHue==`number`&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:El.accentHue,editorFont:e.editorFont===`serif`||e.editorFont===`sans`||e.editorFont===`mono`?e.editorFont:El.editorFont,fontByExtension:jl(e.fontByExtension),defaultSaveDirectory:typeof e.defaultSaveDirectory==`string`&&e.defaultSaveDirectory.trim()?e.defaultSaveDirectory.trim():null,density:e.density===`compact`||e.density===`cozy`||e.density===`spacious`?e.density:El.density,defaultMode:e.defaultMode===`solo`||e.defaultMode===`tandem`?e.defaultMode:El.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:El.selectionToolbar,formattingBarVisible:e.formattingBarVisible===!1?!1:El.formattingBarVisible,railHoverReveal:e.railHoverReveal===!1?!1:El.railHoverReveal,soloRailHidden:e.soloRailHidden===!1?!1:El.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs==`number`&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:El.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy===`exponential`||e.sidecarRetryStrategy===`constant-2s`?e.sidecarRetryStrategy:El.sidecarRetryStrategy,marginView:e.marginView===!0,showComments:e.showComments===!1?!1:El.showComments,showHighlights:e.showHighlights===!1?!1:El.showHighlights,showNotes:e.showNotes===!1?!1:El.showNotes,showRawMarkdown:e.showRawMarkdown===!1?!1:El.showRawMarkdown,decorationsMuted:e.decorationsMuted===!0,models:kl(e.models),defaultModelId:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null,customShortcuts:_l(e.customShortcuts)}}function Nl(){let e;try{e=localStorage.getItem(Na)}catch{e=null}if(e)try{let t=JSON.parse(e);if((!t||typeof t!=`object`||Array.isArray(t))&&(t={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:1}),(typeof t.schemaVersion==`number`?t.schemaVersion:1)===1){let e=t.panelHidden===!0,n=!1,r=!0;e?(n=!1,r=!1):t.layout===`three-panel`?(n=!0,r=!0):t.layout===`tabbed-left`&&(n=!0,r=!1),t={...t,leftPanelVisible:n,rightPanelVisible:r,schemaVersion:2},delete t.layout,delete t.panelHidden}if(t.schemaVersion===2&&(t={...t,models:[],schemaVersion:3}),t.schemaVersion===3&&(t={...t,schemaVersion:4}),t.schemaVersion===4){let e={...t,schemaVersion:5};delete e.leftRailTabs,delete e.rightRailTabs,t=e}if(t.schemaVersion===5){let e={...t,schemaVersion:6};delete e.showIntegrationWizard,t=e}if(t.schemaVersion===6){let e=(Array.isArray(t.models)?t.models:[]).find(e=>typeof e?.id==`string`&&e.enabled===!0);t={...t,schemaVersion:7,defaultModelId:e&&typeof e.id==`string`?e.id:null}}if(t.schemaVersion===7&&(t={...t,schemaVersion:8}),t.schemaVersion===8){let e=t.showAnnotationDecorations===!1,n={...t,showComments:!e,showHighlights:!e,showNotes:!e,decorationsMuted:!1,schemaVersion:9};delete n.showAnnotationDecorations,t=n}if(t.schemaVersion===9&&(t={...t,schemaVersion:10}),t.schemaVersion===10&&(t={...t,schemaVersion:11}),t.schemaVersion===11){let e={...t,schemaVersion:12};if(e.editorMeasure===void 0){let n=t.editorWidthPercent;e.editorMeasure=n===void 0||n===100?`full`:`comfortable`}delete e.editorWidthPercent,t=e}if(t.showAnnotationDecorations===!1&&t.showComments===void 0&&(t={...t,showComments:!1,showHighlights:!1,showNotes:!1}),t.schemaVersion===12&&(t={...t,schemaVersion:13}),t.schemaVersion===13&&(t={...t,schemaVersion:14}),t.schemaVersion===14&&(t={...t,schemaVersion:15}),t.schemaVersion===15){let e={...t,schemaVersion:16};delete e.holdAnnotationsWhileOffline,e.sidecarRetryStrategy===`manual`&&(e.sidecarRetryStrategy=`exponential`),t=e}if(typeof t.schemaVersion==`number`&&t.schemaVersion>16){console.warn(`[tandem] settings schemaVersion=${t.schemaVersion} is newer than v16; loading defensively without writing.`);let e=t.editorMeasure,n=Ml(t);typeof e==`string`&&e!==n.editorMeasure&&console.warn(`[tandem] editorMeasure=${JSON.stringify(e)} from newer client is unknown to v16; displaying as ${JSON.stringify(n.editorMeasure)} (your setting is preserved on-disk).`);let r=new Set(Object.keys(n)),i=new Set([`leftRailTabs`,`rightRailTabs`,`showIntegrationWizard`,`showAnnotationDecorations`,`editorWidthPercent`,`holdAnnotationsWhileOffline`]),a={};for(let[e,n]of Object.entries(t))!r.has(e)&&e!==`_readOnly`&&!i.has(e)&&(a[e]=n);return{...n,...a,_readOnly:!0}}return Ml(t)}catch(e){console.warn(`[tandem] settings JSON is corrupt, resetting to defaults:`,e)}return{...El,reduceMotion:Tl()}}function Pl(e,t){let n={...e,...t},r=kl(n.models);return{...n,customShortcuts:_l(n.customShortcuts),fontByExtension:jl(n.fontByExtension),defaultSaveDirectory:typeof n.defaultSaveDirectory==`string`&&n.defaultSaveDirectory.trim()?n.defaultSaveDirectory.trim():null,selectionDwellMs:Math.max(500,Math.min(Ia,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):El.accentHue,editorMeasure:xl(n.editorMeasure)?n.editorMeasure:El.editorMeasure,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,n.degradedBannerDelayMs)),models:r,defaultModelId:typeof n.defaultModelId==`string`&&r.some(e=>e.id===n.defaultModelId)?n.defaultModelId:null}}function Fl(e,t){if(t){let n=e.fontByExtension?.[t];if(n)return n}return e.editorFont}var Il=`http://127.0.0.1:${xa}`;function Ll(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function Rl(e){return e.toLowerCase().endsWith(`.docx`)}async function zl(e){return Rl(e.name)?Ll(await e.arrayBuffer()):e.text()}var Bl=`modulepreload`,Vl=function(e){return`/`+e},Hl={},Ul=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Vl(t,n),t in Hl)return;Hl[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Bl,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Wl(){try{return Nl().defaultSaveDirectory}catch{return null}}async function Gl(){let e=new AbortController,t=setTimeout(()=>e.abort(),250);try{let t=await fetch(`${Il}/api/integrations`,{signal:e.signal});if(!t.ok)return null;let n=(await t.json()).integrations?.find(e=>e.kind===`claude-code`)?.workingDirectory;return typeof n==`string`&&n.trim()?n.trim():null}catch{return null}finally{clearTimeout(t)}}async function Kl(){try{let{homeDir:e}=await Ul(async()=>{let{homeDir:e}=await import(`./path-49-uTKly.js`);return{homeDir:e}},__vite__mapDeps([0,1])),t=await e();return typeof t==`string`&&t.trim()?t:null}catch{return null}}async function ql(){return Wl()||await Gl()||await Kl()}function Jl(e,t,n=Date.now(),r=20){return[e.find(e=>e.path===t)??{path:t,openedAt:n},...e.filter(e=>e.path!==t)].slice(0,r)}function Yl(e){return e.map(e=>e.path)}function Xl(e,t=Date.now()){if(!e)return``;let n=t-e;if(n<6e4)return`just now`;let r=Math.floor(n/6e4);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Zl(){try{let e=localStorage.getItem(io);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.map(e=>{if(typeof e==`string`)return{path:e,openedAt:0};if(typeof e==`object`&&e&&typeof e.path==`string`){let t=e;return{path:t.path,openedAt:typeof t.openedAt==`number`?t.openedAt:0}}return null}).filter(e=>e!==null):[]}catch(e){return console.warn(`[tandem] failed to load recent files:`,e),[]}}function Ql(e){try{localStorage.setItem(io,JSON.stringify(e)),ru()}catch(e){console.warn(`[tandem] failed to save recent files:`,e)}}function $l(){try{localStorage.removeItem(io),ru()}catch(e){console.warn(`[tandem] failed to clear recent files:`,e)}}var eu=3e4,tu=null;function nu(){let e=Date.now();if(tu&&e-tu.ts<eu)return tu.files;let t=Zl();return tu={files:t,ts:e},t}function ru(){tu=null}var iu=[`editor`,`navigation`,`view`,`document`,`annotations`,`claude`],au=j(N(new Map));function ou(e,t={}){if(z(au).has(e.id)&&!t.replace){let t=`[actions] id collision: "${e.id}" — existing action silently replaced. Pass { replace: true } to suppress this warning.`;console.warn(t)}return M(au,new Map(z(au)).set(e.id,e),!0),!0}function su(){return z(au)}var cu=null;function lu(e){cu=e}function uu(e,t){if(!cu){console.warn(`[actions] "${e}" invoked before App mounted — deps not wired yet`);return}t(cu)}var du=j(!1),fu={get saving(){return z(du)}},pu=!1,mu=!1;function hu(e){return e.connected&&e.tabCount===0&&e.activeTabId===null}async function gu(){if(!mu){mu=!0;try{let e=await fetch(`${Il}${Sc}`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));console.warn(`[Tandem] New Scratchpad failed:`,t.message??e.statusText)}}catch(e){console.warn(`[Tandem] New Scratchpad request failed:`,e)}finally{mu=!1}}}function _u(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}var vu=!1;async function yu(e){let t=await ql();if(!t)return e;try{let{join:n}=await Ul(async()=>{let{join:e}=await import(`./path-49-uTKly.js`);return{join:e}},__vite__mapDeps([0,1]));return await n(t,e)}catch{return e}}function bu(e,t){let n=`.${t}`,r=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return e.slice(r+1).includes(`.`)?e.slice(e.lastIndexOf(`.`)).toLowerCase()===n?e:`${e.slice(0,e.lastIndexOf(`.`))}${n}`:`${e}${n}`}function xu(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(i),0)}async function Su(e){if(vu)return;let{activeDocId:t,notify:n,defaultName:r,sourceFormat:i}=e;if(!t){n(`warning`,`No active document to save.`);return}vu=!0;try{_u()?await Cu(t,n,r??`Scratchpad.md`):await wu(t,n,i)}finally{vu=!1}}async function Cu(e,t,n){let r;try{let{save:e}=await Ul(async()=>{let{save:e}=await import(`./dist-js-BWAGOggB.js`);return{save:e}},__vite__mapDeps([2,1]));r=await e({defaultPath:await yu(n),filters:[{name:`Markdown`,extensions:[`md`]},{name:`Plain Text`,extensions:[`txt`]}]})}catch(e){t(`error`,`Save As dialog unavailable: ${e instanceof Error?e.message:e}`);return}if(typeof r!=`string`||r.length===0)return;let i=r.toLowerCase().endsWith(`.txt`)?`txt`:`md`,a=bu(r,i);a!==r&&t(`info`,`Saving as ${i.toUpperCase()} — only .md and .txt are supported.`);try{let n=await fetch(`${Il}${yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,targetPath:a,format:i})});if(!n.ok){t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`);return}let r=await n.json().catch(()=>null),o=r?.data?.fileName??a,s=r?.data?.targetPath??a;Ql(Jl(Zl(),s)),t(`info`,`Saved to ${o}.`)}catch(e){t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`)}}async function wu(e,t,n){let r=n===`txt`?`txt`:`md`;try{let n=await fetch(`${Il}${yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,serialize:!0,format:r})});if(!n.ok){t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`);return}let i=await n.json().catch(()=>null),a=i?.data?.content,o=i?.data?.fileName??`Scratchpad.${r}`;if(typeof a!=`string`){t(`error`,`Save As returned no content.`);return}xu(a,o,r===`md`?`text/markdown`:`text/plain`),t(`info`,`Downloaded; scratchpad remains in-session.`)}catch(e){t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`)}}async function Tu(e){if(!(!e||pu)){pu=!0,M(du,!0);try{let t=await fetch(`${Il}${yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e})});if(t.ok){let e=await t.json().catch(()=>null);(e?.data?.integrityWarnings?.length??0)>0&&cu?.notify(`error`,`Saved, but some content may not have been preserved — your original is backed up. See the document notice, or run "Restore a backup of this document…" from the command palette.`);let n=e?.data?.fidelityWarnings?.length??0;n>0&&cu?.notify(`warning`,`Saved — ${n} Word feature${n===1?``:`s`} were simplified on export; see the document notice for details.`)}else{let e=await t.json().catch(()=>({}));console.warn(`[Tandem] Save failed:`,e.message??t.statusText)}}catch(e){console.warn(`[Tandem] Save request failed:`,e)}finally{pu=!1,M(du,!1)}}}var Eu=!1;async function Du(){let e;try{e=await fetch(`${Il}${zc}`)}catch(e){return{ok:!1,kind:`network`,detail:e instanceof Error?e.message:String(e)}}return e.status===404?{ok:!1,kind:`not-built`}:e.ok?{ok:!0,value:await e.json()}:{ok:!1,kind:`server-error`,detail:`HTTP ${e.status}`}}async function Ou(){let e;try{e=await fetch(`${Il}${Bc}`,{method:`GET`})}catch(e){return{ok:!1,kind:`network`,detail:e instanceof Error?e.message:String(e)}}if(e.status===404)return{ok:!1,kind:`not-built`};if(!e.ok)return{ok:!1,kind:`server-error`,detail:`HTTP ${e.status}`};let t=await e.json();return typeof t.nonce==`string`?{ok:!0,value:t.nonce}:{ok:!1,kind:`server-error`,detail:`malformed nonce response`}}function ku(e){if(!e||/^[a-z]+:\/\//.test(e))return null;let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>0?e.slice(0,t):null}async function Au(e,t,n,r){let i=await Ou();if(!i.ok){e.notify(`error`,`Failed to acquire launcher nonce: ${i.kind}${i.detail?` (${i.detail})`:``}.`);return}let a=i.value;try{let i=await fetch(`${Il}${t}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,nonce:a})});if(!i.ok){let t=await i.json().catch(()=>({}));e.notify(`error`,`${r.failPrefix}: ${t.message??i.statusText}`);return}e.notify(`info`,r.successMessage)}catch(t){e.notify(`error`,`${r.requestFailPrefix}: ${t instanceof Error?t.message:t}`)}}async function ju(e){if(Eu)return!1;let t=await Du();if(!t.ok)return t.kind===`not-built`?e.notify(`warning`,`Claude launcher not active in this Tandem build.`):t.kind===`network`?e.notify(`error`,`Cannot reach Tandem server${t.detail?`: ${t.detail}`:``}.`):e.notify(`error`,`Launcher status check failed${t.detail?`: ${t.detail}`:``}.`),!1;let n=t.value;return n.available?(`skillRefresh`in n&&n.skillRefresh&&e.notify(`warning`,`Bundled skill refresh failed: ${n.skillRefresh.message}. Run \`tandem setup\` to retry.`),!0):(e.notify(`warning`,`Claude launcher not active in this Tandem build.`),!1)}async function Mu(e){if(!await ju(e))return;let t=ku(e.getActiveDocumentPath());if(!t){e.notify(`warning`,`Active document isn't saved to a folder. Set a working directory in Settings → Claude Code.`);return}if(confirm(`Restart Claude in:\n${t}\n\nYour current task may be interrupted.`)){Eu=!0;try{await Au(e,Vc,{cwd:t},{failPrefix:`Relaunch failed`,requestFailPrefix:`Relaunch request failed`,successMessage:`Claude restarting in ${t}.`})}finally{Eu=!1}}}function Nu(){uu(`launcher-relaunch-here`,e=>void Mu(e))}async function Pu(e){if(await ju(e)&&confirm(`Drop Claude's saved conversation and restart fresh. This cannot be undone.`)){Eu=!0;try{await Au(e,Hc,{},{failPrefix:`Start fresh failed`,requestFailPrefix:`Start-fresh request failed`,successMessage:`Claude restarting with a fresh conversation.`})}finally{Eu=!1}}}var Fu=!1;function Iu(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}async function Lu(e){if(Fu)return;let t=e.getActiveTabId();if(!t){e.notify(`warning`,`No active document.`);return}Fu=!0;try{let n=await fetch(`${Il}${Dc}?documentId=${encodeURIComponent(t)}`);if(!n.ok){let t=await n.json().catch(()=>({}));e.notify(`error`,`Couldn't list backups: ${t.message??n.statusText}`);return}let r=(await n.json().catch(()=>null))?.data?.backups??[];if(r.length===0){e.notify(`info`,`No backups exist for this document yet. Tandem snapshots the on-disk file before its first overwrite each session.`);return}let i=r[0],a=r.map((e,t)=>` ${t+1}. ${Iu(e.timestamp)}`).join(`
4
+ `);if(!confirm(`Available backups (newest first):\n${a}\n\nRestore the most recent backup (${Iu(i.timestamp)})? The document reloads with the backup's content; annotations are preserved.
5
+
6
+ Older backups can be restored by asking Claude (tandem_restoreBackup).`))return;let o=await fetch(`${Il}${Oc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t,backup:i.name})});if(!o.ok){let t=await o.json().catch(()=>({}));e.notify(`error`,`Restore failed: ${t.message??o.statusText}`);return}e.notify(`info`,`Restored backup from ${Iu(i.timestamp)}.`)}catch(t){e.notify(`error`,`Restore request failed: ${t instanceof Error?t.message:t}`)}finally{Fu=!1}}async function Ru(e){let t=e.getActiveDocumentPath();if(!t){e.notify(`warning`,`This document isn't saved to a file yet.`);return}try{let{invoke:e}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);await e(`show_in_file_manager`,{path:t})}catch(t){e.notify(`error`,`Couldn't reveal in file manager: ${t instanceof Error?t.message:String(t)}`)}}var zu=[{id:`save`,label:`Save document`,group:`document`,shortcut:`Ctrl+S`,run(){uu(`save`,e=>void Tu(e.getActiveTabId()))}},{id:`settings`,label:`Open settings`,group:`view`,shortcut:`Ctrl+,`,run(){uu(`settings`,e=>e.openSettings())}},{id:`settings-modal`,label:`Open settings (new)`,group:`view`,shortcut:`Ctrl+Shift+,`,run(){uu(`settings-modal`,e=>e.openSettingsModal())}},{id:`toggle-mode`,label:`Toggle Solo / Tandem mode`,group:`document`,shortcut:`Ctrl+Shift+M`,run(){uu(`toggle-mode`,e=>e.toggleSoloMode())}},{id:`new-scratchpad`,label:`New Scratchpad`,group:`document`,shortcut:`Ctrl+N`,run(){gu()}},{id:`save-as`,label:`Save As…`,group:`document`,shortcut:`Ctrl+Shift+S`,run(){uu(`save-as`,e=>void e.saveAs())}},{id:`close-tab`,label:`Close active tab`,group:`document`,shortcut:`Ctrl+W`,run(){uu(`close-tab`,e=>e.closeActiveTab())}},{id:`open-file`,label:`Open file…`,group:`document`,shortcut:`Ctrl+O`,run(){uu(`open-file`,e=>e.openFileDialog())}},{id:`find`,label:`Find / Replace`,group:`navigation`,shortcut:`Ctrl+F`,run(){uu(`find`,e=>e.openFindBar())}},{id:`find-in-tabs`,label:`Find in open tabs`,group:`navigation`,shortcut:`Ctrl+Shift+F`,run(){uu(`find-in-tabs`,e=>e.openFindBarTabs())}},{id:`find-next`,label:`Find next match`,group:`navigation`,shortcut:`Ctrl+G`,run(){uu(`find-next`,e=>e.findNext())}},{id:`find-previous`,label:`Find previous match`,group:`navigation`,shortcut:`Ctrl+Shift+G`,run(){uu(`find-previous`,e=>e.findPrev())}},{id:`toggle-left-panel`,label:`Toggle left panel`,group:`view`,shortcut:`Alt+Shift+Left`,run(){uu(`toggle-left-panel`,e=>e.toggleLeftPanel())}},{id:`toggle-right-panel`,label:`Toggle right panel`,group:`view`,shortcut:`Alt+Shift+Right`,run(){uu(`toggle-right-panel`,e=>e.toggleRightPanel())}},{id:`reopen-closed-tab`,label:`Reopen closed tab (this session)`,group:`document`,shortcut:`Ctrl+Alt+T`,run(){uu(`reopen-closed-tab`,e=>e.reopenClosedTab())}},{id:`annotation-next`,label:`Next annotation`,group:`annotations`,shortcut:`Alt+]`,run(){uu(`annotation-next`,e=>e.annotationNext())}},{id:`annotation-previous`,label:`Previous annotation`,group:`annotations`,shortcut:`Alt+[`,run(){uu(`annotation-previous`,e=>e.annotationPrev())}},{id:`annotation-accept`,label:`Accept focused annotation`,group:`annotations`,shortcut:`Ctrl+Enter`,run(){uu(`annotation-accept`,e=>e.annotationAccept())}},{id:`annotation-dismiss`,label:`Dismiss focused annotation`,group:`annotations`,shortcut:`Ctrl+Shift+Enter`,run(){uu(`annotation-dismiss`,e=>e.annotationDismiss())}},{id:`select-block`,label:`Select containing block`,group:`editor`,shortcut:`Alt+L`,run(){uu(`select-block`,e=>e.selectBlock())}},{id:`toggle-authorship`,label:`Toggle authorship colors`,group:`view`,shortcut:`Ctrl+Alt+A`,run(){uu(`toggle-authorship`,e=>e.toggleAuthorship())}},{id:`toggle-formatting-bar`,label:`Toggle formatting bar`,group:`view`,run(){uu(`toggle-formatting-bar`,e=>e.toggleFormattingBar())}},{id:`toggle-source-view`,label:`Toggle markdown source view`,group:`view`,run(){uu(`toggle-source-view`,e=>e.toggleSourceView())}},{id:`restore-backup`,label:`Restore a backup of this document…`,group:`document`,run(){uu(`restore-backup`,e=>void Lu(e))}},{id:`launcher-relaunch-here`,label:`Relaunch Claude in this folder`,group:`claude`,run(){uu(`launcher-relaunch-here`,e=>void Mu(e))}},{id:`launcher-start-fresh`,label:`Start fresh Claude conversation`,group:`claude`,run(){uu(`launcher-start-fresh`,e=>void Pu(e))}},..._u()?[{id:`show-in-file-explorer`,label:`Show in file explorer`,group:`document`,run(){uu(`show-in-file-explorer`,e=>void Ru(e))}}]:[]];for(let e of zu)ou(e);function Bu(e,t=`y`){function n(){if(e.isConnected){if(t===`y`||t===`both`){let t=e.scrollTop>0,n=e.scrollTop+e.clientHeight<e.scrollHeight-1;r(`data-overflow-top`,t),r(`data-overflow-bottom`,n)}if(t===`x`||t===`both`){let t=e.scrollLeft>0,n=e.scrollLeft+e.clientWidth<e.scrollWidth-1;r(`data-overflow-left`,t),r(`data-overflow-right`,n)}}}function r(t,n){n?e.setAttribute(t,`true`):e.removeAttribute(t)}n(),e.addEventListener(`scroll`,n,{passive:!0});let i=null;try{i=new ResizeObserver(n),i.observe(e)}catch(e){console.warn(`[tandem:scrollFade] ResizeObserver init failed`,e)}return{destroy(){e.removeEventListener(`scroll`,n),i?.disconnect()}}}function Vu(e){return e.type===`save-error`&&e.documentId?{label:`Retry`,documentId:e.documentId}:null}var Hu={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 Uu(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}var Wu=V(`<button type="button" data-testid="activity-clear-all" class="svelte-bf7dij">Clear all</button>`),Gu=V(`<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>`),Ku=Jr(`<path class="svelte-bf7dij"></path>`),qu=V(`<span class="badge svelte-bf7dij"> </span>`),Ju=V(`<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>`),Yu=V(`<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>`),Xu=V(`<div></div>`),Zu=V(`<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>`),Qu=V(`<span class="svelte-bf7dij">No activity</span>`),$u=V(`<span class="svelte-bf7dij">Activity</span> <span class="count svelte-bf7dij"> </span>`,1),ed=V(`<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 td(e,t){O(t,!0);let n=A(()=>t.items.length),r=A(()=>t.items.some(e=>e.severity===`error`)?`has-error`:t.items.some(e=>e.severity===`warning`)?`has-warning`:t.items.some(e=>e.severity===`info`)?`has-info`:`idle`),i=j(N(Date.now())),a=setInterval(()=>{M(i,Date.now(),!0)},3e4),o=j(!1),s=!1,c;L(()=>{t.open&&!s?(M(o,!0),c&&clearTimeout(c),c=setTimeout(()=>{M(o,!1)},1800)):!t.open&&s&&(M(o,!1),c&&=(clearTimeout(c),void 0)),s=t.open}),va(()=>{clearInterval(a),c&&clearTimeout(c)});var l=ed(),u=P(l);let d;var f=P(u),p=P(f),m=e=>{var r=Zu(),a=P(r),s=I(P(a),2),c=P(s,!0);E(s);var l=I(s,4),u=e=>{var n=Wu();B(`click`,n,function(...e){t.onClear?.apply(this,e)}),H(e,n)};W(l,e=>{z(n)>0&&e(u)}),E(a);var d=I(a,2),f=e=>{H(e,Gu())},p=e=>{var n=Xu();let r;pi(n,21,()=>t.items,e=>e.id,(e,n)=>{let r=A(()=>Vu(z(n)));var a=Yu(),o=P(a),s=P(o);pi(s,20,()=>Hu[z(n).severity],e=>e,(e,t)=>{var n=Ku();R(()=>K(n,`d`,t)),H(e,n)}),E(s),E(o);var c=I(o,2),l=P(c),u=P(l),d=P(u,!0);E(u);var f=I(u,2),p=e=>{var t=qu(),r=P(t);E(t),R(()=>U(r,`×${z(n).count??``}`)),H(e,t)};W(f,e=>{z(n).count>1&&e(p)});var m=I(f,2),h=P(m,!0);E(m),E(l);var g=I(l,2),_=e=>{var i=Ju(),a=I(P(i));E(i),R(()=>{K(i,`data-testid`,`activity-action-${z(n).id}`),U(a,` ${z(r).label??``}`)}),B(`click`,i,()=>t.onAction(z(n))),H(e,i)};W(g,e=>{z(r)&&e(_)}),E(c);var v=I(c,2);E(a),R(e=>{Ui(a,1,`toast-row ${z(n).severity??``}`,`svelte-bf7dij`),K(a,`data-testid`,`activity-row-${z(n).id}`),U(d,z(n).message),U(h,e),K(v,`data-testid`,`activity-dismiss-${z(n).id}`)},[()=>Uu(z(n).timestamp,z(i))]),B(`click`,v,()=>t.onDismiss(z(n).id)),H(e,a)}),E(n),R(()=>r=Ui(n,1,`tray-list svelte-bf7dij`,null,r,{cascade:z(o)})),H(e,n)};W(d,e=>{z(n)===0?e(f):e(p,-1)}),E(r),R(()=>U(c,z(n)===0?`No events`:`${z(n)} event${z(n)===1?``:`s`}`)),H(e,r)};W(p,e=>{t.open&&e(m)}),E(f);var h=I(f,2),g=I(P(h),2),_=e=>{H(e,Qu())},v=e=>{var t=$u(),r=I(F(t),2),i=P(r,!0);E(r),R(()=>U(i,z(n))),H(e,t)};W(g,e=>{z(n)===0?e(_):e(v,-1)}),D(4),E(h),E(u),E(l),R(()=>{d=Ui(u,1,`activity-shell ${z(r)??``}`,`svelte-bf7dij`,d,{open:t.open}),K(h,`aria-expanded`,t.open),K(h,`aria-controls`,t.open?`activity-tray`:void 0)}),B(`click`,h,function(...e){t.onToggle?.apply(this,e)}),H(e,l),k()}Br([`click`]);function nd(e){this.content=e}nd.prototype={constructor:nd,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new nd(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new nd(n)},addToStart:function(e,t){return new nd([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new nd(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new nd(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=nd.from(e),e.size?new nd(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=nd.from(e),e.size?new nd(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=nd.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},nd.from=function(e){if(e instanceof nd)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new nd(t)};function rd(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=rd(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function id(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=id(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var Z=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))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 t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return rd(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return id(this,e,t,n)}findIndex(e){if(e==0)return od(0,e);if(e==this.size)return od(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?od(t+1,i):od(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};Z.empty=new Z([],0);var ad={index:0,offset:0};function od(e,t){return ad.index=e,ad.offset=t,ad}function sd(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!sd(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!sd(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var cd=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&sd(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};cd.none=[];var ld=class extends Error{},Q=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=dd(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ud(this.content,t+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(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(Z.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};Q.empty=new Q(Z.empty,0,0);function ud(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ud(a.content,t-i-1,n-i-1)))}function dd(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=dd(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function fd(e,t,n){if(n.openStart>e.depth)throw new ld(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ld(`Inconsistent open depths`);return pd(e,t,n,0)}function pd(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=pd(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return vd(a,bd(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return vd(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=xd(n,e);return vd(a,yd(e,i,o,t,r))}}function md(e,t){if(!t.type.compatibleContent(e.type))throw new ld(`Cannot join `+t.type.name+` onto `+e.type.name)}function hd(e,t,n){let r=e.node(n);return md(r,t.node(n)),r}function gd(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function _d(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(gd(e.nodeAfter,r),a++));for(let e=a;e<o;e++)gd(i.child(e),r);t&&t.depth==n&&t.textOffset&&gd(t.nodeBefore,r)}function vd(e,t){return e.type.checkContent(t),e.copy(t)}function yd(e,t,n,r,i){let a=e.depth>i&&hd(e,t,i+1),o=r.depth>i&&hd(n,r,i+1),s=[];return _d(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(md(a,o),gd(vd(a,yd(e,t,n,r,i+1)),s)):(a&&gd(vd(a,bd(e,t,i+1)),s),_d(t,n,i,s),o&&gd(vd(o,bd(n,r,i+1)),s)),_d(r,null,i,s),new Z(s)}function bd(e,t,n){let r=[];return _d(null,e,n,r),e.depth>n&&gd(vd(hd(e,t,n+1),bd(e,t,n+1)),r),_d(t,null,n,r),new Z(r)}function xd(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(Z.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Sd=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.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 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 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,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return cd.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Ed(this,e,n);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 t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Td.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Td.set(t,r=new Cd);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%wd,i}},Cd=class{constructor(){this.elts=[],this.i=0}},wd=12,Td=new WeakMap,Ed=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}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)}},Dd=Object.create(null),Od=class e{constructor(e,t,n,r=cd.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Z.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,t,n,r=0){this.content.nodesBetween(e,t,n,r,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,t,n,r){return this.content.textBetween(e,t,n,r)}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,t,n){return this.type==e&&sd(this.attrs,t||e.defaultAttrs||Dd)&&cd.sameSet(this.marks,n||cd.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Q.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new Q(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return fd(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Sd.resolveCached(this,e)}resolveNoCache(e){return Sd.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+`)`),Ad(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=Z.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.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=cd.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!cd.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t 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(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=Z.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Od.prototype.text=void 0;var kd=class e extends Od{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ad(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Ad(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var jd=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Md(t,n);if(r.next==null)return e.empty;let i=Nd(r);r.next&&r.err(`Unexpected trailing text`);let a=Ud(Bd(i));return Wd(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return Z.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
7
+ `)}};jd.empty=new jd(!0);var Md=class{constructor(e,t){this.string=e,this.nodeTypes=t,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 SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Nd(e){let t=[];do t.push(Pd(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Pd(e){let t=[];do t.push(Fd(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Fd(e){let t=zd(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Ld(e,t);else break;return t}function Id(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Ld(e,t){let n=Id(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Id(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Rd(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function zd(e){if(e.eat(`(`)){let t=Nd(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Rd(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Bd(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Vd(e,t){return t-e}function Hd(e,t){let n=[];return r(t),n.sort(Vd);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function Ud(e){let t=Object.create(null);return n(Hd(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Hd(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new jd(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Vd);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Wd(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Gd(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Kd(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function qd(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Jd(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Zd(e,r,t[r]);return n}var Yd=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Jd(e,n.attrs),this.defaultAttrs=Gd(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==jd.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:Kd(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Od(this,this.computeAttrs(e),Z.from(t),cd.setFrom(n))}createChecked(e=null,t,n){return t=Z.from(t),this.checkContent(t),new Od(this,this.computeAttrs(e),t,cd.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=Z.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(Z.empty,!0);return i?new Od(this,e,t.append(i),cd.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){qd(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 t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:cd.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Xd(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Zd=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Xd(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Qd=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Jd(e,r.attrs),this.excluded=null;let i=Gd(this.attrs);this.instance=i?new cd(this,i):null}create(e=null){return!e&&this.instance?this.instance:new cd(this,Kd(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){qd(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},$d=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=nd.from(e.nodes),t.marks=nd.from(e.marks||{}),this.nodes=Yd.compile(this.spec.nodes,this),this.marks=Qd.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=jd.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?ef(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:ef(this,n.split(` `))}this.nodeFromJSON=e=>Od.fromJSON(this,e),this.markFromJSON=e=>cd.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Yd))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new kd(n,n.defaultAttrs,e,cd.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function ef(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function tf(e){return e.tag!=null}function nf(e){return e.style!=null}var rf=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(tf(e))this.tags.push(e);else if(nf(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new pf(this,t,!1);return n.addAll(e,cd.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new pf(this,t,!0);return n.addAll(e,cd.none,t.from,t.to),Q.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(hf(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=gf(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=gf(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},af={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},of={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},sf={ol:!0,ul:!0},cf=1,lf=2,uf=4;function df(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?cf:0)|(t===`full`?lf:0)}var ff=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=cd.none,this.match=i||(a&uf?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Z.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&cf)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=Z.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Z.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!af.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},pf=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=df(null,t.preserveWhitespace,0)|(n?uf:0);i=r?new ff(r.type,r.attrs,cd.none,!0,t.topMatch||r.type.contentMatch,a):n?new ff(null,null,cd.none,!0,null,a):new ff(e.schema.topNodeType,null,cd.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&lf?`full`:this.localPreserveWS||(r.options&cf)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
8
+ `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;sf.hasOwnProperty(a)&&this.parser.normalizeLists&&mf(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:of.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(af.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
9
+ `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=cd.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):_f(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=df(e,i,a.options);a.options&uf&&a.content.length==0&&(o|=uf);let s=cd.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):_f(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new ff(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].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 t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=cf);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function mf(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&sf.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function hf(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function gf(e){let t={};for(let n in e)t[n]=e[n];return t}function _f(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var vf=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=bf(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=wf(bf(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&wf(bf(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return wf(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=yf(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return yf(e.marks)}};function yf(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function bf(e){return e.document||window.document}var xf=new WeakMap;function Sf(e){let t=xf.get(e);return t===void 0&&xf.set(e,t=Cf(e)),t}function Cf(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function wf(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Sf(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=wf(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Tf=65535,Ef=2**16;function Df(e,t){return e+t*Ef}function Of(e){return e&Tf}function kf(e){return(e-(e&Tf))/Ef}var Af=1,jf=2,Mf=4,Nf=8,Pf=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Nf)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Mf)>0}},Ff=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Of(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+kf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Df(o/3,e-s),f=e==s?jf:e==u?Af:Mf;return(t<0?e!=s:e!=u)&&(f|=Nf),new Pf(a,f,d)}r+=l-c}return n?e+r:new Pf(e+r,0,null)}touches(e,t){let n=0,r=Of(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};Ff.empty=new Ff([]);var If=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Pf(e,r,null)}},Lf=Object.create(null),Rf=class{getMap(){return Ff.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Lf[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Lf)throw RangeError(`Duplicate use of step JSON ID `+e);return Lf[e]=t,t.prototype.jsonID=e,t}},zf=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof ld)return e.fail(t.message);throw t}}};function Bf(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Bf(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return Z.fromArray(r)}var Vf=class e extends Rf{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Q(Bf(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return zf.fromReplace(e,this.from,this.to,i)}invert(){return new Hf(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Rf.jsonID(`addMark`,Vf);var Hf=class e extends Rf{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Q(Bf(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return zf.fromReplace(e,this.from,this.to,n)}invert(){return new Vf(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Rf.jsonID(`removeMark`,Hf);var Uf=class e extends Rf{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return zf.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return zf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Wf(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Rf.jsonID(`addNodeMark`,Uf);var Wf=class e extends Rf{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return zf.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return zf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Uf(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Rf.jsonID(`removeNodeMark`,Wf);var Gf=class e extends Rf{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&qf(e,this.from,this.to)?zf.fail(`Structure replace would overwrite content`):zf.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ff([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,Q.fromJSON(t,n.slice),!!n.structure)}};Rf.jsonID(`replace`,Gf);var Kf=class e extends Rf{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(qf(e,this.from,this.gapFrom)||qf(e,this.gapTo,this.to)))return zf.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return zf.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?zf.fromReplace(e,this.from,this.to,n):zf.fail(`Content does not fit in gap`)}getMap(){return new Ff([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,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(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,Q.fromJSON(t,n.slice),n.insert,!!n.structure)}};Rf.jsonID(`replaceAround`,Kf);function qf(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Jf(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Hf(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Vf(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Yf(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Qd){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Hf(t.from,t.to,t.style)))}function Xf(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Gf(s,l,Q.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Hf(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new Q(Z.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Gf(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(Z.empty,!0);e.replace(s,s,new Q(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Zf(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Qf(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Zf(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function $f(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=Z.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=Z.from(r.node(e).copy(u)),d++):c--;let f=Z.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=Z.from(i.node(e).copy(f)),p++):l++;e.step(new Kf(c,l,o,s,new Q(u.append(f),d,p),u.size-d,!0))}function ep(e,t,n=null,r=e){let i=np(e,t),a=i&&rp(r,t);return a?i.map(tp).concat({type:t,attrs:n}).concat(a.map(tp)):null}function tp(e){return{type:e,attrs:null}}function np(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function rp(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function ip(e,t,n){let r=Z.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=Z.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Kf(i,a,i,a,new Q(r,0,0),n.length,!0))}function ap(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&cp(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&sp(e,t,n,a),Xf(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Kf(c,l,c+1,l-1,new Q(Z.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&op(e,t,n,a),!1}})}function op(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function sp(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
10
+ `))}})}function cp(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function lp(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Kf(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new Q(Z.from(o),0,0),1,!0))}function up(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function dp(e,t,n=1,r){let i=e.doc.resolve(t),a=Z.empty,o=Z.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=Z.from(i.node(e).copy(a));let t=r&&r[s];o=Z.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Gf(t,t,new Q(a.append(o),n,n),!0))}function fp(e,t){let n=e.resolve(t),r=n.index();return mp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function pp(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function mp(e,t){return!!(e&&t&&!e.isLeaf&&pp(e,t))}function hp(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&mp(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function gp(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);sp(e,r.node(),r.before(),s)}o.inlineContent&&Xf(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Gf(l,c.map(t+n,-1),Q.empty,!0)),r===!0){let t=e.doc.resolve(l);op(e,t.node(),t.before(),e.steps.length)}return e}function _p(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function vp(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function yp(e,t,n=t,r=Q.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return bp(i,a,r)?new Gf(t,n,r):new xp(i,a,r).fit()}function bp(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var xp=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Z.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Z.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new Q(i,a,o);return e>-1?new Kf(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Gf(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=wp(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(Z.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=wp(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new Q(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=wp(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new Q(Sp(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new Q(Sp(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(Tp(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Cp(this.placed,t,Z.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?Q.empty:new Q(Sp(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new Q(Sp(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ep(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Ep(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Ep(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Cp(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Cp(this.placed,this.depth,Z.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Z.empty,!0);e.childCount&&(this.placed=Cp(this.placed,this.frontier.length,e))}};function Sp(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Sp(e.firstChild.content,t-1,n)))}function Cp(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Cp(e.lastChild.content,t-1,n)))}function wp(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Tp(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Tp(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Z.empty,!0)))),e.copy(r)}function Ep(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Dp(n,a.content,o)?s:null}function Dp(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Op(e){return e.spec.defining||e.spec.definingForContent}function kp(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(bp(i,a,r))return e.step(new Gf(t,n,r));let o=Np(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Op(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new Q(Ap(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Ap(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Ap(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Z.empty,!0))}return e}function jp(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=_p(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new Q(Z.from(r),0,0))}function Mp(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),a=Np(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Np(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var Pp=class e extends Rf{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return zf.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return zf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(r),0,+!t.isLeaf))}getMap(){return Ff.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};Rf.jsonID(`attr`,Pp);var Fp=class e extends Rf{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return zf.ok(n)}getMap(){return Ff.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};Rf.jsonID(`docAttr`,Fp);var Ip=class extends Error{};Ip=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Ip.prototype=Object.create(Error.prototype),Ip.prototype.constructor=Ip,Ip.prototype.name=`TransformError`;var Lp=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new If}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ip(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Q.empty){let r=yp(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Q(Z.from(n),0,0))}delete(e,t){return this.replace(e,t,Q.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return kp(this,e,t,n),this}replaceRangeWith(e,t,n){return jp(this,e,t,n),this}deleteRange(e,t){return Mp(this,e,t),this}lift(e,t){return $f(this,e,t),this}join(e,t=1){return gp(this,e,t),this}wrap(e,t){return ip(this,e,t),this}setBlockType(e,t=e,n,r=null){return ap(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return lp(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Pp(e,t,n)),this}setDocAttribute(e,t){return this.step(new Fp(e,t)),this}addNodeMark(e,t){return this.step(new Uf(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof cd)t.isInSet(n.marks)&&this.step(new Wf(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new Wf(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return dp(this,e,t,n),this}addMark(e,t,n){return Jf(this,e,t,n),this}removeMark(e,t,n){return Yf(this,e,t,n),this}clearIncompatible(e,t,n){return Xf(this,e,t,n),this}},Rp=Object.create(null),zp=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Bp(e.min(t),e.max(t))]}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 t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Q.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?Q.empty:t),o==0&&Xp(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),Xp(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Up(e):Yp(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Yp(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Yp(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new qp(e.node(0))}static atStart(e){return Yp(e,e,0,0,1)||new qp(e)}static atEnd(e){return Yp(e,e,e.content.size,e.childCount,-1)||new qp(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=Rp[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Rp)throw RangeError(`Duplicate use of selection JSON ID `+e);return Rp[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Up.between(this.$anchor,this.$head).getBookmark()}};zp.prototype.visible=!0;var Bp=class{constructor(e,t){this.$from=e,this.$to=t}},Vp=!1;function Hp(e){!Vp&&!e.parent.inlineContent&&(Vp=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var Up=class e extends zp{constructor(e,t=e){Hp(e),Hp(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return zp.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=Q.empty){if(super.replace(e,t),t==Q.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Wp(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=zp.findFrom(n,r,!0)||zp.findFrom(n,-r,!0);if(e)n=e.$head;else return zp.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(zp.findFrom(t,-r,!0)||zp.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};zp.jsonID(`text`,Up);var Wp=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return Up.between(e.resolve(this.anchor),e.resolve(this.head))}},Gp=class e extends zp{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?zp.near(a):new e(a)}content(){return new Q(Z.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new Kp(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Gp.prototype.visible=!1,zp.jsonID(`node`,Gp);var Kp=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Wp(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Gp.isSelectable(n)?new Gp(t):zp.near(t)}},qp=class e extends zp{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Q.empty){if(t==Q.empty){e.delete(0,e.doc.content.size);let t=zp.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return Jp}};zp.jsonID(`all`,qp);var Jp={map(){return this},resolve(e){return new qp(e)}};function Yp(e,t,n,r,i,a=!1){if(t.inlineContent)return Up.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Yp(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Gp.isSelectable(r))return Gp.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function Xp(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Gf||i instanceof Kf))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(zp.near(e.doc.resolve(o),n))}var Zp=1,Qp=2,$p=4,em=class extends Lp{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 RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Zp)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Zp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Qp,this}ensureMarks(e){return cd.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&Qp)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||cd.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(zp.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,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|=$p,this}get scrolledIntoView(){return(this.updated&$p)>0}};function tm(e,t){return!t||!e?e:e.bind(t)}var nm=class{constructor(e,t,n){this.name=e,this.init=tm(t.init,n),this.apply=tm(t.apply,n)}},rm=[new nm(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new nm(`selection`,{init(e,t){return e.selection||zp.atStart(t.doc)},apply(e){return e.selection}}),new nm(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new nm(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],im=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=rm.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new nm(e.key,e.spec.state,e))})}},am=class e{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,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new em(this)}static create(t){let n=new im(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new im(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new im(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=Od.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=zp.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function om(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=om(i,t,{})),n[r]=i}return n}var sm=class{constructor(e){this.spec=e,this.props={},e.props&&om(e.props,this,this.props),this.key=e.key?e.key.key:lm(`plugin`)}getState(e){return e[this.key]}},cm=Object.create(null);function lm(e){return e in cm?e+`$`+ ++cm[e]:(cm[e]=0,e+`$`)}var um=class{constructor(e=`key`){this.key=lm(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},dm=[{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 fm(e){let t=[];return e.state.doc.descendants((e,n)=>{e.type.name===`heading`&&e.attrs.level<=3&&t.push({text:e.textContent,level:e.attrs.level,pos:n})}),t}var pm=V(`<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>`),mm=V(`<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>`),hm=V(`<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>`),gm=V(`<span style="font-size: var(--tandem-text-sm);"> </span> <!>`,1),_m=V(`<span style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="
11
+ font-size: var(--tandem-text-xs);
12
+ color: var(--tandem-fg-subtle);
13
+ font-family: var(--tandem-font-mono);
14
+ min-width: 20px;
15
+ "> </span> <span> </span></span>`),vm=V(`<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>`),ym=V(`<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),bm=V(`<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),xm=V(`<li role="option"><!></li>`),Sm=V(`<div role="presentation" class="palette-scrim svelte-gunx66" style="
16
+ position: fixed; inset: 0;
17
+ background: rgba(0,0,0,0.4);
18
+ backdrop-filter: blur(2px);
19
+ z-index: var(--tandem-z-above-titlebar);
20
+ display: flex; align-items: flex-start; justify-content: center;
21
+ padding-top: 15vh;
22
+ "><div data-testid="command-palette" role="dialog" tabindex="-1" aria-modal="true" aria-label="Command palette" class="palette-modal svelte-gunx66" style="
23
+ width: 640px; max-width: 92vw;
24
+ background: var(--tandem-surface);
25
+ border: 1px solid var(--tandem-border);
26
+ border-radius: var(--tandem-r-5);
27
+ box-shadow: var(--tandem-shadow-4);
28
+ overflow: hidden;
29
+ display: flex; flex-direction: column;
30
+ "><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="
31
+ flex: 1; min-width: 0; padding: 6px 0;
32
+ font-size: var(--tandem-text-md); color: var(--tandem-fg);
33
+ background: transparent; border: none; outline: none;
34
+ "/> <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="
35
+ padding: var(--tandem-space-2) var(--tandem-space-4);
36
+ border-top: 1px solid var(--tandem-border);
37
+ background: var(--tandem-surface-muted);
38
+ display: flex; align-items: center; gap: var(--tandem-space-3);
39
+ font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);
40
+ "><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 Cm(e,t){O(t,!0);let n=q(t,`editor`,3,null),r=q(t,`annotations`,19,()=>[]),i=j(``),a=j(0),o=j(null),s=[`#`,`@`,`?`,`>`],c=A(()=>s.find(e=>z(i).startsWith(e))??null),l=A(()=>(z(c)?z(i).slice(1):z(i)).trim().toLowerCase()),u=A(()=>{if(z(c)!==null&&z(c)!==`>`)return[];let e=su(),t=z(l),n=[];for(let r of e.values())(!t||r.label.toLowerCase().includes(t)||r.group.toLowerCase().includes(t)||(r.shortcut?.toLowerCase().includes(t)??!1))&&n.push({kind:`action`,id:r.id,action:r});return n}),d=A(()=>{if(z(c)!==`#`)return[];let e=n();if(!e||e.isDestroyed)return[];let t=z(l);return fm(e).filter(e=>!t||e.text.toLowerCase().includes(t)).map((e,t)=>({kind:`heading`,id:`heading-${t}`,...e}))}),f=A(()=>{if(z(c)!==`@`)return[];let e=z(l);return r().filter(t=>e?t.content.toLowerCase().includes(e)||t.textSnapshot?.toLowerCase().includes(e):!0).slice(0,50).map(e=>({kind:`annotation`,id:`annotation-${e.id}`,label:e.content?e.content.slice(0,60):`(no content)`,snippet:e.textSnapshot??``,annotationType:e.type}))}),p=A(()=>{if(z(c)!==`?`)return[];let e=z(l),t=su(),n=[];for(let r of t.values())r.shortcut&&(!e||r.label.toLowerCase().includes(e)||r.shortcut.toLowerCase().includes(e))&&n.push({kind:`shortcut`,id:`shortcut-registry-${r.id}`,keys:r.shortcut,description:r.label,group:r.group});for(let t=0;t<dm.length;t++){let r=dm[t];(!e||r.description.toLowerCase().includes(e)||r.keys.toLowerCase().includes(e))&&n.push({kind:`shortcut`,id:`shortcut-static-${t}`,keys:r.keys,description:r.description,group:`other`})}return n}),m=A(()=>[...z(u),...z(d),...z(f),...z(p)]);L(()=>{z(m),M(a,0)}),L(()=>{t.open&&(M(i,``),M(a,0),Promise.resolve().then(()=>z(o)?.focus()))}),_a(()=>{let e=e=>{e.key!==`Escape`||!t.open||(e.preventDefault(),e.stopPropagation(),_())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});let h={"#":`Search headings…`,"@":`Search annotations…`,"?":`Search shortcuts…`,">":`Search commands…`},g=A(()=>z(c)?h[z(c)]:`Type a command, # headings, @ annotations, ? shortcuts…`);function _(){t.onClose()}function v(e){if(e.kind===`action`)_(),e.action.run();else if(e.kind===`heading`){_();let t=n();if(!t||t.isDestroyed)return;let r=e.pos;try{let e=t.state.doc.resolve(r+1),n=Up.near(e);t.view.dispatch(t.state.tr.setSelection(n).scrollIntoView()),t.view.focus()}catch{}}else e.kind===`annotation`&&(_(),t.onFocusAnnotation?.(e.id.replace(`annotation-`,``)))}function y(e){let t=z(m).length;if(e.key===`ArrowDown`)e.preventDefault(),M(a,(z(a)+1)%Math.max(1,t));else if(e.key===`ArrowUp`)e.preventDefault(),M(a,(z(a)-1+Math.max(1,t))%Math.max(1,t));else if(e.key===`Enter`){e.preventDefault();let t=z(m)[z(a)];t&&v(t)}else e.key===`Escape`&&(e.preventDefault(),_())}function b(e){e.target===e.currentTarget&&_()}var x=Xr(),S=F(x),ee=e=>{var t=Sm(),n=P(t),r=P(n),s=P(r),l=I(P(s),2);$i(l),fa(l,e=>M(o,e),()=>z(o)),D(2),E(s);var u=I(s,2),d=e=>{var t=pm(),n=P(t),r=e=>{H(e,Yr(`Searching document headings`))};W(n,e=>{z(c)===`#`&&e(r)});var i=I(n,2),a=e=>{H(e,Yr(`Searching annotations`))};W(i,e=>{z(c)===`@`&&e(a)});var o=I(i,2),s=e=>{H(e,Yr(`Showing keyboard shortcuts`))};W(o,e=>{z(c)===`?`&&e(s)});var l=I(o,2),u=e=>{H(e,Yr(`Filtering commands`))};W(l,e=>{z(c)===`>`&&e(u)}),E(t),H(e,t)};W(u,e=>{z(c)&&e(d)}),E(r);var f=I(r,2),p=P(f),h=e=>{var t=mm(),n=P(t,!0);E(t),R(()=>U(n,z(c)===`#`?`No headings found`:z(c)===`@`?`No annotations found`:z(c)===`?`?`No shortcuts found`:`No commands match`)),H(e,t)},x=e=>{var t=Xr();pi(F(t),19,()=>z(m),e=>e.id,(e,t,n)=>{let r=A(()=>z(n)===z(a));var i=xm(),o=P(i),s=e=>{var n=gm(),r=F(n),i=P(r,!0);E(r);var a=I(r,2),o=e=>{var n=hm(),r=P(n,!0);E(n),R(()=>U(r,z(t).action.shortcut)),H(e,n)};W(a,e=>{z(t).action.shortcut&&e(o)}),R(()=>U(i,z(t).action.label)),H(e,n)},c=e=>{var n=_m(),r=P(n),i=P(r);E(r);var a=I(r,2),o=P(a,!0);E(a),E(n),R(()=>{U(i,`H${z(t).level??``}`),G(a,`font-size: var(--tandem-text-sm); padding-left: calc(${z(t).level-1} * var(--tandem-space-2));`),U(o,z(t).text)}),H(e,n)},l=e=>{var n=ym(),r=F(n),i=P(r),a=P(i,!0);E(i);var o=I(i,2),s=e=>{var n=vm(),r=P(n);E(n),R(()=>U(r,`"${z(t).snippet??``}"`)),H(e,n)};W(o,e=>{z(t).snippet&&e(s)}),E(r);var c=I(r,2),l=P(c,!0);E(c),R(e=>{U(a,z(t).label),U(l,e)},[()=>z(t).annotationType.charAt(0).toUpperCase()+z(t).annotationType.slice(1)]),H(e,n)},u=e=>{var n=bm(),r=F(n),i=P(r,!0);E(r);var a=I(r,2),o=P(a,!0);E(a),R(()=>{U(i,z(t).description),U(o,z(t).keys)}),H(e,n)};W(o,e=>{z(t).kind===`action`?e(s):z(t).kind===`heading`?e(c,1):z(t).kind===`annotation`?e(l,2):z(t).kind===`shortcut`&&e(u,3)}),E(i),R(()=>{K(i,`id`,`palette-item-${z(t).id}`),K(i,`data-testid`,`palette-item-${z(t).id}`),K(i,`aria-selected`,z(r)),G(i,`
41
+ display: flex; align-items: center; justify-content: space-between;
42
+ padding: 8px var(--tandem-space-3);
43
+ border-radius: var(--tandem-r-3);
44
+ transition: background 80ms;
45
+ cursor: ${z(t).kind===`shortcut`?`default`:`pointer`};
46
+ background: ${z(r)?`var(--tandem-accent-bg)`:`transparent`};
47
+ color: ${z(r)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg)`};
48
+ `)}),B(`click`,i,()=>v(z(t))),zr(`mouseenter`,i,()=>M(a,z(n),!0)),H(e,i)}),H(e,t)};W(p,e=>{z(m).length===0?e(h):e(x,-1)}),E(f),Pi(f,(e,t)=>Bu?.(e,t),()=>`y`),D(2),E(n),E(t),R(()=>{K(l,`placeholder`,z(g)),K(l,`aria-activedescendant`,z(m)[z(a)]?`palette-item-${z(m)[z(a)].id}`:void 0)}),B(`click`,t,b),B(`keydown`,t,e=>{e.key===`Escape`&&_()}),B(`keydown`,n,y),aa(l,()=>z(i),e=>M(i,e)),H(e,t)};W(S,e=>{t.open&&e(ee)}),H(e,x),k()}Br([`click`,`keydown`]);var wm=V(`<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 Tm(e,t){var n=wm(),r=I(P(n),4),i=I(r,2);E(n),B(`click`,r,function(...e){t.onRetry?.apply(this,e)}),B(`click`,i,function(...e){t.onDismiss?.apply(this,e)}),H(e,n)}Br([`click`]);function Em(e){return e?e.osSupported?e.coworkDetected?`normal`:`undetected`:`unsupported`:`loading`}function Dm(e){return e.claudeDesktopDetected??!1?(e.workspacesBlocked??0)>0?`blocked`:`noWorkspacesYet`:`noClaude`}function Om(e){switch(e.kind){case`adminDeclined`:return`Tandem couldn't update Windows Firewall — that needs administrator rights, and Tandem doesn't run as admin. Nothing was changed, and your documents stay on this computer (the server is only reachable locally).`;case`netshNotFound`:return`Windows Firewall command (netsh) was not found on PATH. Confirm your Windows install is intact.`;case`netshFailure`:return`Windows Firewall command failed (exit ${e.exitCode}). Details: ${km(e.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 (${e.kind}). Please restart Tandem.`}}function km(e){let t=e.trim();return t.length===0?`(no output)`:t.length<=200?t:`${t.slice(0,197)}...`}function Am(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`kind`in t&&typeof t.kind==`string`)try{return Om(t)}catch(n){return console.error(`[cowork] firewallErrorHint failed for:`,t,n),e}return e}catch{return e}}function jm(e){switch(e){case`ok`:return`Installed`;case`alreadyPresent`:return`Already installed`;case`locked`:return`Locked (retrying)`;case`schemaDrift`:return`Schema drift`;case`insecureAcl`:return`Insecure ACL`;case`failed`:return`Failed`;case`notConfigured`:return`Not configured`}}function Mm(e){switch(e){case`ok`:case`alreadyPresent`:return`success`;case`locked`:return`warning`;case`schemaDrift`:case`insecureAcl`:case`failed`:return`error`;case`notConfigured`:return`neutral`}}function Nm(e){let t=[`failed`,`schemaDrift`,`insecureAcl`,`locked`,`notConfigured`,`alreadyPresent`,`ok`],n=[e.installedPlugins,e.knownMarketplaces,e.coworkSettings];for(let e of t)if(n.includes(e))return e;return`ok`}function Pm(e){let t=e=>e===`ok`||e===`alreadyPresent`;return t(e.installedPlugins)&&t(e.knownMarketplaces)&&t(e.coworkSettings)}function Fm(e){if(!e||!e.enabled)return`not-applicable`;let t=e.workspaces??[];return t.some(Pm)?`reachable`:t.some(e=>Mm(Nm(e))===`error`)?`unreachable`:`pending`}function Im(e){switch(e){case`reachable`:return{title:`Tandem is reachable from Cowork`,detail:`At least one Cowork workspace has the Tandem plugin installed — a Cowork session can find and load it.`,family:`success`};case`unreachable`:return{title:`Tandem isn't reachable yet`,detail:`Cowork is enabled, but a workspace install didn't complete. Re-scan workspaces, or restart Claude Desktop and re-enable.`,family:`error`};case`pending`:return{title:`Waiting for a Cowork session`,detail:`Cowork is enabled. The Tandem plugin installs into a workspace the first time you open a Cowork session.`,family:`warning`};case`not-applicable`:return{title:``,detail:``,family:`neutral`}}}function Lm(e,t){return!(!e||t||!e.osSupported||!e.coworkDetected||e.enabled)}function Rm(){try{return localStorage.getItem(fo)===`true`}catch{return!1}}function zm(){try{localStorage.setItem(fo,`true`)}catch{}}function Bm(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}function Vm(e){let t=null;return{schedule(n){t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,n()},e)},cancel(){t!==null&&(clearTimeout(t),t=null)}}}var Hm=`Tauri runtime not available`;async function Um(){try{return(await Ul(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return Bm()&&console.error(`[cowork] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(Hm)))}}function Wm(e){return e(`cowork_get_status`)}function Gm(e,t){return e(`cowork_toggle_integration`,{enabled:t})}function Km(e){return e(`cowork_rescan`)}function qm(e,t){return e(`cowork_set_lan_ip_override`,{enabled:t})}function Jm(e){return e(`cowork_retry_admin_elevation`)}var Ym=j(!1),Xm=null;function Zm(){return z(Ym)}function Qm(){M(Ym,!0)}function $m(e){e!==Xm&&(Xm=e,e!==null&&M(Ym,!1))}function eh(e){let t=j(null),n=j(!1),r=j(null),i=null,a=!1,o=!0,s=null;va(()=>{o=!1,s!==null&&(clearInterval(s),s=null)});let c=async()=>{if(a){o&&M(n,!1);return}let e=i;if(e)try{let n=await Wm(e);if(!o)return;M(t,n,!0),M(r,null)}catch(e){if(!o)return;let t=e instanceof Error?e.message:String(e);if(t===`Tauri runtime not available`){a=!0,s!==null&&(clearInterval(s),s=null),M(n,!1);return}M(r,t,!0)}finally{o&&M(n,!1)}};return L(()=>{if(!e()){M(n,!1);return}let t=!1;return Um().then(e=>{if(!t)return i=e,M(n,!0),c()}).catch(e=>{t||(M(r,e instanceof Error?e.message:String(e),!0),M(n,!1))}),s=setInterval(()=>{t||a||c()},po),()=>{t=!0,s!==null&&(clearInterval(s),s=null)}}),{get status(){return z(t)},get loading(){return z(n)},get error(){return z(r)},refetch:c}}var th=V(`<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
49
+ restart Tandem to restore normal operation.</div>`),nh=V(`<div class="cad-error svelte-cbdwov" data-testid="cowork-admin-declined-error" role="alert"> </div>`),rh=V(`<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">Cowork will be turned off. Any firewall rule a past admin run added is left in
50
+ place (it's harmless — the server only listens on this computer). You can
51
+ 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>`),ih=V(`<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>`),ah=V(`<div class="cad-backdrop svelte-cbdwov" data-testid="cowork-admin-declined-backdrop" role="button" tabindex="-1" aria-label="Dismiss admin permission notice"><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 needs Windows admin permission to add the firewall rule that lets
52
+ Claude inside the Cowork VM reach Tandem. Without it, that rule wasn't added, so Cowork
53
+ can't connect. Nothing was exposed — Tandem's server only listens on this computer
54
+ (127.0.0.1). You can dismiss this for now, or turn Cowork off below.</div> <a class="cad-link svelte-cbdwov" data-testid="cowork-admin-declined-learn-more-link" target="_blank" rel="noreferrer">Learn more</a> <!> <!></div></div>`);function oh(e,t){O(t,!0);let n=eh(()=>!0),r=A(()=>n.status?.uacDeclined===!0),i=A(()=>z(r)&&!Zm()),a=j(void 0),o=j(!1),s=j(!1),c=j(null);L(()=>{$m(n.status?.uacDeclinedAt??null)}),L(()=>{if(!z(i))return;let e=typeof document<`u`?document.title:null;return typeof document<`u`&&!document.title.startsWith(`⚠`)&&(document.title=`⚠ ${document.title}`),()=>{typeof document<`u`&&e!==null&&(document.title=e)}}),L(()=>{if(!z(i))return;let e=e=>{if(e.key===`Escape`){if(z(s))return;Qm();return}if(e.key!==`Tab`||!z(a))return;let t=z(a).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;if(!z(a).contains(i)){e.preventDefault(),n.focus();return}e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),L(()=>{z(i)&&z(a)?.focus()});async function l(e,t){M(s,!0),M(c,null);try{await e(await Um())}catch(e){M(c,`${t}: ${Am(e instanceof Error?e.message:String(e))}`)}finally{M(s,!1)}}async function u(){await l(async e=>{await Jm(e),await n.refetch()},`Retry failed`)}async function d(){await l(async e=>{await Gm(e,!1),await n.refetch()},`Failed to disable Cowork`),z(c)||M(o,!1)}var f=Xr(),p=F(f),m=e=>{H(e,th())},h=e=>{var t=ah(),n=P(t);K(n,`tabindex`,-1);var r=I(P(n),4),i=I(r,2),l=e=>{var t=nh(),n=P(t,!0);E(t),R(()=>U(n,z(c))),H(e,t)};W(i,e=>{z(c)&&e(l)});var f=I(i,2),p=e=>{var t=rh(),n=I(P(t),4),r=P(n),i=I(r,2);E(n),E(t),R(()=>{r.disabled=z(s),i.disabled=z(s)}),B(`click`,r,()=>void d()),B(`click`,i,()=>{M(o,!1)}),H(e,t)},m=e=>{var t=ih(),n=P(t),r=I(n,2);E(t),R(()=>{n.disabled=z(s),r.disabled=z(s)}),B(`click`,n,()=>{M(o,!0)}),B(`click`,r,()=>void u()),H(e,t)};W(f,e=>{z(o)?e(p):e(m,-1)}),E(n),fa(n,e=>M(a,e),()=>z(a)),E(t),R(()=>K(r,`href`,`${Sa}#cowork`)),B(`click`,t,e=>{!z(s)&&e.target===e.currentTarget&&Qm()}),B(`keydown`,t,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),z(s)||Qm())}),H(e,t)};W(p,e=>{n.error&&!n.status?e(m):z(i)&&e(h,1)}),H(e,f),k()}Br([`click`,`keydown`]);var sh=V(`<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>`),ch=V(`<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 lh(e,t){O(t,!0);let n=j(null),r=j(null),i=j(null);L(()=>{let e=t.ydoc.getMap(Wa),a=()=>{M(n,e.get(`externalConflict`)??null,!0)};a();let o=e=>{e.keysChanged.has(`externalConflict`)&&a()};return e.observe(o),()=>{e.unobserve(o),M(n,null),M(i,null),M(r,null)}});let a=A(()=>z(n)?z(n).kind===`external-edit`?`${t.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.`:z(n).diskChanged?`Unsaved edits for ${t.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 ${t.fileName} were restored from your last session. Keep them, or reload fresh from the file on disk (discards them)?`:``);async function o(e){if(!z(r)){M(r,e,!0),M(i,null);try{let n=await fetch(`${Il}${kc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId,choice:e})});n.ok||M(i,(await n.json().catch(()=>null))?.message??`Request failed (HTTP ${n.status}).`,!0)}catch{M(i,`Could not reach the server.`)}finally{M(r,null)}}}var s=Xr(),c=F(s),l=e=>{var t=ch(),n=P(t),s=P(n,!0);E(n);var c=I(n,2),l=e=>{var t=sh(),n=P(t,!0);E(t),R(()=>U(n,z(i))),H(e,t)};W(c,e=>{z(i)&&e(l)});var u=I(c,2),d=P(u,!0);E(u);var f=I(u,2),p=P(f,!0);E(f),E(t),R(()=>{U(s,z(a)),u.disabled=z(r)!==null,U(d,z(r)===`keep`?`Keeping…`:`Keep my edits`),f.disabled=z(r)!==null,U(p,z(r)===`reload`?`Reloading…`:`Reload from file`)}),B(`click`,u,()=>o(`keep`)),B(`click`,f,()=>o(`reload`)),H(e,t)};W(c,e=>{z(n)&&e(l)}),H(e,s),k()}Br([`click`]);var uh=V(`<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),dh=V(`<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),fh=V(`<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),ph=V(`<p class="empty-sub empty-sub-secondary svelte-16uow3k">Tandem works alongside Claude (the default integration) or any MCP-capable AI client.</p>`),mh=V(`<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),hh=V(`<div class="empty-state svelte-16uow3k"><!></div>`);function gh(e,t){O(t,!0);let n=q(t,`aiChip`,3,null),r=j(!1);L(()=>{if(t.connected){M(r,!1);return}let e=setTimeout(()=>{M(r,!0)},Ea);return()=>clearTimeout(e)});var i=hh(),a=P(i),o=e=>{var n=uh(),r=I(F(n),6),i=P(r),a=I(i,2);E(r),B(`click`,i,function(...e){t.onRetry?.apply(this,e)}),B(`click`,a,function(...e){t.onOpenSettings?.apply(this,e)}),H(e,n)},s=e=>{var r=mh(),i=I(F(r),6),a=P(i);E(i);var o=I(i,2),s=e=>{var n=dh(),r=I(F(n),2),i=P(r);E(r),B(`click`,i,function(...e){t.onConnectAi?.apply(this,e)}),H(e,n)},c=e=>{var n=fh(),r=I(F(n),2),i=P(r);E(r),B(`click`,i,function(...e){t.onRestartClaude?.apply(this,e)}),H(e,n)},l=e=>{H(e,ph())};W(o,e=>{t.connected&&n()===`connect`?e(s):t.connected&&n()===`restart`?e(c,1):t.connected&&e(l,2)}),B(`click`,a,function(...e){t.onOpenFile?.apply(this,e)}),H(e,r)};W(a,e=>{z(r)?e(o):e(s,-1)}),E(i),H(e,i),k()}Br([`click`]);var _h=V(`<li> </li>`),vh=V(`<section data-testid="fidelity-report-integrity-warnings"><h4 class="svelte-coexzc">This save may not have preserved everything</h4> <ul class="svelte-coexzc"></ul> <p class="fidelity-report-restore-hint svelte-coexzc">To recover, run "Restore a backup of this document…" from the command palette.</p></section>`),yh=V(`<li> </li>`),bh=V(`<section data-testid="fidelity-report-import-losses"><h4 class="svelte-coexzc">Not imported — lost if you save over the original</h4> <ul class="svelte-coexzc"></ul></section>`),xh=V(`<li> </li>`),Sh=V(`<section data-testid="fidelity-report-export-downgrades"><h4 class="svelte-coexzc">Simplified on the last save</h4> <ul class="svelte-coexzc"></ul></section>`),Ch=V(`<div data-testid="fidelity-report-details"><!> <!> <!></div>`),wh=V(`<div data-testid="fidelity-report-banner"><span class="tandem-banner__message"><!></span> <button type="button" class="tandem-banner__cta" data-testid="fidelity-report-details-toggle"> </button></div> <!>`,1);function Th(e,t){O(t,!0);let n=j(null),r=j(!1);L(()=>{let e=t.ydoc.getMap(Wa),i=()=>{let t=e.get(to);M(n,t?{importLosses:Array.isArray(t.importLosses)?t.importLosses:[],exportDowngrades:Array.isArray(t.exportDowngrades)?t.exportDowngrades:[],integrityWarnings:Array.isArray(t.integrityWarnings)?t.integrityWarnings:[],updatedAt:typeof t.updatedAt==`number`?t.updatedAt:0}:null,!0)};i();let a=e=>{e.keysChanged.has(`fidelityReport`)&&i()};return e.observe(a),()=>{e.unobserve(a),M(n,null),M(r,!1)}});let i=A(()=>z(n)?.integrityWarnings??[]),a=A(()=>z(i).length>0),o=A(()=>!!z(n)&&(z(n).importLosses.length>0||z(n).exportDowngrades.length>0||z(a)));var s=Xr(),c=F(s),l=e=>{var o=wh(),s=F(o),c=P(s),l=P(c),u=e=>{var n=Yr();R(()=>U(n,`This save of ${t.fileName??``} may have changed more than expected — your original is backed up and
55
+ can be restored.`)),H(e,n)},d=e=>{var n=Yr();R(()=>U(n,`Some Word features in ${t.fileName??``} aren't fully supported. Tandem imported the text and
56
+ structure, but the items below won't survive a save back to .docx.`)),H(e,n)};W(l,e=>{z(a)?e(u):e(d,-1)}),E(c);var f=I(c,2),p=P(f,!0);E(f),E(s);var m=I(s,2),h=e=>{var t=Ch(),r=P(t),o=e=>{var t=vh(),n=I(P(t),2);pi(n,21,()=>z(i),li,(e,t)=>{var n=_h(),r=P(n,!0);E(n),R(()=>U(r,z(t))),H(e,n)}),E(n),D(2),E(t),H(e,t)};W(r,e=>{z(a)&&e(o)});var s=I(r,2),c=e=>{var t=bh(),r=I(P(t),2);pi(r,21,()=>z(n).importLosses,li,(e,t)=>{var n=yh(),r=P(n,!0);E(n),R(()=>U(r,z(t))),H(e,n)}),E(r),E(t),H(e,t)};W(s,e=>{z(n).importLosses.length>0&&e(c)});var l=I(s,2),u=e=>{var t=Sh(),r=I(P(t),2);pi(r,21,()=>z(n).exportDowngrades,li,(e,t)=>{var n=xh(),r=P(n,!0);E(n),R(()=>U(r,z(t))),H(e,n)}),E(r),E(t),H(e,t)};W(l,e=>{z(n).exportDowngrades.length>0&&e(u)}),E(t),R(()=>Ui(t,1,`fidelity-report-details ${z(a)?`fidelity-report-details--warning`:``}`,`svelte-coexzc`)),H(e,t)};W(m,e=>{z(r)&&e(h)}),R(()=>{Ui(s,1,`tandem-banner ${z(a)?`tandem-banner--warning`:`tandem-banner--info`}`),K(s,`role`,z(a)?`alert`:`status`),K(s,`aria-live`,z(a)?`assertive`:`polite`),K(f,`aria-expanded`,z(r)),U(p,z(r)?`Hide details`:`Details`)}),B(`click`,f,()=>M(r,!z(r))),H(e,o)};W(c,e=>{z(o)&&z(n)&&e(l)}),H(e,s),k()}Br([`click`]);async function Eh(e,t={}){let{readOnly:n=!1,notFoundMessage:r=`File not found.`,failureMessage:i=`Failed to open file.`}=t;try{let t=await fetch(`${Il}${_c}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({filePath:e,readOnly:n})});if(!t.ok){let e=i;try{let n=await t.json();n.message&&(e=n.message)}catch{}return t.status===404&&(e=r),{ok:!1,error:e}}return{ok:!0}}catch(e){return console.warn(`[tandem] openServerPath failed:`,e),{ok:!1,error:`Server unavailable.`}}}var Dh=Array.from(wa).sort().map(e=>e.replace(/^\./,``));async function Oh(){let{open:e}=await Ul(async()=>{let{open:e}=await import(`./dist-js-BWAGOggB.js`);return{open:e}},__vite__mapDeps([2,1])),t=await e({multiple:!1,directory:!1,title:`Open file in Tandem`,defaultPath:await ql()??void 0,filters:[{name:`Documents`,extensions:Dh}]});return typeof t==`string`?t:null}async function kh(e={}){let t;try{t=await Oh()}catch(t){console.error(`[tandem] native file picker unavailable:`,t),e.onError?.(`File picker unavailable: ${t instanceof Error?t.message:t}`);return}if(!t)return;let n=await Eh(t);if(!n.ok){e.onError?.(n.error);return}Ql(Jl(Zl(),t))}async function Ah(e){e.isTauri?await kh({onError:e.onError}):e.openModal()}async function jh(e,t){try{let n=await fetch(`${Il}${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0,data:r.data??{}}:{ok:!1,error:r.message??`Request failed.`}}catch(e){return console.warn(`[tandem] sessions request failed:`,e),{ok:!1,error:`Server unavailable.`}}}async function Mh(){try{let e=await fetch(`${Il}${Pc}`),t=await e.json().catch(()=>({}));return e.ok?{ok:!0,data:t.data?.sessions??[]}:{ok:!1,error:t.message??`Failed to load sessions.`}}catch(e){return console.warn(`[tandem] fetchSessions failed:`,e),{ok:!1,error:`Server unavailable.`}}}async function Nh(e){return jh(Fc,{filePath:e})}async function Ph(){return jh(Ic,{})}var Fh=V(`<input type="file" style="display: none;"/>`),Ih=V(`<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>`),Lh=V(`<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>`),Rh=V(`<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>`),zh=V(`<p data-testid="sessions-loading" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">Loading…</p>`),Bh=V(`<p data-testid="sessions-empty" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">No saved sessions.</p>`),Vh=V(`<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>`),Hh=V(`<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),Uh=V(`<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>`),Wh=V(`<!> <!>`,1),Gh=V(`<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>`),Kh=V(`<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 qh(e,t){O(t,!0);let n=j(null),r=j(!1),i=j(void 0),a=j(N(Yl(Zl()))),o=j(N([])),s=j(!1),c=j(!1),l=j(!1),u=j(null);async function d(){M(c,!0),M(u,null);let e=await Mh();e.ok?(M(o,e.data,!0),M(l,!0)):M(u,e.error,!0),M(c,!1)}function f(){M(s,!z(s)),z(s)&&!z(l)&&!z(c)&&d()}async function p(e){M(u,null);let t=await Nh(e);t.ok?M(o,z(o).filter(t=>t.filePath!==e),!0):M(u,t.error,!0)}async function m(){M(u,null);let e=await Ph();e.ok?M(o,[],!0):M(u,e.error,!0)}function h(e){if(!e)return`unknown`;let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}let g=Array.from(wa).sort().join(`,`);function _(e){let t=Jl(Zl(),e);Ql(t),M(a,Yl(t),!0)}function v(){$l(),M(a,[],!0)}async function y(e){if(!z(r)){M(n,null),M(r,!0);try{let r=await Eh(e);if(!r.ok){M(n,r.error,!0);return}_(e),t.onClose()}finally{M(r,!1)}}}async function b(){if(!z(r))try{let e=await Oh();e&&await y(e)}catch(e){M(n,`File picker unavailable: ${e instanceof Error?e.message:e}`)}}async function x(e){if(!z(r)){M(n,null),M(r,!0);try{let r=await zl(e),i=await fetch(`${Il}${xc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileName:e.name,content:r})}),a=await i.json();if(!i.ok){M(n,a.message??`Failed to open file`,!0);return}t.onClose()}catch(e){console.error(`FileOpenDialog: upload failed`,e),e instanceof SyntaxError?M(n,`Server returned an unexpected response`):e instanceof TypeError?M(n,`Unexpected response format`):M(n,`Cannot reach server. Is it running?`)}finally{M(r,!1)}}}function S(e){let t=e.target.files?.[0];t&&x(t)}function ee(){Bm()?b():z(i)?.click()}var C=Kh();K(C,`tabindex`,-1);var te=P(C),w=P(te),ne=I(P(w),2);E(w);var re=I(w,2);Tn(re,!0);var T=P(re,!0);E(re);var ie=I(re,2),ae=e=>{var t=Fh();fa(t,e=>M(i,e),()=>z(i)),R(()=>K(t,`accept`,g)),B(`change`,t,S),H(e,t)},oe=A(()=>!Bm());W(ie,e=>{z(oe)&&e(ae)});var se=I(ie,2),ce=e=>{H(e,Ih())},le=A(()=>Bm());W(se,e=>{z(le)&&e(ce)});var ue=I(se,2),de=e=>{var t=Rh(),n=P(t),r=I(P(n),2);E(n);var i=I(n,2);pi(i,22,()=>z(a),e=>e,(e,t,n)=>{let r=A(()=>t.split(/[/\\]/)),i=A(()=>z(r).at(-1)??t),a=A(()=>z(r).slice(0,-1).join(`/`)||`/`);var o=Lh(),s=P(o),c=P(s,!0);E(s);var l=I(s,2),u=P(l,!0);E(l),E(o),R(()=>{K(o,`data-testid`,`recent-file-${z(n)}`),U(c,z(i)),U(u,z(a))}),B(`click`,o,()=>y(t)),zr(`mouseenter`,o,e=>{e.currentTarget.style.background=`var(--tandem-surface-muted)`}),zr(`mouseleave`,o,e=>{e.currentTarget.style.background=`transparent`}),H(e,o)}),E(i),Pi(i,(e,t)=>Bu?.(e,t),()=>`y`),E(t),B(`click`,r,v),H(e,t)};W(ue,e=>{z(a).length>0&&e(de)});var fe=I(ue,2),pe=P(fe),me=I(P(pe),2),he=P(me,!0);E(me),E(pe);var ge=I(pe,2),_e=e=>{var t=Wh(),n=F(t),r=e=>{H(e,zh())},i=e=>{H(e,Bh())},a=e=>{var t=Hh(),n=F(t),r=P(n);E(n);var i=I(n,2);pi(i,21,()=>z(o),e=>e.filePath,(e,t)=>{let n=A(()=>z(t).filePath.split(/[/\\]/)),r=A(()=>z(n).at(-1)??z(t).filePath),i=A(()=>z(n).slice(0,-1).join(`/`)||`/`);var a=Vh(),o=P(a),s=P(o),c=P(s,!0);E(s);var l=I(s,2),u=P(l,!0);E(l);var d=I(l,2),f=P(d);E(d),E(o);var m=I(o,2);E(a),R(e=>{K(o,`title`,z(t).filePath),U(c,z(r)),U(u,z(i)),U(f,`${e??``} · ${z(t).annotationCount??``} annotation${z(t).annotationCount===1?``:`s`}`),K(m,`aria-label`,`Delete session for ${z(r)}`)},[()=>h(z(t).lastAccessed)]),B(`click`,o,()=>y(z(t).filePath)),B(`click`,m,()=>p(z(t).filePath)),H(e,a)}),E(i),Pi(i,(e,t)=>Bu?.(e,t),()=>`y`),B(`click`,r,m),H(e,t)};W(n,e=>{z(c)?e(r):z(o).length===0?e(i,1):e(a,-1)});var s=I(n,2),l=e=>{var t=Uh(),n=P(t,!0);E(t),R(()=>U(n,z(u))),H(e,t)};W(s,e=>{z(u)&&e(l)}),H(e,t)};W(ge,e=>{z(s)&&e(_e)}),E(fe);var ve=I(fe,2),ye=e=>{var t=Gh(),r=P(t,!0);E(t),R(()=>U(r,z(n))),H(e,t)};W(ve,e=>{z(n)&&e(ye)}),E(te),E(C),R(()=>{re.disabled=z(r),G(re,`width: 100%; padding: 12px; font-size: 14px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: ${z(r)?`wait`:`pointer`}; background: ${z(r)?`var(--tandem-fg-subtle)`:`var(--tandem-accent)`}; color: var(--tandem-accent-fg);`),U(T,z(r)?`Opening…`:`Browse…`),K(pe,`aria-expanded`,z(s)),U(he,z(s)?`▾`:`▸`)}),B(`click`,C,e=>{e.target===e.currentTarget&&t.onClose()}),B(`keydown`,C,e=>{e.key===`Escape`&&t.onClose()}),B(`click`,ne,function(...e){t.onClose?.apply(this,e)}),B(`click`,re,ee),B(`click`,pe,f),H(e,C),k()}Br([`click`,`keydown`,`change`]);var Jh=V(`<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),Yh=V(`<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>`),Xh=V(`<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),Zh=V(`<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>,
57
+ 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 Qh(e,t){O(t,!0);let n=A(()=>{let e=su(),n=t.effectiveShortcutLabels,r=new Map;for(let t of e.values()){if(!t.shortcut)continue;let e=Xc[t.id],i=e&&n?.get(e)||t.shortcut,a=r.get(t.group)??[];a.push({keys:i,description:t.label}),r.set(t.group,a)}return iu.map(e=>({title:e.charAt(0).toUpperCase()+e.slice(1),rows:r.get(e)??[]})).filter(e=>e.rows.length>0)}),r=j(null),i=null;L(()=>{if(!t.open)return;let e=Ar(()=>z(r));if(!e)return;i=document.activeElement,e.focus();let n=t=>{e&&!e.contains(t.target)&&e.focus()};return document.addEventListener(`focusin`,n),()=>{document.removeEventListener(`focusin`,n),i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),L(()=>{if(!t.open)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t.onClose())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});var a=Xr(),o=F(a),s=e=>{var i=Zh(),a=P(i),o=P(a),s=I(P(o),2);E(o);var c=I(o,2);pi(c,17,()=>z(n),e=>e.title,(e,t)=>{var n=Yh(),r=P(n),i=P(r,!0);E(r);var a=I(r,2);pi(a,21,()=>z(t).rows,e=>e.description,(e,t)=>{var n=Jh(),r=F(n),i=P(r),a=P(i,!0);E(i),E(r);var o=I(r,2),s=P(o,!0);E(o),R(()=>{U(a,z(t).keys),U(s,z(t).description)}),H(e,n)}),E(a),E(n),R(()=>U(i,z(t).title)),H(e,n)});var l=I(c,2),u=I(P(l),2);pi(u,21,()=>dm,e=>e.description,(e,t)=>{var n=Xh(),r=F(n),i=P(r),a=P(i,!0);E(i),E(r);var o=I(r,2),s=P(o,!0);E(o),R(()=>{U(a,z(t).keys),U(s,z(t).description)}),H(e,n)}),E(u),E(l),D(2),E(a),fa(a,e=>M(r,e),()=>z(r)),Pi(a,(e,t)=>Bu?.(e,t),()=>`y`),E(i),B(`click`,i,function(...e){t.onClose?.apply(this,e)}),B(`click`,a,e=>e.stopPropagation()),B(`keydown`,a,e=>{if(e.key===`Escape`){t.onClose();return}if(e.stopPropagation(),e.key===`Tab`&&z(r)){let t=Array.from(z(r).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.closest(`[hidden]`));if(t.length===0){e.preventDefault();return}let n=t[0],i=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus())}}),B(`click`,s,function(...e){t.onClose?.apply(this,e)}),H(e,i)};W(o,e=>{t.open&&e(s)}),H(e,a),k()}Br([`click`,`keydown`]);var $h=`/api/integrations/existing`,eg=`/api/integrations`,tg=`/api/integrations/apply`,ng=`/api/integrations/first-run-needed`;function rg(e){return`/api/integrations/secrets/${encodeURIComponent(e)}`}function ig(e){return`/api/models/secrets/${encodeURIComponent(e)}`}var ag=`/api/integrations/claude-cli-status`,og=`/api/integrations/install-claude-code`;function sg(e,t=``,n=globalThis.fetch.bind(globalThis)){let r=j(null),i=j(!1),a=j(null),o=j(!1),s=j(null),c=!0;va(()=>{c=!1});let l=async e=>{try{let i=await n(`${t}${ag}`);if(!c||e())return;if(!i.ok){M(a,`Could not check for Claude (status ${i.status}).`);return}let o=await i.json();if(!c||e())return;M(r,o.presence,!0),M(a,null)}catch(t){if(!c||e())return;M(a,t instanceof Error?t.message:String(t),!0)}finally{c&&!e()&&M(i,!1)}};return L(()=>{if(!e()){M(i,!1);return}let t=!1;return M(i,!0),l(()=>t),()=>{t=!0}}),{get presence(){return z(r)},get loading(){return z(i)},get error(){return z(a)},get installing(){return z(o)},get installError(){return z(s)},install:async()=>{if(!c)return null;M(o,!0),M(s,null);try{let e=await n(`${t}${og}`,{method:`POST`});if(!c)return null;if(!e.ok){let t=await e.json().catch(()=>null);return c&&M(s,cg(e.status,t),!0),null}let i=await e.json();return c?(M(r,i.presence,!0),i.presence===`NOT_INSTALLED`&&M(s,`The installer finished but Claude wasn't detected yet. Open a new terminal and click "Check again", or install Claude Code manually.`),i.presence):null}catch(e){return c&&M(s,e instanceof Error?e.message:String(e),!0),null}finally{c&&M(o,!1)}},refetch:async()=>{c&&(M(i,!0),M(s,null),await l(()=>!1))}}}function cg(e,t){let n=t??null;if(n?.code===`UNSUPPORTED_PLATFORM`)return`Automatic install isn't available on this operating system. Install Claude Code manually, then check again.`;if(n?.code===`INSTALL_IN_PROGRESS`)return`An install is already in progress.`;let r=n?.stderrTail?.trim();return r?`Install failed (exit ${typeof n?.exitCode==`number`?n.exitCode:`?`}). ${r}`:n?.message??`Install failed (status ${e}).`}var lg=`Tauri runtime not available`;async function ug(){try{return(await Ul(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return Bm()&&console.error(`[keychain] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(lg)))}}function dg(e,t,n){return e(`keychain_set`,{account:t,secret:n})}function fg(e,t){return e(`keychain_delete`,{account:t})}function pg(e={}){let t=e.fetchFn??((...e)=>globalThis.fetch(...e)),n=e.baseUrl??``,r=e.pathFor??rg;return{async set(e,i){try{let a=await t(`${n}${r(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({secret:i})});return a.status===503&&(await a.json().catch(()=>null))?.code===`KEYCHAIN_UNAVAILABLE`?{status:`unavailable`}:a.ok?{status:`ok`}:{status:`error`,message:`HTTP ${a.status}`}}catch(e){return{status:`error`,message:e instanceof Error?e.message:String(e)}}},async delete(e){await t(`${n}${r(e)}`,{method:`DELETE`}).catch(()=>{})}}}var mg=[`keychain-init`,`Platform secure storage failure`,`Couldn't access platform secure storage`];function hg(e){return mg.some(t=>e.includes(t))}function gg(e={}){let t=()=>e.invoke?Promise.resolve(e.invoke):ug();return{async set(e,n){try{return await dg(await t(),e,n),{status:`ok`}}catch(e){let t=e instanceof Error?e.message:String(e);return hg(t)?{status:`unavailable`}:{status:`error`,message:t}}},async delete(e){try{await fg(await t(),e)}catch{}}}}function _g(e={}){return e.force===`tauri`||e.force!==`http`&&Bm()?gg({invoke:e.invoke}):pg({fetchFn:e.fetchFn,baseUrl:e.baseUrl,pathFor:e.pathFor})}function vg(e){return e.tandemValidation!==void 0&&e.tandemValidation.status!==`valid`}function yg(e){return(e.status===`ok`||e.status===`missing`)&&!vg(e)}function bg(e){return`${e}-${crypto.randomUUID().replace(/-/g,``).slice(0,12)}`}function xg(e){return`${e}-${crypto.randomUUID().slice(0,8)}`}function Sg(e){if(e.target.kind===`claude-code`){let t=e.tandemEntry?.url??`http://127.0.0.1:3479`,n=xg(`claude-code`);return{id:n,config:{kind:`claude-code`,id:n,label:e.target.label,configPath:e.target.configPath,transport:`http`,url:t},hasStoredSecret:!1,keychainUnavailable:!1}}if(e.target.kind===`claude-desktop`){let t=xg(`claude-desktop`);return{id:t,config:{kind:`claude-desktop`,id:t,label:e.target.label,configPath:e.target.configPath,transport:`stdio`},hasStoredSecret:!1,keychainUnavailable:!1}}return null}function Cg(e={}){let t=e.fetchFn??globalThis.fetch.bind(globalThis),n=e.baseUrl??``,r=e.keychainBackend??_g({fetchFn:t,baseUrl:n}),i=j(`connect`),a=j(!0),o=j(N([])),s=j(N([])),c=j(null),l=j(N([])),u=j(!1),d=0,f=e=>{M(c,e,!0),M(i,`error`),M(a,!1)},p=async()=>{let e=++d;M(a,!0),M(i,`connect`),M(c,null);try{let r=await t(`${n}${$h}`);if(e!==d)return;if(!r.ok){f(`Could not load existing entries (HTTP ${r.status}).`);return}let i=await r.json();if(e!==d)return;M(o,i.installs,!0),M(s,i.installs.filter(yg).map(Sg).filter(e=>e!==null),!0)}catch(t){if(e!==d)return;if(t instanceof TypeError&&/fetch|load failed|network/i.test(t.message)){f(`Could not reach the Tandem server. Make sure Tandem is running, then try again.`);return}f(t instanceof Error?t.message:String(t))}finally{e===d&&M(a,!1)}},m=e=>{let t=z(s).filter(t=>t.config.tokenSecretRef&&!e.some(e=>e.id===t.id));M(s,e,!0);for(let e of t){let t=e.config.tokenSecretRef;t&&r.delete(t)}},h=async(e,t)=>{let n=bg(e.id),i=await r.set(n,t);if(i.status===`unavailable`){M(u,!0),M(s,z(s).map(t=>t.id===e.id?{...t,keychainUnavailable:!0}:t),!0);return}if(i.status===`error`){r.delete(n),f(`Could not store secret: ${i.message}`);return}M(s,z(s).map(t=>t.id===e.id?{...t,config:{...t.config,tokenSecretRef:n},hasStoredSecret:!0,keychainUnavailable:!1}:t),!0)},g=async()=>{let e=z(s).map(e=>e.config.tokenSecretRef).filter(e=>typeof e==`string`&&e.length>0);await Promise.all(e.map(e=>r.delete(e)))};return{get step(){return z(i)},get detecting(){return z(a)},get existing(){return z(o)},get picked(){return z(s)},get errorMessage(){return z(c)},get applyResults(){return z(l)},get keychainUnavailable(){return z(u)},begin:p,setPicked:m,submitSecret:h,save:async()=>{M(i,`applying`);let e={schemaVersion:3,integrations:z(s).map(e=>{if(e.config.kind===`other-mcp`)return{...e.config,apply:`skip`};let t=e.config.configPath,n=z(o).find(e=>e.target.configPath===t),r=n!==void 0&&vg(n);return{...e.config,apply:r?`skip`:`create`}})},r=!1;try{let a=await t(`${n}${eg}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!a.ok){let e=await a.json().catch(()=>null);await g(),f(e?.message??`Could not save (HTTP ${a.status}).`);return}r=!0;let o=await a.json(),s=await t(`${n}${tg}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:o.ids,confirmationNonce:o.confirmationNonce})});if(!s.ok){f((await s.json().catch(()=>null))?.message??`Could not apply (HTTP ${s.status}).`);return}M(l,(await s.json()).results,!0),M(i,`done`)}catch(e){r||await g(),f(e instanceof Error?e.message:String(e))}},reset:()=>{M(i,`connect`),M(a,!1),M(o,[],!0),M(s,[],!0),M(c,null),M(l,[],!0),M(u,!1)},cleanupUnsavedSecrets:async()=>{z(i)===`connect`&&await g()}}}var wg=3e3,Tg=1500,Eg=2e4;function Dg(e,t,n=``,r=globalThis.fetch.bind(globalThis),i={}){let a=i.verifyTimeoutMs??wg,o=i.pollIntervalMs??Tg,s=i.pollDeadlineMs??Eg,c=j(`idle`),l=j(null),u=j(!1),d=j(N([])),f=!0,p=null,m=0;function h(){p!==null&&(clearInterval(p),p=null)}va(()=>{f=!1,h(),m++});async function g(e){let t=++m,i;try{i=await r(`${n}${gc}`,e?{signal:e}:void 0)}catch{return{ok:!1,hasSession:null}}if(!i.ok)return{ok:!1,hasSession:null};let a=null;try{a=await i.json()}catch{a=null}let o=a&&typeof a.hasSession==`boolean`?a.hasSession:null;return o===!0&&t===m&&f&&M(u,!0),{ok:!0,hasSession:o}}return L(()=>{if(!t()){M(c,`idle`),h();return}let n=!1,r=Ar(()=>e()).map(e=>({...e})),i=r.some(e=>e.transport===`http`);if(M(u,!1),M(l,null),M(d,r.map(e=>({id:e.id,status:e.transport===`http`?`verifying`:`not-applicable`})),!0),!i)return M(c,`done`),()=>{n=!0,h()};M(c,`verifying`);let m=new AbortController,_=setTimeout(()=>m.abort(),a);return(async()=>{let{ok:e,hasSession:t}=await g(m.signal);if(clearTimeout(_),n||!f||(M(l,e,!0),M(d,r.map(t=>({id:t.id,status:t.transport===`http`?e?`reachable`:`unreachable`:`not-applicable`})),!0),M(c,`done`),!e||t===!0))return;let i=Date.now()+s;p=setInterval(()=>{if(n||!f||z(u)||Date.now()>=i){h();return}g().then(()=>{z(u)&&h()})},o)})(),()=>{n=!0,clearTimeout(_),m.abort(),h()}}),{get phase(){return z(c)},get serverUp(){return z(l)},get claudeConnected(){return z(u)},get results(){return z(d)}}}var Og=Jr(`<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>`),kg=Jr(`<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>`),Ag=Jr(`<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>`),jg=V(`<span class="itc-check-empty svelte-q7klwd"></span>`),Mg=V(`<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 Ng(e,t){O(t,!0);let n=A(()=>yg(t.install)),r=A(()=>t.install.target.configPath.replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase()),i=A(()=>t.install.status===`error`?{text:t.install.errorMessage?`Couldn't check this one — ${t.install.errorMessage}`:`Couldn't check this one`,family:`error`}:t.install.status===`malformed`?{text:`Settings file couldn't be read — we'll leave it alone`,family:`warning`}:t.install.tandemEntry===void 0?t.install.status===`missing`?{text:`Ready to connect (settings file will be created)`,family:null}:{text:`Ready to connect`,family:null}:vg(t.install)?{text:`Has a custom setup — we won't touch it`,family:`warning`}:{text:`Already connected — we'll refresh it`,family:`success`});var a=Mg();let o;var s=P(a);$i(s);var c=I(s,2),l=P(c),u=e=>{H(e,Og())},d=e=>{H(e,kg())};W(l,e=>{t.install.target.kind===`claude-code`?e(u):e(d,-1)}),E(c);var f=I(c,2),p=P(f),m=P(p,!0);E(p);var h=I(p,2),g=P(h,!0);E(h);var _=I(h,2),v=P(_,!0);E(_),E(f);var y=I(f,2),b=P(y),x=e=>{var n=Xr(),r=F(n),i=e=>{H(e,Ag())},a=e=>{H(e,jg())};W(r,e=>{t.selected?e(i):e(a,-1)}),H(e,n)};W(b,e=>{z(n)&&e(x)}),E(y),E(a),R(()=>{o=Ui(a,1,`itc-card svelte-q7klwd`,null,o,{"is-selected":t.selected,"is-locked":!z(n)}),K(a,`data-testid`,`integration-wizard-card-${z(r)??``}`),ta(s,t.selected),s.disabled=!z(n),K(s,`data-testid`,`integration-wizard-pick-${z(r)??``}`),U(m,t.install.target.label),Ui(h,1,`itc-status itc-status-${z(i).family??`neutral`??``}`,`svelte-q7klwd`),U(g,z(i).text),U(v,t.install.target.configPath)}),B(`change`,s,function(...e){t.onToggle?.apply(this,e)}),H(e,a),k()}Br([`change`]);var Pg=(e,t=m)=>{var n=Rg();R(()=>Ui(n,0,Li(t()),`svelte-bt94ms`)),H(e,n)},Fg=e=>{H(e,zg())},Ig=e=>{H(e,Bg())},Lg=(e,t=m)=>{var n=Vg(),r=I(P(n));E(n),R(()=>U(r,` ${t()??``}`)),H(e,n)},Rg=Jr(`<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>`),zg=Jr(`<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>`),Bg=Jr(`<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>`),Vg=V(`<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>`),Hg=V(`<span><!></span>`),Ug=V(`<p class="iw-subtitle svelte-bt94ms">Connect your AI assistant.</p>`),Wg=V(`<p class="iw-subtitle svelte-bt94ms">Let a teammate's Claude join from the Cowork VM.</p>`),Gg=V(`<div class="iw-whats-next svelte-bt94ms"><!> <span class="svelte-bt94ms">Cowork is enabled. Manage workspaces in Settings&nbsp;→&nbsp;Network.</span></div>`),Kg=V(`<p class="iw-hint-text svelte-bt94ms" data-testid="cowork-vethernet-cidr">Detected Cowork environment: <code class="iw-code-inline svelte-bt94ms"> </code></p>`),qg=V(`<p class="iw-hint-text svelte-bt94ms">A previous attempt couldn't update Windows Firewall (that needs administrator
58
+ rights). Enabling writes the workspace plugin entries either way.</p>`),Jg=V(`<div class="iw-banner-warning svelte-bt94ms"><!> <span class="svelte-bt94ms">Tandem registers itself as a plugin in every detected Cowork workspace so Claude
59
+ in Cowork can reach your open documents. This adds a Windows firewall rule so the
60
+ Cowork VM can connect back — admin is required once.</span></div> <!> <!> <details class="iw-advanced svelte-bt94ms" data-testid="integration-wizard-cowork-explainer"><summary class="svelte-bt94ms"><!> What this does &amp; how to verify</summary> <div class="iw-advanced-body svelte-bt94ms"><p class="iw-hint-text svelte-bt94ms">You don't add a marketplace or run any commands inside Cowork — Tandem writes
61
+ the plugin entry for you. After enabling, open a Cowork session and ask Claude
62
+ to open or list your documents; Tandem's tools should appear. If they don't,
63
+ re-run “Enable Cowork”.</p> <p class="iw-hint-text svelte-bt94ms">Live updates (annotations and chat as they happen) need the Tandem desktop app
64
+ running; the Cowork connection itself is request-and-response.</p></div></details>`,1),Yg=V(`<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-cowork-error"><!> <span class="svelte-bt94ms"> </span></div>`),Xg=V(`<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-cowork-step"><!> <!></section>`),Zg=V(`<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-install-error"><!> <span class="svelte-bt94ms"> </span></div>`),Qg=V(`<p class="iw-hint-text svelte-bt94ms">Don't have Claude Code yet? Install it now — a small, signed download
65
+ straight from Anthropic.</p> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-install-claude"> </button> <!>`,1),$g=V(`<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>`),e_=V(`<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
66
+ connect a different MCP-compatible app manually, point it at:</p> <code class="iw-code svelte-bt94ms"> </code></div>`),t_=V(`<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
67
+ build, so tokens entered here can't be saved. Set the environment
68
+ 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>`),n_=V(`<span class="iw-secret-stored svelte-bt94ms"><!> Token saved</span>`),r_=V(`<span class="iw-secret-skipped svelte-bt94ms">Skipped (secure storage unavailable)</span>`),i_=V(`<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>`),a_=V(`<div class="iw-secret-row svelte-bt94ms"><span class="iw-secret-label svelte-bt94ms"> </span> <!></div>`),o_=V(`<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
69
+ just this computer. Most people can skip this. Tokens are stored in your
70
+ operating system's secure storage.</p> <!> <!></div></details>`),s_=V(`<p class="iw-intro svelte-bt94ms">We'll add a small entry to Claude's settings file so Claude can read and edit the
71
+ documents you have open in Tandem. Nothing else is touched, and you can undo this
72
+ any time.</p> <div class="iw-cards svelte-bt94ms"></div> <!>`,1),c_=V(`<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>`),l_=V(`<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>`),u_=V(`<div class="iw-verifying svelte-bt94ms" data-testid="integration-wizard-step-verifying"><!></div>`),d_=V(`<span class="iw-result-detail svelte-bt94ms">Connected</span> <!>`,1),f_=V(`<span class="iw-result-detail svelte-bt94ms">Left unchanged (already set up, or couldn't be safely edited)</span>`),p_=V(`<span class="iw-result-detail svelte-bt94ms"> </span>`),m_=V(`<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>`),h_=V(`<div class="iw-results svelte-bt94ms"></div>`),g_=V(`Tandem doesn't seem to be running. Start Tandem, then restart Claude and run <code class="iw-code-inline svelte-bt94ms">/mcp</code>.`,1),__=V(`Restart Claude Code, then type <code class="iw-code-inline svelte-bt94ms">/mcp</code> to verify —
73
+ or just ask Claude to open a document.`,1),v_=V(`<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" data-testid="integration-wizard-whats-next"><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"><!></span></div></section>`),y_=V(`<p class="iw-hint-text svelte-bt94ms"> </p>`),b_=V(`<details class="iw-tech-details svelte-bt94ms"><summary class="svelte-bt94ms"><!> Technical details</summary> <pre class="iw-tech-text svelte-bt94ms"> </pre></details>`),x_=V(`<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>`),S_=V(`<span class="iw-more-badge svelte-bt94ms"><!> Enabled</span>`),C_=V(`<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>`),w_=V(`<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>`),T_=V(`<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>`),E_=V(`<section class="iw-more svelte-bt94ms" data-testid="integration-wizard-more"><div class="iw-more-label svelte-bt94ms">More integrations</div> <!> <!></section>`),D_=V(`<!> <!>`,1),O_=V(`<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms">Done</button>`),k_=V(`<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="cowork-enable-confirm-btn"> </button>`),A_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-cowork-back">Back</button> <!>`,1),j_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Cancel</button>`),M_=V(`<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),N_=V(`<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),P_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" disabled="">Connecting…</button>`),F_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-done-retry">Try again</button>`),I_=V(`<!> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-done-close">Done</button>`,1),L_=V(`<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),R_=V(`<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 z_(e,t){O(t,!0);let n=(e,t=m)=>{let n=A(()=>d(t()));var r=Xr(),i=F(r),a=e=>{var r=Hg(),i=P(r),a=e=>{H(e,Yr(`Checking Tandem is reachable…`))},o=e=>{var t=Yr();R(()=>U(t,u.claudeConnected?`Claude connected just now`:`Tandem is responding`)),H(e,t)},s=e=>{H(e,Yr(`Config written, but the Tandem MCP server isn't responding — start Tandem, then restart
74
+ Claude.`))},c=e=>{H(e,Yr(`Tandem starts when Claude Desktop opens`))};W(i,e=>{z(n)===`verifying`?e(a):z(n)===`reachable`?e(o,1):z(n)===`unreachable`?e(s,2):e(c,-1)}),E(r),R(()=>{Ui(r,1,`iw-reachability iw-reachability-${z(n)??``}`,`svelte-bt94ms`),K(r,`data-testid`,`integration-wizard-reachability-${t()??``}`),K(r,`data-reachability-status`,z(n))}),H(e,r)};W(i,e=>{z(n)&&e(a)}),H(e,r)},r=Cg({baseUrl:`http://127.0.0.1:${xa}`}),i=eh(()=>Bm()),a=A(()=>Em(i.status)),o=sg(()=>t.open&&r.step===`connect`,`http://127.0.0.1:${xa}`),s=A(()=>o.presence===`NOT_INSTALLED`),c=A(()=>o.presence===`INSTALLED_NOT_ON_PATH`),l=A(()=>r.applyResults.filter(e=>e.status===`applied`).map(e=>({id:e.id,transport:r.picked.find(t=>t.id===e.id)?.config.transport})).filter(e=>e.transport===`http`||e.transport===`stdio`)),u=Dg(()=>z(l),()=>t.open&&r.step===`done`,`http://127.0.0.1:${xa}`);function d(e){return u.results.find(t=>t.id===e)?.status??null}let f=A(()=>{let e=u.results;return!e.some(e=>e.status===`reachable`||e.status===`unreachable`||e.status===`verifying`)&&e.length>0?`stdio-only`:e.some(e=>e.status===`unreachable`)?`unreachable`:u.claudeConnected?`connected`:`default`}),p=j(`main`),h=j(!1),g=j(null),_=j(null),v=null,y=j(N({}));L(()=>{if(!t.open)return;let e=Ar(()=>z(_));if(e)return v=document.activeElement,e.focus(),()=>{v instanceof HTMLElement&&document.contains(v)&&v.focus()}}),L(()=>{t.open&&(M(p,`main`),r.begin())});async function b(){M(h,!0),M(g,null);try{await Gm(await Um(),!0),await i.refetch(),M(p,`main`)}catch(e){M(g,Am(e instanceof Error?e.message:String(e)),!0)}finally{M(h,!1)}}let x=A(()=>{if(z(a)===`loading`)return`Checking…`;if(z(a)===`unsupported`)return`Coming soon to macOS & Linux`;if(z(a)===`undetected`){let e=i.status,t=e?Dm(e):`noClaude`;return t===`blocked`?`Found in a network-redirected or synced location Tandem can't safely configure`:t===`noWorkspacesYet`?`Claude Desktop detected — run a Cowork session once, then set up here`:`Not detected on this computer`}let e=i.status;return e?.enabled?`Connected — token provisioned`:e?.uacDeclined?`Setup didn't complete last time — try again from here`:`Let a teammate's Claude join from the Cowork VM`});L(()=>{if(!t.open)return;let e=e=>{e.key===`Escape`&&S()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});function S(){r.cleanupUnsavedSecrets().catch(()=>{}),r.reset(),M(y,{},!0),t.onClose()}function ee(){r.reset(),M(y,{},!0),r.begin(),o.refetch(),i.refetch()}async function C(){let e=await o.install();e&&e!==`NOT_INSTALLED`&&r.begin()}function te(e){if(e.key!==`Tab`||!z(_))return;let t=Array.from(z(_).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null);if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||i===z(_))?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())}function w(e){let t=r.picked.findIndex(t=>t.config.configPath===e.target.configPath);if(t>=0){r.setPicked(r.picked.filter((e,n)=>n!==t));return}let n=Sg(e);n&&r.setPicked([...r.picked,n])}function ne(e){return r.picked.some(t=>t.config.configPath===e.target.configPath)}async function re(e){let t=z(y)[e.id]??``;t.length!==0&&(await r.submitSecret(e,t),z(y)[e.id]=``)}let T=/HTTP 5\d\d/,ie=/HTTP 4\d\d/,ae=/fetch|network|Failed to/i,oe=A(()=>r.picked.length===1?`Connect ${r.picked[0].config.label}`:`Connect selected`);function se(e){return r.picked.find(t=>t.id===e.id)?.config.label??`Unknown`}function ce(e){switch(e.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 e.message??`Something went wrong applying this one.`}}let le=A(()=>{let e=r.errorMessage??``;return T.test(e)?`Tandem's helper isn't responding. Make sure Tandem is running, then try again.`:ie.test(e)?`Tandem couldn't save the connection. Try again in a moment.`:ae.test(e)?`Couldn't reach Tandem — is it still running?`:null}),ue=A(()=>r.applyResults.some(e=>e.status===`error`));var de=Xr(),fe=F(de),pe=e=>{var t=R_(),l=P(t),d=P(l),m=P(d),v=P(m),T=P(v,!0);E(v);var ie=I(v,2),ae=e=>{H(e,Ug())},de=e=>{H(e,Wg())};W(ie,e=>{z(p)===`main`&&r.step===`connect`?e(ae):z(p)===`cowork`&&e(de,1)}),E(m);var fe=I(m,2);E(d);var pe=I(d,2),me=P(pe),he=e=>{var t=Xg(),n=P(t),r=e=>{var t=Gg();Fg(P(t)),D(2),E(t),H(e,t)},a=e=>{var t=Jg(),n=F(t);Pg(P(n)),D(2),E(n);var r=I(n,2),a=e=>{var t=Kg(),n=I(P(t)),r=P(n,!0);E(n),E(t),R(()=>U(r,i.status.vethernetCidr)),H(e,t)};W(r,e=>{i.status?.vethernetCidr&&e(a)});var o=I(r,2),s=e=>{H(e,qg())};W(o,e=>{i.status?.uacDeclined&&e(s)});var c=I(o,2),l=P(c);Ig(P(l)),D(),E(l),D(2),E(c),H(e,t)};W(n,e=>{i.status?.enabled?e(r):e(a,-1)});var o=I(n,2),s=e=>{var t=Yg(),n=P(t);Pg(n);var r=I(n,2),i=P(r,!0);E(r),E(t),R(()=>U(i,z(g))),H(e,t)};W(o,e=>{z(g)&&e(s)}),E(t),H(e,t)},ge=e=>{var t=D_(),l=F(t),d=e=>{var t=c_(),n=P(t),i=e=>{Lg(e,()=>`Looking for Claude on your computer…`)},a=e=>{var t=e_(),n=I(P(t),2),r=e=>{var t=Qg(),n=I(F(t),2),r=P(n,!0);E(n);var i=I(n,2),a=e=>{var t=Zg(),n=P(t);Pg(n);var r=I(n,2),i=P(r,!0);E(r),E(t),R(()=>U(i,o.installError)),H(e,t)};W(i,e=>{o.installError&&e(a)}),R(()=>{n.disabled=o.installing,U(r,o.installing?`Installing…`:`Install Claude Code`)}),B(`click`,n,C),H(e,t)},i=e=>{var t=$g();Fg(P(t)),D(2),E(t),H(e,t)};W(n,e=>{z(s)?e(r):z(c)&&e(i,1)});var a=I(n,4),l=P(a);E(a),E(t),R(()=>U(l,`http://127.0.0.1:3479/mcp`)),H(e,t)},l=e=>{var t=s_(),n=I(F(t),2);pi(n,21,()=>r.existing,e=>e.target.configPath,(e,t)=>{{let n=A(()=>ne(z(t)));Ng(e,{get install(){return z(t)},get selected(){return z(n)},onToggle:()=>w(z(t))})}}),E(n);var i=I(n,2),a=e=>{var t=o_(),n=P(t);Ig(P(n)),D(),E(n);var i=I(n,2),a=I(P(i),2),o=e=>{var t=t_();Pg(P(t)),D(2),E(t),H(e,t)};W(a,e=>{r.keychainUnavailable&&e(o)}),pi(I(a,2),17,()=>r.picked,e=>e.id,(e,t)=>{var n=a_(),r=P(n),i=P(r,!0);E(r);var a=I(r,2),o=e=>{var t=n_();Fg(P(t)),D(),E(t),H(e,t)},s=e=>{H(e,r_())},c=e=>{var n=i_(),r=P(n);$i(r);var i=I(r,2);E(n),R(()=>{K(r,`data-testid`,`integration-wizard-secret-input-${z(t).id??``}`),i.disabled=!z(y)[z(t).id],K(i,`data-testid`,`integration-wizard-secret-submit-${z(t).id??``}`)}),aa(r,()=>z(y)[z(t).id],e=>z(y)[z(t).id]=e),B(`click`,i,()=>re(z(t))),H(e,n)};W(a,e=>{z(t).hasStoredSecret?e(o):z(t).keychainUnavailable?e(s,1):e(c,-1)}),E(n),R(()=>U(i,z(t).config.label)),H(e,n)}),E(i),E(t),H(e,t)};W(i,e=>{r.picked.length>0&&e(a)}),H(e,t)};W(n,e=>{r.detecting?e(i):r.existing.length===0?e(a,1):e(l,-1)}),D(2),E(t),H(e,t)},m=e=>{var t=l_();Lg(P(t),()=>`Connecting Claude…`),D(2),E(t),H(e,t)},_=e=>{var t=v_(),i=P(t),a=I(P(i),2),o=P(a,!0);E(a),E(i);var s=I(i,2),c=e=>{var t=u_();Lg(P(t),()=>`Verifying Claude can reach Tandem…`),E(t),H(e,t)};W(s,e=>{u.phase===`verifying`&&e(c)});var l=I(s,2),d=e=>{var t=h_();pi(t,21,()=>r.applyResults,e=>e.id,(e,t)=>{var r=m_(),i=P(r),a=P(i),o=e=>{Fg(e)},s=e=>{H(e,Yr(`—`))},c=e=>{Pg(e)};W(a,e=>{z(t).status===`applied`?e(o):z(t).status===`skipped`?e(s,1):e(c,-1)}),E(i);var l=I(i,2),u=P(l),d=P(u,!0);E(u);var f=I(u,2),p=e=>{var r=d_();n(I(F(r),2),()=>z(t).id),H(e,r)},m=e=>{H(e,f_())},h=e=>{var n=p_(),r=P(n,!0);E(n),R(e=>U(r,e),[()=>ce(z(t))]),H(e,n)};W(f,e=>{z(t).status===`applied`?e(p):z(t).status===`skipped`?e(m,1):e(h,-1)}),E(l),E(r),R(e=>{Ui(r,1,`iw-result iw-result-${z(t).status??``}`,`svelte-bt94ms`),K(r,`data-testid`,`integration-wizard-apply-result-${z(t).id??``}`),U(d,e)},[()=>se(z(t))]),H(e,r)}),E(t),H(e,t)};W(l,e=>{r.applyResults.length>0&&e(d)});var p=I(l,2),m=I(P(p),2),h=P(m),g=e=>{H(e,Yr(`Claude is connected and talking to Tandem. Ask it to open a document.`))},_=e=>{var t=g_();D(2),H(e,t)},v=e=>{H(e,Yr(`Open Claude Desktop to start using Tandem.`))},y=e=>{var t=__();D(2),H(e,t)};W(h,e=>{z(f)===`connected`?e(g):z(f)===`unreachable`?e(_,1):z(f)===`stdio-only`?e(v,2):e(y,-1)}),E(m),E(p),E(t),R(()=>U(o,z(ue)?`Partly connected`:`Claude is connected to Tandem`)),H(e,t)},v=e=>{var t=x_(),n=P(t);Pg(n,()=>`iw-error-icon`);var i=I(n,4),a=e=>{var t=y_(),n=P(t,!0);E(t),R(()=>U(n,z(le))),H(e,t)};W(i,e=>{z(le)&&e(a)});var o=I(i,2),s=e=>{var t=b_(),n=P(t);Ig(P(n)),D(),E(n);var i=I(n,2),a=P(i,!0);E(i),E(t),R(()=>U(a,r.errorMessage)),H(e,t)};W(o,e=>{r.errorMessage&&e(s)}),E(t),H(e,t)};W(l,e=>{r.step===`connect`?e(d):r.step===`applying`?e(m,1):r.step===`done`?e(_,2):r.step===`error`&&e(v,3)});var b=I(l,2),S=e=>{var t=E_(),n=I(P(t),2),r=e=>{var t=w_(),n=P(t),r=I(P(n),2),o=P(r,!0);E(r),E(n);var s=I(n,2),c=e=>{var t=S_();Fg(P(t)),D(),E(t),H(e,t)},l=e=>{var t=C_();B(`click`,t,()=>{M(g,null),M(h,!1),M(p,`cowork`)}),H(e,t)};W(s,e=>{i.status?.enabled?e(c):z(a)===`normal`&&e(l,1)}),E(t),R(()=>U(o,z(x))),H(e,t)},o=A(()=>Bm());W(n,e=>{z(o)&&e(r)});var s=I(n,2),c=e=>{H(e,T_())};W(s,e=>{e(c)}),E(t),H(e,t)};W(b,e=>{(r.step===`connect`||r.step===`done`)&&e(S)}),H(e,t)};W(me,e=>{z(p)===`cowork`?e(he):e(ge,-1)}),E(pe);var _e=I(pe,2),ve=P(_e),ye=e=>{var t=A_(),n=F(t),r=I(n,2),a=e=>{var t=O_();B(`click`,t,()=>M(p,`main`)),H(e,t)},o=e=>{var t=k_(),n=P(t,!0);E(t),R(()=>{t.disabled=z(h),U(n,z(h)?`Enabling…`:`Enable Cowork`)}),B(`click`,t,b),H(e,t)};W(r,e=>{i.status?.enabled?e(a):e(o,-1)}),R(()=>n.disabled=z(h)),B(`click`,n,()=>M(p,`main`)),H(e,t)},be=e=>{var t=Xr(),n=F(t),i=e=>{var t=j_();B(`click`,t,S),H(e,t)},a=e=>{var t=M_(),n=F(t),r=I(n,2);B(`click`,n,S),B(`click`,r,ee),H(e,t)},o=e=>{var t=N_(),n=F(t),i=I(n,2),a=P(i,!0);E(i),R(()=>{i.disabled=r.picked.length===0,U(a,z(oe))}),B(`click`,n,S),B(`click`,i,()=>r.save()),H(e,t)};W(n,e=>{r.detecting?e(i):r.existing.length===0?e(a,1):e(o,-1)}),H(e,t)},xe=e=>{H(e,P_())},Se=e=>{var t=I_(),n=F(t),r=e=>{var t=F_();B(`click`,t,ee),H(e,t)};W(n,e=>{z(ue)&&e(r)}),B(`click`,I(n,2),S),H(e,t)},Ce=e=>{var t=L_(),n=F(t),r=I(n,2);B(`click`,n,S),B(`click`,r,ee),H(e,t)};W(ve,e=>{z(p)===`cowork`?e(ye):r.step===`connect`?e(be,1):r.step===`applying`?e(xe,2):r.step===`done`?e(Se,3):r.step===`error`&&e(Ce,4)}),E(_e),E(l),fa(l,e=>M(_,e),()=>z(_)),E(t),R(()=>U(T,z(p)===`cowork`?`Set up Cowork`:`Connect Claude to Tandem`)),B(`click`,t,e=>{e.target===e.currentTarget&&S()}),B(`keydown`,l,e=>{if(e.key===`Escape`){e.stopPropagation(),S();return}if(e.key===`Tab`){te(e);return}e.stopPropagation()}),B(`click`,fe,S),H(e,t)};W(fe,e=>{t.open&&e(pe)}),H(e,de),k()}Br([`click`,`keydown`]);function B_(e){return e.trial?.daysRemaining??e.daysRemaining??null}function V_(e){if(!e||!e.gateActive)return{editable:!0,showWall:!1,showTrialBanner:!1,trialDaysRemaining:null,statusLabel:``};if(e.status===`restricted`)return{editable:!1,showWall:!0,showTrialBanner:!1,trialDaysRemaining:null,statusLabel:`Trial ended`};if(e.status===`trial`){let t=B_(e);return{editable:!0,showWall:!1,showTrialBanner:!0,trialDaysRemaining:t,statusLabel:t==null?`Trial`:`Trial — ${t} day${t===1?``:`s`} left`}}return{editable:!0,showWall:!1,showTrialBanner:!1,trialDaysRemaining:null,statusLabel:e.license?.name?`Licensed to ${e.license.name}`:`Licensed`}}async function H_(e){let t=await fetch(`${Il}${Lc}`,{signal:e});if(!t.ok)throw Error(`${Lc} responded ${t.status} ${t.statusText}`);return await t.json()}async function U_(e){try{let t=await fetch(`${Il}${Rc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({license:e})}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,state:n}:{ok:!1,error:n.message??`Activation failed.`}}catch{return{ok:!1,error:`Server unavailable.`}}}var W_=6e4;function G_(){let e=j(null),t=A(()=>V_(z(e))),n=!1,r=null,i=null,a=null;function o(e){return e.gateActive&&e.status===`restricted`}function s(e){a!==null&&e!==a&&i?.(),a=e}function c(){r&&=(clearInterval(r),null),n=!1,i=null,a=null}async function l(){try{let t=await H_();M(e,t,!0),s(o(t)),t.gateActive||c()}catch{}}return{get status(){return z(e)},get ui(){return z(t)},start(e){n||(n=!0,i=e?.onTransition??null,l(),r=setInterval(()=>void l(),W_))},stop:c,refresh(){return l()},set(t){M(e,t,!0),s(o(t))}}}var K_=G_(),q_=V(`<strong data-testid="license-trial-days" class="svelte-ae26fd"> </strong> `,1),J_=V(`<div class="license-trial-banner svelte-ae26fd" role="status" aria-live="polite" data-testid="license-trial-banner"><span class="license-trial-banner__text svelte-ae26fd"><!> Activate a license in Settings → License to keep editing when it ends.</span></div>`);function Y_(e,t){O(t,!0);let n=A(()=>K_.ui);var r=Xr(),i=F(r),a=e=>{var t=J_(),r=P(t),i=P(r),a=e=>{var t=q_(),r=F(t),i=P(r,!0);E(r);var a=I(r);R(()=>{U(i,z(n).trialDaysRemaining),U(a,` ${z(n).trialDaysRemaining===1?`day`:`days`} left in your Tandem trial.`)}),H(e,t)},o=e=>{H(e,Yr(`You're trying Tandem.`))};W(i,e=>{z(n).trialDaysRemaining==null?e(o,-1):e(a)}),D(),E(r),E(t),H(e,t)};W(i,e=>{z(n).showTrialBanner&&e(a)}),H(e,r),k()}var X_=V(`<div class="license-activate__error svelte-1yvc9ue" data-testid="license-activate-error" role="alert"> </div>`),Z_=V(`<div class="license-activate svelte-1yvc9ue"><textarea data-testid="license-activate-input" class="license-activate__input svelte-1yvc9ue" placeholder="Paste your license key" spellcheck="false"></textarea> <!> <button type="button" class="license-activate__submit svelte-1yvc9ue" data-testid="license-activate-submit"> </button></div>`);function Q_(e,t){O(t,!0);let n=j(``),r=j(null),i=j(!1);async function a(){let e=z(n).trim();if(!e){M(r,`Paste your license key first.`);return}M(i,!0),M(r,null);let a=await U_(e);M(i,!1),a.ok?(K_.set(a.state),M(n,``),t.onActivated?.()):M(r,a.error,!0)}var o=Z_(),s=P(o);En(s),K(s,`rows`,4);var c=I(s,2),l=e=>{var t=X_(),n=P(t,!0);E(t),R(()=>U(n,z(r))),H(e,t)};W(c,e=>{z(r)&&e(l)});var u=I(c,2),d=P(u,!0);E(u),E(o),R(()=>{s.disabled=z(i),u.disabled=z(i),U(d,z(i)?`Activating…`:`Activate license`)}),aa(s,()=>z(n),e=>M(n,e)),B(`click`,u,()=>void a()),H(e,o),k()}Br([`click`]);var $_=V(`<div class="license-wall-backdrop svelte-1or3b6b" data-testid="license-wall" role="dialog" aria-modal="true" aria-labelledby="license-wall-heading"><div class="license-wall-dialog svelte-1or3b6b"><h2 class="license-wall-heading svelte-1or3b6b" id="license-wall-heading">Your trial has ended</h2> <p class="license-wall-body svelte-1or3b6b">Activate a license to keep editing. Your documents stay open — you can still read and
75
+ export them, and chat with Claude.</p> <!></div></div>`);function ev(e,t){O(t,!0);let n=A(()=>K_.ui);var r=Xr(),i=F(r),a=e=>{var t=$_(),n=P(t);Q_(I(P(n),4),{}),E(n),E(t),H(e,t)};W(i,e=>{z(n).showWall&&e(a)}),H(e,r),k()}var tv=e=>e;function nv(e,{delay:t=0,duration:n=400,easing:r=tv}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}var rv=null;function iv(e){let t=e.decorationsMuted;try{localStorage.setItem(no,String(!t&&e.showAuthorship)),localStorage.setItem(ro,JSON.stringify({comment:!t&&e.showComments,highlight:!t&&e.showHighlights,note:!t&&e.showNotes}))}catch{}}function av(){if(rv)return rv;let e=Nl(),t=j(N(e));return iv(e),rv={get settings(){return z(t)},updateSettings:e=>{if(z(t)._readOnly)return;let n=Pl(z(t),e);try{localStorage.setItem(Na,JSON.stringify(n))}catch{}iv(n),M(t,n,!0)}},rv}function ov(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i,p=e=>{let t=e;for(let n=0;n<8;n++){let n=u(t)-e;if(Math.abs(n)<1e-5)return t;let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;t=e;for(let i=0;i<20;i++){let i=u(t)-e;if(Math.abs(i)<1e-5)break;i>0?r=t:n=t,t=(n+r)/2}return t};return e=>e<=0?0:e>=1?1:d(p(e))}var sv=ov(.2,.8,.2,1),cv=ov(.4,0,.2,1),lv=260,uv=260,dv=280;function fv(e){return e?!0:typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function pv(e){return{h:e.offsetHeight,mb:Number.parseFloat(getComputedStyle(e).marginBottom)||0}}function mv(e,{enabled:t,reduceMotion:n}){if(!t||fv(n))return{duration:0};let{h:r,mb:i}=pv(e);return{duration:lv,easing:sv,css:(e,t)=>`opacity:${e}; transform:translateY(${-6*t}px); height:${e*r}px; margin-bottom:${e*i}px; overflow:clip; box-sizing:border-box;`}}function hv(e,{enabled:t,reduceMotion:n,id:r,modes:i}){let a=i?.get(r);if(i?.delete(r),!t||fv(n))return{duration:0};let{h:o,mb:s}=pv(e),c=e=>a===`accept`?`translateY(${-8*e}px)`:a===`dismiss`?`translateX(${40*e}px) scale(${1-.04*e})`:`none`;return{duration:uv,easing:sv,css:(e,t)=>`opacity:${e}; height:${e*o}px; margin-bottom:${e*s}px; transform:${c(t)}; overflow:clip; box-sizing:border-box;`}}function gv(e,{reduceMotion:t}){if(fv(t))return{duration:0};let{h:n,mb:r}=pv(e);return{duration:dv,easing:sv,css:(e,t)=>`opacity:${e}; transform:translateY(${-8*t}px); height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box;`}}function _v(e,{reduceMotion:t,exitMs:n=200}){if(fv(t))return{duration:0};let{h:r,mb:i}=pv(e);return{duration:n,easing:cv,css:(e,t)=>`opacity:${e}; transform:translateY(${-8*t}px); height:${e*r}px; margin-bottom:${e*i}px; overflow:clip; box-sizing:border-box;`}}var vv=new Map,yv=480,bv=1e3;function xv(e,t){vv.set(e,t),setTimeout(()=>vv.delete(e),bv)}function Sv(e,{id:t,reduceMotion:n}){let r=vv.get(t);if(vv.delete(t),!r||fv(n))return{duration:0};let i=e.getBoundingClientRect(),a=r.left-i.left,o=r.top-i.top;return{duration:yv,easing:sv,css:(e,t)=>`transform:translate(${a*t}px, ${o*t}px); opacity:${.2+.8*e};`}}var Cv=200;function wv(e,{reduceMotion:t}){if(fv(t))return{duration:0};let n=e.offsetWidth;return{duration:Cv,easing:sv,css:e=>`opacity:${e}; width:${e*n}px; min-width:0; overflow:clip; box-sizing:border-box; pointer-events:none;`}}var Tv=220;function Ev(e,{reduceMotion:t}){if(fv(t))return{duration:0};let n=e.offsetWidth;return{duration:Tv,easing:sv,css:e=>`opacity:${e}; width:${e*n}px; min-width:0; overflow:clip; box-sizing:border-box;`}}function Dv(e,{reduceMotion:t}){if(fv(t))return{duration:0};let n=e.offsetWidth,r=e.offsetHeight;return{duration:440,easing:sv,css:e=>`opacity:${e}; width:${e*n}px; height:${e*r}px; overflow:clip; box-sizing:border-box;`}}var Ov=380;function kv(e,{reduceMotion:t}){if(fv(t))return{duration:0};let{h:n,mb:r}=pv(e);return{duration:Ov,easing:sv,css:e=>`opacity:${e}; height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box;`}}var Av=V(`Detected VM subnet: <code> </code>.`,1),jv=V(`<div class="cos-error svelte-1h0desi" data-testid="cowork-onboarding-error" role="alert"> </div>`),Mv=V(`<div class="cos-confirm-banner svelte-1h0desi" data-testid="cowork-onboarding-confirm"><div class="cos-confirm-heading svelte-1h0desi">Confirm: Enable Cowork</div> <div class="cos-confirm-body svelte-1h0desi">Tandem will register itself as a plugin in every detected Cowork workspace so Claude in
76
+ Cowork can reach your open documents. This adds a Windows firewall rule so the Cowork VM
77
+ can connect back — admin is required once. To check it worked afterward, ask Claude in a
78
+ Cowork session to open or list your documents.</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>`),Nv=V(`<button data-testid="cowork-onboarding-learn-more-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Learn more</button>`),Pv=V(`<a class="cos-learn-more-link svelte-1h0desi" data-testid="cowork-onboarding-learn-more-link" target="_blank" rel="noreferrer">Learn more</a>`),Fv=V(`<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>`),Iv=V(`<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 Lv(e,t){O(t,!0);let n=j(!1),r=j(!1),i=j(null);async function a(e,t){M(r,!0),M(i,null);try{return await e(await Um()),!0}catch(e){return M(i,`${t}: ${Am(e instanceof Error?e.message:String(e))}`),!1}finally{M(r,!1)}}async function o(){await a(async e=>{await Gm(e,!0)},`Failed to enable Cowork`)&&t.onAdvance()}function s(){zm(),t.onAdvance()}var c=Iv(),l=I(P(c),2),u=I(P(l)),d=e=>{var n=Av(),r=I(F(n)),i=P(r,!0);E(r),D(),R(()=>U(i,t.status.vethernetCidr)),H(e,n)};W(u,e=>{t.status.vethernetCidr!==null&&e(d)}),E(l);var f=I(l,2),p=e=>{var t=jv(),n=P(t,!0);E(t),R(()=>U(n,z(i))),H(e,t)};W(f,e=>{z(i)&&e(p)});var m=I(f,2),h=e=>{var t=Mv(),i=I(P(t),4),a=P(i),s=I(a,2);E(i),E(t),R(()=>{a.disabled=z(r),s.disabled=z(r)}),B(`click`,a,()=>void o()),B(`click`,s,()=>{M(n,!1)}),H(e,t)},g=e=>{var i=Fv(),a=P(i),o=I(a,2),c=I(o,2),l=e=>{var n=Nv();R(()=>n.disabled=z(r)),B(`click`,n,function(...e){t.onLearnMore?.apply(this,e)}),H(e,n)},u=e=>{var t=Pv();R(()=>K(t,`href`,`${Sa}#cowork`)),H(e,t)};W(c,e=>{t.onLearnMore?e(l):e(u,-1)}),E(i),R(()=>{a.disabled=z(r),o.disabled=z(r)}),B(`click`,a,()=>{M(n,!0)}),B(`click`,o,s),H(e,i)};W(m,e=>{z(n)?e(h):e(g,-1)}),E(c),H(e,c),k()}Br([`click`]);var Rv=V(`<div></div>`),zv=V(`<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);" class="svelte-1us4jmd"></div>`),Bv=V(`<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),Vv=V(`<div class="svelte-1us4jmd"><!></div>`),Hv=V(`<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>`),Uv=V(`<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 Wv(e,t){O(t,!0);let n=av(),r=A(()=>fv(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.`}],a=Bm(),o=Rm(),s=A(()=>a&&Lm(t.coworkStatus,o)),c=A(()=>i.filter(e=>e.id!==`cowork`||z(s))),l=A(()=>z(c).length-1),u=A(()=>z(c)[t.currentStep]),d=A(()=>t.currentStep>=z(l)),f=A(()=>z(u)?.id===`cowork`);var p=Xr(),m=F(p),h=e=>{var n=Uv(),i=P(n),a=e=>{var n=zv();pi(n,20,()=>Array.from({length:z(l)},(e,t)=>t),e=>e,(e,n)=>{var r=Rv();let i;R(()=>{i=Ui(r,1,`tut-dot svelte-1us4jmd`,null,i,{"is-current":n===t.currentStep}),G(r,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${n<=t.currentStep?`var(--tandem-accent)`:`var(--tandem-border)`}; transition: background 0.2s;`)}),H(e,r)}),E(n),H(e,n)};W(i,e=>{z(d)||e(a)});var o=I(i,2);ci(o,()=>z(u).id,e=>{var n=Vv(),i=P(n),a=e=>{Lv(e,{get status(){return t.coworkStatus},get onAdvance(){return t.onNext}})},o=e=>{var t=Bv(),n=F(t),r=P(n,!0);E(n);var i=I(n,2),a=P(i,!0);E(i),R(()=>{U(r,z(u).title),G(i,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${z(d)?0:14}px;`),U(a,z(u).text)}),H(e,t)};W(i,e=>{z(f)&&t.coworkStatus!==null?e(a):e(o,-1)}),E(n),Mi(1,n,()=>nv,()=>({duration:z(r)})),H(e,n)});var s=I(o,2),c=e=>{var n=Hv(),r=P(n),i=P(r);E(r);var a=I(r,2),o=P(a),s=I(o,2),c=P(s,!0);E(s),E(a),E(n),R(()=>{U(i,`Step ${t.currentStep+1} of ${z(l)??``}`),U(c,t.currentStep===z(l)-1?`Done`:`Next`)}),B(`click`,o,function(...e){t.onDismiss?.apply(this,e)}),B(`click`,s,function(...e){t.onNext?.apply(this,e)}),H(e,n)};W(s,e=>{!z(d)&&!z(f)&&e(c)}),E(n),H(e,n)};W(m,e=>{z(u)&&e(h)}),H(e,p),k()}Br([`click`]);var Gv=()=>new Map,Kv=e=>{let t=Gv();return e.forEach((e,n)=>{t.set(n,e)}),t},qv=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Jv=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Yv=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},Xv=()=>new Set,Zv=e=>e[e.length-1],Qv=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},$v=Array.from,ey=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},ty=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},ny=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},ry=Array.isArray,iy=class{constructor(){this._observers=Gv()}on(e,t){return qv(this._observers,e,Xv).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return $v((this._observers.get(e)||Gv()).values()).forEach(e=>e(...t))}destroy(){this._observers=Gv()}},ay=Math.floor,oy=Math.abs,sy=(e,t)=>e<t?e:t,cy=(e,t)=>e>t?e:t;Number.isNaN;var ly=e=>e===0?1/e<0:e<0,uy=1<<17,dy=1<<18,fy=1<<19,py=1<<20,my=1<<21,hy=1<<22,gy=1<<23,_y=1<<24,vy=1<<25,yy=1<<26,by=1<<27,xy=1<<28,Sy=1<<29;uy-1,dy-1,fy-1,py-1,my-1,hy-1,gy-1,_y-1,vy-1,yy-1,by-1,xy-1,Sy-1;var Cy=2**53-1,wy=-(2**53-1),Ty=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&ay(e)===e);Number.isNaN,Number.parseInt;var Ey=String.fromCharCode;String.fromCodePoint,Ey(65535);var Dy=e=>e.toLowerCase(),Oy=/^\s*/g,ky=e=>e.replace(Oy,``),Ay=/([A-Z])/g,jy=(e,t)=>ky(e.replace(Ay,e=>`${t}${Dy(e)}`)),My=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Ny=typeof TextEncoder<`u`?new TextEncoder:null,Py=Ny?e=>Ny.encode(e):My,Fy=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Fy&&Fy.decode(new Uint8Array).length===1&&(Fy=null);var Iy=(e,t)=>ny(t,()=>e).join(``),Ly=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Ry=()=>new Ly,zy=e=>{let t=Ry();return e(t),Vy(t)},By=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Vy=e=>{let t=new Uint8Array(By(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},Hy=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(cy(n,t)*2),e.cpos=0)},Uy=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Wy=Uy,Gy=(e,t)=>{for(;t>127;)Uy(e,128|127&t),t=ay(t/128);Uy(e,127&t)},Ky=(e,t)=>{let n=ly(t);for(n&&(t=-t),Uy(e,(t>63?128:0)|(n?64:0)|63&t),t=ay(t/64);t>0;)Uy(e,(t>127?128:0)|127&t),t=ay(t/128)},qy=new Uint8Array(3e4),Jy=qy.length/3,Yy=Ny&&Ny.encodeInto?(e,t)=>{if(t.length<Jy){let n=Ny.encodeInto(t,qy).written||0;Gy(e,n);for(let t=0;t<n;t++)Uy(e,qy[t])}else Zy(e,Py(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Gy(e,r);for(let t=0;t<r;t++)Uy(e,n.codePointAt(t))},Xy=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=sy(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(cy(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},Zy=(e,t)=>{Gy(e,t.byteLength),Xy(e,t)},Qy=(e,t)=>{Hy(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},$y=(e,t)=>Qy(e,4).setFloat32(0,t,!1),eb=(e,t)=>Qy(e,8).setFloat64(0,t,!1),tb=(e,t)=>Qy(e,8).setBigInt64(0,t,!1),nb=new DataView(new ArrayBuffer(4)),rb=e=>(nb.setFloat32(0,e),nb.getFloat32(0)===e),ib=(e,t)=>{switch(typeof t){case`string`:Uy(e,119),Yy(e,t);break;case`number`:Ty(t)&&oy(t)<=2147483647?(Uy(e,125),Ky(e,t)):rb(t)?(Uy(e,124),$y(e,t)):(Uy(e,123),eb(e,t));break;case`bigint`:Uy(e,122),tb(e,t);break;case`object`:if(t===null)Uy(e,126);else if(ry(t)){Uy(e,117),Gy(e,t.length);for(let n=0;n<t.length;n++)ib(e,t[n])}else if(t instanceof Uint8Array)Uy(e,116),Zy(e,t);else{Uy(e,118);let n=Object.keys(t);Gy(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];Yy(e,i),ib(e,t[i])}}break;case`boolean`:Uy(e,t?120:121);break;default:Uy(e,127)}},ab=class extends Ly{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Gy(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},ob=e=>{e.count>0&&(Ky(e.encoder,e.count===1?e.s:-e.s),e.count>1&&Gy(e.encoder,e.count-2))},sb=class{constructor(){this.encoder=new Ly,this.s=0,this.count=0}write(e){this.s===e?this.count++:(ob(this),this.count=1,this.s=e)}toUint8Array(){return ob(this),Vy(this.encoder)}},cb=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Ky(e.encoder,t),e.count>1&&Gy(e.encoder,e.count-2)}},lb=class{constructor(){this.encoder=new Ly,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(cb(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return cb(this),Vy(this.encoder)}},ub=class{constructor(){this.sarr=[],this.s=``,this.lensE=new sb}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Ly;return this.sarr.push(this.s),this.s=``,Yy(e,this.sarr.join(``)),Xy(e,this.lensE.toUint8Array()),Vy(e)}},db=e=>Error(e),fb=()=>{throw db(`Method unimplemented`)},pb=()=>{throw db(`Unexpected case`)},mb=db(`Unexpected end of array`),hb=db(`Integer out of Range`),gb=class{constructor(e){this.arr=e,this.pos=0}},_b=e=>new gb(e),vb=e=>e.pos!==e.arr.length,yb=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},bb=e=>yb(e,Sb(e)),xb=e=>e.arr[e.pos++],Sb=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Cy)throw hb}throw mb},Cb=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Cy)throw hb}throw mb},wb=Fy?e=>Fy.decode(bb(e)):e=>{let t=Sb(e);if(t===0)return``;{let n=String.fromCodePoint(xb(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(xb(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Tb=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Eb=[e=>void 0,e=>null,Cb,e=>Tb(e,4).getFloat32(0,!1),e=>Tb(e,8).getFloat64(0,!1),e=>Tb(e,8).getBigInt64(0,!1),e=>!1,e=>!0,wb,e=>{let t=Sb(e),n={};for(let r=0;r<t;r++){let t=wb(e);n[t]=Db(e)}return n},e=>{let t=Sb(e),n=[];for(let r=0;r<t;r++)n.push(Db(e));return n},bb],Db=e=>Eb[127-xb(e)](e),Ob=class extends gb{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),vb(this)?this.count=Sb(this)+1:this.count=-1),this.count--,this.s}},kb=class extends gb{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Cb(this);let e=ly(this.s);this.count=1,e&&(this.s=-this.s,this.count=Sb(this)+2)}return this.count--,this.s}},Ab=class extends gb{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Cb(this),t=e&1;this.diff=ay(e/2),this.count=1,t&&(this.count=Sb(this)+2)}return this.s+=this.diff,this.count--,this.s}},jb=class{constructor(e){this.decoder=new kb(e),this.str=wb(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var Mb=crypto.getRandomValues.bind(crypto),Nb=Math.random,Pb=()=>Mb(new Uint32Array(1))[0],Fb=e=>e[ay(Nb()*e.length)],Ib=`10000000-1000-4000-8000-100000000000`,Lb=()=>Ib.replace(/[018]/g,e=>(e^Pb()&15>>e/4).toString(16)),Rb=Date.now,zb=e=>new Promise(e);Promise.all.bind(Promise);var Bb=e=>e===void 0?null:e,Vb=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Vb=localStorage)}catch{}var Hb=Vb,Ub=Symbol(`Equality`),Wb=(e,t)=>e===t||!!e?.[Ub]?.(t)||!1,Gb=e=>typeof e==`object`,Kb=Object.assign,qb=Object.keys,Jb=(e,t)=>{for(let n in e)t(e[n],n)},Yb=e=>qb(e).length,Xb=e=>{for(let t in e)return!1;return!0},Zb=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Qb=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),$b=(e,t)=>e===t||Yb(e)===Yb(t)&&Zb(e,(e,n)=>(e!==void 0||Qb(t,n))&&Wb(t[n],e)),ex=Object.freeze,tx=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&tx(e[t])}return ex(e)},nx=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&nx(e,t,n+1)}},rx=e=>e,ix=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Ub]!=null)return e[Ub](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!ix(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Yb(e)!==Yb(t))return!1;for(let n in e)if(!Qb(e,n)||!ix(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!ix(e[n],t[n]))return!1;break;default:return!1}return!0},ax=(e,t)=>t.includes(e),ox=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,sx=typeof window<`u`&&typeof document<`u`&&!ox;typeof navigator<`u`&&/Mac/.test(navigator.platform);var cx,lx=[],ux=()=>{if(cx===void 0)if(ox){cx=Gv();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&cx.set(t,``),t=r):t===null?lx.push(r):(cx.set(t,r),t=null)}t!==null&&cx.set(t,``)}else typeof location==`object`?(cx=Gv(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);cx.set(`--${jy(t,`-`)}`,n),cx.set(`-${jy(t,`-`)}`,n)}})):cx=Gv();return cx},dx=e=>ux().has(e),fx=e=>Bb(ox?{}[e.toUpperCase().replaceAll(`-`,`_`)]:Hb.getItem(e)),px=e=>dx(`--`+e)||fx(e)!==null,mx=px(`production`),hx=ox&&ax({}.FORCE_COLOR,[`true`,`1`,`2`])||!dx(`--no-colors`)&&!px(`no-color`)&&(!ox||process.stdout.isTTY)&&(!ox||dx(`--color`)||fx(`COLORTERM`)!==null||(fx(`TERM`)||``).includes(`color`)),gx=e=>new Uint8Array(e),_x=sx?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Ey(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),vx=e=>{let t=gx(e.byteLength);return t.set(e),t},yx=e=>zy(t=>ib(t,e)),bx=class{constructor(e,t){this.left=e,this.right=t}},xx=(e,t)=>new bx(e,t),Sx=e=>e.next()>=.5,Cx=(e,t,n)=>ay(e.next()*(n+1-t)+t),wx=(e,t,n)=>ay(e.next()*(n+1-t)+t),Tx=(e,t,n)=>wx(e,t,n),Ex=e=>Ey(Tx(e,97,122)),Dx=(e,t=0,n=20)=>{let r=Tx(e,t,n),i=``;for(let t=0;t<r;t++)i+=Ex(e);return i},Ox=(e,t)=>t[Tx(e,0,t.length-1)],kx=Symbol(`0schema`),Ax=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Iy(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
79
+ `)}},jx=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Ub]?Wb(e,t):ry(e)?ey(e,e=>ty(t,t=>jx(e,t))):Gb(e)?Zb(e,(e,n)=>jx(e,t[n])):!1,Mx=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),jx(t,n)}equals(e){return this.constructor===e.constructor&&ix(this.shape,e.shape)}[kx](){return!0}[Ub](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){fb()}get nullable(){return dS(this,ES)}get optional(){return new Ux(this)}cast(e){return AS(e,this),e}expect(e){return AS(e,this),e}},Nx=class extends Mx{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},Px=(e,t=null)=>new Nx(e,t);Px(Nx);var Fx=class extends Mx{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Ix=e=>new Fx(e);Px(Fx);var Lx=class extends Mx{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},Rx=(...e)=>new Lx(e),zx=Px(Lx),Bx=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Vx=e=>{if(xS.check(e))return[Bx(e)];if(zx.check(e))return e.shape.map(e=>e+``);if(bS.check(e))return[`[+-]?\\d+.?\\d*`];if(SS.check(e))return[`.*`];if(fS.check(e))return e.shape.map(Vx).flat(1);pb()};Px(class extends Mx{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Vx).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Hx=Symbol(`optional`),Ux=class extends Mx{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Hx](){return!0}},Wx=Px(Ux),Gx=class extends Mx{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Gx,Px(Gx);var Kx=class e extends Mx{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):Zb(this.shape,(n,r)=>{let i=this._isPartial&&!Qb(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},qx=e=>new Kx(e),Jx=Px(Kx),Yx=Ix(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Xx=class extends Mx{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Zb(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Zx=(e,t)=>new Xx(e,t),Qx=Px(Xx),$x=class extends Mx{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Zb(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},eS=(...e)=>new $x(e);Px($x);var tS=class extends Mx{constructor(e){super(),this.shape=e.length===1?e[0]:new uS(e)}check(e,t){let n=ry(e)&&ey(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},nS=(...e)=>new tS(e),rS=Px(tS),iS=Ix(e=>ry(e)),aS=class extends Mx{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},oS=(e,t=null)=>new aS(e,t);Px(aS);var sS=oS(Mx),cS=Px(class extends Mx{constructor(e){super(),this.len=e.length-1,this.args=eS(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),lS=Ix(e=>typeof e==`function`);Px(class extends Mx{constructor(e){super(),this.shape=e}check(e,t){let n=ey(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var uS=class extends Mx{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=ty(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},dS=(...e)=>e.findIndex(e=>fS.check(e))>=0?dS(...e.map(e=>kS(e)).map(e=>fS.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new uS(e),fS=Px(uS),pS=()=>!0,mS=Ix(pS),hS=Px(Fx,e=>e.shape===pS),gS=Ix(e=>typeof e==`bigint`),_S=Ix(e=>e===gS),vS=Ix(e=>typeof e==`symbol`);Ix(e=>e===vS);var yS=Ix(e=>typeof e==`number`),bS=Ix(e=>e===yS),xS=Ix(e=>typeof e==`string`),SS=Ix(e=>e===xS),CS=Ix(e=>typeof e==`boolean`),wS=Ix(e=>e===CS),TS=Rx(void 0);Px(Lx,e=>e.shape.length===1&&e.shape[0]===void 0),Rx(void 0);var ES=Rx(null),DS=Px(Lx,e=>e.shape.length===1&&e.shape[0]===null);Px(Uint8Array),Px(Nx,e=>e.shape===Uint8Array);var OS=dS(yS,xS,ES,TS,gS,CS,vS);(()=>{let e=nS(mS),t=Zx(xS,mS),n=dS(yS,xS,ES,CS,e,t);return e.shape=n,t.shape.values=n,n})();var kS=e=>{if(sS.check(e))return e;if(Yx.check(e)){let t={};for(let n in e)t[n]=kS(e[n]);return qx(t)}else if(iS.check(e))return dS(...e.map(kS));else if(OS.check(e))return Rx(e);else if(lS.check(e))return Px(e);pb()},AS=mx?()=>{}:(e,t)=>{let n=new Ax;if(!t.check(e,n))throw db(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},jS=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:kS(e),h:t}),this}else(e){return this.if(mS,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw db(`Unhandled pattern`)}}},MS=(e=>new jS(e))(mS).if(bS,(e,t)=>Cx(t,wy,Cy)).if(SS,(e,t)=>Dx(t)).if(wS,(e,t)=>Sx(t)).if(_S,(e,t)=>BigInt(Cx(t,wy,Cy))).if(fS,(e,t)=>NS(t,Ox(t,e.shape))).if(Jx,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Wx.check(i)){if(Sx(t))continue;i=i.shape}n[r]=MS(i,t)}return n}).if(rS,(e,t)=>{let n=[],r=wx(t,0,42);for(let i=0;i<r;i++)n.push(NS(t,e.shape));return n}).if(zx,(e,t)=>Ox(t,e.shape)).if(DS,(e,t)=>null).if(cS,(e,t)=>{let n=NS(t,e.res);return()=>n}).if(hS,(e,t)=>NS(t,Ox(t,[yS,xS,ES,TS,gS,CS,nS(yS),Zx(dS(`a`,`b`,`c`),yS)]))).if(Qx,(e,t)=>{let n={},r=Cx(t,0,3);for(let i=0;i<r;i++){let r=NS(t,e.shape.keys);n[r]=NS(t,e.shape.values)}return n}).done(),NS=(e,t)=>MS(kS(t),e),PS=typeof document<`u`?document:{};Ix(e=>e.nodeType===zS),typeof DOMParser<`u`&&new DOMParser,Ix(e=>e.nodeType===IS),Ix(e=>e.nodeType===LS);var FS=e=>Jv(e,(e,t)=>`${t}:${e};`).join(``),IS=PS.ELEMENT_NODE,LS=PS.TEXT_NODE;PS.CDATA_SECTION_NODE,PS.COMMENT_NODE;var RS=PS.DOCUMENT_NODE;PS.DOCUMENT_TYPE_NODE;var zS=PS.DOCUMENT_FRAGMENT_NODE;Ix(e=>e.nodeType===RS);var BS=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),VS=(e,t)=>new BS(setTimeout(t,e)),HS=Symbol,US=HS(),WS=HS(),GS=HS(),KS=HS(),qS=HS(),JS=HS(),YS=HS(),XS=HS(),ZS=HS(),QS=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Rb();var $S={[US]:xx(`font-weight`,`bold`),[WS]:xx(`font-weight`,`normal`),[GS]:xx(`color`,`blue`),[qS]:xx(`color`,`green`),[KS]:xx(`color`,`grey`),[JS]:xx(`color`,`red`),[YS]:xx(`color`,`purple`),[XS]:xx(`color`,`orange`),[ZS]:xx(`color`,`black`)},eC=hx?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=Gv(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=$S[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=FS(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:QS,tC=(...e)=>{console.log(...eC(e)),rC.forEach(t=>t.print(e))},nC=(...e)=>{console.warn(...eC(e)),e.unshift(XS),rC.forEach(t=>t.print(e))},rC=Xv(),iC=e=>({[Symbol.iterator](){return this},next:e}),aC=(e,t)=>iC(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),oC=(e,t)=>iC(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),sC=class{constructor(e,t){this.clock=e,this.len=t}},cC=class{constructor(){this.clients=new Map}},lC=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Dw(e,i,o.clock,o.len,n)}}),uC=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=ay((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},dC=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&uC(n,t.clock)!==null},fC=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new sC(r.clock,cy(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},pC=e=>{let t=new cC;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)Qv(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return fC(t),t},mC=(e,t,n,r)=>{qv(e.clients,t,()=>[]).push(new sC(n,r))},hC=()=>new cC,gC=e=>{let t=hC();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new sC(i,a))}}r.length>0&&t.clients.set(n,r)}),t},_C=(e,t)=>{Gy(e.restEncoder,t.clients.size),$v(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),Gy(e.restEncoder,t);let r=n.length;Gy(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},vC=e=>{let t=new cC,n=Sb(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=Sb(e.restDecoder),r=Sb(e.restDecoder);if(r>0){let i=qv(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new sC(e.readDsClock(),e.readDsLen()))}}return t},yC=(e,t,n)=>{let r=new cC,i=Sb(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=Sb(e.restDecoder),a=Sb(e.restDecoder),o=n.clients.get(i)||[],s=yw(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&mC(r,i,s,a-s);let e=xw(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,WE(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,WE(t,c,a-c.id.clock)),c.delete(t))}else mC(r,i,n,a-n)}}if(r.clients.size>0){let e=new kC;return Gy(e.restEncoder,0),_C(e,r),e.toUint8Array()}return null},bC=Pb,xC=class e extends iy{constructor({guid:e=Lb(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=bC(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new _w,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=zb(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>zb(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&Fw(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set($v(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Fw(this,e,t)}get(e,t=dT){let n=qv(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==dT&&r!==t)if(r===dT){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,MT)}getText(e=``){return this.get(e,$T)}getMap(e=``){return this.get(e,FT)}getXmlElement(e=``){return this.get(e,iE)}getXmlFragment(e=``){return this.get(e,nE)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,$v(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,Fw(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},SC=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Sb(this.restDecoder)}readDsLen(){return Sb(this.restDecoder)}},CC=class extends SC{readLeftID(){return ew(Sb(this.restDecoder),Sb(this.restDecoder))}readRightID(){return ew(Sb(this.restDecoder),Sb(this.restDecoder))}readClient(){return Sb(this.restDecoder)}readInfo(){return xb(this.restDecoder)}readString(){return wb(this.restDecoder)}readParentInfo(){return Sb(this.restDecoder)===1}readTypeRef(){return Sb(this.restDecoder)}readLen(){return Sb(this.restDecoder)}readAny(){return Db(this.restDecoder)}readBuf(){return vx(bb(this.restDecoder))}readJSON(){return JSON.parse(wb(this.restDecoder))}readKey(){return wb(this.restDecoder)}},wC=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Sb(this.restDecoder),this.dsCurrVal}readDsLen(){let e=Sb(this.restDecoder)+1;return this.dsCurrVal+=e,e}},TC=class extends wC{constructor(e){super(e),this.keys=[],Sb(e),this.keyClockDecoder=new Ab(bb(e)),this.clientDecoder=new kb(bb(e)),this.leftClockDecoder=new Ab(bb(e)),this.rightClockDecoder=new Ab(bb(e)),this.infoDecoder=new Ob(bb(e),xb),this.stringDecoder=new jb(bb(e)),this.parentInfoDecoder=new Ob(bb(e),xb),this.typeRefDecoder=new kb(bb(e)),this.lenDecoder=new kb(bb(e))}readLeftID(){return new QC(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new QC(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 Db(this.restDecoder)}readBuf(){return bb(this.restDecoder)}readJSON(){return Db(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},EC=class{constructor(){this.restEncoder=Ry()}toUint8Array(){return Vy(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Gy(this.restEncoder,e)}writeDsLen(e){Gy(this.restEncoder,e)}},DC=class extends EC{writeLeftID(e){Gy(this.restEncoder,e.client),Gy(this.restEncoder,e.clock)}writeRightID(e){Gy(this.restEncoder,e.client),Gy(this.restEncoder,e.clock)}writeClient(e){Gy(this.restEncoder,e)}writeInfo(e){Wy(this.restEncoder,e)}writeString(e){Yy(this.restEncoder,e)}writeParentInfo(e){Gy(this.restEncoder,+!!e)}writeTypeRef(e){Gy(this.restEncoder,e)}writeLen(e){Gy(this.restEncoder,e)}writeAny(e){ib(this.restEncoder,e)}writeBuf(e){Zy(this.restEncoder,e)}writeJSON(e){Yy(this.restEncoder,JSON.stringify(e))}writeKey(e){Yy(this.restEncoder,e)}},OC=class{constructor(){this.restEncoder=Ry(),this.dsCurrVal=0}toUint8Array(){return Vy(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,Gy(this.restEncoder,t)}writeDsLen(e){e===0&&pb(),Gy(this.restEncoder,e-1),this.dsCurrVal+=e}},kC=class extends OC{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new lb,this.clientEncoder=new sb,this.leftClockEncoder=new lb,this.rightClockEncoder=new lb,this.infoEncoder=new ab(Wy),this.stringEncoder=new ub,this.parentInfoEncoder=new ab(Wy),this.typeRefEncoder=new sb,this.lenEncoder=new sb}toUint8Array(){let e=Ry();return Gy(e,0),Zy(e,this.keyClockEncoder.toUint8Array()),Zy(e,this.clientEncoder.toUint8Array()),Zy(e,this.leftClockEncoder.toUint8Array()),Zy(e,this.rightClockEncoder.toUint8Array()),Zy(e,Vy(this.infoEncoder)),Zy(e,this.stringEncoder.toUint8Array()),Zy(e,Vy(this.parentInfoEncoder)),Zy(e,this.typeRefEncoder.toUint8Array()),Zy(e,this.lenEncoder.toUint8Array()),Xy(e,Vy(this.restEncoder)),Vy(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){ib(this.restEncoder,e)}writeBuf(e){Zy(this.restEncoder,e)}writeJSON(e){ib(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},AC=(e,t,n,r)=>{r=cy(r,t[0].id.clock);let i=xw(t,r);Gy(e.restEncoder,t.length-i),e.writeClient(n),Gy(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},jC=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{yw(t,n)>e&&r.set(n,e)}),vw(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),Gy(e.restEncoder,r.size),$v(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{AC(e,t.clients.get(n),n,r)})},MC=(e,t)=>{let n=Gv(),r=Sb(e.restDecoder);for(let i=0;i<r;i++){let r=Sb(e.restDecoder),i=Array(r),a=e.readClient(),o=Sb(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new pE(ew(a,o),t),o+=t;break}case 10:{let t=Sb(e.restDecoder);i[n]=new ZE(ew(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new qE(ew(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,JE(e,r));i[n]=c,o+=c.length}}}}return n},NC=(e,t,n)=>{let r=[],i=$v(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new _w,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==ZE){let i=qv(d,u.id.client,()=>yw(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,yw(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new kC;return jC(e,s,new Map),Gy(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},PC=(e,t)=>jC(e,t.doc.store,t.beforeState),FC=(e,t,n,r=new TC(e))=>Fw(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=NC(e,i,MC(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<yw(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=Gw([o.update,a.update])}}else i.pendingStructs=a;let s=yC(r,e,i);if(i.pendingDs){let t=new TC(_b(i.pendingDs));Sb(t.restDecoder);let n=yC(t,e,i);s&&n?i.pendingDs=Gw([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,IC(e.doc,t)}},n,!1),IC=(e,t,n,r=TC)=>{let i=_b(t);FC(i,e,n,new r(i))},LC=(e,t,n)=>IC(e,t,n,CC),RC=(e,t,n=new Map)=>{jC(e,t.store,n),_C(e,gC(t.store))},zC=(e,t=new Uint8Array([0]),n=new kC)=>{RC(n,e,HC(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Kw(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===DC)return Uw(r.map((e,t)=>t===0?e:Zw(e)));if(n.constructor===kC)return Gw(r)}return r[0]},BC=(e,t)=>zC(e,t,new DC),VC=e=>{let t=new Map,n=Sb(e.restDecoder);for(let r=0;r<n;r++){let n=Sb(e.restDecoder),r=Sb(e.restDecoder);t.set(n,r)}return t},HC=e=>VC(new SC(_b(e))),UC=(e,t)=>(Gy(e.restEncoder,t.size),$v(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{Gy(e.restEncoder,t),Gy(e.restEncoder,n)}),e),WC=(e,t)=>UC(e,vw(t.store)),GC=(e,t=new OC)=>(e instanceof Map?UC(t,e):WC(t,e),t.toUint8Array()),KC=e=>GC(e,new EC),qC=class{constructor(){this.l=[]}},JC=()=>new qC,YC=(e,t)=>e.l.push(t),XC=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},ZC=(e,t,n)=>nx(e.l,[t,n]),QC=class{constructor(e,t){this.client=e,this.clock=t}},$C=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,ew=(e,t)=>new QC(e,t),tw=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw pb()},nw=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},rw=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},iw=e=>new rw(e.type==null?null:ew(e.type.client,e.type.clock),e.tname??null,e.item==null?null:ew(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),aw=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},ow=(e,t,n=0)=>new aw(e,t,n),sw=(e,t,n)=>{let r=null,i=null;return e._item===null?i=tw(e):r=ew(e._item.id.client,e._item.id.clock),new rw(r,i,t,n)},cw=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return sw(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return sw(e,ew(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return sw(e,r.lastId,n);r=r.right}return sw(e,null,n)},lw=(e,t)=>{let n=Sw(e,t);return{item:n,diff:t.clock-n.id.clock}},uw=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(yw(r,i.client)<=i.clock)return null;let e=n?HE(r,i):lw(r,i),t=e.item;if(!(t instanceof qE))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(yw(r,a.client)<=a.clock)return null;let{item:e}=n?HE(r,a):{item:Sw(r,a)};if(e instanceof qE&&e.content instanceof BE)c=e.content.type;else return null}else throw pb();l=s>=0?c._length:0}return ow(c,l,e.assoc)},dw=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&$C(e.item,t.item)&&$C(e.type,t.type)&&e.assoc===t.assoc,fw=class{constructor(e,t){this.ds=e,this.sv=t}},pw=(e,t)=>new fw(e,t);pw(hC(),new Map);var mw=e=>pw(gC(e.store),vw(e.store)),hw=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!dC(t.ds,e.id),gw=(e,t)=>{let n=qv(e.meta,gw,Xv),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<yw(r,n)&&ww(e,ew(n,t))}),lC(e,t.ds,e=>{}),n.add(t))},_w=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},vw=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},yw=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},bw=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw pb()}n.push(t)},xw=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=ay(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=ay((n+r)/2)}throw pb()},Sw=(e,t)=>{let n=e.clients.get(t.client);return n[xw(n,t.clock)]},Cw=(e,t,n)=>{let r=xw(t,n),i=t[r];return i.id.clock<n&&i instanceof qE?(t.splice(r+1,0,WE(e,i,n-i.id.clock)),r+1):r},ww=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Cw(e,n,t.clock)]},Tw=(e,t,n)=>{let r=t.clients.get(n.client),i=xw(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==pE&&r.splice(i+1,0,WE(e,a,n.clock-a.id.clock+1)),a},Ew=(e,t,n)=>{let r=e.clients.get(t.id.client);r[xw(r,t.id.clock)]=n},Dw=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Cw(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Cw(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Ow=class{constructor(e,t,n){this.doc=e,this.deleteSet=new cC,this.beforeState=vw(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},kw=(e,t)=>t.deleteSet.clients.size===0&&!Yv(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(fC(t.deleteSet),PC(e,t),_C(e,t.deleteSet),!0),Aw=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&qv(e.changed,t,Xv).add(n)},jw=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof qE&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Mw=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=xw(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof qE&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Nw=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=sy(r.length-1,1+xw(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+jw(r,e)}})},Pw=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{fC(a),n.afterState=vw(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{ZC(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&XT(n)})}),nx(e,[])}finally{r.gc&&Mw(a,i,r.gcFilter),Nw(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=cy(xw(e,r),1);for(let t=e.length-1;t>=n;)t-=1+jw(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=xw(r,n);a+1<r.length&&jw(r,a+1)>1||a>0&&jw(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(tC(XS,US,`[yjs] `,WS,JS,`Changed the client-id because another client seems to be using it.`),r.clientID=bC()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new DC;kw(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new kC;kw(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Pw(e,t+1)}}},Fw=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Ow(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Pw(i,0)}}return o},Iw=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Lw=(e,t,n)=>{lC(e,n.deletions,n=>{n instanceof qE&&t.scope.some(t=>t===e.doc||nw(t,n))&&UE(n,!1)})},Rw=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;Fw(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;lC(n,o.insertions,e=>{if(e instanceof qE){if(e.redone!==null){let{item:t,diff:i}=HE(r,e.id);i>0&&(t=ww(n,ew(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||nw(t,e))&&c.push(e)}}),lC(n,o.deletions,e=>{e instanceof qE&&a.some(t=>t===n.doc||nw(t,e))&&!dC(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=KE(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},zw=class extends iy{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=ry(e)?e[0].doc:e instanceof xC?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new cC;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&mC(i,n,r,a)});let a=Rb(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=pC([t.deletions,e.deleteSet]),t.insertions=pC([t.insertions,i])}else r.push(new Iw(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),lC(e,e.deleteSet,t=>{t instanceof qE&&this.scope.some(n=>n===e.doc||nw(n,t))&&UE(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=ry(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof dT?e.doc!==this.doc:e!==this.doc)&&nC(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Lw(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Lw(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Rw(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Rw(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*Bw(e){let t=Sb(e.restDecoder);for(let n=0;n<t;n++){let t=Sb(e.restDecoder),n=e.readClient(),r=Sb(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=Sb(e.restDecoder);yield new ZE(ew(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new qE(ew(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,JE(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new pE(ew(n,r),t),r+=t}}}}var Vw=class{constructor(e,t){this.gen=Bw(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===ZE);return this.curr}},Hw=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Uw=e=>Gw(e,CC,DC),Ww=(e,t)=>{if(e.constructor===pE){let{client:n,clock:r}=e.id;return new pE(ew(n,r+t),e.length-t)}else if(e.constructor===ZE){let{client:n,clock:r}=e.id;return new ZE(ew(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new qE(ew(r,i+t),null,ew(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Gw=(e,t=TC,n=kC)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(_b(e))),i=r.map(e=>new Vw(e,!0)),a=null,o=new n,s=new Hw(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===ZE?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Jw(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===ZE)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Jw(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new ZE(ew(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===ZE?a.struct.length-=t:n=Ww(n,t)),a.struct.mergeWith(n)||(Jw(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==ZE;n=e.next())Jw(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Jw(s,a.struct,a.offset),a=null),Yw(s),_C(o,pC(r.map(e=>vC(e)))),o.toUint8Array()},Kw=(e,t,n=TC,r=kC)=>{let i=HC(t),a=new r,o=new Hw(a),s=new n(_b(e)),c=new Vw(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===ZE){c.next();continue}if(e.id.clock+e.length>n)for(Jw(o,e,cy(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Jw(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return Yw(o),_C(a,vC(s)),a.toUint8Array()},qw=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Vy(e.encoder.restEncoder)}),e.encoder.restEncoder=Ry(),e.written=0)},Jw=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&qw(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Gy(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Yw=e=>{qw(e);let t=e.encoder.restEncoder;Gy(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];Gy(t,r.written),Xy(t,r.restEncoder)}},Xw=(e,t,n,r)=>{let i=new n(_b(e)),a=new Vw(i,!1),o=new r,s=new Hw(o);for(let e=a.curr;e!==null;e=a.next())Jw(s,t(e),0);return Yw(s),_C(o,vC(i)),o.toUint8Array()},Zw=e=>Xw(e,rx,TC,DC),Qw=`You must not compute changes after the event-handler fired.`,$w=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=eT(this.currentTarget,this.target)}deletes(e){return dC(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw db(Qw);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=Zv(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=Zv(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Zv(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw db(Qw);let t=this.target,n=Xv(),r=Xv(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},eT=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},tT=()=>{nC(`Invalid access: Add Yjs type to a document before reading data.`)},nT=80,rT=0,iT=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=rT++}},aT=e=>{e.timestamp=rT++},oT=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=rT++},sT=(e,t,n)=>{if(e.length>=nT){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return oT(r,t,n),r}else{let r=new iT(t,n);return e.push(r),r}},cT=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>oy(t-e.index)<oy(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,aT(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&oy(n.index-i)<r.parent.length/nT?(oT(n,r,i),n):sT(e._searchMarker,r,i)},lT=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=cy(t,i.index+n))}},uT=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;qv(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;ZC(r._eH,n,t)},dT=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=JC(),this._dEH=JC(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw fb()}clone(){throw fb()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){YC(this._eH,e)}observeDeep(e){YC(this._dEH,e)}unobserve(e){XC(this._eH,e)}unobserveDeep(e){XC(this._dEH,e)}toJSON(){}},fT=(e,t,n)=>{e.doc??tT(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},pT=e=>{e.doc??tT();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},mT=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&hw(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},hT=(e,t)=>{let n=0,r=e._start;for(e.doc??tT();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},gT=(e,t)=>{let n=[];return hT(e,(r,i)=>{n.push(t(r,i,e))}),n},_T=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},vT=(e,t)=>{e.doc??tT();let n=cT(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},yT=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new qE(ew(o,yw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new OE(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new qE(ew(o,yw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new mE(new Uint8Array(n))),i.integrate(e,0);break;case xC:i=new qE(ew(o,yw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new yE(n)),i.integrate(e,0);break;default:if(n instanceof dT)i=new qE(ew(o,yw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new BE(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},bT=()=>db(`Length exceeded!`),xT=(e,t,n,r)=>{if(n>t._length)throw bT();if(n===0)return t._searchMarker&&lT(t._searchMarker,n,r.length),yT(e,t,null,r);let i=n,a=cT(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&ww(e,ew(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&lT(t._searchMarker,i,r.length),yT(e,t,o,r)},ST=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return yT(e,t,r,n)},CT=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=cT(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&ww(e,ew(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&ww(e,ew(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw bT();t._searchMarker&&lT(t._searchMarker,i,-a+r)},wT=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},TT=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new OE([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new OE([r]);break;case Uint8Array:s=new mE(r);break;case xC:s=new yE(r);break;default:if(r instanceof dT)s=new BE(r);else throw Error(`Unexpected content type`)}new qE(ew(o,yw(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},ET=(e,t)=>{e.doc??tT();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},DT=e=>{let t={};return e.doc??tT(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},OT=(e,t)=>{e.doc??tT();let n=e._map.get(t);return n!==void 0&&!n.deleted},kT=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&hw(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},AT=e=>(e.doc??tT(),aC(e._map.entries(),e=>!e[1].deleted)),jT=class extends $w{},MT=class e extends dT{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof dT?e.clone():e)),t}get length(){return this.doc??tT(),this._length}_callObserver(e,t){super._callObserver(e,t),uT(this,e,new jT(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Fw(this.doc,n=>{xT(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):Fw(this.doc,t=>{ST(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Fw(this.doc,n=>{CT(n,this,e,t)})}get(e){return vT(this,e)}toArray(){return pT(this)}slice(e=0,t=this.length){return fT(this,e,t)}toJSON(){return this.map(e=>e instanceof dT?e.toJSON():e)}map(e){return gT(this,e)}forEach(e){hT(this,e)}[Symbol.iterator](){return _T(this)}_write(e){e.writeTypeRef(NE)}},NT=e=>new MT,PT=class extends $w{constructor(e,t,n){super(e,t),this.keysChanged=n}},FT=class e extends dT{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof dT?e.clone():e)}),t}_callObserver(e,t){uT(this,e,new PT(this,e,t))}toJSON(){this.doc??tT();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof dT?r.toJSON():r}}),e}get size(){return[...AT(this)].length}keys(){return oC(AT(this),e=>e[0])}values(){return oC(AT(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return oC(AT(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??tT(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):Fw(this.doc,t=>{wT(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):Fw(this.doc,n=>{TT(n,this,e,t)}),t}get(e){return ET(this,e)}has(e){return OT(this,e)}clear(){this.doc===null?this._prelimContent.clear():Fw(this.doc,e=>{this.forEach(function(t,n,r){wT(e,r,n)})})}_write(e){e.writeTypeRef(PE)}},IT=e=>new FT,LT=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&$b(e,t),RT=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&pb(),this.right.content.constructor){case CE:this.right.deleted||HT(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}},zT=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case CE:t.right.deleted||HT(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&ww(e,ew(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},BT=(e,t,n,r)=>{let i=new Map,a=r?cT(t,n):null;return a?zT(e,new RT(a.p.left,a.p,a.index,i),n-a.index):zT(e,new RT(null,t._start,0,i),n)},VT=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===CE&&LT(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new qE(ew(a,yw(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new CE(o,r));l.integrate(e,0),n.right=l,n.forward()})},HT=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},UT=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===CE&&LT(t[e.right.content.key]??null,e.right.content.value));)e.forward()},WT=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!LT(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new qE(ew(a,yw(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new CE(s,c)),n.right.integrate(e,0),n.forward()}}return o},GT=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;UT(n,i);let s=WT(e,t,n,i),c=r.constructor===String?new AE(r):r instanceof dT?new BE(r):new xE(r),{left:l,right:u,index:d}=n;t._searchMarker&&lT(t._searchMarker,n.index,c.getLength()),u=new qE(ew(o,yw(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),VT(e,t,n,s)},KT=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;UT(n,i);let s=WT(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===CE));){if(!n.right.deleted)switch(n.right.content.constructor){case CE:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(LT(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&ww(e,ew(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
80
+ `;n.right=new qE(ew(o,yw(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new AE(i)),n.right.integrate(e,0),n.forward()}VT(e,t,n,s)},qT=(e,t,n,r,i)=>{let a=t,o=Gv();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===CE){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case CE:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&HT(i,n);break}}}t=t.right}return s},JT=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===CE){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},YT=e=>{let t=0;return Fw(e.doc,n=>{let r=e._start,i=e._start,a=Gv(),o=Kv(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case CE:HT(o,i.content);break;default:t+=qT(n,r,i,a,o),a=Kv(o),r=i;break}i=i.right}}),t},XT=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Dw(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===CE&&e.constructor!==pE&&t.add(e.parent)})}Fw(n,n=>{lC(e,e.deleteSet,e=>{if(e instanceof pE||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===CE?t.add(r):JT(n,e)});for(let e of t)YT(e)})},ZT=(e,t,n)=>{let r=n,i=Kv(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case BE:case xE:case AE:n<t.right.length&&ww(e,ew(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&qT(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&lT(o._searchMarker,t.index,-r+n),t},QT=class extends $w{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];Fw(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},Xb(o)||(e.attributes=Kb({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case BE:case xE:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case AE:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case CE:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(LT(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),LT(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;LT(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(LT(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),HT(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},$T=class e extends dT{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??tT(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new QT(this,e,t);uT(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??tT();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===AE&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):Fw(this.doc,n=>{let r=new RT(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
81
+ `?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&GT(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&ZT(n,r,a.delete):KT(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??tT();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(hw(s,e)||t!==void 0&&hw(s,t))switch(s.content.constructor){case AE:{let r=i.get(`ychange`);e!==void 0&&!hw(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!hw(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case BE:case xE:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case CE:hw(s,e)&&(c(),HT(i,s.content));break}s=s.right}c()};return e||t?Fw(a,n=>{e&&gw(n,e),t&&gw(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):Fw(r,r=>{let i=BT(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),GT(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Fw(r,r=>{let i=BT(r,this,e,!n);GT(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):Fw(n,n=>{ZT(n,BT(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):Fw(r,r=>{let i=BT(r,this,e,!1);i.right!==null&&KT(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Fw(this.doc,t=>{wT(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Fw(this.doc,n=>{TT(n,this,e,t)})}getAttribute(e){return ET(this,e)}getAttributes(){return DT(this)}_write(e){e.writeTypeRef(FE)}},eE=e=>new $T,tE=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??tT()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===iE||t.constructor===nE)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},nE=class e extends dT{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof dT?e.clone():e)),t}get length(){return this.doc??tT(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new tE(this,e)}querySelector(e){e=e.toUpperCase();let t=new tE(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),$v(new tE(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){uT(this,e,new oE(this,t,e))}toString(){return gT(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),hT(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Fw(this.doc,n=>{xT(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Fw(this.doc,n=>{let r=e&&e instanceof dT?e._item:e;yT(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw db(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Fw(this.doc,n=>{CT(n,this,e,t)})}toArray(){return pT(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return vT(this,e)}slice(e=0,t=this.length){return fT(this,e,t)}forEach(e){hT(this,e)}_write(e){e.writeTypeRef(LE)}},rE=e=>new nE,iE=class e extends nE{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Jb(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof dT?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):Fw(this.doc,t=>{wT(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Fw(this.doc,n=>{TT(n,this,e,t)})}getAttribute(e){return ET(this,e)}hasAttribute(e){return OT(this,e)}getAttributes(e){return e?kT(this,e):DT(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return hT(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(IE),e.writeKey(this.nodeName)}},aE=e=>new iE(e.readKey()),oE=class extends $w{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},sE=class e extends FT{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(RE),e.writeKey(this.hookName)}},cE=e=>new sE(e.readKey()),lE=class e extends $T{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(zE)}},uE=e=>new lE,dE=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw fb()}mergeWith(e){return!1}write(e,t,n){throw fb()}integrate(e,t){throw fb()}},fE=0,pE=class extends dE{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),bw(e.doc.store,this)}write(e,t){e.writeInfo(fE),e.writeLen(this.length-t)}getMissing(e,t){return null}},mE=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw fb()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},hE=e=>new mE(e.readBuf()),gE=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){mC(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},_E=e=>new gE(e.readLen()),vE=(e,t)=>new xC({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),yE=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(vE(this.doc.guid,this.opts))}splice(e){throw fb()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},bE=e=>new yE(vE(e.readString(),e.readAny())),xE=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw fb()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},SE=e=>new xE(e.readJSON()),CE=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw fb()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},wE=e=>new CE(e.readKey(),e.readJSON()),TE=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},EE=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new TE(n)},DE=fx(`node_env`)===`development`,OE=class e{constructor(e){this.arr=e,DE&&tx(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},kE=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new OE(n)},AE=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},jE=e=>new AE(e.readString()),ME=[NT,IT,eE,aE,rE,cE,uE],NE=0,PE=1,FE=2,IE=3,LE=4,RE=5,zE=6,BE=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw fb()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},VE=e=>new BE(ME[e.readTypeRef()](e)),HE=(e,t)=>{let n=t,r=0,i;do r>0&&(n=ew(n.client,n.clock+r)),i=Sw(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof qE);return{item:i,diff:r}},UE=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},WE=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new qE(ew(r,i+n),t,ew(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=ew(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},GE=(e,t)=>ty(e,e=>dC(e.deletions,t)),KE=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return ww(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||KE(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=ww(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:ww(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:ww(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||dC(r,d.right.id)||GE(a.undoStack,d.right.id)||GE(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=ww(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=ew(c,yw(s,c)),h=new qE(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,UE(h,!0),h.integrate(e,0),h},qE=class e extends dE{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=yw(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=yw(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===QC&&this.id.client!==this.parent.client&&this.parent.clock>=yw(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Tw(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=ww(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===pE||this.right&&this.right.constructor===pE)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===QC){let e=Sw(n,this.parent);e.constructor===pE?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Tw(e,e.doc.store,ew(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),$C(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if($C(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Sw(e.doc.store,n.origin)))r.has(Sw(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),bw(e.doc.store,this),this.content.integrate(e,this),Aw(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new pE(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:ew(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&$C(e.origin,this.lastId)&&this.right===e&&$C(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),mC(e.deleteSet,this.id.client,this.id.clock,this.length),Aw(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw pb();this.content.gc(e),t?Ew(e,this,new pE(this.id,this.length)):this.content=new gE(this.length)}write(e,t){let n=t>0?ew(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=tw(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===QC?(e.writeParentInfo(!1),e.writeLeftID(t)):pb();i!==null&&e.writeString(i)}this.content.write(e,t)}},JE=(e,t)=>YE[t&31](e),YE=[()=>{pb()},_E,EE,hE,jE,SE,wE,VE,kE,bE,()=>{pb()}],XE=10,ZE=class extends dE{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){pb()}write(e,t){e.writeInfo(XE),Gy(e.restEncoder,this.length-t)}getMissing(e,t){return null}},QE=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},$E=`__ $YJS$ __`;QE[$E]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),QE[$E]=!0;var eD={anthropic:`Claude`,openai:`GPT`,gemini:`Gemini`,"local-ollama":`Local model`,"local-llamacpp":`Local model`},tD=`Assistant`;function nD(e){return(e.defaultModelId?e.models.find(t=>t.id===e.defaultModelId):void 0)||(e.models.length===1?e.models[0]:void 0)}function rD(e,t){let n=nD(e);if(!n)return tD;let r=eD[n.provider]||`Assistant`;return t===`family`?r:n.displayName||n.modelId||r}function iD(e){let t=A(()=>rD(e.settings,`family`)),n=A(()=>rD(e.settings,`model`));return{get family(){return z(t)},get specific(){return z(n)}}}function aD(e){return e?e+1:0}function oD(e){let t=0;return e.forEach(e=>{e.isText?t+=e.text.length:e.type.name===`hardBreak`&&(t+=1)}),t}function sD(e){if(e.isTextblock)return oD(e);let t=0;for(let n=0;n<e.childCount;n++)n>0&&(t+=1),t+=sD(e.child(n));return t}function cD(e,t,n){if(e.isTextblock)return Co(n+Math.min(t,oD(e)));let r=0,i=n;for(let n=0;n<e.childCount;n++){let a=e.child(n),o=i+1;n>0&&(r+=1);let s=sD(a);if(r+s>t)return cD(a,t-r,o);r+=s,i+=a.nodeSize}return Co(n+e.content.size)}function lD(e,t){let n=0,r=0,i=e.childCount;for(let a=0;a<i;a++){let o=e.child(a),s=r+1,c=o.type.name===`heading`?aD(o.attrs.level||1):0,l=c+sD(o);if(n+l>t){let e=t-n;return cD(o,Math.max(0,e-c),s)}if(n+=l,r+=o.nodeSize,a<i-1&&(n+=1,n>t))return Co(s+o.content.size)}return Co(e.content.size)}function uD(e,t,n){if(e.isTextblock)return Math.min(t-n,oD(e));let r=0,i=n;for(let n=0;n<e.childCount;n++){let a=e.child(n),o=i+1;if(n>0&&(r+=1),t<i+a.nodeSize)return t<=o?r:r+uD(a,t,o);r+=sD(a),i+=a.nodeSize}return r}function dD(e,t){let n=0,r=0,i=e.childCount;for(let a=0;a<i;a++){let o=e.child(a),s=r+1,c=o.type.name===`heading`?aD(o.attrs.level||1):0,l=sD(o);if(t<r+o.nodeSize)return So(t<=s?n+c:n+c+uD(o,t,s));n+=c+l,r+=o.nodeSize,a<i-1&&(n+=1)}return So(n)}function fD(e,t,n,r){if(t.isTextblock){let i=0;for(let a=0;a<e.length;a++){let o=e.get(a);if(o instanceof lE){if(o===r.type)return Co(n+Math.min(i+r.index,oD(t)));i+=o.length}}return null}let i=n;e.length!==t.childCount&&console.warn(`[positions] Y.js/PM child count mismatch: yEl(${e.nodeName}).length=${e.length} vs pmNode(${t.type.name}).childCount=${t.childCount}`);let a=Math.min(e.length,t.childCount);for(let n=0;n<a;n++){let a=e.get(n),o=t.child(n),s=i+1;if(a instanceof iE){let e=fD(a,o,s,r);if(e!==null)return e}i+=o.nodeSize}return null}function pD(e,t,n){let r=0,i=Math.min(e.childCount,t.length);for(let a=0;a<i;a++){let i=t.get(a),o=e.child(a),s=r+1;if(i instanceof iE){let e=fD(i,o,s,n);if(e!==null)return e}r+=o.nodeSize}return null}function mD(e,t,n){let r,i;try{let t=iw(n.fromRel),a=iw(n.toRel);r=uw(t,e),i=uw(a,e)}catch(e){return console.warn(`[positions] relRangeToPmPositions: failed to resolve relRange:`,e),null}if(!r||!i)return null;let a=e.getXmlFragment(`default`),o=pD(t,a,r),s=pD(t,a,i);return o===null||s===null?null:{from:o,to:s}}function hD(e,t,n){if(e.relRange&&n){let r=mD(n,t,e.relRange);if(r&&r.from<=r.to)return{...r,method:`rel`};console.warn(r?`[positions] annotationToPmRange: inverted rel range for ${e.id}, falling back to flat`:`[positions] annotationToPmRange: relRange resolved to null for ${e.id}, falling back to flat`)}return e.range?{from:lD(t,e.range.from),to:lD(t,e.range.to),method:`flat`}:null}function gD(e,t){return{from:dD(e,t.from),to:dD(e,t.to)}}function _D(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function vD(e){let t=_D(e),n=[],r=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(e,t,r)=>{let i=n.length,a=t?` class="language-${t}"`:``;return n.push(`<pre><code${a}>${r.trimEnd()}</code></pre>`),`\x00BLOCK${i}\x00`});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,(e,t,n)=>{let r=n.trim();return/^(https?:\/\/|mailto:|#)/i.test(r)?`<a href="${r}" target="_blank" rel="noopener noreferrer">${t}</a>`:t}).replace(/^[*-] (.+)$/gm,`<li>$1</li>`).replace(/\n\n/g,`</p><p>`).replace(/\n/g,`<br>`);for(let e=0;e<n.length;e++)r=r.replace(`\x00BLOCK${e}\x00`,n[e]);return r}var yD=V(`<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>`),bD=V(`<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>`),xD=V(`<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>`),SD=V(`<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>`),CD=V(`<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>`),wD=V(`<div class="chat-markdown svelte-15oag3v"></div>`),TD=V(`<div style="white-space: pre-wrap; word-break: break-word;"> </div>`),ED=V(`<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>`),DD=V(`<span></span>`),OD=V(`<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>`),kD=V(`<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>`),AD=V(`<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-input-area svelte-15oag3v"><textarea placeholder="Message your AI…" class="chat-textarea svelte-15oag3v"></textarea> <button class="chat-send-btn svelte-15oag3v" aria-label="Send message" title="Send · Enter" data-testid="chat-send-btn"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" style="display:block" aria-hidden="true"><path d="M14 2L2 8l4 2 2 4 2-4 4-8z"></path></svg></button></div></div>`);function jD(e,t){O(t,!0);let n=[0,.2,.4],r=iD(av()),i=q(t,`inputEl`,15,null),a=A(()=>t.reduceMotion?`auto`:`smooth`),o=j(N([])),s=j(``),c=j(void 0),l=j(void 0);L(()=>{i(z(l)??null)}),L(()=>{if(!t.ctrlYdoc)return;let e=t.ctrlYdoc.getMap(Ua),n=()=>{let t=[];e.forEach(e=>{t.push(e)}),t.sort((e,t)=>e.timestamp-t.timestamp||e.id.localeCompare(t.id)),M(o,t,!0)};return e.observe(n),n(),()=>e.unobserve(n)});let u=!1;L(()=>{z(o);let e=!!t.claudeActive,n=Ar(()=>z(a));if(!e&&u){u=!1;return}u=e,z(c)?.scrollIntoView({behavior:n})}),L(()=>{let e=t.visible,n=Ar(()=>z(a));e&&z(c)?.scrollIntoView({behavior:n})});let d=A(()=>z(o).filter(e=>e.author===`claude`&&!e.read).length);function f(){if(!t.ctrlYdoc||!z(s).trim())return;let e=t.ctrlYdoc.getMap(Ua),n={id:uc(),author:`user`,text:z(s).trim(),timestamp:Date.now(),...t.activeDocId?{documentId:t.activeDocId}:{},...t.capturedAnchor?{anchor:t.capturedAnchor}:{},read:!1};e.set(n.id,n),M(s,``),t.onCapturedAnchorChange(null),window.dispatchEvent(new CustomEvent(`tandem:addressed-ai`,{detail:{via:`chat`}}))}function p(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),f())}function m(e,n){if(!(!t.editor||n&&n!==t.activeDocId))try{let n=lD(t.editor.state.doc,e.from),r=lD(t.editor.state.doc,e.to);t.editor.chain().focus().setTextSelection({from:n,to:r}).scrollIntoView().run()}catch(e){console.warn(`[ChatPanel] Could not scroll to anchor:`,e instanceof Error?e.message:e)}}function h(e){return e?t.openDocs.find(t=>t.id===e)?.fileName??null:null}async function g(){try{await fetch(`http://127.0.0.1:${xa}${Nc}`,{method:`DELETE`})}catch(e){console.warn(`[ChatPanel] Failed to clear chat:`,e)}}let _=j(N(new Set));function v(e){let t=new Set(z(_));t.has(e)?t.delete(e):t.add(e),M(_,t,!0)}var y=AD(),b=P(y),x=I(P(b)),S=P(x),ee=e=>{var t=yD(),n=P(t,!0);E(t),R(()=>U(n,z(d))),H(e,t)};W(S,e=>{z(d)>0&&e(ee)});var C=I(S,2),te=e=>{var t=bD();B(`click`,t,g),H(e,t)};W(C,e=>{z(o).length>0&&e(te)}),E(x),E(b);var w=I(b,2),ne=P(w),re=e=>{H(e,xD())};W(ne,e=>{z(o).length===0&&e(re)});var T=I(ne,2);pi(T,17,()=>z(o),e=>e.id,(e,t)=>{var n=ED(),i=P(n),a=P(i),o=P(a,!0);E(a);var s=I(a,2),c=e=>{var n=SD(),r=P(n,!0);E(n),R(e=>U(r,e),[()=>h(z(t).documentId)??z(t).documentId]),H(e,n)};W(s,e=>{z(t).documentId&&e(c)});var l=I(s,2),u=P(l,!0);E(l),E(i);var d=I(i,2),f=e=>{var n=CD(),r=P(n,!0);E(n),R(e=>{G(n,`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: ${e??``}; overflow: hidden; transition: max-height 0.3s ease;`),U(r,z(t).anchor.textSnapshot)},[()=>z(_).has(z(t).id)?`500px`:`60px`]),B(`click`,n,()=>m(z(t).anchor,z(t).documentId)),zr(`mouseenter`,n,()=>v(z(t).id)),zr(`mouseleave`,n,()=>v(z(t).id)),H(e,n)};W(d,e=>{z(t).anchor&&e(f)});var p=I(d,2),g=e=>{var n=wD();yi(n,()=>vD(z(t).text),!0),E(n),H(e,n)},y=e=>{var n=TD(),r=P(n,!0);E(n),R(()=>U(r,z(t).text)),H(e,n)};W(p,e=>{z(t).author===`claude`?e(g):e(y,-1)}),E(n),R(e=>{G(n,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${z(t).author===`user`?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; border: 1px solid ${z(t).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);`),G(a,`font-weight: 600; font-size: 11px; color: ${z(t).author===`claude`?`var(--tandem-accent)`:`var(--tandem-fg-muted)`}; text-transform: uppercase;`),U(o,z(t).author===`claude`?r.family:`You`),U(u,e)},[()=>new Date(z(t).timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]),H(e,n)});var ie=I(T,2),ae=e=>{var r=OD(),i=P(r);pi(i,20,()=>n,e=>e,(e,t)=>{var n=DD();R(()=>G(n,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${t??``}s infinite;`)),H(e,n)}),E(i);var a=I(i,2),o=P(a,!0);E(a),E(r),R(()=>U(o,t.claudeStatus??`Your AI is thinking...`)),H(e,r)};W(ie,e=>{t.claudeActive&&e(ae)}),fa(I(ie,2),e=>M(c,e),()=>z(c)),E(w),Pi(w,(e,t)=>Bu?.(e,t),()=>`y`);var oe=I(w,2),se=e=>{var n=kD(),r=P(n),i=P(r);E(r);var a=I(r,2);E(n),R(e=>U(i,`with selection: “${e??``}${t.capturedAnchor.textSnapshot.length>40?`...`:``}”`),[()=>t.capturedAnchor.textSnapshot.slice(0,40)]),B(`click`,a,()=>t.onCapturedAnchorChange(null)),H(e,n)};W(oe,e=>{t.capturedAnchor&&e(se)});var ce=I(oe,2),le=P(ce);En(le),K(le,`rows`,1),fa(le,e=>M(l,e),()=>z(l));var ue=I(le,2);E(ce),E(y),R(e=>{ea(le,z(s)),ue.disabled=e},[()=>!z(s).trim()]),B(`input`,le,e=>M(s,e.target.value,!0)),B(`keydown`,le,p),B(`click`,ue,f),H(e,y),k()}Br([`click`,`input`,`keydown`]);var MD=V(`<button type="button" data-testid="apply-changes-btn"> </button>`);function ND(e,t){O(t,!0);let n=j(!1),r=A(()=>t.annotations.filter(e=>e.status===`accepted`)),i=A(()=>t.annotations.filter(e=>e.status===`pending`)),a=A(()=>z(r).length===0||z(n));async function o(){if(z(a)||!t.documentId)return;let e=`Apply ${z(r).length} change(s) as tracked revisions?\n\nThe changes will appear as tracked revisions in Word — you can Accept or Reject each one individually.\n\nYour original file will be backed up.`;if(z(i).length>0&&(e+=`\n\n⚠ ${z(i).length} annotation(s) are still pending review and will not be applied.`),confirm(e)){M(n,!0);try{let e=await fetch(`${Il}${wc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId})}),n=await e.json().catch(e=>(console.error(`[ApplyChanges] Failed to parse response JSON:`,e),null));if(!e.ok){alert(n?.message??`Apply failed (HTTP ${e.status}).`);return}let r=n?.data;if(r){let e=[`Applied ${r.applied??0} tracked change(s).`];r.rejected>0&&e.push(`${r.rejected} could not be applied.`),r.backupPath&&e.push(`\nBackup saved to:\n${r.backupPath}`),alert(e.join(` `))}else alert(`Changes applied successfully.`)}catch(e){console.error(`[ApplyChanges] Request failed:`,e),alert(e instanceof TypeError?`Could not reach the server.`:`Apply failed: ${e instanceof Error?e.message:String(e)}`)}finally{M(n,!1)}}}var s=Xr(),c=F(s),l=e=>{var t=MD();let i;var s=P(t,!0);E(t),R(()=>{i=Ui(t,1,`acb-btn svelte-hdlegv`,null,i,{"is-disabled":z(a),"is-applying":z(n)}),t.disabled=z(a),K(t,`title`,z(r).length===0?`No accepted suggestions to apply`:void 0),U(s,z(n)?`Applying…`:`Apply as Tracked Changes (${z(r).length})`)}),B(`click`,t,o),H(e,t)};W(c,e=>{t.activeDocFormat===`docx`&&e(l)}),H(e,s),k()}Br([`click`]);function PD(e,t){return e.id<t.id?-1:+(e.id>t.id)}function FD(e){return[...e].sort((e,t)=>{let n=Number.isFinite(e.range?.from)?e.range.from:1/0,r=Number.isFinite(t.range?.from)?t.range.from:1/0;return n===r?PD(e,t):n<r?-1:1})}function ID(e){return[...e].sort((e,t)=>{let n=(Number.isFinite(e.timestamp)?e.timestamp:0)-(Number.isFinite(t.timestamp)?t.timestamp:0);return n===0?PD(e,t):n})}function LD(e,t){return t===`chronological`?ID(e):FD(e)}function RD(e,t){if(!t)return-1;for(let n=0;n<e.length;n++)if(e[n].id===t)return n;return-1}function zD(e,t){if(e.length===0)return null;let n=RD(e,t);return n===-1?e[0].id:e[(n+1)%e.length].id}function BD(e,t){if(e.length===0)return null;let n=RD(e,t);return n===-1?e[e.length-1].id:e[(n-1+e.length)%e.length].id}var VD={background:`var(--tandem-warning-bg)`,border:`var(--tandem-warning-border)`,color:`var(--tandem-warning-fg-strong)`};function HD(e,t){return e.type===`highlight`?[]:t??[]}var UD=V(`<button class="aca-btn aca-btn--accept svelte-1u9ox5p">Accept</button>`),WD=V(`<button class="aca-btn aca-btn--reject svelte-1u9ox5p">Reject</button>`),GD=V(`<div class="aca-row svelte-1u9ox5p"><!> <!></div>`),KD=V(`<button class="aca-btn aca-btn--ghost svelte-1u9ox5p">Archive</button>`),qD=V(`<button class="aca-btn aca-btn--send svelte-1u9ox5p"> </button>`),JD=V(`<div class="aca-row svelte-1u9ox5p"><!> <!></div>`),YD=V(`<button class="aca-btn aca-btn--ghost aca-standalone svelte-1u9ox5p">Remove</button>`),XD=V(`<div class="aca-undo-error svelte-1u9ox5p">Can't undo — text has changed.</div>`),ZD=V(`<div class="aca-undo-row svelte-1u9ox5p"><button data-testid="undo-btn" class="aca-undo svelte-1u9ox5p">Undo</button> <!></div>`);function QD(e,t){O(t,!0);let n=iD(av()),r=j(!1),i=null;function a(){i&&=(clearTimeout(i),null)}function o(e){if(e.stopPropagation(),!t.onUndo)return;let n=t.onUndo(t.annotationId);if(n){a(),M(r,!1);return}n||(M(r,!0),a(),i=setTimeout(()=>{M(r,!1),i=null},3e3))}va(a);var s=Xr(),c=F(s),l=e=>{var n=GD(),r=P(n),i=e=>{var n=UD();R(()=>K(n,`data-testid`,`accept-btn-${t.annotationId??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onAccept(t.annotationId)}),H(e,n)};W(r,e=>{t.onAccept&&e(i)});var a=I(r,2),o=e=>{var n=WD();R(()=>K(n,`data-testid`,`dismiss-btn-${t.annotationId??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onDismiss(t.annotationId)}),H(e,n)};W(a,e=>{t.onDismiss&&e(o)}),E(n),H(e,n)},u=e=>{var r=JD(),i=P(r),a=e=>{var n=KD();R(()=>K(n,`data-testid`,`archive-btn-${t.annotationId??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onRemove(t.annotationId)}),H(e,n)};W(i,e=>{t.onRemove&&e(a)});var o=I(i,2),s=e=>{var r=qD(),i=P(r);E(r),R(()=>{K(r,`data-testid`,`send-to-claude-btn-${t.annotationId??``}`),U(i,`Send to ${n.family??``}`)}),B(`click`,r,e=>{e.stopPropagation(),t.onSendToClaude(t.annotationId)}),H(e,r)};W(o,e=>{t.onSendToClaude&&e(s)}),E(r),H(e,r)},d=e=>{var n=YD();R(()=>K(n,`data-testid`,`remove-btn-${t.annotationId??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onRemove(t.annotationId)}),H(e,n)},f=e=>{var t=ZD(),n=P(t),i=I(n,2),a=e=>{H(e,XD())};W(i,e=>{z(r)&&e(a)}),E(t),B(`click`,n,o),H(e,t)};W(c,e=>{t.isPending&&!t.isEditing&&(t.onAccept||t.onDismiss)?e(l):t.isPending&&!t.isEditing&&t.annotationType===`note`?e(u,1):t.isPending&&!t.isEditing&&t.onRemove?e(d,2):!t.isPending&&t.undoable&&t.onUndo&&e(f,3)}),H(e,s),k()}Br([`click`]);var $D=`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);`,eO=V(`<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),tO=V(`<textarea></textarea>`),nO=V(`<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 rO(e,t){O(t,!0);let n=j(null);L(()=>{z(n)?.focus()});var r=nO(),i=P(r),a=e=>{var r=eO(),i=F(r),a=I(i,2);En(a),fa(a,e=>M(n,e),()=>z(n));var o=I(a,2),s=I(o,2);En(s),R(()=>{K(i,`for`,`edit-newtext-${t.annotationId??``}`),K(a,`id`,`edit-newtext-${t.annotationId??``}`),K(a,`data-testid`,`edit-newtext-${t.annotationId??``}`),ea(a,t.editNewText),G(a,$D),K(o,`for`,`edit-reason-${t.annotationId??``}`),K(s,`id`,`edit-reason-${t.annotationId??``}`),K(s,`data-testid`,`edit-reason-${t.annotationId??``}`),ea(s,t.editReason),G(s,$D)}),B(`input`,a,e=>t.onChangeEditNewText(e.target.value)),B(`keydown`,a,function(...e){t.onKeyDown?.apply(this,e)}),B(`input`,s,e=>t.onChangeEditReason(e.target.value)),B(`keydown`,s,function(...e){t.onKeyDown?.apply(this,e)}),H(e,r)},o=e=>{var r=tO();En(r),fa(r,e=>M(n,e),()=>z(n)),R(()=>{K(r,`data-testid`,`edit-text-${t.annotationId??``}`),ea(r,t.editText),G(r,$D)}),B(`input`,r,e=>t.onChangeEditText(e.target.value)),B(`keydown`,r,function(...e){t.onKeyDown?.apply(this,e)}),H(e,r)};W(i,e=>{t.hasSuggestedText?e(a):e(o,-1)});var s=I(i,2),c=P(s),l=I(c,2);E(s),E(r),R(()=>{K(c,`data-testid`,`edit-save-btn-${t.annotationId??``}`),K(l,`data-testid`,`edit-cancel-btn-${t.annotationId??``}`)}),B(`click`,r,e=>e.stopPropagation()),B(`keydown`,r,e=>e.stopPropagation()),B(`click`,c,e=>{e.stopPropagation(),t.onSave()}),B(`click`,l,e=>{e.stopPropagation(),t.onCancel()}),H(e,r),k()}Br([`click`,`keydown`,`input`]);function iO(e,t){return e===`claude`?t??`Assistant`:e===`import`?`Imported`:`You`}function aO(e){let t=Math.floor((Date.now()-e)/6e4);if(t<1)return`just now`;if(t<60)return`${t}m ago`;let n=Math.floor(t/60);return n<24?`${n}h ago`:new Date(e).toLocaleDateString()}function oO(e){return e.suggestedText===void 0?e.type:`replacement`}function sO(e,t){return e?e.length>t?e.slice(0,t-3)+`...`:e:``}function cO(e){let t=oO(e),n=sO(e.content,60);return`${e.type===`note`?`private `:``}${t} annotation${n?`: `+n:``}, ${e.status}`}function lO(e){return e.type===`highlight`&&e.color?ka[Aa(e.color)]:`var(--tandem-author-user)`}var uO=V(`<span> </span>`),dO=V(`<button class="ach-edit-btn svelte-d1dbnh" title="Edit this annotation's content">✎ Edit</button>`),fO=V(`<span class="ach-edited svelte-d1dbnh">(edited)</span>`),pO=V(`<span class="ach-dot svelte-d1dbnh" aria-hidden="true"></span>`),mO=V(`<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 class="ach-time svelte-d1dbnh"> </span></span></div>`);function hO(e,t){O(t,!0);let n=iD(av()),r=A(()=>oO(t.annotation)),i=A(()=>iO(t.annotation.author,n.family)),a=A(()=>t.annotation.author===`claude`?`var(--tandem-author-claude)`:`var(--tandem-author-user)`);var o=mO(),s=P(o),c=P(s),l=P(c,!0);E(c);var u=I(c,2),d=e=>{var n=Xr();bi(F(n),()=>t.extraPill),H(e,n)};W(u,e=>{t.extraPill&&e(d)});var f=I(u,2),p=e=>{var n=uO();let r;var i=P(n,!0);E(n),R(()=>{r=Ui(n,1,`ach-status svelte-d1dbnh`,null,r,{"is-accepted":t.annotation.status===`accepted`,"is-rejected":t.annotation.status!==`accepted`}),U(i,t.annotation.status)}),H(e,n)};W(f,e=>{t.isPending||e(p)});var m=I(f,2),h=e=>{var n=dO();R(()=>K(n,`data-testid`,`edit-btn-${t.annotation.id??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onEnterEdit()}),H(e,n)};W(m,e=>{t.isPending&&t.canEdit&&!t.isReviewTarget&&!t.isEditing&&e(h)}),E(s);var g=I(s,2),_=P(g),v=e=>{H(e,fO())};W(_,e=>{t.annotation.editedAt&&e(v)});var y=I(_,2),b=e=>{var t=pO();R(()=>G(t,`background: ${z(a)??``};`)),H(e,t)};W(y,e=>{t.annotation.author!==`import`&&e(b)});var x=I(y),S=I(x),ee=P(S,!0);E(S),E(g),E(o),R((e,n)=>{G(c,`background: ${t.badgeBg??``}; color: ${t.badgeFg??``};`),U(l,z(r)),U(x,` ${z(i)??``} `),K(S,`title`,e),U(ee,n)},[()=>new Date(t.annotation.timestamp).toLocaleString(),()=>aO(t.annotation.timestamp)]),H(e,o),k()}Br([`click`]);var gO=V(`<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 _O(e,t){O(t,!0);let n=A(()=>t.text?t.text.length>80?t.text.slice(0,77)+`...`:t.text:``);var r=Xr(),i=F(r),a=e=>{var r=gO(),i=P(r,!0);E(r),R(()=>{K(r,`data-testid`,`annotation-snippet-${t.annotationId??``}`),U(i,z(n))}),H(e,r)};W(i,e=>{t.text&&e(a)}),H(e,r),k()}var vO=V(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),yO=V(`<!> <!> <!>`,1);function bO(e,t){O(t,!0);var n=yO(),r=F(n);hO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-surface-sunk)`,badgeFg:`var(--tandem-fg-muted)`,get onEnterEdit(){return t.onEnterEdit}});var i=I(r,2);_O(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=I(i,2),o=e=>{var n=vO(),r=P(n),i=P(r,!0);E(r),E(n),R(()=>U(i,t.annotation.content||`(no note)`)),H(e,n)};W(a,e=>{t.isEditing||e(o)}),H(e,n),k()}var xO=V(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),SO=V(`<!> <!> <!>`,1);function CO(e,t){O(t,!0);var n=SO(),r=F(n);hO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-surface-sunk)`,badgeFg:`var(--tandem-fg-muted)`,get onEnterEdit(){return t.onEnterEdit}});var i=I(r,2);_O(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=I(i,2),o=e=>{var n=xO(),r=P(n),i=P(r,!0);E(r),E(n),R(()=>U(i,t.annotation.content||`(no note)`)),H(e,n)};W(a,e=>{t.isEditing||e(o)}),H(e,n),k()}var wO=V(`<input type="checkbox" style="margin-top: 4px; flex-shrink: 0; cursor: pointer;"/>`),TO=V(`<div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-bottom: 4px;">From: <span style="font-weight: 500;"> </span></div>`),EO=V(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),DO=V(`<div style="display: flex; align-items: flex-start; gap: var(--tandem-space-2);"><!> <div style="flex: 1; min-width: 0;"><!> <!> <!> <!></div></div>`);function OO(e,t){O(t,!0);let n=q(t,`selected`,3,!1);var r=DO(),i=P(r),a=e=>{var r=wO();$i(r),R(()=>{K(r,`data-testid`,`annotation-select-checkbox-${t.annotation.id??``}`),ta(r,n()),K(r,`aria-label`,`Select ${t.annotation.importSource?.author??`import`} comment for batch promote`)}),B(`click`,r,e=>e.stopPropagation()),B(`change`,r,()=>t.onToggleSelect?.(t.annotation.id)),H(e,r)};W(i,e=>{t.onToggleSelect&&e(a)});var o=I(i,2),s=P(o);hO(s,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-surface-sunk)`,badgeFg:`var(--tandem-fg-muted)`,get onEnterEdit(){return t.onEnterEdit}});var c=I(s,2),l=e=>{var n=TO(),r=I(P(n)),i=P(r,!0);E(r),E(n),R(()=>{K(n,`data-testid`,`annotation-import-byline-${t.annotation.id??``}`),U(i,t.annotation.importSource.author)}),H(e,n)};W(c,e=>{t.annotation.importSource?.author&&e(l)});var u=I(c,2);_O(u,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var d=I(u,2),f=e=>{var n=EO(),r=P(n),i=P(r,!0);E(r),E(n),R(()=>U(i,t.annotation.content||`(no note)`)),H(e,n)};W(d,e=>{t.isEditing||e(f)}),E(o),E(r),H(e,r),k()}Br([`click`,`change`]);var kO=V(`<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>`),AO=V(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),jO=V(`<!> <!> <!>`,1);function MO(e,t){O(t,!0);var n=jO(),r=F(n);hO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-warning-bg)`,badgeFg:`var(--tandem-warning-fg-strong)`,get onEnterEdit(){return t.onEnterEdit},extraPill:e=>{H(e,kO())},$$slots:{extraPill:!0}});var i=I(r,2);_O(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=I(i,2),o=e=>{var n=AO(),r=P(n),i=P(r,!0);E(r),E(n),R(()=>U(i,t.annotation.content||`(no note)`)),H(e,n)};W(a,e=>{t.isEditing||e(o)}),H(e,n),k()}var NO=V(`<span class="ct-author-dot ct-author-dot--claude svelte-4l0b78" aria-hidden="true"></span> `,1),PO=V(`<span> </span>`),FO=V(`<span class="ct-author-dot ct-author-dot--user svelte-4l0b78" aria-hidden="true"></span> You`,1),IO=V(`<span class="ct-edited svelte-4l0b78">(edited)</span>`),LO=V(`<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>`),RO=V(`<div class="ct-root svelte-4l0b78" data-testid="comment-thread"></div>`);function zO(e,t){O(t,!0);let n=iD(av());var r=Xr(),i=F(r),a=e=>{var r=RO();pi(r,21,()=>t.replies,e=>e.id,(e,t)=>{let r=A(()=>z(t).author===`claude`?`claude`:z(t).author===`import`?`import`:`user`);var i=LO(),a=P(i),o=P(a);let s;var c=P(o),l=e=>{var t=NO(),r=I(F(t));R(()=>U(r,` ${n.family??``}`)),H(e,t)},u=e=>{var n=PO(),r=P(n,!0);E(n),R(()=>{K(n,`data-testid`,`reply-import-byline-${z(t).id??``}`),U(r,z(t).importAuthor??`Imported`)}),H(e,n)},d=e=>{var t=FO();D(),H(e,t)};W(c,e=>{z(r)===`claude`?e(l):z(r)===`import`?e(u,1):e(d,-1)}),E(o);var f=I(o,2),p=P(f),m=e=>{H(e,IO())};W(p,e=>{z(t).editedAt&&e(m)});var h=I(p);E(f),E(a);var g=I(a,2),_=P(g,!0);E(g),E(i),R(e=>{K(i,`data-testid`,`reply-${z(t).id??``}`),s=Ui(o,1,`ct-author svelte-4l0b78`,null,s,{"is-claude":z(r)===`claude`,"is-import":z(r)===`import`,"is-user":z(r)===`user`}),U(h,` ${e??``}`),U(_,z(t).text)},[()=>aO(z(t).timestamp)]),H(e,i)}),E(r),H(e,r)};W(i,e=>{t.replies.length>0&&e(a)}),H(e,r),k()}var BO=V(`<div class="art-replies svelte-155xn9n"><!></div>`),VO=V(`<button type="button"><span class="art-arrow svelte-155xn9n" aria-hidden="true">›</span> </button> <!>`,1),HO=V(`<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>`),UO=V(`<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;">Reply</button>`),WO=V(`<div style="margin-top: 6px;"><!></div>`),GO=V(`<div class="art-root svelte-155xn9n"><!> <!></div>`);function KO(e,t){O(t,!0);let n=q(t,`reduceMotion`,3,!1),r=q(t,`openNonce`,3,0),i=A(()=>HD(t.annotation,t.replies)),a=A(()=>t.annotation.id),o=j(!1),s=j(!1),c=j(``),l=j(!1),u=j(null),d=A(()=>!!z(c).trim());L(()=>{z(s)&&z(u)?.focus()});let f=Ar(()=>r());L(()=>{r()!==f&&(f=r(),M(s,!0))});function p(e){e.key===`Escape`&&(e.stopPropagation(),M(s,!1),M(c,``))}async function m(){let e=z(c).trim();if(!(!e||z(l))){M(l,!0);try{await t.onReply?.(z(a),e)!==!1&&(M(c,``),M(s,!1))}finally{M(l,!1)}}}var h=GO(),g=P(h),_=e=>{var t=VO(),r=F(t);let s;var c=I(P(r));E(r);var l=I(r,2),u=e=>{var t=BO();zO(P(t),{get replies(){return z(i)}}),E(t),Mi(3,t,()=>kv,()=>({reduceMotion:n()})),H(e,t)};W(l,e=>{z(o)&&e(u)}),R(()=>{K(r,`data-testid`,`reply-toggle-${z(a)??``}`),s=Ui(r,1,`art-toggle svelte-155xn9n`,null,s,{open:z(o)}),K(r,`aria-expanded`,z(o)),U(c,` ${z(i).length===1?`1 reply`:`${z(i).length} replies`}`)}),B(`click`,r,e=>{e.stopPropagation(),M(o,!z(o))}),H(e,t)};W(g,e=>{z(i).length>0&&e(_)});var v=I(g,2),y=e=>{var t=WO(),n=P(t),r=e=>{var t=HO(),n=P(t);En(n),fa(n,e=>M(u,e),()=>z(u));var r=I(n,2),i=P(r),o=I(i,2);E(r),E(t),R(()=>{K(n,`data-testid`,`reply-input-${z(a)??``}`),ea(n,z(c)),G(n,$D),K(i,`data-testid`,`reply-send-btn-${z(a)??``}`),i.disabled=!z(d)||z(l),G(i,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${z(d)?`var(--tandem-accent-bg)`:`var(--tandem-surface-muted)`}; color: ${z(d)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-subtle)`}; cursor: ${z(d)?`pointer`:`default`};`),K(o,`data-testid`,`reply-cancel-btn-${z(a)??``}`)}),B(`input`,n,e=>M(c,e.target.value,!0)),B(`keydown`,n,p),B(`click`,i,m),B(`click`,o,()=>{M(s,!1),M(c,``)}),H(e,t)},i=e=>{var t=UO();R(()=>K(t,`data-testid`,`reply-btn-${z(a)??``}`)),B(`click`,t,()=>M(s,!0)),H(e,t)};W(n,e=>{z(s)?e(r):e(i,-1)}),E(t),B(`click`,t,e=>e.stopPropagation()),B(`keydown`,t,e=>e.stopPropagation()),H(e,t)};W(v,e=>{t.isPending&&t.onReply&&!t.isEditing&&e(y)}),E(h),H(e,h),k()}Br([`click`,`keydown`,`input`]);var qO=V(`<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),JO=V(`<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>`),YO=V(`<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>`),XO=V(`<!> <!> <!>`,1);function ZO(e,t){O(t,!0);var n=XO(),r=F(n);hO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-suggestion-bg)`,badgeFg:`var(--tandem-suggestion-fg-strong)`,get onEnterEdit(){return t.onEnterEdit}});var i=I(r,2);_O(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=I(i,2),o=e=>{var n=YO(),r=P(n),i=P(r),a=e=>{var n=qO(),r=F(n),i=P(r,!0);E(r);var a=I(r);a.nodeValue=` → `,R(()=>U(i,t.annotation.textSnapshot)),H(e,n)};W(i,e=>{t.annotation.textSnapshot&&e(a)});var o=I(i,2),s=P(o,!0);E(o),E(r);var c=I(r,2),l=e=>{var n=JO(),r=P(n,!0);E(n),R(()=>U(r,t.annotation.content)),H(e,n)};W(c,e=>{t.annotation.content&&e(l)}),E(n),R(()=>{K(r,`data-testid`,`suggestion-diff-${t.annotation.id??``}`),G(r,`padding: 4px 8px; margin-bottom: ${t.annotation.content?`4px`:`0`}; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); font-size: 12px; line-height: 1.5;`),U(s,t.annotation.suggestedText)}),H(e,n)};W(a,e=>{t.isEditing||e(o)}),H(e,n),k()}var QO=V(`<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>`),$O=V(`<div role="listitem"><!> <!> <!> <!> <!></div>`);function ek(e,t){O(t,!0);let n=q(t,`replies`,19,()=>[]),r=q(t,`claudeTyping`,3,!1),i=q(t,`selected`,3,!1),a=q(t,`density`,3,`full`),o=q(t,`lifecycleMotion`,3,!1),s=q(t,`reduceMotion`,3,!1),c=q(t,`openRequest`,3,null),l=iD(av()),u=j(!1),d=j(``),f=j(``),p=j(``),m=A(()=>t.annotation.status===`pending`),h=A(()=>t.annotation.suggestedText!==void 0),g=A(()=>t.onEdit!==void 0),_=A(()=>cO(t.annotation)),v=A(()=>HD(t.annotation,n())),y=A(()=>a()===`stub`?`stub`:z(u)?`full`:a()),b=-1,x=-1,S=j(0);L(()=>{let e=c();if(e)if(e.kind===`edit`){if(e.nonce===b)return;b=e.nonce,t.onEdit&&te()}else{if(e.nonce===x)return;x=e.nonce,M(S,e.nonce,!0)}});let ee=A(()=>t.annotation.author===`import`?`var(--tandem-surface-muted)`:t.annotation.type===`highlight`?`color-mix(in srgb, ${lO(t.annotation)} 18%, var(--tandem-surface))`:t.annotation.type===`note`?`var(--tandem-warning-bg)`:t.annotation.suggestedText===void 0?t.annotation.author===`claude`?`var(--tandem-author-claude-bg)`:`var(--tandem-author-user-bg)`:`var(--tandem-suggestion-bg)`),C=A(()=>t.isReviewTarget?`var(--tandem-accent-bg)`:z(ee));function te(){z(h)?(M(f,t.annotation.suggestedText??``,!0),M(p,t.annotation.content,!0)):M(d,t.annotation.content,!0),M(u,!0)}function w(){let e=z(h)?JSON.stringify({suggestedText:z(f),content:z(p)}):z(d);t.onEdit?.(t.annotation.id,e),M(u,!1)}function ne(){M(u,!1)}function re(e){e.key===`Escape`&&(e.stopPropagation(),ne())}var T=$O();let ie;var ae=P(T),oe=e=>{var n=QO();R(()=>{K(n,`data-testid`,`claude-typing-indicator-${t.annotation.id??``}`),K(n,`aria-label`,`${l.family??``} is working on this annotation`),K(n,`title`,`${l.family??``} is working on this annotation`)}),H(e,n)};W(ae,e=>{r()&&e(oe)});var se=I(ae,2),ce=e=>{OO(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:te,get selected(){return i()},get onToggleSelect(){return t.onToggleSelect}})},le=e=>{CO(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:te})},ue=e=>{MO(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:te})},de=e=>{ZO(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:te})},fe=e=>{bO(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:te})};W(se,e=>{t.annotation.author===`import`?e(ce):t.annotation.type===`highlight`?e(le,1):t.annotation.type===`note`?e(ue,2):t.annotation.suggestedText===void 0?e(fe,-1):e(de,3)});var pe=I(se,2),me=e=>{rO(e,{get annotationId(){return t.annotation.id},get hasSuggestedText(){return z(h)},get editText(){return z(d)},get editNewText(){return z(f)},get editReason(){return z(p)},onChangeEditText:e=>M(d,e,!0),onChangeEditNewText:e=>M(f,e,!0),onChangeEditReason:e=>M(p,e,!0),onKeyDown:re,onSave:w,onCancel:ne})};W(pe,e=>{z(u)&&e(me)});var he=I(pe,2);QD(he,{get annotationId(){return t.annotation.id},get annotationType(){return t.annotation.type},get isPending(){return z(m)},get isEditing(){return z(u)},get undoable(){return t.undoable},get onAccept(){return t.onAccept},get onDismiss(){return t.onDismiss},get onUndo(){return t.onUndo},get onRemove(){return t.onRemove},get onSendToClaude(){return t.onSendToClaude}}),KO(I(he,2),{get annotation(){return t.annotation},get replies(){return z(v)},get isPending(){return z(m)},get isEditing(){return z(u)},get onReply(){return t.onReply},get reduceMotion(){return s()},get openNonce(){return z(S)}}),E(T),R(()=>{ie=Ui(T,1,`tandem-annotation-card svelte-3ascys`,null,ie,{"is-review-target":t.isReviewTarget,"is-density-clamped":z(y)===`clamped`,"is-density-stub":z(y)===`stub`}),K(T,`data-testid`,`annotation-card-${t.annotation.id??``}`),K(T,`data-annotation-id`,t.annotation.id),K(T,`data-annotation-type`,t.annotation.type),K(T,`data-density`,z(y)),K(T,`data-claude-typing`,r()?`true`:void 0),K(T,`aria-label`,z(_)),K(T,`aria-current`,t.isReviewTarget?`true`:void 0),G(T,`background: ${z(C)??``}; opacity: ${z(m)?1:.6}; cursor: ${t.onClick?`pointer`:`default`};`)}),B(`click`,T,function(...e){t.onClick?.apply(this,e)}),Mi(1,T,()=>mv,()=>({enabled:o(),reduceMotion:s()})),Mi(2,T,()=>hv,()=>({enabled:o(),reduceMotion:s(),id:t.annotation.id,modes:t.exitModes})),H(e,T),k()}Br([`click`]);var tk=`browser`;function nk(e,t,n){let r,i=!1;if(e.transact(()=>{r=t(),i=!0},n),!i)throw Error(`origins: transact callback did not run (origin=${n})`);return r}function rk(e,t){return nk(e,t,tk)}function ik(e,t){let n=e,r=e=>{try{t(e)}catch(t){console.warn(`[sanitizeAnnotation] onLossy threw for ${e.kind}:`,t)}},i=n.audience===`private`||n.audience===`outbound`?n.audience:n.author===`import`||n.type===`highlight`||n.type===`note`||n.type===`flag`?`private`:`outbound`,a={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(a.audience===`outbound`&&n.author===`user`&&(n.type===`note`||n.type===`highlight`||n.type===`flag`)&&(a.audience=`private`,r({kind:`audience-conflict-resolved`,id:n.id})),n.type===`suggestion`){let e,t;try{let r=JSON.parse(n.content);e=r.newText,t=r.reason??``}catch{r({kind:`malformed-suggestion-json`,id:n.id}),t=n.content}return{...a,type:`comment`,content:t,suggestedText:e}}return n.type===`question`?(r({kind:`question-to-comment`,id:n.id}),{...a,type:`comment`}):n.type===`highlight`?{...a,type:`highlight`,color:n.color}:n.type===`flag`||n.type===`note`?(n.type===`flag`&&r({kind:`flag-to-note`,id:n.id}),{...a,type:`note`}):n.type===`comment`?{...a,type:`comment`,...n.suggestedText===void 0?{}:{suggestedText:n.suggestedText}}:(r({kind:`unknown-type`,id:n.id,rawType:n.type}),{...a,type:`comment`})}var ak=e=>{console.warn(`[sanitize]`,e)};function ok(e,t,n){if(!e)return;let r=e.getMap(Ra),i=r.get(t);if(!i)return;let a=ik(i,ak);rk(e,()=>{if(a.suggestedText!==void 0){try{let e=JSON.parse(n);r.set(t,{...a,suggestedText:e.suggestedText,content:e.content,editedAt:Date.now(),rev:(a.rev??0)+1})}catch{console.warn(`[annotation-actions] Failed to parse edit payload for annotation ${t}`)}return}r.set(t,{...a,content:n,editedAt:Date.now(),rev:(a.rev??0)+1})})}function sk(e){let{color:t,suggestedText:n,...r}=e;return{...r,type:`comment`,author:e.author===`import`?`user`:e.author,audience:`outbound`,promotedFrom:`note`,rev:(e.rev??0)+1}}function ck(e,t){if(!e)return;let n=e.getMap(Ra),r=n.get(t);if(!r)return;let i=ik(r,ak);i.type===`note`&&rk(e,()=>{n.set(t,sk(i))})}function lk(e,t){if(!e||t.length===0)return 0;let n=e.getMap(Ra),r=0;return rk(e,()=>{for(let e of t){let t=n.get(e);if(!t)continue;let i=ik(t,ak);i.type===`note`&&(n.set(e,sk(i)),r++)}}),r}async function uk(e,t){try{let n=await fetch(`${Il}${jc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({annotationId:e,documentId:t})});if(!n.ok){let e=await n.json().catch(()=>({message:`Unknown error`}));console.error(`[Tandem] Remove annotation failed:`,e)}}catch(e){console.error(`[Tandem] Remove annotation failed:`,e)}}async function dk(e,t,n){try{let r=await fetch(`${Il}${Ac}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({annotationId:e,text:t,documentId:n})});if(!r.ok){let e=await r.json().catch(()=>({}));return console.warn(`[annotation-actions] Reply failed (${r.status}): ${e.message??`unknown error`}`),!1}return!0}catch(e){return console.error(`[annotation-actions] Reply request failed:`,e),!1}}var fk=new Set([`ctx:annotation:accept`,`ctx:annotation:dismiss`,`ctx:annotation:reply`,`ctx:annotation:edit`,`ctx:annotation:sendToClaude`,`ctx:annotation:copy`,`ctx:annotation:remove`]);function pk(e){return typeof e==`string`&&fk.has(e)}var mk=e=>e.status===`pending`,hk=e=>e.author!==`user`&&mk(e),gk=e=>e.author!==`user`&&mk(e),_k=e=>(e.type===`note`||e.type===`comment`)&&mk(e),vk=e=>e.author===`user`&&mk(e),yk=e=>e.author===`user`&&e.type===`note`&&mk(e),bk=e=>e.author===`user`&&mk(e),xk=e=>!0;function Sk(e){return{canAccept:hk(e),canDismiss:gk(e),canReply:_k(e),canEdit:vk(e),canSendToClaude:yk(e),canCopy:xk(e),canRemove:bk(e),isNote:e.type===`note`}}function Ck(e){return e.content?.trim()?e.content:e.textSnapshot??``}var wk=null;function Tk(e){wk=e}function Ek(e,t,n){switch(e){case`ctx:annotation:accept`:hk(t)&&n.accept?.(t.id);return;case`ctx:annotation:dismiss`:gk(t)&&n.dismiss?.(t.id);return;case`ctx:annotation:sendToClaude`:yk(t)&&n.sendToClaude?.(t.id);return;case`ctx:annotation:remove`:bk(t)&&n.remove?.(t.id);return;case`ctx:annotation:edit`:vk(t)&&n.openEdit?.(t.id);return;case`ctx:annotation:reply`:_k(t)&&n.openReply?.(t.id);return;case`ctx:annotation:copy`:if(xk(t)){let e=Ck(t);e&&navigator.clipboard.writeText(e).catch(()=>{})}return}}async function Dk(e,t){Tk({run:t});try{await(await Um())(`show_annotation_context_menu`,{req:Sk(e)})}catch{}}var Ok=0,kk=null;function Ak(){if(!Bm())return()=>{};Ok++,Ok===1&&(kk=Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`context-menu-action`,e=>{let t=e.payload?.id;pk(t)&&wk?.run(t)})),kk.catch(()=>{}));let e=!1;return()=>{if(!e&&(e=!0,Ok--,Ok===0)){let e=kk;kk=null,e?.then(e=>e()).catch(()=>{})}}}var jk=V(`<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 Mk(e,t){O(t,!0);let n=q(t,`reduceMotion`,3,!1),r=iD(av());var i=Xr(),a=F(i),o=e=>{var i=jk(),a=P(i),o=P(a);E(a);var s=I(a,2),c=I(s,2),l=P(c);E(c),E(i),R(()=>{U(o,`${t.selectedCount??``} selected`),U(l,`Send ${t.selectedCount??``} to ${r.family??``}`)}),B(`click`,s,function(...e){t.onClear?.apply(this,e)}),B(`click`,c,function(...e){t.onPromote?.apply(this,e)}),Mi(1,i,()=>gv,()=>({reduceMotion:n()})),Mi(2,i,()=>_v,()=>({reduceMotion:n(),exitMs:200})),H(e,i)};W(a,e=>{t.selectedCount>0&&e(o)}),H(e,i),k()}Br([`click`]);var Nk=V(`<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),Pk=V(`<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>`,1),Fk=V(`<div style="padding: 6px var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; align-items: center;"><!></div>`);function Ik(e,t){O(t,!0);let n=q(t,`confirmRef`,15,null),r=q(t,`reduceMotion`,3,!1),i=A(()=>t.bulkConfirm===`accept`),a=A(()=>t.pendingCount===t.allPendingCount?`${t.pendingCount} annotations?`:`${t.pendingCount} of ${t.allPendingCount} pending?`);var o=Xr(),s=F(o),c=e=>{var o=Fk(),s=P(o),c=e=>{var r=Nk(),o=F(r),s=P(o);E(o);var c=I(o,2);fa(c,e=>n(e),()=>n());var l=I(c,2);G(l,`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);`),R(()=>{U(s,`${z(i)?`Accept`:`Reject`}
82
+ ${z(a)??``}`),G(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: ${z(i)?`var(--tandem-success-bg)`:`var(--tandem-error-bg)`}; color: ${z(i)?`var(--tandem-success-fg-strong)`:`var(--tandem-error-fg-strong)`}; font-weight: 600;`)}),B(`click`,c,function(...e){(z(i)?t.onConfirmAccept:t.onConfirmDismiss)?.apply(this,e)}),B(`click`,l,function(...e){t.onCancel?.apply(this,e)}),H(e,r)},l=e=>{var n=Pk(),r=F(n);G(r,`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 i=P(r);E(r);var a=I(r,2);G(a,`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);`),R(()=>U(i,`Accept All (${t.pendingCount??``})`)),B(`click`,r,function(...e){t.onRequestAccept?.apply(this,e)}),B(`click`,a,function(...e){t.onRequestDismiss?.apply(this,e)}),H(e,n)};W(s,e=>{t.bulkConfirm?e(c):e(l,-1)}),E(o),Mi(1,o,()=>gv,()=>({reduceMotion:r()})),Mi(2,o,()=>_v,()=>({reduceMotion:r(),exitMs:180})),H(e,o)};W(s,e=>{t.pendingCount>1&&e(c)}),H(e,o),k()}Br([`click`]);function Lk(e,t,n,r){return{handleKeyDown:i=>{let{key:a}=i;if(a!==`ArrowLeft`&&a!==`ArrowRight`&&a!==`ArrowUp`&&a!==`ArrowDown`&&a!==`Home`&&a!==`End`)return;let o=r?t.filter(e=>!r(e)):t;if(o.length===0)return;i.preventDefault();let s=e(),c=o.indexOf(s),l=o.length-1,u;u=a===`Home`?0:a===`End`?l:a===`ArrowLeft`||a===`ArrowUp`?c<=0?l:c-1:c>=l?0:c+1;let d=o[u];n(d);let f=i.currentTarget?.querySelectorAll(`[role="radio"]`),p=t.indexOf(d);f?.[p]?.focus()},tabIndexFor:n=>{if(r?.(n))return-1;let i=e(),a=r?t.filter(e=>!r(e)):t;return n===(r?.(i)?a[0]:i)?0:-1}}}var Rk=(e,t=m)=>{var n=Xr(),r=F(n),i=e=>{H(e,zk())},a=e=>{H(e,Bk())},o=e=>{H(e,Vk())},s=e=>{H(e,Hk())},c=e=>{H(e,Uk())},l=e=>{H(e,Wk())},u=e=>{H(e,Gk())};W(r,e=>{t()===`highlight`?e(i):t()===`comment`?e(a,1):t()===`lock`?e(o,2):t()===`sparkle`?e(s,3):t()===`pending`?e(c,4):t()===`check`?e(l,5):t()===`dismiss`&&e(u,6)}),H(e,n)},zk=Jr(`<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>`),Bk=Jr(`<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>`),Vk=Jr(`<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>`),Hk=Jr(`<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>`),Uk=Jr(`<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>`),Wk=Jr(`<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>`),Gk=Jr(`<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>`),Kk=V(`<span class="chip-text"> </span>`),qk=V(`<span></span>`),Jk=V(`<button type="button" role="radio"><!></button>`),Yk=V(`<div class="chip-bar svelte-v4eg2o" role="radiogroup" tabindex="-1"><span aria-hidden="true"></span> <!></div>`);function Xk(e,t){O(t,!0);let n=q(t,`value`,3,``),r=q(t,`options`,19,()=>[]),i=q(t,`onSet`,3,()=>{}),a=q(t,`groupAriaLabel`,3,``),o=q(t,`groupTestId`,3,``),s=Lk(()=>n(),Ar(()=>r().map(e=>e.value)),e=>i()(e)),c=j(null),l=j(N({left:0,width:0,ready:!1}));function u(){if(!z(c))return;let e=z(c).querySelector(`[aria-checked="true"]`);if(!e)return;let t=e.offsetLeft,n=e.offsetWidth;z(l).ready?M(l,{left:t,width:n,ready:!0},!0):(M(l,{left:t,width:n,ready:!1},!0),requestAnimationFrame(()=>{M(l,{left:t,width:n,ready:!0},!0)}))}L(()=>{if(n(),!z(c))return;let e=!1;return Dr().then(()=>{e||requestAnimationFrame(()=>{e||u()})}),()=>{e=!0}}),L(()=>{if(!z(c))return;let e=new ResizeObserver(()=>u());return e.observe(z(c)),()=>e.disconnect()});var d=Yk(),f=P(d);let p;pi(I(f,2),17,r,e=>e.value,(e,t)=>{let r=A(()=>z(t).value===n());var a=Jk();let c;var l=P(a),u=e=>{var n=Kk(),r=P(n,!0);E(n),R(()=>U(r,z(t).label)),H(e,n)},d=e=>{var n=qk();R(()=>Ui(n,1,`pip pip-${z(t).pip??``}`,`svelte-v4eg2o`)),H(e,n)},f=e=>{Rk(e,()=>z(t).icon)};W(l,e=>{z(t).kind===`text`?e(u):z(t).kind===`pip`?e(d,1):z(t).kind===`icon`&&e(f,2)}),E(a),R(e=>{c=Ui(a,1,`chip svelte-v4eg2o`,null,c,{"is-checked":z(r)}),K(a,`aria-checked`,z(r)),K(a,`aria-label`,z(t).label),K(a,`title`,z(t).label),K(a,`tabindex`,e),K(a,`data-testid`,`${o()??``}-${z(t).value??``}`)},[()=>s.tabIndexFor(z(t).value)]),B(`click`,a,()=>i()(z(t).value)),H(e,a)}),E(d),fa(d,e=>M(c,e),()=>z(c)),R(()=>{K(d,`aria-label`,a()),K(d,`data-testid`,o()),p=Ui(f,1,`chip-thumb svelte-v4eg2o`,null,p,{ready:z(l).ready}),G(f,`left: ${z(l).left??``}px; width: ${z(l).width??``}px;`)}),B(`keydown`,d,function(...e){s.handleKeyDown?.apply(this,e)}),H(e,d),k()}Br([`keydown`,`click`]);var Zk=V(`<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>`),Qk=V(`<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 $k(e,t){O(t,!0);let n=iD(av()),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=A(()=>[{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`}]),a=[{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 o=Xr(),s=F(o),c=e=>{var n=Qk(),o=P(n);Xk(o,{groupTestId:`filter-type`,groupAriaLabel:`Filter by type`,get value(){return t.filterType},get options(){return r},onSet:e=>t.onSetFilterType(e)});var s=I(o,2);Xk(s,{groupTestId:`filter-author`,groupAriaLabel:`Filter by author`,get value(){return t.filterAuthor},get options(){return z(i)},onSet:e=>t.onSetFilterAuthor(e)});var c=I(s,2);Xk(c,{groupTestId:`filter-status`,groupAriaLabel:`Filter by status`,get value(){return t.filterStatus},get options(){return a},onSet:e=>t.onSetFilterStatus(e)});var l=I(c,2),u=e=>{var n=Zk();B(`click`,n,function(...e){t.onClearFilters?.apply(this,e)}),H(e,n)};W(l,e=>{t.hasFilters&&e(u)});var d=I(l,2);E(n),B(`click`,d,function(...e){t.onToggleOpen?.apply(this,e)}),H(e,n)};W(s,e=>{t.open&&e(c)}),H(e,o),k()}Br([`click`]);var eA=V(`<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>`),tA=V(`<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
83
+ won't be saved. Close the other instance, or reclaim the lock if no other instance is
84
+ 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>`),nA=V(`<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>`),rA=V(`<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>`),iA=V(`<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>`),aA=V(`<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>`),oA=V(`<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 sA(e,t){O(t,!0);let n=q(t,`storeReadOnly`,3,!1),r=q(t,`claudeWorkingAnnotationId`,3,null),i=A(()=>t.reduceMotion?`auto`:`smooth`),a=`tandem:storeReadOnlyBannerDismissed`;function o(){try{return localStorage.getItem(a)===`true`}catch{return!1}}let s=j(N(o()));L(()=>{if(!n()){M(s,!1),M(m,null);try{localStorage.removeItem(a)}catch{}}});function c(){try{localStorage.setItem(a,`true`)}catch{}M(s,!0)}let l=`tandem:annotationSortMode`;function u(){try{return localStorage.getItem(l)===`chronological`?`chronological`:`position`}catch{return`position`}}let d=j(N(u()));function f(){M(d,z(d)===`position`?`chronological`:`position`,!0);try{localStorage.setItem(l,z(d))}catch{}}let p=j(!1),m=j(null);async function h(){if(!z(p)){M(p,!0),M(m,null);try{let e=await fetch(`${Il}${Mc}`,{method:`POST`});if(!e.ok){let t=`Could not reclaim the annotation store lock.`;try{let n=await e.json();typeof n?.message==`string`&&n.message&&(t=n.message)}catch{}M(m,t,!0)}}catch{M(m,`Could not reach the Tandem server.`)}finally{M(p,!1)}}}let g=j(`all`),_=j(`all`),v=j(`all`),y=j(!1),b=j(null),x=j(void 0),S=j(null);L(()=>{z(b)&&z(S)?.focus()}),L(()=>{z(g),z(_),z(v),M(b,null)}),L(()=>{t.onFilterChange?.(z(g),z(_),z(v))});let ee=j(N(new Map));L(()=>{if(!t.ydoc){M(ee,new Map,!0);return}let e=t.ydoc.getMap(Ga);function n(){let t=new Map;e.forEach(e=>{let n=e;if(n&&typeof n==`object`&&n.annotationId){let e=t.get(n.annotationId)??[];e.push(n),t.set(n.annotationId,e)}});for(let e of t.values())e.sort((e,t)=>e.timestamp-t.timestamp);M(ee,t,!0)}return n(),e.observe(n),()=>e.unobserve(n)});let C=A(()=>{let e=[],n=[];for(let r of t.annotations){r.status===`pending`&&n.push(r);let t;t=z(g)===`all`?!0:z(g)===`with-replacement`?r.suggestedText!==void 0:r.type===z(g);let i=z(_)===`all`||r.author===z(_),a=z(v)===`all`||r.status===z(v);t&&i&&a&&e.push(r)}return{filtered:e,pending:LD(e.filter(e=>e.status===`pending`),z(d)),reviewPending:e.filter(sc),resolved:LD(e.filter(e=>e.status!==`pending`),z(d)),allPending:n,reviewAllPending:t.annotations.filter(sc)}}),te=iD(av()),w=A(()=>z(g)!==`all`||z(_)!==`all`||z(v)!==`all`),ne=A(()=>{if(!z(w))return`All`;let e=[];if(z(g)!==`all`&&e.push({all:`All`,highlight:`Highlights`,comment:`Comments`,note:`Notes`,"with-replacement":`With replacement`}[z(g)]),z(_)!==`all`){let t={all:`Anyone`,claude:te.family,user:`You`,import:`Imported`};e.push(t[z(_)])}return z(v)!==`all`&&e.push({all:`Any status`,pending:`Pending`,accepted:`Accepted`,dismissed:`Dismissed`}[z(v)]),e.join(` · `)||`All`}),re=!1;L(()=>{if(z(g),z(_),z(v),!re){re=!0;return}Ar(()=>{if(t.activeAnnotationId){let e=document.querySelector(`[data-testid="annotation-card-${t.activeAnnotationId}"]`);if(e){e.scrollIntoView({block:`center`});return}console.warn(`[tandem] SidePanel: active annotation ${t.activeAnnotationId} not found on filter change; scrolling to top`)}z(x)?.scrollTo({top:0})})}),L(()=>{let e=t.activeAnnotationId;if(!e)return;let n=z(i),r=t.reduceMotion||typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,a=setTimeout(()=>{let t=document.querySelector(`[data-testid="annotation-card-${e}"]`);if(!t){console.warn(`[tandem] SidePanel: active annotation ${e} not found after 50ms delay; scroll-to-card skipped`);return}if(t.scrollIntoView({behavior:n,block:`nearest`}),r)return;t.classList.add(`tandem-annotation-flash`);let i=e=>{e.animationName.includes(`tandem-annotation-flash`)&&(t.classList.remove(`tandem-annotation-flash`),t.removeEventListener(`animationend`,i))};t.addEventListener(`animationend`,i)},50);return()=>clearTimeout(a)});let T=(e,n)=>ok(t.ydoc,e,n),ie=e=>ck(t.ydoc,e),ae=e=>uk(e,t.documentId),oe=(e,n)=>dk(e,n,t.documentId),se=new Map;function ce(e){se.set(e,`accept`),t.review.handleAccept(e)}function le(e){se.set(e,`dismiss`),t.review.handleDismiss(e)}let ue=j(void 0),de=j(null),fe=0;function pe(e){return t.annotations.find(t=>t.id===e)}function me(e){return t=>{let n=pe(e);n&&Ek(t,n,{accept:ce,dismiss:le,sendToClaude:ie,remove:ae,openEdit:e=>M(de,{id:e,kind:`edit`,nonce:++fe},!0),openReply:e=>M(de,{id:e,kind:`reply`,nonce:++fe},!0)})}}async function he(e){if(!Bm())return;let t=(e.target?.closest(`[data-annotation-id]`))?.getAttribute(`data-annotation-id`);if(!t)return;let n=pe(t);n&&(e.preventDefault(),e.stopPropagation(),await Dk(n,me(t)))}L(()=>{let e=z(ue);if(e)return e.addEventListener(`contextmenu`,he),()=>e.removeEventListener(`contextmenu`,he)}),L(()=>Ak());function ge(e){for(let n of z(C).reviewPending)t.review.resolveAnnotation(n.id,e);M(b,null)}let _e=j(N(new Set));L(()=>{let e=new Set(z(C).pending.filter(e=>e.author===`import`&&e.type===`note`).map(e=>e.id));Ar(()=>{let t=new Set([...z(_e)].filter(t=>e.has(t)));t.size!==z(_e).size&&M(_e,t,!0)})});function ve(e){let t=new Set(z(_e));t.has(e)?t.delete(e):t.add(e),M(_e,t,!0)}function ye(){let e=Array.from(z(_e));lk(t.ydoc,e),M(_e,new Set,!0)}function be(){M(_e,new Set,!0)}function xe(e){e.target===e.currentTarget&&t.onActiveAnnotationChange(null)}var Se=oA(),Ce=P(Se),we=e=>{var t=tA(),n=P(t),r=I(P(n),2),i=P(r),a=P(i,!0);E(i);var o=I(i,2);E(r),E(n);var s=I(n,2),l=e=>{var t=eA(),n=P(t,!0);E(t),R(()=>U(n,z(m))),H(e,t)};W(s,e=>{z(m)&&e(l)}),E(t),R(()=>{G(t,`padding: 10px 14px; margin: 10px 14px 0; background: ${VD.background??``}; border: 1px solid ${VD.border??``}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${VD.color??``}; display: flex; flex-direction: column; gap: var(--tandem-space-2);`),i.disabled=z(p),G(i,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: 1px solid ${VD.border??``}; border-radius: var(--tandem-r-2); background: none; color: ${VD.color??``}; cursor: ${z(p)?`wait`:`pointer`}; font-weight: 500;`),U(a,z(p)?`Reclaiming…`:`Reclaim`),G(o,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${VD.color??``}; cursor: pointer; font-weight: 500;`)}),B(`click`,i,h),B(`click`,o,c),H(e,t)};W(Ce,e=>{n()&&!z(s)&&e(we)});var Te=I(Ce,2),Ee=P(Te),De=P(Ee),Oe=I(P(De)),ke=e=>{var t=nA(),n=P(t,!0);E(t),R(()=>U(n,z(C).allPending.length)),H(e,t)};W(Oe,e=>{z(C).allPending.length>0&&e(ke)}),E(De);var Ae=I(De,2),je=P(Ae);E(Ae);var Me=I(Ae,2),Ne=P(Me),Pe=I(P(Ne),2),Fe=P(Pe,!0);E(Pe),E(Ne);var Ie=I(Ne,2),Le=P(Ie),Re=P(Le);E(Le),D(4),E(Ie),E(Me),E(Ee),E(Te);var ze=I(Te,2);$k(ze,{get filterType(){return z(g)},get filterAuthor(){return z(_)},get filterStatus(){return z(v)},get hasFilters(){return z(w)},get open(){return z(y)},onToggleOpen:()=>M(y,!z(y)),onSetFilterType:e=>{M(g,e,!0)},onSetFilterAuthor:e=>{M(_,e,!0)},onSetFilterStatus:e=>{M(v,e,!0)},onClearFilters:()=>{M(g,`all`),M(_,`all`),M(v,`all`)}});var Be=I(ze,2);ND(P(Be),{get annotations(){return t.annotations},get activeDocFormat(){return t.activeDocFormat},get documentId(){return t.documentId}}),E(Be);var Ve=I(Be,2);Mk(Ve,{get selectedCount(){return z(_e).size},onPromote:ye,onClear:be,get reduceMotion(){return t.reduceMotion}});var He=I(Ve,2);Ik(He,{get bulkConfirm(){return z(b)},get pendingCount(){return z(C).reviewPending.length},get allPendingCount(){return z(C).reviewAllPending.length},onConfirmAccept:()=>ge(`accepted`),onConfirmDismiss:()=>ge(`dismissed`),onCancel:()=>M(b,null),onRequestAccept:()=>M(b,`accept`),onRequestDismiss:()=>M(b,`dismiss`),get reduceMotion(){return t.reduceMotion},get confirmRef(){return z(S)},set confirmRef(e){M(S,e,!0)}});var Ue=I(He,2),We=e=>{var t=rA(),n=P(t),r=P(n,!0);E(n),E(t),R(()=>U(r,z(w)?`No annotations match filters.`:`No annotations yet. Open a document to get started.`)),B(`click`,t,xe),H(e,t)},Ge=e=>{var n=aA(),i=P(n);pi(i,17,()=>z(C).pending,e=>e.id,(e,n)=>{let i=A(()=>t.activeAnnotationId===z(n).id);{let a=A(()=>z(ee).get(z(n).id)??[]),o=A(()=>r()===z(n).id),s=A(()=>hk(z(n))?ce:void 0),c=A(()=>gk(z(n))?le:void 0),l=A(()=>bk(z(n))?ae:void 0),u=A(()=>yk(z(n))?ie:void 0),d=A(()=>vk(z(n))?T:void 0),f=A(()=>_k(z(n))?oe:void 0),p=A(()=>z(de)?.id===z(n).id?z(de):null),m=A(()=>z(_e).has(z(n).id)),h=A(()=>z(n).author===`import`&&z(n).type===`note`?ve:void 0);ek(e,{get annotation(){return z(n)},get replies(){return z(a)},get isReviewTarget(){return z(i)},get claudeTyping(){return z(o)},lifecycleMotion:!0,get reduceMotion(){return t.reduceMotion},get exitModes(){return se},get onAccept(){return z(s)},get onDismiss(){return z(c)},get onRemove(){return z(l)},get onSendToClaude(){return z(u)},get onEdit(){return z(d)},get onReply(){return z(f)},get openRequest(){return z(p)},onClick:()=>t.review.scrollToAnnotation(z(n)),get selected(){return z(m)},get onToggleSelect(){return z(h)}})}});var a=I(i,2),o=e=>{var n=iA(),r=P(n),i=P(r);E(r);var a=I(r,2);pi(a,21,()=>z(C).resolved,e=>e.id,(e,n)=>{{let r=A(()=>z(ee).get(z(n).id)??[]),i=A(()=>t.review.getRecentlyResolved().has(z(n).id));ek(e,{get annotation(){return z(n)},get replies(){return z(r)},get reduceMotion(){return t.reduceMotion},get onUndo(){return t.review.undoResolveAnnotation},get undoable(){return z(i)},onClick:()=>t.review.scrollToAnnotation(z(n))})}}),E(a),E(n),R(()=>U(i,`${z(C).resolved.length??``} resolved`)),H(e,n)};W(a,e=>{z(C).resolved.length>0&&e(o)}),E(n),fa(n,e=>M(ue,e),()=>z(ue)),B(`click`,n,xe),H(e,n)};W(Ue,e=>{z(C).filtered.length===0?e(We):e(Ge,-1)}),E(Se),fa(Se,e=>M(x,e),()=>z(x)),Pi(Se,(e,t)=>Bu?.(e,t),()=>`y`),R(()=>{U(je,`${z(C).allPending.length??``} pending annotation${z(C).allPending.length===1?``:`s`}`),K(Ne,`title`,z(d)===`position`?`Sorted by position in document. Click to sort oldest first.`:`Sorted oldest first. Click to sort by position in document.`),K(Ne,`aria-label`,z(d)===`position`?`Annotations sorted by position in document. Switch to oldest first.`:`Annotations sorted oldest first. Switch to position in document.`),U(Fe,z(d)===`position`?`Position`:`Oldest`),U(Re,`${z(ne)??``} ${z(C).filtered.length??``}`)}),B(`click`,Ne,f),B(`click`,Ie,()=>M(y,!z(y))),H(e,Se),k()}Br([`click`]);var cA=V(`<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>`),lA=V(`<span style="
85
+ flex-shrink: 0;
86
+ font-family: var(--tandem-font-mono);
87
+ font-size: var(--tandem-text-2xs, 10px);
88
+ font-weight: 500;
89
+ color: var(--tandem-fg-subtle);
90
+ background: var(--tandem-surface-muted);
91
+ border-radius: var(--tandem-r-pill);
92
+ padding: 0 var(--tandem-space-1);
93
+ min-width: 16px;
94
+ text-align: center;
95
+ line-height: 16px;
96
+ "> </span>`),uA=V(`<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>`),dA=V(`<ul style="list-style: none; margin: 0; padding: 0;"></ul>`),fA=V(`<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 pA(e,t){O(t,!0);let n=q(t,`annotations`,19,()=>[]),r=q(t,`focusTrigger`,3,0),i=q(t,`activeFilterType`,3,`all`),a=q(t,`activeFilterAuthor`,3,`all`),o=q(t,`activeFilterStatus`,3,`all`),s=j(N([])),c=j(-1),l=j(N([])),u=j(``),d=j(null),f=j(-1);L(()=>{let e=t.editor;if(!e||e.isDestroyed){M(s,[],!0);return}M(s,fm(e),!0),Ar(()=>{M(l,z(l).slice(0,z(s).length),!0),z(c)>=z(s).length&&M(c,Math.max(0,z(s).length-1),!0)});let n=()=>{M(s,fm(e),!0),M(l,z(l).slice(0,z(s).length),!0),z(c)>=z(s).length&&M(c,Math.max(0,z(s).length-1),!0)};return e.on(`update`,n),()=>{e.isDestroyed||e.off(`update`,n),M(s,[],!0)}}),L(()=>{r()>0&&(z(d)?.focus(),z(d)?.select())}),L(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=e.view.dom.closest(`.editor-scroll`)??e.view.dom.parentElement;function r(){if(!e||e.isDestroyed||z(s).length===0){M(f,-1);return}let t=(n?.getBoundingClientRect().top??0)+48,r=-1;for(let n=0;n<z(s).length;n++)try{e.view.coordsAtPos(z(s)[n].pos+1).top<=t&&(r=n)}catch{}M(f,r,!0)}return r(),n?.addEventListener(`scroll`,r),()=>n?.removeEventListener(`scroll`,r)});function p(){let e=t.editor;!e||e.isDestroyed||(z(u)?e.commands.find({query:z(u),caseSensitive:!1,wholeWord:!1,regexMode:!1}):e.commands.findClose())}function m(e){e.key===`Enter`?(e.preventDefault(),e.shiftKey?t.editor?.commands.findPrev():t.editor?.commands.findNext()):e.key===`Escape`&&(e.preventDefault(),M(u,``),t.editor?.commands.findClose(),z(d)?.blur())}let h=A(()=>{let e=t.editor;if(!e||e.isDestroyed||z(s).length===0)return[];let r=e.state.doc.content.size,c=[];for(let t of n()){if(i()!==`all`){if(i()===`with-replacement`){if(!t.suggestedText)continue}else if(t.type!==i())continue}if(!(a()!==`all`&&t.author!==a())&&!(o()!==`all`&&t.status!==o()))try{c.push(lD(e.state.doc,t.range.from))}catch{}}return z(s).map((e,t)=>{let n=t+1<z(s).length?z(s)[t+1].pos:r;return c.filter(t=>t>=e.pos&&t<n).length})});function g(e,n){let r=t.editor;if(!r||r.isDestroyed)return;let{state:i}=r;try{let t=i.doc.resolve(e.pos+1),n=Up.near(t);r.view.dispatch(i.tr.setSelection(n)),r.view.focus();let{node:a}=r.view.domAtPos(e.pos+1),o=a instanceof Element?a:a.parentElement,s=r.view.dom.closest(`.editor-scroll`)??r.view.dom.parentElement;if(o&&s){let e=o.getBoundingClientRect().top,t=s.getBoundingClientRect().top;s.scrollTop+=e-t-s.clientHeight*.05}}catch{}M(c,n,!0)}function _(e){if(z(s).length!==0)if(e.key===`ArrowDown`){e.preventDefault();let t=(z(c)+1)%z(s).length;M(c,t),z(l)[t]?.focus()}else if(e.key===`ArrowUp`){e.preventDefault();let t=(z(c)-1+z(s).length)%z(s).length;M(c,t),z(l)[t]?.focus()}else e.key===`Home`?(e.preventDefault(),M(c,0),z(l)[0]?.focus()):e.key===`End`&&(e.preventDefault(),M(c,z(s).length-1),z(l)[z(s).length-1]?.focus())}var v=fA(),y=I(P(v),2),b=P(y),x=I(P(b),2);$i(x),fa(x,e=>M(d,e),()=>z(d)),E(b),E(y);var S=I(y,2),ee=P(S),C=e=>{H(e,cA())},te=e=>{var t=dA();pi(t,21,()=>z(s),li,(e,t,n)=>{let r=A(()=>z(f)===n),i=A(()=>z(h)[n]??0);var a=uA(),o=P(a),s=P(o),u=I(s,2),d=P(u,!0);E(u);var p=I(u,2),m=e=>{var t=lA(),n=P(t,!0);E(t),R(()=>{K(t,`title`,`${z(i)??``} annotation${z(i)===1?``:`s`}`),U(n,z(i))}),H(e,t)};W(p,e=>{z(i)>0&&e(m)}),E(o),fa(o,(e,t)=>z(l)[t]=e,e=>z(l)?.[e],()=>[n]),E(a),R(()=>{K(o,`data-testid`,`outline-heading-${z(t).level}-${n}`),K(o,`tabindex`,z(c)===n||z(c)===-1&&n===0?0:-1),G(o,`
97
+ display: flex; align-items: center; width: 100%; text-align: left;
98
+ padding: var(--tandem-space-1) var(--tandem-space-3);
99
+ padding-left: calc(var(--tandem-space-1) + ${(z(t).level-1)*12}px);
100
+ font-size: ${z(t).level===1?`var(--tandem-text-sm)`:`var(--tandem-text-xs)`};
101
+ font-weight: ${z(t).level===1?600:z(t).level===2?500:400};
102
+ color: ${z(r)?`var(--tandem-accent)`:z(t).level===1?`var(--tandem-fg)`:z(t).level===2?`var(--tandem-fg-subtle)`:`var(--tandem-fg-muted)`};
103
+ background: ${z(r)?`var(--tandem-accent-bg)`:`none`};
104
+ border: none; cursor: pointer; line-height: 1.5;
105
+ transition: color 0.1s, background 0.1s;
106
+ gap: var(--tandem-space-2);
107
+ `),K(o,`title`,z(t).text),G(s,z(r)?`background-color: var(--tandem-accent); opacity: 1;`:``),U(d,z(t).text||`(untitled)`)}),B(`click`,o,()=>g(z(t),n)),zr(`focus`,o,()=>M(c,n,!0)),zr(`mouseenter`,o,e=>{z(r)||(e.currentTarget.style.background=`var(--tandem-surface-hover, var(--tandem-surface-muted))`)}),zr(`mouseleave`,o,e=>{z(r)||(e.currentTarget.style.background=`none`)}),H(e,a)}),E(t),H(e,t)};W(ee,e=>{z(s).length===0?e(C):e(te,-1)}),E(S),Pi(S,(e,t)=>Bu?.(e,t),()=>`y`),E(v),B(`keydown`,v,_),B(`input`,x,p),B(`keydown`,x,m),aa(x,()=>z(u),e=>M(u,e)),H(e,v),k()}Br([`keydown`,`input`,`click`]);var mA=V(`<div><!></div>`);function hA(e,t){O(t,!0);let n=ma(t,[`$$slots`,`$$events`,`$$legacy`,`kind`,`visible`]),r=A(()=>t.visible===void 0?void 0:`display: ${t.visible?`flex`:`none`}; flex-direction: column; flex: 1; min-height: 0;${t.kind===`outline`?` padding-bottom: var(--tandem-status-clearance-total, 88px);`:``}`);var i=Xr(),a=F(i),o=e=>{var i=mA(),a=P(i),o=e=>{jD(e,ga(()=>n,{get visible(){return t.visible}}))},s=e=>{pA(e,{get editor(){return t.editor},get annotations(){return t.annotations},get focusTrigger(){return t.focusTrigger},get activeFilterType(){return t.activeFilterType},get activeFilterAuthor(){return t.activeFilterAuthor},get activeFilterStatus(){return t.activeFilterStatus}})},c=e=>{sA(e,ga(()=>n))};W(a,e=>{t.kind===`chat`?e(o):t.kind===`outline`?e(s,1):e(c,-1)}),E(i),R(()=>G(i,z(r))),H(e,i)},s=e=>{jD(e,ga(()=>n))},c=e=>{pA(e,{get editor(){return t.editor},get annotations(){return t.annotations},get focusTrigger(){return t.focusTrigger},get activeFilterType(){return t.activeFilterType}})},l=e=>{sA(e,ga(()=>n))};W(a,e=>{z(r)?e(o):t.kind===`chat`?e(s,1):t.kind===`outline`?e(c,2):e(l,-1)}),H(e,i),k()}var gA=V(`<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>`),_A=V(`<button type="button" class="tandem-banner__cta" data-testid="convert-to-markdown-btn"> </button>`),vA=V(`<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
108
+ 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 yA(e,t){O(t,!0);let n=`tandem:reviewOnlyBannerDismissed`;function r(){try{return localStorage.getItem(n)===`true`}catch{return!1}}let i=j(N(r())),a=j(!1),o=j(null);async function s(){if(!(!t.documentId||z(a))){M(a,!0),M(o,null);try{let e=await fetch(`${Il}${Cc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId})});e.ok||M(o,(await e.json().catch(()=>null))?.message??`Conversion failed (HTTP ${e.status}).`,!0)}catch{M(o,`Could not reach the server.`)}finally{M(a,!1)}}}function c(){try{localStorage.setItem(n,`true`)}catch{}M(i,!0)}var l=Xr(),u=F(l),d=e=>{var n=vA(),r=I(P(n),2),i=e=>{var t=gA(),n=P(t,!0);E(t),R(()=>U(n,z(o))),H(e,t)};W(r,e=>{z(o)&&e(i)});var l=I(r,2),u=e=>{var t=_A(),n=P(t,!0);E(t),R(()=>{t.disabled=z(a),U(n,z(a)?`Converting…`:`Convert to Markdown`)}),B(`click`,t,s),H(e,t)};W(l,e=>{t.documentId&&e(u)});var d=I(l,2);E(n),B(`click`,d,c),H(e,n)};W(u,e=>{t.visible&&!z(i)&&e(d)}),H(e,l),k()}Br([`click`]);var bA=null;async function xA(e){if(bA!==null)return bA;let t=await fetch(`${Il}${mc}`,{signal:e});if(!t.ok)throw Error(`${mc} responded ${t.status} ${t.statusText}`);let n=await t.json();return bA=n,n}function SA(e){let t=j(null),n=j(!1);return L(()=>{if(!e())return;let r=!1,i=new AbortController,a=setTimeout(()=>i.abort(),3e3);return M(n,!0),xA(i.signal).then(e=>{r||M(t,e,!0)}).catch(e=>{e instanceof Error&&e.name!==`AbortError`&&console.warn(`[useAppInfo] failed to load /api/info:`,e)}).finally(()=>{clearTimeout(a),r||M(n,!1)}),()=>{r=!0,clearTimeout(a),i.abort()}}),{get info(){return z(t)},get loading(){return z(n)}}}var CA=V(`<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 wA(e,t){O(t,!0);let n=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`;var r=CA(),i=F(r),a=P(i);G(a,n);var o=I(a,2),s=P(o);$i(s),D(2),E(o),D(2),E(i);var c=I(i,2),l=P(c);G(l,n);var u=I(l,2),d=P(u);$i(d),D(2),E(u),D(2),E(c),R(()=>{ta(s,t.settings.highContrast),ta(d,t.settings.annotationPatterns)}),B(`change`,s,e=>t.onUpdate({highContrast:e.target.checked})),B(`change`,d,e=>t.onUpdate({annotationPatterns:e.target.checked})),H(e,r),k()}Br([`change`]);var TA=V(`<button role="radio"> </button>`),EA=V(`<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
109
+ neutral Light. A dark OS appearance still resolves to Dark.</div>`,1),DA=V(`<button role="radio"> </button>`),OA=V(`<button role="radio"> </button>`),kA=V(`<button role="radio"> </button>`),AA=V(`<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>`),jA=V(`<button role="radio"> </button>`),MA=V(`<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>`),NA=V(`<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
110
+ 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
111
+ 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.
112
+ When hidden they stay in the file and always save — only the on-screen markers are
113
+ hidden.</div></div> <div><label data-testid="appearance-rail-hover-reveal" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Reveal rails on hover</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Hover a closed outline or annotations rail to float it over the document without
114
+ resizing it; click its edge to pin it open. When off, rails reveal only on click.</div></div>`,1);function PA(e,t){O(t,!0);let 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(e){return t.settings.fontByExtension?.[e]??t.settings.editorFont}function a(e,n){t.onUpdate({fontByExtension:{...t.settings.fontByExtension,[e]:n}})}function o(){t.onUpdate({fontByExtension:{}})}let s=A(()=>Object.keys(t.settings.fontByExtension??{}).length>0),c=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,l=[[`showAuthorship`,`appearance-show-authorship`,`Authorship colors`],[`showComments`,`appearance-show-comments`,`Comments`],[`showHighlights`,`appearance-show-highlights`,`Highlights`],[`showNotes`,`appearance-show-notes`,`Notes (private)`]];function u(e,t){return[`flex: 1;`,`padding: var(--tandem-space-2);`,`min-height: 24px;`,`border: 2px solid ${e?`var(--tandem-accent)`:`var(--tandem-border)`};`,`border-radius: var(--tandem-r-3);`,`background: ${t?`var(--tandem-surface-muted)`:e?`var(--tandem-accent-bg)`:`var(--tandem-surface)`};`,`cursor: ${t?`not-allowed`:`pointer`};`,`text-align: center;`,`font-size: 11px;`,`color: ${t?`var(--tandem-fg-subtle)`:e?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-muted)`};`,`font-weight: ${e?600:400};`,`opacity: ${t?.6:1};`,`transition: border-color 0.15s, background 0.15s;`].join(` `)}let d=Lk(()=>t.settings.theme,[`light`,`warm`,`dark`,`system`],e=>t.onUpdate({theme:e})),f=Lk(()=>t.settings.primaryTab,[`chat`,`annotations`],e=>t.onUpdate({primaryTab:e})),p=Lk(()=>t.settings.textSize,[`s`,`m`,`l`],e=>t.onUpdate({textSize:e})),m=Lk(()=>t.settings.editorFont,[`sans`,`serif`,`mono`],e=>t.onUpdate({editorFont:e})),h=Lk(()=>t.settings.density,[`compact`,`cozy`,`spacious`],e=>t.onUpdate({density:e})),g={};for(let e of n)g[e.format]=Lk(()=>i(e.format),[`sans`,`serif`,`mono`],t=>a(e.format,t));var _=NA(),y=F(_),b=P(y);G(b,c);var x=I(b,2);pi(x,20,()=>[`light`,`warm`,`dark`,`system`],e=>e,(e,n)=>{var r=TA(),i=P(r,!0);E(r),R((e,a)=>{K(r,`data-testid`,`theme-${n}-btn`),K(r,`aria-checked`,t.settings.theme===n),K(r,`tabindex`,e),G(r,a),U(i,n===`light`?`Light`:n===`warm`?`Warm`:n===`dark`?`Dark`:`System`)},[()=>d.tabIndexFor(n),()=>u(t.settings.theme===n)]),B(`click`,r,()=>t.onUpdate({theme:n})),H(e,r)}),E(x);var S=I(x,2),ee=e=>{var n=EA(),r=F(n),i=P(r);$i(i),D(2),E(r),D(2),R(()=>ta(i,t.settings.systemLightVariant===`warm`)),B(`change`,i,e=>t.onUpdate({systemLightVariant:e.target.checked?`warm`:`light`})),H(e,n)};W(S,e=>{t.settings.theme===`system`&&e(ee)}),E(y);var C=I(y,2),te=P(C);G(te,c);var w=I(te,2),ne=P(w),re=I(ne,2);E(w),E(C);var T=I(C,2),ie=P(T);G(ie,c);var ae=I(ie,2);pi(ae,20,()=>[`s`,`m`,`l`],e=>e,(e,n)=>{var r=DA(),i=P(r,!0);E(r),R((e,a)=>{K(r,`data-testid`,`text-size-${n}-btn`),K(r,`aria-checked`,t.settings.textSize===n),K(r,`tabindex`,e),G(r,a),U(i,n===`s`?`Small`:n===`m`?`Medium`:`Large`)},[()=>p.tabIndexFor(n),()=>u(t.settings.textSize===n)]),B(`click`,r,()=>t.onUpdate({textSize:n})),H(e,r)}),E(ae),D(2),E(T);var oe=I(T,2),se=P(oe);G(se,c);var ce=I(se,2),le=I(P(ce),2);$i(le),E(ce),E(oe);var ue=I(oe,2),de=P(ue);G(de,c);var fe=I(de,2);pi(fe,20,()=>[[`sans`,`Sans-serif`],[`serif`,`Serif (Source Serif 4)`],[`mono`,`Monospace`]],([e,t])=>e,(e,n)=>{var r=A(()=>v(n,2));let i=()=>z(r)[0],a=()=>z(r)[1];var o=OA(),s=P(o,!0);E(o),R((e,n)=>{K(o,`data-testid`,`editor-font-${i()}-btn`),K(o,`aria-checked`,t.settings.editorFont===i()),K(o,`tabindex`,e),G(o,n),U(s,a())},[()=>m.tabIndexFor(i()),()=>u(t.settings.editorFont===i())]),B(`click`,o,()=>t.onUpdate({editorFont:i()})),H(e,o)}),E(fe),E(ue);var pe=I(ue,2),me=P(pe),he=P(me);G(he,`${c} margin-bottom: 0;`);var ge=I(he,2);E(me);var _e=I(me,2);pi(_e,21,()=>n,e=>e.format,(e,t)=>{var n=AA(),o=P(n),s=P(o,!0);E(o);var c=I(o,2);pi(c,21,()=>r,([e,t])=>e,(e,n)=>{var r=A(()=>v(z(n),2));let o=()=>z(r)[0],s=()=>z(r)[1];var c=kA(),l=P(c,!0);E(c),R((e,n,r)=>{K(c,`data-testid`,`font-by-extension-${z(t).format}-${o()}`),K(c,`aria-checked`,e),K(c,`tabindex`,n),G(c,r),U(l,s())},[()=>i(z(t).format)===o(),()=>g[z(t).format].tabIndexFor(o()),()=>u(i(z(t).format)===o())]),B(`click`,c,()=>a(z(t).format,o())),H(e,c)}),E(c),E(n),R(()=>{K(n,`data-testid`,`font-by-extension-row-${z(t).format}`),U(s,z(t).label),K(c,`aria-label`,`Default font for ${z(t).label}`)}),B(`keydown`,c,function(...e){g[z(t).format].handleKeyDown?.apply(this,e)}),H(e,n)}),E(_e),D(2),E(pe);var ve=I(pe,2),ye=P(ve);G(ye,c);var be=I(ye,2);pi(be,20,()=>[[`compact`,`Compact`],[`cozy`,`Cozy`],[`spacious`,`Spacious`]],([e,t])=>e,(e,n)=>{var r=A(()=>v(n,2));let i=()=>z(r)[0],a=()=>z(r)[1];var o=jA(),s=P(o,!0);E(o),R((e,n)=>{K(o,`data-testid`,`density-${i()}-btn`),K(o,`aria-checked`,t.settings.density===i()),K(o,`tabindex`,e),G(o,n),U(s,a())},[()=>h.tabIndexFor(i()),()=>u(t.settings.density===i())]),B(`click`,o,()=>t.onUpdate({density:i()})),H(e,o)}),E(be),E(ve);var xe=I(ve,2),Se=P(xe);G(Se,c),pi(I(Se,2),17,()=>l,([e,t,n])=>e,(e,n)=>{var r=A(()=>v(z(n),3));let i=()=>z(r)[0],a=()=>z(r)[1],o=()=>z(r)[2];var s=MA(),c=P(s);$i(c);var l=I(c,2),u=P(l,!0);E(l),E(s),R(()=>{K(s,`data-testid`,a()),ta(c,t.settings[i()]),U(u,o())}),B(`change`,c,e=>t.onUpdate({[i()]:e.target.checked,...t.settings.decorationsMuted?{decorationsMuted:!1}:{}})),H(e,s)}),D(2),E(xe);var Ce=I(xe,2),we=P(Ce),Te=P(we);$i(Te),D(2),E(we),D(2),E(Ce);var Ee=I(Ce,2),De=P(Ee),Oe=P(De);$i(Oe),D(2),E(De),D(2),E(Ee);var ke=I(Ee,2),Ae=P(ke),je=P(Ae);$i(je),D(2),E(Ae),D(2),E(ke);var Me=I(ke,2),Ne=P(Me),Pe=P(Ne);$i(Pe),D(2),E(Ne),D(2),E(Me),R((e,n,r,i)=>{K(ne,`aria-checked`,t.settings.primaryTab===`chat`),K(ne,`tabindex`,e),G(ne,n),K(re,`aria-checked`,t.settings.primaryTab===`annotations`),K(re,`tabindex`,r),G(re,i),ea(le,t.settings.accentHue),ge.disabled=!z(s),G(ge,`background: none; border: none; padding: 0; font-size: var(--tandem-text-2xs); color: ${z(s)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-subtle)`}; cursor: ${z(s)?`pointer`:`default`}; text-decoration: ${z(s)?`underline`:`none`};`),ta(Te,t.settings.reduceMotion),ta(Oe,t.settings.formattingBarVisible),ta(je,t.settings.showRawMarkdown),ta(Pe,t.settings.railHoverReveal)},[()=>f.tabIndexFor(`chat`),()=>u(t.settings.primaryTab===`chat`),()=>f.tabIndexFor(`annotations`),()=>u(t.settings.primaryTab===`annotations`)]),B(`keydown`,x,function(...e){d.handleKeyDown?.apply(this,e)}),B(`keydown`,w,function(...e){f.handleKeyDown?.apply(this,e)}),B(`click`,ne,()=>t.onUpdate({primaryTab:`chat`})),B(`click`,re,()=>t.onUpdate({primaryTab:`annotations`})),B(`keydown`,ae,function(...e){p.handleKeyDown?.apply(this,e)}),B(`input`,le,e=>t.onUpdate({accentHue:Number(e.target.value)})),B(`keydown`,fe,function(...e){m.handleKeyDown?.apply(this,e)}),B(`click`,ge,o),B(`keydown`,be,function(...e){h.handleKeyDown?.apply(this,e)}),B(`change`,Te,e=>t.onUpdate({reduceMotion:e.target.checked})),B(`change`,Oe,e=>t.onUpdate({formattingBarVisible:e.target.checked})),B(`change`,je,e=>t.onUpdate({showRawMarkdown:e.target.checked})),B(`change`,Pe,e=>t.onUpdate({railHoverReveal:e.target.checked})),H(e,_),k()}Br([`keydown`,`click`,`change`,`input`]);var FA=V(`<button type="button" role="radio"> </button>`),IA=V(`<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>`),LA=V(`<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 RA(e,t){O(t,!0);let n=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,r=Bm();function i(e){let n=e?.trim();t.onUpdate({defaultSaveDirectory:n||null})}function a(e){e.preventDefault(),i(e.target.elements.namedItem(`default-save-dir`)?.value??null)}async function o(){let e;try{({open:e}=await Ul(()=>import(`./dist-js-BWAGOggB.js`),__vite__mapDeps([2,1])))}catch(e){console.warn(`[Settings] Folder picker import failed:`,e),t.notify(`error`,`Folder picker plugin unavailable`);return}try{let t=await e({directory:!0,multiple:!1,title:`Choose default save folder`});typeof t==`string`&&i(t)}catch(e){console.warn(`[Settings] Folder picker open() failed:`,e),t.notify(`error`,`Folder picker permission denied or IPC error`)}}let s=[{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`}],c=Lk(()=>t.settings.editorMeasure,s.map(e=>e.value),e=>t.onUpdate({editorMeasure:e})),l=A(()=>s.find(e=>e.value===t.settings.editorMeasure)?.hint??``);var u=LA(),d=P(u);G(d,n);var f=I(d,4);pi(f,21,()=>s,e=>e.value,(e,n)=>{let r=A(()=>t.settings.editorMeasure===z(n).value);var i=FA(),a=P(i,!0);E(i),R(e=>{K(i,`aria-checked`,z(r)),K(i,`tabindex`,e),K(i,`data-testid`,`editor-measure-${z(n).value}`),G(i,`flex: 1; padding: 6px 4px; border: none; border-radius: var(--tandem-r-1); cursor: pointer; font-size: 11px; font-weight: ${z(r)?600:400}; background: ${z(r)?`var(--tandem-accent)`:`transparent`}; color: ${z(r)?`var(--tandem-accent-fg)`:`var(--tandem-fg)`};`),U(a,z(n).label)},[()=>c.tabIndexFor(z(n).value)]),B(`click`,i,()=>t.onUpdate({editorMeasure:z(n).value})),H(e,i)}),E(f);var p=I(f,2),m=P(p,!0);E(p);var h=I(p,2),g=P(h);G(g,n);var _=I(g,4),v=P(_);$i(v);var y=I(v,2),b=e=>{var t=IA();B(`click`,t,o),H(e,t)};W(y,e=>{r&&e(b)});var x=I(y,2);E(_),E(h),E(u),R(()=>{U(m,z(l)),ea(v,t.settings.defaultSaveDirectory??``),x.disabled=!t.settings.defaultSaveDirectory,G(x,`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: ${t.settings.defaultSaveDirectory?`pointer`:`default`}; opacity: ${t.settings.defaultSaveDirectory?1:.5};`)}),B(`keydown`,f,function(...e){c.handleKeyDown?.apply(this,e)}),zr(`submit`,_,a),zr(`blur`,v,e=>i(e.currentTarget.value)),B(`click`,x,()=>i(null)),H(e,u),k()}Br([`keydown`,`click`]);var zA=V(`<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 BA(e,t){let n=q(t,`defaultOpen`,3,!1);var r=zA(),i=P(r),a=I(P(i));E(i);var o=I(i,2);bi(P(o),()=>t.children),E(o),E(r),R(()=>{K(r,`data-testid`,t.testid),r.open=n(),K(i,`data-testid`,t.testid?`${t.testid}-toggle`:void 0),U(a,` ${t.label??``}`)}),H(e,r)}var VA=V(`<span style="color: var(--tandem-fg-subtle);"> </span>`),HA=V(`<button type="button" data-testid="network-restart-sidecar"> </button>`),UA=V(`<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop &amp;&amp; tandem start</code> to restart</span>`),WA=V(`<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>`),GA=V(`<span><strong>Host:</strong> </span>`),KA=V(`<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>`),qA=V(`<option> </option>`),JA=V(`<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>`),YA=V(`<!> <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</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> <!>`,1),XA=V(`<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 ZA(e,t){O(t,!0);let n=SA(()=>t.open),r=Bm(),i=j(null),a=j(!1);async function o(){if(r){M(a,!0),M(i,null);try{let{invoke:e}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);await e(`restart_sidecar`)}catch(e){M(i,e instanceof Error?e.message:String(e),!0)}finally{M(a,!1)}}}let s=[{value:`exponential`,label:`Exponential backoff`},{value:`constant-2s`,label:`Constant (2s)`}],c=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,l=`font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);`,u=A(()=>n.info?.transport),d=A(()=>n.info?.bindHost),f=A(()=>n.info?.bindPort),p=A(()=>z(u)===`http`),m=A(()=>n.info?.tokenRotatedAt);var h=XA(),g=F(h),_=P(g);G(_,c);var v=I(_,2),y=P(v),b=I(y,2),x=P(b),S=I(x),ee=e=>{var n=VA(),r=P(n);E(n),R(()=>U(r,`· ${t.reconnectAttempts??``} retry attempt${t.reconnectAttempts===1?``:`s`}`)),H(e,n)};W(S,e=>{t.reconnectAttempts>0&&e(ee)}),E(b);var C=I(b,2),te=e=>{var t=HA(),n=P(t,!0);E(t),R(()=>{t.disabled=z(a),G(t,`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: ${z(a)?.5:1};`),U(n,z(a)?`Restarting…`:`Restart sidecar`)}),B(`click`,t,o),H(e,t)},w=e=>{H(e,UA())};W(C,e=>{r?e(te):e(w,-1)}),E(v);var ne=I(v,2),re=e=>{var t=WA(),n=P(t,!0);E(t),R(()=>U(n,z(i))),H(e,t)};W(ne,e=>{z(i)&&e(re)}),E(g);var T=I(g,2),ie=P(T);G(ie,c);var ae=I(ie,2),oe=P(ae),se=I(P(oe));E(oe);var ce=I(oe,2),le=e=>{var t=GA(),n=I(P(t));E(t),R(()=>U(n,` ${z(d)??``}`)),H(e,t)};W(ce,e=>{z(d)&&e(le)}),E(ae),E(T),BA(I(T,2),{label:`Advanced`,testid:`network-advanced`,children:(e,n)=>{var r=YA(),i=F(r),a=e=>{var t=KA(),n=P(t);G(n,c);var r=I(n,2),i=P(r,!0);E(r),G(I(r,2),l),E(t),R(()=>U(i,z(f)??`—`)),H(e,t)};W(i,e=>{z(p)&&e(a)});var o=I(i,2),u=P(o);G(u,c);var d=I(P(u)),h=P(d);E(d),E(u);var g=I(u,2);$i(g),D(2),E(o);var _=I(o,2),v=P(_);G(v,c);var y=I(v,2);pi(y,21,()=>s,e=>e.value,(e,t)=>{var n=qA(),r=P(n,!0);E(n);var i={};R(()=>{U(r,z(t).label),i!==(i=z(t).value)&&(n.value=(n.__value=z(t).value)??``)}),H(e,n)}),E(y);var b;Ki(y),E(_);var x=I(_,2),S=e=>{var t=JA(),n=P(t);G(n,c);var r=I(n,2),i=P(r,!0);E(r),G(I(r,2),l),E(t),R(e=>U(i,e),[()=>z(m)===null?`Auth token not yet created`:`Last rotated: ${new Date(z(m)).toLocaleString()}`]),H(e,t)};W(x,e=>{z(m)!==void 0&&e(S)}),R(()=>{U(h,`${t.settings.degradedBannerDelayMs/1e3}s`),ea(g,t.settings.degradedBannerDelayMs),b!==(b=t.settings.sidecarRetryStrategy)&&(y.value=(y.__value=t.settings.sidecarRetryStrategy)??``,Gi(y,t.settings.sidecarRetryStrategy))}),B(`input`,g,e=>t.onUpdate({degradedBannerDelayMs:Number(e.target.value)})),B(`change`,y,e=>t.onUpdate({sidecarRetryStrategy:e.target.value})),H(e,r)},$$slots:{default:!0}}),R(e=>{G(y,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${t.connected?`var(--tandem-success)`:`var(--tandem-error)`}; flex-shrink: 0;`),U(x,`${t.connected?`Connected to Tandem server`:`Disconnected`} `),U(se,` ${e??``}`)},[()=>z(u)?z(u).toUpperCase():`—`]),H(e,h),k()}Br([`click`,`input`,`change`]);var QA=`INVALID_BODY`,$A=`PATH_REJECTED`,ej=`LAUNCHER_IN_PROGRESS`,tj=`LAUNCHER_NOT_AVAILABLE`,nj=`NO_CLAUDE_INTEGRATION`,rj=V(`<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>`),ij=V(`<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>`),aj=V(`<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>`),oj=V(`<div role="alert" style="font-size: 11px; color: var(--tandem-error-fg);"> </div>`),sj=V(`<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>`),cj=V(`<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>`),lj=V(`<!> <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 uj(e,t){O(t,!0);function n(e){switch(e){case $A:return`Working directory must be a folder inside your home directory.`;case QA:return`Working directory path is invalid.`;case ej:return`Another working-directory update is in progress. Try again.`;case nj:return`No Claude Code integration is configured.`;case tj: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=j(null),a=j(!1),o=j(null),s=j(!1),c=j(!1),l=j(null),u=A(()=>z(s)&&!z(c)&&!z(l)),d=!0;va(()=>{d=!1});async function f(){try{let e=await fetch(`${Il}/api/integrations`);if(!d)return;if(!e.ok){M(l,`Failed to load integrations (HTTP ${e.status}).`);return}let t=await e.json();if(!d)return;let n=t.integrations?.find(e=>e.kind===`claude-code`);n&&(M(c,!0),M(i,n.workingDirectory??null,!0))}catch(e){if(!d)return;console.warn(`[Settings] Failed to load workingDirectory:`,e),M(l,`Couldn't load Claude working directory.`)}finally{d&&M(s,!0)}}f();async function p(e){M(a,!0),M(o,null);try{let r=await fetch(`${Il}${Uc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workingDirectory:e})});if(!d)return;if(!r.ok){let e=await r.json().catch(()=>({}));if(!d)return;M(o,n(e.code),!0);return}let a=await r.json();if(!d)return;M(i,a.workingDirectory??null,!0),t.notify(`info`,`Working directory saved.`)}catch(e){if(!d)return;console.warn(`[Settings] Failed to save workingDirectory:`,e),M(o,`Couldn't save working directory.`)}finally{d&&M(a,!1)}}async function m(){let e;try{({open:e}=await Ul(()=>import(`./dist-js-BWAGOggB.js`),__vite__mapDeps([2,1])))}catch(e){console.warn(`[Settings] Folder picker import failed:`,e),t.notify(`error`,`Folder picker plugin unavailable`);return}try{let t=await e({directory:!0,multiple:!1,title:`Choose Claude working directory`});typeof t==`string`&&p(t)}catch(e){console.warn(`[Settings] Folder picker open() failed:`,e),t.notify(`error`,`Folder picker permission denied or IPC error`)}}function h(e){e.preventDefault();let t=e.target.elements.namedItem(`wd`)?.value.trim();p(t||null)}function g(){p(null)}var _=lj(),v=F(_),y=e=>{var t=rj(),n=I(P(t),4);E(t),B(`click`,n,r),H(e,t)};W(v,e=>{z(u)&&e(y)});var b=I(v,4),x=P(b),S=I(P(x)),ee=P(S);E(S),E(x);var C=I(x,4);$i(C),K(C,`step`,100);var te=I(C,2),w=P(te),ne=P(w);E(w);var re=I(w,2),T=P(re);E(re),E(te),E(b);var ie=I(b,2),ae=P(ie);$i(ae),D(2),E(ie);var oe=I(ie,2),se=P(oe);$i(se),D(2),E(oe);var ce=I(oe,4),le=e=>{var t=ij(),n=P(t,!0);E(t),R(()=>U(n,z(l))),H(e,t)};W(ce,e=>{z(s)&&!z(c)&&z(l)&&e(le)});var ue=I(ce,2),de=e=>{var t=sj(),n=I(P(t),4),r=P(n);$i(r),K(r,`placeholder`,`(default: home)`);var s=I(r,2);E(n);var c=I(n,2),l=P(c),u=e=>{var t=aj();R(()=>t.disabled=z(a)),B(`click`,t,m),H(e,t)},d=A(()=>Bm());W(l,e=>{z(d)&&e(u)});var f=I(l,2);E(c);var p=I(c,2),_=e=>{var t=oj(),n=P(t,!0);E(t),R(()=>U(n,z(o))),H(e,t)};W(p,e=>{z(o)&&e(_)}),E(t),R(()=>{ea(r,z(i)??``),r.disabled=z(a),s.disabled=z(a),f.disabled=z(a)||z(i)===null}),zr(`submit`,n,h),B(`click`,f,g),H(e,t)};W(ue,e=>{z(s)&&z(c)&&e(de)});var fe=I(ue,2),pe=P(fe,!0);E(fe);var me=I(fe,2),he=e=>{var t=Xr();oi(F(t),()=>Ul(()=>import(`./CoworkSettings-BWtK14Nl.js`),__vite__mapDeps([4,5])),e=>{H(e,cj())},(e,t)=>{let n=A(()=>z(t).default);var r=Xr();xi(F(r),()=>z(n),(e,t)=>{t(e,{})}),H(e,r)}),H(e,t)},ge=A(()=>Bm());W(me,e=>{z(ge)&&e(he)}),R((e,n,r)=>{U(ee,`${e??``}s`),K(C,`min`,500),K(C,`max`,Ia),ea(C,t.settings.selectionDwellMs),U(ne,`${n??``}s`),U(T,`${r??``}s`),ta(ae,t.settings.selectionToolbar),ta(se,t.settings.marginView),U(pe,z(u)?`Open integration wizard…`:`Reopen integration wizard…`)},[()=>(t.settings.selectionDwellMs/1e3).toFixed(1),()=>(500/1e3).toFixed(1),()=>(Ia/1e3).toFixed(1)]),B(`input`,C,e=>t.onUpdate({selectionDwellMs:Number(e.target.value)})),B(`change`,ae,e=>t.onUpdate({selectionToolbar:e.target.checked})),B(`change`,se,e=>t.onUpdate({marginView:e.target.checked})),B(`click`,fe,r),H(e,_),k()}Br([`click`,`input`,`change`]);function dj(e){let t=e?.trim();return t?t.slice(0,40):`You`}function fj(){try{return dj(localStorage.getItem(ao))}catch{return`You`}}function pj(e){let t=dj(e);try{localStorage.setItem(ao,t)}catch{}return typeof window<`u`&&window.dispatchEvent(new Event(oo)),t}function mj(e){let t=()=>e(fj()),n=t=>{t.key===`tandem:userName`&&e(dj(t.newValue))};return window.addEventListener(oo,t),window.addEventListener(`storage`,n),()=>{window.removeEventListener(oo,t),window.removeEventListener(`storage`,n)}}function hj(){let e=j(N(fj()));return va(mj(t=>{M(e,t,!0)})),{get userName(){return z(e)},setUserName:t=>{M(e,pj(t),!0)}}}var gj=V(`<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 _j(e,t){O(t,!0);let n=hj(),r=j(N(n.userName)),i=j(void 0);L(()=>{let e=n.userName;z(r)!==e&&document.activeElement!==z(i)&&M(r,e,!0)});var a=gj(),o=F(a),s=I(P(o),2);$i(s),fa(s,e=>M(i,e),()=>z(i)),E(o);var c=I(o,2),l=I(P(c),2),u=P(l),d=I(u,2);E(l),D(2),E(c);var f=I(c,2),p=P(f);$i(p),D(2),E(f),D(2),R(()=>{ea(s,z(r)),K(s,`maxlength`,40),K(u,`aria-checked`,t.settings.defaultMode===`tandem`),K(d,`aria-checked`,t.settings.defaultMode===`solo`),ta(p,t.settings.soloRailHidden)}),B(`input`,s,e=>{M(r,e.target.value,!0)}),zr(`blur`,s,()=>n.setUserName(z(r))),B(`keydown`,s,e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(M(r,n.userName,!0),e.currentTarget.blur())}),B(`click`,u,()=>t.onUpdate({defaultMode:`tandem`})),B(`click`,d,()=>t.onUpdate({defaultMode:`solo`})),B(`change`,p,e=>t.onUpdate({soloRailHidden:e.target.checked})),H(e,a),k()}Br([`input`,`keydown`,`click`,`change`]);var vj=_g({baseUrl:`http://127.0.0.1:${xa}`,pathFor:ig});function yj(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function bj(){return crypto.randomUUID()}function xj(e){if(e.provider!==void 0&&!Sl.includes(e.provider))throw Error(`Invalid model provider: ${String(e.provider)}`)}async function Sj(e,t){let n=await vj.set(e,t);if(n.status===`ok`)return;let r=n.status===`unavailable`?`KEYCHAIN_UNAVAILABLE`:`STORE_FAILED`;throw Error(`Failed to store model key (${r})`)}function Cj(e){return{get models(){return e.settings.models},get defaultModelId(){return e.settings.defaultModelId},get hasLegacyKeys(){return e.settings.models.some(e=>typeof e._legacyApiKey==`string`)},async addModel(t,n){xj(t);let r=bj(),i;n&&n.length>0&&(i=yj(),await Sj(i,n));let a={...t,id:r,...i?{apiKeyRef:i}:{}};return e.updateSettings({models:[...e.settings.models,a]}),r},async updateModel(t,n,r){xj(n);let i=e.settings.models.find(e=>e.id===t);if(!i)return;let a;r!==void 0&&r.length>0&&(a=yj(),await Promise.all([Sj(a,r),i.apiKeyRef?vj.delete(i.apiKeyRef):Promise.resolve()])),e.updateSettings({models:e.settings.models.map(e=>e.id===t?{...e,...n,...a?{apiKeyRef:a}:{}}:e)})},async deleteModel(t){let n=e.settings.models.find(e=>e.id===t);n?.apiKeyRef&&await vj.delete(n.apiKeyRef),e.updateSettings({models:e.settings.models.filter(e=>e.id!==t),defaultModelId:e.settings.defaultModelId===t?null:e.settings.defaultModelId})},toggleEnabled(t){e.updateSettings({models:e.settings.models.map(e=>e.id===t?{...e,enabled:!e.enabled}:e)})},setDefault(t){e.updateSettings({defaultModelId:t})},async migrateLegacyKeys(){let t=e.settings.models,n=t.map((e,t)=>typeof e._legacyApiKey==`string`?t:-1).filter(e=>e>=0);if(n.length===0)return{migrated:0,failed:0};let r=n.map(()=>yj()),i=await Promise.allSettled(n.map((e,n)=>Sj(r[n],t[e]._legacyApiKey))),a=t.slice(),o=0,s=0;return i.forEach((e,i)=>{let c=n[i];if(e.status===`fulfilled`){let e={...t[c],apiKeyRef:r[i]};delete e._legacyApiKey,a[c]=e,o++}else s++}),o>0&&e.updateSettings({models:a}),{migrated:o,failed:s}}}}var wj=V(`<option> </option>`),Tj=V(`<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>`),Ej=V(`<input data-testid="model-edit-apikey" class="mem-input mem-input--mono svelte-1pwv6ag" type="password" autocomplete="off"/>`),Dj=V(`<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">API key</span> <!></label>`),Oj=V(`<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>`),kj=V(`<p class="mem-advanced-help svelte-1pwv6ag">Per-model parameter overrides (temperature, max tokens, etc.) are not editable in
123
+ this preview. The data model accepts a \`params\` map for forward-compat with
124
+ Wave 6 surfaces.</p>`),Aj=V(`<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 jj(e,t){O(t,!0);let 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=Ar(()=>t.entry),i=j(N(r?.provider??`anthropic`)),a=j(N(r?.displayName??``)),o=j(N(r?.modelId??``)),s=j(N(r?.endpoint??``)),c=j(N(r?.enabled??!0)),l=j(``),u=r!==void 0&&!!r.apiKeyRef,d=j(N(r===void 0||!u)),f=r!==void 0,p=A(()=>z(i)===`anthropic`||z(i)===`openai`||z(i)===`gemini`),m=A(()=>z(i).startsWith(`local-`)),h=r?.apiKeyRef?r.apiKeyRef.slice(-4):``,g=A(()=>z(a).trim().length>0&&z(o).trim().length>0&&(!z(p)||!z(d)||z(l).trim().length>0));function _(e){if(e.preventDefault(),!z(g))return;let n={provider:z(i),displayName:z(a).trim(),modelId:z(o).trim(),enabled:z(c)};z(p)&&z(d)&&z(l).trim()&&(n.plaintextApiKey=z(l).trim()),z(m)&&z(s).trim()&&(n.endpoint=z(s).trim()),t.onSave(n)}function v(){M(d,!0),M(l,``)}var y=Aj();K(y,`tabindex`,-1);var b=P(y),x=P(b),S=P(x),ee=P(S,!0);E(S);var C=I(S,2);E(x);var te=I(x,2),w=I(P(te),2);pi(w,21,()=>n,e=>e.value,(e,t)=>{var n=wj(),r=P(n,!0);E(n);var i={};R(()=>{U(r,z(t).label),i!==(i=z(t).value)&&(n.value=(n.__value=z(t).value)??``)}),H(e,n)}),E(w),E(te);var ne=I(te,2),re=I(P(ne),2);$i(re),E(ne);var T=I(ne,2),ie=I(P(T),2);$i(ie),E(T);var ae=I(T,2),oe=e=>{var t=Dj(),n=I(P(t),2),i=e=>{var t=Tj(),n=P(t),r=P(n);E(n);var i=I(n,2);E(t),R(()=>U(r,`••••••••${h??``}`)),B(`click`,i,v),H(e,t)},a=e=>{var t=Ej();$i(t),R(()=>K(t,`placeholder`,f?`Enter new key`:`Paste your API key`)),aa(t,()=>z(l),e=>M(l,e)),H(e,t)};W(n,e=>{f&&r?.apiKeyRef&&!z(d)?e(i):e(a,-1)}),E(t),H(e,t)};W(ae,e=>{z(p)&&e(oe)});var se=I(ae,2),ce=e=>{var t=Oj(),n=I(P(t),2);$i(n),E(t),aa(n,()=>z(s),e=>M(s,e)),H(e,t)};W(se,e=>{z(m)&&e(ce)});var le=I(se,2),ue=P(le);$i(ue),D(2),E(le);var de=I(le,2);BA(de,{label:`Advanced parameters`,testid:`model-edit-advanced`,children:(e,t)=>{H(e,kj())},$$slots:{default:!0}});var fe=I(de,2),pe=P(fe),me=I(pe,2),he=P(me,!0);E(me),E(fe),E(b),E(y),R(()=>{K(y,`aria-label`,f?`Edit model`:`Add model`),U(ee,f?`Edit model`:`Add model`),me.disabled=!z(g),U(he,f?`Save changes`:`Add model`)}),B(`click`,y,e=>{e.target===e.currentTarget&&t.onCancel()}),B(`keydown`,y,e=>{e.key===`Escape`&&t.onCancel()}),zr(`submit`,b,_),B(`click`,C,function(...e){t.onCancel?.apply(this,e)}),qi(w,()=>z(i),e=>M(i,e)),aa(re,()=>z(a),e=>M(a,e)),aa(ie,()=>z(o),e=>M(o,e)),oa(ue,()=>z(c),e=>M(c,e)),B(`click`,pe,function(...e){t.onCancel?.apply(this,e)}),H(e,y),k()}Br([`click`,`keydown`]);var Mj=V(`<span data-testid="models-legacy-migration-status"> </span>`),Nj=V(`<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
125
+ 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>`),Pj=V(`<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>`),Fj=V(`<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),Ij=V(`<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>`),Lj=V(`<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>`),Rj=V(`<div><div class="settings-section-label"> </div> <div style="display: flex; flex-direction: column; gap: 4px;"></div></div>`),zj=V(`<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),Bj=V(`<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>`),Vj=V(`<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"><!> <!></div> <!> <!>`,1);function Hj(e,t){O(t,!0);let n=Cj(av()),r={anthropic:`Anthropic`,openai:`OpenAI`,gemini:`Gemini`,"local-ollama":`Ollama (local)`,"local-llamacpp":`llama.cpp (local)`},i=[`anthropic`,`openai`,`gemini`,`local-ollama`,`local-llamacpp`],a=A(()=>{let e=new Map;for(let t of i)e.set(t,[]);for(let t of n.models){let n=e.get(t.provider);n&&n.push(t)}return e}),o=j(void 0),s=j(!1),c=j(null),l=j(null),u=j(!1),d=j(null);function f(){M(o,void 0),M(l,null),M(s,!0)}function p(e){M(o,e,!0),M(l,null),M(s,!0)}async function m(e){let{plaintextApiKey:t,...r}=e;try{z(o)?await n.updateModel(z(o).id,r,t):await n.addModel(r,t),M(s,!1),M(o,void 0),M(l,null)}catch(e){M(l,e instanceof Error?e.message:`Failed to save`,!0)}}async function h(e){await n.deleteModel(e),M(c,null)}async function g(){M(u,!0),M(d,null);try{let e=await n.migrateLegacyKeys();e.failed>0?M(d,`Migrated ${e.migrated}; ${e.failed} failed. Retry?`):e.migrated>0&&M(d,`Migrated ${e.migrated} ${e.migrated===1?`key`:`keys`} to OS keychain.`)}finally{M(u,!1)}}var _=Vj(),v=F(_),y=P(v),b=e=>{var t=Nj(),n=I(P(t),2),r=P(n),i=P(r,!0);E(r);var a=I(r,2),o=e=>{var t=Mj(),n=P(t,!0);E(t),R(()=>U(n,z(d))),H(e,t)};W(a,e=>{z(d)&&e(o)}),E(n),E(t),R(()=>{r.disabled=z(u),G(r,`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: ${z(u)?`wait`:`pointer`};`),U(i,z(u)?`Migrating…`:`Migrate keys`)}),B(`click`,r,g),H(e,t)};W(y,e=>{n.hasLegacyKeys&&e(b)});var x=I(y,2),S=e=>{var t=Pj(),n=I(P(t),2);E(t),B(`click`,n,f),H(e,t)},ee=e=>{var t=zj(),o=F(t);pi(o,20,()=>i,e=>e,(e,t)=>{let i=A(()=>z(a).get(t)??[]);var o=Xr(),s=F(o),l=e=>{var a=Rj(),o=P(a),s=P(o,!0);E(o);var l=I(o,2);pi(l,21,()=>z(i),e=>e.id,(e,t)=>{var r=Lj(),i=P(r),a=P(i),o=P(a,!0);E(a);var s=I(a,2),l=P(s,!0);E(s),E(i);var u=I(i,2),d=P(u);$i(d),D(2),E(u);var f=I(u,2),m=P(f);$i(m);var g=I(m,2),_=P(g,!0);E(g),E(f);var v=I(f,2),y=I(v,2),b=e=>{var n=Fj(),r=F(n),i=I(r,2);R(()=>K(r,`data-testid`,`model-delete-confirm-${z(t).id}`)),B(`click`,r,()=>h(z(t).id)),B(`click`,i,()=>M(c,null)),H(e,n)},x=e=>{var n=Ij();R(()=>K(n,`data-testid`,`model-delete-btn-${z(t).id}`)),B(`click`,n,()=>M(c,z(t).id,!0)),H(e,n)};W(y,e=>{z(c)===z(t).id?e(b):e(x,-1)}),E(r),R(()=>{K(r,`data-testid`,`model-row-${z(t).id}`),U(o,z(t).displayName),U(l,z(t).modelId),K(d,`data-testid`,`model-default-${z(t).id}`),ta(d,n.defaultModelId===z(t).id),K(m,`data-testid`,`model-toggle-${z(t).id}`),ta(m,z(t).enabled),U(_,z(t).enabled?`On`:`Off`),K(v,`data-testid`,`model-edit-btn-${z(t).id}`)}),B(`change`,d,()=>n.setDefault(z(t).id)),B(`change`,m,()=>n.toggleEnabled(z(t).id)),B(`click`,v,()=>p(z(t))),H(e,r)}),E(l),E(a),R(()=>U(s,r[t])),H(e,a)};W(s,e=>{z(i).length>0&&e(l)}),H(e,o)}),E(o),B(`click`,I(o,2),f),H(e,t)};W(x,e=>{n.models.length===0?e(S):e(ee,-1)}),E(v);var C=I(v,2),te=e=>{var t=Bj(),n=P(t,!0);E(t),R(()=>U(n,z(l))),H(e,t)};W(C,e=>{z(l)&&e(te)});var w=I(C,2),ne=e=>{jj(e,{get entry(){return z(o)},onCancel:()=>{M(s,!1),M(o,void 0),M(l,null)},onSave:m})};W(w,e=>{z(s)&&e(ne)}),H(e,_),k()}Br([`click`,`change`]);var Uj=V(`<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>`),Wj=V(`<span style="justify-self: start; font-size: 11px; color: var(--tandem-accent-fg-strong); font-style: italic;">Press keys… (Esc to cancel)</span>`),Gj=V(`<kbd> </kbd>`),Kj=V(`<button type="button">Reset</button>`),qj=V(`<div style="grid-column: 1 / -1; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),Jj=V(`<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>`),Yj=V(`<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),Xj=V(`<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>`),Zj=V(`<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),Qj=V(`<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 $j(e,t){O(t,!0);let n=q(t,`notify`,3,()=>{}),r=j(null),i=j(null),a=A(()=>t.settings._readOnly===!0),o=A(()=>vl(t.settings.customShortcuts));L(()=>{if(z(r)===null)return;let e=z(r),a=a=>{if(a.preventDefault(),a.stopPropagation(),a.key===`Escape`){M(r,null),M(i,null);return}let s=el(a);if(!s)return;let c=hl(s,z(o),e);if(c){M(i,{id:e,message:`Already used by ${c}`},!0);return}M(r,null),M(i,null),t.onUpdate({customShortcuts:{...t.settings.customShortcuts,[e]:s}}),n()(`info`,`${qc[e]} set to ${ol(s)}`)};return window.addEventListener(`keydown`,a,{capture:!0}),()=>window.removeEventListener(`keydown`,a,{capture:!0})});function s(e){z(a)||(M(i,null),M(r,e,!0))}function c(e){if(z(a))return;let{[e]:n,...o}=t.settings.customShortcuts;t.onUpdate({customShortcuts:o}),z(r)===e&&M(r,null),z(i)?.id===e&&M(i,null)}function l(){z(a)||(t.onUpdate({customShortcuts:{}}),M(r,null),M(i,null))}let u=A(()=>Wc.some(e=>z(o).has(e))),d=A(()=>{let e=su(),t=new Map;for(let n of e.values()){if(!n.shortcut||Xc[n.id])continue;let e=t.get(n.group)??[];e.push({keys:n.shortcut,description:n.label}),t.set(n.group,e)}return iu.map(e=>({title:e.charAt(0).toUpperCase()+e.slice(1),rows:t.get(e)??[]})).filter(e=>e.rows.length>0)}),f=`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=Qj(),m=P(p),h=P(m),g=I(P(h),2);E(h);var _=I(h,2),v=e=>{H(e,Uj())};W(_,e=>{z(a)&&e(v)});var y=I(_,2);pi(y,20,()=>Wc,e=>e,(e,t)=>{let n=A(()=>z(r)===t),l=A(()=>z(o).has(t)),u=A(()=>ol(sl(t,z(o))));var d=Jj(),p=P(d),m=P(p,!0);E(p);var h=I(p,2),g=e=>{var n=Wj();R(()=>K(n,`data-testid`,`shortcut-recording-${t}`)),H(e,n)},_=e=>{var t=Gj();G(t,f);var n=P(t,!0);E(t),R(()=>U(n,z(u))),H(e,t)};W(h,e=>{z(n)?e(g):e(_,-1)});var v=I(h,2),y=P(v),b=P(y,!0);E(y);var x=I(y,2),S=e=>{var n=Kj();R(()=>{K(n,`data-testid`,`shortcut-reset-${t}`),n.disabled=z(a),G(n,`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: ${z(a)?`not-allowed`:`pointer`}; opacity: ${z(a)?.5:1};`)}),B(`click`,n,()=>c(t)),H(e,n)};W(x,e=>{z(l)&&e(S)}),E(v);var ee=I(v,2),C=e=>{var n=qj(),r=P(n,!0);E(n),R(()=>{K(n,`data-testid`,`shortcut-conflict-${t}`),U(r,z(i).message)}),H(e,n)};W(ee,e=>{z(i)&&z(i).id===t&&e(C)}),E(d),R(()=>{K(d,`data-testid`,`shortcut-row-${t}`),U(m,qc[t]),K(y,`data-testid`,`shortcut-edit-${t}`),y.disabled=z(a),G(y,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: ${z(n)?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; color: var(--tandem-fg); cursor: ${z(a)?`not-allowed`:`pointer`}; opacity: ${z(a)?.5:1};`),U(b,z(n)?`Recording…`:`Change`)}),B(`click`,y,()=>s(t)),H(e,d)}),E(y),E(m);var b=I(m,2);pi(b,17,()=>z(d),e=>e.title,(e,t)=>{var n=Xj(),r=P(n),i=P(r);E(r);var a=I(r,2);pi(a,21,()=>z(t).rows,e=>e.keys+e.description,(e,t)=>{var n=Yj(),r=F(n);G(r,f);var i=P(r,!0);E(r);var a=I(r,2),o=P(a,!0);E(a),R(()=>{U(i,z(t).keys),U(o,z(t).description)}),H(e,n)}),E(a),E(n),R(()=>U(i,`${z(t).title??``} (fixed)`)),H(e,n)});var x=I(b,2),S=I(P(x),2);pi(S,21,()=>dm,e=>e.keys+e.description,(e,t)=>{var n=Zj(),r=F(n);G(r,f);var i=P(r,!0);E(r);var a=I(r,2),o=P(a,!0);E(a),R(()=>{U(i,z(t).keys),U(o,z(t).description)}),H(e,n)}),E(S),E(x),E(p),R(()=>{g.disabled=z(a)||!z(u),G(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: ${z(a)||!z(u)?`not-allowed`:`pointer`}; opacity: ${z(a)||!z(u)?.5:1};`)}),B(`click`,g,l),H(e,p),k()}Br([`click`]);var eM=V(`<div data-testid="settings-modal-shortcuts-list"><!></div>`);function tM(e,t){var n=eM();$j(P(n),{get settings(){return t.settings},get onUpdate(){return t.onUpdate},get notify(){return t.notify}}),E(n),H(e,n)}var nM=V(`<div data-testid="license-settings-section"><div class="settings-section-label">License status</div> <div class="license-pill svelte-ezrf0s" data-testid="license-status-pill"> </div> <div class="settings-section-label" style="margin-top: var(--tandem-space-4);">Activate a license</div> <!> <div class="settings-hint" style="margin-top: var(--tandem-space-1);">Paste a license key you received by email, or run <code>tandem activate &lt;file&gt;</code> from
126
+ the command line. A valid license unlocks editing and runs forever.</div></div>`);function rM(e,t){O(t,!0);let n=A(()=>K_.ui),r=A(()=>z(n).statusLabel||`No license required`);function i(){t.notify(`info`,`License activated.`)}var a=nM(),o=I(P(a),2),s=P(o,!0);E(o),Q_(I(o,4),{onActivated:i}),D(2),E(a),R(()=>U(s,z(r))),H(e,a),k()}var iM=null;function aM(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function oM(e){return e.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 sM(e){return e.replace(/(\/Users\/)[^/\\]+/g,`$1[user]`).replace(/(\/home\/)[^/\\]+/g,`$1[user]`).replace(/([A-Za-z]:\\Users\\)[^\\]+/g,`$1[user]`)}function cM(e){return sM(oM(e))}async function lM(){if(aM())try{let{invoke:e}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);if(!await e(`sentry_enabled`).catch(()=>!1))return;let t=await Ul(()=>import(`./prod-Bv0q-mQu.js`),[]),{defaultOptions:n}=await Ul(async()=>{let{defaultOptions:e}=await import(`./dist-BIC2phzY.js`);return{defaultOptions:e}},__vite__mapDeps([6,7]));t.init({...n,sendDefaultPii:!1,beforeSend:e=>{e.message&&=cM(e.message);for(let t of e.exception?.values??[])t.value&&=cM(t.value);return e.request&&(e.request.data=void 0,e.request.url&&(e.request.url=cM(e.request.url))),e},beforeBreadcrumb:e=>(e.message&&=cM(e.message),(e.category===`fetch`||e.category===`xhr`)&&(e.data=void 0),e)}),iM=t,window.addEventListener(`error`,e=>{dM(e.error??e.message,{source:`window.onerror`})}),window.addEventListener(`unhandledrejection`,e=>{dM(e.reason,{source:`unhandledrejection`})}),console.info(`[sentry] client crash reporting initialised`)}catch(e){console.warn(`[sentry] client init failed (non-fatal):`,e)}}function uM(){return iM!==null}function dM(e,t){if(iM)try{iM.captureException(e,t?{extra:t}:void 0)}catch{}}var fM={pass:`[ok] `,warn:`[warn]`,fail:`[fail]`};function pM(e){return e.replace(/[\x00-\x08\x0b-\x1f\x7f]/g,``)}function mM(e){let t=[`Tandem v${e.version} (${e.transport}${e.tauriSidecar?`, desktop`:``})`,`${e.platform}/${e.arch}, Node ${e.nodeVersion}`,``];for(let n of e.report.results)t.push(`${fM[n.status]} ${n.check} — ${pM(n.message)}`),n.status!==`pass`&&n.fix&&t.push(` fix: ${pM(n.fix)}`);return t.push(``,pM(e.report.summary)),t.join(`
127
+ `)}var hM=V(`<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),gM=V(`<button type="button" data-testid="settings-modal-open-log-folder-btn">Open Log Folder</button>`),_M=V(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>`),vM=V(`<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),yM=V(`<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 11px;"></dl>`),bM=V(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>`),xM=V(`<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 SM(e,t){O(t,!0);let n=SA(()=>t.open),r=j(!1),i=j(null),a=j(!1);async function o(){M(a,!0);let e;try{let n;try{n=await fetch(`${Il}${hc}`)}catch{t.notify(`error`,`Couldn't reach the server — is it running?`);return}if(!n.ok){t.notify(`error`,"Diagnostics failed on the server — try `tandem doctor` in a terminal");return}e=mM(await n.json())}catch{t.notify(`error`,"Diagnostics failed on the server — try `tandem doctor` in a terminal");return}finally{M(a,!1)}try{await navigator.clipboard.writeText(e),t.notify(`info`,`Diagnostics copied to clipboard`)}catch{t.notify(`error`,"Couldn't access the clipboard — run `tandem doctor` in a terminal instead")}}async function s(){try{let[{appLogDir:e},t]=await Promise.all([Ul(()=>import(`./path-49-uTKly.js`),__vite__mapDeps([0,1])),Um()]);await t(`show_in_file_manager`,{path:await e()})}catch{t.notify(`error`,`Couldn't open the log folder`)}}async function c(){let e=n.info?.workflowsPath;if(!e){M(i,`Documentation file not found.`);return}M(r,!0),M(i,null);let t=await Eh(e,{readOnly:!0,notFoundMessage:`Documentation file not found.`,failureMessage:`Failed to open documentation.`});M(r,!1),t.ok||M(i,t.error,!0)}let l=A(()=>{let e=n.info;if(!e)return[];let t=[{label:`Version`,value:`Tandem v${e.version}`},{label:`Tools`,value:e.toolCount===null?`Tool count unavailable`:`${e.toolCount} tools available`},{label:`MCP SDK`,value:`MCP SDK ${e.mcpSdkVersion}`},{label:`Transport`,value:e.transport?.toUpperCase()??`—`}];return e.storagePath&&t.push({label:`Storage`,value:e.storagePath}),e.tokenRotatedAt!==void 0&&t.push({label:`Token`,value:e.tokenRotatedAt===null?`Token not created`:`Token rotated ${new Date(e.tokenRotatedAt).toLocaleString()}`}),e.changelogPath&&t.push({label:`Changelog`,value:e.changelogPath}),t.push({label:`Crash reports`,value:uM()?`On (TANDEM_SENTRY_DSN set)`:`Off — opt in with TANDEM_SENTRY_DSN`}),t});var u=xM(),d=F(u),f=P(d),p=P(f,!0);E(f);var m=I(f,2),h=e=>{var t=hM(),n=P(t,!0);E(t),R(()=>U(n,z(i))),H(e,t)};W(m,e=>{z(i)&&e(h)}),E(d);var g=I(d,2),_=P(g),v=P(_,!0);E(_);var y=I(_,2),b=e=>{var t=gM();G(t,`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;`),B(`click`,t,()=>void s()),H(e,t)},x=A(()=>Bm());W(y,e=>{z(x)&&e(b)}),E(g);var S=I(g,2),ee=I(P(S),2),C=e=>{H(e,_M())},te=e=>{var t=yM();pi(t,21,()=>z(l),e=>e.label,(e,t)=>{var n=vM(),r=F(n),i=P(r,!0);E(r);var a=I(r,2),o=P(a,!0);E(a),R(()=>{U(i,z(t).label),U(o,z(t).value)}),H(e,n)}),E(t),H(e,t)},w=e=>{H(e,bM())};W(ee,e=>{n.loading?e(C):n.info?e(te,1):e(w,-1)}),E(S),R(()=>{f.disabled=z(r)||n.loading,G(f,`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: ${z(r)||n.loading?`not-allowed`:`pointer`}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${z(r)||n.loading?.6:1};`),U(p,z(r)?`Opening…`:`View Documentation`),_.disabled=z(a),G(_,`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: ${z(a)?`not-allowed`:`pointer`}; opacity: ${z(a)?.6:1};`),U(v,z(a)?`Collecting…`:`Copy Diagnostics`)}),B(`click`,f,()=>void c()),B(`click`,_,()=>void o()),H(e,u),k()}Br([`click`]);var CM={appearance:`appearance`,editor:`editor`,network:`network`,accessibility:`accessibility`,collaboration:`collaboration`,claudeCode:`claude-code`,models:`models`,shortcuts:`shortcuts`,license:`license`,about:`about`},wM=V(`<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>`),TM=V(`<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>`),EM=V(`<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>`),DM=V(`<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 OM(e,t){O(t,!0);let n=`tandem-settings-modal-heading`,r=[{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:PA},{id:`editor`,label:`Editor`,icon:`M4 4h11M4 9h16M4 14h11M4 19h16`,component:RA},{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:ZA},{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:wA},{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:_j},{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:uj},{id:`models`,label:`Models`,icon:`M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z`,component:Hj},{id:`shortcuts`,label:`Shortcuts`,icon:`M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z`,component:tM},{id:`license`,label:`License`,icon:`M6 10h12v10H6V10Zm2 0V7a4 4 0 0 1 8 0v3`,component:rM},{id:`about`,label:`About`,icon:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01`,component:SM}].filter(e=>e.id!==CM.models||!1),i=q(t,`returnFocusEl`,3,null),a=q(t,`triggerEl`,3,null),o=q(t,`connected`,3,!1),s=q(t,`reconnectAttempts`,3,0),c=q(t,`tabs`,3,r),l=q(t,`initialTabId`,3,null),u=q(t,`notify`,3,()=>{}),d=j(void 0),f=SA(()=>t.open),p=j(!1),m=j(null),h=j(!1);L(()=>{t.open&&M(h,!1)});let g=!1;L(()=>{if(t.open&&!g&&l()){let e=z(v).find(e=>e.id===l());e&&M(y,e.id,!0)}g=t.open});let _=j(!1);L(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(max-width: 860px)`);M(_,e.matches,!0);let t=e=>{M(_,e.matches,!0)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)});let v=A(()=>c().length>0?c():r),y=j(N(r[0].id)),b=A(()=>z(v).find(e=>e.id===z(y))??z(v)[0]),x=A(()=>z(b).label),S=A(()=>({open:t.open,settings:t.settings,onUpdate:t.onUpdate,connected:o(),reconnectAttempts:s(),notify:u()}));L(()=>{z(b)&&z(b).id!==z(y)&&M(y,z(b).id,!0)}),L(()=>{if(t.open)return Ar(()=>z(d)?.focus()),()=>{i()?.focus()}}),L(()=>{if(!t.open)return;let e=e=>{let n=e.target;n&&(a()?.contains(n)||z(d)&&!z(d).contains(n)&&t.onClose())},n=setTimeout(()=>document.addEventListener(`pointerdown`,e),0);return()=>{clearTimeout(n),document.removeEventListener(`pointerdown`,e)}}),_a(()=>{let e=e=>{if(e.key!==`Escape`||!t.open)return;let n=e.target;if(!(!z(d)||!n||!z(d).contains(n))){if(e.stopPropagation(),z(_)&&z(h)){M(h,!1);return}t.onClose()}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),L(()=>{if(!t.open)return;let e=e=>{if(e.key!==`Tab`||!z(d))return;let t=z(d).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;if(!z(d).contains(i)){e.preventDefault(),n.focus();return}e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),L(()=>{z(y),M(m,null)});async function ee(){let e=f.info?.changelogPath;if(!e){M(m,`Changelog file not found.`);return}M(p,!0),M(m,null);let n=await Eh(e,{readOnly:!0,notFoundMessage:`Changelog file not found.`,failureMessage:`Failed to open changelog.`});M(p,!1),n.ok?t.onClose():M(m,n.error,!0)}var C={DEFAULT_SETTINGS_TABS:r},te=Xr(),w=F(te),ne=e=>{var r=DM(),i=F(r),a=I(i,2);K(a,`aria-labelledby`,n),K(a,`tabindex`,-1);var c=P(a),l=P(c),u=P(l);K(u,`id`,n);var g=I(u,2),C=e=>{var t=wM(),n=P(t);E(t),R(()=>U(n,`v${f.info.version??``}`)),H(e,t)};W(g,e=>{f.info&&e(C)}),E(l);var te=I(l,2);pi(te,21,()=>z(v),e=>e.id,(e,t)=>{var n=TM(),r=P(n),i=P(r);E(r);var a=I(r,2),o=P(a,!0);E(a),E(n),R(()=>{K(n,`aria-current`,z(y)===z(t).id?`page`:void 0),K(n,`data-active`,z(y)===z(t).id?`true`:`false`),K(n,`data-testid`,`settings-modal-tab-${z(t).id}`),K(i,`d`,z(t).icon),U(o,z(t).label)}),B(`click`,n,()=>{M(y,z(t).id,!0),M(h,!1)}),H(e,n)}),E(te);var w=I(te,2),ne=P(w),re=P(ne,!0);E(ne);var T=I(ne,2),ie=e=>{var t=EM(),n=P(t,!0);E(t),R(()=>U(n,z(m))),H(e,t)};W(T,e=>{z(m)&&e(ie)});var ae=I(T,2),oe=I(ae,2),se=P(oe),ce=I(se,2),le=P(ce),ue=e=>{H(e,Yr(`MCP connected`))},de=e=>{H(e,Yr(`Reconnecting…`))},fe=e=>{H(e,Yr(`MCP offline`))};W(le,e=>{o()?e(ue):s()>0?e(de,1):e(fe,-1)}),E(ce),E(oe),E(w),E(c),Pi(c,(e,t)=>Bu?.(e,t),()=>`y`);var pe=I(c,2),me=P(pe),he=P(me),ge=I(he,2),_e=P(ge,!0);E(ge);var ve=I(ge,2);E(me);var ye=I(me,2),be=P(ye);ci(P(be),()=>z(b).id,e=>{var t=Xr();xi(F(t),()=>z(b).component,(e,t)=>{t(e,ga(()=>z(S)))}),H(e,t)}),E(be),E(ye),Pi(ye,(e,t)=>Bu?.(e,t),()=>`y`),E(pe),E(a),fa(a,e=>M(d,e),()=>z(d)),R(()=>{K(a,`data-narrow-sidebar-open`,z(h)?`true`:`false`),c.inert=z(_)&&!z(h),ne.disabled=z(p)||f.loading,U(re,z(p)?`Opening…`:`Changelog`),K(ae,`href`,Ca),K(se,`data-state`,o()?`connected`:s()>0?`reconnecting`:`disconnected`),K(he,`aria-label`,z(h)?`Hide sections`:`Show sections`),K(he,`aria-expanded`,z(h)),U(_e,z(x))}),B(`click`,i,function(...e){t.onClose?.apply(this,e)}),B(`keydown`,i,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t.onClose())}),B(`click`,ne,()=>void ee()),B(`click`,he,()=>{M(h,!z(h))}),B(`click`,ve,function(...e){t.onClose?.apply(this,e)}),H(e,r)};return W(w,e=>{t.open&&e(ne)}),H(e,te),k(C)}Br([`click`,`keydown`]);var kM=V(`<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>`),AM=V(`<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>`),jM=V(`<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>`),MM=V(`<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
128
+ restores when you return to Tandem.</div>`,1),NM=V(`<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>`),PM=V(`<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),FM=V(`<div data-testid="settings-shortcuts-list"><!></div>`),IM=V(`<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),LM=V(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>`),RM=V(`<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>`,1),zM=V(`<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>`),BM=V(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>`),VM=V(`<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),HM=V(`<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 UM(e,t){O(t,!0);let n=`tandem-settings-heading`,r=[{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`}],i=q(t,`connected`,3,!1),a=q(t,`reconnectAttempts`,3,0),o=j(void 0),s=j(void 0),c=hj(),l=j(N(c.userName)),u=SA(()=>t.open),d=j(!1),f=j(null),p=j(!1),m=j(null),h=j(`appearance`);L(()=>{z(h),M(f,null),M(m,null)}),L(()=>{let e=c.userName;z(l)!==e&&document.activeElement!==z(s)&&M(l,e,!0)}),L(()=>{if(t.open)return z(o)?.focus(),()=>{t.returnFocusEl?.focus()}}),L(()=>{if(!t.open)return;let e=e=>{let n=e.target;t.anchorEl?.contains(n)||z(o)&&!z(o).contains(n)&&t.onClose()},n=setTimeout(()=>document.addEventListener(`pointerdown`,e),0);return()=>{clearTimeout(n),document.removeEventListener(`pointerdown`,e)}}),L(()=>{if(!t.open)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),t.onClose();return}if(e.key!==`Tab`||!z(o))return;let n=z(o).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement;if(!z(o).contains(a)){e.preventDefault(),r.focus();return}e.shiftKey&&a===r?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});async function g(e,n,r,i){if(!e){r(i.notFound);return}n(!0),r(null);try{let n=await Eh(e,{readOnly:!0,notFoundMessage:i.notFound,failureMessage:i.failed});if(!n.ok){r(n.error);return}t.onClose()}finally{n(!1)}}function _(){return g(u.info?.workflowsPath,e=>M(p,e,!0),e=>M(m,e,!0),{notFound:`Documentation file not found.`,failed:`Failed to open documentation.`})}function v(){return g(u.info?.changelogPath,e=>M(d,e,!0),e=>M(f,e,!0),{notFound:`Changelog file not found.`,failed:`Failed to open changelog.`})}let y=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,b=()=>{};function x(e){return r.find(t=>t.id===e)?.label??`Settings`}function S(){let e=u.info;if(!e)return[];let t=[{label:`Version`,value:`Tandem v${e.version}`},{label:`Tools`,value:e.toolCount===null?`Tool count unavailable`:`${e.toolCount} tools available`},{label:`MCP SDK`,value:`MCP SDK ${e.mcpSdkVersion}`},{label:`Transport`,value:e.transport?.toUpperCase()??`—`}];return e.storagePath&&t.push({label:`Storage`,value:e.storagePath}),e.tokenRotatedAt!==void 0&&t.push({label:`Token`,value:e.tokenRotatedAt===null?`Token not created`:`Token rotated ${new Date(e.tokenRotatedAt).toLocaleString()}`}),e.changelogPath&&t.push({label:`Changelog`,value:e.changelogPath}),t}var ee=Xr(),C=F(ee),te=e=>{var g=HM(),ee=F(g),C=I(ee,2);K(C,`aria-labelledby`,n),K(C,`tabindex`,-1);var te=P(C),w=P(te),ne=P(w);K(ne,`id`,n);var re=I(ne,2),T=e=>{var t=kM(),n=P(t);E(t),R(()=>U(n,`v${u.info.version??``}`)),H(e,t)};W(re,e=>{u.info&&e(T)}),E(w);var ie=I(w,2);pi(ie,21,()=>r,e=>e.id,(e,t)=>{var n=AM(),r=P(n),i=P(r);E(r);var a=I(r,2),o=P(a,!0);E(a),E(n),R(()=>{K(n,`aria-current`,z(h)===z(t).id?`page`:void 0),K(n,`data-active`,z(h)===z(t).id?`true`:`false`),K(i,`d`,z(t).icon),U(o,z(t).label)}),B(`click`,n,()=>M(h,z(t).id,!0)),H(e,n)}),E(ie);var ae=I(ie,2),oe=P(ae),se=P(oe,!0);E(oe);var ce=I(oe,2),le=e=>{var t=jM(),n=P(t,!0);E(t),R(()=>U(n,z(f))),H(e,t)};W(ce,e=>{z(f)&&e(le)});var ue=I(ce,2),de=I(ue,2),fe=P(de),pe=I(fe,2),me=P(pe),he=e=>{H(e,Yr(`MCP connected`))},ge=e=>{H(e,Yr(`Reconnecting…`))},_e=e=>{H(e,Yr(`MCP offline`))};W(me,e=>{i()?e(he):a()>0?e(ge,1):e(_e,-1)}),E(pe),E(de),E(ae),E(te);var ve=I(te,2),ye=P(ve),be=P(ye),xe=P(be,!0);E(be);var Se=I(be,2);E(ye);var Ce=I(ye,2),we=P(Ce),Te=P(we),Ee=e=>{var n=MM(),r=F(n),i=P(r);G(i,y);var a=I(i,2);$i(a),fa(a,e=>M(s,e),()=>z(s)),E(r);var o=I(r,2),u=P(o);G(u,y);var d=I(u,2),f=P(d),p=I(f,2);E(d),D(2),E(o);var m=I(o,2),h=P(m);$i(h),D(2),E(m),D(2),R(()=>{ea(a,z(l)),K(a,`maxlength`,40),K(f,`aria-checked`,t.settings.defaultMode===`tandem`),G(f,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${t.settings.defaultMode===`tandem`?`var(--tandem-accent)`:`var(--tandem-border)`}; border-radius: var(--tandem-r-3); background: ${t.settings.defaultMode===`tandem`?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; color: ${t.settings.defaultMode===`tandem`?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-muted)`}; font-size: 12px; font-weight: ${t.settings.defaultMode===`tandem`?600:400}; cursor: pointer;`),K(p,`aria-checked`,t.settings.defaultMode===`solo`),G(p,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${t.settings.defaultMode===`solo`?`var(--tandem-accent)`:`var(--tandem-border)`}; border-radius: var(--tandem-r-3); background: ${t.settings.defaultMode===`solo`?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; color: ${t.settings.defaultMode===`solo`?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-muted)`}; font-size: 12px; font-weight: ${t.settings.defaultMode===`solo`?600:400}; cursor: pointer;`),ta(h,t.settings.soloRailHidden)}),B(`input`,a,e=>{M(l,e.target.value,!0)}),zr(`blur`,a,()=>c.setUserName(z(l))),B(`keydown`,a,e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(M(l,c.userName,!0),e.currentTarget.blur())}),B(`click`,f,()=>t.onUpdate({defaultMode:`tandem`})),B(`click`,p,()=>t.onUpdate({defaultMode:`solo`})),B(`change`,h,e=>t.onUpdate({soloRailHidden:e.target.checked})),H(e,n)},De=e=>{PA(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},Oe=e=>{RA(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},ke=e=>{ZA(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},Ae=e=>{wA(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},je=e=>{var n=PM(),r=F(n),i=P(r);G(i,y);var a=I(P(i)),o=P(a);E(a),E(i);var s=I(i,4);$i(s),K(s,`step`,100);var c=I(s,2),l=P(c),u=P(l);E(l);var d=I(l,2),f=P(d);E(d),E(c),E(r);var p=I(r,2),m=P(p);$i(m),D(2),E(p);var h=I(p,2),g=P(h);$i(g),D(2),E(h);var _=I(h,4),v=e=>{var t=Xr();oi(F(t),()=>Ul(()=>import(`./CoworkSettings-BWtK14Nl.js`),__vite__mapDeps([4,5])),e=>{H(e,NM())},(e,t)=>{let n=A(()=>z(t).default);var r=Xr();xi(F(r),()=>z(n),(e,t)=>{t(e,{})}),H(e,r)}),H(e,t)},b=A(()=>Bm());W(_,e=>{z(b)&&e(v)}),R((e,n,r)=>{U(o,`${e??``}s`),K(s,`min`,500),K(s,`max`,Ia),ea(s,t.settings.selectionDwellMs),U(u,`${n??``}s`),U(f,`${r??``}s`),ta(m,t.settings.selectionToolbar),ta(g,t.settings.marginView)},[()=>(t.settings.selectionDwellMs/1e3).toFixed(1),()=>(500/1e3).toFixed(1),()=>(Ia/1e3).toFixed(1)]),B(`input`,s,e=>t.onUpdate({selectionDwellMs:Number(e.target.value)})),B(`change`,m,e=>t.onUpdate({selectionToolbar:e.target.checked})),B(`change`,g,e=>t.onUpdate({marginView:e.target.checked})),H(e,n)},Me=e=>{var n=FM();$j(P(n),{get settings(){return t.settings},get onUpdate(){return t.onUpdate},notify:b}),E(n),H(e,n)},Ne=e=>{var t=VM(),n=F(t),r=P(n),i=P(r,!0);E(r);var a=I(r,2),o=e=>{var t=IM(),n=P(t,!0);E(t),R(()=>U(n,z(m))),H(e,t)};W(a,e=>{z(m)&&e(o)}),E(n);var s=I(n,2),c=P(s);G(c,y);var l=I(c,2),d=e=>{H(e,LM())},f=e=>{var t=zM();pi(t,21,S,e=>e.label,(e,t)=>{var n=RM(),r=F(n),i=P(r,!0);E(r);var a=I(r,2),o=P(a,!0);E(a),R(()=>{U(i,z(t).label),U(o,z(t).value)}),H(e,n)}),E(t),H(e,t)},h=e=>{H(e,BM())};W(l,e=>{u.loading?e(d):u.info?e(f,1):e(h,-1)}),E(s),R(()=>{r.disabled=z(p)||u.loading,G(r,`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: ${z(p)||u.loading?`not-allowed`:`pointer`}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${z(p)||u.loading?.6:1};`),U(i,z(p)?`Opening…`:`View Documentation`)}),B(`click`,r,()=>void _()),H(e,t)};W(Te,e=>{z(h)===`collaboration`?e(Ee):z(h)===`appearance`?e(De,1):z(h)===`editor`?e(Oe,2):z(h)===`network`?e(ke,3):z(h)===`accessibility`?e(Ae,4):z(h)===`claude-code`?e(je,5):z(h)===`shortcuts`?e(Me,6):e(Ne,-1)}),E(we),E(Ce),E(ve),E(C),fa(C,e=>M(o,e),()=>z(o)),R(e=>{oe.disabled=z(d)||u.loading,U(se,z(d)?`Opening…`:`Changelog`),K(ue,`href`,Ca),K(fe,`data-state`,i()?`connected`:a()>0?`reconnecting`:`disconnected`),U(xe,e)},[()=>x(z(h))]),B(`click`,ee,function(...e){t.onClose?.apply(this,e)}),B(`click`,oe,()=>void v()),B(`click`,Se,function(...e){t.onClose?.apply(this,e)}),H(e,g)};W(C,e=>{t.open&&e(te)}),H(e,ee),k()}Br([`click`,`input`,`keydown`,`change`]);var WM=Jr(`<path></path>`),GM=V(`<span class="badge svelte-nsu1aw"> </span>`),KM=V(`<button type="button" class="action svelte-nsu1aw"> </button>`),qM=V(`<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>`),JM=V(`<div data-testid="toast-container" class="toast-stack svelte-nsu1aw"></div>`);function YM(e,t){O(t,!0);var n=Xr(),r=F(n),i=e=>{var n=JM();pi(n,21,()=>t.toasts,e=>e.id,(e,n)=>{var r=qM(),i=P(r),a=P(i);pi(a,20,()=>Hu[z(n).severity],e=>e,(e,t)=>{var n=WM();R(()=>K(n,`d`,t)),H(e,n)}),E(a),E(i);var o=I(i,2),s=P(o),c=P(s,!0);E(s);var l=I(s,2),u=e=>{var t=GM(),r=P(t);E(t),R(()=>{K(t,`data-testid`,`toast-count-${z(n).id}`),U(r,`×${z(n).count??``}`)}),H(e,t)};W(l,e=>{z(n).count>1&&e(u)});var d=I(l,2),f=e=>{var r=KM(),i=P(r,!0);E(r),R(()=>{K(r,`data-testid`,`toast-action-${z(n).id}`),U(i,z(n).action.label)}),B(`click`,r,()=>{z(n).action?.onClick(),t.onDismiss(z(n).id)}),H(e,r)};W(d,e=>{z(n).action&&e(f)}),E(o);var p=I(o,2);E(r),R(()=>{K(r,`role`,z(n).severity===`info`?`status`:`alert`),K(r,`data-testid`,`toast-${z(n).id}`),Ui(r,1,`toast-card ${z(n).severity??``}`,`svelte-nsu1aw`),U(c,z(n).message),K(p,`data-testid`,`toast-dismiss-${z(n).id}`)}),B(`click`,p,()=>t.onDismiss(z(n).id)),H(e,r)}),E(n),H(e,n)};W(r,e=>{t.toasts.length>0&&e(i)}),H(e,n),k()}Br([`click`]);var XM=V(`<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 ZM(e,t){let n=A(()=>t.installing?`Installing…`:`Restart to install`);var r=XM(),i=I(P(r),2),a=P(i);E(i);var o=I(i,2),s=P(o,!0);E(o);var c=I(o,2);E(r),R(()=>{U(a,`Tandem v${t.version??``} is available.`),o.disabled=t.installing,U(s,z(n))}),B(`click`,o,function(...e){t.onInstall?.apply(this,e)}),B(`click`,c,function(...e){t.onDismiss?.apply(this,e)}),H(e,r)}Br([`click`]);var QM=Math.floor,$M=(e,t)=>e<t?e:t,eN=(e,t)=>e>t?e:t,tN=128,nN=127,rN=2**53-1,iN=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},aN=typeof TextEncoder<`u`?new TextEncoder:null,oN=aN?e=>aN.encode(e):iN,sN=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});sN&&sN.decode(new Uint8Array).length===1&&(sN=null);var cN=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},lN=(e,t)=>{for(;t>nN;)cN(e,tN|nN&t),t=QM(t/128);cN(e,nN&t)},uN=new Uint8Array(3e4),dN=uN.length/3,fN=aN&&aN.encodeInto?(e,t)=>{if(t.length<dN){let n=aN.encodeInto(t,uN).written||0;lN(e,n);for(let t=0;t<n;t++)cN(e,uN[t])}else mN(e,oN(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;lN(e,r);for(let t=0;t<r;t++)cN(e,n.codePointAt(t))},pN=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=$M(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(eN(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},mN=(e,t)=>{lN(e,t.byteLength),pN(e,t)},hN=e=>Error(e),gN=hN(`Unexpected end of array`),_N=hN(`Integer out of Range`),vN=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},yN=e=>vN(e,xN(e)),bN=e=>e.arr[e.pos++],xN=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&nN)*n,n*=128,r<tN)return t;if(t>rN)throw _N}throw gN},SN=sN?e=>sN.decode(yN(e)):e=>{let t=xN(e);if(t===0)return``;{let n=String.fromCodePoint(bN(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(bN(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},CN;(function(e){e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`})(CN||={});var wN=(e,t)=>{lN(e,CN.Token),fN(e,t)},TN=(e,t,n,r)=>{switch(xN(e)){case CN.Token:t();break;case CN.PermissionDenied:n(SN(e));break;case CN.Authenticated:r(SN(e));break}},EN=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),DN;(function(e){e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`})(DN||={});function ON(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function kN(e){return new Promise(t=>setTimeout(t,e))}function AN(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function jN(e,t){let n=ON(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||AN;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await kN(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await kN(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await kN(e)}return a()}var MN=Math.floor,NN=(e,t)=>e<t?e:t,PN=(e,t)=>e>t?e:t,FN=64,IN=128,LN=63,RN=127,zN=2**53-1,BN=()=>new Set,VN=Array.from,HN=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},UN=typeof TextEncoder<`u`?new TextEncoder:null,WN=UN?e=>UN.encode(e):HN,GN=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});GN&&GN.decode(new Uint8Array).length===1&&(GN=null);var KN=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},qN=()=>new KN,JN=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},YN=e=>{let t=new Uint8Array(JN(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},XN=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},ZN=(e,t)=>{for(;t>RN;)XN(e,IN|RN&t),t=MN(t/128);XN(e,RN&t)},QN=new Uint8Array(3e4),$N=QN.length/3,eP=UN&&UN.encodeInto?(e,t)=>{if(t.length<$N){let n=UN.encodeInto(t,QN).written||0;ZN(e,n);for(let t=0;t<n;t++)XN(e,QN[t])}else nP(e,WN(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;ZN(e,r);for(let t=0;t<r;t++)XN(e,n.codePointAt(t))},tP=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=NN(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(PN(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},nP=(e,t)=>{ZN(e,t.byteLength),tP(e,t)},rP=e=>Error(e),iP=rP(`Unexpected end of array`),aP=rP(`Integer out of Range`),oP=class{constructor(e){this.arr=e,this.pos=0}},sP=e=>new oP(e),cP=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},lP=e=>cP(e,dP(e)),uP=e=>e.arr[e.pos++],dP=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&RN)*n,n*=128,r<IN)return t;if(t>zN)throw aP}throw iP},fP=e=>{let t=e.arr[e.pos++],n=t&LN,r=64,i=(t&FN)>0?-1:1;if((t&IN)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&RN)*r,r*=128,t<IN)return i*n;if(n>zN)throw aP}throw iP},pP=GN?e=>GN.decode(lP(e)):e=>{let t=dP(e);if(t===0)return``;{let n=String.fromCodePoint(uP(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(uP(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},mP=e=>{let t=e.pos,n=pP(e);return e.pos=t,n},hP=Date.now,gP=()=>new Map,_P=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},vP=class{constructor(){this._observers=gP()}on(e,t){_P(this._observers,e,BN).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return VN((this._observers.get(e)||gP()).values()).forEach(e=>e(...t))}destroy(){this._observers=gP()}},yP=Object.keys,bP=e=>yP(e).length,xP=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),SP=(e,t)=>e===t,CP=(e,t)=>{if(e==null||t==null)return SP(e,t);if(e.constructor!==t.constructor)return!1;if(e===t)return!0;switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!CP(e.get(n),t.get(n)))return!1;break;case Object:if(bP(e)!==bP(t))return!1;for(let n in e)if(!xP(e,n)||!CP(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!CP(e[n],t[n]))return!1;break;default:return!1}return!0},wP=3e4,TP=class extends vP{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=hP();this.getLocalState()!==null&&wP/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&wP<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&EP(this,t,`timeout`)},MN(wP/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){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:hP()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),CP(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},EP=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:hP()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},DP=(e,t,n=e.states)=>{let r=t.length,i=qN();ZN(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;ZN(i,r),ZN(i,s),eP(i,JSON.stringify(o))}return YN(i)},OP=(e,t,n)=>{let r=sP(t),i=hP(),a=[],o=[],s=[],c=[],l=dP(r);for(let t=0;t<l;t++){let t=dP(r),n=dP(r),l=JSON.parse(pP(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(CP(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},kP=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},AP=class{constructor(e){this.data=e,this.encoder=qN(),this.decoder=sP(new Uint8Array(this.data))}peekVarString(){return mP(this.decoder)}readVarUint(){return dP(this.decoder)}readVarString(){return pP(this.decoder)}readVarUint8Array(){return lP(this.decoder)}writeVarUint(e){return ZN(this.encoder,e)}writeVarString(e){return eP(this.encoder,e)}writeVarUint8Array(e){return nP(this.encoder,e)}length(){return JN(this.encoder)}},jP;(function(e){e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`})(jP||={});var MP;(function(e){e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`})(MP||={});var NP=class{constructor(){this.encoder=qN()}get(e){return e.encoder}toUint8Array(){return YN(this.encoder)}},PP=class extends NP{constructor(){super(...arguments),this.type=jP.CLOSE,this.description=`Ask the server to close the connection`}get(e){return eP(this.encoder,e.documentName),ZN(this.encoder,this.type),this.encoder}},FP=class extends kP{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=MP.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=MP.Connected,this.emit(`status`,{status:MP.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===MP.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===MP.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(PP,{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===MP.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:jN(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:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{var r;(r=this.webSocket)==null||r.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=MP.Connecting,this.emit(`status`,{status:MP.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){var t;this.resolveConnectionAttempt(),this.lastMessageReceived=hP();let n=new AP(e.data).peekVarString();(t=this.configuration.providerMap.get(n))==null||t.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=MP.Connected,this.emit(`status`,{status:MP.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.reject(),this.connectionAttempt=null}checkConnection(){var e;this.status===MP.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=hP()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:`forced`}}),this.closeTries=0):((e=this.webSocket)==null||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){this.webSocket?.readyState===DN.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=MP.Disconnected,this.emit(`status`,{status:MP.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()}},IP=0,LP=1,RP=2,zP=(e,t)=>{ZN(e,IP),nP(e,KC(t))},BP=(e,t,n)=>{ZN(e,LP),nP(e,BC(t,n))},VP=(e,t,n)=>BP(t,n,lP(e)),HP=(e,t,n)=>{try{LC(t,lP(e),n)}catch(e){console.error(`Caught error while handling a Yjs update`,e)}},UP=(e,t)=>{ZN(e,RP),nP(e,t)},WP=HP,GP=(e,t,n,r)=>{let i=dP(e);switch(i){case IP:VP(e,t,n);break;case LP:HP(e,n,r);break;case RP:WP(e,n,r);break;default:throw Error(`Unknown message type`)}return i},KP=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case jP.Sync:this.applySyncMessage(e,t);break;case jP.Awareness:this.applyAwarenessMessage(e);break;case jP.Auth:this.applyAuthMessage(e);break;case jP.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case jP.Stateless:e.receiveStateless(pP(n.decoder));break;case jP.SyncStatus:this.applySyncStatusMessage(e,fP(n.decoder)===1);break;case jP.CLOSE:let i={code:1e3,reason:pP(n.decoder),target:e.configuration.websocketProvider.webSocket,type:`close`};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:throw Error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(NP,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(jP.Sync);let r=GP(n.decoder,n.encoder,e.document,e);t&&r===LP&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;OP(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;TN(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(jP.Awareness),t.writeVarUint8Array(DP(e.awareness,Array.from(e.awareness.getStates().keys())))}},qP=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return YN(this.encoder)}send(e){e?.send(this.create())}},JP=class extends NP{constructor(){super(...arguments),this.type=jP.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return eP(this.encoder,e.documentName),ZN(this.encoder,this.type),wN(this.encoder,e.token),this.encoder}},YP=class extends NP{constructor(){super(...arguments),this.type=jP.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);eP(this.encoder,e.documentName),ZN(this.encoder,this.type);let t;return t=e.states===void 0?DP(e.awareness,e.clients):DP(e.awareness,e.clients,e.states),nP(this.encoder,t),this.encoder}},XP=class extends NP{constructor(){super(...arguments),this.type=jP.Stateless,this.description=`A stateless message`}get(e){return eP(this.encoder,e.documentName),ZN(this.encoder,this.type),eP(this.encoder,e.payload??``),this.encoder}},ZP=class extends NP{constructor(){super(...arguments),this.type=jP.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return eP(this.encoder,e.documentName),ZN(this.encoder,this.type),zP(this.encoder,e.document),this.encoder}},QP=class extends NP{constructor(){super(...arguments),this.type=jP.Sync,this.description=`A document update`}get(e){return eP(this.encoder,e.documentName),ZN(this.encoder,this.type),UP(this.encoder,e.update),this.encoder}},$P=class extends Error{constructor(){super(...arguments),this.code=1001}},eF=class extends kP{constructor(e){var t,n,r;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=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new xC,this.configuration.awareness=e.awareness===void 0?new TP(this.document):e.awareness,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),(t=this.awareness)==null||t.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:EN(this.awareness.getStates())})}),(n=this.awareness)==null||n.on(`change`,()=>{this.emit(`awarenessChange`,{states:EN(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),(r=this.awareness)==null||r.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 FP(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,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(ZP,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&EP(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(XP,{documentName:this.configuration.name,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(JP,{token:e??``,documentName:this.configuration.name})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(QP,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(YP,{awareness:this.awareness,clients:i,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(ZP,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(YP,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t){if(!this._isAttached)return;let n=new qP(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new AP(e.data),n=t.readVarString();t.writeVarString(n),this.emit(`message`,{event:e,message:new AP(e.data)}),new KP(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&EP(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&&(EP(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),!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,t){if(!this.awareness)throw new $P(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},tF=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},nF=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},rF=null,iF=function(e,t,n){let r=rF||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},aF=function(){rF=null},oF=function(e,t,n,r){return n&&(cF(e,t,n,r,-1)||cF(e,t,n,r,1))},sF=/^(img|br|input|textarea|hr)$/i;function cF(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:lF(e))){let n=e.parentNode;if(!n||n.nodeType!=1||pF(e)||sF.test(e.nodeName)||e.contentEditable==`false`)return!1;t=tF(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?lF(e):0}else return!1}}function lF(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function uF(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=lF(e)}else if(e.parentNode&&!pF(e))t=tF(e),e=e.parentNode;else return null}}function dF(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!pF(e))t=tF(e)+1,e=e.parentNode;else return null}}function fF(e,t,n){for(let r=t==0,i=t==lF(e);r||i;){if(e==n)return!0;let t=tF(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==lF(e)}}function pF(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var mF=function(e){return e.focusNode&&oF(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function hF(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function gF(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function _F(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(lF(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(lF(r.startContainer),r.startOffset)}}}var vF=typeof navigator<`u`?navigator:null,yF=typeof document<`u`?document:null,bF=vF&&vF.userAgent||``,xF=/Edge\/(\d+)/.exec(bF),SF=/MSIE \d/.exec(bF),CF=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bF),wF=!!(SF||CF||xF),TF=SF?document.documentMode:CF?+CF[1]:xF?+xF[1]:0,EF=!wF&&/gecko\/(\d+)/i.test(bF);EF&&+(/Firefox\/(\d+)/.exec(bF)||[0,0])[1];var DF=!wF&&/Chrome\/(\d+)/.exec(bF),OF=!!DF,kF=DF?+DF[1]:0,AF=!wF&&!!vF&&/Apple Computer/.test(vF.vendor),jF=AF&&(/Mobile\/\w+/.test(bF)||!!vF&&vF.maxTouchPoints>2),MF=jF||(vF?/Mac/.test(vF.platform):!1),NF=vF?/Win/.test(vF.platform):!1,PF=/Android \d/.test(bF),FF=!!yF&&`webkitFontSmoothing`in yF.documentElement.style,IF=FF?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function LF(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function RF(e,t){return typeof e==`number`?e:e[t]}function zF(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function BF(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=nF(o);continue}let e=o,n=e==a.body,s=n?LF(a):zF(e),c=0,l=0;if(t.top<s.top+RF(r,`top`)?l=-(s.top-t.top+RF(i,`top`)):t.bottom>s.bottom-RF(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+RF(i,`top`)-s.top:t.bottom-s.bottom+RF(i,`bottom`)),t.left<s.left+RF(r,`left`)?c=-(s.left-t.left+RF(i,`left`)):t.right>s.right-RF(r,`right`)&&(c=t.right-s.right+RF(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:nF(o)}}function VF(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:HF(e.dom)}}function HF(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=nF(r));return t}function UF({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;WF(n,r==0?0:r-t)}function WF(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var GF=null;function KF(e){if(e.setActive)return e.setActive();if(GF)return e.focus(GF);let t=HF(e);e.focus(GF==null?{get preventScroll(){return GF={preventScroll:!0},!0}}:void 0),GF||(GF=!1,WF(t,0))}function qF(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=iF(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?JF(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:qF(n,i)}function JF(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=nI(r,1);if(n.top!=n.bottom&&YF(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function YF(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function XF(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function ZF(e,t,n){let{node:r,offset:i}=qF(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function QF(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function $F(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(YF(t,i))return $F(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function eI(e,t){let n=e.dom.ownerDocument,r,i=0,a=_F(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!YF(t,n)||(o=$F(e.dom,t,n),!o))return null}if(AF)for(let e=o;r&&e;e=nF(e))e.draggable&&(r=void 0);if(o=XF(o,t),r){if(EF&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;FF&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=QF(e,r,i,t))}s??=ZF(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function tI(e){return e.top<e.bottom||e.left<e.right}function nI(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(tI(e))return e}return Array.prototype.find.call(n,tI)||e.getBoundingClientRect()}var rI=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function iI(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=FF||EF;if(r.nodeType==3)if(o&&(rI.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=nI(iF(r,i,i),n);if(EF&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=nI(iF(r,i-1,i-1),-1);if(t.top==e.top){let n=nI(iF(r,i,i+1),-1);if(n.top!=e.top)return aI(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,aI(nI(iF(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==lF(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return oI(e.getBoundingClientRect(),!1)}if(a==null&&i<lF(r)){let e=r.childNodes[i];if(e.nodeType==1)return oI(e.getBoundingClientRect(),!0)}return oI(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==lF(r))){let e=r.childNodes[i-1],t=e.nodeType==3?iF(e,lF(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return aI(nI(t,1),!1)}if(a==null&&i<lF(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?iF(e,0,+!o):e.nodeType==1?e:null:null;if(t)return aI(nI(t,-1),!0)}return aI(nI(r.nodeType==3?iF(r):r,-n),n>=0)}function aI(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function oI(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function sI(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function cI(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return sI(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=iI(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=iF(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var lI=/[\u0590-\u08ac]/;function uI(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!lI.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:sI(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var dI=null,fI=null,pI=!1;function mI(e,t,n){return dI==t&&fI==n?pI:(dI=t,fI=n,pI=n==`up`||n==`down`?cI(e,t,n):uI(e,t,n))}var hI=0,gI=1,_I=2,vI=3,yI=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=hI,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].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 t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.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,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>tF(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof EI){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof bI&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?tF(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?tF(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=tF(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=tF(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((EF||AF)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
129
+ `),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:tF(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(EF&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&AF)&&oF(o.node,o.offset,l.anchorNode,l.anchorOffset)&&oF(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&EF)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?_I:gI,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=vI:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?_I:vI}n=a}this.dirty=_I}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?_I:gI;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},bI=class extends yI{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==hI&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(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}},xI=class extends yI{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},SI=class e extends yI{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=vf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&vI||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=vI&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=hI){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=hI}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=UI(a,n,o,r)),t>0&&(a=UI(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},CI=class e extends yI{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=vf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=PI(u,r,n),l?c=new DI(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new TI(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+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 t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Z.empty)}return e}matchesNode(e,t,n){return this.dirty==hI&&e.eq(this.node)&&FI(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new LI(this,a&&a.node,e);BI(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?cd.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==_I)&&(a&&this.protectLocalComposition(e,a),OI(this.contentDOM,this.children,e),jF&&VI(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Up)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=HI(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new xI(this,i,t,r);e.input.compositionNodes.push(a),this.children=UI(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==vI||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=hI}updateOuterDeco(e){if(FI(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=MI(this.dom,this.nodeDOM,jI(this.outerDeco,this.node,t),jI(e,this.node,t)),this.dom!=n&&(n.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 wI(e,t,n,r,i){PI(r,t,e);let a=new CI(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var TI=class e extends CI{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==vI||this.dirty!=hI&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=hI||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=hI,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=vI)}get domAtom(){return!1}isText(e){return this.node.text==e}},EI=class extends yI{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==hI&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},DI=class extends CI{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==vI)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}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 OI(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=II(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof SI){let t=r?r.previousSibling:e.lastChild;OI(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=II(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var kI=function(e){e&&(this.nodeName=e)};kI.prototype=Object.create(null);var AI=[new kI];function jI(e,t,n){if(e.length==0)return AI;let r=n?AI[0]:new kI,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new kI(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new kI(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function MI(e,t,n,r){if(n==AI&&r==AI)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=AI[0],i=t)}NI(i,o||AI[0],a)}return i}function NI(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function PI(e,t,n){return MI(e,e,AI,jI(t,n,e.nodeType!=1))}function FI(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function II(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var LI=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=RI(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=hI,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=SI.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==vI&&a.dom==a.contentDOM&&(a.dirty=_I),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof CI){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=vI&&FI(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=_I,u.updateChildren(r,a+1),u.dirty=hI),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!FI(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=CI.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=CI.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new bI(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof SI;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof TI)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((AF||OF)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new EI(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function RI(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof SI)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function zI(e,t){return e.type.side-t.type.side}function BI(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(zI);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function VI(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function HI(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function UI(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function WI(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(mF(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Gp.isSelectable(e)&&i.parent&&!(e.isInline&&fF(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Gp(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=tL(e,u,s,n)}return l}function GI(e){return e.editable?e.hasFocus():rL(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function KI(e,t=!1){let n=e.state.selection;if($I(e,n),GI(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&OF){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&oF(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)QI(e);else{let{anchor:r,head:i}=n,a,o;qI&&!(n instanceof Up)&&(n.$from.parent.inlineContent||(a=JI(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=JI(e,n.to))),e.docView.setSelection(r,i,e,t),qI&&(a&&XI(a),o&&XI(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&ZI(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var qI=AF||OF&&kF<63;function JI(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(AF&&i&&i.contentEditable==`false`)return YI(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return YI(i);if(a)return YI(a)}}function YI(e){return e.contentEditable=`true`,AF&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function XI(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function ZI(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!GI(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function QI(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,tF(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&wF&&TF<=11&&(n.disabled=!0,n.disabled=!1)}function $I(e,t){if(t instanceof Gp){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(eL(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else eL(e)}function eL(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function tL(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||Up.between(t,n,r)}function nL(e){return e.editable&&!e.hasFocus()?!1:rL(e)}function rL(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function iL(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return oF(t.node,t.offset,n.anchorNode,n.anchorOffset)}function aL(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&zp.findFrom(a,t)}function oL(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function sL(e,t,n){let r=e.state.selection;if(r instanceof Up){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return oL(e,new Up(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=aL(e.state,t);return n&&n instanceof Gp?oL(e,n):!1}else if(!(MF&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?Gp.isSelectable(i)?oL(e,new Gp(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):FF?oL(e,new Up(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof Gp&&r.node.isInline)return oL(e,new Up(t>0?r.$to:r.$from));else{let n=aL(e.state,t);return n?oL(e,n):!1}}function cL(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function lL(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function uL(e,t){return t<0?dL(e):fL(e)}function dL(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(EF&&n.nodeType==1&&r<cL(n)&&lL(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(lL(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(pL(n))break;else{let t=n.previousSibling;for(;t&&lL(t,-1);)i=n.parentNode,a=tF(t),t=t.previousSibling;if(t)n=t,r=cL(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?gL(e,n,r):i&&gL(e,i,a)}function fL(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=cL(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(lL(e,1))a=n,o=++r;else break}else if(pL(n))break;else{let t=n.nextSibling;for(;t&&lL(t,1);)a=t.parentNode,o=tF(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=cL(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&gL(e,a,o)}function pL(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function mL(e,t){for(;e&&t==e.childNodes.length&&!pF(e);)t=tF(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function hL(e,t){for(;e&&!t&&!pF(e);)t=tF(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function gL(e,t,n){if(t.nodeType!=3){let e,r;(r=mL(t,n))?(t=r,n=0):(e=hL(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(mF(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&KI(e)},50)}function _L(e,t){let n=e.state.doc.resolve(t);if(!(OF||NF)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function vL(e,t,n){let r=e.state.selection;if(r instanceof Up&&!r.empty||n.indexOf(`s`)>-1||MF&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=aL(e.state,t);if(n&&n instanceof Gp)return oL(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof qp?zp.near(n,t):zp.findFrom(n,t);return o?oL(e,o):!1}return!1}function yL(e,t){if(!(e.state.selection instanceof Up))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function bL(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function xL(e){if(!AF||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;bL(e,n,`true`),setTimeout(()=>bL(e,n,`false`),20)}return!1}function SL(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function CL(e,t){let n=t.keyCode,r=SL(t);if(n==8||MF&&n==72&&r==`c`)return yL(e,-1)||uL(e,-1);if(n==46&&!t.shiftKey||MF&&n==68&&r==`c`)return yL(e,1)||uL(e,1);if(n==13||n==27)return!0;if(n==37||MF&&n==66&&r==`c`){let t=n==37?_L(e,e.state.selection.from)==`ltr`?-1:1:-1;return sL(e,t,r)||uL(e,t)}else if(n==39||MF&&n==70&&r==`c`){let t=n==39?_L(e,e.state.selection.from)==`ltr`?1:-1:1;return sL(e,t,r)||uL(e,t)}else if(n==38||MF&&n==80&&r==`c`)return vL(e,-1,r)||uL(e,-1);else if(n==40||MF&&n==78&&r==`c`)return xL(e)||vL(e,1,r)||uL(e,1);else if(r==(MF?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function wL(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||vf.fromSchema(e.state.schema),s=FL(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=NL[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
130
+
131
+ `),slice:t}}function TL(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new Q(Z.from(e.state.schema.text(t.replace(/\r\n?/g,`
132
+ `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=vf.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=RL(n),FF&&zL(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||rf.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!EL.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=BL(ML(s,+u[1],+u[2]),u[4]);else if(s=Q.maxOpen(DL(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=ML(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var EL=/^(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 DL(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&kL(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=AL(a[a.length-1],i.length));let n=OL(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return Z.from(a)}return e}function OL(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Z.from(e));return e}function kL(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=kL(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(Z.from(OL(n,e,i+1))))}}function AL(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,AL(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Z.empty,!0);return e.copy(n.append(r))}function jL(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=jL(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(Z.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function ML(e,t,n){return t<e.openStart&&(e=new Q(jL(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Q(jL(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var NL={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},PL=null;function FL(){return PL||=document.implementation.createHTMLDocument(`title`)}var IL=null;function LL(e){let t=window.trustedTypes;return t?(IL||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),IL.createHTML(e)):e}function RL(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=FL().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&NL[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=LL(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function zL(e){let t=e.querySelectorAll(OF?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function BL(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=Z.from(t.create(r[e+1],i)),a++,o++}return new Q(i,a,o)}var VL={},HL={},UL={touchstart:!0,touchmove:!0},WL=class{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 GL(e){for(let t in VL){let n=VL[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{XL(e,t)&&!YL(e,t)&&(e.editable||!(t.type in HL))&&n(e,t)},UL[t]?{passive:!0}:void 0)}AF&&e.dom.addEventListener(`input`,()=>null),JL(e)}function KL(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function qL(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function JL(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>YL(e,t))})}function YL(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function XL(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function ZL(e,t){!YL(e,t)&&VL[t.type]&&(e.editable||!(t.type in HL))&&VL[t.type](e,t)}HL.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!dR(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(PF&&OF&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),jF&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,hF(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||CL(e,n)?n.preventDefault():KL(e,`key`)},HL.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},HL.keypress=(e,t)=>{let n=t;if(dR(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||MF&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof Up)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function QL(e){return{left:e.clientX,top:e.clientY}}function $L(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function eR(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function tR(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function nR(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Gp.isSelectable(r)?(tR(e,new Gp(n),`pointer`),!0):!1}function rR(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof Gp&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(Gp.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(tR(e,Gp.create(e.state.doc,i),`pointer`),!0)}function iR(e,t,n,r,i){return eR(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?rR(e,n):nR(e,n))}function aR(e,t,n,r){return eR(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function oR(e,t,n,r){return eR(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||sR(e,n,r)}function sR(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(tR(e,Up.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)tR(e,Up.create(r,a+1,a+1+n.content.size),`pointer`);else if(Gp.isSelectable(n))tR(e,Gp.create(r,a),`pointer`);else continue;return!0}}function cR(e){return vR(e)}var lR=MF?`metaKey`:`ctrlKey`;VL.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=cR(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&$L(n,e.input.lastClick)&&!n[lR]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(QL(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new uR(e,o,n,!!r)):(a==`doubleClick`?aR:oR)(e,o.pos,o.inside,n)?n.preventDefault():KL(e,`pointer`))};var uR=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[lR],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Gp&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&EF&&!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)),KL(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(()=>KI(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(QL(e))),this.updateAllowDefault(e),this.allowDefault||!t?KL(this.view,`pointer`):iR(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||AF&&this.mightDrag&&!this.mightDrag.node.isAtom||OF&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(tR(this.view,zp.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):KL(this.view,`pointer`)}move(e){this.updateAllowDefault(e),KL(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)}};VL.touchstart=e=>{e.input.lastTouch=Date.now(),cR(e),KL(e,`pointer`)},VL.touchmove=e=>{e.input.lastTouch=Date.now(),KL(e,`pointer`)},VL.contextmenu=e=>cR(e);function dR(e,t){return e.composing?!0:AF&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var fR=PF?5e3:-1;HL.compositionstart=HL.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Up&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||OF&&NF&&pR(e)))e.markCursor=e.state.storedMarks||n.marks(),vR(e,!0),e.markCursor=null;else if(vR(e,!t.selection.empty),EF&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}mR(e,fR)};function pR(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}HL.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,mR(e,20))};function mR(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>vR(e),t))}function hR(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=_R());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function gR(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=uF(t.focusNode,t.focusOffset),r=dF(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function _R(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function vR(e,t=!1){if(!(PF&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),hR(e),t||e.docView&&e.docView.dirty){let n=WI(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function yR(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var bR=wF&&TF<15||jF&&IF<604;VL.copy=HL.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=bR?null:n.clipboardData,{dom:o,text:s}=wL(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):yR(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function xR(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function SR(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.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=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?CR(e,r.value,null,i,t):CR(e,r.textContent,r.innerHTML,i,t)},50)}function CR(e,t,n,r,i){let a=TL(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||Q.empty)))return!0;if(!a)return!1;let o=xR(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function wR(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}HL.paste=(e,t)=>{let n=t;if(e.composing&&!PF)return;let r=bR?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&CR(e,wR(r),r.getData(`text/html`),i,n)?n.preventDefault():SR(e,n)};var TR=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},ER=MF?`altKey`:`ctrlKey`;function DR(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[ER]}VL.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(QL(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Gp?i.to-1:i.to))){if(r&&r.mightDrag)o=Gp.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Gp.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=wL(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!OF||kF>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(bR?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,bR||n.dataTransfer.setData(`text/plain`,c),e.dragging=new TR(l,DR(e,n),o)},VL.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},HL.dragover=HL.dragenter=(e,t)=>t.preventDefault(),HL.drop=(e,t)=>{try{OR(e,t,e.dragging)}finally{e.dragging=null}};function OR(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(QL(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=TL(e,wR(t.dataTransfer),bR?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&DR(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||Q.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?vp(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&Gp.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Gp(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(tL(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}VL.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&KI(e)},20))},VL.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},VL.beforeinput=(e,t)=>{if(OF&&PF&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,hF(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in HL)VL[e]=HL[e];function kR(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var AR=class e{constructor(e,t){this.toDOM=e,this.spec=t||FR,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new NR(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&kR(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},jR=class e{constructor(e,t){this.attrs=e,this.spec=t||FR}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new NR(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&kR(this.attrs,t.attrs)&&kR(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},MR=class e{constructor(e,t){this.attrs=e,this.spec=t||FR}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new NR(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&kR(this.attrs,t.attrs)&&kR(this.spec,t.spec)}destroy(){}},NR=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new AR(n,r))}static inline(t,n,r,i){return new e(t,n,new jR(r,i))}static node(t,n,r,i){return new e(t,n,new MR(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof jR}get widget(){return this.type instanceof AR}},PR=[],FR={},IR=class e{constructor(e,t){this.local=e.length?e:PR,this.children=t.length?t:PR}static create(e,t){return t.length?WR(t,e,0,FR):LR}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==LR||e.maps.length==0?this:this.mapInner(e,t,0,0,n||FR)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?zR(this.children,o||[],t,n,r,i,a):o?new e(o.sort(GR),PR):LR}add(t,n){return n.length?this==LR?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=HR(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,WR(s,e,o+1,FR)),a+=3}});let o=BR(a?UR(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(GR):this.local,i||this.children)}remove(e){return e.length==0||this==LR?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==LR?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):LR}forChild(t,n){if(this==LR)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof jR){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(GR),PR);return r?new RR([t,r]):t}return r||LR}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return KR(this.localsInner(e))}localsInner(e){if(this==LR)return PR;if(e.inlineContent||!this.local.some(jR.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof jR||t.push(this.local[e]);return t}forEachSet(e){e(this)}};IR.empty=new IR([],[]),IR.removeOverlap=KR;var LR=IR.empty,RR=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,FR));return e.from(r)}forChild(t,n){if(n.isLeaf)return IR.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=LR&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?KR(n?t:t.sort(GR)):PR}static from(t){switch(t.length){case 0:return LR;case 1:return t[0];default:return new e(t.every(e=>e instanceof IR)?t:t.reduce((e,t)=>e.concat(t instanceof IR?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function zR(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==LR?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=WR(VR(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new IR(t.sort(GR),s)}function BR(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new NR(i.from+t,i.to+t,i.type))}return n}function VR(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function HR(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function UR(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function WR(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=HR(e,t,o+n);if(s){a=!0;let e=WR(s,t,n+o+1,r);e!=LR&&i.push(o,o+t.nodeSize,e)}});let o=BR(a?UR(e):e,-n).sort(GR);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new IR(o,i):LR}function GR(e,t){return e.from-t.from||e.to-t.to}function KR(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),qR(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),qR(t,i,r.copy(a.from,r.to)));break}}}return t}function qR(e,t,n){for(;t<e.length&&GR(n,e[t])>0;)t++;e.splice(t,0,n)}function JR(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=LR&&t.push(r)}),e.cursorWrapper&&t.push(IR.create(e.state.doc,[e.cursorWrapper.deco])),RR.from(t)}var YR={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},XR=wF&&TF<=11,ZR=class{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}},QR=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ZR,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);wF&&TF<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():AF&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),XR&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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,YR)),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 t=0;t<e.length;t++)this.queue.push(e[t]);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(nL(this.view)){if(this.suppressingSelectionUpdates)return KI(this.view);if(wF&&TF<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&oF(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 t=new Set,n;for(let n=e.focusNode;n;n=nF(n))t.add(n);for(let r=e.anchorNode;r;r=nF(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))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 t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&nL(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(EF&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||iz(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&mF(n)&&(c=WI(e))&&c.eq(zp.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,KI(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),tz(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,az(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||KI(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(wF&&TF<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?tF(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?tF(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},$R=new WeakMap,ez=!1;function tz(e){if(!$R.has(e)&&($R.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=EF,ez)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.`),ez=!0}}function nz(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return oF(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function rz(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return nz(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?nz(e,n):null}function iz(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function az(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function oz(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],mF(c)||l.push({node:c.focusNode,offset:c.focusOffset})),OF&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||rf.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:sz,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function sz(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(AF&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||AF&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var cz=/^(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 lz(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=WI(e,t);if(n&&!e.state.selection.eq(n)){if(OF&&PF&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,hF(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=oz(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=mz(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(jF&&e.input.lastIOSEnter>Date.now()-225||PF)&&i.some(e=>e.nodeType==1&&!cz.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,hF(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof Up&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=uz(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof Up&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),wF&&TF<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((jF&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,hF(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&fz(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,hF(8,`Backspace`)))){PF&&OF&&e.domObserver.suppressSelectionUpdates();return}OF&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),PF&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,hF(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=uz(e,n.doc,l.sel);t&&!(OF&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||wF&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){wF&&TF<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>KI(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=dz(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function uz(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:tL(e,t.resolve(n.anchor),t.resolve(n.head))}function dz(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(Z.from(l).eq(e))return{mark:s,type:o}}function fz(e,t,n,r,i){if(n-t<=i.pos-r.pos||pz(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(pz(a,!0,!0));return!o.parent.isTextblock||o.pos>n||pz(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function pz(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function mz(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&hz(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&hz(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function hz(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var gz=class{constructor(e,t){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 WL,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Cz),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=yz(this),vz(this),this.nodeViews=xz(this),this.docView=wI(this.state.doc,_z(this),JR(this),this.dom,this),this.domObserver=new QR(this,(e,t,n,r)=>lz(this,e,t,n,r)),this.domObserver.start(),GL(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 t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&JL(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Cz),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(hR(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=xz(this);Sz(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&JL(this),this.editable=yz(this),vz(this);let o=JR(this),s=_z(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&VF(this);if(i){this.domObserver.stop();let t=l&&(wF||OF)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&bz(n.selection,e.selection);if(l){let n=OF?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=gR(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=wI(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&iL(this))?KI(this,t):($I(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&UF(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof Gp){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&BF(this,t.getBoundingClientRect(),e)}else BF(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 e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new TR(e.slice,e.move,r<0?void 0:Gp.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(wF){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&&KF(this.dom),KI(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return eI(this,e)}coordsAtPos(e,t=1){return iI(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return mI(this,t||this.state,e)}pasteHTML(e,t){return CR(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return CR(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return wL(this,e)}destroy(){this.docView&&(qL(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],JR(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,aF())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ZL(this,e)}domSelectionRange(){let e=this.domSelection();return e?AF&&this.root.nodeType===11&&gF(this.dom.ownerDocument)==this.dom&&rz(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};gz.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function _z(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[NR.node(0,e.state.doc.content.size,t)]}function vz(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:NR.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function yz(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function bz(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function xz(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Sz(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Cz(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var wz={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:`'`},Tz={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Ez=typeof navigator<`u`&&/Mac/.test(navigator.platform),Dz=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Oz=0;Oz<10;Oz++)wz[48+Oz]=wz[96+Oz]=String(Oz);for(var Oz=1;Oz<=24;Oz++)wz[Oz+111]=`F`+Oz;for(var Oz=65;Oz<=90;Oz++)wz[Oz]=String.fromCharCode(Oz+32),Tz[Oz]=String.fromCharCode(Oz);for(var kz in wz)Tz.hasOwnProperty(kz)||(Tz[kz]=wz[kz]);function Az(e){var t=!(Ez&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Dz&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Tz:wz)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var jz=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Mz=typeof navigator<`u`&&/Win/.test(navigator.platform);function Nz(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))jz?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function Pz(e){let t=Object.create(null);for(let n in e)t[Nz(n)]=e[n];return t}function Fz(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function Iz(e){return new sm({props:{handleKeyDown:Lz(e)}})}function Lz(e){let t=Pz(e);return function(e,n){let r=Az(n),i,a=t[Fz(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[Fz(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Mz&&n.ctrlKey&&n.altKey)&&(i=wz[n.keyCode])&&i!=r){let r=t[Fz(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Rz=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function zz(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var Bz=(e,t,n)=>{let r=zz(e,n);if(!r)return!1;let i=Kz(r);if(!i){let n=r.blockRange(),i=n&&Qf(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(uB(e,i,t,-1))return!0;if(r.parent.content.size==0&&(Wz(a,`end`)||Gp.isSelectable(a)))for(let n=r.depth;;n--){let o=yp(e.doc,r.before(n),r.after(n),Q.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(Wz(a,`end`)?zp.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):Gp.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},Vz=(e,t,n)=>{let r=zz(e,n);if(!r)return!1;let i=Kz(r);return i?Uz(e,i,t):!1},Hz=(e,t,n)=>{let r=qz(e,n);if(!r)return!1;let i=Xz(r);return i?Uz(e,i,t):!1};function Uz(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=yp(e.doc,i,o,Q.empty);if(!s||s.from!=i||s instanceof Gf&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(Up.create(t.doc,i)),n(t.scrollIntoView())}return!0}function Wz(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Gz=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=Kz(r)}let o=a&&a.nodeBefore;return!o||!Gp.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Gp.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function Kz(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function qz(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var Jz=(e,t,n)=>{let r=qz(e,n);if(!r)return!1;let i=Xz(r);if(!i)return!1;let a=i.nodeAfter;if(uB(e,i,t,1))return!0;if(r.parent.content.size==0&&(Wz(a,`start`)||Gp.isSelectable(a))){let n=yp(e.doc,r.before(),r.after(),Q.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Wz(a,`start`)?zp.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Gp.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},Yz=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=Xz(r)}let o=a&&a.nodeAfter;return!o||!Gp.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Gp.create(e.doc,a.pos)).scrollIntoView()),!0)};function Xz(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var Zz=(e,t)=>{let n=e.selection,r=n instanceof Gp,i;if(r){if(n.node.isTextblock||!fp(e.doc,n.from))return!1;i=n.from}else if(i=hp(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(Gp.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},Qz=(e,t)=>{let n=e.selection,r;if(n instanceof Gp){if(n.node.isTextblock||!fp(e.doc,n.to))return!1;r=n.to}else if(r=hp(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},$z=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&Qf(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},eB=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
133
+ `).scrollIntoView()),!0)};function tB(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var nB=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=tB(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(zp.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},rB=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof qp||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=tB(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(Up.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},iB=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(up(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Qf(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function aB(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof Gp&&t.selection.node.isBlock)return!r.parentOffset||!up(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=tB(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof Up||t.selection instanceof qp)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=up(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,up(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var oB=aB(),sB=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(Gp.create(e.doc,i))),!0)},cB=(e,t)=>(t&&t(e.tr.setSelection(new qp(e.doc))),!0);function lB(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||fp(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function uB(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&lB(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=Z.empty;for(let e=o.length-1;e>=0;e--)s=Z.from(o[e].create(null,s));s=Z.from(i.copy(s));let c=e.tr.step(new Kf(t.pos-1,r,t.pos,r,new Q(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&fp(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:zp.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Qf(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&Wz(a,`start`,!0)&&Wz(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=Z.empty;for(let e=o.length-1;e>=0;e--)r=Z.from(o[e].copy(r));n(e.tr.step(new Kf(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new Q(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function dB(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(Up.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var fB=dB(-1),pB=dB(1);function mB(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&ep(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function hB(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function gB(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var _B=gB(Rz,Bz,Gz),vB=gB(Rz,Jz,Yz),yB={Enter:gB(eB,rB,iB,oB),"Mod-Enter":nB,Backspace:_B,"Mod-Backspace":_B,"Shift-Backspace":_B,Delete:vB,"Mod-Delete":vB,"Mod-a":cB},bB={"Ctrl-h":yB.Backspace,"Alt-Backspace":yB[`Mod-Backspace`],"Ctrl-d":yB.Delete,"Ctrl-Alt-Backspace":yB[`Mod-Delete`],"Alt-Delete":yB[`Mod-Delete`],"Alt-d":yB[`Mod-Delete`],"Ctrl-a":fB,"Ctrl-e":pB};for(let e in yB)bB[e]=yB[e];typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform();function xB(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return SB(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function SB(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new Ed(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new Ed(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=ep(a,n,r,t);return s?(e&&CB(e,t,s,i,n),!0):!1}function CB(e,t,n,r,i){let a=Z.empty;for(let e=n.length-1;e>=0;e--)a=Z.from(n[e].type.create(n[e].attrs,a));e.step(new Kf(t.start-(r?2:0),t.end,t.start,t.end,new Q(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&up(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function wB(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?TB(t,n,e,a):EB(t,n,a):!0:!1}}function TB(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Kf(a-1,o,a,o,new Q(Z.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Ed(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=Qf(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return fp(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function EB(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?Z.empty:Z.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new Kf(d-+!!s,f+ +!!c,d+1,f-1,new Q((s?Z.empty:Z.from(i.copy(Z.empty))).append(c?Z.empty:Z.from(i.copy(Z.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function DB(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=Z.from(r?e.create():null),o=new Q(Z.from(e.create(null,Z.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new Kf(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}function OB(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var kB=class{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(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:OB({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},AB=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}};function jB(e,t,n){return e.config[t]===void 0&&e.parent?jB(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?jB(e.parent,t,n):null}):e.config[t]}function MB(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function NB(e){let t=[],{nodeExtensions:n,markExtensions:r}=MB(e),i=[...n,...r],a={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{let n=jB(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=jB(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function PB(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function FB(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=t?t.split(`;`).map(e=>e.trim()).filter(Boolean):[],i=n[e]?n[e].split(`;`).map(e=>e.trim()).filter(Boolean):[],a=new Map;i.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),r.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),n[e]=Array.from(a.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function IB(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>FB(e,t),{})}function LB(e){return typeof e==`function`}function RB(e,t=void 0,...n){return LB(e)?t?e.bind(t)(...n):e(...n):e}function zB(e={}){return Object.keys(e).length===0&&e.constructor===Object}function BB(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function VB(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):BB(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function HB(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&zB(t)?!1:t!=null))}function UB(e,t){let n=NB(e),{nodeExtensions:r,markExtensions:i}=MB(e);return new $d({topNode:r.find(e=>jB(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=HB({...e.reduce((e,t)=>{let n=jB(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:RB(jB(r,`content`,a)),marks:RB(jB(r,`marks`,a)),group:RB(jB(r,`group`,a)),inline:RB(jB(r,`inline`,a)),atom:RB(jB(r,`atom`,a)),selectable:RB(jB(r,`selectable`,a)),draggable:RB(jB(r,`draggable`,a)),code:RB(jB(r,`code`,a)),whitespace:RB(jB(r,`whitespace`,a)),linebreakReplacement:RB(jB(r,`linebreakReplacement`,a)),defining:RB(jB(r,`defining`,a)),isolating:RB(jB(r,`isolating`,a)),attrs:Object.fromEntries(i.map(e=>[e.name,{default:e?.attribute?.default}]))}),s=RB(jB(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>VB(e,i)));let c=jB(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:IB(e,i)}));let l=jB(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=HB({...e.reduce((e,t)=>{let n=jB(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:RB(jB(r,`inclusive`,a)),excludes:RB(jB(r,`excludes`,a)),group:RB(jB(r,`group`,a)),spanning:RB(jB(r,`spanning`,a)),code:RB(jB(r,`code`,a)),attrs:Object.fromEntries(i.map(e=>[e.name,{default:e?.attribute?.default}]))}),s=RB(jB(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>VB(e,i)));let c=jB(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:IB(e,i)})),[r.name,o]}))})}function WB(e,t){return t.nodes[e]||t.marks[e]||null}function GB(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function KB(e,t){let n=vf.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}var qB=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function JB(e){return Object.prototype.toString.call(e)===`[object RegExp]`}var YB=class{constructor(e){this.find=e.find,this.handler=e.handler}},XB=(e,t)=>{if(JB(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,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 ZB(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=qB(c)+i;return a.forEach(e=>{if(l)return;let a=XB(u,e.find);if(!a)return;let c=s.state.tr,d=OB({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new kB({editor:t,state:d});e.handler({state:d,range:f,match:a,commands:p,chain:m,can:h})===null||!c.steps.length||(c.setMeta(o,{transform:c,from:n,to:r,text:i}),s.dispatch(c),l=!0)}),l}function QB(e){let{editor:t,rules:n}=e,r=new sm({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:KB(Z.from(e),a.schema);let{from:i}=s;ZB({editor:t,from:i,to:i+e.length,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return ZB({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&ZB({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?ZB({editor:t,from:a.pos,to:a.pos,text:`
134
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function $B(e){return Object.prototype.toString.call(e).slice(8,-1)}function eV(e){return $B(e)===`Object`?e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype:!1}function tV(e,t){let n={...e};return eV(e)&&eV(t)&&Object.keys(t).forEach(r=>{eV(t[r])&&eV(e[r])?n[r]=tV(e[r],t[r]):n[r]=t[r]}),n}var nV=class e{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=RB(jB(this,`addOptions`,{name:this.name}))),this.storage=RB(jB(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>tV(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(t={}){let n=new e(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=RB(jB(n,`addOptions`,{name:n.name})),n.storage=RB(jB(n,`addStorage`,{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}};function rV(e){return typeof e==`number`}var iV=class{constructor(e){this.find=e.find,this.handler=e.handler}},aV=(e,t,n)=>{if(JB(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function oV(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new kB({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{if(!e.isTextblock||e.type.spec.code)return;let f=Math.max(r,t),p=Math.min(i,t+e.content.size);aV(e.textBetween(f-t,p-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=f+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},p=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(p)})}),d.every(e=>e!==null)}var sV=null,cV=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function lV(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr;if(!(!oV({editor:t,state:OB({state:e,transaction:c}),from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})||!c.steps.length)){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return n.map(e=>new sm({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(sV=t)},i=()=>{sV&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=sV;e?.isEditable&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:KB(Z.from(t),r.schema);let{from:n}=d,i=n+t.length,a=cV(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(!(!rV(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}function uV(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}var dV=class e{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=e.resolve(t),this.schema=UB(this.extensions,n),this.setupExtensions()}static resolve(t){let n=e.sort(e.flatten(t)),r=uV(n.map(e=>e.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),n}static flatten(e){return e.map(e=>{let t=jB(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...this.flatten(t())]:e}).flat(10)}static sort(e){return e.sort((e,t)=>{let n=jB(e,`priority`)||100,r=jB(t,`priority`)||100;return n>r?-1:+(n<r)})}get commands(){return this.extensions.reduce((e,t)=>{let n=jB(t,`addCommands`,{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:WB(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:t}=this,n=e.sort([...this.extensions].reverse()),r=[],i=[],a=n.map(e=>{let n={name:e.name,options:e.options,storage:e.storage,editor:t,type:WB(e.name,this.schema)},a=[],o=jB(e,`addKeyboardShortcuts`,n),s={};if(e.type===`mark`&&jB(e,`exitable`,n)&&(s.ArrowRight=()=>nV.handleExit({editor:t,mark:e})),o){let e=Object.fromEntries(Object.entries(o()).map(([e,n])=>[e,()=>n({editor:t})]));s={...s,...e}}let c=Iz(s);a.push(c);let l=jB(e,`addInputRules`,n);GB(e,t.options.enableInputRules)&&l&&r.push(...l());let u=jB(e,`addPasteRules`,n);GB(e,t.options.enablePasteRules)&&u&&i.push(...u());let d=jB(e,`addProseMirrorPlugins`,n);if(d){let e=d();a.push(...e)}return a}).flat();return[QB({editor:t,rules:r}),...lV({editor:t,rules:i}),...a]}get attributes(){return NB(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=MB(this.extensions);return Object.fromEntries(t.filter(e=>!!jB(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=jB(t,`addNodeView`,{name:t.name,options:t.options,storage:t.storage,editor:e,type:PB(t.name,this.schema)});return r?[t.name,(i,a,o,s,c)=>{let l=IB(i,n);return r()({node:i,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}setupExtensions(){this.extensions.forEach(e=>{this.editor.extensionStorage[e.name]=e.storage;let t={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:WB(e.name,this.schema)};e.type===`mark`&&(RB(jB(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name);let n=jB(e,`onBeforeCreate`,t),r=jB(e,`onCreate`,t),i=jB(e,`onUpdate`,t),a=jB(e,`onSelectionUpdate`,t),o=jB(e,`onTransaction`,t),s=jB(e,`onFocus`,t),c=jB(e,`onBlur`,t),l=jB(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}},fV=class e{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=RB(jB(this,`addOptions`,{name:this.name}))),this.storage=RB(jB(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>tV(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(t={}){let n=new e({...this.config,...t});return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=RB(jB(n,`addOptions`,{name:n.name})),n.storage=RB(jB(n,`addStorage`,{name:n.name,options:n.options})),n}};function pV(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=`
135
+
136
+ `,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;e.isText&&(s+=(e?.text)?.slice(Math.max(r,n)-n,i-n))}),s}function mV(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}var hV=fV.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new sm({key:new um(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:a}=i,o=Math.min(...a.map(e=>e.$from.pos)),s=Math.max(...a.map(e=>e.$to.pos)),c=mV(n);return pV(r,{from:o,to:s},{...this.options.blockSeparator===void 0?{}:{blockSeparator:this.options.blockSeparator},textSerializers:c})}}})]}}),gV=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),_V=(e=!1)=>({commands:t})=>t.setContent(``,e),vV=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=Qf(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},yV=e=>t=>e(t),bV=()=>({state:e,dispatch:t})=>rB(e,t),xV=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new Up(r.doc.resolve(Math.max(o-1,0)))),!0},SV=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1},CV=e=>({tr:t,state:n,dispatch:r})=>{let i=PB(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},wV=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},TV=()=>({state:e,dispatch:t})=>Rz(e,t),EV=()=>({commands:e})=>e.keyboardShortcut(`Enter`),DV=()=>({state:e,dispatch:t})=>nB(e,t);function OV(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:JB(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function kV(e,t,n={}){return e.find(e=>e.type===t&&OV(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function AV(e,t,n={}){return!!kV(e,t,n)}function jV(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t)||(n||=r.node.marks[0]?.attrs,!kV([...r.node.marks],t,n)))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&AV([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&AV([...e.parent.child(o).marks],t,n);)s+=e.parent.child(o).nodeSize,o+=1;return{from:a,to:s}}function MV(e,t){if(typeof e==`string`){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var NV=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=MV(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=jV(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=Up.create(o,e.from,e.to);n.setSelection(t)}}return!0},PV=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function FV(e){return e instanceof Up}function IV(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function LV(e,t=null){if(!t)return null;let n=zp.atStart(e),r=zp.atEnd(e);if(t===`start`||t===!0)return n;if(t===`end`)return r;let i=n.from,a=r.to;return t===`all`?Up.create(e,IV(0,i,a),IV(e.content.size,i,a)):Up.create(e,IV(t,i,a),IV(t,i,a))}function RV(){return navigator.platform===`Android`||/android/i.test(navigator.userAgent)}function zV(){return[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document}function BV(){return typeof navigator<`u`?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var VV=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(zV()||RV())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),BV()&&!zV()&&!RV()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&e===null||e===!1)return!0;if(a&&e===null&&!FV(n.state.selection))return o(),!0;let s=LV(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},HV=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),UV=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),WV=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&WV(r)}return e};function GV(e){let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return WV(n)}function KV(e,t,n){if(e instanceof Od||e instanceof Z)return e;n={slice:!0,parseOptions:{},...n};let r=typeof e==`object`&&!!e,i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return Z.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),KV(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new $d({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?rf.fromSchema(a).parseSlice(GV(e),n.parseOptions):rf.fromSchema(a).parse(GV(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=rf.fromSchema(t);return n.slice?r.parseSlice(GV(e),n.parseOptions).content:r.parse(GV(e),n.parseOptions)}return KV(``,t,n)}function qV(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Gf||i instanceof Kf))return;let a=e.mapping.maps[r],o=0;a.forEach((e,t,n,r)=>{o===0&&(o=r)}),e.setSelection(zp.near(e.doc.resolve(o),n))}var JV=e=>!(`type`in e),YV=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{KV(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=KV(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((JV(i)?i:[i]).forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let f;if(u){if(Array.isArray(t))f=t.map(e=>e.text||``).join(``);else if(t instanceof Z){let e=``;t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f=typeof t==`object`&&t&&t.text?t.text:t;r.insertText(f,c,l)}else f=i,r.replaceWith(c,l,f);n.updateSelection&&qV(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:f}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:f})}return!0},XV=()=>({state:e,dispatch:t})=>Zz(e,t),ZV=()=>({state:e,dispatch:t})=>Qz(e,t),QV=()=>({state:e,dispatch:t})=>Bz(e,t),$V=()=>({state:e,dispatch:t})=>Jz(e,t),eH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=hp(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},tH=()=>({state:e,dispatch:t,tr:n})=>{try{let r=hp(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},nH=()=>({state:e,dispatch:t})=>Vz(e,t),rH=()=>({state:e,dispatch:t})=>Hz(e,t);function iH(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function aH(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e+=1){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))zV()||iH()?o=!0:i=!0;else throw Error(`Unrecognized modifier name: ${n}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var oH=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let a=aH(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function sH(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?PB(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>o?o.name===e.node.type.name:!0).filter(e=>OV(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var cH=(e,t={})=>({state:n,dispatch:r})=>sH(n,PB(e,n.schema),t)?$z(n,r):!1,lH=()=>({state:e,dispatch:t})=>iB(e,t),uH=e=>({state:t,dispatch:n})=>wB(PB(e,t.schema))(t,n),dH=()=>({state:e,dispatch:t})=>eB(e,t);function fH(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function pH(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var mH=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=fH(typeof e==`string`?e:e.name,r.schema);return s?(s===`node`&&(a=PB(e,r.schema)),s===`mark`&&(o=MV(e,r.schema)),i&&n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&n.setNodeMarkup(r,void 0,pH(e.attrs,t)),o&&e.marks.length&&e.marks.forEach(i=>{o===i.type&&n.addMark(r,r+e.nodeSize,o.create(pH(i.attrs,t)))})})}),!0):!1},hH=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),gH=()=>({tr:e,dispatch:t})=>{if(t){let t=new qp(e.doc);e.setSelection(t)}return!0},_H=()=>({state:e,dispatch:t})=>Gz(e,t),vH=()=>({state:e,dispatch:t})=>Yz(e,t),yH=()=>({state:e,dispatch:t})=>sB(e,t),bH=()=>({state:e,dispatch:t})=>pB(e,t),xH=()=>({state:e,dispatch:t})=>fB(e,t);function SH(e,t,n={},r={}){return KV(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var CH=(e,t=!1,n={},r={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(n.preserveWhitespace!==`full`){let s=SH(e,i.schema,n,{errorOnInvalidContent:r.errorOnInvalidContent??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,s).setMeta(`preventUpdate`,!t),!0}return o&&a.setMeta(`preventUpdate`,!t),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent??i.options.enableContentCheck})};function wH(e,t){let n=MV(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function TH(e,t){let n=new Lp(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function EH(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function DH(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function OH(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function kH(e){return t=>OH(t.$from,e)}function AH(e,t){return pV(e,{from:0,to:e.content.size},t)}function jH(e,t){let n=PB(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function MH(e,t){let n=fH(typeof t==`string`?t:t.name,e.schema);return n===`node`?jH(e,t):n===`mark`?wH(e,t):{}}function NH(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function PH(e){let t=NH(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function FH(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),PH(r)}function IH(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=jV(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}function LH(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}function RH(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?MV(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>OV(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize),c=a-n;o+=c,s.push(...e.marks.map(e=>({mark:e,from:n,to:a})))})}),o===0)return!1;let c=s.filter(e=>a?a.name===e.mark.type.name:!0).filter(e=>OV(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>a?e.mark.type!==a&&e.mark.type.excludes(a):!0).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function zH(e,t,n={}){if(!t)return sH(e,null,n)||RH(e,null,n);let r=fH(t,e.schema);return r===`node`?sH(e,t,n):r===`mark`?RH(e,t,n):!1}function BH(e,t){let{nodeExtensions:n}=MB(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=RB(jB(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function VH(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return/^\s*$/m.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(VH(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function HH(e){return e instanceof Gp}function UH(e,t,n){let{selection:r}=t,i=null;if(FV(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return!!n.isInSet(t)||!t.some(e=>e.type.excludes(n))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var WH=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=MV(e,r.schema);if(i)if(o){let e=wH(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return UH(r,n,c)},GH=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),KH=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=PB(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>hB(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>hB(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},qH=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=IV(e,0,n.content.size),i=Gp.create(n,r);t.setSelection(i)}return!0},JH=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=Up.atStart(n).from,o=Up.atEnd(n).to,s=IV(r,a,o),c=IV(i,a,o),l=Up.create(n,s,c);t.setSelection(l)}return!0},YH=e=>({state:t,dispatch:n})=>DB(PB(e,t.schema))(t,n);function XH(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var ZH=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=LH(l,s.node().type.name,s.node().attrs);if(a instanceof Gp&&a.node.isBlock)return!s.parentOffset||!up(o,s.pos)?!1:(r&&(e&&XH(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:EH(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=up(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&up(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof Up&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&XH(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},QH=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=PB(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=Z.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=Z.from(s.node(t).copy(e));let i=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,a={...LH(d,s.node().type.name,s.node().attrs),...t},c=o.contentMatch.defaultType?.createAndFill(a)||void 0;e=e.append(Z.from(o.createAndFill(null,c)||void 0));let l=s.before(s.depth-(r-1));n.replace(l,s.after(-i),new Q(e,4-r,0));let u=-1;n.doc.nodesBetween(l,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(Up.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...LH(d,u.type.name,u.attrs),...t},m={...LH(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!up(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0},$H=(e,t)=>{let n=kH(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&fp(e.doc,n.pos)&&e.join(n.pos),!0},eU=(e,t)=>{let n=kH(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&fp(e.doc,r)&&e.join(r),!0},tU=Object.freeze({__proto__:null,blur:gV,clearContent:_V,clearNodes:vV,command:yV,createParagraphNear:bV,cut:xV,deleteCurrentNode:SV,deleteNode:CV,deleteRange:wV,deleteSelection:TV,enter:EV,exitCode:DV,extendMarkRange:NV,first:PV,focus:VV,forEach:HV,insertContent:UV,insertContentAt:YV,joinBackward:QV,joinDown:ZV,joinForward:$V,joinItemBackward:eH,joinItemForward:tH,joinTextblockBackward:nH,joinTextblockForward:rH,joinUp:XV,keyboardShortcut:oH,lift:cH,liftEmptyBlock:lH,liftListItem:uH,newlineInCode:dH,resetAttributes:mH,scrollIntoView:hH,selectAll:gH,selectNodeBackward:_H,selectNodeForward:vH,selectParentNode:yH,selectTextblockEnd:bH,selectTextblockStart:xH,setContent:CH,setMark:WH,setMeta:GH,setNode:KH,setNodeSelection:qH,setTextSelection:JH,sinkListItem:YH,splitBlock:ZH,splitListItem:QH,toggleList:(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=PB(e,o.schema),m=PB(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=kH(e=>BH(e.type.name,d))(h);if(y.depth>=1&&x&&y.depth-x.depth<=1){if(x.node.type===p)return l.liftListItem(m);if(BH(x.node.type.name,d)&&p.validContent(x.node.content)&&s)return c().command(()=>(a.setNodeMarkup(x.pos,p),!0)).command(()=>$H(a,p)).command(()=>eU(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>$H(a,p)).command(()=>eU(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>$H(a,p)).command(()=>eU(a,p)).run()},toggleMark:(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=MV(e,r.schema);return RH(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},toggleNode:(e,t,n={})=>({state:r,commands:i})=>{let a=PB(e,r.schema),o=PB(t,r.schema),s=sH(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},toggleWrap:(e,t={})=>({state:n,commands:r})=>{let i=PB(e,n.schema);return sH(n,i,t)?r.lift(i):r.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let t=e.tr,n=a.transform;for(let e=n.steps.length-1;e>=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},unsetMark:(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=MV(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=jV(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},updateAttributes:(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=fH(typeof e==`string`?e:e.name,r.schema);return s?(s===`node`&&(a=PB(e,r.schema)),s===`mark`&&(o=MV(e,r.schema)),i&&n.selection.ranges.forEach(e=>{let i=e.$from.pos,s=e.$to.pos,c,l,u,d;n.selection.empty?r.doc.nodesBetween(i,s,(e,t)=>{a&&a===e.type&&(u=Math.max(t,i),d=Math.min(t+e.nodeSize,s),c=t,l=e)}):r.doc.nodesBetween(i,s,(e,r)=>{r<i&&a&&a===e.type&&(u=Math.max(r,i),d=Math.min(r+e.nodeSize,s),c=r,l=e),r>=i&&r<=s&&(a&&a===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type){let c=Math.max(r,i),l=Math.min(r+e.nodeSize,s);n.addMark(c,l,o.create({...a.attrs,...t}))}}))}),l&&(c!==void 0&&n.setNodeMarkup(c,void 0,{...l.attrs,...t}),o&&l.marks.length&&l.marks.forEach(e=>{o===e.type&&n.addMark(u,d,o.create({...e.attrs,...t}))}))}),!0):!1},wrapIn:(e,t={})=>({state:n,dispatch:r})=>mB(PB(e,n.schema),t)(n,r),wrapInList:(e,t={})=>({state:n,dispatch:r})=>xB(PB(e,n.schema),t)(n,r)}),nU=fV.create({name:`commands`,addCommands(){return{...tU}}}),rU=fV.create({name:`drop`,addProseMirrorPlugins(){return[new sm({key:new um(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),iU=fV.create({name:`editable`,addProseMirrorPlugins(){return[new sm({key:new um(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),aU=new um(`focusEvents`),oU=fV.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new sm({key:aU,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),sU=fV.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:zp.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return zV()||iH()?i:r},addProseMirrorPlugins(){return[new sm({key:new um(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=zp.atStart(t.doc).from,l=zp.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!VH(n.doc))return;let u=n.tr,d=OB({state:n,transaction:u}),{commands:f}=new kB({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),cU=fV.create({name:`paste`,addProseMirrorPlugins(){return[new sm({key:new um(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),lU=fV.create({name:`tabindex`,addProseMirrorPlugins(){return[new sm({key:new um(`tabindex`),props:{attributes:()=>this.editor.isEditable?{tabindex:`0`}:{}}})]}}),uU=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=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}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},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}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=this.pos+r+ +!a;if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;let s=this.resolvedPos.doc.resolve(o);if(!i&&s.depth<=this.depth)return;let c=new e(s,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),t.push(new e(s,this.editor,i,i?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==t[i])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||this.children.length===0)return r;let i=Object.keys(t);return this.children.forEach(a=>{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),!(n&&r.length>0)&&(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},dU=`.ProseMirror {
137
+ position: relative;
138
+ }
139
+
140
+ .ProseMirror {
141
+ word-wrap: break-word;
142
+ white-space: pre-wrap;
143
+ white-space: break-spaces;
144
+ -webkit-font-variant-ligatures: none;
145
+ font-variant-ligatures: none;
146
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
147
+ }
148
+
149
+ .ProseMirror [contenteditable="false"] {
150
+ white-space: normal;
151
+ }
152
+
153
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
154
+ white-space: pre-wrap;
155
+ }
156
+
157
+ .ProseMirror pre {
158
+ white-space: pre-wrap;
159
+ }
160
+
161
+ img.ProseMirror-separator {
162
+ display: inline !important;
163
+ border: none !important;
164
+ margin: 0 !important;
165
+ width: 0 !important;
166
+ height: 0 !important;
167
+ }
168
+
169
+ .ProseMirror-gapcursor {
170
+ display: none;
171
+ pointer-events: none;
172
+ position: absolute;
173
+ margin: 0;
174
+ }
175
+
176
+ .ProseMirror-gapcursor:after {
177
+ content: "";
178
+ display: block;
179
+ position: absolute;
180
+ top: -2px;
181
+ width: 20px;
182
+ border-top: 1px solid black;
183
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
184
+ }
185
+
186
+ @keyframes ProseMirror-cursor-blink {
187
+ to {
188
+ visibility: hidden;
189
+ }
190
+ }
191
+
192
+ .ProseMirror-hideselection *::selection {
193
+ background: transparent;
194
+ }
195
+
196
+ .ProseMirror-hideselection *::-moz-selection {
197
+ background: transparent;
198
+ }
199
+
200
+ .ProseMirror-hideselection * {
201
+ caret-color: transparent;
202
+ }
203
+
204
+ .ProseMirror-focused .ProseMirror-gapcursor {
205
+ display: block;
206
+ }
207
+
208
+ .tippy-box[data-animation=fade][data-state=hidden] {
209
+ opacity: 0
210
+ }`;function fU(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}var pU=class extends AB{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:e})=>{throw e},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:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),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=fU(dU,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,t=!0){this.setOptions({editable:e}),t&&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,t){let n=LB(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){let e=[...this.options.enableCoreExtensions?[iU,hV.configure({blockSeparator:this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator}),nU,oU,sU,lU,rU,cU].filter(e=>typeof this.options.enableCoreExtensions==`object`?this.options.enableCoreExtensions[e.name]!==!1:!0):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new dV(e,this)}createCommandManager(){this.commandManager=new kB({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let e;try{e=SH(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(t.message))throw t;this.emit(`contentError`,{editor:this,error:t,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),e=SH(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let t=LV(e,this.options.autofocus);this.view=new gz(this.options.element,{...this.options.editorProps,attributes:{role:`textbox`,...this.options.editorProps?.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:am.create({doc:e,selection:t||void 0})});let n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.prependClass();let r=this.view.dom;r.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;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e}),n&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let r=e.getMeta(`focus`),i=e.getMeta(`blur`);r&&this.emit(`focus`,{editor:this,event:r.event,transaction:e}),i&&this.emit(`blur`,{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta(`preventUpdate`))&&this.emit(`update`,{editor:this,transaction:e})}getAttributes(e){return MH(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return zH(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return KB(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
211
+
212
+ `,textSerializers:n={}}=e||{};return AH(this.state.doc,{blockSeparator:t,textSerializers:{...mV(this.schema),...n}})}get isEmpty(){return VH(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){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){return!this.view?.docView}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){return new uU(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}};function mU(e){return new YB({find:e.find,handler:({state:t,range:n,match:r})=>{let i=RB(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(IH(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}}})}function hU(e){return new YB({find:e.find,handler:({state:t,range:n,match:r})=>{let i=RB(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()}})}function gU(e){return new YB({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=RB(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)}})}function _U(e){return new YB({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=RB(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&ep(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&fp(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)}})}var vU=class e{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=RB(jB(this,`addOptions`,{name:this.name}))),this.storage=RB(jB(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>tV(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(t={}){let n=new e(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=RB(jB(n,`addOptions`,{name:n.name})),n.storage=RB(jB(n,`addStorage`,{name:n.name,options:n.options})),n}};function yU(e){return new iV({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=RB(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let r=c.search(/\S/),i=n.from+c.indexOf(s),u=i+s.length;if(IH(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>i).length)return null;u<n.to&&o.delete(u,n.to),i>n.from&&o.delete(n.from+r,i),l=n.from+r+s.length,o.addMark(n.from+r,l,e.type.create(a||{})),o.removeStoredMark(e.type)}}})}function bU(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof Gp){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}var xU=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},SU=/[\uD800-\uDBFF]/,CU=/[\uDC00-\uDFFF]/,wU=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&SU.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&CU.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},TU=new um(`y-sync`),EU=new um(`y-undo`),DU=new um(`yjs-cursor`),OU=(e,t)=>e>>>t|e<<32-t,kU=e=>OU(e,2)^OU(e,13)^OU(e,22),AU=e=>OU(e,6)^OU(e,11)^OU(e,25),jU=e=>OU(e,7)^OU(e,18)^e>>>3,MU=e=>OU(e,17)^OU(e,19)^e>>>10,NU=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]),PU=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),FU=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(PU),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=MU(t[e-2])+t[e-7]+jU(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+AU(o)+(o&s^~o&c)+NU[e]+t[e]>>>0,d=kU(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/Sy,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},IU=e=>new FU().digest(e),LU=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},RU=e=>_x(LU(IU(yx(e)))),zU=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!dC(t.ds,e.id),BU=[{light:`#ecd44433`,dark:`#ecd444`}],VU=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=Xv();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,Fb(t))}return e.get(n)},HU=(e,{colors:t=BU,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new GU(e,a),c=new sm({props:{editable:e=>{let t=TU.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:TU,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(TU);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&VS(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=EU.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},TU)})}},destroy:()=>{s.destroy()}})});return c},UU=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new qp(e.doc));else if(t.type===`node`){let r=vW(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Gp.create(e.doc,r))}else{let r=vW(n.doc,n.type,t.anchor,n.mapping),i=vW(n.doc,n.type,t.head,n.mapping);if(r!==null&&i!==null){let t=Up.between(e.doc.resolve(r),e.doc.resolve(i));e.setSelection(t)}}},WU=(e,t)=>({type:t.selection.jsonID,anchor:gW(t.selection.anchor,e.type,e.mapping),head:gW(t.selection.head,e.type,e.mapping)}),GU=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=xU(),this.mapping=t,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=WU(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()?(sx&&this._domSelectionInView===null&&(VS(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=PS.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=pw(hC(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(TU,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>qU(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(e),0,0));t.setMeta(TU,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>qU(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(t),0,0));if(e){let t=sy(cy(e.anchor,0),n.doc.content.size),r=sy(cy(e.head,0),n.doc.content.size);n.setSelection(Up.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(TU,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=mw(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&pb(),r=new xC({gc:!1}),IC(r,t),t=mw(r),IC(r,e),e=mw(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[xw(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{lC(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:VU(n.colorMapping,n.colors,r)}},s=mT(i,new fw(t.ds,e.sv)).map(n=>!n._item.deleted||zU(n._item,e)||zU(n._item,t)?qU(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(TU,{isChangeOrigin:!0}))},TU)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=TU.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);lC(t,t.deleteSet,e=>{if(e.constructor===qE){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>KU(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(n),0,0));UU(r,this.beforeTransactionSelection,this),r=r.setMeta(TU,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof zw}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{dW(this.doc,this.type,e,this),this.beforeTransactionSelection=WU(this,this.prosemirrorView.state)},TU)}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))}},KU=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof iE)return qU(e,t,n,r,i,a);throw fb()}return o},qU=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof iE){let s=KU(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof $T&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=JU(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):mT(e,new fw(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(zU(e._item,r)?zU(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch{return e.doc.transact(t=>{e._item.delete(t)},TU),n.mapping.delete(e),null}},JU=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,lW(n.attributes,t)))}}catch{return e.doc.transact(t=>{e._item.delete(t)},TU),null}return o},YU=(e,t)=>{let n=new lE,r=e.map(e=>({insert:e.text,attributes:uW(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},XU=(e,t)=>{let n=new iE(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,eW(e).map(e=>ZU(e,t))),t.mapping.set(n,e),n},ZU=(e,t)=>e instanceof Array?YU(e,t):XU(e,t),QU=e=>typeof e==`object`&&!!e,$U=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===(t==null?0:Object.keys(t).filter(e=>t[e]!==null).length);for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||QU(o)&&QU(s)&&$U(o,s)}return r},eW=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},tW=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&qb(e.attributes||{}).length===t[n].marks.length&&Zb(e.attributes,(e,r)=>{let i=cW(r),a=t[n].marks;return $U(e,a.find(e=>e.type.name===i)?.attrs)}))},nW=(e,t)=>{if(e instanceof iE&&!(t instanceof Array)&&fW(e,t)){let n=eW(t);return e._length===n.length&&$U(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>nW(e,n[t]))}return e instanceof lE&&t instanceof Array&&tW(e,t)},rW=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),iW=(e,t,n)=>{let r=e.toArray(),i=eW(t),a=i.length,o=r.length,s=sy(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(rW(n.mapping.get(e),t))u=!0;else if(!nW(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(rW(n.mapping.get(e),t))u=!0;else if(!nW(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},aW=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof AE?t+=n.content.str:n.content instanceof CE&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},oW=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=aW(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,uW(e.marks,n))})),{insert:o,remove:s,index:c}=wU(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},sW=/(.*)(--[a-zA-Z0-9+/=]{8})$/,cW=e=>sW.exec(e)?.[1]??e,lW=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(cW(r),e[r]));return n},uW=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=qv(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${RU(e.toJSON())}`:e.type.name]=e.attrs}}),n},dW=(e,t,n,r)=>{if(t instanceof iE&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof iE){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=eW(n),a=i.length,o=t.toArray(),s=o.length,c=sy(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!rW(r.mapping.get(e),t))if(nW(e,t))r.mapping.set(e,t);else break}for(;u+l<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!rW(r.mapping.get(e),t))if(nW(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof lE&&c instanceof Array)tW(n,c)||oW(n,c,r),l+=1;else{let i=n instanceof iE&&fW(n,c),a=d instanceof iE&&fW(d,f);if(i&&a){let e=iW(n,c,r),t=iW(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(dW(e,n,c,r),l+=1):a?(dW(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[ZU(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof lE?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(ZU(i[t],r));t.insert(l,e)}},TU)},fW=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,pW=null,mW=()=>{let e=pW;pW=null,e.forEach((e,t)=>{let n=t.state.tr,r=TU.getState(t.state);r&&r.binding&&!r.binding.isDestroyed&&(e.forEach((e,t)=>{n.setMeta(t,e)}),t.dispatch(n))})},hW=(e,t,n)=>{pW||(pW=new Map,VS(0,mW)),qv(pW,e,Gv).set(t,n)},gW=(e,t,n)=>{if(e===0)return cw(t,0,t.length===0?-1:0);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof lE){if(r._length>=e)return cw(r,e,t.length===0?-1:0);if(e-=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,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new rw(r._item===null?null:r._item.id,r._item===null?tw(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new rw(r._item===null?null:r._item.id,r._item===null?tw(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw pb();if(e===0&&r.constructor!==lE&&r!==t)return _W(r._item.parent,r._item)}return cw(t,t._length,t.length===0?-1:0)},_W=(e,t)=>{let n=null,r=null;return e._item===null?r=tw(e):n=ew(e._item.id.client,e._item.id.clock),new rw(n,r,t.id)},vW=(e,t,n,r)=>{let i=uw(n,e);if(i===null||i.type!==t&&!nw(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===lE)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof lE?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof lE?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1};function yW(e){let t=e.toArray(),n=e=>{let t;if(e instanceof lE)t=e.toDelta().map(e=>{let t={type:`text`,text:e.insert};return e.attributes&&(t.marks=Object.keys(e.attributes).map(t=>{let n=e.attributes[t],r={type:cW(t)};return Object.keys(n)&&(r.attrs=n),r})),t});else if(e instanceof iE){t={type:e.nodeName};let r=e.getAttributes();Object.keys(r).length&&(t.attrs=r);let i=e.toArray();i.length&&(t.content=i.map(n).flat())}else pb();return t};return{type:`doc`,content:t.map(n)}}var bW=(e,t,n)=>e!==t,xW=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(`⁠`),i=document.createTextNode(`⁠`);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},SW=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),CW=/^#[0-9a-fA-F]{6}$/,wW=(e,t,n,r,i)=>{let a=TU.getState(e),o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?IR.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:CW.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=vW(o,a.type,iw(t.cursor.anchor),a.binding.mapping),u=vW(o,a.type,iw(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=cy(e.doc.content.size-1,0);l=sy(l,t),u=sy(u,t),s.push(NR.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=sy(l,u),o=cy(l,u);s.push(NR.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),IR.create(e.doc,s))},TW=(e,{awarenessStateFilter:t=bW,cursorBuilder:n=xW,selectionBuilder:r=SW,getSelection:i=e=>e.selection}={},a=`cursor`)=>new sm({key:DU,state:{init(i,a){return wW(a,e,t,n,r)},apply(i,a,o,s){let c=TU.getState(s),l=i.getMeta(DU);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?wW(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>DU.getState(e)},view:t=>{let n=()=>{t.docView&&hW(t,DU,{awarenessUpdated:!0})},r=()=>{let n=TU.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=gW(o.anchor,n.type,n.binding.mapping),c=gW(o.head,n.type,n.binding.mapping);(r.cursor==null||!dw(iw(r.cursor.anchor),s)||!dw(iw(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&vW(n.doc,n.type,iw(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),EW=e=>EU.getState(e)?.undoManager?.undo()!=null,DW=e=>EU.getState(e)?.undoManager?.redo()!=null,OW=new Set([`paragraph`]),kW=(e,t)=>!(e instanceof qE)||!(e.content instanceof BE)||!(e.content.type instanceof $T||e.content.type instanceof iE&&t.has(e.content.type.nodeName))||e.content.type._length===0,AW=({protectedNodes:e=OW,trackedOrigins:t=[],undoManager:n=null}={})=>new sm({key:EU,state:{init:(r,i)=>{let a=TU.getState(i),o=n||new zw(a.type,{trackedOrigins:new Set([TU].concat(t)),deleteFilter:t=>kW(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=TU.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:WU(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=TU.getState(e.state),n=EU.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,EU.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}}),jW=fV.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.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:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),EU.getState(t).undoManager.undoStack.length===0?!1:n?EW(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),EU.getState(t).undoManager.redoStack.length===0?!1:n?DW(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var e;let t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=AW(this.options.yUndoOptions),r=n.spec.view;n.spec.view=e=>{let{undoManager:t}=EU.getState(e.state);t.restore&&=(t.restore(),()=>{});let n=r?r(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),r=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=r},n?.destroy&&n.destroy()}}};let i=HU(t,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender});return this.editor.options.enableContentCheck&&((e=t.doc)==null||e.on(`beforeTransaction`,()=>{try{let e=yW(t);if(e.content.length===0)return;this.editor.schema.nodeFromJSON(e).check()}catch(e){return this.editor.emit(`contentError`,{error:e,editor:this.editor,disableCollaboration:()=>{var e;(e=t.doc)==null||e.destroy(),this.storage.isDisabled=!0}}),!1}})),[i,n,this.editor.options.enableContentCheck&&new sm({key:new um(`filterInvalidContent`),filterTransaction:()=>{var e;return this.storage.isDisabled&&((e=t.doc)==null||e.destroy()),!0}})].filter(Boolean)}}),MW=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t.user})),NW=()=>null,PW=fV.create({name:`collaborationCursor`,priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:e=>{let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null),t.insertBefore(n,null),t},selectionRender:SW,onUpdate:NW}},onCreate(){if(this.options.onUpdate!==NW&&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 Error(`The "provider" option is required for the CollaborationCursor extension`)},addStorage(){return{users:[]}},addCommands(){return{updateUser:e=>()=>(this.options.user=e,this.options.provider.awareness.setLocalStateField(`user`,this.options.user),!0),user:e=>({editor:t})=>(console.warn(`[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor`),t.commands.updateUser(e))}},addProseMirrorPlugins(){return[TW((this.options.provider.awareness.setLocalStateField(`user`,this.options.user),this.storage.users=MW(this.options.provider.awareness.states),this.options.provider.awareness.on(`update`,()=>{this.storage.users=MW(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}});function FW(e){let{targetEl:t,platform:n,hasSelection:r,isEditable:i}=e,a=t.closest(`a[href]`)!=null,o=t.closest(`td, th`)!=null,s={hasSelection:r,isEditable:i,overLink:a,canMergeCells:!1,canSplitCell:!1};return a?{kind:`link`,...s}:o?{kind:`tableCell`,...s}:n===`macos`?null:{kind:`editorText`,...s}}function IW(e){let t=e.toLowerCase();return t.includes(`mac`)||t===`darwin`?`macos`:t.includes(`win`)?`windows`:`linux`}function LW(e,t,n){let r=e.split(/(?:\r\n?|\n)+/).map(e=>t.nodes.paragraph.create(null,e?t.text(e,n):void 0));return Q.maxOpen(Z.fromArray(r))}var RW=[`http://`,`https://`,`mailto:`,`ftp://`,`//`];function zW(e){let t=e.toLowerCase();return RW.some(e=>t.startsWith(e))}function BW(e){if(!e)return null;let t=e.trim();if(!t)return null;if(zW(t)||t.startsWith(`#`))return t;let n=t.indexOf(`:`);if(n===-1)return t;let r=Math.min(...[`/`,`#`,`?`].map(e=>t.indexOf(e)).filter(e=>e!==-1));return Number.isFinite(r)&&r<n?t:null}function VW(e){return e.chain().focus()}async function HW(e,t){let{editor:n}=t;switch(e){case`ctx:undo`:VW(n).undo().run();return;case`ctx:redo`:VW(n).redo().run();return;case`ctx:pastePlain`:{let e=await t.readClipboardText();if(!e)return;let{state:r,view:i}=n,a=LW(e,r.schema,r.selection.$from.marks());i.dispatch(r.tr.replaceSelection(a).scrollIntoView()),i.focus();return}case`ctx:table:insertRowAbove`:VW(n).addRowBefore().run();return;case`ctx:table:insertRowBelow`:VW(n).addRowAfter().run();return;case`ctx:table:insertColLeft`:VW(n).addColumnBefore().run();return;case`ctx:table:insertColRight`:VW(n).addColumnAfter().run();return;case`ctx:table:deleteRow`:VW(n).deleteRow().run();return;case`ctx:table:deleteCol`:VW(n).deleteColumn().run();return;case`ctx:table:mergeCells`:VW(n).mergeCells().run();return;case`ctx:table:splitCell`:VW(n).splitCell().run();return;case`ctx:table:deleteTable`:VW(n).deleteTable().run();return;case`ctx:link:open`:{let e=t.getLinkHref();e&&t.openHref(e);return}case`ctx:link:copy`:{let e=t.getLinkHref();if(!e)return;let n=BW(e);n&&await t.writeClipboardText(n);return}case`ctx:link:remove`:VW(n).extendMarkRange(`link`).unsetLink().run();return;default:return}}var UW=new Set([`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`]);function WW(e){return typeof e==`string`&&UW.has(e)}async function GW(){try{return await navigator.clipboard.readText()}catch{return null}}async function KW(e){try{await navigator.clipboard.writeText(e)}catch{}}function qW(e,t){if(!Bm())return()=>{};let n=e.view.dom,r=t.platform??IW(typeof navigator<`u`?navigator.platform||navigator.userAgent:``),i=null,a=async t=>{let n=t.target;if(!n)return;let a=FW({targetEl:n,platform:r,hasSelection:!1,isEditable:e.isEditable});if(!a)return;t.preventDefault();let o=e.view.posAtCoords({left:t.clientX,top:t.clientY});if(o){let{from:t,to:n}=e.state.selection;(o.pos<t||o.pos>n)&&e.commands.setTextSelection(o.pos)}if(a.hasSelection=!e.state.selection.empty,i=n.closest(`a[href]`)?.getAttribute(`href`)??null,a.kind===`tableCell`){let t=e.can();a.canMergeCells=t.mergeCells(),a.canSplitCell=t.splitCell()}e.view.focus();try{await(await Um())(`show_context_menu`,{req:a})}catch{}};n.addEventListener(`contextmenu`,a);let o=Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:n})=>n(`context-menu-action`,n=>{let r=n.payload?.id;WW(r)&&HW(r,{editor:e,openHref:t.openHref,getLinkHref:()=>i,readClipboardText:GW,writeClipboardText:KW})}));return o.catch(()=>{}),()=>{n.removeEventListener(`contextmenu`,a),o.then(e=>e()).catch(()=>{})}}var JW=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,YW=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,XW=nV.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){return[`mark`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[mU({find:JW,type:this.type})]},addPasteRules(){return[yU({find:YW,type:this.type})]}}),ZW=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,QW=vU.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:e}){return[`img`,FB(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[hU({find:ZW,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),$W=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,eG=`ελ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`,tG=`numeric`,nG=`ascii`,rG=`alpha`,iG=`asciinumeric`,aG=`alphanumeric`,oG=`domain`,sG=`emoji`,cG=`scheme`,lG=`slashscheme`,uG=`whitespace`;function dG(e,t){return e in t||(t[e]=[]),t[e]}function fG(e,t,n){t[tG]&&(t[iG]=!0,t[aG]=!0),t[nG]&&(t[iG]=!0,t[rG]=!0),t[iG]&&(t[aG]=!0),t[rG]&&(t[aG]=!0),t[aG]&&(t[oG]=!0),t[sG]&&(t[oG]=!0);for(let r in t){let t=dG(r,n);t.indexOf(e)<0&&t.push(e)}}function pG(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function mG(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}mG.groups={},mG.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=mG.groups;let i;return t&&t.j?i=t:(i=new mG(t),n&&r&&fG(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=mG.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new mG,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new mG,a&&(r&&(o.t&&typeof o.t==`string`?fG(a,Object.assign(pG(o.t,r),n),r):n&&fG(a,n,r)),o.t=a),i.j[e]=o,o}};var hG=(e,t,n,r,i)=>e.ta(t,n,r,i),gG=(e,t,n,r,i)=>e.tr(t,n,r,i),_G=(e,t,n,r,i)=>e.ts(t,n,r,i),$=(e,t,n,r,i)=>e.tt(t,n,r,i),vG=`WORD`,yG=`UWORD`,bG=`ASCIINUMERICAL`,xG=`ALPHANUMERICAL`,SG=`LOCALHOST`,CG=`TLD`,wG=`UTLD`,TG=`SCHEME`,EG=`SLASH_SCHEME`,DG=`NUM`,OG=`WS`,kG=`NL`,AG=`OPENBRACE`,jG=`CLOSEBRACE`,MG=`OPENBRACKET`,NG=`CLOSEBRACKET`,PG=`OPENPAREN`,FG=`CLOSEPAREN`,IG=`OPENANGLEBRACKET`,LG=`CLOSEANGLEBRACKET`,RG=`FULLWIDTHLEFTPAREN`,zG=`FULLWIDTHRIGHTPAREN`,BG=`LEFTCORNERBRACKET`,VG=`RIGHTCORNERBRACKET`,HG=`LEFTWHITECORNERBRACKET`,UG=`RIGHTWHITECORNERBRACKET`,WG=`FULLWIDTHLESSTHAN`,GG=`FULLWIDTHGREATERTHAN`,KG=`AMPERSAND`,qG=`APOSTROPHE`,JG=`ASTERISK`,YG=`AT`,XG=`BACKSLASH`,ZG=`BACKTICK`,QG=`CARET`,$G=`COLON`,eK=`COMMA`,tK=`DOLLAR`,nK=`DOT`,rK=`EQUALS`,iK=`EXCLAMATION`,aK=`HYPHEN`,oK=`PERCENT`,sK=`PIPE`,cK=`PLUS`,lK=`POUND`,uK=`QUERY`,dK=`QUOTE`,fK=`FULLWIDTHMIDDLEDOT`,pK=`SEMI`,mK=`SLASH`,hK=`TILDE`,gK=`UNDERSCORE`,_K=`EMOJI`,vK=`SYM`,yK=Object.freeze({__proto__:null,ALPHANUMERICAL:xG,AMPERSAND:KG,APOSTROPHE:qG,ASCIINUMERICAL:bG,ASTERISK:JG,AT:YG,BACKSLASH:XG,BACKTICK:ZG,CARET:QG,CLOSEANGLEBRACKET:LG,CLOSEBRACE:jG,CLOSEBRACKET:NG,CLOSEPAREN:FG,COLON:$G,COMMA:eK,DOLLAR:tK,DOT:nK,EMOJI:_K,EQUALS:rK,EXCLAMATION:iK,FULLWIDTHGREATERTHAN:GG,FULLWIDTHLEFTPAREN:RG,FULLWIDTHLESSTHAN:WG,FULLWIDTHMIDDLEDOT:fK,FULLWIDTHRIGHTPAREN:zG,HYPHEN:aK,LEFTCORNERBRACKET:BG,LEFTWHITECORNERBRACKET:HG,LOCALHOST:SG,NL:kG,NUM:DG,OPENANGLEBRACKET:IG,OPENBRACE:AG,OPENBRACKET:MG,OPENPAREN:PG,PERCENT:oK,PIPE:sK,PLUS:cK,POUND:lK,QUERY:uK,QUOTE:dK,RIGHTCORNERBRACKET:VG,RIGHTWHITECORNERBRACKET:UG,SCHEME:TG,SEMI:pK,SLASH:mK,SLASH_SCHEME:EG,SYM:vK,TILDE:hK,TLD:CG,UNDERSCORE:gK,UTLD:wG,UWORD:yG,WORD:vG,WS:OG}),bK=/[a-z]/,xK=/\p{L}/u,SK=/\p{Emoji}/u,CK=/\d/,wK=/\s/,TK=`\r`,EK=`
213
+ `,DK=`️`,OK=`‍`,kK=``,AK=null,jK=null;function MK(e=[]){let t={};mG.groups=t;let n=new mG;AK??=IK($W),jK??=IK(eG),$(n,`'`,qG),$(n,`{`,AG),$(n,`}`,jG),$(n,`[`,MG),$(n,`]`,NG),$(n,`(`,PG),$(n,`)`,FG),$(n,`<`,IG),$(n,`>`,LG),$(n,`(`,RG),$(n,`)`,zG),$(n,`「`,BG),$(n,`」`,VG),$(n,`『`,HG),$(n,`』`,UG),$(n,`<`,WG),$(n,`>`,GG),$(n,`&`,KG),$(n,`*`,JG),$(n,`@`,YG),$(n,"`",ZG),$(n,`^`,QG),$(n,`:`,$G),$(n,`,`,eK),$(n,`$`,tK),$(n,`.`,nK),$(n,`=`,rK),$(n,`!`,iK),$(n,`-`,aK),$(n,`%`,oK),$(n,`|`,sK),$(n,`+`,cK),$(n,`#`,lK),$(n,`?`,uK),$(n,`"`,dK),$(n,`/`,mK),$(n,`;`,pK),$(n,`~`,hK),$(n,`_`,gK),$(n,`\\`,XG),$(n,`・`,fK);let r=gG(n,CK,DG,{[tG]:!0});gG(r,CK,r);let i=gG(r,bK,bG,{[iG]:!0}),a=gG(r,xK,xG,{[aG]:!0}),o=gG(n,bK,vG,{[nG]:!0});gG(o,CK,i),gG(o,bK,o),gG(i,CK,i),gG(i,bK,i);let s=gG(n,xK,yG,{[rG]:!0});gG(s,bK),gG(s,CK,a),gG(s,xK,s),gG(a,CK,a),gG(a,bK),gG(a,xK,a);let c=$(n,EK,kG,{[uG]:!0}),l=$(n,TK,OG,{[uG]:!0}),u=gG(n,wK,OG,{[uG]:!0});$(n,kK,u),$(l,EK,c),$(l,kK,u),gG(l,wK,u),$(u,TK),$(u,EK),gG(u,wK,u),$(u,kK,u);let d=gG(n,SK,_K,{[sG]:!0});$(d,`#`),gG(d,SK,d),$(d,DK,d);let f=$(d,OK);$(f,`#`),gG(f,SK,d);let p=[[bK,o],[CK,i]],m=[[bK,null],[xK,s],[CK,a]];for(let e=0;e<AK.length;e++)FK(n,AK[e],CG,vG,p);for(let e=0;e<jK.length;e++)FK(n,jK[e],wG,yG,m);fG(CG,{tld:!0,ascii:!0},t),fG(wG,{utld:!0,alpha:!0},t),FK(n,`file`,TG,vG,p),FK(n,`mailto`,TG,vG,p),FK(n,`http`,EG,vG,p),FK(n,`https`,EG,vG,p),FK(n,`ftp`,EG,vG,p),FK(n,`ftps`,EG,vG,p),fG(TG,{scheme:!0,ascii:!0},t),fG(EG,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[cG]:!0}:{[lG]:!0};r.indexOf(`-`)>=0?i[oG]=!0:bK.test(r)?CK.test(r)?i[iG]=!0:i[nG]=!0:i[tG]=!0,_G(n,r,r,i)}return _G(n,`localhost`,SG,{ascii:!0}),n.jd=new mG(vK),{start:n,tokens:Object.assign({groups:t},yK)}}function NK(e,t){let n=PK(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function PK(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function FK(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new mG(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new mG(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function IK(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var LK={defaultProtocol:`http`,events:null,format:zK,formatHref:zK,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function RK(e,t=null){let n=Object.assign({},LK);e&&(n=Object.assign(n,e instanceof RK?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}RK.prototype={o:LK,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:LK[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function zK(e){return e}function BK(e,t){this.t=`token`,this.v=e,this.tk=t}BK.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=LK.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function VK(e,t){class n extends BK{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var HK=VK(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),UK=VK(`text`),WK=VK(`nl`),GK=VK(`url`,{isLink:!0,toHref(e=LK.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==SG&&e[1].t===$G}}),KK=e=>new mG(e);function qK({groups:e}){let t=e.domain.concat([KG,JG,YG,XG,ZG,QG,tK,rK,aK,DG,oK,sK,cK,lK,mK,vK,hK,gK]),n=[qG,$G,eK,nK,iK,oK,uK,dK,pK,IG,LG,AG,jG,NG,MG,PG,FG,RG,zG,BG,VG,HG,UG,WG,GG],r=[KG,qG,JG,XG,ZG,QG,tK,rK,aK,AG,jG,oK,sK,cK,lK,uK,mK,vK,hK,gK],i=KK(),a=$(i,hK);hG(a,r,a),hG(a,e.domain,a);let o=KK(),s=KK(),c=KK();hG(i,e.domain,o),hG(i,e.scheme,s),hG(i,e.slashscheme,c),hG(o,r,a),hG(o,e.domain,o);let l=$(o,YG);$(a,YG,l),$(s,YG,l),$(c,YG,l);let u=$(a,nK);hG(u,r,a),hG(u,e.domain,a);let d=KK();hG(l,e.domain,d),hG(d,e.domain,d);let f=$(d,nK);hG(f,e.domain,d);let p=KK(HK);hG(f,e.tld,p),hG(f,e.utld,p),$(l,SG,p);let m=$(d,aK);$(m,aK,m),hG(m,e.domain,d),hG(p,e.domain,d),$(p,nK,f),$(p,aK,m),hG($(p,$G),e.numeric,HK);let h=$(o,aK),g=$(o,nK);$(h,aK,h),hG(h,e.domain,o),hG(g,r,a),hG(g,e.domain,o);let _=KK(GK);hG(g,e.tld,_),hG(g,e.utld,_),hG(_,e.domain,o),hG(_,r,a),$(_,nK,g),$(_,aK,h),$(_,YG,l);let v=$(_,$G),y=KK(GK);hG(v,e.numeric,y);let b=KK(GK),x=KK();hG(b,t,b),hG(b,n,x),hG(x,t,b),hG(x,n,x),$(_,mK,b),$(y,mK,b);let S=$(s,$G),ee=$($($(c,$G),mK),mK);hG(s,e.domain,o),$(s,nK,g),$(s,aK,h),hG(c,e.domain,o),$(c,nK,g),$(c,aK,h),hG(S,e.domain,b),$(S,mK,b),$(S,uK,b),hG(ee,e.domain,b),hG(ee,t,b),$(ee,mK,b);let C=[[AG,jG],[MG,NG],[PG,FG],[IG,LG],[RG,zG],[BG,VG],[HG,UG],[WG,GG]];for(let e=0;e<C.length;e++){let[r,i]=C[e],a=$(b,r);$(x,r,a),$(a,i,b);let o=KK(GK);hG(a,t,o);let s=KK();hG(a,n),hG(o,t,o),hG(o,n,s),hG(s,t,o),hG(s,n,s),$(o,i,b),$(s,i,b)}return $(i,SG,_),$(i,kG,WK),{start:i,tokens:yK}}function JK(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(YK(UK,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(YK(e,t,r))}}return o.length>0&&a.push(YK(UK,t,o)),a}function YK(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var XK=typeof console<`u`&&console&&console.warn||(()=>{}),ZK=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,QK={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function $K(){return mG.groups={},QK.scanner=null,QK.parser=null,QK.tokenQueue=[],QK.pluginQueue=[],QK.customSchemes=[],QK.initialized=!1,QK}function eq(e,t=!1){if(QK.initialized&&XK(`linkifyjs: already initialized - will not register custom scheme "${e}" ${ZK}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
214
+ 1. Must only contain digits, lowercase ASCII letters or "-"
215
+ 2. Cannot start or end with "-"
216
+ 3. "-" cannot repeat`);QK.customSchemes.push([e,t])}function tq(){QK.scanner=MK(QK.customSchemes);for(let e=0;e<QK.tokenQueue.length;e++)QK.tokenQueue[e][1]({scanner:QK.scanner});QK.parser=qK(QK.scanner.tokens);for(let e=0;e<QK.pluginQueue.length;e++)QK.pluginQueue[e][1]({scanner:QK.scanner,parser:QK.parser});return QK.initialized=!0,QK}function nq(e){return QK.initialized||tq(),JK(QK.parser.start,e,NK(QK.scanner.start,e))}nq.scan=NK;function rq(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new RK(n),i=nq(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var iq=`[\0- \xA0 ᠎ -\u2029  ]`,aq=new RegExp(iq),oq=RegExp(`${iq}$`),sq=new RegExp(iq,`g`);function cq(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function lq(e){return new sm({key:new um(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(FH(TH(n.doc,[...t])).forEach(({newRange:t})=>{let n=DH(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!oq.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(aq).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=nq(n).map(t=>t.toObject(e.defaultProtocol));if(!cq(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>r.schema.marks.code?!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code):!0).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{IH(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function uq(e){return new sm({key:new um(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=r.target,a=[];for(;i.nodeName!==`DIV`;)a.push(i),i=i.parentNode;if(!a.find(e=>e.nodeName===`A`))return!1;let o=MH(t.state,e.type.name),s=r.target,c=s?.href??o.href,l=s?.target??o.target;return s&&c?(window.open(c,l),!0):!1}}})}function dq(e){return new sm({key:new um(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{state:i}=t,{selection:a}=i,{empty:o}=a;if(o)return!1;let s=``;r.content.forEach(e=>{s+=e.textContent});let c=rq(s,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===s);return!s||!c?!1:e.editor.commands.setMark(e.type,{href:c.href})}}})}function fq(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(sq,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))`,`i`))}var pq=nV.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(e=>{if(typeof e==`string`){eq(e);return}eq(e.scheme,e.optionalSlashes)})},onDestroy(){$K()},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:(e,t)=>!!fq(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.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:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!fq(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!fq(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,FB(this.options.HTMLAttributes,e),0]:[`a`,FB(this.options.HTMLAttributes,{...e,href:``}),0]},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!fq(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!fq(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run():!1},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addPasteRules(){return[yU({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=rq(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!fq(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>t.push({text:e.value,data:{href:e.href},index:e.start}))}return t},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(lq({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!fq(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&e.push(uq({type:this.type})),this.options.linkOnPaste&&e.push(dq({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),mq=fV.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new sm({key:new um(`placeholder`),props:{decorations:({doc:e,selection:t})=>{let n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,i=[];if(!n)return null;let a=this.editor.isEmpty;return e.descendants((e,t)=>{let n=r>=t&&r<=t+e.nodeSize,o=!e.isLeaf&&VH(e);if((n||!this.options.showOnlyCurrent)&&o){let r=[this.options.emptyNodeClass];a&&r.push(this.options.emptyEditorClass);let o=NR.node(t,t+e.nodeSize,{class:r.join(` `),"data-placeholder":typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:e,pos:t,hasAnchor:n}):this.options.placeholder});i.push(o)}return this.options.includeChildren}),IR.create(e,i)}}})]}}),hq=nV.create({name:`subscript`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`sub`},{style:`vertical-align`,getAttrs(e){return e===`sub`?null:!1}}]},renderHTML({HTMLAttributes:e}){return[`sub`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),gq=nV.create({name:`superscript`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`sup`},{style:`vertical-align`,getAttrs(e){return e===`super`?null:!1}}]},renderHTML({HTMLAttributes:e}){return[`sup`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),_q,vq;if(typeof WeakMap<`u`){let e=new WeakMap;_q=t=>e.get(t),vq=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;_q=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},vq=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var yq=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return _q(e)||vq(e,bq(e))}};function bq(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=xq(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new yq(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&Sq(s,o,e),s}function xq(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Sq(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=Cq(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function Cq(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function wq(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var Tq=new um(`selectingCells`);function Eq(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Dq(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function Oq(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function kq(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Eq(t.$head)||Aq(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Aq(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function jq(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Mq(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Nq(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Pq(e,t,n){let r=e.node(-1),i=yq.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Fq(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Iq(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function Lq(e,t,n){let r=wq(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var Rq=class e extends zp{constructor(e,t=e){let n=e.node(-1),r=yq.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Bp(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(jq(r)&&jq(i)&&Nq(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return Up.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=yq.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=Fq(e,0,l)),u>0&&(e=Fq(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(Z.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new Q(Z.from(o),1,1)}replace(e,t=Q.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?Q.empty:t)}let i=zp.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new Q(Z.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=yq.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=yq.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=yq.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=yq.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new zq(this.$anchorCell.pos,this.$headCell.pos)}};Rq.prototype.visible=!1,zp.jsonID(`cell`,Rq);var zq=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Nq(t,n)?new Rq(t,n):zp.near(n,1)}};function Bq(e){if(!(e.selection instanceof Rq))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(NR.node(n,n+e.nodeSize,{class:`selectedCell`}))}),IR.create(e.doc,t)}function Vq({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function Hq({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function Uq(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof Gp&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=Rq.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=Rq.rowSelection(e,e)}else if(!n){let e=yq.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=Rq.create(i,t+1,n)}}else r instanceof Up&&Vq(r)?a=Up.create(i,r.from):r instanceof Up&&Hq(r)&&(a=Up.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Wq=new um(`fix-tables`);function Gq(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?Gq(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Kq(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=qq(e,t,r,n))};return t?t.doc!=e.doc&&Gq(t.doc,e.doc,0,r):e.doc.descendants(r),n}function qq(e,t,n,r){let i=yq.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,Fq(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=wq(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(Wq,{fixTables:!0})}function Jq(e){let t=e.selection,n=kq(e),r=n.node(-1),i=n.start(-1),a=yq.get(r);return{...t instanceof Rq?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function Yq(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;Lq(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Iq(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?wq(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function Xq(e,t){if(!Oq(e))return!1;if(t){let n=Jq(e);t(Yq(e.tr,n,n.left))}return!0}function Zq(e,t){if(!Oq(e))return!1;if(t){let n=Jq(e);t(Yq(e.tr,n,n.right))}return!0}function Qq(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,Fq(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function $q(e,t){if(!Oq(e))return!1;if(t){let n=Jq(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;Qq(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=yq.get(e)}t(r)}return!0}function eJ(e,t,n){let r=wq(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function tJ(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;eJ(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?wq(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,wq(r.type.schema).row.create(null,o)),e}function nJ(e,t){if(!Oq(e))return!1;if(t){let n=Jq(e);t(tJ(e.tr,n,n.top))}return!0}function rJ(e,t){if(!Oq(e))return!1;if(t){let n=Jq(e);t(tJ(e.tr,n,n.bottom))}return!0}function iJ(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function aJ(e,t){if(!Oq(e))return!1;if(t){let n=Jq(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;iJ(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=yq.get(n.table)}t(r)}return!0}function oJ(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function sJ({width:e,height:t,map:n},r){let i=r.top*e+r.left,a=i,o=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[a]==n[a-1]||r.right<e&&n[s]==n[s+1])return!0;a+=e,s+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[o]==n[o+e])return!0;i++,o++}return!1}function cJ(e,t){let n=e.selection;if(!(n instanceof Rq)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Jq(e),{map:i}=r;if(sJ(i,r))return!1;if(t){let n=e.tr,a={},o=Z.empty,s,c;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){let l=i.map[e*i.width+t],u=r.table.nodeAt(l);if(!(a[l]||!u))if(a[l]=!0,s==null)s=l,c=u;else{oJ(u)||(o=o.append(u.content));let e=n.mapping.map(l+r.tableStart);n.delete(e,e+u.nodeSize)}}if(s==null||c==null)return!0;if(n.setNodeMarkup(s+r.tableStart,null,{...Iq(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),o.size>0){let e=s+1+c.content.size,t=oJ(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new Rq(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function lJ(e,t){let n=wq(e.schema);return uJ(({node:e})=>n[e.type.spec.tableRole])(e,t)}function uJ(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof Rq){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=Dq(r.$from),!i)return!1;a=Eq(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=Jq(t),u=t.tr;for(let e=0;e<l.right-l.left;e++)s.push(c?{...o,colwidth:c&&c[e]?[c[e]]:null}:o);let d;for(let t=l.top;t<l.bottom;t++){let n=l.map.positionAt(t,l.left,l.table);t==l.top&&(n+=i.nodeSize);for(let r=l.left,a=0;r<l.right;r++,a++)r==l.left&&t==l.top||u.insert(d=u.mapping.map(n+l.tableStart,1),e({node:i,row:t,col:r}).createAndFill(s[a]))}u.setNodeMarkup(a,e({node:i,row:l.top,col:l.left}),s[0]),r instanceof Rq&&u.setSelection(new Rq(u.doc.resolve(r.$anchorCell.pos),d?u.doc.resolve(d):void 0)),n(u)}return!0}}function dJ(e,t){return function(n,r){if(!Oq(n))return!1;let i=kq(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof Rq?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function fJ(e){return function(t,n){if(!Oq(t))return!1;if(n){let r=wq(t.schema),i=Jq(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function pJ(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function mJ(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?fJ(e):function(t,n){if(!Oq(t))return!1;if(n){let r=wq(t.schema),i=Jq(t),a=t.tr,o=pJ(`row`,i,r),s=pJ(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}mJ(`row`,{useDeprecatedLogic:!0}),mJ(`column`,{useDeprecatedLogic:!0});var hJ=mJ(`cell`,{useDeprecatedLogic:!0});function gJ(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function _J(e){return function(t,n){if(!Oq(t))return!1;let r=gJ(kq(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(Up.between(e,Mq(e))).scrollIntoView())}return!0}}function vJ(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function yJ(e,t){let n=e.selection;if(!(n instanceof Rq))return!1;if(t){let r=e.tr,i=wq(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new Q(i,0,0))}),r.docChanged&&t(r)}return!0}function bJ(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=SJ(wq(o).row,new Q(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?SJ(wq(o).row,new Q(t,n,r)).content:t);else return null;return xJ(o,s)}function xJ(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(Z.empty),n[i]<r){let a=wq(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(Z.from(o))}return{height:t.length,width:r,rows:t}}function SJ(e,t){let n=e.createAndFill();return new Lp(n).replace(0,n.content.size,t).doc}function CJ({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(Fq(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(Z.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(Z.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function wJ(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=wq(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,Z.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function TJ(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function EJ(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,Fq(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(Fq(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function DJ(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=yq.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=yq.get(a),f=d.mapping.maps.length}wJ(d,o,a,n,l,u,f)&&p(),TJ(d,o,a,n,c,l,s,f)&&p(),TJ(d,o,a,n,c,l,u,f)&&p(),EJ(d,o,a,n,s,u,c,f)&&p(),EJ(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new Q(i.rows[e-s],0,0))}p(),d.setSelection(new Rq(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var OJ=Lz({ArrowLeft:AJ(`horiz`,-1),ArrowRight:AJ(`horiz`,1),ArrowUp:AJ(`vert`,-1),ArrowDown:AJ(`vert`,1),"Shift-ArrowLeft":jJ(`horiz`,-1),"Shift-ArrowRight":jJ(`horiz`,1),"Shift-ArrowUp":jJ(`vert`,-1),"Shift-ArrowDown":jJ(`vert`,1),Backspace:yJ,"Mod-Backspace":yJ,Delete:yJ,"Mod-Delete":yJ});function kJ(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function AJ(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof Rq)return kJ(n,r,zp.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=FJ(i,e,t);if(o==null)return!1;if(e==`horiz`)return kJ(n,r,zp.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Pq(i,e,t),s;return s=a?zp.near(a,1):t<0?zp.near(n.doc.resolve(i.before(-1)),-1):zp.near(n.doc.resolve(i.after(-1)),1),kJ(n,r,s)}}}function jJ(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof Rq)o=a;else{let r=FJ(i,e,t);if(r==null)return!1;o=new Rq(n.doc.resolve(r))}let s=Pq(o.$headCell,e,t);return s?kJ(n,r,new Rq(o.$anchorCell,s)):!1}}function MJ(e,t){let n=e.state.doc,r=Eq(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new Rq(r))),!0):!1}function NJ(e,t,n){if(!Oq(e.state))return!1;let r=bJ(n),i=e.state.selection;if(i instanceof Rq){r||={width:1,height:1,rows:[Z.from(SJ(wq(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=yq.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=CJ(r,o.right-o.left,o.bottom-o.top),DJ(e.state,e.dispatch,a,o,r),!0}else if(r){let t=kq(e.state),n=t.start(-1);return DJ(e.state,e.dispatch,n,yq.get(t.node(-1)).findCell(t.pos-n),r),!0}else return!1}function PJ(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=IJ(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof Rq)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Eq(e.state.selection.$anchor))!=null&&LJ(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=LJ(e,n),i=Tq.getState(e.state)==null;if(!r||!Nq(t,r))if(i)r=t;else return;let a=new Rq(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(Tq,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),Tq.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Tq,-1))}function o(r){let o=r,s=Tq.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(IJ(e,o.target)!=n&&(c=LJ(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function FJ(e,t,n){if(!(e.state.selection instanceof Up))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function IJ(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function LJ(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Eq(e.state.doc.resolve(r))||Eq(e.state.doc.resolve(i))}var RJ=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,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`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),zJ(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,zJ(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function zJ(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var BJ=new um(`tableColumnResizing`);function VJ({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=RJ,lastColumnResizable:i=!0}={}){let a=new sm({key:BJ,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=wq(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new HJ(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=BJ.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{UJ(t,n,e,i)},mouseleave:e=>{WJ(e)},mousedown:(e,r)=>{GJ(e,r,t,n)}},decorations:e=>{let t=BJ.getState(e);if(t&&t.activeHandle>-1)return eY(e,t.activeHandle)},nodeViews:{}}});return a}var HJ=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(BJ);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return jq(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function UJ(e,t,n,r){if(!e.editable)return;let i=BJ.getState(e.state);if(i&&!i.dragging){let a=qJ(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=JJ(e,t,`left`,n):i-t.clientX<=n&&(o=JJ(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=yq.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}XJ(e,o)}}}function WJ(e){if(!e.editable)return;let t=BJ.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&XJ(e,-1)}function GJ(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=BJ.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=KJ(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(BJ,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=BJ.getState(e.state);r?.dragging&&(ZJ(e,r.activeHandle,YJ(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(BJ,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=BJ.getState(e.state);if(i&&i.dragging){let a=YJ(i.dragging,t,n);QJ(e,i.activeHandle,a,r)}}return QJ(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function KJ(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function qJ(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function JJ(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=Eq(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=yq.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function YJ(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function XJ(e,t){e.dispatch(e.state.tr.setMeta(BJ,{setHandle:t}))}function ZJ(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=yq.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():$J(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function QJ(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=yq.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&zJ(a,c.firstChild,c,r,s,n)}function $J(e){return Array(e).fill(0)}function eY(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return IR.empty;let a=yq.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,BJ.getState(e)?.dragging&&n.push(NR.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(NR.widget(s,c))}}return IR.create(e.doc,n)}function tY({allowTableNodeSelection:e=!1}={}){return new sm({key:Tq,state:{init(){return null},apply(e,t){let n=e.getMeta(Tq);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:Bq,handleDOMEvents:{mousedown:PJ},createSelectionBetween(e){return Tq.getState(e.state)==null?null:e.state.selection},handleTripleClick:MJ,handleKeyDown:OJ,handlePaste:NJ},appendTransaction(t,n,r){return Uq(r,Kq(r,n),e)}})}function nY(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function rY(e,t,n,r,i,a){var o;let s=0,c=!0,l=t.firstChild,u=e.firstChild;if(u!==null)for(let e=0,n=0;e<u.childCount;e+=1){let{colspan:o,colwidth:d}=u.child(e).attrs;for(let e=0;e<o;e+=1,n+=1){let o=i===n?a:d&&d[e],u=o?`${o}px`:``;if(s+=o||r,o||(c=!1),l){if(l.style.width!==u){let[e,t]=nY(r,o);l.style.setProperty(e,t)}l=l.nextSibling}else{let e=document.createElement(`col`),[n,i]=nY(r,o);e.style.setProperty(n,i),t.appendChild(e)}}}for(;l;){let e=l.nextSibling;(o=l.parentNode)==null||o.removeChild(l),l=e}c?(n.style.width=`${s}px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=`${s}px`)}var iY=class{constructor(e,t){this.node=e,this.cellMinWidth=t,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`)),rY(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type===this.node.type?(this.node=e,rY(e,this.colgroup,this.table,this.cellMinWidth),!0):!1}ignoreMutation(e){return e.type===`attributes`&&(e.target===this.table||this.colgroup.contains(e.target))}};function aY(e,t,n,r){let i=0,a=!0,o=[],s=e.firstChild;if(!s)return{};for(let e=0,c=0;e<s.childCount;e+=1){let{colspan:l,colwidth:u}=s.child(e).attrs;for(let e=0;e<l;e+=1,c+=1){let s=n===c?r:u&&u[e];i+=s||t,s||(a=!1);let[l,d]=nY(t,s);o.push([`col`,{style:`${l}: ${d}`}])}}let c=a?`${i}px`:``,l=a?``:`${i}px`;return{colgroup:[`colgroup`,{},...o],tableWidth:c,tableMinWidth:l}}function oY(e,t){return t?e.createChecked(null,t):e.createAndFill()}function sY(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function cY(e,t,n,r,i){let a=sY(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=oY(a.cell,i);if(e&&s.push(e),r){let e=oY(a.header_cell,i);e&&o.push(e)}}let c=[];for(let e=0;e<t;e+=1)c.push(a.row.createChecked(null,r&&e===0?o:s));return a.table.createChecked(null,c)}function lY(e){return e instanceof Rq}var uY=({editor:e})=>{let{selection:t}=e.state;if(!lY(t))return!1;let n=0;return OH(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},dY=vU.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:iY,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=aY(e,this.options.cellMinWidth),a=[`table`,FB(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${i}`}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},a]:a},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=cY(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(Up.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>Xq(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Zq(e,t),deleteColumn:()=>({state:e,dispatch:t})=>$q(e,t),addRowBefore:()=>({state:e,dispatch:t})=>nJ(e,t),addRowAfter:()=>({state:e,dispatch:t})=>rJ(e,t),deleteRow:()=>({state:e,dispatch:t})=>aJ(e,t),deleteTable:()=>({state:e,dispatch:t})=>vJ(e,t),mergeCells:()=>({state:e,dispatch:t})=>cJ(e,t),splitCell:()=>({state:e,dispatch:t})=>lJ(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>mJ(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>mJ(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>hJ(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>cJ(e,t)?!0:lJ(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>dJ(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>_J(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>_J(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Kq(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=Rq.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}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:uY,"Mod-Backspace":uY,Delete:uY,"Mod-Delete":uY}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[VJ({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],tY({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){return{tableRole:RB(jB(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),fY=vU.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):null}}}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`}]},renderHTML({HTMLAttributes:e}){return[`td`,FB(this.options.HTMLAttributes,e),0]}}),pY=vU.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):null}}}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`}]},renderHTML({HTMLAttributes:e}){return[`th`,FB(this.options.HTMLAttributes,e),0]}}),mY=vU.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,FB(this.options.HTMLAttributes,e),0]}}),hY=nV.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),gY=/^\s*>\s$/,_Y=vU.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return[`blockquote`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[_U({find:gY,type:this.type})]}}),vY=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,yY=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,bY=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,xY=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,SY=nV.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return[`strong`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[mU({find:vY,type:this.type}),mU({find:bY,type:this.type})]},addPasteRules(){return[yU({find:yY,type:this.type}),yU({find:xY,type:this.type})]}}),CY=`listItem`,wY=`textStyle`,TY=/^\s*([-+*])\s$/,EY=vU.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:e}){return[`ul`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(CY,this.editor.getAttributes(wY)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=_U({find:TY,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=_U({find:TY,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(wY),editor:this.editor})),[e]}}),DY=/(^|[^`])`([^`]+)`(?!`)/,OY=/(^|[^`])`([^`]+)`(?!`)/g,kY=nV.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[mU({find:DY,type:this.type})]},addPasteRules(){return[yU({find:OY,type:this.type})]}}),AY=/^```([a-z]+)?[\s\n]$/,jY=/^~~~([a-z]+)?[\s\n]$/,MY=vU.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:e=>{let{languageClassPrefix:t}=this.options;return[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,FB(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
217
+
218
+ `);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(zp.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[gU({find:AY,type:this.type,getAttributes:e=>({language:e[1]})}),gU({find:jY,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new sm({key:new um(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
219
+ `));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(Up.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),NY=vU.create({name:`doc`,topNode:!0,content:`block+`});function PY(e={}){return new sm({view(t){return new FY(t,e)}})}var FY=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.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`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=vp(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},IY=fV.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[PY(this.options)]}}),LY=class e extends zp{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):zp.near(r)}content(){return Q.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new RY(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!BY(e)||!VY(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Gp.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};LY.prototype.visible=!1,LY.findFrom=LY.findGapCursorFrom,zp.jsonID(`gapcursor`,LY);var RY=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return LY.valid(t)?new LY(t):zp.near(t)}};function zY(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function BY(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||zY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function VY(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||zY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function HY(){return new sm({props:{decorations:qY,createSelectionBetween(e,t,n){return t.pos==n.pos&&LY.valid(n)?new LY(n):null},handleClick:GY,handleKeyDown:UY,handleDOMEvents:{beforeinput:KY}}})}var UY=Lz({ArrowLeft:WY(`horiz`,-1),ArrowRight:WY(`horiz`,1),ArrowUp:WY(`vert`,-1),ArrowDown:WY(`vert`,1)});function WY(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof Up){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=LY.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new LY(c))),!0):!1}}function GY(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!LY.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Gp.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new LY(r))),!0)}function KY(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof LY))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=Z.empty;for(let e=r.length-1;e>=0;e--)i=Z.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Q(i,0,0));return a.setSelection(Up.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function qY(e){if(!(e.selection instanceof LY))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,IR.create(e.doc,[NR.widget(e.selection.head,t,{key:`gapcursor`})])}var JY=fV.create({name:`gapCursor`,addProseMirrorPlugins(){return[HY()]},extendNodeSchema(e){return{allowGapCursor:RB(jB(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),YY=vU.create({name:`hardBreak`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,FB(this.options.HTMLAttributes,e)]},renderText(){return`
220
+ `},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),XY=vU.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(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,FB(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>gU({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),ZY=200,QY=function(){};QY.prototype.append=function(e){return e.length?(e=QY.from(e),!this.length&&e||e.length<ZY&&this.leafAppend(e)||this.length<ZY&&e.leafPrepend(this)||this.appendInner(e)):this},QY.prototype.prepend=function(e){return e.length?QY.from(e).append(this):this},QY.prototype.appendInner=function(e){return new eX(this,e)},QY.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?QY.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},QY.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},QY.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},QY.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},QY.from=function(e){return e instanceof QY?e:e&&e.length?new $Y(e):QY.empty};var $Y=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=ZY)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=ZY)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(QY);QY.empty=new $Y([]);var eX=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(QY),tX=500,nX=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,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,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new iX(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new iX(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new iX(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>oX&&(s=rX(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new If;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new iX(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new iX(i,o,l))}else r.push(new iX(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new iX(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>tX&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new iX(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(QY.from(i.reverse()),a)}};nX.empty=new nX(QY.empty,0);function rX(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var iX=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},aX=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},oX=20;function sX(e,t,n,r){let i=n.getMeta(hX),a;if(i)return i.historyState;n.getMeta(gX)&&(e=new aX(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(hX))return o.getMeta(hX).redo?new aX(e.done.addTransform(n,void 0,r,mX(t)),e.undone,lX(n.mapping.maps),e.prevTime,e.prevComposition):new aX(e.done,e.undone.addTransform(n,void 0,r,mX(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!cX(n,e.prevRanges)),s=o?uX(e.prevRanges,n.mapping):lX(n.mapping.maps);return new aX(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,mX(t)),nX.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new aX(e.done.rebased(n,a),e.undone.rebased(n,a),uX(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new aX(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),uX(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function cX(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function lX(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function uX(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function dX(e,t,n){let r=mX(t),i=hX.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new aX(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(hX,{redo:n,historyState:c})}var fX=!1,pX=null;function mX(e){let t=e.plugins;if(pX!=t){fX=!1,pX=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){fX=!0;break}}return fX}var hX=new um(`history`),gX=new um(`closeHistory`);function _X(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new sm({key:hX,state:{init(){return new aX(nX.empty,nX.empty,null,0,-1)},apply(t,n,r){return sX(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?yX:n==`historyRedo`?bX:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function vX(e,t){return(n,r)=>{let i=hX.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=dX(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var yX=vX(!1,!0),bX=vX(!0,!0),xX=fV.create({name:`history`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>yX(e,t),redo:()=>({state:e,dispatch:t})=>bX(e,t)}},addProseMirrorPlugins(){return[_X(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()}}}),SX=vU.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{}}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,FB(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!bU(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$from:r,$to:i}=n,a=e();return r.parentOffset===0?a.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):HH(n)?a.insertContentAt(i.pos,{type:this.name}):a.insertContent({type:this.name}),a.command(({tr:e,dispatch:t})=>{if(t){let{$to:t}=e.selection,n=t.end();if(t.nodeAfter)t.nodeAfter.isTextblock?e.setSelection(Up.create(e.doc,t.pos+1)):t.nodeAfter.isBlock?e.setSelection(Gp.create(e.doc,t.pos)):e.setSelection(Up.create(e.doc,t.pos));else{let r=t.parent.type.contentMatch.defaultType?.create();r&&(e.insert(n,r),e.setSelection(Up.create(e.doc,n+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[hU({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),CX=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,wX=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,TX=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,EX=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,DX=nV.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[mU({find:CX,type:this.type}),mU({find:TX,type:this.type})]},addPasteRules(){return[yU({find:wX,type:this.type}),yU({find:EX,type:this.type})]}}),OX=vU.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,FB(this.options.HTMLAttributes,e),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)}}}),kX=`listItem`,AX=`textStyle`,jX=/^(\d+)\.\s$/,MX=vU.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:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>e.getAttribute(`type`)}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return t===1?[`ol`,FB(this.options.HTMLAttributes,n),0]:[`ol`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(kX,this.editor.getAttributes(AX)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=_U({find:jX,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=_U({find:jX,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(AX)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),NX=vU.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),PX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,FX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,IX=nV.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,FB(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[mU({find:PX,type:this.type})]},addPasteRules(){return[yU({find:FX,type:this.type})]}}),LX=vU.create({name:`text`,group:`inline`}),RX=fV.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(SY.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(_Y.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(EY.configure(this.options.bulletList)),this.options.code!==!1&&e.push(kY.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(MY.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(NY.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(IY.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(JY.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(YY.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(XY.configure(this.options.heading)),this.options.history!==!1&&e.push(xX.configure(this.options.history)),this.options.horizontalRule!==!1&&e.push(SX.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(DX.configure(this.options.italic)),this.options.listItem!==!1&&e.push(OX.configure(this.options.listItem)),this.options.orderedList!==!1&&e.push(MX.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(NX.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(IX.configure(this.options.strike)),this.options.text!==!1&&e.push(LX.configure(this.options.text)),e}}),zX=nV.create({name:`footnote-ref`,inclusive:!1,addAttributes(){return{id:{default:null,parseHTML:()=>null,renderHTML:e=>e.id==null?{}:{"data-footnote-id":String(e.id)}},kind:{default:`footnote`,parseHTML:()=>null,renderHTML:()=>({})}}},parseHTML(){return[]},renderHTML({HTMLAttributes:e}){return[`sup`,FB({class:`tandem-footnote-ref`},e),0]}}),BX=new um(`listItemCheckbox`),VX=/^\[([ xX])\]\s$/,HX=OX.extend({addAttributes(){return{...this.parent?.(),checked:{default:null,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===`true`?!0:t===`false`?!1:null},renderHTML:e=>e.checked===null||e.checked===void 0?{}:{"data-checked":String(e.checked)}}}},addInputRules(){let e=this.type;return[new YB({find:VX,handler:({state:t,range:n,match:r})=>{let i=r[1]!==` `,a=t.doc.resolve(n.from),o=-1,s={};for(let t=a.depth;t>0;t--){let n=a.node(t);if(n.type===e){o=a.before(t),s=n.attrs;break}}if(o<0)return null;let c=t.tr;c.delete(n.from,n.to),c.setNodeMarkup(o,void 0,{...s,checked:i})}})]},addProseMirrorPlugins(){let e=this.type;return[...this.parent?.()??[],new sm({key:BX,props:{decorations:t=>{let n=[];return t.doc.descendants((t,r)=>{if(t.type!==e||t.attrs.checked===null||t.attrs.checked===void 0)return;let i=t.attrs.checked===!0;n.push(NR.widget(r+1,(t,n)=>UX(t,n,i,e),{side:-1,key:`tandem-checkbox-${r}:${i}`,stopEvent:()=>!0,ignoreSelection:!0}))}),IR.create(t.doc,n)}}})]}});function UX(e,t,n,r){let i=document.createElement(`label`);i.className=`tandem-list-checkbox`,i.contentEditable=`false`;let a=document.createElement(`input`);return a.type=`checkbox`,a.checked=n,a.setAttribute(`aria-label`,n?`Checked task`:`Unchecked task`),a.addEventListener(`mousedown`,e=>e.preventDefault()),a.addEventListener(`change`,()=>{if(!e.editable){a.checked=n;return}let i=t();if(i==null)return;let o=i-1,s=e.state.doc.resolve(o).nodeAfter;!s||s.type!==r||e.dispatch(e.state.tr.setNodeMarkup(o,void 0,{...s.attrs,checked:!s.attrs.checked}))}),i.appendChild(a),i}var WX=fV.create({name:`markdownHtml`,addGlobalAttributes(){return[{types:[`paragraph`],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})},markdownRaw:{default:null,parseHTML:()=>null,renderHTML:e=>e.markdownRaw?{"data-markdown-raw":``}:{}}}}]}}),GX=nV.create({name:`rawMarkdown`,parseHTML(){return[]},renderHTML(){return[`span`,{class:`tandem-raw-md`},0]}}),KX=pq.extend({renderHTML(e){let t=this.parent?.(e)??[`a`,FB(this.options.HTMLAttributes,e.HTMLAttributes),0];if(Array.isArray(t)&&t.length>=2&&t[1]&&typeof t[1]==`object`){let e=t[1],n=e.href;typeof n==`string`&&n.length>0&&e.title==null&&(t[1]={...e,title:n})}return t}});function qX(){return[RX.configure({history:!1,listItem:!1}),HX,hY,gq,hq,zX,XW.configure({multicolor:!0}),KX.configure({openOnClick:!1,HTMLAttributes:{rel:`noopener noreferrer`,target:`_blank`}}),QW.configure({allowBase64:!0}),mq.configure({placeholder:`Start typing…`}),dY.configure({resizable:!0}),mY,fY,pY,WX,GX]}var JX=new um(`tandemAnnotations`),YX={comment:!0,highlight:!0,note:!0};function XX(){try{let e=localStorage.getItem(ro);if(!e)return{...YX};let t=JSON.parse(e);return{comment:t.comment!==!1,highlight:t.highlight!==!1,note:t.note!==!1}}catch(e){return console.warn(`[annotation] localStorage unavailable`,e),{...YX}}}function ZX(){return rD(Nl(),`family`)}function QX(e){return e===`highlight`?`highlight`:e===`note`||e===`flag`?`note`:`comment`}function $X(e,t,n,r,i){let a=[],o=e.content.size;return t.forEach(t=>{let s=ik(t,e=>{console.warn(`[sanitize]`,e)});if(s.status!==`pending`||!r[s.type]||!s.range&&!s.relRange)return;let c=hD(s,e,n);if(!c)return;s.relRange&&c.method===`flat`&&console.warn(`[annotation] relRange-equipped annotation %s fell back to flat offsets`,s.id);let{from:l,to:u}=c;if(l>=u||l<0||u>o)return;let d={};switch(s.type){case`highlight`:{let e=Aa(s.color),t=ka[e];d={class:`tandem-highlight tandem-highlight--${e}`,style:`background: ${t}; border-radius: var(--tandem-r-1); padding: 1px 0;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Highlight annotation (${e})`};break}case`comment`:d=s.suggestedText===void 0?s.author===`claude`?{class:`tandem-comment tandem-comment--claude`,style:`border-bottom: 2px solid var(--tandem-author-claude); padding-bottom: 1px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`${i} comment annotation`}:{class:`tandem-comment`,style:`border-bottom: 2px dashed var(--tandem-author-user); padding-bottom: 1px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Comment annotation`}:{class:`tandem-suggestion`,style:`background: var(--tandem-suggestion-bg); text-decoration: underline wavy var(--tandem-suggestion); text-underline-offset: 3px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Replacement annotation`};break;case`note`:d={class:`tandem-note`,style:`border-bottom: 2px dotted var(--tandem-fg-muted); padding-bottom: 1px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Note annotation`};break;default:console.warn(`[annotation] Unhandled annotation type in buildDecorations, skipping`);return}try{a.push(NR.inline(l,u,d))}catch(e){if(!(e instanceof RangeError))throw e;console.debug(`[annotation] RangeError for %s (from=%d, to=%d), skipping`,s.id,l,u)}}),IR.create(e,a)}var eZ=fV.create({name:`tandemAnnotations`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Ra),n=XX(),r=ZX();function i(){for(let e of t.values()){let t=e;if(t&&t.status===`pending`&&n[QX(t.type)])return!0}return!1}let a=i(),o=!1;return[new sm({key:JX,state:{init(i,o){return a?$X(o.doc,t,e,n,r):IR.empty},apply(s,c,l,u){let d=s.getMeta(JX);if(d&&typeof d==`object`&&d.type===`toggle-decorations`&&(n=d.visible,a=i(),o=!1),d)return r=ZX(),a?$X(u.doc,t,e,n,r):IR.empty;if(!a)return IR.empty;if(s.docChanged){if(!o&&c===IR.empty&&a){let i=$X(u.doc,t,e,n,r);return i!==IR.empty&&(o=!0),i}return c.map(s.mapping,s.doc)}return c}},props:{decorations(e){return JX.getState(e)}},view(e){let n=null,r=!1;function s(){n===null&&(n=requestAnimationFrame(()=>{n=null,r=!0;let t=e.state.tr.setMeta(JX,!0);e.dispatch(t)}))}let c=()=>{a=i(),o=!1,s()};t.observe(c);let l=setTimeout(()=>{!r&&n===null&&t.size>0&&c()},500);return{destroy(){clearTimeout(l),n!==null&&cancelAnimationFrame(n),t.unobserve(c)}}}})]}}),tZ=new um(`tandemAnnotationPing`),nZ=700,rZ=500,iZ=`tandem-annotation-ping`;function aZ(e,t){return!(!t.isLive||t.alreadySeen||!e||e.status!==`pending`||!t.visible[QX(e.type)])}function oZ(){try{if(Nl().reduceMotion)return!0}catch{}return typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var sZ=fV.create({name:`tandemAnnotationPing`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Ra),n=new Set,r=!1;return[new sm({key:tZ,state:{init:()=>IR.empty,apply(e,t){let n=t.map(e.mapping,e.doc),r=e.getMeta(tZ);if(r?.type===`add`)n=n.add(e.doc,[r.deco]);else if(r?.type===`remove`){let e=n.find(void 0,void 0,e=>e.pingId===r.id);e.length&&(n=n.remove(e))}return n}},props:{decorations(e){return tZ.getState(e)}},view(i){let a=new Map,o=!1;function s(t,n){if(oZ())return;let r=hD(n,i.state.doc,e);if(r)try{let e=i.state.doc.resolve(r.from),n=e.depth;if(n<1)return;let s=e.before(n),c=e.after(n),l=NR.node(s,c,{class:iZ},{pingId:t});i.dispatch(i.state.tr.setMeta(tZ,{type:`add`,deco:l}));let u=setTimeout(()=>{a.delete(t),!o&&i.dispatch(i.state.tr.setMeta(tZ,{type:`remove`,id:t}))},nZ);a.set(t,u)}catch(e){if(!(e instanceof RangeError))throw e}}let c,l=()=>{for(let e of t.keys())n.add(e);r=!0},u=()=>{clearTimeout(c),c=setTimeout(l,rZ)},d=e=>{r||u();let i=XX();for(let a of e.keysChanged){let e=t.get(a),o=aZ(e,{isLive:r,alreadySeen:n.has(a),visible:i});n.add(a),o&&e&&s(a,e)}};return t.observe(d),u(),{destroy(){o=!0,clearTimeout(c);for(let e of a.values())clearTimeout(e);a.clear(),t.unobserve(d)}}}})]}}),cZ=new um(`tandemAuthorship`),lZ=new Set([`paragraph`,`heading`]);function uZ(e,t,n){if(e.relRange){let r=mD(n,t,e.relRange);if(r&&r.from<r.to)return r}if(e.range){console.warn(`[authorship] Falling back to flat offsets for range`,e.id);let n=lD(t,e.range.from),r=lD(t,e.range.to);if(n<r)return{from:n,to:r}}return null}function dZ(e,t,n,r){if(!r)return IR.empty;let i=[],a=e.content.size,o=[];return t.forEach(t=>{let r=t;if(!r.author||!r.range||r.author!==`user`&&r.author!==`claude`)return;let s=uZ(r,e,n);if(!s)return;let{from:c,to:l}=s;if(!(c>=l||c<0||l>a)){try{i.push(NR.inline(c,l,{"data-tandem-author":r.author}))}catch(e){if(!(e instanceof RangeError))throw e;console.warn(`[authorship] Decoration RangeError for entry`,r.id,e)}o.push({author:r.author,from:c,to:l})}}),e.descendants((e,t)=>{if(!lZ.has(e.type.name))return;let n=t,r=t+e.nodeSize,a=0,s=0;for(let e of o){let t=Math.max(e.from,n),i=Math.min(e.to,r);if(i<=t)continue;let o=i-t;e.author===`user`?a+=o:s+=o}if(a===0&&s===0||e.content.size===0)return;let c=a>=s?`user`:`claude`;try{i.push(NR.node(n,r,{"data-tandem-author-block":c}))}catch(e){if(!(e instanceof RangeError))throw e;console.warn(`[authorship] node Decoration RangeError at offset`,t,e)}}),IR.create(e,i)}var fZ=fV.create({name:`tandemAuthorship`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(qa),n=!1;try{n=localStorage.getItem(no)===`true`}catch(e){console.warn(`[authorship] localStorage unavailable`,e)}return[new sm({key:cZ,state:{init(r,i){return{visible:n,decorations:dZ(i.doc,t,e,n)}},apply(n,r,i,a){let o=n.getMeta(cZ);if(o?.type===`toggle`){let n=o.visible;return{visible:n,decorations:dZ(a.doc,t,e,n)}}return o?.type===`rebuild`?{visible:r.visible,decorations:dZ(a.doc,t,e,r.visible)}:n.docChanged&&r.visible?{visible:r.visible,decorations:r.decorations.map(n.mapping,n.doc)}:r}},props:{decorations(e){return cZ.getState(e)?.decorations??IR.empty}},view(e){let n=()=>{let t=e.state.tr.setMeta(cZ,{type:`rebuild`});e.dispatch(t)};t.observe(n);let r=setTimeout(()=>{t.size>0&&n()},500);return{destroy(){clearTimeout(r),t.unobserve(n)}}}})]},onTransaction({transaction:e}){let t=this.options.ydoc;if(!t||e.getMeta(`y-sync$`)||e.getMeta(cZ)||!e.docChanged)return;let n=t.getMap(qa),r=e.doc;e.steps.forEach(e=>{e.getMap().forEach((e,t,i,a)=>{if(a-i-(t-e)>0)try{let e=dD(r,Co(i)),t=dD(r,Co(a));if(t<=e)return;let o=fc(`user`),s={id:o,author:`user`,range:{from:e,to:t},timestamp:Date.now()};n.set(o,s)}catch(e){console.warn(`[authorship] Position conversion failed during user attribution`,e)}})})}}),pZ=new um(`tandemAwareness`);function mZ(e,t){if(!t)return IR.empty;let n=[],{focusParagraph:r,focusOffset:i,active:a}=t;if(r!==null&&r>=0){let t=0;e.forEach((e,i)=>{t===r&&n.push(NR.node(i,i+e.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;`})),t++})}if(i!==null&&i>=0)try{let t=lD(e,So(i)),r=a===!1?` tandem-claude-cursor-idle`:``;n.push(NR.widget(t,()=>{let e=document.createElement(`span`);e.className=`tandem-claude-cursor${r}`,e.setAttribute(`aria-hidden`,`true`);let t=document.createElement(`span`);return t.className=`tandem-claude-cursor-label`,t.textContent=`AI`,e.appendChild(t),e}))}catch(e){console.warn(`[awareness] cursor decoration failed, falling back to gutter-only:`,e)}return n.length===0?IR.empty:IR.create(e,n)}var hZ=fV.create({name:`tandemAwareness`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(za),n=e.getMap(Ba);return[new sm({key:pZ,state:{init(e,n){let r=t.get(Xa);return mZ(n.doc,r??null)},apply(e,n,r,i){if(e.getMeta(pZ)){let e=t.get(Xa);return mZ(i.doc,e??null)}return e.docChanged?n.map(e.mapping,e.doc):n}},props:{decorations(e){return pZ.getState(e)}},view(e){let n=()=>{let t=e.state.tr.setMeta(pZ,!0);e.dispatch(t)};return t.observe(n),{destroy(){t.unobserve(n)}}}}),new sm({key:new um(`tandemUserAwareness`),view(){let e=null,t=null,r=null,i=!1,a=-1;return{update(o,s){let{state:c}=o;if(!c.selection.eq(s.selection)){let e=gD(c.doc,{from:Co(c.selection.from),to:Co(c.selection.to)});if(c.selection.from===c.selection.to)r&&=(clearTimeout(r),null),n.set(Ja,{...e,timestamp:Date.now()});else{let t=c.doc.textBetween(c.selection.from,c.selection.to,`
221
+ `),i=t.length>200?t.slice(0,197)+`...`:t;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n.set(Ja,{...e,selectedText:i,timestamp:Date.now()})},150)}}c.doc!==s.doc&&(a=c.selection.from,i=!0,t||=setTimeout(()=>{t=null,i&&n.set(Ya,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200),e&&clearTimeout(e),e=setTimeout(()=>{i=!1,n.set(Ya,{isTyping:!1,cursor:o.state.selection.from,lastEdit:Date.now()})},Ta))},destroy(){e&&clearTimeout(e),t&&clearTimeout(t),r&&clearTimeout(r)}}}})]}}),gZ=new um(`tandemFindReplace`),_Z={query:``,caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:IR.empty};function vZ(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function yZ(e){if(!e.query)return null;try{let t=e.regexMode?e.query:vZ(e.query),n=e.caseSensitive?`g`:`gi`,r=e.wholeWord?`\\b${t}\\b`:t;return new RegExp(r,n)}catch{return null}}function bZ(e,t){let n=yZ(t);if(!n)return[];let r=[];return e.descendants((e,t)=>{if(!e.isTextblock)return;let i=e.textContent;for(let e of i.matchAll(n)){let n=e.index??0;r.push({from:t+1+n,to:t+1+n+e[0].length})}}),r}function xZ(e,t,n){if(t.length===0)return IR.empty;let r=[];for(let e=0;e<t.length;e++){let{from:i,to:a}=t[e];try{r.push(NR.inline(i,a,{class:e===n?`tandem-find-active`:`tandem-find-match`}))}catch{}}return IR.create(e,r)}function SZ(e,t){if(e.length===0)return-1;for(let n=0;n<e.length;n++)if(e[n].from<=t&&t<=e[n].to)return n;for(let n=0;n<e.length;n++)if(e[n].from>t)return n;return 0}function CZ(e,t,n){if(e.type===`close`)return _Z;if(e.type===`find`){let t=e.opts,r=bZ(n.doc,t),i=n.selection.from,a=SZ(r,i);return{...t,matches:r,activeIndex:a,decoSet:xZ(n.doc,r,a)}}if(e.type===`next`){let e=t.matches.length===0?-1:(t.activeIndex+1)%t.matches.length;return{...t,activeIndex:e,decoSet:xZ(n.doc,t.matches,e)}}if(e.type===`prev`){let e=t.matches.length===0?-1:(t.activeIndex-1+t.matches.length)%t.matches.length;return{...t,activeIndex:e,decoSet:xZ(n.doc,t.matches,e)}}return e}var wZ=fV.create({name:`tandemFindReplace`,addProseMirrorPlugins(){return[new sm({key:gZ,state:{init:()=>_Z,apply(e,t,n,r){let i=e.getMeta(gZ);if(i)return CZ(i,t,r);if(!t.query)return t;if(e.docChanged){let e=bZ(r.doc,t),n=r.selection.from,i=SZ(e,n);return{...t,matches:e,activeIndex:i,decoSet:xZ(r.doc,e,i)}}let a=r.selection.from,o=SZ(t.matches,a);return o===t.activeIndex?t:{...t,activeIndex:o,decoSet:xZ(r.doc,t.matches,o)}}},props:{decorations(e){return gZ.getState(e)?.decoSet??IR.empty}}})]},addCommands(){return{find:e=>({dispatch:t,tr:n})=>(t&&t(n.setMeta(gZ,{type:`find`,opts:e})),!0),findNext:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(gZ,{type:`next`})),!0),findPrev:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(gZ,{type:`prev`})),!0),findClose:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(gZ,{type:`close`})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:e})=>gZ.getState(e.state)?.query?(e.commands.findClose(),!0):!1}}});function TZ(e){return gZ.getState(e)}function EZ(e,t){let n=TZ(e.state);if(!n||n.activeIndex<0||n.matches.length===0)return!1;let{from:r,to:i}=n.matches[n.activeIndex],a=e.state.tr.insertText(t,r,i).setMeta(gZ,{type:`next`});return e.dispatch(a),!0}async function DZ(e,t,n){let r=0,i=!1;for(let a=0;a<50;a++){let o=TZ(e.state);if(!o?.query||o.matches.length===0)break;let s=o.matches.slice(0,100);try{let i=e.state.tr;for(let e=s.length-1;e>=0;e--){let{from:n,to:r}=s[e];i=i.insertText(t,n,r)}e.dispatch(i),r+=s.length,n?.(r,r+(o.matches.length-s.length))}catch(e){i=!0,console.warn(`[find-replace] replaceAll chunk failed at pass`,a,e);break}if(s.length<100)break;await new Promise(e=>setTimeout(e,0))}return{replaced:r,partial:i}}var OZ=new um(`tandemHeadingCollapse`),kZ=`tandem:headingCollapse:`;function AZ(e){return!e||e.startsWith(`upload://`)?null:kZ+e}function jZ(e){let t=AZ(e);if(!t)return new Set;try{let e=window.localStorage.getItem(t);if(!e)return new Set;let n=JSON.parse(e);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function MZ(e,t){let n=AZ(e);if(n)try{t.size===0?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(Array.from(t)))}catch{}}function NZ(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function PZ(e){let t=[],n=new Map;return e.descendants((r,i,a)=>{if(r.type.name!==`heading`)return!0;if(a!==e)return!1;let o=r.attrs.level??1,s=`${o}::${NZ(r.textContent)}`,c=n.get(s)??0;n.set(s,c+1);let l=`${s}::${c}`;return t.push({pos:i,level:o,hash:l}),!1}),t}function FZ(e,t,n,r){if(n.size===0)return n;let i=new Set(t.map(e=>e.hash));if(e.length===t.length){let i=[];for(let n=0;n<e.length;n++)e[n].hash!==t[n].hash&&i.push(n);if(i.length!==1)return n;let a=i[0],o=e[a].hash,s=t[a].hash;if(!n.has(o))return n;let c=new Set(n);return c.delete(o),c.add(s),MZ(r,c),c}if(t.length>e.length||t.length===0)return n;let a=!1,o=new Set;for(let e of n)i.has(e)?o.add(e):a=!0;return a?(MZ(r,o),o):n}function IZ(e,t,n){return NR.widget(e+1,e=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`tandem-heading-chevron`,r.dataset.testid=`heading-chevron`,r.dataset.headingHash=t,r.dataset.collapsed=String(n),r.setAttribute(`aria-label`,n?`Expand section`:`Collapse section`),r.setAttribute(`aria-expanded`,String(!n)),r.contentEditable=`false`,r.textContent=n?`▶`:`▼`,r.addEventListener(`mousedown`,e=>{e.preventDefault()}),r.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault();let r=e.state.tr.setMeta(OZ,{type:`toggle`,hash:t});e.dispatch(r)}),r},{side:-1,ignoreSelection:!0,stopEvent:()=>!0,key:`chevron:${t}:${n?`c`:`e`}`})}function LZ(e,t,n){let r=t[n],i=e.content.size;for(let e=n+1;e<t.length;e++)if(t[e].level<=r.level){i=t[e].pos;break}let a=[];return e.forEach((e,t)=>{if(t>r.pos&&t<i){let n=t,r=t+e.nodeSize;a.push(NR.node(n,r,{class:`tandem-heading-collapsed-hidden`,style:`display: none;`}))}}),a}function RZ(e,t,n){let r=[];for(let i=0;i<t.length;i++){let a=t[i],o=n.has(a.hash);try{r.push(IZ(a.pos,a.hash,o)),o&&r.push(...LZ(e,t,i))}catch{}}return r.length===0?IR.empty:IR.create(e,r)}var zZ=fV.create({name:`tandemHeadingCollapse`,addOptions(){return{filePath:null}},addProseMirrorPlugins(){let e=this.options.filePath;return[new sm({key:OZ,state:{init(t,n){let r=jZ(e),i=PZ(n.doc);return{collapsed:r,headings:i,decoSet:RZ(n.doc,i,r),hasSeenContent:i.length>0}},apply(t,n,r,i){let a=t.getMeta(OZ);if(a?.type===`toggle`){let t=new Set(n.collapsed);return t.has(a.hash)?t.delete(a.hash):t.add(a.hash),MZ(e,t),{collapsed:t,headings:n.headings,decoSet:RZ(i.doc,n.headings,t),hasSeenContent:n.hasSeenContent}}if(a?.type===`rehydrate`){let t=PZ(i.doc),n=jZ(e),r=new Set(t.map(e=>e.hash)),a=new Set;for(let e of n)r.has(e)&&a.add(e);return a.size!==n.size&&MZ(e,a),{collapsed:a,headings:t,decoSet:RZ(i.doc,t,a),hasSeenContent:!0}}if(!t.docChanged)return n;let o=PZ(i.doc),s=n.hasSeenContent||o.length>0,c=n.collapsed;return n.hasSeenContent&&(c=FZ(n.headings,o,n.collapsed,e)),{collapsed:c,headings:o,decoSet:RZ(i.doc,o,c),hasSeenContent:s}}},view(e){let t=!1,n=null;function r(){t||n!==null||(n=requestAnimationFrame(()=>{if(n=null,t)return;let r=OZ.getState(e.state);if(!r||r.headings.length===0)return;t=!0;let i=e.state.tr.setMeta(OZ,{type:`rehydrate`}).setMeta(`addToHistory`,!1);e.dispatch(i)}))}return r(),{update(e){if(t)return;let n=OZ.getState(e.state);!n||n.headings.length===0||r()},destroy(){n!==null&&cancelAnimationFrame(n)}}},props:{decorations(e){return OZ.getState(e)?.decoSet??IR.empty}}})]}}),BZ=new um(`tandemSelectionDecoration`),VZ=fV.create({name:`tandemSelectionDecoration`,addProseMirrorPlugins(){return[new sm({key:BZ,props:{decorations(e){let{selection:t}=e;if(!(t instanceof Up))return IR.empty;let{from:n,to:r}=t;return n===r?IR.empty:IR.create(e.doc,[NR.inline(n,r,{class:`tandem-selection-blurred`})])}}})]}});function HZ(e){return e.chain().focus()}var UZ={tag:`path`,attrs:{d:`M6 4.5h7M6 8h7M6 11.5h7`}},WZ=[{id:`heading-1`,label:`Heading 1`,keywords:[`h1`,`heading`,`title`],hint:`h1`,icon:{kind:`glyph`,glyph:`H¹`},run:e=>HZ(e).toggleHeading({level:1}).run()},{id:`heading-2`,label:`Heading 2`,keywords:[`h2`,`heading`,`subtitle`],hint:`h2`,icon:{kind:`glyph`,glyph:`H²`},run:e=>HZ(e).toggleHeading({level:2}).run()},{id:`heading-3`,label:`Heading 3`,keywords:[`h3`,`heading`,`subheading`],hint:`h3`,icon:{kind:`glyph`,glyph:`H³`},run:e=>HZ(e).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`}},UZ]},run:e=>HZ(e).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`}},UZ]},run:e=>HZ(e).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:e=>HZ(e).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:e=>HZ(e).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:e=>HZ(e).toggleCodeBlock().run()},{id:`horizontal-rule`,label:`Horizontal rule`,keywords:[`hr`,`divider`,`rule`,`separator`],hint:`hr`,icon:{kind:`glyph`,glyph:`—`},run:e=>HZ(e).setHorizontalRule().run()}];function GZ(e){let t=/(?:^|\s)\/([A-Za-z0-9 -]*)$/.exec(e);if(!t)return null;let n=t[1]??``;return{fromOffset:e.length-n.length-1,query:n}}function KZ(e){let t=e.trim().toLowerCase();return t?WZ.filter(e=>[e.label,...e.keywords].join(` `).toLowerCase().includes(t)):WZ}var qZ=[`popup-annotation-input`,`popup-note-submit`,`popup-comment-submit`,`popup-highlight-yellow`,`popup-highlight-green`,`popup-highlight-blue`,`popup-highlight-pink`];function JZ(e){let t=document.querySelector(`[data-testid="${e}"]`);return t?document.activeElement===t:!1}function YZ(e){for(let t of e)if(document.querySelector(`[data-testid="${t}"]`))return!0;return!1}function XZ(){return typeof document>`u`?!1:!!(JZ(`find-input`)||document.querySelector(`[data-testid="command-palette"]`)||YZ(qZ))}var ZZ=`http://www.w3.org/2000/svg`,QZ=new um(`tandemSlashCommand`);function $Z(e){return`${e.from}:${e.to}:${e.query}`}function eQ(e){if(!e.docChanged||e.getMeta(`y-sync$`))return!1;let t=e.getMeta(`uiEvent`);if(t===`paste`||t===`drop`||e.getMeta(`paste`))return!1;let n=e.selection.from,r=!1;return e.mapping.maps.forEach((t,i)=>{t.forEach((t,a,o,s)=>{s<=o||e.mapping.slice(i+1).map(s,-1)===n&&(r=!0)})}),r}function tQ(e,t=0){if(XZ())return null;let{selection:n}=e;if(!n.empty)return null;let r=n.$from,i=GZ(r.parent.textBetween(0,r.parentOffset,`
222
+ `,`
223
+ `));if(!i)return null;let a=r.start()+i.fromOffset,o=r.pos,s=KZ(i.query);return s.length===0?null:{from:a,to:o,query:i.query,selectedIndex:Math.min(t,s.length-1)}}function nQ(e,t){let n=e.getMeta(QZ);return n?n.type===`close`?{active:null,dismissedKey:t.active?$Z(t.active):t.dismissedKey}:n.type===`select`&&t.active?{...t,active:{...t.active,selectedIndex:n.selectedIndex??t.active.selectedIndex}}:t:null}function rQ(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function iQ(){let e=document.createElement(`div`);e.className=`tandem-slash-menu__hint`;for(let[t,n]of[[`↑↓`,`navigate`],[`↵`,`insert`],[`esc`,`close`]]){let r=document.createElement(`span`),i=document.createElement(`kbd`);i.textContent=t,r.appendChild(i),r.appendChild(document.createTextNode(` ${n}`)),e.appendChild(r)}return e}function aQ(e){let t=document.createElement(`span`);if(t.className=`tandem-slash-menu__icon`,t.setAttribute(`aria-hidden`,`true`),e.kind===`glyph`)return t.textContent=e.glyph,t;let n=document.createElementNS(ZZ,`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(let t of e.els){let e=document.createElementNS(ZZ,t.tag);for(let[n,r]of Object.entries(t.attrs))e.setAttribute(n,r);n.appendChild(e)}return t.appendChild(n),t}function oQ(e,t,n,r,i){let a=KZ(t.query);rQ(e),e.className=`tandem-floating-pill tandem-slash-menu`;let o=document.createElement(`div`);o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,`Slash commands`),a.forEach((e,n)=>{let a=document.createElement(`button`);a.type=`button`,a.role=`option`,a.id=`slash-command-${e.id}`,a.className=`tandem-slash-menu__item`,a.setAttribute(`aria-selected`,String(n===t.selectedIndex)),a.setAttribute(`aria-label`,e.label),a.dataset.commandId=e.id,a.appendChild(aQ(e.icon));let s=document.createElement(`span`);s.className=`tandem-slash-menu__label`,s.textContent=e.label,a.appendChild(s);let c=document.createElement(`span`);c.className=`tandem-slash-menu__shortcut`,c.setAttribute(`aria-hidden`,`true`),c.textContent=e.hint,a.appendChild(c),a.addEventListener(`mouseenter`,()=>r(n)),a.addEventListener(`mousedown`,t=>{t.preventDefault(),i(e)}),o.appendChild(a)}),e.appendChild(o),e.appendChild(iQ());let s=n.view.coordsAtPos(t.from);e.style.display=`block`,e.style.position=`fixed`,e.style.left=`${Math.max(8,s.left)}px`,e.style.top=`${s.bottom+8}px`}function sQ(e,t){let n=KZ(t.query)[t.selectedIndex];return n?(e.chain().focus().deleteRange({from:t.from,to:t.to}).run(),n.run(e),!0):!1}var cQ=fV.create({name:`slashCommand`,addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){let e=this.editor,t=this.options.onOpenChange;return[new sm({key:QZ,state:{init:()=>({active:null,dismissedKey:null}),apply(e,t,n,r){let i=nQ(e,t);if(i)return i;let a=tQ(r,t.active?.selectedIndex??0);return a&&!t.active&&!eQ(e)||a&&$Z(a)===t.dismissedKey?{active:null,dismissedKey:t.dismissedKey}:{active:a,dismissedKey:a?null:t.dismissedKey}}},props:{handleKeyDown(t,n){let r=QZ.getState(t.state)?.active;if(!r)return!1;let i=KZ(r.query);if(n.key===`ArrowDown`){n.preventDefault();let e=(r.selectedIndex+1)%i.length;return t.dispatch(t.state.tr.setMeta(QZ,{type:`select`,selectedIndex:e})),!0}if(n.key===`ArrowUp`){n.preventDefault();let e=(r.selectedIndex-1+i.length)%i.length;return t.dispatch(t.state.tr.setMeta(QZ,{type:`select`,selectedIndex:e})),!0}return n.key===`Enter`?(n.preventDefault(),sQ(e,r)):n.key===`Escape`?(n.preventDefault(),t.dispatch(t.state.tr.setMeta(QZ,{type:`close`})),!0):!1}},view(n){let r=document.createElement(`div`);r.dataset.testid=`slash-command-menu`,r.style.display=`none`,document.body.appendChild(r);let i=!1,a=e=>{e!==i&&(i=e,t?.(e))},o=()=>{r.style.display=`none`,rQ(r),a(!1)},s=()=>{let t=QZ.getState(n.state)?.active;if(!t){o();return}oQ(r,t,e,e=>{n.dispatch(n.state.tr.setMeta(QZ,{type:`select`,selectedIndex:e}))},r=>{e.chain().focus().deleteRange({from:t.from,to:t.to}).run(),r.run(e),o(),n.dispatch(n.state.tr.setMeta(QZ,{type:`close`}))}),a(!0)};return s(),{update:s,destroy(){a(!1),r.remove()}}}})]}}),lQ={};function uQ(e){let t=lQ[e];if(t)return t;t=lQ[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);t.push(n)}for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[r]=`%`+(`0`+r.toString(16).toUpperCase()).slice(-2)}return t}function dQ(e,t){typeof t!=`string`&&(t=dQ.defaultChars);let n=uQ(t);return e.replace(/(%[a-f0-9]{2})+/gi,function(e){let t=``;for(let r=0,i=e.length;r<i;r+=3){let a=parseInt(e.slice(r+1,r+3),16);if(a<128){t+=n[a];continue}if((a&224)==192&&r+3<i){let n=parseInt(e.slice(r+4,r+6),16);if((n&192)==128){let e=a<<6&1984|n&63;e<128?t+=`��`:t+=String.fromCharCode(e),r+=3;continue}}if((a&240)==224&&r+6<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16);if((n&192)==128&&(i&192)==128){let e=a<<12&61440|n<<6&4032|i&63;e<2048||e>=55296&&e<=57343?t+=`���`:t+=String.fromCharCode(e),r+=6;continue}}if((a&248)==240&&r+9<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16),o=parseInt(e.slice(r+10,r+12),16);if((n&192)==128&&(i&192)==128&&(o&192)==128){let e=a<<18&1835008|n<<12&258048|i<<6&4032|o&63;e<65536||e>1114111?t+=`����`:(e-=65536,t+=String.fromCharCode(55296+(e>>10),56320+(e&1023))),r+=9;continue}}t+=`�`}return t})}dQ.defaultChars=`;/?:@&=+$,#`,dQ.componentChars=``;var fQ={};function pQ(e){let t=fQ[e];if(t)return t;t=fQ[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);/^[0-9a-z]$/i.test(n)?t.push(n):t.push(`%`+(`0`+e.toString(16).toUpperCase()).slice(-2))}for(let n=0;n<e.length;n++)t[e.charCodeAt(n)]=e[n];return t}function mQ(e,t,n){typeof t!=`string`&&(n=t,t=mQ.defaultChars),n===void 0&&(n=!0);let r=pQ(t),i=``;for(let t=0,a=e.length;t<a;t++){let o=e.charCodeAt(t);if(n&&o===37&&t+2<a&&/^[0-9a-f]{2}$/i.test(e.slice(t+1,t+3))){i+=e.slice(t,t+3),t+=2;continue}if(o<128){i+=r[o];continue}if(o>=55296&&o<=57343){if(o>=55296&&o<=56319&&t+1<a){let n=e.charCodeAt(t+1);if(n>=56320&&n<=57343){i+=encodeURIComponent(e[t]+e[t+1]),t++;continue}}i+=`%EF%BF%BD`;continue}i+=encodeURIComponent(e[t])}return i}mQ.defaultChars=`;/?:@&=+$,-_.!~*'()#`,mQ.componentChars=`-_.!~*'()`;function hQ(e){let t=``;return t+=e.protocol||``,t+=e.slashes?`//`:``,t+=e.auth?e.auth+`@`:``,e.hostname&&e.hostname.indexOf(`:`)!==-1?t+=`[`+e.hostname+`]`:t+=e.hostname||``,t+=e.port?`:`+e.port:``,t+=e.pathname||``,t+=e.search||``,t+=e.hash||``,t}function gQ(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var _Q=/^([a-z0-9.+-]+:)/i,vQ=/:[0-9]*$/,yQ=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,bQ=[`%`,`/`,`?`,`;`,`#`,`'`,`{`,`}`,`|`,`\\`,`^`,"`",`<`,`>`,`"`,"`",` `,`\r`,`
224
+ `,` `],xQ=[`/`,`?`,`#`],SQ=255,CQ=/^[+a-z0-9A-Z_-]{0,63}$/,wQ=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,TQ={javascript:!0,"javascript:":!0},EQ={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function DQ(e,t){if(e&&e instanceof gQ)return e;let n=new gQ;return n.parse(e,t),n}gQ.prototype.parse=function(e,t){let n,r,i,a=e;if(a=a.trim(),!t&&e.split(`#`).length===1){let e=yQ.exec(a);if(e)return this.pathname=e[1],e[2]&&(this.search=e[2]),this}let o=_Q.exec(a);if(o&&(o=o[0],n=o.toLowerCase(),this.protocol=o,a=a.substr(o.length)),(t||o||a.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i=a.substr(0,2)===`//`,i&&!(o&&TQ[o])&&(a=a.substr(2),this.slashes=!0)),!TQ[o]&&(i||o&&!EQ[o])){let e=-1;for(let t=0;t<xQ.length;t++)r=a.indexOf(xQ[t]),r!==-1&&(e===-1||r<e)&&(e=r);let t,n;n=e===-1?a.lastIndexOf(`@`):a.lastIndexOf(`@`,e),n!==-1&&(t=a.slice(0,n),a=a.slice(n+1),this.auth=t),e=-1;for(let t=0;t<bQ.length;t++)r=a.indexOf(bQ[t]),r!==-1&&(e===-1||r<e)&&(e=r);e===-1&&(e=a.length),a[e-1]===`:`&&e--;let i=a.slice(0,e);a=a.slice(e),this.parseHost(i),this.hostname=this.hostname||``;let o=this.hostname[0]===`[`&&this.hostname[this.hostname.length-1]===`]`;if(!o){let e=this.hostname.split(/\./);for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n&&!n.match(CQ)){let r=``;for(let e=0,t=n.length;e<t;e++)n.charCodeAt(e)>127?r+=`x`:r+=n[e];if(!r.match(CQ)){let r=e.slice(0,t),i=e.slice(t+1),o=n.match(wQ);o&&(r.push(o[1]),i.unshift(o[2])),i.length&&(a=i.join(`.`)+a),this.hostname=r.join(`.`);break}}}}this.hostname.length>SQ&&(this.hostname=``),o&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}let s=a.indexOf(`#`);s!==-1&&(this.hash=a.substr(s),a=a.slice(0,s));let c=a.indexOf(`?`);return c!==-1&&(this.search=a.substr(c),a=a.slice(0,c)),a&&(this.pathname=a),EQ[n]&&this.hostname&&!this.pathname&&(this.pathname=``),this},gQ.prototype.parseHost=function(e){let t=vQ.exec(e);t&&(t=t[0],t!==`:`&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};var OQ=t({decode:()=>dQ,encode:()=>mQ,format:()=>hQ,parse:()=>DQ}),kQ=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,AQ=/[\0-\x1F\x7F-\x9F]/,jQ=/[\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]/,MQ=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\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]/,NQ=/[\$\+<->\^`\|~\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]/,PQ=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,FQ=t({Any:()=>kQ,Cc:()=>AQ,Cf:()=>jQ,P:()=>MQ,S:()=>NQ,Z:()=>PQ}),IQ=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肻\xA0ଷ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(e=>e.charCodeAt(0))),LQ=new Uint16Array(`Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢`.split(``).map(e=>e.charCodeAt(0))),RQ=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]]),zQ=String.fromCodePoint??function(e){let t=``;return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t};function BQ(e){return e>=55296&&e<=57343||e>1114111?65533:RQ.get(e)??e}var VQ;(function(e){e[e.NUM=35]=`NUM`,e[e.SEMI=59]=`SEMI`,e[e.EQUALS=61]=`EQUALS`,e[e.ZERO=48]=`ZERO`,e[e.NINE=57]=`NINE`,e[e.LOWER_A=97]=`LOWER_A`,e[e.LOWER_F=102]=`LOWER_F`,e[e.LOWER_X=120]=`LOWER_X`,e[e.LOWER_Z=122]=`LOWER_Z`,e[e.UPPER_A=65]=`UPPER_A`,e[e.UPPER_F=70]=`UPPER_F`,e[e.UPPER_Z=90]=`UPPER_Z`})(VQ||={});var HQ=32,UQ;(function(e){e[e.VALUE_LENGTH=49152]=`VALUE_LENGTH`,e[e.BRANCH_LENGTH=16256]=`BRANCH_LENGTH`,e[e.JUMP_TABLE=127]=`JUMP_TABLE`})(UQ||={});function WQ(e){return e>=VQ.ZERO&&e<=VQ.NINE}function GQ(e){return e>=VQ.UPPER_A&&e<=VQ.UPPER_F||e>=VQ.LOWER_A&&e<=VQ.LOWER_F}function KQ(e){return e>=VQ.UPPER_A&&e<=VQ.UPPER_Z||e>=VQ.LOWER_A&&e<=VQ.LOWER_Z||WQ(e)}function qQ(e){return e===VQ.EQUALS||KQ(e)}var JQ;(function(e){e[e.EntityStart=0]=`EntityStart`,e[e.NumericStart=1]=`NumericStart`,e[e.NumericDecimal=2]=`NumericDecimal`,e[e.NumericHex=3]=`NumericHex`,e[e.NamedEntity=4]=`NamedEntity`})(JQ||={});var YQ;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Strict=1]=`Strict`,e[e.Attribute=2]=`Attribute`})(YQ||={});var XQ=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=JQ.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=YQ.Strict}startEntity(e){this.decodeMode=e,this.state=JQ.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case JQ.EntityStart:return e.charCodeAt(t)===VQ.NUM?(this.state=JQ.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=JQ.NamedEntity,this.stateNamedEntity(e,t));case JQ.NumericStart:return this.stateNumericStart(e,t);case JQ.NumericDecimal:return this.stateNumericDecimal(e,t);case JQ.NumericHex:return this.stateNumericHex(e,t);case JQ.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|HQ)===VQ.LOWER_X?(this.state=JQ.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=JQ.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,n,r){if(t!==n){let i=n-t;this.result=this.result*r**+i+parseInt(e.substr(t,i),r),this.consumed+=i}}stateNumericHex(e,t){let n=t;for(;t<e.length;){let r=e.charCodeAt(t);if(WQ(r)||GQ(r))t+=1;else return this.addToNumericResult(e,n,t,16),this.emitNumericEntity(r,3)}return this.addToNumericResult(e,n,t,16),-1}stateNumericDecimal(e,t){let n=t;for(;t<e.length;){let r=e.charCodeAt(t);if(WQ(r))t+=1;else return this.addToNumericResult(e,n,t,10),this.emitNumericEntity(r,2)}return this.addToNumericResult(e,n,t,10),-1}emitNumericEntity(e,t){var n;if(this.consumed<=t)return(n=this.errors)==null||n.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===VQ.SEMI)this.consumed+=1;else if(this.decodeMode===YQ.Strict)return 0;return this.emitCodePoint(BQ(this.result),this.consumed),this.errors&&(e!==VQ.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){let{decodeTree:n}=this,r=n[this.treeIndex],i=(r&UQ.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){let a=e.charCodeAt(t);if(this.treeIndex=QQ(n,r,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===YQ.Attribute&&(i===0||qQ(a))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],i=(r&UQ.VALUE_LENGTH)>>14,i!==0){if(a===VQ.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==YQ.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;let{result:t,decodeTree:n}=this,r=(n[t]&UQ.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,r,this.consumed),(e=this.errors)==null||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){let{decodeTree:r}=this;return this.emitCodePoint(t===1?r[e]&~UQ.VALUE_LENGTH:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case JQ.NamedEntity:return this.result!==0&&(this.decodeMode!==YQ.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case JQ.NumericDecimal:return this.emitNumericEntity(0,2);case JQ.NumericHex:return this.emitNumericEntity(0,3);case JQ.NumericStart:return(e=this.errors)==null||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case JQ.EntityStart:return 0}}};function ZQ(e){let t=``,n=new XQ(e,e=>t+=zQ(e));return function(e,r){let i=0,a=0;for(;(a=e.indexOf(`&`,a))>=0;){t+=e.slice(i,a),n.startEntity(r);let o=n.write(e,a+1);if(o<0){i=a+n.end();break}i=a+o,a=o===0?i+1:i}let o=t+e.slice(i);return t=``,o}}function QQ(e,t,n,r){let i=(t&UQ.BRANCH_LENGTH)>>7,a=t&UQ.JUMP_TABLE;if(i===0)return a!==0&&r===a?n:-1;if(a){let t=r-a;return t<0||t>=i?-1:e[n+t]-1}let o=n,s=o+i-1;for(;o<=s;){let t=o+s>>>1,n=e[t];if(n<r)o=t+1;else if(n>r)s=t-1;else return e[t+i]}return-1}var $Q=ZQ(IQ);ZQ(LQ);function e$(e,t=YQ.Legacy){return $Q(e,t)}function t$(e){return $Q(e,YQ.Strict)}var n$=t({arrayReplaceAt:()=>c$,asciiTrim:()=>j$,assign:()=>s$,escapeHtml:()=>x$,escapeRE:()=>C$,fromCodePoint:()=>u$,has:()=>o$,isMdAsciiPunct:()=>O$,isPunctChar:()=>E$,isPunctCharCode:()=>D$,isSpace:()=>w$,isString:()=>i$,isValidEntityCode:()=>l$,isWhiteSpace:()=>T$,lib:()=>M$,normalizeReference:()=>k$,unescapeAll:()=>g$,unescapeMd:()=>h$});function r$(e){return Object.prototype.toString.call(e)}function i$(e){return r$(e)===`[object String]`}var a$=Object.prototype.hasOwnProperty;function o$(e,t){return a$.call(e,t)}function s$(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){if(t){if(typeof t!=`object`)throw TypeError(t+`must be object`);Object.keys(t).forEach(function(n){e[n]=t[n]})}}),e}function c$(e,t,n){return[].concat(e.slice(0,t),n,e.slice(t+1))}function l$(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534||e>=0&&e<=8||e===11||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function u$(e){if(e>65535){e-=65536;let t=55296+(e>>10),n=56320+(e&1023);return String.fromCharCode(t,n)}return String.fromCharCode(e)}var d$=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,f$=RegExp(d$.source+`|&([a-z#][a-z0-9]{1,31});`,`gi`),p$=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function m$(e,t){if(t.charCodeAt(0)===35&&p$.test(t)){let n=t[1].toLowerCase()===`x`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return l$(n)?u$(n):e}let n=e$(e);return n===e?e:n}function h$(e){return e.indexOf(`\\`)<0?e:e.replace(d$,`$1`)}function g$(e){return e.indexOf(`\\`)<0&&e.indexOf(`&`)<0?e:e.replace(f$,function(e,t,n){return t||m$(e,n)})}var _$=/[&<>"]/,v$=/[&<>"]/g,y$={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`};function b$(e){return y$[e]}function x$(e){return _$.test(e)?e.replace(v$,b$):e}var S$=/[.?*+^$[\]\\(){}|-]/g;function C$(e){return e.replace(S$,`\\$&`)}function w$(e){switch(e){case 9:case 32:return!0}return!1}function T$(e){if(e>=8192&&e<=8202)return!0;switch(e){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 E$(e){return MQ.test(e)||NQ.test(e)}function D$(e){return E$(u$(e))}function O$(e){switch(e){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 k$(e){return e=e.trim().replace(/\s+/g,` `),e.toLowerCase().toUpperCase()}function A$(e){return e===32||e===9||e===10||e===13}function j$(e){let t=0;for(;t<e.length&&A$(e.charCodeAt(t));t++);let n=e.length-1;for(;n>=t&&A$(e.charCodeAt(n));n--);return e.slice(t,n+1)}var M$={mdurl:OQ,ucmicro:FQ};function N$(e,t,n){let r,i,a,o,s=e.posMax,c=e.pos;for(e.pos=t+1,r=1;e.pos<s;){if(a=e.src.charCodeAt(e.pos),a===93&&(r--,r===0)){i=!0;break}if(o=e.pos,e.md.inline.skipToken(e),a===91){if(o===e.pos-1)r++;else if(n)return e.pos=c,-1}}let l=-1;return i&&(l=e.pos),e.pos=c,l}function P$(e,t,n){let r,i=t,a={ok:!1,pos:0,str:``};if(e.charCodeAt(i)===60){for(i++;i<n;){if(r=e.charCodeAt(i),r===10||r===60)return a;if(r===62)return a.pos=i+1,a.str=g$(e.slice(t+1,i)),a.ok=!0,a;if(r===92&&i+1<n){i+=2;continue}i++}return a}let o=0;for(;i<n&&(r=e.charCodeAt(i),!(r===32||r<32||r===127));){if(r===92&&i+1<n){if(e.charCodeAt(i+1)===32)break;i+=2;continue}if(r===40&&(o++,o>32))return a;if(r===41){if(o===0)break;o--}i++}return t===i||o!==0?a:(a.str=g$(e.slice(t,i)),a.pos=i,a.ok=!0,a)}function F$(e,t,n,r){let i,a=t,o={ok:!1,can_continue:!1,pos:0,str:``,marker:0};if(r)o.str=r.str,o.marker=r.marker;else{if(a>=n)return o;let r=e.charCodeAt(a);if(r!==34&&r!==39&&r!==40)return o;t++,a++,r===40&&(r=41),o.marker=r}for(;a<n;){if(i=e.charCodeAt(a),i===o.marker)return o.pos=a+1,o.str+=g$(e.slice(t,a)),o.ok=!0,o;if(i===40&&o.marker===41)return o;i===92&&a+1<n&&a++,a++}return o.can_continue=!0,o.str+=g$(e.slice(t,a)),o}var I$=t({parseLinkDestination:()=>P$,parseLinkLabel:()=>N$,parseLinkTitle:()=>F$}),L$={};L$.code_inline=function(e,t,n,r,i){let a=e[t];return`<code`+i.renderAttrs(a)+`>`+x$(a.content)+`</code>`},L$.code_block=function(e,t,n,r,i){let a=e[t];return`<pre`+i.renderAttrs(a)+`><code>`+x$(e[t].content)+`</code></pre>
225
+ `},L$.fence=function(e,t,n,r,i){let a=e[t],o=a.info?g$(a.info).trim():``,s=``,c=``;if(o){let e=o.split(/(\s+)/g);s=e[0],c=e.slice(2).join(``)}let l;if(l=n.highlight&&n.highlight(a.content,s,c)||x$(a.content),l.indexOf(`<pre`)===0)return l+`
226
+ `;if(o){let e=a.attrIndex(`class`),t=a.attrs?a.attrs.slice():[];e<0?t.push([`class`,n.langPrefix+s]):(t[e]=t[e].slice(),t[e][1]+=` `+n.langPrefix+s);let r={attrs:t};return`<pre><code${i.renderAttrs(r)}>${l}</code></pre>\n`}return`<pre><code${i.renderAttrs(a)}>${l}</code></pre>\n`},L$.image=function(e,t,n,r,i){let a=e[t];return a.attrs[a.attrIndex(`alt`)][1]=i.renderInlineAsText(a.children,n,r),i.renderToken(e,t,n)},L$.hardbreak=function(e,t,n){return n.xhtmlOut?`<br />
227
+ `:`<br>
228
+ `},L$.softbreak=function(e,t,n){return n.breaks?n.xhtmlOut?`<br />
229
+ `:`<br>
230
+ `:`
231
+ `},L$.text=function(e,t){return x$(e[t].content)},L$.html_block=function(e,t){return e[t].content},L$.html_inline=function(e,t){return e[t].content};function R$(){this.rules=s$({},L$)}R$.prototype.renderAttrs=function(e){let t,n,r;if(!e.attrs)return``;for(r=``,t=0,n=e.attrs.length;t<n;t++)r+=` `+x$(e.attrs[t][0])+`="`+x$(e.attrs[t][1])+`"`;return r},R$.prototype.renderToken=function(e,t,n){let r=e[t],i=``;if(r.hidden)return``;r.block&&r.nesting!==-1&&t&&e[t-1].hidden&&(i+=`
232
+ `),i+=(r.nesting===-1?`</`:`<`)+r.tag,i+=this.renderAttrs(r),r.nesting===0&&n.xhtmlOut&&(i+=` /`);let a=!1;if(r.block&&(a=!0,r.nesting===1&&t+1<e.length)){let n=e[t+1];(n.type===`inline`||n.hidden||n.nesting===-1&&n.tag===r.tag)&&(a=!1)}return i+=a?`>
233
+ `:`>`,i},R$.prototype.renderInline=function(e,t,n){let r=``,i=this.rules;for(let a=0,o=e.length;a<o;a++){let o=e[a].type;i[o]===void 0?r+=this.renderToken(e,a,t):r+=i[o](e,a,t,n,this)}return r},R$.prototype.renderInlineAsText=function(e,t,n){let r=``;for(let i=0,a=e.length;i<a;i++)switch(e[i].type){case`text`:r+=e[i].content;break;case`image`:r+=this.renderInlineAsText(e[i].children,t,n);break;case`html_inline`:case`html_block`:r+=e[i].content;break;case`softbreak`:case`hardbreak`:r+=`
234
+ `;break;default:}return r},R$.prototype.render=function(e,t,n){let r=``,i=this.rules;for(let a=0,o=e.length;a<o;a++){let o=e[a].type;o===`inline`?r+=this.renderInline(e[a].children,t,n):i[o]===void 0?r+=this.renderToken(e,a,t,n):r+=i[o](e,a,t,n,this)}return r};function z$(){this.__rules__=[],this.__cache__=null}z$.prototype.__find__=function(e){for(let t=0;t<this.__rules__.length;t++)if(this.__rules__[t].name===e)return t;return-1},z$.prototype.__compile__=function(){let e=this,t=[``];e.__rules__.forEach(function(e){e.enabled&&e.alt.forEach(function(e){t.indexOf(e)<0&&t.push(e)})}),e.__cache__={},t.forEach(function(t){e.__cache__[t]=[],e.__rules__.forEach(function(n){n.enabled&&(t&&n.alt.indexOf(t)<0||e.__cache__[t].push(n.fn))})})},z$.prototype.at=function(e,t,n){let r=this.__find__(e),i=n||{};if(r===-1)throw Error(`Parser rule not found: `+e);this.__rules__[r].fn=t,this.__rules__[r].alt=i.alt||[],this.__cache__=null},z$.prototype.before=function(e,t,n,r){let i=this.__find__(e),a=r||{};if(i===-1)throw Error(`Parser rule not found: `+e);this.__rules__.splice(i,0,{name:t,enabled:!0,fn:n,alt:a.alt||[]}),this.__cache__=null},z$.prototype.after=function(e,t,n,r){let i=this.__find__(e),a=r||{};if(i===-1)throw Error(`Parser rule not found: `+e);this.__rules__.splice(i+1,0,{name:t,enabled:!0,fn:n,alt:a.alt||[]}),this.__cache__=null},z$.prototype.push=function(e,t,n){let r=n||{};this.__rules__.push({name:e,enabled:!0,fn:t,alt:r.alt||[]}),this.__cache__=null},z$.prototype.enable=function(e,t){Array.isArray(e)||(e=[e]);let n=[];return e.forEach(function(e){let r=this.__find__(e);if(r<0){if(t)return;throw Error(`Rules manager: invalid rule name `+e)}this.__rules__[r].enabled=!0,n.push(e)},this),this.__cache__=null,n},z$.prototype.enableOnly=function(e,t){Array.isArray(e)||(e=[e]),this.__rules__.forEach(function(e){e.enabled=!1}),this.enable(e,t)},z$.prototype.disable=function(e,t){Array.isArray(e)||(e=[e]);let n=[];return e.forEach(function(e){let r=this.__find__(e);if(r<0){if(t)return;throw Error(`Rules manager: invalid rule name `+e)}this.__rules__[r].enabled=!1,n.push(e)},this),this.__cache__=null,n},z$.prototype.getRules=function(e){return this.__cache__===null&&this.__compile__(),this.__cache__[e]||[]};function B$(e,t,n){this.type=e,this.tag=t,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}B$.prototype.attrIndex=function(e){if(!this.attrs)return-1;let t=this.attrs;for(let n=0,r=t.length;n<r;n++)if(t[n][0]===e)return n;return-1},B$.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]},B$.prototype.attrSet=function(e,t){let n=this.attrIndex(e),r=[e,t];n<0?this.attrPush(r):this.attrs[n]=r},B$.prototype.attrGet=function(e){let t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n},B$.prototype.attrJoin=function(e,t){let n=this.attrIndex(e);n<0?this.attrPush([e,t]):this.attrs[n][1]=this.attrs[n][1]+` `+t};function V$(e,t,n){this.src=e,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=t}V$.prototype.Token=B$;var H$=/\r\n?|\n/g,U$=/\0/g;function W$(e){let t;t=e.src.replace(H$,`
235
+ `),t=t.replace(U$,`�`),e.src=t}function G$(e){let t;e.inlineMode?(t=new e.Token(`inline`,``,0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}function K$(e){let t=e.tokens;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.type===`inline`&&e.md.inline.parse(r.content,e.md,e.env,r.children)}}function q$(e){return/^<a[>\s]/i.test(e)}function J$(e){return/^<\/a\s*>/i.test(e)}function Y$(e){let t=e.tokens;if(e.md.options.linkify)for(let n=0,r=t.length;n<r;n++){if(t[n].type!==`inline`||!e.md.linkify.pretest(t[n].content))continue;let r=t[n].children,i=0;for(let a=r.length-1;a>=0;a--){let o=r[a];if(o.type===`link_close`){for(a--;r[a].level!==o.level&&r[a].type!==`link_open`;)a--;continue}if(o.type===`html_inline`&&(q$(o.content)&&i>0&&i--,J$(o.content)&&i++),!(i>0)&&o.type===`text`&&e.md.linkify.test(o.content)){let i=o.content,s=e.md.linkify.match(i),c=[],l=o.level,u=0;s.length>0&&s[0].index===0&&a>0&&r[a-1].type===`text_special`&&(s=s.slice(1));for(let t=0;t<s.length;t++){let n=s[t].url,r=e.md.normalizeLink(n);if(!e.md.validateLink(r))continue;let a=s[t].text;a=s[t].schema?s[t].schema===`mailto:`&&!/^mailto:/i.test(a)?e.md.normalizeLinkText(`mailto:`+a).replace(/^mailto:/,``):e.md.normalizeLinkText(a):e.md.normalizeLinkText(`http://`+a).replace(/^http:\/\//,``);let o=s[t].index;if(o>u){let t=new e.Token(`text`,``,0);t.content=i.slice(u,o),t.level=l,c.push(t)}let d=new e.Token(`link_open`,`a`,1);d.attrs=[[`href`,r]],d.level=l++,d.markup=`linkify`,d.info=`auto`,c.push(d);let f=new e.Token(`text`,``,0);f.content=a,f.level=l,c.push(f);let p=new e.Token(`link_close`,`a`,-1);p.level=--l,p.markup=`linkify`,p.info=`auto`,c.push(p),u=s[t].lastIndex}if(u<i.length){let t=new e.Token(`text`,``,0);t.content=i.slice(u),t.level=l,c.push(t)}t[n].children=r=c$(r,a,c)}}}}var X$=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Z$=/\((c|tm|r)\)/i,Q$=/\((c|tm|r)\)/gi,$$={c:`©`,r:`®`,tm:`™`};function e1(e,t){return $$[t.toLowerCase()]}function t1(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&(r.content=r.content.replace(Q$,e1)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function n1(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&X$.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(/(^|[^-])---(?=[^-]|$)/gm,`$1—`).replace(/(^|\s)--(?=\s|$)/gm,`$1–`).replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,`$1–`)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function r1(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type===`inline`&&(Z$.test(e.tokens[t].content)&&t1(e.tokens[t].children),X$.test(e.tokens[t].content)&&n1(e.tokens[t].children))}var i1=/['"]/,a1=/['"]/g,o1=`’`;function s1(e,t,n,r){e[t]||(e[t]=[]),e[t].push({pos:n,ch:r})}function c1(e,t){let n=``,r=0;t.sort((e,t)=>e.pos-t.pos);for(let i=0;i<t.length;i++){let a=t[i];n+=e.slice(r,a.pos)+a.ch,r=a.pos+1}return n+e.slice(r)}function l1(e,t){let n,r=[],i={};for(let a=0;a<e.length;a++){let o=e[a],s=e[a].level;for(n=r.length-1;n>=0&&!(r[n].level<=s);n--);if(r.length=n+1,o.type!==`text`)continue;let c=o.content,l=0,u=c.length;OUTER:for(;l<u;){a1.lastIndex=l;let o=a1.exec(c);if(!o)break;let d=!0,f=!0;l=o.index+1;let p=o[0]===`'`,m=32;if(o.index-1>=0)m=c.charCodeAt(o.index-1);else for(n=a-1;n>=0&&!(e[n].type===`softbreak`||e[n].type===`hardbreak`);n--)if(e[n].content){m=e[n].content.charCodeAt(e[n].content.length-1);break}let h=32;if(l<u)h=c.charCodeAt(l);else for(n=a+1;n<e.length&&!(e[n].type===`softbreak`||e[n].type===`hardbreak`);n++)if(e[n].content){h=e[n].content.charCodeAt(0);break}let g=O$(m)||D$(m),_=O$(h)||D$(h),v=T$(m),y=T$(h);if(y?d=!1:_&&(v||g||(d=!1)),v?f=!1:g&&(y||_||(f=!1)),h===34&&o[0]===`"`&&m>=48&&m<=57&&(f=d=!1),d&&f&&(d=g,f=_),!d&&!f){p&&s1(i,a,o.index,o1);continue}if(f)for(n=r.length-1;n>=0;n--){let e=r[n];if(r[n].level<s)break;if(e.single===p&&r[n].level===s){e=r[n];let s,c;p?(s=t.md.options.quotes[2],c=t.md.options.quotes[3]):(s=t.md.options.quotes[0],c=t.md.options.quotes[1]),s1(i,a,o.index,c),s1(i,e.token,e.pos,s),r.length=n;continue OUTER}}d?r.push({token:a,pos:o.index,single:p,level:s}):f&&p&&s1(i,a,o.index,o1)}}Object.keys(i).forEach(function(t){e[t].content=c1(e[t].content,i[t])})}function u1(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!==`inline`||!i1.test(e.tokens[t].content)||l1(e.tokens[t].children,e)}function d1(e){let t,n,r=e.tokens,i=r.length;for(let e=0;e<i;e++){if(r[e].type!==`inline`)continue;let i=r[e].children,a=i.length;for(t=0;t<a;t++)i[t].type===`text_special`&&(i[t].type=`text`);for(t=n=0;t<a;t++)i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}}var f1=[[`normalize`,W$],[`block`,G$],[`inline`,K$],[`linkify`,Y$],[`replacements`,r1],[`smartquotes`,u1],[`text_join`,d1]];function p1(){this.ruler=new z$;for(let e=0;e<f1.length;e++)this.ruler.push(f1[e][0],f1[e][1])}p1.prototype.process=function(e){let t=this.ruler.getRules(``);for(let n=0,r=t.length;n<r;n++)t[n](e)},p1.prototype.State=V$;function m1(e,t,n,r){this.src=e,this.md=t,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;let i=this.src;for(let e=0,t=0,n=0,r=0,a=i.length,o=!1;t<a;t++){let s=i.charCodeAt(t);if(!o)if(w$(s)){n++,s===9?r+=4-r%4:r++;continue}else o=!0;(s===10||t===a-1)&&(s!==10&&t++,this.bMarks.push(e),this.eMarks.push(t),this.tShift.push(n),this.sCount.push(r),this.bsCount.push(0),o=!1,n=0,r=0,e=t+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}m1.prototype.push=function(e,t,n){let r=new B$(e,t,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r},m1.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]},m1.prototype.skipEmptyLines=function(e){for(let t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e},m1.prototype.skipSpaces=function(e){for(let t=this.src.length;e<t&&w$(this.src.charCodeAt(e));e++);return e},m1.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!w$(this.src.charCodeAt(--e)))return e+1;return e},m1.prototype.skipChars=function(e,t){for(let n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e},m1.prototype.skipCharsBack=function(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e},m1.prototype.getLines=function(e,t,n,r){if(e>=t)return``;let i=Array(t-e);for(let a=0,o=e;o<t;o++,a++){let e=0,s=this.bMarks[o],c=s,l;for(l=o+1<t||r?this.eMarks[o]+1:this.eMarks[o];c<l&&e<n;){let t=this.src.charCodeAt(c);if(w$(t))t===9?e+=4-(e+this.bsCount[o])%4:e++;else if(c-s<this.tShift[o])e++;else break;c++}e>n?i[a]=Array(e-n+1).join(` `)+this.src.slice(c,l):i[a]=this.src.slice(c,l)}return i.join(``)},m1.prototype.Token=B$;var h1=65536;function g1(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(n,r)}function _1(e){let t=[],n=e.length,r=0,i=e.charCodeAt(r),a=!1,o=0,s=``;for(;r<n;)i===124&&(a?(s+=e.substring(o,r-1),o=r):(t.push(s+e.substring(o,r)),s=``,o=r+1)),a=i===92,r++,i=e.charCodeAt(r);return t.push(s+e.substring(o)),t}function v1(e,t,n,r){if(t+2>n)return!1;let i=t+1;if(e.sCount[i]<e.blkIndent||e.sCount[i]-e.blkIndent>=4)return!1;let a=e.bMarks[i]+e.tShift[i];if(a>=e.eMarks[i])return!1;let o=e.src.charCodeAt(a++);if(o!==124&&o!==45&&o!==58||a>=e.eMarks[i])return!1;let s=e.src.charCodeAt(a++);if(s!==124&&s!==45&&s!==58&&!w$(s)||o===45&&w$(s))return!1;for(;a<e.eMarks[i];){let t=e.src.charCodeAt(a);if(t!==124&&t!==45&&t!==58&&!w$(t))return!1;a++}let c=g1(e,t+1),l=c.split(`|`),u=[];for(let e=0;e<l.length;e++){let t=l[e].trim();if(!t){if(e===0||e===l.length-1)continue;return!1}if(!/^:?-+:?$/.test(t))return!1;t.charCodeAt(t.length-1)===58?u.push(t.charCodeAt(0)===58?`center`:`right`):t.charCodeAt(0)===58?u.push(`left`):u.push(``)}if(c=g1(e,t).trim(),c.indexOf(`|`)===-1||e.sCount[t]-e.blkIndent>=4)return!1;l=_1(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop();let d=l.length;if(d===0||d!==u.length)return!1;if(r)return!0;let f=e.parentType;e.parentType=`table`;let p=e.md.block.ruler.getRules(`blockquote`),m=e.push(`table_open`,`table`,1),h=[t,0];m.map=h;let g=e.push(`thead_open`,`thead`,1);g.map=[t,t+1];let _=e.push(`tr_open`,`tr`,1);_.map=[t,t+1];for(let t=0;t<l.length;t++){let n=e.push(`th_open`,`th`,1);u[t]&&(n.attrs=[[`style`,`text-align:`+u[t]]]);let r=e.push(`inline`,``,0);r.content=l[t].trim(),r.children=[],e.push(`th_close`,`th`,-1)}e.push(`tr_close`,`tr`,-1),e.push(`thead_close`,`thead`,-1);let v,y=0;for(i=t+2;i<n&&!(e.sCount[i]<e.blkIndent);i++){let r=!1;for(let t=0,a=p.length;t<a;t++)if(p[t](e,i,n,!0)){r=!0;break}if(r||(c=g1(e,i).trim(),!c)||e.sCount[i]-e.blkIndent>=4||(l=_1(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop(),y+=d-l.length,y>h1))break;if(i===t+2){let n=e.push(`tbody_open`,`tbody`,1);n.map=v=[t+2,0]}let a=e.push(`tr_open`,`tr`,1);a.map=[i,i+1];for(let t=0;t<d;t++){let n=e.push(`td_open`,`td`,1);u[t]&&(n.attrs=[[`style`,`text-align:`+u[t]]]);let r=e.push(`inline`,``,0);r.content=l[t]?l[t].trim():``,r.children=[],e.push(`td_close`,`td`,-1)}e.push(`tr_close`,`tr`,-1)}return v&&(e.push(`tbody_close`,`tbody`,-1),v[1]=i),e.push(`table_close`,`table`,-1),h[1]=i,e.parentType=f,e.line=i,!0}function y1(e,t,n){if(e.sCount[t]-e.blkIndent<4)return!1;let r=t+1,i=r;for(;r<n;){if(e.isEmpty(r)){r++;continue}if(e.sCount[r]-e.blkIndent>=4){r++,i=r;continue}break}e.line=i;let a=e.push(`code_block`,`code`,0);return a.content=e.getLines(t,i,4+e.blkIndent,!1)+`
236
+ `,a.map=[t,e.line],!0}function b1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||i+3>a)return!1;let o=e.src.charCodeAt(i);if(o!==126&&o!==96)return!1;let s=i;i=e.skipChars(i,o);let c=i-s;if(c<3)return!1;let l=e.src.slice(s,i),u=e.src.slice(i,a);if(o===96&&u.indexOf(String.fromCharCode(o))>=0)return!1;if(r)return!0;let d=t,f=!1;for(;d++,!(d>=n||(i=s=e.bMarks[d]+e.tShift[d],a=e.eMarks[d],i<a&&e.sCount[d]<e.blkIndent));)if(e.src.charCodeAt(i)===o&&!(e.sCount[d]-e.blkIndent>=4)&&(i=e.skipChars(i,o),!(i-s<c)&&(i=e.skipSpaces(i),!(i<a)))){f=!0;break}c=e.sCount[t],e.line=d+ +!!f;let p=e.push(`fence`,`code`,0);return p.info=u,p.content=e.getLines(t+1,d,c,!0),p.markup=l,p.map=[t,e.line],!0}function x1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o=e.lineMax;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==62)return!1;if(r)return!0;let s=[],c=[],l=[],u=[],d=e.md.block.ruler.getRules(`blockquote`),f=e.parentType;e.parentType=`blockquote`;let p=!1,m;for(m=t;m<n;m++){let t=e.sCount[m]<e.blkIndent;if(i=e.bMarks[m]+e.tShift[m],a=e.eMarks[m],i>=a)break;if(e.src.charCodeAt(i++)===62&&!t){let t=e.sCount[m]+1,n,r;e.src.charCodeAt(i)===32?(i++,t++,r=!1,n=!0):e.src.charCodeAt(i)===9?(n=!0,(e.bsCount[m]+t)%4==3?(i++,t++,r=!1):r=!0):n=!1;let o=t;for(s.push(e.bMarks[m]),e.bMarks[m]=i;i<a;){let t=e.src.charCodeAt(i);if(w$(t))t===9?o+=4-(o+e.bsCount[m]+ +!!r)%4:o++;else break;i++}p=i>=a,c.push(e.bsCount[m]),e.bsCount[m]=e.sCount[m]+1+ +!!n,l.push(e.sCount[m]),e.sCount[m]=o-t,u.push(e.tShift[m]),e.tShift[m]=i-e.bMarks[m];continue}if(p)break;let r=!1;for(let t=0,i=d.length;t<i;t++)if(d[t](e,m,n,!0)){r=!0;break}if(r){e.lineMax=m,e.blkIndent!==0&&(s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]-=e.blkIndent);break}s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]=-1}let h=e.blkIndent;e.blkIndent=0;let g=e.push(`blockquote_open`,`blockquote`,1);g.markup=`>`;let _=[t,0];g.map=_,e.md.block.tokenize(e,t,m);let v=e.push(`blockquote_close`,`blockquote`,-1);v.markup=`>`,e.lineMax=o,e.parentType=f,_[1]=e.line;for(let n=0;n<u.length;n++)e.bMarks[n+t]=s[n],e.tShift[n+t]=u[n],e.sCount[n+t]=l[n],e.bsCount[n+t]=c[n];return e.blkIndent=h,!0}function S1(e,t,n,r){let i=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let a=e.bMarks[t]+e.tShift[t],o=e.src.charCodeAt(a++);if(o!==42&&o!==45&&o!==95)return!1;let s=1;for(;a<i;){let t=e.src.charCodeAt(a++);if(t!==o&&!w$(t))return!1;t===o&&s++}if(s<3)return!1;if(r)return!0;e.line=t+1;let c=e.push(`hr`,`hr`,0);return c.map=[t,e.line],c.markup=Array(s+1).join(String.fromCharCode(o)),!0}function C1(e,t){let n=e.eMarks[t],r=e.bMarks[t]+e.tShift[t],i=e.src.charCodeAt(r++);return i!==42&&i!==45&&i!==43||r<n&&!w$(e.src.charCodeAt(r))?-1:r}function w1(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t],i=n;if(i+1>=r)return-1;let a=e.src.charCodeAt(i++);if(a<48||a>57)return-1;for(;;){if(i>=r)return-1;if(a=e.src.charCodeAt(i++),a>=48&&a<=57){if(i-n>=10)return-1;continue}if(a===41||a===46)break;return-1}return i<r&&(a=e.src.charCodeAt(i),!w$(a))?-1:i}function T1(e,t){let n=e.level+2;for(let r=t+2,i=e.tokens.length-2;r<i;r++)e.tokens[r].level===n&&e.tokens[r].type===`paragraph_open`&&(e.tokens[r+2].hidden=!0,e.tokens[r].hidden=!0,r+=2)}function E1(e,t,n,r){let i,a,o,s,c=t,l=!0;if(e.sCount[c]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[c]-e.listIndent>=4&&e.sCount[c]<e.blkIndent)return!1;let u=!1;r&&e.parentType===`paragraph`&&e.sCount[c]>=e.blkIndent&&(u=!0);let d,f,p;if((p=w1(e,c))>=0){if(d=!0,o=e.bMarks[c]+e.tShift[c],f=Number(e.src.slice(o,p-1)),u&&f!==1)return!1}else if((p=C1(e,c))>=0)d=!1;else return!1;if(u&&e.skipSpaces(p)>=e.eMarks[c])return!1;if(r)return!0;let m=e.src.charCodeAt(p-1),h=e.tokens.length;d?(s=e.push(`ordered_list_open`,`ol`,1),f!==1&&(s.attrs=[[`start`,f]])):s=e.push(`bullet_list_open`,`ul`,1);let g=[c,0];s.map=g,s.markup=String.fromCharCode(m);let _=!1,v=e.md.block.ruler.getRules(`list`),y=e.parentType;for(e.parentType=`list`;c<n;){a=p,i=e.eMarks[c];let t=e.sCount[c]+p-(e.bMarks[c]+e.tShift[c]),r=t;for(;a<i;){let t=e.src.charCodeAt(a);if(t===9)r+=4-(r+e.bsCount[c])%4;else if(t===32)r++;else break;a++}let u=a,f;f=u>=i?1:r-t,f>4&&(f=1);let h=t+f;s=e.push(`list_item_open`,`li`,1),s.markup=String.fromCharCode(m);let g=[c,0];s.map=g,d&&(s.info=e.src.slice(o,p-1));let y=e.tight,b=e.tShift[c],x=e.sCount[c],S=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=h,e.tight=!0,e.tShift[c]=u-e.bMarks[c],e.sCount[c]=r,u>=i&&e.isEmpty(c+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,c,n,!0),(!e.tight||_)&&(l=!1),_=e.line-c>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=S,e.tShift[c]=b,e.sCount[c]=x,e.tight=y,s=e.push(`list_item_close`,`li`,-1),s.markup=String.fromCharCode(m),c=e.line,g[1]=c,c>=n||e.sCount[c]<e.blkIndent||e.sCount[c]-e.blkIndent>=4)break;let ee=!1;for(let t=0,r=v.length;t<r;t++)if(v[t](e,c,n,!0)){ee=!0;break}if(ee)break;if(d){if(p=w1(e,c),p<0)break;o=e.bMarks[c]+e.tShift[c]}else if(p=C1(e,c),p<0)break;if(m!==e.src.charCodeAt(p-1))break}return s=d?e.push(`ordered_list_close`,`ol`,-1):e.push(`bullet_list_close`,`ul`,-1),s.markup=String.fromCharCode(m),g[1]=c,e.line=c,e.parentType=y,l&&T1(e,h),!0}function D1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==91)return!1;function s(t){let n=e.lineMax;if(t>=n||e.isEmpty(t))return null;let r=!1;if(e.sCount[t]-e.blkIndent>3&&(r=!0),e.sCount[t]<0&&(r=!0),!r){let r=e.md.block.ruler.getRules(`reference`),i=e.parentType;e.parentType=`reference`;let a=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,t,n,!0)){a=!0;break}if(e.parentType=i,a)return null}let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];return e.src.slice(i,a+1)}let c=e.src.slice(i,a+1);a=c.length;let l=-1;for(i=1;i<a;i++){let e=c.charCodeAt(i);if(e===91)return!1;if(e===93){l=i;break}else if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(e===92&&(i++,i<a&&c.charCodeAt(i)===10)){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}}if(l<0||c.charCodeAt(l+1)!==58)return!1;for(i=l+2;i<a;i++){let e=c.charCodeAt(i);if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(!w$(e))break}let u=e.md.helpers.parseLinkDestination(c,i,a);if(!u.ok)return!1;let d=e.md.normalizeLink(u.str);if(!e.md.validateLink(d))return!1;i=u.pos;let f=i,p=o,m=i;for(;i<a;i++){let e=c.charCodeAt(i);if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(!w$(e))break}let h=e.md.helpers.parseLinkTitle(c,i,a);for(;h.can_continue;){let t=s(o);if(t===null)break;c+=t,i=a,a=c.length,o++,h=e.md.helpers.parseLinkTitle(c,i,a,h)}let g;for(i<a&&m!==i&&h.ok?(g=h.str,i=h.pos):(g=``,i=f,o=p);i<a&&w$(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10&&g)for(g=``,i=f,o=p;i<a&&w$(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10)return!1;let _=k$(c.slice(1,l));return _?r?!0:(e.env.references===void 0&&(e.env.references={}),e.env.references[_]===void 0&&(e.env.references[_]={title:g,href:d}),e.line=o,!0):!1}var O1=`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`.split(`.`),k1=RegExp(`^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)`),A1=RegExp(`^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>)`),j1=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[RegExp(`^</?(`+O1.join(`|`)+`)(?=(\\s|/?>|$))`,`i`),/^$/,!0],[RegExp(A1.source+`\\s*$`),/^$/,!1]];function M1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(i)!==60)return!1;let o=e.src.slice(i,a),s=0;for(;s<j1.length&&!j1[s][0].test(o);s++);if(s===j1.length)return!1;if(r)return j1[s][2];let c=t+1,l=j1[s][1].test(``);if(!j1[s][1].test(o)){for(;c<n&&!(e.sCount[c]<e.blkIndent&&(l||!e.isEmpty(c)));c++)if(i=e.bMarks[c]+e.tShift[c],a=e.eMarks[c],o=e.src.slice(i,a),j1[s][1].test(o)){o.length!==0&&c++;break}}e.line=c;let u=e.push(`html_block`,``,0);return u.map=[t,c],u.content=e.getLines(t,c,e.blkIndent,!0),!0}function N1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let o=e.src.charCodeAt(i);if(o!==35||i>=a)return!1;let s=1;for(o=e.src.charCodeAt(++i);o===35&&i<a&&s<=6;)s++,o=e.src.charCodeAt(++i);if(s>6||i<a&&!w$(o))return!1;if(r)return!0;a=e.skipSpacesBack(a,i);let c=e.skipCharsBack(a,35,i);c>i&&w$(e.src.charCodeAt(c-1))&&(a=c),e.line=t+1;let l=e.push(`heading_open`,`h`+String(s),1);l.markup=`########`.slice(0,s),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=j$(e.src.slice(i,a)),u.map=[t,e.line],u.children=[];let d=e.push(`heading_close`,`h`+String(s),-1);return d.markup=`########`.slice(0,s),!0}function P1(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`);if(e.sCount[t]-e.blkIndent>=4)return!1;let i=e.parentType;e.parentType=`paragraph`;let a=0,o,s=t+1;for(;s<n&&!e.isEmpty(s);s++){if(e.sCount[s]-e.blkIndent>3)continue;if(e.sCount[s]>=e.blkIndent){let t=e.bMarks[s]+e.tShift[s],n=e.eMarks[s];if(t<n&&(o=e.src.charCodeAt(t),(o===45||o===61)&&(t=e.skipChars(t,o),t=e.skipSpaces(t),t>=n))){a=o===61?1:2;break}}if(e.sCount[s]<0)continue;let t=!1;for(let i=0,a=r.length;i<a;i++)if(r[i](e,s,n,!0)){t=!0;break}if(t)break}if(!a)return e.parentType=i,!1;let c=j$(e.getLines(t,s,e.blkIndent,!1));e.line=s+1;let l=e.push(`heading_open`,`h`+String(a),1);l.markup=String.fromCharCode(o),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=c,u.map=[t,e.line-1],u.children=[];let d=e.push(`heading_close`,`h`+String(a),-1);return d.markup=String.fromCharCode(o),e.parentType=i,!0}function F1(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`),i=e.parentType,a=t+1;for(e.parentType=`paragraph`;a<n&&!e.isEmpty(a);a++){if(e.sCount[a]-e.blkIndent>3||e.sCount[a]<0)continue;let t=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,a,n,!0)){t=!0;break}if(t)break}let o=j$(e.getLines(t,a,e.blkIndent,!1));e.line=a;let s=e.push(`paragraph_open`,`p`,1);s.map=[t,e.line];let c=e.push(`inline`,``,0);return c.content=o,c.map=[t,e.line],c.children=[],e.push(`paragraph_close`,`p`,-1),e.parentType=i,!0}var I1=[[`table`,v1,[`paragraph`,`reference`]],[`code`,y1],[`fence`,b1,[`paragraph`,`reference`,`blockquote`,`list`]],[`blockquote`,x1,[`paragraph`,`reference`,`blockquote`,`list`]],[`hr`,S1,[`paragraph`,`reference`,`blockquote`,`list`]],[`list`,E1,[`paragraph`,`reference`,`blockquote`]],[`reference`,D1],[`html_block`,M1,[`paragraph`,`reference`,`blockquote`]],[`heading`,N1,[`paragraph`,`reference`,`blockquote`]],[`lheading`,P1],[`paragraph`,F1]];function L1(){this.ruler=new z$;for(let e=0;e<I1.length;e++)this.ruler.push(I1[e][0],I1[e][1],{alt:(I1[e][2]||[]).slice()})}L1.prototype.tokenize=function(e,t,n){let r=this.ruler.getRules(``),i=r.length,a=e.md.options.maxNesting,o=t,s=!1;for(;o<n&&(e.line=o=e.skipEmptyLines(o),!(o>=n||e.sCount[o]<e.blkIndent));){if(e.level>=a){e.line=n;break}let t=e.line,c=!1;for(let a=0;a<i;a++)if(c=r[a](e,o,n,!1),c){if(t>=e.line)throw Error(`block rule didn't increment state.line`);break}if(!c)throw Error(`none of the block rules matched`);e.tight=!s,e.isEmpty(e.line-1)&&(s=!0),o=e.line,o<n&&e.isEmpty(o)&&(s=!0,o++,e.line=o)}},L1.prototype.parse=function(e,t,n,r){if(!e)return;let i=new this.State(e,t,n,r);this.tokenize(i,i.line,i.lineMax)},L1.prototype.State=m1;function R1(e,t,n,r){this.src=e,this.env=n,this.md=t,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}R1.prototype.pushPending=function(){let e=new B$(`text`,``,0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending=``,e},R1.prototype.push=function(e,t,n){this.pending&&this.pushPending();let r=new B$(e,t,n),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},R1.prototype.scanDelims=function(e,t){let n=this.posMax,r=this.src.charCodeAt(e),i;if(e===0)i=32;else if(e===1)i=this.src.charCodeAt(0),(i&63488)==55296&&(i=65533);else if(i=this.src.charCodeAt(e-1),(i&64512)==56320){let t=this.src.charCodeAt(e-2);i=(t&64512)==55296?65536+(t-55296<<10)+(i-56320):65533}else (i&64512)==55296&&(i=65533);let a=e;for(;a<n&&this.src.charCodeAt(a)===r;)a++;let o=a-e,s=a<n?this.src.charCodeAt(a):32;if((s&64512)==55296){let e=this.src.charCodeAt(a+1);s=(e&64512)==56320?65536+(s-55296<<10)+(e-56320):65533}else (s&64512)==56320&&(s=65533);let c=O$(i)||D$(i),l=O$(s)||D$(s),u=T$(i),d=T$(s),f=!d&&(!l||u||c),p=!u&&(!c||d||l);return{can_open:f&&(t||!p||c),can_close:p&&(t||!f||l),length:o}},R1.prototype.Token=B$;function z1(e){switch(e){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 B1(e,t){let n=e.pos;for(;n<e.posMax&&!z1(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}var V1=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function H1(e,t){if(!e.md.options.linkify||e.linkLevel>0)return!1;let n=e.pos,r=e.posMax;if(n+3>r||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47)return!1;let i=e.pending.match(V1);if(!i)return!1;let a=i[1],o=e.md.linkify.matchAtStart(e.src.slice(n-a.length));if(!o)return!1;let s=o.url;if(s.length<=a.length)return!1;let c=s.length;for(;c>0&&s.charCodeAt(c-1)===42;)c--;c!==s.length&&(s=s.slice(0,c));let l=e.md.normalizeLink(s);if(!e.md.validateLink(l))return!1;if(!t){e.pending=e.pending.slice(0,-a.length);let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,l]],t.markup=`linkify`,t.info=`auto`;let n=e.push(`text`,``,0);n.content=e.md.normalizeLinkText(s);let r=e.push(`link_close`,`a`,-1);r.markup=`linkify`,r.info=`auto`}return e.pos+=s.length-a.length,!0}function U1(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==10)return!1;let r=e.pending.length-1,i=e.posMax;if(!t)if(r>=0&&e.pending.charCodeAt(r)===32)if(r>=1&&e.pending.charCodeAt(r-1)===32){let t=r-1;for(;t>=1&&e.pending.charCodeAt(t-1)===32;)t--;e.pending=e.pending.slice(0,t),e.push(`hardbreak`,`br`,0)}else e.pending=e.pending.slice(0,-1),e.push(`softbreak`,`br`,0);else e.push(`softbreak`,`br`,0);for(n++;n<i&&w$(e.src.charCodeAt(n));)n++;return e.pos=n,!0}var W1=[];for(let e=0;e<256;e++)W1.push(0);`\\!"#$%&'()*+,./:;<=>?@[]^_\`{|}~-`.split(``).forEach(function(e){W1[e.charCodeAt(0)]=1});function G1(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=e.src.charCodeAt(n);if(i===10){for(t||e.push(`hardbreak`,`br`,0),n++;n<r&&(i=e.src.charCodeAt(n),w$(i));)n++;return e.pos=n,!0}let a=e.src[n];if(i>=55296&&i<=56319&&n+1<r){let t=e.src.charCodeAt(n+1);t>=56320&&t<=57343&&(a+=e.src[n+1],n++)}let o=`\\`+a;if(!t){let t=e.push(`text_special`,``,0);i<256&&W1[i]!==0?t.content=a:t.content=o,t.markup=o,t.info=`escape`}return e.pos=n+1,!0}function K1(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==96)return!1;let r=n;n++;let i=e.posMax;for(;n<i&&e.src.charCodeAt(n)===96;)n++;let a=e.src.slice(r,n),o=a.length;if(e.backticksScanned&&(e.backticks[o]||0)<=r)return t||(e.pending+=a),e.pos+=o,!0;let s=n,c;for(;(c=e.src.indexOf("`",s))!==-1;){for(s=c+1;s<i&&e.src.charCodeAt(s)===96;)s++;let r=s-c;if(r===o){if(!t){let t=e.push(`code_inline`,`code`,0);t.markup=a,t.content=e.src.slice(n,c).replace(/\n/g,` `).replace(/^ (.+) $/,`$1`)}return e.pos=s,!0}e.backticks[r]=c}return e.backticksScanned=!0,t||(e.pending+=a),e.pos+=o,!0}function q1(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==126)return!1;let i=e.scanDelims(e.pos,!0),a=i.length,o=String.fromCharCode(r);if(a<2)return!1;let s;a%2&&(s=e.push(`text`,``,0),s.content=o,a--);for(let t=0;t<a;t+=2)s=e.push(`text`,``,0),s.content=o+o,e.delimiters.push({marker:r,length:0,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0}function J1(e,t){let n,r=[],i=t.length;for(let a=0;a<i;a++){let i=t[a];if(i.marker!==126||i.end===-1)continue;let o=t[i.end];n=e.tokens[i.token],n.type=`s_open`,n.tag=`s`,n.nesting=1,n.markup=`~~`,n.content=``,n=e.tokens[o.token],n.type=`s_close`,n.tag=`s`,n.nesting=-1,n.markup=`~~`,n.content=``,e.tokens[o.token-1].type===`text`&&e.tokens[o.token-1].content===`~`&&r.push(o.token-1)}for(;r.length;){let t=r.pop(),i=t+1;for(;i<e.tokens.length&&e.tokens[i].type===`s_close`;)i++;i--,t!==i&&(n=e.tokens[i],e.tokens[i]=e.tokens[t],e.tokens[t]=n)}}function Y1(e){let t=e.tokens_meta,n=e.tokens_meta.length;J1(e,e.delimiters);for(let r=0;r<n;r++)t[r]&&t[r].delimiters&&J1(e,t[r].delimiters)}var X1={tokenize:q1,postProcess:Y1};function Z1(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==95&&r!==42)return!1;let i=e.scanDelims(e.pos,r===42);for(let t=0;t<i.length;t++){let t=e.push(`text`,``,0);t.content=String.fromCharCode(r),e.delimiters.push({marker:r,length:i.length,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return e.pos+=i.length,!0}function Q1(e,t){let n=t.length;for(let r=n-1;r>=0;r--){let n=t[r];if(n.marker!==95&&n.marker!==42||n.end===-1)continue;let i=t[n.end],a=r>0&&t[r-1].end===n.end+1&&t[r-1].marker===n.marker&&t[r-1].token===n.token-1&&t[n.end+1].token===i.token+1,o=String.fromCharCode(n.marker),s=e.tokens[n.token];s.type=a?`strong_open`:`em_open`,s.tag=a?`strong`:`em`,s.nesting=1,s.markup=a?o+o:o,s.content=``;let c=e.tokens[i.token];c.type=a?`strong_close`:`em_close`,c.tag=a?`strong`:`em`,c.nesting=-1,c.markup=a?o+o:o,c.content=``,a&&(e.tokens[t[r-1].token].content=``,e.tokens[t[n.end+1].token].content=``,r--)}}function $1(e){let t=e.tokens_meta,n=e.tokens_meta.length;Q1(e,e.delimiters);for(let r=0;r<n;r++)t[r]&&t[r].delimiters&&Q1(e,t[r].delimiters)}var e0={tokenize:Z1,postProcess:$1};function t0(e,t){let n,r,i,a,o=``,s=``,c=e.pos,l=!0;if(e.src.charCodeAt(e.pos)!==91)return!1;let u=e.pos,d=e.posMax,f=e.pos+1,p=e.md.helpers.parseLinkLabel(e,e.pos,!0);if(p<0)return!1;let m=p+1;if(m<d&&e.src.charCodeAt(m)===40){for(l=!1,m++;m<d&&(n=e.src.charCodeAt(m),!(!w$(n)&&n!==10));m++);if(m>=d)return!1;if(c=m,i=e.md.helpers.parseLinkDestination(e.src,m,e.posMax),i.ok){for(o=e.md.normalizeLink(i.str),e.md.validateLink(o)?m=i.pos:o=``,c=m;m<d&&(n=e.src.charCodeAt(m),!(!w$(n)&&n!==10));m++);if(i=e.md.helpers.parseLinkTitle(e.src,m,e.posMax),m<d&&c!==m&&i.ok)for(s=i.str,m=i.pos;m<d&&(n=e.src.charCodeAt(m),!(!w$(n)&&n!==10));m++);}(m>=d||e.src.charCodeAt(m)!==41)&&(l=!0),m++}if(l){if(e.env.references===void 0)return!1;if(m<d&&e.src.charCodeAt(m)===91?(c=m+1,m=e.md.helpers.parseLinkLabel(e,m),m>=0?r=e.src.slice(c,m++):m=p+1):m=p+1,r||=e.src.slice(f,p),a=e.env.references[k$(r)],!a)return e.pos=u,!1;o=a.href,s=a.title}if(!t){e.pos=f,e.posMax=p;let t=e.push(`link_open`,`a`,1),n=[[`href`,o]];t.attrs=n,s&&n.push([`title`,s]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push(`link_close`,`a`,-1)}return e.pos=m,e.posMax=d,!0}function n0(e,t){let n,r,i,a,o,s,c,l,u=``,d=e.pos,f=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91)return!1;let p=e.pos+2,m=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(m<0)return!1;if(a=m+1,a<f&&e.src.charCodeAt(a)===40){for(a++;a<f&&(n=e.src.charCodeAt(a),!(!w$(n)&&n!==10));a++);if(a>=f)return!1;for(l=a,s=e.md.helpers.parseLinkDestination(e.src,a,e.posMax),s.ok&&(u=e.md.normalizeLink(s.str),e.md.validateLink(u)?a=s.pos:u=``),l=a;a<f&&(n=e.src.charCodeAt(a),!(!w$(n)&&n!==10));a++);if(s=e.md.helpers.parseLinkTitle(e.src,a,e.posMax),a<f&&l!==a&&s.ok)for(c=s.str,a=s.pos;a<f&&(n=e.src.charCodeAt(a),!(!w$(n)&&n!==10));a++);else c=``;if(a>=f||e.src.charCodeAt(a)!==41)return e.pos=d,!1;a++}else{if(e.env.references===void 0)return!1;if(a<f&&e.src.charCodeAt(a)===91?(l=a+1,a=e.md.helpers.parseLinkLabel(e,a),a>=0?i=e.src.slice(l,a++):a=m+1):a=m+1,i||=e.src.slice(p,m),o=e.env.references[k$(i)],!o)return e.pos=d,!1;u=o.href,c=o.title}if(!t){r=e.src.slice(p,m);let t=[];e.md.inline.parse(r,e.md,e.env,t);let n=e.push(`image`,`img`,0),i=[[`src`,u],[`alt`,``]];n.attrs=i,n.children=t,n.content=r,c&&i.push([`title`,c])}return e.pos=a,e.posMax=f,!0}var r0=/^([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])?)*)$/,i0=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function a0(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==60)return!1;let r=e.pos,i=e.posMax;for(;;){if(++n>=i)return!1;let t=e.src.charCodeAt(n);if(t===60)return!1;if(t===62)break}let a=e.src.slice(r+1,n);if(i0.test(a)){let n=e.md.normalizeLink(a);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}if(r0.test(a)){let n=e.md.normalizeLink(`mailto:`+a);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}return!1}function o0(e){return/^<a[>\s]/i.test(e)}function s0(e){return/^<\/a\s*>/i.test(e)}function c0(e){let t=e|32;return t>=97&&t<=122}function l0(e,t){if(!e.md.options.html)return!1;let n=e.posMax,r=e.pos;if(e.src.charCodeAt(r)!==60||r+2>=n)return!1;let i=e.src.charCodeAt(r+1);if(i!==33&&i!==63&&i!==47&&!c0(i))return!1;let a=e.src.slice(r).match(k1);if(!a)return!1;if(!t){let t=e.push(`html_inline`,``,0);t.content=a[0],o0(t.content)&&e.linkLevel++,s0(t.content)&&e.linkLevel--}return e.pos+=a[0].length,!0}var u0=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,d0=/^&([a-z][a-z0-9]{1,31});/i;function f0(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==38||n+1>=r)return!1;if(e.src.charCodeAt(n+1)===35){let r=e.src.slice(n).match(u0);if(r){if(!t){let t=r[1][0].toLowerCase()===`x`?parseInt(r[1].slice(1),16):parseInt(r[1],10),n=e.push(`text_special`,``,0);n.content=l$(t)?u$(t):u$(65533),n.markup=r[0],n.info=`entity`}return e.pos+=r[0].length,!0}}else{let r=e.src.slice(n).match(d0);if(r){let n=t$(r[0]);if(n!==r[0]){if(!t){let t=e.push(`text_special`,``,0);t.content=n,t.markup=r[0],t.info=`entity`}return e.pos+=r[0].length,!0}}}return!1}function p0(e){let t={},n=e.length;if(!n)return;let r=0,i=-2,a=[];for(let o=0;o<n;o++){let n=e[o];if(a.push(0),(e[r].marker!==n.marker||i!==n.token-1)&&(r=o),i=n.token,n.length=n.length||0,!n.close)continue;t.hasOwnProperty(n.marker)||(t[n.marker]=[-1,-1,-1,-1,-1,-1]);let s=t[n.marker][(n.open?3:0)+n.length%3],c=r-a[r]-1,l=c;for(;c>s;c-=a[c]+1){let t=e[c];if(t.marker===n.marker&&t.open&&t.end<0){let r=!1;if((t.close||n.open)&&(t.length+n.length)%3==0&&(t.length%3!=0||n.length%3!=0)&&(r=!0),!r){let r=c>0&&!e[c-1].open?a[c-1]+1:0;a[o]=o-c+r,a[c]=r,n.open=!1,t.end=o,t.close=!1,l=-1,i=-2;break}}}l!==-1&&(t[n.marker][(n.open?3:0)+(n.length||0)%3]=l)}}function m0(e){let t=e.tokens_meta,n=e.tokens_meta.length;p0(e.delimiters);for(let e=0;e<n;e++)t[e]&&t[e].delimiters&&p0(t[e].delimiters)}function h0(e){let t,n,r=0,i=e.tokens,a=e.tokens.length;for(t=n=0;t<a;t++)i[t].nesting<0&&r--,i[t].level=r,i[t].nesting>0&&r++,i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}var g0=[[`text`,B1],[`linkify`,H1],[`newline`,U1],[`escape`,G1],[`backticks`,K1],[`strikethrough`,X1.tokenize],[`emphasis`,e0.tokenize],[`link`,t0],[`image`,n0],[`autolink`,a0],[`html_inline`,l0],[`entity`,f0]],_0=[[`balance_pairs`,m0],[`strikethrough`,X1.postProcess],[`emphasis`,e0.postProcess],[`fragments_join`,h0]];function v0(){this.ruler=new z$;for(let e=0;e<g0.length;e++)this.ruler.push(g0[e][0],g0[e][1]);this.ruler2=new z$;for(let e=0;e<_0.length;e++)this.ruler2.push(_0[e][0],_0[e][1])}v0.prototype.skipToken=function(e){let t=e.pos,n=this.ruler.getRules(``),r=n.length,i=e.md.options.maxNesting,a=e.cache;if(a[t]!==void 0){e.pos=a[t];return}let o=!1;if(e.level<i){for(let i=0;i<r;i++)if(e.level++,o=n[i](e,!0),e.level--,o){if(t>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}else e.pos=e.posMax;o||e.pos++,a[t]=e.pos},v0.prototype.tokenize=function(e){let t=this.ruler.getRules(``),n=t.length,r=e.posMax,i=e.md.options.maxNesting;for(;e.pos<r;){let a=e.pos,o=!1;if(e.level<i){for(let r=0;r<n;r++)if(o=t[r](e,!1),o){if(a>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}if(o){if(e.pos>=r)break;continue}e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()},v0.prototype.parse=function(e,t,n,r){let i=new this.State(e,t,n,r);this.tokenize(i);let a=this.ruler2.getRules(``),o=a.length;for(let e=0;e<o;e++)a[e](i)},v0.prototype.State=R1;function y0(e){let t={};return e||={},t.src_Any=kQ.source,t.src_Cc=AQ.source,t.src_Z=PQ.source,t.src_P=MQ.source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join(`|`),t.src_ZCc=[t.src_Z,t.src_Cc].join(`|`),t.src_pseudo_letter=`(?:(?![><|]|`+t.src_ZPCc+`)`+t.src_Any+`)`,t.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]?)`,t.src_auth=`(?:(?:(?!`+t.src_ZCc+`|[@/\\[\\]()]).)+@)?`,t.src_port=`(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?`,t.src_host_terminator=`(?=$|[><|]|`+t.src_ZPCc+`)(?!`+(e[`---`]?`-(?!--)|`:`-|`)+`_|:\\d|\\.-|\\.(?!$|`+t.src_ZPCc+`))`,t.src_path=`(?:[/?#](?:(?!`+t.src_ZCc+`|[><|]|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+t.src_ZCc+`|\\]).)*\\]|\\((?:(?!`+t.src_ZCc+`|[)]).)*\\)|\\{(?:(?!`+t.src_ZCc+`|[}]).)*\\}|\\"(?:(?!`+t.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+t.src_ZCc+`|[']).)+\\'|\\'(?=`+t.src_pseudo_letter+`|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!`+t.src_ZCc+`|[.]|$)|`+(e[`---`]?`\\-(?!--(?:[^-]|$))(?:-*)|`:`\\-+|`)+`,(?!`+t.src_ZCc+`|$)|;(?!`+t.src_ZCc+`|$)|\\!+(?!`+t.src_ZCc+`|[!]|$)|\\?(?!`+t.src_ZCc+`|[?]|$))+|\\/)?`,t.src_email_name=`[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*`,t.src_xn=`xn--[a-z0-9\\-]{1,59}`,t.src_domain_root=`(?:`+t.src_xn+`|`+t.src_pseudo_letter+`{1,63})`,t.src_domain=`(?:`+t.src_xn+`|(?:`+t.src_pseudo_letter+`)|(?:`+t.src_pseudo_letter+`(?:-|`+t.src_pseudo_letter+`){0,61}`+t.src_pseudo_letter+`))`,t.src_host=`(?:(?:(?:(?:`+t.src_domain+`)\\.)*`+t.src_domain+`))`,t.tpl_host_fuzzy=`(?:`+t.src_ip4+`|(?:(?:(?:`+t.src_domain+`)\\.)+(?:%TLDS%)))`,t.tpl_host_no_ip_fuzzy=`(?:(?:(?:`+t.src_domain+`)\\.)+(?:%TLDS%))`,t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:`+t.src_ZPCc+`|>|$))`,t.tpl_email_fuzzy=`(^|[><|]|"|\\(|`+t.src_ZCc+`)(`+t.src_email_name+`@`+t.tpl_host_fuzzy_strict+`)`,t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+`)`,t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+`)`,t}function b0(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}function x0(e){return Object.prototype.toString.call(e)}function S0(e){return x0(e)===`[object String]`}function C0(e){return x0(e)===`[object Object]`}function w0(e){return x0(e)===`[object RegExp]`}function T0(e){return x0(e)===`[object Function]`}function E0(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,`\\$&`)}var D0={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function O0(e){return Object.keys(e||{}).reduce(function(e,t){return e||D0.hasOwnProperty(t)},!1)}var k0={"http:":{validate:function(e,t,n){let r=e.slice(t);return n.re.http||(n.re.http=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(e,t,n){let r=e.slice(t);return n.re.no_http||(n.re.no_http=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)?t>=3&&e[t-3]===`:`||t>=3&&e[t-3]===`/`?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){let r=e.slice(t);return n.re.mailto||(n.re.mailto=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}}},A0=`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]`,j0=`biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф`.split(`|`);function M0(e){return function(t,n){let r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function N0(){return function(e,t){t.normalize(e)}}function P0(e){let t=e.re=y0(e.__opts__),n=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||n.push(A0),n.push(t.src_xn),t.src_tlds=n.join(`|`);function r(e){return e.replace(`%TLDS%`,t.src_tlds)}t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),`i`),t.email_fuzzy_global=RegExp(r(t.tpl_email_fuzzy),`ig`),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),`i`),t.link_fuzzy_global=RegExp(r(t.tpl_link_fuzzy),`ig`),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),`i`),t.link_no_ip_fuzzy_global=RegExp(r(t.tpl_link_no_ip_fuzzy),`ig`),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),`i`);let i=[];e.__compiled__={};function a(e,t){throw Error(`(LinkifyIt) Invalid schema "`+e+`": `+t)}Object.keys(e.__schemas__).forEach(function(t){let n=e.__schemas__[t];if(n===null)return;let r={validate:null,link:null};if(e.__compiled__[t]=r,C0(n)){w0(n.validate)?r.validate=M0(n.validate):T0(n.validate)?r.validate=n.validate:a(t,n),T0(n.normalize)?r.normalize=n.normalize:n.normalize?a(t,n):r.normalize=N0();return}if(S0(n)){i.push(t);return}a(t,n)}),i.forEach(function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)}),e.__compiled__[``]={validate:null,normalize:N0()};let o=Object.keys(e.__compiled__).filter(function(t){return t.length>0&&e.__compiled__[t]}).map(E0).join(`|`);e.re.schema_test=RegExp(`(^|(?!_)(?:[><|]|`+t.src_ZPCc+`))(`+o+`)`,`i`),e.re.schema_search=RegExp(`(^|(?!_)(?:[><|]|`+t.src_ZPCc+`))(`+o+`)`,`ig`),e.re.schema_at_start=RegExp(`^`+e.re.schema_search.source,`i`),e.re.pretest=RegExp(`(`+e.re.schema_test.source+`)|(`+e.re.host_fuzzy_test.source+`)|@`,`i`)}function F0(e,t,n,r){let i=e.slice(n,r);this.schema=t.toLowerCase(),this.index=n,this.lastIndex=r,this.raw=i,this.text=i,this.url=i}function I0(e,t){if(!(this instanceof I0))return new I0(e,t);t||O0(e)&&(t=e,e={}),this.__opts__=b0({},D0,t),this.__schemas__=b0({},k0,e),this.__compiled__={},this.__tlds__=j0,this.__tlds_replaced__=!1,this.re={},P0(this)}I0.prototype.add=function(e,t){return this.__schemas__[e]=t,P0(this),this},I0.prototype.set=function(e){return this.__opts__=b0(this.__opts__,e),this},I0.prototype.test=function(e){if(!e.length)return!1;let t,n;if(this.re.schema_test.test(e)){for(n=this.re.schema_search,n.lastIndex=0;(t=n.exec(e))!==null;)if(this.testSchemaAt(e,t[2],n.lastIndex))return!0}return!!(this.__opts__.fuzzyLink&&this.__compiled__[`http:`]&&e.search(this.re.host_fuzzy_test)>=0&&e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy)!==null||this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`]&&e.indexOf(`@`)>=0&&e.match(this.re.email_fuzzy)!==null)},I0.prototype.pretest=function(e){return this.re.pretest.test(e)},I0.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},I0.prototype.match=function(e){let t=[],n=[],r=[],i=[],a,o,s;function c(e,t){return e?t?e.index===t.index?e.lastIndex>=t.lastIndex?e:t:e.index<t.index?e:t:e:t}if(!e.length)return null;if(this.re.schema_test.test(e))for(s=this.re.schema_search,s.lastIndex=0;(a=s.exec(e))!==null;)o=this.testSchemaAt(e,a[2],s.lastIndex),o&&n.push({schema:a[2],index:a.index+a[1].length,lastIndex:a.index+a[0].length+o});if(this.__opts__.fuzzyLink&&this.__compiled__[`http:`])for(s=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)r.push({schema:``,index:a.index+a[1].length,lastIndex:a.index+a[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`])for(s=this.re.email_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)i.push({schema:`mailto:`,index:a.index+a[1].length,lastIndex:a.index+a[0].length});let l=[0,0,0],u=0;for(;;){let a=[n[l[0]],i[l[1]],r[l[2]]],o=c(c(a[0],a[1]),a[2]);if(!o)break;if(o===a[0]?l[0]++:o===a[1]?l[1]++:l[2]++,o.index<u)continue;let s=new F0(e,o.schema,o.index,o.lastIndex);this.__compiled__[s.schema].normalize(s,this),t.push(s),u=o.lastIndex}return t.length?t:null},I0.prototype.matchAtStart=function(e){if(!e.length)return null;let t=this.re.schema_at_start.exec(e);if(!t)return null;let n=this.testSchemaAt(e,t[2],t[0].length);if(!n)return null;let r=new F0(e,t[2],t.index+t[1].length,t.index+t[0].length+n);return this.__compiled__[r.schema].normalize(r,this),r},I0.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(e,t,n){return e!==n[t-1]}).reverse(),P0(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,P0(this),this)},I0.prototype.normalize=function(e){e.schema||(e.url=`http://`+e.url),e.schema===`mailto:`&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:`+e.url)},I0.prototype.onCompile=function(){};var L0=2147483647,R0=36,z0=1,B0=26,V0=38,H0=700,U0=72,W0=128,G0=`-`,K0=/^xn--/,q0=/[^\0-\x7F]/,J0=/[\x2E\u3002\uFF0E\uFF61]/g,Y0={overflow:`Overflow: input needs wider integers to process`,"not-basic":`Illegal input >= 0x80 (not a basic code point)`,"invalid-input":`Invalid input`},X0=R0-z0,Z0=Math.floor,Q0=String.fromCharCode;function $0(e){throw RangeError(Y0[e])}function e2(e,t){let n=[],r=e.length;for(;r--;)n[r]=t(e[r]);return n}function t2(e,t){let n=e.split(`@`),r=``;n.length>1&&(r=n[0]+`@`,e=n[1]),e=e.replace(J0,`.`);let i=e2(e.split(`.`),t).join(`.`);return r+i}function n2(e){let t=[],n=0,r=e.length;for(;n<r;){let i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){let r=e.charCodeAt(n++);(r&64512)==56320?t.push(((i&1023)<<10)+(r&1023)+65536):(t.push(i),n--)}else t.push(i)}return t}var r2=e=>String.fromCodePoint(...e),i2=function(e){return e>=48&&e<58?26+(e-48):e>=65&&e<91?e-65:e>=97&&e<123?e-97:R0},a2=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},o2=function(e,t,n){let r=0;for(e=n?Z0(e/H0):e>>1,e+=Z0(e/t);e>455;r+=R0)e=Z0(e/X0);return Z0(r+36*e/(e+V0))},s2=function(e){let t=[],n=e.length,r=0,i=W0,a=U0,o=e.lastIndexOf(G0);o<0&&(o=0);for(let n=0;n<o;++n)e.charCodeAt(n)>=128&&$0(`not-basic`),t.push(e.charCodeAt(n));for(let s=o>0?o+1:0;s<n;){let o=r;for(let t=1,i=R0;;i+=R0){s>=n&&$0(`invalid-input`);let o=i2(e.charCodeAt(s++));o>=R0&&$0(`invalid-input`),o>Z0((L0-r)/t)&&$0(`overflow`),r+=o*t;let c=i<=a?z0:i>=a+B0?B0:i-a;if(o<c)break;let l=R0-c;t>Z0(L0/l)&&$0(`overflow`),t*=l}let c=t.length+1;a=o2(r-o,c,o==0),Z0(r/c)>L0-i&&$0(`overflow`),i+=Z0(r/c),r%=c,t.splice(r++,0,i)}return String.fromCodePoint(...t)},c2=function(e){let t=[];e=n2(e);let n=e.length,r=W0,i=0,a=U0;for(let n of e)n<128&&t.push(Q0(n));let o=t.length,s=o;for(o&&t.push(G0);s<n;){let n=L0;for(let t of e)t>=r&&t<n&&(n=t);let c=s+1;n-r>Z0((L0-i)/c)&&$0(`overflow`),i+=(n-r)*c,r=n;for(let n of e)if(n<r&&++i>L0&&$0(`overflow`),n===r){let e=i;for(let n=R0;;n+=R0){let r=n<=a?z0:n>=a+B0?B0:n-a;if(e<r)break;let i=e-r,o=R0-r;t.push(Q0(a2(r+i%o,0))),e=Z0(i/o)}t.push(Q0(a2(e,0))),a=o2(i,c,s===o),i=0,++s}++i,++r}return t.join(``)},l2={version:`2.3.1`,ucs2:{decode:n2,encode:r2},decode:s2,encode:c2,toASCII:function(e){return t2(e,function(e){return q0.test(e)?`xn--`+c2(e):e})},toUnicode:function(e){return t2(e,function(e){return K0.test(e)?s2(e.slice(4).toLowerCase()):e})}},u2={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{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`]}}},commonmark:{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`]}}}},d2=/^(vbscript|javascript|file|data):/,f2=/^data:image\/(gif|png|jpeg|webp);/;function p2(e){let t=e.trim().toLowerCase();return d2.test(t)?f2.test(t):!0}var m2=[`http:`,`https:`,`mailto:`];function h2(e){let t=DQ(e,!0);if(t.hostname&&(!t.protocol||m2.indexOf(t.protocol)>=0))try{t.hostname=l2.toASCII(t.hostname)}catch{}return mQ(hQ(t))}function g2(e){let t=DQ(e,!0);if(t.hostname&&(!t.protocol||m2.indexOf(t.protocol)>=0))try{t.hostname=l2.toUnicode(t.hostname)}catch{}return dQ(hQ(t),dQ.defaultChars+`%`)}function _2(e,t){if(!(this instanceof _2))return new _2(e,t);t||i$(e)||(t=e||{},e=`default`),this.inline=new v0,this.block=new L1,this.core=new p1,this.renderer=new R$,this.linkify=new I0,this.validateLink=p2,this.normalizeLink=h2,this.normalizeLinkText=g2,this.utils=n$,this.helpers=s$({},I$),this.options={},this.configure(e),t&&this.set(t)}_2.prototype.set=function(e){return s$(this.options,e),this},_2.prototype.configure=function(e){let t=this;if(i$(e)){let t=e;if(e=u2[t],!e)throw Error('Wrong `markdown-it` preset "'+t+`", check name`)}if(!e)throw Error("Wrong `markdown-it` preset, can't be empty");return e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach(function(n){e.components[n].rules&&t[n].ruler.enableOnly(e.components[n].rules),e.components[n].rules2&&t[n].ruler2.enableOnly(e.components[n].rules2)}),this},_2.prototype.enable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(function(t){n=n.concat(this[t].ruler.enable(e,!0))},this),n=n.concat(this.inline.ruler2.enable(e,!0));let r=e.filter(function(e){return n.indexOf(e)<0});if(r.length&&!t)throw Error(`MarkdownIt. Failed to enable unknown rule(s): `+r);return this},_2.prototype.disable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(function(t){n=n.concat(this[t].ruler.disable(e,!0))},this),n=n.concat(this.inline.ruler2.disable(e,!0));let r=e.filter(function(e){return n.indexOf(e)<0});if(r.length&&!t)throw Error(`MarkdownIt. Failed to disable unknown rule(s): `+r);return this},_2.prototype.use=function(e){let t=[this].concat(Array.prototype.slice.call(arguments,1));return e.apply(e,t),this},_2.prototype.parse=function(e,t){if(typeof e!=`string`)throw Error(`Input data should be a String`);let n=new this.core.State(e,this,t);return this.core.process(n),n.tokens},_2.prototype.render=function(e,t){return t||={},this.renderer.render(this.parse(e,t),this.options,t)},_2.prototype.parseInline=function(e,t){let n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens},_2.prototype.renderInline=function(e,t){return t||={},this.renderer.render(this.parseInline(e,t),this.options,t)};var v2=new $d({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(e){return[`h`+e.attrs.level,0]}},code_block:{content:`text*`,group:`block`,code:!0,defining:!0,marks:``,attrs:{params:{default:``}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>({params:e.getAttribute(`data-params`)||``})}],toDOM(e){return[`pre`,e.attrs.params?{"data-params":e.attrs.params}:{},[`code`,0]]}},ordered_list:{content:`list_item+`,group:`block`,attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:`ol`,getAttrs(e){return{order:e.hasAttribute(`start`)?+e.getAttribute(`start`):1,tight:e.hasAttribute(`data-tight`)}}}],toDOM(e){return[`ol`,{start:e.attrs.order==1?null:e.attrs.order,"data-tight":e.attrs.tight?`true`:null},0]}},bullet_list:{content:`list_item+`,group:`block`,attrs:{tight:{default:!1}},parseDOM:[{tag:`ul`,getAttrs:e=>({tight:e.hasAttribute(`data-tight`)})}],toDOM(e){return[`ul`,{"data-tight":e.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(e){return{src:e.getAttribute(`src`),title:e.getAttribute(`title`),alt:e.getAttribute(`alt`)}}}],toDOM(e){return[`img`,e.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:e=>e.type.name==`em`}],toDOM(){return[`em`]}},strong:{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return[`strong`]}},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM(e){return[`a`,e.attrs]}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return[`code`]}}}});function y2(e,t){if(e.isText&&t.isText&&cd.sameSet(e.marks,t.marks))return e.withText(e.text+t.text)}var b2=class{constructor(e,t){this.schema=e,this.tokenHandlers=t,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:cd.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 t=this.top(),n=t.content,r=n[n.length-1],i=this.schema.text(e,t.marks),a;r&&(a=y2(r,i))?n[n.length-1]=a:n.push(i)}openMark(e){let t=this.top();t.marks=e.addToSet(t.marks)}closeMark(e){let t=this.top();t.marks=e.removeFromSet(t.marks)}parseTokens(e){for(let t=0;t<e.length;t++){let n=e[t],r=this.tokenHandlers[n.type];if(!r)throw Error("Token type `"+n.type+"` not supported by Markdown parser");r(this,n,e,t)}}addNode(e,t,n){let r=this.top(),i=e.createAndFill(t,n,r?r.marks:[]);return i?(this.push(i),i):null}openNode(e,t){this.stack.push({type:e,attrs:t,content:[],marks:cd.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}};function x2(e,t,n,r){return e.getAttrs?e.getAttrs(t,n,r):e.attrs instanceof Function?e.attrs(t):e.attrs}function S2(e,t){return e.noCloseToken||t==`code_inline`||t==`code_block`||t==`fence`}function C2(e){return e[e.length-1]==`
237
+ `?e.slice(0,e.length-1):e}function w2(){}function T2(e,t){let n=Object.create(null);for(let r in t){let i=t[r];if(i.block){let t=e.nodeType(i.block);S2(i,r)?n[r]=(e,n,r,a)=>{e.openNode(t,x2(i,n,r,a)),e.addText(C2(n.content)),e.closeNode()}:(n[r+`_open`]=(e,n,r,a)=>e.openNode(t,x2(i,n,r,a)),n[r+`_close`]=e=>e.closeNode())}else if(i.node){let t=e.nodeType(i.node);n[r]=(e,n,r,a)=>e.addNode(t,x2(i,n,r,a))}else if(i.mark){let t=e.marks[i.mark];S2(i,r)?n[r]=(e,n,r,a)=>{e.openMark(t.create(x2(i,n,r,a))),e.addText(C2(n.content)),e.closeMark(t)}:(n[r+`_open`]=(e,n,r,a)=>e.openMark(t.create(x2(i,n,r,a))),n[r+`_close`]=e=>e.closeMark(t))}else if(i.ignore)S2(i,r)?n[r]=w2:(n[r+`_open`]=w2,n[r+`_close`]=w2);else throw RangeError(`Unrecognized parsing spec `+JSON.stringify(i))}return n.text=(e,t)=>e.addText(t.content),n.inline=(e,t)=>e.parseTokens(t.children),n.softbreak=n.softbreak||(e=>e.addText(` `)),n}var E2=class{constructor(e,t,n){this.schema=e,this.tokenizer=t,this.tokens=n,this.tokenHandlers=T2(e,n)}parse(e,t={}){let n=new b2(this.schema,this.tokenHandlers),r;n.parseTokens(this.tokenizer.parse(e,t));do r=n.closeNode();while(n.stack.length);return r||this.schema.topNodeType.createAndFill()}};function D2(e,t){for(;++t<e.length;)if(e[t].type!=`list_item_open`)return e[t].hidden;return!1}new E2(v2,_2(`commonmark`,{html:!1}),{blockquote:{block:`blockquote`},paragraph:{block:`paragraph`},list_item:{block:`list_item`},bullet_list:{block:`bullet_list`,getAttrs:(e,t,n)=>({tight:D2(t,n)})},ordered_list:{block:`ordered_list`,getAttrs:(e,t,n)=>({order:+e.attrGet(`start`)||1,tight:D2(t,n)})},heading:{block:`heading`,getAttrs:e=>({level:+e.tag.slice(1)})},code_block:{block:`code_block`,noCloseToken:!0},fence:{block:`code_block`,getAttrs:e=>({params:e.info||``}),noCloseToken:!0},hr:{node:`horizontal_rule`},image:{node:`image`,getAttrs:e=>({src:e.attrGet(`src`),title:e.attrGet(`title`)||null,alt:e.children[0]&&e.children[0].content||null})},hardbreak:{node:`hard_break`},em:{mark:`em`},strong:{mark:`strong`},link:{mark:`link`,getAttrs:e=>({href:e.attrGet(`href`),title:e.attrGet(`title`)||null})},code_inline:{mark:`code`,noCloseToken:!0}});var O2={open:``,close:``,mixable:!0};new class{constructor(e,t,n={}){this.nodes=e,this.marks=t,this.options=n}serialize(e,t={}){t=Object.assign({},this.options,t);let n=new j2(this.nodes,this.marks,t);return n.renderContent(e),n.out}}({blockquote(e,t){e.wrapBlock(`> `,null,t,()=>e.renderContent(t))},code_block(e,t){let n=t.textContent.match(/`{3,}/gm),r=n?n.sort().slice(-1)[0]+"`":"```";e.write(r+(t.attrs.params||``)+`
238
+ `),e.text(t.textContent,!1),e.write(`
239
+ `),e.write(r),e.closeBlock(t)},heading(e,t){e.write(e.repeat(`#`,t.attrs.level)+` `),e.renderInline(t,!1),e.closeBlock(t)},horizontal_rule(e,t){e.write(t.attrs.markup||`---`),e.closeBlock(t)},bullet_list(e,t){e.renderList(t,` `,()=>(t.attrs.bullet||`*`)+` `)},ordered_list(e,t){let n=t.attrs.order||1,r=String(n+t.childCount-1).length,i=e.repeat(` `,r+2);e.renderList(t,i,t=>{let i=String(n+t);return e.repeat(` `,r-i.length)+i+`. `})},list_item(e,t){e.renderContent(t)},paragraph(e,t){e.renderInline(t),e.closeBlock(t)},image(e,t){e.write(`![`+e.esc(t.attrs.alt||``)+`](`+t.attrs.src.replace(/[\(\)]/g,`\\$&`)+(t.attrs.title?` "`+t.attrs.title.replace(/"/g,`\\"`)+`"`:``)+`)`)},hard_break(e,t,n,r){for(let i=r+1;i<n.childCount;i++)if(n.child(i).type!=t.type){e.write(`\\
240
+ `);return}},text(e,t){e.text(t.text,!e.inAutolink)}},{em:{open:`*`,close:`*`,mixable:!0,expelEnclosingWhitespace:!0},strong:{open:`**`,close:`**`,mixable:!0,expelEnclosingWhitespace:!0},link:{open(e,t,n,r){return e.inAutolink=A2(t,n,r),e.inAutolink?`<`:`[`},close(e,t,n,r){let{inAutolink:i}=e;return e.inAutolink=void 0,i?`>`:`](`+t.attrs.href.replace(/[\(\)"]/g,`\\$&`)+(t.attrs.title?` "${t.attrs.title.replace(/"/g,`\\"`)}"`:``)+`)`},mixable:!0},code:{open(e,t,n,r){return k2(n.child(r),-1)},close(e,t,n,r){return k2(n.child(r-1),1)},escape:!1}});function k2(e,t){let n=/`+/g,r,i=0;if(e.isText)for(;r=n.exec(e.text);)i=Math.max(i,r[0].length);let a=i>0&&t>0?" `":"`";for(let e=0;e<i;e++)a+="`";return i>0&&t<0&&(a+=` `),a}function A2(e,t,n){if(e.attrs.title||!/^\w+:/.test(e.attrs.href))return!1;let r=t.child(n);return!r.isText||r.text!=e.attrs.href||r.marks[r.marks.length-1]!=e?!1:n==t.childCount-1||!e.isInSet(t.child(n+1).marks)}var j2=class{constructor(e,t,n){this.nodes=e,this.marks=t,this.options=n,this.delim=``,this.out=``,this.closed=null,this.inAutolink=void 0,this.atBlockStart=!1,this.inTightList=!1,this.options.tightLists===void 0&&(this.options.tightLists=!1),this.options.hardBreakNodeName===void 0&&(this.options.hardBreakNodeName=`hard_break`)}flushClose(e=2){if(this.closed){if(this.atBlank()||(this.out+=`
241
+ `),e>1){let t=this.delim,n=/\s+$/.exec(t);n&&(t=t.slice(0,t.length-n[0].length));for(let n=1;n<e;n++)this.out+=t+`
242
+ `}this.closed=null}}getMark(e){let t=this.marks[e];if(!t){if(this.options.strict!==!1)throw Error(`Mark type \`${e}\` not supported by Markdown renderer`);t=O2}return t}wrapBlock(e,t,n,r){let i=this.delim;this.write(t??e),this.delim+=e,r(),this.delim=i,this.closeBlock(n)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){this.atBlank()||(this.out+=`
243
+ `)}write(e){this.flushClose(),this.delim&&this.atBlank()&&(this.out+=this.delim),e&&(this.out+=e)}closeBlock(e){this.closed=e}text(e,t=!0){let n=e.split(`
244
+ `);for(let e=0;e<n.length;e++)this.write(),!t&&n[e][0]==`[`&&/(^|[^\\])\!$/.test(this.out)&&(this.out=this.out.slice(0,this.out.length-1)+`\\!`),this.out+=t?this.esc(n[e],this.atBlockStart):n[e],e!=n.length-1&&(this.out+=`
245
+ `)}render(e,t,n){if(this.nodes[e.type.name])this.nodes[e.type.name](this,e,t,n);else if(this.options.strict!==!1)throw Error("Token type `"+e.type.name+"` not supported by Markdown renderer");else e.type.isLeaf||(e.type.inlineContent?this.renderInline(e):this.renderContent(e),e.isBlock&&this.closeBlock(e))}renderContent(e){e.forEach((t,n,r)=>this.render(t,e,r))}renderInline(e,t=!0){this.atBlockStart=t;let n=[],r=``,i=(t,i,a)=>{let o=t?t.marks:[];t&&t.type.name===this.options.hardBreakNodeName&&(o=o.filter(t=>{if(a+1==e.childCount)return!1;let n=e.child(a+1);return t.isInSet(n.marks)&&(!n.isText||/\S/.test(n.text))}));let s=r;if(r=``,t&&t.isText&&o.some(e=>{let t=this.getMark(e.type.name);return t&&t.expelEnclosingWhitespace&&!e.isInSet(n)})){let[e,r,i]=/^(\s*)(.*)$/m.exec(t.text);r&&(s+=r,t=i?t.withText(i):null,t||(o=n))}if(t&&t.isText&&o.some(t=>{let n=this.getMark(t.type.name);return n&&n.expelEnclosingWhitespace&&!this.isMarkAhead(e,a+1,t)})){let[e,i,a]=/^(.*?)(\s*)$/m.exec(t.text);a&&(r=a,t=i?t.withText(i):null,t||(o=n))}let c=o.length?o[o.length-1]:null,l=c&&this.getMark(c.type.name).escape===!1,u=o.length-+!!l;outer:for(let e=0;e<u;e++){let t=o[e];if(!this.getMark(t.type.name).mixable)break;for(let r=0;r<n.length;r++){let i=n[r];if(!this.getMark(i.type.name).mixable)break;if(t.eq(i)){e>r?o=o.slice(0,r).concat(t).concat(o.slice(r,e)).concat(o.slice(e+1,u)):r>e&&(o=o.slice(0,e).concat(o.slice(e+1,r)).concat(t).concat(o.slice(r,u)));continue outer}}}let d=0;for(;d<Math.min(n.length,u)&&o[d].eq(n[d]);)++d;for(;d<n.length;)this.text(this.markString(n.pop(),!1,e,a),!1);if(s&&this.text(s),t){for(;n.length<u;){let t=o[n.length];n.push(t),this.text(this.markString(t,!0,e,a),!1),this.atBlockStart=!1}l&&t.isText?this.text(this.markString(c,!0,e,a)+t.text+this.markString(c,!1,e,a+1),!1):this.render(t,e,a),this.atBlockStart=!1}t?.isText&&t.nodeSize>0&&(this.atBlockStart=!1)};e.forEach(i),i(null,0,e.childCount),this.atBlockStart=!1}renderList(e,t,n){this.closed&&this.closed.type==e.type?this.flushClose(3):this.inTightList&&this.flushClose(1);let r=e.attrs.tight===void 0?this.options.tightLists:e.attrs.tight,i=this.inTightList;this.inTightList=r,e.forEach((i,a,o)=>{o&&r&&this.flushClose(1),this.wrapBlock(t,n(o),e,()=>this.render(i,e,o))}),this.inTightList=i}esc(e,t=!1){return e=e.replace(/[`*\\~\[\]_]/g,(t,n)=>t==`_`&&n>0&&n+1<e.length&&e[n-1].match(/\w/)&&e[n+1].match(/\w/)?t:`\\`+t),t&&(e=e.replace(/^(\+[ ]|[\-*>])/,`\\$&`).replace(/^(\s*)(#{1,6})(\s|$)/,`$1\\$2$3`).replace(/^(\s*\d+)\.\s/,`$1\\. `)),this.options.escapeExtraCharacters&&(e=e.replace(this.options.escapeExtraCharacters,`\\$&`)),e}quote(e){let t=e.indexOf(`"`)==-1?`""`:e.indexOf(`'`)==-1?`''`:`()`;return t[0]+e+t[1]}repeat(e,t){let n=``;for(let r=0;r<t;r++)n+=e;return n}markString(e,t,n,r){let i=this.getMark(e.type.name),a=t?i.open:i.close;return typeof a==`string`?a:a(this,e,n,r)}getEnclosingWhitespace(e){return{leading:(e.match(/^(\s+)/)||[void 0])[0],trailing:(e.match(/(\s+)$/)||[void 0])[0]}}isMarkAhead(e,t,n){for(;;t++){if(t>=e.childCount)return!1;let r=e.child(t);if(r.type.name!=this.options.hardBreakNodeName)return n.isInSet(r.marks);t++}}};function M2(e){let t={blockquote:{block:`blockquote`},paragraph:{block:`paragraph`},list_item:{block:`listItem`},bullet_list:{block:`bulletList`},ordered_list:{block:`orderedList`,getAttrs:e=>({start:+(e.attrGet(`start`)??1)||1})},heading:{block:`heading`,getAttrs:e=>({level:+e.tag.slice(1)})},code_block:{block:`codeBlock`,noCloseToken:!0,getAttrs:e=>({language:e.info?.trim()||null})},fence:{block:`codeBlock`,noCloseToken:!0,getAttrs:e=>({language:e.info?.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:e=>({href:BW(e.attrGet(`href`)),title:e.attrGet(`title`)||null})}},n={};for(let[r,i]of Object.entries(t))i.node&&!e.nodes[i.node]||i.block&&!e.nodes[i.block]||i.mark&&!e.marks[i.mark]||(n[r]=i);return n}function N2(e){return new E2(e,_2(`commonmark`,{html:!1}).enable([`strikethrough`,`linkify`]),M2(e))}function P2(e){return e?!!(/^\s{0,3}(#{1,6}\s|[-*+]\s|\d+[.)]\s|>\s|```|~~~|-{3,}\s*$|\*{3,}\s*$|_{3,}\s*$)/m.test(e)||/(\*\*\S(?:[^*\n]*\S)?\*\*|__\S(?:[^_\n]*\S)?__|\*\S(?:[^*\n]*\S)?\*|`[^`\n]+`|~~\S(?:[^~\n]*\S)?~~|\[[^\]\n]+\]\([^)\n]+\))/.test(e)):!1}function F2(e,t){if(!P2(e))return null;let n;try{let r=N2(t).parse(e);if(!r)return null;n=r}catch{return null}return n.childCount===0?null:Q.maxOpen(n.content)}var I2=V(`<div role="presentation" data-testid="editor-root"></div>`);function L2(e,t){O(t,!0);let n=new Set([...wa].filter(e=>e!==`.docx`));function r(e,t){let r=t.includes(`\\`)?`\\`:`/`,i=e.indexOf(`#`),a=i>=0?e.slice(0,i):e;if(!a)return null;let o=a.match(/\.[^./\\]+$/),s=o?o[0].toLowerCase():``;if(!n.has(s))return null;let c=t.split(r);c.pop();let l=a.replace(/\//g,r).split(r),u=[...c];for(let e of l)e===`..`?u.length>0&&u.pop():e!==`.`&&u.push(e);return u.join(r)}let i=j(null),a=null,o=A(()=>t.format===`docx`);L(()=>{if(t.ydoc,t.provider,!a)return;let e=new pU({element:a,extensions:[...qX(),jW.configure({document:t.ydoc}),PW.configure({provider:t.provider,user:{name:fj(),color:`var(--tandem-warning)`}}),eZ.configure({ydoc:t.ydoc}),sZ.configure({ydoc:t.ydoc}),zZ.configure({filePath:Ar(()=>t.currentFilePath??null)}),fZ.configure({ydoc:t.ydoc}),hZ.configure({ydoc:t.ydoc}),cQ.configure({onOpenChange:t.onSlashCommandMenuChange}),wZ,VZ],editorProps:{attributes:{class:`tandem-editor`,style:`outline: none; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;`},clipboardTextParser:(e,t,n,r)=>{if(!n){let t=F2(e,r.state.schema);if(t)return t}return LW(e,r.state.schema,t.marks())}},editable:Ar(()=>!t.readOnly),autofocus:Ar(()=>!t.readOnly)});M(i,e,!0),Ar(()=>t.onEditorReady?.(e));let n=qW(e,{openHref:e=>{c(e)}});return()=>{Ar(()=>t.onEditorReady?.(null)),n(),e.destroy(),z(i)===e&&M(i,null)}});let s;L(()=>{let e=z(i);if(!e)return;let n=t.readOnly;s!==n&&(s=n,e.setEditable(!n))}),L(()=>{let e=z(i);if(e)return mj(t=>e.commands.updateUser({name:t}))}),L(()=>{let e=z(i);if(!e)return;let n=e.view.dom;n.querySelectorAll(`.tandem-annotation-active`).forEach(e=>{e.classList.remove(`tandem-annotation-active`)}),t.activeAnnotationId&&n.querySelectorAll(`[data-annotation-id="${CSS.escape(t.activeAnnotationId)}"]`).forEach(e=>{e.classList.add(`tandem-annotation-active`)})});async function c(e){if(!(!e||e.startsWith(`#`))){if(zW(e)){window.open(e,`_blank`,`noopener,noreferrer`);return}if(t.currentFilePath){let n=r(e,t.currentFilePath);if(n){let e=await Eh(n);e.ok||console.warn(`[tandem] Could not open linked file "${n}": ${e.error}`)}}}}async function l(e){let n=e.target.closest(`a[href]`);if(n){let t=n.getAttribute(`href`)??``;if(!t||t.startsWith(`#`))return;e.preventDefault(),await c(t);return}let r={highlight:2,comment:1,note:0},i=e.target.closest(`[data-annotation-id]`),a=null,o=-1/0;for(;i;){let e=i.getAttribute(`data-annotation-id`);if(e){let t=r[i.getAttribute(`data-annotation-type`)??``]??-1;t>o&&(o=t,a=e)}let t=i.parentElement;i=t?t.closest(`[data-annotation-id]`):null}a&&t.onAnnotationClick?t.onAnnotationClick(a):a||t.onClearAnnotation?.()}var u=I2();let d;fa(u,e=>a=e,()=>a),R(()=>d=Ui(u,1,``,null,d,{"tandem-paged":z(o)})),B(`click`,u,l),H(e,u),k()}Br([`click`]);var R2=V(`<div data-testid="find-scope-pills" class="fr-scope svelte-1q9bff2"><span class="label svelte-1q9bff2">Scope</span> <button data-testid="find-scope-doc">This document</button> <button data-testid="find-scope-tabs">Open tabs</button></div>`),z2=V(`<div class="fr-msg error svelte-1q9bff2" role="alert"><span class="msg-ic svelte-1q9bff2" aria-hidden="true"><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"><path d="M12 9v4"></path><path d="M12 17h.01"></path><path d="M10.29 3.86l-8.16 14.14A2 2 0 0 0 3.84 21h16.32a2 2 0 0 0 1.71-3l-8.16-14.14a2 2 0 0 0-3.42 0z"></path></svg></span> <span> </span></div>`),B2=V(`<div class="fr-msg warning svelte-1q9bff2" role="status"> </div>`),V2=V(`<div class="fr-xdoc-status svelte-1q9bff2">Searching…</div>`),H2=V(`<div class="fr-xdoc-status svelte-1q9bff2">No matches in open tabs</div>`),U2=V(`<div class="fr-xdoc-snip svelte-1q9bff2"> </div>`),W2=V(`<div class="fr-xdoc-row svelte-1q9bff2"><div class="fr-xdoc-name svelte-1q9bff2"> <span class="fr-xdoc-count svelte-1q9bff2"> </span></div> <!></div>`),G2=V(`<div data-testid="find-cross-doc-results" class="fr-xdoc svelte-1q9bff2"><!></div>`),K2=V(`<div class="fr-anchor svelte-1q9bff2"><div data-testid="find-replace-bar" role="dialog" tabindex="-1" aria-modal="false" aria-label="Find and replace"><div class="fr-find svelte-1q9bff2"><span class="ic svelte-1q9bff2" aria-hidden="true"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"></circle><path d="m20 20-3.5-3.5"></path></svg></span> <input data-testid="find-input" type="text" placeholder="Find in document…" aria-label="Find in document" autocomplete="off" class="svelte-1q9bff2"/> <span data-testid="find-match-count"> </span> <span class="esc svelte-1q9bff2" aria-hidden="true">Esc</span></div> <div class="fr-controls svelte-1q9bff2"><div class="nav-group svelte-1q9bff2"><button data-testid="find-prev-btn" class="fr-nav svelte-1q9bff2" title="Previous match (⇧↵)" aria-label="Previous match"><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="M18 15l-6-6-6 6"></path></svg></button> <button data-testid="find-next-btn" class="fr-nav svelte-1q9bff2" title="Next match (↵)" aria-label="Next match"><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 9l6 6 6-6"></path></svg></button></div> <div class="toggles svelte-1q9bff2"><button data-testid="find-case-toggle" title="Case sensitive">Aa</button> <button data-testid="find-word-toggle" title="Whole word">\\b</button> <button data-testid="find-regex-toggle" title="Regular expression">.*</button></div> <span class="spacer svelte-1q9bff2"></span> <button data-testid="find-replace-expand-btn" aria-label="Toggle replace row" title="Toggle replace"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" class="svelte-1q9bff2"><path d="M6 9l6 6 6-6"></path></svg></button> <button data-testid="find-close-btn" class="fr-close svelte-1q9bff2" title="Close (Esc)" aria-label="Close find bar"><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></div> <div class="fr-replace svelte-1q9bff2"><span class="ic svelte-1q9bff2" aria-hidden="true"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><path d="M14 2v6h6"></path><path d="M9 15l3 3 3-3"></path><path d="M12 12v6"></path></svg></span> <input data-testid="replace-input" type="text" placeholder="Replace with…" aria-label="Replace with" autocomplete="off" class="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 primary svelte-1q9bff2"><!></button></div> <!> <!> <!> <!> <div class="fr-footer svelte-1q9bff2"><span class="kgrp svelte-1q9bff2"><span class="key svelte-1q9bff2">↵</span>next</span> <span class="kgrp svelte-1q9bff2"><span class="key svelte-1q9bff2">⇧</span><span class="key svelte-1q9bff2">↵</span>prev</span> <span class="spacer svelte-1q9bff2"></span> <span class="kgrp svelte-1q9bff2">Esc to close</span></div></div></div>`);function q2(e,t){O(t,!0);let n=q(t,`tabs`,19,()=>[]),r=j(`doc`),i=j(N([])),a=j(!1);L(()=>{n().length<=1&&z(r)===`tabs`&&(M(r,`doc`),M(i,[],!0),M(a,!1))});function o(e){let t=e.getXmlFragment(`default`),n=[];function r(e){if(e instanceof lE)n.push(e.toString());else{for(let t=0;t<e.length;t++){let n=e.get(t);(n instanceof lE||n instanceof iE)&&r(n)}e instanceof iE&&e.nodeName!==`text`&&n.push(` `)}}return r(t),n.join(``)}function s(e,t,n){let r=o(e),i=n?t:t.toLowerCase(),a=n?r:r.toLowerCase(),s=[],c=0,l=0;for(;(l=a.indexOf(i,l))!==-1;){if(c++,s.length<3){let e=Math.max(0,l-30),t=Math.min(r.length,l+i.length+30),n=r.slice(e,t).replace(/\s+/g,` `).trim();s.push((e>0?`…`:``)+n+(t<r.length?`…`:``))}l+=i.length}return{count:c,snippets:s}}let c;va(()=>clearTimeout(c));function l(e,t){if(clearTimeout(c),!e){M(i,[],!0),M(a,!1);return}M(a,!0),c=setTimeout(()=>{let r=[];for(let i of n()){if(!i.ydoc)continue;let{count:n,snippets:a}=s(i.ydoc,e,t);n>0&&r.push({tabId:i.id,fileName:i.fileName,count:n,snippets:a})}M(i,r,!0),M(a,!1)},300)}let u=j(``),d=j(``),f=j(!1),p=j(!1),m=j(!1),h=j(null),g=j(!1),_=j(null),v=j(null),y=j(!1),b=j(0),x=A(()=>(z(b),t.editor?TZ(t.editor.state):void 0)),S=A(()=>z(x)?.matches.length??0),ee=A(()=>z(x)?.activeIndex??-1),C=A(()=>z(r)===`doc`&&!!z(u)&&z(S)===0&&!z(h)),te=A(()=>z(r)!==`doc`||!z(u)?``:z(h)?`error`:z(S)===0?`0 matches`:`${z(ee)+1} / ${z(S)}`),w=j(null),ne=j(null);L(()=>{t.open&&z(w)?.focus()});let re=!1;L(()=>{let e=t.open&&!re;re=t.open,!(!e||!t.forceScope)&&(t.forceScope===`tabs`&&n().length>1?(M(r,`tabs`),l(z(u),z(f))):M(r,`doc`))}),L(()=>{if(!t.open)return;let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>cn(b);return e.on(`transaction`,n),()=>{e.isDestroyed||e.off(`transaction`,n)}});function T(){if(z(r)===`tabs`){l(z(u),z(f));return}let e=t.editor;if(!e||!z(u)){M(h,null),e?.commands.findClose();return}if(z(m))try{new RegExp(z(u)),M(h,null)}catch(e){M(h,e instanceof Error?e.message:`Invalid regex`,!0);return}else M(h,null);let n={query:z(u),caseSensitive:z(f),wholeWord:z(p),regexMode:z(m)};e.commands.find(n)}function ie(e){M(r,e,!0),e===`tabs`?(t.editor?.commands.findClose(),l(z(u),z(f))):(M(i,[],!0),clearTimeout(c),T())}function ae(){M(y,!z(y)),z(y)&&requestAnimationFrame(()=>z(ne)?.focus())}function oe(e){if(e.key===`Enter`){e.preventDefault(),e.shiftKey?t.editor?.commands.findPrev():t.editor?.commands.findNext();return}if(e.key===`Escape`){if(e.preventDefault(),e.stopPropagation(),z(y)){M(y,!1),z(w)?.focus();return}se()}}function se(){M(y,!1),t.editor?.commands.findClose(),t.onClose()}async function ce(){let e=t.editor;if(!e||!z(u)||z(g))return;let n=z(S);if(n>500&&!window.confirm(`Replace all ${n} occurrences? This cannot be undone as a single action.`))return;M(g,!0),M(v,null),M(_,{replaced:0,total:n},!0);let{replaced:r,partial:i}=await DZ(e.view,z(d),(e,t)=>{M(_,{replaced:e,total:t},!0)});M(_,null),M(g,!1),i&&M(v,`Replaced ${r} of ${n}; re-run to continue`)}var le=Xr(),ue=F(le),de=e=>{var o=K2(),s=P(o);let c;var l=P(s),x=I(P(l),2);$i(x),fa(x,e=>M(w,e),()=>z(w));var ee=I(x,2);let re;var le=P(ee,!0);E(ee),D(2),E(l);var ue=I(l,2),de=P(ue),fe=P(de),pe=I(fe,2);E(de);var me=I(de,2),he=P(me);let ge;var _e=I(he,2);let ve;var ye=I(_e,2);let be;E(me);var xe=I(me,4);let Se;var Ce=I(xe,2);E(ue);var we=I(ue,2),Te=I(P(we),2);$i(Te),fa(Te,e=>M(ne,e),()=>z(ne));var Ee=I(Te,2),De=I(Ee,2),Oe=P(De),ke=e=>{var t=Yr();R(()=>U(t,`${z(_).replaced??``}/${z(_).total??``}`)),H(e,t)},Ae=e=>{H(e,Yr(`All`))};W(Oe,e=>{z(g)&&z(_)?e(ke):e(Ae,-1)}),E(De),E(we);var je=I(we,2),Me=e=>{var t=R2(),n=I(P(t),2);let i;var a=I(n,2);let o;E(t),R(()=>{i=Ui(n,1,`fr-scope-pill svelte-1q9bff2`,null,i,{on:z(r)===`doc`}),K(n,`aria-pressed`,z(r)===`doc`),o=Ui(a,1,`fr-scope-pill svelte-1q9bff2`,null,o,{on:z(r)===`tabs`}),K(a,`aria-pressed`,z(r)===`tabs`)}),B(`click`,n,()=>ie(`doc`)),B(`click`,a,()=>ie(`tabs`)),H(e,t)};W(je,e=>{n().length>1&&e(Me)});var Ne=I(je,2),Pe=e=>{var t=z2(),n=I(P(t),2),r=P(n,!0);E(n),E(t),R(()=>U(r,z(h))),H(e,t)};W(Ne,e=>{z(h)&&e(Pe)});var Fe=I(Ne,2),Ie=e=>{var t=B2(),n=P(t,!0);E(t),R(()=>U(n,z(v))),H(e,t)};W(Fe,e=>{z(v)&&e(Ie)});var Le=I(Fe,2),Re=e=>{var t=G2(),n=P(t),r=e=>{H(e,V2())},o=e=>{H(e,H2())},s=e=>{var t=Xr();pi(F(t),17,()=>z(i),li,(e,t)=>{var n=W2(),r=P(n),i=P(r),a=I(i),o=P(a);E(a),E(r),pi(I(r,2),17,()=>z(t).snippets,li,(e,t)=>{var n=U2(),r=P(n,!0);E(n),R(()=>U(r,z(t))),H(e,n)}),E(n),R(()=>{U(i,`${z(t).fileName??``} `),U(o,`(${z(t).count??``} ${z(t).count===1?`match`:`matches`})`)}),H(e,n)}),H(e,t)};W(n,e=>{z(a)?e(r):z(u)&&z(i).length===0?e(o,1):e(s,-1)}),E(t),H(e,t)};W(Le,e=>{z(r)===`tabs`&&e(Re)}),D(2),E(s),E(o),R(()=>{c=Ui(s,1,`fr svelte-1q9bff2`,null,c,{"no-match":z(C)}),re=Ui(ee,1,`count svelte-1q9bff2`,null,re,{"no-match":z(C),err:!!z(h)}),U(le,z(te)),fe.disabled=z(S)===0,pe.disabled=z(S)===0,ge=Ui(he,1,`fr-toggle svelte-1q9bff2`,null,ge,{on:z(f)}),K(he,`aria-pressed`,z(f)),ve=Ui(_e,1,`fr-toggle svelte-1q9bff2`,null,ve,{on:z(p)}),K(_e,`aria-pressed`,z(p)),be=Ui(ye,1,`fr-toggle svelte-1q9bff2`,null,be,{on:z(m)}),K(ye,`aria-pressed`,z(m)),Se=Ui(xe,1,`fr-expand svelte-1q9bff2`,null,Se,{on:z(y)}),K(xe,`aria-expanded`,z(y)),K(we,`hidden`,!z(y)),Ee.disabled=z(S)===0||z(g)||z(r)===`tabs`,K(Ee,`title`,z(r)===`tabs`?`Replace is not available in Open tabs mode`:void 0),De.disabled=z(S)===0||z(g)||z(r)===`tabs`,K(De,`title`,z(r)===`tabs`?`Replace All is not available in Open tabs mode`:void 0)}),B(`keydown`,s,oe),B(`input`,x,T),aa(x,()=>z(u),e=>M(u,e)),B(`click`,fe,()=>t.editor?.commands.findPrev()),B(`click`,pe,()=>t.editor?.commands.findNext()),B(`click`,he,()=>{M(f,!z(f)),T()}),B(`click`,_e,()=>{M(p,!z(p)),T()}),B(`click`,ye,()=>{M(m,!z(m)),T()}),B(`click`,xe,ae),B(`click`,Ce,se),aa(Te,()=>z(d),e=>M(d,e)),B(`click`,Ee,()=>{t.editor&&(EZ(t.editor.view,z(d)),cn(b))}),B(`click`,De,ce),H(e,o)};W(ue,e=>{t.open&&e(de)}),H(e,le),k()}Br([`keydown`,`input`,`click`]);var J2=V(`<div class="source-view-warning svelte-fwjuih" data-testid="source-view-annotation-warning" role="status"> </div>`),Y2=V(`<div class="source-view-error svelte-fwjuih" data-testid="source-view-error" role="alert"> </div>`),X2=V(`<div class="source-view-loading svelte-fwjuih">Loading source…</div>`),Z2=V(`<textarea class="source-view-textarea svelte-fwjuih" data-testid="source-view-textarea" spellcheck="false" autocomplete="off" autocapitalize="off" aria-label="Markdown source"></textarea>`),Q2=V(`<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 $2(e,t){O(t,!0);let n=Ar(()=>t.initialDraft),r=j(``),i=j(``),a=j(!0),o=j(!1),s=j(null),c=A(()=>!z(a)&&z(i)!==z(r)),l=j(0);L(()=>{let e=t.ydoc.getMap(Ra),n=()=>{M(l,e.size,!0)};return n(),e.observe(n),()=>e.unobserve(n)}),L(()=>{let e=t.documentId,o=!1;return M(a,!0),M(s,null),(async()=>{try{let t=await fetch(`${Il}${Tc}?documentId=${encodeURIComponent(e)}`);if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}let a=await t.json();if(o)return;M(r,a.markdown??``,!0),M(i,n??z(r),!0)}catch(e){if(o)return;M(s,e instanceof Error?e.message:`Failed to load markdown source.`,!0)}finally{o||M(a,!1)}})(),()=>{o=!0}});async function u(){M(o,!0),M(s,null);try{let e=await fetch(`${Il}${Ec}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId,markdown:z(i)})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.message??e.statusText)}return M(r,z(i),!0),t.onDraftChange(z(i),!1),!0}catch(e){return M(s,e instanceof Error?e.message:`Failed to apply markdown changes.`,!0),!1}finally{M(o,!1)}}function d(e){let n=e.target.value;t.onDraftChange(n,n!==z(r))}async function f(){z(c)&&!await u()||t.onExit()}async function p(e){(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),e.stopPropagation(),z(c)&&!z(o)&&await u())}async function m(){try{await navigator.clipboard.writeText(z(i))}catch{}}var h=Q2(),g=P(h),_=P(g),v=I(_,4);E(g);var y=I(g,2),b=e=>{var t=J2(),n=P(t);E(t),R(()=>U(n,`Editing the source clears this document's ${z(l)??``} annotation${z(l)===1?``:`s`} when you return to the editor.`)),H(e,t)};W(y,e=>{z(l)>0&&e(b)});var x=I(y,2),S=e=>{var t=Y2(),n=P(t,!0);E(t),R(()=>U(n,z(s))),H(e,t)};W(x,e=>{z(s)&&e(S)});var ee=I(x,2),C=e=>{H(e,X2())},te=e=>{var t=Z2();En(t),B(`input`,t,d),B(`keydown`,t,p),aa(t,()=>z(i),e=>M(i,e)),H(e,t)};W(ee,e=>{z(a)?e(C):e(te,-1)}),E(h),R(()=>{_.disabled=z(o),v.disabled=z(a)}),B(`click`,_,f),B(`click`,v,m),H(e,h),k()}Br([`click`,`input`,`keydown`]);function e4(e,t){function n(n){e.contains(n.target)||t(n)}return document.addEventListener(`mousedown`,n),{destroy(){document.removeEventListener(`mousedown`,n)}}}var t4=V(`<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),n4=V(`<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
246
+ marks. Toggle a type to hide its marks in the document; side-panel cards
247
+ 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>`),r4=V(`<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 i4(e,t){O(t,!0);let n=j(!1),r=j(null);function i(){t.onUpdate({decorationsMuted:!t.decorationsMuted})}function a(e,n){t.onUpdate({[e]:!n,...t.decorationsMuted?{decorationsMuted:!1}:{}})}function o(){M(n,!1),z(r)?.focus()}function s(e){e.key===`Escape`&&z(n)&&(e.stopPropagation(),o())}function c(){t.onOpenSettings?.(),M(n,!1)}var l=r4();let u;var d=P(l);let f;var p=I(d,4);fa(p,e=>M(r,e),()=>z(r));var m=I(p,2),h=e=>{var n=n4(),r=I(P(n),4);let i;var o=I(r,2);let s;var l=I(o,2);let u;var d=I(l,2);let f;var p=I(d,2),m=e=>{var t=t4();B(`click`,I(F(t),2),c),H(e,t)};W(p,e=>{t.onOpenSettings&&e(m)}),E(n),R(()=>{i=Ui(r,1,`mi svelte-94a7fq`,null,i,{on:t.showAuthorship}),K(r,`aria-checked`,t.showAuthorship),s=Ui(o,1,`mi svelte-94a7fq`,null,s,{on:t.showComments}),K(o,`aria-checked`,t.showComments),u=Ui(l,1,`mi svelte-94a7fq`,null,u,{on:t.showHighlights}),K(l,`aria-checked`,t.showHighlights),f=Ui(d,1,`mi svelte-94a7fq`,null,f,{on:t.showNotes}),K(d,`aria-checked`,t.showNotes)}),B(`click`,r,()=>a(`showAuthorship`,t.showAuthorship)),B(`click`,o,()=>a(`showComments`,t.showComments)),B(`click`,l,()=>a(`showHighlights`,t.showHighlights)),B(`click`,d,()=>a(`showNotes`,t.showNotes)),H(e,n)};W(m,e=>{z(n)&&e(h)}),E(l),Pi(l,(e,t)=>e4?.(e,t),()=>()=>M(n,!1)),R(()=>{u=Ui(l,1,`split menu-wrap svelte-94a7fq`,null,u,{open:z(n)}),f=Ui(d,1,`ib half-main svelte-94a7fq`,null,f,{on:!t.decorationsMuted}),K(d,`aria-pressed`,!t.decorationsMuted),K(d,`title`,t.decorationsMuted?`Restore decorations`:`Mute decorations`),K(d,`aria-label`,t.decorationsMuted?`Restore decorations`:`Mute decorations`),K(p,`aria-expanded`,z(n))}),B(`keydown`,l,s),B(`click`,d,i),B(`click`,p,()=>M(n,!z(n))),H(e,l),k()}Br([`keydown`,`click`]);function a4(e,t,n,r={}){let{capture:i=!0}=r;function a(t){let r=e();r&&(t.target instanceof Node&&r.contains(t.target)||n(t))}for(let e of t)document.addEventListener(e,a,i);return()=>{for(let e of t)document.removeEventListener(e,a,i)}}function o4(e){let t=e.closest?.(`[data-tauri-drag-region]`);return!!t&&t.getAttribute(`data-tauri-drag-region`)!==`false`}function s4(e){return t=>{t.preventDefault(),e()}}function c4(e){let t=e.getAttributes(`link`).href;return t===void 0?``:typeof t==`string`?t:(console.warn(`[tandem] getInitialLinkHref: non-string href attribute`,{href:t}),``)}function l4(e,t){let n=t.trim();n?e.chain().focus().setLink({href:n}).run():e.isActive(`link`)&&e.chain().focus().unsetLink().run()}var u4=V(`<button type="button"><!></button>`);function d4(e,t){let n=q(t,`disabled`,3,!1),r=q(t,`active`,3,!1),i=q(t,`style`,3,``),a=A(()=>t.ariaLabel??(typeof t.label==`string`?t.label:void 0)),o=A(()=>z(a)??``),s=A(()=>n()&&t.disabledTitle?t.disabledTitle:t.shortcut?`${z(o)} (${t.shortcut})`:z(o));var c=u4();let l;var u=P(c),d=e=>{var n=Xr();bi(F(n),()=>t.children),H(e,n)},f=e=>{var n=Yr();R(()=>U(n,t.label)),H(e,n)};W(u,e=>{t.children?e(d):e(f,-1)}),E(c),R(()=>{l=Ui(c,1,`toolbar-btn svelte-xw5pw0`,null,l,{"is-active":r()}),K(c,`data-testid`,t.testId),c.disabled=n(),K(c,`title`,z(s)),K(c,`aria-label`,z(a)),K(c,`aria-pressed`,t.ariaPressed),K(c,`aria-haspopup`,t.ariaHasPopup),K(c,`aria-expanded`,t.ariaExpanded),G(c,i())}),B(`mousedown`,c,function(...e){t.onMouseDown?.apply(this,e)}),B(`click`,c,function(...e){t.onClick?.apply(this,e)}),H(e,c)}Br([`mousedown`,`click`]);var f4=Jr(`<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>`),p4=Jr(`<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>`),m4=V(`<!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div>`,1),h4=Jr(`<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>`),g4=V(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
248
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
249
+ border-radius: var(--tandem-r-3); padding: 6px;
250
+ display: flex; align-items: center; gap: 4px;
251
+ 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;
252
+ border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
253
+ background: var(--tandem-surface); color: var(--tandem-fg);
254
+ 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;
255
+ border: 1px solid var(--tandem-accent-border); background: transparent;
256
+ color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
257
+ 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;
258
+ border: 1px solid var(--tandem-border); background: transparent;
259
+ color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),_4=V(`<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),v4=V(`<button type="button" role="menuitemradio"> </button>`),y4=V(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
260
+ background: var(--tandem-surface); border: 1px solid var(--tandem-border);
261
+ border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
262
+ gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),b4=Jr(`<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>`),x4=Jr(`<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>`),S4=Jr(`<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>`),C4=Jr(`<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>`),w4=V(`<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 T4(e,t){O(t,!0);let n=q(t,`disabled`,3,!1),r=q(t,`variant`,3,`bar`),i=A(()=>r()===`bar`),a=A(()=>r()===`bar`),o=[1,2,3],s={1:700,2:600,3:500},c=j(0),l=j(!1),u=j(!1),d=j(``),f=j(null);L(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>{e.isDestroyed||cn(c)};return e.on(`transaction`,n),()=>{e.isDestroyed||e.off(`transaction`,n)}}),L(()=>{z(u)&&(z(f)?.focus(),z(f)?.select())});function p(e){for(let t of o)if(e.isActive(`heading`,{level:t}))return t;return null}let m=A(()=>t.editor?t.editor.isEditable:!1),h=A(()=>!z(m)||!!n()),g=A(()=>(z(c),t.editor?EU.getState(t.editor.state):null)),_=A(()=>!z(h)&&(z(g)?.undoManager?.undoStack.length??0)>0),v=A(()=>!z(h)&&(z(g)?.undoManager?.redoStack.length??0)>0),y=A(()=>(z(c),t.editor?p(t.editor):null)),b=A(()=>(z(c),!!t.editor?.isActive(`bold`))),x=A(()=>(z(c),!!t.editor?.isActive(`italic`))),S=A(()=>(z(c),!!t.editor?.isActive(`strike`))),ee=A(()=>(z(c),!!t.editor?.isActive(`code`))),C=A(()=>(z(c),!!t.editor?.isActive(`bulletList`))),te=A(()=>(z(c),!!t.editor?.isActive(`orderedList`))),w=A(()=>(z(c),!!t.editor?.isActive(`blockquote`))),ne=A(()=>(z(c),!!t.editor?.isActive(`codeBlock`))),re=A(()=>(z(c),!!t.editor?.isActive(`link`))),T=A(()=>(z(c),t.editor?z(h)||!t.editor.isActive(`link`)&&t.editor.state.selection.from===t.editor.state.selection.to:!0)),ie=A(()=>z(y)?`H${z(y)}`:`H`),ae=A(()=>s4(()=>t.editor?.commands.undo())),oe=A(()=>s4(()=>t.editor?.commands.redo())),se=A(()=>s4(()=>t.editor?.chain().focus().toggleBold().run())),ce=A(()=>s4(()=>t.editor?.chain().focus().toggleItalic().run())),le=A(()=>s4(()=>t.editor?.chain().focus().toggleStrike().run())),ue=A(()=>s4(()=>t.editor?.chain().focus().toggleCode().run())),de=A(()=>s4(()=>t.editor?.chain().focus().toggleBulletList().run())),fe=A(()=>s4(()=>t.editor?.chain().focus().toggleOrderedList().run())),pe=A(()=>s4(()=>t.editor?.chain().focus().toggleBlockquote().run())),me=A(()=>s4(()=>t.editor?.chain().focus().setHorizontalRule().run())),he=A(()=>s4(()=>t.editor?.chain().focus().toggleCodeBlock().run()));function ge(e){return t=>{t.detail===0&&e(t)}}function _e(e){return n=>{n.preventDefault(),!(!t.editor||t.editor.isDestroyed)&&(t.editor.chain().focus().toggleHeading({level:e}).run(),M(l,!1))}}function ve(e){e.preventDefault(),t.editor&&(M(d,c4(t.editor),!0),M(u,!0))}function ye(){t.editor&&(l4(t.editor,z(d)),be())}function be(){M(u,!1),M(d,``)}function xe(e){e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),ye()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),be())}var Se=Xr(),Ce=F(Se),we=e=>{var t=w4(),n=P(t),r=e=>{var t=m4(),n=F(t);{let e=e=>{H(e,f4())},t=A(()=>!z(_)),r=A(()=>ge(z(ae)));d4(n,{ariaLabel:`Undo`,shortcut:`Ctrl+Z`,get disabled(){return z(t)},get onMouseDown(){return z(ae)},get onClick(){return z(r)},children:e,$$slots:{default:!0}})}var r=I(n,2);{let e=e=>{H(e,p4())},t=A(()=>!z(v)),n=A(()=>ge(z(oe)));d4(r,{ariaLabel:`Redo`,shortcut:`Ctrl+Shift+Z`,get disabled(){return z(t)},get onMouseDown(){return z(oe)},get onClick(){return z(n)},children:e,$$slots:{default:!0}})}D(2),H(e,t)};W(n,e=>{z(i)&&e(r)});var c=I(n,2);{let e=A(()=>ge(z(se)));d4(c,{label:`B`,shortcut:`Ctrl+B`,get disabled(){return z(h)},get active(){return z(b)},get onMouseDown(){return z(se)},get onClick(){return z(e)},style:`font-weight: 700;`})}var p=I(c,2);{let e=A(()=>ge(z(ce)));d4(p,{label:`I`,shortcut:`Ctrl+I`,get disabled(){return z(h)},get active(){return z(x)},get onMouseDown(){return z(ce)},get onClick(){return z(e)},style:`font-style: italic;`})}var m=I(p,2);{let e=A(()=>ge(z(le)));d4(m,{label:`S`,shortcut:`Ctrl+Shift+X`,get disabled(){return z(h)},get active(){return z(S)},get onMouseDown(){return z(le)},get onClick(){return z(e)},style:`text-decoration: line-through;`})}var g=I(m,2);{let e=A(()=>ge(z(ue)));d4(g,{label:`<>`,shortcut:`Ctrl+E`,get disabled(){return z(h)},get active(){return z(ee)},get onMouseDown(){return z(ue)},get onClick(){return z(e)},style:`font-family: monospace;`})}var Se=I(g,2),Ce=P(Se);{let e=e=>{H(e,h4())},t=A(()=>z(re)||z(u)),n=A(()=>ge(ve));d4(Ce,{ariaLabel:`Link`,shortcut:`Ctrl+K`,get disabled(){return z(T)},get active(){return z(t)},ariaHasPopup:`dialog`,get ariaExpanded(){return z(u)},onMouseDown:ve,get onClick(){return z(n)},children:e,$$slots:{default:!0}})}var we=I(Ce,2),Te=e=>{var t=g4(),n=P(t);$i(n),fa(n,e=>M(f,e),()=>z(f));var r=I(n,2),i=A(()=>ge(e=>{e.preventDefault(),ye()})),a=I(r,2),o=A(()=>ge(e=>{e.preventDefault(),be()}));E(t),B(`keydown`,n,xe),aa(n,()=>z(d),e=>M(d,e)),B(`mousedown`,r,e=>{e.preventDefault(),ye()}),B(`click`,r,function(...e){z(i)?.apply(this,e)}),B(`mousedown`,a,e=>{e.preventDefault(),be()}),B(`click`,a,function(...e){z(o)?.apply(this,e)}),H(e,t)};W(we,e=>{z(u)&&e(Te)}),E(Se),Pi(Se,(e,t)=>e4?.(e,t),()=>be);var Ee=I(Se,4),De=P(Ee);{let e=e=>{var t=_4(),n=F(t),r=P(n,!0);E(n),D(2),R(()=>U(r,z(ie))),H(e,t)},t=A(()=>z(y)?`Heading ${z(y)}`:`Heading`),n=A(()=>z(y)!==null),r=A(()=>ge(e=>{e.preventDefault(),M(l,!z(l))}));d4(De,{get ariaLabel(){return z(t)},get disabled(){return z(h)},get active(){return z(n)},ariaHasPopup:`menu`,get ariaExpanded(){return z(l)},style:`gap: 2px; padding-right: 4px;`,onMouseDown:e=>{e.preventDefault(),M(l,!z(l))},get onClick(){return z(r)},children:e,$$slots:{default:!0}})}var Oe=I(De,2),ke=e=>{var t=y4();pi(t,20,()=>o,e=>e,(e,t)=>{let n=A(()=>_e(t));var r=v4(),i=A(()=>ge(z(n))),a=P(r);E(r),R(()=>{K(r,`aria-checked`,z(y)===t),G(r,`padding: 4px 12px; font-size: 13px; border: none;
263
+ border-radius: var(--tandem-r-2);
264
+ background: ${z(y)===t?`var(--tandem-accent-bg)`:`transparent`};
265
+ color: ${z(y)===t?`var(--tandem-accent)`:`var(--tandem-fg)`};
266
+ cursor: pointer; text-align: left;
267
+ font-weight: ${s[t]??``}; white-space: nowrap;`),U(a,`Heading ${t??``}`)}),B(`mousedown`,r,function(...e){z(n)?.apply(this,e)}),B(`click`,r,function(...e){z(i)?.apply(this,e)}),H(e,r)}),E(t),H(e,t)};W(Oe,e=>{z(l)&&e(ke)}),E(Ee),Pi(Ee,(e,t)=>e4?.(e,t),()=>()=>M(l,!1));var Ae=I(Ee,2);{let e=e=>{H(e,b4())},t=A(()=>ge(z(de)));d4(Ae,{ariaLabel:`Bullet list`,shortcut:`Ctrl+Shift+8`,get disabled(){return z(h)},get active(){return z(C)},get onMouseDown(){return z(de)},get onClick(){return z(t)},children:e,$$slots:{default:!0}})}var je=I(Ae,2);{let e=e=>{H(e,x4())},t=A(()=>ge(z(fe)));d4(je,{ariaLabel:`Ordered list`,shortcut:`Ctrl+Shift+7`,get disabled(){return z(h)},get active(){return z(te)},get onMouseDown(){return z(fe)},get onClick(){return z(t)},children:e,$$slots:{default:!0}})}var Me=I(je,2);{let e=e=>{H(e,S4())},t=A(()=>ge(z(pe)));d4(Me,{ariaLabel:`Blockquote`,shortcut:`Ctrl+Shift+B`,get disabled(){return z(h)},get active(){return z(w)},get onMouseDown(){return z(pe)},get onClick(){return z(t)},children:e,$$slots:{default:!0}})}var Ne=I(Me,2),Pe=e=>{{let t=A(()=>ge(z(me)));d4(e,{label:`—`,ariaLabel:`Horizontal rule`,get disabled(){return z(h)},get onMouseDown(){return z(me)},get onClick(){return z(t)}})}};W(Ne,e=>{z(a)&&e(Pe)});var Fe=I(Ne,2);{let e=e=>{H(e,C4())},t=A(()=>ge(z(he)));d4(Fe,{ariaLabel:`Code block`,get disabled(){return z(h)},get active(){return z(ne)},get onMouseDown(){return z(he)},get onClick(){return z(t)},children:e,$$slots:{default:!0}})}E(t),B(`keydown`,Se,e=>{e.key===`Escape`&&be()}),B(`keydown`,Ee,e=>{e.key===`Escape`&&M(l,!1)}),H(e,t)};W(Ce,e=>{t.editor&&e(we)}),H(e,Se),k()}Br([`keydown`,`mousedown`,`click`]);function E4(e,t,n){let r=e.getMap(Ra),i=null,a;for(let[e,n]of r.entries())if(n.type===`highlight`&&n.range.from===t.from&&n.range.to===t.to&&n.author===`user`&&n.status===`pending`&&n.content===``){i=e,a=n.color;break}if(i===null){let i=lc(),a={id:i,author:`user`,type:`highlight`,audience:`private`,range:{from:t.from,to:t.to},content:``,status:`pending`,timestamp:Date.now(),color:n};return rk(e,()=>r.set(i,a)),`added`}if(a===n)return rk(e,()=>r.delete(i)),`removed`;let o=lc(),s={id:o,author:`user`,type:`highlight`,audience:`private`,range:{from:t.from,to:t.to},content:``,status:`pending`,timestamp:Date.now(),color:n};return rk(e,()=>{r.delete(i),r.set(o,s)}),`recolored`}function D4(e,t){let n=e.getMap(Ra),r=[];for(let[e,i]of n.entries())i.type===`highlight`&&i.range.from===t.from&&i.range.to===t.to&&i.author===`user`&&i.status===`pending`&&i.content===``&&r.push(e);return r.length===0?`noop`:(rk(e,()=>{for(let e of r)n.delete(e)}),`removed`)}function O4({anchorX:e,anchorY:t,toolbarHeight:n,toolbarWidth:r,viewportHeight:i,viewportWidth:a,previousPlacement:o}){let s=Math.max(8,a-8-r),c=t+6,l=c+n,u=t-6-n,d=i-8,f=l<=(o===`below`?d+4:d-4),p=u>=48,m=Math.max(48,i-n-8),h,g;f?(h=c,g=`below`):p?(h=u,g=`above`):(h=m,g=`below`);let _=i-(t-6);return{left:Math.min(Math.max(e,8),s),top:Math.min(Math.max(h,48),m),bottom:_,placement:g}}function k4(e,t){return e.on(`selectionUpdate`,t),()=>e.off(`selectionUpdate`,t)}var A4=V(`<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),j4=V(`<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),M4=V(`<button type="button"></button>`),N4=V(`<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 P4(e,t){O(t,!0);let n=q(t,`selectionToolbar`,3,!0),r=q(t,`suppressSelectionToolbar`,3,!1),i=q(t,`requestCommentFocus`,3,0),a=q(t,`showAuthorship`,3,!0),o=q(t,`showComments`,3,!0),s=q(t,`showHighlights`,3,!0),c=q(t,`showNotes`,3,!0),l=q(t,`decorationsMuted`,3,!1),u=q(t,`formattingBarVisible`,3,!0),d=q(t,`reduceMotion`,3,!1),f=iD(av()),p=j(!1),m=j(null),h=j(null),g=j(``),_=j(null),v=j(null),y=j(!1),b=j(!1),x=j(!1),S,ee,C=-1,te=-1,w=!1,ne=0,re=0,T=0,ie=0,ae=null,oe=null,se=!1;function ce(){ae=w?ne:T,oe=w?re:ie,!fv(d())&&(M(x,!0),clearTimeout(ee),ee=setTimeout(()=>{M(x,!1)},440))}function le(){clearTimeout(S),clearTimeout(ee),M(b,!1),M(x,!1),C=-1,te=-1,ae=null,oe=null,w=!1}function ue(e,t,n){C=e,te=t,w=n,clearTimeout(S),S=setTimeout(()=>{ce(),M(b,!0)},100)}let de=il(),fe=de?`⌥⏎`:`Alt+⏎`,pe=de?`⌘⏎`:`Ctrl+⏎`,me=A(()=>{let e=z(m);if(!e)return``;let t=e.placement===`above`?`bottom: ${e.bottom}px; top: auto;`:`top: ${e.top}px; bottom: auto;`;return`left: ${e.left}px; ${t}`}),he=j(0),ge=j(N(window.innerHeight)),_e=j(N(window.innerWidth)),ve=Object.keys(Oa),ye=A(()=>!!t.editor&&!!t.ydoc&&z(p)),be=A(()=>n()&&!r()&&z(ye)&&z(m)!==null&&z(b)),xe=A(()=>z(g).trim()),Se,Ce=0,we=0;function Te(e){let{from:t,to:n}=e.state.selection,r=t!==n;if(M(p,r),!r){M(m,null),Se=void 0,we=0,le(),document.activeElement!==z(v)&&M(y,!1);return}!z(b)&&!se&&(t!==C||n!==te)&&ue(t,n,!1);try{let t=e.view.coordsAtPos(e.state.selection.head);T=t.left,ie=t.bottom;let n=O4({anchorX:ae??T,anchorY:oe??ie,toolbarHeight:200,toolbarWidth:z(he),viewportHeight:z(ge),viewportWidth:z(_e),previousPlacement:Se});if(Se=n.placement,we=0,z(m)&&z(m).left===n.left&&z(m).top===n.top&&z(m).bottom===n.bottom&&z(m).placement===n.placement)return;M(m,{left:n.left,top:n.top,bottom:n.bottom,placement:n.placement},!0)}catch{if(we>=3){we=0,M(m,null),Se=void 0;return}we+=1,cancelAnimationFrame(Ce),Ce=requestAnimationFrame(()=>{e.isDestroyed||Te(e)})}}L(()=>{if(!t.editor)return;let e=t.editor;function n(){Te(e)}let r=e.view.dom,i=r.ownerDocument;function a(e){e.button!==0||!e.isPrimary||(se=!0)}function o(t){if(!se)return;se=!1,ne=t.clientX,re=t.clientY;let{from:n,to:r}=e.state.selection;n!==r&&!z(b)&&ue(n,r,!0)}function s(){se=!1}r.addEventListener(`pointerdown`,a),i.addEventListener(`pointerup`,o),i.addEventListener(`pointercancel`,s);let c=k4(e,n);return n(),()=>{r.removeEventListener(`pointerdown`,a),i.removeEventListener(`pointerup`,o),i.removeEventListener(`pointercancel`,s),cancelAnimationFrame(Ce),Ce=0,clearTimeout(S),clearTimeout(ee),c()}}),L(()=>{if(!t.editor||!z(m))return;let e=t.editor,n=0;function r(){cancelAnimationFrame(n),n=requestAnimationFrame(()=>{M(ge,window.innerHeight,!0),M(_e,window.innerWidth,!0),Te(e)})}window.addEventListener(`resize`,r);let i=!1;requestAnimationFrame(()=>{i=!0});let a=a4(()=>z(h),[`scroll`],()=>{i&&document.activeElement!==z(v)&&Me()});return()=>{cancelAnimationFrame(n),window.removeEventListener(`resize`,r),a()}}),L(()=>{let e=t.editor,n=z(h);if(!e||!n||!z(m))return;let r=z(x),i=()=>{if(document.activeElement!==z(v)){if(z(x)){z(he)===0&&(M(he,n.scrollWidth,!0),Te(e));return}M(he,n.getBoundingClientRect().width,!0),Te(e)}};r||i();let a=new ResizeObserver(i);return a.observe(n),()=>a.disconnect()}),L(()=>{z(be)&&!z(_)&&Oe(),z(be)||(M(_,null),document.activeElement!==z(v)&&M(g,``))});let Ee=0;L(()=>{if(i()===Ee||(Ee=i(),i()===0||!t.editor))return;let{from:e,to:n}=t.editor.state.selection;e!==n&&(Ar(()=>Oe()),M(y,!0),M(b,!0),ce(),requestAnimationFrame(()=>z(v)?.focus()))}),L(()=>{if(!t.editor||!z(be))return;let e=t.editor,n=()=>{document.activeElement!==z(v)&&Oe()};return e.on(`selectionUpdate`,n),()=>{e.isDestroyed||e.off(`selectionUpdate`,n)}}),L(()=>{if(!z(be))return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Me())}return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});function De(e,n,r){if(!t.editor||!t.ydoc||e!==`highlight`&&!n.trim())return;let{from:i,to:a}=z(_)??t.editor.state.selection;if(i===a)return;let o=dD(t.editor.state.doc,Co(i)),s=dD(t.editor.state.doc,Co(a)),c=lc(),l={id:c,author:`user`,type:e,audience:e===`highlight`||e===`note`?`private`:`outbound`,range:{from:o,to:s},content:n,status:`pending`,timestamp:Date.now(),...r?.color?{color:r.color}:{}};return rk(t.ydoc,()=>t.ydoc.getMap(Ra).set(c,l)),M(_,null),c}function Oe(){if(!t.editor)return;let{from:e,to:n}=t.editor.state.selection;M(_,{from:e,to:n},!0)}function ke(e){if(!t.editor||!t.ydoc)return;let{from:n,to:r}=z(_)??t.editor.state.selection;if(n===r)return;let i=dD(t.editor.state.doc,Co(n)),a=dD(t.editor.state.doc,Co(r));E4(t.ydoc,{from:i,to:a},e),M(_,null),t.editor.chain().setTextSelection(r).run()}function Ae(){if(!t.editor||!t.ydoc)return;let{from:e,to:n}=z(_)??t.editor.state.selection;if(e===n)return;let r=dD(t.editor.state.doc,Co(e)),i=dD(t.editor.state.doc,Co(n));D4(t.ydoc,{from:r,to:i}),M(_,null),t.editor.chain().setTextSelection(n).run()}function je(e){return t=>{t.detail===0&&e(t)}}function Me(){M(p,!1),M(m,null),M(_,null),M(g,``),M(y,!1),le(),t.editor?.chain().focus().run()}function Ne(){M(y,!0),requestAnimationFrame(()=>z(v)?.focus())}function Pe(){if(!z(xe))return;let e=z(h)?.getBoundingClientRect(),t=De(`comment`,z(xe));t&&e&&xv(t,e),window.dispatchEvent(new CustomEvent(`tandem:addressed-ai`,{detail:{via:`comment`}})),Me()}function Fe(){if(!z(xe))return;let e=z(h)?.getBoundingClientRect(),t=De(`note`,z(xe));t&&e&&xv(t,e),Me()}function Ie(e){e.key===`Enter`&&e.altKey?(e.preventDefault(),Fe()):e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),Pe()):e.key===`Escape`&&(e.preventDefault(),Me())}var Le=Xr(),Re=F(Le),ze=e=>{var n=N4();let r;var i=P(n);let p;var _=P(i),b=P(_),x=P(b),S=P(x);T4(S,{get editor(){return t.editor},variant:`popup`});var ee=I(S,2),C=e=>{var n=A4(),r=I(F(n),2);i4(P(r),{get showAuthorship(){return a()},get showComments(){return o()},get showHighlights(){return s()},get showNotes(){return c()},get decorationsMuted(){return l()},get onUpdate(){return t.onUpdateDecorations},get onOpenSettings(){return t.onOpenSettings}}),E(r),B(`mousedown`,r,e=>e.preventDefault()),H(e,n)};W(ee,e=>{t.onUpdateDecorations&&e(C)});var te=I(ee,2),w=e=>{var n=j4(),r=I(F(n),2),i=A(()=>je(()=>t.onToggleFormattingBar?.())),a=P(r),o=P(a);E(a),E(r),R(()=>{K(r,`aria-label`,u()?`Hide formatting bar`:`Show formatting bar`),K(r,`title`,u()?`Hide formatting bar`:`Show formatting bar`),K(o,`d`,u()?`m18 15-6-6-6 6`:`m6 9 6 6 6-6`)}),B(`mousedown`,r,e=>{e.preventDefault(),t.onToggleFormattingBar?.()}),B(`click`,r,function(...e){z(i)?.apply(this,e)}),H(e,n)};W(te,e=>{t.onToggleFormattingBar&&e(w)}),E(x);var ne=I(x,2),re=P(ne),T=P(re),ie=A(()=>je(()=>{Ae(),t.editor?.chain().focus().run()}));pi(I(T,2),17,()=>ve,li,(e,n)=>{var r=M4(),i=A(()=>je(()=>{ke(z(n)),t.editor?.chain().focus().run()}));R(()=>{K(r,`data-testid`,`popup-highlight-${z(n)}`),K(r,`aria-label`,`Highlight ${z(n)}`),K(r,`title`,`Highlight ${z(n)}`),G(r,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${ka[z(n)]}; cursor: pointer; padding: 0;`)}),B(`mousedown`,r,e=>{e.preventDefault(),ke(z(n)),t.editor?.chain().focus().run()}),B(`click`,r,function(...e){z(i)?.apply(this,e)}),H(e,r)}),E(re);var ae=I(re,4),oe=A(()=>je(()=>Ne()));E(ne),E(b),E(_),E(i);var se=I(i,2);let ce;var le=P(se),ue=P(le),de=P(ue);En(de),K(de,`rows`,1),fa(de,e=>M(v,e),()=>z(v));var he=I(de,2),ge=P(he),_e=I(P(ge)),ye=P(_e,!0);E(_e),E(ge);var be=I(ge,2),Se=P(be),Ce=I(Se),we=P(Ce,!0);E(Ce),E(be),E(he),E(ue),E(le),E(se),E(n),fa(n,e=>M(h,e),()=>z(h)),R(()=>{r=Ui(n,1,`tandem-floating-pill selection-popup svelte-1tvmluw`,null,r,{"is-annotate":z(y),"is-below":z(m).placement===`below`}),G(n,z(me)),p=Ui(i,1,`morph-block morph-format svelte-1tvmluw`,null,p,{"is-active":!z(y)}),i.inert=z(y),ce=Ui(se,1,`morph-block morph-annotate svelte-1tvmluw`,null,ce,{"is-active":z(y)}),se.inert=!z(y),K(ge,`title`,`Note to self — private, not sent to ${f.family??``} (Alt+Enter)`),ge.disabled=!z(xe),U(ye,fe),K(be,`aria-label`,`Send to ${f.family??``} (Ctrl+Enter)`),K(be,`title`,`Send to ${f.family??``} — outbound comment (Ctrl/Cmd+Enter)`),be.disabled=!z(xe),U(Se,`Send to ${f.family??``} `),U(we,pe)}),B(`mousedown`,b,e=>e.preventDefault()),B(`mousedown`,T,e=>{e.preventDefault(),Ae(),t.editor?.chain().focus().run()}),B(`click`,T,function(...e){z(ie)?.apply(this,e)}),B(`mousedown`,ae,e=>{e.preventDefault(),Ne()}),B(`click`,ae,function(...e){z(oe)?.apply(this,e)}),B(`keydown`,de,Ie),aa(de,()=>z(g),e=>M(g,e)),B(`click`,ge,Fe),B(`click`,be,Pe),Mi(1,n,()=>Dv,()=>({reduceMotion:d()})),H(e,n)};W(Re,e=>{z(be)&&z(m)&&e(ze)}),H(e,Le),k()}Br([`mousedown`,`click`,`keydown`]);function F4(e,t=document.documentElement){let n=Math.max(0,Math.min(360,Math.round(e)));return t.style.setProperty(`--tandem-accent-h`,`${n}deg`),()=>t.style.removeProperty(`--tandem-accent-h`)}function I4(e){L(()=>F4(e()))}var L4=8e3;function R4(e){let t=j(null),n=j(!1),r=j(!1),i=0,a=0,o=!1;async function s(e){let n;try{n=await fetch(`${Il}${zc}`)}catch{return}if(e===i&&n.ok)try{M(t,await n.json(),!0),M(r,!0)}catch{}}async function c(){let e;try{e=await fetch(`${Il}${gc}`)}catch{return null}if(!e.ok)return null;try{let t=await e.json();return typeof t.hasSession==`boolean`?t.hasSession:null}catch{return null}}async function l(){let e=++a,t=await c();return t!==null&&e===a&&!o&&M(n,t,!0),t}async function u(){return await l()??z(n)}function d(){s(++i),l()}d();let f=setInterval(()=>d(),L4);va(()=>{i++,o=!0,clearInterval(f)});let p=A(()=>!e.firstRunSettled()||!e.connected()||!z(r)||z(t)===null?`booting`:z(n)?`ready`:z(t).available===!1?`unconfigured`:z(t).running===!0?`ready`:`stopped`),m=A(()=>e.soloMode()?null:z(p)===`unconfigured`?`connect`:z(p)===`stopped`?`restart`:null);return{get state(){return z(p)},get chip(){return z(m)},refresh:()=>d(),probeSession:u}}function z4(e,t=document.documentElement){return e?t.setAttribute(`data-annotation-patterns`,`true`):t.removeAttribute(`data-annotation-patterns`),()=>t.removeAttribute(`data-annotation-patterns`)}function B4(e){L(()=>z4(e()))}function V4(e){let t=j(N(new Map));return L(()=>{let n=e.getYdoc();if(!n){z(t).size>0&&M(t,new Map,!0);return}let r=n.getMap(Ga),i=()=>{M(t,H4(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return z(t)}}}function H4(e){let t=new Map;e.forEach(e=>{let n=e;if(!n||typeof n!=`object`||!n.annotationId)return;let r=t.get(n.annotationId)??[];r.push(n),t.set(n.annotationId,r)});for(let e of t.values())e.sort((e,t)=>e.timestamp-t.timestamp);return t}var U4=25;function W4(e=U4){let t=N([]);return{push(n){if(!(t.length&&t[t.length-1].filePath===n.filePath))for(t.push(n);t.length>e;)t.shift()},pop(){return t.pop()??null},peek(){return t.length?t[t.length-1]:null},get top(){return t.length?t[t.length-1]:null},size(){return t.length},clear(){t.length=0}}}function G4(e,t=()=>Da){let n=j(!1),r=j(!1);return L(()=>{let i=e();if(i==null){M(n,!1),M(r,!1);return}let a=Date.now()-i,o=t()-a;if(o<=0){M(n,!0);return}let s=setTimeout(()=>{M(n,!0)},o);return()=>clearTimeout(s)}),{get showBanner(){return z(n)&&!z(r)},dismiss(){M(r,!0)}}}function K4(e,t=document.documentElement){return t.setAttribute(`data-density`,e),()=>t.removeAttribute(`data-density`)}function q4(e){L(()=>K4(e()))}function J4(e){let t=Pa[e];try{let e=localStorage.getItem(t);if(e){let n=parseInt(e,10);if(Number.isFinite(n))return Math.max(200,Math.min(600,n));console.warn(`[tandem] ignoring non-numeric panel width for ${t}: ${e}`)}}catch(e){console.warn(`[tandem] localStorage unavailable reading ${t}:`,e)}return 300}function Y4(e){let{side:t}=e,n=Pa[t],r=j(N(e.initialWidth)),i=null;return L(()=>{!e.getVisible()&&i&&(document.removeEventListener(`mousemove`,i.move),document.removeEventListener(`mouseup`,i.up),i=null,document.body.style.userSelect=``,document.body.style.cursor=``)}),L(()=>()=>{i&&=(document.removeEventListener(`mousemove`,i.move),document.removeEventListener(`mouseup`,i.up),document.body.style.userSelect=``,document.body.style.cursor=``,null)}),{get width(){return z(r)},handleResizeStart:a=>{a.preventDefault();let o=a.clientX,s=z(r),c=s;document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`;let l=e=>{let n=e.clientX-o,i=t===`left`?s+n:s-n;c=Math.max(200,Math.min(600,i)),M(r,c,!0)},u=()=>{if(document.removeEventListener(`mousemove`,l),document.removeEventListener(`mouseup`,u),i=null,document.body.style.userSelect=``,document.body.style.cursor=``,e.getVisible())try{localStorage.setItem(n,String(c))}catch(e){console.warn(`[tandem] failed to persist ${n}:`,e)}};i={move:l,up:u},document.addEventListener(`mousemove`,l),document.addEventListener(`mouseup`,u)},handleResizeStep:t=>{let i=Math.max(200,Math.min(600,z(r)+t));if(M(r,i,!0),e.getVisible())try{localStorage.setItem(n,String(i))}catch(e){console.warn(`[tandem] failed to persist ${n}:`,e)}}}}var X4={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 Z4(e){let t=document.documentElement;return t.style.setProperty(`--tandem-editor-font-family`,X4[e]),()=>t.style.removeProperty(`--tandem-editor-font-family`)}function Q4(e){L(()=>Z4(e()))}function $4(){let e=j(!1);return{get fileDragOver(){return z(e)},handleEditorDragOver:t=>{Bm()||t.dataTransfer?.types.includes(`Files`)&&(t.preventDefault(),M(e,!0))},handleEditorDragLeave:t=>{Bm()||(t.currentTarget===t.target||!t.currentTarget.contains(t.relatedTarget))&&M(e,!1)},handleEditorDrop:async t=>{if(Bm()||(M(e,!1),!t.dataTransfer?.files.length))return;t.preventDefault();let n=t.dataTransfer.files[0],r=await zl(n);try{let e=await fetch(`${Il}${xc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileName:n.name,content:r})});if(!e.ok){let t=await e.json().catch(()=>({message:`Upload failed`}));console.error(`[useFileDrop] Upload failed:`,e.status,t.message??t.error)}}catch{console.error(`[useFileDrop] Server unreachable — file drop ignored`)}}}}function e3(e){return!!e?.query}function t3(){let e=j(null),t=j(null),n=j(null),r=j(!1),i=0;async function a(){let a=++i;try{let o=await fetch(ng,{credentials:`same-origin`});if(!o.ok){if(a!==i)return;M(e,!1),M(t,null),M(n,null),M(r,!0);return}let s=await o.json();if(a!==i)return;M(e,s.needed===!0),M(t,typeof s.serverVersion==`string`?s.serverVersion:null,!0),M(n,typeof s.confirmationNonce==`string`?s.confirmationNonce:null,!0),M(r,!0)}catch{if(a!==i)return;M(e,!1),M(t,null),M(n,null),M(r,!0)}}return a(),{get needed(){return z(e)},get serverVersion(){return z(t)},get confirmationNonce(){return z(n)},get settled(){return z(r)},refetch:a}}function n3(e,t=document.documentElement){return e?t.setAttribute(`data-high-contrast`,`true`):t.removeAttribute(`data-high-contrast`),()=>t.removeAttribute(`data-high-contrast`)}function r3(e){L(()=>n3(e()))}function i3(e,t,n,r){let i=new Map,a=0,o=0;for(let s of e){let e=t(s);if(e){a++;try{let t=n(e.from);if(!Number.isFinite(t.top))continue;i.set(s.id,t.top-r())}catch{o++}}}return{positions:i,attempted:a,thrown:o}}function a3(e){let t=null;return{schedule(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel(){t!==null&&(cancelAnimationFrame(t),t=null)}}}function o3(e){let t=j(N(new Map));function n(){if(!e.getEnabled()){z(t).size>0&&M(t,new Map,!0);return}let n=e.getEditor(),r=e.getLayerEl(),i=e.getYdoc();if(!n||!r||!i){z(t).size>0&&M(t,new Map,!0);return}let{positions:a,attempted:o,thrown:s}=i3(e.getAnnotations(),e=>hD(e,n.state.doc,i),e=>n.view.coordsAtPos(e),()=>r.getBoundingClientRect().top);o>0&&s===o&&console.warn(`[margin] coordsAtPos threw for all ${o} annotations — view may be detached`),!s3(z(t),a)&&M(t,a,!0)}let r=a3(n);return L(()=>{if(!e.getEnabled())return;let t=e.getEditor(),n=e.getLayerEl();if(!t||!n)return;let i=()=>r.schedule();t.on(`transaction`,i);let a=new ResizeObserver(()=>r.schedule());return a.observe(n),r.schedule(),()=>{t.off(`transaction`,i),a.disconnect(),r.cancel()}}),L(()=>{e.getAnnotations(),r.schedule()}),{get byId(){return z(t)}}}function s3(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(e===void 0||Math.abs(e-r)>.5)return!1}return!0}var c3=co,l3=250;function u3(e,t){return e.severity===`info`&&t-e.timestamp>=c3}function d3(e){try{let t=localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);if(!Array.isArray(n))return[];let r=Date.now();return n.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.message==`string`&&typeof e.timestamp==`number`&&[`info`,`warning`,`error`].includes(e.severity)).filter(e=>!u3(e,r)).slice(-50)}catch(e){return console.warn(`[useNotifications] failed to load activity history:`,e),[]}}function f3(e={}){let t=e.persist??!0,n=e.storageKey??`tandem:activityHistory`,r=j(N([])),i=j(N(t?d3(n):[])),a=new Map,o=new Map,s=null,c=()=>{if(t){s=null;try{localStorage.setItem(n,JSON.stringify(z(i)))}catch{}}},l=()=>{t&&(s&&clearTimeout(s),s=setTimeout(c,l3))},u=e=>{let t=a.get(e);t&&(clearTimeout(t),a.delete(e))},d=(e,t)=>{u(e);let n=so[t]??so.info;a.set(e,setTimeout(()=>{M(r,z(r).filter(t=>t.id!==e),!0),a.delete(e)},n))},f=(e,t)=>{if(e.dedupKey){let n=z(r).findIndex(t=>t.dedupKey===e.dedupKey);if(n!==-1){let i=z(r)[n];u(i.id);let a={...e,count:i.count+1,action:t},o=[...z(r)];o[n]=a,M(r,o,!0),d(a.id,a.severity);return}}let n={...e,count:1,action:t},i=[...z(r),n];for(;i.length>5;)u(i.shift().id);M(r,i,!0),d(n.id,n.severity)},p=e=>{let t=o.get(e);t&&(clearTimeout(t),o.delete(e))},m=(e,t)=>{p(e);let n=Math.max(0,c3-(Date.now()-t));o.set(e,setTimeout(()=>{o.delete(e),z(i).some(t=>t.id===e)&&(M(i,z(i).filter(t=>t.id!==e),!0),M(r,z(r).filter(t=>t.id!==e),!0),l())},n))},h=e=>{if(e.dedupKey){let t=z(i).findIndex(t=>t.dedupKey===e.dedupKey);if(t!==-1){let n=z(i)[t],r={...e,id:n.id,count:n.count+1},a=[...z(i)];a[t]=r,M(i,a,!0),r.severity===`info`?m(r.id,r.timestamp):p(r.id),l();return}}let t={...e,count:1},n=[...z(i),t];for(;n.length>50;)n.shift();M(i,n,!0),t.severity===`info`&&m(t.id,t.timestamp),l()},g=(e,t,n)=>{h(e),(e.severity!==`info`||t)&&f(e,n)},_=e=>{M(r,z(r).filter(t=>t.id!==e),!0),u(e)},v=e=>{M(i,z(i).filter(t=>t.id!==e),!0),p(e),l()},y=()=>{M(i,[],!0);for(let e of o.values())clearTimeout(e);o.clear(),l()};for(let e of z(i))e.severity===`info`&&m(e.id,e.timestamp);let b=(e,t)=>g(e,!0,t),x=`http://127.0.0.1:${xa}${pc}`,S=new EventSource(x);return S.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{console.warn(`[useNotifications] Malformed SSE data:`,e.data);return}g(t,!1)},S.onerror=()=>{S.readyState===EventSource.CLOSED&&console.warn(`[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?`)},va(()=>{S.close();for(let e of a.values())clearTimeout(e);a.clear();for(let e of o.values())clearTimeout(e);o.clear(),s&&(clearTimeout(s),c())}),{get toasts(){return z(r)},get activity(){return z(i)},get total(){return z(i).length},dismiss:_,dismissActivity:v,clearActivity:y,push:b}}function p3(e,t){let n=null,r=null,i=(...i)=>{r=i,n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null;let t=r;r=null,t&&e(...t)},t)};return i.cancel=()=>{n!==null&&(clearTimeout(n),n=null),r=null},i.flush=()=>{n!==null&&(clearTimeout(n),n=null);let t=r;r=null,t&&e(...t)},i}function m3(e){return`tandem:scratchpad:${e}`}var h3=`tandem:scratchpad:latest`,g3=500;function _3(e){let t=[],n=e=>{if(e instanceof lE)return e.toString();if(e instanceof iE){let t=``;for(let r=0;r<e.length;r++)t+=n(e.get(r));return t}return``};for(let r=0;r<e.length;r++){let i=e.get(r);(i instanceof iE||i instanceof lE)&&t.push(n(i))}return t.join(`
268
+ `).replace(/\n+$/,``)}function v3(e){try{return localStorage.getItem(e)}catch{return null}}function y3(e,t){try{localStorage.setItem(e,t)}catch{}}function b3(e){try{localStorage.removeItem(e)}catch{}}function x3(e){let t=new Map,n=N({}),r=()=>Object.values(n).some(Boolean),i=e=>{let t=_3(e.ydoc.getXmlFragment(`default`)),r=m3(e.uuid);if(t.length===0){b3(r),v3(h3)===e.uuid&&b3(h3),n[e.uuid]=!1;return}y3(r,t),y3(h3,e.uuid),n[e.uuid]=!0},a=(e,n,r)=>{if(t.has(e))return;let a={uuid:e,ydoc:n,provider:r,updateHandler:()=>{},syncedHandler:null,persist:p3(()=>{},g3)};if(a.persist=p3(()=>i(a),g3),a.updateHandler=()=>a.persist(),n.on(`update`,a.updateHandler),t.set(e,a),r.synced)o(a);else{let n=()=>{a.syncedHandler=null,r.off(`synced`,n),t.get(e)===a&&o(a)};a.syncedHandler=n,r.on(`synced`,n)}},o=e=>{let r=e.ydoc.getXmlFragment(`default`);if(_3(r).length>0)return;let i=e.uuid,a=v3(m3(i));if(a===null&&t.size===1){let t=v3(h3);t&&t!==e.uuid&&(a=v3(m3(t)),i=t)}if(a===null||a.length===0)return;let o=a.split(`
269
+ `).map(e=>{let t=new iE(`paragraph`);return e.length>0&&t.insert(0,[new lE(e)]),t});rk(e.ydoc,()=>{r.length>0&&r.delete(0,r.length),r.insert(0,o)}),y3(m3(e.uuid),a),y3(h3,e.uuid),i!==e.uuid&&b3(m3(i)),n[e.uuid]=!0},s=e=>{let n=t.get(e);n&&(n.persist.flush(),n.ydoc.off(`update`,n.updateHandler),n.syncedHandler&&n.provider.off(`synced`,n.syncedHandler),t.delete(e))},c=e=>{b3(m3(e)),v3(h3)===e&&b3(h3),t.get(e)?.persist.cancel(),n[e]=!1},l=Ln(()=>{L(()=>{let n=e(),r=new Set;for(let e of n){if(!bo(e.filePath))continue;let t=xo(e.filePath);t&&(r.add(t),a(t,e.ydoc,e.provider))}for(let e of[...t.keys()])r.has(e)||s(e)}),L(()=>{let e=e=>{if(r()){for(let e of t.values())e.persist.flush();return e.preventDefault(),e.returnValue=`You have unsaved scratchpad content.`,`You have unsaved scratchpad content.`}};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)})});return{hasUnsavedContent:e=>n[e]===!0,clearUnsaved:c,destroy:()=>{l();for(let e of[...t.keys()])s(e)}}}function S3(e,t,n){return e.length<2?null:e[(e.findIndex(e=>e.id===t)+(n?-1:1)+e.length)%e.length].id}function C3(e,t,n){let r=null;_a(()=>{r=r=>{if(!r.ctrlKey&&!r.metaKey||r.key!==`Tab`)return;let i=S3(e(),t(),r.shiftKey);i&&(r.preventDefault(),n(i))},window.addEventListener(`keydown`,r)}),va(()=>{r&&window.removeEventListener(`keydown`,r)})}function w3(e,t){return e.length===0||t<1||t>9?null:e[Math.min(t-1,e.length-1)].id}function T3(e){if(e.isComposing)return!0;let t=e.target;return t?t.tagName===`INPUT`||t.tagName===`TEXTAREA`:!1}function E3(e,t){let n=new Set(t),r=e.filter(e=>n.has(e)),i=new Set(r),a=t.filter(e=>!i.has(e));return[...r,...a]}function D3(e,t,n,r,i=`left`){let a=e.filter(e=>r.has(e)),o=a.indexOf(t),s=a.indexOf(n);if(o===-1||s===-1)return a;let c=[...a];c.splice(o,1);let l=c.indexOf(n),u=i===`right`?l+1:l;return c.splice(u,0,t),c}function O3(e){let t=j(N([]));L(()=>{let n=e().map(e=>e.id),r=E3(z(t),n);(z(t).length!==r.length||z(t).some((e,t)=>e!==r[t]))&&M(t,r,!0)});let n=A(()=>{let n=e(),r=new Map(n.map(e=>[e.id,e])),i=n.map(e=>e.id);return E3(z(t),i).map(e=>r.get(e)).filter(Boolean)});return{get orderedTabs(){return z(n)},reorder:(n,r,i=`left`)=>{if(n===r)return;let a=e(),o=new Set(a.map(e=>e.id));M(t,D3(z(t),n,r,o,i),!0)}}}function k3(e,t){let n=j(N((()=>{try{let e=localStorage.getItem(Ma),t=ac.safeParse(e);return t.success?t.data:ja}catch(e){return console.warn(`[tandem] localStorage unavailable reading ${Ma}:`,e),ja}})()));return L(()=>{let e=z(n);try{localStorage.setItem(Ma,e)}catch(e){console.warn(`[tandem] failed to persist ${Ma}:`,e)}}),L(()=>{let t=e(),r=z(n);if(t)try{t.getMap(Ba).set(Va,r)}catch(e){console.warn(`[tandem] failed to broadcast tandem mode to Y.Map:`,e)}}),L(()=>{let n=e(),r=t();if(n)try{n.getMap(Ba).set(Ha,r)}catch(e){console.warn(`[tandem] failed to broadcast dwell ms to Y.Map:`,e)}}),{get tandemMode(){return z(n)},setTandemMode(e){M(n,e,!0)}}}var A3=j(!1),j3=!1,M3=()=>{},N3={get fileDragOver(){return z(A3)}};function P3(e){let t=e.split(/[/\\]/).at(-1)??``,n=t.lastIndexOf(`.`);return n<=0?!1:wa.has(t.slice(n).toLowerCase())}var F3=(()=>{let e=Array.from(wa).sort();return e.length<=1?e[0]??``:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(`, `)}, or ${e.at(-1)}`})();function I3(e,t,n){M3({id:`tauri-drop-${n}-${Date.now()}`,type:`general-error`,severity:t,message:e,dedupKey:n,timestamp:Date.now()})}function L3(e){M3=e,!j3&&Bm()&&(j3=!0,Ul(async()=>{let{getCurrentWebview:e}=await import(`./webview-C-97RVRf.js`);return{getCurrentWebview:e}},__vite__mapDeps([8,1,9,3])).then(async({getCurrentWebview:e})=>{await e().onDragDropEvent(e=>{try{let t=e.payload;switch(t.type){case`enter`:M(A3,!0);return;case`drop`:M(A3,!1);for(let e of t.paths)if(P3(e)){(async()=>{let t=await Eh(e);t.ok||I3(`Couldn't open ${e}: ${t.error}`,`error`,`tauri-drop-open-failed`)})();return}I3(`Tandem can only open ${F3} files`,`warning`,`tauri-drop-unsupported`);return;case`leave`:M(A3,!1);return;default:console.warn(`[useTauriFileDrop] unknown payload type:`,t)}}catch(e){console.error(`[useTauriFileDrop] callback threw:`,e),I3(`Drag-and-drop encountered an error — try the Open File dialog`,`error`,`tauri-drop-callback-error`)}})}).catch(e=>{j3=!1,console.error(`[useTauriFileDrop] Failed to attach onDragDropEvent:`,e),I3(`Drag-and-drop unavailable — use the Open File dialog instead`,`warning`,`tauri-drop-unavailable`)}))}var R3=new class{#e=j(N(Bm()?window.__TANDEM_INITIAL_THEME__??null:null));get current(){return z(this.#e)}set current(e){M(this.#e,e,!0)}},z3=!1;function B3(e){R3.current=e,typeof window<`u`&&(window.__TANDEM_INITIAL_THEME__=e)}function V3(){if(z3||!Bm())return;z3=!0;let e=null;Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]).then(({invoke:t})=>{e=t,t(`get_app_theme`).then(e=>{B3(e===`dark`?`dark`:`light`)}).catch(e=>{console.warn(`[useTauriTheme] get_app_theme failed:`,e)})}).catch(e=>{console.warn(`[useTauriTheme] Tauri API import failed:`,e)}),Ul(async()=>{let{getCurrentWindow:e}=await import(`./window-CR0qpD8C.js`);return{getCurrentWindow:e}},__vite__mapDeps([9,1,3])).then(({getCurrentWindow:e})=>{e().onThemeChanged(({payload:e})=>{B3(e===`dark`?`dark`:`light`)}).catch(e=>{console.warn(`[useTauriTheme] onThemeChanged subscribe failed:`,e)})}).catch(e=>{console.warn(`[useTauriTheme] Tauri window API import failed:`,e)});let t=!1,n=setInterval(()=>{!document.hasFocus()||!e||e(`get_app_theme`).then(e=>{let n=e===`dark`?`dark`:`light`;R3.current!==n&&(B3(n),t=!1)}).catch(e=>{t||=(console.warn(`[useTauriTheme] theme poll failed (further errors suppressed):`,e),!0)})},3e3);window.addEventListener(`pagehide`,()=>clearInterval(n),{once:!0})}function H3(e=`light`){let t=e===`warm`?`warm`:`light`;try{if(typeof window>`u`)return t;if(Bm()){let e=R3.current;if(e===`dark`)return`dark`;if(e===`light`)return t;let n=window.__TANDEM_INITIAL_THEME__;if(n===`dark`)return`dark`;if(n===`light`)return t}return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:t}catch(e){return console.warn(`[Tandem] Theme detection failed, defaulting to light:`,e),t}}function U3(e,t=`light`){return e===`system`?H3(t):e}function W3(e){try{let t=document.querySelector(`meta[name="theme-color"]`);t&&(t.content=e===`dark`?`#1c1c24`:e===`warm`?`#f1ead9`:`#fafaf9`)}catch{}}function G3(e,t=`light`){let n=document.documentElement,r=U3(e,t);if(n.setAttribute(`data-theme`,r),W3(r),e!==`system`||Bm())return()=>n.removeAttribute(`data-theme`);let i=window.matchMedia(`(prefers-color-scheme: dark)`),a=()=>{let e=H3(t);n.setAttribute(`data-theme`,e),W3(e)};return i.addEventListener(`change`,a),()=>{i.removeEventListener(`change`,a),n.removeAttribute(`data-theme`)}}function K3(e,t=()=>`light`){V3(),L(()=>{let n=e(),r=t();return R3.current,G3(n,r)})}function q3(){try{return localStorage.getItem(lo)===`true`}catch{return!1}}function J3(e){return e.author===`user`&&!e.id.startsWith(`tutorial-`)}function Y3(){try{localStorage.setItem(lo,`true`)}catch{}}function X3(e,t,n){let r=j(N(q3())),i=j(0),a=0,o=Rm(),s=A(()=>n()===`welcome.md`),c=A(()=>!z(r)&&z(s)),l=Bm(),u=eh(()=>l&&z(c)),d=A(()=>!l||u.status!==null||u.error!==null),f=A(()=>l&&Lm(u.status,o)),p=A(()=>z(d)?z(f)?4:3:1/0);return L(()=>{if(!z(c)||z(i)!==0)return;let t=e().filter(e=>e.id.startsWith(uo));t.length!==0&&t.some(e=>e.status!==`pending`)&&(a=Date.now(),M(i,1))}),L(()=>{!z(c)||z(i)!==1||e().some(J3)&&(a=Date.now(),M(i,2))}),L(()=>{if(!z(c)||z(i)!==2||!isFinite(z(p)))return;let e=t();if(!e)return;let n=()=>{Date.now()-a<2e3||e.isFocused&&(a=Date.now(),M(i,3))};return e.on(`update`,n),()=>{e.off(`update`,n)}}),L(()=>{if(!z(c)||!isFinite(z(p))||z(i)!==z(p))return;let e=setTimeout(()=>{Y3(),M(r,!0)},3e3);return()=>clearTimeout(e)}),L(()=>{isFinite(z(p))&&z(i)>z(p)&&M(i,z(p),!0)}),{get tutorialActive(){return z(c)},get currentStep(){return z(i)},get coworkStatus(){return u.status},dismissTutorial:()=>{Y3(),M(r,!0)},nextStep:()=>{a=Date.now(),M(i,Math.min(z(i)+1,z(p)),!0)}}}var Z3=`tandem://update-available`,Q3=`tandem:updater-dismissed-v`;function $3(e){return`${Q3}${e}`}function e6(e){try{return window.localStorage.getItem($3(e))===`1`}catch{return!1}}function t6(e){try{window.localStorage.setItem($3(e),`1`)}catch{}}var n6=j(null),r6=j(null),i6=0,a6=null,o6=!1,s6=0;function c6(){return i6}function l6(){return z(n6)}function u6(){return z(r6)}function d6(e){e&&(t6(e),M(r6,e,!0))}function f6(){if(i6+=1,i6===1&&Bm()){o6=!1;let e=++s6;(async()=>{try{let{listen:t}=await Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1]));if(o6||e!==s6||c6()===0)return;let n=await t(Z3,e=>{let t=e.payload?.version??null;t&&(M(n6,t,!0),z(r6)!==t&&M(r6,null))});if(o6||e!==s6||c6()===0){n();return}a6=n}catch(e){console.warn(`[useUpdaterChannel] listen() failed:`,e)}})()}let e=!1;return()=>{if(!e&&(e=!0,i6=Math.max(0,i6-1),i6===0)){o6=!0;let e=a6;if(a6=null,e)try{e()}catch(e){console.warn(`[useUpdaterChannel] unlisten threw:`,e)}}}}function p6(){return L(()=>f6()),{get availableVersion(){return l6()},get showDot(){let e=l6();return!(!e||u6()===e||e6(e))},acknowledge(){d6(l6())}}}var m6=3e4;function h6(){let e=j(!1),t=null;function n(){t!==null&&(clearTimeout(t),t=null)}L(()=>{let e=f6();return()=>{n(),e()}});async function r(){if(!(!l6()||z(e))){M(e,!0),n(),t=setTimeout(()=>{t=null,M(e,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${m6}ms; re-arming CTA`)},m6);try{let{invoke:t}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);await t(`install_update`),n(),M(e,!1)}catch(t){console.warn(`[useUpdaterBanner] install_update failed:`,t),n(),M(e,!1)}}}return{get availableVersion(){return l6()},get installing(){return z(e)},get showBanner(){let e=l6();return!(!e||u6()===e||e6(e))},dismiss(){d6(l6())},install:r}}function g6(){let e=j(N(window.innerWidth));return L(()=>{let t=null,n=()=>{t===null&&(t=requestAnimationFrame(()=>{M(e,window.innerWidth,!0),t=null}))};return window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),t!==null&&cancelAnimationFrame(t)}}),{get width(){return z(e)}}}function _6(){let e=null;_a(()=>{let t=!1,n;Ul(async()=>{let{getCurrentWebview:e}=await import(`./webview-C-97RVRf.js`);return{getCurrentWebview:e}},__vite__mapDeps([8,1,9,3])).then(({getCurrentWebview:e})=>{if(t)return;let r=e(),i=1;try{let e=localStorage.getItem(ho);if(e!==null){let t=Number(e);Number.isFinite(t)?i=Math.max(go,Math.min(2,t)):console.warn(`[tandem] ignoring invalid stored zoom: ${e}`)}}catch{}i!==1&&r.setZoom(i).catch(e=>{console.warn(`[tandem] failed to restore zoom level:`,e)});function a(e){try{localStorage.setItem(ho,String(e))}catch{}}let o=e=>{!(e.metaKey||e.ctrlKey)||e.key!==`0`||(e.preventDefault(),e.stopPropagation(),i=1,r.setZoom(1).catch(e=>{console.warn(`[tandem] failed to reset zoom:`,e)}),a(1))},s=.1,c=e=>{if(!(e.metaKey||e.ctrlKey))return;let t=e.key===`+`||e.key===`=`,n=e.key===`-`||e.key===`_`;if(!t&&!n)return;let r=t?i+s:i-s;i=Math.max(go,Math.min(2,Math.round(r*100)/100)),a(i)};window.addEventListener(`keydown`,o,{capture:!0}),window.addEventListener(`keydown`,c,{capture:!0}),n=()=>{window.removeEventListener(`keydown`,o,{capture:!0}),window.removeEventListener(`keydown`,c,{capture:!0})}}).catch(()=>{}),e=()=>{t=!0,n?.()}}),va(()=>{e?.()})}var v6=1e3;function y6(e){let t=!1;return function(){e.isDestroyed()||t||(t=!0,queueMicrotask(async()=>{try{for(;!e.isDestroyed();){let t=await e.fetchGenerationId();if(e.isDestroyed())return;if(t&&t===e.getPinnedGeneration()){e.onGenerationUnchanged();return}if(t){e.rebuild(t);return}await e.sleep(v6)}}finally{t=!1}}))}}function b6(e){let{prev:t,serverActiveId:n,serverIds:r,removedCount:i,serverEpoch:a,lastAppliedEpoch:o}=e;return t===null||!r.has(t)?n:i>0&&n===t||a===o?t:n}function x6(e,t,n){return e.filter(e=>!t.has(e.id)&&!n.has(e.id))}function S6(e){return e===`constant-2s`?{delay:2e3,factor:1,maxAttempts:0,minDelay:2e3,maxDelay:2e3,jitter:!1}:{delay:1e3,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0}}function C6(e){let t=t=>({...t,...S6(e?.getRetryStrategy?.()??`exponential`)}),n=j(N([])),r=j(null),i=j(!1),a=j(`connecting`),o=j(0),s=j(null),c=j(N([])),l=j(null),u=j(!1),d=j(null),f=j(!1),p=j(!1),m=j(!1),h=j(null),g=null,_=!1,v=null,y=null,b=new Set,x=new Map,S=new Map,ee=new Map,C=!1,te=e=>{let{ydoc:t}=e,n=t.getMap(Ra),r=()=>{let e=[];n.forEach(t=>{e.push(ik(t,e=>{console.warn(`[sanitize]`,e)}))}),M(c,e,!0)};n.observe(r),r();let i=t.getMap(za),a=null,o=!1,s=null,f=e=>e?`${e.tool} ${e.annotationId??``} ${e.token??e.startedAt}`:null,p=()=>{let e=i.get(Xa),t=e?.status??null,n=e?.active??!1,r=e?.working??null;t!==a&&(a=t,M(l,t,!0)),n!==o&&(o=n,M(u,n,!0));let c=f(r);c!==s&&(s=c,M(d,r,!0))};return i.observe(p),p(),()=>{n.unobserve(r),i.unobserve(p)}},w=e=>new Promise(t=>setTimeout(t,e)),ne=async()=>{try{let e=await fetch(`http://127.0.0.1:${xa}${mc}`,{signal:AbortSignal.timeout(5e3)});return e.ok?(await e.json()).generationId??null:null}catch{return null}},re=()=>{for(let e of S.values())e.cleanup();S.clear();for(let e of ee.values())e();ee.clear();for(let e of x.values())e.provider.destroy(),e.ydoc.destroy();x.clear(),b.clear();for(let e of z(n))e.provider.destroy(),e.ydoc.destroy();M(n,[],!0)},T=y6({isDestroyed:()=>C,fetchGenerationId:ne,getPinnedGeneration:()=>v,onGenerationUnchanged:()=>{console.warn(`[Tandem] Provider auth failed without a generation change`)},rebuild:e=>{console.warn(`[Tandem] Server restarted — resyncing documents`),re(),ae?.(),M(m,!0),y=null,g=setTimeout(()=>{M(m,!1)},5e3),se(e)},sleep:w}),ie=(e,i,a)=>{let o=z(n),s=new Set(o.map(e=>e.id)),c=new Set(e.map(e=>e.id));for(let e of o)b.delete(e.id),x.delete(e.id);for(let[e,t]of x)c.has(e)||(ee.get(e)?.(),ee.delete(e),t.provider.destroy(),t.ydoc.destroy(),x.delete(e),b.delete(e));let l=x6(e,s,b),u=[];for(let e of l){b.add(e.id);let n=new xC,r=new eF(t({url:`ws://127.0.0.1:${ba}`,name:e.id,document:n,token:v}));r.on(`authenticationFailed`,T),x.set(e.id,{ydoc:n,provider:r});let i=n.getMap(Wa),a=e=>{if(!e.keysChanged.has(`openDocuments`)&&!e.keysChanged.has(`activeDocumentId`)&&!e.keysChanged.has(`activeDocumentEpoch`))return;let t=i.get(Za),n=i.get(Qa),r=i.get($a);t&&ie(t,n??null,r??null)};i.observe(a),ee.set(e.id,()=>i.unobserve(a)),u.push({...e,ydoc:n,provider:r})}let d=o.filter(e=>!c.has(e.id));for(let e of d){let t=S.get(e.id);t&&(t.cleanup(),S.delete(e.id)),ee.get(e.id)?.(),ee.delete(e.id),b.delete(e.id),x.delete(e.id),e.provider.destroy(),e.ydoc.destroy()}let f=new Map(e.map(e=>[e.id,e]));M(n,[...o.filter(e=>c.has(e.id)).map(e=>{let t=f.get(e.id);return!t||t.fileName===e.fileName&&t.filePath===e.filePath&&t.format===e.format&&t.readOnly===e.readOnly&&t.source===e.source?e:{...e,fileName:t.fileName,filePath:t.filePath,format:t.format,readOnly:t.readOnly,source:t.source}}),...u],!0),i!==null&&(M(r,b6({prev:z(r),serverActiveId:i,serverIds:c,removedCount:d.length,serverEpoch:a,lastAppliedEpoch:y}),!0),y=a)},ae=null,oe=null;function se(e){v=e;let n=new xC,r=new eF(t({url:`ws://127.0.0.1:${ba}`,name:La,document:n,token:e}));M(h,n,!0),oe=r,r.on(`authenticationFailed`,T),r.on(`status`,({status:e})=>{M(i,e===`connected`),M(a,[`connected`,`connecting`,`disconnected`].includes(e)?e:`connecting`,!0),e===`connected`?(_=!0,M(o,0),M(s,null)):e===`disconnected`?z(s)===null&&M(s,Date.now(),!0):e===`connecting`&&(_&&M(o,z(o)+1),z(s)===null&&M(s,Date.now(),!0))});let c=n.getMap(Wa),l=e=>{if(e.keysChanged.has(`openDocuments`)||e.keysChanged.has(`activeDocumentId`)||e.keysChanged.has(`activeDocumentEpoch`)){let e=c.get(Za),t=c.get(Qa),n=c.get($a);e&&ie(e,t??null,n??null)}e.keysChanged.has(`storeReadOnly`)&&M(f,c.get(eo)===!0)};c.observe(l);let u=c.get(Za),d=c.get(Qa),m=c.get($a);u&&ie(u,d??null,m??null),M(f,c.get(eo)===!0),ae=()=>{c.unobserve(l),g&&=(clearTimeout(g),null),r.destroy(),n.destroy(),M(h,null),oe=null,ae=null},M(p,!0)}(async()=>{for(;!C;){let e=await ne();if(C)return;if(e){se(e);return}M(p,!0),M(a,`disconnected`),M(i,!1),z(s)===null&&M(s,Date.now(),!0),await w(1e3)}})();let ce=A(()=>z(n).find(e=>e.id===z(r))??null),le=A(()=>z(ce)?.ydoc??null),ue=Ln(()=>{L(()=>{z(le);let e=z(ce);for(let e of S.values())e.cleanup();if(S.clear(),e){let t=te(e);S.set(e.id,{cleanup:t})}else M(c,[],!0),M(l,null),M(u,!1),M(d,null)})});return{get tabs(){return z(n)},get activeTabId(){return z(r)},setActiveTabId:e=>{M(r,e,!0)},handleTabClose:e=>{if(z(r)===e){let t=z(n),i=t.findIndex(t=>t.id===e),a=t.filter(t=>t.id!==e);a.length===0?M(r,null):M(r,a[Math.min(i,a.length-1)].id,!0)}fetch(`http://127.0.0.1:${xa}${vc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e})}).then(e=>{e.ok||console.warn(`[Tandem] Server rejected close:`,e.status)}).catch(e=>{console.warn(`[Tandem] Failed to close document on server:`,e)})},handleTabRename:(e,t,r)=>{let i=z(n).find(t=>t.id===e);if(!i)return;let a=i.fileName,o=t=>z(n).map(n=>n.id===e?{...n,fileName:t}:n);M(n,o(t),!0);let s=e=>{M(n,o(a),!0),r?.(e)};fetch(`http://127.0.0.1:${xa}${bc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,newName:t})}).then(async e=>{if(e.ok)return;let t=`Rename failed (${e.status}).`;try{let n=await e.json();n?.message&&(t=n.message)}catch{}console.warn(`[Tandem] Server rejected rename:`,e.status,t),s(t)}).catch(e=>{console.warn(`[Tandem] Failed to rename document on server:`,e),s(`Rename failed: could not reach the server.`)})},get connected(){return z(i)},get connectionStatus(){return z(a)},get reconnectAttempts(){return z(o)},get disconnectedSince(){return z(s)},get annotations(){return z(c)},get claudeStatus(){return z(l)},get claudeActive(){return z(u)},get claudeWorking(){return z(d)},get storeReadOnly(){return z(f)},get bootstrapYdoc(){return z(h)},get ready(){return z(p)},get serverRestarted(){return z(m)},destroy:()=>{C||(C=!0,ue(),re(),ae?.(),M(c,[],!0),M(r,null),M(p,!1))},reconnect(){oe?.connect();for(let e of z(n))e.provider.connect()},rebuildForLicenseChange(){if(C)return;let e=v;e!==null&&(re(),ae?.(),y=null,se(e))}}}var w6={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 T6(e){return e.column+e.inset+e.gap}w6.full.column;var E6=T6(w6.full);function D6(e){return 2*E6+e+480}function O6(e){let t=e+480;return{t1:D6(e),t2:2*T6(w6.narrow)+t,t3:2*T6(w6.stub)+t}}var k6={off:0,stub:1,narrow:2,full:3};function A6(e,t,n,r){let{t1:i,t2:a,t3:o}=n,s=t,c=r,l=s<o?`off`:s<a?`stub`:s<i?`narrow`:`full`,u=s>i+c?`full`:s>a+c?`narrow`:s>o+c?`stub`:`off`;return k6[e]>k6[l]?l:k6[e]<k6[u]?u:e}function j6(e,t,n){return e?t&&n===`full`?`full`:`off`:t?n:`off`}function M6(e,t,n){return!t&&!n?`off`:e}function N6(e){return e.isDocx?e.effectivelyOn?`position: relative;`:`display: contents;`:`--editor-measure: ${e.measure}; --margin-left-track: ${e.leftReservePx}px; --margin-right-track: ${e.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 P6(e){let t=A(()=>(e.getLeftRailVisible()?e.leftRailWidthPx:0)+(e.getRightRailVisible()?e.rightRailWidthPx:0)),n=A(()=>O6(z(t))),r=j(`full`);L(()=>{let t=e.getViewportWidth(),i=z(n),a=Ar(()=>z(r)),o=A6(a,t,i,32);o!==a&&M(r,o,!0)});let i=A(()=>e.getFormat()===`docx`),a=A(()=>j6(z(i),e.getMarginView(),z(r))),o=A(()=>M6(z(a),z(i),e.getLeftHasPending())),s=A(()=>M6(z(a),z(i),e.getRightHasPending())),c=A(()=>z(o)!==`off`),l=A(()=>z(s)!==`off`),u=A(()=>z(c)||z(l)),d=A(()=>w6[z(o)]),f=A(()=>w6[z(s)]),p=new Set,m=A(()=>N6({isDocx:z(i),effectivelyOn:z(u),leftReservePx:T6(z(d)),rightReservePx:T6(z(f)),measure:(()=>{let t=e.getEditorMeasure(),n=bl[t];return n===void 0&&!p.has(t)&&(p.add(t),console.warn(`[tandem] editorMeasure=${JSON.stringify(t)} not in EDITOR_MEASURE_CH; falling back to comfortable. Both useTandemSettings validators should have coerced this upstream — a TS-violating cast slipped past them.`)),n??bl.comfortable})()}));return{get effectivelyOn(){return z(u)},get leftVisible(){return z(c)},get rightVisible(){return z(l)},get leftMode(){return z(o)},get rightMode(){return z(s)},get leftGeometry(){return z(d)},get rightGeometry(){return z(f)},get layerStyle(){return z(m)}}}function F6(e,t){let n=A(()=>e.settings.leftPanelVisible),r=A(()=>e.settings.rightPanelVisible&&!(t.tandemMode===`solo`&&e.settings.soloRailHidden));function i(){e.updateSettings({leftPanelVisible:!e.settings.leftPanelVisible})}function a(){if(z(r)){e.updateSettings({rightPanelVisible:!1});return}e.updateSettings({rightPanelVisible:!0,...t.tandemMode===`solo`?{soloRailHidden:!1}:{}})}return{get leftVisible(){return z(n)},get rightVisible(){return z(r)},toggleLeft:i,toggleRight:a}}function I6(e){return e.mode===`stub`?`stub`:e.isEditing||e.isActive?`full`:e.mode===`narrow`?`clamped`:`full`}var L6=6;function R6(e,t={}){let n=t.gap??L6,r=new Map;if(e.length===0)return r;let i=e.map((e,t)=>({...e,idx:t})).sort((e,t)=>e.top-t.top||e.idx-t.idx),a=-1/0;for(let e of i){if(!Number.isFinite(e.top))continue;let t=Math.max(e.top,a);r.set(e.id,t),typeof e.height==`number`&&Number.isFinite(e.height)&&e.height>0&&(a=t+e.height+n)}return r}function z6(e,t){let n=[];for(let r of e.keys())t.has(r)||n.push(r);for(let t of n)e.delete(t);return n.length}var B6=.62;function V6(e){let t=e.endX-e.startX,n=e.startX+t*B6,r=e.endX-t*B6;return`M ${e.startX.toFixed(1)},${e.startY.toFixed(1)} C ${n.toFixed(1)},${e.startY.toFixed(1)} ${r.toFixed(1)},${e.endY.toFixed(1)} ${e.endX.toFixed(1)},${e.endY.toFixed(1)}`}function H6(e){throw Error(`unhandled annotation author: ${String(e)}`)}function U6(e){switch(e){case`claude`:return`var(--tandem-author-claude)`;case`user`:return`var(--tandem-author-user)`;case`import`:return`var(--tandem-fg-subtle)`;default:return H6(e)}}var W6=Jr(`<path stroke-linecap="round" fill="none"></path><circle data-testid="margin-anchor-dot"></circle>`,1),G6=V(`<div class="margin-bubble svelte-lzz9jv"><!></div>`),K6=V(`<svg aria-hidden="true"></svg> <div></div>`,1);function q6(e,t){O(t,!0);let n=q(t,`reduceMotion`,3,!1),r=A(()=>t.side===`right`?0:t.gap),i=A(()=>t.side===`right`?t.gap:0),a=A(()=>`position: absolute; top: 0; bottom: 0; ${t.side}: ${t.edgeInset+t.width}px; width: ${t.gap}px; pointer-events: none;`),o=A(()=>t.annotations.filter(e=>t.positions.has(e.id)&&e.status===`pending`)),s=j(N(new Map)),c=A(()=>new Map(z(o).map(e=>[e.id,I6({mode:t.mode,isActive:e.id===t.activeAnnotationId,isEditing:!1})]))),l=A(()=>R6(z(o).map(e=>({id:e.id,top:t.positions.get(e.id)??0,height:z(c).get(e.id)===`stub`?void 0:z(s).get(e.id)}))));L(()=>{let e=new Set(z(o).map(e=>e.id));Ar(()=>{z6(z(s),e)>0&&M(s,new Map(z(s)),!0)})});function u(e,t){if(!Number.isFinite(t)||t<=0)return;let n=z(s).get(e);if(n!==void 0&&Math.abs(n-t)<.5)return;let r=new Map(z(s));r.set(e,t),M(s,r,!0)}let d=j(void 0),f=j(null),p=0;function m(e){return t.annotations.find(t=>t.id===e)}function h(e){return n=>{let r=m(e);r&&Ek(n,r,{accept:t.onAccept,dismiss:t.onDismiss,sendToClaude:t.onSendToClaude,remove:t.onRemove,openEdit:e=>M(f,{id:e,kind:`edit`,nonce:++p},!0),openReply:e=>M(f,{id:e,kind:`reply`,nonce:++p},!0)})}}async function g(e){if(!Bm())return;let t=(e.target?.closest(`[data-annotation-id]`))?.getAttribute(`data-annotation-id`);if(!t)return;let n=m(t);n&&(e.preventDefault(),e.stopPropagation(),await Dk(n,h(t)))}L(()=>{let e=z(d);if(e)return e.addEventListener(`contextmenu`,g),()=>e.removeEventListener(`contextmenu`,g)}),L(()=>Ak());var _=K6(),v=F(_);pi(v,21,()=>z(o),e=>e.id,(e,n)=>{let a=A(()=>t.positions.get(z(n).id)),o=A(()=>z(l).get(z(n).id));var s=Xr(),c=F(s),u=e=>{let s=A(()=>z(n).id===t.activeAnnotationId),c=A(()=>z(o)??z(a)),l=A(()=>z(c)+12),u=A(()=>U6(z(n).author)),d=A(()=>V6({startX:z(r),startY:z(a),endX:z(i),endY:z(l)}));var f=W6(),p=F(f),m=I(p);R(()=>{K(p,`data-annotation-id`,z(n).id),K(p,`data-tandem-author`,z(n).author),K(p,`d`,z(d)),K(p,`stroke`,z(u)),K(p,`stroke-width`,z(s)?1.8:1.1),K(p,`stroke-opacity`,z(s)?.82:.38),K(m,`data-annotation-id`,z(n).id),K(m,`data-tandem-author`,z(n).author),K(m,`cx`,z(r)),K(m,`cy`,z(a)),K(m,`r`,z(s)?3:2),K(m,`fill`,z(u)),K(m,`fill-opacity`,z(s)?.72:.42)}),H(e,f)};W(c,e=>{z(a)!==void 0&&e(u)}),H(e,s)}),E(v);var y=I(v,2);pi(y,21,()=>z(o),e=>e.id,(e,r)=>{let i=A(()=>z(l).get(z(r).id)??t.positions.get(z(r).id)??0),a=A(()=>HD(z(r),t.repliesById.get(z(r).id))),o=A(()=>z(c).get(z(r).id)??`full`);var s=G6(),d=P(s);{let e=A(()=>z(r).id===t.activeAnnotationId),i=A(()=>hk(z(r))?t.onAccept:void 0),s=A(()=>gk(z(r))?t.onDismiss:void 0),c=A(()=>bk(z(r))?t.onRemove:void 0),l=A(()=>yk(z(r))?t.onSendToClaude:void 0),u=A(()=>vk(z(r))?t.onEdit:void 0),p=A(()=>_k(z(r))?t.onReply:void 0),m=A(()=>z(f)?.id===z(r).id?z(f):null);ek(d,{get annotation(){return z(r)},get replies(){return z(a)},get isReviewTarget(){return z(e)},get density(){return z(o)},get reduceMotion(){return n()},onClick:()=>t.onClick(z(r)),get onAccept(){return z(i)},get onDismiss(){return z(s)},get onRemove(){return z(c)},get onSendToClaude(){return z(l)},get onEdit(){return z(u)},get onReply(){return z(p)},get openRequest(){return z(m)}})}E(s),R(()=>{K(s,`data-testid`,`margin-bubble-${z(r).id??``}`),K(s,`data-margin-bubble-reply-count`,z(a).length),G(s,`position: absolute; top: ${z(i)??``}px; ${t.side??``}: 0; width: ${t.width??``}px; pointer-events: auto;`)}),Mi(1,s,()=>Sv,()=>({id:z(r).id,reduceMotion:n()})),ua(s,`clientHeight`,e=>u(z(r).id,e)),H(e,s)}),E(y),fa(y,e=>M(d,e),()=>z(d)),R(()=>{K(v,`data-testid`,`margin-leaders-${t.side??``}`),G(v,z(a)),K(y,`data-testid`,`margin-column-${t.side??``}`),K(y,`aria-label`,t.side===`left`?`Note bubbles`:`Comment bubbles`),G(y,`position: absolute; top: 0; ${t.side??``}: ${t.edgeInset??``}px; width: ${t.width??``}px; pointer-events: none;`)}),H(e,_),k()}function J6(e){return e.type===`note`}function Y6(e){return e.author===`import`||e.type===`comment`}var X6=V(`<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),Z6=V(`<span></span>`),Q6=V(`<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 $6(e,t){O(t,!0);let n=q(t,`annotations`,19,()=>[]),r=A(()=>t.side===`left`?`Outline`:`Annotations`);function i(e){return e.type===`highlight`?`hl`:e.type===`comment`&&e.suggestedText!=null?`suggest`:e.author===`claude`?`claude`:e.author===`import`?`import`:`user`}function a(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t.onActivate())}var o=Q6(),s=P(o),c=P(s,!0);E(s);var l=I(s,2),u=P(l),d=e=>{var t=X6();D(8),H(e,t)},f=e=>{var t=Xr();pi(F(t),17,n,e=>e.id,(e,t)=>{var n=Z6();R(e=>Ui(n,1,`peek-dot ${e??``}`,`svelte-1mwvi22`),[()=>i(z(t))]),H(e,n)}),H(e,t)};W(u,e=>{t.kind===`outline`?e(d):e(f,-1)}),E(l);var p=I(l,2),m=P(p,!0);E(p),E(o),R(()=>{Ui(o,1,`peek-strip peek-strip-${t.side??``}`,`svelte-1mwvi22`),K(o,`data-testid`,`peek-strip-${t.side}`),K(o,`aria-label`,t.side===`left`?`Show left panel`:`Show right panel`),K(o,`aria-expanded`,!t.collapsed),G(o,t.collapsed?``:`display: none;`),U(c,t.side===`left`?`›`:`‹`),U(m,z(r))}),B(`click`,o,function(...e){t.onActivate?.apply(this,e)}),B(`keydown`,o,a),H(e,o),k()}Br([`click`,`keydown`]);var e8=e=>{console.warn(`[sanitize]`,e)};function t8(e,t,n){if(e.suggestedText===void 0)return!1;let r=e.suggestedText,i=hD(e,t.state.doc,n);if(!i)return console.warn(`[SidePanel] Could not resolve range for suggestion`,e.id),!1;try{t.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,r).run()}catch(t){return console.error(`[SidePanel] Editor mutation failed for suggestion`,e.id,t),!1}return!0}function n8({getYdoc:e,getEditor:t,getAnnotations:n,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:a}){let o=j(0),s=j(N(new Set)),c=new Map,l=null;va(()=>{for(let e of c.values())clearTimeout(e);c.clear()});function u(){return n().filter(sc)}function d(n,r){let i=e();if(!i)return;let a=i.getMap(Ra),o=a.get(n);if(!o||o.status!==`pending`)return;let c=ik(o,e8);if(a.set(n,{...c,status:r}),r===`accepted`&&c.suggestedText!==void 0){let e=t();if(e&&!t8(c,e,i)){a.set(n,{...c,status:`pending`});return}}l=n,M(s,new Set(z(s)).add(n),!0)}function f(e){let t=c.get(e);t&&clearTimeout(t),c.set(e,setTimeout(()=>{c.delete(e);let t=new Set(z(s));t.delete(e),M(s,t,!0)},3e3))}function p(e){let t=c.get(e);t&&(clearTimeout(t),c.delete(e));let n=new Set(z(s));n.delete(e),M(s,n,!0)}function m(n){let r=e();if(!r)return!1;let i=r.getMap(Ra),a=i.get(n);if(!a||a.status===`pending`)return p(n),!1;let o=ik(a,e8),s=t();if(o.status===`accepted`&&o.suggestedText!==void 0&&s)try{let e=o.suggestedText,t=o.textSnapshot;if(typeof e==`string`&&typeof t==`string`){let i=hD(o,s.state.doc,r);if(!i)return console.warn(`[undo] Cannot resolve range for annotation ${n}, skipping`),f(n),!1;if(s.state.doc.textBetween(i.from,i.to)!==e)return console.warn(`[undo] Text changed since accept for annotation ${n}, skipping`),f(n),!1;s.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,t).run()}}catch(e){return console.warn(`[undo] Failed to revert text for annotation ${n}:`,e),f(n),!1}return i.set(n,{...o,status:`pending`}),p(n),l===n&&(l=null),!0}function h(e){d(e,`accepted`)}function g(e){d(e,`dismissed`)}function _(n){let r=t();if(!r)return;let a=hD(n,r.state.doc,e());if(!a)return;r.chain().focus().setTextSelection({from:a.from,to:a.to}).run();let o=r.view.domAtPos(a.from);(o.node instanceof HTMLElement?o.node:o.node.parentElement)?.scrollIntoView({behavior:i(),block:`center`})}return L(()=>{let e=a?.()??null;e!==null&&(n().some(t=>t.id===e&&t.status===`pending`)||r(u()[z(o)]?.id??null))}),L(()=>{let e=u();z(o)>=e.length&&M(o,Math.max(0,e.length-1),!0)}),{resolveAnnotation:d,undoResolveAnnotation:m,handleAccept:h,handleDismiss:g,scrollToAnnotation:_,getRecentlyResolved:()=>z(s),getReviewIndex:()=>z(o),getReviewTargets:u}}var r8=V(`<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>`),i8=V(`<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>`),a8=V(`<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 o8(e,t){O(t,!0);let n=[{value:`yellow`,label:`Yellow`},{value:`green`,label:`Green`},{value:`blue`,label:`Blue`},{value:`pink`,label:`Pink`}],r=q(t,`disabled`,3,!1),i=j(`yellow`),a=j(!1),o=j(null);L(()=>{t.onOpenChange?.(z(a))}),L(()=>{if(z(a))return a4(()=>z(o),[`mousedown`],()=>{M(a,!1)},{capture:!1})});function s(e){e.preventDefault(),t.onHighlight(z(i))}function c(e){e.preventDefault(),M(a,!z(a))}function l(e){M(i,e,!0),M(a,!1)}var u=a8(),d=P(u);d4(d,{label:`Highlight`,testId:`toolbar-highlight-btn`,get disabled(){return r()},disabledTitle:`Select text first`,onMouseDown:s});var f=I(d,2),p=P(f);E(f);var m=I(f,2),h=e=>{var t=i8(),r=P(t);pi(r,17,()=>n,({value:e,label:t})=>e,(e,t)=>{let n=()=>z(t).value,r=()=>z(t).label;var a=r8();let o;var s=P(a);D(2),E(a),R(()=>{K(a,`data-testid`,`toolbar-highlight-color-${n()}`),K(a,`title`,r()),K(a,`aria-label`,r()),o=Ui(a,1,`highlight-picker-swatch svelte-1d240y8`,null,o,{"is-selected":n()===z(i)}),G(s,`background: ${ka[n()]??``};`)}),B(`click`,a,()=>l(n())),H(e,a)});var s=I(r,2);E(t),fa(t,e=>M(o,e),()=>z(o)),B(`click`,s,()=>M(a,!1)),H(e,t)};W(m,e=>{z(a)&&e(h)}),E(u),R(()=>{f.disabled=r(),G(p,`background: ${ka[z(i)]??``};`)}),B(`mousedown`,f,c),H(e,u),k()}Br([`mousedown`,`click`]);var s8=V(`<div class="fmtbar-divider svelte-1lcxsnm"></div> <!>`,1),c8=V(`<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),l8=V(`<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 u8(e,t){O(t,!0);let n=q(t,`showAuthorship`,3,!0),r=q(t,`showComments`,3,!0),i=q(t,`showHighlights`,3,!0),a=q(t,`showNotes`,3,!0),o=q(t,`decorationsMuted`,3,!1),s=j(0);L(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>{e.isDestroyed||cn(s)};return e.on(`selectionUpdate`,n),e.on(`transaction`,n),()=>{e.off(`selectionUpdate`,n),e.off(`transaction`,n)}});let c=A(()=>(z(s),!t.editor||t.editor.isDestroyed||!t.ydoc?!1:!t.editor.state.selection.empty)),l=j(!1);function u(e){if(!t.editor||!t.ydoc||t.editor.isDestroyed)return;let{state:n}=t.editor,{from:r,to:i}=n.selection;if(r===i)return;let a=dD(n.doc,Co(r)),o=dD(n.doc,Co(i));if(a===null||o===null){console.warn(`[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded`,{from:r,to:i});return}E4(t.ydoc,{from:a,to:o},e)}var d=l8(),f=P(d),p=P(f),m=P(p);T4(m,{get editor(){return t.editor}});var h=I(m,4);{let e=A(()=>!z(c));o8(h,{get disabled(){return z(e)},onHighlight:u,onOpenChange:e=>M(l,e,!0)})}E(p);var g=I(p,2),_=e=>{var s=s8();i4(I(F(s),2),{get showAuthorship(){return n()},get showComments(){return r()},get showHighlights(){return i()},get showNotes(){return a()},get decorationsMuted(){return o()},get onUpdate(){return t.onUpdateDecorations},get onOpenSettings(){return t.onOpenSettings}}),H(e,s)};W(g,e=>{t.onUpdateDecorations&&e(_)});var v=I(g,2),y=e=>{var n=c8();B(`click`,I(F(n),2),function(...e){t.onHide?.apply(this,e)}),H(e,n)};W(v,e=>{t.onHide&&e(y)}),E(f),E(d),R(()=>G(d,`position: fixed; top: var(--tandem-fmtbar-top, 52px); left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; z-index: ${z(l)?`var(--tandem-z-toast)`:`var(--tandem-z-sticky)`};`)),H(e,d),k()}Br([`click`]);var d8=V(`<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 f8(e,t){O(t,!0);var n=d8(),r=P(n);let i;var a=I(r,2),o=I(a,2);E(n),R(()=>{i=Ui(r,1,`thumb svelte-14q5edy`,null,i,{tandem:t.tandemMode===`tandem`}),Ui(a,1,Li(t.tandemMode===`solo`?`on`:``),`svelte-14q5edy`),K(a,`aria-pressed`,t.tandemMode===`solo`),Ui(o,1,Li(t.tandemMode===`tandem`?`on`:``),`svelte-14q5edy`),K(o,`aria-pressed`,t.tandemMode===`tandem`)}),B(`click`,a,()=>t.onModeChange(`solo`)),B(`click`,o,()=>t.onModeChange(`tandem`)),H(e,n),k()}Br([`click`]);var p8=[{value:`system`,label:`Match system`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`warm`,label:`Warm`}],m8=V(`<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>`),h8=V(`<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>`),g8=V(`<div class="brand-menu-divider svelte-12l7ydf" role="separator"></div>`),_8=V(`<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),v8=V(`<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>`),y8=V(`<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>`),b8=V(`<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>`),x8=V(`<div class="title-bar-center svelte-12l7ydf" data-tauri-drag-region="false"><!></div>`),S8=V(`<button type="button" data-testid="titlebar-source-toggle" data-tauri-drag-region="false"><span aria-hidden="true">&lt;/&gt;</span></button>`),C8=V(`<span class="status-dot svelte-12l7ydf" data-tauri-drag-region="false" title="AI assistant is connected" aria-label="AI assistant is connected"></span>`),w8=V(`<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>`),T8=V(`<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>`),E8=V(`<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>`),D8=Jr(`<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>`),O8=Jr(`<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>`),k8=V(`<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),A8=V(`<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 j8(e,t){O(t,!0);let n=q(t,`claudeActive`,3,!1),r=q(t,`theme`,3,`system`),i=q(t,`settingsBtn`,15,null),a=q(t,`updateAvailable`,3,!1),o=q(t,`defaultModelLabel`,3,null),s=q(t,`aiChip`,3,null),c=q(t,`sourceViewActive`,3,!1),l=q(t,`onToggleSourceView`,3,null),u=j(null),d=j(!1),f=[],p=!0;_a(async()=>{if(Bm())try{let[{invoke:e},{getCurrentWindow:t}]=await Promise.all([Ul(()=>import(`./core-SwWLTXZB.js`),[]),Ul(()=>import(`./window-CR0qpD8C.js`),__vite__mapDeps([9,1,3]))]);if(!p||(await e(`setup_overlay_titlebar`).catch(e=>{console.error(`[TitleBar] setup_overlay_titlebar failed:`,e)}),!p))return;let n=t();if(M(u,n,!0),M(d,await n.isMaximized(),!0),!p)return;let r=await n.onResized(async()=>{try{M(d,await n.isMaximized(),!0)}catch(e){console.warn(`[TitleBar] isMaximized check failed on resize:`,e)}});if(!p){r();return}f.push(r);let i=await n.onMoved(async()=>{try{M(d,await n.isMaximized(),!0)}catch(e){console.warn(`[TitleBar] isMaximized check failed on move:`,e)}});if(!p){i();return}f.push(i)}catch(e){console.error(`[TitleBar] Window API initialization failed:`,e)}}),va(()=>{p=!1,f.forEach(e=>e())});async function m(){try{await z(u)?.minimize()}catch(e){console.error(`[TitleBar] minimize failed:`,e)}}async function h(){try{await z(u)?.toggleMaximize()}catch(e){console.error(`[TitleBar] toggleMaximize failed:`,e)}}async function g(){try{await z(u)?.close()}catch(e){console.error(`[TitleBar] close failed:`,e)}}let _=j(!1),v=j(null);L(()=>{if(z(_))return a4(()=>z(v)??i(),[`mousedown`],()=>{M(_,!1)})});function y(){M(_,!z(_))}function b(){M(_,!1),i()?.focus()}function x(e){e.key===`Escape`&&(e.stopPropagation(),b())}function S(e){t.onSetTheme?.(e),b()}function ee(){t.onOpenSettings?.(),M(_,!1)}function C(){t.onOpenHelp?.(),M(_,!1)}var te=A8(),w=P(te),ne=P(w),re=I(P(ne),2),T=e=>{H(e,m8())},ie=A(()=>Bm()&&a());W(re,e=>{z(ie)&&e(T)}),E(ne),fa(ne,e=>i(e),()=>i());var ae=I(ne,2),oe=e=>{var n=b8(),i=P(n),a=e=>{var n=_8(),i=I(F(n),2);pi(i,21,()=>p8,e=>e.value,(e,t)=>{var n=h8();let i;var a=I(P(n),2),o=P(a,!0);E(a),E(n),R(()=>{i=Ui(n,1,`brand-theme-sw svelte-12l7ydf`,null,i,{on:r()===z(t).value}),K(n,`data-testid`,`brand-menu-theme-${z(t).value??``}`),K(n,`data-theme-swatch`,z(t).value),K(n,`aria-checked`,r()===z(t).value),U(o,z(t).label)}),B(`click`,n,()=>S(z(t).value)),H(e,n)}),E(i);var a=I(i,2),o=e=>{H(e,g8())};W(a,e=>{(t.onOpenSettings||t.onOpenHelp)&&e(o)}),H(e,n)};W(i,e=>{t.onSetTheme&&e(a)});var o=I(i,2),s=e=>{var t=v8();B(`click`,t,ee),H(e,t)};W(o,e=>{t.onOpenSettings&&e(s)});var c=I(o,2),l=e=>{var t=y8();B(`click`,t,C),H(e,t)};W(c,e=>{t.onOpenHelp&&e(l)}),E(n),fa(n,e=>M(v,e),()=>z(v)),B(`keydown`,n,x),H(e,n)};W(ae,e=>{z(_)&&e(oe)}),E(w);var se=I(w,4),ce=e=>{var n=x8();bi(P(n),()=>t.center),E(n),H(e,n)};W(se,e=>{t.center&&e(ce)});var le=I(se,4),ue=P(le),de=e=>{var t=S8();let n;R(()=>{n=Ui(t,1,`source-toggle-btn svelte-12l7ydf`,null,n,{on:c()}),K(t,`aria-label`,c()?`Switch to formatted editor`:`View markdown source`),K(t,`aria-pressed`,c()),K(t,`title`,c()?`Switch to formatted editor`:`View markdown source`)}),B(`click`,t,function(...e){l()?.apply(this,e)}),H(e,t)};W(ue,e=>{l()&&e(de)});var fe=I(ue,2),pe=e=>{f8(e,{get tandemMode(){return t.tandemMode},get onModeChange(){return t.onModeChange}})};W(fe,e=>{t.tandemMode&&t.onModeChange&&e(pe)});var me=I(fe,2),he=e=>{H(e,C8())};W(me,e=>{n()&&e(he)});var ge=I(me,2),_e=e=>{var n=w8();B(`click`,n,function(...e){t.onConnectAi?.apply(this,e)}),H(e,n)},ve=e=>{var n=T8();B(`click`,n,function(...e){t.onRestartClaude?.apply(this,e)}),H(e,n)},ye=e=>{var n=E8(),r=I(P(n),2),i=P(r,!0);E(r),E(n),R(()=>{K(n,`aria-label`,`Default model: ${o()}. Open Settings → Models.`),K(n,`title`,`Default model: ${o()}`),U(i,o())}),B(`click`,n,function(...e){t.onOpenModelsSettings?.apply(this,e)}),H(e,n)};W(ge,e=>{s()===`connect`?e(_e):s()===`restart`?e(ve,1):o()&&t.onOpenModelsSettings&&e(ye,2)}),E(le);var be=I(le,2),xe=e=>{var t=k8(),n=I(F(t),2),r=P(n),i=I(r,2),a=P(i),o=e=>{H(e,D8())},s=e=>{H(e,O8())};W(a,e=>{z(d)?e(o):e(s,-1)}),E(i);var c=I(i,2);E(n),R(()=>{r.disabled=z(u)===null,K(i,`aria-label`,z(d)?`Restore`:`Maximize`),i.disabled=z(u)===null,c.disabled=z(u)===null}),B(`click`,r,m),B(`click`,i,h),B(`click`,c,g),H(e,t)},Se=A(()=>Bm());W(be,e=>{z(Se)&&e(xe)}),E(te),R(()=>K(ne,`aria-expanded`,z(_))),B(`click`,ne,y),H(e,te),k()}Br([`click`,`keydown`]);var M8=`tandem-status-count-mode`,N8=[`words`,`characters`,`sentences`,`paragraphs`,`pages`],P8={words:`words`,characters:`chars`,sentences:`sentences`,paragraphs:`paragraphs`,pages:`pages`},F8=250;function I8(e){let t=e.trim();return t?t.split(/\s+/).length:0}function L8(e){return N8[(N8.indexOf(e)+1)%N8.length]??`words`}function R8(e){return P8[e]}function z8(){try{let e=localStorage.getItem(M8);if(e&&N8.includes(e))return e}catch{}return`words`}function B8(e){try{localStorage.setItem(M8,e)}catch{}}function V8(e,t){if(!e||e.isDestroyed)return 0;let n=e.state.doc.textContent;switch(t){case`characters`:return n.length;case`words`:return I8(n);case`sentences`:return n.match(/[^.!?]+[.!?]+(?:\s|$)/g)?.length??+!!n.trim();case`paragraphs`:{let t=0;return e.state.doc.forEach(e=>{e.type.name===`paragraph`&&e.textContent.trim()&&t++}),t}case`pages`:return Math.ceil(I8(n)/F8)}}var H8=V(`<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>`),U8=V(`<span data-testid="save-indicator" style="color: var(--tandem-accent);" class="svelte-1esxubl">Saving...</span>`),W8=V(`<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>`),G8=V(`<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>`),K8=V(`<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-2);" class="svelte-1esxubl"><span class="claude-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </span> <!></div></div>`);function q8(e,t){O(t,!0);let n=q(t,`claudeWorkingTool`,3,null),r=q(t,`saving`,3,!1);function i(e){return{tandem_edit:`editing`,tandem_comment:`commenting`,tandem_reply:`replying`,tandem_annotationReply:`replying`}[e]??e.replace(/^tandem_/,``)}let a=iD(av()),o=j(!1),s=j(0),c=Ar(()=>t.connected);L(()=>{let e=c;if(c=t.connected,t.connected&&!e){M(o,!0);let e=setTimeout(()=>{M(o,!1)},2e3);return()=>clearTimeout(e)}}),L(()=>{if(t.disconnectedSince==null){M(s,0);return}M(s,Math.floor((Date.now()-t.disconnectedSince)/1e3),!0);let e=setInterval(()=>{M(s,Math.floor((Date.now()-(t.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(e)});let l=A(()=>t.connectionStatus===`connecting`),u=A(()=>t.connected?`var(--tandem-success)`:z(l)?`var(--tandem-warning)`:`var(--tandem-error)`),d=A(()=>z(o)?`Reconnected`:t.connectionStatus===`connected`?`Synced`:t.connectionStatus===`connecting`?(()=>{let e=[`Reconnecting…`];if(t.reconnectAttempts>0||z(s)>0){let n=[];t.reconnectAttempts>0&&n.push(`attempt ${t.reconnectAttempts}`),z(s)>0&&n.push(`${z(s)}s`),e.push(`(${n.join(`, `)})`)}return e.join(` `)})():`Disconnected — check that the server is running`),f=A(()=>z(o)?`var(--tandem-success-fg-strong)`:t.connectionStatus===`connected`?`var(--tandem-fg-muted)`:t.connectionStatus===`connecting`?`var(--tandem-warning-fg-strong)`:`var(--tandem-error-fg-strong)`),p=j(N(z8())),m=j(0);L(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>{e.isDestroyed||cn(m)};return e.on(`update`,n),e.on(`transaction`,n),()=>{e.off(`update`,n),e.off(`transaction`,n)}});let h=A(()=>(z(m),V8(t.editor??null,z(p))));function g(){let e=L8(z(p));M(p,e,!0),B8(e)}var _=K8(),v=P(_),y=P(v),b=I(y,2),x=P(b,!0);E(b);var S=I(b,2),ee=e=>{var t=H8(),n=P(t);E(t),R((e,r,i,a)=>{K(t,`title`,e),K(t,`aria-label`,r),U(n,`${i??``} ${a??``}`)},[()=>`Click to cycle: ${R8(L8(z(p)))}`,()=>`${z(h)} ${R8(z(p))} (click to change unit)`,()=>z(h).toLocaleString(),()=>R8(z(p))]),B(`click`,t,g),H(e,t)};W(S,e=>{t.editor&&e(ee)});var C=I(S,2),te=e=>{H(e,U8())};W(C,e=>{r()&&e(te)}),E(v);var w=I(v,2),ne=e=>{H(e,W8())};W(w,e=>{t.readOnly&&e(ne)});var re=I(w,2),T=P(re),ie=I(T,2),ae=P(ie,!0);E(ie);var oe=I(ie,2),se=e=>{var t=G8(),r=I(P(t),6),o=P(r);E(r),E(t),R(e=>U(o,`${a.specific??``} is ${e??``}…`),[()=>i(n())]),H(e,t)};W(oe,e=>{n()&&e(se)}),E(re),E(_),R(()=>{G(y,`width: 7px; height: 7px; border-radius: 50%; background: ${z(u)??``}; display: inline-block; animation: ${t.connected&&z(o)?`tandem-conn-bloom 500ms var(--tandem-ease-out)`:z(l)?`tandem-conn-pulse 900ms ease-in-out infinite`:`none`};`),G(b,`color: ${z(f)??``}; transition: color 0.3s ease;`),U(x,z(d)),G(T,`width: 7px; height: 7px; border-radius: 50%; background: var(--tandem-author-claude); opacity: ${t.claudeActive?1:.4}; display: inline-block; transition: opacity 0.3s ease; animation: ${t.claudeActive?`tandem-status-pulse 1.5s ease-in-out infinite`:`none`};`),G(ie,`transition: color 0.3s ease; color: ${t.claudeActive?`var(--tandem-fg)`:`var(--tandem-fg-subtle)`};`),U(ae,t.claudeStatus?`${a.specific} · ${t.claudeStatus}`:`${a.specific} · idle`)}),H(e,_),k()}Br([`click`]);function J8(e){let t=e-1;return t*t*t+1}function Y8(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=J8}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=X8(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function X8(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}function Z8(e){return e.source===`file`&&!e.readOnly}var Q8={md:`md`,markdown:`md`,docx:`docx`,doc:`docx`,txt:`txt`,text:`txt`,html:`html`,htm:`html`};function $8(e){let t=e.lastIndexOf(`.`);return t<=0||t===e.length-1?`other`:Q8[e.slice(t+1).toLowerCase()]??`other`}function e5(e){let t=e.split(/[/\\]/);return{name:t.at(-1)??e,dir:t.slice(0,-1).join(`/`)}}function t5(e,t=Date.now()){let{dir:n,name:r}=e5(e.path);return{path:e.path,name:r,dir:n,when:Xl(e.openedAt,t),pip:$8(r)}}function n5(e,t){let n=t.trim().toLowerCase();return n?e.name.toLowerCase().includes(n)||e.dir.toLowerCase().includes(n):!0}function r5(e,t){let n=t.trim();if(!n)return[{text:e,match:!1}];let r=e.toLowerCase(),i=n.toLowerCase(),a=[],o=0;for(;o<e.length;){let t=r.indexOf(i,o);if(t===-1){a.push({text:e.slice(o),match:!1});break}t>o&&a.push({text:e.slice(o,t),match:!1}),a.push({text:e.slice(t,t+i.length),match:!0}),o=t+i.length}return a}var i5=Jr(`<path></path>`),a5=Jr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg>`),o5=V(`<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>`),s5=V(`<span class="ntl-count svelte-7c4il0" aria-hidden="true"> </span>`),c5=V(`<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>`),l5=V(`<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>`),u5=V(`<mark class="svelte-7c4il0"> </mark>`),d5=V(`<span class="ntl-path svelte-7c4il0"> </span>`),f5=V(`<span class="ntl-when svelte-7c4il0"> </span>`),p5=V(`<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>`),m5=V(`<div class="ntl-recents svelte-7c4il0"></div>`),h5=V(`<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>`),g5=V(`<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 _5(e,t){O(t,!0);let n=(e,t=m,n=m,r=m)=>{var i=a5();pi(i,21,()=>u[t()]??[],li,(e,t)=>{var n=i5();R(()=>K(n,`d`,z(t))),H(e,n)}),E(i),R(()=>{K(i,`width`,n()),K(i,`height`,n()),K(i,`stroke-width`,r())}),H(e,i)},r=j(``),i=j(null),a=j(null),o=A(()=>t.recentFiles.map(e=>t5(e))),s=A(()=>z(o).filter(e=>n5(e,z(r)))),c=A(()=>z(o).length>0),l=A(()=>z(r).trim().length>0),u={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 d(){return Array.from(z(i)?.querySelectorAll(`[data-nav-item]`)??[])}function f(e){let t=d();if(t.length===0)return;let n=t.indexOf(document.activeElement);if(n===-1){(e>0?t[0]:t[t.length-1])?.focus();return}t[(n+e+t.length)%t.length]?.focus()}function p(e){e.key===`Escape`?(e.preventDefault(),t.onClose()):e.key===`ArrowDown`?(e.preventDefault(),f(1)):e.key===`ArrowUp`&&(e.preventDefault(),f(-1))}L(()=>{z(i)&&z(a)?.focus({preventScroll:!0})});var h=g5(),g=P(h),_=P(g);n(P(_),()=>`search`,()=>13,()=>1.7),E(_);var v=I(_,2);$i(v),fa(v,e=>M(a,e),()=>z(a));var y=I(v,2),b=e=>{var t=o5();B(`click`,t,()=>M(r,``)),H(e,t)};W(y,e=>{z(l)&&e(b)});var x=I(y,2),S=e=>{var t=s5(),n=P(t);E(t),R(()=>U(n,`${z(s).length??``} of ${z(o).length??``}`)),H(e,t)};W(x,e=>{z(c)&&e(S)}),D(2),E(g);var ee=I(g,2),C=P(ee),te=P(C),w=e=>{var t=c5(),r=P(t);n(P(r),()=>`inbox`,()=>16,()=>1.6),E(r),D(2),E(t),H(e,t)},ne=e=>{var t=l5(),n=P(t);D(),E(t),R(e=>U(n,`No matches for “${e??``}”. `),[()=>z(r).trim()]),H(e,t)},re=e=>{var n=m5();pi(n,23,()=>z(s),e=>e.path,(e,n,i)=>{var a=p5(),o=P(a),s=I(o,2),c=P(s);pi(c,21,()=>r5(z(n).name,z(r)),li,(e,t)=>{var n=Xr(),r=F(n),i=e=>{var n=u5(),r=P(n,!0);E(n),R(()=>U(r,z(t).text)),H(e,n)},a=e=>{var n=Yr();R(()=>U(n,z(t).text)),H(e,n)};W(r,e=>{z(t).match?e(i):e(a,-1)}),H(e,n)}),E(c);var l=I(c,2),u=e=>{var t=d5(),r=P(t,!0);E(t),R(()=>U(r,z(n).dir)),H(e,t)};W(l,e=>{z(n).dir&&e(u)}),E(s);var d=I(s,2),f=e=>{var t=f5(),r=P(t,!0);E(t),R(()=>U(r,z(n).when)),H(e,t)};W(d,e=>{z(n).when&&e(f)}),E(a),R(()=>{K(a,`data-testid`,`new-tab-recent-${z(i)}`),K(a,`title`,z(n).path),Ui(o,1,`ntl-pip ntl-pip-${z(n).pip??``}`,`svelte-7c4il0`)}),B(`click`,a,()=>t.onOpen(z(n).path)),H(e,a)}),E(n),H(e,n)};W(te,e=>{z(c)?z(s).length===0?e(ne,1):e(re,-1):e(w)}),E(C);var T=I(C,2),ie=I(P(T),2),ae=P(ie);n(P(ae),()=>`plus`,()=>14,()=>1.9),E(ae),D(4),E(ie);var oe=I(ie,4),se=P(oe);n(P(se),()=>`folder`,()=>13,()=>1.7),E(se),D(4),E(oe);var ce=I(oe,2),le=e=>{var r=h5(),i=P(r);n(P(i),()=>`undo`,()=>13,()=>1.7),E(i),D(4),E(r),R(()=>K(r,`title`,t.closedTabTop.filePath)),B(`click`,r,function(...e){t.onReopenClosed?.apply(this,e)}),H(e,r)};W(ce,e=>{t.closedTabTop&&e(le)}),E(T),E(ee),D(2),E(h),fa(h,e=>M(i,e),()=>z(i)),B(`keydown`,h,p),aa(v,()=>z(r),e=>M(r,e)),B(`click`,ie,function(...e){t.onNewScratchpad?.apply(this,e)}),B(`click`,oe,function(...e){t.onBrowse?.apply(this,e)}),H(e,h),k()}Br([`keydown`,`click`]);var v5=V(`<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 y5(e,t){O(t,!0);let n=j(N(Ar(()=>t.initial))),r=!1;function i(e){if(r)return;r=!0;let i=z(n).trim();e&&i.length>0&&i!==t.initial?t.oncommit(i):t.oncancel()}function a(e){e.focus();let n=t.initial.lastIndexOf(`.`);e.setSelectionRange(0,n>0?n:t.initial.length)}function o(e){e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),i(!0)):e.key===`Escape`&&(e.preventDefault(),i(!1))}var s=v5();$i(s),zn(()=>aa(s,()=>z(n),e=>M(n,e))),Pi(s,e=>a?.(e)),R(()=>K(s,`data-testid`,t.testId)),B(`keydown`,s,o),zr(`blur`,s,()=>i(!1)),B(`pointerdown`,s,e=>e.stopPropagation()),B(`click`,s,e=>e.stopPropagation()),B(`dblclick`,s,e=>e.stopPropagation()),H(e,s),k()}Br([`keydown`,`pointerdown`,`click`,`dblclick`]);var b5=V(`<span class="dot svelte-1btt0ja" aria-hidden="true">●</span>`),x5=V(`<span class="saved-check svelte-1btt0ja" aria-hidden="true">✓</span>`),S5=V(`<span class="svelte-1btt0ja"> </span>`),C5=V(`<span class="tab-ro-badge svelte-1btt0ja" aria-label="Read-only">RO</span>`),w5=V(`<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 T5(e,t){O(t,!0);let n=q(t,`reduceMotion`,3,!1),r=q(t,`isRenaming`,3,!1),i=A(()=>Z8(t.tab)),a=j(!1),o=0,s=null;L(()=>{let{ydoc:e,readOnly:n}=t.tab;if(n){M(a,!1);return}let r=e.getXmlFragment(`default`),i=e.getMap(Wa),c=!1,l=setTimeout(()=>{c=!0,s=i.get(`savedAtVersion`)??0,o=0,M(a,!1)},500),u=()=>{c&&(o++,M(a,!0))};r.observeDeep(u);let d=()=>{if(!c)return;let e=i.get(Ka);e!==void 0&&e!==s&&(s=e,o=0,M(a,!1))};return i.observe(d),()=>{clearTimeout(l),r.unobserveDeep(u),i.unobserve(d)}});let c=j(!1),l=!1;L(()=>{let e=l;if(l=z(a),!z(a)&&e){M(c,!0);let e=setTimeout(()=>{M(c,!1)},600);return()=>clearTimeout(e)}M(c,!1)});let u=A(()=>[`display: flex`,`align-items: center`,`gap: 6px`,`padding: 0 10px 0 12px`,`height: 26px`,`font-size: var(--tandem-text-sm)`,`cursor: pointer`,`background: ${t.isActive?`var(--tandem-surface)`:`transparent`}`,`color: ${t.isActive?`var(--tandem-fg)`:`var(--tandem-fg-subtle)`}`,`border: 1px solid ${t.isActive?`var(--tandem-border)`:`transparent`}`,`border-left: ${t.dropIndicator===`left`?`2px solid var(--tandem-accent)`:t.isActive?`1px solid var(--tandem-border)`:`2px solid transparent`}`,`border-right: ${t.dropIndicator===`right`?`2px solid var(--tandem-accent)`:t.isActive?`1px solid var(--tandem-border)`:`2px solid transparent`}`,`border-radius: var(--tandem-r-pill)`,`box-shadow: ${t.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(`; `)),d=j(void 0);function f(){z(d)&&(z(d).style.color=`var(--tandem-error)`)}function p(){z(d)&&(z(d).style.color=`var(--tandem-fg-muted)`)}var m=w5();K(m,`tabindex`,0);var h=P(m),g=P(h),_=e=>{H(e,b5())},v=e=>{H(e,x5())};W(g,e=>{z(a)?e(_):z(c)&&e(v,1)}),E(h);var y=I(h,2),b=e=>{{let n=A(()=>`tab-rename-input-${t.tab.id}`);y5(e,{get initial(){return t.tab.fileName},get testId(){return z(n)},oncommit:e=>t.onrename?.(t.tab.id,e),oncancel:()=>t.onrenamecancel?.()})}},x=e=>{var n=S5(),r=P(n,!0);E(n),R(()=>{K(n,`data-testid`,`tab-name-${t.tab.id}`),K(n,`title`,z(i)?`${t.tab.filePath} — double-click or F2 to rename`:t.tab.filePath),G(n,`font-weight: ${t.isActive?500:400}; min-width: 80px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),U(r,t.tab.fileName)}),B(`dblclick`,n,e=>{z(i)&&(e.stopPropagation(),t.onstartrename?.(t.tab.id))}),H(e,n)};W(y,e=>{r()?e(b):e(x,-1)});var S=I(y,2),ee=e=>{H(e,C5())};W(S,e=>{t.tab.readOnly&&e(ee)});var C=I(S,2);fa(C,e=>M(d,e),()=>z(d)),E(m),R(()=>{K(m,`data-testid`,`tab-${t.tab.id}`),K(m,`data-active`,t.isActive),K(m,`aria-selected`,t.isActive),K(m,`aria-label`,t.tab.fileName),G(m,z(u)),K(h,`data-testid`,`unsaved-indicator-${t.tab.id}`),K(h,`aria-hidden`,!z(a)),K(C,`aria-label`,`Close ${t.tab.fileName}`)}),B(`click`,m,()=>t.onswitch(t.tab.id)),B(`pointerdown`,m,e=>t.onpointerdown(e,t.tab.id)),B(`keydown`,m,e=>t.onkeydown(e,t.tab.id)),B(`click`,C,e=>{e.stopPropagation(),t.onclose(t.tab.id)}),B(`pointerdown`,C,e=>e.stopPropagation()),zr(`mouseenter`,C,f),zr(`mouseleave`,C,p),Mi(1,m,()=>Ev,()=>({reduceMotion:n()})),Mi(2,m,()=>wv,()=>({reduceMotion:n()})),H(e,m),k()}Br([`click`,`pointerdown`,`keydown`,`dblclick`]);var E5=new Set([`ctx:tab:close`,`ctx:tab:closeOthers`,`ctx:tab:closeRight`,`ctx:tab:copyPath`,`ctx:tab:reveal`]);function D5(e){return typeof e==`string`&&E5.has(e)}function O5(e){return!bo(e)&&!yo(e)}function k5(e,t){let n=e.findIndex(e=>e.id===t),r=n>=0?e[n]:void 0;return{canCloseOthers:e.length>1,canCloseRight:n>=0&&n<e.length-1,hasPath:!!r&&O5(r.filePath)}}function A5(e,t){return e.some(e=>e.id===t)?e.filter(e=>e.id!==t).map(e=>e.id):[]}function j5(e,t){let n=e.findIndex(e=>e.id===t);return n<0?[]:e.slice(n+1).map(e=>e.id)}var M5=V(`<div class="tab-flip svelte-urrc8n" role="presentation"><!></div>`),N5=V(`<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 P5(e,t){O(t,!0);let n=q(t,`reduceMotion`,3,!1),r=q(t,`openMenuTrigger`,3,0),i=q(t,`renameTrigger`,3,0),a=q(t,`closedTabTop`,3,null),o=j(null);function s(e){M(o,e,!0)}function c(e,n){M(o,null),t.onTabRename?.(e,n)}function l(){M(o,null)}let u=A(()=>n()?`auto`:`smooth`),d=j(!1),f=j(N([])),p=j(null),m=j(!1),h=j(!1),g=j(null),_=new Set;L(()=>{let e=new Set(t.tabs.map(e=>e.id));for(let t of _)e.has(t)||_.delete(t)});function v(e){_.has(e)||(_.add(e),t.onTabClose(e))}let y=null,b=null;async function x(e){if(!Bm())return;let n=e.target?.closest(`[data-testid^="tab-"][role="tab"]`),r=he(n);if(!r)return;let i=t.tabs.find(e=>e.id===r);if(i){y=r,b=i.filePath,e.preventDefault();try{await(await Um())(`show_tab_context_menu`,{req:k5(t.tabs,r)})}catch{}}}async function S(e){let n=y,r=b;if(n)switch(e){case`ctx:tab:close`:v(n);return;case`ctx:tab:closeOthers`:t.onCloseOthers?.(n);return;case`ctx:tab:closeRight`:t.onCloseToRight?.(n);return;case`ctx:tab:copyPath`:if(r&&O5(r))try{await navigator.clipboard.writeText(r)}catch{}return;case`ctx:tab:reveal`:if(r&&O5(r))try{await(await Um())(`show_in_file_manager`,{path:r})}catch{}return}}let ee=j(void 0),C=j(!1),te=j(!1),w=j(null),ne=j(null),re=null,T=0,ie=0,ae=!1,oe=null;function se(e){ge(e)}function ce(e){_e(e)}function le(e){re!==null&&e.pointerId===re&&de()}function ue(e){e.key===`Escape`&&de()}function de(){if(oe&&re!==null)try{oe.releasePointerCapture(re)}catch{}window.removeEventListener(`pointermove`,se),window.removeEventListener(`pointerup`,ce),window.removeEventListener(`pointercancel`,le),window.removeEventListener(`keydown`,ue),M(w,null),M(ne,null),re=null,ae=!1,oe=null}va(de),L(()=>{if(!z(w)&&!z(ne))return;let e=new Set(t.tabs.map(e=>e.id));z(w)&&!e.has(z(w))&&M(w,null),z(ne)&&!e.has(z(ne).id)&&M(ne,null)});function fe(){let e=z(ee);e&&(M(C,e.scrollLeft>0),M(te,e.scrollLeft+e.clientWidth<e.scrollWidth-1))}L(()=>{let e=z(ee);if(!e)return;fe(),e.addEventListener(`scroll`,fe,{passive:!0});let t=new ResizeObserver(fe);return t.observe(e),()=>{e.removeEventListener(`scroll`,fe),t.disconnect()}}),L(()=>{let e=z(ee);if(e)return e.addEventListener(`contextmenu`,x),()=>e.removeEventListener(`contextmenu`,x)}),L(()=>{if(!Bm())return;let e=Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`context-menu-action`,e=>{let t=e.payload?.id;D5(t)&&S(t)}));return e.catch(()=>{}),()=>{e.then(e=>e()).catch(()=>{})}}),L(()=>{t.tabs.length,fe()}),L(()=>{if(!t.activeTabId||!z(ee))return;let e=z(ee).querySelector(`[data-testid="tab-${t.activeTabId}"]`);e&&e.scrollIntoView({inline:`nearest`,block:`nearest`,behavior:z(u)})});function pe(e,t){if(!(e.button!==0||z(ye))){re=e.pointerId,T=e.clientX,ie=e.clientY,ae=!1,M(w,t,!0),oe=e.currentTarget;try{oe.setPointerCapture(e.pointerId)}catch{}window.addEventListener(`pointermove`,se),window.addEventListener(`pointerup`,ce),window.addEventListener(`pointercancel`,le),window.addEventListener(`keydown`,ue)}}function me(e,t){return document.elementFromPoint(e,t)?.closest(`[data-testid^="tab-"][role="tab"]`)??null}function he(e){return e?.getAttribute(`data-testid`)?.slice(4)??null}function ge(e){if(re===null||e.pointerId!==re||!z(w))return;if(!ae){let t=e.clientX-T,n=e.clientY-ie;if(Math.hypot(t,n)<5)return;ae=!0}e.preventDefault();let t=me(e.clientX,e.clientY),n=he(t);if(!t||!n||n===z(w)){M(ne,null);return}let r=t.getBoundingClientRect(),i=r.left+r.width/2;M(ne,{id:n,side:e.clientX<i?`left`:`right`},!0)}function _e(e){if(re===null||e.pointerId!==re)return;let n=ae,r=z(ne);if(n&&z(w)&&r&&r.id!==z(w)&&t.reorder&&t.tabs.some(e=>e.id===z(w))&&t.tabs.some(e=>e.id===r.id)&&t.reorder(z(w),r.id,r.side),n){let e,t=n=>{n.stopPropagation(),n.preventDefault(),window.removeEventListener(`click`,t,!0),clearTimeout(e)};window.addEventListener(`click`,t,!0),e=setTimeout(()=>window.removeEventListener(`click`,t,!0),0)}de()}function ve(e,n){if(!e.altKey||!t.reorder||e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let r=t.tabs.findIndex(e=>e.id===n);r!==-1&&(e.key===`ArrowLeft`&&r>0?t.reorder(n,t.tabs[r-1].id):e.key===`ArrowRight`&&r<t.tabs.length-1&&t.reorder(t.tabs[r+1].id,n))}let ye=A(()=>t.tabs.length<=1);function be(){let e=!z(d);if(e)M(f,nu(),!0),De=document.activeElement,M(m,Se(),!0);else{xe();return}M(d,e)}function xe(){let e=document.activeElement;e&&z(g)?.contains(e)&&e.blur(),M(d,!1)}function Se(){if(!z(p))return!1;let e=z(p).getBoundingClientRect(),t=window.innerWidth,n=Math.min(460,t-16);return e.right-n>=8?!1:e.left+n<=t-8?!0:t-e.left>e.right}let Ce=null;function we(e){if(!z(g))return NaN;let t=getComputedStyle(z(g)).getPropertyValue(e).trim();return t.endsWith(`ms`)?parseFloat(t):t.endsWith(`s`)?parseFloat(t)*1e3:parseFloat(t)}function Te(){if(!z(g))return 0;let e=we(`--morph-p1`)+we(`--morph-p2`);return Number.isFinite(e)&&e>0?e+40:0}L(()=>{if(z(d)){Ce&&=(clearTimeout(Ce),null),M(h,!0);return}if(!Ar(()=>z(h)))return;Ce&&clearTimeout(Ce);let e=Te();if(e<=0){M(h,!1);return}Ce=setTimeout(()=>{M(h,!1),Ce=null},e)}),va(()=>{Ce&&clearTimeout(Ce)});let Ee=!1,De=null;L(()=>{if(!z(d))return;function e(e){let t=e.target;t&&(z(p)?.contains(t)||t.closest?.(`.new-tab-menu`)||o4(t)||(Ee=!0,xe()))}return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)});let Oe=!1;L(()=>{if(z(d)){Oe=!0;return}if(!Oe)return;Oe=!1;let e=De;if(De=null,Ee){Ee=!1;return}e&&e.isConnected&&e!==z(p)&&!z(g)?.contains(e)&&e.focus({preventScroll:!0})}),L(()=>{r()>0&&Ar(be)}),L(()=>{i()>0&&Ar(()=>{let e=t.tabs.find(e=>e.id===t.activeTabId);e&&Z8(e)&&M(o,e.id,!0)})});var ke=N5(),Ae=P(ke);pi(Ae,29,()=>t.tabs,e=>e.id,(e,r)=>{var i=M5(),a=P(i);{let e=A(()=>z(r).id===t.activeTabId),i=A(()=>z(ne)?.id===z(r).id?z(ne).side:null),u=A(()=>z(o)===z(r).id);T5(a,{get tab(){return z(r)},get isActive(){return z(e)},get onswitch(){return t.onTabSwitch},onclose:v,onpointerdown:pe,get dropIndicator(){return z(i)},onkeydown:ve,get reduceMotion(){return n()},get isRenaming(){return z(u)},onstartrename:s,onrename:c,onrenamecancel:l})}E(i),ji(i,()=>Y8,()=>({duration:fv(n())?0:200})),H(e,i)}),E(Ae),fa(Ae,e=>M(ee,e),()=>z(ee));var je=I(Ae,2),Me=P(je);let Ne;var Pe=P(Me);fa(Pe,e=>M(p,e),()=>z(p));var Fe=I(Pe,2),Ie=P(Fe),Le=P(Ie),Re=e=>{_5(e,{get recentFiles(){return z(f)},get closedTabTop(){return a()},onOpen:async e=>{xe();let t=await Eh(e);t.ok?Ql(Jl(nu(),e)):console.warn(`[tandem] failed to open recent file:`,t.error)},onNewScratchpad:()=>{xe(),gu()},onBrowse:()=>{xe(),t.onRequestOpenDialog?.()},onReopenClosed:()=>{xe(),t.onReopenClosed?.()},onClose:xe})};W(Le,e=>{z(h)&&e(Re)}),E(Ie),E(Fe),E(Me),fa(Me,e=>M(g,e),()=>z(g)),E(je),E(ke),R(()=>{Ui(Ae,1,Li([`tab-scroll-hide`,`tab-scroll-mask`,z(C)&&z(te)&&`has-overflow`,z(C)&&!z(te)&&`overflow-left`,!z(C)&&z(te)&&`overflow-right`])),Ne=Ui(Me,1,`nt-morph svelte-urrc8n`,null,Ne,{open:z(d),filled:z(d)||z(h),"grow-right":z(m)}),K(Pe,`aria-expanded`,z(d)),Ie.inert=!z(d)}),B(`click`,Pe,be),H(e,ke),k()}Br([`click`]);var F5=(e,t=m,n=m)=>{var r=L5();R(()=>{Ui(r,1,`panel-edge-collapse panel-edge-collapse-${t()}`,`svelte-y74n0s`),K(r,`data-testid`,`panel-edge-collapse-${t()}`),K(r,`aria-label`,t()===`left`?`Hide left panel`:`Hide right panel`)}),B(`click`,r,function(...e){n()?.apply(this,e)}),H(e,r)},I5=V(`<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>`),L5=V(`<div role="button" tabindex="-1"></div>`),R5=V(`<!> <!>`,1),z5=V(`<!> <!> <!>`,1),B5=V(`<div class="margin-track svelte-y74n0s" style="grid-column: 2; grid-row: 1;"><!></div>`),V5=V(`<div class="margin-track svelte-y74n0s" style="grid-column: 4; grid-row: 1;"><!></div>`),H5=V(`<div class="editor-content-track svelte-y74n0s" style="grid-column: 3; grid-row: 1;"><!></div> <!> <!>`,1),U5=V(`<div class="editor-end-marker svelte-y74n0s" aria-hidden="true"><span class="editor-end-pill svelte-y74n0s">End of document</span></div>`),W5=V(`<div data-testid="editor-stage"><!></div> <!>`,1),G5=V(`<div class="editor-column-wrap svelte-y74n0s"><div data-testid="editor-scroll-container" role="region" aria-label="Document editor"><!> <!> <!></div> <!></div>`),K5=V(`<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>`),q5=V(`<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>`),J5=V(`<div class="rail-float-shadow rail-float-shadow-left svelte-y74n0s" aria-hidden="true"></div>`),Y5=V(`<div class="rail-float-shadow rail-float-shadow-right svelte-y74n0s" aria-hidden="true"></div>`),X5=V(`<span class="rail-tab-badge svelte-y74n0s"> </span>`),Z5=V(`<!> <!> <!> <!> <!> <!> <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),Q5=V(`<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>`);function $5(e,t){O(t,!0);let n=e=>{P5(e,{get tabs(){return p.orderedTabs},get activeTabId(){return a.activeTabId},get onTabSwitch(){return a.setActiveTabId},onTabClose:l,onCloseOthers:u,onCloseToRight:d,get reorder(){return p.reorder},get reduceMotion(){return h.settings.reduceMotion},onRequestOpenDialog:()=>void _e(),get openMenuTrigger(){return z(D)},onTabRename:(e,t)=>a.handleTabRename(e,t,e=>C.push({id:dc(),type:`launcher`,severity:`error`,message:e,timestamp:Date.now()})),get renameTrigger(){return z(We)},get closedTabTop(){return s.top},onReopenClosed:f})},r=(e,t=m,n=m,r=m,i=m)=>{var a=I5();K(a,`aria-valuemin`,0),K(a,`aria-valuemax`,100),R(e=>{K(a,`data-testid`,r()??`${t()}-panel-resize-handle`),K(a,`aria-label`,t()===`left`?`Resize left panel`:`Resize right panel`),K(a,`aria-valuenow`,e)},[()=>i()===void 0?50:Math.round((i()-200)/400*100)]),B(`mousedown`,a,function(...e){n()?.apply(this,e)}),B(`keydown`,a,e=>{let n=null;e.key===`ArrowRight`||e.key===`ArrowUp`?n=16:e.key===`ArrowLeft`||e.key===`ArrowDown`?n=-16:e.key===`PageUp`?n=80:e.key===`PageDown`?n=-80:e.key===`Home`?n=200-(t()===`left`?qe.width:Je.width):e.key===`End`&&(n=600-(t()===`left`?qe.width:Je.width)),n!==null&&(e.preventDefault(),e.stopPropagation(),t()===`left`?qe.handleResizeStep(n):Je.handleResizeStep(n))}),B(`keyup`,a,()=>{}),zr(`mouseenter`,a,e=>{e.currentTarget.style.background=`var(--tandem-border-strong)`}),zr(`mouseleave`,a,e=>{e.currentTarget.style.background=`transparent`}),H(e,a)},i=e=>{var t=G5(),n=P(t);let r;{let e=e=>{L2(e,{get ydoc(){return z(Ct).ydoc},get provider(){return z(Ct).provider},get readOnly(){return z(Ot)},get currentFilePath(){return z(Ct).filePath},get format(){return z(Ct).format},get activeAnnotationId(){return z(ke)},onEditorReady:e=>M(Me,e,!0),onAnnotationClick:e=>{M(De,`annotations`),M(ke,e,!0)},onClearAnnotation:()=>{M(ke,null)},onSlashCommandMenuChange:e=>M(Pe,e,!0)})},t=(e,t=m,n=m)=>{let r=A(()=>t()===`left`?bt.leftGeometry:bt.rightGeometry),i=A(()=>t()===`left`?bt.leftMode:bt.rightMode);q6(e,{get side(){return t()},get annotations(){return n()},get positions(){return Lt.byId},get width(){return z(r).column},get edgeInset(){return z(r).inset},get gap(){return z(r).gap},get mode(){return z(i)},get activeAnnotationId(){return z(ke)},get repliesById(){return Rt.byId},get reduceMotion(){return h.settings.reduceMotion},onClick:e=>{M(ke,e.id,!0),Nt.scrollToAnnotation(e)},get onAccept(){return Nt.handleAccept},get onDismiss(){return Nt.handleDismiss},get onRemove(){return z(zt).onRemove},get onEdit(){return z(zt).onEdit},get onReply(){return z(zt).onReply},get onSendToClaude(){return z(zt).onSendToClaude}})};var i=P(n);{let e=A(()=>z(Dt)&&z(Ct)?.format===`docx`),t=A(()=>z(Ct)?.id);yA(i,{get visible(){return z(e)},get documentId(){return z(t)}})}var o=I(i,2),s=e=>{var t=R5(),n=F(t);lh(n,{get ydoc(){return z(Ct).ydoc},get documentId(){return z(Ct).id},get fileName(){return z(Ct).fileName}}),Th(I(n,2),{get ydoc(){return z(Ct).ydoc},get documentId(){return z(Ct).id},get fileName(){return z(Ct).fileName}}),H(e,t)};W(o,e=>{z(Ct)&&z(Ct).format===`docx`&&e(s)});var c=I(o,2),l=e=>{var t=Xr();ci(F(t),()=>z(Ct).id,e=>{{let t=A(()=>z(Re).get(z(Ct).id));$2(e,{get documentId(){return z(Ct).id},get ydoc(){return z(Ct).ydoc},get initialDraft(){return z(t)},onDraftChange:(e,t)=>Be(z(Ct).id,e,t),onExit:()=>Mt(z(Ct).id)})}}),H(e,t)},u=n=>{var r=W5(),i=F(r),o=P(i),s=n=>{var r=z5(),i=F(r);ci(i,()=>z(Ct).id,t=>{e(t)});var a=I(i,2),o=e=>{t(e,()=>`left`,()=>z(Ft))};W(a,e=>{bt.leftVisible&&z(Ct)&&e(o)});var s=I(a,2),c=e=>{t(e,()=>`right`,()=>z(It))};W(s,e=>{bt.rightVisible&&z(Ct)&&e(c)}),H(n,r)},c=n=>{var r=H5(),i=F(r),o=P(i),s=t=>{var n=Xr();ci(F(n),()=>z(Ct).id,t=>{e(t)}),H(t,n)},c=e=>{gh(e,{get connected(){return a.connected},get aiChip(){return ie.chip},onOpenFile:()=>M(ge,!0),onRetry:()=>a.reconnect(),onOpenSettings:be,onConnectAi:ae,onRestartClaude:oe})};W(o,e=>{z(Ct)?e(s):e(c,-1)}),E(i);var l=I(i,2),u=e=>{var n=B5();t(P(n),()=>`left`,()=>z(Ft)),E(n),H(e,n)};W(l,e=>{bt.leftVisible&&z(Ct)&&e(u)});var d=I(l,2),f=e=>{var n=V5();t(P(n),()=>`right`,()=>z(It)),E(n),H(e,n)};W(d,e=>{bt.rightVisible&&z(Ct)&&e(f)}),H(n,r)};W(o,e=>{z(Ct)?.format===`docx`?e(s):e(c,-1)}),E(i),fa(i,e=>M(Ne,e),()=>z(Ne));var l=I(i,2),u=e=>{H(e,U5())};W(l,e=>{z(Ct)&&e(u)}),R(()=>G(i,bt.layerStyle)),H(n,r)};W(c,e=>{z(At)&&z(Ct)?e(l):e(u,-1)}),E(n),fa(n,e=>M(wt,e),()=>z(wt)),Pi(n,(e,t)=>Bu?.(e,t),()=>`y`)}q2(I(n,2),{get editor(){return z(Me)},get open(){return z(Fe)},onClose:()=>M(Fe,!1),get tabs(){return a.tabs},get forceScope(){return z(Ie)}}),E(t),R(()=>{r=Ui(n,1,`editor-scroll tandem-scroll-fade-y`,null,r,{"hide-raw-md":!h.settings.showRawMarkdown}),G(n,`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: ${w.fileDragOver||N3.fileDragOver?`2px dashed var(--tandem-accent)`:`2px solid transparent`}; background: ${w.fileDragOver||N3.fileDragOver?`var(--tandem-accent-bg)`:`var(--tandem-bg)`}; transition: border-color 0.15s, background 0.15s; border-radius: ${w.fileDragOver||N3.fileDragOver?`var(--tandem-r-5)`:`0`};`)}),zr(`dragover`,n,function(...e){w.handleEditorDragOver?.apply(this,e)}),zr(`dragleave`,n,function(...e){w.handleEditorDragLeave?.apply(this,e)}),zr(`drop`,n,function(...e){w.handleEditorDrop?.apply(this,e)}),H(e,t)},a=C6({getRetryStrategy:()=>h.settings.sidecarRetryStrategy});va(()=>a.destroy());let o=x3(()=>a.tabs);va(()=>o.destroy()),K_.start({onTransition:()=>a.rebuildForLicenseChange()}),va(()=>K_.stop());let s=W4(),c=new Set;function l(e){let t=a.tabs.find(t=>t.id===e);if(t&&bo(t.filePath)){let e=xo(t.filePath);if(e&&o.hasUnsavedContent(e)){if(!window.confirm(`This scratchpad has unsaved content that will be lost. Close it anyway?`))return;o.clearUnsaved(e)}}if(!(z(ze).has(e)&&!window.confirm(`This document has unsaved markdown-source edits that will be lost. Close it anyway?`))){if(t&&!yo(t.filePath)&&s.push({filePath:t.filePath,closedAt:Date.now()}),z(Le).has(e)){let t=new Set(z(Le));t.delete(e),M(Le,t,!0)}Ve(e),Tt.delete(e),a.handleTabClose(e)}}function u(e){for(let t of A5(p.orderedTabs,e))l(t)}function d(e){for(let t of j5(p.orderedTabs,e))l(t)}async function f(){let e=s.pop();if(!e)return;let t=a.tabs.find(t=>t.filePath===e.filePath);if(t){a.setActiveTabId(t.id);return}if(c.has(e.filePath))return;c.add(e.filePath);let n=t=>{s.push(e);let n=e.filePath.split(/[\\/]/).pop()||e.filePath;C.push({id:`reopen-failed-${Date.now()}`,type:`general-error`,severity:`error`,message:`Couldn't reopen ${n}: ${t}`,dedupKey:`reopen-failed:${e.filePath}`,timestamp:Date.now()})};try{let t=await Eh(e.filePath);t.ok||n(t.error)}finally{c.delete(e.filePath)}}let p=O3(()=>a.tabs);C3(()=>p.orderedTabs,()=>a.activeTabId,e=>a.setActiveTabId(e)),L(()=>{let e=a.tabs;if(e.length!==0)try{let t=Zl(),n=t;for(let t of e)yo(t.filePath)||(n=Jl(n,t.filePath));(n.length!==t.length||n.some((e,n)=>e!==t[n]))&&Ql(n)}catch(e){console.warn(`[tandem] failed to sync recent files:`,e)}});let h=av(),g=k3(()=>a.bootstrapYdoc,()=>h.settings.selectionDwellMs),_=F6(h,g),v=A(()=>vl(h.settings.customShortcuts)),y=A(()=>cl(z(v))),b=A(()=>a.annotations),x=G4(()=>a.disconnectedSince,()=>h.settings.degradedBannerDelayMs),S=h6();_6();let ee=A(()=>a.tabs.map(e=>({id:e.id,fileName:e.fileName}))),C=f3(),te=j(!1),w=$4();if(L3(C.push),Bm()){let e=null,t=!1;Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`sidecar-restart-failed`,()=>{C.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(n=>{t?n():e=n}).catch(e=>{console.warn(`[App] Failed to wire sidecar-restart-failed listener:`,e)}),va(()=>{t=!0,e?.()})}if(Bm()){let e=null,t=!1;Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`open-integration-wizard`,()=>{window.dispatchEvent(new CustomEvent(`tandem:open-integration-wizard`))})).then(n=>{t?n():e=n}).catch(e=>{console.warn(`[App] Failed to wire open-integration-wizard listener:`,e),C.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()})}),va(()=>{t=!0,e?.()})}if(Bm()){let e=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.`}},t=t=>{C.push({id:`startup-file-rejected-${Date.now()}`,type:`general-error`,severity:`warning`,message:e(t),dedupKey:`startup-file-rejected`,timestamp:Date.now(),errorCode:`STARTUP_FILE_REJECTED`})},n=null,r=!1;Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`startup-file-rejected`,e=>{t(typeof e.payload==`string`?e.payload:``)})).then(e=>{r?e():n=e}).catch(e=>{console.warn(`[App] Failed to wire startup-file-rejected listener:`,e)}),Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]).then(({invoke:e})=>e(`get_startup_rejection`)).then(e=>{e&&t(e)}).catch(e=>{console.warn(`[App] Failed to poll buffered startup rejection:`,e)}),va(()=>{r=!0,n?.()})}let ne=j(!1),re=j(!1),T=t3(),ie=R4({connected:()=>a.connected,firstRunSettled:()=>T.settled,soloMode:()=>g.tandemMode===`solo`});function ae(){window.dispatchEvent(new CustomEvent(`tandem:open-integration-wizard`))}function oe(){Nu(),setTimeout(()=>ie.refresh(),2e3),setTimeout(()=>ie.refresh(),5e3)}L(()=>{let e=async e=>{let t=e.detail?.via;if(ie.chip===null||await ie.probeSession())return;let n=ie.chip;if(n===null)return;let r=t===`comment`?`Comment`:`Message`;C.push({id:`ai-not-ready-${t??`chat`}-${Date.now()}`,type:`launcher`,severity:`warning`,message:`${r} saved — no AI is connected yet. It'll be seen when AI connects.`,dedupKey:`ai-not-ready-${t??`chat`}`,timestamp:Date.now()},{label:n===`connect`?`Connect AI`:`Restart Claude Code`,onClick:n===`connect`?ae:oe})};return window.addEventListener(`tandem:addressed-ai`,e),()=>window.removeEventListener(`tandem:addressed-ai`,e)});let se=`tandem:wizard-dismissed`,ce=j(N(ue())),le=j(!1);function ue(){try{return localStorage.getItem(se)}catch{return null}}let de=A(()=>T.needed===!0&&T.serverVersion!==null&&z(ce)!==T.serverVersion),fe=A(()=>z(le)||z(de));function pe(){if(z(de)&&T.serverVersion!==null)try{localStorage.setItem(se,T.serverVersion),M(ce,T.serverVersion,!0)}catch{}M(le,!1)}L(()=>{let e=e=>{e.key===se&&M(ce,e.newValue,!0)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)}),L(()=>{let e=()=>{M(le,!0),M(re,!1),T.refetch()};return window.addEventListener(`tandem:open-integration-wizard`,e),()=>window.removeEventListener(`tandem:open-integration-wizard`,e)});let me=j(null),he=j(!1),ge=j(!1);function _e(){return Ah({isTauri:Bm(),openModal:()=>{M(ge,!0)},onError:e=>C.push({id:dc(),type:`general-error`,severity:`error`,message:e,timestamp:Date.now()})})}let ve=p6();function ye(){z(ne)||ve.acknowledge(),M(ne,!z(ne))}function be(){ve.acknowledge(),M(re,!0)}let xe=j(null);function Se(){z(re)||M(xe,CM.models,!0),be()}function Ce(){ve.acknowledge(),M(ne,!0)}lu({getActiveTabId:()=>a.activeTabId,getActiveDocumentPath:()=>{let e=a.tabs.find(e=>e.id===a.activeTabId);return e&&!yo(e.filePath)?e.filePath:null},notify:(e,t)=>{C.push({id:`launcher-${Date.now()}`,type:`launcher`,severity:e,message:t,timestamp:Date.now()})},openSettings:Ce,openSettingsModal:be,toggleSoloMode:()=>g.setTandemMode(g.tandemMode===`solo`?`tandem`:`solo`),openFindBar:()=>{M(Ie,`doc`),M(Fe,!0)},openFindBarTabs:()=>{M(Ie,`tabs`),M(Fe,!0)},findNext:()=>{let e=z(Me),t=e?TZ(e.state):void 0;e&&e3(t)?e.commands.findNext():(M(Ie,`doc`),M(Fe,!0))},findPrev:()=>{let e=z(Me),t=e?TZ(e.state):void 0;e&&e3(t)?e.commands.findPrev():(M(Ie,`doc`),M(Fe,!0))},closeActiveTab:()=>{let e=a.activeTabId;e&&l(e)},openFileDialog:()=>void _e(),toggleLeftPanel:()=>Qe(),toggleRightPanel:()=>$e(),reopenClosedTab:()=>void f(),annotationNext:()=>{let e=FD(z(b)),t=zD(e,z(ke));if(t){M(ke,t,!0);let n=e.find(e=>e.id===t);n&&Nt.scrollToAnnotation(n)}},annotationPrev:()=>{let e=FD(z(b)),t=BD(e,z(ke));if(t){M(ke,t,!0);let n=e.find(e=>e.id===t);n&&Nt.scrollToAnnotation(n)}},annotationAccept:()=>{let e=Pt();e&&e.author!==`user`&&Nt.handleAccept(e.id)},annotationDismiss:()=>{let e=Pt();e&&e.author!==`user`&&Nt.handleDismiss(e.id)},selectBlock:()=>z(Me)?.chain().focus().selectParentNode().run(),toggleAuthorship:()=>we(!h.settings.showAuthorship),toggleFormattingBar:()=>h.updateSettings({formattingBarVisible:!h.settings.formattingBarVisible}),toggleSourceView:()=>jt(),saveAs:async()=>{let e=a.tabs.find(e=>e.id===a.activeTabId);if(!e||!yo(e.filePath)){C.push({id:dc(),type:`launcher`,severity:`info`,message:`Save As is only available for scratchpads; this document is already on disk.`,timestamp:Date.now()});return}let t=Math.max(e.filePath.lastIndexOf(`/`),e.filePath.lastIndexOf(`\\`)),n=e.filePath.slice(t+1);await Su({activeDocId:a.activeTabId,defaultName:n,sourceFormat:e.format,notify:(e,t)=>C.push({id:dc(),type:`launcher`,severity:e,message:t,timestamp:Date.now()})})}});function we(e){h.updateSettings({showAuthorship:e,...h.settings.decorationsMuted?{decorationsMuted:!1}:{}})}let Te=null;L(()=>{let e=z(Me);if(!e)return;let t=h.settings,n=!t.decorationsMuted&&t.showAuthorship;if(Te===n)return;let r=Te===null;Te=n,!r&&Ar(()=>{let t=e.state.tr.setMeta(cZ,{type:`toggle`,visible:n});e.view.dispatch(t)})});let Ee=null;L(()=>{let e=z(Me);if(!e)return;let t=h.settings,n=t.decorationsMuted,r={comment:!n&&t.showComments,highlight:!n&&t.showHighlights,note:!n&&t.showNotes},i=`${+!!r.comment}${+!!r.highlight}${+!!r.note}`;if(Ee===i)return;let a=Ee===null;Ee=i,!a&&Ar(()=>{let t=e.state.tr.setMeta(JX,{type:`toggle-decorations`,visible:r});e.view.dispatch(t)})}),L(()=>(document.body.classList.toggle(`tandem-reduce-motion`,h.settings.reduceMotion),()=>document.body.classList.remove(`tandem-reduce-motion`))),L(()=>(document.body.classList.toggle(`tandem-rail-hover-reveal`,h.settings.railHoverReveal),()=>document.body.classList.remove(`tandem-rail-hover-reveal`))),K3(()=>h.settings.theme,()=>h.settings.systemLightVariant),I4(()=>h.settings.accentHue),Q4(()=>Fl(h.settings,z(Ct)?.format)),q4(()=>h.settings.density),r3(()=>h.settings.highContrast),B4(()=>h.settings.annotationPatterns),L(()=>{let e=wl[h.settings.textSize];return document.documentElement.style.setProperty(`--tandem-editor-font-size`,`${e}px`),()=>document.documentElement.style.removeProperty(`--tandem-editor-font-size`)});let De=j(N(h.settings.primaryTab===`chat`?`chat`:`annotations`)),Oe=A(()=>z(De)===`annotations`?0:z(b).filter(sc).length),ke=j(null),Ae=j(!1),je=j(null),Me=j(null),Ne=j(null),Pe=j(!1),Fe=j(!1),Ie=j(`doc`),Le=j(N(new Set)),Re=j(N(new Map)),ze=j(N(new Set));function Be(e,t,n){let r=new Map(z(Re)),i=new Set(z(ze));n?(r.set(e,t),i.add(e)):(r.delete(e),i.delete(e)),M(Re,r,!0),M(ze,i,!0)}function Ve(e){if(!z(Re).has(e)&&!z(ze).has(e))return;let t=new Map(z(Re)),n=new Set(z(ze));t.delete(e),n.delete(e),M(Re,t,!0),M(ze,n,!0)}let He=j(0),Ue=j(0),D=j(0),We=j(0),Ge=J4(`left`),Ke=J4(`right`),qe=Y4({side:`left`,initialWidth:Ge,getVisible:()=>z(Ye)}),Je=Y4({side:`right`,initialWidth:Ke,getVisible:()=>z(Xe)}),Ye=A(()=>_.leftVisible),Xe=A(()=>_.rightVisible);function Ze(e,t){queueMicrotask(()=>{let n=t?`panel-edge-collapse-${e}`:`peek-strip-${e}`,r=document.querySelector(`[data-testid="${n}"]`);r?r.focus():console.warn(`[tandem] focusToggleTarget: ${n} not mounted; focus dropped to body`)})}let Qe=()=>{et(`left`),nt.left=!1;let e=!_.leftVisible;_.toggleLeft(),Ze(`left`,e)},$e=()=>{et(`right`),nt.right=!1;let e=!_.rightVisible;_.toggleRight(),Ze(`right`,e)};function et(e){nt[e]&&(rt[e]=!0,requestAnimationFrame(()=>{rt[e]=!1}))}let tt=N({left:!1,right:!1}),nt=N({left:!1,right:!1}),rt=N({left:!1,right:!1}),it=N({left:!1,right:!1}),at={left:void 0,right:void 0},ot={left:void 0,right:void 0},st={left:void 0,right:void 0},ct={left:!1,right:!1},lt={left:!1,right:!1},ut=e=>z(e===`left`?Ye:Xe);function dt(e){if(ct[e]=!0,!(ut(e)||!h.settings.railHoverReveal)){if(clearTimeout(at[e]),it[e]){clearTimeout(ot[e]),it[e]=!1,nt[e]=!0;return}at[e]=setTimeout(()=>{nt[e]=!0},120)}}function ft(e){if(!(ct[e]||lt[e])&&nt[e]){if(nt[e]=!1,ut(e)||fv(h.settings.reduceMotion)){it[e]=!1;return}it[e]=!0,clearTimeout(ot[e]),ot[e]=setTimeout(()=>{it[e]=!1},300)}}function pt(e){ct[e]=!1,clearTimeout(at[e]),at[e]=setTimeout(()=>ft(e),180)}function mt(e){lt[e]=!0}function ht(e,t){let n=t.currentTarget,r=t.relatedTarget;r&&n.contains(r)||(lt[e]=!1,ft(e))}function gt(e,t){t.propertyName!==`width`||t.target!==t.currentTarget||(tt[e]=!1,clearTimeout(st[e]))}let _t=Ar(()=>({left:z(Ye),right:z(Xe)}));L(()=>{let e=z(Ye),t=z(Xe);Ar(()=>{vt(`left`,e),vt(`right`,t)})});function vt(e,t){if(t===_t[e])return;let n=_t[e]&&!t;_t[e]=t,!(!n||h.settings.reduceMotion)&&(tt[e]=!0,clearTimeout(st[e]),st[e]=setTimeout(()=>{tt[e]=!1},400))}L(()=>()=>{clearTimeout(at.left),clearTimeout(at.right),clearTimeout(st.left),clearTimeout(st.right),clearTimeout(ot.left),clearTimeout(ot.right)});let yt=g6(),bt=P6({getFormat:()=>z(Ct)?.format,getMarginView:()=>h.settings.marginView,getEditorMeasure:()=>h.settings.editorMeasure,getLeftRailVisible:()=>z(Ye),getRightRailVisible:()=>z(Xe),getViewportWidth:()=>yt.width,getLeftHasPending:()=>z(b).some(e=>e.status===`pending`&&J6(e)),getRightHasPending:()=>z(b).some(e=>e.status===`pending`&&Y6(e)),leftRailWidthPx:Ge,rightRailWidthPx:Ke});function xt(){if(z(De)===`chat`||!z(Me))return;let{from:e,to:t}=z(Me).state.selection;if(e===t)return;let n=gD(z(Me).state.doc,{from:Co(e),to:Co(t)}),r=z(Me).state.doc.textBetween(e,t,`
270
+ `);M(je,{...n,textSnapshot:r.length>200?r.slice(0,197)+`...`:r},!0)}let St={"toggle-help":e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||(e.preventDefault(),M(Ae,Ar(()=>!z(Ae)),!0))},"select-all":e=>{let t=document.activeElement;t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t?.closest?.(`.ProseMirror`)||(e.preventDefault(),z(Me)?.commands.selectAll())},save:e=>{e.preventDefault(),!z(At)&&Tu(a.activeTabId)},"save-as":e=>{let t=e.target;if(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable))return;e.preventDefault();let n=a.tabs.find(e=>e.id===a.activeTabId);if(!n||!yo(n.filePath)){C.push({id:dc(),type:`launcher`,severity:`info`,message:`Save As is only available for scratchpads; this document is already on disk.`,timestamp:Date.now()});return}let r=Math.max(n.filePath.lastIndexOf(`/`),n.filePath.lastIndexOf(`\\`)),i=n.filePath.slice(r+1);Su({activeDocId:a.activeTabId,defaultName:i,sourceFormat:n.format,notify:(e,t)=>C.push({id:dc(),type:`launcher`,severity:e,message:t,timestamp:Date.now()})})},"settings-modal":e=>{e.preventDefault(),be()},settings:e=>{e.preventDefault(),Ce()},"toggle-palette":e=>{e.preventDefault(),M(he,!Ar(()=>z(he)))},"new-scratchpad":e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`)||(e.preventDefault(),gu())},"close-tab":e=>{if(T3(e))return;e.preventDefault();let t=a.activeTabId;t&&l(t)},"open-file":e=>{T3(e)||(e.preventDefault(),_e())},"pick-tab":(e,t)=>{if(T3(e))return;let n=t?.tabIndex;if(n===void 0)return;let r=w3(a.tabs,n);r&&(e.preventDefault(),a.setActiveTabId(r))},"toggle-mode":e=>{T3(e)||(e.preventDefault(),g.setTandemMode(g.tandemMode===`solo`?`tandem`:`solo`))},"reopen-closed-tab":e=>{T3(e)||(e.preventDefault(),f())},"new-tab-menu":e=>{T3(e)||(e.preventDefault(),M(D,z(D)+1))},find:(e,t)=>{if(e.preventDefault(),t?.shift){M(Ie,`tabs`),M(Fe,!0);return}z(Ye)?M(He,z(He)+1):(M(Ie,`doc`),M(Fe,!0))},"find-nav":(e,t)=>{if(T3(e))return;e.preventDefault();let n=z(Me),r=n?TZ(n.state):void 0;n&&e3(r)?t?.shift?n.commands.findPrev():n.commands.findNext():(M(Ie,`doc`),M(Fe,!0))},"annotation-accept-or-dismiss":(e,t)=>{if(T3(e))return;e.preventDefault();let n=Pt();n&&n.author!==`user`&&(t?.shift?Nt.handleDismiss(n.id):Nt.handleAccept(n.id))},"comment-on-selection":e=>{e.preventDefault();let t=!!z(Me)&&z(Me).state.selection.from!==z(Me).state.selection.to,n=z(Dt);if(!(z(Pe)||z(Fe)||z(he))){if(!t){C.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(n){C.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(!h.settings.selectionToolbar){C.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}M(Ue,z(Ue)+1)}},"toggle-authorship":e=>{e.preventDefault(),we(!h.settings.showAuthorship)},"toggle-left-panel":e=>{T3(e)||(e.preventDefault(),Qe())},"toggle-right-panel":e=>{T3(e)||(e.preventDefault(),$e())},"annotation-next":e=>{if(T3(e))return;e.preventDefault();let t=FD(z(b)),n=zD(t,z(ke));if(n){M(ke,n,!0);let e=t.find(e=>e.id===n);e&&Nt.scrollToAnnotation(e)}},"annotation-prev":e=>{if(T3(e))return;e.preventDefault();let t=FD(z(b)),n=BD(t,z(ke));if(n){M(ke,n,!0);let e=t.find(e=>e.id===n);e&&Nt.scrollToAnnotation(e)}},"select-block":e=>{T3(e)||(e.preventDefault(),z(Me)&&z(Me).chain().focus().selectParentNode().run())}};L(()=>{function e(e){if(e.key===`F2`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){if(T3(e))return;let t=a.tabs.find(e=>e.id===a.activeTabId);t&&Z8(t)&&(e.preventDefault(),M(We,z(We)+1));return}let t=ul(e,Ar(()=>z(v)));t&&St[t.id]?.(e,t.context)}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),L(()=>{function e(e){if(e.key!==`Escape`||e.defaultPrevented||z(ke)===null||z(Fe))return;let t=document.activeElement;t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||(!t||t===document.body||t.closest(`.ProseMirror, [data-testid="editor-root"], [data-testid="annotation-list-scroll-container"]`))&&(e.preventDefault(),M(ke,null))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let Ct=A(()=>a.tabs.find(e=>e.id===a.activeTabId)),wt=j(null),Tt=new Map,Et;L(()=>{let e=z(wt);if(!e)return;let t=()=>{Et!==void 0&&Tt.set(Et,e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)}),L(()=>{let e=z(wt),t=z(Ct)?.id;if(!e||t===Et||(Et=t,t===void 0))return;let n=Tt.get(t)??0,r=0,i=!1,a=()=>{i||Et!==t||(e.scrollTop=n,e.scrollTop<n&&r<30&&(r+=1,requestAnimationFrame(a)))};return requestAnimationFrame(a),()=>{i=!0}});let Dt=A(()=>z(Ct)?.readOnly===!0),Ot=A(()=>z(Dt)||K_.ui.showWall),kt=A(()=>!!z(Ct)&&z(Ct).format===`md`&&!z(Dt)),At=A(()=>!!z(Ct)&&z(Le).has(z(Ct).id));function jt(){if(!z(Ct))return;let e=z(Ct).id,t=new Set(z(Le));if(t.has(e))t.delete(e);else{if(!z(kt))return;t.add(e),M(Fe,!1),M(Pe,!1),M(he,!1)}M(Le,t,!0)}function Mt(e){if(!z(Le).has(e))return;let t=new Set(z(Le));t.delete(e),M(Le,t,!0),Ve(e)}L(()=>{let e=e=>{z(ze).size!==0&&(e.preventDefault(),e.returnValue=`You have unsaved markdown-source edits.`)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)}),L(()=>{if(!hu({connected:a.connected,tabCount:a.tabs.length,activeTabId:a.activeTabId}))return;let e=setTimeout(()=>{gu()},400);return()=>clearTimeout(e)});let Nt=n8({getYdoc:()=>z(Ct)?.ydoc??null,getEditor:()=>z(Me),getAnnotations:()=>z(b),onActiveAnnotationChange:e=>{M(ke,e,!0)},getScrollBehavior:()=>h.settings.reduceMotion?`auto`:`smooth`,getActiveAnnotationId:()=>z(ke)});function Pt(){return z(ke)?z(b).find(e=>e.id===z(ke)):Nt.getReviewTargets()[0]}let Ft=A(()=>bt.effectivelyOn?z(b).filter(J6):[]),It=A(()=>bt.effectivelyOn?z(b).filter(Y6):[]),Lt=o3({getEditor:()=>z(Me),getYdoc:()=>z(Ct)?.ydoc??null,getAnnotations:()=>[...z(Ft),...z(It)],getLayerEl:()=>z(Ne),getEnabled:()=>bt.effectivelyOn}),Rt=V4({getYdoc:()=>z(Ct)?.ydoc??null}),zt=A(()=>{let e=z(Ct)?.ydoc??null,t=z(Ct)?.id;return{ydoc:e,docId:t,onEdit:(t,n)=>ok(e,t,n),onReply:(e,n)=>dk(e,n,t),onRemove:e=>uk(e,t),onSendToClaude:t=>ck(e,t)}}),Bt=X3(()=>z(b),()=>z(Me),()=>z(Ct)?.fileName);var Vt=Q5(),Ht=P(Vt);{let e=A(()=>null),t=A(()=>z(kt)||z(At)?jt:null);j8(Ht,{get tandemMode(){return g.tandemMode},get onModeChange(){return g.setTandemMode},get claudeActive(){return a.claudeActive},get theme(){return h.settings.theme},onSetTheme:e=>h.updateSettings({theme:e}),onOpenHelp:()=>M(Ae,!0),onOpenSettings:ye,onOpenSettingsModal:be,get updateAvailable(){return ve.showDot},get defaultModelLabel(){return z(e)},onOpenModelsSettings:Se,get aiChip(){return ie.chip},onConnectAi:ae,onRestartClaude:oe,get sourceViewActive(){return z(At)},get onToggleSourceView(){return z(t)},get center(){return n},get settingsBtn(){return z(me)},set settingsBtn(e){M(me,e,!0)}})}var Ut=I(Ht,2),Wt=e=>{H(e,K5())},Gt=e=>{var t=Z5(),n=F(t),o=e=>{H(e,q5())};W(n,e=>{a.serverRestarted&&e(o)});var s=I(n,2),c=e=>{ZM(e,{get version(){return S.availableVersion},get installing(){return S.installing},onInstall:()=>{S.install()},get onDismiss(){return S.dismiss}})},l=A(()=>Bm()&&S.showBanner&&S.availableVersion);W(s,e=>{z(l)&&e(c)});var u=I(s,2),d=e=>{Tm(e,{get onDismiss(){return x.dismiss},onRetry:()=>{a.reconnect()}})};W(u,e=>{x.showBanner&&e(d)});var f=I(u,2);Y_(f,{});var p=I(f,2);{let e=A(()=>z(Ct)?.ydoc??null),t=A(()=>z(Pe)||z(Fe)||z(he));P4(p,{get editor(){return z(Me)},get ydoc(){return z(e)},get selectionToolbar(){return h.settings.selectionToolbar},get suppressSelectionToolbar(){return z(t)},get requestCommentFocus(){return z(Ue)},get showAuthorship(){return h.settings.showAuthorship},get showComments(){return h.settings.showComments},get showHighlights(){return h.settings.showHighlights},get showNotes(){return h.settings.showNotes},get decorationsMuted(){return h.settings.decorationsMuted},onUpdateDecorations:e=>h.updateSettings(e),onOpenSettings:ye,get formattingBarVisible(){return h.settings.formattingBarVisible},onToggleFormattingBar:()=>h.updateSettings({formattingBarVisible:!h.settings.formattingBarVisible}),get reduceMotion(){return h.settings.reduceMotion}})}var m=I(p,2),g=e=>{{let t=A(()=>z(Ct)?.ydoc??null);u8(e,{get editor(){return z(Me)},get ydoc(){return z(t)},get showAuthorship(){return h.settings.showAuthorship},get showComments(){return h.settings.showComments},get showHighlights(){return h.settings.showHighlights},get showNotes(){return h.settings.showNotes},get decorationsMuted(){return h.settings.decorationsMuted},onUpdateDecorations:e=>h.updateSettings(e),onOpenSettings:ye,onHide:()=>h.updateSettings({formattingBarVisible:!1})})}};W(m,e=>{h.settings.formattingBarVisible&&e(g)});var _=I(m,2),v=P(_);let w;var T=P(v),ie=e=>{var t=J5();R(()=>G(t,`width: ${qe.width}px;`)),H(e,t)};W(T,e=>{(nt.left||it.left)&&e(ie)});var ae=I(T,2),oe=P(ae);hA(oe,{kind:`outline`,get focusTrigger(){return z(He)},get editor(){return z(Me)},visible:!0}),F5(I(oe,2),()=>`left`,()=>Qe),E(ae);var se=I(ae,2);{let e=A(()=>!z(Ye));$6(se,{side:`left`,get collapsed(){return z(e)},kind:`outline`,onActivate:Qe})}E(v);var ce=I(v,2),le=e=>{r(e,()=>`left`,()=>e=>qe.handleResizeStart(e),()=>void 0,()=>qe.width)};W(ce,e=>{z(Ye)&&e(le)});var ue=I(ce,2);i(ue);var de=I(ue,2),_e=e=>{r(e,()=>`right`,()=>e=>Je.handleResizeStart(e),()=>`panel-resize-handle`,()=>Je.width)};W(de,e=>{z(Xe)&&e(_e)});var ve=I(de,2);let be;var Se=P(ve),Ce=e=>{var t=Y5();R(()=>G(t,`width: ${Je.width}px;`)),H(e,t)};W(Se,e=>{(nt.right||it.right)&&e(Ce)});var we=I(Se,2),Te=P(we);F5(Te,()=>`right`,()=>$e);var Ee=I(Te,2),Ne=P(Ee),Ie=P(Ne),Le=I(P(Ie)),Re=e=>{var t=X5(),n=P(t,!0);E(t),R(()=>U(n,z(Oe)>9?`9+`:z(Oe))),H(e,t)};W(Le,e=>{z(De)!==`annotations`&&z(Oe)>0&&e(Re)}),E(Ie);var ze=I(Ie,2);E(Ne),E(Ee);var Be=I(Ee,2);{let e=A(()=>z(De)===`chat`);hA(Be,{kind:`chat`,get ctrlYdoc(){return a.bootstrapYdoc},get editor(){return z(Me)},get activeDocId(){return a.activeTabId},get openDocs(){return z(ee)},get claudeActive(){return a.claudeActive},get claudeStatus(){return a.claudeStatus},get capturedAnchor(){return z(je)},onCapturedAnchorChange:e=>M(je,e,!0),get reduceMotion(){return h.settings.reduceMotion},get visible(){return z(e)}})}var Ve=I(Be,2);{let e=A(()=>z(Ct)?.ydoc??null),t=A(()=>z(Ct)?.format),n=A(()=>z(Ct)?.id),r=A(()=>a.claudeWorking?.annotationId??null),i=A(()=>z(De)===`annotations`);hA(Ve,{kind:`side`,get annotations(){return z(b)},get editor(){return z(Me)},get ydoc(){return z(e)},get activeDocFormat(){return z(t)},get documentId(){return z(n)},get activeAnnotationId(){return z(ke)},onActiveAnnotationChange:e=>M(ke,e,!0),get reduceMotion(){return h.settings.reduceMotion},get storeReadOnly(){return a.storeReadOnly},get claudeWorkingAnnotationId(){return z(r)},get review(){return Nt},get visible(){return z(i)}})}E(we);var D=I(we,2);{let e=A(()=>!z(Xe));$6(D,{side:`right`,get collapsed(){return z(e)},kind:`annotations`,get annotations(){return z(b)},onActivate:$e})}E(ve),E(_);var We=I(_,2);{let e=A(()=>a.claudeWorking?.tool??null);q8(We,{get connected(){return a.connected},get connectionStatus(){return a.connectionStatus},get reconnectAttempts(){return a.reconnectAttempts},get disconnectedSince(){return a.disconnectedSince},get claudeStatus(){return a.claudeStatus},get claudeActive(){return a.claudeActive},get claudeWorkingTool(){return z(e)},get readOnly(){return z(Dt)},get saving(){return fu.saving},get editor(){return z(Me)}})}var Ge=I(We,2);UM(Ge,{get open(){return z(ne)},onClose:()=>M(ne,!1),get settings(){return h.settings},get onUpdate(){return h.updateSettings},get returnFocusEl(){return z(me)},get anchorEl(){return z(me)},get connected(){return a.connected},get reconnectAttempts(){return a.reconnectAttempts}});var Ke=I(Ge,2);OM(Ke,{get open(){return z(re)},onClose:()=>{M(re,!1),M(xe,null)},get settings(){return h.settings},get onUpdate(){return h.updateSettings},get returnFocusEl(){return z(me)},get triggerEl(){return z(me)},get connected(){return a.connected},get reconnectAttempts(){return a.reconnectAttempts},get initialTabId(){return z(xe)},notify:(e,t)=>C.push({id:`settings-${Date.now()}`,type:`launcher`,severity:e,message:t,timestamp:Date.now()})});var Ze=I(Ke,2);ev(Ze,{});var O=I(Ze,2);Qh(O,{get open(){return z(Ae)},onClose:()=>M(Ae,!1),get effectiveShortcutLabels(){return z(y)}});var k=I(O,2),et=e=>{z_(e,{open:!0,onClose:pe})};W(k,e=>{z(fe)&&e(et)});var at=I(k,2),ot=e=>{qh(e,{onClose:()=>M(ge,!1)})};W(at,e=>{z(ge)&&e(ot)});var st=I(at,2);Cm(st,{get open(){return z(he)},onClose:()=>M(he,!1),get editor(){return z(Me)},get annotations(){return z(b)},onFocusAnnotation:e=>{M(ke,e,!0)}});var ct=I(st,2);YM(ct,{get toasts(){return C.toasts},get onDismiss(){return C.dismiss}});var lt=I(ct,2);td(lt,{get items(){return C.activity},get open(){return z(te)},onToggle:()=>M(te,!z(te)),get onDismiss(){return C.dismissActivity},get onClear(){return C.clearActivity},onAction:e=>{let t=Vu(e);t&&(a.tabs.some(e=>e.id===t.documentId)?Tu(t.documentId):C.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 ut=I(lt,2),ft=e=>{oh(e,{})},_t=A(()=>Bm()&&!z(fe));W(ut,e=>{z(_t)&&e(ft)});var vt=I(ut,2),yt=e=>{Wv(e,{get currentStep(){return Bt.currentStep},get onNext(){return Bt.nextStep},get onDismiss(){return Bt.dismissTutorial},get coworkStatus(){return Bt.coworkStatus}})};W(vt,e=>{Bt.tutorialActive&&e(yt)}),R(()=>{w=Ui(v,1,`rail-shell rail-shell-left svelte-y74n0s`,null,w,{collapsed:!z(Ye),animating:tt.left,"rail-floating-chrome":nt.left||it.left,floating:nt.left,"float-closing":it.left,"pin-snap":rt.left}),K(v,`data-testid`,nt.left?`rail-float-left`:void 0),G(v,z(Ye)?`width: ${qe.width}px;`:``),G(ae,`width: ${qe.width}px;`),be=Ui(ve,1,`rail-shell rail-shell-right svelte-y74n0s`,null,be,{collapsed:!z(Xe),animating:tt.right,"rail-floating-chrome":nt.right||it.right,floating:nt.right,"float-closing":it.right,"pin-snap":rt.right}),K(ve,`data-testid`,nt.right?`rail-float-right`:void 0),G(ve,z(Xe)?`width: ${Je.width}px;`:``),G(we,`width: ${Je.width}px;`),Ui(Ie,1,`rail-tab`+(z(De)===`annotations`?` on`:``),`svelte-y74n0s`),Ui(ze,1,`rail-tab`+(z(De)===`chat`?` on`:``),`svelte-y74n0s`)}),zr(`scroll`,_,e=>{e.currentTarget.scrollLeft=0}),zr(`mouseenter`,v,()=>dt(`left`)),zr(`mouseleave`,v,()=>pt(`left`)),B(`focusin`,v,()=>mt(`left`)),B(`focusout`,v,e=>ht(`left`,e)),zr(`transitionend`,v,e=>gt(`left`,e)),zr(`mouseenter`,ve,()=>dt(`right`)),zr(`mouseleave`,ve,()=>pt(`right`)),B(`focusin`,ve,()=>mt(`right`)),B(`focusout`,ve,e=>ht(`right`,e)),zr(`transitionend`,ve,e=>gt(`right`,e)),B(`click`,Ie,()=>{M(De,`annotations`)}),B(`mousedown`,ze,xt),B(`click`,ze,()=>{M(De,`chat`)}),H(e,t)};W(Ut,e=>{a.ready?e(Gt,-1):e(Wt)}),E(Vt),R(()=>K(Vt,`data-tandem-mode`,g.tandemMode)),H(e,Vt),k()}Br([`mousedown`,`keydown`,`keyup`,`click`,`focusin`,`focusout`]);var e7=`error-boundary-recover-btn`,t7=`error-boundary-reload-btn`;function n7(e,t){O(t,!0),L(()=>{t.onSuccess()}),k()}var r7=V(`<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>`),i7=V(`<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>`),a7=V(`<!> <!>`,1);function o7(e,t){O(t,!0);let n=j(0),r=j(0);var i=Xr();zt(F(i),{onerror:e=>{dM(e,{source:`ErrorBoundary`}),M(r,z(r)+1)},failed:(e,t=m,i=m)=>{var a=Xr();ci(F(a),()=>z(r),e=>{var r=i7(),a=I(P(r),2),o=P(a,!0);E(a);var s=I(a,2),c=P(s,!0);E(s);var l=I(s,2),u=e=>{var t=r7();R(()=>K(t,`data-testid`,e7)),B(`click`,t,()=>{M(n,z(n)+1),i()()}),H(e,t)};W(l,e=>{z(n)<3&&e(u)});var d=I(l,2);E(r),R(e=>{U(o,z(n)>=3?`We weren't able to recover this time — reloading the page should get you going again.`:`The editor ran into an unexpected hiccup.`),U(c,e),K(d,`data-testid`,t7)},[()=>t()instanceof Error?t().message:String(t())]),B(`click`,d,()=>window.location.reload()),H(e,r)}),H(e,a)}},e=>{var r=a7(),i=F(r);bi(i,()=>t.children),n7(I(i,2),{onSuccess:()=>{M(n,0)}}),H(e,r)}),H(e,i),k()}Br([`click`]);function s7(e){o7(e,{children:(e,t)=>{$5(e,{})},$$slots:{default:!0}})}lM(),Qr(s7,{target:document.getElementById(`root`)});export{B as A,O as B,pi as C,V as D,H as E,I as F,E as H,M as I,j as L,R as M,P as N,Yr as O,F as P,A as R,Ui as S,U as T,t as U,D as V,va as _,Um as a,ta as b,Im as c,Vm as d,Dm as f,Sa as g,mo as h,Gm as i,z as j,Br as k,Em as l,jm as m,Km as n,Nm as o,Mm as p,qm as r,Fm as s,eh as t,Am as u,$i as v,W as w,G as x,K as y,k as z};