tandem-editor 0.11.2 → 0.12.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.
- package/.claude-plugin/plugin.json +2 -2
- package/CHANGELOG.md +135 -65
- package/README.md +9 -9
- package/dist/channel/index.js +59 -18
- package/dist/channel/index.js.map +1 -1
- package/dist/cli/index.js +102 -31
- package/dist/cli/index.js.map +1 -1
- package/dist/client/assets/{CoworkSettings-DK3jjdwK.js → CoworkSettings-C0cS9R7L.js} +1 -1
- package/dist/client/assets/event-CNdo2oXa.js +1 -0
- package/dist/client/assets/index-Dn5JwXA3.css +1 -0
- package/dist/client/assets/index-n-vFW5By.js +299 -0
- package/dist/client/assets/webview-Bhf-n_os.js +1 -0
- package/dist/client/assets/window-DePn7tLG.js +1 -0
- package/dist/client/index.html +4 -2
- package/dist/monitor/index.js +23 -16
- package/dist/monitor/index.js.map +1 -1
- package/dist/server/index.js +388 -331
- package/dist/server/index.js.map +1 -1
- package/package.json +7 -3
- package/dist/client/assets/index-CfT503n4.js +0 -297
- package/dist/client/assets/index-DeJe09pn.css +0 -1
- package/dist/client/assets/webview-Ben21ZLJ.js +0 -1
- package/dist/client/assets/window-BxBvHL5k.js +0 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-DePn7tLG.js","assets/core-DhEqZVGG.js","assets/event-CNdo2oXa.js","assets/webview-Bhf-n_os.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var pT=Object.defineProperty;var _y=n=>{throw TypeError(n)};var mT=(n,e,t)=>e in n?pT(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var gn=(n,e,t)=>mT(n,typeof e!="symbol"?e+"":e,t),Dh=(n,e,t)=>e.has(n)||_y("Cannot "+t);var J=(n,e,t)=>(Dh(n,e,"read from private field"),t?t.call(n):e.get(n)),Ke=(n,e,t)=>e.has(n)?_y("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Je=(n,e,t,r)=>(Dh(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),mt=(n,e,t)=>(Dh(n,e,"access private method"),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();const f1=!1;var Tg=Array.isArray,gT=Array.prototype.indexOf,Ba=Array.prototype.includes,Vf=Array.from,vT=Object.defineProperty,Io=Object.getOwnPropertyDescriptor,h1=Object.getOwnPropertyDescriptors,yT=Object.prototype,bT=Array.prototype,Eg=Object.getPrototypeOf,Sy=Object.isExtensible;function wl(n){return typeof n=="function"}const Dr=()=>{};function wT(n){return typeof(n==null?void 0:n.then)=="function"}function xT(n){for(var e=0;e<n.length;e++)n[e]()}function p1(){var n,e,t=new Promise((r,i)=>{n=r,e=i});return{promise:t,resolve:n,reject:e}}function Cy(n,e){if(Array.isArray(n))return n;if(!(Symbol.iterator in n))return Array.from(n);const t=[];for(const r of n)if(t.push(r),t.length===e)break;return t}const Pn=2,Ha=4,Uf=8,m1=1<<24,Qr=16,ni=32,no=64,jp=128,Lr=512,mn=1024,bn=2048,Ai=4096,Jn=8192,zr=16384,Js=32768,Wp=1<<25,Vo=65536,gu=1<<17,kT=1<<18,Zs=1<<19,_T=1<<20,bi=1<<25,Ns=65536,vu=1<<21,va=1<<22,Po=1<<23,_i=Symbol("$state"),g1=Symbol("legacy props"),ST=Symbol(""),Kd=Symbol("attributes"),Kp=Symbol("class"),qp=Symbol("style"),Al=Symbol("text"),qd=Symbol("form reset"),jf=new class extends Error{constructor(){super(...arguments);gn(this,"name","StaleReactionError");gn(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var c1;const CT=!!((c1=globalThis.document)!=null&&c1.contentType)&&globalThis.document.contentType.includes("xml");function v1(n){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function TT(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function ET(n,e,t){throw new Error("https://svelte.dev/e/each_key_duplicate")}function AT(n){throw new Error("https://svelte.dev/e/effect_in_teardown")}function MT(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function OT(n){throw new Error("https://svelte.dev/e/effect_orphan")}function DT(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function RT(n){throw new Error("https://svelte.dev/e/props_invalid_value")}function NT(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function IT(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function PT(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function LT(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const zT=1,FT=2,y1=4,BT=8,HT=16,VT=1,UT=2,jT=4,WT=8,KT=16,qT=1,JT=2,hn=Symbol(),b1="http://www.w3.org/1999/xhtml",ZT="http://www.w3.org/2000/svg",YT="http://www.w3.org/1998/Math/MathML";function GT(){console.warn("https://svelte.dev/e/derived_inert")}function XT(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function QT(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function w1(n){return n===this.v}function x1(n,e){return n!=n?e==e:n!==e||n!==null&&typeof n=="object"||typeof n=="function"}function k1(n){return!x1(n,this.v)}let cl=!1,$T=!1;function eE(){cl=!0}let qt=null;function Va(n){qt=n}function Pe(n,e=!1,t){qt={p:qt,i:!1,c:null,e:null,s:n,x:null,r:ut,l:cl&&!e?{s:null,u:null,$:[]}:null}}function Le(n){var e=qt,t=e.e;if(t!==null){e.e=null;for(var r of t)q1(r)}return n!==void 0&&(e.x=n),e.i=!0,qt=e.p,n??{}}function Ys(){return!cl||qt!==null&&qt.l===null}let ls=[];function _1(){var n=ls;ls=[],xT(n)}function Si(n){if(ls.length===0&&!ya){var e=ls;queueMicrotask(()=>{e===ls&&_1()})}ls.push(n)}function tE(){for(;ls.length>0;)_1()}function S1(n){var e=ut;if(e===null)return pt.f|=Po,n;if((e.f&Js)===0&&(e.f&Ha)===0)throw n;Mo(n,e)}function Mo(n,e){for(;e!==null;){if((e.f&jp)!==0){if((e.f&Js)===0)throw n;try{e.b.error(n);return}catch(t){n=t}}e=e.parent}throw n}const nE=-7169;function Wt(n,e){n.f=n.f&nE|e}function Ag(n){(n.f&Lr)!==0||n.deps===null?Wt(n,mn):Wt(n,Ai)}function C1(n){if(n!==null)for(const e of n)(e.f&Pn)===0||(e.f&Ns)===0||(e.f^=Ns,C1(e.deps))}function T1(n,e,t){(n.f&bn)!==0?e.add(n):(n.f&Ai)!==0&&t.add(n),C1(n.deps),Wt(n,mn)}let yd=!1;function rE(n){var e=yd;try{return yd=!1,[n(),yd]}finally{yd=e}}let Rh=null,ta=null,je=null,Fl=null,An=null,Jp=null,ya=!1,Nh=!1,ha=null,Jd=null;var Ty=0;let iE=1;var Da,Co,vs,Ra,Na,ys,Ia,qi,Kc,hr,qc,To,gi,vi,Pa,La,St,Zp,Ml,Yp,E1,A1,Zd,oE,Gp,sa;const Pf=class Pf{constructor(){Ke(this,St);gn(this,"id",iE++);Ke(this,Da,!1);gn(this,"linked",!0);Ke(this,Co,null);Ke(this,vs,null);gn(this,"async_deriveds",new Map);gn(this,"current",new Map);gn(this,"previous",new Map);gn(this,"unblocked",new Set);Ke(this,Ra,new Set);Ke(this,Na,new Set);Ke(this,ys,new Set);Ke(this,Ia,0);Ke(this,qi,new Map);Ke(this,Kc,null);Ke(this,hr,[]);Ke(this,qc,[]);Ke(this,To,new Set);Ke(this,gi,new Set);Ke(this,vi,new Map);Ke(this,Pa,new Set);gn(this,"is_fork",!1);Ke(this,La,!1)}skip_effect(e){J(this,vi).has(e)||J(this,vi).set(e,{d:[],m:[]}),J(this,Pa).delete(e)}unskip_effect(e,t=r=>this.schedule(r)){var r=J(this,vi).get(e);if(r){J(this,vi).delete(e);for(var i of r.d)Wt(i,bn),t(i);for(i of r.m)Wt(i,Ai),t(i)}J(this,Pa).add(e)}capture(e,t,r=!1){e.v!==hn&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&Po)===0&&(this.current.set(e,[t,r]),An==null||An.set(e,t)),this.is_fork||(e.v=t)}activate(){je=this}deactivate(){je=null,An=null}flush(){try{Nh=!0,je=this,mt(this,St,Ml).call(this)}finally{Ty=0,Jp=null,ha=null,Jd=null,Nh=!1,je=null,An=null,ks.clear()}}discard(){for(const e of J(this,Na))e(this);J(this,Na).clear(),J(this,ys).clear(),mt(this,St,sa).call(this)}register_created_effect(e){J(this,qc).push(e)}increment(e,t){if(Je(this,Ia,J(this,Ia)+1),e){let r=J(this,qi).get(t)??0;J(this,qi).set(t,r+1)}}decrement(e,t){if(Je(this,Ia,J(this,Ia)-1),e){let r=J(this,qi).get(t)??0;r===1?J(this,qi).delete(t):J(this,qi).set(t,r-1)}J(this,La)||(Je(this,La,!0),Si(()=>{Je(this,La,!1),this.linked&&this.flush()}))}transfer_effects(e,t){for(const r of e)J(this,To).add(r);for(const r of t)J(this,gi).add(r);e.clear(),t.clear()}oncommit(e){J(this,Ra).add(e)}ondiscard(e){J(this,Na).add(e)}on_fork_commit(e){J(this,ys).add(e)}run_fork_commit_callbacks(){for(const e of J(this,ys))e(this);J(this,ys).clear()}settled(){return(J(this,Kc)??Je(this,Kc,p1())).promise}static ensure(){var e;if(je===null){const t=je=new Pf;mt(e=t,St,Gp).call(e),!Nh&&!ya&&Si(()=>{J(t,Da)||t.flush()})}return je}apply(){{An=null;return}}schedule(e){var i;if(Jp=e,(i=e.b)!=null&&i.is_pending&&(e.f&(Ha|Uf|m1))!==0&&(e.f&Js)===0){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var r=t.f;if(ha!==null&&t===ut&&(pt===null||(pt.f&Pn)===0))return;if((r&(no|ni))!==0){if((r&mn)===0)return;t.f^=mn}}J(this,hr).push(t)}};Da=new WeakMap,Co=new WeakMap,vs=new WeakMap,Ra=new WeakMap,Na=new WeakMap,ys=new WeakMap,Ia=new WeakMap,qi=new WeakMap,Kc=new WeakMap,hr=new WeakMap,qc=new WeakMap,To=new WeakMap,gi=new WeakMap,vi=new WeakMap,Pa=new WeakMap,La=new WeakMap,St=new WeakSet,Zp=function(){if(this.is_fork)return!0;for(const r of J(this,qi).keys()){for(var e=r,t=!1;e.parent!==null;){if(J(this,vi).has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1},Ml=function(){var l,c,d,u;if(Je(this,Da,!0),Ty++>1e3&&(mt(this,St,sa).call(this),sE()),!mt(this,St,Zp).call(this)){for(const h of J(this,To))J(this,gi).delete(h),Wt(h,bn),this.schedule(h);for(const h of J(this,gi))Wt(h,Ai),this.schedule(h)}const e=J(this,hr);Je(this,hr,[]),this.apply();var t=ha=[],r=[],i=Jd=[];for(const h of e)try{mt(this,St,Yp).call(this,h,t,r)}catch(p){throw R1(h),p}if(je=null,i.length>0){var o=Pf.ensure();for(const h of i)o.schedule(h)}if(ha=null,Jd=null,mt(this,St,Zp).call(this)){mt(this,St,Zd).call(this,r),mt(this,St,Zd).call(this,t);for(const[h,p]of J(this,vi))D1(h,p);i.length>0&&mt(l=je,St,Ml).call(l);return}const s=mt(this,St,E1).call(this);if(s){mt(c=s,St,A1).call(c,this);return}J(this,To).clear(),J(this,gi).clear();for(const h of J(this,Ra))h(this);J(this,Ra).clear(),Fl=this,Ey(r),Ey(t),Fl=null,(d=J(this,Kc))==null||d.resolve();var a=je;if(this.linked&&J(this,Ia)===0&&mt(this,St,sa).call(this),J(this,hr).length>0){a===null&&(a=this,mt(this,St,Gp).call(this));const h=a;J(h,hr).push(...J(this,hr).filter(p=>!J(h,hr).includes(p)))}a!==null&&mt(u=a,St,Ml).call(u)},Yp=function(e,t,r){e.f^=mn;for(var i=e.first;i!==null;){var o=i.f,s=(o&(ni|no))!==0,a=s&&(o&mn)!==0,l=a||(o&Jn)!==0||J(this,vi).has(i);if(!l&&i.fn!==null){s?i.f^=mn:(o&Ha)!==0?t.push(i):td(i)&&((o&Qr)!==0&&J(this,gi).add(i),Ua(i));var c=i.first;if(c!==null){i=c;continue}}for(;i!==null;){var d=i.next;if(d!==null){i=d;break}i=i.parent}}},E1=function(){for(var e=J(this,Co);e!==null;){if(!e.is_fork){for(const[t,[,r]]of this.current)if(e.current.has(t)&&!r)return e}e=J(e,Co)}return null},A1=function(e){var r;for(const[i,o]of e.current)!this.previous.has(i)&&e.previous.has(i)&&this.previous.set(i,e.previous.get(i)),this.current.set(i,o);for(const[i,o]of e.async_deriveds){const s=this.async_deriveds.get(i);s&&o.promise.then(s.resolve)}const t=i=>{var o=i.reactions;if(o!==null)for(const l of o){var s=l.f;if((s&Pn)!==0)t(l);else{var a=l;s&(va|Qr)&&!this.async_deriveds.has(a)&&(J(this,gi).delete(a),Wt(a,bn),this.schedule(a))}}};for(const i of this.current.keys())t(i);this.oncommit(()=>e.discard()),mt(r=e,St,sa).call(r),je=this,mt(this,St,Ml).call(this)},Zd=function(e){for(var t=0;t<e.length;t+=1)T1(e[t],J(this,To),J(this,gi))},oE=function(){var d;mt(this,St,sa).call(this);for(let u=Rh;u!==null;u=J(u,vs)){var e=u.id<this.id,t=[];for(const[h,[p,m]]of this.current){if(u.current.has(h)){var r=u.current.get(h)[0];if(e&&p!==r)u.current.set(h,[p,m]);else continue}t.push(h)}if(e)for(const[h,p]of this.async_deriveds){const m=u.async_deriveds.get(h);m&&p.promise.then(m.resolve)}if(J(u,Da)){var i=[...u.current.keys()].filter(h=>!this.current.has(h));if(i.length===0)e&&u.discard();else if(t.length>0){if(e)for(const h of J(this,Pa))u.unskip_effect(h,p=>{var m;(p.f&(Qr|va))!==0?u.schedule(p):mt(m=u,St,Zd).call(m,[p])});u.activate();var o=new Set,s=new Map;for(var a of t)O1(a,i,o,s);s=new Map;var l=[...u.current.keys()].filter(h=>this.current.has(h)?this.current.get(h)[0]!==h.v:!0);if(l.length>0)for(const h of J(this,qc))(h.f&(zr|Jn|gu))===0&&Mg(h,l,s)&&((h.f&(va|Qr))!==0?(Wt(h,bn),u.schedule(h)):J(u,To).add(h));if(J(u,hr).length>0){u.apply();for(var c of J(u,hr))mt(d=u,St,Yp).call(d,c,[],[]);Je(u,hr,[])}u.deactivate()}}}},Gp=function(){ta===null?Rh=ta=this:(Je(ta,vs,this),Je(this,Co,ta)),ta=this},sa=function(){var e=J(this,Co),t=J(this,vs);e===null?Rh=t:Je(e,vs,t),t===null?ta=e:Je(t,Co,e),this.linked=!1};let ro=Pf;function M1(n){var e=ya;ya=!0;try{for(var t;;){if(tE(),je===null)return t;je.flush()}}finally{ya=e}}function sE(){try{DT()}catch(n){Mo(n,Jp)}}let Yr=null;function Ey(n){var e=n.length;if(e!==0){for(var t=0;t<e;){var r=n[t++];if((r.f&(zr|Jn))===0&&td(r)&&(Yr=new Set,Ua(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Y1(r),(Yr==null?void 0:Yr.size)>0)){ks.clear();for(const i of Yr){if((i.f&(zr|Jn))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)Yr.has(s)&&(Yr.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){const l=o[a];(l.f&(zr|Jn))===0&&Ua(l)}}Yr.clear()}}Yr=null}}function O1(n,e,t,r){if(!t.has(n)&&(t.add(n),n.reactions!==null))for(const i of n.reactions){const o=i.f;(o&Pn)!==0?O1(i,e,t,r):(o&(va|Qr))!==0&&(o&bn)===0&&Mg(i,e,r)&&(Wt(i,bn),Og(i))}}function Mg(n,e,t){const r=t.get(n);if(r!==void 0)return r;if(n.deps!==null)for(const i of n.deps){if(Ba.call(e,i))return!0;if((i.f&Pn)!==0&&Mg(i,e,t))return t.set(i,!0),!0}return t.set(n,!1),!1}function Og(n){je.schedule(n)}function D1(n,e){if(!((n.f&ni)!==0&&(n.f&mn)!==0)){(n.f&bn)!==0?e.d.push(n):(n.f&Ai)!==0&&e.m.push(n),Wt(n,mn);for(var t=n.first;t!==null;)D1(t,e),t=t.next}}function R1(n){Wt(n,mn);for(var e=n.first;e!==null;)R1(e),e=e.next}function aE(n){let e=0,t=io(0),r;return()=>{Ng()&&(f(t),ed(()=>(e===0&&(r=Dt(()=>n(()=>Bl(t)))),e+=1,()=>{Si(()=>{e-=1,e===0&&(r==null||r(),r=void 0,Bl(t))})})))}}var lE=Vo|Zs;function N1(n,e,t,r){new cE(n,e,t,r)}var Tr,Cg,Er,bs,tr,Ar,qn,pr,Ji,ws,Eo,za,Jc,Zc,Zi,Lf,Jt,dE,uE,fE,Xp,Yd,Gd,Qp,$p;class cE{constructor(e,t,r,i){Ke(this,Jt);gn(this,"parent");gn(this,"is_pending",!1);gn(this,"transform_error");Ke(this,Tr);Ke(this,Cg,null);Ke(this,Er);Ke(this,bs);Ke(this,tr);Ke(this,Ar,null);Ke(this,qn,null);Ke(this,pr,null);Ke(this,Ji,null);Ke(this,ws,0);Ke(this,Eo,0);Ke(this,za,!1);Ke(this,Jc,new Set);Ke(this,Zc,new Set);Ke(this,Zi,null);Ke(this,Lf,aE(()=>(Je(this,Zi,io(J(this,ws))),()=>{Je(this,Zi,null)})));var o;Je(this,Tr,e),Je(this,Er,t),Je(this,bs,s=>{var a=ut;a.b=this,a.f|=jp,r(s)}),this.parent=ut.b,this.transform_error=i??((o=this.parent)==null?void 0:o.transform_error)??(s=>s),Je(this,tr,Gs(()=>{mt(this,Jt,Xp).call(this)},lE))}defer_effect(e){T1(e,J(this,Jc),J(this,Zc))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!J(this,Er).pending}update_pending_count(e,t){mt(this,Jt,Qp).call(this,e,t),Je(this,ws,J(this,ws)+e),!(!J(this,Zi)||J(this,za))&&(Je(this,za,!0),Si(()=>{Je(this,za,!1),J(this,Zi)&&Gi(J(this,Zi),J(this,ws))}))}get_effect_pending(){return J(this,Lf).call(this),f(J(this,Zi))}error(e){if(!J(this,Er).onerror&&!J(this,Er).failed)throw e;je!=null&&je.is_fork?(J(this,Ar)&&je.skip_effect(J(this,Ar)),J(this,qn)&&je.skip_effect(J(this,qn)),J(this,pr)&&je.skip_effect(J(this,pr)),je.on_fork_commit(()=>{mt(this,Jt,$p).call(this,e)})):mt(this,Jt,$p).call(this,e)}}Tr=new WeakMap,Cg=new WeakMap,Er=new WeakMap,bs=new WeakMap,tr=new WeakMap,Ar=new WeakMap,qn=new WeakMap,pr=new WeakMap,Ji=new WeakMap,ws=new WeakMap,Eo=new WeakMap,za=new WeakMap,Jc=new WeakMap,Zc=new WeakMap,Zi=new WeakMap,Lf=new WeakMap,Jt=new WeakSet,dE=function(){try{Je(this,Ar,Mr(()=>J(this,bs).call(this,J(this,Tr))))}catch(e){this.error(e)}},uE=function(e){const t=J(this,Er).failed;t&&Je(this,pr,Mr(()=>{t(J(this,Tr),()=>e,()=>()=>{})}))},fE=function(){const e=J(this,Er).pending;e&&(this.is_pending=!0,Je(this,qn,Mr(()=>e(J(this,Tr)))),Si(()=>{var t=Je(this,Ji,document.createDocumentFragment()),r=Xi();t.append(r),Je(this,Ar,mt(this,Jt,Gd).call(this,()=>Mr(()=>J(this,bs).call(this,r)))),J(this,Eo)===0&&(J(this,Tr).before(t),Je(this,Ji,null),_s(J(this,qn),()=>{Je(this,qn,null)}),mt(this,Jt,Yd).call(this,je))}))},Xp=function(){try{if(this.is_pending=this.has_pending_snippet(),Je(this,Eo,0),Je(this,ws,0),Je(this,Ar,Mr(()=>{J(this,bs).call(this,J(this,Tr))})),J(this,Eo)>0){var e=Je(this,Ji,document.createDocumentFragment());Fg(J(this,Ar),e);const t=J(this,Er).pending;Je(this,qn,Mr(()=>t(J(this,Tr))))}else mt(this,Jt,Yd).call(this,je)}catch(t){this.error(t)}},Yd=function(e){this.is_pending=!1,e.transfer_effects(J(this,Jc),J(this,Zc))},Gd=function(e){var t=ut,r=pt,i=qt;Mi(J(this,tr)),jr(J(this,tr)),Va(J(this,tr).ctx);try{return ro.ensure(),e()}catch(o){return S1(o),null}finally{Mi(t),jr(r),Va(i)}},Qp=function(e,t){var r;if(!this.has_pending_snippet()){this.parent&&mt(r=this.parent,Jt,Qp).call(r,e,t);return}Je(this,Eo,J(this,Eo)+e),J(this,Eo)===0&&(mt(this,Jt,Yd).call(this,t),J(this,qn)&&_s(J(this,qn),()=>{Je(this,qn,null)}),J(this,Ji)&&(J(this,Tr).before(J(this,Ji)),Je(this,Ji,null)))},$p=function(e){J(this,Ar)&&(Zn(J(this,Ar)),Je(this,Ar,null)),J(this,qn)&&(Zn(J(this,qn)),Je(this,qn,null)),J(this,pr)&&(Zn(J(this,pr)),Je(this,pr,null));var t=J(this,Er).onerror;let r=J(this,Er).failed;var i=!1,o=!1;const s=()=>{if(i){QT();return}i=!0,o&<(),J(this,pr)!==null&&_s(J(this,pr),()=>{Je(this,pr,null)}),mt(this,Jt,Gd).call(this,()=>{mt(this,Jt,Xp).call(this)})},a=l=>{try{o=!0,t==null||t(l,s),o=!1}catch(c){Mo(c,J(this,tr)&&J(this,tr).parent)}r&&Je(this,pr,mt(this,Jt,Gd).call(this,()=>{try{return Mr(()=>{var c=ut;c.b=this,c.f|=jp,r(J(this,Tr),()=>l,()=>s)})}catch(c){return Mo(c,J(this,tr).parent),null}}))};Si(()=>{var l;try{l=this.transform_error(e)}catch(c){Mo(c,J(this,tr)&&J(this,tr).parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(a,c=>Mo(c,J(this,tr)&&J(this,tr).parent)):a(l)})};function hE(n,e,t,r){const i=Ys()?sc:Dg;var o=n.filter(h=>!h.settled);if(t.length===0&&o.length===0){r(e.map(i));return}var s=ut,a=I1(),l=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(h=>h.promise)):null;function c(h){if((s.f&zr)===0){a();try{r(h)}catch(p){Mo(p,s)}oc()}}var d=P1();if(t.length===0){l.then(()=>c(e.map(i))).finally(d);return}function u(){Promise.all(t.map(h=>pE(h))).then(h=>c([...e.map(i),...h])).catch(h=>Mo(h,s)).finally(d)}l?l.then(()=>{a(),u(),oc()}):u()}function I1(){var n=ut,e=pt,t=qt,r=je;return function(o=!0){Mi(n),jr(e),Va(t),o&&(n.f&zr)===0&&(r==null||r.activate(),r==null||r.apply())}}function oc(n=!0){Mi(null),jr(null),Va(null),n&&(je==null||je.deactivate())}function P1(){var n=ut,e=n.b,t=je,r=e.is_rendered();return e.update_pending_count(1,t),t.increment(r,n),()=>{e.update_pending_count(-1,t),t.decrement(r,n)}}function sc(n){var e=Pn|bn;return ut!==null&&(ut.f|=Zs),{ctx:qt,deps:null,effects:null,equals:w1,f:e,fn:n,reactions:null,rv:0,v:hn,wv:0,parent:ut,ac:null}}const bd=Symbol("obsolete");function pE(n,e,t){let r=ut;r===null&&TT();var i=void 0,o=io(hn),s=!pt,a=new Set;return EE(()=>{var p;var l=ut,c=p1();i=c.promise;try{Promise.resolve(n()).then(c.resolve,m=>{m!==jf&&c.reject(m)}).finally(oc)}catch(m){c.reject(m),oc()}var d=je;if(s){if((l.f&Js)!==0)var u=P1();if(r.b.is_rendered())(p=d.async_deriveds.get(l))==null||p.reject(bd);else for(const m of a.values())m.reject(bd);a.add(c),d.async_deriveds.set(l,c)}const h=(m,v=void 0)=>{u==null||u(),a.delete(c),v!==bd&&(d.activate(),v?(o.f|=Po,Gi(o,v)):((o.f&Po)!==0&&(o.f^=Po),Gi(o,m)),d.deactivate())};c.promise.then(h,m=>h(null,m||"unknown"))}),Ig(()=>{for(const l of a)l.reject(bd)}),new Promise(l=>{function c(d){function u(){d===i?l(o):c(i)}d.then(u,u)}c(i)})}function F(n){const e=sc(n);return Q1(e),e}function Dg(n){const e=sc(n);return e.equals=k1,e}function mE(n){var e=n.effects;if(e!==null){n.effects=null;for(var t=0;t<e.length;t+=1)Zn(e[t])}}function Rg(n){var e,t=ut,r=n.parent;if(!oo&&r!==null&&(r.f&(zr|Jn))!==0)return GT(),n.v;Mi(r);try{n.f&=~Ns,mE(n),e=nx(n)}finally{Mi(t)}return e}function L1(n){var e=Rg(n);if(!n.equals(e)&&(n.wv=ex(),(!(je!=null&&je.is_fork)||n.deps===null)&&(je!==null?(je.capture(n,e,!0),Fl==null||Fl.capture(n,e,!0)):n.v=e,n.deps===null))){Wt(n,mn);return}oo||(An!==null?(Ng()||je!=null&&je.is_fork)&&An.set(n,e):Ag(n))}function gE(n){var e,t;if(n.effects!==null)for(const r of n.effects)(r.teardown||r.ac)&&((e=r.teardown)==null||e.call(r),(t=r.ac)==null||t.abort(jf),r.teardown=Dr,r.ac=null,ac(r,0),Lg(r))}function z1(n){if(n.effects!==null)for(const e of n.effects)e.teardown&&Ua(e)}let yu=new Set;const ks=new Map;let F1=!1;function io(n,e){var t={f:0,v:n,reactions:null,equals:w1,rv:0,wv:0};return t}function B(n,e){const t=io(n);return Q1(t),t}function em(n,e=!1,t=!0){var i;const r=io(n);return e||(r.equals=k1),cl&&t&&qt!==null&&qt.l!==null&&((i=qt.l).s??(i.s=[])).push(r),r}function b(n,e,t=!1){pt!==null&&(!$r||(pt.f&gu)!==0)&&Ys()&&(pt.f&(Pn|Qr|va|gu))!==0&&(Fr===null||!Ba.call(Fr,n))&&PT();let r=t?at(e):e;return Gi(n,r,Jd)}function Gi(n,e,t=null){if(!n.equals(e)){ks.set(n,oo?e:n.v);var r=ro.ensure();if(r.capture(n,e),(n.f&Pn)!==0){const i=n;(n.f&bn)!==0&&Rg(i),An===null&&Ag(i)}n.wv=ex(),B1(n,bn,t),Ys()&&ut!==null&&(ut.f&mn)!==0&&(ut.f&(ni|no))===0&&(Cr===null?ME([n]):Cr.push(n)),!r.is_fork&&yu.size>0&&!F1&&vE()}return e}function vE(){F1=!1;for(const n of yu){(n.f&mn)!==0&&Wt(n,Ai);let e;try{e=td(n)}catch{e=!0}e&&Ua(n)}yu.clear()}function bu(n,e=1){var t=f(n),r=e===1?t++:t--;return b(n,t),r}function Bl(n){b(n,n.v+1)}function B1(n,e,t){var r=n.reactions;if(r!==null)for(var i=Ys(),o=r.length,s=0;s<o;s++){var a=r[s],l=a.f;if(!(!i&&a===ut)){var c=(l&bn)===0;if(c&&Wt(a,e),(l&gu)!==0)yu.add(a);else if((l&Pn)!==0){var d=a;An==null||An.delete(d),(l&Ns)===0&&(l&Lr&&(ut===null||(ut.f&vu)===0)&&(a.f|=Ns),B1(d,Ai,t))}else if(c){var u=a;(l&Qr)!==0&&Yr!==null&&Yr.add(u),t!==null?t.push(u):Og(u)}}}}function at(n){if(typeof n!="object"||n===null||_i in n)return n;const e=Eg(n);if(e!==yT&&e!==bT)return n;var t=new Map,r=Tg(n),i=B(0),o=Ss,s=a=>{if(Ss===o)return a();var l=pt,c=Ss;jr(null),Ry(o);var d=a();return jr(l),Ry(c),d};return r&&t.set("length",B(n.length)),new Proxy(n,{defineProperty(a,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&NT();var d=t.get(l);return d===void 0?s(()=>{var u=B(c.value);return t.set(l,u),u}):b(d,c.value,!0),!0},deleteProperty(a,l){var c=t.get(l);if(c===void 0){if(l in a){const d=s(()=>B(hn));t.set(l,d),Bl(i)}}else b(c,hn),Bl(i);return!0},get(a,l,c){var p;if(l===_i)return n;var d=t.get(l),u=l in a;if(d===void 0&&(!u||(p=Io(a,l))!=null&&p.writable)&&(d=s(()=>{var m=at(u?a[l]:hn),v=B(m);return v}),t.set(l,d)),d!==void 0){var h=f(d);return h===hn?void 0:h}return Reflect.get(a,l,c)},getOwnPropertyDescriptor(a,l){var c=Reflect.getOwnPropertyDescriptor(a,l);if(c&&"value"in c){var d=t.get(l);d&&(c.value=f(d))}else if(c===void 0){var u=t.get(l),h=u==null?void 0:u.v;if(u!==void 0&&h!==hn)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(a,l){var h;if(l===_i)return!0;var c=t.get(l),d=c!==void 0&&c.v!==hn||Reflect.has(a,l);if(c!==void 0||ut!==null&&(!d||(h=Io(a,l))!=null&&h.writable)){c===void 0&&(c=s(()=>{var p=d?at(a[l]):hn,m=B(p);return m}),t.set(l,c));var u=f(c);if(u===hn)return!1}return d},set(a,l,c,d){var _;var u=t.get(l),h=l in a;if(r&&l==="length")for(var p=c;p<u.v;p+=1){var m=t.get(p+"");m!==void 0?b(m,hn):p in a&&(m=s(()=>B(hn)),t.set(p+"",m))}if(u===void 0)(!h||(_=Io(a,l))!=null&&_.writable)&&(u=s(()=>B(void 0)),b(u,at(c)),t.set(l,u));else{h=u.v!==hn;var v=s(()=>at(c));b(u,v)}var g=Reflect.getOwnPropertyDescriptor(a,l);if(g!=null&&g.set&&g.set.call(d,c),!h){if(r&&typeof l=="string"){var y=t.get("length"),w=Number(l);Number.isInteger(w)&&w>=y.v&&b(y,w+1)}Bl(i)}return!0},ownKeys(a){f(i);var l=Reflect.ownKeys(a).filter(u=>{var h=t.get(u);return h===void 0||h.v!==hn});for(var[c,d]of t)d.v!==hn&&!(c in a)&&l.push(c);return l},setPrototypeOf(){IT()}})}function Ay(n){try{if(n!==null&&typeof n=="object"&&_i in n)return n[_i]}catch{}return n}function yE(n,e){return Object.is(Ay(n),Ay(e))}var My,H1,V1,U1;function bE(){if(My===void 0){My=window,H1=/Firefox/.test(navigator.userAgent);var n=Element.prototype,e=Node.prototype,t=Text.prototype;V1=Io(e,"firstChild").get,U1=Io(e,"nextSibling").get,Sy(n)&&(n[Kp]=void 0,n[Kd]=null,n[qp]=void 0,n.__e=void 0),Sy(t)&&(t[Al]=void 0)}}function Xi(n=""){return document.createTextNode(n)}function wi(n){return V1.call(n)}function $c(n){return U1.call(n)}function x(n,e){return wi(n)}function ye(n,e=!1){{var t=wi(n);return t instanceof Comment&&t.data===""?$c(t):t}}function k(n,e=1,t=!1){let r=n;for(;e--;)r=$c(r);return r}function wE(n){n.textContent=""}function j1(){return!1}function W1(n,e,t){return document.createElementNS(e??b1,n,void 0)}function xE(n,e){{const t=document.body;n.autofocus=!0,Si(()=>{document.activeElement===t&&n.focus()})}}let Oy=!1;function kE(){Oy||(Oy=!0,document.addEventListener("reset",n=>{Promise.resolve().then(()=>{var e;if(!n.defaultPrevented)for(const t of n.target.elements)(e=t[qd])==null||e.call(t)})},{capture:!0}))}function Wf(n){var e=pt,t=ut;jr(null),Mi(null);try{return n()}finally{jr(e),Mi(t)}}function K1(n,e,t,r=t){n.addEventListener(e,()=>Wf(t));const i=n[qd];i?n[qd]=()=>{i(),r(!0)}:n[qd]=()=>r(!0),kE()}function _E(n){ut===null&&(pt===null&&OT(),MT()),oo&&AT()}function SE(n,e){var t=e.last;t===null?e.last=e.first=n:(t.next=n,n.prev=t,e.last=n)}function Pi(n,e){var t=ut;t!==null&&(t.f&Jn)!==0&&(n|=Jn);var r={ctx:qt,deps:null,nodes:null,f:n|bn|Lr,first:null,fn:e,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};je==null||je.register_created_effect(r);var i=r;if((n&Ha)!==0)ha!==null?ha.push(r):ro.ensure().schedule(r);else if(e!==null){try{Ua(r)}catch(s){throw Zn(r),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&Zs)===0&&(i=i.first,(n&Qr)!==0&&(n&Vo)!==0&&i!==null&&(i.f|=Vo))}if(i!==null&&(i.parent=t,t!==null&&SE(i,t),pt!==null&&(pt.f&Pn)!==0&&(n&no)===0)){var o=pt;(o.effects??(o.effects=[])).push(i)}return r}function Ng(){return pt!==null&&!$r}function Ig(n){const e=Pi(Uf,null);return Wt(e,mn),e.teardown=n,e}function le(n){_E();var e=ut.f,t=!pt&&(e&ni)!==0&&(e&Js)===0;if(t){var r=qt;(r.e??(r.e=[])).push(n)}else return q1(n)}function q1(n){return Pi(Ha|_T,n)}function CE(n){ro.ensure();const e=Pi(no|Zs,n);return()=>{Zn(e)}}function TE(n){ro.ensure();const e=Pi(no|Zs,n);return(t={})=>new Promise(r=>{t.outro?_s(e,()=>{Zn(e),r(void 0)}):(Zn(e),r(void 0))})}function Pg(n){return Pi(Ha,n)}function EE(n){return Pi(va|Zs,n)}function ed(n,e=0){return Pi(Uf|e,n)}function K(n,e=[],t=[],r=[]){hE(r,e,t,i=>{Pi(Uf,()=>n(...i.map(f)))})}function Gs(n,e=0){var t=Pi(Qr|e,n);return t}function Mr(n){return Pi(ni|Zs,n)}function J1(n){var e=n.teardown;if(e!==null){const t=oo,r=pt;Dy(!0),jr(null);try{e.call(null)}finally{Dy(t),jr(r)}}}function Lg(n,e=!1){var t=n.first;for(n.first=n.last=null;t!==null;){const i=t.ac;i!==null&&Wf(()=>{i.abort(jf)});var r=t.next;(t.f&no)!==0?t.parent=null:Zn(t,e),t=r}}function AE(n){for(var e=n.first;e!==null;){var t=e.next;(e.f&ni)===0&&Zn(e),e=t}}function Zn(n,e=!0){var t=!1;(e||(n.f&kT)!==0)&&n.nodes!==null&&n.nodes.end!==null&&(Z1(n.nodes.start,n.nodes.end),t=!0),Wt(n,Wp),Lg(n,e&&!t),ac(n,0);var r=n.nodes&&n.nodes.t;if(r!==null)for(const o of r)o.stop();J1(n),n.f^=Wp,n.f|=zr;var i=n.parent;i!==null&&i.first!==null&&Y1(n),n.next=n.prev=n.teardown=n.ctx=n.deps=n.fn=n.nodes=n.ac=n.b=null}function Z1(n,e){for(;n!==null;){var t=n===e?null:$c(n);n.remove(),n=t}}function Y1(n){var e=n.parent,t=n.prev,r=n.next;t!==null&&(t.next=r),r!==null&&(r.prev=t),e!==null&&(e.first===n&&(e.first=r),e.last===n&&(e.last=t))}function _s(n,e,t=!0){var r=[];G1(n,r,!0);var i=()=>{t&&Zn(n),e&&e()},o=r.length;if(o>0){var s=()=>--o||i();for(var a of r)a.out(s)}else i()}function G1(n,e,t){if((n.f&Jn)===0){n.f^=Jn;var r=n.nodes&&n.nodes.t;if(r!==null)for(const a of r)(a.is_global||t)&&e.push(a);for(var i=n.first;i!==null;){var o=i.next;if((i.f&no)===0){var s=(i.f&Vo)!==0||(i.f&ni)!==0&&(n.f&Qr)!==0;G1(i,e,s?t:!1)}i=o}}}function zg(n){X1(n,!0)}function X1(n,e){if((n.f&Jn)!==0){n.f^=Jn,(n.f&mn)===0&&(Wt(n,bn),ro.ensure().schedule(n));for(var t=n.first;t!==null;){var r=t.next,i=(t.f&Vo)!==0||(t.f&ni)!==0;X1(t,i?e:!1),t=r}var o=n.nodes&&n.nodes.t;if(o!==null)for(const s of o)(s.is_global||e)&&s.in()}}function Fg(n,e){if(n.nodes)for(var t=n.nodes.start,r=n.nodes.end;t!==null;){var i=t===r?null:$c(t);e.append(t),t=i}}let Xd=!1,oo=!1;function Dy(n){oo=n}let pt=null,$r=!1;function jr(n){pt=n}let ut=null;function Mi(n){ut=n}let Fr=null;function Q1(n){pt!==null&&(Fr===null?Fr=[n]:Fr.push(n))}let nr=null,dr=0,Cr=null;function ME(n){Cr=n}let $1=1,cs=0,Ss=cs;function Ry(n){Ss=n}function ex(){return++$1}function td(n){var e=n.f;if((e&bn)!==0)return!0;if(e&Pn&&(n.f&=~Ns),(e&Ai)!==0){for(var t=n.deps,r=t.length,i=0;i<r;i++){var o=t[i];if(td(o)&&L1(o),o.wv>n.wv)return!0}(e&Lr)!==0&&An===null&&Wt(n,mn)}return!1}function tx(n,e,t=!0){var r=n.reactions;if(r!==null&&!(Fr!==null&&Ba.call(Fr,n)))for(var i=0;i<r.length;i++){var o=r[i];(o.f&Pn)!==0?tx(o,e,!1):e===o&&(t?Wt(o,bn):(o.f&mn)!==0&&Wt(o,Ai),Og(o))}}function nx(n){var v;var e=nr,t=dr,r=Cr,i=pt,o=Fr,s=qt,a=$r,l=Ss,c=n.f;nr=null,dr=0,Cr=null,pt=(c&(ni|no))===0?n:null,Fr=null,Va(n.ctx),$r=!1,Ss=++cs,n.ac!==null&&(Wf(()=>{n.ac.abort(jf)}),n.ac=null);try{n.f|=vu;var d=n.fn,u=d();n.f|=Js;var h=n.deps,p=je==null?void 0:je.is_fork;if(nr!==null){var m;if(p||ac(n,dr),h!==null&&dr>0)for(h.length=dr+nr.length,m=0;m<nr.length;m++)h[dr+m]=nr[m];else n.deps=h=nr;if(Ng()&&(n.f&Lr)!==0)for(m=dr;m<h.length;m++)((v=h[m]).reactions??(v.reactions=[])).push(n)}else!p&&h!==null&&dr<h.length&&(ac(n,dr),h.length=dr);if(Ys()&&Cr!==null&&!$r&&h!==null&&(n.f&(Pn|Ai|bn))===0)for(m=0;m<Cr.length;m++)tx(Cr[m],n);if(i!==null&&i!==n){if(cs++,i.deps!==null)for(let g=0;g<t;g+=1)i.deps[g].rv=cs;if(e!==null)for(const g of e)g.rv=cs;Cr!==null&&(r===null?r=Cr:r.push(...Cr))}return(n.f&Po)!==0&&(n.f^=Po),u}catch(g){return S1(g)}finally{n.f^=vu,nr=e,dr=t,Cr=r,pt=i,Fr=o,Va(s),$r=a,Ss=l}}function OE(n,e){let t=e.reactions;if(t!==null){var r=gT.call(t,n);if(r!==-1){var i=t.length-1;i===0?t=e.reactions=null:(t[r]=t[i],t.pop())}}if(t===null&&(e.f&Pn)!==0&&(nr===null||!Ba.call(nr,e))){var o=e;(o.f&Lr)!==0&&(o.f^=Lr,o.f&=~Ns),o.v!==hn&&Ag(o),gE(o),ac(o,0)}}function ac(n,e){var t=n.deps;if(t!==null)for(var r=e;r<t.length;r++)OE(n,t[r])}function Ua(n){var e=n.f;if((e&zr)===0){Wt(n,mn);var t=ut,r=Xd;ut=n,Xd=!0;try{(e&(Qr|m1))!==0?AE(n):Lg(n),J1(n);var i=nx(n);n.teardown=typeof i=="function"?i:null,n.wv=$1;var o;f1&&$T&&(n.f&bn)!==0&&n.deps}finally{Xd=r,ut=t}}}async function DE(){await Promise.resolve(),M1()}function f(n){var e=n.f,t=(e&Pn)!==0;if(pt!==null&&!$r){var r=ut!==null&&(ut.f&zr)!==0;if(!r&&(Fr===null||!Ba.call(Fr,n))){var i=pt.deps;if((pt.f&vu)!==0)n.rv<cs&&(n.rv=cs,nr===null&&i!==null&&i[dr]===n?dr++:nr===null?nr=[n]:nr.push(n));else{(pt.deps??(pt.deps=[])).push(n);var o=n.reactions;o===null?n.reactions=[pt]:Ba.call(o,pt)||o.push(pt)}}}if(oo&&ks.has(n))return ks.get(n);if(t){var s=n;if(oo){var a=s.v;return((s.f&mn)===0&&s.reactions!==null||ix(s))&&(a=Rg(s)),ks.set(s,a),a}var l=(s.f&Lr)===0&&!$r&&pt!==null&&(Xd||(pt.f&Lr)!==0),c=(s.f&Js)===0;td(s)&&(l&&(s.f|=Lr),L1(s)),l&&!c&&(z1(s),rx(s))}if(An!=null&&An.has(n))return An.get(n);if((n.f&Po)!==0)throw n.v;return n.v}function rx(n){if(n.f|=Lr,n.deps!==null)for(const e of n.deps)(e.reactions??(e.reactions=[])).push(n),(e.f&Pn)!==0&&(e.f&Lr)===0&&(z1(e),rx(e))}function ix(n){if(n.v===hn)return!0;if(n.deps===null)return!1;for(const e of n.deps)if(ks.has(e)||(e.f&Pn)!==0&&ix(e))return!0;return!1}function Dt(n){var e=$r;try{return $r=!0,n()}finally{$r=e}}function RE(n){if(!(typeof n!="object"||!n||n instanceof EventTarget)){if(_i in n)tm(n);else if(!Array.isArray(n))for(let e in n){const t=n[e];typeof t=="object"&&t&&_i in t&&tm(t)}}}function tm(n,e=new Set){if(typeof n=="object"&&n!==null&&!(n instanceof EventTarget)&&!e.has(n)){e.add(n),n instanceof Date&&n.getTime();for(let r in n)try{tm(n[r],e)}catch{}const t=Eg(n);if(t!==Object.prototype&&t!==Array.prototype&&t!==Map.prototype&&t!==Set.prototype&&t!==Date.prototype){const r=h1(t);for(let i in r){const o=r[i].get;if(o)try{o.call(n)}catch{}}}}}const NE=["touchstart","touchmove"];function IE(n){return NE.includes(n)}const ds=Symbol("events"),ox=new Set,nm=new Set;function PE(n,e,t,r={}){function i(o){if(r.capture||rm.call(e,o),!o.cancelBubble)return Wf(()=>t==null?void 0:t.call(this,o))}return n.startsWith("pointer")||n.startsWith("touch")||n==="wheel"?Si(()=>{e.addEventListener(n,i,r)}):e.addEventListener(n,i,r),i}function Et(n,e,t,r,i){var o={capture:r,passive:i},s=PE(n,e,t,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Ig(()=>{e.removeEventListener(n,s,o)})}function L(n,e,t){(e[ds]??(e[ds]={}))[n]=t}function qe(n){for(var e=0;e<n.length;e++)ox.add(n[e]);for(var t of nm)t(n)}let Ny=null;function rm(n){var g,y;var e=this,t=e.ownerDocument,r=n.type,i=((g=n.composedPath)==null?void 0:g.call(n))||[],o=i[0]||n.target;Ny=n;var s=0,a=Ny===n&&n[ds];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){n[ds]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||n.target,o!==e){vT(n,"currentTarget",{configurable:!0,get(){return o||t}});var d=pt,u=ut;jr(null),Mi(null);try{for(var h,p=[];o!==null;){var m=o.assignedSlot||o.parentNode||o.host||null;try{var v=(y=o[ds])==null?void 0:y[r];v!=null&&(!o.disabled||n.target===o)&&v.call(o,n)}catch(w){h?p.push(w):h=w}if(n.cancelBubble||m===e||m===null)break;o=m}if(h){for(let w of p)queueMicrotask(()=>{throw w});throw h}}finally{n[ds]=e,delete n.currentTarget,jr(d),Mi(u)}}}var d1;const Ih=((d1=globalThis==null?void 0:globalThis.window)==null?void 0:d1.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:n=>n});function LE(n){return(Ih==null?void 0:Ih.createHTML(n))??n}function sx(n){var e=W1("template");return e.innerHTML=LE(n.replaceAll("<!>","<!---->")),e.content}function Is(n,e){var t=ut;t.nodes===null&&(t.nodes={start:n,end:e,a:null,t:null})}function E(n,e){var t=(e&qT)!==0,r=(e&JT)!==0,i,o=!n.startsWith("<!>");return()=>{i===void 0&&(i=sx(o?n:"<!>"+n),t||(i=wi(i)));var s=r||H1?document.importNode(i,!0):i.cloneNode(!0);if(t){var a=wi(s),l=s.lastChild;Is(a,l)}else Is(s,s);return s}}function zE(n,e,t="svg"){var r=!n.startsWith("<!>"),i=`<${t}>${r?n:"<!>"+n}</${t}>`,o;return()=>{if(!o){var s=sx(i),a=wi(s);o=wi(a)}var l=o.cloneNode(!0);return Is(l,l),l}}function Kr(n,e){return zE(n,e,"svg")}function nn(n=""){{var e=Xi(n+"");return Is(e,e),e}}function xt(){var n=document.createDocumentFragment(),e=document.createComment(""),t=Xi();return n.append(e,t),Is(e,t),n}function S(n,e){n!==null&&n.before(e)}function $(n,e){var t=e==null?"":typeof e=="object"?`${e}`:e;t!==(n[Al]??(n[Al]=n.nodeValue))&&(n[Al]=t,n.nodeValue=`${t}`)}function FE(n,e){return BE(n,e)}const wd=new Map;function BE(n,{target:e,anchor:t,props:r={},events:i,context:o,intro:s=!0,transformError:a}){bE();var l=void 0,c=TE(()=>{var d=t??e.appendChild(Xi());N1(d,{pending:()=>{}},p=>{Pe({});var m=qt;o&&(m.c=o),i&&(r.$$events=i),l=n(p,r)||{},Le()},a);var u=new Set,h=p=>{for(var m=0;m<p.length;m++){var v=p[m];if(!u.has(v)){u.add(v);var g=IE(v);for(const _ of[e,document]){var y=wd.get(_);y===void 0&&(y=new Map,wd.set(_,y));var w=y.get(v);w===void 0?(_.addEventListener(v,rm,{passive:g}),y.set(v,1)):y.set(v,w+1)}}}};return h(Vf(ox)),nm.add(h),()=>{var g;for(var p of u)for(const y of[e,document]){var m=wd.get(y),v=m.get(p);--v==0?(y.removeEventListener(p,rm),m.delete(p),m.size===0&&wd.delete(y)):m.set(p,v)}nm.delete(h),d!==t&&((g=d.parentNode)==null||g.removeChild(d))}});return HE.set(l,c),l}let HE=new WeakMap;var Gr,yi,mr,xs,Yc,Gc,zf;class nd{constructor(e,t=!0){gn(this,"anchor");Ke(this,Gr,new Map);Ke(this,yi,new Map);Ke(this,mr,new Map);Ke(this,xs,new Set);Ke(this,Yc,!0);Ke(this,Gc,e=>{if(J(this,Gr).has(e)){var t=J(this,Gr).get(e),r=J(this,yi).get(t);if(r)zg(r),J(this,xs).delete(t);else{var i=J(this,mr).get(t);i&&(J(this,yi).set(t,i.effect),J(this,mr).delete(t),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[o,s]of J(this,Gr)){if(J(this,Gr).delete(o),o===e)break;const a=J(this,mr).get(s);a&&(Zn(a.effect),J(this,mr).delete(s))}for(const[o,s]of J(this,yi)){if(o===t||J(this,xs).has(o))continue;const a=()=>{if(Array.from(J(this,Gr).values()).includes(o)){var c=document.createDocumentFragment();Fg(s,c),c.append(Xi()),J(this,mr).set(o,{effect:s,fragment:c})}else Zn(s);J(this,xs).delete(o),J(this,yi).delete(o)};J(this,Yc)||!r?(J(this,xs).add(o),_s(s,a,!1)):a()}}});Ke(this,zf,e=>{J(this,Gr).delete(e);const t=Array.from(J(this,Gr).values());for(const[r,i]of J(this,mr))t.includes(r)||(Zn(i.effect),J(this,mr).delete(r))});this.anchor=e,Je(this,Yc,t)}ensure(e,t){var r=je,i=j1();if(t&&!J(this,yi).has(e)&&!J(this,mr).has(e))if(i){var o=document.createDocumentFragment(),s=Xi();o.append(s),J(this,mr).set(e,{effect:Mr(()=>t(s)),fragment:o})}else J(this,yi).set(e,Mr(()=>t(this.anchor)));if(J(this,Gr).set(r,e),i){for(const[a,l]of J(this,yi))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of J(this,mr))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(J(this,Gc)),r.ondiscard(J(this,zf))}else J(this,Gc).call(this,r)}}Gr=new WeakMap,yi=new WeakMap,mr=new WeakMap,xs=new WeakMap,Yc=new WeakMap,Gc=new WeakMap,zf=new WeakMap;const VE=0,Iy=1,UE=2;function ax(n,e,t,r,i){var o=Ys(),s=hn,a=o?io(s):em(s,!1,!1),l=o?io(s):em(s,!1,!1),c=new nd(n);Gs(()=>{var d=je;d.deactivate();var u=e();d.activate();var h=!1;if(wT(u)){var p=I1(),m=!1;const v=g=>{if(!h){m=!0,p(!1),ro.ensure();try{g()}finally{oc(!1),ya||M1()}}};u.then(g=>{v(()=>{Gi(a,g),c.ensure(Iy,r&&(y=>r(y,a)))})},g=>{v(()=>{if(Gi(l,g),c.ensure(UE,i&&(y=>i(y,l))),!i)throw l.v})}),Si(()=>{m||v(()=>{c.ensure(VE,t)})})}else Gi(a,u),c.ensure(Iy,r&&(v=>r(v,a)));return()=>{h=!0}})}function Z(n,e,t=!1){var r=new nd(n),i=t?Vo:0;function o(s,a){r.ensure(s,a)}Gs(()=>{var s=!1;e((a,l=0)=>{s=!0,o(l,a)}),s||o(-1,null)},i)}const jE=Symbol("NaN");function wu(n,e,t){var r=new nd(n),i=!Ys();Gs(()=>{var o=e();o!==o&&(o=jE),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,t)})}function ja(n,e){return e}function WE(n,e,t){for(var r=[],i=e.length,o,s=e.length,a=0;a<i;a++){let u=e[a];_s(u,()=>{if(o){if(o.pending.delete(u),o.done.add(u),o.pending.size===0){var h=n.outrogroups;im(n,Vf(o.done)),h.delete(o),h.size===0&&(n.outrogroups=null)}}else s-=1},!1)}if(s===0){var l=r.length===0&&t!==null;if(l){var c=t,d=c.parentNode;wE(d),d.append(c),n.items.clear()}im(n,e,!l)}else o={pending:new Set(e),done:new Set},(n.outrogroups??(n.outrogroups=new Set)).add(o)}function im(n,e,t=!0){var r;if(n.pending.size>0){r=new Set;for(const s of n.pending.values())for(const a of s)r.add(n.items.get(a).e)}for(var i=0;i<e.length;i++){var o=e[i];if(r!=null&&r.has(o)){o.f|=bi;const s=document.createDocumentFragment();Fg(o,s)}else Zn(e[i],t)}}var Py;function dt(n,e,t,r,i,o=null){var s=n,a=new Map,l=(e&y1)!==0;if(l){var c=n;s=c.appendChild(Xi())}var d=null,u=Dg(()=>{var _=t();return Tg(_)?_:_==null?[]:Vf(_)}),h,p=new Map,m=!0;function v(_){(w.effect.f&zr)===0&&(w.pending.delete(_),w.fallback=d,KE(w,h,s,e,r),d!==null&&(h.length===0?(d.f&bi)===0?zg(d):(d.f^=bi,Ol(d,null,s)):_s(d,()=>{d=null})))}function g(_){w.pending.delete(_)}var y=Gs(()=>{h=f(u);for(var _=h.length,C=new Set,A=je,j=j1(),H=0;H<_;H+=1){var D=h[H],N=r(D,H),W=m?null:a.get(N);W?(W.v&&Gi(W.v,D),W.i&&Gi(W.i,H),j&&A.unskip_effect(W.e)):(W=qE(a,m?s:Py??(Py=Xi()),D,N,H,i,e,t),m||(W.e.f|=bi),a.set(N,W)),C.add(N)}if(_===0&&o&&!d&&(m?d=Mr(()=>o(s)):(d=Mr(()=>o(Py??(Py=Xi()))),d.f|=bi)),_>C.size&&ET(),!m)if(p.set(A,C),j){for(const[ee,z]of a)C.has(ee)||A.skip_effect(z.e);A.oncommit(v),A.ondiscard(g)}else v(A);f(u)}),w={effect:y,items:a,pending:p,outrogroups:null,fallback:d};m=!1}function xl(n){for(;n!==null&&(n.f&ni)===0;)n=n.next;return n}function KE(n,e,t,r,i){var W,ee,z,Y,te,ne,q,P,M;var o=(r&BT)!==0,s=e.length,a=n.items,l=xl(n.effect.first),c,d=null,u,h=[],p=[],m,v,g,y;if(o)for(y=0;y<s;y+=1)m=e[y],v=i(m,y),g=a.get(v).e,(g.f&bi)===0&&((ee=(W=g.nodes)==null?void 0:W.a)==null||ee.measure(),(u??(u=new Set)).add(g));for(y=0;y<s;y+=1){if(m=e[y],v=i(m,y),g=a.get(v).e,n.outrogroups!==null)for(const O of n.outrogroups)O.pending.delete(g),O.done.delete(g);if((g.f&Jn)!==0&&(zg(g),o&&((Y=(z=g.nodes)==null?void 0:z.a)==null||Y.unfix(),(u??(u=new Set)).delete(g))),(g.f&bi)!==0)if(g.f^=bi,g===l)Ol(g,null,t);else{var w=d?d.next:l;g===n.effect.last&&(n.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),ho(n,d,g),ho(n,g,w),Ol(g,w,t),d=g,h=[],p=[],l=xl(d.next);continue}if(g!==l){if(c!==void 0&&c.has(g)){if(h.length<p.length){var _=p[0],C;d=_.prev;var A=h[0],j=h[h.length-1];for(C=0;C<h.length;C+=1)Ol(h[C],_,t);for(C=0;C<p.length;C+=1)c.delete(p[C]);ho(n,A.prev,j.next),ho(n,d,A),ho(n,j,_),l=_,d=j,y-=1,h=[],p=[]}else c.delete(g),Ol(g,l,t),ho(n,g.prev,g.next),ho(n,g,d===null?n.effect.first:d.next),ho(n,d,g),d=g;continue}for(h=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=xl(l.next);if(l===null)continue}(g.f&bi)===0&&h.push(g),d=g,l=xl(g.next)}if(n.outrogroups!==null){for(const O of n.outrogroups)O.pending.size===0&&(im(n,Vf(O.done)),(te=n.outrogroups)==null||te.delete(O));n.outrogroups.size===0&&(n.outrogroups=null)}if(l!==null||c!==void 0){var H=[];if(c!==void 0)for(g of c)(g.f&Jn)===0&&H.push(g);for(;l!==null;)(l.f&Jn)===0&&l!==n.fallback&&H.push(l),l=xl(l.next);var D=H.length;if(D>0){var N=(r&y1)!==0&&s===0?t:null;if(o){for(y=0;y<D;y+=1)(q=(ne=H[y].nodes)==null?void 0:ne.a)==null||q.measure();for(y=0;y<D;y+=1)(M=(P=H[y].nodes)==null?void 0:P.a)==null||M.fix()}WE(n,H,N)}}o&&Si(()=>{var O,I;if(u!==void 0)for(g of u)(I=(O=g.nodes)==null?void 0:O.a)==null||I.apply()})}function qE(n,e,t,r,i,o,s,a){var l=(s&zT)!==0?(s&HT)===0?em(t,!1,!1):io(t):null,c=(s&FT)!==0?io(i):null;return{v:l,i:c,e:Mr(()=>(o(e,l??t,c??i,a),()=>{n.delete(r)}))}}function Ol(n,e,t){if(n.nodes)for(var r=n.nodes.start,i=n.nodes.end,o=e&&(e.f&bi)===0?e.nodes.start:t;r!==null;){var s=$c(r);if(o.before(r),r===i)return;r=s}}function ho(n,e,t){e===null?n.effect.first=t:e.next=t,t===null?n.effect.last=e:t.prev=e}function JE(n,e,t=!1,r=!1,i=!1,o=!1){var s=n,a="";if(t)var l=n;K(()=>{var c=ut;if(a!==(a=e()??"")){if(t){c.nodes=null,l.innerHTML=a,a!==""&&Is(wi(l),l.lastChild);return}if(c.nodes!==null&&(Z1(c.nodes.start,c.nodes.end),c.nodes=null),a!==""){var d=r?ZT:i?YT:void 0,u=W1(r?"svg":i?"math":"template",d);u.innerHTML=a;var h=r||i?u:u.content;if(Is(wi(h),h.lastChild),r||i)for(;wi(h);)s.before(wi(h));else s.before(h)}}})}function Bg(n,e,...t){var r=new nd(n);Gs(()=>{const i=e()??null;r.ensure(i,i&&(o=>i(o,...t)))},Vo)}function Hg(n,e,t){var r=new nd(n);Gs(()=>{var i=e()??null;r.ensure(i,i&&(o=>t(o,i)))},Vo)}function lc(n,e,t){Pg(()=>{var r=Dt(()=>e(n,t==null?void 0:t())||{});if(t&&(r!=null&&r.update)){var i=!1,o={};ed(()=>{var s=t();RE(s),i&&x1(o,s)&&(o=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}const Ly=[...`
|
|
3
|
+
\r\f \v\uFEFF`];function ZE(n,e,t){var r=n==null?"":""+n;if(t){for(var i of Object.keys(t))if(t[i])r=r?r+" "+i:i;else if(r.length)for(var o=i.length,s=0;(s=r.indexOf(i,s))>=0;){var a=s+o;(s===0||Ly.includes(r[s-1]))&&(a===r.length||Ly.includes(r[a]))?r=(s===0?"":r.substring(0,s))+r.substring(a+1):s=a}}return r===""?null:r}function YE(n,e){return n==null?null:String(n)}function Vg(n,e,t,r,i,o){var s=n[Kp];if(s!==t||s===void 0){var a=ZE(t,r,o);a==null?n.removeAttribute("class"):n.className=a,n[Kp]=t}else if(o&&i!==o)for(var l in o){var c=!!o[l];(i==null||c!==!!i[l])&&n.classList.toggle(l,c)}return o}function re(n,e,t,r){var i=n[qp];if(i!==e){var o=YE(e);o==null?n.removeAttribute("style"):n.style.cssText=o,n[qp]=e}return r}function Ug(n,e,t=!1){if(n.multiple){if(e==null)return;if(!Tg(e))return XT();for(var r of n.options)r.selected=e.includes(zy(r));return}for(r of n.options){var i=zy(r);if(yE(i,e)){r.selected=!0;return}}(!t||e!==void 0)&&(n.selectedIndex=-1)}function lx(n){var e=new MutationObserver(()=>{Ug(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Ig(()=>{e.disconnect()})}function zy(n){return"__value"in n?n.__value:n.value}const GE=Symbol("is custom element"),XE=Symbol("is html"),QE=CT?"progress":"PROGRESS";function yr(n,e){var t=jg(n);t.value===(t.value=e??void 0)||n.value===e&&(e!==0||n.nodeName!==QE)||(n.value=e??"")}function ti(n,e){var t=jg(n);t.checked!==(t.checked=e??void 0)&&(n.checked=e)}function G(n,e,t,r){var i=jg(n);i[e]!==(i[e]=t)&&(e==="loading"&&(n[ST]=t),t==null?n.removeAttribute(e):typeof t!="string"&&$E(n).includes(e)?n[e]=t:n.setAttribute(e,t))}function jg(n){return n[Kd]??(n[Kd]={[GE]:n.nodeName.includes("-"),[XE]:n.namespaceURI===b1})}var Fy=new Map;function $E(n){var e=n.getAttribute("is")||n.nodeName,t=Fy.get(e);if(t)return t;Fy.set(e,t=[]);for(var r,i=n,o=Element.prototype;o!==i;){r=h1(i);for(var s in r)r[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&t.push(s);i=Eg(i)}return t}function Uo(n,e,t=e){var r=new WeakSet;K1(n,"input",async i=>{var o=i?n.defaultValue:n.value;if(o=Lh(n)?zh(o):o,t(o),je!==null&&r.add(je),await DE(),o!==(o=e())){var s=n.selectionStart,a=n.selectionEnd,l=n.value.length;if(n.value=o??"",a!==null){var c=n.value.length;s===a&&a===l&&c>l?(n.selectionStart=c,n.selectionEnd=c):(n.selectionStart=s,n.selectionEnd=Math.min(a,c))}}}),Dt(e)==null&&n.value&&(t(Lh(n)?zh(n.value):n.value),je!==null&&r.add(je)),ed(()=>{var i=e();if(n===document.activeElement){var o=je;if(r.has(o))return}Lh(n)&&i===zh(n.value)||n.type==="date"&&!i&&!n.value||i!==n.value&&(n.value=i??"")})}function Ph(n,e,t=e){K1(n,"change",r=>{var i=r?n.defaultChecked:n.checked;t(i)}),Dt(e)==null&&t(n.checked),ed(()=>{var r=e();n.checked=!!r})}function Lh(n){var e=n.type;return e==="number"||e==="range"}function zh(n){return n===""?null:+n}var Ao,Fa,Xc,Ff,cx;const Bf=class Bf{constructor(e){Ke(this,Ff);Ke(this,Ao,new WeakMap);Ke(this,Fa);Ke(this,Xc);Je(this,Xc,e)}observe(e,t){var r=J(this,Ao).get(e)||new Set;return r.add(t),J(this,Ao).set(e,r),mt(this,Ff,cx).call(this).observe(e,J(this,Xc)),()=>{var i=J(this,Ao).get(e);i.delete(t),i.size===0&&(J(this,Ao).delete(e),J(this,Fa).unobserve(e))}}};Ao=new WeakMap,Fa=new WeakMap,Xc=new WeakMap,Ff=new WeakSet,cx=function(){return J(this,Fa)??Je(this,Fa,new ResizeObserver(e=>{for(var t of e){Bf.entries.set(t.target,t);for(var r of J(this,Ao).get(t.target)||[])r(t)}}))},gn(Bf,"entries",new WeakMap);let om=Bf;var eA=new om({box:"border-box"});function tA(n,e,t){var r=eA.observe(n,()=>t(n[e]));Pg(()=>(Dt(()=>t(n[e])),r))}function Fh(n,e){return n===e||(n==null?void 0:n[_i])===e}function gt(n={},e,t,r){var i=qt.r,o=ut;return Pg(()=>{var s,a;return ed(()=>{s=a,a=(r==null?void 0:r())||[],Dt(()=>{Fh(t(...a),n)||(e(n,...a),s&&Fh(t(...s),n)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&Wp;)l=l.parent;const c=()=>{a&&Fh(t(...a),n)&&e(null,...a)},d=l.teardown;l.teardown=()=>{c(),d==null||d()}}}),n}const nA={get(n,e){if(!n.exclude.includes(e))return n.props[e]},set(n,e){return!1},getOwnPropertyDescriptor(n,e){if(!n.exclude.includes(e)&&e in n.props)return{enumerable:!0,configurable:!0,value:n.props[e]}},has(n,e){return n.exclude.includes(e)?!1:e in n.props},ownKeys(n){return Reflect.ownKeys(n.props).filter(e=>!n.exclude.includes(e))}};function rA(n,e,t){return new Proxy({props:n,exclude:e},nA)}const iA={get(n,e){let t=n.props.length;for(;t--;){let r=n.props[t];if(wl(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r)return r[e]}},set(n,e,t){let r=n.props.length;for(;r--;){let i=n.props[r];wl(i)&&(i=i());const o=Io(i,e);if(o&&o.set)return o.set(t),!0}return!1},getOwnPropertyDescriptor(n,e){let t=n.props.length;for(;t--;){let r=n.props[t];if(wl(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r){const i=Io(r,e);return i&&!i.configurable&&(i.configurable=!0),i}}},has(n,e){if(e===_i||e===g1)return!1;for(let t of n.props)if(wl(t)&&(t=t()),t!=null&&e in t)return!0;return!1},ownKeys(n){const e=[];for(let t of n.props)if(wl(t)&&(t=t()),!!t){for(const r in t)e.includes(r)||e.push(r);for(const r of Object.getOwnPropertySymbols(t))e.includes(r)||e.push(r)}return e}};function Dl(...n){return new Proxy({props:n},iA)}function st(n,e,t,r){var C;var i=!cl||(t&UT)!==0,o=(t&WT)!==0,s=(t&KT)!==0,a=r,l=!0,c=void 0,d=()=>s&&i?(c??(c=sc(r)),f(c)):(l&&(l=!1,a=s?Dt(r):r),a);let u;if(o){var h=_i in n||g1 in n;u=((C=Io(n,e))==null?void 0:C.set)??(h&&e in n?A=>n[e]=A:void 0)}var p,m=!1;o?[p,m]=rE(()=>n[e]):p=n[e],p===void 0&&r!==void 0&&(p=d(),u&&(i&&RT(),u(p)));var v;if(i?v=()=>{var A=n[e];return A===void 0?d():(l=!0,A)}:v=()=>{var A=n[e];return A!==void 0&&(a=void 0),A===void 0?a:A},i&&(t&jT)===0)return v;if(u){var g=n.$$legacy;return(function(A,j){return arguments.length>0?((!i||!j||g||m)&&u(j?v():A),A):v()})}var y=!1,w=((t&VT)!==0?sc:Dg)(()=>(y=!1,v()));o&&f(w);var _=ut;return(function(A,j){if(arguments.length>0){const H=j?f(w):i&&o?at(A):A;return b(w,H),y=!0,a!==void 0&&(a=H),A}return oo&&y||(_.f&zr)!==0?w.v:f(w)})}function rd(n){qt===null&&v1(),cl&&qt.l!==null?oA(qt).m.push(n):le(()=>{const e=Dt(n);if(typeof e=="function")return e})}function ri(n){qt===null&&v1(),rd(()=>()=>Dt(n))}function oA(n){var e=n.l;return e.u??(e.u={a:[],b:[],m:[]})}const sA="5";var u1;typeof window<"u"&&((u1=window.__svelte??(window.__svelte={})).v??(u1.v=new Set)).add(sA);eE();const aA="modulepreload",lA=function(n){return"/"+n},By={},Wr=function(e,t,r){let i=Promise.resolve();if(t&&t.length>0){let s=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=s(t.map(c=>{if(c=lA(c),c in By)return;By[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":aA,d||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),d)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return e().catch(o)})},cA="/api/notify-stream",Hy="/api/info",dl="/api/open",dA="/api/close",uA="/api/save",dx="/api/upload",fA="/api/scratchpad",hA="/api/convert",pA="/api/apply-changes",mA="/api/annotation-reply",gA="/api/remove-annotation",vA="/api/chat",yA="upload://";function Vy(n){return n.startsWith(yA)}const Qd=n=>n,Dn=n=>n;var wt;(function(n){n.assertEqual=i=>{};function e(i){}n.assertIs=e;function t(i){throw new Error}n.assertNever=t,n.arrayToEnum=i=>{const o={};for(const s of i)o[s]=s;return o},n.getValidEnumValues=i=>{const o=n.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(const a of o)s[a]=i[a];return n.objectValues(s)},n.objectValues=i=>n.objectKeys(i).map(function(o){return i[o]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const o=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},n.find=(i,o)=>{for(const s of i)if(o(s))return s},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}n.joinValues=r,n.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(wt||(wt={}));var Uy;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Uy||(Uy={}));const Me=wt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),vo=n=>{switch(typeof n){case"undefined":return Me.undefined;case"string":return Me.string;case"number":return Number.isNaN(n)?Me.nan:Me.number;case"boolean":return Me.boolean;case"function":return Me.function;case"bigint":return Me.bigint;case"symbol":return Me.symbol;case"object":return Array.isArray(n)?Me.array:n===null?Me.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Me.promise:typeof Map<"u"&&n instanceof Map?Me.map:typeof Set<"u"&&n instanceof Set?Me.set:typeof Date<"u"&&n instanceof Date?Me.date:Me.object;default:return Me.unknown}},fe=wt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class so extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(o){return o.message},r={_errors:[]},i=o=>{for(const s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)r._errors.push(t(s));else{let a=r,l=0;for(;l<s.path.length;){const c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(s))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(e){if(!(e instanceof so))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,wt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const i of this.issues)if(i.path.length>0){const o=i.path[0];t[o]=t[o]||[],t[o].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}so.create=n=>new so(n);const sm=(n,e)=>{let t;switch(n.code){case fe.invalid_type:n.received===Me.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case fe.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,wt.jsonStringifyReplacer)}`;break;case fe.unrecognized_keys:t=`Unrecognized key(s) in object: ${wt.joinValues(n.keys,", ")}`;break;case fe.invalid_union:t="Invalid input";break;case fe.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${wt.joinValues(n.options)}`;break;case fe.invalid_enum_value:t=`Invalid enum value. Expected ${wt.joinValues(n.options)}, received '${n.received}'`;break;case fe.invalid_arguments:t="Invalid function arguments";break;case fe.invalid_return_type:t="Invalid function return type";break;case fe.invalid_date:t="Invalid date";break;case fe.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:wt.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case fe.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case fe.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case fe.custom:t="Invalid input";break;case fe.invalid_intersection_types:t="Intersection results could not be merged";break;case fe.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case fe.not_finite:t="Number must be finite";break;default:t=e.defaultError,wt.assertNever(n)}return{message:t}};let bA=sm;function wA(){return bA}const xA=n=>{const{data:e,path:t,errorMaps:r,issueData:i}=n,o=[...t,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(s,{data:e,defaultError:a}).message;return{...i,path:o,message:a}};function xe(n,e){const t=wA(),r=xA({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===sm?void 0:sm].filter(i=>!!i)});n.common.issues.push(r)}class br{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const i of t){if(i.status==="aborted")return Ye;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const i of t){const o=await i.key,s=await i.value;r.push({key:o,value:s})}return br.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const i of t){const{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return Ye;o.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(r[o.value]=s.value)}return{status:e.value,value:r}}}const Ye=Object.freeze({status:"aborted"}),Rl=n=>({status:"dirty",value:n}),qr=n=>({status:"valid",value:n}),jy=n=>n.status==="aborted",Wy=n=>n.status==="dirty",Wa=n=>n.status==="valid",xu=n=>typeof Promise<"u"&&n instanceof Promise;var De;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(De||(De={}));class jo{constructor(e,t,r,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ky=(n,e)=>{if(Wa(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new so(n.common.issues);return this._error=t,this._error}}};function ft(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:i}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,a)=>{const{message:l}=n;return s.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:l??t??a.defaultError}},description:i}}class vt{get description(){return this._def.description}_getType(e){return vo(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:vo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new br,ctx:{common:e.parent.common,data:e.data,parsedType:vo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(xu(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vo(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Ky(r,i)}"~validate"(e){var r,i;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vo(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:t});return Wa(o)?{value:o.value}:{issues:t.common.issues}}catch(o){(i=(r=o==null?void 0:o.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(o=>Wa(o)?{value:o.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:vo(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(xu(i)?i:Promise.resolve(i));return Ky(r,o)}refine(e,t){const r=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,o)=>{const s=e(i),a=()=>o.addIssue({code:fe.custom,...r(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,t){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof t=="function"?t(r,i):t),!1))}_refinement(e){return new qa({schema:this,typeName:Ge.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:t=>this["~validate"](t)}}optional(){return Lo.create(this,this._def)}nullable(){return Ja.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ci.create(this)}promise(){return Cu.create(this,this._def)}or(e){return _u.create([this,e],this._def)}and(e){return Su.create(this,e,this._def)}transform(e){return new qa({...ft(this._def),schema:this,typeName:Ge.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lm({...ft(this._def),innerType:this,defaultValue:t,typeName:Ge.ZodDefault})}brand(){return new WA({typeName:Ge.ZodBranded,type:this,...ft(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new cm({...ft(this._def),innerType:this,catchValue:t,typeName:Ge.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Wg.create(this,e)}readonly(){return dm.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const kA=/^c[^\s-]{8,}$/i,_A=/^[0-9a-z]+$/,SA=/^[0-9A-HJKMNP-TV-Z]{26}$/i,CA=/^[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,TA=/^[a-z0-9_-]{21}$/i,EA=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,AA=/^[-+]?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)?)??$/,MA=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,OA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Bh;const DA=/^(?:(?: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])$/,RA=/^(?:(?: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])$/,NA=/^(([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]))$/,IA=/^(([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])$/,PA=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,LA=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ux="((\\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])))",zA=new RegExp(`^${ux}$`);function fx(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);const t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function FA(n){return new RegExp(`^${fx(n)}$`)}function BA(n){let e=`${ux}T${fx(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function HA(n,e){return!!((e==="v4"||!e)&&DA.test(n)||(e==="v6"||!e)&&NA.test(n))}function VA(n,e){if(!EA.test(n))return!1;try{const[t]=n.split(".");if(!t)return!1;const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function UA(n,e){return!!((e==="v4"||!e)&&RA.test(n)||(e==="v6"||!e)&&IA.test(n))}class us extends vt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Me.string){const o=this._getOrReturnCtx(e);return xe(o,{code:fe.invalid_type,expected:Me.string,received:o.parsedType}),Ye}const r=new br;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){const s=e.data.length>o.value,a=e.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(e,i),s?xe(i,{code:fe.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&xe(i,{code:fe.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")MA.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"email",code:fe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")Bh||(Bh=new RegExp(OA,"u")),Bh.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"emoji",code:fe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")CA.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"uuid",code:fe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")TA.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"nanoid",code:fe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")kA.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cuid",code:fe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")_A.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cuid2",code:fe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")SA.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"ulid",code:fe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),xe(i,{validation:"url",code:fe.invalid_string,message:o.message}),r.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"regex",code:fe.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?BA(o).test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?zA.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?FA(o).test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?AA.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"duration",code:fe.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?HA(e.data,o.version)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"ip",code:fe.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?VA(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"jwt",code:fe.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?UA(e.data,o.version)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"cidr",code:fe.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?PA.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"base64",code:fe.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?LA.test(e.data)||(i=this._getOrReturnCtx(e,i),xe(i,{validation:"base64url",code:fe.invalid_string,message:o.message}),r.dirty()):wt.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(i=>e.test(i),{validation:t,code:fe.invalid_string,...De.errToObj(r)})}_addCheck(e){return new us({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...De.errToObj(e)})}url(e){return this._addCheck({kind:"url",...De.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...De.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...De.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...De.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...De.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...De.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...De.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...De.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...De.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...De.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...De.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...De.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...De.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...De.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...De.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...De.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...De.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...De.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...De.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...De.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...De.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...De.errToObj(t)})}nonempty(e){return this.min(1,De.errToObj(e))}trim(){return new us({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new us({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new us({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}us.create=n=>new us({checks:[],typeName:Ge.ZodString,coerce:(n==null?void 0:n.coerce)??!1,...ft(n)});function jA(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=t>r?t:r,o=Number.parseInt(n.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return o%s/10**i}class cc extends vt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Me.number){const o=this._getOrReturnCtx(e);return xe(o,{code:fe.invalid_type,expected:Me.number,received:o.parsedType}),Ye}let r;const i=new br;for(const o of this._def.checks)o.kind==="int"?wt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),xe(r,{code:fe.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),xe(r,{code:fe.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),xe(r,{code:fe.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?jA(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),xe(r,{code:fe.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),xe(r,{code:fe.not_finite,message:o.message}),i.dirty()):wt.assertNever(o);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,De.toString(t))}gt(e,t){return this.setLimit("min",e,!1,De.toString(t))}lte(e,t){return this.setLimit("max",e,!0,De.toString(t))}lt(e,t){return this.setLimit("max",e,!1,De.toString(t))}setLimit(e,t,r,i){return new cc({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:De.toString(i)}]})}_addCheck(e){return new cc({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:De.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:De.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:De.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:De.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:De.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:De.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:De.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:De.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:De.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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"&&wt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}cc.create=n=>new cc({checks:[],typeName:Ge.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...ft(n)});class dc extends vt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Me.bigint)return this._getInvalidInput(e);let r;const i=new br;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),xe(r,{code:fe.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),xe(r,{code:fe.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),xe(r,{code:fe.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):wt.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return xe(t,{code:fe.invalid_type,expected:Me.bigint,received:t.parsedType}),Ye}gte(e,t){return this.setLimit("min",e,!0,De.toString(t))}gt(e,t){return this.setLimit("min",e,!1,De.toString(t))}lte(e,t){return this.setLimit("max",e,!0,De.toString(t))}lt(e,t){return this.setLimit("max",e,!1,De.toString(t))}setLimit(e,t,r,i){return new dc({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:De.toString(i)}]})}_addCheck(e){return new dc({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:De.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:De.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:De.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:De.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:De.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}dc.create=n=>new dc({checks:[],typeName:Ge.ZodBigInt,coerce:(n==null?void 0:n.coerce)??!1,...ft(n)});class qy extends vt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Me.boolean){const r=this._getOrReturnCtx(e);return xe(r,{code:fe.invalid_type,expected:Me.boolean,received:r.parsedType}),Ye}return qr(e.data)}}qy.create=n=>new qy({typeName:Ge.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...ft(n)});class ku extends vt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Me.date){const o=this._getOrReturnCtx(e);return xe(o,{code:fe.invalid_type,expected:Me.date,received:o.parsedType}),Ye}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return xe(o,{code:fe.invalid_date}),Ye}const r=new br;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),xe(i,{code:fe.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):wt.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ku({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:De.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:De.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ku.create=n=>new ku({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:Ge.ZodDate,...ft(n)});class Jy extends vt{_parse(e){if(this._getType(e)!==Me.symbol){const r=this._getOrReturnCtx(e);return xe(r,{code:fe.invalid_type,expected:Me.symbol,received:r.parsedType}),Ye}return qr(e.data)}}Jy.create=n=>new Jy({typeName:Ge.ZodSymbol,...ft(n)});class Zy extends vt{_parse(e){if(this._getType(e)!==Me.undefined){const r=this._getOrReturnCtx(e);return xe(r,{code:fe.invalid_type,expected:Me.undefined,received:r.parsedType}),Ye}return qr(e.data)}}Zy.create=n=>new Zy({typeName:Ge.ZodUndefined,...ft(n)});class Yy extends vt{_parse(e){if(this._getType(e)!==Me.null){const r=this._getOrReturnCtx(e);return xe(r,{code:fe.invalid_type,expected:Me.null,received:r.parsedType}),Ye}return qr(e.data)}}Yy.create=n=>new Yy({typeName:Ge.ZodNull,...ft(n)});class Gy extends vt{constructor(){super(...arguments),this._any=!0}_parse(e){return qr(e.data)}}Gy.create=n=>new Gy({typeName:Ge.ZodAny,...ft(n)});class Xy extends vt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return qr(e.data)}}Xy.create=n=>new Xy({typeName:Ge.ZodUnknown,...ft(n)});class Wo extends vt{_parse(e){const t=this._getOrReturnCtx(e);return xe(t,{code:fe.invalid_type,expected:Me.never,received:t.parsedType}),Ye}}Wo.create=n=>new Wo({typeName:Ge.ZodNever,...ft(n)});class Qy extends vt{_parse(e){if(this._getType(e)!==Me.undefined){const r=this._getOrReturnCtx(e);return xe(r,{code:fe.invalid_type,expected:Me.void,received:r.parsedType}),Ye}return qr(e.data)}}Qy.create=n=>new Qy({typeName:Ge.ZodVoid,...ft(n)});class Ci extends vt{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==Me.array)return xe(t,{code:fe.invalid_type,expected:Me.array,received:t.parsedType}),Ye;if(i.exactLength!==null){const s=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(s||a)&&(xe(t,{code:s?fe.too_big:fe.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(xe(t,{code:fe.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(xe(t,{code:fe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((s,a)=>i.type._parseAsync(new jo(t,s,t.path,a)))).then(s=>br.mergeArray(r,s));const o=[...t.data].map((s,a)=>i.type._parseSync(new jo(t,s,t.path,a)));return br.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new Ci({...this._def,minLength:{value:e,message:De.toString(t)}})}max(e,t){return new Ci({...this._def,maxLength:{value:e,message:De.toString(t)}})}length(e,t){return new Ci({...this._def,exactLength:{value:e,message:De.toString(t)}})}nonempty(e){return this.min(1,e)}}Ci.create=(n,e)=>new Ci({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Ge.ZodArray,...ft(e)});function aa(n){if(n instanceof pn){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=Lo.create(aa(r))}return new pn({...n._def,shape:()=>e})}else return n instanceof Ci?new Ci({...n._def,type:aa(n.element)}):n instanceof Lo?Lo.create(aa(n.unwrap())):n instanceof Ja?Ja.create(aa(n.unwrap())):n instanceof Ps?Ps.create(n.items.map(e=>aa(e))):n}class pn extends vt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=wt.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Me.object){const c=this._getOrReturnCtx(e);return xe(c,{code:fe.invalid_type,expected:Me.object,received:c.parsedType}),Ye}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Wo&&this._def.unknownKeys==="strip"))for(const c in i.data)s.includes(c)||a.push(c);const l=[];for(const c of s){const d=o[c],u=i.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new jo(i,u,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Wo){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of a)l.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")a.length>0&&(xe(i,{code:fe.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of a){const u=i.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new jo(i,u,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const u=await d.key,h=await d.value;c.push({key:u,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>br.mergeObjectSync(r,c)):br.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return De.errToObj,new pn({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var o,s;const i=((s=(o=this._def).errorMap)==null?void 0:s.call(o,t,r).message)??r.defaultError;return t.code==="unrecognized_keys"?{message:De.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new pn({...this._def,unknownKeys:"strip"})}passthrough(){return new pn({...this._def,unknownKeys:"passthrough"})}extend(e){return new pn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new pn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ge.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new pn({...this._def,catchall:e})}pick(e){const t={};for(const r of wt.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new pn({...this._def,shape:()=>t})}omit(e){const t={};for(const r of wt.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new pn({...this._def,shape:()=>t})}deepPartial(){return aa(this)}partial(e){const t={};for(const r of wt.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new pn({...this._def,shape:()=>t})}required(e){const t={};for(const r of wt.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof Lo;)o=o._def.innerType;t[r]=o}return new pn({...this._def,shape:()=>t})}keyof(){return hx(wt.objectKeys(this.shape))}}pn.create=(n,e)=>new pn({shape:()=>n,unknownKeys:"strip",catchall:Wo.create(),typeName:Ge.ZodObject,...ft(e)});pn.strictCreate=(n,e)=>new pn({shape:()=>n,unknownKeys:"strict",catchall:Wo.create(),typeName:Ge.ZodObject,...ft(e)});pn.lazycreate=(n,e)=>new pn({shape:n,unknownKeys:"strip",catchall:Wo.create(),typeName:Ge.ZodObject,...ft(e)});class _u extends vt{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function i(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const s=o.map(a=>new so(a.ctx.common.issues));return xe(t,{code:fe.invalid_union,unionErrors:s}),Ye}if(t.common.async)return Promise.all(r.map(async o=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(i);{let o;const s=[];for(const l of r){const c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(l=>new so(l));return xe(t,{code:fe.invalid_union,unionErrors:a}),Ye}}get options(){return this._def.options}}_u.create=(n,e)=>new _u({options:n,typeName:Ge.ZodUnion,...ft(e)});function am(n,e){const t=vo(n),r=vo(e);if(n===e)return{valid:!0,data:n};if(t===Me.object&&r===Me.object){const i=wt.objectKeys(e),o=wt.objectKeys(n).filter(a=>i.indexOf(a)!==-1),s={...n,...e};for(const a of o){const l=am(n[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(t===Me.array&&r===Me.array){if(n.length!==e.length)return{valid:!1};const i=[];for(let o=0;o<n.length;o++){const s=n[o],a=e[o],l=am(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===Me.date&&r===Me.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Su extends vt{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(jy(o)||jy(s))return Ye;const a=am(o.value,s.value);return a.valid?((Wy(o)||Wy(s))&&t.dirty(),{status:t.value,value:a.data}):(xe(r,{code:fe.invalid_intersection_types}),Ye)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Su.create=(n,e,t)=>new Su({left:n,right:e,typeName:Ge.ZodIntersection,...ft(t)});class Ps extends vt{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Me.array)return xe(r,{code:fe.invalid_type,expected:Me.array,received:r.parsedType}),Ye;if(r.data.length<this._def.items.length)return xe(r,{code:fe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ye;!this._def.rest&&r.data.length>this._def.items.length&&(xe(r,{code:fe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const o=[...r.data].map((s,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new jo(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>br.mergeArray(t,s)):br.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new Ps({...this._def,rest:e})}}Ps.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ps({items:n,typeName:Ge.ZodTuple,rest:null,...ft(e)})};class $y extends vt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Me.map)return xe(r,{code:fe.invalid_type,expected:Me.map,received:r.parsedType}),Ye;const i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new jo(r,a,r.path,[c,"key"])),value:o._parse(new jo(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of s){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return Ye;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(c.value,d.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const l of s){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return Ye;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(c.value,d.value)}return{status:t.value,value:a}}}}$y.create=(n,e,t)=>new $y({valueType:e,keyType:n,typeName:Ge.ZodMap,...ft(t)});class uc extends vt{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Me.set)return xe(r,{code:fe.invalid_type,expected:Me.set,received:r.parsedType}),Ye;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(xe(r,{code:fe.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(xe(r,{code:fe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const o=this._def.valueType;function s(l){const c=new Set;for(const d of l){if(d.status==="aborted")return Ye;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}const a=[...r.data.values()].map((l,c)=>o._parse(new jo(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,t){return new uc({...this._def,minSize:{value:e,message:De.toString(t)}})}max(e,t){return new uc({...this._def,maxSize:{value:e,message:De.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}uc.create=(n,e)=>new uc({valueType:n,minSize:null,maxSize:null,typeName:Ge.ZodSet,...ft(e)});class eb extends vt{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}eb.create=(n,e)=>new eb({getter:n,typeName:Ge.ZodLazy,...ft(e)});class tb extends vt{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return xe(t,{received:t.data,code:fe.invalid_literal,expected:this._def.value}),Ye}return{status:"valid",value:e.data}}get value(){return this._def.value}}tb.create=(n,e)=>new tb({value:n,typeName:Ge.ZodLiteral,...ft(e)});function hx(n,e){return new Ka({values:n,typeName:Ge.ZodEnum,...ft(e)})}class Ka extends vt{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return xe(t,{expected:wt.joinValues(r),received:t.parsedType,code:fe.invalid_type}),Ye}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return xe(t,{received:t.data,code:fe.invalid_enum_value,options:r}),Ye}return qr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ka.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ka.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Ka.create=hx;class nb extends vt{_parse(e){const t=wt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Me.string&&r.parsedType!==Me.number){const i=wt.objectValues(t);return xe(r,{expected:wt.joinValues(i),received:r.parsedType,code:fe.invalid_type}),Ye}if(this._cache||(this._cache=new Set(wt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=wt.objectValues(t);return xe(r,{received:r.data,code:fe.invalid_enum_value,options:i}),Ye}return qr(e.data)}get enum(){return this._def.values}}nb.create=(n,e)=>new nb({values:n,typeName:Ge.ZodNativeEnum,...ft(e)});class Cu extends vt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Me.promise&&t.common.async===!1)return xe(t,{code:fe.invalid_type,expected:Me.promise,received:t.parsedType}),Ye;const r=t.parsedType===Me.promise?t.data:Promise.resolve(t.data);return qr(r.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Cu.create=(n,e)=>new Cu({type:n,typeName:Ge.ZodPromise,...ft(e)});class qa extends vt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ge.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:s=>{xe(r,s),s.fatal?t.abort():t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const s=i.transform(r.data,o);if(r.common.async)return Promise.resolve(s).then(async a=>{if(t.value==="aborted")return Ye;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Ye:l.status==="dirty"||t.value==="dirty"?Rl(l.value):l});{if(t.value==="aborted")return Ye;const a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?Ye:a.status==="dirty"||t.value==="dirty"?Rl(a.value):a}}if(i.type==="refinement"){const s=a=>{const l=i.refinement(a,o);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Ye:(a.status==="dirty"&&t.dirty(),s(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Ye:(a.status==="dirty"&&t.dirty(),s(a.value).then(()=>({status:t.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Wa(s))return Ye;const a=i.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>Wa(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:t.value,value:a})):Ye);wt.assertNever(i)}}qa.create=(n,e,t)=>new qa({schema:n,typeName:Ge.ZodEffects,effect:e,...ft(t)});qa.createWithPreprocess=(n,e,t)=>new qa({schema:e,effect:{type:"preprocess",transform:n},typeName:Ge.ZodEffects,...ft(t)});class Lo extends vt{_parse(e){return this._getType(e)===Me.undefined?qr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Lo.create=(n,e)=>new Lo({innerType:n,typeName:Ge.ZodOptional,...ft(e)});class Ja extends vt{_parse(e){return this._getType(e)===Me.null?qr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ja.create=(n,e)=>new Ja({innerType:n,typeName:Ge.ZodNullable,...ft(e)});class lm extends vt{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===Me.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}lm.create=(n,e)=>new lm({innerType:n,typeName:Ge.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ft(e)});class cm extends vt{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return xu(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new so(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new so(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}cm.create=(n,e)=>new cm({innerType:n,typeName:Ge.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ft(e)});class rb extends vt{_parse(e){if(this._getType(e)!==Me.nan){const r=this._getOrReturnCtx(e);return xe(r,{code:fe.invalid_type,expected:Me.nan,received:r.parsedType}),Ye}return{status:"valid",value:e.data}}}rb.create=n=>new rb({typeName:Ge.ZodNaN,...ft(n)});class WA extends vt{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Wg extends vt{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Ye:o.status==="dirty"?(t.dirty(),Rl(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Ye:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,t){return new Wg({in:e,out:t,typeName:Ge.ZodPipeline})}}class dm extends vt{_parse(e){const t=this._def.innerType._parse(e),r=i=>(Wa(i)&&(i.value=Object.freeze(i.value)),i);return xu(t)?t.then(i=>r(i)):r(t)}unwrap(){return this._def.innerType}}dm.create=(n,e)=>new dm({innerType:n,typeName:Ge.ZodReadonly,...ft(e)});var Ge;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Ge||(Ge={}));Wo.create;Ci.create;_u.create;Su.create;Ps.create;const Jr=Ka.create;Cu.create;Lo.create;Ja.create;Jr(["highlight","note","comment"]);Jr(["pending","accepted","dismissed"]);Jr(["yellow","green","blue","pink"]);Jr(["info","warning","error","success"]);const KA=Jr(["solo","tandem"]);Jr(["user","claude","import"]);Jr(["user","claude"]);Jr(["accept","dismiss"]);Jr(["markdown","json"]);Jr(["md","txt","html","docx"]);Jr(["RANGE_GONE","RANGE_MOVED","FILE_LOCKED","FILE_NOT_FOUND","NO_DOCUMENT","INVALID_RANGE","INVALID_ARGUMENT","NOT_FOUND","ANNOTATION_RESOLVED","FORMAT_ERROR","PERMISSION_DENIED"]);Jr(["CHANNEL_CONNECT_FAILED","MONITOR_CONNECT_FAILED"]);function qA(n){return n.author!=="user"}function Tu(n){return n.status==="pending"&&qA(n)}const ib=3478,Kf=3479,px="https://github.com/bloknayrb/tandem",mx=`${px}/issues/new`,JA=new Set([".md",".txt",".html",".htm",".docx"]),ZA=3e3,YA=3e3,GA=3e4,gx={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)"},fc={yellow:"var(--tandem-highlight-yellow)",green:"var(--tandem-highlight-green)",blue:"var(--tandem-highlight-blue)",pink:"var(--tandem-highlight-pink)"};function vx(n){return n&&n in gx?n:"yellow"}const ob="tandem",xd="tandem:mode",yx="tandem:settings",XA="tandem-panel-width",QA="tandem-left-panel-width",bx={left:QA,right:XA},wx=1e3,Za=500,Ya=3e3,$A="__tandem_ctrl__",Ko="annotations",xx="awareness",um="userAwareness",e2="mode",t2="selectionDwellMs",sb="chat",$d="documentMeta",kx="annotationReplies",ab="savedAtVersion",lb="authorship",cb="selection",db="activity",fm="claude",kl="openDocuments",_l="activeDocumentId",Hh="generationId",Vh="readOnly",Uh="storeReadOnly",_x="tandem:showAuthorship",Kg="tandem:recentFiles",n2=20,qg="tandem:userName",Sx="You",hm="tandem:user-name-changed",qf=40,ub={error:8e3,warning:6e3,info:4e3},r2=5,Cx="tandem:tutorialCompleted",Tx="tutorial-",Ex="tandem:coworkOnboardingSkipped",i2=3e4,qj=2e3,fb="tandem:zoomLevel",hb=.5,pb=2,Sl=1,Gn=`http://127.0.0.1:${Kf}`;function o2(n){const e=new Uint8Array(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function s2(n){return n.toLowerCase().endsWith(".docx")}async function Ax(n){if(s2(n.name)){const e=await n.arrayBuffer();return o2(e)}return n.text()}const Jg=["editor","navigation","view","document","annotations"];let eu=B(at(new Map));function a2(n,e={}){if(f(eu).has(n.id)&&!e.replace){const t=`[actions] id collision: "${n.id}" — existing action silently replaced. Pass { replace: true } to suppress this warning.`;console.warn(t)}return b(eu,new Map(f(eu)).set(n.id,n),!0),!0}function hc(){return f(eu)}let pm=null;function l2(n){pm=n}function un(n,e){if(!pm){console.warn(`[actions] "${n}" invoked before App mounted — deps not wired yet`);return}e(pm)}let mm=B(!1);const c2={get saving(){return f(mm)}};let jh=!1,Wh=!1;async function Zg(){if(!Wh){Wh=!0;try{const n=await fetch(`${Gn}${fA}`,{method:"POST"});if(!n.ok){const e=await n.json().catch(()=>({}));console.warn("[Tandem] New Scratchpad failed:",e.message??n.statusText)}}catch(n){console.warn("[Tandem] New Scratchpad request failed:",n)}finally{Wh=!1}}}async function Mx(n){if(!(!n||jh)){jh=!0,b(mm,!0);try{const e=await fetch(`${Gn}${uA}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:n})});if(!e.ok){const t=await e.json().catch(()=>({}));console.warn("[Tandem] Save failed:",t.message??e.statusText)}}catch(e){console.warn("[Tandem] Save request failed:",e)}finally{jh=!1,b(mm,!1)}}}const d2=[{id:"save",label:"Save document",group:"document",shortcut:"Ctrl+S",run(){un("save",n=>void Mx(n.getActiveTabId()))}},{id:"settings",label:"Open settings",group:"view",shortcut:"Ctrl+,",run(){un("settings",n=>n.openSettings())}},{id:"settings-modal",label:"Open settings (new)",group:"view",shortcut:"Ctrl+Shift+,",run(){un("settings-modal",n=>n.openSettingsModal())}},{id:"toggle-mode",label:"Toggle Solo / Tandem mode",group:"document",shortcut:"Ctrl+Shift+M",run(){un("toggle-mode",n=>n.toggleSoloMode())}},{id:"new-scratchpad",label:"New Scratchpad",group:"document",shortcut:"Ctrl+N",run(){Zg()}},{id:"close-tab",label:"Close active tab",group:"document",shortcut:"Ctrl+W",run(){un("close-tab",n=>n.closeActiveTab())}},{id:"open-file",label:"Open file…",group:"document",shortcut:"Ctrl+O",run(){un("open-file",n=>n.openFileDialog())}},{id:"find",label:"Find / Replace",group:"navigation",shortcut:"Ctrl+F",run(){un("find",n=>n.openFindBar())}},{id:"find-in-tabs",label:"Find in open tabs",group:"navigation",shortcut:"Ctrl+Shift+F",run(){un("find-in-tabs",n=>n.openFindBarTabs())}},{id:"find-next",label:"Find next match",group:"navigation",shortcut:"Ctrl+G",run(){un("find-next",n=>n.findNext())}},{id:"find-previous",label:"Find previous match",group:"navigation",shortcut:"Ctrl+Shift+G",run(){un("find-previous",n=>n.findPrev())}},{id:"toggle-left-panel",label:"Toggle left panel",group:"view",shortcut:"Ctrl+\\",run(){un("toggle-left-panel",n=>n.toggleLeftPanel())}},{id:"toggle-right-panel",label:"Toggle right panel",group:"view",shortcut:"Ctrl+Shift+\\",run(){un("toggle-right-panel",n=>n.toggleRightPanel())}},{id:"reopen-closed-tab",label:"Reopen closed tab (this session)",group:"document",shortcut:"Ctrl+Alt+T",run(){un("reopen-closed-tab",n=>n.reopenClosedTab())}},{id:"annotation-next",label:"Next annotation",group:"annotations",shortcut:"Alt+]",run(){un("annotation-next",n=>n.annotationNext())}},{id:"annotation-previous",label:"Previous annotation",group:"annotations",shortcut:"Alt+[",run(){un("annotation-previous",n=>n.annotationPrev())}},{id:"annotation-accept",label:"Accept focused annotation",group:"annotations",shortcut:"Ctrl+Enter",run(){un("annotation-accept",n=>n.annotationAccept())}},{id:"annotation-dismiss",label:"Dismiss focused annotation",group:"annotations",shortcut:"Ctrl+Shift+Enter",run(){un("annotation-dismiss",n=>n.annotationDismiss())}},{id:"select-block",label:"Select containing block",group:"editor",shortcut:"Alt+L",run(){un("select-block",n=>n.selectBlock())}},{id:"toggle-authorship",label:"Toggle authorship colors",group:"view",shortcut:"Ctrl+Alt+A",run(){un("toggle-authorship",n=>n.toggleAuthorship())}}];for(const n of d2)a2(n);function Tn(n){this.content=n}Tn.prototype={constructor:Tn,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),o=r.content.slice();return i==-1?o.push(t||n,e):(o[i+1]=e,t&&(o[i]=t)),new Tn(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Tn(t)},addToStart:function(n,e){return new Tn([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Tn(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),o=r.find(n);return i.splice(o==-1?i.length:o,0,e,t),new Tn(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Tn.from(n),n.size?new Tn(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Tn.from(n),n.size?new Tn(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Tn.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Tn.from=function(n){if(n instanceof Tn)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Tn(e)};function Ox(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=Ox(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Dx(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),a=e.child(--o),l=s.nodeSize;if(s==a){t-=l,r-=l;continue}if(!s.sameMarkup(a))return{a:t,b:r};if(s.isText&&s.text!=a.text){let c=0,d=Math.min(s.text.length,a.text.length);for(;c<d&&s.text[s.text.length-c-1]==a.text[a.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(s.content.size||a.content.size){let c=Dx(s.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}class oe{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,o){for(let s=0,a=0;a<t;s++){let l=this.content[s],c=a+l.nodeSize;if(c>e&&r(l,i+a,o||null,s)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,t-d),r,i+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new oe(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-s),Math.min(a.text.length,t-s)):a=a.cut(Math.max(0,e-s-1),Math.min(a.content.size,t-s-1))),r.push(a),i+=a.nodeSize),s=l}return new oe(r,i)}cutByIndex(e,t){return e==t?oe.empty:e==0&&t==this.content.length?this:new oe(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new oe(i,o)}addToStart(e){return new oe([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new oe(this.content.concat(e),this.size+e.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 new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Ox(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Dx(this,e,t,r)}findIndex(e){if(e==0)return kd(0,e);if(e==this.size)return kd(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),o=r+i.nodeSize;if(o>=e)return o==e?kd(t+1,o):kd(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return oe.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new oe(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return oe.empty;let t,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(t||(t=e.slice(0,i)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new oe(t||e,r)}static from(e){if(!e)return oe.empty;if(e instanceof oe)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new oe([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}oe.empty=new oe([],0);const Kh={index:0,offset:0};function kd(n,e){return Kh.index=n,Kh.offset=e,Kh}function Eu(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Eu(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Eu(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Rt=class gm{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||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&&Eu(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 new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return gm.none;if(e instanceof gm)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Rt.none=[];class Au extends Error{}class pe{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Nx(this.content,e+this.openStart,t);return r&&new pe(r,this.openStart,this.openEnd)}removeBetween(e,t){return new pe(Rx(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return pe.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new pe(oe.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new pe(e,r,i)}}pe.empty=new pe(oe.empty,0,0);function Rx(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:a}=n.findIndex(t);if(i==e||o.isText){if(a!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Rx(o.content,e-i-1,t-i-1)))}function Nx(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let a=Nx(s.content,e-o-1,t,s);return a&&n.replaceChild(i,s.copy(a))}function u2(n,e,t){if(t.openStart>n.depth)throw new Au("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Au("Inconsistent open depths");return Ix(n,e,t,0)}function Ix(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let s=Ix(n,e,t,r+1);return o.copy(o.content.replaceChild(i,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,a=s.content;return Ts(s,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=f2(t,n);return Ts(o,Lx(n,s,a,e,r))}else return Ts(o,Mu(n,e,r))}function Px(n,e){if(!e.type.compatibleContent(n.type))throw new Au("Cannot join "+e.type.name+" onto "+n.type.name)}function vm(n,e,t){let r=n.node(t);return Px(r,e.node(t)),r}function Cs(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hl(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Cs(n.nodeAfter,r),o++));for(let a=o;a<s;a++)Cs(i.child(a),r);e&&e.depth==t&&e.textOffset&&Cs(e.nodeBefore,r)}function Ts(n,e){return n.type.checkContent(e),n.copy(e)}function Lx(n,e,t,r,i){let o=n.depth>i&&vm(n,e,i+1),s=r.depth>i&&vm(t,r,i+1),a=[];return Hl(null,n,i,a),o&&s&&e.index(i)==t.index(i)?(Px(o,s),Cs(Ts(o,Lx(n,e,t,r,i+1)),a)):(o&&Cs(Ts(o,Mu(n,e,i+1)),a),Hl(e,t,i,a),s&&Cs(Ts(s,Mu(t,r,i+1)),a)),Hl(r,null,i,a),new oe(a)}function Mu(n,e,t){let r=[];if(Hl(null,n,t,r),n.depth>t){let i=vm(n,e,t+1);Cs(Ts(i,Mu(n,e,t+1)),r)}return Hl(e,null,t,r),new oe(r)}function f2(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(oe.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class pc{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}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 r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Rt.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let a=r;r=i,i=a}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let 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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Ou(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:a,offset:l}=s.content.findIndex(o),c=o-l;if(r.push(s,a,i+l),!c||(s=s.child(a),s.isText))break;o=c-1,i+=l+1}return new pc(t,r,o)}static resolveCached(e,t){let r=mb.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==t)return s}else mb.set(e,r=new h2);let i=r.elts[r.i]=pc.resolve(e,t);return r.i=(r.i+1)%p2,i}}class h2{constructor(){this.elts=[],this.i=0}}const p2=12,mb=new WeakMap;class Ou{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const m2=Object.create(null);let zo=class ym{constructor(e,t,r,i=Rt.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||oe.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,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Eu(this.attrs,t||e.defaultAttrs||m2)&&Rt.sameSet(this.marks,r||Rt.none)}copy(e=null){return e==this.content?this:new ym(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ym(this.type,this.attrs,this.content,e)}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,r=!1){if(e==t)return pe.empty;let i=this.resolve(e),o=this.resolve(t),s=r?0:i.sharedDepth(t),a=i.start(s),c=i.node(s).content.cut(i.pos-a,o.pos-a);return new pe(c,i.depth-s,o.depth-s)}replace(e,t,r){return u2(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return pc.resolveCached(this,e)}resolveNoCache(e){return pc.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),zx(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=oe.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),a=s&&s.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=i;l<o;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Rt.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Rt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=oe.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};zo.prototype.text=void 0;class Du extends zo{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):zx(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(e){return e==this.marks?this:new Du(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Du(this.type,this.attrs,e,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 zx(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Ls{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new g2(e,t);if(r.next==null)return Ls.empty;let i=Fx(r);r.next&&r.err("Unexpected trailing text");let o=_2(k2(i));return S2(o,r),o}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,r=e.childCount){let i=this;for(let o=t;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type: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 r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function o(s,a){let l=s.matchFragment(e,r);if(l&&(!t||l.validEnd))return oe.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:u}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let h=o(u,a.concat(d));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let a=i;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(`
|
|
4
|
+
`)}}Ls.empty=new Ls(!0);class g2{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 new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Fx(n){let e=[];do e.push(v2(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function v2(n){let e=[];do e.push(y2(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function y2(n){let e=x2(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=b2(n,e);else break;return e}function gb(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function b2(n,e){let t=gb(n),r=t;return n.eat(",")&&(n.next!="}"?r=gb(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function w2(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function x2(n){if(n.eat("(")){let e=Fx(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=w2(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function k2(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,a,l){let c={term:l,to:a};return e[s].push(c),c}function i(s,a){s.forEach(l=>l.to=a)}function o(s,a){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(o(c,a)),[]);if(s.type=="seq")for(let l=0;;l++){let c=o(s.exprs[l],a);if(l==s.exprs.length-1)return c;i(c,a=t())}else if(s.type=="star"){let l=t();return r(a,l),i(o(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=t();return i(o(s.expr,a),l),i(o(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(a)].concat(o(s.expr,a));if(s.type=="range"){let l=a;for(let c=0;c<s.min;c++){let d=t();i(o(s.expr,l),d),l=d}if(s.max==-1)i(o(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let d=t();r(l,d),i(o(s.expr,l),d),l=d}return[r(l)]}else{if(s.type=="name")return[r(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Bx(n,e){return e-n}function vb(n,e){let t=[];return r(e),t.sort(Bx);function r(i){let o=n[i];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(i);for(let s=0;s<o.length;s++){let{term:a,to:l}=o[s];!a&&t.indexOf(l)==-1&&r(l)}}}function _2(n){let e=Object.create(null);return t(vb(n,0));function t(r){let i=[];r.forEach(s=>{n[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<i.length;d++)i[d][0]==a&&(c=i[d][1]);vb(n,l).forEach(d=>{c||i.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new Ls(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(Bx);o.next.push({type:i[s][0],next:e[a.join(",")]||t(a)})}return o}}function S2(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],o=!i.validEnd,s=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];s.push(l.name),o&&!(l.isText||l.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Hx(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Vx(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let o=n[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Ux(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let o=n[i];o.validate&&o.validate(e[i])}}function jx(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new T2(n,r,e[r]);return t}let yb=class Wx{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=jx(e,r.attrs),this.defaultAttrs=Hx(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ls.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:Vx(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new zo(this,this.computeAttrs(e),oe.from(t),Rt.setFrom(r))}createChecked(e=null,t,r){return t=oe.from(t),this.checkContent(t),new zo(this,this.computeAttrs(e),t,Rt.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=oe.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(oe.empty,!0);return o?new zo(this,e,t.append(o),Rt.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ux(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 r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Rt.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new Wx(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function C2(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class T2{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?C2(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Jf{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=jx(e,i.attrs),this.excluded=null;let o=Hx(this.attrs);this.instance=o?new Rt(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Rt(this,Vx(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new Jf(o,i++,t,s)),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){Ux(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let Kx=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Tn.from(e.nodes),t.marks=Tn.from(e.marks||{}),this.nodes=yb.compile(this.spec.nodes,this),this.marks=Jf.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",a=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=Ls.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=a=="_"?null:a?bb(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:bb(this,s.split(" "))}this.nodeFromJSON=i=>zo.fromJSON(this,i),this.markFromJSON=i=>Rt.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof yb){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Du(r,r.defaultAttrs,e,Rt.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 new RangeError("Unknown node type: "+e);return t}};function bb(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],o=n.marks[i],s=o;if(o)t.push(o);else for(let a in n.marks){let l=n.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&t.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function E2(n){return n.tag!=null}function A2(n){return n.style!=null}let Vl=class bm{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(E2(i))this.tags.push(i);else if(A2(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new xb(this,t,!1);return r.addAll(e,Rt.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new xb(this,t,!0);return r.addAll(e,Rt.none,t.from,t.to),pe.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(D2(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],a=s.style;if(!(a.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(s.getAttrs){let l=s.getAttrs(t);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<t.length;s++){let a=t[s];if((a.priority==null?50:a.priority)<o)break}t.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=kb(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=kb(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new bm(e,bm.schemaRules(e)))}};const qx={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},M2={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Jx={ol:!0,ul:!0},mc=1,wm=2,Ul=4;function wb(n,e,t){return e!=null?(e?mc:0)|(e==="full"?wm:0):n&&n.whitespace=="pre"?mc|wm:t&~Ul}class _d{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=Rt.none,this.match=o||(s&Ul?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(oe.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&mc)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=oe.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(oe.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&&!qx.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class xb{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=wb(null,t.preserveWhitespace,0)|(r?Ul:0);i?o=new _d(i.type,i.attrs,Rt.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new _d(null,null,Rt.none,!0,null,s):o=new _d(e.schema.topNodeType,null,Rt.none,!0,null,s),this.nodes=[o],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 r=e.nodeValue,i=this.top,o=i.options&wm?"full":this.localPreserveWS||(i.options&mc)>0,{schema:s}=this.parser;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
|
|
5
|
+
`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),t,!0),a[l]&&this.insertNode(s.text(a[l]),t,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),a;Jx.hasOwnProperty(s)&&this.parser.normalizeLists&&O2(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:M2.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(qx.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=l&&l.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(o),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
6
|
+
`),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 r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let a=void 0;;){let l=this.parser.matchStyle(o,s,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,r,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,t.attrs||null,r,t.preserveWhitespace);l&&(o=!0,r=l)}else{let l=this.parser.schema.marks[t.mark];r=r.concat(l.create(t.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}o&&this.sync(a)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];s!=a;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,r){let i,o;for(let s=this.open,a=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,o=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)t=this.enterInner(i[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=Rt.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):_b(a.type,e.type))&&(s=a.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,i)),o}enterInner(e,t,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let a=wb(e,o,s.options);s.options&Ul&&s.content.length==0&&(a|=Ul);let l=Rt.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):_b(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new _d(e,t,l,i,null,a)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=mc)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].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,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].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("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let d=l>0||l==0&&i?this.nodes[l].type:r&&l>=o?r.node(l-o).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function O2(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Jx.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function D2(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function kb(n){let e={};for(let t in n)e[t]=n[t];return e}function _b(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||o.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class Xs{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=qh(t).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let a=0,l=0;for(;a<o.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(o[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)i=o.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],d=this.serializeMark(c,s.isInline,t);d&&(o.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=tu(qh(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&tu(qh(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return tu(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Xs(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Sb(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Sb(e.marks)}}function Sb(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function qh(n){return n.document||window.document}const Cb=new WeakMap;function R2(n){let e=Cb.get(n);return e===void 0&&Cb.set(n,e=N2(n)),e}function N2(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function tu(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=R2(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let a,l=t?n.createElementNS(t,i):n.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?l.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):u=="style"&&l.style?l.style.cssText=c[u]:l.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:m}=tu(n,h,t,r);if(l.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const Zx=65535,Yx=Math.pow(2,16);function I2(n,e){return n+e*Yx}function Tb(n){return n&Zx}function P2(n){return(n-(n&Zx))/Yx}const Gx=1,Xx=2,nu=4,Qx=8;class xm{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Qx)>0}get deletedBefore(){return(this.delInfo&(Gx|nu))>0}get deletedAfter(){return(this.delInfo&(Xx|nu))>0}get deletedAcross(){return(this.delInfo&nu)>0}}class gr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&gr.empty)return gr.empty}recover(e){let t=0,r=Tb(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+P2(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+o],d=this.ranges[a+s],u=l+c;if(e<=u){let h=c?e==l?-1:e==u?1:t:t,p=l+i+(h<0?0:d);if(r)return p;let m=e==(t<0?l:u)?null:I2(a/3,e-l),v=e==l?Xx:e==u?Gx:nu;return(t<0?e!=l:e!=u)&&(v|=Qx),new xm(p,v,m)}i+=d-c}return r?e+i:new xm(e+i,0,null)}touches(e,t){let r=0,i=Tb(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+o],d=l+c;if(e<=d&&a==i*3)return!0;r+=this.ranges[a+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],a=s-(this.inverted?o:0),l=s+(this.inverted?0:o),c=this.ranges[i+t],d=this.ranges[i+r];e(a,a+c,l,l+d),o+=d-c}}invert(){return new gr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?gr.empty:new gr(e<0?[0,-e,0]:[0,0,e])}}gr.empty=new gr([]);class gc{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new gc(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i: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=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new gc;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],a=s.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new xm(e,i,null)}}const Jh=Object.create(null);class jn{getMap(){return gr.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Jh[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Jh)throw new RangeError("Duplicate use of step JSON ID "+e);return Jh[e]=t,t.prototype.jsonID=e,t}}class rn{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new rn(e,null)}static fail(e){return new rn(null,e)}static fromReplace(e,t,r,i){try{return rn.ok(e.replace(t,r,i))}catch(o){if(o instanceof Au)return rn.fail(o.message);throw o}}}function Yg(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(Yg(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return oe.fromArray(r)}class Oo extends jn{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new pe(Yg(t.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return rn.fromReplace(e,this.from,this.to,o)}invert(){return new xi(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Oo(t.pos,r.pos,this.mark)}merge(e){return e instanceof Oo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Oo(t.from,t.to,e.markFromJSON(t.mark))}}jn.jsonID("addMark",Oo);class xi extends jn{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new pe(Yg(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return rn.fromReplace(e,this.from,this.to,r)}invert(){return new Oo(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new xi(t.pos,r.pos,this.mark)}merge(e){return e instanceof xi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new xi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new xi(t.from,t.to,e.markFromJSON(t.mark))}}jn.jsonID("removeMark",xi);class Do extends jn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return rn.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return rn.fromReplace(e,this.pos,this.pos+1,new pe(oe.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Do(this.pos,t.marks[i]);return new Do(this.pos,this.mark)}}return new zs(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Do(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Do(t.pos,e.markFromJSON(t.mark))}}jn.jsonID("addNodeMark",Do);class zs extends jn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return rn.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return rn.fromReplace(e,this.pos,this.pos+1,new pe(oe.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Do(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new zs(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new zs(t.pos,e.markFromJSON(t.mark))}}jn.jsonID("removeNodeMark",zs);class yn extends jn{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&km(e,this.from,this.to)?rn.fail("Structure replace would overwrite content"):rn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new gr([this.from,this.to-this.from,this.slice.size])}invert(e){return new yn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new yn(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof yn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?pe.empty:new pe(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new yn(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?pe.empty:new pe(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new yn(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new yn(t.from,t.to,pe.fromJSON(e,t.slice),!!t.structure)}}jn.jsonID("replace",yn);class wn extends jn{constructor(e,t,r,i,o,s,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=a}apply(e){if(this.structure&&(km(e,this.from,this.gapFrom)||km(e,this.gapTo,this.to)))return rn.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return rn.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?rn.fromReplace(e,this.from,this.to,r):rn.fail("Content does not fit in gap")}getMap(){return new gr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new wn(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||o>r.pos?null:new wn(t.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new wn(t.from,t.to,t.gapFrom,t.gapTo,pe.fromJSON(e,t.slice),t.insert,!!t.structure)}}jn.jsonID("replaceAround",wn);function km(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function L2(n,e,t,r){let i=[],o=[],s,a;n.doc.nodesBetween(e,t,(l,c,d)=>{if(!l.isInline)return;let u=l.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+l.nodeSize,t),m=r.addToSet(u);for(let v=0;v<u.length;v++)u[v].isInSet(m)||(s&&s.to==h&&s.mark.eq(u[v])?s.to=p:i.push(s=new xi(h,p,u[v])));a&&a.to==h?a.to=p:o.push(a=new Oo(h,p,r))}}),i.forEach(l=>n.step(l)),o.forEach(l=>n.step(l))}function z2(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(r instanceof Jf){let c=s.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,t);for(let d=0;d<l.length;d++){let u=l[d],h;for(let p=0;p<i.length;p++){let m=i[p];m.step==o-1&&u.eq(i[p].style)&&(h=m)}h?(h.to=c,h.step=o):i.push({style:u,from:Math.max(a,e),to:c,step:o})}}}),i.forEach(s=>n.step(new xi(s.from,s.to,s.style)))}function Gg(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],a=e+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)s.push(new yn(a,d,pe.empty));else{r=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new xi(a,d,c.marks[h]));if(i&&c.isText&&t.whitespace!="pre"){let h,p=/\r?\n|\r/g,m;for(;h=p.exec(c.text);)m||(m=new pe(oe.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new yn(a+h.index,a+h.index+h[0].length,m))}}a=d}if(!r.validEnd){let l=r.fillBefore(oe.empty,!0);n.replace(a,a,new pe(l,0,0))}for(let l=s.length-1;l>=0;l--)n.step(s[l])}function F2(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ul(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,o=0;;--r){let s=n.$from.node(r),a=n.$from.index(r)+i,l=n.$to.indexAfter(r)-o;if(r<n.depth&&s.canReplace(a,l,t))return r;if(r==0||s.type.spec.isolating||!F2(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function B2(n,e,t){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),a=i.after(o+1),l=s,c=a,d=oe.empty,u=0;for(let m=o,v=!1;m>t;m--)v||r.index(m)>0?(v=!0,d=oe.from(r.node(m).copy(d)),u++):l--;let h=oe.empty,p=0;for(let m=o,v=!1;m>t;m--)v||i.after(m+1)<i.end(m)?(v=!0,h=oe.from(i.node(m).copy(h)),p++):c++;n.step(new wn(l,c,s,a,new pe(d.append(h),u,p),d.size-u,!0))}function Xg(n,e,t=null,r=n){let i=H2(n,e),o=i&&V2(r,e);return o?i.map(Eb).concat({type:e,attrs:t}).concat(o.map(Eb)):null}function Eb(n){return{type:n,attrs:null}}function H2(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(r,i,s)?o:null}function V2(n,e){let{parent:t,startIndex:r,endIndex:i}=n,o=t.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(t.child(c).type);return!l||!l.validEnd?null:s}function U2(n,e,t){let r=oe.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let a=t[s].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=oe.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new wn(i,o,i,o,new pe(r,0,0),t.length,!0))}function j2(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,a)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&W2(n.doc,n.mapping.slice(o).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?c=!1:!p&&m&&(c=!0)}c===!1&&ek(n,s,a,o),Gg(n,n.mapping.slice(o).map(a,1),r,void 0,c===null);let d=n.mapping.slice(o),u=d.map(a,1),h=d.map(a+s.nodeSize,1);return n.step(new wn(u,h,u+1,h-1,new pe(oe.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&$x(n,s,a,o),!1}})}function $x(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let l=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function ek(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(`
|
|
7
|
+
`))}})}function W2(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function K2(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new wn(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new pe(oe.from(s),0,0),1,!0))}function Qi(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=t-2;c>o;c--,d--){let u=i.node(c),h=i.index(c);if(u.type.spec.isolating)return!1;let p=u.content.cutByIndex(h,u.childCount),m=r&&r[d+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let v=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!v.type.validContent(p))return!1}let a=i.indexAfter(o),l=r&&r[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function q2(n,e,t=1,r){let i=n.doc.resolve(e),o=oe.empty,s=oe.empty;for(let a=i.depth,l=i.depth-t,c=t-1;a>l;a--,c--){o=oe.from(i.node(a).copy(o));let d=r&&r[c];s=oe.from(d?d.type.create(d.attrs,s):i.node(a).copy(s))}n.step(new yn(e,e,new pe(o.append(s),t,t),!0))}function Qo(n,e){let t=n.resolve(e),r=t.index();return tk(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function J2(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function tk(n,e){return!!(n&&e&&!n.isLeaf&&J2(n,e))}function Zf(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let o,s,a=r.index(i);if(i==r.depth?(o=r.nodeBefore,s=r.nodeAfter):t>0?(o=r.node(i+1),a++,s=r.node(i).maybeChild(a)):(o=r.node(i).maybeChild(a-1),s=r.node(i+1)),o&&!o.isTextblock&&tk(o,s)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function Z2(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,o=n.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(i);d&&!u?r=!1:!d&&u&&(r=!0)}let a=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);ek(n,d.node(),d.before(),a)}s.inlineContent&&Gg(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let l=n.mapping.slice(a),c=l.map(e-t);if(n.step(new yn(c,l.map(e+t,-1),pe.empty,!0)),r===!0){let d=n.doc.resolve(c);$x(n,d.node(),d.before(),n.steps.length)}return n}function Y2(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function nk(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=r.depth;s>=0;s--){let a=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.index(s)+(a>0?1:0),c=r.node(s),d=!1;if(o==1)d=c.canReplace(l,l,i);else{let u=c.contentMatchAt(l).findWrapping(i.firstChild.type);d=u&&c.canReplaceWith(l,l,u[0])}if(d)return a==0?r.pos:a<0?r.before(s+1):r.after(s+1)}return null}function Yf(n,e,t=e,r=pe.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return rk(i,o,r)?new yn(e,t,r):new G2(i,o,r).fit()}function rk(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class G2{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=oe.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=oe.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,a=i.depth;for(;s&&a&&o.childCount==1;)o=o.firstChild.content,s--,a--;let l=new pe(o,s,a);return e>-1?new wn(r.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||r.pos!=this.$to.pos?new yn(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Zh(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,u=null;if(t==1&&(s?c.matchType(s.type)||(u=c.fillBefore(oe.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:u};if(t==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:d};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Zh(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new pe(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Zh(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new pe(Nl(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new pe(Nl(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let v=0;v<o.length;v++)this.openFrontierNode(o[v]);let s=this.unplaced,a=r?r.content:s.content,l=s.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[t];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));u=u.matchFragment(i)}let p=a.size+e-(s.content.size-s.openEnd);for(;c<a.childCount;){let v=a.child(c),g=u.matchType(v.type);if(!g)break;c++,(c>1||l==0||v.content.size)&&(u=g,d.push(ik(v.mark(h.allowedMarks(v.marks)),c==1?l:0,c==a.childCount?p:-1)))}let m=c==a.childCount;m||(p=-1),this.placed=Il(this.placed,t,oe.from(d)),this.frontier[t].match=u,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,g=a;v<p;v++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=m?e==0?pe.empty:new pe(Nl(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new pe(Nl(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Yh(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:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Yh(e,t,i,r,o);if(s){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=Yh(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:o?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=Il(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Il(this.placed,this.depth,oe.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(oe.empty,!0);t.childCount&&(this.placed=Il(this.placed,this.frontier.length,t))}}function Nl(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Nl(n.firstChild.content,e-1,t)))}function Il(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Il(n.lastChild.content,e-1,t)))}function Zh(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function ik(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,ik(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(oe.empty,!0)))),n.copy(r)}function Yh(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!X2(t,o.content,s)?a:null}function X2(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Q2(n){return n.spec.defining||n.spec.definingForContent}function $2(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),o=n.doc.resolve(t);if(rk(i,o,r))return n.step(new yn(e,t,r));let s=sk(i,o);s[s.length-1]==0&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let h=i.depth,p=i.pos-1;h>0;h--,p--){let m=i.node(h).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;s.indexOf(h)>-1?a=h:i.before(h)==p&&s.splice(1,0,-h)}let l=s.indexOf(a),c=[],d=r.openStart;for(let h=r.content,p=0;;p++){let m=h.firstChild;if(c.push(m),p==r.openStart)break;h=m.content}for(let h=d-1;h>=0;h--){let p=c[h],m=Q2(p.type);if(m&&!p.sameMarkup(i.node(Math.abs(a)-1)))d=h;else if(m||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+d+1)%(r.openStart+1),m=c[p];if(m)for(let v=0;v<s.length;v++){let g=s[(v+l)%s.length],y=!0;g<0&&(y=!1,g=-g);let w=i.node(g-1),_=i.index(g-1);if(w.canReplaceWith(_,_,m.type,m.marks))return n.replace(i.before(g),y?o.after(g):t,new pe(ok(r.content,0,r.openStart,p),p,r.openEnd))}}let u=n.steps.length;for(let h=s.length-1;h>=0&&(n.replace(e,t,r),!(n.steps.length>u));h--){let p=s[h];p<0||(e=i.before(p),t=o.after(p))}}function ok(n,e,t,r,i){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(ok(o.content,e+1,t,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(oe.empty,!0))}return n}function eM(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Y2(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new pe(oe.from(r),0,0))}function tM(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=sk(r,i);for(let s=0;s<o.length;s++){let a=o[s],l=s==o.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),i.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return n.delete(r.before(a),i.after(a))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function sk(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(o<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class ba extends jn{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return rn.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return rn.fromReplace(e,this.pos,this.pos+1,new pe(oe.from(i),0,t.isLeaf?0:1))}getMap(){return gr.empty}invert(e){return new ba(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ba(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ba(t.pos,t.attr,t.value)}}jn.jsonID("attr",ba);class vc extends jn{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return rn.ok(r)}getMap(){return gr.empty}invert(e){return new vc(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new vc(t.attr,t.value)}}jn.jsonID("docAttr",vc);let Ga=class extends Error{};Ga=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Ga.prototype=Object.create(Error.prototype);Ga.prototype.constructor=Ga;Ga.prototype.name="TransformError";class Qg{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new gc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ga(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 r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,a,l)=>{e=Math.min(e,a),t=Math.max(t,l)})}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,r=pe.empty){let i=Yf(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new pe(oe.from(r),0,0))}delete(e,t){return this.replace(e,t,pe.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return $2(this,e,t,r),this}replaceRangeWith(e,t,r){return eM(this,e,t,r),this}deleteRange(e,t){return tM(this,e,t),this}lift(e,t){return B2(this,e,t),this}join(e,t=1){return Z2(this,e,t),this}wrap(e,t){return U2(this,e,t),this}setBlockType(e,t=e,r,i=null){return j2(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return K2(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new ba(e,t,r)),this}setDocAttribute(e,t){return this.step(new vc(e,t)),this}addNodeMark(e,t){return this.step(new Do(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Rt)t.isInSet(r.marks)&&this.step(new zs(e,t));else{let i=r.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new zs(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,t=1,r){return q2(this,e,t,r),this}addMark(e,t,r){return L2(this,e,t,r),this}removeMark(e,t,r){return z2(this,e,t,r),this}clearIncompatible(e,t,r){return Gg(this,e,t,r),this}}const Gh=Object.create(null);class We{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ak(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=pe.empty){let r=t.content.lastChild,i=null;for(let a=0;a<t.openEnd;a++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:l,$to:c}=s[a],d=e.mapping.slice(o);e.replaceRange(d.map(l.pos),d.map(c.pos),a?pe.empty:t),a==0&&Ob(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:a}=i[o],l=e.mapping.slice(r),c=l.map(s.pos),d=l.map(a.pos);o?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Ob(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new Ne(e):la(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?la(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):la(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new or(e.node(0))}static atStart(e){return la(e,e,0,0,1)||new or(e)}static atEnd(e){return la(e,e,e.content.size,e.childCount,-1)||new or(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Gh[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Gh)throw new RangeError("Duplicate use of selection JSON ID "+e);return Gh[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Ne.between(this.$anchor,this.$head).getBookmark()}}We.prototype.visible=!0;class ak{constructor(e,t){this.$from=e,this.$to=t}}let Ab=!1;function Mb(n){!Ab&&!n.parent.inlineContent&&(Ab=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class Ne extends We{constructor(e,t=e){Mb(e),Mb(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return We.near(r);let i=e.resolve(t.map(this.anchor));return new Ne(i.parent.inlineContent?i:r,r)}replace(e,t=pe.empty){if(super.replace(e,t),t==pe.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Ne&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gf(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ne(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=We.findFrom(t,r,!0)||We.findFrom(t,-r,!0);if(o)t=o.$head;else return We.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(We.findFrom(e,-r,!0)||We.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new Ne(e,t)}}We.jsonID("text",Ne);class Gf{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Gf(e.map(this.anchor),e.map(this.head))}resolve(e){return Ne.between(e.resolve(this.anchor),e.resolve(this.head))}}class Fe extends We{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return r?We.near(o):new Fe(o)}content(){return new pe(oe.from(this.node),0,0)}eq(e){return e instanceof Fe&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new $g(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Fe(e.resolve(t.anchor))}static create(e,t){return new Fe(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Fe.prototype.visible=!1;We.jsonID("node",Fe);class $g{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Gf(r,r):new $g(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&Fe.isSelectable(r)?new Fe(t):We.near(t)}}class or extends We{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=pe.empty){if(t==pe.empty){e.delete(0,e.doc.content.size);let r=We.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new or(e)}map(e){return new or(e)}eq(e){return e instanceof or}getBookmark(){return nM}}We.jsonID("all",or);const nM={map(){return this},resolve(n){return new or(n)}};function la(n,e,t,r,i,o=!1){if(e.inlineContent)return Ne.create(n,t);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&Fe.isSelectable(a))return Fe.create(n,t-(i<0?a.nodeSize:0))}else{let l=la(n,a,t+i,i<0?a.childCount:0,i,o);if(l)return l}t+=a.nodeSize*i}return null}function Ob(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof yn||i instanceof wn))return;let o=n.mapping.maps[r],s;o.forEach((a,l,c,d)=>{s==null&&(s=d)}),n.setSelection(We.near(n.doc.resolve(s),t))}const Db=1,Sd=2,Rb=4;let rM=class extends Qg{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Db)&~Sd,this.storedMarks=null,this}get selectionSet(){return(this.updated&Db)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Sd,this}ensureMarks(e){return Rt.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&Sd)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Sd,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Rt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(We.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|=Rb,this}get scrolledIntoView(){return(this.updated&Rb)>0}};function Nb(n,e){return!e||!n?n:n.bind(e)}class Pl{constructor(e,t,r){this.name=e,this.init=Nb(t.init,r),this.apply=Nb(t.apply,r)}}const iM=[new Pl("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Pl("selection",{init(n,e){return n.selection||We.atStart(e.doc)},apply(n){return n.selection}}),new Pl("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Pl("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Xh{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=iM.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Pl(r.key,r.spec.state,r))})}}class pa{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 r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let a=this.config.plugins[s];if(a.spec.appendTransaction){let l=i?i[s].n:0,c=i?i[s].state:this,d=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let u=0;u<this.config.plugins.length;u++)i.push(u<s?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),o=!0}i&&(i[s]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new pa(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new rM(this)}static create(e){let t=new Xh(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new pa(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Xh(this.schema,e.plugins),r=t.fields,i=new pa(t);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Xh(e.schema,e.plugins),o=new pa(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=zo.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=We.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){o[s.name]=c.fromJSON.call(l,e,t[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function lk(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=lk(i,e,{})),t[r]=i}return t}class Ct{constructor(e){this.spec=e,this.props={},e.props&&lk(e.props,this,this.props),this.key=e.key?e.key.key:ck("plugin")}getState(e){return e[this.key]}}const Qh=Object.create(null);function ck(n){return n in Qh?n+"$"+ ++Qh[n]:(Qh[n]=0,n+"$")}class At{constructor(e="key"){this.key=ck(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const _m=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"Ctrl+N",description:"New scratchpad"},{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+M",description:"Comment on selection (in editor)"},{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 Sm(n){const e=[];return n.state.doc.descendants((t,r)=>{t.type.name==="heading"&&t.attrs.level<=3&&e.push({text:t.textContent,level:t.attrs.level,pos:r})}),e}var oM=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>'),sM=E('<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>'),aM=E('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>'),lM=E('<span style="font-size: var(--tandem-text-sm);"> </span> <!>',1),cM=E(`<span style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="
|
|
8
|
+
font-size: var(--tandem-text-xs);
|
|
9
|
+
color: var(--tandem-fg-subtle);
|
|
10
|
+
font-family: var(--tandem-font-mono);
|
|
11
|
+
min-width: 20px;
|
|
12
|
+
"> </span> <span> </span></span>`),dM=E('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>'),uM=E('<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),fM=E('<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),hM=E('<li role="option"><!></li>'),pM=E(`<div role="presentation" style="
|
|
13
|
+
position: fixed; inset: 0;
|
|
14
|
+
background: rgba(0,0,0,0.4);
|
|
15
|
+
z-index: var(--tandem-z-overlay, 200);
|
|
16
|
+
display: flex; align-items: flex-start; justify-content: center;
|
|
17
|
+
padding-top: 15vh;
|
|
18
|
+
"><div data-testid="command-palette" role="dialog" tabindex="-1" aria-modal="true" aria-label="Command palette" style="
|
|
19
|
+
width: 560px; max-width: 90vw;
|
|
20
|
+
background: var(--tandem-surface);
|
|
21
|
+
border: 1px solid var(--tandem-border);
|
|
22
|
+
border-radius: var(--tandem-r-4);
|
|
23
|
+
box-shadow: var(--tandem-shadow-4);
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
display: flex; flex-direction: column;
|
|
26
|
+
"><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);"><input data-testid="palette-input" type="text" aria-label="Search commands" aria-controls="palette-results" style="
|
|
27
|
+
width: 100%; padding: 6px 0;
|
|
28
|
+
font-size: var(--tandem-text-md); color: var(--tandem-fg);
|
|
29
|
+
background: transparent; border: none; outline: none;
|
|
30
|
+
"/> <!></div> <ul id="palette-results" role="listbox" aria-label="Results" style="max-height: 400px; overflow-y: auto; padding: var(--tandem-space-1) 0; list-style: none; margin: 0;"><!></ul> <div style="
|
|
31
|
+
padding: var(--tandem-space-2) var(--tandem-space-4);
|
|
32
|
+
border-top: 1px solid var(--tandem-border);
|
|
33
|
+
display: flex; gap: var(--tandem-space-3);
|
|
34
|
+
font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);
|
|
35
|
+
"><span><kbd style="font-family: var(--tandem-font-mono);">#</kbd> headings</span> <span><kbd style="font-family: var(--tandem-font-mono);">@</kbd> annotations</span> <span><kbd style="font-family: var(--tandem-font-mono);">?</kbd> shortcuts</span> <span><kbd style="font-family: var(--tandem-font-mono);">></kbd> commands</span></div></div></div>`);function mM(n,e){Pe(e,!0);let t=st(e,"editor",3,null),r=st(e,"annotations",19,()=>[]),i=B(""),o=B(0),s=B(null);const a=["#","@","?",">"],l=F(()=>a.find(D=>f(i).startsWith(D))??null),c=F(()=>(f(l)?f(i).slice(1):f(i)).trim().toLowerCase()),d=F(()=>{var ee;if(f(l)!==null&&f(l)!==">")return[];const D=hc(),N=f(c),W=[];for(const z of D.values())(!N||z.label.toLowerCase().includes(N)||z.group.toLowerCase().includes(N)||(((ee=z.shortcut)==null?void 0:ee.toLowerCase().includes(N))??!1))&&W.push({kind:"action",id:z.id,action:z});return W}),u=F(()=>{if(f(l)!=="#")return[];const D=t();if(!D||D.isDestroyed)return[];const N=f(c);return Sm(D).filter(W=>!N||W.text.toLowerCase().includes(N)).map((W,ee)=>({kind:"heading",id:`heading-${ee}`,...W}))}),h=F(()=>{if(f(l)!=="@")return[];const D=f(c);return r().filter(N=>{var W;return D?N.content.toLowerCase().includes(D)||((W=N.textSnapshot)==null?void 0:W.toLowerCase().includes(D)):!0}).slice(0,50).map(N=>({kind:"annotation",id:`annotation-${N.id}`,label:N.content?N.content.slice(0,60):"(no content)",snippet:N.textSnapshot??"",annotationType:N.type}))}),p=F(()=>{if(f(l)!=="?")return[];const D=f(c),N=hc(),W=[];for(const ee of N.values())ee.shortcut&&(!D||ee.label.toLowerCase().includes(D)||ee.shortcut.toLowerCase().includes(D))&&W.push({kind:"shortcut",id:`shortcut-registry-${ee.id}`,keys:ee.shortcut,description:ee.label,group:ee.group});for(let ee=0;ee<_m.length;ee++){const z=_m[ee];(!D||z.description.toLowerCase().includes(D)||z.keys.toLowerCase().includes(D))&&W.push({kind:"shortcut",id:`shortcut-static-${ee}`,keys:z.keys,description:z.description,group:"other"})}return W}),m=F(()=>[...f(d),...f(u),...f(h),...f(p)]);le(()=>{f(m),b(o,0)}),le(()=>{e.open&&(b(i,""),b(o,0),Promise.resolve().then(()=>{var D;return(D=f(s))==null?void 0:D.focus()}))});const v={"#":"Search headings…","@":"Search annotations…","?":"Search shortcuts…",">":"Search commands…"},g=F(()=>f(l)?v[f(l)]:"Type a command, # headings, @ annotations, ? shortcuts…");function y(){e.onClose()}function w(D){var N;if(D.kind==="action")y(),D.action.run();else if(D.kind==="heading"){y();const W=t();if(!W||W.isDestroyed)return;const ee=D.pos;try{const z=W.state.doc.resolve(ee+1),Y=Ne.near(z);W.view.dispatch(W.state.tr.setSelection(Y).scrollIntoView()),W.view.focus()}catch{}}else D.kind==="annotation"&&(y(),(N=e.onFocusAnnotation)==null||N.call(e,D.id.replace("annotation-","")))}function _(D){const N=f(m).length;if(D.key==="ArrowDown")D.preventDefault(),b(o,(f(o)+1)%Math.max(1,N));else if(D.key==="ArrowUp")D.preventDefault(),b(o,(f(o)-1+Math.max(1,N))%Math.max(1,N));else if(D.key==="Enter"){D.preventDefault();const W=f(m)[f(o)];W&&w(W)}else D.key==="Escape"&&(D.preventDefault(),y())}function C(D){D.target===D.currentTarget&&y()}var A=xt(),j=ye(A);{var H=D=>{var N=pM(),W=x(N),ee=x(W),z=x(ee);gt(z,O=>b(s,O),()=>f(s));var Y=k(z,2);{var te=O=>{var I=oM(),T=x(I);{var R=ie=>{var de=nn("Searching document headings");S(ie,de)};Z(T,ie=>{f(l)==="#"&&ie(R)})}var V=k(T,2);{var se=ie=>{var de=nn("Searching annotations");S(ie,de)};Z(V,ie=>{f(l)==="@"&&ie(se)})}var he=k(V,2);{var we=ie=>{var de=nn("Showing keyboard shortcuts");S(ie,de)};Z(he,ie=>{f(l)==="?"&&ie(we)})}var ae=k(he,2);{var Q=ie=>{var de=nn("Filtering commands");S(ie,de)};Z(ae,ie=>{f(l)===">"&&ie(Q)})}S(O,I)};Z(Y,O=>{f(l)&&O(te)})}var ne=k(ee,2),q=x(ne);{var P=O=>{var I=sM(),T=x(I);K(()=>$(T,f(l)==="#"?"No headings found":f(l)==="@"?"No annotations found":f(l)==="?"?"No shortcuts found":"No commands match")),S(O,I)},M=O=>{var I=xt(),T=ye(I);dt(T,19,()=>f(m),R=>R.id,(R,V,se)=>{const he=F(()=>f(se)===f(o));var we=hM(),ae=x(we);{var Q=_e=>{var Oe=lM(),Re=ye(Oe),tt=x(Re),Ve=k(Re,2);{var ce=Ie=>{var ge=aM(),ze=x(ge);K(()=>$(ze,f(V).action.shortcut)),S(Ie,ge)};Z(Ve,Ie=>{f(V).action.shortcut&&Ie(ce)})}K(()=>$(tt,f(V).action.label)),S(_e,Oe)},ie=_e=>{var Oe=cM(),Re=x(Oe),tt=x(Re),Ve=k(Re,2),ce=x(Ve);K(()=>{$(tt,`H${f(V).level??""}`),re(Ve,`font-size: var(--tandem-text-sm); padding-left: calc(${f(V).level-1} * var(--tandem-space-2));`),$(ce,f(V).text)}),S(_e,Oe)},de=_e=>{var Oe=uM(),Re=ye(Oe),tt=x(Re),Ve=x(tt),ce=k(tt,2);{var Ie=Ae=>{var be=dM(),nt=x(be);K(()=>$(nt,`"${f(V).snippet??""}"`)),S(Ae,be)};Z(ce,Ae=>{f(V).snippet&&Ae(Ie)})}var ge=k(Re,2),ze=x(ge);K(Ae=>{$(Ve,f(V).label),$(ze,Ae)},[()=>f(V).annotationType.charAt(0).toUpperCase()+f(V).annotationType.slice(1)]),S(_e,Oe)},Ce=_e=>{var Oe=fM(),Re=ye(Oe),tt=x(Re),Ve=k(Re,2),ce=x(Ve);K(()=>{$(tt,f(V).description),$(ce,f(V).keys)}),S(_e,Oe)};Z(ae,_e=>{f(V).kind==="action"?_e(Q):f(V).kind==="heading"?_e(ie,1):f(V).kind==="annotation"?_e(de,2):f(V).kind==="shortcut"&&_e(Ce,3)})}K(()=>{G(we,"id",`palette-item-${f(V).id}`),G(we,"data-testid",`palette-item-${f(V).id}`),G(we,"aria-selected",f(he)),re(we,`
|
|
36
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
37
|
+
padding: 8px var(--tandem-space-4);
|
|
38
|
+
cursor: ${f(V).kind==="shortcut"?"default":"pointer"};
|
|
39
|
+
background: ${f(he)?"var(--tandem-accent-bg)":"transparent"};
|
|
40
|
+
color: ${f(he)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg)"};
|
|
41
|
+
`)}),L("click",we,()=>w(f(V))),Et("mouseenter",we,()=>b(o,f(se),!0)),S(R,we)}),S(O,I)};Z(q,O=>{f(m).length===0?O(P):O(M,-1)})}K(()=>{G(z,"placeholder",f(g)),G(z,"aria-activedescendant",f(m)[f(o)]?`palette-item-${f(m)[f(o)].id}`:void 0)}),L("click",N,C),L("keydown",N,O=>{O.key==="Escape"&&y()}),L("keydown",W,_),Uo(z,()=>f(i),O=>b(i,O)),S(D,N)};Z(j,D=>{e.open&&D(H)})}S(n,A),Le()}qe(["click","keydown"]);var gM=E('<div class="tandem-banner tandem-banner--info" 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">Connection to the Tandem server has been lost. Ensure the server is 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 vM(n,e){var t=gM(),r=k(x(t),4),i=k(r,2);L("click",r,function(...o){var s;(s=e.onRetry)==null||s.apply(this,o)}),L("click",i,function(...o){var s;(s=e.onDismiss)==null||s.apply(this,o)}),S(n,t)}qe(["click"]);function Yj(n){return n?n.osSupported?n.coworkDetected?"normal":"undetected":"unsupported":"loading"}function yM(n){switch(n.kind){case"adminDeclined":return"Admin permission was denied. Retry with admin, or disable Cowork integration.";case"netshNotFound":return"Windows Firewall command (netsh) was not found on PATH. Confirm your Windows install is intact.";case"netshFailure":return`Windows Firewall command failed (exit ${n.exitCode}). Details: ${bM(n.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 (${n.kind}). Please restart Tandem.`}}function bM(n){const e=n.trim();return e.length===0?"(no output)":e.length<=200?e:`${e.slice(0,197)}...`}function dk(n){try{const e=JSON.parse(n);if(typeof e=="object"&&e!==null&&"kind"in e&&typeof e.kind=="string")try{return yM(e)}catch(t){return console.error("[cowork] firewallErrorHint failed for:",e,t),n}return n}catch{return n}}function Gj(n){switch(n){case"ok":return"Installed";case"alreadyPresent":return"Already installed";case"locked":return"Locked (retrying)";case"schemaDrift":return"Schema drift";case"insecureAcl":return"Insecure ACL";case"failed":return"Failed"}}function Xj(n){switch(n){case"ok":case"alreadyPresent":return"success";case"locked":return"warning";case"schemaDrift":case"insecureAcl":case"failed":return"error"}}function Qj(n){const e=["failed","schemaDrift","insecureAcl","locked","alreadyPresent","ok"],t=[n.installedPlugins,n.knownMarketplaces,n.coworkSettings];for(const r of e)if(t.includes(r))return r;return"ok"}function uk(n,e){return!(!n||e||!n.osSupported||!n.coworkDetected||n.enabled)}function fk(){try{return localStorage.getItem(Ex)==="true"}catch{return!1}}function wM(){try{localStorage.setItem(Ex,"true")}catch{}}function Nn(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}function $j(n){let e=null;return{schedule(t){e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,t()},n)},cancel(){e!==null&&(clearTimeout(e),e=null)}}}const hk="Tauri runtime not available";async function ev(){try{return(await Wr(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(n){return Nn()&&console.error("[cowork] Failed to load @tauri-apps/api/core:",n),(()=>Promise.reject(new Error(hk)))}}function xM(n){return n("cowork_get_status")}function pk(n,e){return n("cowork_toggle_integration",{enabled:e})}function eW(n){return n("cowork_rescan")}function tW(n,e){return n("cowork_set_lan_ip_override",{enabled:e})}function kM(n){return n("cowork_retry_admin_elevation")}function mk(n){let e=B(null),t=B(!1),r=B(null),i=null,o=!1,s=!0,a=null;ri(()=>{s=!1,a!==null&&(clearInterval(a),a=null)});const l=async()=>{if(o){s&&b(t,!1);return}const c=i;if(c)try{const d=await xM(c);if(!s)return;b(e,d,!0),b(r,null)}catch(d){if(!s)return;const u=d instanceof Error?d.message:String(d);if(u===hk){o=!0,a!==null&&(clearInterval(a),a=null),b(t,!1);return}b(r,u,!0)}finally{s&&b(t,!1)}};return le(()=>{if(!n()){b(t,!1);return}let d=!1;return ev().then(u=>{if(!d)return i=u,b(t,!0),l()}).catch(u=>{if(d)return;const h=u instanceof Error?u.message:String(u);b(r,h,!0),b(t,!1)}),a=setInterval(()=>{d||o||l()},i2),()=>{d=!0,a!==null&&(clearInterval(a),a=null)}}),{get status(){return f(e)},get loading(){return f(t)},get error(){return f(r)},refetch:l}}var _M=E(`<div data-testid="cowork-admin-declined-status-error" role="alert" style="position: fixed; bottom: 16px; right: 16px; z-index: 10000; max-width: 400px; border: 1px solid var(--tandem-error-border); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); border-radius: var(--tandem-r-3); padding: 10px 14px; font-size: 12px; line-height: 1.5;">Cowork status check failed: unable to determine if admin elevation was declined. Please
|
|
42
|
+
restart Tandem to restore normal operation.</div>`),SM=E('<div data-testid="cowork-admin-declined-error" role="alert" style="font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); padding: 6px 8px;"> </div>'),CM=E('<div data-testid="cowork-admin-declined-confirm-disable" style="font-size: 12px; color: var(--tandem-warning-fg-strong); background: var(--tandem-warning-bg); border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-2); padding: 8px 10px;"><div style="font-weight: 600; margin-bottom: 6px;">Disable Cowork integration?</div> <div style="margin-bottom: 8px;">The deny rule will remain in place. You can re-enable Cowork later from Settings.</div> <div style="display: flex; gap: 8px;"><button data-testid="cowork-admin-declined-disable-confirm-btn" type="button" style="padding: 4px 10px; font-size: 12px; border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); background: var(--tandem-error); color: var(--tandem-error-fg); cursor: pointer; font-weight: 600;">Disable</button> <button data-testid="cowork-admin-declined-disable-cancel-btn" type="button" style="padding: 4px 10px; font-size: 12px; 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></div></div>'),TM=E('<div style="display: flex; gap: 8px; justify-content: flex-end;"><button data-testid="cowork-admin-declined-disable-btn" type="button" style="padding: 6px 12px; font-size: 13px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Disable Cowork</button> <button data-testid="cowork-admin-declined-retry-btn" type="button" style="padding: 6px 12px; font-size: 13px; border: 1px solid var(--tandem-accent); border-radius: var(--tandem-r-2); background: var(--tandem-accent); color: var(--tandem-accent-fg); cursor: pointer; font-weight: 600;">Retry with admin</button></div>'),EM=E(`<div data-testid="cowork-admin-declined-backdrop" style="position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 10000; display: flex; align-items: center; justify-content: center;"><div data-testid="cowork-admin-declined-modal" role="dialog" aria-modal="true" aria-labelledby="cowork-admin-declined-heading" style="width: 440px; max-width: calc(100vw - 32px); background: var(--tandem-surface); color: var(--tandem-fg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-4); padding: 20px; box-shadow: var(--tandem-shadow-3); outline: none; display: flex; flex-direction: column; gap: 12px;"><h2 id="cowork-admin-declined-heading" style="margin: 0; font-size: 16px; font-weight: 600; color: var(--tandem-error-fg-strong);">Admin permission required</h2> <div style="font-size: 13px; line-height: 1.5; color: var(--tandem-fg-muted);">Cowork integration requires Windows admin permission to configure firewall rules. Without
|
|
43
|
+
it, Tandem can't safely be reached from inside the Cowork VM. Port 3479 is currently
|
|
44
|
+
blocked by a deny rule to protect your machine.</div> <!> <!></div></div>`);function AM(n,e){Pe(e,!0);const t='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',r=mk(()=>!0),i=F(()=>{var g;return((g=r.status)==null?void 0:g.uacDeclined)===!0});let o=B(void 0),s=B(!1),a=B(!1),l=B(null);le(()=>{if(!f(i))return;const g=typeof document<"u"?document.title:null;return typeof document<"u"&&!document.title.startsWith("⚠")&&(document.title=`⚠ ${document.title}`),()=>{typeof document<"u"&&g!==null&&(document.title=g)}}),le(()=>{if(!f(i))return;const g=y=>{if(y.key!=="Tab"||!f(o))return;const w=f(o).querySelectorAll(t);if(w.length===0)return;const _=w[0],C=w[w.length-1],A=document.activeElement;if(!f(o).contains(A)){y.preventDefault(),_.focus();return}y.shiftKey&&A===_?(y.preventDefault(),C.focus()):!y.shiftKey&&A===C&&(y.preventDefault(),_.focus())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)}),le(()=>{var g;f(i)&&((g=f(o))==null||g.focus())});async function c(g,y){b(a,!0),b(l,null);try{const w=await ev();await g(w)}catch(w){const _=w instanceof Error?w.message:String(w),C=dk(_);b(l,`${y}: ${C}`)}finally{b(a,!1)}}async function d(){await c(async g=>{await kM(g),await r.refetch()},"Retry failed")}async function u(){await c(async g=>{await pk(g,!1),await r.refetch()},"Failed to disable Cowork"),b(s,!1)}var h=xt(),p=ye(h);{var m=g=>{var y=_M();S(g,y)},v=g=>{var y=EM(),w=x(y);G(w,"tabindex",-1);var _=k(x(w),4);{var C=D=>{var N=SM(),W=x(N);K(()=>$(W,f(l))),S(D,N)};Z(_,D=>{f(l)&&D(C)})}var A=k(_,2);{var j=D=>{var N=CM(),W=k(x(N),4),ee=x(W),z=k(ee,2);K(()=>{ee.disabled=f(a),z.disabled=f(a)}),L("click",ee,()=>void u()),L("click",z,()=>{b(s,!1)}),S(D,N)},H=D=>{var N=TM(),W=x(N),ee=k(W,2);K(()=>{W.disabled=f(a),ee.disabled=f(a)}),L("click",W,()=>{b(s,!0)}),L("click",ee,()=>void d()),S(D,N)};Z(A,D=>{f(s)?D(j):D(H,-1)})}gt(w,D=>b(o,D),()=>f(o)),S(g,y)};Z(p,g=>{r.error&&!r.status?g(m):f(i)&&g(v,1)})}S(n,h),Le()}qe(["click"]);var MM=E("<span>Cannot reach the Tandem server. Is it running?</span>"),OM=E('<span style="font-family: var(--tandem-font-sans); font-size: 13px; color: var(--tandem-fg-subtle);">Tip: open Claude Code in this directory to start collaborating</span>'),DM=E("<span>No document open. Click + in the tab bar or drop a file here.</span> <!>",1),RM=E('<div style="display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 360px; color: var(--tandem-fg-subtle); gap: 10px; font-family: var(--tandem-font-serif); font-size: 17px; line-height: 1.55; text-align: center;"><!></div>');function NM(n,e){Pe(e,!0);let t=B(!1);le(()=>{if(e.connected){b(t,!1);return}const a=setTimeout(()=>{b(t,!0)},YA);return()=>clearTimeout(a)});var r=RM(),i=x(r);{var o=a=>{var l=MM();S(a,l)},s=a=>{var l=DM(),c=k(ye(l),2);{var d=u=>{var h=OM();S(u,h)};Z(c,u=>{e.connected&&!e.claudeActive&&u(d)})}S(a,l)};Z(i,a=>{f(t)?a(o):a(s,-1)})}S(n,r),Le()}function tv(n,e,t=n2){const r=n.filter(i=>i!==e);return[e,...r].slice(0,t)}function nv(){try{const n=localStorage.getItem(Kg);if(!n)return[];const e=JSON.parse(n);return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}catch(n){return console.warn("[tandem] failed to load recent files:",n),[]}}function rv(n){try{localStorage.setItem(Kg,JSON.stringify(n)),gk()}catch(e){console.warn("[tandem] failed to save recent files:",e)}}function IM(){try{localStorage.removeItem(Kg),gk()}catch(n){console.warn("[tandem] failed to clear recent files:",n)}}const PM=3e4;let Ll=null;function Ib(){const n=Date.now();if(Ll&&n-Ll.ts<PM)return Ll.files;const e=nv();return Ll={files:e,ts:n},e}function gk(){Ll=null}var LM=E('<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>'),zM=E('<div data-testid="recent-files-list" style="margin-top: 14px;"><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 style="max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div></div>'),FM=E('<div><input type="text" placeholder="Paste absolute file path..." style="width: 100%; padding: 8px 10px; font-size: 13px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); box-sizing: border-box; background: var(--tandem-surface); color: var(--tandem-fg);" data-testid="file-path-input"/> <button data-testid="file-open-submit"> </button> <!></div>'),BM=E('<div role="button" data-testid="file-upload-zone"><input type="file" accept=".md,.txt,.html,.htm,.docx" style="display: none;"/> <div style="font-size: 13px; color: var(--tandem-fg-muted);"> </div> <div style="font-size: 11px; color: var(--tandem-fg-subtle); margin-top: 6px;">.md, .txt, .html, .docx</div></div>'),HM=E('<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>'),VM=E('<div role="dialog" aria-modal="true" aria-label="Open File" style="position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; background: rgba(0,0,0,0.3);"><div style="background: var(--tandem-surface); border-radius: var(--tandem-r-4); 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 style="background: none; border: none; cursor: pointer; font-size: 16px; color: var(--tandem-fg-subtle);">×</button></div> <div style="display: flex; gap: 8px; margin-bottom: 16px;"><button>File Path</button> <button>Open</button></div> <!> <!></div></div>');function UM(n,e){Pe(e,!0);let t=B("upload"),r=B(""),i=B(null),o=B(!1),s=B(!1),a=B(void 0),l=B(at(nv()));function c(z){b(l,(()=>{const Y=tv(f(l),z);return rv(Y),Y})(),!0)}function d(){IM(),b(l,[],!0)}async function u(z){if(!f(o)){b(i,null),b(o,!0);try{const Y=await fetch(`${Gn}${dl}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:z})}),te=await Y.json();if(!Y.ok){b(i,te.message??"Failed to open file",!0);return}c(z),e.onClose()}catch(Y){console.error("FileOpenDialog: path open failed",Y),Y instanceof SyntaxError?b(i,"Server returned an unexpected response"):Y instanceof TypeError?b(i,"Unexpected response format"):b(i,"Cannot reach server. Is it running?")}finally{b(o,!1)}}}function h(){f(r).trim()&&u(f(r).trim())}async function p(z){if(!f(o)){b(i,null),b(o,!0);try{const Y=await Ax(z),te=await fetch(`${Gn}${dx}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:z.name,content:Y})}),ne=await te.json();if(!te.ok){b(i,ne.message??"Failed to open file",!0);return}e.onClose()}catch(Y){console.error("FileOpenDialog: upload failed",Y),Y instanceof SyntaxError?b(i,"Server returned an unexpected response"):Y instanceof TypeError?b(i,"Unexpected response format"):b(i,"Cannot reach server. Is it running?")}finally{b(o,!1)}}}function m(z){var te;z.preventDefault(),b(s,!1);const Y=(te=z.dataTransfer)==null?void 0:te.files[0];Y&&p(Y)}function v(z){var ne;const te=(ne=z.target.files)==null?void 0:ne[0];te&&p(te)}var g=VM();G(g,"tabindex",-1);var y=x(g),w=x(y),_=k(x(w),2),C=k(w,2),A=x(C),j=k(A,2),H=k(C,2);{var D=z=>{var Y=FM(),te=x(Y);xE(te);var ne=k(te,2),q=x(ne),P=k(ne,2);{var M=O=>{var I=zM(),T=x(I),R=k(x(T),2),V=k(T,2);dt(V,22,()=>f(l),se=>se,(se,he,we)=>{const ae=F(()=>he.split(/[/\\]/)),Q=F(()=>f(ae).at(-1)??he),ie=F(()=>f(ae).slice(0,-1).join("/")||"/");var de=LM(),Ce=x(de),_e=x(Ce),Oe=k(Ce,2),Re=x(Oe);K(()=>{G(de,"data-testid",`recent-file-${f(we)}`),$(_e,f(Q)),$(Re,f(ie))}),L("click",de,()=>{b(r,he,!0),u(he)}),Et("mouseenter",de,tt=>{tt.currentTarget.style.background="var(--tandem-surface-muted)"}),Et("mouseleave",de,tt=>{tt.currentTarget.style.background="transparent"}),S(se,de)}),L("click",R,d),S(O,I)};Z(P,O=>{f(l).length>0&&O(M)})}K((O,I)=>{ne.disabled=O,re(ne,I),$(q,f(o)?"Opening...":"Open")},[()=>f(o)||!f(r).trim(),()=>`margin-top: 10px; width: 100%; padding: 8px; font-size: 13px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: ${f(o)?"wait":"pointer"}; background: ${f(o)?"var(--tandem-fg-subtle)":"var(--tandem-accent)"}; color: var(--tandem-accent-fg); opacity: ${f(r).trim()?1:.5};`]),L("keydown",te,O=>{O.key==="Enter"&&h()}),Uo(te,()=>f(r),O=>b(r,O)),L("click",ne,h),S(z,Y)},N=z=>{var Y=BM();G(Y,"tabindex",0);var te=x(Y);gt(te,P=>b(a,P),()=>f(a));var ne=k(te,2),q=x(ne);K(()=>{re(Y,`border: 2px dashed ${f(s)?"var(--tandem-accent)":"var(--tandem-border-strong)"}; border-radius: var(--tandem-r-3); padding: 32px 16px; text-align: center; cursor: ${f(o)?"wait":"pointer"}; background: ${f(s)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; transition: border-color 0.15s, background 0.15s;`),$(q,f(o)?"Opening...":"Drop a file here or click to browse")}),Et("dragover",Y,P=>{P.preventDefault(),b(s,!0)}),Et("dragleave",Y,()=>b(s,!1)),Et("drop",Y,m),L("click",Y,()=>{var P;return(P=f(a))==null?void 0:P.click()}),L("keydown",Y,P=>{var M;(P.key==="Enter"||P.key===" ")&&((M=f(a))==null||M.click())}),L("change",te,v),S(z,Y)};Z(H,z=>{f(t)==="path"?z(D):z(N,-1)})}var W=k(H,2);{var ee=z=>{var Y=HM(),te=x(Y);K(()=>$(te,f(i))),S(z,Y)};Z(W,z=>{f(i)&&z(ee)})}K(()=>{re(A,`flex: 1; padding: 6px; font-size: 13px; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); cursor: pointer; background: ${f(t)==="path"?"var(--tandem-accent)":"var(--tandem-surface)"}; color: ${f(t)==="path"?"var(--tandem-accent-fg)":"var(--tandem-fg)"};`),re(j,`flex: 1; padding: 6px; font-size: 13px; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); cursor: pointer; background: ${f(t)==="upload"?"var(--tandem-accent)":"var(--tandem-surface)"}; color: ${f(t)==="upload"?"var(--tandem-accent-fg)":"var(--tandem-fg)"};`)}),L("click",g,z=>{z.target===z.currentTarget&&e.onClose()}),L("keydown",g,z=>{z.key==="Escape"&&e.onClose()}),L("click",_,function(...z){var Y;(Y=e.onClose)==null||Y.apply(this,z)}),L("click",A,()=>b(t,"path")),L("click",j,()=>b(t,"upload")),S(n,g),Le()}qe(["click","keydown","change"]);var jM=E('<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),WM=E('<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>'),KM=E('<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),qM=E(`<div role="presentation" style="position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: 1000;" data-testid="help-modal"><div role="dialog" aria-modal="true" aria-label="Keyboard Shortcuts" tabindex="-1" style="background-color: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-4); 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" aria-label="Close help" data-testid="help-modal-close" style="background: none; border: none; cursor: pointer; font-size: 18px; color: var(--tandem-fg-muted); line-height: 1; padding: 2px 6px; border-radius: var(--tandem-r-2);">✕</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>,
|
|
45
|
+
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 JM(n,e){Pe(e,!0);const t=F(()=>{const l=hc(),c=new Map;for(const d of l.values()){if(!d.shortcut)continue;const u=c.get(d.group)??[];u.push({keys:d.shortcut,description:d.label}),c.set(d.group,u)}return Jg.map(d=>({title:d.charAt(0).toUpperCase()+d.slice(1),rows:c.get(d)??[]})).filter(d=>d.rows.length>0)});let r=B(null),i=null;le(()=>{if(!e.open)return;const l=Dt(()=>f(r));if(!l)return;i=document.activeElement,l.focus();const c=d=>{l&&!l.contains(d.target)&&l.focus()};return document.addEventListener("focusin",c),()=>{document.removeEventListener("focusin",c),i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),le(()=>{if(!e.open)return;const l=c=>{c.key==="Escape"&&e.onClose()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)});var o=xt(),s=ye(o);{var a=l=>{var c=qM(),d=x(c),u=x(d),h=k(x(u),2),p=k(u,2);dt(p,17,()=>f(t),g=>g.title,(g,y)=>{var w=WM(),_=x(w),C=x(_),A=k(_,2);dt(A,21,()=>f(y).rows,j=>j.description,(j,H)=>{var D=jM(),N=ye(D),W=x(N),ee=x(W),z=k(N,2),Y=x(z);K(()=>{$(ee,f(H).keys),$(Y,f(H).description)}),S(j,D)}),K(()=>$(C,f(y).title)),S(g,w)});var m=k(p,2),v=k(x(m),2);dt(v,21,()=>_m,g=>g.description,(g,y)=>{var w=KM(),_=ye(w),C=x(_),A=x(C),j=k(_,2),H=x(j);K(()=>{$(A,f(y).keys),$(H,f(y).description)}),S(g,w)}),gt(d,g=>b(r,g),()=>f(r)),L("click",c,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),L("click",d,g=>g.stopPropagation()),L("keydown",d,g=>{if(g.key==="Escape"){e.onClose();return}if(g.stopPropagation(),g.key==="Tab"&&f(r)){const y=Array.from(f(r).querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(C=>!C.closest("[hidden]"));if(y.length===0){g.preventDefault();return}const w=y[0],_=y[y.length-1];g.shiftKey&&document.activeElement===w?(g.preventDefault(),_.focus()):!g.shiftKey&&document.activeElement===_&&(g.preventDefault(),w.focus())}}),L("click",h,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),S(l,c)};Z(s,l=>{e.open&&l(a)})}S(n,o),Le()}qe(["click","keydown"]);var ZM=E("Detected VM subnet: <code> </code>.",1),YM=E('<div data-testid="cowork-onboarding-error" role="alert" style="font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); padding: 6px 8px;"> </div>'),GM=E('<div data-testid="cowork-onboarding-confirm" style="font-size: 12px; color: var(--tandem-warning-fg-strong); background: var(--tandem-warning-bg); border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-2); padding: 8px 10px;"><div style="font-weight: 600; margin-bottom: 6px;">Confirm: Enable Cowork</div> <div style="margin-bottom: 8px;">Windows will prompt for admin permission to modify firewall rules. This is expected.</div> <div style="display: flex; gap: 8px;"><button data-testid="cowork-onboarding-enable-confirm-btn" type="button">Enable</button> <button data-testid="cowork-onboarding-enable-cancel-btn" type="button">Cancel</button></div></div>'),XM=E('<button data-testid="cowork-onboarding-learn-more-btn" type="button">Learn more</button>'),QM=E('<a data-testid="cowork-onboarding-learn-more-link" target="_blank" rel="noreferrer" style="font-size: 12px; color: var(--tandem-accent); align-self: center; text-decoration: underline;">Learn more</a>'),$M=E('<div style="display: flex; gap: 8px; flex-wrap: wrap;"><button data-testid="cowork-onboarding-enable-btn" type="button">Enable</button> <button data-testid="cowork-onboarding-skip-btn" type="button">Skip</button> <!></div>'),eO=E('<div data-testid="cowork-onboarding-step" style="display: flex; flex-direction: column; gap: 8px;"><div style="font-size: 14px; font-weight: 600; color: var(--tandem-fg);">Claude Desktop Cowork detected</div> <div style="font-size: 13px; line-height: 1.5; color: var(--tandem-fg-muted);">Enable Tandem inside Cowork workspaces? <!></div> <!> <!></div>');function tO(n,e){Pe(e,!0);const t="padding: 4px 10px; font-size: 12px; border: 1px solid var(--tandem-accent); border-radius: var(--tandem-r-2); background: var(--tandem-accent); color: var(--tandem-accent-fg); cursor: pointer; font-weight: 600;",r="padding: 4px 10px; font-size: 12px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;";let i=B(!1),o=B(!1),s=B(null);async function a(_,C){b(o,!0),b(s,null);try{const A=await ev();return await _(A),!0}catch(A){const j=A instanceof Error?A.message:String(A),H=dk(j);return b(s,`${C}: ${H}`),!1}finally{b(o,!1)}}async function l(){await a(async C=>{await pk(C,!0)},"Failed to enable Cowork")&&e.onAdvance()}function c(){wM(),e.onAdvance()}var d=eO(),u=k(x(d),2),h=k(x(u));{var p=_=>{var C=ZM(),A=k(ye(C)),j=x(A);K(()=>$(j,e.status.vethernetCidr)),S(_,C)};Z(h,_=>{e.status.vethernetCidr!==null&&_(p)})}var m=k(u,2);{var v=_=>{var C=YM(),A=x(C);K(()=>$(A,f(s))),S(_,C)};Z(m,_=>{f(s)&&_(v)})}var g=k(m,2);{var y=_=>{var C=GM(),A=k(x(C),4),j=x(A);re(j,t);var H=k(j,2);re(H,r),K(()=>{j.disabled=f(o),H.disabled=f(o)}),L("click",j,()=>void l()),L("click",H,()=>{b(i,!1)}),S(_,C)},w=_=>{var C=$M(),A=x(C);re(A,t);var j=k(A,2);re(j,r);var H=k(j,2);{var D=W=>{var ee=XM();re(ee,r),K(()=>ee.disabled=f(o)),L("click",ee,function(...z){var Y;(Y=e.onLearnMore)==null||Y.apply(this,z)}),S(W,ee)},N=W=>{var ee=QM();K(()=>G(ee,"href",`${px}#cowork`)),S(W,ee)};Z(H,W=>{e.onLearnMore?W(D):W(N,-1)})}K(()=>{A.disabled=f(o),j.disabled=f(o)}),L("click",A,()=>{b(i,!0)}),L("click",j,c),S(_,C)};Z(g,_=>{f(i)?_(y):_(w,-1)})}S(n,d),Le()}qe(["click"]);var nO=E("<div></div>"),rO=E('<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);"></div>'),iO=E('<div style="font-size: var(--tandem-text-sm); font-weight: 600; color: var(--tandem-fg); margin-bottom: var(--tandem-space-1);"> </div> <div> </div>',1),oO=E('<div style="display: flex; justify-content: space-between; align-items: center;"><span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </span> <div style="display: flex; gap: 12px; align-items: center;"><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;">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-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; font-weight: 500;"> </button></div></div>'),sO=E('<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;"><!> <!> <!></div>');function aO(n,e){Pe(e,!0);const t=[{id:"review",title:"Review an annotation",text:"Open the side panel and accept or dismiss one of the highlighted annotations. Try Review Mode (Ctrl+Shift+R) for keyboard shortcuts."},{id:"question",title:"Ask a question",text:"Select text and click Comment to send a question to Claude — or click Note to keep a private thought 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."},{id:"cowork",title:"Claude Desktop Cowork detected",text:""},{id:"complete",title:"You're ready!",text:"You've learned the basics. Press ? anytime to see keyboard shortcuts."}],r=Nn(),i=fk(),o=F(()=>r&&uk(e.coworkStatus,i)),s=F(()=>t.filter(m=>m.id!=="cowork"||f(o))),a=F(()=>f(s).length-1),l=F(()=>f(s)[e.currentStep]),c=F(()=>e.currentStep>=f(a)),d=F(()=>{var m;return((m=f(l))==null?void 0:m.id)==="cowork"});var u=xt(),h=ye(u);{var p=m=>{var v=sO(),g=x(v);{var y=H=>{var D=rO();dt(D,20,()=>Array.from({length:f(a)},(N,W)=>W),N=>N,(N,W)=>{var ee=nO();K(()=>re(ee,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${W<=e.currentStep?"var(--tandem-accent)":"var(--tandem-border)"}; transition: background 0.2s;`)),S(N,ee)}),S(H,D)};Z(g,H=>{f(c)||H(y)})}var w=k(g,2);{var _=H=>{tO(H,{get status(){return e.coworkStatus},get onAdvance(){return e.onNext}})},C=H=>{var D=iO(),N=ye(D),W=x(N),ee=k(N,2),z=x(ee);K(()=>{$(W,f(l).title),re(ee,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${f(c)?0:14}px;`),$(z,f(l).text)}),S(H,D)};Z(w,H=>{f(d)&&e.coworkStatus!==null?H(_):H(C,-1)})}var A=k(w,2);{var j=H=>{var D=oO(),N=x(D),W=x(N),ee=k(N,2),z=x(ee),Y=k(z,2),te=x(Y);K(()=>{$(W,`Step ${e.currentStep+1} of ${f(a)??""}`),$(te,e.currentStep===f(a)-1?"Done":"Next")}),L("click",z,function(...ne){var q;(q=e.onDismiss)==null||q.apply(this,ne)}),L("click",Y,function(...ne){var q;(q=e.onNext)==null||q.apply(this,ne)}),S(H,D)};Z(A,H=>{!f(c)&&!f(d)&&H(j)})}S(m,v)};Z(h,m=>{f(l)&&m(p)})}S(n,u),Le()}qe(["click"]);const Br=()=>new Map,Cm=n=>{const e=Br();return n.forEach((t,r)=>{e.set(r,t)}),e},Li=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},lO=(n,e)=>{const t=[];for(const[r,i]of n)t.push(e(i,r));return t},cO=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},Fs=()=>new Set,$h=n=>n[n.length-1],dO=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},qo=Array.from,iv=(n,e)=>{for(let t=0;t<n.length;t++)if(!e(n[t],t,n))return!1;return!0},ov=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},uO=(n,e)=>{const t=new Array(n);for(let r=0;r<n;r++)t[r]=e(r,t);return t},Xa=Array.isArray;class vk{constructor(){this._observers=Br()}on(e,t){return Li(this._observers,e,Fs).add(t),t}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return qo((this._observers.get(e)||Br()).values()).forEach(r=>r(...t))}destroy(){this._observers=Br()}}const ii=Math.floor,ru=Math.abs,$i=(n,e)=>n<e?n:e,oi=(n,e)=>n>e?n:e,yk=n=>n!==0?n<0:1/n<0,Pb=1,Lb=2,ep=4,tp=8,yc=32,eo=64,Yn=128,fO=1<<29,Xf=31,Tm=63,Es=127,hO=2147483647,Ru=Number.MAX_SAFE_INTEGER,zb=Number.MIN_SAFE_INTEGER,pO=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&ii(n)===n),bk=String.fromCharCode,mO=n=>n.toLowerCase(),gO=/^\s*/g,vO=n=>n.replace(gO,""),yO=/([A-Z])/g,Fb=(n,e)=>vO(n.replace(yO,t=>`${e}${mO(t)}`)),bO=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},bc=typeof TextEncoder<"u"?new TextEncoder:null,wO=n=>bc.encode(n),xO=bc?wO:bO;let jl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});jl&&jl.decode(new Uint8Array).length===1&&(jl=null);const kO=(n,e)=>uO(e,()=>n).join("");let id=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};const od=()=>new id,_O=n=>{const e=od();return n(e),ei(e)},SO=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},ei=n=>{const e=new Uint8Array(SO(n));let t=0;for(let r=0;r<n.bufs.length;r++){const i=n.bufs[r];e.set(i,t),t+=i.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},CO=(n,e)=>{const t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(oi(t,e)*2),n.cpos=0)},vn=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},Em=vn,ht=(n,e)=>{for(;e>Es;)vn(n,Yn|Es&e),e=ii(e/128);vn(n,Es&e)},sv=(n,e)=>{const t=yk(e);for(t&&(e=-e),vn(n,(e>Tm?Yn:0)|(t?eo:0)|Tm&e),e=ii(e/64);e>0;)vn(n,(e>Es?Yn:0)|Es&e),e=ii(e/128)},Am=new Uint8Array(3e4),TO=Am.length/3,EO=(n,e)=>{if(e.length<TO){const t=bc.encodeInto(e,Am).written||0;ht(n,t);for(let r=0;r<t;r++)vn(n,Am[r])}else ur(n,xO(e))},AO=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;ht(n,r);for(let i=0;i<r;i++)vn(n,t.codePointAt(i))},wa=bc&&bc.encodeInto?EO:AO,Qf=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=$i(t-r,e.length),o=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,o>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(oi(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},ur=(n,e)=>{ht(n,e.byteLength),Qf(n,e)},av=(n,e)=>{CO(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},MO=(n,e)=>av(n,4).setFloat32(0,e,!1),OO=(n,e)=>av(n,8).setFloat64(0,e,!1),DO=(n,e)=>av(n,8).setBigInt64(0,e,!1),Bb=new DataView(new ArrayBuffer(4)),RO=n=>(Bb.setFloat32(0,n),Bb.getFloat32(0)===n),Qa=(n,e)=>{switch(typeof e){case"string":vn(n,119),wa(n,e);break;case"number":pO(e)&&ru(e)<=hO?(vn(n,125),sv(n,e)):RO(e)?(vn(n,124),MO(n,e)):(vn(n,123),OO(n,e));break;case"bigint":vn(n,122),DO(n,e);break;case"object":if(e===null)vn(n,126);else if(Xa(e)){vn(n,117),ht(n,e.length);for(let t=0;t<e.length;t++)Qa(n,e[t])}else if(e instanceof Uint8Array)vn(n,116),ur(n,e);else{vn(n,118);const t=Object.keys(e);ht(n,t.length);for(let r=0;r<t.length;r++){const i=t[r];wa(n,i),Qa(n,e[i])}}break;case"boolean":vn(n,e?120:121);break;default:vn(n,127)}};class Hb extends id{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ht(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Vb=n=>{n.count>0&&(sv(n.encoder,n.count===1?n.s:-n.s),n.count>1&&ht(n.encoder,n.count-2))};class iu{constructor(){this.encoder=new id,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Vb(this),this.count=1,this.s=e)}toUint8Array(){return Vb(this),ei(this.encoder)}}const Ub=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);sv(n.encoder,e),n.count>1&&ht(n.encoder,n.count-2)}};class np{constructor(){this.encoder=new id,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ub(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ub(this),ei(this.encoder)}}class NO{constructor(){this.sarr=[],this.s="",this.lensE=new iu}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new id;return this.sarr.push(this.s),this.s="",wa(e,this.sarr.join("")),Qf(e,this.lensE.toUint8Array()),ei(e)}}const Oi=n=>new Error(n),Hr=()=>{throw Oi("Method unimplemented")},Hn=()=>{throw Oi("Unexpected case")},wk=Oi("Unexpected end of array"),xk=Oi("Integer out of Range");let $f=class{constructor(e){this.arr=e,this.pos=0}};const fl=n=>new $f(n),IO=n=>n.pos!==n.arr.length,PO=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},fr=n=>PO(n,ct(n)),$a=n=>n.arr[n.pos++],ct=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const i=n.arr[n.pos++];if(e=e+(i&Es)*t,t*=128,i<Yn)return e;if(e>Ru)throw xk}throw wk},lv=n=>{let e=n.arr[n.pos++],t=e&Tm,r=64;const i=(e&eo)>0?-1:1;if((e&Yn)===0)return i*t;const o=n.arr.length;for(;n.pos<o;){if(e=n.arr[n.pos++],t=t+(e&Es)*r,r*=128,e<Yn)return i*t;if(t>Ru)throw xk}throw wk},LO=n=>{let e=ct(n);if(e===0)return"";{let t=String.fromCodePoint($a(n));if(--e<100)for(;e--;)t+=String.fromCodePoint($a(n));else for(;e>0;){const r=e<1e4?e:1e4,i=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(t))}},zO=n=>jl.decode(fr(n)),xa=jl?zO:LO,cv=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},FO=n=>cv(n,4).getFloat32(0,!1),BO=n=>cv(n,8).getFloat64(0,!1),HO=n=>cv(n,8).getBigInt64(0,!1),VO=[n=>{},n=>null,lv,FO,BO,HO,n=>!1,n=>!0,xa,n=>{const e=ct(n),t={};for(let r=0;r<e;r++){const i=xa(n);t[i]=wc(n)}return t},n=>{const e=ct(n),t=[];for(let r=0;r<e;r++)t.push(wc(n));return t},fr],wc=n=>VO[127-$a(n)](n);class jb extends $f{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),IO(this)?this.count=ct(this)+1:this.count=-1),this.count--,this.s}}class ou extends $f{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=lv(this);const e=yk(this.s);this.count=1,e&&(this.s=-this.s,this.count=ct(this)+2)}return this.count--,this.s}}class rp extends $f{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=lv(this),t=e&1;this.diff=ii(e/2),this.count=1,t&&(this.count=ct(this)+2)}return this.s+=this.diff,this.count--,this.s}}class UO{constructor(e){this.decoder=new ou(e),this.str=xa(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const jO=crypto.getRandomValues.bind(crypto),WO=Math.random,kk=()=>jO(new Uint32Array(1))[0],KO=n=>n[ii(WO()*n.length)],qO="10000000-1000-4000-8000"+-1e11,JO=()=>qO.replace(/[018]/g,n=>(n^kk()&15>>n/4).toString(16)),ZO=Date.now,Wb=n=>new Promise(n);Promise.all.bind(Promise);const Kb=n=>n===void 0?null:n;class YO{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let _k=new YO,GO=!0;try{typeof localStorage<"u"&&localStorage&&(_k=localStorage,GO=!1)}catch{}const XO=_k,xc=Symbol("Equality"),Sk=(n,e)=>{var t;return n===e||!!((t=n==null?void 0:n[xc])!=null&&t.call(n,e))||!1},QO=n=>typeof n=="object",$O=Object.assign,Ck=Object.keys,eD=(n,e)=>{for(const t in n)e(n[t],t)},Nu=n=>Ck(n).length,tD=n=>{for(const e in n)return!1;return!0},hl=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},dv=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),nD=(n,e)=>n===e||Nu(n)===Nu(e)&&hl(n,(t,r)=>(t!==void 0||dv(e,r))&&Sk(e[r],t)),rD=Object.freeze,Tk=n=>{for(const e in n){const t=n[e];(typeof t=="object"||typeof t=="function")&&Tk(n[e])}return rD(n)},uv=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&uv(n,e,t+1)}},iD=n=>n,su=(n,e)=>{if(n===e)return!0;if(n==null||e==null||n.constructor!==e.constructor&&(n.constructor||Object)!==(e.constructor||Object))return!1;if(n[xc]!=null)return n[xc](e);switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!su(n.get(t),e.get(t)))return!1;break}case void 0:case Object:if(Nu(n)!==Nu(e))return!1;for(const t in n)if(!dv(n,t)||!su(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!su(n[t],e[t]))return!1;break;default:return!1}return!0},oD=(n,e)=>e.includes(n);var Ek={};const el=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Ak=typeof window<"u"&&typeof document<"u"&&!el;let ui;const sD=()=>{if(ui===void 0)if(el){ui=Br();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&ui.set(e,""),e=r):e!==null&&(ui.set(e,r),e=null)}e!==null&&ui.set(e,"")}else typeof location=="object"?(ui=Br(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");ui.set(`--${Fb(e,"-")}`,t),ui.set(`-${Fb(e,"-")}`,t)}})):ui=Br();return ui},Mm=n=>sD().has(n),Iu=n=>Kb(el?Ek[n.toUpperCase().replaceAll("-","_")]:XO.getItem(n)),Mk=n=>Mm("--"+n)||Iu(n)!==null,aD=Mk("production"),lD=el&&oD(Ek.FORCE_COLOR,["true","1","2"]),cD=lD||!Mm("--no-colors")&&!Mk("no-color")&&(!el||process.stdout.isTTY)&&(!el||Mm("--color")||Iu("COLORTERM")!==null||(Iu("TERM")||"").includes("color")),dD=n=>new Uint8Array(n),uD=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=bk(n[t]);return btoa(e)},fD=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),hD=Ak?uD:fD,pD=n=>{const e=dD(n.byteLength);return e.set(n),e},mD=n=>_O(e=>Qa(e,n));class gD{constructor(e,t){this.left=e,this.right=t}}const Fi=(n,e)=>new gD(n,e),qb=n=>n.next()>=.5,ip=(n,e,t)=>ii(n.next()*(t+1-e)+e),Ok=(n,e,t)=>ii(n.next()*(t+1-e)+e),fv=(n,e,t)=>Ok(n,e,t),vD=n=>bk(fv(n,97,122)),yD=(n,e=0,t=20)=>{const r=fv(n,e,t);let i="";for(let o=0;o<r;o++)i+=vD(n);return i},op=(n,e)=>e[fv(n,0,e.length-1)],bD=Symbol("0schema");class wD{constructor(){this._rerrs=[]}extend(e,t,r,i=null){this._rerrs.push({path:e,expected:t,has:r,message:i})}toString(){const e=[];for(let t=this._rerrs.length-1;t>0;t--){const r=this._rerrs[t];e.push(kO(" ",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
46
|
+
`)}}const Om=(n,e)=>n===e?!0:n==null||e==null||n.constructor!==e.constructor?!1:n[xc]?Sk(n,e):Xa(n)?iv(n,t=>ov(e,r=>Om(t,r))):QO(n)?hl(n,(t,r)=>Om(t,e[r])):!1;class Wn{extends(e){let[t,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,t]=[t,r]),Om(t,r)}equals(e){return this.constructor===e.constructor&&su(this.shape,e.shape)}[bD](){return!0}[xc](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Hr()}get nullable(){return pl(this,ih)}get optional(){return new Nk(this)}cast(e){return Jb(e,this),e}expect(e){return Jb(e,this),e}}gn(Wn,"_dilutes",!1);class hv extends Wn{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){const r=(e==null?void 0:e.constructor)===this.shape&&(this._c==null||this._c(e));return!r&&(t==null||t.extend(null,this.shape.name,e==null?void 0:e.constructor.name,(e==null?void 0:e.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}}const an=(n,e=null)=>new hv(n,e);an(hv);class pv extends Wn{constructor(e){super(),this.shape=e}check(e,t){const r=this.shape(e);return!r&&(t==null||t.extend(null,"custom prop",e==null?void 0:e.constructor.name,"failed to check custom prop")),r}}const Sn=n=>new pv(n);an(pv);class eh extends Wn{constructor(e){super(),this.shape=e}check(e,t){const r=this.shape.some(i=>i===e);return!r&&(t==null||t.extend(null,this.shape.join(" | "),e.toString())),r}}const th=(...n)=>new eh(n),Dk=an(eh),xD=RegExp.escape||(n=>n.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Rk=n=>{if(tl.check(n))return[xD(n)];if(Dk.check(n))return n.shape.map(e=>e+"");if(Uk.check(n))return["[+-]?\\d+.?\\d*"];if(jk.check(n))return[".*"];if(Lu.check(n))return n.shape.map(Rk).flat(1);Hn()};class kD extends Wn{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Rk).map(t=>`(${t.join("|")})`).join("")+"$")}check(e,t){const r=this._r.exec(e)!=null;return!r&&(t==null||t.extend(null,this._r.toString(),e.toString(),"String doesn't match string template.")),r}}an(kD);const _D=Symbol("optional");class Nk extends Wn{constructor(e){super(),this.shape=e}check(e,t){const r=e===void 0||this.shape.check(e);return!r&&(t==null||t.extend(null,"undefined (optional)","()")),r}get[_D](){return!0}}const SD=an(Nk);class CD extends Wn{check(e,t){return t==null||t.extend(null,"never",typeof e),!1}}an(CD);const Hf=class Hf extends Wn{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}get partial(){return new Hf(this.shape,!0)}check(e,t){return e==null?(t==null||t.extend(null,"object","null"),!1):hl(this.shape,(r,i)=>{const o=this._isPartial&&!dv(e,i)||r.check(e[i],t);return!o&&(t==null||t.extend(i.toString(),r.toString(),typeof e[i],"Object property does not match")),o})}};gn(Hf,"_dilutes",!0);let Pu=Hf;const TD=n=>new Pu(n),ED=an(Pu),AD=Sn(n=>n!=null&&(n.constructor===Object||n.constructor==null));class Ik extends Wn{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&hl(e,(r,i)=>{const o=this.shape.keys.check(i,t);return!o&&(t==null||t.extend(i+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value")),o&&this.shape.values.check(r,t)})}}const Pk=(n,e)=>new Ik(n,e),MD=an(Ik);class Lk extends Wn{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&hl(this.shape,(r,i)=>{const o=r.check(e[i],t);return!o&&(t==null||t.extend(i.toString(),"Tuple",typeof r)),o})}}const OD=(...n)=>new Lk(n);an(Lk);class zk extends Wn{constructor(e){super(),this.shape=e.length===1?e[0]:new nh(e)}check(e,t){const r=Xa(e)&&iv(e,i=>this.shape.check(i));return!r&&(t==null||t.extend(null,"Array","")),r}}const Fk=(...n)=>new zk(n),DD=an(zk),RD=Sn(n=>Xa(n));class Bk extends Wn{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&(t==null||t.extend(null,this.shape.name,e==null?void 0:e.constructor.name)),r}}const ND=(n,e=null)=>new Bk(n,e);an(Bk);const ID=ND(Wn);class PD extends Wn{constructor(e){super(),this.len=e.length-1,this.args=OD(...e.slice(-1)),this.res=e[this.len]}check(e,t){const r=e.constructor===Function&&e.length<=this.len;return!r&&(t==null||t.extend(null,"function",typeof e)),r}}const LD=an(PD),zD=Sn(n=>typeof n=="function");class FD extends Wn{constructor(e){super(),this.shape=e}check(e,t){const r=iv(this.shape,i=>i.check(e,t));return!r&&(t==null||t.extend(null,"Intersectinon",typeof e)),r}}an(FD,n=>n.shape.length>0);class nh extends Wn{constructor(e){super(),this.shape=e}check(e,t){const r=ov(this.shape,i=>i.check(e,t));return t==null||t.extend(null,"Union",typeof e),r}}gn(nh,"_dilutes",!0);const pl=(...n)=>n.findIndex(e=>Lu.check(e))>=0?pl(...n.map(e=>kc(e)).map(e=>Lu.check(e)?e.shape:[e]).flat(1)):n.length===1?n[0]:new nh(n),Lu=an(nh),Hk=()=>!0,zu=Sn(Hk),BD=an(pv,n=>n.shape===Hk),mv=Sn(n=>typeof n=="bigint"),HD=Sn(n=>n===mv),Vk=Sn(n=>typeof n=="symbol");Sn(n=>n===Vk);const ka=Sn(n=>typeof n=="number"),Uk=Sn(n=>n===ka),tl=Sn(n=>typeof n=="string"),jk=Sn(n=>n===tl),rh=Sn(n=>typeof n=="boolean"),VD=Sn(n=>n===rh),Wk=th(void 0);an(eh,n=>n.shape.length===1&&n.shape[0]===void 0);th(void 0);const ih=th(null),UD=an(eh,n=>n.shape.length===1&&n.shape[0]===null);an(Uint8Array);an(hv,n=>n.shape===Uint8Array);const jD=pl(ka,tl,ih,Wk,mv,rh,Vk);(()=>{const n=Fk(zu),e=Pk(tl,zu),t=pl(ka,tl,ih,rh,n,e);return n.shape=t,e.shape.values=t,t})();const kc=n=>{if(ID.check(n))return n;if(AD.check(n)){const e={};for(const t in n)e[t]=kc(n[t]);return TD(e)}else{if(RD.check(n))return pl(...n.map(kc));if(jD.check(n))return th(n);if(zD.check(n))return an(n)}Hn()},Jb=aD?()=>{}:(n,e)=>{const t=new wD;if(!e.check(n,t))throw Oi(`Expected value to be of type ${e.constructor.name}.
|
|
47
|
+
${t.toString()}`)};class WD{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:kc(e),h:t}),this}else(e){return this.if(zu,e)}done(){return(e,t)=>{for(let r=0;r<this.patterns.length;r++){const i=this.patterns[r];if(i.if.check(e))return i.h(e,t)}throw Oi("Unhandled pattern")}}}const KD=n=>new WD(n),Kk=KD(zu).if(Uk,(n,e)=>ip(e,zb,Ru)).if(jk,(n,e)=>yD(e)).if(VD,(n,e)=>qb(e)).if(HD,(n,e)=>BigInt(ip(e,zb,Ru))).if(Lu,(n,e)=>na(e,op(e,n.shape))).if(ED,(n,e)=>{const t={};for(const r in n.shape){let i=n.shape[r];if(SD.check(i)){if(qb(e))continue;i=i.shape}t[r]=Kk(i,e)}return t}).if(DD,(n,e)=>{const t=[],r=Ok(e,0,42);for(let i=0;i<r;i++)t.push(na(e,n.shape));return t}).if(Dk,(n,e)=>op(e,n.shape)).if(UD,(n,e)=>null).if(LD,(n,e)=>{const t=na(e,n.res);return()=>t}).if(BD,(n,e)=>na(e,op(e,[ka,tl,ih,Wk,mv,rh,Fk(ka),Pk(pl("a","b","c"),ka)]))).if(MD,(n,e)=>{const t={},r=ip(e,0,3);for(let i=0;i<r;i++){const o=na(e,n.shape.keys),s=na(e,n.shape.values);t[o]=s}return t}).done(),na=(n,e)=>Kk(kc(e),n),sd=typeof document<"u"?document:{};Sn(n=>n.nodeType===GD);typeof DOMParser<"u"&&new DOMParser;Sn(n=>n.nodeType===JD);Sn(n=>n.nodeType===ZD);const qD=n=>lO(n,(e,t)=>`${t}:${e};`).join(""),JD=sd.ELEMENT_NODE,ZD=sd.TEXT_NODE,YD=sd.DOCUMENT_NODE,GD=sd.DOCUMENT_FRAGMENT_NODE;Sn(n=>n.nodeType===YD);const XD=n=>class{constructor(t){this._=t}destroy(){n(this._)}},QD=XD(clearTimeout),gv=(n,e)=>new QD(setTimeout(e,n)),lo=Symbol,qk=lo(),Jk=lo(),$D=lo(),eR=lo(),tR=lo(),Zk=lo(),nR=lo(),vv=lo(),rR=lo(),iR=n=>{var i;n.length===1&&((i=n[0])==null?void 0:i.constructor)===Function&&(n=n[0]());const e=[],t=[];let r=0;for(;r<n.length;r++){const o=n[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)e.push(o);else if(o.constructor===Object)break}for(r>0&&t.push(e.join(""));r<n.length;r++){const o=n[r];o instanceof Symbol||t.push(o)}return t},oR={[qk]:Fi("font-weight","bold"),[Jk]:Fi("font-weight","normal"),[$D]:Fi("color","blue"),[tR]:Fi("color","green"),[eR]:Fi("color","grey"),[Zk]:Fi("color","red"),[nR]:Fi("color","purple"),[vv]:Fi("color","orange"),[rR]:Fi("color","black")},sR=n=>{var s;n.length===1&&((s=n[0])==null?void 0:s.constructor)===Function&&(n=n[0]());const e=[],t=[],r=Br();let i=[],o=0;for(;o<n.length;o++){const a=n[o],l=oR[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const c=qD(r);o>0||c.length>0?(e.push("%c"+a),t.push(c)):e.push(a)}else break}}for(o>0&&(i=t,i.unshift(e.join("")));o<n.length;o++){const a=n[o];a instanceof Symbol||i.push(a)}return i},Yk=cD?sR:iR,aR=(...n)=>{console.log(...Yk(n)),Xk.forEach(e=>e.print(n))},Gk=(...n)=>{console.warn(...Yk(n)),n.unshift(vv),Xk.forEach(e=>e.print(n))},Xk=Fs(),Qk=n=>({[Symbol.iterator](){return this},next:n}),lR=(n,e)=>Qk(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),sp=(n,e)=>Qk(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class oh{constructor(e,t){this.clock=e,this.len=t}}class ml{constructor(){this.clients=new Map}}const Jo=(n,e,t)=>e.clients.forEach((r,i)=>{const o=n.doc.store.clients.get(i);if(o!=null){const s=o[o.length-1],a=s.id.clock+s.length;for(let l=0,c=r[l];l<r.length&&c.clock<a;c=r[++l])f_(n,o,c.clock,c.len,t)}}),cR=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const i=ii((t+r)/2),o=n[i],s=o.clock;if(s<=e){if(e<s+o.len)return i;t=i+1}else r=i-1}return null},gl=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&cR(t,e.clock)!==null},yv=n=>{n.clients.forEach(e=>{e.sort((i,o)=>i.clock-o.clock);let t,r;for(t=1,r=1;t<e.length;t++){const i=e[r-1],o=e[t];i.clock+i.len>=o.clock?e[r-1]=new oh(i.clock,oi(i.len,o.clock+o.len-i.clock)):(r<t&&(e[r]=o),r++)}e.length=r})},Dm=n=>{const e=new ml;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,i)=>{if(!e.clients.has(i)){const o=r.slice();for(let s=t+1;s<n.length;s++)dO(o,n[s].clients.get(i)||[]);e.clients.set(i,o)}});return yv(e),e},_c=(n,e,t,r)=>{Li(n.clients,e,()=>[]).push(new oh(t,r))},$k=()=>new ml,e_=n=>{const e=$k();return n.clients.forEach((t,r)=>{const i=[];for(let o=0;o<t.length;o++){const s=t[o];if(s.deleted){const a=s.id.clock;let l=s.length;if(o+1<t.length)for(let c=t[o+1];o+1<t.length&&c.deleted;c=t[++o+1])l+=c.length;i.push(new oh(a,l))}}i.length>0&&e.clients.set(r,i)}),e},vl=(n,e)=>{ht(n.restEncoder,e.clients.size),qo(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),ht(n.restEncoder,t);const i=r.length;ht(n.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];n.writeDsClock(s.clock),n.writeDsLen(s.len)}})},bv=n=>{const e=new ml,t=ct(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const i=ct(n.restDecoder),o=ct(n.restDecoder);if(o>0){const s=Li(e.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new oh(n.readDsClock(),n.readDsLen()))}}return e},Zb=(n,e,t)=>{const r=new ml,i=ct(n.restDecoder);for(let o=0;o<i;o++){n.resetDsCurVal();const s=ct(n.restDecoder),a=ct(n.restDecoder),l=t.clients.get(s)||[],c=Qt(t,s);for(let d=0;d<a;d++){const u=n.readDsClock(),h=u+n.readDsLen();if(u<c){c<h&&_c(r,s,c,h-c);let p=si(l,u),m=l[p];for(!m.deleted&&m.id.clock<u&&(l.splice(p+1,0,Wu(e,m,u-m.id.clock)),p++);p<l.length&&(m=l[p++],m.id.clock<h);)m.deleted||(h<m.id.clock+m.length&&l.splice(p,0,Wu(e,m,h-m.id.clock)),m.delete(e))}else _c(r,s,u,h-u)}}if(r.clients.size>0){const o=new Bs;return ht(o.restEncoder,0),vl(o,r),o.toUint8Array()}return null},t_=kk;class Di extends vk{constructor({guid:e=JO(),collectionid:t=null,gc:r=!0,gcFilter:i=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=t_(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new d_,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Wb(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Wb(c=>{const d=u=>{(u===void 0||u===!0)&&(this.off("sync",d),c())};this.on("sync",d)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Ot(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(qo(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Ot(this,e,t)}get(e,t=xn){const r=Li(this.share,e,()=>{const o=new t;return o._integrate(this,null),o}),i=r.constructor;if(t!==xn&&i!==t)if(i===xn){const o=new t;o._map=r._map,r._map.forEach(s=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,Ca)}getText(e=""){return this.get(e,Zo)}getMap(e=""){return this.get(e,rl)}getXmlElement(e=""){return this.get(e,on)}getXmlFragment(e=""){return this.get(e,Hs)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,qo(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new Di({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,Ot(e.parent.doc,r=>{const i=t.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class n_{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return ct(this.restDecoder)}readDsLen(){return ct(this.restDecoder)}}class r_ extends n_{readLeftID(){return $e(ct(this.restDecoder),ct(this.restDecoder))}readRightID(){return $e(ct(this.restDecoder),ct(this.restDecoder))}readClient(){return ct(this.restDecoder)}readInfo(){return $a(this.restDecoder)}readString(){return xa(this.restDecoder)}readParentInfo(){return ct(this.restDecoder)===1}readTypeRef(){return ct(this.restDecoder)}readLen(){return ct(this.restDecoder)}readAny(){return wc(this.restDecoder)}readBuf(){return pD(fr(this.restDecoder))}readJSON(){return JSON.parse(xa(this.restDecoder))}readKey(){return xa(this.restDecoder)}}class dR{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=ct(this.restDecoder),this.dsCurrVal}readDsLen(){const e=ct(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class nl extends dR{constructor(e){super(e),this.keys=[],ct(e),this.keyClockDecoder=new rp(fr(e)),this.clientDecoder=new ou(fr(e)),this.leftClockDecoder=new rp(fr(e)),this.rightClockDecoder=new rp(fr(e)),this.infoDecoder=new jb(fr(e),$a),this.stringDecoder=new UO(fr(e)),this.parentInfoDecoder=new jb(fr(e),$a),this.typeRefDecoder=new ou(fr(e)),this.lenDecoder=new ou(fr(e))}readLeftID(){return new _a(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new _a(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 wc(this.restDecoder)}readBuf(){return fr(this.restDecoder)}readJSON(){return wc(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class i_{constructor(){this.restEncoder=od()}toUint8Array(){return ei(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ht(this.restEncoder,e)}writeDsLen(e){ht(this.restEncoder,e)}}class ad extends i_{writeLeftID(e){ht(this.restEncoder,e.client),ht(this.restEncoder,e.clock)}writeRightID(e){ht(this.restEncoder,e.client),ht(this.restEncoder,e.clock)}writeClient(e){ht(this.restEncoder,e)}writeInfo(e){Em(this.restEncoder,e)}writeString(e){wa(this.restEncoder,e)}writeParentInfo(e){ht(this.restEncoder,e?1:0)}writeTypeRef(e){ht(this.restEncoder,e)}writeLen(e){ht(this.restEncoder,e)}writeAny(e){Qa(this.restEncoder,e)}writeBuf(e){ur(this.restEncoder,e)}writeJSON(e){wa(this.restEncoder,JSON.stringify(e))}writeKey(e){wa(this.restEncoder,e)}}class o_{constructor(){this.restEncoder=od(),this.dsCurrVal=0}toUint8Array(){return ei(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,ht(this.restEncoder,t)}writeDsLen(e){e===0&&Hn(),ht(this.restEncoder,e-1),this.dsCurrVal+=e}}class Bs extends o_{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new np,this.clientEncoder=new iu,this.leftClockEncoder=new np,this.rightClockEncoder=new np,this.infoEncoder=new Hb(Em),this.stringEncoder=new NO,this.parentInfoEncoder=new Hb(Em),this.typeRefEncoder=new iu,this.lenEncoder=new iu}toUint8Array(){const e=od();return ht(e,0),ur(e,this.keyClockEncoder.toUint8Array()),ur(e,this.clientEncoder.toUint8Array()),ur(e,this.leftClockEncoder.toUint8Array()),ur(e,this.rightClockEncoder.toUint8Array()),ur(e,ei(this.infoEncoder)),ur(e,this.stringEncoder.toUint8Array()),ur(e,ei(this.parentInfoEncoder)),ur(e,this.typeRefEncoder.toUint8Array()),ur(e,this.lenEncoder.toUint8Array()),Qf(e,ei(this.restEncoder)),ei(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Qa(this.restEncoder,e)}writeBuf(e){ur(this.restEncoder,e)}writeJSON(e){Qa(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const uR=(n,e,t,r)=>{r=oi(r,e[0].id.clock);const i=si(e,r);ht(n.restEncoder,e.length-i),n.writeClient(t),ht(n.restEncoder,r);const o=e[i];o.write(n,r-o.id.clock);for(let s=i+1;s<e.length;s++)e[s].write(n,0)},wv=(n,e,t)=>{const r=new Map;t.forEach((i,o)=>{Qt(e,o)>i&&r.set(o,i)}),ld(e).forEach((i,o)=>{t.has(o)||r.set(o,0)}),ht(n.restEncoder,r.size),qo(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{uR(n,e.clients.get(i),i,o)})},fR=(n,e)=>{const t=Br(),r=ct(n.restDecoder);for(let i=0;i<r;i++){const o=ct(n.restDecoder),s=new Array(o),a=n.readClient();let l=ct(n.restDecoder);t.set(a,{i:0,refs:s});for(let c=0;c<o;c++){const d=n.readInfo();switch(Xf&d){case 0:{const u=n.readLen();s[c]=new Nr($e(a,l),u),l+=u;break}case 10:{const u=ct(n.restDecoder);s[c]=new Ir($e(a,l),u),l+=u;break}default:{const u=(d&(eo|Yn))===0,h=new Pt($e(a,l),null,(d&Yn)===Yn?n.readLeftID():null,null,(d&eo)===eo?n.readRightID():null,u?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,u&&(d&yc)===yc?n.readString():null,I_(n,d));s[c]=h,l+=h.length}}}}return t},hR=(n,e,t)=>{const r=[];let i=qo(t.keys()).sort((p,m)=>p-m);if(i.length===0)return null;const o=()=>{if(i.length===0)return null;let p=t.get(i[i.length-1]);for(;p.refs.length===p.i;)if(i.pop(),i.length>0)p=t.get(i[i.length-1]);else return null;return p};let s=o();if(s===null)return null;const a=new d_,l=new Map,c=(p,m)=>{const v=l.get(p);(v==null||v>m)&&l.set(p,m)};let d=s.refs[s.i++];const u=new Map,h=()=>{for(const p of r){const m=p.id.client,v=t.get(m);v?(v.i--,a.clients.set(m,v.refs.slice(v.i)),t.delete(m),v.i=0,v.refs=[]):a.clients.set(m,[p]),i=i.filter(g=>g!==m)}r.length=0};for(;;){if(d.constructor!==Ir){const m=Li(u,d.id.client,()=>Qt(e,d.id.client))-d.id.clock;if(m<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{const v=d.getMissing(n,e);if(v!==null){r.push(d);const g=t.get(v)||{refs:[],i:0};if(g.refs.length===g.i)c(v,Qt(e,v)),h();else{d=g.refs[g.i++];continue}}else(m===0||m<d.length)&&(d.integrate(n,m),u.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(s!==null&&s.i<s.refs.length)d=s.refs[s.i++];else{if(s=o(),s===null)break;d=s.refs[s.i++]}}if(a.clients.size>0){const p=new Bs;return wv(p,a,new Map),ht(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},pR=(n,e)=>wv(n,e.doc.store,e.beforeState),mR=(n,e,t,r=new nl(n))=>Ot(e,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=fR(r,s),c=hR(i,a,l),d=a.pendingStructs;if(d){for(const[h,p]of d.missing)if(p<Qt(a,h)){o=!0;break}if(c){for(const[h,p]of c.missing){const m=d.missing.get(h);(m==null||m>p)&&d.missing.set(h,p)}d.update=Bu([d.update,c.update])}}else a.pendingStructs=c;const u=Zb(r,i,a);if(a.pendingDs){const h=new nl(fl(a.pendingDs));ct(h.restDecoder);const p=Zb(h,i,a);u&&p?a.pendingDs=Bu([u,p]):a.pendingDs=u||p}else a.pendingDs=u;if(o){const h=a.pendingStructs.update;a.pendingStructs=null,Fu(i.doc,h)}},t,!1),Fu=(n,e,t,r=nl)=>{const i=fl(e);mR(i,n,t,new r(i))},gR=(n,e,t)=>Fu(n,e,t,r_),vR=(n,e,t=new Map)=>{wv(n,e.store,t),vl(n,e_(e.store))},yR=(n,e=new Uint8Array([0]),t=new Bs)=>{const r=s_(e);vR(t,n,r);const i=[t.toUint8Array()];if(n.store.pendingDs&&i.push(n.store.pendingDs),n.store.pendingStructs&&i.push(zR(n.store.pendingStructs.update,e)),i.length>1){if(t.constructor===ad)return PR(i.map((o,s)=>s===0?o:BR(o)));if(t.constructor===Bs)return Bu(i)}return i[0]},bR=(n,e)=>yR(n,e,new ad),wR=n=>{const e=new Map,t=ct(n.restDecoder);for(let r=0;r<t;r++){const i=ct(n.restDecoder),o=ct(n.restDecoder);e.set(i,o)}return e},s_=n=>wR(new n_(fl(n))),a_=(n,e)=>(ht(n.restEncoder,e.size),qo(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{ht(n.restEncoder,t),ht(n.restEncoder,r)}),n),xR=(n,e)=>a_(n,ld(e.store)),kR=(n,e=new o_)=>(n instanceof Map?a_(e,n):xR(e,n),e.toUint8Array()),_R=n=>kR(n,new i_);class SR{constructor(){this.l=[]}}const Yb=()=>new SR,Gb=(n,e)=>n.l.push(e),Xb=(n,e)=>{const t=n.l,r=t.length;n.l=t.filter(i=>e!==i),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},l_=(n,e,t)=>uv(n.l,[e,t]);class _a{constructor(e,t){this.client=e,this.clock=t}}const ma=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,$e=(n,e)=>new _a(n,e),Sc=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw Hn()},Cc=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class Tc{constructor(e,t,r,i=0){this.type=e,this.tname=t,this.item=r,this.assoc=i}}const As=n=>new Tc(n.type==null?null:$e(n.type.client,n.type.clock),n.tname??null,n.item==null?null:$e(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class CR{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const TR=(n,e,t=0)=>new CR(n,e,t),Cd=(n,e,t)=>{let r=null,i=null;return n._item===null?i=Sc(n):r=$e(n._item.id.client,n._item.id.clock),new Tc(r,i,e,t)},ap=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return Cd(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Cd(n,$e(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return Cd(n,r.lastId,t);r=r.right}return Cd(n,null,t)},ER=(n,e)=>{const t=Sa(n,e),r=e.clock-t.id.clock;return{item:t,diff:r}},Rm=(n,e,t=!0)=>{const r=e.store,i=n.item,o=n.type,s=n.tname,a=n.assoc;let l=null,c=0;if(i!==null){if(Qt(r,i.client)<=i.clock)return null;const d=t?Lm(r,i):ER(r,i),u=d.item;if(!(u instanceof Pt))return null;if(l=u.parent,l._item===null||!l._item.deleted){c=u.deleted||!u.countable?0:d.diff+(a>=0?0:1);let h=u.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(s!==null)l=e.get(s);else if(o!==null){if(Qt(r,o.client)<=o.clock)return null;const{item:d}=t?Lm(r,o):{item:Sa(r,o)};if(d instanceof Pt&&d.content instanceof li)l=d.content.type;else return null}else throw Hn();a>=0?c=l._length:c=0}return TR(l,c,n.assoc)},Qb=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&ma(n.item,e.item)&&ma(n.type,e.type)&&n.assoc===e.assoc;class xv{constructor(e,t){this.ds=e,this.sv=t}}const c_=(n,e)=>new xv(n,e),lp=n=>c_(e_(n.store),ld(n.store)),is=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!gl(e.ds,n.id),Nm=(n,e)=>{const t=Li(n.meta,Nm,Fs),r=n.doc.store;t.has(e)||(e.sv.forEach((i,o)=>{i<Qt(r,o)&&ir(n,$e(o,i))}),Jo(n,e.ds,i=>{}),t.add(e))};class d_{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ld=n=>{const e=new Map;return n.clients.forEach((t,r)=>{const i=t[t.length-1];e.set(r,i.id.clock+i.length)}),e},Qt=(n,e)=>{const t=n.clients.get(e);if(t===void 0)return 0;const r=t[t.length-1];return r.id.clock+r.length},u_=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{const r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw Hn()}t.push(e)},si=(n,e)=>{let t=0,r=n.length-1,i=n[r],o=i.id.clock;if(o===e)return r;let s=ii(e/(o+i.length-1)*r);for(;t<=r;){if(i=n[s],o=i.id.clock,o<=e){if(e<o+i.length)return s;t=s+1}else r=s-1;s=ii((t+r)/2)}throw Hn()},AR=(n,e)=>{const t=n.clients.get(e.client);return t[si(t,e.clock)]},Sa=AR,Im=(n,e,t)=>{const r=si(e,t),i=e[r];return i.id.clock<t&&i instanceof Pt?(e.splice(r+1,0,Wu(n,i,t-i.id.clock)),r+1):r},ir=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[Im(n,t,e.clock)]},$b=(n,e,t)=>{const r=e.clients.get(t.client),i=si(r,t.clock),o=r[i];return t.clock!==o.id.clock+o.length-1&&o.constructor!==Nr&&r.splice(i+1,0,Wu(n,o,t.clock-o.id.clock+1)),o},MR=(n,e,t)=>{const r=n.clients.get(e.id.client);r[si(r,e.id.clock)]=t},f_=(n,e,t,r,i)=>{if(r===0)return;const o=t+r;let s=Im(n,e,t),a;do a=e[s++],o<a.id.clock+a.length&&Im(n,e,o),i(a);while(s<e.length&&e[s].id.clock<o)};class OR{constructor(e,t,r){this.doc=e,this.deleteSet=new ml,this.beforeState=ld(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=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const e0=(n,e)=>e.deleteSet.clients.size===0&&!cO(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(yv(e.deleteSet),pR(n,e),vl(n,e.deleteSet),!0),t0=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&Li(n.changed,e,Fs).add(t)},au=(n,e)=>{let t=n[e],r=n[e-1],i=e;for(;i>0;t=r,r=n[--i-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof Pt&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}const o=e-i;return o&&n.splice(e+1-o,o),o},DR=(n,e,t)=>{for(const[r,i]of n.clients.entries()){const o=e.clients.get(r);for(let s=i.length-1;s>=0;s--){const a=i[s],l=a.clock+a.len;for(let c=si(o,a.clock),d=o[c];c<o.length&&d.id.clock<l;d=o[++c]){const u=o[c];if(a.clock+a.len<=u.id.clock)break;u instanceof Pt&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},RR=(n,e)=>{n.clients.forEach((t,r)=>{const i=e.clients.get(r);for(let o=t.length-1;o>=0;o--){const s=t[o],a=$i(i.length-1,1+si(i,s.clock+s.len-1));for(let l=a,c=i[l];l>0&&c.id.clock>=s.clock;c=i[l])l-=1+au(i,l)}})},h_=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,i=r.store,o=t.deleteSet,s=t._mergeStructs;try{yv(o),t.afterState=ld(t.doc.store),r.emit("beforeObserverCalls",[t,r]);const a=[];t.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,l)})),a.push(()=>{t.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(d=>d.target._item===null||!d.target._item.deleted),l.forEach(d=>{d.currentTarget=c,d._path=null}),l.sort((d,u)=>d.path.length-u.path.length),a.push(()=>{l_(c._dEH,l,t)}))}),a.push(()=>r.emit("afterTransaction",[t,r])),a.push(()=>{t._needFormattingCleanup&&$R(t)})}),uv(a,[])}finally{r.gc&&DR(o,i,r.gcFilter),RR(o,i),t.afterState.forEach((d,u)=>{const h=t.beforeState.get(u)||0;if(h!==d){const p=i.clients.get(u),m=oi(si(p,h),1);for(let v=p.length-1;v>=m;)v-=1+au(p,v)}});for(let d=s.length-1;d>=0;d--){const{client:u,clock:h}=s[d].id,p=i.clients.get(u),m=si(p,h);m+1<p.length&&au(p,m+1)>1||m>0&&au(p,m)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(aR(vv,qk,"[yjs] ",Jk,Zk,"Changed the client-id because another client seems to be using it."),r.clientID=t_()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const d=new ad;e0(d,t)&&r.emit("update",[d.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const d=new Bs;e0(d,t)&&r.emit("updateV2",[d.toUint8Array(),t.origin,r,t])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=t;(a.size>0||c.size>0||l.size>0)&&(a.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),c.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,t]),c.forEach(d=>d.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):h_(n,e+1)}}},Ot=(n,e,t=null,r=!0)=>{const i=n._transactionCleanups;let o=!1,s=null;n._transaction===null&&(o=!0,n._transaction=new OR(n,t,r),i.push(n._transaction),i.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{s=e(n._transaction)}finally{if(o){const a=n._transaction===i[0];n._transaction=null,a&&h_(i,0)}}return s};class NR{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const n0=(n,e,t)=>{Jo(n,t.deletions,r=>{r instanceof Pt&&e.scope.some(i=>i===n.doc||Cc(i,r))&&Mv(r,!1)})},r0=(n,e,t)=>{let r=null;const i=n.doc,o=n.scope;Ot(i,a=>{for(;e.length>0&&n.currStackItem===null;){const l=i.store,c=e.pop(),d=new Set,u=[];let h=!1;Jo(a,c.insertions,p=>{if(p instanceof Pt){if(p.redone!==null){let{item:m,diff:v}=Lm(l,p.id);v>0&&(m=ir(a,$e(m.id.client,m.id.clock+v))),p=m}!p.deleted&&o.some(m=>m===a.doc||Cc(m,p))&&u.push(p)}}),Jo(a,c.deletions,p=>{p instanceof Pt&&o.some(m=>m===a.doc||Cc(m,p))&&!gl(c.insertions,p.id)&&d.add(p)}),d.forEach(p=>{h=N_(a,p,d,c.insertions,n.ignoreRemoteMapChanges,n)!==null||h});for(let p=u.length-1;p>=0;p--){const m=u[p];n.deleteFilter(m)&&(m.delete(a),h=!0)}n.currStackItem=h?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},n);const s=n.currStackItem;if(s!=null){const a=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:s,type:t,changedParentTypes:a,origin:n},n]),n.currStackItem=null}return s};class p_ extends vk{constructor(e,{captureTimeout:t=500,captureTransaction:r=l=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:a=Xa(e)?e[0].doc:e instanceof Di?e:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=i,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=s,this.captureTimeout=t,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(g=>l.changedParentTypes.has(g)||g===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const c=this.undoing,d=this.redoing,u=c?this.redoStack:this.undoStack;c?this.stopCapturing():d||this.clear(!1,!0);const h=new ml;l.afterState.forEach((g,y)=>{const w=l.beforeState.get(y)||0,_=g-w;_>0&&_c(h,y,w,_)});const p=ZO();let m=!1;if(this.lastChange>0&&p-this.lastChange<this.captureTimeout&&u.length>0&&!c&&!d){const g=u[u.length-1];g.deletions=Dm([g.deletions,l.deleteSet]),g.insertions=Dm([g.insertions,h])}else u.push(new NR(l.deleteSet,h)),m=!0;!c&&!d&&(this.lastChange=p),Jo(l,l.deleteSet,g=>{g instanceof Pt&&this.scope.some(y=>y===l.doc||Cc(y,g))&&Mv(g,!0)});const v=[{stackItem:u[u.length-1],origin:l.origin,type:c?"redo":"undo",changedParentTypes:l.changedParentTypes},this];m?this.emit("stack-item-added",v):this.emit("stack-item-updated",v)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const t=new Set(this.scope);e=Xa(e)?e:[e],e.forEach(r=>{t.has(r)||(t.add(r),(r instanceof xn?r.doc!==this.doc:r!==this.doc)&&Gk("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>n0(r,this,i)),this.undoStack=[]),t&&(this.redoStack.forEach(i=>n0(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=r0(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=r0(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*IR(n){const e=ct(n.restDecoder);for(let t=0;t<e;t++){const r=ct(n.restDecoder),i=n.readClient();let o=ct(n.restDecoder);for(let s=0;s<r;s++){const a=n.readInfo();if(a===10){const l=ct(n.restDecoder);yield new Ir($e(i,o),l),o+=l}else if((Xf&a)!==0){const l=(a&(eo|Yn))===0,c=new Pt($e(i,o),null,(a&Yn)===Yn?n.readLeftID():null,null,(a&eo)===eo?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(a&yc)===yc?n.readString():null,I_(n,a));yield c,o+=c.length}else{const l=n.readLen();yield new Nr($e(i,o),l),o+=l}}}}class kv{constructor(e,t){this.gen=IR(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===Ir);return this.curr}}class _v{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const PR=n=>Bu(n,r_,ad),LR=(n,e)=>{if(n.constructor===Nr){const{client:t,clock:r}=n.id;return new Nr($e(t,r+e),n.length-e)}else if(n.constructor===Ir){const{client:t,clock:r}=n.id;return new Ir($e(t,r+e),n.length-e)}else{const t=n,{client:r,clock:i}=t.id;return new Pt($e(r,i+e),null,$e(r,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},Bu=(n,e=nl,t=Bs)=>{if(n.length===1)return n[0];const r=n.map(d=>new e(fl(d)));let i=r.map(d=>new kv(d,!0)),o=null;const s=new t,a=new _v(s);for(;i=i.filter(h=>h.curr!==null),i.sort((h,p)=>{if(h.curr.id.client===p.curr.id.client){const m=h.curr.id.clock-p.curr.id.clock;return m===0?h.curr.constructor===p.curr.constructor?0:h.curr.constructor===Ir?1:-1:m}else return p.curr.id.client-h.curr.id.client}),i.length!==0;){const d=i[0],u=d.curr.id.client;if(o!==null){let h=d.curr,p=!1;for(;h!==null&&h.id.clock+h.length<=o.struct.id.clock+o.struct.length&&h.id.client>=o.struct.id.client;)h=d.next(),p=!0;if(h===null||h.id.client!==u||p&&h.id.clock>o.struct.id.clock+o.struct.length)continue;if(u!==o.struct.id.client)xo(a,o.struct,o.offset),o={struct:h,offset:0},d.next();else if(o.struct.id.clock+o.struct.length<h.id.clock)if(o.struct.constructor===Ir)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{xo(a,o.struct,o.offset);const m=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new Ir($e(u,o.struct.id.clock+o.struct.length),m),offset:0}}else{const m=o.struct.id.clock+o.struct.length-h.id.clock;m>0&&(o.struct.constructor===Ir?o.struct.length-=m:h=LR(h,m)),o.struct.mergeWith(h)||(xo(a,o.struct,o.offset),o={struct:h,offset:0},d.next())}}else o={struct:d.curr,offset:0},d.next();for(let h=d.curr;h!==null&&h.id.client===u&&h.id.clock===o.struct.id.clock+o.struct.length&&h.constructor!==Ir;h=d.next())xo(a,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(xo(a,o.struct,o.offset),o=null),Sv(a);const l=r.map(d=>bv(d)),c=Dm(l);return vl(s,c),s.toUint8Array()},zR=(n,e,t=nl,r=Bs)=>{const i=s_(e),o=new r,s=new _v(o),a=new t(fl(n)),l=new kv(a,!1);for(;l.curr;){const d=l.curr,u=d.id.client,h=i.get(u)||0;if(l.curr.constructor===Ir){l.next();continue}if(d.id.clock+d.length>h)for(xo(s,d,oi(h-d.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)xo(s,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=h;)l.next()}Sv(s);const c=bv(a);return vl(o,c),o.toUint8Array()},m_=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:ei(n.encoder.restEncoder)}),n.encoder.restEncoder=od(),n.written=0)},xo=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&m_(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),ht(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},Sv=n=>{m_(n);const e=n.encoder.restEncoder;ht(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];ht(e,r.written),Qf(e,r.restEncoder)}},FR=(n,e,t,r)=>{const i=new t(fl(n)),o=new kv(i,!1),s=new r,a=new _v(s);for(let c=o.curr;c!==null;c=o.next())xo(a,e(c),0);Sv(a);const l=bv(i);return vl(s,l),s.toUint8Array()},BR=n=>FR(n,iD,nl,ad),i0="You must not compute changes after the event-handler fired.";class sh{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||(this._path=HR(this.currentTarget,this.target))}deletes(e){return gl(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Oi(i0);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(i=>{if(i!==null){const o=t._map.get(i);let s,a;if(this.adds(o)){let l=o.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(o))if(l!==null&&this.deletes(l))s="delete",a=$h(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",a=$h(l.content.getContent())):(s="add",a=void 0)}else if(this.deletes(o))s="delete",a=$h(o.content.getContent());else return;e.set(i,{action:s,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Oi(i0);const t=this.target,r=Fs(),i=Fs(),o=[];if(e={added:r,deleted:i,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let a=null;const l=()=>{a&&o.push(a)};for(let c=t._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,i.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const HR=(n,e)=>{const t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;t.unshift(r)}e=e._item.parent}return t},Fn=()=>{Gk("Invalid access: Add Yjs type to a document before reading data.")},g_=80;let Cv=0;class VR{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Cv++}}const UR=n=>{n.timestamp=Cv++},v_=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=Cv++},jR=(n,e,t)=>{if(n.length>=g_){const r=n.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return v_(r,e,t),r}else{const r=new VR(e,t);return n.push(r),r}},ah=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;const t=n._searchMarker.length===0?null:n._searchMarker.reduce((o,s)=>ru(e-o.index)<ru(e-s.index)?o:s);let r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,UR(t));r.right!==null&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return t!==null&&ru(t.index-i)<r.parent.length/g_?(v_(t,r,i),t):jR(n._searchMarker,r,i)},Ec=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){const i=n[r];if(t>0){let o=i.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(i.index-=o.length);if(o===null||o.marker===!0){n.splice(r,1);continue}i.p=o,o.marker=!0}(e<i.index||t>0&&e===i.index)&&(i.index=oi(e,i.index+t))}},lh=(n,e,t)=>{const r=n,i=e.changedParentTypes;for(;Li(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;l_(r._eH,t,e)};class xn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Yb(),this._dEH=Yb(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Hr()}clone(){throw Hr()}_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){Gb(this._eH,e)}observeDeep(e){Gb(this._dEH,e)}unobserve(e){Xb(this._eH,e)}unobserveDeep(e){Xb(this._dEH,e)}toJSON(){}}const y_=(n,e,t)=>{n.doc??Fn(),e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e;const i=[];let o=n._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const s=o.content.getContent();if(s.length<=e)e-=s.length;else{for(let a=e;a<s.length&&r>0;a++)i.push(s[a]),r--;e=0}}o=o.right}return i},b_=n=>{n.doc??Fn();const e=[];let t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){const r=t.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}t=t.right}return e},w_=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&is(r,e)){const i=r.content.getContent();for(let o=0;o<i.length;o++)t.push(i[o])}r=r.right}return t},Ac=(n,e)=>{let t=0,r=n._start;for(n.doc??Fn();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let o=0;o<i.length;o++)e(i[o],t++,n)}r=r.right}},x_=(n,e)=>{const t=[];return Ac(n,(r,i)=>{t.push(e(r,i,n))}),t},WR=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}const i=t[r++];return t.length<=r&&(t=null),{done:!1,value:i}}}},k_=(n,e)=>{n.doc??Fn();const t=ah(n,e);let r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Hu=(n,e,t,r)=>{let i=t;const o=n.doc,s=o.clientID,a=o.store,l=t===null?e._start:t.right;let c=[];const d=()=>{c.length>0&&(i=new Pt($e(s,Qt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Vs(c)),i.integrate(n,0),c=[])};r.forEach(u=>{if(u===null)c.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(u);break;default:switch(d(),u.constructor){case Uint8Array:case ArrayBuffer:i=new Pt($e(s,Qt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new cd(new Uint8Array(u))),i.integrate(n,0);break;case Di:i=new Pt($e(s,Qt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new dd(u)),i.integrate(n,0);break;default:if(u instanceof xn)i=new Pt($e(s,Qt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new li(u)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},__=()=>Oi("Length exceeded!"),S_=(n,e,t,r)=>{if(t>e._length)throw __();if(t===0)return e._searchMarker&&Ec(e._searchMarker,t,r.length),Hu(n,e,null,r);const i=t,o=ah(e,t);let s=e._start;for(o!==null&&(s=o.p,t-=o.index,t===0&&(s=s.prev,t+=s&&s.countable&&!s.deleted?s.length:0));s!==null;s=s.right)if(!s.deleted&&s.countable){if(t<=s.length){t<s.length&&ir(n,$e(s.id.client,s.id.clock+t));break}t-=s.length}return e._searchMarker&&Ec(e._searchMarker,i,r.length),Hu(n,e,s,r)},KR=(n,e,t)=>{let i=(e._searchMarker||[]).reduce((o,s)=>s.index>o.index?s:o,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return Hu(n,e,i,t)},C_=(n,e,t,r)=>{if(r===0)return;const i=t,o=r,s=ah(e,t);let a=e._start;for(s!==null&&(a=s.p,t-=s.index);a!==null&&t>0;a=a.right)!a.deleted&&a.countable&&(t<a.length&&ir(n,$e(a.id.client,a.id.clock+t)),t-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&ir(n,$e(a.id.client,a.id.clock+r)),a.delete(n),r-=a.length),a=a.right;if(r>0)throw __();e._searchMarker&&Ec(e._searchMarker,i,-o+r)},Vu=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},Tv=(n,e,t,r)=>{const i=e._map.get(t)||null,o=n.doc,s=o.clientID;let a;if(r==null)a=new Vs([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new Vs([r]);break;case Uint8Array:a=new cd(r);break;case Di:a=new dd(r);break;default:if(r instanceof xn)a=new li(r);else throw new Error("Unexpected content type")}new Pt($e(s,Qt(o.store,s)),i,i&&i.lastId,null,null,e,t,a).integrate(n,0)},Ev=(n,e)=>{n.doc??Fn();const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},T_=n=>{const e={};return n.doc??Fn(),n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},E_=(n,e)=>{n.doc??Fn();const t=n._map.get(e);return t!==void 0&&!t.deleted},qR=(n,e)=>{const t={};return n._map.forEach((r,i)=>{let o=r;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&is(o,e)&&(t[i]=o.content.getContent()[o.length-1])}),t},Td=n=>(n.doc??Fn(),lR(n._map.entries(),e=>!e[1].deleted));class JR extends sh{}class Ca extends xn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new Ca;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ca}clone(){const e=new Ca;return e.insert(0,this.toArray().map(t=>t instanceof xn?t.clone():t)),e}get length(){return this.doc??Fn(),this._length}_callObserver(e,t){super._callObserver(e,t),lh(this,e,new JR(this,e))}insert(e,t){this.doc!==null?Ot(this.doc,r=>{S_(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?Ot(this.doc,t=>{KR(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?Ot(this.doc,r=>{C_(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return k_(this,e)}toArray(){return b_(this)}slice(e=0,t=this.length){return y_(this,e,t)}toJSON(){return this.map(e=>e instanceof xn?e.toJSON():e)}map(e){return x_(this,e)}forEach(e){Ac(this,e)}[Symbol.iterator](){return WR(this)}_write(e){e.writeTypeRef(yN)}}const ZR=n=>new Ca;class YR extends sh{constructor(e,t,r){super(e,t),this.keysChanged=r}}class rl extends xn{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((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new rl}clone(){const e=new rl;return this.forEach((t,r)=>{e.set(r,t instanceof xn?t.clone():t)}),e}_callObserver(e,t){lh(this,e,new YR(this,e,t))}toJSON(){this.doc??Fn();const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[r]=i instanceof xn?i.toJSON():i}}),e}get size(){return[...Td(this)].length}keys(){return sp(Td(this),e=>e[0])}values(){return sp(Td(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return sp(Td(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Fn(),this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Ot(this.doc,t=>{Vu(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?Ot(this.doc,r=>{Tv(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return Ev(this,e)}has(e){return E_(this,e)}clear(){this.doc!==null?Ot(this.doc,e=>{this.forEach(function(t,r,i){Vu(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(bN)}}const GR=n=>new rl,Ro=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&nD(n,e);class Pm{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&Hn(),this.right.content.constructor){case sn:this.right.deleted||yl(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const o0=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case sn:e.right.deleted||yl(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&ir(n,$e(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},Ed=(n,e,t,r)=>{const i=new Map,o=r?ah(e,t):null;if(o){const s=new Pm(o.p.left,o.p,o.index,i);return o0(n,s,t-o.index)}else{const s=new Pm(null,e._start,0,i);return o0(n,s,t)}},A_=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===sn&&Ro(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();const i=n.doc,o=i.clientID;r.forEach((s,a)=>{const l=t.left,c=t.right,d=new Pt($e(o,Qt(i.store,o)),l,l&&l.lastId,c,c&&c.id,e,null,new sn(a,s));d.integrate(n,0),t.right=d,t.forward()})},yl=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},M_=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===sn&&Ro(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},O_=(n,e,t,r)=>{const i=n.doc,o=i.clientID,s=new Map;for(const a in r){const l=r[a],c=t.currentAttributes.get(a)??null;if(!Ro(c,l)){s.set(a,c);const{left:d,right:u}=t;t.right=new Pt($e(o,Qt(i.store,o)),d,d&&d.lastId,u,u&&u.id,e,null,new sn(a,l)),t.right.integrate(n,0),t.forward()}}return s},cp=(n,e,t,r,i)=>{t.currentAttributes.forEach((h,p)=>{i[p]===void 0&&(i[p]=null)});const o=n.doc,s=o.clientID;M_(t,i);const a=O_(n,e,t,i),l=r.constructor===String?new ai(r):r instanceof xn?new li(r):new Qs(r);let{left:c,right:d,index:u}=t;e._searchMarker&&Ec(e._searchMarker,t.index,l.getLength()),d=new Pt($e(s,Qt(o.store,s)),c,c&&c.lastId,d,d&&d.id,e,null,l),d.integrate(n,0),t.right=d,t.index=u,t.forward(),A_(n,e,t,a)},s0=(n,e,t,r,i)=>{const o=n.doc,s=o.clientID;M_(t,i);const a=O_(n,e,t,i);e:for(;t.right!==null&&(r>0||a.size>0&&(t.right.deleted||t.right.content.constructor===sn));){if(!t.right.deleted)switch(t.right.content.constructor){case sn:{const{key:l,value:c}=t.right.content,d=i[l];if(d!==void 0){if(Ro(d,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}t.right.delete(n)}else t.currentAttributes.set(l,c);break}default:r<t.right.length&&ir(n,$e(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
48
|
+
`;t.right=new Pt($e(s,Qt(o.store,s)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new ai(l)),t.right.integrate(n,0),t.forward()}A_(n,e,t,a)},D_=(n,e,t,r,i)=>{let o=e;const s=Br();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===sn){const c=o.content;s.set(c.key,c)}o=o.right}let a=0,l=!1;for(;e!==o;){if(t===e&&(l=!0),!e.deleted){const c=e.content;switch(c.constructor){case sn:{const{key:d,value:u}=c,h=r.get(d)??null;(s.get(d)!==c||h===u)&&(e.delete(n),a++,!l&&(i.get(d)??null)===u&&h!==u&&(h===null?i.delete(d):i.set(d,h))),!l&&!e.deleted&&yl(i,c);break}}}e=e.right}return a},XR=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===sn){const r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},QR=n=>{let e=0;return Ot(n.doc,t=>{let r=n._start,i=n._start,o=Br();const s=Cm(o);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case sn:yl(s,i.content);break;default:e+=D_(t,r,i,o,s),o=Cm(s),r=i;break}i=i.right}}),e},$R=n=>{const e=new Set,t=n.doc;for(const[r,i]of n.afterState.entries()){const o=n.beforeState.get(r)||0;i!==o&&f_(n,t.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===sn&&s.constructor!==Nr&&e.add(s.parent)})}Ot(t,r=>{Jo(n,n.deleteSet,i=>{if(i instanceof Nr||!i.parent._hasFormatting||e.has(i.parent))return;const o=i.parent;i.content.constructor===sn?e.add(o):XR(r,i)});for(const i of e)QR(i)})},a0=(n,e,t)=>{const r=t,i=Cm(e.currentAttributes),o=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case li:case Qs:case ai:t<e.right.length&&ir(n,$e(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}o&&D_(n,o,e.right,i,e.currentAttributes);const s=(e.left||e.right).parent;return s._searchMarker&&Ec(s._searchMarker,e.index,-r+t),e};class eN extends sh{constructor(e,t,r){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];Ot(e,r=>{const i=new Map,o=new Map;let s=this.target._start,a=null;const l={};let c="",d=0,u=0;const h=()=>{if(a!==null){let p=null;switch(a){case"delete":u>0&&(p={delete:u}),u=0;break;case"insert":(typeof c=="object"||c.length>0)&&(p={insert:c},i.size>0&&(p.attributes={},i.forEach((m,v)=>{m!==null&&(p.attributes[v]=m)}))),c="";break;case"retain":d>0&&(p={retain:d},tD(l)||(p.attributes=$O({},l))),d=0;break}p&&t.push(p),a=null}};for(;s!==null;){switch(s.content.constructor){case li:case Qs:this.adds(s)?this.deletes(s)||(h(),a="insert",c=s.content.getContent()[0],h()):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),u+=1):s.deleted||(a!=="retain"&&(h(),a="retain"),d+=1);break;case ai:this.adds(s)?this.deletes(s)||(a!=="insert"&&(h(),a="insert"),c+=s.content.str):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),u+=s.length):s.deleted||(a!=="retain"&&(h(),a="retain"),d+=s.length);break;case sn:{const{key:p,value:m}=s.content;if(this.adds(s)){if(!this.deletes(s)){const v=i.get(p)??null;Ro(v,m)?m!==null&&s.delete(r):(a==="retain"&&h(),Ro(m,o.get(p)??null)?delete l[p]:l[p]=m)}}else if(this.deletes(s)){o.set(p,m);const v=i.get(p)??null;Ro(v,m)||(a==="retain"&&h(),l[p]=v)}else if(!s.deleted){o.set(p,m);const v=l[p];v!==void 0&&(Ro(v,m)?v!==null&&s.delete(r):(a==="retain"&&h(),m===null?delete l[p]:l[p]=m))}s.deleted||(a==="insert"&&h(),yl(i,s.content));break}}s=s.right}for(h();t.length>0;){const p=t[t.length-1];if(p.retain!==void 0&&p.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class Zo extends xn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Fn(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new Zo}clone(){const e=new Zo;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const r=new eN(this,e,t);lh(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Fn();let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===ai&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?Ot(this.doc,r=>{const i=new Pm(null,this._start,0,new Map);for(let o=0;o<e.length;o++){const s=e[o];if(s.insert!==void 0){const a=!t&&typeof s.insert=="string"&&o===e.length-1&&i.right===null&&s.insert.slice(-1)===`
|
|
49
|
+
`?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&cp(r,this,i,a,s.attributes||{})}else s.retain!==void 0?s0(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&a0(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??Fn();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const u={};let h=!1;o.forEach((m,v)=>{h=!0,u[v]=m});const p={insert:a};h&&(p.attributes=u),i.push(p),a=""}}const d=()=>{for(;l!==null;){if(is(l,e)||t!==void 0&&is(l,t))switch(l.content.constructor){case ai:{const u=o.get("ychange");e!==void 0&&!is(l,e)?(u===void 0||u.user!==l.id.client||u.type!=="removed")&&(c(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):t!==void 0&&!is(l,t)?(u===void 0||u.user!==l.id.client||u.type!=="added")&&(c(),o.set("ychange",r?r("added",l.id):{type:"added"})):u!==void 0&&(c(),o.delete("ychange")),a+=l.content.str;break}case li:case Qs:{c();const u={insert:l.content.getContent()[0]};if(o.size>0){const h={};u.attributes=h,o.forEach((p,m)=>{h[m]=p})}i.push(u);break}case sn:is(l,e)&&(c(),yl(o,l.content));break}l=l.right}c()};return e||t?Ot(s,u=>{e&&Nm(u,e),t&&Nm(u,t),d()},"cleanup"):d(),i}insert(e,t,r){if(t.length<=0)return;const i=this.doc;i!==null?Ot(i,o=>{const s=Ed(o,this,e,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),cp(o,this,s,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const i=this.doc;i!==null?Ot(i,o=>{const s=Ed(o,this,e,!r);cp(o,this,s,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;const r=this.doc;r!==null?Ot(r,i=>{a0(i,Ed(i,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;const i=this.doc;i!==null?Ot(i,o=>{const s=Ed(o,this,e,!1);s.right!==null&&s0(o,this,s,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?Ot(this.doc,t=>{Vu(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?Ot(this.doc,r=>{Tv(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return Ev(this,e)}getAttributes(){return T_(this)}_write(e){e.writeTypeRef(wN)}}const tN=n=>new Zo;class dp{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Fn()}[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===on||t.constructor===Hs)&&t._start!==null)e=t._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Hs extends xn{constructor(){super(),this._prelimContent=[]}get firstChild(){const 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 Hs}clone(){const e=new Hs;return e.insert(0,this.toArray().map(t=>t instanceof xn?t.clone():t)),e}get length(){return this.doc??Fn(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new dp(this,e)}querySelector(e){e=e.toUpperCase();const r=new dp(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),qo(new dp(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){lh(this,e,new iN(this,t,e))}toString(){return x_(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Ac(this,o=>{i.insertBefore(o.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?Ot(this.doc,r=>{S_(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)Ot(this.doc,r=>{const i=e&&e instanceof xn?e._item:e;Hu(r,this,i,t)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(o=>o===e)+1;if(i===0&&e!==null)throw Oi("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?Ot(this.doc,r=>{C_(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return b_(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return k_(this,e)}slice(e=0,t=this.length){return y_(this,e,t)}forEach(e){Ac(this,e)}_write(e){e.writeTypeRef(kN)}}const nN=n=>new Hs;class on extends Hs{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new on(this.nodeName)}clone(){const e=new on(this.nodeName),t=this.getAttributes();return eD(t,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof xn?r.clone():r)),e}toString(){const e=this.getAttributes(),t=[],r=[];for(const a in e)r.push(a);r.sort();const i=r.length;for(let a=0;a<i;a++){const l=r[a];t.push(l+'="'+e[l]+'"')}const o=this.nodeName.toLocaleLowerCase(),s=t.length>0?" "+t.join(" "):"";return`<${o}${s}>${super.toString()}</${o}>`}removeAttribute(e){this.doc!==null?Ot(this.doc,t=>{Vu(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?Ot(this.doc,r=>{Tv(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return Ev(this,e)}hasAttribute(e){return E_(this,e)}getAttributes(e){return e?qR(this,e):T_(this)}toDOM(e=document,t={},r){const i=e.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const a=o[s];typeof a=="string"&&i.setAttribute(s,a)}return Ac(this,s=>{i.appendChild(s.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(xN),e.writeKey(this.nodeName)}}const rN=n=>new on(n.readKey());class iN extends sh{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class Uu extends rl{constructor(e){super(),this.hookName=e}_copy(){return new Uu(this.hookName)}clone(){const e=new Uu(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){const i=t[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(_N),e.writeKey(this.hookName)}}const oN=n=>new Uu(n.readKey());class In extends Zo{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new In}clone(){const e=new In;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const t=[];for(const i in e.attributes){const o=[];for(const s in e.attributes[i])o.push({key:s,value:e.attributes[i][s]});o.sort((s,a)=>s.key<a.key?-1:1),t.push({nodeName:i,attrs:o})}t.sort((i,o)=>i.nodeName<o.nodeName?-1:1);let r="";for(let i=0;i<t.length;i++){const o=t[i];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){const a=o.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=e.insert;for(let i=t.length-1;i>=0;i--)r+=`</${t[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(SN)}}const sN=n=>new In;class Av{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Hr()}mergeWith(e){return!1}write(e,t,r){throw Hr()}integrate(e,t){throw Hr()}}const aN=0;class Nr extends Av{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),u_(e.doc.store,this)}write(e,t){e.writeInfo(aN),e.writeLen(this.length-t)}getMissing(e,t){return null}}class cd{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new cd(this.content)}splice(e){throw Hr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const lN=n=>new cd(n.readBuf());class Mc{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Mc(this.len)}splice(e){const t=new Mc(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){_c(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const cN=n=>new Mc(n.readLen()),R_=(n,e)=>new Di({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class dd{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const 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 dd(R_(this.doc.guid,this.opts))}splice(e){throw Hr()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const dN=n=>new dd(R_(n.readString(),n.readAny()));class Qs{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Qs(this.embed)}splice(e){throw Hr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const uN=n=>new Qs(n.readJSON());class sn{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new sn(this.key,this.value)}splice(e){throw Hr()}mergeWith(e){return!1}integrate(e,t){const r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const fN=n=>new sn(n.readKey(),n.readJSON());class ju{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ju(this.arr)}splice(e){const t=new ju(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const o=this.arr[i];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}const hN=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++){const i=n.readString();i==="undefined"?t.push(void 0):t.push(JSON.parse(i))}return new ju(t)},pN=Iu("node_env")==="development";class Vs{constructor(e){this.arr=e,pN&&Tk(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Vs(this.arr)}splice(e){const t=new Vs(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const o=this.arr[i];e.writeAny(o)}}getRef(){return 8}}const mN=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new Vs(t)};class ai{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new ai(this.str)}splice(e){const t=new ai(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}const gN=n=>new ai(n.readString()),vN=[ZR,GR,tN,rN,nN,oN,sN],yN=0,bN=1,wN=2,xN=3,kN=4,_N=5,SN=6;class li{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new li(this.type._copy())}splice(e){throw Hr()}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(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const CN=n=>new li(vN[n.readTypeRef()](n)),Lm=(n,e)=>{let t=e,r=0,i;do r>0&&(t=$e(t.client,t.clock+r)),i=Sa(n,t),r=t.clock-i.id.clock,t=i.redone;while(t!==null&&i instanceof Pt);return{item:i,diff:r}},Mv=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},Wu=(n,e,t)=>{const{client:r,clock:i}=e.id,o=new Pt($e(r,i+t),e,$e(r,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=$e(e.redone.client,e.redone.clock+t)),e.right=o,o.right!==null&&(o.right.left=o),n._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=t,o},l0=(n,e)=>ov(n,t=>gl(t.deletions,e)),N_=(n,e,t,r,i,o)=>{const s=n.doc,a=s.store,l=s.clientID,c=e.redone;if(c!==null)return ir(n,c);let d=e.parent._item,u=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!t.has(d)||N_(n,d,t,r,i,o)===null))return null;for(;d.redone!==null;)d=ir(n,d.redone)}const p=d===null?e.parent:d.content.type;if(e.parentSub===null){for(u=e.left,h=e;u!==null;){let y=u;for(;y!==null&&y.parent._item!==d;)y=y.redone===null?null:ir(n,y.redone);if(y!==null&&y.parent._item===d){u=y;break}u=u.left}for(;h!==null;){let y=h;for(;y!==null&&y.parent._item!==d;)y=y.redone===null?null:ir(n,y.redone);if(y!==null&&y.parent._item===d){h=y;break}h=h.right}}else if(h=null,e.right&&!i){for(u=e;u!==null&&u.right!==null&&(u.right.redone||gl(r,u.right.id)||l0(o.undoStack,u.right.id)||l0(o.redoStack,u.right.id));)for(u=u.right;u.redone;)u=ir(n,u.redone);if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;const m=Qt(a,l),v=$e(l,m),g=new Pt(v,u,u&&u.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=v,Mv(g,!0),g.integrate(n,0),g};let Pt=class zm extends Av{constructor(e,t,r,i,o,s,a,l){super(e,l.getLength()),this.origin=r,this.left=t,this.right=i,this.rightOrigin=o,this.parent=s,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?Lb:0}set marker(e){(this.info&tp)>0!==e&&(this.info^=tp)}get marker(){return(this.info&tp)>0}get keep(){return(this.info&Pb)>0}set keep(e){this.keep!==e&&(this.info^=Pb)}get countable(){return(this.info&Lb)>0}get deleted(){return(this.info&ep)>0}set deleted(e){this.deleted!==e&&(this.info^=ep)}markDeleted(){this.info|=ep}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Qt(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Qt(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===_a&&this.id.client!==this.parent.client&&this.parent.clock>=Qt(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=$b(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=ir(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Nr||this.right&&this.right.constructor===Nr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===zm?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===zm&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===_a){const r=Sa(t,this.parent);r.constructor===Nr?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=$b(e,e.doc.store,$e(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 r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,s=new Set;for(;i!==null&&i!==this.right;){if(s.add(i),o.add(i),ma(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(ma(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(Sa(e.doc.store,i.origin)))o.has(Sa(e.doc.store,i.origin))||(r=i,o.clear());else break;i=i.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),u_(e.doc.store,this),this.content.integrate(e,this),t0(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Nr(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:$e(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ma(e.origin,this.lastId)&&this.right===e&&ma(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),_c(e.deleteSet,this.id.client,this.id.clock,this.length),t0(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw Hn();this.content.gc(e),t?MR(e,this,new Nr(this.id,this.length)):this.content=new Mc(this.length)}write(e,t){const r=t>0?$e(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&Xf|(r===null?0:Yn)|(i===null?0:eo)|(o===null?0:yc);if(e.writeInfo(s),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=Sc(a);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===_a?(e.writeParentInfo(!1),e.writeLeftID(a)):Hn();o!==null&&e.writeString(o)}this.content.write(e,t)}};const I_=(n,e)=>TN[e&Xf](n),TN=[()=>{Hn()},cN,hN,lN,gN,uN,fN,CN,mN,dN,()=>{Hn()}],EN=10;class Ir extends Av{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){Hn()}write(e,t){e.writeInfo(EN),ht(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const P_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},L_="__ $YJS$ __";P_[L_]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");P_[L_]=!0;function Ov(n){return`${n}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Fm(){return Ov("ann")}function AN(){return Ov("msg")}function MN(n){return Ov(n)}function z_(n){return n?n+1:0}function ch(n){let e=0;return n.forEach(t=>{t.isText?e+=t.text.length:t.type.name==="hardBreak"&&(e+=1)}),e}function ud(n){if(n.isTextblock)return ch(n);let e=0;for(let t=0;t<n.childCount;t++)t>0&&(e+=1),e+=ud(n.child(t));return e}function F_(n,e,t){if(n.isTextblock)return Dn(t+Math.min(e,ch(n)));let r=0,i=t;for(let o=0;o<n.childCount;o++){const s=n.child(o),a=i+1;o>0&&(r+=1);const l=ud(s);if(r+l>e)return F_(s,e-r,a);r+=l,i+=s.nodeSize}return Dn(t+n.content.size)}function Yo(n,e){let t=0,r=0;const i=n.childCount;for(let o=0;o<i;o++){const s=n.child(o),a=r+1,l=s.type.name==="heading"?z_(s.attrs.level||1):0,c=ud(s),d=l+c;if(t+d>e){const u=e-t,h=Math.max(0,u-l);return F_(s,h,a)}if(t+=d,r+=s.nodeSize,o<i-1&&(t+=1,t>e))return Dn(a+s.content.size)}return Dn(n.content.size)}function B_(n,e,t){if(n.isTextblock)return Math.min(e-t,ch(n));let r=0,i=t;for(let o=0;o<n.childCount;o++){const s=n.child(o),a=i+1;o>0&&(r+=1);const l=i+s.nodeSize;if(e<l)return e<=a?r:r+B_(s,e,a);r+=ud(s),i+=s.nodeSize}return r}function ki(n,e){let t=0,r=0;const i=n.childCount;for(let o=0;o<i;o++){const s=n.child(o),a=r+1,l=s.type.name==="heading"?z_(s.attrs.level||1):0,c=ud(s),d=r+s.nodeSize;if(e<d)return e<=a?Qd(t+l):Qd(t+l+B_(s,e,a));t+=l+c,r+=s.nodeSize,o<i-1&&(t+=1)}return Qd(t)}function H_(n,e,t,r){if(e.isTextblock){let s=0;for(let a=0;a<n.length;a++){const l=n.get(a);if(l instanceof In){if(l===r.type)return Dn(t+Math.min(s+r.index,ch(e)));s+=l.length}}return null}let i=t;n.length!==e.childCount&&console.warn(`[positions] Y.js/PM child count mismatch: yEl(${n.nodeName}).length=${n.length} vs pmNode(${e.type.name}).childCount=${e.childCount}`);const o=Math.min(n.length,e.childCount);for(let s=0;s<o;s++){const a=n.get(s),l=e.child(s),c=i+1;if(a instanceof on){const d=H_(a,l,c,r);if(d!==null)return d}i+=l.nodeSize}return null}function c0(n,e,t){let r=0;const i=Math.min(n.childCount,e.length);for(let o=0;o<i;o++){const s=e.get(o),a=n.child(o),l=r+1;if(s instanceof on){const c=H_(s,a,l,t);if(c!==null)return c}r+=a.nodeSize}return null}function V_(n,e,t){let r,i;try{const l=As(t.fromRel),c=As(t.toRel);r=Rm(l,n),i=Rm(c,n)}catch(l){return console.warn("[positions] relRangeToPmPositions: failed to resolve relRange:",l),null}if(!r||!i)return null;const o=n.getXmlFragment("default"),s=c0(e,o,r),a=c0(e,o,i);return s===null||a===null?null:{from:s,to:a}}function Oc(n,e,t){if(n.relRange&&t){const r=V_(t,e,n.relRange);if(r&&r.from<=r.to)return{...r,method:"rel"};r&&console.warn(`[positions] annotationToPmRange: inverted rel range for ${n.id}, falling back to flat`)}return n.range?{from:Yo(e,n.range.from),to:Yo(e,n.range.to),method:"flat"}:null}function U_(n,e){return{from:ki(n,e.from),to:ki(n,e.to)}}function ON(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function DN(n){const e=ON(n),t=[];let r=e.replace(/```(\w*)\n?([\s\S]*?)```/g,(i,o,s)=>{const a=t.length,l=o?` class="language-${o}"`:"";return t.push(`<pre><code${l}>${s.trimEnd()}</code></pre>`),`\0BLOCK${a}\0`});r=r.replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`([^`\n]+)`/g,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,o,s)=>{const a=s.trim();return/^(https?:\/\/|mailto:|#)/i.test(a)?`<a href="${a}" target="_blank" rel="noopener noreferrer">${o}</a>`:o}).replace(/^[*-] (.+)$/gm,"<li>$1</li>").replace(/\n\n/g,"</p><p>").replace(/\n/g,"<br>");for(let i=0;i<t.length;i++)r=r.replace(`\0BLOCK${i}\0`,t[i]);return r}var RN=E('<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>'),NN=E('<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>'),IN=E('<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 Claude.</div>'),PN=E('<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>'),LN=E('<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>'),zN=E('<div class="chat-markdown svelte-15oag3v"></div>'),FN=E('<div style="white-space: pre-wrap; word-break: break-word;"> </div>'),BN=E('<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>'),HN=E("<span></span>"),VN=E('<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>'),UN=E('<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>'),jN=E('<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 style="flex: 1; overflow: auto; padding: var(--tandem-space-3); min-height: 0;"><!> <!> <!> <div></div></div> <!> <div style="padding: var(--tandem-space-2) var(--tandem-space-3); border-top: 1px solid var(--tandem-border); display: flex; gap: var(--tandem-space-2);"><textarea placeholder="Message Claude..." style="flex: 1; padding: var(--tandem-space-2); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-3); font-size: var(--tandem-text-base); resize: none; outline: none; font-family: inherit; background: var(--tandem-surface); color: var(--tandem-fg);"></textarea> <button>Send</button></div></div>');function d0(n,e){Pe(e,!0);const t=[0,.2,.4];let r=st(e,"inputEl",15,null);const i=F(()=>e.reduceMotion?"auto":"smooth");let o=B(at([])),s=B(""),a=B(void 0),l=B(void 0);le(()=>{r(f(l)??null)}),le(()=>{if(!e.ctrlYdoc)return;const T=e.ctrlYdoc.getMap(sb),R=()=>{const V=[];T.forEach(se=>{V.push(se)}),V.sort((se,he)=>se.timestamp-he.timestamp||se.id.localeCompare(he.id)),b(o,V,!0)};return T.observe(R),R(),()=>T.unobserve(R)});let c=!1;le(()=>{var V;f(o);const T=!!e.claudeActive,R=f(i);if(!T&&c){c=!1;return}c=T,(V=f(a))==null||V.scrollIntoView({behavior:R})}),le(()=>{var V;const T=e.visible,R=f(i);T&&((V=f(a))==null||V.scrollIntoView({behavior:R}))});const d=F(()=>f(o).filter(T=>T.author==="claude"&&!T.read).length);function u(){if(!e.ctrlYdoc||!f(s).trim())return;const T=e.ctrlYdoc.getMap(sb),R={id:AN(),author:"user",text:f(s).trim(),timestamp:Date.now(),...e.activeDocId?{documentId:e.activeDocId}:{},...e.capturedAnchor?{anchor:e.capturedAnchor}:{},read:!1};T.set(R.id,R),b(s,""),e.onCapturedAnchorChange(null)}function h(T){T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),u())}function p(T,R){if(!(!e.editor||R&&R!==e.activeDocId))try{const V=Yo(e.editor.state.doc,T.from),se=Yo(e.editor.state.doc,T.to);e.editor.chain().focus().setTextSelection({from:V,to:se}).scrollIntoView().run()}catch(V){console.warn("[ChatPanel] Could not scroll to anchor:",V instanceof Error?V.message:V)}}function m(T){if(!T)return null;const R=e.openDocs.find(V=>V.id===T);return(R==null?void 0:R.fileName)??null}async function v(){try{await fetch(`http://127.0.0.1:${Kf}${vA}`,{method:"DELETE"})}catch(T){console.warn("[ChatPanel] Failed to clear chat:",T)}}let g=B(at(new Set));function y(T){const R=new Set(f(g));R.has(T)?R.delete(T):R.add(T),b(g,R,!0)}var w=jN(),_=x(w),C=k(x(_)),A=x(C);{var j=T=>{var R=RN(),V=x(R);K(()=>$(V,f(d))),S(T,R)};Z(A,T=>{f(d)>0&&T(j)})}var H=k(A,2);{var D=T=>{var R=NN();L("click",R,v),S(T,R)};Z(H,T=>{f(o).length>0&&T(D)})}var N=k(_,2),W=x(N);{var ee=T=>{var R=IN();S(T,R)};Z(W,T=>{f(o).length===0&&T(ee)})}var z=k(W,2);dt(z,17,()=>f(o),T=>T.id,(T,R)=>{var V=BN(),se=x(V),he=x(se),we=x(he),ae=k(he,2);{var Q=Ve=>{var ce=PN(),Ie=x(ce);K(ge=>$(Ie,ge),[()=>m(f(R).documentId)??f(R).documentId]),S(Ve,ce)};Z(ae,Ve=>{f(R).documentId&&Ve(Q)})}var ie=k(ae,2),de=x(ie),Ce=k(se,2);{var _e=Ve=>{var ce=LN(),Ie=x(ce);K(ge=>{re(ce,`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: ${ge??""}; overflow: hidden; transition: max-height 0.3s ease;`),$(Ie,f(R).anchor.textSnapshot)},[()=>f(g).has(f(R).id)?"500px":"60px"]),L("click",ce,()=>p(f(R).anchor,f(R).documentId)),Et("mouseenter",ce,()=>y(f(R).id)),Et("mouseleave",ce,()=>y(f(R).id)),S(Ve,ce)};Z(Ce,Ve=>{f(R).anchor&&Ve(_e)})}var Oe=k(Ce,2);{var Re=Ve=>{var ce=zN();JE(ce,()=>DN(f(R).text),!0),S(Ve,ce)},tt=Ve=>{var ce=FN(),Ie=x(ce);K(()=>$(Ie,f(R).text)),S(Ve,ce)};Z(Oe,Ve=>{f(R).author==="claude"?Ve(Re):Ve(tt,-1)})}K(Ve=>{re(V,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${f(R).author==="user"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; border: 1px solid ${f(R).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);`),re(he,`font-weight: 600; font-size: 11px; color: ${f(R).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"}; text-transform: uppercase;`),$(we,f(R).author),$(de,Ve)},[()=>new Date(f(R).timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]),S(T,V)});var Y=k(z,2);{var te=T=>{var R=VN(),V=x(R);dt(V,20,()=>t,we=>we,(we,ae)=>{var Q=HN();K(()=>re(Q,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${ae??""}s infinite;`)),S(we,Q)});var se=k(V,2),he=x(se);K(()=>$(he,e.claudeStatus??"Claude is thinking...")),S(T,R)};Z(Y,T=>{e.claudeActive&&T(te)})}var ne=k(Y,2);gt(ne,T=>b(a,T),()=>f(a));var q=k(N,2);{var P=T=>{var R=UN(),V=x(R),se=x(V),he=k(V,2);K(we=>$(se,`with selection: “${we??""}${e.capturedAnchor.textSnapshot.length>40?"...":""}”`),[()=>e.capturedAnchor.textSnapshot.slice(0,40)]),L("click",he,()=>e.onCapturedAnchorChange(null)),S(T,R)};Z(q,T=>{e.capturedAnchor&&T(P)})}var M=k(q,2),O=x(M);G(O,"rows",2),gt(O,T=>b(l,T),()=>f(l));var I=k(O,2);K((T,R,V,se)=>{yr(O,f(s)),I.disabled=T,re(I,`padding: var(--tandem-space-2) var(--tandem-space-3); background: ${R??""}; color: ${V??""}; border: none; border-radius: var(--tandem-r-3); cursor: ${se??""}; font-size: var(--tandem-text-base); font-weight: 500; align-self: flex-end;`)},[()=>!f(s).trim(),()=>f(s).trim()?"var(--tandem-accent)":"var(--tandem-border-strong)",()=>f(s).trim()?"var(--tandem-accent-fg)":"var(--tandem-fg-subtle)",()=>f(s).trim()?"pointer":"default"]),L("input",O,T=>b(s,T.target.value,!0)),L("keydown",O,h),L("click",I,u),S(n,w),Le()}qe(["click","input","keydown"]);function il(n,e){const t=n,r=s=>{try{e(s)}catch(a){console.warn(`[sanitizeAnnotation] onLossy threw for ${s.kind}:`,a)}},i=t.audience==="private"||t.audience==="outbound"?t.audience:t.author==="import"||t.type==="highlight"||t.type==="note"||t.type==="flag"?"private":"outbound",o={id:t.id,author:t.author,range:t.range,content:t.content,status:t.status,timestamp:t.timestamp,...t.relRange!==void 0?{relRange:t.relRange}:{},...t.textSnapshot!==void 0?{textSnapshot:t.textSnapshot}:{},...t.editedAt!==void 0?{editedAt:t.editedAt}:{},...typeof t.rev=="number"?{rev:t.rev}:{},audience:i,...t.promotedFrom!==void 0?{promotedFrom:t.promotedFrom}:{},...t.importSource!==void 0?{importSource:t.importSource}:{}};if(o.audience==="outbound"&&t.author==="user"&&(t.type==="note"||t.type==="highlight"||t.type==="flag")&&(o.audience="private",r({kind:"audience-conflict-resolved",id:t.id})),t.type==="suggestion"){let s,a;try{const l=JSON.parse(t.content);s=l.newText,a=l.reason??""}catch{r({kind:"malformed-suggestion-json",id:t.id}),a=t.content}return{...o,type:"comment",content:a,suggestedText:s}}return t.type==="question"?(r({kind:"question-to-comment",id:t.id}),{...o,type:"comment"}):t.type==="highlight"?{...o,type:"highlight",color:t.color}:t.author==="import"&&t.type==="note"?(r({kind:"import-note-to-comment",id:t.id}),{...o,type:"comment"}):t.type==="flag"||t.type==="note"?(t.type==="flag"&&r({kind:"flag-to-note",id:t.id}),{...o,type:"note"}):t.type==="comment"?{...o,type:"comment",...t.suggestedText!==void 0?{suggestedText:t.suggestedText}:{}}:(r({kind:"unknown-type",id:t.id,rawType:t.type}),{...o,type:"comment"})}var WN=E('<button type="button" data-testid="apply-changes-btn"> </button>');function KN(n,e){Pe(e,!0);let t=B(!1);const r=F(()=>e.annotations.filter(d=>d.status==="accepted")),i=F(()=>e.annotations.filter(d=>d.status==="pending")),o=F(()=>f(r).length===0||f(t));async function s(){if(f(o)||!e.documentId)return;let d=`Apply ${f(r).length} change(s) as tracked revisions?
|
|
50
|
+
|
|
51
|
+
The changes will appear as tracked revisions in Word — you can Accept or Reject each one individually.
|
|
52
|
+
|
|
53
|
+
Your original file will be backed up.`;if(f(i).length>0&&(d+=`
|
|
54
|
+
|
|
55
|
+
⚠ ${f(i).length} annotation(s) are still pending review and will not be applied.`),!!confirm(d)){b(t,!0);try{const u=await fetch(`${Gn}${pA}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})}),h=await u.json().catch(m=>(console.error("[ApplyChanges] Failed to parse response JSON:",m),null));if(!u.ok){alert((h==null?void 0:h.message)??`Apply failed (HTTP ${u.status}).`);return}const p=h==null?void 0:h.data;if(p){const m=[`Applied ${p.applied??0} tracked change(s).`];p.rejected>0&&m.push(`${p.rejected} could not be applied.`),p.backupPath&&m.push(`
|
|
56
|
+
Backup saved to:
|
|
57
|
+
${p.backupPath}`),alert(m.join(" "))}else alert("Changes applied successfully.")}catch(u){console.error("[ApplyChanges] Request failed:",u),alert(u instanceof TypeError?"Could not reach the server.":`Apply failed: ${u instanceof Error?u.message:String(u)}`)}finally{b(t,!1)}}}var a=xt(),l=ye(a);{var c=d=>{var u=WN(),h=x(u);K(()=>{u.disabled=f(o),G(u,"title",f(r).length===0?"No accepted suggestions to apply":void 0),re(u,`width: 100%; padding: var(--tandem-space-1) var(--tandem-space-3); font-size: var(--tandem-text-xs); font-weight: 500; border: 1px solid ${f(o)?"var(--tandem-border)":"var(--tandem-info-border)"}; border-radius: var(--tandem-r-2); background: ${f(o)?"var(--tandem-surface-muted)":"var(--tandem-info)"}; color: ${f(o)?"var(--tandem-fg-subtle)":"var(--tandem-info-fg)"}; cursor: ${f(o)?"default":"pointer"}; opacity: ${f(t)?.6:1}; white-space: nowrap;`),$(h,f(t)?"Applying…":`Apply as Tracked Changes (${f(r).length})`)}),L("click",u,s),S(d,u)};Z(l,d=>{e.activeDocFormat==="docx"&&d(c)})}S(n,a),Le()}qe(["click"]);const ns={background:"var(--tandem-warning-bg)",border:"var(--tandem-warning-border)",color:"var(--tandem-warning-fg-strong)"};function dh(n,e){return n.type!=="comment"?[]:e??[]}var qN=E('<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;">Accept</button>'),JN=E('<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-error-bg); color: var(--tandem-error-fg-strong); cursor: pointer;">Reject</button>'),ZN=E('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),YN=E('<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-muted); color: var(--tandem-fg-muted); cursor: pointer;">Archive</button>'),GN=E('<button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-accent-border); border-radius: var(--tandem-r-1); background: var(--tandem-accent-bg); color: var(--tandem-accent); cursor: pointer;">Send to Claude</button>'),XN=E('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),QN=E('<button style="margin-top: 4px; 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-muted); color: var(--tandem-fg-muted); cursor: pointer;">Remove</button>'),$N=E(`<div style="font-size: var(--tandem-text-xs); color: var(--tandem-error-fg); margin-top: 2px;">Can't undo — text has changed.</div>`),eI=E('<div style="margin-top: 4px;"><button data-testid="undo-btn" style="padding: 1px 6px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-accent); cursor: pointer; text-decoration: underline;">Undo</button> <!></div>');function tI(n,e){Pe(e,!0);let t=B(!1),r=null;function i(){r&&(clearTimeout(r),r=null)}function o(h){if(h.stopPropagation(),!e.onUndo)return;const p=e.onUndo(e.annotationId);if(p){i(),b(t,!1);return}p||(b(t,!0),i(),r=setTimeout(()=>{b(t,!1),r=null},3e3))}ri(i);var s=xt(),a=ye(s);{var l=h=>{var p=ZN(),m=x(p);{var v=w=>{var _=qN();K(()=>G(_,"data-testid",`accept-btn-${e.annotationId??""}`)),L("click",_,C=>{C.stopPropagation(),e.onAccept(e.annotationId)}),S(w,_)};Z(m,w=>{e.onAccept&&w(v)})}var g=k(m,2);{var y=w=>{var _=JN();K(()=>G(_,"data-testid",`dismiss-btn-${e.annotationId??""}`)),L("click",_,C=>{C.stopPropagation(),e.onDismiss(e.annotationId)}),S(w,_)};Z(g,w=>{e.onDismiss&&w(y)})}S(h,p)},c=h=>{var p=XN(),m=x(p);{var v=w=>{var _=YN();K(()=>G(_,"data-testid",`archive-btn-${e.annotationId??""}`)),L("click",_,C=>{C.stopPropagation(),e.onRemove(e.annotationId)}),S(w,_)};Z(m,w=>{e.onRemove&&w(v)})}var g=k(m,2);{var y=w=>{var _=GN();K(()=>G(_,"data-testid",`send-to-claude-btn-${e.annotationId??""}`)),L("click",_,C=>{C.stopPropagation(),e.onSendToClaude(e.annotationId)}),S(w,_)};Z(g,w=>{e.onSendToClaude&&w(y)})}S(h,p)},d=h=>{var p=QN();K(()=>G(p,"data-testid",`remove-btn-${e.annotationId??""}`)),L("click",p,m=>{m.stopPropagation(),e.onRemove(e.annotationId)}),S(h,p)},u=h=>{var p=eI(),m=x(p),v=k(m,2);{var g=y=>{var w=$N();S(y,w)};Z(v,y=>{f(t)&&y(g)})}L("click",m,o),S(h,p)};Z(a,h=>{e.isPending&&!e.isEditing&&(e.onAccept||e.onDismiss)?h(l):e.isPending&&!e.isEditing&&e.annotationType==="note"?h(c,1):e.isPending&&!e.isEditing&&e.onRemove?h(d,2):!e.isPending&&e.undoable&&e.onUndo&&h(u,3)})}S(n,s),Le()}qe(["click"]);const Wl="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);",u0="padding: 4px 10px; 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;";var nI=E('<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),rI=E("<textarea></textarea>"),iI=E('<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 oI(n,e){Pe(e,!0);let t=B(null);le(()=>{var d;(d=f(t))==null||d.focus()});var r=iI(),i=x(r);{var o=d=>{var u=nI(),h=ye(u),p=k(h,2);gt(p,g=>b(t,g),()=>f(t));var m=k(p,2),v=k(m,2);K(()=>{G(h,"for",`edit-newtext-${e.annotationId??""}`),G(p,"id",`edit-newtext-${e.annotationId??""}`),G(p,"data-testid",`edit-newtext-${e.annotationId??""}`),yr(p,e.editNewText),re(p,Wl),G(m,"for",`edit-reason-${e.annotationId??""}`),G(v,"id",`edit-reason-${e.annotationId??""}`),G(v,"data-testid",`edit-reason-${e.annotationId??""}`),yr(v,e.editReason),re(v,Wl)}),L("input",p,g=>e.onChangeEditNewText(g.target.value)),L("keydown",p,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),L("input",v,g=>e.onChangeEditReason(g.target.value)),L("keydown",v,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),S(d,u)},s=d=>{var u=rI();gt(u,h=>b(t,h),()=>f(t)),K(()=>{G(u,"data-testid",`edit-text-${e.annotationId??""}`),yr(u,e.editText),re(u,Wl)}),L("input",u,h=>e.onChangeEditText(h.target.value)),L("keydown",u,function(...h){var p;(p=e.onKeyDown)==null||p.apply(this,h)}),S(d,u)};Z(i,d=>{e.hasSuggestedText?d(o):d(s,-1)})}var a=k(i,2),l=x(a),c=k(l,2);K(()=>{G(l,"data-testid",`edit-save-btn-${e.annotationId??""}`),G(c,"data-testid",`edit-cancel-btn-${e.annotationId??""}`)}),L("click",r,d=>d.stopPropagation()),L("keydown",r,d=>d.stopPropagation()),L("click",l,d=>{d.stopPropagation(),e.onSave()}),L("click",c,d=>{d.stopPropagation(),e.onCancel()}),S(n,r),Le()}qe(["click","keydown","input"]);function sI(n){return n==="claude"?"Claude":n==="import"?"Imported":"You"}function j_(n){return n.suggestedText!==void 0?"replacement":n.type}function aI(n,e){return n?n.length>e?n.slice(0,e-3)+"...":n:""}function lI(n){const e=j_(n),t=aI(n.content,60);return`${n.type==="note"?"private ":""}${e} annotation${t?": "+t:""}, ${n.status}`}function cI(n){return n.type==="highlight"&&n.color?fc[vx(n.color)]:"var(--tandem-author-user)"}var dI=E("<span> </span>"),uI=E(`<button style="padding: 1px 4px; font-size: 11px; border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer; line-height: 1;" title="Edit this annotation's content">✎ Edit</button>`),fI=E('<span style="font-style: italic; font-size: 10px; color: var(--tandem-fg-subtle);">(edited)</span>'),hI=E('<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px;"><span style="font-weight: 600; text-transform: capitalize; display: flex; align-items: center; gap: 6px; color: var(--tandem-fg-muted); font-size: 11px;"><span class="annotation-type-badge svelte-d1dbnh"> </span> <!> <!> <!></span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); display: flex; align-items: center; gap: 4px;"><!> </span></div>');function fd(n,e){Pe(e,!0);const t=F(()=>j_(e.annotation)),r=F(()=>sI(e.annotation.author));var i=hI(),o=x(i),s=x(o),a=x(s),l=k(s,2);{var c=w=>{var _=xt(),C=ye(_);Bg(C,()=>e.extraPill),S(w,_)};Z(l,w=>{e.extraPill&&w(c)})}var d=k(l,2);{var u=w=>{var _=dI(),C=x(_);K(()=>{re(_,`margin-left: 6px; font-size: 10px; color: ${e.annotation.status==="accepted"?"var(--tandem-success)":"var(--tandem-error)"}; font-weight: 600;`),$(C,e.annotation.status)}),S(w,_)};Z(d,w=>{e.isPending||w(u)})}var h=k(d,2);{var p=w=>{var _=uI();K(()=>G(_,"data-testid",`edit-btn-${e.annotation.id??""}`)),L("click",_,C=>{C.stopPropagation(),e.onEnterEdit()}),S(w,_)};Z(h,w=>{e.isPending&&e.canEdit&&!e.isReviewTarget&&!e.isEditing&&w(p)})}var m=k(o,2),v=x(m);{var g=w=>{var _=fI();S(w,_)};Z(v,w=>{e.annotation.editedAt&&w(g)})}var y=k(v);K(()=>{re(s,`font-family: var(--tandem-font-mono); font-size: var(--tandem-text-2xs); letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 7px; border-radius: var(--tandem-r-pill); background: ${e.badgeBg??""}; color: ${e.badgeFg??""};`),$(a,f(t)),$(y,` ${f(r)??""}`)}),S(n,i),Le()}qe(["click"]);var pI=E('<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 hd(n,e){Pe(e,!0);const t=F(()=>e.text?e.text.length>80?e.text.slice(0,77)+"...":e.text:"");var r=xt(),i=ye(r);{var o=s=>{var a=pI(),l=x(a);K(()=>{G(a,"data-testid",`annotation-snippet-${e.annotationId??""}`),$(l,f(t))}),S(s,a)};Z(i,s=>{e.text&&s(o)})}S(n,r),Le()}var mI=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),gI=E("<!> <!> <!>",1);function vI(n,e){Pe(e,!0);var t=gI(),r=ye(t);fd(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);hd(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=mI(),c=x(l),d=x(c);K(()=>$(d,e.annotation.content||"(no note)")),S(a,l)};Z(o,a=>{e.isEditing||a(s)})}S(n,t),Le()}var yI=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),bI=E("<!> <!> <!>",1);function wI(n,e){Pe(e,!0);var t=bI(),r=ye(t);fd(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);hd(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=yI(),c=x(l),d=x(c);K(()=>$(d,e.annotation.content||"(no note)")),S(a,l)};Z(o,a=>{e.isEditing||a(s)})}S(n,t),Le()}var xI=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),kI=E("<!> <!> <!>",1);function _I(n,e){Pe(e,!0);var t=kI(),r=ye(t);fd(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);hd(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=xI(),c=x(l),d=x(c);K(()=>$(d,e.annotation.content||"(no note)")),S(a,l)};Z(o,a=>{e.isEditing||a(s)})}S(n,t),Le()}var SI=E('<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>'),CI=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),TI=E("<!> <!> <!>",1);function EI(n,e){Pe(e,!0);var t=TI(),r=ye(t);fd(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-warning-bg)",badgeFg:"var(--tandem-warning-fg-strong)",get onEnterEdit(){return e.onEnterEdit},extraPill:l=>{var c=SI();S(l,c)},$$slots:{extraPill:!0}});var i=k(r,2);hd(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=CI(),c=x(l),d=x(c);K(()=>$(d,e.annotation.content||"(no note)")),S(a,l)};Z(o,a=>{e.isEditing||a(s)})}S(n,t),Le()}var AI=E('<span style="font-style: italic; margin-right: 4px;">(edited)</span>'),MI=E('<div style="padding: 4px 0; font-size: 12px; line-height: 1.4;"><div style="display: flex; justify-content: space-between; margin-bottom: 2px;"><span> </span> <span style="font-size: 10px; color: var(--tandem-fg-subtle);"><!> </span></div> <p style="margin: 0; color: var(--tandem-fg);"> </p></div>'),OI=E('<div data-testid="comment-thread" style="margin-top: 6px; padding-left: 8px; border-left: 2px solid var(--tandem-border);"></div>');function W_(n,e){Pe(e,!0);function t(s){const a=new Date(s),c=new Date().getTime()-a.getTime(),d=Math.floor(c/6e4);if(d<1)return"just now";if(d<60)return`${d}m ago`;const u=Math.floor(d/60);return u<24?`${u}h ago`:a.toLocaleDateString()}var r=xt(),i=ye(r);{var o=s=>{var a=OI();dt(a,21,()=>e.replies,l=>l.id,(l,c)=>{var d=MI(),u=x(d),h=x(u),p=x(h),m=k(h,2),v=x(m);{var g=C=>{var A=AI();S(C,A)};Z(v,C=>{f(c).editedAt&&C(g)})}var y=k(v),w=k(u,2),_=x(w);K(C=>{G(d,"data-testid",`reply-${f(c).id??""}`),re(h,`font-weight: 600; font-size: 11px; color: ${f(c).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};`),$(p,f(c).author==="claude"?"Claude":"You"),$(y,` ${C??""}`),$(_,f(c).text)},[()=>t(f(c).timestamp)]),S(l,d)}),S(s,a)};Z(i,s=>{e.replies.length>0&&s(o)})}S(n,r),Le()}var DI=E('<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>'),RI=E('<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;"> </button>'),NI=E('<div style="margin-top: 6px;"><!></div>'),II=E('<div style="margin-top: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </div>'),PI=E("<!> <!> <!>",1);function LI(n,e){Pe(e,!0);const t=F(()=>dh(e.annotation,e.replies)),r=F(()=>e.annotation.id);let i=B(!1),o=B(""),s=B(!1),a=B(null);const l=F(()=>!!f(o).trim());le(()=>{var y;f(i)&&((y=f(a))==null||y.focus())});function c(y){y.key==="Escape"&&(y.stopPropagation(),b(i,!1),b(o,""))}async function d(){var w;const y=f(o).trim();if(!(!y||f(s))){b(s,!0);try{await((w=e.onReply)==null?void 0:w.call(e,f(r),y))!==!1&&(b(o,""),b(i,!1))}finally{b(s,!1)}}}var u=PI(),h=ye(u);W_(h,{get replies(){return f(t)}});var p=k(h,2);{var m=y=>{var w=NI(),_=x(w);{var C=j=>{var H=DI(),D=x(H);gt(D,z=>b(a,z),()=>f(a));var N=k(D,2),W=x(N),ee=k(W,2);K(()=>{G(D,"data-testid",`reply-input-${f(r)??""}`),yr(D,f(o)),re(D,Wl),G(W,"data-testid",`reply-send-btn-${f(r)??""}`),W.disabled=!f(l)||f(s),re(W,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${f(l)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${f(l)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${f(l)?"pointer":"default"};`),G(ee,"data-testid",`reply-cancel-btn-${f(r)??""}`)}),L("input",D,z=>b(o,z.target.value,!0)),L("keydown",D,c),L("click",W,d),L("click",ee,()=>{b(i,!1),b(o,"")}),S(j,H)},A=j=>{var H=RI(),D=x(H);K(()=>{G(H,"data-testid",`reply-btn-${f(r)??""}`),$(D,`Reply${f(t).length>0?` (${f(t).length})`:""}`)}),L("click",H,()=>b(i,!0)),S(j,H)};Z(_,j=>{f(i)?j(C):j(A,-1)})}L("click",w,j=>j.stopPropagation()),L("keydown",w,j=>j.stopPropagation()),S(y,w)};Z(p,y=>{e.isPending&&e.onReply&&!e.isEditing&&y(m)})}var v=k(p,2);{var g=y=>{var w=II(),_=x(w);K(()=>$(_,`${f(t).length??""}
|
|
58
|
+
${f(t).length===1?"reply":"replies"}`)),S(y,w)};Z(v,y=>{!e.isPending&&f(t).length>0&&!e.onReply&&y(g)})}S(n,u),Le()}qe(["click","keydown","input"]);var zI=E('<p style="margin: 0; font-size: var(--tandem-text-sm); color: var(--tandem-fg-subtle);">No replies yet.</p>'),FI=E('<textarea data-testid="reply-thread-overlay-input" placeholder="Write a reply..."></textarea> <div style="display: flex; gap: var(--tandem-space-2); margin-top: var(--tandem-space-2);"><button type="button" data-testid="reply-thread-overlay-send">Send</button> <button type="button" data-testid="reply-thread-overlay-cancel">Cancel</button></div>',1),BI=E('<button type="button" data-testid="reply-thread-overlay-reply">Reply</button>'),HI=E('<div style="border-top: 1px solid var(--tandem-border); padding-top: var(--tandem-space-3);"><!></div>'),VI=E('<div role="presentation" data-testid="reply-thread-overlay" style="position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: 1000;"><div role="dialog" aria-modal="true" aria-label="Reply thread" tabindex="-1" style="background-color: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-3); padding: var(--tandem-space-4) var(--tandem-space-5); width: 520px; max-width: 90vw; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--tandem-space-3);"><div style="display: flex; align-items: center; justify-content: space-between;"><h2 style="margin: 0; font-size: var(--tandem-text-lg); font-weight: 600; color: var(--tandem-fg);">Reply thread <span style="font-weight: 400; color: var(--tandem-fg-subtle); font-size: var(--tandem-text-sm); margin-left: var(--tandem-space-2);"> </span></h2> <button type="button" data-testid="reply-thread-overlay-close" aria-label="Close reply thread" style="background: none; border: none; cursor: pointer; font-size: 18px; color: var(--tandem-fg-muted); line-height: 1; padding: 2px 6px; border-radius: var(--tandem-r-2);">✕</button></div> <div style="padding: var(--tandem-space-2) var(--tandem-space-3); background: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); border-left: 3px solid var(--tandem-author-claude); font-size: var(--tandem-text-sm); color: var(--tandem-fg-muted); white-space: pre-wrap;"> </div> <!> <!></div></div>');function UI(n,e){Pe(e,!0);const t=F(()=>dh(e.annotation,e.replies));let r=B(null),i=B(null),o=null,s=B(!1),a=B(""),l=B(!1);const c=F(()=>!!f(a).trim());le(()=>{if(!e.open)return;const g=Dt(()=>f(r));if(!g)return;o=document.activeElement,g.focus();const y=w=>{g&&!g.contains(w.target)&&g.focus()};return document.addEventListener("focusin",y),()=>{document.removeEventListener("focusin",y),o instanceof HTMLElement&&document.contains(o)&&o.focus()}}),le(()=>{e.open||(b(s,!1),b(a,""),b(l,!1))}),le(()=>{var g;f(s)&&((g=f(i))==null||g.focus())});function d(g){g.key==="Escape"&&(g.stopPropagation(),b(s,!1),b(a,""))}async function u(){const g=f(a).trim();if(!(!g||f(l)||!e.onReply)){b(l,!0);try{await e.onReply(e.annotation.id,g)!==!1&&(b(a,""),b(s,!1))}finally{b(l,!1)}}}function h(g){if(g.key==="Escape"){e.onClose();return}if(g.stopPropagation(),g.key!=="Tab"||!f(r))return;const y=Array.from(f(r).querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(C=>!C.closest("[hidden]"));if(y.length===0){g.preventDefault();return}const w=y[0],_=y[y.length-1];g.shiftKey&&document.activeElement===w?(g.preventDefault(),_.focus()):!g.shiftKey&&document.activeElement===_&&(g.preventDefault(),w.focus())}var p=xt(),m=ye(p);{var v=g=>{var y=VI(),w=x(y),_=x(w),C=x(_),A=k(x(C)),j=x(A),H=k(C,2),D=k(_,2),N=x(D),W=k(D,2);{var ee=ne=>{var q=zI();S(ne,q)},z=ne=>{W_(ne,{get replies(){return f(t)}})};Z(W,ne=>{f(t).length===0?ne(ee):ne(z,-1)})}var Y=k(W,2);{var te=ne=>{var q=HI(),P=x(q);{var M=I=>{var T=FI(),R=ye(T);gt(R,we=>b(i,we),()=>f(i));var V=k(R,2),se=x(V),he=k(se,2);K(()=>{re(R,Wl),se.disabled=!f(c)||f(l),re(se,`padding: 4px 10px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${f(c)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${f(c)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${f(c)&&!f(l)?"pointer":"default"};`),re(he,u0)}),L("keydown",R,d),Uo(R,()=>f(a),we=>b(a,we)),L("click",se,u),L("click",he,()=>{b(s,!1),b(a,"")}),S(I,T)},O=I=>{var T=BI();K(()=>re(T,u0)),L("click",T,()=>b(s,!0)),S(I,T)};Z(P,I=>{f(s)?I(M):I(O,-1)})}S(ne,q)};Z(Y,ne=>{e.onReply&&ne(te)})}gt(w,ne=>b(r,ne),()=>f(r)),K(()=>{$(j,`(${f(t).length??""}
|
|
59
|
+
${f(t).length===1?"reply":"replies"})`),$(N,e.annotation.content)}),L("click",y,function(...ne){var q;(q=e.onClose)==null||q.apply(this,ne)}),L("keydown",y,()=>{}),L("click",w,ne=>ne.stopPropagation()),L("keydown",w,h),L("click",H,function(...ne){var q;(q=e.onClose)==null||q.apply(this,ne)}),S(g,y)};Z(m,g=>{e.open&&g(v)})}S(n,p),Le()}qe(["click","keydown"]);var jI=E('<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),WI=E('<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>'),KI=E('<div 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>'),qI=E("<!> <!> <!>",1);function JI(n,e){Pe(e,!0);var t=qI(),r=ye(t);fd(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-suggestion-bg)",badgeFg:"var(--tandem-suggestion-fg-strong)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);hd(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=KI(),c=x(l),d=x(c);{var u=g=>{var y=jI(),w=ye(y),_=x(w),C=k(w);C.nodeValue=" → ",K(()=>$(_,e.annotation.textSnapshot)),S(g,y)};Z(d,g=>{e.annotation.textSnapshot&&g(u)})}var h=k(d,2),p=x(h),m=k(c,2);{var v=g=>{var y=WI(),w=x(y);K(()=>$(w,e.annotation.content)),S(g,y)};Z(m,g=>{e.annotation.content&&g(v)})}K(()=>{G(c,"data-testid",`suggestion-diff-${e.annotation.id??""}`),re(c,`padding: 4px 8px; margin-bottom: ${e.annotation.content?"4px":"0"}; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); font-size: 12px; line-height: 1.5;`),$(p,e.annotation.suggestedText)}),S(a,l)};Z(o,a=>{e.isEditing||a(s)})}S(n,t),Le()}var ZI=E('<button type="button" style="margin-top: var(--tandem-space-1); padding: var(--tandem-space-1) var(--tandem-space-2); font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;">Expand thread</button>'),YI=E('<div role="listitem"><!> <!> <!> <!> <!></div> <!>',1);function Bm(n,e){Pe(e,!0);let t=st(e,"replies",19,()=>[]),r=B(!1),i=B(""),o=B(""),s=B("");const a=F(()=>e.annotation.status==="pending"),l=F(()=>e.annotation.suggestedText!==void 0),c=F(()=>e.onEdit!==void 0),d=F(()=>lI(e.annotation)),u=F(()=>dh(e.annotation,t())),h=F(()=>f(u).length>=1);let p=B(!1);const m=F(()=>e.annotation.type==="highlight"?cI(e.annotation):e.annotation.suggestedText!==void 0?"var(--tandem-suggestion)":e.annotation.type==="note"?"var(--tandem-warning)":"var(--tandem-author-user)"),v=F(()=>e.isReviewTarget?"var(--tandem-accent-bg)":"var(--tandem-surface)");function g(){f(l)?(b(o,e.annotation.suggestedText??"",!0),b(s,e.annotation.content,!0)):b(i,e.annotation.content,!0),b(r,!0)}function y(){var T;const I=f(l)?JSON.stringify({suggestedText:f(o),content:f(s)}):f(i);(T=e.onEdit)==null||T.call(e,e.annotation.id,I),b(r,!1)}function w(){b(r,!1)}function _(I){I.key==="Escape"&&(I.stopPropagation(),w())}var C=YI(),A=ye(C),j=x(A);{var H=I=>{_I(I,{get annotation(){return e.annotation},get isPending(){return f(a)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return f(r)},get canEdit(){return f(c)},onEnterEdit:g})},D=I=>{wI(I,{get annotation(){return e.annotation},get isPending(){return f(a)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return f(r)},get canEdit(){return f(c)},onEnterEdit:g})},N=I=>{EI(I,{get annotation(){return e.annotation},get isPending(){return f(a)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return f(r)},get canEdit(){return f(c)},onEnterEdit:g})},W=I=>{JI(I,{get annotation(){return e.annotation},get isPending(){return f(a)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return f(r)},get canEdit(){return f(c)},onEnterEdit:g})},ee=I=>{vI(I,{get annotation(){return e.annotation},get isPending(){return f(a)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return f(r)},get canEdit(){return f(c)},onEnterEdit:g})};Z(j,I=>{e.annotation.author==="import"?I(H):e.annotation.type==="highlight"?I(D,1):e.annotation.type==="note"?I(N,2):e.annotation.suggestedText!==void 0?I(W,3):I(ee,-1)})}var z=k(j,2);{var Y=I=>{oI(I,{get annotationId(){return e.annotation.id},get hasSuggestedText(){return f(l)},get editText(){return f(i)},get editNewText(){return f(o)},get editReason(){return f(s)},onChangeEditText:T=>b(i,T,!0),onChangeEditNewText:T=>b(o,T,!0),onChangeEditReason:T=>b(s,T,!0),onKeyDown:_,onSave:y,onCancel:w})};Z(z,I=>{f(r)&&I(Y)})}var te=k(z,2);tI(te,{get annotationId(){return e.annotation.id},get annotationType(){return e.annotation.type},get isPending(){return f(a)},get isEditing(){return f(r)},get undoable(){return e.undoable},get onAccept(){return e.onAccept},get onDismiss(){return e.onDismiss},get onUndo(){return e.onUndo},get onRemove(){return e.onRemove},get onSendToClaude(){return e.onSendToClaude}});var ne=k(te,2);LI(ne,{get annotation(){return e.annotation},get replies(){return f(u)},get isPending(){return f(a)},get isEditing(){return f(r)},get onReply(){return e.onReply}});var q=k(ne,2);{var P=I=>{var T=ZI();K(()=>G(T,"data-testid",`reply-thread-expand-${e.annotation.id??""}`)),L("click",T,R=>{R.stopPropagation(),b(p,!0)}),S(I,T)};Z(q,I=>{f(h)&&I(P)})}var M=k(A,2);{var O=I=>{UI(I,{get open(){return f(p)},get annotation(){return e.annotation},get replies(){return f(u)},get onReply(){return e.onReply},onClose:()=>b(p,!1)})};Z(M,I=>{(f(h)||f(p))&&I(O)})}K(()=>{G(A,"data-testid",`annotation-card-${e.annotation.id??""}`),G(A,"aria-label",f(d)),G(A,"aria-current",e.isReviewTarget?"true":void 0),re(A,`padding: var(--tandem-space-3); margin-bottom: var(--tandem-space-2); border: 1px solid var(--tandem-border); border-left: 3px solid ${f(m)??""}; background: ${f(v)??""}; border-radius: var(--tandem-r-3); font-size: var(--tandem-text-base); opacity: ${f(a)?1:.6}; cursor: ${e.onClick?"pointer":"default"}; box-shadow: ${e.isReviewTarget?"0 0 0 3px var(--tandem-accent-bg)":"none"}; transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;`)}),L("click",A,function(...I){var T;(T=e.onClick)==null||T.apply(this,I)}),S(n,C),Le()}qe(["click"]);var GI=E('<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),XI=E('<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>',1),QI=E('<div style="padding: 6px var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; align-items: center;"><!></div>');function $I(n,e){Pe(e,!0);let t=st(e,"confirmRef",15,null);const r=F(()=>e.bulkConfirm==="accept"),i=F(()=>e.pendingCount===e.allPendingCount?`${e.pendingCount} annotations?`:`${e.pendingCount} of ${e.allPendingCount} pending?`);var o=xt(),s=ye(o);{var a=l=>{var c=QI(),d=x(c);{var u=p=>{var m=GI(),v=ye(m),g=x(v),y=k(v,2);gt(y,_=>t(_),()=>t());var w=k(y,2);re(w,"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);"),K(()=>{$(g,`${f(r)?"Accept":"Reject"}
|
|
60
|
+
${f(i)??""}`),re(y,`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: ${f(r)?"var(--tandem-success-bg)":"var(--tandem-error-bg)"}; color: ${f(r)?"var(--tandem-success-fg-strong)":"var(--tandem-error-fg-strong)"}; font-weight: 600;`)}),L("click",y,function(..._){var C;(C=f(r)?e.onConfirmAccept:e.onConfirmDismiss)==null||C.apply(this,_)}),L("click",w,function(..._){var C;(C=e.onCancel)==null||C.apply(this,_)}),S(p,m)},h=p=>{var m=XI(),v=ye(m);re(v,"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 g=x(v),y=k(v,2);re(y,"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);"),K(()=>$(g,`Accept All (${e.pendingCount??""})`)),L("click",v,function(...w){var _;(_=e.onRequestAccept)==null||_.apply(this,w)}),L("click",y,function(...w){var _;(_=e.onRequestDismiss)==null||_.apply(this,w)}),S(p,m)};Z(d,p=>{e.bulkConfirm?p(u):p(h,-1)})}S(l,c)};Z(s,l=>{e.pendingCount>1&&l(a)})}S(n,o),Le()}qe(["click"]);var eP=E("<option> </option>"),tP=E('<select style="padding: 2px 4px; font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer; outline: none;"></select>');function up(n,e){Pe(e,!0);var t=tP();dt(t,21,()=>e.options,i=>i.value,(i,o)=>{var s=eP(),a=x(s),l={};K(()=>{$(a,f(o).label),l!==(l=f(o).value)&&(s.value=(s.__value=f(o).value)??"")}),S(i,s)});var r;lx(t),K(()=>{G(t,"data-testid",e.testId),G(t,"aria-label",e.ariaLabel),r!==(r=e.value)&&(t.value=(t.__value=e.value)??"",Ug(t,e.value))}),L("change",t,i=>e.onChange(i.target.value)),S(n,t),Le()}qe(["change"]);var nP=E('<div style="padding: 6px 16px; border-bottom: 1px solid var(--tandem-border);"><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;"><span> </span> <span style="font-size: 9px; opacity: 0.7;">▾</span> <span>Filter</span></button></div>'),rP=E('<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>'),iP=E('<div style="padding: 8px 16px; border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; 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 oP(n,e){Pe(e,!0);const t=F(()=>{if(!e.hasFilters)return"All";const a=[];if(e.filterType!=="all"){const l={all:"All",highlight:"Highlights",comment:"Comments",note:"Notes","with-replacement":"With replacement"};a.push(l[e.filterType])}if(e.filterAuthor!=="all"){const l={all:"Anyone",claude:"Claude",user:"You",import:"Imported"};a.push(l[e.filterAuthor])}if(e.filterStatus!=="all"){const l={all:"Any status",pending:"Pending",accepted:"Accepted",dismissed:"Dismissed"};a.push(l[e.filterStatus])}return a.join(" · ")||"All"});var r=xt(),i=ye(r);{var o=a=>{var l=nP(),c=x(l),d=x(c),u=x(d);K(()=>$(u,`${f(t)??""} ${e.totalCount??""}`)),L("click",c,function(...h){var p;(p=e.onToggleOpen)==null||p.apply(this,h)}),S(a,l)},s=a=>{var l=iP(),c=x(l);up(c,{testId:"filter-type",ariaLabel:"Filter by type",get value(){return e.filterType},onChange:v=>e.onSetFilterType(v),options:[{value:"all",label:"All types"},{value:"highlight",label:"Highlights"},{value:"comment",label:"Comments"},{value:"note",label:"Notes"},{value:"with-replacement",label:"With replacement"}]});var d=k(c,2);up(d,{testId:"filter-author",ariaLabel:"Filter by author",get value(){return e.filterAuthor},onChange:v=>e.onSetFilterAuthor(v),options:[{value:"all",label:"Anyone"},{value:"claude",label:"Claude"},{value:"user",label:"You"},{value:"import",label:"Imported"}]});var u=k(d,2);up(u,{testId:"filter-status",ariaLabel:"Filter by status",get value(){return e.filterStatus},onChange:v=>e.onSetFilterStatus(v),options:[{value:"all",label:"Any status"},{value:"pending",label:"Pending"},{value:"accepted",label:"Accepted"},{value:"dismissed",label:"Dismissed"}]});var h=k(u,2);{var p=v=>{var g=rP();L("click",g,function(...y){var w;(w=e.onClearFilters)==null||w.apply(this,y)}),S(v,g)};Z(h,v=>{e.hasFilters&&v(p)})}var m=k(h,2);L("click",m,function(...v){var g;(g=e.onToggleOpen)==null||g.apply(this,v)}),S(a,l)};Z(i,a=>{e.open?a(s,-1):a(o)})}S(n,r),Le()}qe(["click"]);var sP=E(`<div data-testid="store-readonly-banner" class="svelte-l26r3u"><span class="svelte-l26r3u">Annotation store is read-only — another Tandem instance holds the lock. Annotations
|
|
61
|
+
won't be saved. Close the other instance and restart.</span> <button data-testid="store-readonly-dismiss" class="svelte-l26r3u">Dismiss</button></div>`),aP=E('<div class="svelte-l26r3u"><span data-testid="held-banner" class="svelte-l26r3u"> </span> <button style="font-size: var(--tandem-text-xs); padding: 4px 10px; border: 1px solid var(--tandem-author-claude); border-radius: var(--tandem-r-2); background: var(--tandem-author-claude); color: var(--tandem-author-claude-fg); cursor: pointer; font-weight: 500;" class="svelte-l26r3u">Show all</button></div>'),lP=E('<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>'),cP=E('<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>'),dP=E('<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>'),uP=E('<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>'),fP=E('<div data-testid="annotation-list-scroll-container" style="width: 100%; background: var(--tandem-surface-muted); display: flex; flex-direction: column; overflow-y: auto;" class="svelte-l26r3u"><!> <!> <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></div> <!> <div style="padding: var(--tandem-space-1) var(--tandem-space-4) 0;" class="svelte-l26r3u"><!></div> <!> <!></div>');function f0(n,e){Pe(e,!0);let t=st(e,"heldCount",3,0),r=st(e,"storeReadOnly",3,!1);const i=F(()=>e.reduceMotion?"auto":"smooth"),o="tandem:storeReadOnlyBannerDismissed";function s(){try{return localStorage.getItem(o)==="true"}catch{return!1}}let a=B(at(s()));le(()=>{if(!r()){b(a,!1);try{localStorage.removeItem(o)}catch{}}});function l(){try{localStorage.setItem(o,"true")}catch{}b(a,!0)}let c=B("all"),d=B("all"),u=B("all"),h=B(!1),p=B(null),m=B(void 0),v=B(null);le(()=>{var Q;f(p)&&((Q=f(v))==null||Q.focus())}),le(()=>{f(c),f(d),f(u),b(p,null)}),le(()=>{var Q;(Q=e.onFilterChange)==null||Q.call(e,f(c),f(d),f(u))});let g=B(at(new Map));le(()=>{if(!e.ydoc){b(g,new Map,!0);return}const Q=e.ydoc.getMap(kx);function ie(){const de=new Map;Q.forEach(Ce=>{const _e=Ce;if(_e&&typeof _e=="object"&&_e.annotationId){const Oe=de.get(_e.annotationId)??[];Oe.push(_e),de.set(_e.annotationId,Oe)}});for(const Ce of de.values())Ce.sort((_e,Oe)=>_e.timestamp-Oe.timestamp);b(g,de,!0)}return ie(),Q.observe(ie),()=>Q.unobserve(ie)});const y=F(()=>{const Q=[],ie=[];for(const Re of e.annotations){Re.status==="pending"&&ie.push(Re);let tt;f(c)==="all"?tt=!0:f(c)==="with-replacement"?tt=Re.suggestedText!==void 0:tt=Re.type===f(c);const Ve=f(d)==="all"||Re.author===f(d),ce=f(u)==="all"||Re.status===f(u);tt&&Ve&&ce&&Q.push(Re)}const de=Q.filter(Re=>Re.status==="pending"),Ce=Q.filter(Tu),_e=Q.filter(Re=>Re.status!=="pending"),Oe=e.annotations.filter(Tu);return{filtered:Q,pending:de,reviewPending:Ce,resolved:_e,allPending:ie,reviewAllPending:Oe}}),w=F(()=>f(c)!=="all"||f(d)!=="all"||f(u)!=="all");let _=!1;le(()=>{if(f(c),f(d),f(u),!_){_=!0;return}Dt(()=>{var Q;if(e.activeAnnotationId){const ie=document.querySelector(`[data-testid="annotation-card-${e.activeAnnotationId}"]`);if(ie){ie.scrollIntoView({block:"center"});return}console.warn(`[tandem] SidePanel: active annotation ${e.activeAnnotationId} not found on filter change; scrolling to top`)}(Q=f(m))==null||Q.scrollTo({top:0})})}),le(()=>{const Q=e.activeAnnotationId;if(!Q)return;const ie=f(i),de=setTimeout(()=>{const Ce=document.querySelector(`[data-testid="annotation-card-${Q}"]`);if(Ce){Ce.scrollIntoView({behavior:ie,block:"nearest"}),Ce.classList.add("tandem-annotation-flash");const _e=()=>Ce.classList.remove("tandem-annotation-flash");Ce.addEventListener("animationend",_e,{once:!0})}else console.warn(`[tandem] SidePanel: active annotation ${Q} not found after 50ms delay; scroll-to-card skipped`)},50);return()=>clearTimeout(de)});function C(Q,ie){if(!e.ydoc)return;const de=e.ydoc.getMap(Ko),Ce=de.get(Q);if(!Ce)return;const _e=il(Ce,Oe=>{console.warn("[sanitize]",Oe)});if(_e.suggestedText!==void 0){try{const Oe=JSON.parse(ie);de.set(Q,{..._e,suggestedText:Oe.suggestedText,content:Oe.content,editedAt:Date.now()})}catch{console.warn(`[SidePanel] Failed to parse edit payload for annotation ${Q}`)}return}de.set(Q,{..._e,content:ie,editedAt:Date.now()})}function A(Q){if(!e.ydoc)return;const ie=e.ydoc.getMap(Ko),de=ie.get(Q);if(!de)return;const Ce=il(de,_e=>{console.warn("[sanitize]",_e)});ie.set(Q,{...Ce,type:"comment"})}async function j(Q){try{const ie=await fetch(`${Gn}${gA}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:Q,documentId:e.documentId})});if(!ie.ok){const de=await ie.json().catch(()=>({message:"Unknown error"}));console.error("[Tandem] Remove annotation failed:",de)}}catch(ie){console.error("[Tandem] Remove annotation failed:",ie)}}async function H(Q,ie){try{const de=await fetch(`${Gn}${mA}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:Q,text:ie,documentId:e.documentId})});if(!de.ok){const Ce=await de.json().catch(()=>({}));return console.warn(`[SidePanel] Reply failed (${de.status}): ${Ce.message??"unknown error"}`),!1}return!0}catch(de){return console.error("[SidePanel] Reply request failed:",de),!1}}function D(Q){for(const ie of f(y).reviewPending)e.review.resolveAnnotation(ie.id,Q);b(p,null)}var N=fP(),W=x(N);{var ee=Q=>{var ie=sP(),de=k(x(ie),2);K(()=>{re(ie,`padding: 10px 14px; margin: 10px 14px 0; background: ${ns.background}; border: 1px solid ${ns.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${ns.color}; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;`),re(de,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${ns.color}; cursor: pointer; font-weight: 500;`)}),L("click",de,l),S(Q,ie)};Z(W,Q=>{r()&&!f(a)&&Q(ee)})}var z=k(W,2);{var Y=Q=>{var ie=aP(),de=x(ie),Ce=x(de),_e=k(de,2);K(()=>{re(ie,`padding: 10px 14px; margin: 10px 14px 0; background: ${ns.background}; border: 1px solid ${ns.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${ns.color}; display: flex; justify-content: space-between; align-items: center; gap: 10px;`),$(Ce,`${t()??""} annotation${t()!==1?"s":""} held`)}),L("click",_e,()=>{var Oe;return(Oe=e.onModeChange)==null?void 0:Oe.call(e,"tandem")}),S(Q,ie)};Z(z,Q=>{t()>0&&Q(Y)})}var te=k(z,2),ne=x(te),q=x(ne),P=k(x(q));{var M=Q=>{var ie=lP(),de=x(ie);K(()=>$(de,f(y).allPending.length)),S(Q,ie)};Z(P,Q=>{f(y).allPending.length>0&&Q(M)})}var O=k(q,2),I=x(O),T=k(te,2);oP(T,{get filterType(){return f(c)},get filterAuthor(){return f(d)},get filterStatus(){return f(u)},get hasFilters(){return f(w)},get open(){return f(h)},get totalCount(){return f(y).filtered.length},onToggleOpen:()=>b(h,!f(h)),onSetFilterType:Q=>{b(c,Q,!0)},onSetFilterAuthor:Q=>{b(d,Q,!0)},onSetFilterStatus:Q=>{b(u,Q,!0)},onClearFilters:()=>{b(c,"all"),b(d,"all"),b(u,"all")}});var R=k(T,2),V=x(R);KN(V,{get annotations(){return e.annotations},get activeDocFormat(){return e.activeDocFormat},get documentId(){return e.documentId}});var se=k(R,2);$I(se,{get bulkConfirm(){return f(p)},get pendingCount(){return f(y).reviewPending.length},get allPendingCount(){return f(y).reviewAllPending.length},onConfirmAccept:()=>D("accepted"),onConfirmDismiss:()=>D("dismissed"),onCancel:()=>b(p,null),onRequestAccept:()=>b(p,"accept"),onRequestDismiss:()=>b(p,"dismiss"),get confirmRef(){return f(v)},set confirmRef(Q){b(v,Q,!0)}});var he=k(se,2);{var we=Q=>{var ie=cP(),de=x(ie),Ce=x(de);K(()=>$(Ce,f(w)?"No annotations match filters.":"No annotations yet. Open a document to get started.")),S(Q,ie)},ae=Q=>{var ie=uP(),de=x(ie);dt(de,17,()=>f(y).pending,Oe=>Oe.id,(Oe,Re)=>{const tt=F(()=>{var Ve;return e.activeAnnotationId!==null?e.activeAnnotationId===f(Re).id:((Ve=e.review.getActiveReviewAnn())==null?void 0:Ve.id)===f(Re).id});{let Ve=F(()=>f(g).get(f(Re).id)??[]),ce=F(()=>f(Re).author!=="user"?e.review.handleAccept:void 0),Ie=F(()=>f(Re).author!=="user"?e.review.handleDismiss:void 0),ge=F(()=>f(Re).author==="user"?j:void 0),ze=F(()=>f(Re).type==="note"?A:void 0);Bm(Oe,{get annotation(){return f(Re)},get replies(){return f(Ve)},get isReviewTarget(){return f(tt)},get onAccept(){return f(ce)},get onDismiss(){return f(Ie)},get onRemove(){return f(ge)},get onSendToClaude(){return f(ze)},onEdit:C,onReply:H,onClick:()=>e.review.scrollToAnnotation(f(Re))})}});var Ce=k(de,2);{var _e=Oe=>{var Re=dP(),tt=x(Re),Ve=x(tt),ce=k(tt,2);dt(ce,21,()=>f(y).resolved,Ie=>Ie.id,(Ie,ge)=>{{let ze=F(()=>f(g).get(f(ge).id)??[]),Ae=F(()=>e.review.getRecentlyResolved().has(f(ge).id));Bm(Ie,{get annotation(){return f(ge)},get replies(){return f(ze)},get onUndo(){return e.review.undoResolveAnnotation},get undoable(){return f(Ae)},onClick:()=>e.review.scrollToAnnotation(f(ge))})}}),K(()=>$(Ve,`${f(y).resolved.length??""} resolved`)),S(Oe,Re)};Z(Ce,Oe=>{f(y).resolved.length>0&&Oe(_e)})}S(Q,ie)};Z(he,Q=>{f(y).filtered.length===0?Q(we):Q(ae,-1)})}gt(N,Q=>b(m,Q),()=>f(m)),K(()=>$(I,`${f(y).allPending.length??""} pending annotation${f(y).allPending.length!==1?"s":""}`)),S(n,N),Le()}qe(["click"]);var hP=E('<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>'),pP=E(`<span style="
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
font-size: var(--tandem-text-2xs, 10px);
|
|
64
|
+
font-weight: 500;
|
|
65
|
+
color: var(--tandem-fg-subtle);
|
|
66
|
+
background: var(--tandem-surface-muted);
|
|
67
|
+
border-radius: var(--tandem-r-pill);
|
|
68
|
+
padding: 0 var(--tandem-space-1);
|
|
69
|
+
min-width: 16px;
|
|
70
|
+
text-align: center;
|
|
71
|
+
line-height: 16px;
|
|
72
|
+
"> </span>`),mP=E('<li><button><span style="flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></button></li>'),gP=E('<ul style="list-style: none; margin: 0; padding: 0;"></ul>'),vP=E(`<nav data-testid="outline-panel" aria-label="Document outline" style="display: flex; flex-direction: column; flex: 1; overflow-y: auto;"><div style="padding: var(--tandem-space-2) var(--tandem-space-3); border-bottom: 1px solid var(--tandem-border);"><input type="search" placeholder="Search in document…" data-testid="outline-search-input" aria-label="Search document" style="
|
|
73
|
+
width: 100%; box-sizing: border-box;
|
|
74
|
+
padding: var(--tandem-space-1) var(--tandem-space-2);
|
|
75
|
+
font-size: var(--tandem-text-xs);
|
|
76
|
+
border: 1px solid var(--tandem-border);
|
|
77
|
+
border-radius: var(--tandem-r-2);
|
|
78
|
+
background: var(--tandem-surface);
|
|
79
|
+
color: var(--tandem-fg);
|
|
80
|
+
outline: none;
|
|
81
|
+
"/></div> <div style="flex: 1; overflow-y: auto; padding: var(--tandem-space-2) 0;"><!></div></nav>`);function h0(n,e){Pe(e,!0);let t=st(e,"annotations",19,()=>[]),r=st(e,"focusTrigger",3,0),i=st(e,"activeFilterType",3,"all"),o=st(e,"activeFilterAuthor",3,"all"),s=st(e,"activeFilterStatus",3,"all"),a=B(at([])),l=B(-1),c=B(at([])),d=B(""),u=B(null),h=B(-1);le(()=>{const N=e.editor;if(!N||N.isDestroyed){b(a,[],!0);return}b(a,Sm(N),!0),Dt(()=>{b(c,f(c).slice(0,f(a).length),!0),f(l)>=f(a).length&&b(l,Math.max(0,f(a).length-1),!0)});const W=()=>{b(a,Sm(N),!0),b(c,f(c).slice(0,f(a).length),!0),f(l)>=f(a).length&&b(l,Math.max(0,f(a).length-1),!0)};return N.on("update",W),()=>{N.isDestroyed||N.off("update",W),b(a,[],!0)}}),le(()=>{var N,W;r()>0&&((N=f(u))==null||N.focus(),(W=f(u))==null||W.select())}),le(()=>{const N=e.editor;if(!N||N.isDestroyed)return;function W(){if(!N||N.isDestroyed||f(a).length===0){b(h,-1);return}const Y=N.view.dom.getBoundingClientRect().top+48;let te=-1;for(let ne=0;ne<f(a).length;ne++)try{N.view.coordsAtPos(f(a)[ne].pos+1).top<=Y&&(te=ne)}catch{}b(h,te,!0)}W();const ee=N.view.dom.closest(".editor-scroll")??N.view.dom.parentElement;return ee==null||ee.addEventListener("scroll",W),()=>ee==null?void 0:ee.removeEventListener("scroll",W)});function p(){const N=e.editor;!N||N.isDestroyed||(f(d)?N.commands.find({query:f(d),caseSensitive:!1,wholeWord:!1,regexMode:!1}):N.commands.findClose())}function m(N){var W,ee,z,Y;N.key==="Enter"?(N.preventDefault(),N.shiftKey?(W=e.editor)==null||W.commands.findPrev():(ee=e.editor)==null||ee.commands.findNext()):N.key==="Escape"&&(N.preventDefault(),b(d,""),(z=e.editor)==null||z.commands.findClose(),(Y=f(u))==null||Y.blur())}const v=F(()=>{const N=e.editor;if(!N||N.isDestroyed||f(a).length===0)return[];const W=N.state.doc.content.size,ee=[];for(const z of t()){if(i()!=="all"){if(i()==="with-replacement"){if(!z.suggestedText)continue}else if(z.type!==i())continue}if(!(o()!=="all"&&z.author!==o())&&!(s()!=="all"&&z.status!==s()))try{ee.push(Yo(N.state.doc,z.range.from))}catch{}}return f(a).map((z,Y)=>{const te=Y+1<f(a).length?f(a)[Y+1].pos:W;return ee.filter(ne=>ne>=z.pos&&ne<te).length})});function g(N,W){const ee=e.editor;if(!ee||ee.isDestroyed)return;const{state:z}=ee;try{const Y=z.doc.resolve(N.pos+1),te=Ne.near(Y);ee.view.dispatch(z.tr.setSelection(te)),ee.view.focus();const{node:ne}=ee.view.domAtPos(N.pos+1),q=ne instanceof Element?ne:ne.parentElement,P=ee.view.dom.closest(".editor-scroll")??ee.view.dom.parentElement;if(q&&P){const M=q.getBoundingClientRect().top,O=P.getBoundingClientRect().top;P.scrollTop+=M-O-P.clientHeight*.05}}catch{}b(l,W,!0)}function y(N){var W,ee,z,Y;if(f(a).length!==0)if(N.key==="ArrowDown"){N.preventDefault();const te=(f(l)+1)%f(a).length;b(l,te),(W=f(c)[te])==null||W.focus()}else if(N.key==="ArrowUp"){N.preventDefault();const te=(f(l)-1+f(a).length)%f(a).length;b(l,te),(ee=f(c)[te])==null||ee.focus()}else N.key==="Home"?(N.preventDefault(),b(l,0),(z=f(c)[0])==null||z.focus()):N.key==="End"&&(N.preventDefault(),b(l,f(a).length-1),(Y=f(c)[f(a).length-1])==null||Y.focus())}var w=vP(),_=x(w),C=x(_);gt(C,N=>b(u,N),()=>f(u));var A=k(_,2),j=x(A);{var H=N=>{var W=hP();S(N,W)},D=N=>{var W=gP();dt(W,21,()=>f(a),ja,(ee,z,Y)=>{const te=F(()=>f(h)===Y),ne=F(()=>f(v)[Y]??0);var q=mP(),P=x(q),M=x(P),O=x(M),I=k(M,2);{var T=R=>{var V=pP(),se=x(V);K(()=>{G(V,"title",`${f(ne)??""} annotation${f(ne)!==1?"s":""}`),$(se,f(ne))}),S(R,V)};Z(I,R=>{f(ne)>0&&R(T)})}gt(P,(R,V)=>f(c)[V]=R,R=>{var V;return(V=f(c))==null?void 0:V[R]},()=>[Y]),K(()=>{G(P,"data-testid",`outline-heading-${f(z).level}-${Y}`),G(P,"tabindex",f(l)===Y||f(l)===-1&&Y===0?0:-1),re(P,`
|
|
82
|
+
display: flex; align-items: center; width: 100%; text-align: left;
|
|
83
|
+
padding: var(--tandem-space-1) var(--tandem-space-3);
|
|
84
|
+
padding-left: calc(var(--tandem-space-1) + ${(f(z).level-1)*12}px);
|
|
85
|
+
font-size: ${f(z).level===1?"var(--tandem-text-sm)":"var(--tandem-text-xs)"};
|
|
86
|
+
font-weight: ${f(z).level===1?600:f(z).level===2?500:400};
|
|
87
|
+
color: ${f(te)?"var(--tandem-accent)":f(z).level===1?"var(--tandem-fg)":f(z).level===2?"var(--tandem-fg-subtle)":"var(--tandem-fg-muted)"};
|
|
88
|
+
background: ${f(te)?"var(--tandem-accent-bg)":"none"};
|
|
89
|
+
border: none; cursor: pointer; line-height: 1.5;
|
|
90
|
+
transition: color 0.1s, background 0.1s;
|
|
91
|
+
gap: var(--tandem-space-2);
|
|
92
|
+
`),G(P,"title",f(z).text),$(O,f(z).text||"(untitled)")}),L("click",P,()=>g(f(z),Y)),Et("focus",P,()=>b(l,Y,!0)),Et("mouseenter",P,R=>{f(te)||(R.currentTarget.style.background="var(--tandem-surface-hover, var(--tandem-surface-muted))")}),Et("mouseleave",P,R=>{f(te)||(R.currentTarget.style.background="none")}),S(ee,q)}),S(N,W)};Z(j,N=>{f(a).length===0?N(H):N(D,-1)})}L("keydown",w,y),L("input",C,p),L("keydown",C,m),Uo(C,()=>f(d),N=>b(d,N)),S(n,w),Le()}qe(["keydown","input","click"]);var yP=E("<div><!></div>");function ra(n,e){Pe(e,!0);let t=rA(e,["$$slots","$$events","$$legacy","kind","visible"]);const r=F(()=>e.visible!==void 0?`display: ${e.visible?"flex":"none"}; flex-direction: column; flex: 1; min-height: 0;`:void 0);var i=xt(),o=ye(i);{var s=d=>{var u=yP(),h=x(u);{var p=g=>{d0(g,Dl(()=>t,{get visible(){return e.visible}}))},m=g=>{h0(g,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType},get activeFilterAuthor(){return e.activeFilterAuthor},get activeFilterStatus(){return e.activeFilterStatus}})},v=g=>{f0(g,Dl(()=>t))};Z(h,g=>{e.kind==="chat"?g(p):e.kind==="outline"?g(m,1):g(v,-1)})}K(()=>re(u,f(r))),S(d,u)},a=d=>{d0(d,Dl(()=>t))},l=d=>{h0(d,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType}})},c=d=>{f0(d,Dl(()=>t))};Z(o,d=>{f(r)?d(s):e.kind==="chat"?d(a,1):e.kind==="outline"?d(l,2):d(c,-1)})}S(n,i),Le()}var bP=E('<span style="color: var(--tandem-error-fg-strong); font-size: 12px; max-width: 200px;"> </span>'),wP=E('<button type="button" data-testid="convert-to-markdown-btn"> </button>'),xP=E(`<div data-testid="review-only-banner" style="padding: var(--tandem-space-2) var(--tandem-space-4); background-color: var(--tandem-info-bg); border-bottom: 1px solid var(--tandem-info-border); display: flex; align-items: center; justify-content: space-between; font-size: var(--tandem-text-base); color: var(--tandem-info-fg-strong); gap: var(--tandem-space-3);"><span>This document is open in review-only mode. You can add annotations and review, but cannot
|
|
93
|
+
edit directly.</span> <div style="display: flex; align-items: center; gap: var(--tandem-space-2); flex-shrink: 0;"><!> <!> <button type="button" data-testid="review-only-dismiss" style="background: none; border: none; color: var(--tandem-info-fg-strong); cursor: pointer; font-weight: 500; font-size: 13px; padding: 2px 8px; white-space: nowrap;">Dismiss</button></div></div>`);function kP(n,e){Pe(e,!0);const t="tandem:reviewOnlyBannerDismissed";function r(){try{return localStorage.getItem(t)==="true"}catch{return!1}}let i=B(at(r())),o=B(!1),s=B(null);async function a(){if(!(!e.documentId||f(o))){b(o,!0),b(s,null);try{const h=await fetch(`${Gn}${hA}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})});if(!h.ok){const p=await h.json().catch(()=>null);b(s,(p==null?void 0:p.message)??`Conversion failed (HTTP ${h.status}).`,!0)}}catch{b(s,"Could not reach the server.")}finally{b(o,!1)}}}function l(){try{localStorage.setItem(t,"true")}catch{}b(i,!0)}var c=xt(),d=ye(c);{var u=h=>{var p=xP(),m=k(x(p),2),v=x(m);{var g=C=>{var A=bP(),j=x(A);K(()=>$(j,f(s))),S(C,A)};Z(v,C=>{f(s)&&C(g)})}var y=k(v,2);{var w=C=>{var A=wP(),j=x(A);K(()=>{A.disabled=f(o),re(A,`background: var(--tandem-info); border: none; color: var(--tandem-info-fg); cursor: ${f(o)?"default":"pointer"}; font-weight: 500; font-size: var(--tandem-text-sm); padding: 4px 10px; border-radius: var(--tandem-r-2); white-space: nowrap; opacity: ${f(o)?.6:1};`),$(j,f(o)?"Converting…":"Convert to Markdown")}),L("click",A,a),S(C,A)};Z(y,C=>{e.documentId&&C(w)})}var _=k(y,2);L("click",_,l),S(h,p)};Z(d,h=>{e.visible&&!f(i)&&h(u)})}S(n,c),Le()}qe(["click"]);let fp=null;async function _P(n){if(fp!==null)return fp;const e=await fetch(`${Gn}${Hy}`,{signal:n});if(!e.ok)throw new Error(`${Hy} responded ${e.status} ${e.statusText}`);const t=await e.json();return fp=t,t}function uh(n){let e=B(null),t=B(!1);return le(()=>{if(!n())return;let r=!1;const i=new AbortController,o=setTimeout(()=>i.abort(),3e3);return b(t,!0),_P(i.signal).then(s=>{r||b(e,s,!0)}).catch(s=>{s instanceof Error&&s.name!=="AbortError"&&console.warn("[useAppInfo] failed to load /api/info:",s)}).finally(()=>{clearTimeout(o),r||b(t,!1)}),()=>{r=!0,clearTimeout(o),i.abort()}}),{get info(){return f(e)},get loading(){return f(t)}}}async function K_(n,e={}){const{readOnly:t=!1,notFoundMessage:r="File not found.",failureMessage:i="Failed to open file."}=e;try{const o=await fetch(`${Gn}${dl}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:n,readOnly:t})});if(!o.ok){let s=i;try{const a=await o.json();a.message&&(s=a.message)}catch{}return o.status===404&&(s=r),{ok:!1,error:s}}return{ok:!0}}catch{return{ok:!1,error:"Server unavailable."}}}var SP=E('<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 q_(n,e){Pe(e,!0);const t="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";var r=SP(),i=ye(r),o=x(i);re(o,t);var s=k(o,2),a=x(s),l=k(i,2),c=x(l);re(c,t);var d=k(c,2),u=x(d);K(()=>{ti(a,e.settings.highContrast),ti(u,e.settings.annotationPatterns)}),L("change",a,h=>e.onUpdate({highContrast:h.target.checked})),L("change",u,h=>e.onUpdate({annotationPatterns:h.target.checked})),S(n,r),Le()}qe(["change"]);function Cl(n,e,t,r){return{handleKeyDown:s=>{var y;const{key:a}=s;if(a!=="ArrowLeft"&&a!=="ArrowRight"&&a!=="ArrowUp"&&a!=="ArrowDown"&&a!=="Home"&&a!=="End")return;const l=e;if(l.length===0)return;s.preventDefault();const c=n(),d=l.indexOf(c),u=l.length-1;let h;a==="Home"?h=0:a==="End"?h=u:a==="ArrowLeft"||a==="ArrowUp"?h=d<=0?u:d-1:h=d>=u?0:d+1;const p=l[h];t(p);const m=s.currentTarget,v=m==null?void 0:m.querySelectorAll('[role="radio"]'),g=e.indexOf(p);(y=v==null?void 0:v[g])==null||y.focus()},tabIndexFor:s=>{const l=n();return s===l?0:-1}}}var CP=E('<button role="radio"> </button>'),TP=E('<button role="radio"> </button>'),EP=E('<button role="radio"> </button>'),AP=E('<button role="radio"> </button>'),MP=E('<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><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><label data-testid="reduce-motion-toggle" style="display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><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>',1);function J_(n,e){Pe(e,!0);const t="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";function r(M,O){return["flex: 1;","padding: var(--tandem-space-2);","min-height: 24px;",`border: 2px solid ${M?"var(--tandem-accent)":"var(--tandem-border)"};`,"border-radius: var(--tandem-r-3);",`background: ${M?"var(--tandem-accent-bg)":"var(--tandem-surface)"};`,"cursor: pointer;","text-align: center;","font-size: 11px;",`color: ${M?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"};`,`font-weight: ${M?600:400};`,"opacity: 1;","transition: border-color 0.15s, background 0.15s;"].join(" ")}const i=Cl(()=>e.settings.theme,["light","dark","system"],M=>e.onUpdate({theme:M})),o=Cl(()=>e.settings.primaryTab,["chat","annotations"],M=>e.onUpdate({primaryTab:M})),s=Cl(()=>e.settings.textSize,["s","m","l"],M=>e.onUpdate({textSize:M})),a=Cl(()=>e.settings.editorFont,["sans","serif","mono"],M=>e.onUpdate({editorFont:M})),l=Cl(()=>e.settings.density,["compact","cozy","spacious"],M=>e.onUpdate({density:M}));var c=MP(),d=ye(c),u=x(d);re(u,t);var h=k(u,2);dt(h,20,()=>["light","dark","system"],M=>M,(M,O)=>{var I=CP(),T=x(I);K((R,V)=>{G(I,"data-testid",`theme-${O}-btn`),G(I,"aria-checked",e.settings.theme===O),G(I,"tabindex",R),re(I,V),$(T,O==="light"?"Light":O==="dark"?"Dark":"System")},[()=>i.tabIndexFor(O),()=>r(e.settings.theme===O)]),L("click",I,()=>e.onUpdate({theme:O})),S(M,I)});var p=k(d,2),m=x(p);re(m,t);var v=k(m,2),g=x(v),y=k(g,2),w=k(p,2),_=x(w);re(_,t);var C=k(_,2);dt(C,20,()=>["s","m","l"],M=>M,(M,O)=>{var I=TP(),T=x(I);K((R,V)=>{G(I,"data-testid",`text-size-${O}-btn`),G(I,"aria-checked",e.settings.textSize===O),G(I,"tabindex",R),re(I,V),$(T,O==="s"?"Small":O==="m"?"Medium":"Large")},[()=>s.tabIndexFor(O),()=>r(e.settings.textSize===O)]),L("click",I,()=>e.onUpdate({textSize:O})),S(M,I)});var A=k(w,2),j=x(A);re(j,t);var H=k(j,2),D=k(x(H),2),N=k(A,2),W=x(N);re(W,t);var ee=k(W,2);dt(ee,20,()=>[["sans","Sans-serif"],["serif","Serif"],["mono","Monospace"]],([M,O])=>M,(M,O)=>{var I=F(()=>Cy(O,2));let T=()=>f(I)[0],R=()=>f(I)[1];var V=EP(),se=x(V);K((he,we)=>{G(V,"data-testid",`editor-font-${T()}-btn`),G(V,"aria-checked",e.settings.editorFont===T()),G(V,"tabindex",he),re(V,we),$(se,R())},[()=>a.tabIndexFor(T()),()=>r(e.settings.editorFont===T())]),L("click",V,()=>e.onUpdate({editorFont:T()})),S(M,V)});var z=k(N,2),Y=x(z);re(Y,t);var te=k(Y,2);dt(te,20,()=>[["compact","Compact"],["cozy","Cozy"],["spacious","Spacious"]],([M,O])=>M,(M,O)=>{var I=F(()=>Cy(O,2));let T=()=>f(I)[0],R=()=>f(I)[1];var V=AP(),se=x(V);K((he,we)=>{G(V,"data-testid",`density-${T()}-btn`),G(V,"aria-checked",e.settings.density===T()),G(V,"tabindex",he),re(V,we),$(se,R())},[()=>l.tabIndexFor(T()),()=>r(e.settings.density===T())]),L("click",V,()=>e.onUpdate({density:T()})),S(M,V)});var ne=k(z,2),q=x(ne),P=x(q);K((M,O,I,T)=>{G(g,"aria-checked",e.settings.primaryTab==="chat"),G(g,"tabindex",M),re(g,O),G(y,"aria-checked",e.settings.primaryTab==="annotations"),G(y,"tabindex",I),re(y,T),yr(D,e.settings.accentHue),ti(P,e.settings.reduceMotion)},[()=>o.tabIndexFor("chat"),()=>r(e.settings.primaryTab==="chat"),()=>o.tabIndexFor("annotations"),()=>r(e.settings.primaryTab==="annotations")]),L("keydown",h,function(...M){var O;(O=i.handleKeyDown)==null||O.apply(this,M)}),L("keydown",v,function(...M){var O;(O=o.handleKeyDown)==null||O.apply(this,M)}),L("click",g,()=>e.onUpdate({primaryTab:"chat"})),L("click",y,()=>e.onUpdate({primaryTab:"annotations"})),L("keydown",C,function(...M){var O;(O=s.handleKeyDown)==null||O.apply(this,M)}),L("input",D,M=>e.onUpdate({accentHue:Number(M.target.value)})),L("keydown",ee,function(...M){var O;(O=a.handleKeyDown)==null||O.apply(this,M)}),L("keydown",te,function(...M){var O;(O=l.handleKeyDown)==null||O.apply(this,M)}),L("change",P,M=>e.onUpdate({reduceMotion:M.target.checked})),S(n,c),Le()}qe(["keydown","click","input","change"]);var OP=E('<div><div>Editor Width: <span style="font-weight: 400; text-transform: none;"> </span></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 6px;">How much of the available space the editor text fills</div> <input data-testid="editor-width-slider" type="range" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Editor width"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span>40%</span> <span>100%</span></div></div>');function Z_(n,e){Pe(e,!0);const t="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";var r=OP(),i=x(r);re(i,t);var o=k(x(i)),s=x(o),a=k(i,4);G(a,"min",40),G(a,"max",100),G(a,"step",5),K(()=>{$(s,`${e.settings.editorWidthPercent??""}%`),yr(a,e.settings.editorWidthPercent)}),L("input",a,l=>e.onUpdate({editorWidthPercent:Number(l.target.value)})),S(n,r),Le()}qe(["input"]);var DP=E('<span style="color: var(--tandem-fg-subtle);"> </span>'),RP=E('<button type="button" data-testid="network-restart-sidecar"> </button>'),NP=E('<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop && tandem start</code> to restart</span>'),IP=E('<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>'),PP=E("<span><strong>Host:</strong> </span>"),LP=E('<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 <N></code>.</div></div>'),zP=E("<option> </option>"),FP=E('<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>'),BP=E('<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> <!> <div><div>Show degraded banner after: <span style="font-weight: 400; text-transform: none;"> </span></div> <input data-testid="network-degraded-delay-slider" type="range" min="5000" max="120000" step="5000" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Degraded banner delay"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span>5s</span> <span>120s</span></div></div> <div><div>Reconnect Strategy <span style="font-size: 10px; color: var(--tandem-fg-subtle);">(not yet active)</span></div> <select data-testid="network-retry-strategy" style="width: 100%; padding: 6px 8px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: pointer;" aria-label="Reconnect retry strategy"></select></div> <label><input type="checkbox" data-testid="network-hold-annotations-toggle" style="accent-color: var(--tandem-accent);"/> <span>Hold annotations while offline <span style="font-size: 10px; color: var(--tandem-fg-subtle);">(not yet active)</span></span></label> <div>When enabled, annotation events will queue locally and sync when the connection is restored.</div> <!>',1);function Y_(n,e){Pe(e,!0);const t=uh(()=>e.open),r=Nn();let i=B(null),o=B(!1);async function s(){if(r){b(o,!0),b(i,null);try{const{invoke:ce}=await Wr(async()=>{const{invoke:Ie}=await import("./core-DhEqZVGG.js");return{invoke:Ie}},[]);await ce("restart_sidecar")}catch(ce){b(i,ce instanceof Error?ce.message:String(ce),!0)}finally{b(o,!1)}}}const a=[{value:"exponential",label:"Exponential backoff"},{value:"constant-2s",label:"Constant (2s)"},{value:"manual",label:"Manual only"}],l="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",c="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;",d="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);",u=F(()=>{var ce;return(ce=t.info)==null?void 0:ce.transport}),h=F(()=>{var ce;return(ce=t.info)==null?void 0:ce.bindHost}),p=F(()=>{var ce;return(ce=t.info)==null?void 0:ce.bindPort}),m=F(()=>f(u)==="http"),v=F(()=>{var ce;return(ce=t.info)==null?void 0:ce.tokenRotatedAt});var g=BP(),y=ye(g),w=x(y);re(w,l);var _=k(w,2),C=x(_),A=k(C,2),j=x(A),H=k(j);{var D=ce=>{var Ie=DP(),ge=x(Ie);K(()=>$(ge,`· ${e.reconnectAttempts??""} retry attempt${e.reconnectAttempts===1?"":"s"}`)),S(ce,Ie)};Z(H,ce=>{e.reconnectAttempts>0&&ce(D)})}var N=k(A,2);{var W=ce=>{var Ie=RP(),ge=x(Ie);K(()=>{Ie.disabled=f(o),re(Ie,`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: ${f(o)?.5:1};`),$(ge,f(o)?"Restarting…":"Restart sidecar")}),L("click",Ie,s),S(ce,Ie)},ee=ce=>{var Ie=NP();S(ce,Ie)};Z(N,ce=>{r?ce(W):ce(ee,-1)})}var z=k(_,2);{var Y=ce=>{var Ie=IP(),ge=x(Ie);K(()=>$(ge,f(i))),S(ce,Ie)};Z(z,ce=>{f(i)&&ce(Y)})}var te=k(y,2),ne=x(te);re(ne,l);var q=k(ne,2),P=x(q),M=k(x(P)),O=k(P,2);{var I=ce=>{var Ie=PP(),ge=k(x(Ie));K(()=>$(ge,` ${f(h)??""}`)),S(ce,Ie)};Z(O,ce=>{f(h)&&ce(I)})}var T=k(te,2);{var R=ce=>{var Ie=LP(),ge=x(Ie);re(ge,l);var ze=k(ge,2),Ae=x(ze),be=k(ze,2);re(be,d),K(()=>$(Ae,f(p)??"—")),S(ce,Ie)};Z(T,ce=>{f(m)&&ce(R)})}var V=k(T,2),se=x(V);re(se,l);var he=k(x(se)),we=x(he),ae=k(se,2),Q=k(V,2),ie=x(Q);re(ie,l);var de=k(ie,2);dt(de,21,()=>a,ce=>ce.value,(ce,Ie)=>{var ge=zP(),ze=x(ge),Ae={};K(()=>{$(ze,f(Ie).label),Ae!==(Ae=f(Ie).value)&&(ge.value=(ge.__value=f(Ie).value)??"")}),S(ce,ge)});var Ce;lx(de);var _e=k(Q,2);re(_e,c);var Oe=x(_e),Re=k(_e,2);re(Re,d);var tt=k(Re,2);{var Ve=ce=>{var Ie=FP(),ge=x(Ie);re(ge,l);var ze=k(ge,2),Ae=x(ze),be=k(ze,2);re(be,d),K(nt=>$(Ae,nt),[()=>f(v)===null?"Auth token not yet created":`Last rotated: ${new Date(f(v)).toLocaleString()}`]),S(ce,Ie)};Z(tt,ce=>{f(v)!==void 0&&ce(Ve)})}K(ce=>{re(C,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${e.connected?"var(--tandem-success)":"var(--tandem-error)"}; flex-shrink: 0;`),$(j,`${e.connected?"Connected to claude-sidecar":"Disconnected"} `),$(M,` ${ce??""}`),$(we,`${e.settings.degradedBannerDelayMs/1e3}s`),yr(ae,e.settings.degradedBannerDelayMs),Ce!==(Ce=e.settings.sidecarRetryStrategy)&&(de.value=(de.__value=e.settings.sidecarRetryStrategy)??"",Ug(de,e.settings.sidecarRetryStrategy)),ti(Oe,e.settings.holdAnnotationsWhileOffline)},[()=>f(u)?f(u).toUpperCase():"—"]),L("input",ae,ce=>e.onUpdate({degradedBannerDelayMs:Number(ce.target.value)})),L("change",de,ce=>e.onUpdate({sidecarRetryStrategy:ce.target.value})),L("change",Oe,ce=>e.onUpdate({holdAnnotationsWhileOffline:ce.target.checked})),S(n,g),Le()}qe(["click","input","change"]);function Dv(n){const e=n==null?void 0:n.trim();return e?e.slice(0,qf):Sx}function Rv(){try{return Dv(localStorage.getItem(qg))}catch{return Sx}}function HP(n){const e=Dv(n);try{localStorage.setItem(qg,e)}catch{}return typeof window<"u"&&window.dispatchEvent(new Event(hm)),e}function G_(n){const e=()=>n(Rv()),t=r=>{r.key===qg&&n(Dv(r.newValue))};return window.addEventListener(hm,e),window.addEventListener("storage",t),()=>{window.removeEventListener(hm,e),window.removeEventListener("storage",t)}}function Nv(){let n=B(at(Rv()));const e=G_(r=>{b(n,r,!0)});return ri(e),{get userName(){return f(n)},setUserName:r=>{const i=HP(r);b(n,i,!0)}}}var VP=E(`<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" style="display: flex; gap: var(--tandem-space-2);"><button type="button" data-testid="settings-modal-default-mode-tandem-btn" role="radio">Tandem</button> <button type="button" data-testid="settings-modal-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="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 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
|
|
94
|
+
restores when you return to Tandem.</div>`,1);function UP(n,e){Pe(e,!0);const t=Nv();let r=B(at(t.userName)),i=B(void 0);le(()=>{const m=t.userName;f(r)!==m&&document.activeElement!==f(i)&&b(r,m,!0)});var o=VP(),s=ye(o),a=k(x(s),2);gt(a,m=>b(i,m),()=>f(i));var l=k(s,2),c=k(x(l),2),d=x(c),u=k(d,2),h=k(l,2),p=x(h);K(()=>{yr(a,f(r)),G(a,"maxlength",qf),G(d,"aria-checked",e.settings.defaultMode==="tandem"),re(d,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="tandem"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="tandem"?600:400}; cursor: pointer;`),G(u,"aria-checked",e.settings.defaultMode==="solo"),re(u,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="solo"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="solo"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="solo"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="solo"?600:400}; cursor: pointer;`),ti(p,e.settings.soloRailHidden)}),L("input",a,m=>{b(r,m.target.value,!0)}),Et("blur",a,()=>t.setUserName(f(r))),L("keydown",a,m=>{m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(b(r,t.userName,!0),m.currentTarget.blur())}),L("click",d,()=>e.onUpdate({defaultMode:"tandem"})),L("click",u,()=>e.onUpdate({defaultMode:"solo"})),L("change",p,m=>e.onUpdate({soloRailHidden:m.target.checked})),S(n,o),Le()}qe(["input","keydown","click","change"]);var jP=E('<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),WP=E('<div><div class="settings-section-label">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 Claude 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> <!>',1);function KP(n,e){Pe(e,!0);var t=WP(),r=ye(t),i=x(r),o=k(x(i)),s=x(o),a=k(i,4);G(a,"step",100);var l=k(a,2),c=x(l),d=x(c),u=k(c,2),h=x(u),p=k(r,2),m=x(p),v=k(p,2),g=x(v),y=k(v,2);{var w=C=>{var A=xt(),j=ye(A);ax(j,()=>Wr(()=>import("./CoworkSettings-C0cS9R7L.js"),[]),H=>{var D=jP();S(H,D)},(H,D)=>{const N=F(()=>f(D).default);var W=xt(),ee=ye(W);Hg(ee,()=>f(N),(z,Y)=>{Y(z,{})}),S(H,W)}),S(C,A)},_=F(()=>Nn());Z(y,C=>{f(_)&&C(w)})}K((C,A,j)=>{$(s,`${C??""}s`),G(a,"min",Za),G(a,"max",Ya),yr(a,e.settings.selectionDwellMs),$(d,`${A??""}s`),$(h,`${j??""}s`),ti(m,e.settings.selectionToolbar),ti(g,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(Za/1e3).toFixed(1),()=>(Ya/1e3).toFixed(1)]),L("input",a,C=>e.onUpdate({selectionDwellMs:Number(C.target.value)})),L("change",m,C=>e.onUpdate({selectionToolbar:C.target.checked})),L("change",g,C=>e.onUpdate({marginView:C.target.checked})),S(n,t),Le()}qe(["input","change"]);var qP=E('<kbd style="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);"> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),JP=E('<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>'),ZP=E('<kbd style="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);"> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),YP=E('<div data-testid="settings-modal-shortcuts-list" style="display: flex; flex-direction: column; gap: var(--tandem-space-4);"><!> <section><div class="settings-section-label">Other</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section></div>');function GP(n,e){Pe(e,!0),le(()=>{});const t=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"Ctrl+F",description:"Find / Replace"},{keys:"?",description:"Show keyboard shortcuts"},{keys:"Ctrl+Tab",description:"Next document tab"},{keys:"Ctrl+Shift+Tab",description:"Previous document tab"}],r=F(()=>{const l=hc(),c=new Map;for(const d of l.values()){if(!d.shortcut)continue;const u=c.get(d.group)??[];u.push({keys:d.shortcut,description:d.label}),c.set(d.group,u)}return Jg.map(d=>({title:d.charAt(0).toUpperCase()+d.slice(1),rows:c.get(d)??[]})).filter(d=>d.rows.length>0)});var i=YP(),o=x(i);dt(o,17,()=>f(r),l=>l.title,(l,c)=>{var d=JP(),u=x(d),h=x(u),p=k(u,2);dt(p,21,()=>f(c).rows,m=>m.keys+m.description,(m,v)=>{var g=qP(),y=ye(g),w=x(y),_=k(y,2),C=x(_);K(()=>{$(w,f(v).keys),$(C,f(v).description)}),S(m,g)}),K(()=>$(h,f(c).title)),S(l,d)});var s=k(o,2),a=k(x(s),2);dt(a,21,()=>t,l=>l.keys+l.description,(l,c)=>{var d=ZP(),u=ye(d),h=x(u),p=k(u,2),m=x(p);K(()=>{$(h,f(c).keys),$(m,f(c).description)}),S(l,d)}),S(n,i),Le()}var XP=E('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),QP=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),$P=E('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),eL=E('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),tL=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),nL=E('<div><button type="button" data-testid="settings-modal-view-documentation-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 rL(n,e){Pe(e,!0);const t=uh(()=>e.open??!1);let r=B(!1),i=B(null);async function o(){var C;const w=(C=t.info)==null?void 0:C.workflowsPath;if(!w){b(i,"Documentation file not found.");return}b(r,!0),b(i,null);const _=await K_(w,{readOnly:!0,notFoundMessage:"Documentation file not found.",failureMessage:"Failed to open documentation."});b(r,!1),_.ok||b(i,_.error,!0)}const s=F(()=>{var C;const w=t.info;if(!w)return[];const _=[{label:"Version",value:`Tandem v${w.version}`},{label:"Tools",value:w.toolCount===null?"Tool count unavailable":`${w.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${w.mcpSdkVersion}`},{label:"Transport",value:((C=w.transport)==null?void 0:C.toUpperCase())??"—"}];return w.storagePath&&_.push({label:"Storage",value:w.storagePath}),w.tokenRotatedAt!==void 0&&_.push({label:"Token",value:w.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(w.tokenRotatedAt).toLocaleString()}`}),w.changelogPath&&_.push({label:"Changelog",value:w.changelogPath}),_});var a=nL(),l=ye(a),c=x(l),d=x(c),u=k(c,2);{var h=w=>{var _=XP(),C=x(_);K(()=>$(C,f(i))),S(w,_)};Z(u,w=>{f(i)&&w(h)})}var p=k(l,2),m=k(x(p),2);{var v=w=>{var _=QP();S(w,_)},g=w=>{var _=eL();dt(_,21,()=>f(s),C=>C.label,(C,A)=>{var j=$P(),H=ye(j),D=x(H),N=k(H,2),W=x(N);K(()=>{$(D,f(A).label),$(W,f(A).value)}),S(C,j)}),S(w,_)},y=w=>{var _=tL();S(w,_)};Z(m,w=>{t.loading?w(v):t.info?w(g,1):w(y,-1)})}K(()=>{c.disabled=f(r)||t.loading,re(c,`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: ${f(r)||t.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${f(r)||t.loading?.6:1};`),$(d,f(r)?"Opening…":"View Documentation")}),L("click",c,()=>void o()),S(n,a),Le()}qe(["click"]);var iL=E('<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>'),oL=E('<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>'),sL=E('<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>'),aL=E('<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: 9998;"></div> <div data-testid="settings-modal" role="dialog" aria-modal="true" class="settings-modal svelte-bbu5nk"><aside class="settings-modal-sidebar 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"><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 svelte-bbu5nk"><div class="settings-modal-content-inner svelte-bbu5nk"><!></div></div></section></div>',1);function lL(n,e){Pe(e,!0);const t="tandem-settings-modal-heading",r='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',i=[{id:"appearance",label:"Appearance",icon:"M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z",component:J_},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16",component:Z_},{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:Y_},{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:q_},{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:UP},{id:"claude-code",label:"Claude Code/Cowork",icon:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z",component:KP},{id:"shortcuts",label:"Shortcuts",icon:"M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z",component:GP},{id:"about",label:"About",icon:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01",component:rL}];let o=st(e,"returnFocusEl",3,null),s=st(e,"triggerEl",3,null),a=st(e,"connected",3,!1),l=st(e,"reconnectAttempts",3,0),c=st(e,"tabs",3,i),d=B(void 0);const u=uh(()=>e.open);let h=B(!1),p=B(null);const m=F(()=>c().length>0?c():i);let v=B(at(i[0].id));const g=F(()=>f(m).find(D=>D.id===f(v))??f(m)[0]),y=F(()=>f(g).label),w=F(()=>({open:e.open,settings:e.settings,onUpdate:e.onUpdate,connected:a(),reconnectAttempts:l()}));le(()=>{f(g)&&f(g).id!==f(v)&&b(v,f(g).id,!0)}),le(()=>{if(e.open)return Dt(()=>{var D;return(D=f(d))==null?void 0:D.focus()}),()=>{var D;(D=o())==null||D.focus()}}),le(()=>{if(!e.open)return;const D=W=>{var z;const ee=W.target;ee&&((z=s())!=null&&z.contains(ee)||f(d)&&!f(d).contains(ee)&&e.onClose())},N=setTimeout(()=>document.addEventListener("pointerdown",D),0);return()=>{clearTimeout(N),document.removeEventListener("pointerdown",D)}}),rd(()=>{const D=N=>{if(N.key!=="Escape"||!e.open)return;const W=N.target;!f(d)||!W||!f(d).contains(W)||(N.stopPropagation(),e.onClose())};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)}),le(()=>{if(!e.open)return;const D=N=>{if(N.key!=="Tab"||!f(d))return;const W=f(d).querySelectorAll(r);if(W.length===0)return;const ee=W[0],z=W[W.length-1],Y=document.activeElement;if(!f(d).contains(Y)){N.preventDefault(),ee.focus();return}N.shiftKey&&Y===ee?(N.preventDefault(),z.focus()):!N.shiftKey&&Y===z&&(N.preventDefault(),ee.focus())};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)}),le(()=>{f(v),b(p,null)});async function _(){var W;const D=(W=u.info)==null?void 0:W.changelogPath;if(!D){b(p,"Changelog file not found.");return}b(h,!0),b(p,null);const N=await K_(D,{readOnly:!0,notFoundMessage:"Changelog file not found.",failureMessage:"Failed to open changelog."});b(h,!1),N.ok?e.onClose():b(p,N.error,!0)}var C={DEFAULT_SETTINGS_TABS:i},A=xt(),j=ye(A);{var H=D=>{var N=aL(),W=ye(N),ee=k(W,2);G(ee,"aria-labelledby",t),G(ee,"tabindex",-1);var z=x(ee),Y=x(z),te=x(Y);G(te,"id",t);var ne=k(te,2);{var q=ge=>{var ze=iL(),Ae=x(ze);K(()=>$(Ae,`v${u.info.version??""}`)),S(ge,ze)};Z(ne,ge=>{u.info&&ge(q)})}var P=k(Y,2);dt(P,21,()=>f(m),ge=>ge.id,(ge,ze)=>{var Ae=oL(),be=x(Ae),nt=x(be),kt=k(be,2),yt=x(kt);K(()=>{G(Ae,"aria-current",f(v)===f(ze).id?"page":void 0),G(Ae,"data-active",f(v)===f(ze).id?"true":"false"),G(Ae,"data-testid",`settings-modal-tab-${f(ze).id}`),G(nt,"d",f(ze).icon),$(yt,f(ze).label)}),L("click",Ae,()=>b(v,f(ze).id,!0)),S(ge,Ae)});var M=k(P,2),O=x(M),I=x(O),T=k(O,2);{var R=ge=>{var ze=sL(),Ae=x(ze);K(()=>$(Ae,f(p))),S(ge,ze)};Z(T,ge=>{f(p)&&ge(R)})}var V=k(T,2),se=k(V,2),he=x(se),we=k(he,2),ae=x(we);{var Q=ge=>{var ze=nn("MCP connected");S(ge,ze)},ie=ge=>{var ze=nn("Reconnecting…");S(ge,ze)},de=ge=>{var ze=nn("MCP offline");S(ge,ze)};Z(ae,ge=>{a()?ge(Q):l()>0?ge(ie,1):ge(de,-1)})}var Ce=k(z,2),_e=x(Ce),Oe=x(_e),Re=x(Oe),tt=k(Oe,2),Ve=k(_e,2),ce=x(Ve),Ie=x(ce);wu(Ie,()=>f(g).id,ge=>{var ze=xt(),Ae=ye(ze);Hg(Ae,()=>f(g).component,(be,nt)=>{nt(be,Dl(()=>f(w)))}),S(ge,ze)}),gt(ee,ge=>b(d,ge),()=>f(d)),K(()=>{O.disabled=f(h)||u.loading,$(I,f(h)?"Opening…":"Changelog"),G(V,"href",mx),G(he,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),$(Re,f(y))}),L("click",W,function(...ge){var ze;(ze=e.onClose)==null||ze.apply(this,ge)}),L("keydown",W,ge=>{(ge.key==="Enter"||ge.key===" ")&&(ge.preventDefault(),e.onClose())}),L("click",O,()=>void _()),L("click",tt,function(...ge){var ze;(ze=e.onClose)==null||ze.apply(this,ge)}),S(D,N)};Z(j,D=>{e.open&&D(H)})}return S(n,A),Le(C)}qe(["click","keydown"]);var cL=E('<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>'),dL=E('<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>'),uL=E('<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),fL=E(`<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
|
|
95
|
+
restores when you return to Tandem.</div>`,1),hL=E('<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),pL=E('<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 Claude 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> <!>',1),mL=E('<kbd style="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);"> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),gL=E('<section><div> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section>'),vL=E('<kbd style="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);"> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>',1),yL=E('<div data-testid="settings-shortcuts-list" style="display: flex; flex-direction: column; gap: var(--tandem-space-4);"><!> <section><div>Other</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section></div>'),bL=E('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),wL=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),xL=E('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),kL=E('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),_L=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),SL=E('<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),CL=E('<div aria-hidden="true" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); z-index: 9998;"></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 style="background: none; border: 1px solid transparent; cursor: pointer; color: var(--tandem-fg-subtle); font-size: 18px; line-height: 1; padding: 4px 8px; min-width: 30px; min-height: 30px; border-radius: var(--tandem-r-2);" 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 TL(n,e){Pe(e,!0);const t="tandem-settings-heading",r='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',i=[{id:"appearance",label:"Appearance",icon:"M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z"},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16"},{id:"network",label:"Network",icon:"M3 12h18M3 12a9 9 0 0 1 18 0M3 12a9 9 0 0 0 18 0M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"},{id:"accessibility",label:"Accessibility",icon:"M12 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4ZM4 9h16M9 9v5l-2 7M15 9v5l2 7M9 14h6"},{id:"collaboration",label:"Collaboration",icon:"M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM21 21v-2a4 4 0 0 0-3-3.87M16 3.13A4 4 0 0 1 16 11"},{id:"claude-code",label:"Claude Code/Cowork",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"}],o=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"Ctrl+F",description:"Find / Replace"},{keys:"?",description:"Show keyboard shortcuts"},{keys:"Ctrl+Tab",description:"Next document tab"},{keys:"Ctrl+Shift+Tab",description:"Previous document tab"}],s=F(()=>{const z=hc(),Y=new Map;for(const te of z.values()){if(!te.shortcut)continue;const ne=te.group,q=Y.get(ne)??[];q.push({keys:te.shortcut,description:te.label}),Y.set(ne,q)}return Jg.map(te=>({title:te.charAt(0).toUpperCase()+te.slice(1),rows:Y.get(te)??[]})).filter(te=>te.rows.length>0)});let a=st(e,"connected",3,!1),l=st(e,"reconnectAttempts",3,0),c=B(void 0),d=B(void 0);const u=Nv();let h=B(at(u.userName));const p=uh(()=>e.open);let m=B(!1),v=B(null),g=B(!1),y=B(null),w=B("appearance");le(()=>{f(w),b(v,null),b(y,null)}),le(()=>{const z=u.userName;f(h)!==z&&document.activeElement!==f(d)&&b(h,z,!0)}),le(()=>{var z;if(e.open)return(z=f(c))==null||z.focus(),()=>{var Y;(Y=e.returnFocusEl)==null||Y.focus()}}),le(()=>{if(!e.open)return;const z=te=>{var q;const ne=te.target;(q=e.anchorEl)!=null&&q.contains(ne)||f(c)&&!f(c).contains(ne)&&e.onClose()},Y=setTimeout(()=>document.addEventListener("pointerdown",z),0);return()=>{clearTimeout(Y),document.removeEventListener("pointerdown",z)}}),le(()=>{if(!e.open)return;const z=Y=>{if(Y.key==="Escape"){e.onClose();return}if(Y.key!=="Tab"||!f(c))return;const te=f(c).querySelectorAll(r);if(te.length===0)return;const ne=te[0],q=te[te.length-1],P=document.activeElement;if(!f(c).contains(P)){Y.preventDefault(),ne.focus();return}Y.shiftKey&&P===ne?(Y.preventDefault(),q.focus()):!Y.shiftKey&&P===q&&(Y.preventDefault(),ne.focus())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)});async function _(z,Y,te,ne){if(!z){te(ne.notFound);return}Y(!0),te(null);try{const q=await fetch(`${Gn}${dl}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:z,readOnly:!0})});if(!q.ok){let P=ne.failed;try{const M=await q.json();M.message&&(P=M.message)}catch{}q.status===404&&(P=ne.notFound),te(P);return}e.onClose()}catch(q){console.warn("[Tandem] Failed to open read-only file:",q),te("Server unavailable.")}finally{Y(!1)}}function C(){var z;return _((z=p.info)==null?void 0:z.workflowsPath,Y=>b(g,Y,!0),Y=>b(y,Y,!0),{notFound:"Documentation file not found.",failed:"Failed to open documentation."})}function A(){var z;return _((z=p.info)==null?void 0:z.changelogPath,Y=>b(m,Y,!0),Y=>b(v,Y,!0),{notFound:"Changelog file not found.",failed:"Failed to open changelog."})}const j="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";function H(z){var Y;return((Y=i.find(te=>te.id===z))==null?void 0:Y.label)??"Settings"}function D(){var te;const z=p.info;if(!z)return[];const Y=[{label:"Version",value:`Tandem v${z.version}`},{label:"Tools",value:z.toolCount===null?"Tool count unavailable":`${z.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${z.mcpSdkVersion}`},{label:"Transport",value:((te=z.transport)==null?void 0:te.toUpperCase())??"—"}];return z.storagePath&&Y.push({label:"Storage",value:z.storagePath}),z.tokenRotatedAt!==void 0&&Y.push({label:"Token",value:z.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(z.tokenRotatedAt).toLocaleString()}`}),z.changelogPath&&Y.push({label:"Changelog",value:z.changelogPath}),Y}var N=xt(),W=ye(N);{var ee=z=>{var Y=CL(),te=ye(Y),ne=k(te,2);G(ne,"aria-labelledby",t),G(ne,"tabindex",-1);var q=x(ne),P=x(q),M=x(P);G(M,"id",t);var O=k(M,2);{var I=Se=>{var Xe=cL(),X=x(Xe);K(()=>$(X,`v${p.info.version??""}`)),S(Se,Xe)};Z(O,Se=>{p.info&&Se(I)})}var T=k(P,2);dt(T,21,()=>i,Se=>Se.id,(Se,Xe)=>{var X=dL(),U=x(X),ve=x(U),ke=k(U,2),Be=x(ke);K(()=>{G(X,"aria-current",f(w)===f(Xe).id?"page":void 0),G(X,"data-active",f(w)===f(Xe).id?"true":"false"),G(ve,"d",f(Xe).icon),$(Be,f(Xe).label)}),L("click",X,()=>b(w,f(Xe).id,!0)),S(Se,X)});var R=k(T,2),V=x(R),se=x(V),he=k(V,2);{var we=Se=>{var Xe=uL(),X=x(Xe);K(()=>$(X,f(v))),S(Se,Xe)};Z(he,Se=>{f(v)&&Se(we)})}var ae=k(he,2),Q=k(ae,2),ie=x(Q),de=k(ie,2),Ce=x(de);{var _e=Se=>{var Xe=nn("MCP connected");S(Se,Xe)},Oe=Se=>{var Xe=nn("Reconnecting…");S(Se,Xe)},Re=Se=>{var Xe=nn("MCP offline");S(Se,Xe)};Z(Ce,Se=>{a()?Se(_e):l()>0?Se(Oe,1):Se(Re,-1)})}var tt=k(q,2),Ve=x(tt),ce=x(Ve),Ie=x(ce),ge=k(ce,2),ze=k(Ve,2),Ae=x(ze),be=x(Ae);{var nt=Se=>{var Xe=fL(),X=ye(Xe),U=x(X);re(U,j);var ve=k(U,2);gt(ve,lt=>b(d,lt),()=>f(d));var ke=k(X,2),Be=x(ke);re(Be,j);var me=k(Be,2),Te=x(me),rt=k(Te,2),Mt=k(ke,2),Tt=x(Mt);K(()=>{yr(ve,f(h)),G(ve,"maxlength",qf),G(Te,"aria-checked",e.settings.defaultMode==="tandem"),re(Te,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="tandem"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="tandem"?600:400}; cursor: pointer;`),G(rt,"aria-checked",e.settings.defaultMode==="solo"),re(rt,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="solo"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="solo"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="solo"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="solo"?600:400}; cursor: pointer;`),ti(Tt,e.settings.soloRailHidden)}),L("input",ve,lt=>{b(h,lt.target.value,!0)}),Et("blur",ve,()=>u.setUserName(f(h))),L("keydown",ve,lt=>{lt.key==="Enter"&<.currentTarget.blur(),lt.key==="Escape"&&(b(h,u.userName,!0),lt.currentTarget.blur())}),L("click",Te,()=>e.onUpdate({defaultMode:"tandem"})),L("click",rt,()=>e.onUpdate({defaultMode:"solo"})),L("change",Tt,lt=>e.onUpdate({soloRailHidden:lt.target.checked})),S(Se,Xe)},kt=Se=>{J_(Se,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},yt=Se=>{Z_(Se,{get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},Cn=Se=>{Y_(Se,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return a()},get reconnectAttempts(){return l()}})},ln=Se=>{q_(Se,{get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},co=Se=>{var Xe=pL(),X=ye(Xe),U=x(X);re(U,j);var ve=k(x(U)),ke=x(ve),Be=k(U,4);G(Be,"step",100);var me=k(Be,2),Te=x(me),rt=x(Te),Mt=k(Te,2),Tt=x(Mt),lt=k(X,2),He=x(lt),Qe=k(lt,2),bt=x(Qe),Yt=k(Qe,2);{var Vt=$t=>{var er=xt(),ar=ye(er);ax(ar,()=>Wr(()=>import("./CoworkSettings-C0cS9R7L.js"),[]),uo=>{var fo=hL();S(uo,fo)},(uo,fo)=>{const ea=F(()=>f(fo).default);var It=xt(),_t=ye(It);Hg(_t,()=>f(ea),(lr,wr)=>{wr(lr,{})}),S(uo,It)}),S($t,er)},cn=F(()=>Nn());Z(Yt,$t=>{f(cn)&&$t(Vt)})}K(($t,er,ar)=>{$(ke,`${$t??""}s`),G(Be,"min",Za),G(Be,"max",Ya),yr(Be,e.settings.selectionDwellMs),$(rt,`${er??""}s`),$(Tt,`${ar??""}s`),ti(He,e.settings.selectionToolbar),ti(bt,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(Za/1e3).toFixed(1),()=>(Ya/1e3).toFixed(1)]),L("input",Be,$t=>e.onUpdate({selectionDwellMs:Number($t.target.value)})),L("change",He,$t=>e.onUpdate({selectionToolbar:$t.target.checked})),L("change",bt,$t=>e.onUpdate({marginView:$t.target.checked})),S(Se,Xe)},Ue=Se=>{var Xe=yL(),X=x(Xe);dt(X,17,()=>f(s),Be=>Be.title,(Be,me)=>{var Te=gL(),rt=x(Te);re(rt,j);var Mt=x(rt),Tt=k(rt,2);dt(Tt,21,()=>f(me).rows,lt=>lt.keys+lt.description,(lt,He)=>{var Qe=mL(),bt=ye(Qe),Yt=x(bt),Vt=k(bt,2),cn=x(Vt);K(()=>{$(Yt,f(He).keys),$(cn,f(He).description)}),S(lt,Qe)}),K(()=>$(Mt,f(me).title)),S(Be,Te)});var U=k(X,2),ve=x(U);re(ve,j);var ke=k(ve,2);dt(ke,21,()=>o,Be=>Be.keys+Be.description,(Be,me)=>{var Te=vL(),rt=ye(Te),Mt=x(rt),Tt=k(rt,2),lt=x(Tt);K(()=>{$(Mt,f(me).keys),$(lt,f(me).description)}),S(Be,Te)}),S(Se,Xe)},Nt=Se=>{var Xe=SL(),X=ye(Xe),U=x(X),ve=x(U),ke=k(U,2);{var Be=He=>{var Qe=bL(),bt=x(Qe);K(()=>$(bt,f(y))),S(He,Qe)};Z(ke,He=>{f(y)&&He(Be)})}var me=k(X,2),Te=x(me);re(Te,j);var rt=k(Te,2);{var Mt=He=>{var Qe=wL();S(He,Qe)},Tt=He=>{var Qe=kL();dt(Qe,21,D,bt=>bt.label,(bt,Yt)=>{var Vt=xL(),cn=ye(Vt),$t=x(cn),er=k(cn,2),ar=x(er);K(()=>{$($t,f(Yt).label),$(ar,f(Yt).value)}),S(bt,Vt)}),S(He,Qe)},lt=He=>{var Qe=_L();S(He,Qe)};Z(rt,He=>{p.loading?He(Mt):p.info?He(Tt,1):He(lt,-1)})}K(()=>{U.disabled=f(g)||p.loading,re(U,`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: ${f(g)||p.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${f(g)||p.loading?.6:1};`),$(ve,f(g)?"Opening…":"View Documentation")}),L("click",U,()=>void C()),S(Se,Xe)};Z(be,Se=>{f(w)==="collaboration"?Se(nt):f(w)==="appearance"?Se(kt,1):f(w)==="editor"?Se(yt,2):f(w)==="network"?Se(Cn,3):f(w)==="accessibility"?Se(ln,4):f(w)==="claude-code"?Se(co,5):f(w)==="shortcuts"?Se(Ue,6):Se(Nt,-1)})}gt(ne,Se=>b(c,Se),()=>f(c)),K(Se=>{V.disabled=f(m)||p.loading,$(se,f(m)?"Opening…":"Changelog"),G(ae,"href",mx),G(ie,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),$(Ie,Se)},[()=>H(f(w))]),L("click",te,function(...Se){var Xe;(Xe=e.onClose)==null||Xe.apply(this,Se)}),L("click",V,()=>void A()),L("click",ge,function(...Se){var Xe;(Xe=e.onClose)==null||Xe.apply(this,Se)}),S(z,Y)};Z(W,z=>{e.open&&z(ee)})}S(n,N),Le()}qe(["click","input","keydown","change"]);var EL=E('<span class="toast-badge svelte-nsu1aw"> </span>'),AL=E('<div><span> </span> <!> <button style="position: absolute; top: 6px; right: 6px; border: none; background: transparent; cursor: pointer; font-size: 14px; color: var(--tandem-fg-subtle); line-height: 1; padding: 2px 4px;" aria-label="Dismiss notification">×</button></div>'),ML=E('<div data-testid="toast-container" style="position: fixed; bottom: 40px; right: var(--tandem-space-4); z-index: var(--tandem-z-toast); display: flex; flex-direction: column; gap: var(--tandem-space-2); max-width: 360px; pointer-events: none;"></div>');function OL(n,e){Pe(e,!0);const t={error:"var(--tandem-error)",warning:"var(--tandem-warning)",info:"var(--tandem-accent)"},r={error:"var(--tandem-error-bg)",warning:"var(--tandem-warning-bg)",info:"var(--tandem-accent-bg)"},i={error:"var(--tandem-error-fg-strong)",warning:"var(--tandem-warning-fg-strong)",info:"var(--tandem-accent-fg-strong)"};var o=xt(),s=ye(o);{var a=l=>{var c=ML();dt(c,21,()=>e.toasts,d=>d.id,(d,u)=>{const h=F(()=>t[f(u).severity]),p=F(()=>r[f(u).severity]),m=F(()=>i[f(u).severity]),v=F(()=>f(u).severity==="info"?"status":"alert");var g=AL(),y=x(g),w=x(y),_=k(y,2);{var C=j=>{var H=EL(),D=x(H);K(()=>{G(H,"data-testid",`toast-count-${f(u).id}`),re(H,`margin-left: 6px; font-size: 11px; font-weight: 600; color: ${f(m)??""}; background: ${f(p)??""}; padding: 1px 5px; border-radius: var(--tandem-r-4);`),$(D,`×${f(u).count??""}`)}),S(j,H)};Z(_,j=>{f(u).count>1&&j(C)})}var A=k(_,2);K(()=>{G(g,"role",f(v)),G(g,"data-testid",`toast-${f(u).id}`),re(g,`pointer-events: auto; background: var(--tandem-surface); border-radius: var(--tandem-r-3); border-left: 4px solid ${f(h)??""}; box-shadow: var(--tandem-shadow-4); padding: 10px 32px 10px 12px; position: relative; animation: tandem-toast-slide-in 0.2s ease-out; font-size: var(--tandem-text-base); line-height: 1.4; color: var(--tandem-fg);`),$(w,f(u).message),G(A,"data-testid",`toast-dismiss-${f(u).id}`)}),L("click",A,()=>e.onDismiss(f(u).id)),S(d,g)}),S(l,c)};Z(s,l=>{e.toasts.length>0&&l(a)})}S(n,o),Le()}qe(["click"]);var DL=E('<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 RL(n,e){const t=F(()=>e.installing?"Installing…":"Restart to install");var r=DL(),i=k(x(r),2),o=x(i),s=k(i,2),a=x(s),l=k(s,2);K(()=>{$(o,`Tandem v${e.version??""} is available.`),s.disabled=e.installing,$(a,f(t))}),L("click",s,function(...c){var d;(d=e.onInstall)==null||d.apply(this,c)}),L("click",l,function(...c){var d;(d=e.onDismiss)==null||d.apply(this,c)}),S(n,r)}qe(["click"]);const NL=Math.floor,IL=(n,e)=>n<e?n:e,PL=(n,e)=>n>e?n:e,X_=128,lu=127,LL=Number.MAX_SAFE_INTEGER,zL=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},Dc=typeof TextEncoder<"u"?new TextEncoder:null,FL=n=>Dc.encode(n),BL=Dc?FL:zL;let Kl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Kl&&Kl.decode(new Uint8Array).length===1&&(Kl=null);const Ku=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},fh=(n,e)=>{for(;e>lu;)Ku(n,X_|lu&e),e=NL(e/128);Ku(n,lu&e)},Hm=new Uint8Array(3e4),HL=Hm.length/3,VL=(n,e)=>{if(e.length<HL){const t=Dc.encodeInto(e,Hm).written||0;fh(n,t);for(let r=0;r<t;r++)Ku(n,Hm[r])}else KL(n,BL(e))},UL=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;fh(n,r);for(let i=0;i<r;i++)Ku(n,t.codePointAt(i))},jL=Dc&&Dc.encodeInto?VL:UL,WL=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=IL(t-r,e.length),o=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,o>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(PL(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},KL=(n,e)=>{fh(n,e.byteLength),WL(n,e)},Q_=n=>new Error(n),qL=Q_("Unexpected end of array"),JL=Q_("Integer out of Range"),ZL=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},YL=n=>ZL(n,Iv(n)),p0=n=>n.arr[n.pos++],Iv=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const i=n.arr[n.pos++];if(e=e+(i&lu)*t,t*=128,i<X_)return e;if(e>LL)throw JL}throw qL},GL=n=>{let e=Iv(n);if(e===0)return"";{let t=String.fromCodePoint(p0(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(p0(n));else for(;e>0;){const r=e<1e4?e:1e4,i=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(t))}},XL=n=>Kl.decode(YL(n)),m0=Kl?XL:GL;var Ta;(function(n){n[n.Token=0]="Token",n[n.PermissionDenied=1]="PermissionDenied",n[n.Authenticated=2]="Authenticated"})(Ta||(Ta={}));const QL=(n,e)=>{fh(n,Ta.Token),jL(n,e)},$L=(n,e,t,r)=>{switch(Iv(n)){case Ta.Token:{e();break}case Ta.PermissionDenied:{t(m0(n));break}case Ta.Authenticated:{r(m0(n));break}}},g0=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t}));var Vm;(function(n){n[n.Connecting=0]="Connecting",n[n.Open=1]="Open",n[n.Closing=2]="Closing",n[n.Closed=3]="Closed"})(Vm||(Vm={}));function e3(n){return n||(n={}),{delay:n.delay===void 0?200:n.delay,initialDelay:n.initialDelay===void 0?0:n.initialDelay,minDelay:n.minDelay===void 0?0:n.minDelay,maxDelay:n.maxDelay===void 0?0:n.maxDelay,factor:n.factor===void 0?0:n.factor,maxAttempts:n.maxAttempts===void 0?3:n.maxAttempts,timeout:n.timeout===void 0?0:n.timeout,jitter:n.jitter===!0,initialJitter:n.initialJitter===!0,handleError:n.handleError===void 0?null:n.handleError,handleTimeout:n.handleTimeout===void 0?null:n.handleTimeout,beforeAttempt:n.beforeAttempt===void 0?null:n.beforeAttempt,calculateDelay:n.calculateDelay===void 0?null:n.calculateDelay}}async function hp(n){return new Promise(e=>setTimeout(e,n))}function t3(n,e){let t=e.delay;if(t===0)return 0;if(e.factor&&(t*=Math.pow(e.factor,n.attemptNum-1),e.maxDelay!==0&&(t=Math.min(t,e.maxDelay))),e.jitter){const r=Math.ceil(e.minDelay),i=Math.floor(t);t=Math.floor(Math.random()*(i-r+1))+r}return Math.round(t)}async function n3(n,e){const t=e3(e);for(const a of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const l=t[a];if(!Number.isInteger(l)||l<0)throw new Error(`Value for ${a} must be an integer greater than or equal to 0`)}if(t.factor.constructor!==Number||t.factor<0)throw new Error("Value for factor must be a number greater than or equal to 0");if(t.delay<t.minDelay)throw new Error(`delay cannot be less than minDelay (delay: ${t.delay}, minDelay: ${t.minDelay}`);const r={attemptNum:0,attemptsRemaining:t.maxAttempts?t.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=t.calculateDelay||t3;async function o(){if(t.beforeAttempt&&t.beforeAttempt(r,t),r.aborted){const l=new Error("Attempt aborted");throw l.code="ATTEMPT_ABORTED",l}const a=async l=>{if(t.handleError&&await t.handleError(l,r,t),r.aborted||r.attemptsRemaining===0)throw l;r.attemptNum++;const c=i(r,t);return c&&await hp(c),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,t.timeout?new Promise((l,c)=>{const d=setTimeout(()=>{if(t.handleTimeout)try{l(t.handleTimeout(r,t))}catch(u){c(u)}else{const u=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${t.timeout})`);u.code="ATTEMPT_TIMEOUT",c(u)}},t.timeout);n(r,t).then(u=>{clearTimeout(d),l(u)}).catch(u=>{clearTimeout(d),a(u).then(l).catch(c)})}):n(r,t).catch(a)}const s=t.calculateDelay?t.calculateDelay(r,t):t.initialDelay;if(s&&await hp(s),r.attemptNum<1&&t.initialJitter){const a=i(r,t);a&&await hp(a)}return o()}const $_=Math.floor,r3=(n,e)=>n<e?n:e,i3=(n,e)=>n>e?n:e,o3=64,qu=128,s3=63,ql=127,eS=Number.MAX_SAFE_INTEGER,a3=()=>new Set,l3=Array.from,c3=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},Rc=typeof TextEncoder<"u"?new TextEncoder:null,d3=n=>Rc.encode(n),u3=Rc?d3:c3;let Jl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Jl&&Jl.decode(new Uint8Array).length===1&&(Jl=null);class f3{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Pv=()=>new f3,tS=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},Lv=n=>{const e=new Uint8Array(tS(n));let t=0;for(let r=0;r<n.bufs.length;r++){const i=n.bufs[r];e.set(i,t),t+=i.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},Ju=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},Bn=(n,e)=>{for(;e>ql;)Ju(n,qu|ql&e),e=$_(e/128);Ju(n,ql&e)},Um=new Uint8Array(3e4),h3=Um.length/3,p3=(n,e)=>{if(e.length<h3){const t=Rc.encodeInto(e,Um).written||0;Bn(n,t);for(let r=0;r<t;r++)Ju(n,Um[r])}else bl(n,u3(e))},m3=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;Bn(n,r);for(let i=0;i<r;i++)Ju(n,t.codePointAt(i))},ao=Rc&&Rc.encodeInto?p3:m3,g3=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=r3(t-r,e.length),o=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,o>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(i3(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},bl=(n,e)=>{Bn(n,e.byteLength),g3(n,e)},nS=n=>new Error(n),rS=nS("Unexpected end of array"),iS=nS("Integer out of Range");class v3{constructor(e){this.arr=e,this.pos=0}}const oS=n=>new v3(n),y3=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},hh=n=>y3(n,Ms(n)),v0=n=>n.arr[n.pos++],Ms=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const i=n.arr[n.pos++];if(e=e+(i&ql)*t,t*=128,i<qu)return e;if(e>eS)throw iS}throw rS},b3=n=>{let e=n.arr[n.pos++],t=e&s3,r=64;const i=(e&o3)>0?-1:1;if((e&qu)===0)return i*t;const o=n.arr.length;for(;n.pos<o;){if(e=n.arr[n.pos++],t=t+(e&ql)*r,r*=128,e<qu)return i*t;if(t>eS)throw iS}throw rS},w3=n=>{let e=Ms(n);if(e===0)return"";{let t=String.fromCodePoint(v0(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(v0(n));else for(;e>0;){const r=e<1e4?e:1e4,i=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(t))}},x3=n=>Jl.decode(hh(n)),Nc=Jl?x3:w3,k3=n=>{const e=n.pos,t=Nc(n);return n.pos=e,t},ol=Date.now,pp=()=>new Map,_3=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r};class S3{constructor(){this._observers=pp()}on(e,t){_3(this._observers,e,a3).add(t)}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return l3((this._observers.get(e)||pp()).values()).forEach(r=>r(...t))}destroy(){this._observers=pp()}}const C3=Object.keys,y0=n=>C3(n).length,T3=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),E3=(n,e)=>n===e,Zl=(n,e)=>{if(n==null||e==null)return E3(n,e);if(n.constructor!==e.constructor)return!1;if(n===e)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!Zl(n.get(t),e.get(t)))return!1;break}case Object:if(y0(n)!==y0(e))return!1;for(const t in n)if(!T3(n,t)||!Zl(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Zl(n[t],e[t]))return!1;break;default:return!1}return!0},mp=3e4;class A3 extends S3{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=ol();this.getLocalState()!==null&&mp/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,o)=>{o!==this.clientID&&mp<=t-i.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&cu(this,r,"timeout")},$_(mp/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,r=this.meta.get(t),i=r===void 0?0:r.clock+1,o=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:i,lastUpdated:ol()});const s=[],a=[],l=[],c=[];e===null?c.push(t):o==null?e!=null&&s.push(t):(a.push(t),Zl(o,e)||l.push(t)),(s.length>0||l.length>0||c.length>0)&&this.emit("change",[{added:s,updated:l,removed:c},"local"]),this.emit("update",[{added:s,updated:a,removed:c},"local"])}setLocalStateField(e,t){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:t})}getStates(){return this.states}}const cu=(n,e,t)=>{const r=[];for(let i=0;i<e.length;i++){const o=e[i];if(n.states.has(o)){if(n.states.delete(o),o===n.clientID){const s=n.meta.get(o);n.meta.set(o,{clock:s.clock+1,lastUpdated:ol()})}r.push(o)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},t]),n.emit("update",[{added:[],updated:[],removed:r},t]))},jm=(n,e,t=n.states)=>{const r=e.length,i=Pv();Bn(i,r);for(let o=0;o<r;o++){const s=e[o],a=t.get(s)||null,l=n.meta.get(s).clock;Bn(i,s),Bn(i,l),ao(i,JSON.stringify(a))}return Lv(i)},M3=(n,e,t)=>{const r=oS(e),i=ol(),o=[],s=[],a=[],l=[],c=Ms(r);for(let d=0;d<c;d++){const u=Ms(r);let h=Ms(r);const p=JSON.parse(Nc(r)),m=n.meta.get(u),v=n.states.get(u),g=m===void 0?0:m.clock;(g<h||g===h&&p===null&&n.states.has(u))&&(p===null?u===n.clientID&&n.getLocalState()!=null?h++:n.states.delete(u):n.states.set(u,p),n.meta.set(u,{clock:h,lastUpdated:i}),m===void 0&&p!==null?o.push(u):m!==void 0&&p===null?l.push(u):p!==null&&(Zl(p,v)||a.push(u),s.push(u)))}(o.length>0||a.length>0||l.length>0)&&n.emit("change",[{added:o,updated:a,removed:l},t]),(o.length>0||s.length>0||l.length>0)&&n.emit("update",[{added:o,updated:s,removed:l},t])};let sS=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};class Wm{constructor(e){this.data=e,this.encoder=Pv(),this.decoder=oS(new Uint8Array(this.data))}peekVarString(){return k3(this.decoder)}readVarUint(){return Ms(this.decoder)}readVarString(){return Nc(this.decoder)}readVarUint8Array(){return hh(this.decoder)}writeVarUint(e){return Bn(this.encoder,e)}writeVarString(e){return ao(this.encoder,e)}writeVarUint8Array(e){return bl(this.encoder,e)}length(){return tS(this.encoder)}}var En;(function(n){n[n.Sync=0]="Sync",n[n.Awareness=1]="Awareness",n[n.Auth=2]="Auth",n[n.QueryAwareness=3]="QueryAwareness",n[n.Stateless=5]="Stateless",n[n.CLOSE=7]="CLOSE",n[n.SyncStatus=8]="SyncStatus"})(En||(En={}));var Kn;(function(n){n.Connecting="connecting",n.Connected="connected",n.Disconnected="disconnected"})(Kn||(Kn={}));class $s{constructor(){this.encoder=Pv()}get(e){return e.encoder}toUint8Array(){return Lv(this.encoder)}}class O3 extends $s{constructor(){super(...arguments),this.type=En.CLOSE,this.description="Ask the server to close the connection"}get(e){return ao(this.encoder,e.documentName),Bn(this.encoder,this.type),this.encoder}}class D3 extends sS{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=Kn.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=Kn.Connected,this.emit("status",{status:Kn.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===Kn.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===Kn.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(O3,{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===Kn.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const e=()=>{let i=!1;return{retryPromise:n3(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:s=>{(!this.shouldConnect||i)&&s.abort()}}).catch(s=>{if(s&&s.code!=="ATTEMPT_ABORTED")throw s}),cancelFunc:()=>{i=!0}}},{retryPromise:t,cancelFunc:r}=e();return this.cancelWebsocketRetry=r,t}attachWebSocketListeners(e,t){const{identifier:r}=e,i=c=>this.emit("message",c),o=c=>this.emit("close",{event:c}),s=c=>this.emit("open",c),a=c=>{t(c)};this.webSocketHandlers[r]={message:i,close:o,open:s,error:a};const l=this.webSocketHandlers[e.identifier];Object.keys(l).forEach(c=>{e.addEventListener(c,l[c])})}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(r=>{var i;(i=this.webSocket)===null||i===void 0||i.removeEventListener(r,t[r]),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;const r=new this.configuration.WebSocketPolyfill(this.url);r.binaryType="arraybuffer",r.identifier=this.identifier,this.attachWebSocketListeners(r,t),this.webSocket=r,this.status=Kn.Connecting,this.emit("status",{status:Kn.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){var t;this.resolveConnectionAttempt(),this.lastMessageReceived=ol();const i=new Wm(e.data).peekVarString();(t=this.configuration.providerMap.get(i))===null||t===void 0||t.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Kn.Connected,this.emit("status",{status:Kn.Connected}),this.emit("connect"),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){var e;(e=this.connectionAttempt)===null||e===void 0||e.reject(),this.connectionAttempt=null}checkConnection(){var e;this.status===Kn.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=ol()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):((e=this.webSocket)===null||e===void 0||e.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]==="/";)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}send(e){var t;((t=this.webSocket)===null||t===void 0?void 0:t.readyState)===Vm.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=Kn.Disconnected,this.emit("status",{status:Kn.Disconnected}),this.emit("disconnect",{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout(()=>{this.connect()},this.configuration.delay)}destroy(){this.emit("destroy"),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}}const aS=0,zv=1,lS=2,R3=(n,e)=>{Bn(n,aS);const t=_R(e);bl(n,t)},N3=(n,e,t)=>{Bn(n,zv),bl(n,bR(e,t))},I3=(n,e,t)=>N3(e,t,hh(n)),cS=(n,e,t)=>{try{gR(e,hh(n),t)}catch(r){console.error("Caught error while handling a Yjs update",r)}},P3=(n,e)=>{Bn(n,lS),bl(n,e)},L3=cS,z3=(n,e,t,r)=>{const i=Ms(n);switch(i){case aS:I3(n,e,t);break;case zv:cS(n,t,r);break;case lS:L3(n,t,r);break;default:throw new Error("Unknown message type")}return i};class F3{constructor(e){this.message=e}apply(e,t){const{message:r}=this,i=r.readVarUint(),o=r.length();switch(i){case En.Sync:this.applySyncMessage(e,t);break;case En.Awareness:this.applyAwarenessMessage(e);break;case En.Auth:this.applyAuthMessage(e);break;case En.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case En.Stateless:e.receiveStateless(Nc(r.decoder));break;case En.SyncStatus:this.applySyncStatusMessage(e,b3(r.decoder)===1);break;case En.CLOSE:const s={code:1e3,reason:Nc(r.decoder),target:e.configuration.websocketProvider.webSocket,type:"close"};e.onClose(),e.configuration.onClose({event:s}),e.forwardClose({event:s});break;default:throw new Error(`Can’t apply message of unknown type: ${i}`)}r.length()>o+1&&e.send($s,{encoder:r.encoder})}applySyncMessage(e,t){const{message:r}=this;r.writeVarUint(En.Sync);const i=z3(r.decoder,r.encoder,e.document,e);t&&i===zv&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;M3(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;$L(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;t.writeVarUint(En.Awareness),t.writeVarUint8Array(jm(e.awareness,Array.from(e.awareness.getStates().keys())))}}class B3{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Lv(this.encoder)}send(e){e==null||e.send(this.create())}}class H3 extends $s{constructor(){super(...arguments),this.type=En.Auth,this.description="Authentication"}get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return ao(this.encoder,e.documentName),Bn(this.encoder,this.type),QL(this.encoder,e.token),this.encoder}}class b0 extends $s{constructor(){super(...arguments),this.type=En.Awareness,this.description="Awareness states update"}get(e){if(typeof e.awareness>"u")throw new Error("The awareness message requires awareness as an argument");if(typeof e.clients>"u")throw new Error("The awareness message requires clients as an argument");ao(this.encoder,e.documentName),Bn(this.encoder,this.type);let t;return e.states===void 0?t=jm(e.awareness,e.clients):t=jm(e.awareness,e.clients,e.states),bl(this.encoder,t),this.encoder}}class V3 extends $s{constructor(){super(...arguments),this.type=En.Stateless,this.description="A stateless message"}get(e){var t;return ao(this.encoder,e.documentName),Bn(this.encoder,this.type),ao(this.encoder,(t=e.payload)!==null&&t!==void 0?t:""),this.encoder}}class w0 extends $s{constructor(){super(...arguments),this.type=En.Sync,this.description="First sync step"}get(e){if(typeof e.document>"u")throw new Error("The sync step one message requires document as an argument");return ao(this.encoder,e.documentName),Bn(this.encoder,this.type),R3(this.encoder,e.document),this.encoder}}class U3 extends $s{constructor(){super(...arguments),this.type=En.Sync,this.description="A document update"}get(e){return ao(this.encoder,e.documentName),Bn(this.encoder,this.type),P3(this.encoder,e.update),this.encoder}}class j3 extends Error{constructor(){super(...arguments),this.code=1001}}class x0 extends sS{constructor(e){var t,r,i;super(),this.configuration={name:"",document:void 0,awareness:void 0,token:null,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit("connect"),this.forwardStatus=o=>this.emit("status",o),this.forwardClose=o=>this.emit("close",o),this.forwardDisconnect=o=>this.emit("disconnect",o),this.forwardDestroy=()=>this.emit("destroy"),this.setConfiguration(e),this.configuration.document=e.document?e.document:new Di,this.configuration.awareness=e.awareness!==void 0?e.awareness:new A3(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("unsyncedChanges",this.configuration.onUnsyncedChanges),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),(t=this.awareness)===null||t===void 0||t.on("update",()=>{this.emit("awarenessUpdate",{states:g0(this.awareness.getStates())})}),(r=this.awareness)===null||r===void 0||r.on("change",()=>{this.emit("awarenessChange",{states:g0(this.awareness.getStates())})}),this.document.on("update",this.boundDocumentUpdateHandler),(i=this.awareness)===null||i===void 0||i.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval=="number"&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new D3(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&(this.unsyncedChanges-=1),this.unsyncedChanges===0&&(this.synced=!0),this.emit("unsyncedChanges",{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(w0,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&cu(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(V3,{documentName:this.configuration.name,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(t){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${t}`);return}this.send(H3,{token:e??"",documentName:this.configuration.name})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(U3,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:t,removed:r},i){const o=e.concat(t).concat(r);this.send(b0,{awareness:this.awareness,clients:o,documentName:this.configuration.name})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit("synced",{state:e}))}receiveStateless(e){this.emit("stateless",{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn("HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn("HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}async onOpen(e){this.isAuthenticated=!1,this.emit("open",{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token=="function"?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(w0,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(b0,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t){if(!this._isAttached)return;const r=new B3(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new Wm(e.data),r=t.readVarString();t.writeVarString(r),this.emit("message",{event:e,message:new Wm(e.data)}),new F3(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&cu(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&&(cu(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>"u"||!("removeEventListener"in window))&&window.removeEventListener("pagehide",this.boundPageHide)}detach(){this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("status",this.forwardStatus),this.configuration.websocketProvider.off("status",this.configuration.onStatus),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||(this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("status",this.configuration.onStatus),this.configuration.websocketProvider.on("status",this.forwardStatus),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.configuration.websocketProvider.attach(this),this._isAttached=!0)}permissionDeniedHandler(e){this.emit("authenticationFailed",{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit("authenticated",{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new j3(`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)}}const Mn=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},sl=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Km=null;const Ki=function(n,e,t){let r=Km||(Km=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},W3=function(){Km=null},Us=function(n,e,t,r){return t&&(k0(n,e,t,r,-1)||k0(n,e,t,r,1))},K3=/^(img|br|input|textarea|hr)$/i;function k0(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Pr(n))){let s=n.parentNode;if(!s||s.nodeType!=1||pd(n)||K3.test(n.nodeName)||n.contentEditable=="false")return!1;e=Mn(n)+(i<0?0:1),n=s}else if(n.nodeType==1){let s=n.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else n=s,e=i<0?Pr(n):0}else return!1}}function Pr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function q3(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Pr(n)}else if(n.parentNode&&!pd(n))e=Mn(n),n=n.parentNode;else return null}}function J3(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!pd(n))e=Mn(n)+1,n=n.parentNode;else return null}}function Z3(n,e,t){for(let r=e==0,i=e==Pr(n);r||i;){if(n==t)return!0;let o=Mn(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==Pr(n)}}function pd(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const ph=function(n){return n.focusNode&&Us(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function ss(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Y3(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function G3(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Pr(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Pr(r.startContainer),r.startOffset)}}}const Ri=typeof navigator<"u"?navigator:null,_0=typeof document<"u"?document:null,$o=Ri&&Ri.userAgent||"",qm=/Edge\/(\d+)/.exec($o),dS=/MSIE \d/.exec($o),Jm=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec($o),sr=!!(dS||Jm||qm),Fo=dS?document.documentMode:Jm?+Jm[1]:qm?+qm[1]:0,Vr=!sr&&/gecko\/(\d+)/i.test($o);Vr&&+(/Firefox\/(\d+)/.exec($o)||[0,0])[1];const Zm=!sr&&/Chrome\/(\d+)/.exec($o),Rn=!!Zm,uS=Zm?+Zm[1]:0,Vn=!sr&&!!Ri&&/Apple Computer/.test(Ri.vendor),al=Vn&&(/Mobile\/\w+/.test($o)||!!Ri&&Ri.maxTouchPoints>2),Or=al||(Ri?/Mac/.test(Ri.platform):!1),fS=Ri?/Win/.test(Ri.platform):!1,Yi=/Android \d/.test($o),md=!!_0&&"webkitFontSmoothing"in _0.documentElement.style,X3=md?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Q3(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Bi(n,e){return typeof n=="number"?n:n[e]}function $3(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function S0(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=sl(s);continue}let a=s,l=a==o.body,c=l?Q3(o):$3(a),d=0,u=0;if(e.top<c.top+Bi(r,"top")?u=-(c.top-e.top+Bi(i,"top")):e.bottom>c.bottom-Bi(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Bi(i,"top")-c.top:e.bottom-c.bottom+Bi(i,"bottom")),e.left<c.left+Bi(r,"left")?d=-(c.left-e.left+Bi(i,"left")):e.right>c.right-Bi(r,"right")&&(d=e.right-c.right+Bi(i,"right")),d||u)if(l)o.defaultView.scrollBy(d,u);else{let p=a.scrollLeft,m=a.scrollTop;u&&(a.scrollTop+=u),d&&(a.scrollLeft+=d);let v=a.scrollLeft-p,g=a.scrollTop-m;e={left:e.left-v,top:e.top-g,right:e.right-v,bottom:e.bottom-g}}let h=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:sl(s)}}function e4(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let a=n.root.elementFromPoint(o,s);if(!a||a==n.dom||!n.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:hS(n.dom)}}function hS(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=sl(r));return e}function t4({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;pS(t,r==0?0:r-e)}function pS(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:o}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let ia=null;function n4(n){if(n.setActive)return n.setActive();if(ia)return n.focus(ia);let e=hS(n);n.focus(ia==null?{get preventScroll(){return ia={preventScroll:!0},!0}}:void 0),ia||(ia=!1,pS(e,0))}function mS(n,e){let t,r=2e8,i,o=0,s=e.top,a=e.top,l,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=Ki(d).getClientRects();else continue;for(let p=0;p<h.length;p++){let m=h[p];if(m.top<=s&&m.bottom>=a){s=Math.max(m.bottom,s),a=Math.min(m.top,a);let v=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(v<r){t=d,r=v,i=v&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,d.nodeType==1&&v&&(o=u+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=d,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=u+1)}}return!t&&l&&(t=l,i=c,r=0),t&&t.nodeType==3?r4(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:mS(t,i)}function r4(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=go(r,1);if(s.top!=s.bottom&&Fv(e,s)){i={node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function Fv(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function i4(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function o4(n,e,t){let{node:r,offset:i}=mS(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function s4(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let a=n.docView.nearestDesc(o,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?i=a.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(i=a.posAfter),s=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function gS(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=n.childNodes[o];if(s.nodeType==1){let a=s.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Fv(e,c))return gS(s,e,c)}}if((o=(o+1)%r)==i)break}return n}function a4(n,e){let t=n.dom.ownerDocument,r,i=0,o=G3(t,e.left,e.top);o&&({node:r,offset:i}=o);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!s||!n.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=n.dom.getBoundingClientRect();if(!Fv(e,c)||(s=gS(n.dom,e,c),!s))return null}if(Vn)for(let c=s;r&&c;c=sl(c))c.draggable&&(r=void 0);if(s=i4(s,e),r){if(Vr&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&i++}let c;md&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=s4(n,r,i,e))}a==null&&(a=o4(n,s,e));let l=n.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function C0(n){return n.top<n.bottom||n.left<n.right}function go(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(C0(r))return r}return Array.prototype.find.call(t,C0)||n.getBoundingClientRect()}const l4=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function vS(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=md||Vr;if(r.nodeType==3)if(s&&(l4.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let l=go(Ki(r,i,i),t);if(Vr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=go(Ki(r,i-1,i-1),-1);if(c.top==l.top){let d=go(Ki(r,i,i+1),-1);if(d.top!=l.top)return Tl(d,d.left<c.left)}}return l}else{let l=i,c=i,d=t<0?1:-1;return t<0&&!i?(c++,d=-1):t>=0&&i==r.nodeValue.length?(l--,d=1):t<0?l--:c++,Tl(go(Ki(r,l,c),d),d<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==Pr(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return gp(l.getBoundingClientRect(),!1)}if(o==null&&i<Pr(r)){let l=r.childNodes[i];if(l.nodeType==1)return gp(l.getBoundingClientRect(),!0)}return gp(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==Pr(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Ki(l,Pr(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Tl(go(c,1),!1)}if(o==null&&i<Pr(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Ki(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return Tl(go(c,-1),!0)}return Tl(go(r.nodeType==3?Ki(r):r,-t),t>=0)}function Tl(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function gp(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function yS(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function c4(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return yS(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=vS(n,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Ki(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const d4=/[\u0590-\u08ac]/;function u4(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=n.domSelection();return a?!d4.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?o:s:yS(n,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:m,focusOffset:v}=n.domSelectionRange(),g=m&&!p.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==v;try{a.collapse(d,u),l&&(l!=d||c!=u)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let T0=null,E0=null,A0=!1;function f4(n,e,t){return T0==e&&E0==t?A0:(T0=e,E0=t,A0=t=="up"||t=="down"?c4(n,e,t):u4(n,e,t))}const Ur=0,M0=1,fs=2,Ni=3;class gd{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ur,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){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,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Mn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let a=i.children[s];if(a.size){i=a;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],a=o+s.size;if(a>e||s instanceof wS){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof bS&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?Mn(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?Mn(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,a=0;;a++){let l=this.children[a],c=s+l.size;if(i==-1&&e<=c){let d=s+l.border;if(e>=d&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,d);e=s;for(let u=a;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=Mn(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>t||a==this.children.length-1)){t=c;for(let d=a+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){o=Mn(u.dom);break}t+=u.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}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:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let p=0,m=0;p<this.children.length;p++){let v=this.children[p],g=m+v.size;if(o>m&&s<g)return v.setSelection(e-m-v.border,t-m-v.border,r,i);m=g}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((Vr||Vn)&&e==t){let{node:p,offset:m}=a;if(p.nodeType==3){if(u=!!(m&&p.nodeValue[m-1]==`
|
|
96
|
+
`),u&&m==p.nodeValue.length)for(let v=p,g;v;v=v.parentNode){if(g=v.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:Mn(g)+1});break}let y=v.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let v=p.childNodes[m-1];u=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(Vr&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||u&&Vn)&&Us(a.node,a.offset,d.anchorNode,d.anchorOffset)&&Us(l.node,l.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!(u&&Vr)){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>t){let m=a;a=l,l=m}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&t>=r:e<s&&t>r){let a=r+o.border,l=s-o.border;if(e>=a&&t<=l){this.dirty=e==r||t==s?fs:M0,e==a&&t==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ni:o.markDirty(e-a,t-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?fs:Ni}r=s}this.dirty=fs}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?fs:M0;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class bS extends gd{constructor(e,t,r,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Ur&&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}}class h4 extends gd{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class js extends gd{constructor(e,t,r,i,o){super(e,[],r,i),this.mark=t,this.spec=o}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=Xs.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new js(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Ni||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ni&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ur){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ur}}slice(e,t,r){let i=js.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;t<s&&(o=Gm(o,t,s,r)),e>0&&(o=Gm(o,0,e,r));for(let a=0;a<o.length;a++)o[a].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Bo extends gd{constructor(e,t,r,i,o,s,a,l,c){super(e,[],o,s),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=a}static create(e,t,r,i,o,s){let a=o.nodeViews[t.type.name],l,c=a&&a(t,o,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Xs.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=_S(d,r,t),c?l=new p4(e,t,r,i,d,u||null,h,c,o,s+1):t.isText?new mh(e,t,r,i,d,h,o):new Bo(e,t,r,i,d,u||null,h,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>oe.empty)}return e}matchesNode(e,t,r){return this.dirty==Ur&&e.eq(this.node)&&Zu(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new g4(this,s&&s.node,e);b4(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!u&&l.syncToMarks(d==this.node.childCount?Rt.none:this.node.child(d).marks,r,e,d),l.placeWidget(c,e,i)},(c,d,u,h)=>{l.syncToMarks(c.marks,r,e,h);let p;l.findNodeMatch(c,d,u,h)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(p=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(c,d,u,p,e)||l.updateNextNode(c,d,u,e,h,i)||l.addNode(c,d,u,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==fs)&&(s&&this.protectLocalComposition(e,s),xS(this.contentDOM,this.children,e),al&&w4(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Ne)||r<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,a=x4(this.node.content,s,r-t,i-t);return a<0?null:{node:o,pos:a,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new h4(this,o,t,i);e.input.compositionNodes.push(s),this.children=Gm(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==Ni||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ur}updateOuterDeco(e){if(Zu(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=kS(this.dom,this.nodeDOM,Ym(this.outerDeco,this.node,t),Ym(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function O0(n,e,t,r,i){_S(r,e,n);let o=new Bo(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class mh extends Bo{constructor(e,t,r,i,o,s,a){super(e,t,r,i,o,null,s,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==Ni||this.dirty!=Ur&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ur||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ur,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new mh(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ni)}get domAtom(){return!1}isText(e){return this.node.text==e}}class wS extends gd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ur&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class p4 extends Bo{constructor(e,t,r,i,o,s,a,l,c,d){super(e,t,r,i,o,s,a,c,d),this.spec=l}update(e,t,r,i){if(this.dirty==Ni)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function xS(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=s.dom;if(a.parentNode==n){for(;a!=r;)r=D0(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(a,r);if(s instanceof js){let l=r?r.previousSibling:n.lastChild;xS(s.contentDOM,s.children,t),r=l?l.nextSibling:n.firstChild}}for(;r;)r=D0(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Yl=function(n){n&&(this.nodeName=n)};Yl.prototype=Object.create(null);const hs=[new Yl];function Ym(n,e,t){if(n.length==0)return hs;let r=t?hs[0]:new Yl,i=[r];for(let o=0;o<n.length;o++){let s=n[o].type.attrs;if(s){s.nodeName&&i.push(r=new Yl(s.nodeName));for(let a in s){let l=s[a];l!=null&&(t&&i.length==1&&i.push(r=new Yl(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return i}function kS(n,e,t,r){if(t==hs&&r==hs)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],a=t[o];if(o){let l;a&&a.nodeName==s.nodeName&&i!=n&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=hs[0]),i=l}m4(i,a||hs[0],s)}return i}function m4(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&n.classList.add(i[o]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function _S(n,e,t){return kS(n,n,hs,Ym(e,t,n.nodeType!=1))}function Zu(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function D0(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class g4{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=v4(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,i){let o=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;o<a&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Ur,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){l=d;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let d=js.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,i,o){let s=this.top.children[i];return s.dirty==Ni&&s.dom==s.contentDOM&&(s.dirty=fs),s.update(e,t,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,o,s){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Bo){let c=this.preMatch.matched.get(l);if(c!=null&&c!=o)return!1;let d=l.dom,u,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=Ni&&Zu(t,l.outerDeco));if(!h&&l.update(e,t,r,i))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(l,e,t,r,i,s)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=fs,u.updateChildren(i,s+1),u.dirty=Ur),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Zu(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=Bo.create(this.top,t,r,i,o,s);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,r,i,o){let s=Bo.create(this.top,e,t,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new bS(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof js;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof mh)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Vn||Rn)&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new wS(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function v4(n,e){let t=e,r=t.children.length,i=n.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(r){let c=t.children[r-1];if(c instanceof js)t=c,r=c.children.length;else{a=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=n.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function y4(n,e){return n.type.side-e.type.side}function b4(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,i,e.forChild(o,d),c),o+=d.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u;for(;s<i.length&&i[s].to==o;){let g=i[s++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(y4);for(let g=0;g<u.length;g++)t(u[g],c,!!l)}else t(d,c,!!l);let h,p;if(l)p=-1,h=l,l=null;else if(c<n.childCount)p=c,h=n.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=o&&a.splice(g--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let m=o+h.nodeSize;if(h.isText){let g=m;s<i.length&&i[s].from<g&&(g=i[s].from);for(let y=0;y<a.length;y++)a[y].to<g&&(g=a[y].to);g<m&&(l=h.cut(g-o),h=h.cut(0,g-o),m=g,p=-1)}else for(;s<i.length&&i[s].to<m;)s++;let v=h.isInline&&!h.isLeaf?a.filter(g=>!g.inline):a.slice();r(h,v,e.forChild(o,h),p),o=m}}function w4(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function x4(n,e,t,r){for(let i=0,o=0;i<n.childCount&&o<=r;){let s=n.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<n.childCount;){let c=n.child(i++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=t){if(o>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Gm(n,e,t,r,i){let o=[];for(let s=0,a=0;s<n.length;s++){let l=n[s],c=a,d=a+=l.size;c>=t||d<=e?o.push(l):(c<e&&o.push(l.slice(0,e-c,r)),i&&(o.push(i),i=void 0),d>t&&o.push(l.slice(t-c,l.size,r)))}return o}function Bv(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(ph(t)){for(l=s;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&Fe.isSelectable(u)&&i.parent&&!(u.isInline&&Z3(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;c=new Fe(s==h?a:r.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=s,h=s;for(let p=0;p<t.rangeCount;p++){let m=t.getRangeAt(p);u=Math.min(u,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(u<0)return null;[l,s]=h==n.state.selection.anchor?[h,u]:[u,h],a=r.resolve(s)}else l=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let u=e=="pointer"||n.state.selection.head<a.pos&&!o?1:-1;c=Hv(n,d,a,u)}return c}function SS(n){return n.editable?n.hasFocus():TS(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function to(n,e=!1){let t=n.state.selection;if(CS(n,t),!!SS(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Rn){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Us(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)_4(n);else{let{anchor:r,head:i}=t,o,s;R0&&!(t instanceof Ne)&&(t.$from.parent.inlineContent||(o=N0(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=N0(n,t.to))),n.docView.setSelection(r,i,n,e),R0&&(o&&I0(o),s&&I0(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&k4(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const R0=Vn||Rn&&uS<63;function N0(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(Vn&&i&&i.contentEditable=="false")return vp(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return vp(i);if(o)return vp(o)}}function vp(n){return n.contentEditable="true",Vn&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function I0(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function k4(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!SS(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function _4(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,Mn(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&sr&&Fo<=11&&(t.disabled=!0,t.disabled=!1)}function CS(n,e){if(e instanceof Fe){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(P0(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else P0(n)}function P0(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Hv(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||Ne.between(e,t,r)}function L0(n){return n.editable&&!n.hasFocus()?!1:TS(n)}function TS(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function S4(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Us(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Xm(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&We.findFrom(o,e)}function yo(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function z0(n,e,t){let r=n.state.selection;if(r instanceof Ne)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return yo(n,new Ne(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Xm(n.state,e);return i&&i instanceof Fe?yo(n,i):!1}else if(!(Or&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(a))&&!s.contentDOM?Fe.isSelectable(o)?yo(n,new Fe(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):md?yo(n,new Ne(n.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Fe&&r.node.isInline)return yo(n,new Ne(e>0?r.$to:r.$from));{let i=Xm(n.state,e);return i?yo(n,i):!1}}}function Yu(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Gl(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function oa(n,e){return e<0?C4(n):T4(n)}function C4(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(Vr&&t.nodeType==1&&r<Yu(t)&&Gl(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(Gl(a,-1))i=t,o=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(ES(t))break;{let a=t.previousSibling;for(;a&&Gl(a,-1);)i=t.parentNode,o=Mn(a),a=a.previousSibling;if(a)t=a,r=Yu(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Qm(n,t,r):i&&Qm(n,i,o)}function T4(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Yu(t),o,s;for(;;)if(r<i){if(t.nodeType!=1)break;let a=t.childNodes[r];if(Gl(a,1))o=t,s=++r;else break}else{if(ES(t))break;{let a=t.nextSibling;for(;a&&Gl(a,1);)o=a.parentNode,s=Mn(a)+1,a=a.nextSibling;if(a)t=a,r=0,i=Yu(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}o&&Qm(n,o,s)}function ES(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function E4(n,e){for(;n&&e==n.childNodes.length&&!pd(n);)e=Mn(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function A4(n,e){for(;n&&!e&&!pd(n);)e=Mn(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Qm(n,e,t){if(e.nodeType!=3){let o,s;(s=E4(e,t))?(e=s,t=0):(o=A4(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(ph(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&to(n)},50)}function F0(n,e){let t=n.state.doc.resolve(e);if(!(Rn||fS)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function B0(n,e,t){let r=n.state.selection;if(r instanceof Ne&&!r.empty||t.indexOf("s")>-1||Or&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Xm(n.state,e);if(s&&s instanceof Fe)return yo(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof or?We.near(s,e):We.findFrom(s,e);return a?yo(n,a):!1}return!1}function H0(n,e){if(!(n.state.selection instanceof Ne))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function V0(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function M4(n){if(!Vn||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;V0(n,r,"true"),setTimeout(()=>V0(n,r,"false"),20)}return!1}function O4(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function D4(n,e){let t=e.keyCode,r=O4(e);if(t==8||Or&&t==72&&r=="c")return H0(n,-1)||oa(n,-1);if(t==46&&!e.shiftKey||Or&&t==68&&r=="c")return H0(n,1)||oa(n,1);if(t==13||t==27)return!0;if(t==37||Or&&t==66&&r=="c"){let i=t==37?F0(n,n.state.selection.from)=="ltr"?-1:1:-1;return z0(n,i,r)||oa(n,i)}else if(t==39||Or&&t==70&&r=="c"){let i=t==39?F0(n,n.state.selection.from)=="ltr"?1:-1:1;return z0(n,i,r)||oa(n,i)}else{if(t==38||Or&&t==80&&r=="c")return B0(n,-1,r)||oa(n,-1);if(t==40||Or&&t==78&&r=="c")return M4(n)||B0(n,1,r)||oa(n,1);if(r==(Or?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Vv(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||Xs.fromSchema(n.state.schema),a=NS(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=RS[c.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let m=a.createElement(d[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),u++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
97
|
+
|
|
98
|
+
`);return{dom:l,text:h,slice:e}}function AS(n,e,t,r,i){let o=i.parent.type.spec.code,s,a;if(!t&&!e)return null;let l=!!e&&(r||o||!t);if(l){if(n.someProp("transformPastedText",h=>{e=h(e,o||r,n)}),o)return a=new pe(oe.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
99
|
+
`))),0,0),n.someProp("transformPasted",h=>{a=h(a,n,!0)}),a;let u=n.someProp("clipboardTextParser",h=>h(e,i,r,n));if(u)a=u;else{let h=i.marks(),{schema:p}=n.state,m=Xs.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let g=s.appendChild(document.createElement("p"));v&&g.appendChild(m.serializeNode(p.text(v,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),s=P4(t),md&&L4(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||Vl.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!R4.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)a=z4(U0(a,+d[1],+d[2]),d[4]);else if(a=pe.maxOpen(N4(a.content,i),!0),a.openStart||a.openEnd){let u=0,h=0;for(let p=a.content.firstChild;u<a.openStart&&!p.type.spec.isolating;u++,p=p.firstChild);for(let p=a.content.lastChild;h<a.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);a=U0(a,u,h)}return n.someProp("transformPasted",u=>{a=u(a,n,l)}),a}const R4=/^(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 N4(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&OS(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=DS(s[s.length-1],o.length));let d=MS(a,l);s.push(d),i=i.matchType(d.type),o=l}}),s)return oe.from(s)}return n}function MS(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,oe.from(n));return n}function OS(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let o=OS(n,e,t,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(oe.from(MS(t,n,i+1))))}}function DS(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,DS(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(oe.empty,!0);return n.copy(t.append(r))}function $m(n,e,t,r,i,o){let s=e<0?n.firstChild:n.lastChild,a=s.content;return n.childCount>1&&(o=0),i<r-1&&(a=$m(a,e,t,r,i+1,o)),i>=t&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(oe.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(a))}function U0(n,e,t){return e<n.openStart&&(n=new pe($m(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new pe($m(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const RS={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let j0=null;function NS(){return j0||(j0=document.implementation.createHTMLDocument("title"))}let yp=null;function I4(n){let e=window.trustedTypes;return e?(yp||(yp=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),yp.createHTML(n)):n}function P4(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=NS().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&RS[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=I4(n),i)for(let o=0;o<i.length;o++)t=t.querySelector(i[o])||t;return t}function L4(n){let e=n.querySelectorAll(Rn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function z4(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:o,openEnd:s}=n;for(let a=r.length-2;a>=0;a-=2){let l=t.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=oe.from(l.create(r[a+1],i)),o++,s++}return new pe(i,o,s)}const Xn={},Qn={},F4={touchstart:!0,touchmove:!0};class B4{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 H4(n){for(let e in Xn){let t=Xn[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{U4(n,r)&&!Uv(n,r)&&(n.editable||!(r.type in Qn))&&t(n,r)},F4[e]?{passive:!0}:void 0)}Vn&&n.dom.addEventListener("input",()=>null),eg(n)}function No(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function V4(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function eg(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Uv(n,r))})}function Uv(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function U4(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function j4(n,e){!Uv(n,e)&&Xn[e.type]&&(n.editable||!(e.type in Qn))&&Xn[e.type](n,e)}Qn.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!PS(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Yi&&Rn&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),al&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,ss(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||D4(n,t)?t.preventDefault():No(n,"key")};Qn.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Qn.keypress=(n,e)=>{let t=e;if(PS(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Or&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof Ne)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i,o))&&n.dispatch(o()),t.preventDefault()}};function gh(n){return{left:n.clientX,top:n.clientY}}function W4(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function jv(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,a=>s>o.depth?a(n,t,o.nodeAfter,o.before(s),i,!0):a(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function Ea(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function K4(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&Fe.isSelectable(r)?(Ea(n,new Fe(t)),!0):!1}function q4(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof Fe&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(Fe.isSelectable(a)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(Ea(n,Fe.create(n.state.doc,i)),!0):!1}function J4(n,e,t,r,i){return jv(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?q4(n,t):K4(n,t))}function Z4(n,e,t,r){return jv(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Y4(n,e,t,r){return jv(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||G4(n,t,r)}function G4(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Ea(n,Ne.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),a=i.before(o);if(s.inlineContent)Ea(n,Ne.create(r,a+1,a+1+s.content.size));else if(Fe.isSelectable(s))Ea(n,Fe.create(r,a));else continue;return!0}}function Wv(n){return Gu(n)}const IS=Or?"metaKey":"ctrlKey";Xn.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Wv(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&W4(t,n.input.lastClick)&&!t[IS]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button};let s=n.posAtCoords(gh(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new X4(n,s,t,!!r)):(o=="doubleClick"?Z4:Y4)(n,s.pos,s.inside,t)?t.preventDefault():No(n,"pointer"))};class X4{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[IS],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);o=d.parent,s=d.depth?d.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof Fe&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Vr&&!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)),No(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(()=>to(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(gh(e))),this.updateAllowDefault(e),this.allowDefault||!t?No(this.view,"pointer"):J4(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Vn&&this.mightDrag&&!this.mightDrag.node.isAtom||Rn&&!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)?(Ea(this.view,We.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):No(this.view,"pointer")}move(e){this.updateAllowDefault(e),No(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)}}Xn.touchstart=n=>{n.input.lastTouch=Date.now(),Wv(n),No(n,"pointer")};Xn.touchmove=n=>{n.input.lastTouch=Date.now(),No(n,"pointer")};Xn.contextmenu=n=>Wv(n);function PS(n,e){return n.composing?!0:Vn&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Q4=Yi?5e3:-1;Qn.compositionstart=Qn.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof Ne&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Rn&&fS&&$4(n)))n.markCursor=n.state.storedMarks||t.marks(),Gu(n,!0),n.markCursor=null;else if(Gu(n,!e.selection.empty),Vr&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let a=n.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}LS(n,Q4)};function $4(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Qn.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,LS(n,20))};function LS(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Gu(n),e))}function zS(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=tz());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ez(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=q3(e.focusNode,e.focusOffset),r=J3(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function tz(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Gu(n,e=!1){if(!(Yi&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),zS(n),e||n.docView&&n.docView.dirty){let t=Bv(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function nz(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Ic=sr&&Fo<15||al&&X3<604;Xn.copy=Qn.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=Ic?null:t.clipboardData,s=r.content(),{dom:a,text:l}=Vv(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):nz(n,a),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function rz(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function iz(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Pc(n,r.value,null,i,e):Pc(n,r.textContent,r.innerHTML,i,e)},50)}function Pc(n,e,t,r,i){let o=AS(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,i,o||pe.empty)))return!0;if(!o)return!1;let s=rz(o),a=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function FS(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Qn.paste=(n,e)=>{let t=e;if(n.composing&&!Yi)return;let r=Ic?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Pc(n,FS(r),r.getData("text/html"),i,t)?t.preventDefault():iz(n,t)};class BS{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const oz=Or?"altKey":"ctrlKey";function HS(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[oz]}Xn.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(gh(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof Fe?i.to-1:i.to))){if(r&&r.mightDrag)s=Fe.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(s=Fe.create(n.state.doc,u.posBefore))}}let a=(s||n.state.selection).content(),{dom:l,text:c,slice:d}=Vv(n,a);(!t.dataTransfer.files.length||!Rn||uS>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ic?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ic||t.dataTransfer.setData("text/plain",c),n.dragging=new BS(d,HS(n,t),s)};Xn.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Qn.dragover=Qn.dragenter=(n,e)=>e.preventDefault();Qn.drop=(n,e)=>{try{sz(n,e,n.dragging)}finally{n.dragging=null}};function sz(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(gh(e));if(!r)return;let i=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",p=>{o=p(o,n,!1)}):o=AS(n,FS(e.dataTransfer),Ic?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&HS(n,e));if(n.someProp("handleDrop",p=>p(n,e,o||pe.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?nk(n.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let l=n.state.tr;if(s){let{node:p}=t;p?p.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,u=l.doc;if(d?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(u))return;let h=l.doc.resolve(c);if(d&&Fe.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new Fe(h));else{let p=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,v,g,y)=>p=y),l.setSelection(Hv(n,h,l.doc.resolve(p)))}n.focus(),n.dispatch(l.setMeta("uiEvent","drop"))}Xn.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&to(n)},20))};Xn.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Xn.beforeinput=(n,e)=>{if(Rn&&Yi&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,ss(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Qn)Xn[n]=Qn[n];function Lc(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Xu{constructor(e,t){this.toDOM=e,this.spec=t||Os,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new Ft(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Xu&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Lc(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ho{constructor(e,t){this.attrs=e,this.spec=t||Os}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Ft(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ho&&Lc(this.attrs,e.attrs)&&Lc(this.spec,e.spec)}static is(e){return e.type instanceof Ho}destroy(){}}class Kv{constructor(e,t){this.attrs=e,this.spec=t||Os}map(e,t,r,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new Ft(o.pos-r,s.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(r)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof Kv&&Lc(this.attrs,e.attrs)&&Lc(this.spec,e.spec)}destroy(){}}class Ft{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Ft(e,t,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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Ft(e,e,new Xu(t,r))}static inline(e,t,r,i){return new Ft(e,t,new Ho(r,i))}static node(e,t,r,i){return new Ft(e,t,new Kv(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ho}get widget(){return this.type instanceof Xu}}const ca=[],Os={};class et{constructor(e,t){this.local=e.length?e:ca,this.children=t.length?t:ca}static create(e,t){return t.length?Qu(t,e,0,Os):zn}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,o){for(let s=0;s<this.local.length;s++){let a=this.local[s];a.from<=t&&a.to>=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let a=this.children[s]+1;this.children[s+2].findInner(e-a,t-a,r,i+a,o)}}map(e,t,r){return this==zn||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Os)}mapInner(e,t,r,i,o){let s;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,i);l&&l.type.valid(t,l)?(s||(s=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?az(this.children,s||[],e,t,r,i,o):s?new et(s.sort(Ds),ca):zn}add(e,t){return t.length?this==zn?et.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,o=0;e.forEach((a,l)=>{let c=l+r,d;if(d=US(t,a,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<l;)o+=3;i[o]==l?i[o+2]=i[o+2].addInner(a,d,c+1):i.splice(o,0,l,l+a.nodeSize,Qu(d,a,c+1,Os)),o+=3}});let s=VS(o?jS(t):t,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new et(s.length?this.local.concat(s).sort(Ds):this.local,i||this.children)}remove(e){return e.length==0||this==zn?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,a=r[o]+t,l=r[o+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>a&&u.to<l&&(e[d]=null,(s||(s=[])).push(u));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,a+1);c!=zn?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let a=0;a<i.length;a++)i[a].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new et(i,r):zn}forChild(e,t){if(this==zn)return this;if(t.isLeaf)return et.empty;let r,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,s=o+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<s&&l.to>o&&l.type instanceof Ho){let c=Math.max(o,l.from)-o,d=Math.min(s,l.to)-o;c<d&&(i||(i=[])).push(l.copy(c,d))}}if(i){let a=new et(i.sort(Ds),ca);return r?new ko([a,r]):a}return r||zn}eq(e){if(this==e)return!0;if(!(e instanceof et)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return qv(this.localsInner(e))}localsInner(e){if(this==zn)return ca;if(e.inlineContent||!this.local.some(Ho.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ho||t.push(this.local[r]);return t}forEachSet(e){e(this)}}et.empty=new et([],[]);et.removeOverlap=qv;const zn=et.empty;class ko{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Os));return ko.from(r)}forChild(e,t){if(t.isLeaf)return et.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=zn&&(o instanceof ko?r=r.concat(o.members):r.push(o))}return ko.from(r)}eq(e){if(!(e instanceof ko)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?qv(r?t:t.sort(Ds)):ca}static from(e){switch(e.length){case 0:return zn;case 1:return e[0];default:return new ko(e.every(t=>t instanceof et)?e:e.reduce((t,r)=>t.concat(r instanceof et?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function az(n,e,t,r,i,o,s){let a=n.slice();for(let c=0,d=o;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,p,m,v)=>{let g=v-m-(p-h);for(let y=0;y<a.length;y+=3){let w=a[y+1];if(w<0||h>w+d-u)continue;let _=a[y]+d-u;p>=_?a[y+1]=h<=_?-2:-1:h>=d&&g&&(a[y]+=g,a[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=t.map(n[c]+o),u=d-i;if(u<0||u>=r.content.size){l=!0;continue}let h=t.map(n[c+1]+o,-1),p=h-i,{index:m,offset:v}=r.content.findIndex(u),g=r.maybeChild(m);if(g&&v==u&&v+g.nodeSize==p){let y=a[c+2].mapInner(t,g,d+1,n[c]+o+1,s);y!=zn?(a[c]=u,a[c+1]=p,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=lz(a,n,e,t,i,o,s),d=Qu(c,r,0,s);e=d.local;for(let u=0;u<a.length;u+=3)a[u+1]<0&&(a.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let p=d.children[u];for(;h<a.length&&a[h]<p;)h+=3;a.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new et(e.sort(Ds),a)}function VS(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new Ft(i.from+e,i.to+e,i.type))}return t}function lz(n,e,t,r,i,o,s){function a(l,c){for(let d=0;d<l.local.length;d++){let u=l.local[d].map(r,i,c);u?t.push(u):s.onRemove&&s.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<n.length;l+=3)n[l+1]==-1&&a(n[l+2],e[l]+o+1);return t}function US(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let o=0,s;o<n.length;o++)(s=n[o])&&s.from>t&&s.to<r&&((i||(i=[])).push(s),n[o]=null);return i}function jS(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Qu(n,e,t,r){let i=[],o=!1;e.forEach((a,l)=>{let c=US(n,a,l+t);if(c){o=!0;let d=Qu(c,a,t+l+1,r);d!=zn&&i.push(l,l+a.nodeSize,d)}});let s=VS(o?jS(n):n,-t).sort(Ds);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||i.length?new et(s,i):zn}function Ds(n,e){return n.from-e.from||n.to-e.to}function qv(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[i]=o.copy(o.from,r.to),W0(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),W0(e,i,r.copy(o.from,r.to)));break}}}return e}function W0(n,e,t){for(;e<n.length&&Ds(t,n[e])>0;)e++;n.splice(e,0,t)}function bp(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=zn&&e.push(r)}),n.cursorWrapper&&e.push(et.create(n.state.doc,[n.cursorWrapper.deco])),ko.from(e)}const cz={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},dz=sr&&Fo<=11;class uz{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class fz{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new uz,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);sr&&Fo<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Vn&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),dz&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,cz)),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(L0(this.view)){if(this.suppressingSelectionUpdates)return to(this.view);if(sr&&Fo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Us(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,r;for(let o=e.focusNode;o;o=sl(o))t.add(o);for(let o=e.anchorNode;o;o=sl(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&L0(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],l);u&&(o=o<0?u.from:Math.min(u.from,o),s=s<0?u.to:Math.max(u.to,s),u.typeOver&&(a=!0))}if(l.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of l)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(Vr&&l.length){let d=l.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let p=h.parentNode;p&&p.nodeName=="LI"&&(!u||mz(e,u)!=p)&&h.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ph(r)&&(c=Bv(e))&&c.eq(We.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,to(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),hz(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,gz(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||to(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(sr&&Fo<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h)}let s=i&&i.parentNode==e.target?Mn(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?Mn(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let K0=new WeakMap,q0=!1;function hz(n){if(!K0.has(n)&&(K0.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Vr,q0)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."),q0=!0}}function J0(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return Us(s.node,s.offset,i,o)&&([t,r,i,o]=[i,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}}function pz(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return J0(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?J0(n,t):null}function mz(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function gz(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let a=s;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(o,a.firstChild),r==o&&n.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function vz(n,e,t){let{node:r,fromOffset:i,toOffset:o,from:s,to:a}=n.docView.parseRange(e,t),l=n.domSelectionRange(),c,d=l.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],ph(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Rn&&n.input.lastKeyCode===8)for(let g=o;g>i;g--){let y=r.childNodes[g-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){o=g;break}if(!w||w.size)break}let u=n.state.doc,h=n.someProp("domParser")||Vl.fromSchema(n.state.schema),p=u.resolve(s),m=null,v=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:yz,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),m={anchor:g+s,head:y+s}}return{doc:v,sel:m,from:s,to:a}}function yz(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Vn&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Vn&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const bz=/^(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 wz(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let H=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,D=Bv(n,H);if(D&&!n.state.selection.eq(D)){if(Rn&&Yi&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",W=>W(n,ss(13,"Enter"))))return;let N=n.state.tr.setSelection(D);H=="pointer"?N.setMeta("pointer",!0):H=="key"&&N.scrollIntoView(),o&&N.setMeta("composition",o),n.dispatch(N)}return}let s=n.state.doc.resolve(e),a=s.sharedDepth(t);e=s.before(a+1),t=n.state.doc.resolve(t).after(a+1);let l=n.state.selection,c=vz(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),h,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,p="end"):(h=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let m=_z(u.content,c.doc.content,c.from,h,p);if(m&&n.input.domChangeCount++,(al&&n.input.lastIOSEnter>Date.now()-225||Yi)&&i.some(H=>H.nodeType==1&&!bz.test(H.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",H=>H(n,ss(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof Ne&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let H=Z0(n,n.state.doc,c.sel);if(H&&!H.eq(n.state.selection)){let D=n.state.tr.setSelection(H);o&&D.setMeta("composition",o),n.dispatch(D)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof Ne&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),sr&&Fo<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)==" "&&(m.start--,m.endA--,m.endB--);let v=c.doc.resolveNoCache(m.start-c.from),g=c.doc.resolveNoCache(m.endB-c.from),y=d.resolve(m.start),w=v.sameParent(g)&&v.parent.inlineContent&&y.end()>=m.endA;if((al&&n.input.lastIOSEnter>Date.now()-225&&(!w||i.some(H=>H.nodeName=="DIV"||H.nodeName=="P"))||!w&&v.pos<c.doc.content.size&&(!v.sameParent(g)||!v.parent.inlineContent)&&v.pos<g.pos&&!/\S/.test(c.doc.textBetween(v.pos,g.pos,"","")))&&n.someProp("handleKeyDown",H=>H(n,ss(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&kz(d,m.start,m.endA,v,g)&&n.someProp("handleKeyDown",H=>H(n,ss(8,"Backspace")))){Yi&&Rn&&n.domObserver.suppressSelectionUpdates();return}Rn&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Yi&&!w&&v.start()!=g.start()&&g.parentOffset==0&&v.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,g=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(H){return H(n,ss(13,"Enter"))})},20));let _=m.start,C=m.endA,A=H=>{let D=H||n.state.tr.replace(_,C,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let N=Z0(n,D.doc,c.sel);N&&!(Rn&&n.composing&&N.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(N.head==_||N.head==D.mapping.map(C)-1)||sr&&N.empty&&N.head==_)&&D.setSelection(N)}return o&&D.setMeta("composition",o),D.scrollIntoView()},j;if(w)if(v.pos==g.pos){sr&&Fo<=11&&v.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>to(n),20));let H=A(n.state.tr.delete(_,C)),D=d.resolve(m.start).marksAcross(d.resolve(m.endA));D&&H.ensureMarks(D),n.dispatch(H)}else if(m.endA==m.endB&&(j=xz(v.parent.content.cut(v.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let H=A(n.state.tr);j.type=="add"?H.addMark(_,C,j.mark):H.removeMark(_,C,j.mark),n.dispatch(H)}else if(v.parent.child(v.index()).isText&&v.index()==g.index()-(g.textOffset?0:1)){let H=v.parent.textBetween(v.parentOffset,g.parentOffset),D=()=>A(n.state.tr.insertText(H,_,C));n.someProp("handleTextInput",N=>N(n,_,C,H,D))||n.dispatch(D())}else n.dispatch(A());else n.dispatch(A())}function Z0(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Hv(n,e.resolve(t.anchor),e.resolve(t.head))}function xz(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,a,l;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<t.length;d++)o=t[d].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",l=d=>d.mark(a.addToSet(d.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(oe.from(c).eq(n))return{mark:a,type:s}}function kz(n,e,t,r,i){if(t-e<=i.pos-r.pos||wp(r,!0,!1)<i.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let a=o.nodeAfter;return a!=null&&t==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=n.resolve(wp(o,!0,!0));return!s.parent.isTextblock||s.pos>t||wp(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function wp(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function _z(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:a}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s<o&&n.size<e.size){let l=r<=o&&r>=s?o-r:0;o-=l,o&&o<e.size&&Y0(e.textBetween(o-1,o+1))&&(o+=l?1:-1),a=o+(a-s),s=o}else if(a<o){let l=r<=o&&r>=a?o-r:0;o-=l,o&&o<n.size&&Y0(n.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function Y0(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class WS{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 B4,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ew),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=Q0(this),X0(this),this.nodeViews=$0(this),this.docView=O0(this.state.doc,G0(this),bp(this),this.dom,this),this.domObserver=new fz(this,(r,i,o,s)=>wz(this,r,i,o,s)),this.domObserver.start(),H4(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&&eg(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ew),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(zS(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=$0(this);Cz(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&eg(this),this.editable=Q0(this),X0(this);let l=bp(this),c=G0(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=o||!this.docView.matchesNode(e.doc,c,l);(u||!e.selection.eq(i.selection))&&(s=!0);let h=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&e4(this);if(s){this.domObserver.stop();let p=u&&(sr||Rn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Sz(i.selection,e.selection);if(u){let m=Rn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ez(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=O0(e.doc,c,l,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&S4(this))?to(this,p):(CS(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&t4(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof Fe){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&S0(this,t.getBoundingClientRect(),e)}else S0(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new BS(e.slice,e.move,i<0?void 0:Fe.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let a=this.directPlugins[s].props[e];if(a!=null&&(i=t?t(a):a))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let a=o[s].props[e];if(a!=null&&(i=t?t(a):a))return i}}hasFocus(){if(sr){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&&n4(this.dom),to(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return a4(this,e)}coordsAtPos(e,t=1){return vS(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,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return f4(this,t||this.state,e)}pasteHTML(e,t){return Pc(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Pc(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Vv(this,e)}destroy(){this.docView&&(V4(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],bp(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,W3())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return j4(this,e)}domSelectionRange(){let e=this.domSelection();return e?Vn&&this.root.nodeType===11&&Y3(this.dom.ownerDocument)==this.dom&&pz(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}WS.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function G0(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ft.node(0,n.state.doc.content.size,e)]}function X0(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ft.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Q0(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Sz(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function $0(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Cz(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function ew(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Go={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:"'"},$u={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Tz=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ez=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var On=0;On<10;On++)Go[48+On]=Go[96+On]=String(On);for(var On=1;On<=24;On++)Go[On+111]="F"+On;for(var On=65;On<=90;On++)Go[On]=String.fromCharCode(On+32),$u[On]=String.fromCharCode(On);for(var xp in Go)$u.hasOwnProperty(xp)||($u[xp]=Go[xp]);function Az(n){var e=Tz&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ez&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?$u:Go)[n.keyCode]||n.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}const Mz=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Oz=typeof navigator<"u"&&/Win/.test(navigator.platform);function Dz(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))Mz?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function Rz(n){let e=Object.create(null);for(let t in n)e[Dz(t)]=n[t];return e}function kp(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Nz(n){return new Ct({props:{handleKeyDown:Jv(n)}})}function Jv(n){let e=Rz(n);return function(t,r){let i=Az(r),o,s=e[kp(i,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[kp(i,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Oz&&r.ctrlKey&&r.altKey)&&(o=Go[r.keyCode])&&o!=i){let a=e[kp(o,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}const Zv=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function KS(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const qS=(n,e,t)=>{let r=KS(n,t);if(!r)return!1;let i=Yv(r);if(!i){let s=r.blockRange(),a=s&&ul(s);return a==null?!1:(e&&e(n.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(tC(n,i,e,-1))return!0;if(r.parent.content.size==0&&(ll(o,"end")||Fe.isSelectable(o)))for(let s=r.depth;;s--){let a=Yf(n.doc,r.before(s),r.after(s),pe.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(ll(o,"end")?We.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Fe.create(l.doc,i.pos-o.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},Iz=(n,e,t)=>{let r=KS(n,t);if(!r)return!1;let i=Yv(r);return i?JS(n,i,e):!1},Pz=(n,e,t)=>{let r=YS(n,t);if(!r)return!1;let i=Gv(r);return i?JS(n,i,e):!1};function JS(n,e,t){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=Yf(n.doc,o,l,pe.empty);if(!c||c.from!=o||c instanceof yn&&c.slice.size>=l-o)return!1;if(t){let d=n.tr.step(c);d.setSelection(Ne.create(d.doc,o)),t(d.scrollIntoView())}return!0}function ll(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const ZS=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=Yv(r)}let s=o&&o.nodeBefore;return!s||!Fe.isSelectable(s)?!1:(e&&e(n.tr.setSelection(Fe.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Yv(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function YS(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const GS=(n,e,t)=>{let r=YS(n,t);if(!r)return!1;let i=Gv(r);if(!i)return!1;let o=i.nodeAfter;if(tC(n,i,e,1))return!0;if(r.parent.content.size==0&&(ll(o,"start")||Fe.isSelectable(o))){let s=Yf(n.doc,r.before(),r.after(),pe.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=n.tr.step(s);a.setSelection(ll(o,"start")?We.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):Fe.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},XS=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=Gv(r)}let s=o&&o.nodeAfter;return!s||!Fe.isSelectable(s)?!1:(e&&e(n.tr.setSelection(Fe.create(n.doc,o.pos)).scrollIntoView()),!0)};function Gv(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Lz=(n,e)=>{let t=n.selection,r=t instanceof Fe,i;if(r){if(t.node.isTextblock||!Qo(n.doc,t.from))return!1;i=t.from}else if(i=Zf(n.doc,t.from,-1),i==null)return!1;if(e){let o=n.tr.join(i);r&&o.setSelection(Fe.create(o.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},zz=(n,e)=>{let t=n.selection,r;if(t instanceof Fe){if(t.node.isTextblock||!Qo(n.doc,t.to))return!1;r=t.to}else if(r=Zf(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Fz=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),o=i&&ul(i);return o==null?!1:(e&&e(n.tr.lift(i,o).scrollIntoView()),!0)},QS=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
100
|
+
`).scrollIntoView()),!0)};function Xv(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Bz=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=Xv(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=t.after(),l=n.tr.replaceWith(a,a,s.createAndFill());l.setSelection(We.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},$S=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof or||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Xv(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,a=n.tr.insert(s,o.createAndFill());a.setSelection(Ne.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},eC=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(Qi(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&ul(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Hz(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Fe&&e.selection.node.isBlock)return!r.parentOffset||!Qi(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,a,l=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),a=Xv(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),o.unshift(l&&a?{type:a}:null),s=p;break}else{if(p==1)return!1;o.unshift(null)}let d=e.tr;(e.selection instanceof Ne||e.selection instanceof or)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=Qi(d.doc,u,o.length,o);if(h||(o[0]=a?{type:a}:null,h=Qi(d.doc,u,o.length,o)),!h)return!1;if(d.split(u,o.length,o),!l&&c&&r.node(s).type!=a){let p=d.mapping.map(r.before(s)),m=d.doc.resolve(p);a&&r.node(s-1).canReplaceWith(m.index(),m.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(s)),a)}return t&&t(d.scrollIntoView()),!0}}const Vz=Hz(),Uz=(n,e)=>{let{$from:t,to:r}=n.selection,i,o=t.sharedDepth(r);return o==0?!1:(i=t.before(o),e&&e(n.tr.setSelection(Fe.create(n.doc,i))),!0)};function jz(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Qo(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function tC(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&jz(n,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(a=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&a.matchType(s[0]||o.type).validEnd){if(t){let p=e.pos+o.nodeSize,m=oe.empty;for(let y=s.length-1;y>=0;y--)m=oe.from(s[y].create(null,m));m=oe.from(i.copy(m));let v=n.tr.step(new wn(e.pos-1,p,e.pos,p,new pe(m,1,0),s.length,!0)),g=v.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Qo(v.doc,g.pos)&&v.join(g.pos),t(v.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&l?null:We.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&ul(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&ll(o,"start",!0)&&ll(i,"end")){let p=i,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let v=o,g=1;for(;!v.isTextblock;v=v.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(t){let y=oe.empty;for(let _=m.length-1;_>=0;_--)y=oe.from(m[_].copy(y));let w=n.tr.step(new wn(e.pos-m.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new pe(y,m.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function nC(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(Ne.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}const Wz=nC(-1),Kz=nC(1);function qz(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),a=s&&Xg(s,n,e);return a?(r&&r(t.tr.wrap(s,a).scrollIntoView()),!0):!1}}function tw(n,e=null){return function(t,r){let i=!1;for(let o=0;o<t.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:a}}=t.selection.ranges[o];t.doc.nodesBetween(s,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(n,e)))if(l.type==n)i=!0;else{let d=t.doc.resolve(c),u=d.index();i=d.parent.canReplaceWith(u,u+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[s];o.setBlockType(a,l,n,e)}r(o.scrollIntoView())}return!0}}function Qv(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}Qv(Zv,qS,ZS);Qv(Zv,GS,XS);Qv(QS,$S,eC,Vz);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Jz(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o);if(!s)return!1;let a=r?t.tr:null;return Zz(a,s,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function Zz(n,e,t,r=null){let i=!1,o=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=s.resolve(e.start-2);o=new Ou(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Ou(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=Xg(o,t,r,e);return a?(n&&Yz(n,e,a,i,t),!0):!1}function Yz(n,e,t,r,i){let o=oe.empty;for(let d=t.length-1;d>=0;d--)o=oe.from(t[d].type.create(t[d].attrs,o));n.step(new wn(e.start-(r?2:0),e.end,e.start,e.end,new pe(o,0,0),t.length,!0));let s=0;for(let d=0;d<t.length;d++)t[d].type==i&&(s=d+1);let a=t.length-s,l=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&Qi(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return n}function Gz(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?Xz(e,t,n,o):Qz(e,t,o):!0:!1}}function Xz(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new wn(o-1,s,o,s,new pe(oe.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Ou(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=ul(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return Qo(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function Qz(n,e,t){let r=n.tr,i=t.parent;for(let p=t.end,m=t.endIndex-1,v=t.startIndex;m>v;m--)p-=i.child(m).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==i.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?oe.empty:oe.from(i))))return!1;let u=o.pos,h=u+s.nodeSize;return r.step(new wn(u-(a?1:0),h+(l?1:0),u+1,h-1,new pe((a?oe.empty:oe.from(i.copy(oe.empty))).append(l?oe.empty:oe.from(i.copy(oe.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function $z(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=n)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,d=oe.from(c?n.create():null),u=new pe(oe.from(n.create(null,oe.from(a.type.create(null,d)))),c?3:1,0),h=o.start,p=o.end;t(e.tr.step(new wn(h-(c?3:1),p,h,p,u,1,!0)).scrollIntoView())}return!0}}function vh(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,o=t.storedMarks,t}}}class yh{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:i}=t,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...d)=>{const u=l(...d)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a=[],l=!!e,c=e||o.tr,d=()=>(!l&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),a.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(r).map(([h,p])=>[h,(...v)=>{const g=this.buildProps(c,t),y=p(...v)(g);return a.push(y),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...d)=>c(...d)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a={tr:e,editor:i,view:s,state:vh({state:o,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...d)=>c(...d)(a)]))}};return a}}class eF{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){const r=(...i)=>{this.off(e,r),t.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function Ee(n,e,t){return n.config[e]===void 0&&n.parent?Ee(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?Ee(n.parent,e,t):null}):n.config[e]}function bh(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function rC(n){const e=[],{nodeExtensions:t,markExtensions:r}=bh(n),i=[...t,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage,extensions:i},l=Ee(s,"addGlobalAttributes",a);if(!l)return;l().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([h,p])=>{e.push({type:u,name:h,attribute:{...o,...p}})})})})}),i.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage},l=Ee(s,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([d,u])=>{const h={...o,...u};typeof(h==null?void 0:h.default)=="function"&&(h.default=h.default()),h!=null&&h.isRequired&&(h==null?void 0:h.default)===void 0&&delete h.default,e.push({type:s.name,name:d,attribute:h})})}),e}function _n(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function Zt(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){const a=o?String(o).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(d=>!l.includes(d));r[i]=[...l,...c].join(" ")}else if(i==="style"){const a=o?o.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;l.forEach(d=>{const[u,h]=d.split(":").map(p=>p.trim());c.set(u,h)}),a.forEach(d=>{const[u,h]=d.split(":").map(p=>p.trim());c.set(u,h)}),r[i]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[i]=o}),r},{})}function tg(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>Zt(t,r),{})}function iC(n){return typeof n=="function"}function ot(n,e=void 0,...t){return iC(n)?e?n.bind(e)(...t):n(...t):n}function tF(n={}){return Object.keys(n).length===0&&n.constructor===Object}function nF(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function nw(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((o,s)=>{const a=s.attribute.parseHTML?s.attribute.parseHTML(t):nF(t.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function rw(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&tF(t)?!1:t!=null))}function rF(n,e){var t;const r=rC(n),{nodeExtensions:i,markExtensions:o}=bh(n),s=(t=i.find(c=>Ee(c,"topNode")))===null||t===void 0?void 0:t.name,a=Object.fromEntries(i.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((y,w)=>{const _=Ee(w,"extendNodeSchema",u);return{...y,..._?_(c):{}}},{}),p=rw({...h,content:ot(Ee(c,"content",u)),marks:ot(Ee(c,"marks",u)),group:ot(Ee(c,"group",u)),inline:ot(Ee(c,"inline",u)),atom:ot(Ee(c,"atom",u)),selectable:ot(Ee(c,"selectable",u)),draggable:ot(Ee(c,"draggable",u)),code:ot(Ee(c,"code",u)),whitespace:ot(Ee(c,"whitespace",u)),linebreakReplacement:ot(Ee(c,"linebreakReplacement",u)),defining:ot(Ee(c,"defining",u)),isolating:ot(Ee(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var w;return[y.name,{default:(w=y==null?void 0:y.attribute)===null||w===void 0?void 0:w.default}]}))}),m=ot(Ee(c,"parseHTML",u));m&&(p.parseDOM=m.map(y=>nw(y,d)));const v=Ee(c,"renderHTML",u);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:tg(y,d)}));const g=Ee(c,"renderText",u);return g&&(p.toText=g),[c.name,p]})),l=Object.fromEntries(o.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((g,y)=>{const w=Ee(y,"extendMarkSchema",u);return{...g,...w?w(c):{}}},{}),p=rw({...h,inclusive:ot(Ee(c,"inclusive",u)),excludes:ot(Ee(c,"excludes",u)),group:ot(Ee(c,"group",u)),spanning:ot(Ee(c,"spanning",u)),code:ot(Ee(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))}),m=ot(Ee(c,"parseHTML",u));m&&(p.parseDOM=m.map(g=>nw(g,d)));const v=Ee(c,"renderHTML",u);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:tg(g,d)})),[c.name,p]}));return new Kx({topNode:s,nodes:a,marks:l})}function _p(n,e){return e.nodes[n]||e.marks[n]||null}function iw(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function $v(n,e){const t=Xs.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const iF=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,a)=>{var l,c;const d=((c=(l=i.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:i,pos:o,parent:s,index:a}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-o))}),t};function ey(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class wh{constructor(e){this.find=e.find,this.handler=e.handler}}const oF=(n,e)=>{if(ey(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Ad(n){var e;const{editor:t,from:r,to:i,text:o,rules:s,plugin:a}=n,{view:l}=t;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(h=>h.type.spec.code))return!1;let d=!1;const u=iF(c)+o;return s.forEach(h=>{if(d)return;const p=oF(u,h.find);if(!p)return;const m=l.state.tr,v=vh({state:l.state,transaction:m}),g={from:r-(p[0].length-o.length),to:i},{commands:y,chain:w,can:_}=new yh({editor:t,state:v});h.handler({state:v,range:g,match:p,commands:y,chain:w,can:_})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:i,text:o}),l.dispatch(m),d=!0)}),d}function sF(n){const{editor:e,rules:t}=n,r=new Ct({state:{init(){return null},apply(i,o,s){const a=i.getMeta(r);if(a)return a;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=$v(oe.from(d),s.schema);const{from:u}=l,h=u+d.length;Ad({editor:e,from:u,to:h,text:d,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,a){return Ad({editor:e,from:o,to:s,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&Ad({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?Ad({editor:e,from:s.pos,to:s.pos,text:`
|
|
101
|
+
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function aF(n){return Object.prototype.toString.call(n).slice(8,-1)}function Md(n){return aF(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function xh(n,e){const t={...n};return Md(n)&&Md(e)&&Object.keys(e).forEach(r=>{Md(e[r])&&Md(n[r])?t[r]=xh(n[r],e[r]):t[r]=e[r]}),t}class Ii{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=ot(Ee(this,"addOptions",{name:this.name}))),this.storage=ot(Ee(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ii(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>xh(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Ii(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ot(Ee(t,"addOptions",{name:t.name})),t.storage=ot(Ee(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const l=s.find(c=>(c==null?void 0:c.type.name)===t.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function lF(n){return typeof n=="number"}class cF{constructor(e){this.find=e.find,this.handler=e.handler}}const dF=(n,e,t)=>{if(ey(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const o=[i.text];return o.index=i.index,o.input=n,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function uF(n){const{editor:e,state:t,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=n,{commands:l,chain:c,can:d}=new yh({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,i,(p,m)=>{if(!p.isTextblock||p.type.spec.code)return;const v=Math.max(r,m),g=Math.min(i,m+p.content.size),y=p.textBetween(v-m,g-m,void 0,"");dF(y,o.find,s).forEach(_=>{if(_.index===void 0)return;const C=v+_.index+1,A=C+_[0].length,j={from:t.tr.mapping.map(C),to:t.tr.mapping.map(A)},H=o.handler({state:t,range:j,match:_,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});u.push(H)})}),u.every(p=>p!==null)}let Od=null;const fF=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function hF(n){const{editor:e,rules:t}=n;let r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:d,from:u,to:h,rule:p,pasteEvt:m})=>{const v=d.tr,g=vh({state:d,transaction:v});if(!(!uF({editor:e,state:g,from:Math.max(u-1,0),to:h.b-1,rule:p,pasteEvent:m,dropEvent:a})||!v.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return t.map(d=>new Ct({view(u){const h=m=>{var v;r=!((v=u.dom.parentElement)===null||v===void 0)&&v.contains(m.target)?u.dom.parentElement:null,r&&(Od=e)},p=()=>{Od&&(Od=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(u,h)=>{if(o=r===u.dom.parentElement,a=h,!o){const p=Od;p!=null&&p.isEditable&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(u,h)=>{var p;const m=(p=h.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=h,i=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(u,h,p)=>{const m=u[0],v=m.getMeta("uiEvent")==="paste"&&!i,g=m.getMeta("uiEvent")==="drop"&&!o,y=m.getMeta("applyPasteRules"),w=!!y;if(!v&&!g&&!w)return;if(w){let{text:A}=y;typeof A=="string"?A=A:A=$v(oe.from(A),p.schema);const{from:j}=y,H=j+A.length,D=fF(A);return l({rule:d,state:p,from:j,to:{b:H},pasteEvt:D})}const _=h.doc.content.findDiffStart(p.doc.content),C=h.doc.content.findDiffEnd(p.doc.content);if(!(!lF(_)||!C||_===C.b))return l({rule:d,state:p,from:_,to:C,pasteEvt:s})}}))}function pF(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class ga{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=ga.resolve(e),this.schema=rF(this.extensions,t),this.setupExtensions()}static resolve(e){const t=ga.sort(ga.flatten(e)),r=pF(t.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},i=Ee(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{const o=Ee(r,"priority")||100,s=Ee(i,"priority")||100;return o>s?-1:o<s?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:_p(t.name,this.schema)},i=Ee(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=ga.sort([...this.extensions].reverse()),r=[],i=[],o=t.map(s=>{const a={name:s.name,options:s.options,storage:s.storage,editor:e,type:_p(s.name,this.schema)},l=[],c=Ee(s,"addKeyboardShortcuts",a);let d={};if(s.type==="mark"&&Ee(s,"exitable",a)&&(d.ArrowRight=()=>Ii.handleExit({editor:e,mark:s})),c){const v=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));d={...d,...v}}const u=Nz(d);l.push(u);const h=Ee(s,"addInputRules",a);iw(s,e.options.enableInputRules)&&h&&r.push(...h());const p=Ee(s,"addPasteRules",a);iw(s,e.options.enablePasteRules)&&p&&i.push(...p());const m=Ee(s,"addProseMirrorPlugins",a);if(m){const v=m();l.push(...v)}return l}).flat();return[sF({editor:e,rules:r}),...hF({editor:e,rules:i}),...o]}get attributes(){return rC(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=bh(this.extensions);return Object.fromEntries(t.filter(r=>!!Ee(r,"addNodeView")).map(r=>{const i=this.attributes.filter(l=>l.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:e,type:_n(r.name,this.schema)},s=Ee(r,"addNodeView",o);if(!s)return[];const a=(l,c,d,u,h)=>{const p=tg(l,i);return s()({node:l,view:c,getPos:d,decorations:u,innerDecorations:h,editor:e,extension:r,HTMLAttributes:p})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:_p(e.name,this.schema)};e.type==="mark"&&(!((t=ot(Ee(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=Ee(e,"onBeforeCreate",r),o=Ee(e,"onCreate",r),s=Ee(e,"onUpdate",r),a=Ee(e,"onSelectionUpdate",r),l=Ee(e,"onTransaction",r),c=Ee(e,"onFocus",r),d=Ee(e,"onBlur",r),u=Ee(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),s&&this.editor.on("update",s),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}}class Bt{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=ot(Ee(this,"addOptions",{name:this.name}))),this.storage=ot(Ee(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Bt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>xh(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Bt({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ot(Ee(t,"addOptions",{name:t.name})),t.storage=ot(Ee(t,"addStorage",{name:t.name,options:t.options})),t}}function oC(n,e,t){const{from:r,to:i}=e,{blockSeparator:o=`
|
|
102
|
+
|
|
103
|
+
`,textSerializers:s={}}=t||{};let a="";return n.nodesBetween(r,i,(l,c,d,u)=>{var h;l.isBlock&&c>r&&(a+=o);const p=s==null?void 0:s[l.type.name];if(p)return d&&(a+=p({node:l,pos:c,parent:d,index:u,range:e})),!1;l.isText&&(a+=(h=l==null?void 0:l.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,i-c))}),a}function sC(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const mF=Bt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ct({key:new At("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(d=>d.$from.pos)),a=Math.max(...o.map(d=>d.$to.pos)),l=sC(t);return oC(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),gF=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),vF=(n=!1)=>({commands:e})=>e.setContent("",n),yF=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:o,$to:s})=>{n.doc.nodesBetween(o.pos,s.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(l)),h=c.resolve(d.map(l+a.nodeSize)),p=u.blockRange(h);if(!p)return;const m=ul(p);if(a.type.isTextblock){const{defaultType:v}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(p.start,v)}(m||m===0)&&e.lift(p,m)})}),!0},bF=n=>e=>n(e),wF=()=>({state:n,dispatch:e})=>$S(n,e),xF=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,o=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new Ne(r.doc.resolve(Math.max(s-1,0)))),!0},kF=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){const a=i.before(o),l=i.after(o);n.delete(a,l).scrollIntoView()}return!0}return!1},_F=n=>({tr:e,state:t,dispatch:r})=>{const i=_n(n,t.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){const l=o.before(s),c=o.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},SF=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},CF=()=>({state:n,dispatch:e})=>Zv(n,e),TF=()=>({commands:n})=>n.keyboardShortcut("Enter"),EF=()=>({state:n,dispatch:e})=>Bz(n,e);function ef(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:ey(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function aC(n,e,t={}){return n.find(r=>r.type===e&&ef(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function ow(n,e,t={}){return!!aC(n,e,t)}function ty(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(t=t||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!aC([...i.node.marks],e,t)))return;let s=i.index,a=n.start()+i.offset,l=s+1,c=a+i.node.nodeSize;for(;s>0&&ow([...n.parent.child(s-1).marks],e,t);)s-=1,a-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&ow([...n.parent.child(l).marks],e,t);)c+=n.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function es(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const AF=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const o=es(n,r.schema),{doc:s,selection:a}=t,{$from:l,from:c,to:d}=a;if(i){const u=ty(l,o,e);if(u&&u.from<=c&&u.to>=d){const h=Ne.create(s,u.from,u.to);t.setSelection(h)}}return!0},MF=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function lC(n){return n instanceof Ne}function ps(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function cC(n,e=null){if(!e)return null;const t=We.atStart(n),r=We.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,o=r.to;return e==="all"?Ne.create(n,ps(0,i,o),ps(n.content.size,i,o)):Ne.create(n,ps(e,i,o),ps(e,i,o))}function sw(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function tf(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function OF(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const DF=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(tf()||sw())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),OF()&&!tf()&&!sw()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!lC(t.state.selection))return s(),!0;const a=cC(i.doc,n)||t.state.selection,l=t.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},RF=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),NF=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),dC=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&dC(r)}return n};function Dd(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return dC(t)}function zc(n,e,t){if(n instanceof zo||n instanceof oe)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return oe.fromArray(n.map(a=>e.nodeFromJSON(a)));const s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),zc("",e,t)}if(i){if(t.errorOnInvalidContent){let s=!1,a="";const l=new Kx({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Vl.fromSchema(l).parseSlice(Dd(n),t.parseOptions):Vl.fromSchema(l).parse(Dd(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=Vl.fromSchema(e);return t.slice?o.parseSlice(Dd(n),t.parseOptions).content:o.parse(Dd(n),t.parseOptions)}return zc("",e,t)}function IF(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof yn||i instanceof wn))return;const o=n.mapping.maps[r];let s=0;o.forEach((a,l,c,d)=>{s===0&&(s=d)}),n.setSelection(We.near(n.doc.resolve(s),t))}const PF=n=>!("type"in n),LF=(n,e,t)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;const l=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{zc(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=zc(e,o.schema,{parseOptions:c,errorOnInvalidContent:(s=t.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(g){return l(g),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,p=!0;if((PF(a)?a:[a]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),d===u&&p){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let v;if(h){if(Array.isArray(e))v=e.map(g=>g.text||"").join("");else if(e instanceof oe){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),v=g}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,u)}else v=a,r.replaceWith(d,u,v);t.updateSelection&&IF(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},zF=()=>({state:n,dispatch:e})=>Lz(n,e),FF=()=>({state:n,dispatch:e})=>zz(n,e),BF=()=>({state:n,dispatch:e})=>qS(n,e),HF=()=>({state:n,dispatch:e})=>GS(n,e),VF=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Zf(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},UF=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Zf(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},jF=()=>({state:n,dispatch:e})=>Iz(n,e),WF=()=>({state:n,dispatch:e})=>Pz(n,e);function uC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function KF(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,o,s;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))tf()||uC()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),s&&(t=`Meta-${t}`),o&&(t=`Shift-${t}`),t}const qF=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const o=KF(n).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,a))});return l==null||l.steps.forEach(c=>{const d=c.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Fc(n,e,t={}){const{from:r,to:i,empty:o}=n.selection,s=e?_n(e,n.schema):null,a=[];n.doc.nodesBetween(r,i,(u,h)=>{if(u.isText)return;const p=Math.max(r,h),m=Math.min(i,h+u.nodeSize);a.push({node:u,from:p,to:m})});const l=i-r,c=a.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>ef(u.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=l}const JF=(n,e={})=>({state:t,dispatch:r})=>{const i=_n(n,t.schema);return Fc(t,i,e)?Fz(t,r):!1},ZF=()=>({state:n,dispatch:e})=>eC(n,e),YF=n=>({state:e,dispatch:t})=>{const r=_n(n,e.schema);return Gz(r)(e,t)},GF=()=>({state:n,dispatch:e})=>QS(n,e);function kh(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function aw(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}const XF=(n,e)=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null;const a=kh(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(o=_n(n,r.schema)),a==="mark"&&(s=es(n,r.schema)),i&&t.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,d)=>{o&&o===c.type&&t.setNodeMarkup(d,void 0,aw(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(u=>{s===u.type&&t.addMark(d,d+c.nodeSize,s.create(aw(u.attrs,e)))})})}),!0):!1},QF=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),$F=()=>({tr:n,dispatch:e})=>{if(e){const t=new or(n.doc);n.setSelection(t)}return!0},eB=()=>({state:n,dispatch:e})=>ZS(n,e),tB=()=>({state:n,dispatch:e})=>XS(n,e),nB=()=>({state:n,dispatch:e})=>Uz(n,e),rB=()=>({state:n,dispatch:e})=>Kz(n,e),iB=()=>({state:n,dispatch:e})=>Wz(n,e);function ng(n,e,t={},r={}){return zc(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const oB=(n,e=!1,t={},r={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{var l,c;const{doc:d}=o;if(t.preserveWhitespace!=="full"){const u=ng(n,i.schema,t,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:i.options.enableContentCheck});return s&&o.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:d.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function fC(n,e){const t=es(e,n.schema),{from:r,to:i,empty:o}=n.selection,s=[];o?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});const a=s.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function sB(n,e){const t=new Qg(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function aB(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function lB(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,o)=>{t(i)&&r.push({node:i,pos:o})}),r}function hC(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function ny(n){return e=>hC(e.$from,n)}function cB(n,e){const t={from:0,to:n.content.size};return oC(n,t,e)}function dB(n,e){const t=_n(e,n.schema),{from:r,to:i}=n.selection,o=[];n.doc.nodesBetween(r,i,a=>{o.push(a)});const s=o.reverse().find(a=>a.type.name===t.name);return s?{...s.attrs}:{}}function pC(n,e){const t=kh(typeof e=="string"?e:e.name,n.schema);return t==="node"?dB(n,e):t==="mark"?fC(n,e):{}}function uB(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function fB(n){const e=uB(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,s)=>s!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function hB(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,o)=>{const s=[];if(i.ranges.length)i.forEach((a,l)=>{s.push({from:a,to:l})});else{const{from:a,to:l}=t[o];if(a===void 0||l===void 0)return;s.push({from:a,to:l})}s.forEach(({from:a,to:l})=>{const c=e.slice(o).map(a,-1),d=e.slice(o).map(l),u=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:u,to:h},newRange:{from:c,to:d}})})}),fB(r)}function ry(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const o=t.resolve(n),s=ty(o,i.type);s&&r.push({mark:i,...s})}):t.nodesBetween(n,e,(i,o)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function du(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function rg(n,e,t={}){const{empty:r,ranges:i}=n.selection,o=e?es(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>o?o.name===u.type.name:!0).find(u=>ef(u.attrs,t,{strict:!1}));let s=0;const a=[];if(i.forEach(({$from:u,$to:h})=>{const p=u.pos,m=h.pos;n.doc.nodesBetween(p,m,(v,g)=>{if(!v.isText&&!v.marks.length)return;const y=Math.max(p,g),w=Math.min(m,g+v.nodeSize),_=w-y;s+=_,a.push(...v.marks.map(C=>({mark:C,from:y,to:w})))})}),s===0)return!1;const l=a.filter(u=>o?o.name===u.mark.type.name:!0).filter(u=>ef(u.mark.attrs,t,{strict:!1})).reduce((u,h)=>u+h.to-h.from,0),c=a.filter(u=>o?u.mark.type!==o&&u.mark.type.excludes(o):!0).reduce((u,h)=>u+h.to-h.from,0);return(l>0?l+c:l)>=s}function pB(n,e,t={}){if(!e)return Fc(n,null,t)||rg(n,null,t);const r=kh(e,n.schema);return r==="node"?Fc(n,e,t):r==="mark"?rg(n,e,t):!1}function lw(n,e){const{nodeExtensions:t}=bh(e),r=t.find(s=>s.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=ot(Ee(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function _h(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(o=>{i!==!1&&(_h(o,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function mB(n){return n instanceof Fe}function gB(n,e,t){var r;const{selection:i}=e;let o=null;if(lC(i)&&(o=i.$cursor),o){const a=(r=n.storedMarks)!==null&&r!==void 0?r:o.marks();return!!t.isInSet(a)||!a.some(l=>l.type.excludes(t))}const{ranges:s}=i;return s.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,l.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){const p=!h||h.type.allowsMarkType(t),m=!!t.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(t));c=p&&m}return!c}),c})}const vB=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:o}=t,{empty:s,ranges:a}=o,l=es(n,r.schema);if(i)if(s){const c=fC(r,l);t.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,p)=>{const m=Math.max(p,d),v=Math.min(p+h.nodeSize,u);h.marks.find(y=>y.type===l)?h.marks.forEach(y=>{l===y.type&&t.addMark(m,v,l.create({...y.attrs,...e}))}):t.addMark(m,v,l.create(e))})});return gB(r,t,l)},yB=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),bB=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const o=_n(n,t.schema);let s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:a})=>tw(o,{...s,...e})(t)?!0:a.clearNodes()).command(({state:a})=>tw(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},wB=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=ps(n,0,r.content.size),o=Fe.create(r,i);e.setSelection(o)}return!0},xB=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:o}=typeof n=="number"?{from:n,to:n}:n,s=Ne.atStart(r).from,a=Ne.atEnd(r).to,l=ps(i,s,a),c=ps(o,s,a),d=Ne.create(r,l,c);e.setSelection(d)}return!0},kB=n=>({state:e,dispatch:t})=>{const r=_n(n,e.schema);return $z(r)(e,t)};function cw(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}const _B=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:o,doc:s}=e,{$from:a,$to:l}=o,c=i.extensionManager.attributes,d=du(c,a.node().type.name,a.node().attrs);if(o instanceof Fe&&o.node.isBlock)return!a.parentOffset||!Qi(s,a.pos)?!1:(r&&(n&&cw(t,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:aB(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=u&&h?[{type:h,attrs:d}]:void 0,m=Qi(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&Qi(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(m=!0,p=h?[{type:h,attrs:d}]:void 0),r){if(m&&(o instanceof Ne&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),h&&!u&&!a.parentOffset&&a.parent.type!==h)){const v=e.mapping.map(a.before()),g=e.doc.resolve(v);a.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}n&&cw(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},SB=(n,e={})=>({tr:t,state:r,dispatch:i,editor:o})=>{var s;const a=_n(n,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const u=l.node(-1);if(u.type!==a)return!1;const h=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let y=oe.empty;const w=l.index(-1)?1:l.index(-2)?2:3;for(let D=l.depth-w;D>=l.depth-3;D-=1)y=oe.from(l.node(D).copy(y));const _=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,C={...du(h,l.node().type.name,l.node().attrs),...e},A=((s=a.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(C))||void 0;y=y.append(oe.from(a.createAndFill(null,A)||void 0));const j=l.before(l.depth-(w-1));t.replace(j,l.after(-_),new pe(y,4-w,0));let H=-1;t.doc.nodesBetween(j,t.doc.content.size,(D,N)=>{if(H>-1)return!1;D.isTextblock&&D.content.size===0&&(H=N+1)}),H>-1&&t.setSelection(Ne.near(t.doc.resolve(H))),t.scrollIntoView()}return!0}const p=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,m={...du(h,u.type.name,u.attrs),...e},v={...du(h,l.node().type.name,l.node().attrs),...e};t.delete(l.pos,c.pos);const g=p?[{type:a,attrs:m},{type:p,attrs:v}]:[{type:a,attrs:m}];if(!Qi(t.doc,l.pos,2))return!1;if(i){const{selection:y,storedMarks:w}=r,{splittableMarks:_}=o.extensionManager,C=w||y.$to.parentOffset&&y.$from.marks();if(t.split(l.pos,2,g).scrollIntoView(),!C||!i)return!0;const A=C.filter(j=>_.includes(j.type.name));t.ensureMarks(A)}return!0},Sp=(n,e)=>{const t=ny(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Qo(n.doc,t.pos)&&n.join(t.pos),!0},Cp=(n,e)=>{const t=ny(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Qo(n.doc,r)&&n.join(r),!0},CB=(n,e,t,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:u,splittableMarks:h}=i.extensionManager,p=_n(n,s.schema),m=_n(e,s.schema),{selection:v,storedMarks:g}=s,{$from:y,$to:w}=v,_=y.blockRange(w),C=g||v.$to.parentOffset&&v.$from.marks();if(!_)return!1;const A=ny(j=>lw(j.type.name,u))(v);if(_.depth>=1&&A&&_.depth-A.depth<=1){if(A.node.type===p)return c.liftListItem(m);if(lw(A.node.type.name,u)&&p.validContent(A.node.content)&&a)return l().command(()=>(o.setNodeMarkup(A.pos,p),!0)).command(()=>Sp(o,p)).command(()=>Cp(o,p)).run()}return!t||!C||!a?l().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>Sp(o,p)).command(()=>Cp(o,p)).run():l().command(()=>{const j=d().wrapInList(p,r),H=C.filter(D=>h.includes(D.type.name));return o.ensureMarks(H),j?!0:c.clearNodes()}).wrapInList(p,r).command(()=>Sp(o,p)).command(()=>Cp(o,p)).run()},TB=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=t,s=es(n,r.schema);return rg(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},EB=(n,e,t={})=>({state:r,commands:i})=>{const o=_n(n,r.schema),s=_n(e,r.schema),a=Fc(r,o,t);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(s,l):i.setNode(o,{...l,...t})},AB=(n,e={})=>({state:t,commands:r})=>{const i=_n(n,t.schema);return Fc(t,i,e)?r.lift(i):r.wrapIn(i,e)},MB=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let o;if(i.spec.isInputRules&&(o=i.getState(n))){if(e){const s=n.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l-=1)s.step(a.steps[l].invert(a.docs[l]));if(o.text){const l=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,l))}else s.delete(o.from,o.to)}return!0}}return!1},OB=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},DB=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=t,l=es(n,r.schema),{$from:c,empty:d,ranges:u}=a;if(!i)return!0;if(d&&s){let{from:h,to:p}=a;const m=(o=c.marks().find(g=>g.type===l))===null||o===void 0?void 0:o.attrs,v=ty(c,l,m);v&&(h=v.from,p=v.to),t.removeMark(h,p,l)}else u.forEach(h=>{t.removeMark(h.$from.pos,h.$to.pos,l)});return t.removeStoredMark(l),!0},RB=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null;const a=kh(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(o=_n(n,r.schema)),a==="mark"&&(s=es(n,r.schema)),i&&t.selection.ranges.forEach(l=>{const c=l.$from.pos,d=l.$to.pos;let u,h,p,m;t.selection.empty?r.doc.nodesBetween(c,d,(v,g)=>{o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,d),u=g,h=v)}):r.doc.nodesBetween(c,d,(v,g)=>{g<c&&o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,d),u=g,h=v),g>=c&&g<=d&&(o&&o===v.type&&t.setNodeMarkup(g,void 0,{...v.attrs,...e}),s&&v.marks.length&&v.marks.forEach(y=>{if(s===y.type){const w=Math.max(g,c),_=Math.min(g+v.nodeSize,d);t.addMark(w,_,s.create({...y.attrs,...e}))}}))}),h&&(u!==void 0&&t.setNodeMarkup(u,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(v=>{s===v.type&&t.addMark(p,m,s.create({...v.attrs,...e}))}))}),!0):!1},NB=(n,e={})=>({state:t,dispatch:r})=>{const i=_n(n,t.schema);return qz(i,e)(t,r)},IB=(n,e={})=>({state:t,dispatch:r})=>{const i=_n(n,t.schema);return Jz(i,e)(t,r)};var PB=Object.freeze({__proto__:null,blur:gF,clearContent:vF,clearNodes:yF,command:bF,createParagraphNear:wF,cut:xF,deleteCurrentNode:kF,deleteNode:_F,deleteRange:SF,deleteSelection:CF,enter:TF,exitCode:EF,extendMarkRange:AF,first:MF,focus:DF,forEach:RF,insertContent:NF,insertContentAt:LF,joinBackward:BF,joinDown:FF,joinForward:HF,joinItemBackward:VF,joinItemForward:UF,joinTextblockBackward:jF,joinTextblockForward:WF,joinUp:zF,keyboardShortcut:qF,lift:JF,liftEmptyBlock:ZF,liftListItem:YF,newlineInCode:GF,resetAttributes:XF,scrollIntoView:QF,selectAll:$F,selectNodeBackward:eB,selectNodeForward:tB,selectParentNode:nB,selectTextblockEnd:rB,selectTextblockStart:iB,setContent:oB,setMark:vB,setMeta:yB,setNode:bB,setNodeSelection:wB,setTextSelection:xB,sinkListItem:kB,splitBlock:_B,splitListItem:SB,toggleList:CB,toggleMark:TB,toggleNode:EB,toggleWrap:AB,undoInputRule:MB,unsetAllMarks:OB,unsetMark:DB,updateAttributes:RB,wrapIn:NB,wrapInList:IB});const LB=Bt.create({name:"commands",addCommands(){return{...PB}}}),zB=Bt.create({name:"drop",addProseMirrorPlugins(){return[new Ct({key:new At("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),FB=Bt.create({name:"editable",addProseMirrorPlugins(){return[new Ct({key:new At("editable"),props:{editable:()=>this.editor.options.editable}})]}}),BB=new At("focusEvents"),HB=Bt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new Ct({key:BB,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),VB=Bt.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:d,$anchor:u}=l,{pos:h,parent:p}=u,m=u.parent.isTextblock&&h>0?a.doc.resolve(h-1):u,v=m.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=v&&m.parent.childCount===1?g===u.pos:We.atStart(c).from===h;return!d||!p.type.isTextblock||p.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return tf()||uC()?o:i},addProseMirrorPlugins(){return[new Ct({key:new At("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(v=>v.getMeta("composition")))return;const r=n.some(v=>v.docChanged)&&!e.doc.eq(t.doc),i=n.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:a}=e.selection,l=We.atStart(e.doc).from,c=We.atEnd(e.doc).to;if(o||!(s===l&&a===c)||!_h(t.doc))return;const h=t.tr,p=vh({state:t,transaction:h}),{commands:m}=new yh({editor:this.editor,state:p});if(m.clearNodes(),!!h.steps.length)return h}})]}}),UB=Bt.create({name:"paste",addProseMirrorPlugins(){return[new Ct({key:new At("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),jB=Bt.create({name:"tabindex",addProseMirrorPlugins(){return[new Ct({key:new At("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class as{get name(){return this.node.type.name}constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new as(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new as(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new as(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const i=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,s=this.pos+r+(o?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(s);if(!i&&a.depth<=this.depth)return;const l=new as(a,this.editor,i,i?t:null);i&&(l.actualDepth=this.depth+1),e.push(new as(a,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const o=i.node.attrs,s=Object.keys(t);for(let a=0;a<s.length;a+=1){const l=s[a];if(o[l]!==t[l])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const o=Object.keys(t);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&o.every(l=>t[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,t,r))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const WB=`.ProseMirror {
|
|
104
|
+
position: relative;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.ProseMirror {
|
|
108
|
+
word-wrap: break-word;
|
|
109
|
+
white-space: pre-wrap;
|
|
110
|
+
white-space: break-spaces;
|
|
111
|
+
-webkit-font-variant-ligatures: none;
|
|
112
|
+
font-variant-ligatures: none;
|
|
113
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.ProseMirror [contenteditable="false"] {
|
|
117
|
+
white-space: normal;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
121
|
+
white-space: pre-wrap;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.ProseMirror pre {
|
|
125
|
+
white-space: pre-wrap;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
img.ProseMirror-separator {
|
|
129
|
+
display: inline !important;
|
|
130
|
+
border: none !important;
|
|
131
|
+
margin: 0 !important;
|
|
132
|
+
width: 0 !important;
|
|
133
|
+
height: 0 !important;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.ProseMirror-gapcursor {
|
|
137
|
+
display: none;
|
|
138
|
+
pointer-events: none;
|
|
139
|
+
position: absolute;
|
|
140
|
+
margin: 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.ProseMirror-gapcursor:after {
|
|
144
|
+
content: "";
|
|
145
|
+
display: block;
|
|
146
|
+
position: absolute;
|
|
147
|
+
top: -2px;
|
|
148
|
+
width: 20px;
|
|
149
|
+
border-top: 1px solid black;
|
|
150
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@keyframes ProseMirror-cursor-blink {
|
|
154
|
+
to {
|
|
155
|
+
visibility: hidden;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.ProseMirror-hideselection *::selection {
|
|
160
|
+
background: transparent;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
164
|
+
background: transparent;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.ProseMirror-hideselection * {
|
|
168
|
+
caret-color: transparent;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
172
|
+
display: block;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
176
|
+
opacity: 0
|
|
177
|
+
}`;function KB(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}let qB=class extends eF{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:t})=>{throw t},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:t,slice:r,moved:i})=>this.options.onDrop(t,r,i)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=KB(WB,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){const r=iC(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(o=>{const s=typeof o=="string"?`${o}$`:o.key;r=r.filter(a=>!a.key.startsWith(s))}),t.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[FB,mF.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),LB,HB,VB,jB,zB,UB].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new ga(i,this)}createCommandManager(){this.commandManager=new yh({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=ng(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),t=ng(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=cC(t,this.options.autofocus);this.view=new WS(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:pa.create({doc:t,selection:r||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const 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(s=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(s)});return}const t=this.state.apply(e),r=!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}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return pC(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return pB(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return $v(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
|
|
178
|
+
|
|
179
|
+
`,textSerializers:r={}}=e||{};return cB(this.state.doc,{blockSeparator:t,textSerializers:{...sC(this.schema),...r}})}get isEmpty(){return _h(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new as(t,this)}get $doc(){return this.$pos(0)}};function Ws(n){return new wh({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ot(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:o}=e,s=r[r.length-1],a=r[0];if(s){const l=a.search(/\S/),c=t.from+a.indexOf(s),d=c+s.length;if(ry(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===n.type&&v!==p.mark.type)).filter(p=>p.to>c).length)return null;d<t.to&&o.delete(d,t.to),c>t.from&&o.delete(t.from+l,c);const h=t.from+l+s.length;o.addMark(t.from+l,h,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function JB(n){return new wh({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ot(n.getAttributes,void 0,r)||{},{tr:o}=e,s=t.from;let a=t.to;const l=n.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=s+c;d>a?d=a:a=d+r[1].length;const u=r[0][r[0].length-1];o.insertText(u,s+r[0].length-1),o.replaceWith(d,a,l)}else if(r[0]){const c=n.type.isInline?s:s-1;o.insert(c,n.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()}})}function ig(n){return new wh({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),o=ot(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)}})}function Bc(n){return new wh({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const o=ot(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),l=s.doc.resolve(t.from).blockRange(),c=l&&Xg(l,n.type,o);if(!c)return null;if(s.wrap(l,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:h}=e,{splittableMarks:p}=n.editor.extensionManager,m=h||u.$to.parentOffset&&u.$from.marks();if(m){const v=m.filter(g=>p.includes(g.type.name));s.ensureMarks(v)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,o).run()}const d=s.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&Qo(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&s.join(t.from-1)}})}let $n=class og{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=ot(Ee(this,"addOptions",{name:this.name}))),this.storage=ot(Ee(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new og(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>xh(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new og(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ot(Ee(t,"addOptions",{name:t.name})),t.storage=ot(Ee(t,"addStorage",{name:t.name,options:t.options})),t}};function Xo(n){return new cF({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const o=ot(n.getAttributes,void 0,r,i);if(o===!1||o===null)return null;const{tr:s}=e,a=r[r.length-1],l=r[0];let c=t.to;if(a){const d=l.search(/\S/),u=t.from+l.indexOf(a),h=u+a.length;if(ry(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(g=>g===n.type&&g!==m.mark.type)).filter(m=>m.to>u).length)return null;h<t.to&&s.delete(h,t.to),u>t.from&&s.delete(t.from+d,u),c=t.from+d+a.length,s.addMark(t.from+d,c,n.type.create(o||{})),s.removeStoredMark(n.type)}}})}function ZB(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof Fe){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let i=r.depth;for(;i>=0;){const o=r.index(i);if(r.node(i).contentMatchAt(o).matchType(e))return!0;i-=1}return!1}const YB=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},GB=/[\uD800-\uDBFF]/,XB=/[\uDC00-\uDFFF]/,QB=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&GB.test(n[t-1])&&t--;r+t<n.length&&r+t<e.length&&n[n.length-r-1]===e[e.length-r-1];)r++;return r>0&&XB.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},$B=QB,Ht=new At("y-sync"),Ti=new At("y-undo"),Rd=new At("yjs-cursor"),Ei=(n,e)=>n>>>e|n<<32-e,e5=n=>Ei(n,2)^Ei(n,13)^Ei(n,22),t5=n=>Ei(n,6)^Ei(n,11)^Ei(n,25),n5=n=>Ei(n,7)^Ei(n,18)^n>>>3,r5=n=>Ei(n,17)^Ei(n,19)^n>>>10,i5=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]),o5=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class s5{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(o5),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,t=this._W;for(let u=16;u<64;u++)t[u]=r5(t[u-2])+t[u-7]+n5(t[u-15])+t[u-16];let r=e[0],i=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],d=e[7];for(let u=0,h,p;u<64;u++)h=d+t5(a)+(a&l^~a&c)+i5[u]+t[u]>>>0,p=e5(r)+(r&i^r&o^i&o)>>>0,d=c,c=l,l=a,a=s+h>>>0,s=o,o=i,i=r,r=h+p>>>0;e[0]+=r,e[1]+=i,e[2]+=o,e[3]+=s,e[4]+=a,e[5]+=l,e[6]+=c,e[7]+=d}digest(e){let t=0;for(;t+56<=e.length;){let s=0;for(;s<16&&t+3<e.length;s++)this._W[s]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!==0){for(this._W.fill(0,s,16);t<e.length;)this._W[s]|=e[t]<<(3-t%4)*8,t++;this._W[s]|=Yn<<(3-t%4)*8}this._updateHash()}const r=t%64!==0;this._W.fill(0,0,16);let i=0;for(;t<e.length;i++)for(let s=3;s>=0&&t<e.length;s--)this._W[i]|=e[t++]<<s*8;r||(this._W[i-(t%4===0?0:1)]|=Yn<<(3-t%4)*8),this._W[14]=e.byteLength/fO,this._W[15]=e.byteLength*8,this._updateHash();const o=new Uint8Array(32);for(let s=0;s<this._H.length;s++)for(let a=0;a<4;a++)o[s*4+a]=this._H[s]>>>(3-a)*8;return o}}const a5=n=>new s5().digest(n),l5=n=>{for(let t=6;t<n.length;t++)n[t%6]=n[t%6]^n[t];return n.slice(0,6)},c5=n=>hD(l5(a5(mD(n)))),nf=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!gl(e.ds,n.id),d5=[{light:"#ecd44433",dark:"#ecd444"}],u5=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){const r=Fs();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,KO(e))}return n.get(t)},f5=(n,{colors:e=d5,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let s=!1;const a=new p5(n,o),l=new Ct({props:{editable:c=>{const d=Ht.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:Ht,state:{init:(c,d)=>({type:n,doc:n.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,permanentUserData:r}),apply:(c,d)=>{const u=c.getMeta(Ht);if(u!==void 0){d=Object.assign({},d);for(const h in u)d[h]=u[h]}return d.addToHistory=c.getMeta("addToHistory")!==!1,d.isChangeOrigin=u!==void 0&&!!u.isChangeOrigin,d.isUndoRedoOperation=u!==void 0&&!!u.isChangeOrigin&&!!u.isUndoRedoOperation,a.prosemirrorView!==null&&u!==void 0&&(u.snapshot!=null||u.prevSnapshot!=null)&&gv(0,()=>{a.prosemirrorView!=null&&(u.restore==null?a._renderSnapshot(u.snapshot,u.prevSnapshot,d):(a._renderSnapshot(u.snapshot,u.snapshot,d),delete d.restore,delete d.snapshot,delete d.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),d}},view:c=>(a.initView(c),o==null&&a._forceRerender(),i(),{update:()=>{const d=l.getState(c.state);if(d.snapshot==null&&d.prevSnapshot==null&&(s||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(s=!0,d.addToHistory===!1&&!d.isChangeOrigin){const u=Ti.getState(c.state),h=u&&u.undoManager;h&&h.stopCapturing()}a.mux(()=>{d.doc.transact(u=>{u.meta.set("addToHistory",d.addToHistory),a._prosemirrorChanged(c.state.doc)},Ht)})}},destroy:()=>{a.destroy()}})});return l},h5=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")n.setSelection(new or(n.doc));else if(e.type==="node"){const r=Aa(t.doc,t.type,e.anchor,t.mapping);n.setSelection(Fe.create(n.doc,r))}else{const r=Aa(t.doc,t.type,e.anchor,t.mapping),i=Aa(t.doc,t.type,e.head,t.mapping);if(r!==null&&i!==null){const o=Ne.between(n.doc.resolve(r),n.doc.resolve(i));n.setSelection(o)}}},sg=(n,e)=>({type:e.selection.jsonID,anchor:of(e.selection.anchor,n.type,n.mapping),head:of(e.selection.head,n.type,n.mapping)});class p5{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=YB(),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=sg(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()?(Ak&&this._domSelectionInView===null&&(gv(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const 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);const i=t.getBoundingClientRect(),o=sd.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||o.clientWidth||0)&&i.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(e,t){t||(t=c_($k(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ht,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>uu(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new pe(oe.from(e),0,0));t.setMeta(Ht,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,t=this.type.toArray().map(i=>uu(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new pe(oe.from(t),0,0));if(e){const i=$i(oi(e.anchor,0),r.doc.content.size),o=$i(oi(e.head,0),r.doc.content.size);r.setSelection(Ne.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(Ht,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let i=this.doc,o=this.type;if(e||(e=lp(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&Hn(),i=new Di({gc:!1}),Fu(i,t),t=lp(i),Fu(i,e),e=lp(i),o._item===null){const s=Array.from(this.doc.share.keys()).find(a=>this.doc.share.get(a)===this.type);o=i.getXmlFragment(s)}else{const s=i.store.clients.get(o._item.id.client)??[],a=si(s,o._item.id.clock);o=s[a].content.type}this.mapping.clear(),this.mux(()=>{i.transact(s=>{const a=r.permanentUserData;a&&a.dss.forEach(u=>{Jo(s,u,h=>{})});const l=(u,h)=>{const p=u==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:p,type:u,color:u5(r.colorMapping,r.colors,p)}},c=w_(o,new xv(t.ds,e.sv)).map(u=>!u._item.deleted||nf(u._item,e)||nf(u._item,t)?uu(u,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,l):null).filter(u=>u!==null),d=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new pe(oe.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(Ht,{isChangeOrigin:!0}))},Ht)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;const r=Ht.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const i=(a,l)=>this.mapping.delete(l);Jo(t,t.deleteSet,a=>{if(a.constructor===Pt){const l=a.content.type;l&&this.mapping.delete(l)}}),t.changed.forEach(i),t.changedParentTypes.forEach(i);const o=this.type.toArray().map(a=>mC(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new pe(oe.from(o),0,0));h5(s,this.beforeTransactionSelection,this),s=s.setMeta(Ht,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof p_}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{lg(this.doc,this.type,e,this),this.beforeTransactionSelection=sg(this,this.prosemirrorView.state)},Ht)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const mC=(n,e,t,r,i,o)=>{const s=t.mapping.get(n);if(s===void 0){if(n instanceof on)return uu(n,e,t,r,i,o);throw Hr()}return s},uu=(n,e,t,r,i,o)=>{const s=[],a=l=>{var c,d;if(l instanceof on){const u=mC(l,e,t,r,i,o);u!==null&&s.push(u)}else{const u=(d=(c=l._item.right)==null?void 0:c.content)==null?void 0:d.type;u instanceof Zo&&!u._item.deleted&&u._item.id.client===u.doc.clientID&&(l.applyDelta([{retain:l.length},...u.toDelta()]),u.doc.transact(p=>{u._item.delete(p)}));const h=m5(l,e,t,r,i,o);h!==null&&h.forEach(p=>{p!==null&&s.push(p)})}};r===void 0||i===void 0?n.toArray().forEach(a):w_(n,new xv(i.ds,r.sv)).forEach(a);try{const l=n.getAttributes(r);r!==void 0&&(nf(n._item,r)?nf(n._item,i)||(l.ychange=o?o("added",n._item.id):{type:"added"}):l.ychange=o?o("removed",n._item.id):{type:"removed"});const c=e.node(n.nodeName,l,s);return t.mapping.set(n,c),c}catch{return n.doc.transact(c=>{n._item.delete(c)},Ht),t.mapping.delete(n),null}},m5=(n,e,t,r,i,o)=>{const s=[],a=n.toDelta(r,i,o);try{for(let l=0;l<a.length;l++){const c=a[l];s.push(e.text(c.insert,x5(c.attributes,e)))}}catch{return n.doc.transact(c=>{n._item.delete(c)},Ht),null}return s},g5=(n,e)=>{const t=new In,r=n.map(i=>({insert:i.text,attributes:vC(i.marks,e)}));return t.applyDelta(r),e.mapping.set(t,n),t},v5=(n,e)=>{const t=new on(n.type.name);for(const r in n.attrs){const i=n.attrs[r];i!==null&&r!=="ychange"&&t.setAttribute(r,i)}return t.insert(0,Sh(n).map(r=>ag(r,e))),e.mapping.set(t,n),t},ag=(n,e)=>n instanceof Array?g5(n,e):v5(n,e),dw=n=>typeof n=="object"&&n!==null,iy=(n,e)=>{const t=Object.keys(n).filter(i=>n[i]!==null);let r=t.length===(e==null?0:Object.keys(e).filter(i=>e[i]!==null).length);for(let i=0;i<t.length&&r;i++){const o=t[i],s=n[o],a=e[o];r=o==="ychange"||s===a||dw(s)&&dw(a)&&iy(s,a)}return r},Sh=n=>{const e=n.content.content,t=[];for(let r=0;r<e.length;r++){const i=e[r];if(i.isText){const o=[];for(let s=e[r];r<e.length&&s.isText;s=e[++r])o.push(s);r--,t.push(o)}else t.push(i)}return t},gC=(n,e)=>{const t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&Ck(r.attributes||{}).length===e[i].marks.length&&hl(r.attributes,(o,s)=>{var c;const a=oy(s),l=e[i].marks;return iy(o,(c=l.find(d=>d.type.name===a))==null?void 0:c.attrs)}))},Hc=(n,e)=>{if(n instanceof on&&!(e instanceof Array)&&cg(n,e)){const t=Sh(e);return n._length===t.length&&iy(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>Hc(r,t[i]))}return n instanceof In&&e instanceof Array&&gC(n,e)},rf=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),uw=(n,e,t)=>{const r=n.toArray(),i=Sh(e),o=i.length,s=r.length,a=$i(s,o);let l=0,c=0,d=!1;for(;l<a;l++){const u=r[l],h=i[l];if(rf(t.mapping.get(u),h))d=!0;else if(!Hc(u,h))break}for(;l+c<a;c++){const u=r[s-c-1],h=i[o-c-1];if(rf(t.mapping.get(u),h))d=!0;else if(!Hc(u,h))break}return{equalityFactor:l+c,foundMappedChild:d}},y5=n=>{let e="",t=n._start;const r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof ai?e+=t.content.str:t.content instanceof sn&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},b5=(n,e,t)=>{t.mapping.set(n,e);const{nAttrs:r,str:i}=y5(n),o=e.map(c=>({insert:c.text,attributes:Object.assign({},r,vC(c.marks,t))})),{insert:s,remove:a,index:l}=$B(i,o.map(c=>c.insert).join(""));n.delete(l,a),n.insert(l,s),n.applyDelta(o.map(c=>({retain:c.insert.length,attributes:c.attributes})))},w5=/(.*)(--[a-zA-Z0-9+/=]{8})$/,oy=n=>{var e;return((e=w5.exec(n))==null?void 0:e[1])??n},x5=(n,e)=>{const t=[];for(const r in n)t.push(e.mark(oy(r),n[r]));return t},vC=(n,e)=>{const t={};return n.forEach(r=>{if(r.type.name!=="ychange"){const i=Li(e.isOMark,r.type,()=>!r.type.excludes(r.type));t[i?`${r.type.name}--${c5(r.toJSON())}`:r.type.name]=r.attrs}}),t},lg=(n,e,t,r)=>{if(e instanceof on&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,t),e instanceof on){const u=e.getAttributes(),h=t.attrs;for(const p in h)h[p]!==null?u[p]!==h[p]&&p!=="ychange"&&e.setAttribute(p,h[p]):e.removeAttribute(p);for(const p in u)h[p]===void 0&&e.removeAttribute(p)}const i=Sh(t),o=i.length,s=e.toArray(),a=s.length,l=$i(o,a);let c=0,d=0;for(;c<l;c++){const u=s[c],h=i[c];if(!rf(r.mapping.get(u),h))if(Hc(u,h))r.mapping.set(u,h);else break}for(;d+c<l;d++){const u=s[a-d-1],h=i[o-d-1];if(!rf(r.mapping.get(u),h))if(Hc(u,h))r.mapping.set(u,h);else break}n.transact(()=>{for(;a-c-d>0&&o-c-d>0;){const h=s[c],p=i[c],m=s[a-d-1],v=i[o-d-1];if(h instanceof In&&p instanceof Array)gC(h,p)||b5(h,p,r),c+=1;else{let g=h instanceof on&&cg(h,p),y=m instanceof on&&cg(m,v);if(g&&y){const w=uw(h,p,r),_=uw(m,v,r);w.foundMappedChild&&!_.foundMappedChild?y=!1:!w.foundMappedChild&&_.foundMappedChild||w.equalityFactor<_.equalityFactor?g=!1:y=!1}g?(lg(n,h,p,r),c+=1):y?(lg(n,m,v,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[ag(p,r)]),c+=1)}}const u=a-c-d;if(a===1&&o===0&&s[0]instanceof In?(r.mapping.delete(s[0]),s[0].delete(0,s[0].length)):u>0&&(e.slice(c,c+u).forEach(h=>r.mapping.delete(h)),e.delete(c,u)),c+d<o){const h=[];for(let p=c;p<o-d;p++)h.push(ag(i[p],r));e.insert(c,h)}},Ht)},cg=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;let Xl=null;const k5=()=>{const n=Xl;Xl=null,n.forEach((e,t)=>{const r=t.state.tr,i=Ht.getState(t.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((o,s)=>{r.setMeta(s,o)}),t.dispatch(r))})},_5=(n,e,t)=>{Xl||(Xl=new Map,gv(0,k5)),Li(Xl,n,Br).set(e,t)},of=(n,e,t)=>{if(n===0)return ap(e,0,e.length===0?-1:0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof In){if(r._length>=n)return ap(r,n,e.length===0?-1:0);if(n-=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,n--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const i=(t.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&n<i)r=r._first.content.type,n--;else{if(n===1&&r._length===0&&i>1)return new Tc(r._item===null?null:r._item.id,r._item===null?Sc(r):null,null);if(n-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(n===0)return r=r._item===null?r:r._item.parent,new Tc(r._item===null?null:r._item.id,r._item===null?Sc(r):null,null);do r=r._item.parent,n--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw Hn();if(n===0&&r.constructor!==In&&r!==e)return S5(r._item.parent,r._item)}return ap(e,e._length,e.length===0?-1:0)},S5=(n,e)=>{let t=null,r=null;return n._item===null?r=Sc(n):t=$e(n._item.id.client,n._item.id.clock),new Tc(t,r,e.id)},Aa=(n,e,t,r)=>{const i=Rm(t,n);if(i===null||i.type!==e&&!Cc(e,i.type._item))return null;let o=i.type,s=0;if(o.constructor===In)s=i.index;else if(o._item===null||!o._item.deleted){let a=o._first,l=0;for(;l<o._length&&l<i.index&&a!==null;){if(!a.deleted){const c=a.content.type;l++,c instanceof In?s+=c._length:s+=r.get(c).nodeSize}a=a.right}s+=1}for(;o!==e&&o._item!==null;){const a=o._item.parent;if(a._item===null||!a._item.deleted){s+=1;let l=a._first;for(;l!==null;){const c=l.content.type;if(c===o)break;l.deleted||(c instanceof In?s+=c._length:s+=r.get(c).nodeSize),l=l.right}}o=a}return s-1};function C5(n){const e=n.toArray(),t=r=>{let i;if(r instanceof In)i=r.toDelta().map(s=>{const a={type:"text",text:s.insert};return s.attributes&&(a.marks=Object.keys(s.attributes).map(l=>{const c=s.attributes[l],u={type:oy(l)};return Object.keys(c)&&(u.attrs=c),u})),a});else if(r instanceof on){i={type:r.nodeName};const o=r.getAttributes();Object.keys(o).length&&(i.attrs=o);const s=r.toArray();s.length&&(i.content=s.map(t).flat())}else Hn();return i};return{type:"doc",content:e.map(t)}}const T5=(n,e,t)=>n!==e,E5=n=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null);const r=document.createTextNode(""),i=document.createTextNode("");return e.insertBefore(r,null),e.insertBefore(t,null),e.insertBefore(i,null),e},yC=n=>({style:`background-color: ${n.color}70`,class:"ProseMirror-yjs-selection"}),A5=/^#[0-9a-fA-F]{6}$/,fw=(n,e,t,r,i)=>{const o=Ht.getState(n),s=o.doc,a=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?et.create(n.doc,[]):(e.getStates().forEach((l,c)=>{if(t(s.clientID,c,l)&&l.cursor!=null){const d=l.user||{};d.color==null?d.color="#ffa500":A5.test(d.color)||console.warn("A user uses an unsupported color format",d),d.name==null&&(d.name=`User: ${c}`);let u=Aa(s,o.type,As(l.cursor.anchor),o.binding.mapping),h=Aa(s,o.type,As(l.cursor.head),o.binding.mapping);if(u!==null&&h!==null){const p=oi(n.doc.content.size-1,0);u=$i(u,p),h=$i(h,p),a.push(Ft.widget(h,()=>r(d,c),{key:c+"",side:10}));const m=$i(u,h),v=oi(u,h);a.push(Ft.inline(m,v,i(d,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),et.create(n.doc,a))},M5=(n,{awarenessStateFilter:e=T5,cursorBuilder:t=E5,selectionBuilder:r=yC,getSelection:i=s=>s.selection}={},o="cursor")=>new Ct({key:Rd,state:{init(s,a){return fw(a,n,e,t,r)},apply(s,a,l,c){const d=Ht.getState(c),u=s.getMeta(Rd);return d&&d.isChangeOrigin||u&&u.awarenessUpdated?fw(c,n,e,t,r):a.map(s.mapping,s.doc)}},props:{decorations:s=>Rd.getState(s)},view:s=>{const a=()=>{s.docView&&_5(s,Rd,{awarenessUpdated:!0})},l=()=>{const c=Ht.getState(s.state),d=n.getLocalState()||{};if(s.hasFocus()){const u=i(s.state),h=of(u.anchor,c.type,c.binding.mapping),p=of(u.head,c.type,c.binding.mapping);(d.cursor==null||!Qb(As(d.cursor.anchor),h)||!Qb(As(d.cursor.head),p))&&n.setLocalStateField(o,{anchor:h,head:p})}else d.cursor!=null&&Aa(c.doc,c.type,As(d.cursor.anchor),c.binding.mapping)!==null&&n.setLocalStateField(o,null)};return n.on("change",a),s.dom.addEventListener("focusin",l),s.dom.addEventListener("focusout",l),{update:l,destroy:()=>{s.dom.removeEventListener("focusin",l),s.dom.removeEventListener("focusout",l),n.off("change",a),n.setLocalStateField(o,null)}}}}),O5=n=>{var e,t;return((t=(e=Ti.getState(n))==null?void 0:e.undoManager)==null?void 0:t.undo())!=null},D5=n=>{var e,t;return((t=(e=Ti.getState(n))==null?void 0:e.undoManager)==null?void 0:t.redo())!=null},R5=new Set(["paragraph"]),N5=(n,e)=>!(n instanceof Pt)||!(n.content instanceof li)||!(n.content.type instanceof Zo||n.content.type instanceof on&&e.has(n.content.type.nodeName))||n.content.type._length===0,I5=({protectedNodes:n=R5,trackedOrigins:e=[],undoManager:t=null}={})=>new Ct({key:Ti,state:{init:(r,i)=>{const o=Ht.getState(i),s=t||new p_(o.type,{trackedOrigins:new Set([Ht].concat(e)),deleteFilter:a=>N5(a,n),captureTransaction:a=>a.meta.get("addToHistory")!==!1});return{undoManager:s,prevSel:null,hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0}},apply:(r,i,o,s)=>{const a=Ht.getState(s).binding,l=i.undoManager,c=l.undoStack.length>0,d=l.redoStack.length>0;return a?{undoManager:l,prevSel:sg(a,o),hasUndoOps:c,hasRedoOps:d}:c!==i.hasUndoOps||d!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):i}},view:r=>{const i=Ht.getState(r.state),o=Ti.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:s})=>{const a=i.binding;a&&s.meta.set(a,Ti.getState(r.state).prevSel)}),o.on("stack-item-popped",({stackItem:s})=>{const a=i.binding;a&&(a.beforeTransactionSelection=s.meta.get(a)||a.beforeTransactionSelection)}),{destroy:()=>{o.destroy()}}}}),P5=Bt.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(n=>n.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:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),Ti.getState(e).undoManager.undoStack.length===0?!1:t?O5(e):!0),redo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),Ti.getState(e).undoManager.redoStack.length===0?!1:t?D5(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var n;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=I5(this.options.yUndoOptions),r=t.spec.view;t.spec.view=s=>{const{undoManager:a}=Ti.getState(s.state);a.restore&&(a.restore(),a.restore=()=>{});const l=r?r(s):void 0;return{destroy:()=>{const c=a.trackedOrigins.has(a),d=a._observers;a.restore=()=>{c&&a.trackedOrigins.add(a),a.doc.on("afterTransaction",a.afterTransactionHandler),a._observers=d},l!=null&&l.destroy&&l.destroy()}}};const i={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=f5(e,i);return this.editor.options.enableContentCheck&&((n=e.doc)===null||n===void 0||n.on("beforeTransaction",()=>{try{const s=C5(e);if(s.content.length===0)return;this.editor.schema.nodeFromJSON(s).check()}catch(s){return this.editor.emit("contentError",{error:s,editor:this.editor,disableCollaboration:()=>{var a;(a=e.doc)===null||a===void 0||a.destroy(),this.storage.isDisabled=!0}}),!1}})),[o,t,this.editor.options.enableContentCheck&&new Ct({key:new At("filterInvalidContent"),filterTransaction:()=>{var s;return this.storage.isDisabled&&((s=e.doc)===null||s===void 0||s.destroy()),!0}})].filter(Boolean)}}),hw=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t.user})),pw=()=>null,L5=Bt.create({name:"collaborationCursor",priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},selectionRender:yC,onUpdate:pw}},onCreate(){if(this.options.onUpdate!==pw&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),!this.options.provider)throw new Error('The "provider" option is required for the CollaborationCursor extension')},addStorage(){return{users:[]}},addCommands(){return{updateUser:n=>()=>(this.options.user=n,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:n=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),e.commands.updateUser(n))}},addProseMirrorPlugins(){return[M5((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=hw(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=hw(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),z5=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,F5=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,B5=Ii.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",Zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ws({find:z5,type:this.type})]},addPasteRules(){return[Xo({find:F5,type:this.type})]}}),H5="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",V5="ελ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",dg="numeric",ug="ascii",fg="alpha",Ql="asciinumeric",zl="alphanumeric",hg="domain",bC="emoji",U5="scheme",j5="slashscheme",Tp="whitespace";function W5(n,e){return n in e||(e[n]=[]),e[n]}function ms(n,e,t){e[dg]&&(e[Ql]=!0,e[zl]=!0),e[ug]&&(e[Ql]=!0,e[fg]=!0),e[Ql]&&(e[zl]=!0),e[fg]&&(e[zl]=!0),e[zl]&&(e[hg]=!0),e[bC]&&(e[hg]=!0);for(const r in e){const i=W5(r,t);i.indexOf(n)<0&&i.push(n)}}function K5(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function rr(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}rr.groups={};rr.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],o=e.jr[r][1];if(o&&i.test(n))return o}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let i=0;i<n.length;i++)this.tt(n[i],e,t,r)},tr(n,e,t,r){r=r||rr.groups;let i;return e&&e.j?i=e:(i=new rr(e),t&&r&&ms(e,t,r)),this.jr.push([n,i]),i},ts(n,e,t,r){let i=this;const o=n.length;if(!o)return i;for(let s=0;s<o-1;s++)i=i.tt(n[s]);return i.tt(n[o-1],e,t,r)},tt(n,e,t,r){r=r||rr.groups;const i=this;if(e&&e.j)return i.j[n]=e,e;const o=e;let s,a=i.go(n);if(a?(s=new rr,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new rr,o){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(K5(s.t,r),t);ms(o,l,r)}else t&&ms(o,t,r);s.t=o}return i.j[n]=s,s}};const it=(n,e,t,r,i)=>n.ta(e,t,r,i),Ut=(n,e,t,r,i)=>n.tr(e,t,r,i),mw=(n,e,t,r,i)=>n.ts(e,t,r,i),ue=(n,e,t,r,i)=>n.tt(e,t,r,i),Ui="WORD",pg="UWORD",wC="ASCIINUMERICAL",xC="ALPHANUMERICAL",Vc="LOCALHOST",mg="TLD",gg="UTLD",fu="SCHEME",da="SLASH_SCHEME",sy="NUM",vg="WS",ay="NL",$l="OPENBRACE",ec="CLOSEBRACE",sf="OPENBRACKET",af="CLOSEBRACKET",lf="OPENPAREN",cf="CLOSEPAREN",df="OPENANGLEBRACKET",uf="CLOSEANGLEBRACKET",ff="FULLWIDTHLEFTPAREN",hf="FULLWIDTHRIGHTPAREN",pf="LEFTCORNERBRACKET",mf="RIGHTCORNERBRACKET",gf="LEFTWHITECORNERBRACKET",vf="RIGHTWHITECORNERBRACKET",yf="FULLWIDTHLESSTHAN",bf="FULLWIDTHGREATERTHAN",wf="AMPERSAND",xf="APOSTROPHE",kf="ASTERISK",bo="AT",_f="BACKSLASH",Sf="BACKTICK",Cf="CARET",_o="COLON",ly="COMMA",Tf="DOLLAR",fi="DOT",Ef="EQUALS",cy="EXCLAMATION",Sr="HYPHEN",tc="PERCENT",Af="PIPE",Mf="PLUS",Of="POUND",nc="QUERY",dy="QUOTE",kC="FULLWIDTHMIDDLEDOT",uy="SEMI",hi="SLASH",rc="TILDE",Df="UNDERSCORE",_C="EMOJI",Rf="SYM";var SC=Object.freeze({__proto__:null,ALPHANUMERICAL:xC,AMPERSAND:wf,APOSTROPHE:xf,ASCIINUMERICAL:wC,ASTERISK:kf,AT:bo,BACKSLASH:_f,BACKTICK:Sf,CARET:Cf,CLOSEANGLEBRACKET:uf,CLOSEBRACE:ec,CLOSEBRACKET:af,CLOSEPAREN:cf,COLON:_o,COMMA:ly,DOLLAR:Tf,DOT:fi,EMOJI:_C,EQUALS:Ef,EXCLAMATION:cy,FULLWIDTHGREATERTHAN:bf,FULLWIDTHLEFTPAREN:ff,FULLWIDTHLESSTHAN:yf,FULLWIDTHMIDDLEDOT:kC,FULLWIDTHRIGHTPAREN:hf,HYPHEN:Sr,LEFTCORNERBRACKET:pf,LEFTWHITECORNERBRACKET:gf,LOCALHOST:Vc,NL:ay,NUM:sy,OPENANGLEBRACKET:df,OPENBRACE:$l,OPENBRACKET:sf,OPENPAREN:lf,PERCENT:tc,PIPE:Af,PLUS:Mf,POUND:Of,QUERY:nc,QUOTE:dy,RIGHTCORNERBRACKET:mf,RIGHTWHITECORNERBRACKET:vf,SCHEME:fu,SEMI:uy,SLASH:hi,SLASH_SCHEME:da,SYM:Rf,TILDE:rc,TLD:mg,UNDERSCORE:Df,UTLD:gg,UWORD:pg,WORD:Ui,WS:vg});const Hi=/[a-z]/,El=new RegExp("\\p{L}","u"),Ep=new RegExp("\\p{Emoji}","u"),Vi=/\d/,Ap=/\s/,gw="\r",Mp=`
|
|
180
|
+
`,q5="️",J5="",Op="";let Nd=null,Id=null;function Z5(n=[]){const e={};rr.groups=e;const t=new rr;Nd==null&&(Nd=vw(H5)),Id==null&&(Id=vw(V5)),ue(t,"'",xf),ue(t,"{",$l),ue(t,"}",ec),ue(t,"[",sf),ue(t,"]",af),ue(t,"(",lf),ue(t,")",cf),ue(t,"<",df),ue(t,">",uf),ue(t,"(",ff),ue(t,")",hf),ue(t,"「",pf),ue(t,"」",mf),ue(t,"『",gf),ue(t,"』",vf),ue(t,"<",yf),ue(t,">",bf),ue(t,"&",wf),ue(t,"*",kf),ue(t,"@",bo),ue(t,"`",Sf),ue(t,"^",Cf),ue(t,":",_o),ue(t,",",ly),ue(t,"$",Tf),ue(t,".",fi),ue(t,"=",Ef),ue(t,"!",cy),ue(t,"-",Sr),ue(t,"%",tc),ue(t,"|",Af),ue(t,"+",Mf),ue(t,"#",Of),ue(t,"?",nc),ue(t,'"',dy),ue(t,"/",hi),ue(t,";",uy),ue(t,"~",rc),ue(t,"_",Df),ue(t,"\\",_f),ue(t,"・",kC);const r=Ut(t,Vi,sy,{[dg]:!0});Ut(r,Vi,r);const i=Ut(r,Hi,wC,{[Ql]:!0}),o=Ut(r,El,xC,{[zl]:!0}),s=Ut(t,Hi,Ui,{[ug]:!0});Ut(s,Vi,i),Ut(s,Hi,s),Ut(i,Vi,i),Ut(i,Hi,i);const a=Ut(t,El,pg,{[fg]:!0});Ut(a,Hi),Ut(a,Vi,o),Ut(a,El,a),Ut(o,Vi,o),Ut(o,Hi),Ut(o,El,o);const l=ue(t,Mp,ay,{[Tp]:!0}),c=ue(t,gw,vg,{[Tp]:!0}),d=Ut(t,Ap,vg,{[Tp]:!0});ue(t,Op,d),ue(c,Mp,l),ue(c,Op,d),Ut(c,Ap,d),ue(d,gw),ue(d,Mp),Ut(d,Ap,d),ue(d,Op,d);const u=Ut(t,Ep,_C,{[bC]:!0});ue(u,"#"),Ut(u,Ep,u),ue(u,q5,u);const h=ue(u,J5);ue(h,"#"),Ut(h,Ep,u);const p=[[Hi,s],[Vi,i]],m=[[Hi,null],[El,a],[Vi,o]];for(let v=0;v<Nd.length;v++)po(t,Nd[v],mg,Ui,p);for(let v=0;v<Id.length;v++)po(t,Id[v],gg,pg,m);ms(mg,{tld:!0,ascii:!0},e),ms(gg,{utld:!0,alpha:!0},e),po(t,"file",fu,Ui,p),po(t,"mailto",fu,Ui,p),po(t,"http",da,Ui,p),po(t,"https",da,Ui,p),po(t,"ftp",da,Ui,p),po(t,"ftps",da,Ui,p),ms(fu,{scheme:!0,ascii:!0},e),ms(da,{slashscheme:!0,ascii:!0},e),n=n.sort((v,g)=>v[0]>g[0]?1:-1);for(let v=0;v<n.length;v++){const g=n[v][0],w=n[v][1]?{[U5]:!0}:{[j5]:!0};g.indexOf("-")>=0?w[hg]=!0:Hi.test(g)?Vi.test(g)?w[Ql]=!0:w[ug]=!0:w[dg]=!0,mw(t,g,g,w)}return mw(t,"localhost",Vc,{ascii:!0}),t.jd=new rr(Rf),{start:t,tokens:Object.assign({groups:e},SC)}}function CC(n,e){const t=Y5(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,i=[];let o=0,s=0;for(;s<r;){let a=n,l=null,c=0,d=null,u=-1,h=-1;for(;s<r&&(l=a.go(t[s]));)a=l,a.accepts()?(u=0,h=0,d=a):u>=0&&(u+=t[s].length,h++),c+=t[s].length,o+=t[s].length,s++;o-=u,s-=h,c-=u,i.push({t:d.t,v:e.slice(o-c,o),s:o-c,e:o})}return i}function Y5(n){const e=[],t=n.length;let r=0;for(;r<t;){let i=n.charCodeAt(r),o,s=i<55296||i>56319||r+1===t||(o=n.charCodeAt(r+1))<56320||o>57343?n[r]:n.slice(r,r+2);e.push(s),r+=s.length}return e}function po(n,e,t,r,i){let o;const s=e.length;for(let a=0;a<s-1;a++){const l=e[a];n.j[l]?o=n.j[l]:(o=new rr(r),o.jr=i.slice(),n.j[l]=o),n=o}return o=new rr(t),o.jr=i.slice(),n.j[e[s-1]]=o,o}function vw(n){const e=[],t=[];let r=0,i="0123456789";for(;r<n.length;){let o=0;for(;i.indexOf(n[r+o])>=0;)o++;if(o>0){e.push(t.join(""));for(let s=parseInt(n.substring(r,r+o),10);s>0;s--)t.pop();r+=o}else t.push(n[r]),r++}return e}const Uc={defaultProtocol:"http",events:null,format:yw,formatHref:yw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function fy(n,e=null){let t=Object.assign({},Uc);n&&(t=Object.assign(t,n instanceof fy?n.o:n));const r=t.ignoreTags,i=[];for(let o=0;o<r.length;o++)i.push(r[o].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=i}fy.prototype={o:Uc,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let i=this.o[n];return i&&(typeof i=="object"?(i=t.t in i?i[t.t]:Uc[n],typeof i=="function"&&r&&(i=i(e,t))):typeof i=="function"&&r&&(i=i(e,t.t,t)),i)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function yw(n){return n}function TC(n,e){this.t="token",this.v=n,this.tk=e}TC.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Uc.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),o=this.toFormattedString(n),s={},a=n.get("className",t,e),l=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:i,attributes:s,content:o,eventListeners:u}}};function Ch(n,e){class t extends TC{constructor(i,o){super(i,o),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const bw=Ch("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ww=Ch("text"),G5=Ch("nl"),Pd=Ch("url",{isLink:!0,toHref(n=Uc.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Vc&&n[1].t===_o}}),_r=n=>new rr(n);function X5({groups:n}){const e=n.domain.concat([wf,kf,bo,_f,Sf,Cf,Tf,Ef,Sr,sy,tc,Af,Mf,Of,hi,Rf,rc,Df]),t=[xf,_o,ly,fi,cy,tc,nc,dy,uy,df,uf,$l,ec,af,sf,lf,cf,ff,hf,pf,mf,gf,vf,yf,bf],r=[wf,xf,kf,_f,Sf,Cf,Tf,Ef,Sr,$l,ec,tc,Af,Mf,Of,nc,hi,Rf,rc,Df],i=_r(),o=ue(i,rc);it(o,r,o),it(o,n.domain,o);const s=_r(),a=_r(),l=_r();it(i,n.domain,s),it(i,n.scheme,a),it(i,n.slashscheme,l),it(s,r,o),it(s,n.domain,s);const c=ue(s,bo);ue(o,bo,c),ue(a,bo,c),ue(l,bo,c);const d=ue(o,fi);it(d,r,o),it(d,n.domain,o);const u=_r();it(c,n.domain,u),it(u,n.domain,u);const h=ue(u,fi);it(h,n.domain,u);const p=_r(bw);it(h,n.tld,p),it(h,n.utld,p),ue(c,Vc,p);const m=ue(u,Sr);ue(m,Sr,m),it(m,n.domain,u),it(p,n.domain,u),ue(p,fi,h),ue(p,Sr,m);const v=ue(p,_o);it(v,n.numeric,bw);const g=ue(s,Sr),y=ue(s,fi);ue(g,Sr,g),it(g,n.domain,s),it(y,r,o),it(y,n.domain,s);const w=_r(Pd);it(y,n.tld,w),it(y,n.utld,w),it(w,n.domain,s),it(w,r,o),ue(w,fi,y),ue(w,Sr,g),ue(w,bo,c);const _=ue(w,_o),C=_r(Pd);it(_,n.numeric,C);const A=_r(Pd),j=_r();it(A,e,A),it(A,t,j),it(j,e,A),it(j,t,j),ue(w,hi,A),ue(C,hi,A);const H=ue(a,_o),D=ue(l,_o),N=ue(D,hi),W=ue(N,hi);it(a,n.domain,s),ue(a,fi,y),ue(a,Sr,g),it(l,n.domain,s),ue(l,fi,y),ue(l,Sr,g),it(H,n.domain,A),ue(H,hi,A),ue(H,nc,A),it(W,n.domain,A),it(W,e,A),ue(W,hi,A);const ee=[[$l,ec],[sf,af],[lf,cf],[df,uf],[ff,hf],[pf,mf],[gf,vf],[yf,bf]];for(let z=0;z<ee.length;z++){const[Y,te]=ee[z],ne=ue(A,Y);ue(j,Y,ne),ue(ne,te,A);const q=_r(Pd);it(ne,e,q);const P=_r();it(ne,t),it(q,e,q),it(q,t,P),it(P,e,q),it(P,t,P),ue(q,te,A),ue(P,te,A)}return ue(i,Vc,w),ue(i,ay,G5),{start:i,tokens:SC}}function Q5(n,e,t){let r=t.length,i=0,o=[],s=[];for(;i<r;){let a=n,l=null,c=null,d=0,u=null,h=-1;for(;i<r&&!(l=a.go(t[i].t));)s.push(t[i++]);for(;i<r&&(c=l||a.go(t[i].t));)l=null,a=c,a.accepts()?(h=0,u=a):h>=0&&h++,i++,d++;if(h<0)i-=d,i<r&&(s.push(t[i]),i++);else{s.length>0&&(o.push(Dp(ww,e,s)),s=[]),i-=h,d-=h;const p=u.t,m=t.slice(i-d,i);o.push(Dp(p,e,m))}}return s.length>0&&o.push(Dp(ww,e,s)),o}function Dp(n,e,t){const r=t[0].s,i=t[t.length-1].e,o=e.slice(r,i);return new n(o,t)}const $5=typeof console<"u"&&console&&console.warn||(()=>{}),eH="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",zt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function tH(){return rr.groups={},zt.scanner=null,zt.parser=null,zt.tokenQueue=[],zt.pluginQueue=[],zt.customSchemes=[],zt.initialized=!1,zt}function xw(n,e=!1){if(zt.initialized&&$5(`linkifyjs: already initialized - will not register custom scheme "${n}" ${eH}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
181
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
182
|
+
2. Cannot start or end with "-"
|
|
183
|
+
3. "-" cannot repeat`);zt.customSchemes.push([n,e])}function nH(){zt.scanner=Z5(zt.customSchemes);for(let n=0;n<zt.tokenQueue.length;n++)zt.tokenQueue[n][1]({scanner:zt.scanner});zt.parser=X5(zt.scanner.tokens);for(let n=0;n<zt.pluginQueue.length;n++)zt.pluginQueue[n][1]({scanner:zt.scanner,parser:zt.parser});return zt.initialized=!0,zt}function hy(n){return zt.initialized||nH(),Q5(zt.parser.start,n,CC(zt.scanner.start,n))}hy.scan=CC;function EC(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new fy(t),i=hy(n),o=[];for(let s=0;s<i.length;s++){const a=i[s];a.isLink&&(!e||a.t===e)&&r.check(a)&&o.push(a.toFormattedObject(r))}return o}const py="[\0- -\u2029 ]",rH=new RegExp(py),iH=new RegExp(`${py}$`),oH=new RegExp(py,"g");function sH(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function aH(n){return new Ct({key:new At("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!i||o)return;const{tr:s}=r,a=sB(t.doc,[...e]);if(hB(a).forEach(({newRange:c})=>{const d=lB(r.doc,c,p=>p.isTextblock);let u,h;if(d.length>1)u=d[0],h=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(c.from,c.to," "," ");if(!iH.test(p))return;u=d[0],h=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&h){const p=h.split(rH).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],v=u.pos+h.lastIndexOf(m);if(!m)return!1;const g=hy(m).map(y=>y.toObject(n.defaultProtocol));if(!sH(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:v+y.start+1,to:v+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{ry(y.from,y.to,r.doc).some(w=>w.mark.type===n.type)||s.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function lH(n){return new Ct({key:new At("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let s=r.target;const a=[];for(;s.nodeName!=="DIV";)a.push(s),s=s.parentNode;if(!a.find(h=>h.nodeName==="A"))return!1;const l=pC(e.state,n.type.name),c=r.target,d=(i=c==null?void 0:c.href)!==null&&i!==void 0?i:l.href,u=(o=c==null?void 0:c.target)!==null&&o!==void 0?o:l.target;return c&&d?(window.open(d,u),!0):!1}}})}function cH(n){return new Ct({key:new At("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:o}=i,{empty:s}=o;if(s)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=EC(a,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!l?!1:n.editor.commands.setMark(n.type,{href:l.href})}}})}function rs(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(oH,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const dH=Ii.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(n=>{if(typeof n=="string"){xw(n);return}xw(n.scheme,n.optionalSlashes)})},onDestroy(){tH()},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:(n,e)=>!!rs(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.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:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!rs(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!rs(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Zt(this.options.HTMLAttributes,n),0]:["a",Zt(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!rs(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!rs(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Xo({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=EC(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!rs(s,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(aH({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!rs(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(lH({type:this.type})),this.options.linkOnPaste&&n.push(cH({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),uH=Bt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Ct({key:new At("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!t)return null;const o=this.editor.isEmpty;return n.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,c=!s.isLeaf&&_h(s);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=Ft.node(a,a+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});i.push(u)}return this.options.includeChildren}),et.create(n,i)}}})]}});let yg,bg;if(typeof WeakMap<"u"){let n=new WeakMap;yg=e=>n.get(e),bg=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;yg=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},bg=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var Kt=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,i=e/this.width|0;let o=r+1,s=i+1;for(let a=1;o<this.width&&this.map[e+a]==t;a++)o++;for(let a=1;s<this.height&&this.map[e+this.width*a]==t;a++)s++;return{left:r,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:i,top:o,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?r==0:i==this.width)?null:this.map[o*this.width+(t<0?r-1:i)]:(t<0?o==0:s==this.height)?null:this.map[r+this.width*(t<0?o-1:s)]}rectBetween(n,e){const{left:t,right:r,top:i,bottom:o}=this.findCell(n),{left:s,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(i,l),right:Math.max(r,a),bottom:Math.max(o,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let i=n.left;i<n.right;i++){const o=r*this.width+i,s=this.map[o];t[s]||(t[s]=!0,!(i==n.left&&i&&this.map[o-1]==s||r==n.top&&r&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let r=0,i=0;;r++){const o=i+t.child(r).nodeSize;if(r==n){let s=e+n*this.width;const a=(n+1)*this.width;for(;s<a&&this.map[s]<i;)s++;return s==a?o-1:this.map[s]}i=o}}static get(n){return yg(n)||bg(n,fH(n))}};function fH(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=hH(n),t=n.childCount,r=[];let i=0,o=null;const s=[];for(let c=0,d=e*t;c<d;c++)r[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let m=0;;m++){for(;i<r.length&&r[i]!=0;)i++;if(m==u.childCount)break;const v=u.child(m),{colspan:g,rowspan:y,colwidth:w}=v.attrs;for(let _=0;_<y;_++){if(_+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:y-_});break}const C=i+_*e;for(let A=0;A<g;A++){r[C+A]==0?r[C+A]=d:(o||(o=[])).push({type:"collision",row:c,pos:d,n:g-A});const j=w&&w[A];if(j){const H=(C+A)%e*2,D=s[H];D==null||D!=j&&s[H+1]==1?(s[H]=j,s[H+1]=1):D==j&&s[H+1]++}}}i+=g,d+=v.nodeSize}const h=(c+1)*e;let p=0;for(;i<h;)r[i++]==0&&p++;p&&(o||(o=[])).push({type:"missing",row:c,n:p}),d++}(e===0||t===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new Kt(e,t,r,o);let l=!1;for(let c=0;!l&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(l=!0);return l&&pH(a,s,n),a}function hH(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const i=n.child(r);let o=0;if(t)for(let s=0;s<r;s++){const a=n.child(s);for(let l=0;l<a.childCount;l++){const c=a.child(l);s+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const a=i.child(s);o+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function pH(n,e,t){n.problems||(n.problems=[]);const r={};for(let i=0;i<n.map.length;i++){const o=n.map[i];if(r[o])continue;r[o]=!0;const s=t.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let a=null;const l=s.attrs;for(let c=0;c<l.colspan;c++){const d=e[(i+c)%n.width*2];d!=null&&(!l.colwidth||l.colwidth[c]!=d)&&((a||(a=mH(l)))[c]=d)}a&&n.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function mH(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Un(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const So=new At("selectingCells");function Ks(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function gH(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function ci(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Th(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Ks(e.$head)||vH(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function vH(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function wg(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function yH(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function my(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function AC(n,e,t){const r=n.node(-1),i=Kt.get(r),o=n.start(-1),s=i.nextCell(n.pos-o,e,t);return s==null?null:n.node(0).resolve(o+s)}function qs(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function MC(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function bH(n,e,t){const r=Un(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}var Lt=class ji extends We{constructor(e,t=e){const r=e.node(-1),i=Kt.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,t.pos-o),a=e.node(0),l=i.cellsInRect(s).filter(d=>d!=t.pos-o);l.unshift(t.pos-o);const c=l.map(d=>{const u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const h=o+d+1;return new ak(a.resolve(h),a.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(wg(r)&&wg(i)&&my(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?ji.rowSelection(r,i):o&&this.isColSelection()?ji.colSelection(r,i):new ji(r,i)}return Ne.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=Kt.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let d=l*t.width+i.left,u=i.left;u<i.right;u++,d++){const h=t.map[d];if(o[h])continue;o[h]=!0;const p=t.findCell(h);let m=e.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const v=i.left-p.left,g=p.right-i.right;if(v>0||g>0){let y=m.attrs;if(v>0&&(y=qs(y,0,v)),g>0&&(y=qs(y,y.colspan-g,g)),p.left<i.left){if(m=m.type.createAndFill(y),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else m=m.type.create(y,m.content)}if(p.top<i.top||p.bottom>i.bottom){const y={...m.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top<i.top?m=m.type.createAndFill(y):m=m.type.create(y,m.content)}c.push(m)}s.push(e.child(l).copy(oe.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new pe(oe.from(a),1,1)}replace(e,t=pe.empty){const r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:a,$to:l}=i[s],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),s?pe.empty:t)}const o=We.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new pe(oe.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Kt.get(t),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(t.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),i=Kt.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(t=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(t=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(e=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new ji(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Kt.get(e),r=this.$anchorCell.start(-1),i=t.colCount(this.$anchorCell.pos-r),o=t.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==t.width}eq(e){return e instanceof ji&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=Kt.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(t.pos-o),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(t=l.resolve(o+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(t=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(e=l.resolve(o+i.map[i.width*(s.top+1)-1]))),new ji(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ji(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ji(e.resolve(t),e.resolve(r))}getBookmark(){return new wH(this.$anchorCell.pos,this.$headCell.pos)}};Lt.prototype.visible=!1;We.jsonID("cell",Lt);var wH=class OC{constructor(e,t){this.anchor=e,this.head=t}map(e){return new OC(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&my(t,r)?new Lt(t,r):We.near(r,1)}};function xH(n){if(!(n.selection instanceof Lt))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(Ft.node(r,r+t.nodeSize,{class:"selectedCell"}))}),et.create(n.doc,e)}function kH({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function _H({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){const o=n.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){t=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return t!==r&&e.parentOffset===0}function SH(n,e,t){const r=(e||n).selection,i=(e||n).doc;let o,s;if(r instanceof Fe&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=Lt.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=Lt.rowSelection(a,a)}else if(!t){const a=Kt.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];o=Lt.create(i,l+1,c)}}else r instanceof Ne&&kH(r)?o=Ne.create(i,r.from):r instanceof Ne&&_H(r)&&(o=Ne.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=n.tr)).setSelection(o),e}const CH=new At("fix-tables");function DC(n,e,t,r){const i=n.childCount,o=e.childCount;e:for(let s=0,a=0;s<o;s++){const l=e.child(s);for(let c=a,d=Math.min(i,s+3);c<d;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<i&&n.child(a).sameMarkup(l)?DC(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function RC(n,e){let t;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(t=TH(n,i,o,t))};return e?e.doc!=n.doc&&DC(e.doc,n.doc,0,r):n.doc.descendants(r),t}function TH(n,e,t,r){const i=Kt.get(e);if(!i.problems)return r;r||(r=n.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)o[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,qs(u,u.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(t);r.delete(d,d+e.nodeSize)}}let s,a;for(let l=0;l<o.length;l++)o[l]&&(s==null&&(s=l),a=l);for(let l=0,c=t+1;l<i.height;l++){const d=e.child(l),u=c+d.nodeSize,h=o[l];if(h>0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);const m=[];for(let g=0;g<h;g++){const y=Un(n.schema)[p].createAndFill();y&&m.push(y)}const v=(l==0||s==l-1)&&a==l?c+1:u-1;r.insert(r.mapping.map(v),m)}c=u}return r.setMeta(CH,{fixTables:!0})}function zi(n){const e=n.selection,t=Th(n),r=t.node(-1),i=t.start(-1),o=Kt.get(r);return{...e instanceof Lt?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(t.pos-i),tableStart:i,map:o,table:r}}function NC(n,{map:e,tableStart:t,table:r},i){let o=i>0?-1:0;bH(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+i;if(i>0&&i<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,MC(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?Un(r.type.schema).cell:r.nodeAt(e.map[a+o]).type,c=e.positionAt(s,i,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function EH(n,e){if(!ci(n))return!1;if(e){const t=zi(n);e(NC(n.tr,t,t.left))}return!0}function AH(n,e){if(!ci(n))return!1;if(e){const t=zi(n);e(NC(n.tr,t,t.right))}return!0}function MH(n,{map:e,table:t,tableStart:r},i){const o=n.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+i,l=e.map[a],c=t.nodeAt(l),d=c.attrs;if(i>0&&e.map[a-1]==l||i<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(o).map(r+l),null,qs(d,i-e.colCount(l)));else{const u=n.mapping.slice(o).map(r+l);n.delete(u,u+c.nodeSize)}s+=d.rowspan}}function OH(n,e){if(!ci(n))return!1;if(e){const t=zi(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;MH(r,t,i),i!=t.left;i--){const o=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=Kt.get(o)}e(r)}return!0}function DH(n,e,t){var r;const i=Un(e.type.schema).header_cell;for(let o=0;o<n.width;o++)if(((r=e.nodeAt(n.map[o+t*n.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function IC(n,{map:e,tableStart:t,table:r},i){let o=t;for(let c=0;c<i;c++)o+=r.child(c).nodeSize;const s=[];let a=i>0?-1:0;DH(e,r,i+a)&&(a=i==0||i==e.height?null:0);for(let c=0,d=e.width*i;c<e.width;c++,d++)if(i>0&&i<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],h=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var l;const u=a==null?Un(r.type.schema).cell:(l=r.nodeAt(e.map[d+a*e.width]))===null||l===void 0?void 0:l.type,h=u==null?void 0:u.createAndFill();h&&s.push(h)}return n.insert(o,Un(r.type.schema).row.create(null,s)),n}function RH(n,e){if(!ci(n))return!1;if(e){const t=zi(n);e(IC(n.tr,t,t.top))}return!0}function NH(n,e){if(!ci(n))return!1;if(e){const t=zi(n);e(IC(n.tr,t,t.bottom))}return!0}function IH(n,{map:e,table:t,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=t.child(c).nodeSize;const s=o+t.child(i).nodeSize,a=n.mapping.maps.length;n.delete(o+r,s+r);const l=new Set;for(let c=0,d=i*e.width;c<e.width;c++,d++){const u=e.map[d];if(!l.has(u)){if(l.add(u),i>0&&u==e.map[d-e.width]){const h=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<e.height&&u==e.map[d+e.width]){const h=t.nodeAt(u),p=h.attrs,m=h.type.create({...p,rowspan:h.attrs.rowspan-1},h.content),v=e.positionAt(i+1,c,t);n.insert(n.mapping.slice(a).map(r+v),m),c+=p.colspan-1}}}}function PH(n,e){if(!ci(n))return!1;if(e){const t=zi(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;IH(r,t,i),i!=t.top;i--){const o=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");t.table=o,t.map=Kt.get(t.table)}e(r)}return!0}function kw(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function LH({width:n,height:e,map:t},r){let i=r.top*n+r.left,o=i,s=(r.bottom-1)*n+r.left,a=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[o]==t[o-1]||r.right<n&&t[a]==t[a+1])return!0;o+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[i]==t[i-n]||r.bottom<e&&t[s]==t[s+n])return!0;i++,s++}return!1}function _w(n,e){const t=n.selection;if(!(t instanceof Lt)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=zi(n),{map:i}=r;if(LH(i,r))return!1;if(e){const o=n.tr,s={};let a=oe.empty,l,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const h=i.map[d*i.width+u],p=r.table.nodeAt(h);if(!(s[h]||!p))if(s[h]=!0,l==null)l=h,c=p;else{kw(p)||(a=a.append(p.content));const m=o.mapping.map(h+r.tableStart);o.delete(m,m+p.nodeSize)}}if(l==null||c==null)return!0;if(o.setNodeMarkup(l+r.tableStart,null,{...MC(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const d=l+1+c.content.size,u=kw(c)?l+1:d;o.replaceWith(u+r.tableStart,d+r.tableStart,a)}o.setSelection(new Lt(o.doc.resolve(l+r.tableStart))),e(o)}return!0}function Sw(n,e){const t=Un(n.schema);return zH(({node:r})=>t[r.type.spec.tableRole])(n,e)}function zH(n){return(e,t)=>{const r=e.selection;let i,o;if(r instanceof Lt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var s;if(i=gH(r.$from),!i)return!1;o=(s=Ks(r.$from))===null||s===void 0?void 0:s.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let a=i.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const d=zi(e),u=e.tr;for(let p=0;p<d.right-d.left;p++)l.push(c?{...a,colwidth:c&&c[p]?[c[p]]:null}:a);let h;for(let p=d.top;p<d.bottom;p++){let m=d.map.positionAt(p,d.left,d.table);p==d.top&&(m+=i.nodeSize);for(let v=d.left,g=0;v<d.right;v++,g++)v==d.left&&p==d.top||u.insert(h=u.mapping.map(m+d.tableStart,1),n({node:i,row:p,col:v}).createAndFill(l[g]))}u.setNodeMarkup(o,n({node:i,row:d.top,col:d.left}),l[0]),r instanceof Lt&&u.setSelection(new Lt(u.doc.resolve(r.$anchorCell.pos),h?u.doc.resolve(h):void 0)),t(u)}return!0}}function FH(n,e){return function(t,r){if(!ci(t))return!1;const i=Th(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){const o=t.tr;t.selection instanceof Lt?t.selection.forEachCell((s,a)=>{s.attrs[n]!==e&&o.setNodeMarkup(a,null,{...s.attrs,[n]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[n]:e}),r(o)}return!0}}function BH(n){return function(e,t){if(!ci(e))return!1;if(t){const r=Un(e.schema),i=zi(e),o=e.tr,s=i.map.cellsInRect(n=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:n=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=s.map(l=>i.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&o.setNodeMarkup(i.tableStart+s[l],r.cell,a[l].attrs);if(o.steps.length===0)for(let l=0;l<s.length;l++)o.setNodeMarkup(i.tableStart+s[l],r.header_cell,a[l].attrs);t(o)}return!0}}function Cw(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const o=e.table.nodeAt(r[i]);if(o&&o.type!==t.header_cell)return!1}return!0}function jc(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?BH(n):function(t,r){if(!ci(t))return!1;if(r){const i=Un(t.schema),o=zi(t),s=t.tr,a=Cw("row",o,i),l=Cw("column",o,i),c=(n==="column"?a:n==="row"&&l)?1:0,d=n=="column"?{left:0,top:c,right:1,bottom:o.map.height}:n=="row"?{left:c,top:0,right:o.map.width,bottom:1}:o,u=n=="column"?l?i.cell:i.header_cell:n=="row"?a?i.cell:i.header_cell:i.cell;o.map.cellsInRect(d).forEach(h=>{const p=h+o.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,u,m.attrs)}),r(s)}return!0}}jc("row",{useDeprecatedLogic:!0});jc("column",{useDeprecatedLogic:!0});const HH=jc("cell",{useDeprecatedLogic:!0});function VH(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){const o=n.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){const o=t.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function Tw(n){return function(e,t){if(!ci(e))return!1;const r=VH(Th(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(Ne.between(i,yH(i))).scrollIntoView())}return!0}}function UH(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Ld(n,e){const t=n.selection;if(!(t instanceof Lt))return!1;if(e){const r=n.tr,i=Un(n.schema).cell.createAndFill().content;t.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new pe(i,0,0))}),r.docChanged&&e(r)}return!0}function jH(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if(o=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const d=l?0:Math.max(0,t-1),u=l<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=xg(Un(s).row,new pe(c,d,u)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(t||r?xg(Un(s).row,new pe(e,t,r)).content:e);else return null;return WH(s,a)}function WH(n,e){const t=[];for(let i=0;i<e.length;i++){const o=e[i];for(let s=o.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=o.child(s).attrs;for(let c=i;c<i+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(oe.empty),t[i]<r){const o=Un(n).cell.createAndFill(),s=[];for(let a=t[i];a<r;a++)s.push(o);e[i]=e[i].append(oe.from(s))}return{height:e.length,width:r,rows:e}}function xg(n,e){const t=n.createAndFill();return new Qg(t).replace(0,t.content.size,e).doc}function KH({width:n,height:e,rows:t},r,i){if(n!=r){const o=[],s=[];for(let a=0;a<t.length;a++){const l=t[a],c=[];for(let d=o[a]||0,u=0;d<r;u++){let h=l.child(u%l.childCount);d+h.attrs.colspan>r&&(h=h.type.createChecked(qs(h.attrs,h.attrs.colspan,d+h.attrs.colspan-r),h.content)),c.push(h),d+=h.attrs.colspan;for(let p=1;p<h.attrs.rowspan;p++)o[a+p]=(o[a+p]||0)+h.attrs.colspan}s.push(oe.from(c))}t=s,n=r}if(e!=i){const o=[];for(let s=0,a=0;s<i;s++,a++){const l=[],c=t[a%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);s+u.attrs.rowspan>i&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,i-u.attrs.rowspan)},u.content)),l.push(u)}o.push(oe.from(l))}t=o,e=i}return{width:n,height:e,rows:t}}function qH(n,e,t,r,i,o,s){const a=n.doc.type.schema,l=Un(a);let c,d;if(i>e.width)for(let u=0,h=0;u<e.height;u++){const p=t.child(u);h+=p.nodeSize;const m=[];let v;p.lastChild==null||p.lastChild.type==l.cell?v=c||(c=l.cell.createAndFill()):v=d||(d=l.header_cell.createAndFill());for(let g=e.width;g<i;g++)m.push(v);n.insert(n.mapping.slice(s).map(h-1+r),m)}if(o>e.height){const u=[];for(let m=0,v=(e.height-1)*e.width;m<Math.max(e.width,i);m++){const g=m>=e.width?!1:t.nodeAt(e.map[v+m]).type==l.header_cell;u.push(g?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,oe.from(u)),p=[];for(let m=e.height;m<o;m++)p.push(h);n.insert(n.mapping.slice(s).map(r+t.nodeSize-2),p)}return!!(c||d)}function Ew(n,e,t,r,i,o,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let c=i;c<o;c++){const d=s*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){l=!0;const h=t.nodeAt(u),{top:p,left:m}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,{...h.attrs,rowspan:s-p}),n.insert(n.mapping.slice(a).map(e.positionAt(s,m,t)),h.type.createAndFill({...h.attrs,rowspan:p+h.attrs.rowspan-s})),c+=h.attrs.colspan-1}}return l}function Aw(n,e,t,r,i,o,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let c=i;c<o;c++){const d=c*e.width+s,u=e.map[d];if(e.map[d-1]==u){l=!0;const h=t.nodeAt(u),p=e.colCount(u),m=n.mapping.slice(a).map(u+r);n.setNodeMarkup(m,null,qs(h.attrs,s-p,h.attrs.colspan-(s-p))),n.insert(m+h.nodeSize,h.type.createAndFill(qs(h.attrs,0,s-p))),c+=h.attrs.rowspan-1}}return l}function Mw(n,e,t,r,i){let o=t?n.doc.nodeAt(t-1):n.doc;if(!o)throw new Error("No table found");let s=Kt.get(o);const{top:a,left:l}=r,c=l+i.width,d=a+i.height,u=n.tr;let h=0;function p(){if(o=t?u.doc.nodeAt(t-1):u.doc,!o)throw new Error("No table found");s=Kt.get(o),h=u.mapping.maps.length}qH(u,s,o,t,c,d,h)&&p(),Ew(u,s,o,t,l,c,a,h)&&p(),Ew(u,s,o,t,l,c,d,h)&&p(),Aw(u,s,o,t,a,d,l,h)&&p(),Aw(u,s,o,t,a,d,c,h)&&p();for(let m=a;m<d;m++){const v=s.positionAt(m,l,o),g=s.positionAt(m,c,o);u.replace(u.mapping.slice(h).map(v+t),u.mapping.slice(h).map(g+t),new pe(i.rows[m-a],0,0))}p(),u.setSelection(new Lt(u.doc.resolve(t+s.positionAt(a,l,o)),u.doc.resolve(t+s.positionAt(d-1,c-1,o)))),e(u)}const JH=Jv({ArrowLeft:zd("horiz",-1),ArrowRight:zd("horiz",1),ArrowUp:zd("vert",-1),ArrowDown:zd("vert",1),"Shift-ArrowLeft":Fd("horiz",-1),"Shift-ArrowRight":Fd("horiz",1),"Shift-ArrowUp":Fd("vert",-1),"Shift-ArrowDown":Fd("vert",1),Backspace:Ld,"Mod-Backspace":Ld,Delete:Ld,"Mod-Delete":Ld});function hu(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function zd(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;if(o instanceof Lt)return hu(t,r,We.near(o.$headCell,e));if(n!="horiz"&&!o.empty)return!1;const s=PC(i,n,e);if(s==null)return!1;if(n=="horiz")return hu(t,r,We.near(t.doc.resolve(o.head+e),e));{const a=t.doc.resolve(s),l=AC(a,n,e);let c;return l?c=We.near(l,1):e<0?c=We.near(t.doc.resolve(a.before(-1)),-1):c=We.near(t.doc.resolve(a.after(-1)),1),hu(t,r,c)}}}function Fd(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof Lt)s=o;else{const l=PC(i,n,e);if(l==null)return!1;s=new Lt(t.doc.resolve(l))}const a=AC(s.$headCell,n,e);return a?hu(t,r,new Lt(s.$anchorCell,a)):!1}}function ZH(n,e){const t=n.state.doc,r=Ks(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Lt(r))),!0):!1}function YH(n,e,t){if(!ci(n.state))return!1;let r=jH(t);const i=n.state.selection;if(i instanceof Lt){r||(r={width:1,height:1,rows:[oe.from(xg(Un(n.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=Kt.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=KH(r,a.right-a.left,a.bottom-a.top),Mw(n.state,n.dispatch,s,a,r),!0}else if(r){const o=Th(n.state),s=o.start(-1);return Mw(n.state,n.dispatch,s,Kt.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function GH(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Ow(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof Lt)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Ks(n.state.selection.$anchor))!=null&&((t=Rp(n,e))===null||t===void 0?void 0:t.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(l,c){let d=Rp(n,c);const u=So.getState(n.state)==null;if(!d||!my(l,d))if(u)d=l;else return;const h=new Lt(l,d);if(u||!n.state.selection.eq(h)){const p=n.state.tr.setSelection(h);u&&p.setMeta(So,l.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",a),So.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(So,-1))}function a(l){const c=l,d=So.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(Ow(n,c.target)!=r&&(u=Rp(n,e),!u))return s();u&&o(u,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",a)}function PC(n,e,t){if(!(n.state.selection instanceof Ne))return null;const{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?s:null}}return null}function Ow(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Rp(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:i}=t;return r>=0&&Ks(n.state.doc.resolve(r))||Ks(n.state.doc.resolve(i))}var XH=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")),kg(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,kg(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function kg(n,e,t,r,i,o){let s=0,a=!0,l=e.firstChild;const c=n.firstChild;if(c){for(let u=0,h=0;u<c.childCount;u++){const{colspan:p,colwidth:m}=c.child(u).attrs;for(let v=0;v<p;v++,h++){const g=i==h?o:m&&m[v],y=g?g+"px":"";if(s+=g||r,g||(a=!1),l)l.style.width!=y&&(l.style.width=y),l=l.nextSibling;else{const w=document.createElement("col");w.style.width=y,e.appendChild(w)}}}for(;l;){var d;const u=l.nextSibling;(d=l.parentNode)===null||d===void 0||d.removeChild(l),l=u}a?(t.style.width=s+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=s+"px")}}const vr=new At("tableColumnResizing");function QH({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=XH,lastColumnResizable:i=!0}={}){const o=new Ct({key:vr,state:{init(s,a){var l;const c=(l=o.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,d=Un(a.schema).table.name;return r&&c&&(c[d]=(u,h)=>new r(u,t,h)),new $H(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=vr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{eV(s,a,n,i)},mouseleave:s=>{tV(s)},mousedown:(s,a)=>{nV(s,a,e,t)}},decorations:s=>{const a=vr.getState(s);if(a&&a.activeHandle>-1)return aV(s,a.activeHandle)},nodeViews:{}}});return o}var $H=class pu{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(vr);if(r&&r.setHandle!=null)return new pu(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new pu(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return wg(e.doc.resolve(i))||(i=-1),new pu(i,t.dragging)}return t}};function eV(n,e,t,r){if(!n.editable)return;const i=vr.getState(n.state);if(i&&!i.dragging){const o=iV(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=t?s=Dw(n,e,"left",t):l-e.clientX<=t&&(s=Dw(n,e,"right",t))}if(s!=i.activeHandle){if(!r&&s!==-1){const a=n.state.doc.resolve(s),l=a.node(-1),c=Kt.get(l),d=a.start(-1);if(c.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==c.width-1)return}LC(n,s)}}}function tV(n){if(!n.editable)return;const e=vr.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&LC(n,-1)}function nV(n,e,t,r){var i;if(!n.editable)return!1;const o=(i=n.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=vr.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=n.state.doc.nodeAt(s.activeHandle),l=rV(n,s.activeHandle,a.attrs);n.dispatch(n.state.tr.setMeta(vr,{setDragging:{startX:e.clientX,startWidth:l}}));function c(u){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",d);const h=vr.getState(n.state);h!=null&&h.dragging&&(oV(n,h.activeHandle,Rw(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(vr,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=vr.getState(n.state);if(h&&h.dragging){const p=Rw(h.dragging,u,t);Nw(n,h.activeHandle,p,r)}}return Nw(n,s.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",d),e.preventDefault(),!0}function rV(n,e,{colspan:t,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=n.domAtPos(e);let s=o.node.childNodes[o.offset].offsetWidth,a=t;if(r)for(let l=0;l<t;l++)r[l]&&(s-=r[l],a--);return s/a}function iV(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Dw(n,e,t,r){const i=t=="right"?-r:r,o=n.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,a=Ks(n.state.doc.resolve(s));if(!a)return-1;if(t=="right")return a.pos;const l=Kt.get(a.node(-1)),c=a.start(-1),d=l.map.indexOf(a.pos-c);return d%l.width==0?-1:c+l.map[d-1]}function Rw(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function LC(n,e){n.dispatch(n.state.tr.setMeta(vr,{setHandle:e}))}function oV(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),o=Kt.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<o.height;c++){const d=c*o.width+a;if(c&&o.map[d]==o.map[d-o.width])continue;const u=o.map[d],h=i.nodeAt(u).attrs,p=h.colspan==1?0:a-o.colCount(u);if(h.colwidth&&h.colwidth[p]==t)continue;const m=h.colwidth?h.colwidth.slice():sV(h.colspan);m[p]=t,l.setNodeMarkup(s+u,null,{...h,colwidth:m})}l.docChanged&&n.dispatch(l)}function Nw(n,e,t,r){const i=n.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=Kt.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let l=n.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&kg(o,l.firstChild,l,r,a,t)}function sV(n){return Array(n).fill(0)}function aV(n,e){const t=[],r=n.doc.resolve(e),i=r.node(-1);if(!i)return et.empty;const o=Kt.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const d=a+c*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(c==0||o.map[d]!=o.map[d-o.width])){var l;const u=o.map[d],h=s+u+i.nodeAt(u).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((l=vr.getState(n))===null||l===void 0)&&l.dragging&&t.push(Ft.node(s+u,s+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),t.push(Ft.widget(h,p))}}return et.create(n.doc,t)}function lV({allowTableNodeSelection:n=!1}={}){return new Ct({key:So,state:{init(){return null},apply(e,t){const r=e.getMeta(So);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:i,pos:o}=e.mapping.mapResult(t);return i?null:o}},props:{decorations:xH,handleDOMEvents:{mousedown:GH},createSelectionBetween(e){return So.getState(e.state)!=null?e.state.selection:null},handleTripleClick:ZH,handleKeyDown:JH,handlePaste:YH},appendTransaction(e,t,r){return SH(r,RC(r,t),n)}})}function _g(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function Iw(n,e,t,r,i,o){var s;let a=0,l=!0,c=e.firstChild;const d=n.firstChild;if(d!==null)for(let u=0,h=0;u<d.childCount;u+=1){const{colspan:p,colwidth:m}=d.child(u).attrs;for(let v=0;v<p;v+=1,h+=1){const g=i===h?o:m&&m[v],y=g?`${g}px`:"";if(a+=g||r,g||(l=!1),c){if(c.style.width!==y){const[w,_]=_g(r,g);c.style.setProperty(w,_)}c=c.nextSibling}else{const w=document.createElement("col"),[_,C]=_g(r,g);w.style.setProperty(_,C),e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(s=c.parentNode)===null||s===void 0||s.removeChild(c),c=u}l?(t.style.width=`${a}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${a}px`)}class cV{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")),Iw(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Iw(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function dV(n,e,t,r){let i=0,o=!0;const s=[],a=n.firstChild;if(!a)return{};for(let u=0,h=0;u<a.childCount;u+=1){const{colspan:p,colwidth:m}=a.child(u).attrs;for(let v=0;v<p;v+=1,h+=1){const g=t===h?r:m&&m[v];i+=g||e,g||(o=!1);const[y,w]=_g(e,g);s.push(["col",{style:`${y}: ${w}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:c}}function Pw(n,e){return n.createAndFill()}function uV(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function fV(n,e,t,r,i){const o=uV(n),s=[],a=[];for(let c=0;c<t;c+=1){const d=Pw(o.cell);if(d&&a.push(d),r){const u=Pw(o.header_cell);u&&s.push(u)}}const l=[];for(let c=0;c<e;c+=1)l.push(o.row.createChecked(null,r&&c===0?s:a));return o.table.createChecked(null,l)}function hV(n){return n instanceof Lt}const Bd=({editor:n})=>{const{selection:e}=n.state;if(!hV(e))return!1;let t=0;const r=hC(e.ranges[0].$from,o=>o.type.name==="table");return r==null||r.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},pV=$n.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:cV,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:i}=dV(n,this.options.cellMinWidth),o=["table",Zt(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${i}`}),t,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const s=fV(o.schema,n,e,t);if(i){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Ne.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>EH(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>AH(n,e),deleteColumn:()=>({state:n,dispatch:e})=>OH(n,e),addRowBefore:()=>({state:n,dispatch:e})=>RH(n,e),addRowAfter:()=>({state:n,dispatch:e})=>NH(n,e),deleteRow:()=>({state:n,dispatch:e})=>PH(n,e),deleteTable:()=>({state:n,dispatch:e})=>UH(n,e),mergeCells:()=>({state:n,dispatch:e})=>_w(n,e),splitCell:()=>({state:n,dispatch:e})=>Sw(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>jc("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>jc("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>HH(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>_w(n,e)?!0:Sw(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>FH(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Tw(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Tw(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&RC(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Lt.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Bd,"Mod-Backspace":Bd,Delete:Bd,"Mod-Delete":Bd}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[QH({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],lV({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:ot(Ee(n,"tableRole",e))}}}),mV=$n.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",Zt(this.options.HTMLAttributes,n),0]}}),gV=$n.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",Zt(this.options.HTMLAttributes,n),0]}}),vV=$n.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",Zt(this.options.HTMLAttributes,n),0]}}),yV=/^\s*>\s$/,bV=$n.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",Zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Bc({find:yV,type:this.type})]}}),wV=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,xV=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,kV=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,_V=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,SV=Ii.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",Zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ws({find:wV,type:this.type}),Ws({find:kV,type:this.type})]},addPasteRules(){return[Xo({find:xV,type:this.type}),Xo({find:_V,type:this.type})]}}),CV="listItem",Lw="textStyle",zw=/^\s*([-+*])\s$/,TV=$n.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:n}){return["ul",Zt(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(CV,this.editor.getAttributes(Lw)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Bc({find:zw,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Bc({find:zw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Lw),editor:this.editor})),[n]}}),EV=/(^|[^`])`([^`]+)`(?!`)/,AV=/(^|[^`])`([^`]+)`(?!`)/g,MV=Ii.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",Zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ws({find:EV,type:this.type})]},addPasteRules(){return[Xo({find:AV,type:this.type})]}}),OV=/^```([a-z]+)?[\s\n]$/,DV=/^~~~([a-z]+)?[\s\n]$/,RV=$n.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:n=>{var e;const{languageClassPrefix:t}=this.options,o=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(t)).map(s=>s.replace(t,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",Zt(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
|
|
184
|
+
|
|
185
|
+
`);return!o||!s?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:o}=t;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const a=i.after();return a===void 0?!1:r.nodeAt(a)?n.commands.command(({tr:c})=>(c.setSelection(We.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[ig({find:OV,type:this.type,getAttributes:n=>({language:n[1]})}),ig({find:DV,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new Ct({key:new At("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i==null?void 0:i.mode;if(!t||!o)return!1;const{tr:s,schema:a}=n.state,l=a.text(t.replace(/\r\n?/g,`
|
|
186
|
+
`));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Ne.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}}),NV=$n.create({name:"doc",topNode:!0,content:"block+"});function IV(n={}){return new Ct({view(e){return new PV(e,n)}})}class PV{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler: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,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,a=o.height/i.offsetHeight;if(t){let u=e.nodeBefore,h=e.nodeAfter;if(u||h){let p=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(p){let m=p.getBoundingClientRect(),v=u?m.bottom:m.top;u&&h&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:m.left,right:m.right,top:v-g,bottom:v+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=l.getBoundingClientRect(),h=u.width/l.offsetWidth,p=u.height/l.offsetHeight;c=u.left-l.scrollLeft*h,d=u.top-l.scrollTop*p}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/a+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=nk(this.editorView.state.doc,s,this.editorView.dragging.slice);a!=null&&(s=a)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const LV=Bt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[IV(this.options)]}});class jt extends We{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return jt.valid(r)?new jt(r):We.near(r)}content(){return pe.empty}eq(e){return e instanceof jt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new jt(e.resolve(t.pos))}getBookmark(){return new gy(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!zV(e)||!FV(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&jt.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(t>0?e.indexAfter(s)<a.childCount:e.index(s)>0){o=a.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let l=e.doc.resolve(i);if(jt.valid(l))return l}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!Fe.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let a=e.doc.resolve(i);if(jt.valid(a))return a}return null}}}jt.prototype.visible=!1;jt.findFrom=jt.findGapCursorFrom;We.jsonID("gapcursor",jt);class gy{constructor(e){this.pos=e}map(e){return new gy(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return jt.valid(t)?new jt(t):We.near(t)}}function zC(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function zV(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||zC(i.type))return!0;if(i.inlineContent)return!1}}return!0}function FV(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||zC(i.type))return!0;if(i.inlineContent)return!1}}return!0}function BV(){return new Ct({props:{decorations:jV,createSelectionBetween(n,e,t){return e.pos==t.pos&&jt.valid(t)?new jt(t):null},handleClick:VV,handleKeyDown:HV,handleDOMEvents:{beforeinput:UV}}})}const HV=Jv({ArrowLeft:Hd("horiz",-1),ArrowRight:Hd("horiz",1),ArrowUp:Hd("vert",-1),ArrowDown:Hd("vert",1)});function Hd(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,a=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Ne){if(!o.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=jt.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new jt(c))),!0):!1}}function VV(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!jt.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&Fe.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new jt(r))),!0)}function UV(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof jt))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=oe.empty;for(let s=r.length-1;s>=0;s--)i=oe.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new pe(i,0,0));return o.setSelection(Ne.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function jV(n){if(!(n.selection instanceof jt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",et.create(n.doc,[Ft.widget(n.selection.head,e,{key:"gapcursor"})])}const WV=Bt.create({name:"gapCursor",addProseMirrorPlugins(){return[BV()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ot(Ee(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),KV=$n.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",Zt(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
187
|
+
`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:o}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:a}=r.extensionManager,l=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&s){const u=l.filter(h=>a.includes(h.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),qV=$n.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(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Zt(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>ig({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Nf=200,kn=function(){};kn.prototype.append=function(e){return e.length?(e=kn.from(e),!this.length&&e||e.length<Nf&&this.leafAppend(e)||this.length<Nf&&e.leafPrepend(this)||this.appendInner(e)):this};kn.prototype.prepend=function(e){return e.length?kn.from(e).append(this):this};kn.prototype.appendInner=function(e){return new JV(this,e)};kn.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?kn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};kn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};kn.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};kn.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};kn.from=function(e){return e instanceof kn?e:e&&e.length?new FC(e):kn.empty};var FC=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,a){for(var l=o;l<s;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,a){for(var l=o-1;l>=s;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Nf)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Nf)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(kn);kn.empty=new FC([]);var JV=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var a=this.left.length;if(i<a&&this.left.forEachInner(r,i,Math.min(o,a),s)===!1||o>a&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,o)-a,s+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(o,a)-a,s+a)===!1||o<a&&this.left.forEachInvertedInner(r,Math.min(i,a),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(kn);const ZV=500;class Xr{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){i||(i=this.remapping(r,h+1),o=i.maps.length),o--,d.push(u);return}if(i){d.push(new pi(u.map));let p=u.step.map(i.slice(o)),m;p&&s.maybeStep(p).doc&&(m=s.mapping.maps[s.mapping.maps.length-1],c.push(new pi(m,void 0,void 0,c.length+d.length))),o--,m&&i.appendMap(m,o)}else s.maybeStep(u.step);if(u.selection)return a=i?u.selection.map(i.slice(o)):u.selection,l=new Xr(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,t,r,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new pi(e.mapping.maps[d],u,t),p;(p=l&&l.merge(h))&&(h=p,d?o.pop():a=a.slice(0,a.length-1)),o.push(h),t&&(s++,t=void 0),i||(l=h)}let c=s-r.depth;return c>GV&&(a=YV(a,c),s-=c),new Xr(a.append(o),s)}remapping(e,t){let r=new gc;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new Xr(this.items.append(e.map(t=>new pi(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},i);let l=t;this.items.forEach(h=>{let p=o.getMirror(--l);if(p==null)return;s=Math.min(s,p);let m=o.maps[p];if(h.step){let v=e.steps[p].invert(e.docs[p]),g=h.selection&&h.selection.map(o.slice(l+1,p));g&&a++,r.push(new pi(m,v,g))}else r.push(new pi(m))},i);let c=[];for(let h=t;h<s;h++)c.push(new pi(o.maps[h]));let d=this.items.slice(0,i).append(c).append(r),u=new Xr(d,a);return u.emptyItemCount()>ZV&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,a)=>{if(a>=e)i.push(s),s.selection&&o++;else if(s.step){let l=s.step.map(t.slice(r)),c=l&&l.getMap();if(r--,c&&t.appendMap(c,r),l){let d=s.selection&&s.selection.map(t.slice(r));d&&o++;let u=new pi(c.invert(),l,d),h,p=i.length-1;(h=i.length&&i[p].merge(u))?i[p]=h:i.push(u)}}else s.map&&r--},this.items.length,0),new Xr(kn.from(i.reverse()),o)}}Xr.empty=new Xr(kn.empty,0);function YV(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class pi{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new pi(t.getMap().invert(),t,this.selection)}}}class wo{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const GV=20;function XV(n,e,t,r){let i=t.getMeta(Rs),o;if(i)return i.historyState;t.getMeta(e6)&&(n=new wo(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Rs))return s.getMeta(Rs).redo?new wo(n.done.addTransform(t,void 0,r,mu(e)),n.undone,Fw(t.mapping.maps),n.prevTime,n.prevComposition):new wo(n.done,n.undone.addTransform(t,void 0,r,mu(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!s&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!QV(t,n.prevRanges)),c=s?Np(n.prevRanges,t.mapping):Fw(t.mapping.maps);return new wo(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,mu(e)),Xr.empty,c,t.time,a??n.prevComposition)}else return(o=t.getMeta("rebased"))?new wo(n.done.rebased(t,o),n.undone.rebased(t,o),Np(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new wo(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Np(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function QV(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function Fw(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function Np(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),o=e.map(n[r+1],-1);i<=o&&t.push(i,o)}return t}function $V(n,e,t){let r=mu(e),i=Rs.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),l=new wo(t?a:o.remaining,t?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(Rs,{redo:t,historyState:l})}let Ip=!1,Bw=null;function mu(n){let e=n.plugins;if(Bw!=e){Ip=!1,Bw=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ip=!0;break}}return Ip}const Rs=new At("history"),e6=new At("closeHistory");function t6(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Ct({key:Rs,state:{init(){return new wo(Xr.empty,Xr.empty,null,0,-1)},apply(e,t,r){return XV(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?HC:r=="historyRedo"?VC:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function BC(n,e){return(t,r)=>{let i=Rs.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=$V(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const HC=BC(!1,!0),VC=BC(!0,!0),n6=Bt.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>HC(n,e),redo:()=>({state:n,dispatch:e})=>VC(n,e)}},addProseMirrorPlugins(){return[t6(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()}}}),r6=$n.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",Zt(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!ZB(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$from:r,$to:i}=t,o=n();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):mB(t)?o.insertContentAt(i.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:s,dispatch:a})=>{var l;if(a){const{$to:c}=s.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(Ne.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(Fe.create(s.doc,c.pos)):s.setSelection(Ne.create(s.doc,c.pos));else{const u=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();u&&(s.insert(d,u),s.setSelection(Ne.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[JB({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),i6=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,o6=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,s6=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,a6=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,l6=Ii.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",Zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ws({find:i6,type:this.type}),Ws({find:s6,type:this.type})]},addPasteRules(){return[Xo({find:o6,type:this.type}),Xo({find:a6,type:this.type})]}}),c6=$n.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Zt(this.options.HTMLAttributes,n),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)}}}),d6="listItem",Hw="textStyle",Vw=/^(\d+)\.\s$/,u6=$n.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:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",Zt(this.options.HTMLAttributes,t),0]:["ol",Zt(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(d6,this.editor.getAttributes(Hw)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Bc({find:Vw,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)&&(n=Bc({find:Vw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Hw)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),f6=$n.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),h6=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,p6=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,m6=Ii.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Zt(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ws({find:h6,type:this.type})]},addPasteRules(){return[Xo({find:p6,type:this.type})]}}),g6=$n.create({name:"text",group:"inline"}),v6=Bt.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(SV.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(bV.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(TV.configure(this.options.bulletList)),this.options.code!==!1&&n.push(MV.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(RV.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(NV.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(LV.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(WV.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(KV.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(qV.configure(this.options.heading)),this.options.history!==!1&&n.push(n6.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(r6.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(l6.configure(this.options.italic)),this.options.listItem!==!1&&n.push(c6.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(u6.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(f6.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(m6.configure(this.options.strike)),this.options.text!==!1&&n.push(g6.configure(this.options.text)),n}}),Vd=new At("tandemAnnotations");function Pp(n,e,t){const r=[],i=n.content.size;return e.forEach(o=>{const s=il(o,u=>{console.warn("[sanitize]",u)});if(s.status!=="pending"||!s.range&&!s.relRange)return;const a=Oc(s,n,t);if(!a)return;s.relRange&&a.method==="flat"&&console.warn("[annotation] relRange-equipped annotation %s fell back to flat offsets",s.id);const{from:l,to:c}=a;if(l>=c||l<0||c>i)return;let d={};switch(s.type){case"highlight":{const u=vx(s.color),h=fc[u];d={class:`tandem-highlight tandem-highlight--${u}`,style:`background: ${h}; border-radius: var(--tandem-r-1); padding: 1px 0;`,"data-annotation-id":s.id,"data-annotation-author":s.author,"aria-label":`Highlight annotation (${u})`};break}case"comment":s.suggestedText!==void 0?d={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-author":s.author,"aria-label":"Replacement annotation"}:s.author==="claude"?d={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-author":s.author,"aria-label":"Claude comment annotation"}:d={class:"tandem-comment",style:"border-bottom: 2px dashed var(--tandem-author-user); padding-bottom: 1px;","data-annotation-id":s.id,"data-annotation-author":s.author,"aria-label":"Comment 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-author":s.author,"aria-label":"Note annotation"};break;default:{console.warn("[annotation] Unhandled annotation type in buildDecorations, skipping");return}}try{r.push(Ft.inline(l,c,d))}catch(u){if(!(u instanceof RangeError))throw u;console.debug("[annotation] RangeError for %s (from=%d, to=%d), skipping",s.id,l,c)}}),et.create(n,r)}const y6=Bt.create({name:"tandemAnnotations",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(Ko);let t=e.size>0,r=!1;return[new Ct({key:Vd,state:{init(i,o){return Pp(o.doc,e,n)},apply(i,o,s,a){if(i.getMeta(Vd))return Pp(a.doc,e,n);if(i.docChanged){if(!r&&o===et.empty&&t){const l=Pp(a.doc,e,n);return l!==et.empty&&(r=!0),l}return o.map(i.mapping,i.doc)}return o}},props:{decorations(i){return Vd.getState(i)}},view(i){let o=null,s=!1;function a(){o===null&&(o=requestAnimationFrame(()=>{o=null,s=!0;const d=i.state.tr.setMeta(Vd,!0);i.dispatch(d)}))}const l=()=>{t=e.size>0,r=!1,a()};e.observe(l);const c=setTimeout(()=>{!s&&o===null&&e.size>0&&l()},500);return{destroy(){clearTimeout(c),o!==null&&cancelAnimationFrame(o),e.unobserve(l)}}}})]}}),ua=new At("tandemAuthorship"),b6=new Set(["paragraph","heading"]);function w6(n,e,t){if(n.relRange){const r=V_(t,e,n.relRange);if(r&&r.from<r.to)return r}if(n.range){console.warn("[authorship] Falling back to flat offsets for range",n.id);const r=Yo(e,n.range.from),i=Yo(e,n.range.to);if(r<i)return{from:r,to:i}}return null}function Lp(n,e,t,r){if(!r)return et.empty;const i=[],o=n.content.size,s=[];return e.forEach(a=>{const l=a;if(!l.author||!l.range||l.author!=="user"&&l.author!=="claude")return;const c=w6(l,n,t);if(!c)return;const{from:d,to:u}=c;if(!(d>=u||d<0||u>o)){try{i.push(Ft.inline(d,u,{"data-tandem-author":l.author}))}catch(h){if(!(h instanceof RangeError))throw h;console.warn("[authorship] Decoration RangeError for entry",l.id,h)}s.push({author:l.author,from:d,to:u})}}),n.descendants((a,l)=>{if(!b6.has(a.type.name))return;const c=l,d=l+a.nodeSize;let u=0,h=0;for(const m of s){const v=Math.max(m.from,c),g=Math.min(m.to,d);if(g<=v)continue;const y=g-v;m.author==="user"?u+=y:h+=y}if(u===0&&h===0)return;const p=u>=h?"user":"claude";try{i.push(Ft.node(c,d,{"data-tandem-author-block":p}))}catch(m){if(!(m instanceof RangeError))throw m;console.warn("[authorship] node Decoration RangeError at offset",l,m)}}),et.create(n,i)}const x6=Bt.create({name:"tandemAuthorship",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(lb);let t=!1;try{t=localStorage.getItem(_x)==="true"}catch(r){console.warn("[authorship] localStorage unavailable",r)}return[new Ct({key:ua,state:{init(r,i){return{visible:t,decorations:Lp(i.doc,e,n,t)}},apply(r,i,o,s){const a=r.getMeta(ua);if((a==null?void 0:a.type)==="toggle"){const l=a.visible;return{visible:l,decorations:Lp(s.doc,e,n,l)}}return(a==null?void 0:a.type)==="rebuild"?{visible:i.visible,decorations:Lp(s.doc,e,n,i.visible)}:r.docChanged&&i.visible?{visible:i.visible,decorations:i.decorations.map(r.mapping,r.doc)}:i}},props:{decorations(r){var i;return((i=ua.getState(r))==null?void 0:i.decorations)??et.empty}},view(r){const i=()=>{const s=r.state.tr.setMeta(ua,{type:"rebuild"});r.dispatch(s)};e.observe(i);const o=setTimeout(()=>{e.size>0&&i()},500);return{destroy(){clearTimeout(o),e.unobserve(i)}}}})]},onTransaction({transaction:n}){const e=this.options.ydoc;if(!e||n.getMeta("y-sync$")||n.getMeta(ua)||!n.docChanged)return;const t=e.getMap(lb),r=n.doc;n.steps.forEach(i=>{i.getMap().forEach((s,a,l,c)=>{if(c-l-(a-s)>0)try{const u=ki(r,Dn(l)),h=ki(r,Dn(c));if(h<=u)return;const p=MN("user"),m={id:p,author:"user",range:{from:u,to:h},timestamp:Date.now()};t.set(p,m)}catch(u){console.warn("[authorship] Position conversion failed during user attribution",u)}})})}}),Ud=new At("tandemAwareness");function Uw(n,e){if(!e)return et.empty;const t=[],{focusParagraph:r,focusOffset:i,active:o}=e;if(r!==null&&r>=0){let s=0;n.forEach((a,l)=>{s===r&&t.push(Ft.node(l,l+a.nodeSize,{class:"tandem-claude-focus",style:"background: var(--tandem-claude-focus-bg); border-left: 3px solid var(--tandem-claude-focus-border); padding-left: 8px; transition: background 0.3s ease, border-color 0.3s ease;"})),s++})}if(i!==null&&i>=0)try{const s=Yo(n,Qd(i)),a=o===!1?" tandem-claude-cursor-idle":"";t.push(Ft.widget(s,()=>{const l=document.createElement("span");l.className=`tandem-claude-cursor${a}`,l.setAttribute("aria-hidden","true");const c=document.createElement("span");return c.className="tandem-claude-cursor-label",c.textContent="Claude",l.appendChild(c),l}))}catch(s){console.warn("[awareness] cursor decoration failed, falling back to gutter-only:",s)}return t.length===0?et.empty:et.create(n,t)}const k6=Bt.create({name:"tandemAwareness",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(xx),t=n.getMap(um);return[new Ct({key:Ud,state:{init(r,i){const o=e.get(fm);return Uw(i.doc,o??null)},apply(r,i,o,s){if(r.getMeta(Ud)){const a=e.get(fm);return Uw(s.doc,a??null)}return r.docChanged?i.map(r.mapping,r.doc):i}},props:{decorations(r){return Ud.getState(r)}},view(r){const i=()=>{const o=r.state.tr.setMeta(Ud,!0);r.dispatch(o)};return e.observe(i),{destroy(){e.unobserve(i)}}}}),new Ct({key:new At("tandemUserAwareness"),view(){let r=null,i=null,o=null,s=!1,a=-1;return{update(l,c){const{state:d}=l;if(!d.selection.eq(c.selection)){const u=U_(d.doc,{from:Dn(d.selection.from),to:Dn(d.selection.to)});if(d.selection.from===d.selection.to)o&&(clearTimeout(o),o=null),t.set(cb,{...u,timestamp:Date.now()});else{const h=d.doc.textBetween(d.selection.from,d.selection.to,`
|
|
188
|
+
`),p=h.length>200?h.slice(0,197)+"...":h;o&&clearTimeout(o),o=setTimeout(()=>{o=null,t.set(cb,{...u,selectedText:p,timestamp:Date.now()})},150)}}d.doc!==c.doc&&(a=d.selection.from,s=!0,i||(i=setTimeout(()=>{i=null,s&&t.set(db,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200)),r&&clearTimeout(r),r=setTimeout(()=>{s=!1,t.set(db,{isTyping:!1,cursor:l.state.selection.from,lastEdit:Date.now()})},ZA))},destroy(){r&&clearTimeout(r),i&&clearTimeout(i),o&&clearTimeout(o)}}}})]}}),mi=new At("tandemFindReplace"),UC={query:"",caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:et.empty};function _6(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S6(n){if(!n.query)return null;try{const e=n.regexMode?n.query:_6(n.query),t=n.caseSensitive?"g":"gi",r=n.wholeWord?`\\b${e}\\b`:e;return new RegExp(r,t)}catch{return null}}function jC(n,e){const t=S6(e);if(!t)return[];const r=[];return n.descendants((i,o)=>{if(!i.isTextblock)return;const s=i.textContent;for(const a of s.matchAll(t)){const l=a.index??0;r.push({from:o+1+l,to:o+1+l+a[0].length})}}),r}function ic(n,e,t){if(e.length===0)return et.empty;const r=[];for(let i=0;i<e.length;i++){const{from:o,to:s}=e[i];try{r.push(Ft.inline(o,s,{class:i===t?"tandem-find-active":"tandem-find-match"}))}catch{}}return et.create(n,r)}function Sg(n,e){if(n.length===0)return-1;for(let t=0;t<n.length;t++)if(n[t].from<=e&&e<=n[t].to)return t;for(let t=0;t<n.length;t++)if(n[t].from>e)return t;return 0}function C6(n,e,t){if(n.type==="close")return UC;if(n.type==="find"){const i=n.opts,o=jC(t.doc,i),s=t.selection.from,a=Sg(o,s);return{...i,matches:o,activeIndex:a,decoSet:ic(t.doc,o,a)}}if(n.type==="next"){const i=e.matches.length===0?-1:(e.activeIndex+1)%e.matches.length;return{...e,activeIndex:i,decoSet:ic(t.doc,e.matches,i)}}if(n.type==="prev"){const i=e.matches.length===0?-1:(e.activeIndex-1+e.matches.length)%e.matches.length;return{...e,activeIndex:i,decoSet:ic(t.doc,e.matches,i)}}return n}const T6=Bt.create({name:"tandemFindReplace",addProseMirrorPlugins(){return[new Ct({key:mi,state:{init:()=>UC,apply(n,e,t,r){const i=n.getMeta(mi);if(i)return C6(i,e,r);if(!e.query)return e;if(n.docChanged){const a=jC(r.doc,e),l=r.selection.from,c=Sg(a,l);return{...e,matches:a,activeIndex:c,decoSet:ic(r.doc,a,c)}}const o=r.selection.from,s=Sg(e.matches,o);return s===e.activeIndex?e:{...e,activeIndex:s,decoSet:ic(r.doc,e.matches,s)}}},props:{decorations(n){var e;return((e=mi.getState(n))==null?void 0:e.decoSet)??et.empty}}})]},addCommands(){return{find:n=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(mi,{type:"find",opts:n})),!0),findNext:()=>({dispatch:n,tr:e})=>(n&&n(e.setMeta(mi,{type:"next"})),!0),findPrev:()=>({dispatch:n,tr:e})=>(n&&n(e.setMeta(mi,{type:"prev"})),!0),findClose:()=>({dispatch:n,tr:e})=>(n&&n(e.setMeta(mi,{type:"close"})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:n})=>{const e=mi.getState(n.state);return e!=null&&e.query?(n.commands.findClose(),!0):!1}}}});function Ma(n){return mi.getState(n)}function E6(n,e){const t=Ma(n.state);if(!t||t.activeIndex<0||t.matches.length===0)return!1;const{from:r,to:i}=t.matches[t.activeIndex],o=n.state.tr.insertText(e,r,i).setMeta(mi,{type:"next"});return n.dispatch(o),!0}async function A6(n,e,t){let i=0,o=!1;for(let s=0;s<50;s++){const a=Ma(n.state);if(!(a!=null&&a.query)||a.matches.length===0)break;const l=a.matches.slice(0,100);try{let c=n.state.tr;for(let d=l.length-1;d>=0;d--){const{from:u,to:h}=l[d];c=c.insertText(e,u,h)}n.dispatch(c),i+=l.length,t==null||t(i,i+(a.matches.length-l.length))}catch(c){o=!0,console.warn("[find-replace] replaceAll chunk failed at pass",s,c);break}if(l.length<100)break;await new Promise(c=>setTimeout(c,0))}return{replaced:i,partial:o}}const M6=Bt.create({name:"markdownHtml",addGlobalAttributes(){return[{types:["paragraph"],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}}]}}),O6=new At("tandemSelectionDecoration"),D6=Bt.create({name:"tandemSelectionDecoration",addProseMirrorPlugins(){return[new Ct({key:O6,props:{decorations(n){const{selection:e}=n;if(!(e instanceof Ne))return et.empty;const{from:t,to:r}=e;return t===r?et.empty:et.create(n.doc,[Ft.inline(t,r,{class:"tandem-selection-blurred"})])}}})]}});function mo(n){return n.chain().focus()}const jw=[{id:"heading-1",label:"Heading 1",keywords:["h1","heading","title"],run:n=>mo(n).toggleHeading({level:1}).run()},{id:"heading-2",label:"Heading 2",keywords:["h2","heading","subtitle"],run:n=>mo(n).toggleHeading({level:2}).run()},{id:"heading-3",label:"Heading 3",keywords:["h3","heading","subheading"],run:n=>mo(n).toggleHeading({level:3}).run()},{id:"bullet-list",label:"Bullet list",keywords:["bullet","ul","list"],run:n=>mo(n).toggleBulletList().run()},{id:"numbered-list",label:"Numbered list",keywords:["numbered","ordered","ol","list"],run:n=>mo(n).toggleOrderedList().run()},{id:"quote",label:"Quote",keywords:["blockquote","quote"],run:n=>mo(n).toggleBlockquote().run()},{id:"code-block",label:"Code block",keywords:["code","pre","snippet"],run:n=>mo(n).toggleCodeBlock().run()},{id:"horizontal-rule",label:"Horizontal rule",keywords:["hr","divider","rule","separator"],run:n=>mo(n).setHorizontalRule().run()}];function R6(n){const e=/(?:^|\s)\/([A-Za-z0-9 -]*)$/.exec(n);if(!e)return null;const t=e[1]??"";return{fromOffset:n.length-t.length-1,query:t}}function Eh(n){const e=n.trim().toLowerCase();return e?jw.filter(t=>[t.label,...t.keywords].join(" ").toLowerCase().includes(e)):jw}const N6=["popup-annotation-input","popup-note-submit","popup-comment-submit","popup-highlight-yellow","popup-highlight-green","popup-highlight-blue","popup-highlight-pink"];function I6(n){const e=document.querySelector(`[data-testid="${n}"]`);return e?document.activeElement===e:!1}function P6(n){for(const e of n)if(document.querySelector(`[data-testid="${e}"]`))return!0;return!1}function L6(){return typeof document>"u"?!1:!!(I6("find-input")||document.querySelector('[data-testid="command-palette"]')||P6(N6))}const Wi=new At("tandemSlashCommand");function WC(n){return`${n.from}:${n.to}:${n.query}`}function Ww(n,e=0){if(L6())return null;const{selection:t}=n;if(!t.empty)return null;const r=t.$from,i=r.parent.textBetween(0,r.parentOffset,`
|
|
189
|
+
`,`
|
|
190
|
+
`),o=R6(i);if(!o)return null;const s=r.start()+o.fromOffset,a=r.pos,l=Eh(o.query);return l.length===0?null:{from:s,to:a,query:o.query,selectedIndex:Math.min(e,l.length-1)}}function z6(n,e){const t=n.getMeta(Wi);return t?t.type==="close"?{active:null,dismissedKey:e.active?WC(e.active):e.dismissedKey}:t.type==="select"&&e.active?{...e,active:{...e.active,selectedIndex:t.selectedIndex??e.active.selectedIndex}}:e:null}function KC(n){for(;n.firstChild;)n.removeChild(n.firstChild)}function F6(n,e,t,r,i){const o=Eh(e.query);KC(n),n.setAttribute("role","listbox"),n.setAttribute("aria-label","Slash commands"),o.forEach((a,l)=>{const c=document.createElement("button");c.type="button",c.role="option",c.id=`slash-command-${a.id}`,c.setAttribute("aria-selected",String(l===e.selectedIndex)),c.textContent=a.label,c.dataset.commandId=a.id,c.style.cssText="display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--tandem-r-2); background: transparent; color: var(--tandem-fg); font: inherit; font-size: 13px; text-align: left; cursor: pointer;",l===e.selectedIndex&&(c.style.background="var(--tandem-accent-bg)",c.style.color="var(--tandem-accent)"),c.addEventListener("mouseenter",()=>r(l)),c.addEventListener("mousedown",d=>{d.preventDefault(),i(a)}),n.appendChild(c)});const s=t.view.coordsAtPos(e.from);n.style.display="block",n.style.position="fixed",n.style.left=`${Math.max(8,s.left)}px`,n.style.top=`${s.bottom+8}px`,n.style.zIndex="1100",n.style.minWidth="180px",n.style.padding="4px",n.style.border="1px solid var(--tandem-border)",n.style.borderRadius="6px",n.style.background="var(--tandem-surface)",n.style.boxShadow="0 1px 2px color-mix(in srgb, var(--tandem-fg) 4%, transparent), 0 8px 28px color-mix(in srgb, var(--tandem-fg) 10%, transparent)"}function B6(n,e){const t=Eh(e.query)[e.selectedIndex];return t?(n.chain().focus().deleteRange({from:e.from,to:e.to}).run(),t.run(n),!0):!1}const H6=Bt.create({name:"slashCommand",addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){const n=this.editor,e=this.options.onOpenChange;return[new Ct({key:Wi,state:{init:(t,r)=>({active:Ww(r),dismissedKey:null}),apply(t,r,i,o){var l;const s=z6(t,r);if(s)return s;const a=Ww(o,((l=r.active)==null?void 0:l.selectedIndex)??0);return a&&WC(a)===r.dismissedKey?{active:null,dismissedKey:r.dismissedKey}:{active:a,dismissedKey:a?null:r.dismissedKey}}},props:{handleKeyDown(t,r){const i=Wi.getState(t.state),o=i==null?void 0:i.active;if(!o)return!1;const s=Eh(o.query);if(r.key==="ArrowDown"){r.preventDefault();const a=(o.selectedIndex+1)%s.length;return t.dispatch(t.state.tr.setMeta(Wi,{type:"select",selectedIndex:a})),!0}if(r.key==="ArrowUp"){r.preventDefault();const a=(o.selectedIndex-1+s.length)%s.length;return t.dispatch(t.state.tr.setMeta(Wi,{type:"select",selectedIndex:a})),!0}return r.key==="Enter"?(r.preventDefault(),B6(n,o)):r.key==="Escape"?(r.preventDefault(),t.dispatch(t.state.tr.setMeta(Wi,{type:"close"})),!0):!1}},view(t){const r=document.createElement("div");r.dataset.testid="slash-command-menu",r.style.display="none",document.body.appendChild(r);let i=!1;const o=l=>{l!==i&&(i=l,e==null||e(l))},s=()=>{r.style.display="none",KC(r),o(!1)},a=()=>{var c;const l=(c=Wi.getState(t.state))==null?void 0:c.active;if(!l){s();return}F6(r,l,n,d=>{t.dispatch(t.state.tr.setMeta(Wi,{type:"select",selectedIndex:d}))},d=>{n.chain().focus().deleteRange({from:l.from,to:l.to}).run(),d.run(n),s(),t.dispatch(t.state.tr.setMeta(Wi,{type:"close"}))}),o(!0)};return a(),{update:a,destroy(){o(!1),r.remove()}}}})]}});var V6=E('<div role="presentation" data-testid="editor-root"></div>');function U6(n,e){Pe(e,!0);const t=new Set([...JA].filter(p=>p!==".docx")),r=["http://","https://","mailto:","ftp://","//"];function i(p){return r.some(m=>p.startsWith(m))}function o(p,m){const v=m.includes("\\")?"\\":"/",g=p.indexOf("#"),y=g>=0?p.slice(0,g):p;if(!y)return null;const w=y.match(/\.[^./\\]+$/),_=w?w[0].toLowerCase():"";if(!t.has(_))return null;const C=m.split(v);C.pop();const j=y.replace(/\//g,v).split(v),H=[...C];for(const D of j)D===".."?H.length>0&&H.pop():D!=="."&&H.push(D);return H.join(v)}let s=B(null),a=null;const l=F(()=>e.format==="docx");le(()=>{if(e.ydoc,e.provider,!a)return;const p=new qB({element:a,extensions:[v6.configure({history:!1}),B5.configure({multicolor:!0}),dH.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),uH.configure({placeholder:"Start typing…"}),pV.configure({resizable:!0}),vV,mV,gV,M6,P5.configure({document:e.ydoc}),L5.configure({provider:e.provider,user:{name:Rv(),color:"var(--tandem-warning)"}}),y6.configure({ydoc:e.ydoc}),x6.configure({ydoc:e.ydoc}),k6.configure({ydoc:e.ydoc}),H6.configure({onOpenChange:e.onSlashCommandMenuChange}),T6,D6],editorProps:{attributes:{class:"tandem-editor",style:"outline: none; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;"}},editable:Dt(()=>!e.readOnly),autofocus:Dt(()=>!e.readOnly)});return b(s,p,!0),Dt(()=>{var m;return(m=e.onEditorReady)==null?void 0:m.call(e,p)}),()=>{Dt(()=>{var m;return(m=e.onEditorReady)==null?void 0:m.call(e,null)}),p.destroy(),f(s)===p&&b(s,null)}});let c;le(()=>{const p=f(s);if(!p)return;const m=e.readOnly;c!==m&&(c=m,p.setEditable(!m))}),le(()=>{const p=f(s);if(p)return G_(m=>p.commands.updateUser({name:m}))}),le(()=>{const p=f(s);if(!p)return;const m=p.view.dom;m.querySelectorAll(".tandem-annotation-active").forEach(v=>{v.classList.remove("tandem-annotation-active")}),e.activeAnnotationId&&m.querySelectorAll(`[data-annotation-id="${CSS.escape(e.activeAnnotationId)}"]`).forEach(v=>{v.classList.add("tandem-annotation-active")})});async function d(p){const m=p.target.closest("a[href]");if(m){const y=m.getAttribute("href")??"";if(!y||y.startsWith("#"))return;if(p.preventDefault(),i(y)){window.open(y,"_blank","noopener,noreferrer");return}if(e.currentFilePath){const w=o(y,e.currentFilePath);if(w)try{const _=await fetch(`${Gn}${dl}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:w})});if(!_.ok){const C=await _.json().catch(()=>({}));console.warn(`[tandem] Could not open linked file "${w}": ${C.message??_.statusText}`)}}catch(_){console.warn("[tandem] Failed to open relative link:",_)}}return}const v=p.target.closest("[data-annotation-id]");if(!v)return;const g=v.getAttribute("data-annotation-id");g&&e.onAnnotationClick&&e.onAnnotationClick(g)}var u=V6();let h;gt(u,p=>a=p,()=>a),K(()=>h=Vg(u,1,"",null,h,{"tandem-paged":f(l)})),L("click",u,d),S(n,u),Le()}qe(["click"]);var j6=E('<div data-testid="find-scope-pills" style="display: flex; gap: var(--tandem-space-1); align-items: center;"><button data-testid="find-scope-doc">This document</button> <button data-testid="find-scope-tabs">Open tabs</button></div>'),W6=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-error-fg);" role="alert"> </div>'),K6=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-warning-fg); padding: 2px 0;" role="status"> </div>'),q6=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);">Searching…</div>'),J6=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);">No matches in open tabs</div>'),Z6=E('<div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); padding-left: var(--tandem-space-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </div>'),Y6=E('<div style="display: flex; flex-direction: column; gap: 2px;"><div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg); font-weight: 500;"> <span style="color: var(--tandem-fg-subtle); font-weight: normal;"> </span></div> <!></div>'),G6=E('<div data-testid="find-cross-doc-results" style="border-top: 1px solid var(--tandem-border); padding-top: var(--tandem-space-2); display: flex; flex-direction: column; gap: var(--tandem-space-1);"><!></div>'),X6=E(`<div data-testid="find-replace-bar" role="dialog" tabindex="-1" aria-modal="false" aria-label="Find and replace" style="
|
|
191
|
+
position: absolute; bottom: 0; right: 0;
|
|
192
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
193
|
+
border-radius: var(--tandem-r-3) var(--tandem-r-3) 0 0;
|
|
194
|
+
padding: var(--tandem-space-3) var(--tandem-space-4);
|
|
195
|
+
box-shadow: var(--tandem-shadow-3);
|
|
196
|
+
z-index: var(--tandem-z-overlay, 200);
|
|
197
|
+
min-width: 320px; max-width: 480px;
|
|
198
|
+
display: flex; flex-direction: column; gap: var(--tandem-space-2);
|
|
199
|
+
"><!> <div style="display: flex; gap: var(--tandem-space-2); align-items: center;"><input data-testid="find-input" type="text" placeholder="Find…" aria-label="Find"/> <span data-testid="find-match-count" style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); white-space: nowrap; min-width: 48px; text-align: right;"><!></span> <button data-testid="find-prev-btn" title="Previous match (Shift+Enter)" aria-label="Previous match">↑</button> <button data-testid="find-next-btn" title="Next match (Enter)" aria-label="Next match">↓</button> <button data-testid="find-close-btn" title="Close (Esc)" aria-label="Close find bar" style="background: none; border: none; cursor: pointer; font-size: 16px; color: var(--tandem-fg-muted); padding: 0 2px; line-height: 1;">×</button></div> <!> <div style="display: flex; gap: var(--tandem-space-3); align-items: center;"><label style="display: flex; align-items: center; gap: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); cursor: pointer; user-select: none;"><input data-testid="find-case-toggle" type="checkbox"/> Aa</label> <label style="display: flex; align-items: center; gap: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); cursor: pointer; user-select: none;"><input data-testid="find-word-toggle" type="checkbox"/> \\b</label> <label style="display: flex; align-items: center; gap: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); cursor: pointer; user-select: none;"><input data-testid="find-regex-toggle" type="checkbox"/> .*</label></div> <div style="display: flex; gap: var(--tandem-space-2); align-items: center;"><input data-testid="replace-input" type="text" placeholder="Replace with…" aria-label="Replace with" style="
|
|
200
|
+
flex: 1; padding: 4px 8px; font-size: var(--tandem-text-sm);
|
|
201
|
+
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
202
|
+
background: var(--tandem-surface); color: var(--tandem-fg); outline: none;
|
|
203
|
+
"/> <button data-testid="replace-btn">Replace</button> <button data-testid="replace-all-btn"><!></button></div> <!> <!></div>`);function Q6(n,e){Pe(e,!0);let t=st(e,"tabs",19,()=>[]),r=B("doc"),i=B(at([])),o=B(!1);le(()=>{t().length<=1&&f(r)==="tabs"&&(b(r,"doc"),b(i,[],!0),b(o,!1))});function s(P){const M=P.getXmlFragment("default"),O=[];function I(T){if(T instanceof In)O.push(T.toString());else{for(let R=0;R<T.length;R++){const V=T.get(R);(V instanceof In||V instanceof on)&&I(V)}T instanceof on&&T.nodeName!=="text"&&O.push(" ")}}return I(M),O.join("")}function a(P,M,O){const I=s(P),T=O?M:M.toLowerCase(),R=O?I:I.toLowerCase(),V=[];let se=0,he=0;for(;(he=R.indexOf(T,he))!==-1;){if(se++,V.length<3){const we=Math.max(0,he-30),ae=Math.min(I.length,he+T.length+30),Q=I.slice(we,ae).replace(/\s+/g," ").trim();V.push((we>0?"…":"")+Q+(ae<I.length?"…":""))}he+=T.length}return{count:se,snippets:V}}let l;ri(()=>clearTimeout(l));function c(P,M){if(clearTimeout(l),!P){b(i,[],!0),b(o,!1);return}b(o,!0),l=setTimeout(()=>{const O=[];for(const I of t()){if(!I.ydoc)continue;const{count:T,snippets:R}=a(I.ydoc,P,M);T>0&&O.push({tabId:I.id,fileName:I.fileName,count:T,snippets:R})}b(i,O,!0),b(o,!1)},300)}let d=B(""),u=B(""),h=B(!1),p=B(!1),m=B(!1),v=B(null),g=B(!1),y=B(null),w=B(null),_=B(0);const C=F(()=>(f(_),e.editor?Ma(e.editor.state):void 0)),A=F(()=>{var P;return((P=f(C))==null?void 0:P.matches.length)??0}),j=F(()=>{var P;return((P=f(C))==null?void 0:P.activeIndex)??-1});let H=B(null);le(()=>{var P;e.open&&((P=f(H))==null||P.focus())});let D=!1;le(()=>{const P=e.open&&!D;D=e.open,!(!P||!e.forceScope)&&(e.forceScope==="tabs"&&t().length>1?(b(r,"tabs"),c(f(d),f(h))):b(r,"doc"))}),le(()=>{const P=e.editor;if(!P||P.isDestroyed)return;const M=()=>bu(_);return P.on("update",M),P.on("selectionUpdate",M),()=>{P.isDestroyed||(P.off("update",M),P.off("selectionUpdate",M))}});function N(){if(f(r)==="tabs"){c(f(d),f(h));return}const P=e.editor;if(!P||!f(d)){b(v,null),P==null||P.commands.findClose();return}if(f(m))try{new RegExp(f(d)),b(v,null)}catch(O){b(v,O instanceof Error?O.message:"Invalid regex",!0);return}else b(v,null);const M={query:f(d),caseSensitive:f(h),wholeWord:f(p),regexMode:f(m)};P.commands.find(M)}function W(P){var M;b(r,P,!0),P==="tabs"?((M=e.editor)==null||M.commands.findClose(),c(f(d),f(h))):(b(i,[],!0),clearTimeout(l),N())}function ee(P){var M,O;if(P.key==="Enter"){P.preventDefault(),P.shiftKey?(M=e.editor)==null||M.commands.findPrev():(O=e.editor)==null||O.commands.findNext();return}P.key==="Escape"&&z()}function z(){var P;(P=e.editor)==null||P.commands.findClose(),e.onClose()}async function Y(){const P=e.editor;if(!P||!f(d)||f(g))return;const M=f(A);if(M>500&&!window.confirm(`Replace all ${M} occurrences? This cannot be undone as a single action.`))return;b(g,!0),b(w,null),b(y,{replaced:0,total:M},!0);const{replaced:O,partial:I}=await A6(P.view,f(u),(T,R)=>{b(y,{replaced:T,total:R},!0)});b(y,null),b(g,!1),I&&b(w,`Replaced ${O} of ${M}; re-run to continue`)}var te=xt(),ne=ye(te);{var q=P=>{var M=X6(),O=x(M);{var I=Ue=>{var Nt=j6(),Se=x(Nt),Xe=k(Se,2);K(()=>{G(Se,"aria-pressed",f(r)==="doc"),re(Se,`
|
|
204
|
+
padding: 2px var(--tandem-space-2); font-size: var(--tandem-text-xs);
|
|
205
|
+
border: 1px solid ${f(r)==="doc"?"var(--tandem-accent-border)":"var(--tandem-border)"};
|
|
206
|
+
border-radius: var(--tandem-r-pill);
|
|
207
|
+
background: ${f(r)==="doc"?"var(--tandem-accent-bg)":"var(--tandem-surface)"};
|
|
208
|
+
color: ${f(r)==="doc"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};
|
|
209
|
+
cursor: pointer;
|
|
210
|
+
`),G(Xe,"aria-pressed",f(r)==="tabs"),re(Xe,`
|
|
211
|
+
padding: 2px var(--tandem-space-2); font-size: var(--tandem-text-xs);
|
|
212
|
+
border: 1px solid ${f(r)==="tabs"?"var(--tandem-accent-border)":"var(--tandem-border)"};
|
|
213
|
+
border-radius: var(--tandem-r-pill);
|
|
214
|
+
background: ${f(r)==="tabs"?"var(--tandem-accent-bg)":"var(--tandem-surface)"};
|
|
215
|
+
color: ${f(r)==="tabs"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};
|
|
216
|
+
cursor: pointer;
|
|
217
|
+
`)}),L("click",Se,()=>W("doc")),L("click",Xe,()=>W("tabs")),S(Ue,Nt)};Z(O,Ue=>{t().length>1&&Ue(I)})}var T=k(O,2),R=x(T);gt(R,Ue=>b(H,Ue),()=>f(H));var V=k(R,2),se=x(V);{var he=Ue=>{var Nt=nn();K(()=>$(Nt,f(A)===0?"No matches":`${f(j)+1} / ${f(A)}`)),S(Ue,Nt)};Z(se,Ue=>{f(d)&&Ue(he)})}var we=k(V,2),ae=k(we,2),Q=k(ae,2),ie=k(T,2);{var de=Ue=>{var Nt=W6(),Se=x(Nt);K(()=>$(Se,f(v))),S(Ue,Nt)};Z(ie,Ue=>{f(v)&&Ue(de)})}var Ce=k(ie,2),_e=x(Ce),Oe=x(_e),Re=k(_e,2),tt=x(Re),Ve=k(Re,2),ce=x(Ve),Ie=k(Ce,2),ge=x(Ie),ze=k(ge,2),Ae=k(ze,2),be=x(Ae);{var nt=Ue=>{var Nt=nn();K(()=>$(Nt,`${f(y).replaced??""}/${f(y).total??""}`)),S(Ue,Nt)},kt=Ue=>{var Nt=nn("All");S(Ue,Nt)};Z(be,Ue=>{f(g)&&f(y)?Ue(nt):Ue(kt,-1)})}var yt=k(Ie,2);{var Cn=Ue=>{var Nt=K6(),Se=x(Nt);K(()=>$(Se,f(w))),S(Ue,Nt)};Z(yt,Ue=>{f(w)&&Ue(Cn)})}var ln=k(yt,2);{var co=Ue=>{var Nt=G6(),Se=x(Nt);{var Xe=ve=>{var ke=q6();S(ve,ke)},X=ve=>{var ke=J6();S(ve,ke)},U=ve=>{var ke=xt(),Be=ye(ke);dt(Be,17,()=>f(i),ja,(me,Te)=>{var rt=Y6(),Mt=x(rt),Tt=x(Mt),lt=k(Tt),He=x(lt),Qe=k(Mt,2);dt(Qe,17,()=>f(Te).snippets,ja,(bt,Yt)=>{var Vt=Z6(),cn=x(Vt);K(()=>$(cn,f(Yt))),S(bt,Vt)}),K(()=>{$(Tt,`${f(Te).fileName??""} `),$(He,`(${f(Te).count??""} ${f(Te).count===1?"match":"matches"})`)}),S(me,rt)}),S(ve,ke)};Z(Se,ve=>{f(o)?ve(Xe):f(d)&&f(i).length===0?ve(X,1):ve(U,-1)})}S(Ue,Nt)};Z(ln,Ue=>{f(r)==="tabs"&&Ue(co)})}K(()=>{re(R,`
|
|
218
|
+
flex: 1; padding: 4px 8px; font-size: var(--tandem-text-sm);
|
|
219
|
+
border: 1px solid ${f(v)?"var(--tandem-error)":"var(--tandem-border)"};
|
|
220
|
+
border-radius: var(--tandem-r-2); background: var(--tandem-surface);
|
|
221
|
+
color: var(--tandem-fg); outline: none;
|
|
222
|
+
`),we.disabled=f(A)===0,re(we,`background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); padding: 2px 6px; cursor: pointer; font-size: 12px; color: var(--tandem-fg-muted); opacity: ${f(A)===0?.4:1};`),ae.disabled=f(A)===0,re(ae,`background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); padding: 2px 6px; cursor: pointer; font-size: 12px; color: var(--tandem-fg-muted); opacity: ${f(A)===0?.4:1};`),ze.disabled=f(A)===0||f(g)||f(r)==="tabs",G(ze,"title",f(r)==="tabs"?"Replace is not available in Open tabs mode":void 0),re(ze,`
|
|
223
|
+
padding: 4px 10px; font-size: var(--tandem-text-xs); cursor: pointer;
|
|
224
|
+
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
225
|
+
background: var(--tandem-surface); color: var(--tandem-fg-muted);
|
|
226
|
+
opacity: ${f(A)===0||f(g)||f(r)==="tabs"?.4:1};
|
|
227
|
+
`),Ae.disabled=f(A)===0||f(g)||f(r)==="tabs",G(Ae,"title",f(r)==="tabs"?"Replace All is not available in Open tabs mode":void 0),re(Ae,`
|
|
228
|
+
padding: 4px 10px; font-size: var(--tandem-text-xs); cursor: pointer;
|
|
229
|
+
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
230
|
+
background: var(--tandem-surface); color: var(--tandem-fg-muted);
|
|
231
|
+
opacity: ${f(A)===0||f(g)||f(r)==="tabs"?.4:1};
|
|
232
|
+
`)}),L("keydown",M,ee),L("input",R,N),Uo(R,()=>f(d),Ue=>b(d,Ue)),L("click",we,()=>{var Ue;return(Ue=e.editor)==null?void 0:Ue.commands.findPrev()}),L("click",ae,()=>{var Ue;return(Ue=e.editor)==null?void 0:Ue.commands.findNext()}),L("click",Q,z),L("change",Oe,N),Ph(Oe,()=>f(h),Ue=>b(h,Ue)),L("change",tt,N),Ph(tt,()=>f(p),Ue=>b(p,Ue)),L("change",ce,N),Ph(ce,()=>f(m),Ue=>b(m,Ue)),Uo(ge,()=>f(u),Ue=>b(u,Ue)),L("click",ze,()=>{e.editor&&(E6(e.editor.view,f(u)),bu(_))}),L("click",Ae,Y),S(P,M)};Z(ne,P=>{e.open&&P(q)})}S(n,te),Le()}qe(["keydown","click","input","change"]);function qC(n,e,t,r={}){const{capture:i=!0}=r;function o(s){const a=n();a&&(s.target instanceof Node&&a.contains(s.target)||t(s))}for(const s of e)document.addEventListener(s,o,i);return()=>{for(const s of e)document.removeEventListener(s,o,i)}}function JC(n,e,t){const r=n.getMap(Ko);let i=null,o;for(const[l,c]of r.entries())if(c.type==="highlight"&&c.range.from===e.from&&c.range.to===e.to&&c.author==="user"&&c.status==="pending"&&c.content===""){i=l,o=c.color;break}if(i===null){const l=Fm(),c={id:l,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:t};return r.set(l,c),"added"}if(o===t)return r.delete(i),"removed";const s=Fm(),a={id:s,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:t};return n.transact(()=>{r.delete(i),r.set(s,a)}),"recolored"}const Kw=48,zp=8,$6=10;function eU({start:n,end:e,toolbarHeight:t,toolbarWidth:r,viewportHeight:i,viewportWidth:o}){const s=(n.left+e.right)/2,a=r/2,l=zp+a,c=Math.max(l,o-zp-a),d=Math.min(n.top,e.top)-$6-t,u=Math.max(Kw,i-t-zp);return{left:Math.min(Math.max(s,l),c),top:Math.min(Math.max(d,Kw),u)}}function tU(n,e){return n.on("selectionUpdate",e),()=>n.off("selectionUpdate",e)}var nU=E('<button type="button"><!></button>');function Ln(n,e){const t=st(e,"disabled",3,!1),r=st(e,"active",3,!1),i=st(e,"style",3,""),o=F(()=>{let v="1px solid transparent",g="transparent",y="var(--tandem-fg-muted)";return t()?(g="transparent",y="var(--tandem-fg-subtle)"):r()&&(g="var(--tandem-accent-bg)",v="1px solid var(--tandem-accent-border)",y="var(--tandem-accent-fg-strong)"),{border:v,background:g,color:y}}),s=F(()=>e.ariaLabel??(typeof e.label=="string"?e.label:void 0)),a=F(()=>f(s)??""),l=F(()=>t()&&e.disabledTitle?e.disabledTitle:e.shortcut?`${f(a)} (${e.shortcut})`:f(a)),c="height: 28px; padding: 0 8px; font-size: 12px; border-radius: var(--tandem-r-2); display: inline-flex; align-items: center; justify-content: center; gap: 5px;",d=F(()=>`${c} cursor: ${t()?"not-allowed":"pointer"}; ${i()}; border: ${f(o).border}; background: ${f(o).background}; color: ${f(o).color};`);var u=nU(),h=x(u);{var p=v=>{var g=xt(),y=ye(g);Bg(y,()=>e.children),S(v,g)},m=v=>{var g=nn();K(()=>$(g,e.label)),S(v,g)};Z(h,v=>{e.children?v(p):v(m,-1)})}K(()=>{G(u,"data-testid",e.testId),u.disabled=t(),G(u,"title",f(l)),G(u,"aria-label",f(s)),re(u,f(d))}),L("mousedown",u,function(...v){var g;(g=e.onMouseDown)==null||g.apply(this,v)}),L("click",u,function(...v){var g;(g=e.onClick)==null||g.apply(this,v)}),S(n,u)}qe(["mousedown","click"]);var rU=E('<button type="button"></button>'),iU=E('<div role="toolbar" aria-label="Selection tools"><div style="display: flex; align-items: center; gap: 1px; padding: 4px; border-bottom: 1px solid var(--tandem-border);"><!> <!> <div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px;"></div> <div style="display: inline-flex; gap: 3px; padding: 0 4px;" aria-label="Highlight colors"></div></div> <div style="padding: 6px 8px;"><textarea data-testid="popup-annotation-input" aria-label="Annotation text" placeholder="Write a note or instruction..." style="width: 100%; box-sizing: border-box; field-sizing: content; min-height: 28px; max-height: 120px; overflow-y: auto; resize: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg); font-size: 12px; padding: 4px 6px; outline: none; font-family: inherit;"></textarea></div> <div style="display: flex; justify-content: space-between; gap: 6px; padding: 4px 8px 6px;"><button type="button" data-testid="popup-note-submit" aria-label="Note to self" style="flex: 1; height: 28px; padding: 0 10px; border: 1px solid var(--tandem-border); background: transparent; color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); font-size: 12px; font-weight: 500; cursor: pointer;">Note to self</button> <button type="button" data-testid="popup-comment-submit" aria-label="Comment on selection" style="flex: 1; height: 28px; padding: 0 10px; border: 1px solid var(--tandem-author-user); background: transparent; color: var(--tandem-author-user); border-radius: var(--tandem-r-2); font-size: 12px; font-weight: 600; cursor: pointer;">Comment</button></div></div>');function oU(n,e){Pe(e,!0);let t=st(e,"selectionToolbar",3,!0),r=st(e,"suppressSelectionToolbar",3,!1),i=st(e,"requestCommentFocus",3,0),o=B(!1),s=B(null),a=B(null),l=B(""),c=B(null),d=B(null),u=B(0),h=B(0),p=B(at(window.innerHeight)),m=B(at(window.innerWidth));const v=Object.keys(gx),g=F(()=>!!e.editor&&!!e.ydoc&&f(o)),y=F(()=>t()&&!r()&&f(g)&&f(s)!==null),w=F(()=>f(l).trim());function _(q){const{from:P,to:M}=q.state.selection,O=P!==M;if(b(o,O),!O){b(s,null);return}try{const I=q.view.coordsAtPos(P),T=q.view.coordsAtPos(M),R=eU({start:I,end:T,toolbarHeight:f(u),toolbarWidth:f(h),viewportHeight:f(p),viewportWidth:f(m)});if(f(s)&&f(s).left===R.left&&f(s).top===R.top)return;b(s,R,!0)}catch{b(s,null)}}le(()=>{if(!e.editor)return;const q=e.editor;function P(){_(q)}const M=tU(q,P);return P(),M}),le(()=>{if(!e.editor||!f(s))return;const q=e.editor;let P=0;function M(){cancelAnimationFrame(P),P=requestAnimationFrame(()=>{b(p,window.innerHeight,!0),b(m,window.innerWidth,!0),_(q)})}window.addEventListener("resize",M);const O=qC(()=>f(a),["scroll"],()=>{document.activeElement!==f(d)&&N()});return()=>{cancelAnimationFrame(P),window.removeEventListener("resize",M),O()}}),le(()=>{const q=e.editor,P=f(a);if(!q||!P||!f(s))return;const M=()=>{if(document.activeElement===f(d))return;const I=P.getBoundingClientRect();b(u,I.height,!0),b(h,I.width,!0),_(q)};M();const O=new ResizeObserver(M);return O.observe(P),()=>O.disconnect()}),le(()=>{f(y)&&!f(c)&&j(),f(y)||(b(c,null),document.activeElement!==f(d)&&b(l,""))});let C=0;le(()=>{if(i()===C||(C=i(),i()===0||!e.editor))return;const{from:q,to:P}=e.editor.state.selection;q!==P&&(Dt(()=>j()),requestAnimationFrame(()=>{var M;return(M=f(d))==null?void 0:M.focus()}))}),le(()=>{if(!e.editor||!f(y))return;const q=e.editor,P=()=>{document.activeElement!==f(d)&&j()};return q.on("selectionUpdate",P),()=>{q.isDestroyed||q.off("selectionUpdate",P)}}),le(()=>{if(!f(y))return;function q(P){P.key==="Escape"&&(P.preventDefault(),N())}return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)});function A(q,P,M){if(!e.editor||!e.ydoc)return;const O=f(c)??e.editor.state.selection,{from:I,to:T}=O;if(I===T)return;const R=ki(e.editor.state.doc,Dn(I)),V=ki(e.editor.state.doc,Dn(T)),se=Fm(),we={id:se,author:"user",type:q,audience:q==="highlight"||q==="note"?"private":"outbound",range:{from:R,to:V},content:P,status:"pending",timestamp:Date.now()};e.ydoc.getMap(Ko).set(se,we),b(c,null)}function j(){if(!e.editor)return;const{from:q,to:P}=e.editor.state.selection;b(c,{from:q,to:P},!0)}function H(q){if(!e.editor||!e.ydoc)return;const P=f(c)??e.editor.state.selection,{from:M,to:O}=P;if(M===O)return;const I=ki(e.editor.state.doc,Dn(M)),T=ki(e.editor.state.doc,Dn(O));JC(e.ydoc,{from:I,to:T},q),b(c,null)}function D(q){return P=>{P.detail===0&&q(P)}}function N(){var q;b(o,!1),b(s,null),b(c,null),b(l,""),(q=e.editor)==null||q.chain().focus().run()}function W(){f(w)&&(A("comment",f(w)),N())}function ee(){A("note",f(w)),N()}function z(q){q.key==="Enter"&&!q.shiftKey?(q.preventDefault(),W()):q.key==="Escape"&&(q.preventDefault(),N())}var Y=xt(),te=ye(Y);{var ne=q=>{var P=iU(),M=x(P),O=x(M);Ln(O,{label:"B",ariaLabel:"Bold",style:"font-weight: 700; min-width: 28px;",onMouseDown:ae=>ae.preventDefault(),onClick:()=>{var ae;return(ae=e.editor)==null?void 0:ae.chain().focus().toggleBold().run()}});var I=k(O,2);Ln(I,{label:"I",ariaLabel:"Italic",style:"font-style: italic; min-width: 28px;",onMouseDown:ae=>ae.preventDefault(),onClick:()=>{var ae;return(ae=e.editor)==null?void 0:ae.chain().focus().toggleItalic().run()}});var T=k(I,4);dt(T,21,()=>v,ja,(ae,Q)=>{var ie=rU(),de=F(()=>D(()=>{var Ce;H(f(Q)),(Ce=e.editor)==null||Ce.chain().focus().run()}));K(()=>{G(ie,"data-testid",`popup-highlight-${f(Q)}`),G(ie,"aria-label",`Highlight ${f(Q)}`),G(ie,"title",`Highlight ${f(Q)}`),re(ie,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${fc[f(Q)]}; cursor: pointer; padding: 0;`)}),L("mousedown",ie,Ce=>{var _e;Ce.preventDefault(),H(f(Q)),(_e=e.editor)==null||_e.chain().focus().run()}),L("click",ie,function(...Ce){var _e;(_e=f(de))==null||_e.apply(this,Ce)}),S(ae,ie)});var R=k(M,2),V=x(R);G(V,"rows",1),gt(V,ae=>b(d,ae),()=>f(d));var se=k(R,2),he=x(se),we=k(he,2);gt(P,ae=>b(a,ae),()=>f(a)),K(()=>{re(P,`position: fixed; left: ${f(s).left}px; top: ${f(s).top}px; transform: translateX(-50%); display: flex; flex-direction: column; background: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-4); box-shadow: 0 1px 2px color-mix(in srgb, var(--tandem-fg) 4%, transparent), 0 8px 28px color-mix(in srgb, var(--tandem-fg) 10%, transparent); z-index: var(--tandem-z-modal); min-width: 260px; max-width: 320px;`),we.disabled=!f(w)}),L("keydown",V,z),Uo(V,()=>f(l),ae=>b(l,ae)),L("click",he,ee),L("click",we,W),S(q,P)};Z(te,q=>{f(y)&&f(s)&&q(ne)})}S(n,Y),Le()}qe(["mousedown","click","keydown"]);function sU(n,e=document.documentElement){const t=Math.max(0,Math.min(360,Math.round(n)));return e.style.setProperty("--tandem-accent-h",`${t}deg`),()=>e.style.removeProperty("--tandem-accent-h")}function aU(n){le(()=>sU(n()))}function jd(n){return[...n].sort((e,t)=>{const r=e.range.from-t.range.from;return r!==0?r:e.id<t.id?-1:e.id>t.id?1:0})}function ZC(n,e){if(!e)return-1;for(let t=0;t<n.length;t++)if(n[t].id===e)return t;return-1}function qw(n,e){if(n.length===0)return null;const t=ZC(n,e);return t===-1?n[0].id:n[(t+1)%n.length].id}function Jw(n,e){if(n.length===0)return null;const t=ZC(n,e);return t===-1?n[n.length-1].id:n[(t-1+n.length)%n.length].id}function lU(n,e=document.documentElement){return n?e.setAttribute("data-annotation-patterns","true"):e.removeAttribute("data-annotation-patterns"),()=>e.removeAttribute("data-annotation-patterns")}function cU(n){le(()=>lU(n()))}function dU(n){let e=B(at(new Map));return le(()=>{const t=n.getYdoc();if(!t){f(e).size>0&&b(e,new Map,!0);return}const r=t.getMap(kx),i=()=>{b(e,uU(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return f(e)}}}function uU(n){const e=new Map;n.forEach(t=>{const r=t;if(!r||typeof r!="object"||!r.annotationId)return;const i=e.get(r.annotationId)??[];i.push(r),e.set(r.annotationId,i)});for(const t of e.values())t.sort((r,i)=>r.timestamp-i.timestamp);return e}const fU=25;function hU(n=fU){const e=[];return{push(t){if(!(e.length&&e[e.length-1].filePath===t.filePath))for(e.push(t);e.length>n;)e.shift()},pop(){return e.pop()??null},peek(){return e.length?e[e.length-1]:null},size(){return e.length},clear(){e.length=0}}}function pU(n,e=()=>GA){let t=B(!1),r=B(!1);return le(()=>{const i=n();if(i==null){b(t,!1),b(r,!1);return}const o=Date.now()-i,s=e()-o;if(s<=0){b(t,!0);return}const a=setTimeout(()=>{b(t,!0)},s);return()=>clearTimeout(a)}),{get showBanner(){return f(t)&&!f(r)},dismiss(){b(r,!0)}}}function mU(n,e=document.documentElement){return e.setAttribute("data-density",n),()=>e.removeAttribute("data-density")}function gU(n){le(()=>mU(n()))}const Oa=200,Wc=600,vU=300;function Zw(n){const e=bx[n];try{const t=localStorage.getItem(e);if(t){const r=parseInt(t,10);if(Number.isFinite(r))return Math.max(Oa,Math.min(Wc,r));console.warn(`[tandem] ignoring non-numeric panel width for ${e}: ${t}`)}}catch(t){console.warn(`[tandem] localStorage unavailable reading ${e}:`,t)}return vU}function Yw(n){const{side:e}=n,t=bx[e];let r=B(at(n.initialWidth)),i=null;return le(()=>{!n.getVisible()&&i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),i=null,document.body.style.userSelect="",document.body.style.cursor="")}),le(()=>()=>{i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),document.body.style.userSelect="",document.body.style.cursor="",i=null)}),{get width(){return f(r)},handleResizeStart:a=>{a.preventDefault();const l=a.clientX,c=f(r);let d=c;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const u=p=>{const m=p.clientX-l,v=e==="left"?c+m:c-m;d=Math.max(Oa,Math.min(Wc,v)),b(r,d,!0)},h=()=>{if(document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h),i=null,document.body.style.userSelect="",document.body.style.cursor="",n.getVisible())try{localStorage.setItem(t,String(d))}catch(p){console.warn(`[tandem] failed to persist ${t}:`,p)}};i={move:u,up:h},document.addEventListener("mousemove",u),document.addEventListener("mouseup",h)},handleResizeStep:a=>{const l=Math.max(Oa,Math.min(Wc,f(r)+a));if(b(r,l,!0),n.getVisible())try{localStorage.setItem(t,String(l))}catch(c){console.warn(`[tandem] failed to persist ${t}:`,c)}}}}const yU={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 bU(n){const e=document.documentElement;return e.style.setProperty("--tandem-editor-font-family",yU[n]),()=>e.style.removeProperty("--tandem-editor-font-family")}function wU(n){le(()=>bU(n()))}function xU(){let n=B(!1);return{get fileDragOver(){return f(n)},handleEditorDragOver:i=>{var o;(o=i.dataTransfer)!=null&&o.types.includes("Files")&&(i.preventDefault(),b(n,!0))},handleEditorDragLeave:i=>{(i.currentTarget===i.target||!i.currentTarget.contains(i.relatedTarget))&&b(n,!1)},handleEditorDrop:async i=>{var a;if(b(n,!1),!((a=i.dataTransfer)!=null&&a.files.length))return;i.preventDefault();const o=i.dataTransfer.files[0],s=await Ax(o);try{const l=await fetch(`${Gn}${dx}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:o.name,content:s})});if(!l.ok){const c=await l.json().catch(()=>({message:"Upload failed"}));console.error("[useFileDrop] Upload failed:",l.status,c.message??c.error)}}catch{console.error("[useFileDrop] Server unreachable — file drop ignored")}}}}function Fp(n){return!!(n!=null&&n.query)}function kU(n,e=document.documentElement){return n?e.setAttribute("data-high-contrast","true"):e.removeAttribute("data-high-contrast"),()=>e.removeAttribute("data-high-contrast")}function _U(n){le(()=>kU(n()))}function SU(n,e,t,r){const i=new Map;let o=0,s=0;for(const a of n){const l=e(a);if(l){o++;try{const c=t(l.from);if(!Number.isFinite(c.top))continue;i.set(a.id,c.top-r)}catch{s++}}}return{positions:i,attempted:o,thrown:s}}function CU(n){let e=null;return{schedule(){e===null&&(e=requestAnimationFrame(()=>{e=null,n()}))},cancel(){e!==null&&(cancelAnimationFrame(e),e=null)}}}function TU(n){let e=B(at(new Map));function t(){if(!n.getEnabled()){f(e).size>0&&b(e,new Map,!0);return}const i=n.getEditor(),o=n.getLayerEl(),s=n.getYdoc();if(!i||!o||!s){f(e).size>0&&b(e,new Map,!0);return}const a=o.getBoundingClientRect().top,l=n.getAnnotations(),{positions:c,attempted:d,thrown:u}=SU(l,h=>Oc(h,i.state.doc,s),h=>i.view.coordsAtPos(h),a);d>0&&u===d&&console.warn(`[margin] coordsAtPos threw for all ${d} annotations — view may be detached`),!EU(f(e),c)&&b(e,c,!0)}const r=CU(t);return le(()=>{if(!n.getEnabled())return;const i=n.getEditor(),o=n.getLayerEl();if(!i||!o)return;const s=()=>r.schedule();i.on("transaction",s);const a=new ResizeObserver(()=>r.schedule());return a.observe(o),r.schedule(),()=>{i.off("transaction",s),a.disconnect(),r.cancel()}}),le(()=>{n.getAnnotations(),r.schedule()}),{get byId(){return f(e)}}}function EU(n,e){if(n.size!==e.size)return!1;for(const[t,r]of n){const i=e.get(t);if(i===void 0||Math.abs(i-r)>.5)return!1}return!0}function AU(n,e){return n.status!=="pending"||e==="tandem"?!0:n.author!=="claude"}function MU(){let n=B(at([]));const e=new Map,t=l=>{const c=e.get(l);c&&(clearTimeout(c),e.delete(l))},r=(l,c)=>{const d=e.get(l);d&&clearTimeout(d);const u=ub[c]??ub.info,h=setTimeout(()=>{b(n,f(n).filter(p=>p.id!==l),!0),e.delete(l)},u);e.set(l,h)},i=l=>{b(n,f(n).filter(c=>c.id!==l),!0),t(l)},o=`http://127.0.0.1:${Kf}${cA}`,s=new EventSource(o),a=l=>{if(l.dedupKey){const u=f(n).findIndex(h=>h.dedupKey===l.dedupKey);if(u!==-1){const h=f(n)[u];t(h.id);const p={...l,count:h.count+1},m=[...f(n)];m[u]=p,b(n,m,!0),r(p.id,p.severity);return}}const c={...l,count:1},d=[...f(n),c];for(;d.length>r2;){const u=d.shift();t(u.id)}b(n,d,!0),r(c.id,c.severity)};return s.onmessage=l=>{let c;try{c=JSON.parse(l.data)}catch{console.warn("[useNotifications] Malformed SSE data:",l.data);return}a(c)},s.onerror=()=>{s.readyState===EventSource.CLOSED&&console.warn("[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?")},ri(()=>{s.close();for(const l of e.values())clearTimeout(l);e.clear()}),{get toasts(){return f(n)},dismiss:i,push:a}}function OU(n){return n.isComposing||n.code!=="Comma"||n.shiftKey?!1:n.ctrlKey||n.metaKey}function DU(n){return n.isComposing||n.code!=="Comma"||!n.shiftKey?!1:n.ctrlKey||n.metaKey}function RU(n,e,t){if(n.length<2)return null;const o=(n.findIndex(s=>s.id===e)+(t?-1:1)+n.length)%n.length;return n[o].id}function NU(n,e,t){let r=null;rd(()=>{r=i=>{if(!i.ctrlKey&&!i.metaKey||i.key!=="Tab")return;const o=RU(n(),e(),i.shiftKey);o&&(i.preventDefault(),t(o))},window.addEventListener("keydown",r)}),ri(()=>{r&&window.removeEventListener("keydown",r)})}function IU(n,e){if(n.length===0||e<1||e>9)return null;const t=Math.min(e-1,n.length-1);return n[t].id}function Zr(n){if(n.isComposing)return!0;const e=n.target;return e?e.tagName==="INPUT"||e.tagName==="TEXTAREA":!1}function Gw(n,e){const t=new Set(e),r=n.filter(s=>t.has(s)),i=new Set(r),o=e.filter(s=>!i.has(s));return[...r,...o]}function PU(n,e,t,r,i="left"){const o=n.filter(u=>r.has(u)),s=o.indexOf(e),a=o.indexOf(t);if(s===-1||a===-1)return o;const l=[...o];l.splice(s,1);const c=l.indexOf(t),d=i==="right"?c+1:c;return l.splice(d,0,e),l}function LU(n){let e=B(at([]));le(()=>{const o=n().map(a=>a.id),s=Gw(f(e),o);(f(e).length!==s.length||f(e).some((a,l)=>a!==s[l]))&&b(e,s,!0)});const t=F(()=>{const i=n(),o=new Map(i.map(l=>[l.id,l])),s=i.map(l=>l.id);return Gw(f(e),s).map(l=>o.get(l)).filter(Boolean)});return{get orderedTabs(){return f(t)},reorder:(i,o,s="left")=>{if(i===o)return;const a=n(),l=new Set(a.map(c=>c.id));b(e,PU(f(e),i,o,l,s),!0)}}}function zU(n,e){let t=B(at((()=>{try{const r=localStorage.getItem(xd),i=KA.safeParse(r);return i.success?i.data:ob}catch(r){return console.warn(`[tandem] localStorage unavailable reading ${xd}:`,r),ob}})()));return le(()=>{const r=f(t);try{localStorage.setItem(xd,r)}catch(i){console.warn(`[tandem] failed to persist ${xd}:`,i)}}),le(()=>{const r=n(),i=f(t);if(r)try{r.getMap(um).set(e2,i)}catch(o){console.warn("[tandem] failed to broadcast tandem mode to Y.Map:",o)}}),le(()=>{const r=n(),i=e();if(r)try{r.getMap(um).set(t2,i)}catch(o){console.warn("[tandem] failed to broadcast dwell ms to Y.Map:",o)}}),{get tandemMode(){return f(t)},setTandemMode(r){b(t,r,!0)}}}const FU={system:"dark",dark:"light",light:"system"},BU={light:"Switch to system theme",dark:"Switch to light theme",system:"Switch to dark theme"},HU={s:14,m:16,l:18};function Xw(){try{return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}const fn={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:2,primaryTab:"annotations",panelOrder:"chat-editor-annotations",editorWidthPercent:100,selectionDwellMs:wx,showAuthorship:!0,reduceMotion:!1,textSize:"m",theme:"system",accentHue:275,editorFont:"serif",density:"cozy",defaultMode:"tandem",highContrast:!1,annotationPatterns:!1,selectionToolbar:!0,soloRailHidden:!0,leftRailTabs:["annotations","outline"],rightRailTabs:["annotations","chat"],degradedBannerDelayMs:3e4,sidecarRetryStrategy:"exponential",holdAnnotationsWhileOffline:!0,marginView:!1},VU=["annotations","chat","outline"];function Qw(n,e){if(Array.isArray(n)){const t=n.filter(r=>VU.includes(r));return t.length>0?t:e}return e}function UU(){let n;try{n=localStorage.getItem(yx)}catch{n=null}if(n)try{let e=JSON.parse(n);if((!e||typeof e!="object"||Array.isArray(e))&&(e={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:2}),e.schemaVersion!==2){const r=e.panelHidden===!0;let i=!1,o=!0;r?(i=!1,o=!1):e.layout==="three-panel"?(i=!0,o=!0):e.layout==="tabbed-left"&&(i=!0,o=!1),e={...e,leftPanelVisible:i,rightPanelVisible:o,schemaVersion:2},delete e.layout,delete e.panelHidden}let t=fn.leftRailTabs;if(!Array.isArray(e.leftRailTabs)){const r=e.leftSlot;(r==null?void 0:r.kind)==="outline"?(console.warn("[tandem] migrating legacy leftSlot.kind=outline → leftRailTabs"),t=["outline","annotations"]):(r==null?void 0:r.kind)==="side"&&console.warn("[tandem] migrating legacy leftSlot.kind=side → leftRailTabs")}return{leftPanelVisible:e.leftPanelVisible===!0,rightPanelVisible:e.rightPanelVisible!==!1,schemaVersion:2,primaryTab:e.primaryTab==="annotations"?"annotations":"chat",panelOrder:e.panelOrder==="annotations-editor-chat"?"annotations-editor-chat":"chat-editor-annotations",editorWidthPercent:Math.max(40,Math.min(100,Number(e.editorWidthPercent)||fn.editorWidthPercent)),selectionDwellMs:Math.max(Za,Math.min(Ya,Number(e.selectionDwellMs)||wx)),showAuthorship:e.showAuthorship===!1?!1:fn.showAuthorship,reduceMotion:typeof e.reduceMotion=="boolean"?e.reduceMotion:Xw(),textSize:e.textSize==="s"||e.textSize==="m"||e.textSize==="l"?e.textSize:fn.textSize,theme:e.theme==="light"||e.theme==="dark"||e.theme==="system"?e.theme:fn.theme,accentHue:typeof e.accentHue=="number"&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:fn.accentHue,editorFont:e.editorFont==="serif"||e.editorFont==="sans"||e.editorFont==="mono"?e.editorFont:fn.editorFont,density:e.density==="compact"||e.density==="cozy"||e.density==="spacious"?e.density:fn.density,defaultMode:e.defaultMode==="solo"||e.defaultMode==="tandem"?e.defaultMode:fn.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:fn.selectionToolbar,soloRailHidden:e.soloRailHidden===!1?!1:fn.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs=="number"&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:fn.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy==="exponential"||e.sidecarRetryStrategy==="constant-2s"||e.sidecarRetryStrategy==="manual"?e.sidecarRetryStrategy:fn.sidecarRetryStrategy,holdAnnotationsWhileOffline:typeof e.holdAnnotationsWhileOffline=="boolean"?e.holdAnnotationsWhileOffline:fn.holdAnnotationsWhileOffline,leftRailTabs:Qw(e.leftRailTabs,t),rightRailTabs:Qw(e.rightRailTabs,fn.rightRailTabs),marginView:e.marginView===!0}}catch(e){console.warn("[tandem] settings JSON is corrupt, resetting to defaults:",e)}return{...fn,reduceMotion:Xw()}}function jU(n,e){const t={...n,...e};return{...t,editorWidthPercent:Math.max(40,Math.min(100,t.editorWidthPercent)),selectionDwellMs:Math.max(Za,Math.min(Ya,t.selectionDwellMs)),accentHue:Number.isFinite(t.accentHue)?Math.max(0,Math.min(360,t.accentHue)):fn.accentHue,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,t.degradedBannerDelayMs)),leftRailTabs:t.leftRailTabs.length>0?t.leftRailTabs:fn.leftRailTabs,rightRailTabs:t.rightRailTabs.length>0?t.rightRailTabs:fn.rightRailTabs}}function WU(){let n=B(at(UU()));return{get settings(){return f(n)},updateSettings:t=>{const r=jU(f(n),t);try{localStorage.setItem(yx,JSON.stringify(r)),localStorage.setItem(_x,String(r.showAuthorship))}catch{}b(n,r,!0)}}}var Qc;class KU{constructor(){Ke(this,Qc,B(at(Nn()?window.__TANDEM_INITIAL_THEME__??null:null)))}get current(){return f(J(this,Qc))}set current(e){b(J(this,Qc),e,!0)}}Qc=new WeakMap;const Ah=new KU;let $w=!1;function Bp(n){Ah.current=n,typeof window<"u"&&(window.__TANDEM_INITIAL_THEME__=n)}function qU(){if($w||!Nn())return;$w=!0;let n=null;Wr(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]).then(({invoke:i})=>{n=i,i("get_app_theme").then(o=>{Bp(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] get_app_theme failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri API import failed:",i)}),Wr(async()=>{const{getCurrentWindow:i}=await import("./window-DePn7tLG.js").then(o=>o.w);return{getCurrentWindow:i}},__vite__mapDeps([0,1,2])).then(({getCurrentWindow:i})=>{i().onThemeChanged(({payload:o})=>{Bp(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] onThemeChanged subscribe failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri window API import failed:",i)});let e=!1;const t=setInterval(()=>{!document.hasFocus()||!n||n("get_app_theme").then(i=>{const o=i==="dark"?"dark":"light";Ah.current!==o&&(Bp(o),e=!1)}).catch(i=>{e||(console.warn("[useTauriTheme] theme poll failed (further errors suppressed):",i),e=!0)})},3e3),r=()=>clearInterval(t);window.addEventListener("pagehide",r,{once:!0})}function YC(){try{if(typeof window>"u")return"light";if(Nn()){const n=Ah.current;if(n==="dark"||n==="light")return n;const e=window.__TANDEM_INITIAL_THEME__;if(e==="dark"||e==="light")return e}return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(n){return console.warn("[Tandem] Theme detection failed, defaulting to light:",n),"light"}}function JU(n){return n==="system"?YC():n}function e1(n){try{const e=document.querySelector('meta[name="theme-color"]');e&&(e.content=n==="dark"?"#1c1c24":"#fafaf9")}catch{}}function ZU(n){const e=document.documentElement,t=JU(n);if(e.setAttribute("data-theme",t),e1(t),n!=="system")return()=>e.removeAttribute("data-theme");if(Nn())return()=>e.removeAttribute("data-theme");const r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>{const o=YC();e.setAttribute("data-theme",o),e1(o)};return r.addEventListener("change",i),()=>{r.removeEventListener("change",i),e.removeAttribute("data-theme")}}function YU(n){qU(),le(()=>{const e=n();return Ah.current,ZU(e)})}function GU(){try{return localStorage.getItem(Cx)==="true"}catch{return!1}}function XU(n){return n.author==="user"&&!n.id.startsWith(Tx)}function t1(){try{localStorage.setItem(Cx,"true")}catch{}}function QU(n,e,t){let r=B(at(GU())),i=B(0),o=0;const s=fk(),a=F(()=>t()==="welcome.md"),l=F(()=>!f(r)&&f(a)),c=Nn(),d=mk(()=>c&&f(l)),u=F(()=>!c||d.status!==null||d.error!==null),h=F(()=>c&&uk(d.status,s)),p=F(()=>f(u)?f(h)?4:3:1/0);return le(()=>{if(!f(l)||f(i)!==0)return;const y=n().filter(_=>_.id.startsWith(Tx));if(y.length===0)return;y.some(_=>_.status!=="pending")&&(o=Date.now(),b(i,1))}),le(()=>{if(!f(l)||f(i)!==1)return;n().some(XU)&&(o=Date.now(),b(i,2))}),le(()=>{if(!f(l)||f(i)!==2||!isFinite(f(p)))return;const g=e();if(!g)return;const y=()=>{Date.now()-o<2e3||g.isFocused&&(o=Date.now(),b(i,3))};return g.on("update",y),()=>{g.off("update",y)}}),le(()=>{if(!f(l)||!isFinite(f(p))||f(i)!==f(p))return;const g=setTimeout(()=>{t1(),b(r,!0)},3e3);return()=>clearTimeout(g)}),le(()=>{isFinite(f(p))&&f(i)>f(p)&&b(i,f(p),!0)}),{get tutorialActive(){return f(l)},get currentStep(){return f(i)},get coworkStatus(){return d.status},dismissTutorial:()=>{t1(),b(r,!0)},nextStep:()=>{o=Date.now(),b(i,Math.min(f(i)+1,f(p)),!0)}}}const $U="tandem://update-available",e8="tandem:updater-dismissed-v";function GC(n){return`${e8}${n}`}function XC(n){try{return window.localStorage.getItem(GC(n))==="1"}catch{return!1}}function t8(n){try{window.localStorage.setItem(GC(n),"1")}catch{}}let QC=B(null),If=B(null),fa=0,Hp=null,Wd=!1,Vp=0;function n1(){return fa}function gs(){return f(QC)}function $C(){return f(If)}function eT(n){n&&(t8(n),b(If,n,!0))}function tT(){if(fa+=1,fa===1&&Nn()){Wd=!1;const e=++Vp;(async()=>{try{const{listen:t}=await Wr(async()=>{const{listen:i}=await import("./event-CNdo2oXa.js");return{listen:i}},__vite__mapDeps([2,1]));if(Wd||e!==Vp||n1()===0)return;const r=await t($U,i=>{var s;const o=((s=i.payload)==null?void 0:s.version)??null;o&&(b(QC,o,!0),f(If)!==o&&b(If,null))});if(Wd||e!==Vp||n1()===0){r();return}Hp=r}catch(t){console.warn("[useUpdaterChannel] listen() failed:",t)}})()}let n=!1;return()=>{if(!n&&(n=!0,fa=Math.max(0,fa-1),fa===0)){Wd=!0;const e=Hp;if(Hp=null,e)try{e()}catch(t){console.warn("[useUpdaterChannel] unlisten threw:",t)}}}}function n8(){return le(()=>tT()),{get availableVersion(){return gs()},get showDot(){const n=gs();return!(!n||$C()===n||XC(n))},acknowledge(){eT(gs())}}}const r1=3e4;function r8(){let n=B(!1),e=null;function t(){e!==null&&(clearTimeout(e),e=null)}le(()=>{const i=tT();return()=>{t(),i()}});async function r(){if(!(!gs()||f(n))){b(n,!0),t(),e=setTimeout(()=>{e=null,b(n,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${r1}ms; re-arming CTA`)},r1);try{const{invoke:o}=await Wr(async()=>{const{invoke:s}=await import("./core-DhEqZVGG.js");return{invoke:s}},[]);await o("install_update"),t(),b(n,!1)}catch(o){console.warn("[useUpdaterBanner] install_update failed:",o),t(),b(n,!1)}}}return{get availableVersion(){return gs()},get installing(){return f(n)},get showBanner(){const i=gs();return!(!i||$C()===i||XC(i))},dismiss(){eT(gs())},install:r}}function i8(){let n=null;rd(()=>{let e=!1,t;Wr(async()=>{const{getCurrentWebview:r}=await import("./webview-Bhf-n_os.js");return{getCurrentWebview:r}},__vite__mapDeps([3,0,1,2])).then(({getCurrentWebview:r})=>{if(e)return;const i=r();let o=Sl;try{const d=localStorage.getItem(fb);if(d!==null){const u=Number(d);Number.isFinite(u)?o=Math.max(hb,Math.min(pb,u)):console.warn(`[tandem] ignoring invalid stored zoom: ${d}`)}}catch{}o!==Sl&&i.setZoom(o).catch(d=>{console.warn("[tandem] failed to restore zoom level:",d)});function s(d){try{localStorage.setItem(fb,String(d))}catch{}}const a=d=>{!(d.metaKey||d.ctrlKey)||d.key!=="0"||(d.preventDefault(),d.stopPropagation(),o=Sl,i.setZoom(Sl).catch(h=>{console.warn("[tandem] failed to reset zoom:",h)}),s(Sl))},l=.1,c=d=>{if(!(d.metaKey||d.ctrlKey))return;const h=d.key==="+"||d.key==="=",p=d.key==="-"||d.key==="_";if(!h&&!p)return;const m=h?o+l:o-l;o=Math.max(hb,Math.min(pb,Math.round(m*100)/100)),s(o)};window.addEventListener("keydown",a,{capture:!0}),window.addEventListener("keydown",c,{capture:!0}),t=()=>{window.removeEventListener("keydown",a,{capture:!0}),window.removeEventListener("keydown",c,{capture:!0})}}).catch(()=>{}),n=()=>{e=!0,t==null||t()}}),ri(()=>{n==null||n()})}function o8(n,e,t){return n.filter(r=>!e.has(r.id)&&!t.has(r.id))}function s8(){let n=B(at([])),e=B(null),t=B(!1),r=B("connecting"),i=B(0),o=B(null),s=B(at([])),a=B(null),l=B(!1),c=B(!1),d=B(!1),u=B(!1),h=B(!1),p=B(null),m=null,v=!1,g=null;const y=new Set,w=new Map,_=new Map,C=new Map;let A=!1;const j=q=>{const{ydoc:P}=q,M=P.getMap(Ko),O=()=>{const Q=[];M.forEach(ie=>{Q.push(il(ie,de=>{console.warn("[sanitize]",de)}))}),b(s,Q,!0)};M.observe(O),O();const I=P.getMap(xx);let T=null,R=!1;const V=()=>{const Q=I.get(fm),ie=(Q==null?void 0:Q.status)??null,de=(Q==null?void 0:Q.active)??!1;ie!==T&&(T=ie,b(a,ie,!0)),de!==R&&(R=de,b(l,de,!0))};I.observe(V),V();const se=P.getMap($d);let he=!1;const we=Q=>{if(!Q.keysChanged.has(Vh))return;const ie=se.get(Vh)===!0;ie!==he&&(he=ie,b(c,ie))};se.observe(we);const ae=se.get(Vh)===!0;return ae!==he&&(he=ae,b(c,ae)),()=>{M.unobserve(O),I.unobserve(V),se.unobserve(we)}},H=(q,P)=>{var he,we;const M=f(n),O=new Set(M.map(ae=>ae.id)),I=new Set(q.map(ae=>ae.id));for(const ae of M)y.delete(ae.id),w.delete(ae.id);for(const[ae,Q]of w)I.has(ae)||((he=C.get(ae))==null||he(),C.delete(ae),Q.provider.destroy(),Q.ydoc.destroy(),w.delete(ae),y.delete(ae));const T=o8(q,O,y),R=[];for(const ae of T){y.add(ae.id);const Q=new Di,ie=new x0({url:`ws://127.0.0.1:${ib}`,name:ae.id,document:Q});w.set(ae.id,{ydoc:Q,provider:ie});const de=Q.getMap($d),Ce=_e=>{if(!_e.keysChanged.has(kl)&&!_e.keysChanged.has(_l))return;const Oe=de.get(kl),Re=de.get(_l);Oe&&H(Oe,Re??null)};de.observe(Ce),C.set(ae.id,()=>de.unobserve(Ce)),R.push({...ae,ydoc:Q,provider:ie})}const V=M.filter(ae=>!I.has(ae.id));for(const ae of V){const Q=_.get(ae.id);Q&&(Q.cleanup(),_.delete(ae.id)),(we=C.get(ae.id))==null||we(),C.delete(ae.id),y.delete(ae.id),w.delete(ae.id),ae.provider.destroy(),ae.ydoc.destroy()}const se=M.filter(ae=>I.has(ae.id));if(b(n,[...se,...R],!0),P!==null){const ae=f(e);ae===null?b(e,P,!0):I.has(ae)&&V.length>0&&P===ae||b(e,P,!0)}};let D=null,N=null;{const q=new Di,P=new x0({url:`ws://127.0.0.1:${ib}`,name:$A,document:q});b(p,q,!0),N=P,P.on("status",({status:V})=>{b(t,V==="connected"),b(r,["connected","connecting","disconnected"].includes(V)?V:"connecting",!0),V==="connected"?(v=!0,b(i,0),b(o,null)):V==="disconnected"?f(o)===null&&b(o,Date.now(),!0):V==="connecting"&&(v&&b(i,f(i)+1),f(o)===null&&b(o,Date.now(),!0))});const M=q.getMap($d),O=V=>{if(V.keysChanged.has(Hh)){const se=M.get(Hh);se&&g&&se!==g&&(console.warn("[Tandem] Server restarted — refreshing documents"),b(h,!0),m&&clearTimeout(m),m=setTimeout(()=>{b(h,!1)},5e3)),se&&(g=se)}if(V.keysChanged.has(kl)||V.keysChanged.has(_l)){const se=M.get(kl),he=M.get(_l);se&&H(se,he??null)}V.keysChanged.has(Uh)&&b(d,M.get(Uh)===!0)};M.observe(O);const I=M.get(Hh);I&&(g=I);const T=M.get(kl),R=M.get(_l);T&&H(T,R??null),b(d,M.get(Uh)===!0),D=()=>{M.unobserve(O),m&&(clearTimeout(m),m=null),P.destroy(),q.destroy(),b(p,null),N=null},b(u,!0)}const W=F(()=>f(n).find(q=>q.id===f(e))??null),ee=F(()=>{var q;return((q=f(W))==null?void 0:q.ydoc)??null}),z=CE(()=>{le(()=>{f(ee);const q=f(W);for(const P of _.values())P.cleanup();if(_.clear(),q){const P=j(q);_.set(q.id,{cleanup:P})}else b(s,[],!0),b(a,null),b(l,!1),b(c,!1)})});return{get tabs(){return f(n)},get activeTabId(){return f(e)},setActiveTabId:q=>{b(e,q,!0)},handleTabClose:q=>{if(f(e)===q){const P=f(n),M=P.findIndex(I=>I.id===q),O=P.filter(I=>I.id!==q);O.length===0?b(e,null):b(e,O[Math.min(M,O.length-1)].id,!0)}fetch(`http://127.0.0.1:${Kf}${dA}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:q})}).then(P=>{P.ok||console.warn("[Tandem] Server rejected close:",P.status)}).catch(P=>{console.warn("[Tandem] Failed to close document on server:",P)})},get connected(){return f(t)},get connectionStatus(){return f(r)},get reconnectAttempts(){return f(i)},get disconnectedSince(){return f(o)},get annotations(){return f(s)},get claudeStatus(){return f(a)},get claudeActive(){return f(l)},get readOnly(){return f(c)},get storeReadOnly(){return f(d)},get bootstrapYdoc(){return f(p)},get ready(){return f(u)},get serverRestarted(){return f(h)},destroy:()=>{if(!A){A=!0,z();for(const q of _.values())q.cleanup();_.clear();for(const q of C.values())q();C.clear();for(const q of w.values())q.provider.destroy(),q.ydoc.destroy();w.clear(),y.clear();for(const q of f(n))q.provider.destroy(),q.ydoc.destroy();D==null||D(),b(n,[],!0),b(s,[],!0),b(e,null),b(u,!1)}},reconnect(){N==null||N.connect();for(const q of f(n))q.provider.connect()}}}const a8=6;function l8(n,e={}){const t=e.gap??a8,r=new Map;if(n.length===0)return r;const i=n.map((s,a)=>({...s,idx:a})).sort((s,a)=>s.top-a.top||s.idx-a.idx);let o=Number.NEGATIVE_INFINITY;for(const s of i){if(!Number.isFinite(s.top))continue;const a=Math.max(s.top,o);r.set(s.id,a),typeof s.height=="number"&&Number.isFinite(s.height)&&s.height>0&&(o=a+s.height+t)}return r}function c8(n,e){const t=[];for(const r of n.keys())e.has(r)||t.push(r);for(const r of t)n.delete(r);return t.length}var d8=E("<div><!></div>"),u8=E("<div></div>");function i1(n,e){Pe(e,!0);const t=F(()=>e.annotations.filter(a=>e.positions.has(a.id)&&a.status==="pending"));let r=B(at(new Map));const i=F(()=>{const a=f(t).map(l=>({id:l.id,top:e.positions.get(l.id)??0,height:f(r).get(l.id)}));return l8(a)});le(()=>{const a=new Set(f(t).map(l=>l.id));Dt(()=>{c8(f(r),a)>0&&b(r,new Map(f(r)),!0)})});function o(a,l){if(!Number.isFinite(l)||l<=0)return;const c=f(r).get(a);if(c!==void 0&&Math.abs(c-l)<.5)return;const d=new Map(f(r));d.set(a,l),b(r,d,!0)}var s=u8();dt(s,21,()=>f(t),a=>a.id,(a,l)=>{const c=F(()=>f(i).get(f(l).id)??e.positions.get(f(l).id)??0),d=F(()=>dh(f(l),e.repliesById.get(f(l).id)));var u=d8(),h=x(u);{let p=F(()=>f(l).id===e.activeAnnotationId),m=F(()=>f(l).author!=="user"?e.onAccept:void 0),v=F(()=>f(l).author!=="user"?e.onDismiss:void 0),g=F(()=>f(l).author==="user"?e.onRemove:void 0),y=F(()=>f(l).type==="note"?e.onSendToClaude:void 0);Bm(h,{get annotation(){return f(l)},get replies(){return f(d)},get isReviewTarget(){return f(p)},onClick:()=>e.onClick(f(l)),get onAccept(){return f(m)},get onDismiss(){return f(v)},get onRemove(){return f(g)},get onSendToClaude(){return f(y)},get onEdit(){return e.onEdit},get onReply(){return e.onReply}})}K(()=>{G(u,"data-testid",`margin-bubble-${f(l).id??""}`),G(u,"data-margin-bubble-reply-count",f(d).length),re(u,`position: absolute; top: ${f(c)??""}px; ${e.side??""}: 0; width: ${e.width??""}px; pointer-events: auto;`)}),tA(u,"clientHeight",p=>o(f(l).id,p)),S(a,u)}),K(()=>{G(s,"data-testid",`margin-column-${e.side??""}`),G(s,"aria-label",e.side==="left"?"Note bubbles":"Comment bubbles"),re(s,`position: absolute; top: 0; ${e.side??""}: ${e.edgeInset??""}px; width: ${e.width??""}px; pointer-events: none;`)}),S(n,s),Le()}function Rr(n,e){function t(r){n.contains(r.target)||e(r)}return document.addEventListener("mousedown",t),{destroy(){document.removeEventListener("mousedown",t)}}}var f8=E('<label><input type="checkbox" style="accent-color: var(--tandem-accent);"/> </label>'),h8=E("<div></div>"),p8=E(`<div class="rail-tab-picker" style="display: flex; align-items: center;"><button aria-label="Configure tabs" style="
|
|
233
|
+
width: 22px; height: 22px; border: none; background: transparent;
|
|
234
|
+
cursor: pointer; border-radius: var(--tandem-r-2);
|
|
235
|
+
color: var(--tandem-fg-subtle); font-size: 14px; line-height: 1;
|
|
236
|
+
display: flex; align-items: center; justify-content: center;
|
|
237
|
+
padding: 0;
|
|
238
|
+
">+</button> <!></div>`);function o1(n,e){Pe(e,!0);let t=st(e,"disabledTabs",19,()=>[]),r=st(e,"testIdPrefix",3,""),i=B(!1),o=B(null),s=B(null);const a=[{id:"annotations",label:"Annotations"},{id:"chat",label:"Chat"},{id:"outline",label:"Outline"}];function l(m){if(t().includes(m))return;const v=e.enabledTabs.includes(m)?e.enabledTabs.filter(g=>g!==m):[...e.enabledTabs,m];v.length>0&&e.onTabsChange(v)}function c(m){if(m.stopPropagation(),f(i)){b(i,!1);return}if(f(o)){const v=f(o).getBoundingClientRect();b(s,{top:v.bottom+4,right:window.innerWidth-v.right},!0)}b(i,!0)}le(()=>{f(i)||b(s,null)});var d=p8(),u=x(d);gt(u,m=>b(o,m),()=>f(o));var h=k(u,2);{var p=m=>{var v=h8();dt(v,21,()=>a,ja,(g,y)=>{const w=F(()=>e.enabledTabs.length===1&&e.enabledTabs.includes(f(y).id)),_=F(()=>t().includes(f(y).id)||f(w));var C=f8(),A=x(C),j=k(A);K(H=>{G(C,"title",f(_)?"Each rail must keep at least one tab":void 0),re(C,`
|
|
239
|
+
display: flex; align-items: center; gap: var(--tandem-space-2);
|
|
240
|
+
padding: var(--tandem-space-1) var(--tandem-space-2);
|
|
241
|
+
cursor: ${f(_)?"not-allowed":"pointer"}; border-radius: var(--tandem-r-2);
|
|
242
|
+
font-size: var(--tandem-text-sm); color: ${f(_)?"var(--tandem-fg-subtle)":"var(--tandem-fg)"};
|
|
243
|
+
opacity: ${f(_)?.5:1};
|
|
244
|
+
`),G(A,"data-testid",`${r()}rail-tab-picker-${f(y).id}`),ti(A,H),A.disabled=f(_),$(j,` ${f(y).label??""}`)},[()=>e.enabledTabs.includes(f(y).id)]),L("change",A,()=>l(f(y).id)),S(g,C)}),K(()=>{G(v,"data-testid",`${r()}rail-tab-picker-dropdown`),re(v,`
|
|
245
|
+
position: fixed; top: ${f(s).top??""}px; right: ${f(s).right??""}px;
|
|
246
|
+
z-index: var(--tandem-z-dropdown, 200);
|
|
247
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
248
|
+
border-radius: var(--tandem-r-3); box-shadow: var(--tandem-shadow-2);
|
|
249
|
+
padding: var(--tandem-space-2); min-width: 140px;
|
|
250
|
+
`)}),S(m,v)};Z(h,m=>{f(i)&&f(s)&&m(p)})}lc(d,(m,v)=>Rr==null?void 0:Rr(m,v),()=>()=>b(i,!1)),K(()=>{G(u,"data-testid",`${r()}rail-tab-picker-btn`),G(u,"aria-expanded",f(i))}),L("click",u,c),S(n,d),Le()}qe(["click","change"]);const s1=n=>{console.warn("[sanitize]",n)};function m8(n,e,t){if(n.suggestedText===void 0)return!1;const r=n.suggestedText,i=Oc(n,e.state.doc,t);if(!i)return console.warn("[SidePanel] Could not resolve range for suggestion",n.id),!1;try{e.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,r).run()}catch(o){return console.error("[SidePanel] Editor mutation failed for suggestion",n.id,o),!1}return!0}function g8({getYdoc:n,getEditor:e,getAnnotations:t,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:o}){let s=B(0),a=B(at(new Set));const l=new Map;ri(()=>{for(const w of l.values())clearTimeout(w);l.clear()});function c(){return t().filter(Tu)}function d(){const w=c();return w.length>0?w[f(s)]??null:null}function u(w,_){const C=n();if(!C)return;const A=C.getMap(Ko),j=A.get(w);if(!j||j.status!=="pending")return;const H=il(j,s1);if(A.set(w,{...H,status:_}),_==="accepted"&&H.suggestedText!==void 0){const D=e();if(D&&!m8(H,D,C)){A.set(w,{...H,status:"pending"});return}}b(a,new Set(f(a)).add(w),!0)}function h(w){const _=l.get(w);_&&clearTimeout(_),l.set(w,setTimeout(()=>{l.delete(w);const C=new Set(f(a));C.delete(w),b(a,C,!0)},3e3))}function p(w){const _=l.get(w);_&&(clearTimeout(_),l.delete(w));const C=new Set(f(a));C.delete(w),b(a,C,!0)}function m(w){const _=n();if(!_)return!1;const C=_.getMap(Ko),A=C.get(w);if(!A||A.status==="pending")return p(w),!1;const j=il(A,s1),H=e();if(j.status==="accepted"&&j.suggestedText!==void 0&&H)try{const D=j.suggestedText,N=j.textSnapshot;if(typeof D=="string"&&typeof N=="string"){const W=Oc(j,H.state.doc,_);if(!W)return console.warn(`[undo] Cannot resolve range for annotation ${w}, skipping`),h(w),!1;if(H.state.doc.textBetween(W.from,W.to)!==D)return console.warn(`[undo] Text changed since accept for annotation ${w}, skipping`),h(w),!1;H.chain().focus().deleteRange({from:W.from,to:W.to}).insertContentAt(W.from,N).run()}}catch(D){return console.warn(`[undo] Failed to revert text for annotation ${w}:`,D),h(w),!1}return C.set(w,{...j,status:"pending"}),p(w),!0}function v(w){u(w,"accepted")}function g(w){u(w,"dismissed")}function y(w){const _=e();if(!_)return;const C=Oc(w,_.state.doc,n());if(!C)return;_.chain().focus().setTextSelection({from:C.from,to:C.to}).run();const A=_.view.domAtPos(C.from),j=A.node instanceof HTMLElement?A.node:A.node.parentElement;j==null||j.scrollIntoView({behavior:i(),block:"center"})}return le(()=>{var A;const w=c(),_=((A=w[f(s)])==null?void 0:A.id)??null,C=(o==null?void 0:o())??null;if(C===null){r(_);return}w.some(j=>j.id===C)||r(_)}),le(()=>{const w=c();f(s)>=w.length&&b(s,Math.max(0,w.length-1),!0)}),{resolveAnnotation:u,undoResolveAnnotation:m,handleAccept:v,handleDismiss:g,scrollToAnnotation:y,getRecentlyResolved:()=>f(a),getReviewIndex:()=>f(s),getReviewTargets:c,getActiveReviewAnn:d}}var v8=Kr('<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>'),y8=Kr('<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>'),b8=E('<button type="button" role="menuitem"> </button>'),w8=E(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
251
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
252
|
+
border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
|
|
253
|
+
gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),x8=Kr('<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>'),k8=Kr('<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>'),_8=Kr('<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>'),S8=Kr('<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>'),C8=E(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
254
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
255
|
+
border-radius: var(--tandem-r-3); padding: 6px;
|
|
256
|
+
display: flex; align-items: center; gap: 4px;
|
|
257
|
+
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;
|
|
258
|
+
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
259
|
+
background: var(--tandem-surface); color: var(--tandem-fg);
|
|
260
|
+
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;
|
|
261
|
+
border: 1px solid var(--tandem-accent-border); background: transparent;
|
|
262
|
+
color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
|
|
263
|
+
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;
|
|
264
|
+
border: 1px solid var(--tandem-border); background: transparent;
|
|
265
|
+
color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),T8=Kr('<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>'),E8=E('<div style="display: flex; align-items: center; gap: 2px;"><!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <!> <!> <!> <!> <div style="position: relative;" role="presentation"><!> <!></div> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <!> <!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <div style="position: relative;" role="presentation"><!> <!></div> <!> <!></div>');function A8(n,e){Pe(e,!0);const t=st(e,"disabled",3,!1),r=[1,2,3],i={1:700,2:600,3:500};let o=B(0),s=B(!1),a=B(!1),l=B(""),c=B(null);le(()=>{const T=e.editor;if(!T||T.isDestroyed)return;const R=()=>{T.isDestroyed||bu(o)};return T.on("transaction",R),()=>{T.isDestroyed||T.off("transaction",R)}}),le(()=>{var T,R;f(a)&&((T=f(c))==null||T.focus(),(R=f(c))==null||R.select())});function d(T){for(const R of r)if(T.isActive("heading",{level:R}))return R;return null}const u=F(()=>e.editor?e.editor.isEditable:!1),h=F(()=>!f(u)||!!t()),p=F(()=>(f(o),e.editor?Ti.getState(e.editor.state):null)),m=F(()=>{var T,R;return!f(h)&&(((R=(T=f(p))==null?void 0:T.undoManager)==null?void 0:R.undoStack.length)??0)>0}),v=F(()=>{var T,R;return!f(h)&&(((R=(T=f(p))==null?void 0:T.undoManager)==null?void 0:R.redoStack.length)??0)>0}),g=F(()=>(f(o),e.editor?d(e.editor):null)),y=F(()=>{var T;return f(o),!!((T=e.editor)!=null&&T.isActive("bold"))}),w=F(()=>{var T;return f(o),!!((T=e.editor)!=null&&T.isActive("italic"))}),_=F(()=>{var T;return f(o),!!((T=e.editor)!=null&&T.isActive("strike"))}),C=F(()=>{var T;return f(o),!!((T=e.editor)!=null&&T.isActive("code"))}),A=F(()=>{var T;return f(o),!!((T=e.editor)!=null&&T.isActive("bulletList"))}),j=F(()=>{var T;return f(o),!!((T=e.editor)!=null&&T.isActive("orderedList"))}),H=F(()=>{var T;return f(o),!!((T=e.editor)!=null&&T.isActive("blockquote"))}),D=F(()=>{var T;return f(o),!!((T=e.editor)!=null&&T.isActive("codeBlock"))}),N=F(()=>{var T;return f(o),!!((T=e.editor)!=null&&T.isActive("link"))}),W=F(()=>(f(o),e.editor?f(h)||!e.editor.isActive("link")&&e.editor.state.selection.from===e.editor.state.selection.to:!0)),ee=F(()=>f(g)?`H${f(g)}`:"H");function z(T){return R=>{R.preventDefault(),T()}}function Y(T){return R=>{R.preventDefault(),!(!e.editor||e.editor.isDestroyed)&&(e.editor.chain().focus().toggleHeading({level:T}).run(),b(s,!1))}}function te(T){T.preventDefault(),e.editor&&(b(l,e.editor.getAttributes("link").href??"",!0),b(a,!0))}function ne(){if(!e.editor)return;const T=f(l).trim();T?e.editor.chain().focus().setLink({href:T}).run():e.editor.isActive("link")&&e.editor.chain().focus().unsetLink().run(),q()}function q(){b(a,!1),b(l,"")}function P(T){T.key==="Enter"?(T.preventDefault(),ne()):T.key==="Escape"&&(T.preventDefault(),q())}var M=xt(),O=ye(M);{var I=T=>{var R=E8(),V=x(R);{const be=yt=>{var Cn=v8();S(yt,Cn)};let nt=F(()=>!f(m)),kt=F(()=>z(()=>e.editor.commands.undo()));Ln(V,{ariaLabel:"Undo",shortcut:"Ctrl+Z",get disabled(){return f(nt)},get onMouseDown(){return f(kt)},style:"min-width: 30px; padding: 4px 6px;",children:be,$$slots:{default:!0}})}var se=k(V,2);{const be=yt=>{var Cn=y8();S(yt,Cn)};let nt=F(()=>!f(v)),kt=F(()=>z(()=>e.editor.commands.redo()));Ln(se,{ariaLabel:"Redo",shortcut:"Ctrl+Shift+Z",get disabled(){return f(nt)},get onMouseDown(){return f(kt)},style:"min-width: 30px; padding: 4px 6px;",children:be,$$slots:{default:!0}})}var he=k(se,4);{let be=F(()=>z(()=>e.editor.chain().focus().toggleBold().run()));Ln(he,{label:"B",shortcut:"Ctrl+B",get disabled(){return f(h)},get active(){return f(y)},get onMouseDown(){return f(be)},style:"font-weight: 700; min-width: 30px;"})}var we=k(he,2);{let be=F(()=>z(()=>e.editor.chain().focus().toggleItalic().run()));Ln(we,{label:"I",shortcut:"Ctrl+I",get disabled(){return f(h)},get active(){return f(w)},get onMouseDown(){return f(be)},style:"font-style: italic; min-width: 30px;"})}var ae=k(we,2);{let be=F(()=>z(()=>e.editor.chain().focus().toggleStrike().run()));Ln(ae,{label:"S",shortcut:"Ctrl+Shift+X",get disabled(){return f(h)},get active(){return f(_)},get onMouseDown(){return f(be)},style:"text-decoration: line-through; min-width: 30px;"})}var Q=k(ae,2);{let be=F(()=>z(()=>e.editor.chain().focus().toggleCode().run()));Ln(Q,{label:"<>",shortcut:"Ctrl+E",get disabled(){return f(h)},get active(){return f(C)},get onMouseDown(){return f(be)},style:"font-family: monospace; min-width: 30px;"})}var ie=k(Q,2),de=x(ie);{let be=F(()=>f(g)!==null);Ln(de,{get label(){return f(ee)},get disabled(){return f(h)},get active(){return f(be)},onMouseDown:nt=>{nt.preventDefault(),b(s,!f(s))},style:"min-width: 30px;"})}var Ce=k(de,2);{var _e=be=>{var nt=w8();dt(nt,20,()=>r,kt=>kt,(kt,yt)=>{var Cn=b8(),ln=F(()=>Y(yt)),co=x(Cn);K(()=>{re(Cn,`padding: 4px 12px; font-size: 13px; border: none;
|
|
266
|
+
border-radius: var(--tandem-r-2);
|
|
267
|
+
background: ${f(g)===yt?"var(--tandem-accent-bg)":"transparent"};
|
|
268
|
+
color: ${f(g)===yt?"var(--tandem-accent)":"var(--tandem-fg)"};
|
|
269
|
+
cursor: pointer; text-align: left;
|
|
270
|
+
font-weight: ${i[yt]??""}; white-space: nowrap;`),$(co,`Heading ${yt??""}`)}),L("mousedown",Cn,function(...Ue){var Nt;(Nt=f(ln))==null||Nt.apply(this,Ue)}),S(kt,Cn)}),S(be,nt)};Z(Ce,be=>{f(s)&&be(_e)})}lc(ie,(be,nt)=>Rr==null?void 0:Rr(be,nt),()=>()=>b(s,!1));var Oe=k(ie,4);{const be=kt=>{var yt=x8();S(kt,yt)};let nt=F(()=>z(()=>e.editor.chain().focus().toggleBulletList().run()));Ln(Oe,{ariaLabel:"Bullet list",shortcut:"Ctrl+Shift+8",get disabled(){return f(h)},get active(){return f(A)},get onMouseDown(){return f(nt)},style:"min-width: 30px; padding: 4px 6px;",children:be,$$slots:{default:!0}})}var Re=k(Oe,2);{const be=kt=>{var yt=k8();S(kt,yt)};let nt=F(()=>z(()=>e.editor.chain().focus().toggleOrderedList().run()));Ln(Re,{ariaLabel:"Ordered list",shortcut:"Ctrl+Shift+7",get disabled(){return f(h)},get active(){return f(j)},get onMouseDown(){return f(nt)},style:"min-width: 30px; padding: 4px 6px;",children:be,$$slots:{default:!0}})}var tt=k(Re,2);{const be=kt=>{var yt=_8();S(kt,yt)};let nt=F(()=>z(()=>e.editor.chain().focus().toggleBlockquote().run()));Ln(tt,{ariaLabel:"Blockquote",shortcut:"Ctrl+Shift+B",get disabled(){return f(h)},get active(){return f(H)},get onMouseDown(){return f(nt)},style:"min-width: 30px; padding: 4px 6px;",children:be,$$slots:{default:!0}})}var Ve=k(tt,4),ce=x(Ve);{const be=kt=>{var yt=S8();S(kt,yt)};let nt=F(()=>f(N)||f(a));Ln(ce,{ariaLabel:"Link",shortcut:"Ctrl+K",get disabled(){return f(W)},get active(){return f(nt)},onMouseDown:te,style:"min-width: 30px; padding: 4px 6px;",children:be,$$slots:{default:!0}})}var Ie=k(ce,2);{var ge=be=>{var nt=C8(),kt=x(nt);gt(kt,ln=>b(c,ln),()=>f(c));var yt=k(kt,2),Cn=k(yt,2);L("keydown",kt,P),Uo(kt,()=>f(l),ln=>b(l,ln)),L("mousedown",yt,ln=>{ln.preventDefault(),ne()}),L("mousedown",Cn,ln=>{ln.preventDefault(),q()}),S(be,nt)};Z(Ie,be=>{f(a)&&be(ge)})}lc(Ve,(be,nt)=>Rr==null?void 0:Rr(be,nt),()=>q);var ze=k(Ve,2);{let be=F(()=>z(()=>e.editor.chain().focus().setHorizontalRule().run()));Ln(ze,{label:"—",ariaLabel:"Horizontal rule",get disabled(){return f(h)},get onMouseDown(){return f(be)},style:"min-width: 30px;"})}var Ae=k(ze,2);{const be=kt=>{var yt=T8();S(kt,yt)};let nt=F(()=>z(()=>e.editor.chain().focus().toggleCodeBlock().run()));Ln(Ae,{ariaLabel:"Code block",get disabled(){return f(h)},get active(){return f(D)},get onMouseDown(){return f(nt)},style:"min-width: 30px; padding: 4px 6px;",children:be,$$slots:{default:!0}})}L("keydown",ie,be=>{be.key==="Escape"&&b(s,!1)}),L("keydown",Ve,be=>{be.key==="Escape"&&q()}),S(T,R)};Z(O,T=>{e.editor&&T(I)})}S(n,M),Le()}qe(["keydown","mousedown"]);var M8=E("<button></button>"),O8=E(`<div style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
271
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
272
|
+
border-radius: var(--tandem-r-3); padding: 6px; display: flex; gap: 4px;
|
|
273
|
+
z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-2);"><!> <button data-testid="color-picker-close" title="Close" aria-label="Close color picker" style="width: 24px; height: 24px; border-radius: var(--tandem-r-2);
|
|
274
|
+
border: 1px solid var(--tandem-border);
|
|
275
|
+
background: var(--tandem-surface-muted); cursor: pointer; padding: 0;
|
|
276
|
+
font-size: 13px; color: var(--tandem-fg-muted);
|
|
277
|
+
display: flex; align-items: center; justify-content: center;">✕</button></div>`),D8=E('<div style="display: flex; align-items: center; gap: 2px; position: relative;"><!> <button data-testid="toolbar-highlight-color-toggle" title="Choose highlight color"><span></span></button> <!></div>');function R8(n,e){Pe(e,!0);const t=[{value:"yellow",label:"Yellow"},{value:"green",label:"Green"},{value:"blue",label:"Blue"},{value:"pink",label:"Pink"}],r=st(e,"disabled",3,!1);let i=B("yellow"),o=B(!1),s=B(null);le(()=>{if(f(o))return qC(()=>f(s),["mousedown"],()=>{b(o,!1)},{capture:!1})});function a(g){g.preventDefault(),e.onHighlight(f(i))}function l(g){g.preventDefault(),b(o,!f(o))}function c(g){b(i,g,!0),b(o,!1)}var d=D8(),u=x(d);Ln(u,{label:"Highlight",testId:"toolbar-highlight-btn",get disabled(){return r()},disabledTitle:"Select text first",onMouseDown:a,style:"border-radius: var(--tandem-r-2) 0 0 var(--tandem-r-2); border-right: none;"});var h=k(u,2),p=x(h),m=k(h,2);{var v=g=>{var y=O8(),w=x(y);dt(w,17,()=>t,({value:C,label:A})=>C,(C,A)=>{let j=()=>f(A).value,H=()=>f(A).label;var D=M8();K(()=>{G(D,"data-testid",`toolbar-highlight-color-${j()}`),G(D,"title",H()),G(D,"aria-label",H()),re(D,`width: 24px; height: 24px; border-radius: var(--tandem-r-2);
|
|
278
|
+
border: ${j()===f(i)?"2px solid var(--tandem-fg)":"1px solid var(--tandem-border)"};
|
|
279
|
+
background: ${fc[j()]??""};
|
|
280
|
+
cursor: pointer; padding: 0;`)}),L("click",D,()=>c(j())),S(C,D)});var _=k(w,2);gt(y,C=>b(s,C),()=>f(s)),L("click",_,()=>b(o,!1)),S(g,y)};Z(m,g=>{f(o)&&g(v)})}K(()=>{h.disabled=r(),re(h,`padding: 4px 6px; font-size: 13px; border: 1px solid var(--tandem-border);
|
|
281
|
+
border-radius: 0 var(--tandem-r-2) var(--tandem-r-2) 0;
|
|
282
|
+
background: ${r()?"var(--tandem-surface-muted)":"var(--tandem-surface)"};
|
|
283
|
+
cursor: ${r()?"not-allowed":"pointer"};
|
|
284
|
+
display: flex; align-items: center;`),re(p,`display: inline-block; width: 12px; height: 12px; border-radius: var(--tandem-r-1);
|
|
285
|
+
background: ${fc[f(i)]??""};
|
|
286
|
+
border: 1px solid var(--tandem-border);`)}),L("mousedown",h,l),S(n,d),Le()}qe(["mousedown","click"]);var N8=E(`<div data-testid="formatting-bar" style="display: flex; align-items: center; height: var(--tandem-h-fmtbar, 36px);
|
|
287
|
+
padding: 0 var(--tandem-space-3);
|
|
288
|
+
border-bottom: 1px solid var(--tandem-border);
|
|
289
|
+
background: var(--tandem-surface-muted);
|
|
290
|
+
user-select: none; position: relative; z-index: 4;"><div style="flex: 1; display: flex; align-items: center; gap: 2px; overflow: hidden; min-width: 0;"><!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px; flex-shrink: 0;"></div> <!></div></div>`);function I8(n,e){Pe(e,!0);let t=B(0);le(()=>{const c=e.editor;if(!c||c.isDestroyed)return;const d=()=>{c.isDestroyed||bu(t)};return c.on("selectionUpdate",d),c.on("transaction",d),()=>{c.off("selectionUpdate",d),c.off("transaction",d)}});const r=F(()=>(f(t),!e.editor||e.editor.isDestroyed||!e.ydoc?!1:!e.editor.state.selection.empty));function i(c){if(!e.editor||!e.ydoc||e.editor.isDestroyed)return;const{state:d}=e.editor,{from:u,to:h}=d.selection;if(u===h)return;const p=ki(d.doc,Dn(u)),m=ki(d.doc,Dn(h));if(p===null||m===null){console.warn("[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded",{from:u,to:h});return}JC(e.ydoc,{from:p,to:m},c)}var o=N8(),s=x(o),a=x(s);A8(a,{get editor(){return e.editor}});var l=k(a,4);{let c=F(()=>!f(r));R8(l,{get disabled(){return f(c)},onHighlight:i})}S(n,o),Le()}var P8=E('<span style="width: 6px; height: 6px; border-radius: var(--tandem-r-circle); background: var(--tandem-fg-subtle); display: inline-block;"></span>'),L8=E('<span style="width: 6px; height: 6px; border-radius: var(--tandem-r-circle); background: var(--tandem-success); display: inline-block;"></span>'),z8=E('<div data-testid="mode-toggle" role="group" aria-label="Claude collaboration mode" style="display: inline-flex; background: var(--tandem-surface-sunk); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); padding: 2px; gap: 2px;"><button data-testid="mode-solo-btn" title="Write undisturbed — Claude only responds when you message" class="svelte-14q5edy"><!> Solo</button> <button data-testid="mode-tandem-btn" title="Full collaboration — Claude reacts to selections and document changes" class="svelte-14q5edy"><!> Tandem</button></div>');function F8(n,e){Pe(e,!0);var t=z8(),r=x(t),i=x(r);{var o=c=>{var d=P8();S(c,d)};Z(i,c=>{e.tandemMode==="solo"&&c(o)})}var s=k(r,2),a=x(s);{var l=c=>{var d=L8();S(c,d)};Z(a,c=>{e.tandemMode==="tandem"&&c(l)})}K(()=>{G(r,"aria-pressed",e.tandemMode==="solo"),re(r,`height: 24px; padding: 0 10px; font-size: 12px; border: none; border-radius: var(--tandem-r-1); cursor: pointer;
|
|
291
|
+
background: ${e.tandemMode==="solo"?"var(--tandem-surface)":"transparent"};
|
|
292
|
+
color: ${e.tandemMode==="solo"?"var(--tandem-fg)":"var(--tandem-fg-muted)"};
|
|
293
|
+
font-weight: 500;
|
|
294
|
+
display: flex; align-items: center; gap: 5px;`),G(s,"aria-pressed",e.tandemMode==="tandem"),re(s,`height: 24px; padding: 0 10px; font-size: 12px; border: none; border-radius: var(--tandem-r-1); cursor: pointer;
|
|
295
|
+
background: ${e.tandemMode==="tandem"?"var(--tandem-surface)":"transparent"};
|
|
296
|
+
color: ${e.tandemMode==="tandem"?"var(--tandem-fg)":"var(--tandem-fg-muted)"};
|
|
297
|
+
font-weight: 500;
|
|
298
|
+
display: flex; align-items: center; gap: 5px;`)}),L("click",r,()=>e.onModeChange("solo")),L("click",s,()=>e.onModeChange("tandem")),S(n,t),Le()}qe(["click"]);const a1=(n,e=Dr,t=Dr,r=Dr)=>{const i=F(()=>t()?`Hide ${e()} panel`:`Show ${e()} panel`);var o=B8();let s;var a=x(o),l=k(x(a));K(()=>{s=Vg(o,1,"icon-btn svelte-12l7ydf",null,s,{active:t()}),G(o,"data-testid",`titlebar-toggle-${e()}`),G(o,"aria-label",f(i)),G(o,"aria-pressed",t()),G(o,"title",f(i)),G(l,"x",e()==="left"?1.5:9.5)}),L("click",o,function(...c){var d;(d=r())==null||d.apply(this,c)}),S(n,o)};var B8=E('<button type="button"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="1.5" y="2.5" width="13" height="11" rx="1.5" stroke="currentColor" stroke-width="1.4" fill="none"></rect><rect y="2.5" width="5" height="11" fill="currentColor" opacity="0.55"></rect></svg></button>'),H8=E('<span class="status-dot svelte-12l7ydf" title="Claude is connected" aria-label="Claude is connected"></span>'),V8=E('<button type="button" data-testid="toolbar-authorship-toggle"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="5.5" cy="8" r="3.2" fill="var(--tandem-author-user)"></circle><circle cx="10.5" cy="8" r="3.2" fill="var(--tandem-author-claude)" opacity="0.85"></circle></svg></button>'),U8=Kr('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="8" cy="8" r="3" stroke="currentColor" stroke-width="1.4" fill="none"></circle><g stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="8" y1="1.5" x2="8" y2="3"></line><line x1="8" y1="13" x2="8" y2="14.5"></line><line x1="1.5" y1="8" x2="3" y2="8"></line><line x1="13" y1="8" x2="14.5" y2="8"></line><line x1="3.2" y1="3.2" x2="4.3" y2="4.3"></line><line x1="11.7" y1="11.7" x2="12.8" y2="12.8"></line><line x1="3.2" y1="12.8" x2="4.3" y2="11.7"></line><line x1="11.7" y1="4.3" x2="12.8" y2="3.2"></line></g></svg>'),j8=Kr('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M13.5 10A5.5 5.5 0 0 1 6 2.5a6 6 0 1 0 7.5 7.5Z" fill="currentColor"></path></svg>'),W8=Kr('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M8 1.5a6.5 6.5 0 1 0 0 13Z" fill="currentColor"></path><circle cx="8" cy="8" r="6.5" stroke="currentColor" stroke-width="1.4" fill="none"></circle></svg>'),K8=E('<button type="button" class="icon-btn svelte-12l7ydf" data-testid="titlebar-theme-toggle"><!></button>'),q8=E('<button type="button" class="icon-btn svelte-12l7ydf" data-testid="titlebar-help-btn" aria-label="Help (?)" aria-keyshortcuts="?" title="Help (?)"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="8" cy="8" r="6.3" stroke="currentColor" stroke-width="1.4" fill="none"></circle><path d="M6 6.2A2 2 0 0 1 10 6.2c0 1.2-2 1.4-2 2.6" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" fill="none"></path><circle cx="8" cy="11.5" r="0.85" fill="currentColor"></circle></svg></button>'),J8=E('<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>'),Z8=E('<span class="settings-btn-wrap svelte-12l7ydf"><button type="button" class="icon-btn svelte-12l7ydf" data-testid="settings-btn" aria-keyshortcuts="Control+Comma" title="Settings (Ctrl+,)"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M8.97 1.5h-1.94a.6.6 0 0 0-.59.49l-.22 1.18a4.7 4.7 0 0 0-1.18.68l-1.13-.42a.6.6 0 0 0-.72.27l-.97 1.68a.6.6 0 0 0 .13.76l.91.77a4.7 4.7 0 0 0 0 1.36l-.91.77a.6.6 0 0 0-.13.76l.97 1.68a.6.6 0 0 0 .72.27l1.13-.42c.36.28.76.51 1.18.68l.22 1.18a.6.6 0 0 0 .59.49h1.94a.6.6 0 0 0 .59-.49l.22-1.18a4.7 4.7 0 0 0 1.18-.68l1.13.42a.6.6 0 0 0 .72-.27l.97-1.68a.6.6 0 0 0-.13-.76l-.91-.77a4.7 4.7 0 0 0 0-1.36l.91-.77a.6.6 0 0 0 .13-.76l-.97-1.68a.6.6 0 0 0-.72-.27l-1.13.42a4.7 4.7 0 0 0-1.18-.68l-.22-1.18A.6.6 0 0 0 8.97 1.5Z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round" fill="none"></path><circle cx="8" cy="8" r="2" stroke="currentColor" stroke-width="1.3" fill="none"></circle></svg></button> <!></span>'),Y8=Kr('<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>'),G8=Kr('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>'),X8=E('<div class="title-bar-controls svelte-12l7ydf"><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>'),Q8=E('<div class="title-bar svelte-12l7ydf" data-testid="title-bar"><div class="title-bar-left svelte-12l7ydf" data-tauri-drag-region=""><span class="brand svelte-12l7ydf" aria-label="Tandem"><img class="brand-mark svelte-12l7ydf" src="/favicon.png" alt="" width="20" height="20"/> <span class="brand-wordmark svelte-12l7ydf">Tandem</span></span></div> <div class="title-bar-drag svelte-12l7ydf" data-tauri-drag-region=""></div> <div class="title-bar-actions svelte-12l7ydf"><!> <!> <!> <span class="actions-divider svelte-12l7ydf" aria-hidden="true"></span> <!> <!> <!> <!> <!></div> <!></div>');function $8(n,e){Pe(e,!0);let t=st(e,"claudeActive",3,!1),r=st(e,"leftPanelVisible",3,!1),i=st(e,"rightPanelVisible",3,!1),o=st(e,"theme",3,"system"),s=st(e,"showAuthorship",3,!1),a=st(e,"settingsBtn",15,null),l=st(e,"updateAvailable",3,!1),c=B(null),d=B(!1),u=[],h=!0;rd(async()=>{if(Nn())try{const[{invoke:R},{getCurrentWindow:V}]=await Promise.all([Wr(()=>import("./core-DhEqZVGG.js"),[]),Wr(()=>import("./window-DePn7tLG.js").then(ae=>ae.w),__vite__mapDeps([0,1,2]))]);if(!h||(await R("setup_overlay_titlebar").catch(ae=>{console.error("[TitleBar] setup_overlay_titlebar failed:",ae)}),!h))return;const se=V();if(b(c,se,!0),b(d,await se.isMaximized(),!0),!h)return;const he=await se.onResized(async()=>{try{b(d,await se.isMaximized(),!0)}catch(ae){console.warn("[TitleBar] isMaximized check failed on resize:",ae)}});if(!h){he();return}u.push(he);const we=await se.onMoved(async()=>{try{b(d,await se.isMaximized(),!0)}catch(ae){console.warn("[TitleBar] isMaximized check failed on move:",ae)}});if(!h){we();return}u.push(we)}catch(R){console.error("[TitleBar] Window API initialization failed:",R)}}),ri(()=>{h=!1,u.forEach(R=>R())});async function p(){var R;try{await((R=f(c))==null?void 0:R.minimize())}catch(V){console.error("[TitleBar] minimize failed:",V)}}async function m(){var R;try{await((R=f(c))==null?void 0:R.toggleMaximize())}catch(V){console.error("[TitleBar] toggleMaximize failed:",V)}}async function v(){var R;try{await((R=f(c))==null?void 0:R.close())}catch(V){console.error("[TitleBar] close failed:",V)}}const g=F(()=>BU[o()]);le(()=>{e.onOpenSettingsModal});var y=Q8(),w=k(x(y),4),_=x(w);{var C=R=>{F8(R,{get tandemMode(){return e.tandemMode},get onModeChange(){return e.onModeChange}})};Z(_,R=>{e.tandemMode&&e.onModeChange&&R(C)})}var A=k(_,2);{var j=R=>{var V=H8();S(R,V)};Z(A,R=>{t()&&R(j)})}var H=k(A,2);{var D=R=>{var V=V8();let se;K(()=>{se=Vg(V,1,"icon-btn svelte-12l7ydf",null,se,{active:s()}),G(V,"aria-label",s()?"Hide authorship colors":"Show authorship colors"),G(V,"aria-pressed",s()),G(V,"title",s()?"Hide authorship colors":"Show authorship colors")}),L("click",V,()=>e.onAuthorshipChange(!s())),S(R,V)};Z(H,R=>{e.onAuthorshipChange&&R(D)})}var N=k(H,4);{var W=R=>{a1(R,()=>"left",r,()=>e.onToggleLeftPanel)};Z(N,R=>{e.onToggleLeftPanel&&R(W)})}var ee=k(N,2);{var z=R=>{a1(R,()=>"right",i,()=>e.onToggleRightPanel)};Z(ee,R=>{e.onToggleRightPanel&&R(z)})}var Y=k(ee,2);{var te=R=>{var V=K8(),se=x(V);{var he=Q=>{var ie=U8();S(Q,ie)},we=Q=>{var ie=j8();S(Q,ie)},ae=Q=>{var ie=W8();S(Q,ie)};Z(se,Q=>{o()==="light"?Q(he):o()==="dark"?Q(we,1):Q(ae,-1)})}K(()=>{G(V,"aria-label",f(g)),G(V,"title",f(g))}),L("click",V,function(...Q){var ie;(ie=e.onCycleTheme)==null||ie.apply(this,Q)}),S(R,V)};Z(Y,R=>{e.onCycleTheme&&R(te)})}var ne=k(Y,2);{var q=R=>{var V=q8();L("click",V,function(...se){var he;(he=e.onOpenHelp)==null||he.apply(this,se)}),S(R,V)};Z(ne,R=>{e.onOpenHelp&&R(q)})}var P=k(ne,2);{var M=R=>{var V=Z8(),se=x(V);gt(se,Q=>a(Q),()=>a());var he=k(se,2);{var we=Q=>{var ie=J8();S(Q,ie)},ae=F(()=>Nn()&&l());Z(he,Q=>{f(ae)&&Q(we)})}K(()=>G(se,"aria-label",l()?"Settings (update available)":"Settings")),L("click",se,function(...Q){var ie;(ie=e.onOpenSettings)==null||ie.apply(this,Q)}),S(R,V)};Z(P,R=>{e.onOpenSettings&&R(M)})}var O=k(w,2);{var I=R=>{var V=X8(),se=x(V),he=k(se,2),we=x(he);{var ae=de=>{var Ce=Y8();S(de,Ce)},Q=de=>{var Ce=G8();S(de,Ce)};Z(we,de=>{f(d)?de(ae):de(Q,-1)})}var ie=k(he,2);K(()=>{se.disabled=f(c)===null,G(he,"aria-label",f(d)?"Restore":"Maximize"),he.disabled=f(c)===null,ie.disabled=f(c)===null}),L("click",se,p),L("click",he,m),L("click",ie,v),S(R,V)},T=F(()=>Nn());Z(O,R=>{f(T)&&R(I)})}S(n,y),Le()}qe(["click"]);var ej=E('<span style="color: var(--tandem-fg-subtle);"> </span>'),tj=E('<span data-testid="save-indicator" style="color: var(--tandem-accent);">Saving...</span>'),nj=E('<button class="sb-held svelte-1esxubl" data-testid="sb-held" title="Show held annotations — switches to Tandem"><span class="held-dot svelte-1esxubl"></span> <strong class="svelte-1esxubl"> </strong> held</button>'),rj=E('<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);">Review Only</span>'),ij=E('<div style="display: flex; align-items: center; justify-content: space-between; padding: 0 var(--tandem-space-4); height: 28px; border-top: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); 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);"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span class="status-dot svelte-1esxubl"></span> <span> </span> <!> <!></div> <div style="display: flex; align-items: center; gap: var(--tandem-space-1); font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"><span>You:</span> <input data-testid="user-name-input" type="text" aria-label="Display name" title="Your display name" style="background: transparent; border: none; border-bottom: 1px dashed transparent; color: var(--tandem-fg-muted); font: inherit; font-family: var(--tandem-font-sans); font-size: var(--tandem-text-xs); width: 80px; outline: none; padding: 0 2px;"/></div> <!> <!> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span class="claude-dot svelte-1esxubl"></span> <span> </span></div></div>');function oj(n,e){Pe(e,!0);let t=st(e,"documentCount",3,0),r=st(e,"saving",3,!1);const i=2e3,o=Nv();let s=B(at(o.userName)),a=B(void 0);le(()=>{const O=o.userName;f(s)!==O&&document.activeElement!==f(a)&&b(s,O,!0)});let l=B(!1),c=B(0),d=Dt(()=>e.connected);le(()=>{const O=d;if(d=e.connected,e.connected&&!O){b(l,!0);const I=setTimeout(()=>{b(l,!1)},i);return()=>clearTimeout(I)}}),le(()=>{if(e.disconnectedSince==null){b(c,0);return}b(c,Math.floor((Date.now()-e.disconnectedSince)/1e3),!0);const O=setInterval(()=>{b(c,Math.floor((Date.now()-(e.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(O)});const u=F(()=>e.connectionStatus==="connecting"),h=F(()=>e.connected?"var(--tandem-success)":f(u)?"var(--tandem-warning)":"var(--tandem-error)"),p=F(()=>f(l)?"Reconnected":e.connectionStatus==="connected"?"Connected":e.connectionStatus==="connecting"?(()=>{const O=["Reconnecting…"];if(e.reconnectAttempts>0||f(c)>0){const I=[];e.reconnectAttempts>0&&I.push(`attempt ${e.reconnectAttempts}`),f(c)>0&&I.push(`${f(c)}s`),O.push(`(${I.join(", ")})`)}return O.join(" ")})():"Disconnected — check that the server is running"),m=F(()=>(e.heldCount??0)>0&&e.mode==="solo");function v(){o.setUserName(f(s))}var g=ij(),y=x(g),w=x(y),_=k(w,2),C=x(_),A=k(_,2);{var j=O=>{var I=ej(),T=x(I);K(()=>$(T,`${t()??""} doc${t()!==1?"s":""} open`)),S(O,I)};Z(A,O=>{t()>0&&O(j)})}var H=k(A,2);{var D=O=>{var I=tj();S(O,I)};Z(H,O=>{r()&&O(D)})}var N=k(y,2),W=k(x(N),2);gt(W,O=>b(a,O),()=>f(a));var ee=k(N,2);{var z=O=>{var I=nj(),T=k(x(I),2),R=x(T);K(()=>$(R,e.heldCount)),L("click",I,function(...V){var se;(se=e.onShowHeld)==null||se.apply(this,V)}),S(O,I)};Z(ee,O=>{f(m)&&O(z)})}var Y=k(ee,2);{var te=O=>{var I=rj();S(O,I)};Z(Y,O=>{e.readOnly&&O(te)})}var ne=k(Y,2),q=x(ne),P=k(q,2),M=x(P);K(()=>{re(w,`width: 8px; height: 8px; border-radius: 50%; background: ${f(h)??""}; display: inline-block; animation: ${f(u)?"tandem-reconnect-pulse 1.2s ease-in-out infinite":"none"};`),$(C,f(p)),yr(W,f(s)),G(W,"maxlength",qf),re(q,`width: 8px; height: 8px; border-radius: 50%; background: var(--tandem-author-claude); opacity: ${e.claudeActive?1:.4}; display: inline-block; transition: opacity 0.3s ease; animation: ${e.claudeActive?"tandem-status-pulse 1.5s ease-in-out infinite":"none"};`),re(P,`transition: color 0.3s ease; color: ${e.claudeActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"};`),$(M,e.claudeStatus?`Claude · ${e.claudeStatus}`:"Claude · idle")}),L("input",W,O=>{b(s,O.target.value,!0)}),Et("blur",W,v),L("keydown",W,O=>{O.key==="Enter"&&O.currentTarget.blur(),O.key==="Escape"&&(b(s,o.userName,!0),O.currentTarget.blur())}),S(n,g),Le()}qe(["input","keydown","click"]);function Up(n){return document.body.appendChild(n),{destroy(){n.remove()}}}var sj=E('<button role="menuitem" type="button" class="new-tab-menu-item svelte-7c4il0"><span class="new-tab-menu-badge svelte-7c4il0"> </span> <span class="new-tab-menu-label svelte-7c4il0"> </span></button>'),aj=E('<div class="new-tab-menu-divider svelte-7c4il0"></div>'),lj=E('<div role="dialog" aria-label="New tab" tabindex="-1" class="new-tab-menu svelte-7c4il0"><div class="new-tab-menu-header svelte-7c4il0">Recent files</div> <!> <!> <button role="menuitem" type="button" data-testid="palette-item-new-scratchpad" class="new-tab-menu-item new-tab-menu-action svelte-7c4il0">New Scratchpad</button> <button role="menuitem" type="button" class="new-tab-menu-item new-tab-menu-action svelte-7c4il0" style="padding-bottom: 8px;">Browse files…</button></div>');function cj(n,e){Pe(e,!0);function t(v){return v.replace(/[/\\]+$/,"").replace(/.*[/\\]/,"")}function r(v){var y;const g=((y=v.split(".").pop())==null?void 0:y.toLowerCase())??"";return g==="md"?"M":g==="docx"||g==="doc"?"W":g==="txt"?"T":g==="html"||g==="htm"?"H":g.slice(0,1).toUpperCase()||"?"}function i(v){var g,y;if(v.key==="Escape")v.preventDefault(),e.onClose();else if(v.key==="ArrowDown"){v.preventDefault();const w=o(),_=w.indexOf(document.activeElement);(g=w[(_+1)%w.length])==null||g.focus()}else if(v.key==="ArrowUp"){v.preventDefault();const w=o(),_=w.indexOf(document.activeElement);(y=w[(_-1+w.length)%w.length])==null||y.focus()}}function o(){var v;return Array.from(((v=f(s))==null?void 0:v.querySelectorAll("[role='menuitem']"))??[])}let s=B(null);function a(v){var y,w;const g=v.target;g&&((y=e.anchorEl)!=null&&y.contains(g)||(w=g.closest)!=null&&w.call(g,"[data-tauri-drag-region]")||e.onClose())}function l(){if(!f(s))return;if(!e.anchorEl){f(s).style.top="8px",f(s).style.left="8px",f(s).style.right="auto";return}const v=e.anchorEl.getBoundingClientRect(),g=f(s).offsetWidth,y=window.innerWidth,w=v.bottom+4,_=v.left;_+g>y-8?(f(s).style.right="8px",f(s).style.left="auto"):(f(s).style.left=`${_}px`,f(s).style.right="auto"),f(s).style.top=`${w}px`}le(()=>{var v;f(s)&&(l(),(v=o()[0])==null||v.focus())});var c=lj(),d=k(x(c),2);dt(d,17,()=>e.recentFiles,ja,(v,g)=>{var y=sj(),w=x(y),_=x(w),C=k(w,2),A=x(C);K((j,H)=>{G(y,"title",f(g)),$(_,j),$(A,H)},[()=>r(f(g)),()=>t(f(g))]),L("click",y,()=>e.onOpen(f(g))),S(v,y)});var u=k(d,2);{var h=v=>{var g=aj();S(v,g)};Z(u,v=>{e.recentFiles.length>0&&v(h)})}var p=k(u,2),m=k(p,2);lc(c,v=>Up==null?void 0:Up(v)),lc(c,(v,g)=>Rr==null?void 0:Rr(v,g),()=>a),gt(c,v=>b(s,v),()=>f(s)),L("keydown",c,i),L("click",p,function(...v){var g;(g=e.onNewScratchpad)==null||g.apply(this,v)}),L("click",m,function(...v){var g;(g=e.onBrowse)==null||g.apply(this,v)}),S(n,c),Le()}qe(["keydown","click"]);var dj=E('<span style="font-family: var(--tandem-font-mono); font-size: var(--tandem-text-2xs); color: var(--tandem-warning-fg-strong); background: var(--tandem-warning-bg); border: 1px solid var(--tandem-warning-border); padding: 0 4px; border-radius: var(--tandem-r-pill);">RO</span>'),uj=E('<div role="tab"><span>●</span> <span> </span> <span> </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">×</button></div>');function fj(n,e){Pe(e,!0);const t={md:"MD",txt:"TXT",html:"HTML",docx:"DOCX"},r={md:"var(--tandem-accent-fg-strong)",txt:"var(--tandem-fg-faint)",html:"var(--tandem-info-fg)",docx:"var(--tandem-suggestion-fg-strong)"},i=F(()=>r[e.tab.format]??"var(--tandem-fg-faint)");let o=B(!1),s=null;le(()=>{const{ydoc:C,readOnly:A}=e.tab;if(A){b(o,!1);return}const j=C.getXmlFragment("default"),H=C.getMap($d);let D=!1;const N=setTimeout(()=>{D=!0,s=H.get(ab)??0,b(o,!1)},500),W=()=>{D&&b(o,!0)};j.observeDeep(W);const ee=()=>{if(!D)return;const z=H.get(ab);z!==void 0&&z!==s&&(s=z,b(o,!1))};return H.observe(ee),()=>{clearTimeout(N),j.unobserveDeep(W),H.unobserve(ee)}});const a=F(()=>["display: flex","align-items: center","gap: 8px","padding: 0 12px","height: 100%","font-size: var(--tandem-text-sm)","cursor: pointer",`background: ${e.isActive?"var(--tandem-surface)":"transparent"}`,`color: ${e.isActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}`,"border-top: 0",`border-bottom: ${e.isActive?"2px solid var(--tandem-accent)":"2px solid transparent"}`,`border-left: ${e.dropIndicator==="left"?"2px solid var(--tandem-accent)":"2px solid transparent"}`,`border-right: ${e.dropIndicator==="right"?"2px solid var(--tandem-accent)":"2px solid transparent"}`,"margin-bottom: -1px","user-select: none","white-space: nowrap","transition: background 0.15s, color 0.15s, border-color 0.15s","flex-shrink: 0"].join("; "));let l=B(void 0);function c(){f(l)&&(f(l).style.color="var(--tandem-error)")}function d(){f(l)&&(f(l).style.color="var(--tandem-fg-muted)")}var u=uj();G(u,"tabindex",0);var h=x(u),p=k(h,2),m=x(p),v=k(p,2),g=x(v),y=k(v,2);{var w=C=>{var A=dj();S(C,A)};Z(y,C=>{e.tab.readOnly&&C(w)})}var _=k(y,2);gt(_,C=>b(l,C),()=>f(l)),K(C=>{G(u,"data-testid",`tab-${e.tab.id}`),G(u,"data-active",e.isActive),G(u,"aria-selected",e.isActive),G(u,"aria-label",e.tab.fileName),G(u,"draggable",e.draggable),re(u,f(a)),G(h,"data-testid",`unsaved-indicator-${e.tab.id}`),re(h,`color: var(--tandem-warning); font-size: 10px; visibility: ${f(o)?"visible":"hidden"};`),G(h,"aria-hidden",!f(o)),G(p,"data-testid",`tab-format-badge-${e.tab.id}`),G(p,"aria-label",`Format: ${e.tab.format}`),re(p,`font-family: var(--tandem-font-mono); font-size: 9px; font-weight: 600; letter-spacing: 0.03em; color: ${f(i)}; background: transparent; padding: 1px 4px; border: 1px solid ${f(i)}; border-radius: var(--tandem-r-pill); white-space: nowrap;`),$(m,C),G(v,"data-testid",`tab-name-${e.tab.id}`),G(v,"title",e.tab.filePath),re(v,`font-weight: ${e.isActive?500:400}; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),$(g,e.tab.fileName),G(_,"aria-label",`Close ${e.tab.fileName}`)},[()=>t[e.tab.format]??e.tab.format.toUpperCase()]),L("click",u,()=>e.onswitch(e.tab.id)),Et("dragstart",u,C=>e.ondragstart(C,e.tab.id)),Et("dragover",u,C=>e.ondragover(C,e.tab.id)),Et("drop",u,C=>e.ondrop(C,e.tab.id)),Et("dragend",u,function(...C){var A;(A=e.ondragend)==null||A.apply(this,C)}),Et("dragleave",u,function(...C){var A;(A=e.ondragleave)==null||A.apply(this,C)}),L("keydown",u,C=>e.onkeydown(C,e.tab.id)),L("click",_,C=>{C.stopPropagation(),e.onclose(e.tab.id)}),Et("dragover",_,C=>{C.stopPropagation(),C.preventDefault()}),Et("drop",_,C=>{C.stopPropagation(),C.preventDefault()}),Et("mouseenter",_,c),Et("mouseleave",_,d),S(n,u),Le()}qe(["click","keydown"]);var hj=E('<button data-testid="tab-scroll-left" style="display: flex; align-items: center; justify-content: center; width: 28px; min-width: 28px; background: linear-gradient(to right, var(--tandem-surface-muted) 70%, transparent); border: none; cursor: pointer; font-size: 12px; color: var(--tandem-fg-muted); padding: 0; z-index: 1;" title="Scroll tabs left">◀</button>'),pj=E('<button data-testid="tab-scroll-right" style="display: flex; align-items: center; justify-content: center; width: 28px; min-width: 28px; background: linear-gradient(to left, var(--tandem-surface-muted) 70%, transparent); border: none; cursor: pointer; font-size: 12px; color: var(--tandem-fg-muted); padding: 0; z-index: 1;" title="Scroll tabs right">▶</button>'),mj=E('<div style="position: relative; display: flex; align-items: stretch; background: var(--tandem-surface-muted); border-bottom: 1px solid var(--tandem-border); min-height: 32px; padding: 0 var(--tandem-space-3); z-index: var(--tandem-z-base);"><!> <div data-testid="tab-scroll-container" class="tab-scroll-hide" role="tablist" aria-label="Open documents" style="display: flex; align-items: stretch; gap: 2px; flex: 1; overflow-x: auto; overflow-y: hidden;"></div> <button data-testid="open-file-btn" title="Open file" style="background: none; border: none; border-radius: var(--tandem-r-2); cursor: pointer; font-size: 16px; line-height: 1; color: var(--tandem-fg-subtle); padding: 0 8px; margin-left: 4px; flex-shrink: 0;">+</button> <!> <!></div>');function gj(n,e){Pe(e,!0);const t=st(e,"reduceMotion",3,!1),r=F(()=>t()?"auto":"smooth");let i=B(!1),o=B(at([])),s=B(null),a=new Set;le(()=>{const M=new Set(e.tabs.map(O=>O.id));for(const O of a)M.has(O)||a.delete(O)});function l(M){a.has(M)||(a.add(M),e.onTabClose(M))}let c=B(void 0),d=B(!1),u=B(!1),h=B(null),p=B(null);function m(){b(h,null),b(p,null)}le(()=>{if(!f(h)&&!f(p))return;const M=new Set(e.tabs.map(O=>O.id));f(h)&&!M.has(f(h))&&b(h,null),f(p)&&!M.has(f(p).id)&&b(p,null)});function v(){const M=f(c);M&&(b(d,M.scrollLeft>0),b(u,M.scrollLeft+M.clientWidth<M.scrollWidth-1))}le(()=>{const M=f(c);if(!M)return;v(),M.addEventListener("scroll",v,{passive:!0});const O=new ResizeObserver(v);return O.observe(M),()=>{M.removeEventListener("scroll",v),O.disconnect()}}),le(()=>{e.tabs.length,v()}),le(()=>{if(!e.activeTabId||!f(c))return;const M=f(c).querySelector(`[data-testid="tab-${e.activeTabId}"]`);M&&M.scrollIntoView({inline:"nearest",block:"nearest",behavior:f(r)})});function g(M,O){b(h,O,!0),M.dataTransfer&&(M.dataTransfer.setData("text/plain",O),M.dataTransfer.effectAllowed="move")}function y(M,O){if(!f(h))return;if(M.preventDefault(),f(h)===O){b(p,null);return}const I=M.currentTarget.getBoundingClientRect(),T=I.left+I.width/2,R=M.clientX<T?"left":"right";b(p,{id:O,side:R},!0)}function w(M,O){var T;M.preventDefault();const I=f(h)||((T=M.dataTransfer)==null?void 0:T.getData("text/plain"))||"";if(I&&I!==O&&e.reorder){const R=M.currentTarget.getBoundingClientRect(),V=R.left+R.width/2,se=M.clientX<V?"left":"right";e.reorder(I,O,se)}m()}function _(){m()}function C(){b(p,null)}function A(M,O){if(!M.altKey||!e.reorder||M.key!=="ArrowLeft"&&M.key!=="ArrowRight")return;M.preventDefault();const I=e.tabs.findIndex(T=>T.id===O);I!==-1&&(M.key==="ArrowLeft"&&I>0?e.reorder(O,e.tabs[I-1].id):M.key==="ArrowRight"&&I<e.tabs.length-1&&e.reorder(e.tabs[I+1].id,O))}function j(){var M;(M=f(c))==null||M.scrollBy({left:-150,behavior:f(r)})}function H(){var M;(M=f(c))==null||M.scrollBy({left:150,behavior:f(r)})}const D=F(()=>e.tabs.length<=1);le(()=>{if(!f(i))return;function M(O){var T,R,V;const I=O.target;I&&((T=f(s))!=null&&T.contains(I)||(R=I.closest)!=null&&R.call(I,".new-tab-menu")||(V=I.closest)!=null&&V.call(I,"[data-tauri-drag-region]")||b(i,!1))}return window.addEventListener("pointerdown",M,!0),()=>window.removeEventListener("pointerdown",M,!0)});var N=mj(),W=x(N);{var ee=M=>{var O=hj();L("click",O,j),S(M,O)};Z(W,M=>{f(d)&&M(ee)})}var z=k(W,2);dt(z,21,()=>e.tabs,M=>M.id,(M,O)=>{{let I=F(()=>f(O).id===e.activeTabId),T=F(()=>!f(D)),R=F(()=>{var V;return((V=f(p))==null?void 0:V.id)===f(O).id?f(p).side:null});fj(M,{get tab(){return f(O)},get isActive(){return f(I)},get onswitch(){return e.onTabSwitch},onclose:l,get draggable(){return f(T)},ondragstart:g,ondragover:y,ondrop:w,ondragend:_,ondragleave:C,get dropIndicator(){return f(R)},onkeydown:A})}}),gt(z,M=>b(c,M),()=>f(c));var Y=k(z,2);gt(Y,M=>b(s,M),()=>f(s));var te=k(Y,2);{var ne=M=>{var O=pj();L("click",O,H),S(M,O)};Z(te,M=>{f(u)&&M(ne)})}var q=k(te,2);{var P=M=>{cj(M,{get recentFiles(){return f(o)},get anchorEl(){return f(s)},onOpen:async O=>{b(i,!1);try{const I=await fetch(`${Gn}${dl}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:O})});if(I.ok)rv(tv(Ib(),O));else{const T=await I.text();console.warn("[tandem] failed to open recent file:",T)}}catch(I){console.warn("[tandem] failed to open recent file:",I)}},onNewScratchpad:()=>{b(i,!1),Zg()},onBrowse:()=>{var O;b(i,!1),(O=e.onRequestOpenDialog)==null||O.call(e)},onClose:()=>b(i,!1)})};Z(q,M=>{f(i)&&M(P)})}L("click",Y,()=>{b(o,Ib(),!0),b(i,!f(i))}),Et("mouseenter",Y,M=>{M.currentTarget.style.color="var(--tandem-accent)",M.currentTarget.style.borderColor="var(--tandem-accent)"}),Et("mouseleave",Y,M=>{M.currentTarget.style.color="var(--tandem-fg-muted)",M.currentTarget.style.borderColor="var(--tandem-border-strong)"}),S(n,N),Le()}qe(["click"]);var vj=E('<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>'),yj=E("<div><!></div>"),bj=E("<!> <!>",1),wj=E('<div class="editor-scroll" role="region" aria-label="Document editor"><!> <div><!> <!></div> <!></div>'),xj=E('<span style="position: absolute; top: 2px; right: 2px; background: var(--tandem-error); color: var(--tandem-error-fg); font-size: 9px; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700;"> </span>'),kj=E('<button data-testid="annotations-tab"><!> <!></button>'),_j=E('<button data-testid="chat-tab"><!></button>'),Sj=E('<button data-testid="outline-tab"><!></button>'),Cj=E('<div><div style="display: flex; border-bottom: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); min-height: 38px; align-items: stretch; padding: 0 var(--tandem-space-2); gap: 2px;"><!> <!> <!> <div style="display: flex; align-items: center; margin-left: auto; padding-right: var(--tandem-space-1);"><!></div></div> <!> <!> <!></div>'),Tj=E('<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>'),Ej=E('<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>'),Aj=E('<button data-testid="left-annotations-tab"> </button>'),Mj=E('<button data-testid="left-chat-tab"> </button>'),Oj=E('<button data-testid="left-outline-tab"> </button>'),Dj=E('<div><div style="display: flex; border-bottom: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); min-height: 38px; align-items: stretch; padding: 0 var(--tandem-space-2); gap: 2px;"><!> <!> <!> <div style="display: flex; align-items: center; margin-left: auto; padding-right: var(--tandem-space-1);"><!></div></div> <div style="display: flex; flex-direction: column; flex: 1; min-height: 0;"><!> <!> <!></div></div> <!>',1),Rj=E("<!> <!>",1),Nj=E('<!> <!> <!> <!> <!> <!> <div style="display: flex; flex: 1; overflow: hidden; background: var(--tandem-bg);"><!> <!> <!></div> <!> <!> <!> <!> <!> <!> <!> <!> <!>',1),Ij=E('<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>');function Pj(n,e){Pe(e,!0);const t=(X,U=Dr,ve=Dr,ke=Dr,Be=Dr)=>{var me=vj();G(me,"aria-valuemin",0),G(me,"aria-valuemax",100),K(Te=>{G(me,"data-testid",ke()??`${U()}-panel-resize-handle`),G(me,"aria-label",U()==="left"?"Resize left panel":"Resize right panel"),G(me,"aria-valuenow",Te)},[()=>Be()!==void 0?Math.round((Be()-Oa)/(Wc-Oa)*100):50]),L("mousedown",me,function(...Te){var rt;(rt=ve())==null||rt.apply(this,Te)}),L("keydown",me,Te=>{let Tt=null;Te.key==="ArrowRight"||Te.key==="ArrowUp"?Tt=16:Te.key==="ArrowLeft"||Te.key==="ArrowDown"?Tt=-16:Te.key==="PageUp"?Tt=80:Te.key==="PageDown"?Tt=-80:Te.key==="Home"?Tt=Oa-(U()==="left"?de.width:Ce.width):Te.key==="End"&&(Tt=Wc-(U()==="left"?de.width:Ce.width)),Tt!==null&&(Te.preventDefault(),Te.stopPropagation(),U()==="left"?de.handleResizeStep(Tt):Ce.handleResizeStep(Tt))}),L("keyup",me,()=>{}),Et("mouseenter",me,Te=>{Te.currentTarget.style.background="var(--tandem-border-strong)"}),Et("mouseleave",me,Te=>{Te.currentTarget.style.background="transparent"}),S(X,me)},r=X=>{var U=wj();{const lt=He=>{U6(He,{get ydoc(){return f(Ae).ydoc},get provider(){return f(Ae).provider},get readOnly(){return o.readOnly},get currentFilePath(){return f(Ae).filePath},get format(){return f(Ae).format},get activeAnnotationId(){return f(P)},onEditorReady:Qe=>b(I,Qe,!0),onAnnotationClick:Qe=>{b(te,"annotations"),b(P,Qe,!0)},onSlashCommandMenuChange:Qe=>b(R,Qe,!0)})};var ve=x(U);{let He=F(()=>{var bt,Yt;return((bt=f(Ae))==null?void 0:bt.readOnly)===!0&&((Yt=f(Ae))==null?void 0:Yt.format)==="docx"}),Qe=F(()=>{var bt;return(bt=f(Ae))==null?void 0:bt.id});kP(ve,{get visible(){return f(He)},get documentId(){return f(Qe)}})}var ke=k(ve,2),Be=x(ke);{var me=He=>{var Qe=xt(),bt=ye(Qe);wu(bt,()=>f(Ae).id,Yt=>{lt(Yt)}),S(He,Qe)},Te=He=>{var Qe=yj(),bt=x(Qe);{var Yt=cn=>{var $t=xt(),er=ye($t);wu(er,()=>f(Ae).id,ar=>{lt(ar)}),S(cn,$t)},Vt=cn=>{NM(cn,{get connected(){return o.connected},get claudeActive(){return o.claudeActive}})};Z(bt,cn=>{f(Ae)?cn(Yt):cn(Vt,-1)})}K(()=>re(Qe,`max-width: ${f(ge)}; margin: 0 auto;`)),S(He,Qe)};Z(Be,He=>{var Qe;((Qe=f(Ae))==null?void 0:Qe.format)==="docx"?He(me):He(Te,-1)})}var rt=k(Be,2);{var Mt=He=>{var Qe=bj(),bt=ye(Qe);i1(bt,{side:"left",get annotations(){return f(nt)},get positions(){return yt.byId},width:240,edgeInset:8,get activeAnnotationId(){return f(P)},get repliesById(){return Cn.byId},onClick:Vt=>{b(P,Vt.id,!0),be.scrollToAnnotation(Vt)}});var Yt=k(bt,2);i1(Yt,{side:"right",get annotations(){return f(kt)},get positions(){return yt.byId},width:240,edgeInset:8,get activeAnnotationId(){return f(P)},get repliesById(){return Cn.byId},onClick:Vt=>{b(P,Vt.id,!0),be.scrollToAnnotation(Vt)},get onAccept(){return be.handleAccept},get onDismiss(){return be.handleDismiss}}),S(He,Qe)};Z(rt,He=>{u.settings.marginView&&f(Ae)&&He(Mt)})}gt(ke,He=>b(T,He),()=>f(T));var Tt=k(ke,2);Q6(Tt,{get editor(){return f(I)},get open(){return f(V)},onClose:()=>b(V,!1),get tabs(){return o.tabs},get forceScope(){return f(se)}}),K(()=>re(ke,u.settings.marginView?"position: relative;":"display: contents;"))}K(()=>re(U,`position: relative; flex: 1; overflow: auto; padding: var(--tandem-space-7) var(--tandem-space-5); border: ${w.fileDragOver?"2px dashed var(--tandem-accent)":"2px solid transparent"}; background: ${w.fileDragOver?"var(--tandem-accent-bg)":"var(--tandem-bg)"}; transition: border-color 0.15s, background 0.15s; border-radius: ${w.fileDragOver?"var(--tandem-r-5)":"0"};`)),Et("dragover",U,function(...lt){var He;(He=w.handleEditorDragOver)==null||He.apply(this,lt)}),Et("dragleave",U,function(...lt){var He;(He=w.handleEditorDragLeave)==null||He.apply(this,lt)}),Et("drop",U,function(...lt){var He;(He=w.handleEditorDrop)==null||He.apply(this,lt)}),S(X,U)},i=(X,U=Dr,ve=Dr)=>{const ke=F(()=>u.settings.rightRailTabs),Be=F(()=>f(ke).length>3);var me=Cj(),Te=x(me),rt=x(Te);{var Mt=It=>{var _t=kj(),lr=x(_t);{var wr=xr=>{var Ze=nn("◨");S(xr,Ze)},en=xr=>{var Ze=nn("Annotations");S(xr,Ze)};Z(lr,xr=>{f(Be)?xr(wr):xr(en,-1)})}var dn=k(lr,2);{var cr=xr=>{var Ze=xj(),tn=x(Ze);K(()=>$(tn,f(q)>9?"9+":f(q))),S(xr,Ze)};Z(dn,xr=>{f(te)!=="annotations"&&f(q)>0&&xr(cr)})}K(()=>{re(_t,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(te)==="annotations"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(te)==="annotations"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; position: relative; white-space: nowrap;`),G(_t,"title",f(Be)?"Annotations":void 0)}),L("click",_t,()=>{b(te,"annotations")}),S(It,_t)},Tt=F(()=>f(ke).includes("annotations"));Z(rt,It=>{f(Tt)&&It(Mt)})}var lt=k(rt,2);{var He=It=>{var _t=_j(),lr=x(_t);{var wr=dn=>{var cr=nn("💬");S(dn,cr)},en=dn=>{var cr=nn("Chat");S(dn,cr)};Z(lr,dn=>{f(Be)?dn(wr):dn(en,-1)})}K(()=>{re(_t,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(te)==="chat"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(te)==="chat"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),G(_t,"title",f(Be)?"Chat":void 0)}),L("mousedown",_t,ze),L("click",_t,()=>{b(te,"chat")}),S(It,_t)},Qe=F(()=>f(ke).includes("chat"));Z(lt,It=>{f(Qe)&&It(He)})}var bt=k(lt,2);{var Yt=It=>{var _t=Sj(),lr=x(_t);{var wr=dn=>{var cr=nn("≡");S(dn,cr)},en=dn=>{var cr=nn("Outline");S(dn,cr)};Z(lr,dn=>{f(Be)?dn(wr):dn(en,-1)})}K(()=>{re(_t,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(te)==="outline"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(te)==="outline"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),G(_t,"title",f(Be)?"Outline":void 0)}),L("click",_t,()=>{b(te,"outline")}),S(It,_t)},Vt=F(()=>f(ke).includes("outline"));Z(bt,It=>{f(Vt)&&It(Yt)})}var cn=k(bt,2),$t=x(cn);{let It=F(()=>u.settings.leftRailTabs.length===1?u.settings.leftRailTabs:[]);o1($t,{get enabledTabs(){return u.settings.rightRailTabs},get disabledTabs(){return f(It)},onTabsChange:_t=>{Ve("right",_t)}})}var er=k(Te,2);{let It=F(()=>f(te)==="chat"&&f(ke).includes("chat"));ra(er,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return f(I)},get activeDocId(){return o.activeTabId},get openDocs(){return f(g)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return f(O)},onCapturedAnchorChange:_t=>b(O,_t,!0),get reduceMotion(){return u.settings.reduceMotion},get visible(){return f(It)}})}var ar=k(er,2);{let It=F(()=>{var en;return((en=f(Ae))==null?void 0:en.ydoc)??null}),_t=F(()=>{var en;return(en=f(Ae))==null?void 0:en.format}),lr=F(()=>{var en;return(en=f(Ae))==null?void 0:en.id}),wr=F(()=>f(te)==="annotations"&&f(ke).includes("annotations"));ra(ar,{kind:"side",get annotations(){return f(p).visibleAnnotations},get editor(){return f(I)},get ydoc(){return f(It)},get heldCount(){return f(p).heldCount},get tandemMode(){return h.tandemMode},get onModeChange(){return h.setTandemMode},get activeDocFormat(){return f(_t)},get documentId(){return f(lr)},get activeAnnotationId(){return f(P)},onActiveAnnotationChange:en=>b(P,en,!0),get reduceMotion(){return u.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get review(){return be},onFilterChange:(en,dn,cr)=>{b(ae,{type:en,author:dn,status:cr},!0)},get visible(){return f(wr)}})}var uo=k(ar,2);{var fo=It=>{{let _t=F(()=>f(te)==="outline");ra(It,{kind:"outline",get editor(){return f(I)},get annotations(){return f(p).visibleAnnotations},get focusTrigger(){return f(he)},get activeFilterType(){return f(ae).type},get visible(){return f(_t)}})}},ea=F(()=>f(ke).includes("outline"));Z(uo,It=>{f(ea)&&It(fo)})}K(()=>re(me,`display: flex; flex-direction: column; width: ${U()}px; ${ve()==="left"?"border-right":"border-left"}: 1px solid var(--tandem-border); background: var(--tandem-surface-muted);`)),S(X,me)},o=s8();ri(()=>o.destroy());const s=hU(),a=new Set;function l(X){const U=o.tabs.find(ve=>ve.id===X);U&&!Vy(U.filePath)&&s.push({filePath:U.filePath,closedAt:Date.now()}),o.handleTabClose(X)}async function c(){const X=s.pop();if(!X)return;const U=o.tabs.find(ke=>ke.filePath===X.filePath);if(U){o.setActiveTabId(U.id);return}if(a.has(X.filePath))return;a.add(X.filePath);const ve=ke=>{s.push(X);const Be=X.filePath.split(/[\\/]/).pop()||X.filePath;y.push({id:`reopen-failed-${Date.now()}`,type:"general-error",severity:"error",message:`Couldn't reopen ${Be}: ${ke}`,dedupKey:`reopen-failed:${X.filePath}`,timestamp:Date.now()})};try{const ke=await fetch(`${Gn}${dl}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:X.filePath})});ke.ok||ve(`server returned ${ke.status}`)}catch(ke){ve(ke instanceof Error?ke.message:"network error")}finally{a.delete(X.filePath)}}const d=LU(()=>o.tabs);NU(()=>d.orderedTabs,()=>o.activeTabId,X=>o.setActiveTabId(X)),le(()=>{const X=o.tabs;if(X.length!==0)try{const U=nv();let ve=U;for(const ke of X)Vy(ke.filePath)||(ve=tv(ve,ke.filePath));(ve.length!==U.length||ve.some((ke,Be)=>ke!==U[Be]))&&rv(ve)}catch(U){console.warn("[tandem] failed to sync recent files:",U)}});const u=WU(),h=zU(()=>o.bootstrapYdoc,()=>u.settings.selectionDwellMs),p=F(()=>{const X=o.annotations,U=h.tandemMode,ve=[];let ke=0;for(const Be of X)AU(Be,U)?ve.push(Be):Be.status==="pending"&&ke++;return{visibleAnnotations:ve,heldCount:ke}}),m=pU(()=>o.disconnectedSince,()=>u.settings.degradedBannerDelayMs),v=r8();i8();const g=F(()=>o.tabs.map(X=>({id:X.id,fileName:X.fileName}))),y=MU(),w=xU();if(Nn()){let X=null,U=!1;Wr(async()=>{const{listen:ve}=await import("./event-CNdo2oXa.js");return{listen:ve}},__vite__mapDeps([2,1])).then(({listen:ve})=>ve("sidecar-restart-failed",()=>{y.push({id:`sidecar-restart-failed-${Date.now()}`,type:"general-error",severity:"error",message:"Sidecar failed to restart — see logs",dedupKey:"sidecar-restart-failed",timestamp:Date.now(),errorCode:"SIDECAR_RESTART_FAILED"})})).then(ve=>{U?ve():X=ve}).catch(ve=>{console.warn("[App] Failed to wire sidecar-restart-failed listener:",ve)}),ri(()=>{U=!0,X==null||X()})}let _=B(!1),C=B(!1),A=B(null),j=B(!1),H=B(!1);const D=n8();function N(){f(_)||D.acknowledge(),b(_,!f(_))}function W(){D.acknowledge(),b(C,!0)}function ee(){D.acknowledge(),b(_,!0)}function z(){u.updateSettings({theme:FU[u.settings.theme]})}l2({getActiveTabId:()=>o.activeTabId,openSettings:ee,openSettingsModal:W,toggleSoloMode:()=>h.setTandemMode(h.tandemMode==="solo"?"tandem":"solo"),openFindBar:()=>{b(se,"doc"),b(V,!0)},openFindBarTabs:()=>{b(se,"tabs"),b(V,!0)},findNext:()=>{const X=f(I),U=X?Ma(X.state):void 0;X&&Fp(U)?X.commands.findNext():(b(se,"doc"),b(V,!0))},findPrev:()=>{const X=f(I),U=X?Ma(X.state):void 0;X&&Fp(U)?X.commands.findPrev():(b(se,"doc"),b(V,!0))},closeActiveTab:()=>{const X=o.activeTabId;X&&l(X)},openFileDialog:()=>{b(H,!0)},toggleLeftPanel:()=>Re(),toggleRightPanel:()=>tt(),reopenClosedTab:()=>void c(),annotationNext:()=>{const X=jd(f(p).visibleAnnotations),U=qw(X,f(P));if(U){b(P,U,!0);const ve=X.find(ke=>ke.id===U);ve&&be.scrollToAnnotation(ve)}},annotationPrev:()=>{const X=jd(f(p).visibleAnnotations),U=Jw(X,f(P));if(U){b(P,U,!0);const ve=X.find(ke=>ke.id===U);ve&&be.scrollToAnnotation(ve)}},annotationAccept:()=>{const X=f(p).visibleAnnotations.find(U=>U.id===f(P));X&&X.author!=="user"&&be.handleAccept(X.id)},annotationDismiss:()=>{const X=f(p).visibleAnnotations.find(U=>U.id===f(P));X&&X.author!=="user"&&be.handleDismiss(X.id)},selectBlock:()=>{var X;return(X=f(I))==null?void 0:X.chain().focus().selectParentNode().run()},toggleAuthorship:()=>u.updateSettings({showAuthorship:!u.settings.showAuthorship})});let Y=null;le(()=>{const X=f(I);if(!X)return;const U=u.settings.showAuthorship;if(Y===U)return;const ve=Y===null;Y=U,!ve&&Dt(()=>{const ke=X.state.tr.setMeta(ua,{type:"toggle",visible:U});X.view.dispatch(ke)})}),le(()=>(document.body.classList.toggle("tandem-reduce-motion",u.settings.reduceMotion),()=>document.body.classList.remove("tandem-reduce-motion"))),YU(()=>u.settings.theme),aU(()=>u.settings.accentHue),wU(()=>u.settings.editorFont),gU(()=>u.settings.density),_U(()=>u.settings.highContrast),cU(()=>u.settings.annotationPatterns),le(()=>{const X=HU[u.settings.textSize];return document.documentElement.style.setProperty("--tandem-editor-font-size",`${X}px`),()=>document.documentElement.style.removeProperty("--tandem-editor-font-size")});let te=B(at(u.settings.primaryTab==="chat"?"chat":"annotations")),ne=B(at(u.settings.leftRailTabs[0]??"annotations"));le(()=>{const X=u.settings.leftRailTabs;X.includes(f(ne))||Dt(()=>{b(ne,X[0]??"annotations",!0)})}),le(()=>{const X=u.settings.rightRailTabs;X.includes(f(te))||Dt(()=>{b(te,X[0]??"chat",!0)})});const q=F(()=>f(te)==="annotations"?0:f(p).visibleAnnotations.filter(Tu).length);let P=B(null),M=B(!1),O=B(null),I=B(null),T=B(null),R=B(!1),V=B(!1),se=B("doc"),he=B(0),we=B(0),ae=B(at({type:"all",author:"all",status:"all"}));const Q=Zw("left"),ie=Zw("right"),de=Yw({side:"left",initialWidth:Q,getVisible:()=>f(_e)}),Ce=Yw({side:"right",initialWidth:ie,getVisible:()=>f(Oe)}),_e=F(()=>u.settings.leftPanelVisible),Oe=F(()=>u.settings.rightPanelVisible&&!(h.tandemMode==="solo"&&u.settings.soloRailHidden));function Re(){u.updateSettings({leftPanelVisible:!u.settings.leftPanelVisible})}function tt(){f(Oe)?u.updateSettings({rightPanelVisible:!1}):u.updateSettings({rightPanelVisible:!0,...h.tandemMode==="solo"?{soloRailHidden:!1}:{}})}function Ve(X,U){const ve=u.settings.leftRailTabs,ke=u.settings.rightRailTabs,Be=X==="left"?ve:ke,me=X==="left"?ke:ve,Te=U.filter(Mt=>!Be.includes(Mt));if(Te.length===0)return u.updateSettings(X==="left"?{leftRailTabs:U}:{rightRailTabs:U}),!0;const rt=me.filter(Mt=>!Te.includes(Mt));return rt.length===0?(console.warn("[tandem] cross-rail tab move blocked — would leave the %s rail empty",X==="left"?"right":"left"),!1):(u.updateSettings(X==="left"?{leftRailTabs:U,rightRailTabs:rt}:{rightRailTabs:U,leftRailTabs:rt}),!0)}function ce(X,U,ve){b(ae,{type:X,author:U,status:ve},!0)}const Ie=496,ge=F(()=>{const X=u.settings.editorWidthPercent,U=u.settings.marginView?Ie:0;return U>0?`calc(${X}% - ${U}px)`:`${X}%`});function ze(){if(f(te)==="chat"||!f(I))return;const{from:X,to:U}=f(I).state.selection;if(X===U)return;const ve=U_(f(I).state.doc,{from:Dn(X),to:Dn(U)}),ke=f(I).state.doc.textBetween(X,U,`
|
|
299
|
+
`);b(O,{...ve,textSnapshot:ke.length>200?ke.slice(0,197)+"...":ke},!0)}le(()=>{function X(U){var ve,ke,Be;if(U.key==="?"){const me=U.target;if(me.tagName==="INPUT"||me.tagName==="TEXTAREA"||me.isContentEditable)return;b(M,Dt(()=>!f(M)),!0);return}if(U.ctrlKey||U.metaKey){if(U.code==="KeyA"&&!U.altKey&&!U.shiftKey){const me=document.activeElement;if(me instanceof HTMLInputElement||me instanceof HTMLTextAreaElement||(ve=me==null?void 0:me.closest)!=null&&ve.call(me,".ProseMirror"))return;U.preventDefault(),(ke=f(I))==null||ke.commands.selectAll()}else if(U.code==="KeyS")U.preventDefault(),Mx(o.activeTabId);else if(DU(U))U.preventDefault(),W();else if(OU(U))U.preventDefault(),ee();else if(U.shiftKey&&U.code==="KeyP")U.preventDefault(),b(j,!Dt(()=>f(j)));else if(U.code==="KeyN"){const me=U.target;if(me.tagName==="INPUT"||me.tagName==="TEXTAREA")return;U.preventDefault(),Zg()}else if(U.key==="/"){const me=U.target;if(me.tagName==="INPUT"||me.tagName==="TEXTAREA"||me.isContentEditable)return;U.preventDefault(),b(M,Dt(()=>!f(M)),!0)}else if(U.code==="KeyW"){if(Zr(U))return;U.preventDefault();const me=o.activeTabId;me&&l(me)}else if(U.code==="KeyO"){if(Zr(U))return;U.preventDefault(),b(H,!0)}else if(/^Digit[1-9]$/.test(U.code)){if(Zr(U))return;const me=IU(o.tabs,Number(U.code.slice(5)));me&&(U.preventDefault(),o.setActiveTabId(me))}else if(U.shiftKey&&!U.altKey&&U.code==="KeyM"){if(Zr(U))return;U.preventDefault(),h.setTandemMode(h.tandemMode==="solo"?"tandem":"solo")}else if(U.code==="Backslash"){if(Zr(U))return;U.preventDefault(),U.shiftKey?tt():Re()}else if(U.altKey&&U.code==="KeyT"){if(Zr(U))return;U.preventDefault(),c()}}if((U.ctrlKey||U.metaKey)&&U.code==="KeyF"){if(U.preventDefault(),U.shiftKey){b(se,"tabs"),b(V,!0);return}f(_e)&&f(ne)==="outline"||f(Oe)&&f(te)==="outline"?b(he,f(he)+1):(b(se,"doc"),b(V,!0))}if((U.ctrlKey||U.metaKey)&&U.code==="KeyG"){if(Zr(U))return;U.preventDefault();const me=f(I),Te=me?Ma(me.state):void 0;me&&Fp(Te)?U.shiftKey?me.commands.findPrev():me.commands.findNext():(b(se,"doc"),b(V,!0))}if(U.altKey&&!U.ctrlKey&&!U.metaKey&&!U.shiftKey){if(U.code==="BracketRight"){if(Zr(U))return;U.preventDefault();const me=jd(f(p).visibleAnnotations),Te=qw(me,f(P));if(Te){b(P,Te,!0);const rt=me.find(Mt=>Mt.id===Te);rt&&be.scrollToAnnotation(rt)}return}if(U.code==="BracketLeft"){if(Zr(U))return;U.preventDefault();const me=jd(f(p).visibleAnnotations),Te=Jw(me,f(P));if(Te){b(P,Te,!0);const rt=me.find(Mt=>Mt.id===Te);rt&&be.scrollToAnnotation(rt)}return}}if((U.ctrlKey||U.metaKey)&&U.key==="Enter"){if(Zr(U))return;U.preventDefault();const me=f(p).visibleAnnotations.find(Te=>Te.id===f(P));me&&me.author!=="user"&&(U.shiftKey?be.handleDismiss(me.id):be.handleAccept(me.id));return}if((U.ctrlKey||U.metaKey)&&U.altKey&&U.code==="KeyM"){U.preventDefault();const me=!!f(I)&&f(I).state.selection.from!==f(I).state.selection.to,Te=((Be=f(Ae))==null?void 0:Be.readOnly)===!0;if(f(R)||f(V)||f(j))return;if(!me){y.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(Te){y.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(!u.settings.selectionToolbar){y.push({id:`comment-shortcut-toolbar-off-${Date.now()}`,type:"general-error",severity:"info",message:"Enable selection toolbar in Settings to comment via keyboard",dedupKey:"comment-shortcut-toolbar-off",timestamp:Date.now()});return}b(we,f(we)+1);return}if(U.altKey&&!U.ctrlKey&&!U.metaKey&&!U.shiftKey&&U.code==="KeyL"){if(Zr(U))return;U.preventDefault(),f(I)&&f(I).chain().focus().selectParentNode().run();return}if((U.ctrlKey||U.metaKey)&&U.altKey&&U.code==="KeyA"){U.preventDefault(),u.updateSettings({showAuthorship:!u.settings.showAuthorship});return}}return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)});const Ae=F(()=>o.tabs.find(X=>X.id===o.activeTabId)),be=g8({getYdoc:()=>{var X;return((X=f(Ae))==null?void 0:X.ydoc)??null},getEditor:()=>f(I),getAnnotations:()=>f(p).visibleAnnotations,onActiveAnnotationChange:X=>{b(P,X,!0)},getScrollBehavior:()=>u.settings.reduceMotion?"auto":"smooth",getActiveAnnotationId:()=>f(P)}),nt=F(()=>u.settings.marginView?f(p).visibleAnnotations.filter(X=>X.type==="note"):[]),kt=F(()=>u.settings.marginView?f(p).visibleAnnotations.filter(X=>X.author==="import"||X.type==="comment"):[]),yt=TU({getEditor:()=>f(I),getYdoc:()=>{var X;return((X=f(Ae))==null?void 0:X.ydoc)??null},getAnnotations:()=>[...f(nt),...f(kt)],getLayerEl:()=>f(T),getEnabled:()=>u.settings.marginView}),Cn=dU({getYdoc:()=>{var X;return((X=f(Ae))==null?void 0:X.ydoc)??null}}),ln=QU(()=>f(p).visibleAnnotations,()=>f(I),()=>{var X;return(X=f(Ae))==null?void 0:X.fileName});var co=Ij(),Ue=x(co);$8(Ue,{get tandemMode(){return h.tandemMode},get onModeChange(){return h.setTandemMode},get claudeActive(){return o.claudeActive},get leftPanelVisible(){return f(_e)},onToggleLeftPanel:Re,get rightPanelVisible(){return f(Oe)},onToggleRightPanel:tt,get theme(){return u.settings.theme},onCycleTheme:z,get showAuthorship(){return u.settings.showAuthorship},onAuthorshipChange:X=>u.updateSettings({showAuthorship:X}),onOpenHelp:()=>b(M,!0),onOpenSettings:N,onOpenSettingsModal:W,get updateAvailable(){return D.showDot},get settingsBtn(){return f(A)},set settingsBtn(X){b(A,X,!0)}});var Nt=k(Ue,2);{var Se=X=>{var U=Tj();S(X,U)},Xe=X=>{var U=Nj(),ve=ye(U);{var ke=Ze=>{var tn=Ej();S(Ze,tn)};Z(ve,Ze=>{o.serverRestarted&&Ze(ke)})}var Be=k(ve,2);{var me=Ze=>{RL(Ze,{get version(){return v.availableVersion},get installing(){return v.installing},onInstall:()=>{v.install()},get onDismiss(){return v.dismiss}})},Te=F(()=>Nn()&&v.showBanner&&v.availableVersion);Z(Be,Ze=>{f(Te)&&Ze(me)})}var rt=k(Be,2);{var Mt=Ze=>{vM(Ze,{get onDismiss(){return m.dismiss},onRetry:()=>{o.reconnect()}})};Z(rt,Ze=>{m.showBanner&&Ze(Mt)})}var Tt=k(rt,2);{let Ze=F(()=>{var kr;return((kr=f(Ae))==null?void 0:kr.ydoc)??null}),tn=F(()=>f(R)||f(V)||f(j));oU(Tt,{get editor(){return f(I)},get ydoc(){return f(Ze)},get selectionToolbar(){return u.settings.selectionToolbar},get suppressSelectionToolbar(){return f(tn)},get requestCommentFocus(){return f(we)}})}var lt=k(Tt,2);gj(lt,{get tabs(){return d.orderedTabs},get activeTabId(){return o.activeTabId},get onTabSwitch(){return o.setActiveTabId},onTabClose:l,get reorder(){return d.reorder},get reduceMotion(){return u.settings.reduceMotion},onRequestOpenDialog:()=>{b(H,!0)}});var He=k(lt,2);{let Ze=F(()=>{var tn;return((tn=f(Ae))==null?void 0:tn.ydoc)??null});I8(He,{get editor(){return f(I)},get ydoc(){return f(Ze)}})}var Qe=k(He,2),bt=x(Qe);{var Yt=Ze=>{const tn=F(()=>u.settings.leftRailTabs),kr=F(()=>f(tn).length>3),Mh=F(()=>u.settings.rightRailTabs.length===1?u.settings.rightRailTabs:[]);var vd=Dj(),Oh=ye(vd),vy=x(Oh),yy=x(vy);{var nT=Gt=>{var Xt=Aj(),ts=x(Xt);K(()=>{re(Xt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(ne)==="annotations"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(ne)==="annotations"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),G(Xt,"title",f(kr)?"Annotations":void 0),$(ts,f(kr)?"◨":"Annotations")}),L("click",Xt,()=>{b(ne,"annotations")}),S(Gt,Xt)},rT=F(()=>f(tn).includes("annotations"));Z(yy,Gt=>{f(rT)&&Gt(nT)})}var by=k(yy,2);{var iT=Gt=>{var Xt=Mj(),ts=x(Xt);K(()=>{re(Xt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(ne)==="chat"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(ne)==="chat"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),G(Xt,"title",f(kr)?"Chat":void 0),$(ts,f(kr)?"💬":"Chat")}),L("click",Xt,()=>{b(ne,"chat")}),S(Gt,Xt)},oT=F(()=>f(tn).includes("chat"));Z(by,Gt=>{f(oT)&&Gt(iT)})}var wy=k(by,2);{var sT=Gt=>{var Xt=Oj(),ts=x(Xt);K(()=>{re(Xt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(ne)==="outline"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(ne)==="outline"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),G(Xt,"title",f(kr)?"Outline":void 0),$(ts,f(kr)?"≡":"Outline")}),L("click",Xt,()=>{b(ne,"outline")}),S(Gt,Xt)},aT=F(()=>f(tn).includes("outline"));Z(wy,Gt=>{f(aT)&&Gt(sT)})}var lT=k(wy,2),cT=x(lT);o1(cT,{get enabledTabs(){return f(tn)},get disabledTabs(){return f(Mh)},testIdPrefix:"left-",onTabsChange:Gt=>{Ve("left",Gt)}});var dT=k(vy,2),xy=x(dT);{let Gt=F(()=>f(ne)==="chat"&&f(tn).includes("chat"));ra(xy,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return f(I)},get activeDocId(){return o.activeTabId},get openDocs(){return f(g)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return f(O)},onCapturedAnchorChange:Xt=>b(O,Xt,!0),get reduceMotion(){return u.settings.reduceMotion},get visible(){return f(Gt)}})}var ky=k(xy,2);{let Gt=F(()=>{var di;return((di=f(Ae))==null?void 0:di.ydoc)??null}),Xt=F(()=>{var di;return(di=f(Ae))==null?void 0:di.format}),ts=F(()=>{var di;return(di=f(Ae))==null?void 0:di.id}),hT=F(()=>f(ne)==="annotations"&&f(tn).includes("annotations"));ra(ky,{kind:"side",get annotations(){return f(p).visibleAnnotations},get activeFilterType(){return f(ae).type},get activeFilterAuthor(){return f(ae).author},get activeFilterStatus(){return f(ae).status},onFilterChange:ce,get editor(){return f(I)},get ydoc(){return f(Gt)},get heldCount(){return f(p).heldCount},get tandemMode(){return h.tandemMode},get onModeChange(){return h.setTandemMode},get activeDocFormat(){return f(Xt)},get documentId(){return f(ts)},get activeAnnotationId(){return f(P)},onActiveAnnotationChange:di=>b(P,di,!0),get reduceMotion(){return u.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get review(){return be},get visible(){return f(hT)}})}var uT=k(ky,2);{let Gt=F(()=>f(ne)==="outline"&&f(tn).includes("outline"));ra(uT,{kind:"outline",get focusTrigger(){return f(he)},get editor(){return f(I)},get visible(){return f(Gt)}})}var fT=k(Oh,2);t(fT,()=>"left",()=>Gt=>de.handleResizeStart(Gt),()=>{},()=>de.width),K(()=>re(Oh,`display: flex; flex-direction: column; width: ${de.width}px; border-right: 1px solid var(--tandem-border); background: var(--tandem-surface-muted);`)),S(Ze,vd)};Z(bt,Ze=>{f(_e)&&Ze(Yt)})}var Vt=k(bt,2);r(Vt);var cn=k(Vt,2);{var $t=Ze=>{var tn=Rj(),kr=ye(tn);t(kr,()=>"right",()=>vd=>Ce.handleResizeStart(vd),()=>"panel-resize-handle",()=>Ce.width);var Mh=k(kr,2);i(Mh,()=>Ce.width,()=>"right"),S(Ze,tn)};Z(cn,Ze=>{f(Oe)&&Ze($t)})}var er=k(Qe,2);oj(er,{get connected(){return o.connected},get connectionStatus(){return o.connectionStatus},get reconnectAttempts(){return o.reconnectAttempts},get disconnectedSince(){return o.disconnectedSince},get claudeStatus(){return o.claudeStatus},get claudeActive(){return o.claudeActive},get readOnly(){return o.readOnly},get documentCount(){return o.tabs.length},get saving(){return c2.saving},get heldCount(){return f(p).heldCount},get mode(){return h.tandemMode},onShowHeld:()=>h.setTandemMode("tandem")});var ar=k(er,2);TL(ar,{get open(){return f(_)},onClose:()=>b(_,!1),get settings(){return u.settings},get onUpdate(){return u.updateSettings},get returnFocusEl(){return f(A)},get anchorEl(){return f(A)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts}});var uo=k(ar,2);lL(uo,{get open(){return f(C)},onClose:()=>b(C,!1),get settings(){return u.settings},get onUpdate(){return u.updateSettings},get returnFocusEl(){return f(A)},get triggerEl(){return f(A)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts}});var fo=k(uo,2);JM(fo,{get open(){return f(M)},onClose:()=>b(M,!1)});var ea=k(fo,2);{var It=Ze=>{UM(Ze,{onClose:()=>b(H,!1)})};Z(ea,Ze=>{f(H)&&Ze(It)})}var _t=k(ea,2);mM(_t,{get open(){return f(j)},onClose:()=>b(j,!1),get editor(){return f(I)},get annotations(){return f(p).visibleAnnotations},onFocusAnnotation:Ze=>{b(P,Ze,!0)}});var lr=k(_t,2);OL(lr,{get toasts(){return y.toasts},get onDismiss(){return y.dismiss}});var wr=k(lr,2);{var en=Ze=>{AM(Ze,{})},dn=F(()=>Nn());Z(wr,Ze=>{f(dn)&&Ze(en)})}var cr=k(wr,2);{var xr=Ze=>{aO(Ze,{get currentStep(){return ln.currentStep},get onNext(){return ln.nextStep},get onDismiss(){return ln.dismissTutorial},get coworkStatus(){return ln.coworkStatus}})};Z(cr,Ze=>{ln.tutorialActive&&Ze(xr)})}S(X,U)};Z(Nt,X=>{o.ready?X(Xe,-1):X(Se)})}S(n,co),Le()}qe(["mousedown","keydown","keyup","click"]);const l1=3,Lj="error-boundary-recover-btn",zj="error-boundary-reload-btn";function Fj(n,e){Pe(e,!0),le(()=>{e.onSuccess()}),Le()}var Bj=E('<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>'),Hj=E('<div role="alert" class="error-boundary svelte-1bcl6yi"><h2 class="svelte-1bcl6yi">Something went wrong</h2> <p class="message svelte-1bcl6yi"> </p> <pre class="detail svelte-1bcl6yi"> </pre> <!> <button class="btn btn-secondary svelte-1bcl6yi">Reload</button></div>'),Vj=E("<!> <!>",1);function Uj(n,e){let t=B(0),r=B(0);var i=xt(),o=ye(i);N1(o,{onerror:()=>{b(r,f(r)+1)},failed:(a,l=Dr,c=Dr)=>{var d=xt(),u=ye(d);wu(u,()=>f(r),h=>{var p=Hj(),m=k(x(p),2),v=x(m),g=k(m,2),y=x(g),w=k(g,2);{var _=A=>{var j=Bj();K(()=>G(j,"data-testid",Lj)),L("click",j,()=>{b(t,f(t)+1),c()()}),S(A,j)};Z(w,A=>{f(t)<l1&&A(_)})}var C=k(w,2);K(A=>{$(v,f(t)>=l1?"Recovery attempts exhausted. Reload the page to continue.":"The editor encountered an unexpected error."),$(y,A),G(C,"data-testid",zj)},[()=>l()instanceof Error?l().message:String(l())]),L("click",C,()=>window.location.reload()),S(h,p)}),S(a,d)}},a=>{var l=Vj(),c=ye(l);Bg(c,()=>e.children);var d=k(c,2);Fj(d,{onSuccess:()=>{b(t,0)}}),S(a,l)}),S(n,i)}qe(["click"]);function jj(n){Uj(n,{children:(e,t)=>{Pj(e,{})}})}FE(jj,{target:document.getElementById("root")});export{dt as A,Qj as B,qj as C,Gj as D,qe as E,tW as F,Xj as G,px as T,k as a,S as b,mk as c,Le as d,B as e,Yj as f,f as g,x as h,Z as i,G as j,ye as k,ti as l,$j as m,$ as n,ri as o,Pe as p,L as q,b as r,re as s,K as t,F as u,E as v,ev as w,dk as x,pk as y,eW as z};
|