tandem-editor 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cli/index.js +1 -1
- package/dist/client/assets/{CoworkSettings-BfROGjTw.js → CoworkSettings-DK3jjdwK.js} +1 -1
- package/dist/client/assets/{index-BEmR1MMN.js → index-CfT503n4.js} +39 -39
- package/dist/client/index.html +1 -1
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-BxBvHL5k.js","assets/core-DhEqZVGG.js","assets/webview-Ben21ZLJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var IS=Object.defineProperty;var kv=n=>{throw TypeError(n)};var LS=(n,e,t)=>e in n?IS(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var jn=(n,e,t)=>LS(n,typeof e!="symbol"?e+"":e,t),Wf=(n,e,t)=>e.has(n)||kv("Cannot "+t);var j=(n,e,t)=>(Wf(n,e,"read from private field"),t?t.call(n):e.get(n)),Ze=(n,e,t)=>e.has(n)?kv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),st=(n,e,t,r)=>(Wf(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Ot=(n,e,t)=>(Wf(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 PS=!1;var Rm=Array.isArray,zS=Array.prototype.indexOf,ma=Array.prototype.includes,tf=Array.from,BS=Object.defineProperty,po=Object.getOwnPropertyDescriptor,ow=Object.getOwnPropertyDescriptors,FS=Object.prototype,HS=Array.prototype,Nm=Object.getPrototypeOf,_v=Object.isExtensible;function Ja(n){return typeof n=="function"}const pr=()=>{};function VS(n){return typeof(n==null?void 0:n.then)=="function"}function US(n){for(var e=0;e<n.length;e++)n[e]()}function sw(){var n,e,t=new Promise((r,i)=>{n=r,e=i});return{promise:t,resolve:n,reject:e}}function Sv(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 Dn=2,ga=4,nf=8,aw=1<<24,ii=16,zr=32,Vi=64,Qh=128,br=512,rn=1024,xn=2048,di=4096,Pn=8192,ir=16384,Ds=32768,$h=1<<25,xo=65536,ep=1<<17,jS=1<<18,Rs=1<<19,WS=1<<20,ei=1<<25,ms=65536,Nd=1<<21,Al=1<<22,mo=1<<23,oi=Symbol("$state"),lw=Symbol("legacy props"),KS=Symbol(""),Mi=new class extends Error{constructor(){super(...arguments);jn(this,"name","StaleReactionError");jn(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var nw;const qS=!!((nw=globalThis.document)!=null&&nw.contentType)&&globalThis.document.contentType.includes("xml");function cw(n){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function JS(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function YS(n,e,t){throw new Error("https://svelte.dev/e/each_key_duplicate")}function ZS(n){throw new Error("https://svelte.dev/e/effect_in_teardown")}function GS(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function XS(n){throw new Error("https://svelte.dev/e/effect_orphan")}function QS(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function $S(n){throw new Error("https://svelte.dev/e/props_invalid_value")}function eC(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function tC(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function nC(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function rC(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const iC=1,oC=2,dw=4,sC=8,aC=16,lC=1,cC=2,dC=4,uC=8,fC=16,hC=1,pC=2,tn=Symbol(),uw="http://www.w3.org/1999/xhtml",mC="http://www.w3.org/2000/svg",gC="http://www.w3.org/1998/Math/MathML";function vC(){console.warn("https://svelte.dev/e/derived_inert")}function yC(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function bC(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function fw(n){return n===this.v}function hw(n,e){return n!=n?e==e:n!==e||n!==null&&typeof n=="object"||typeof n=="function"}function pw(n){return!hw(n,this.v)}let za=!1,wC=!1;function xC(){za=!0}let Vt=null;function va(n){Vt=n}function qe(n,e=!1,t){Vt={p:Vt,i:!1,c:null,e:null,s:n,x:null,r:it,l:za&&!e?{s:null,u:null,$:[]}:null}}function Je(n){var e=Vt,t=e.e;if(t!==null){e.e=null;for(var r of t)zw(r)}return e.i=!0,Vt=e.p,{}}function Ns(){return!za||Vt!==null&&Vt.l===null}let Wo=[];function mw(){var n=Wo;Wo=[],US(n)}function si(n){if(Wo.length===0&&!Qs){var e=Wo;queueMicrotask(()=>{e===Wo&&mw()})}Wo.push(n)}function kC(){for(;Wo.length>0;)mw()}function gw(n){var e=it;if(e===null)return ct.f|=mo,n;if((e.f&Ds)===0&&(e.f&ga)===0)throw n;lo(n,e)}function lo(n,e){for(;e!==null;){if((e.f&Qh)!==0){if((e.f&Ds)===0)throw n;try{e.b.error(n);return}catch(t){n=t}}e=e.parent}throw n}const _C=-7169;function qt(n,e){n.f=n.f&_C|e}function Im(n){(n.f&br)!==0||n.deps===null?qt(n,rn):qt(n,di)}function vw(n){if(n!==null)for(const e of n)(e.f&Dn)===0||(e.f&ms)===0||(e.f^=ms,vw(e.deps))}function yw(n,e,t){(n.f&xn)!==0?e.add(n):(n.f&di)!==0&&t.add(n),vw(n.deps),qt(n,rn)}let Pc=!1;function SC(n){var e=Pc;try{return Pc=!1,[n(),Pc]}finally{Pc=e}}const Bo=new Set;let Be=null,gn=null,tp=null,Qs=!1,Kf=!1,Ys=null,ad=null;var Cv=0;let CC=1;var da,ua,Qo,Oi,Xr,uc,$n,fc,so,Di,Qr,fa,ha,$o,Xt,ld,bw,cd,np,dd,TC;const Xu=class Xu{constructor(){Ze(this,Xt);jn(this,"id",CC++);jn(this,"current",new Map);jn(this,"previous",new Map);Ze(this,da,new Set);Ze(this,ua,new Set);Ze(this,Qo,new Set);Ze(this,Oi,new Map);Ze(this,Xr,new Map);Ze(this,uc,null);Ze(this,$n,[]);Ze(this,fc,[]);Ze(this,so,new Set);Ze(this,Di,new Set);Ze(this,Qr,new Map);Ze(this,fa,new Set);jn(this,"is_fork",!1);Ze(this,ha,!1);Ze(this,$o,new Set)}skip_effect(e){j(this,Qr).has(e)||j(this,Qr).set(e,{d:[],m:[]}),j(this,fa).delete(e)}unskip_effect(e,t=r=>this.schedule(r)){var r=j(this,Qr).get(e);if(r){j(this,Qr).delete(e);for(var i of r.d)qt(i,xn),t(i);for(i of r.m)qt(i,di),t(i)}j(this,fa).add(e)}capture(e,t,r=!1){e.v!==tn&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&mo)===0&&(this.current.set(e,[t,r]),gn==null||gn.set(e,t)),this.is_fork||(e.v=t)}activate(){Be=this}deactivate(){Be=null,gn=null}flush(){try{Kf=!0,Be=this,Ot(this,Xt,cd).call(this)}finally{Cv=0,tp=null,Ys=null,ad=null,Kf=!1,Be=null,gn=null,rs.clear()}}discard(){for(const e of j(this,ua))e(this);j(this,ua).clear(),j(this,Qo).clear(),Bo.delete(this)}register_created_effect(e){j(this,fc).push(e)}increment(e,t){let r=j(this,Oi).get(t)??0;if(j(this,Oi).set(t,r+1),e){let i=j(this,Xr).get(t)??0;j(this,Xr).set(t,i+1)}}decrement(e,t,r){let i=j(this,Oi).get(t)??0;if(i===1?j(this,Oi).delete(t):j(this,Oi).set(t,i-1),e){let o=j(this,Xr).get(t)??0;o===1?j(this,Xr).delete(t):j(this,Xr).set(t,o-1)}j(this,ha)||r||(st(this,ha,!0),si(()=>{st(this,ha,!1),this.flush()}))}transfer_effects(e,t){for(const r of e)j(this,so).add(r);for(const r of t)j(this,Di).add(r);e.clear(),t.clear()}oncommit(e){j(this,da).add(e)}ondiscard(e){j(this,ua).add(e)}on_fork_commit(e){j(this,Qo).add(e)}run_fork_commit_callbacks(){for(const e of j(this,Qo))e(this);j(this,Qo).clear()}settled(){return(j(this,uc)??st(this,uc,sw())).promise}static ensure(){if(Be===null){const e=Be=new Xu;Kf||(Bo.add(Be),Qs||si(()=>{Be===e&&e.flush()}))}return Be}apply(){{gn=null;return}}schedule(e){var i;if(tp=e,(i=e.b)!=null&&i.is_pending&&(e.f&(ga|nf|aw))!==0&&(e.f&Ds)===0){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var r=t.f;if(Ys!==null&&t===it&&(ct===null||(ct.f&Dn)===0))return;if((r&(Vi|zr))!==0){if((r&rn)===0)return;t.f^=rn}}j(this,$n).push(t)}};da=new WeakMap,ua=new WeakMap,Qo=new WeakMap,Oi=new WeakMap,Xr=new WeakMap,uc=new WeakMap,$n=new WeakMap,fc=new WeakMap,so=new WeakMap,Di=new WeakMap,Qr=new WeakMap,fa=new WeakMap,ha=new WeakMap,$o=new WeakMap,Xt=new WeakSet,ld=function(){return this.is_fork||j(this,Xr).size>0},bw=function(){for(const r of j(this,$o))for(const i of j(r,Xr).keys()){for(var e=!1,t=i;t.parent!==null;){if(j(this,Qr).has(t)){e=!0;break}t=t.parent}if(!e)return!0}return!1},cd=function(){var a,l;if(Cv++>1e3&&(Bo.delete(this),AC()),!Ot(this,Xt,ld).call(this)){for(const c of j(this,so))j(this,Di).delete(c),qt(c,xn),this.schedule(c);for(const c of j(this,Di))qt(c,di),this.schedule(c)}const e=j(this,$n);st(this,$n,[]),this.apply();var t=Ys=[],r=[],i=ad=[];for(const c of e)try{Ot(this,Xt,np).call(this,c,t,r)}catch(d){throw _w(c),d}if(Be=null,i.length>0){var o=Xu.ensure();for(const c of i)o.schedule(c)}if(Ys=null,ad=null,Ot(this,Xt,ld).call(this)||Ot(this,Xt,bw).call(this)){Ot(this,Xt,dd).call(this,r),Ot(this,Xt,dd).call(this,t);for(const[c,d]of j(this,Qr))kw(c,d)}else{j(this,Oi).size===0&&Bo.delete(this),j(this,so).clear(),j(this,Di).clear();for(const c of j(this,da))c(this);j(this,da).clear(),Tv(r),Tv(t),(a=j(this,uc))==null||a.resolve()}var s=Be;if(j(this,$n).length>0){const c=s??(s=this);j(c,$n).push(...j(this,$n).filter(d=>!j(c,$n).includes(d)))}s!==null&&(Bo.add(s),Ot(l=s,Xt,cd).call(l))},np=function(e,t,r){e.f^=rn;for(var i=e.first;i!==null;){var o=i.f,s=(o&(zr|Vi))!==0,a=s&&(o&rn)!==0,l=a||(o&Pn)!==0||j(this,Qr).has(i);if(!l&&i.fn!==null){s?i.f^=rn:(o&ga)!==0?t.push(i):wc(i)&&((o&ii)!==0&&j(this,Di).add(i),ya(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}}},dd=function(e){for(var t=0;t<e.length;t+=1)yw(e[t],j(this,so),j(this,Di))},TC=function(){var d,u,h;for(const p of Bo){var e=p.id<this.id,t=[];for(const[m,[v,g]]of this.current){if(p.current.has(m)){var r=p.current.get(m)[0];if(e&&v!==r)p.current.set(m,[v,g]);else continue}t.push(m)}var i=[...p.current.keys()].filter(m=>!this.current.has(m));if(i.length===0)e&&p.discard();else if(t.length>0){if(e)for(const m of j(this,fa))p.unskip_effect(m,v=>{var g;(v.f&(ii|Al))!==0?p.schedule(v):Ot(g=p,Xt,dd).call(g,[v])});p.activate();var o=new Set,s=new Map;for(var a of t)xw(a,i,o,s);s=new Map;var l=[...p.current.keys()].filter(m=>this.current.has(m)?this.current.get(m)[0]!==m:!0);for(const m of j(this,fc))(m.f&(ir|Pn|ep))===0&&Lm(m,l,s)&&((m.f&(Al|ii))!==0?(qt(m,xn),p.schedule(m)):j(p,so).add(m));if(j(p,$n).length>0){p.apply();for(var c of j(p,$n))Ot(d=p,Xt,np).call(d,c,[],[]);st(p,$n,[])}p.deactivate()}}for(const p of Bo)j(p,$o).has(this)&&(j(p,$o).delete(this),j(p,$o).size===0&&!Ot(u=p,Xt,ld).call(u)&&(p.activate(),Ot(h=p,Xt,cd).call(h)))};let Ui=Xu;function ww(n){var e=Qs;Qs=!0;try{for(var t;;){if(kC(),Be===null)return t;Be.flush()}}finally{Qs=e}}function AC(){try{QS()}catch(n){lo(n,tp)}}let Dr=null;function Tv(n){var e=n.length;if(e!==0){for(var t=0;t<e;){var r=n[t++];if((r.f&(ir|Pn))===0&&wc(r)&&(Dr=new Set,ya(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Vw(r),(Dr==null?void 0:Dr.size)>0)){rs.clear();for(const i of Dr){if((i.f&(ir|Pn))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)Dr.has(s)&&(Dr.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){const l=o[a];(l.f&(ir|Pn))===0&&ya(l)}}Dr.clear()}}Dr=null}}function xw(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&Dn)!==0?xw(i,e,t,r):(o&(Al|ii))!==0&&(o&xn)===0&&Lm(i,e,r)&&(qt(i,xn),Pm(i))}}function Lm(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(ma.call(e,i))return!0;if((i.f&Dn)!==0&&Lm(i,e,t))return t.set(i,!0),!0}return t.set(n,!1),!1}function Pm(n){Be.schedule(n)}function kw(n,e){if(!((n.f&zr)!==0&&(n.f&rn)!==0)){(n.f&xn)!==0?e.d.push(n):(n.f&di)!==0&&e.m.push(n),qt(n,rn);for(var t=n.first;t!==null;)kw(t,e),t=t.next}}function _w(n){qt(n,rn);for(var e=n.first;e!==null;)_w(e),e=e.next}function EC(n){let e=0,t=ji(0),r;return()=>{Fm()&&(f(t),bc(()=>(e===0&&(r=Yt(()=>n(()=>ll(t)))),e+=1,()=>{si(()=>{e-=1,e===0&&(r==null||r(),r=void 0,ll(t))})})))}}var MC=xo|Rs;function Sw(n,e,t,r){new OC(n,e,t,r)}var cr,Dm,dr,es,Wn,ur,Ln,er,Ri,ts,ao,pa,hc,pc,Ni,Qu,Ut,DC,RC,NC,rp,ud,fd,ip,op;class OC{constructor(e,t,r,i){Ze(this,Ut);jn(this,"parent");jn(this,"is_pending",!1);jn(this,"transform_error");Ze(this,cr);Ze(this,Dm,null);Ze(this,dr);Ze(this,es);Ze(this,Wn);Ze(this,ur,null);Ze(this,Ln,null);Ze(this,er,null);Ze(this,Ri,null);Ze(this,ts,0);Ze(this,ao,0);Ze(this,pa,!1);Ze(this,hc,new Set);Ze(this,pc,new Set);Ze(this,Ni,null);Ze(this,Qu,EC(()=>(st(this,Ni,ji(j(this,ts))),()=>{st(this,Ni,null)})));var o;st(this,cr,e),st(this,dr,t),st(this,es,s=>{var a=it;a.b=this,a.f|=Qh,r(s)}),this.parent=it.b,this.transform_error=i??((o=this.parent)==null?void 0:o.transform_error)??(s=>s),st(this,Wn,Is(()=>{Ot(this,Ut,rp).call(this)},MC))}defer_effect(e){yw(e,j(this,hc),j(this,pc))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!j(this,dr).pending}update_pending_count(e,t){Ot(this,Ut,ip).call(this,e,t),st(this,ts,j(this,ts)+e),!(!j(this,Ni)||j(this,pa))&&(st(this,pa,!0),si(()=>{st(this,pa,!1),j(this,Ni)&&Li(j(this,Ni),j(this,ts))}))}get_effect_pending(){return j(this,Qu).call(this),f(j(this,Ni))}error(e){if(!j(this,dr).onerror&&!j(this,dr).failed)throw e;Be!=null&&Be.is_fork?(j(this,ur)&&Be.skip_effect(j(this,ur)),j(this,Ln)&&Be.skip_effect(j(this,Ln)),j(this,er)&&Be.skip_effect(j(this,er)),Be.on_fork_commit(()=>{Ot(this,Ut,op).call(this,e)})):Ot(this,Ut,op).call(this,e)}}cr=new WeakMap,Dm=new WeakMap,dr=new WeakMap,es=new WeakMap,Wn=new WeakMap,ur=new WeakMap,Ln=new WeakMap,er=new WeakMap,Ri=new WeakMap,ts=new WeakMap,ao=new WeakMap,pa=new WeakMap,hc=new WeakMap,pc=new WeakMap,Ni=new WeakMap,Qu=new WeakMap,Ut=new WeakSet,DC=function(){try{st(this,ur,fr(()=>j(this,es).call(this,j(this,cr))))}catch(e){this.error(e)}},RC=function(e){const t=j(this,dr).failed;t&&st(this,er,fr(()=>{t(j(this,cr),()=>e,()=>()=>{})}))},NC=function(){const e=j(this,dr).pending;e&&(this.is_pending=!0,st(this,Ln,fr(()=>e(j(this,cr)))),si(()=>{var t=st(this,Ri,document.createDocumentFragment()),r=Pi();t.append(r),st(this,ur,Ot(this,Ut,fd).call(this,()=>fr(()=>j(this,es).call(this,r)))),j(this,ao)===0&&(j(this,cr).before(t),st(this,Ri,null),is(j(this,Ln),()=>{st(this,Ln,null)}),Ot(this,Ut,ud).call(this,Be))}))},rp=function(){try{if(this.is_pending=this.has_pending_snippet(),st(this,ao,0),st(this,ts,0),st(this,ur,fr(()=>{j(this,es).call(this,j(this,cr))})),j(this,ao)>0){var e=st(this,Ri,document.createDocumentFragment());jm(j(this,ur),e);const t=j(this,dr).pending;st(this,Ln,fr(()=>t(j(this,cr))))}else Ot(this,Ut,ud).call(this,Be)}catch(t){this.error(t)}},ud=function(e){this.is_pending=!1,e.transfer_effects(j(this,hc),j(this,pc))},fd=function(e){var t=it,r=ct,i=Vt;ui(j(this,Wn)),Cr(j(this,Wn)),va(j(this,Wn).ctx);try{return Ui.ensure(),e()}catch(o){return gw(o),null}finally{ui(t),Cr(r),va(i)}},ip=function(e,t){var r;if(!this.has_pending_snippet()){this.parent&&Ot(r=this.parent,Ut,ip).call(r,e,t);return}st(this,ao,j(this,ao)+e),j(this,ao)===0&&(Ot(this,Ut,ud).call(this,t),j(this,Ln)&&is(j(this,Ln),()=>{st(this,Ln,null)}),j(this,Ri)&&(j(this,cr).before(j(this,Ri)),st(this,Ri,null)))},op=function(e){j(this,ur)&&(zn(j(this,ur)),st(this,ur,null)),j(this,Ln)&&(zn(j(this,Ln)),st(this,Ln,null)),j(this,er)&&(zn(j(this,er)),st(this,er,null));var t=j(this,dr).onerror;let r=j(this,dr).failed;var i=!1,o=!1;const s=()=>{if(i){bC();return}i=!0,o&&rC(),j(this,er)!==null&&is(j(this,er),()=>{st(this,er,null)}),Ot(this,Ut,fd).call(this,()=>{Ot(this,Ut,rp).call(this)})},a=l=>{try{o=!0,t==null||t(l,s),o=!1}catch(c){lo(c,j(this,Wn)&&j(this,Wn).parent)}r&&st(this,er,Ot(this,Ut,fd).call(this,()=>{try{return fr(()=>{var c=it;c.b=this,c.f|=Qh,r(j(this,cr),()=>l,()=>s)})}catch(c){return lo(c,j(this,Wn).parent),null}}))};si(()=>{var l;try{l=this.transform_error(e)}catch(c){lo(c,j(this,Wn)&&j(this,Wn).parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(a,c=>lo(c,j(this,Wn)&&j(this,Wn).parent)):a(l)})};function IC(n,e,t,r){const i=Ns()?rf:zm;var o=n.filter(h=>!h.settled);if(t.length===0&&o.length===0){r(e.map(i));return}var s=it,a=Cw(),l=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(h=>h.promise)):null;function c(h){a();try{r(h)}catch(p){(s.f&ir)===0&&lo(p,s)}El()}if(t.length===0){l.then(()=>c(e.map(i)));return}var d=Tw();function u(){Promise.all(t.map(h=>LC(h))).then(h=>c([...e.map(i),...h])).catch(h=>lo(h,s)).finally(()=>d())}l?l.then(()=>{a(),u(),El()}):u()}function Cw(){var n=it,e=ct,t=Vt,r=Be;return function(o=!0){ui(n),Cr(e),va(t),o&&(n.f&ir)===0&&(r==null||r.activate(),r==null||r.apply())}}function El(n=!0){ui(null),Cr(null),va(null),n&&(Be==null||Be.deactivate())}function Tw(){var n=it,e=n.b,t=Be,r=e.is_rendered();return e.update_pending_count(1,t),t.increment(r,n),(i=!1)=>{e.update_pending_count(-1,t),t.decrement(r,n,i)}}function rf(n){var e=Dn|xn;return it!==null&&(it.f|=Rs),{ctx:Vt,deps:null,effects:null,equals:fw,f:e,fn:n,reactions:null,rv:0,v:tn,wv:0,parent:it,ac:null}}function LC(n,e,t){let r=it;r===null&&JS();var i=void 0,o=ji(tn),s=!ct,a=new Map;return YC(()=>{var p;var l=it,c=sw();i=c.promise;try{Promise.resolve(n()).then(c.resolve,c.reject).finally(El)}catch(m){c.reject(m),El()}var d=Be;if(s){if((l.f&Ds)!==0)var u=Tw();if(r.b.is_rendered())(p=a.get(d))==null||p.reject(Mi),a.delete(d);else{for(const m of a.values())m.reject(Mi);a.clear()}a.set(d,c)}const h=(m,v=void 0)=>{if(u){var g=v===Mi;u(g)}if(!(v===Mi||(l.f&ir)!==0)){if(d.activate(),v)o.f|=mo,Li(o,v);else{(o.f&mo)!==0&&(o.f^=mo),Li(o,m);for(const[y,k]of a){if(a.delete(y),y===d)break;k.reject(Mi)}}d.deactivate()}};c.promise.then(h,m=>h(null,m||"unknown"))}),Hm(()=>{for(const l of a.values())l.reject(Mi)}),new Promise(l=>{function c(d){function u(){d===i?l(o):c(i)}d.then(u,u)}c(i)})}function H(n){const e=rf(n);return Ww(e),e}function zm(n){const e=rf(n);return e.equals=pw,e}function PC(n){var e=n.effects;if(e!==null){n.effects=null;for(var t=0;t<e.length;t+=1)zn(e[t])}}function Bm(n){var e,t=it,r=n.parent;if(!Wi&&r!==null&&(r.f&(ir|Pn))!==0)return vC(),n.v;ui(r);try{n.f&=~ms,PC(n),e=Yw(n)}finally{ui(t)}return e}function Aw(n){var e=Bm(n);if(!n.equals(e)&&(n.wv=qw(),(!(Be!=null&&Be.is_fork)||n.deps===null)&&(Be!==null?Be.capture(n,e,!0):n.v=e,n.deps===null))){qt(n,rn);return}Wi||(gn!==null?(Fm()||Be!=null&&Be.is_fork)&&gn.set(n,e):Im(n))}function zC(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(Mi),r.teardown=pr,r.ac=null,Ml(r,0),Vm(r))}function Ew(n){if(n.effects!==null)for(const e of n.effects)e.teardown&&ya(e)}let sp=new Set;const rs=new Map;let Mw=!1;function ji(n,e){var t={f:0,v:n,reactions:null,equals:fw,rv:0,wv:0};return t}function F(n,e){const t=ji(n);return Ww(t),t}function ap(n,e=!1,t=!0){var i;const r=ji(n);return e||(r.equals=pw),za&&t&&Vt!==null&&Vt.l!==null&&((i=Vt.l).s??(i.s=[])).push(r),r}function b(n,e,t=!1){ct!==null&&(!Ir||(ct.f&ep)!==0)&&Ns()&&(ct.f&(Dn|ii|Al|ep))!==0&&(wr===null||!ma.call(wr,n))&&nC();let r=t?dt(e):e;return Li(n,r,ad)}function Li(n,e,t=null){if(!n.equals(e)){rs.set(n,Wi?e:n.v);var r=Ui.ensure();if(r.capture(n,e),(n.f&Dn)!==0){const i=n;(n.f&xn)!==0&&Bm(i),gn===null&&Im(i)}n.wv=qw(),Ow(n,xn,t),Ns()&&it!==null&&(it.f&rn)!==0&&(it.f&(zr|Vi))===0&&(lr===null?GC([n]):lr.push(n)),!r.is_fork&&sp.size>0&&!Mw&&BC()}return e}function BC(){Mw=!1;for(const n of sp)(n.f&rn)!==0&&qt(n,di),wc(n)&&ya(n);sp.clear()}function Id(n,e=1){var t=f(n),r=e===1?t++:t--;return b(n,t),r}function ll(n){b(n,n.v+1)}function Ow(n,e,t){var r=n.reactions;if(r!==null)for(var i=Ns(),o=r.length,s=0;s<o;s++){var a=r[s],l=a.f;if(!(!i&&a===it)){var c=(l&xn)===0;if(c&&qt(a,e),(l&Dn)!==0){var d=a;gn==null||gn.delete(d),(l&ms)===0&&(l&br&&(it===null||(it.f&Nd)===0)&&(a.f|=ms),Ow(d,di,t))}else if(c){var u=a;(l&ii)!==0&&Dr!==null&&Dr.add(u),t!==null?t.push(u):Pm(u)}}}}function dt(n){if(typeof n!="object"||n===null||oi in n)return n;const e=Nm(n);if(e!==FS&&e!==HS)return n;var t=new Map,r=Rm(n),i=F(0),o=ss,s=a=>{if(ss===o)return a();var l=ct,c=ss;Cr(null),Dv(o);var d=a();return Cr(l),Dv(c),d};return r&&t.set("length",F(n.length)),new Proxy(n,{defineProperty(a,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&eC();var d=t.get(l);return d===void 0?s(()=>{var u=F(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(()=>F(tn));t.set(l,d),ll(i)}}else b(c,tn),ll(i);return!0},get(a,l,c){var p;if(l===oi)return n;var d=t.get(l),u=l in a;if(d===void 0&&(!u||(p=po(a,l))!=null&&p.writable)&&(d=s(()=>{var m=dt(u?a[l]:tn),v=F(m);return v}),t.set(l,d)),d!==void 0){var h=f(d);return h===tn?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!==tn)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(a,l){var h;if(l===oi)return!0;var c=t.get(l),d=c!==void 0&&c.v!==tn||Reflect.has(a,l);if(c!==void 0||it!==null&&(!d||(h=po(a,l))!=null&&h.writable)){c===void 0&&(c=s(()=>{var p=d?dt(a[l]):tn,m=F(p);return m}),t.set(l,c));var u=f(c);if(u===tn)return!1}return d},set(a,l,c,d){var S;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,tn):p in a&&(m=s(()=>F(tn)),t.set(p+"",m))}if(u===void 0)(!h||(S=po(a,l))!=null&&S.writable)&&(u=s(()=>F(void 0)),b(u,dt(c)),t.set(l,u));else{h=u.v!==tn;var v=s(()=>dt(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"),k=Number(l);Number.isInteger(k)&&k>=y.v&&b(y,k+1)}ll(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!==tn});for(var[c,d]of t)d.v!==tn&&!(c in a)&&l.push(c);return l},setPrototypeOf(){tC()}})}function Av(n){try{if(n!==null&&typeof n=="object"&&oi in n)return n[oi]}catch{}return n}function FC(n,e){return Object.is(Av(n),Av(e))}var Ev,Dw,Rw,Nw;function HC(){if(Ev===void 0){Ev=window,Dw=/Firefox/.test(navigator.userAgent);var n=Element.prototype,e=Node.prototype,t=Text.prototype;Rw=po(e,"firstChild").get,Nw=po(e,"nextSibling").get,_v(n)&&(n.__click=void 0,n.__className=void 0,n.__attributes=null,n.__style=void 0,n.__e=void 0),_v(t)&&(t.__t=void 0)}}function Pi(n=""){return document.createTextNode(n)}function ti(n){return Rw.call(n)}function yc(n){return Nw.call(n)}function x(n,e){return ti(n)}function ze(n,e=!1){{var t=ti(n);return t instanceof Comment&&t.data===""?yc(t):t}}function _(n,e=1,t=!1){let r=n;for(;e--;)r=yc(r);return r}function VC(n){n.textContent=""}function Iw(){return!1}function Lw(n,e,t){return document.createElementNS(e??uw,n,void 0)}function UC(n,e){{const t=document.body;n.autofocus=!0,si(()=>{document.activeElement===t&&n.focus()})}}let Mv=!1;function jC(){Mv||(Mv=!0,document.addEventListener("reset",n=>{Promise.resolve().then(()=>{var e;if(!n.defaultPrevented)for(const t of n.target.elements)(e=t.__on_r)==null||e.call(t)})},{capture:!0}))}function of(n){var e=ct,t=it;Cr(null),ui(null);try{return n()}finally{Cr(e),ui(t)}}function Pw(n,e,t,r=t){n.addEventListener(e,()=>of(t));const i=n.__on_r;i?n.__on_r=()=>{i(),r(!0)}:n.__on_r=()=>r(!0),jC()}function WC(n){it===null&&(ct===null&&XS(),GS()),Wi&&ZS()}function KC(n,e){var t=e.last;t===null?e.last=e.first=n:(t.next=n,n.prev=t,e.last=n)}function vi(n,e){var t=it;t!==null&&(t.f&Pn)!==0&&(n|=Pn);var r={ctx:Vt,deps:null,nodes:null,f:n|xn|br,first:null,fn:e,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};Be==null||Be.register_created_effect(r);var i=r;if((n&ga)!==0)Ys!==null?Ys.push(r):Ui.ensure().schedule(r);else if(e!==null){try{ya(r)}catch(s){throw zn(r),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&Rs)===0&&(i=i.first,(n&ii)!==0&&(n&xo)!==0&&i!==null&&(i.f|=xo))}if(i!==null&&(i.parent=t,t!==null&&KC(i,t),ct!==null&&(ct.f&Dn)!==0&&(n&Vi)===0)){var o=ct;(o.effects??(o.effects=[])).push(i)}return r}function Fm(){return ct!==null&&!Ir}function Hm(n){const e=vi(nf,null);return qt(e,rn),e.teardown=n,e}function de(n){WC();var e=it.f,t=!ct&&(e&zr)!==0&&(e&Ds)===0;if(t){var r=Vt;(r.e??(r.e=[])).push(n)}else return zw(n)}function zw(n){return vi(ga|WS,n)}function qC(n){Ui.ensure();const e=vi(Vi|Rs,n);return()=>{zn(e)}}function JC(n){Ui.ensure();const e=vi(Vi|Rs,n);return(t={})=>new Promise(r=>{t.outro?is(e,()=>{zn(e),r(void 0)}):(zn(e),r(void 0))})}function Bw(n){return vi(ga,n)}function YC(n){return vi(Al|Rs,n)}function bc(n,e=0){return vi(nf|e,n)}function Y(n,e=[],t=[],r=[]){IC(r,e,t,i=>{vi(nf,()=>n(...i.map(f)))})}function Is(n,e=0){var t=vi(ii|e,n);return t}function fr(n){return vi(zr|Rs,n)}function Fw(n){var e=n.teardown;if(e!==null){const t=Wi,r=ct;Ov(!0),Cr(null);try{e.call(null)}finally{Ov(t),Cr(r)}}}function Vm(n,e=!1){var t=n.first;for(n.first=n.last=null;t!==null;){const i=t.ac;i!==null&&of(()=>{i.abort(Mi)});var r=t.next;(t.f&Vi)!==0?t.parent=null:zn(t,e),t=r}}function ZC(n){for(var e=n.first;e!==null;){var t=e.next;(e.f&zr)===0&&zn(e),e=t}}function zn(n,e=!0){var t=!1;(e||(n.f&jS)!==0)&&n.nodes!==null&&n.nodes.end!==null&&(Hw(n.nodes.start,n.nodes.end),t=!0),qt(n,$h),Vm(n,e&&!t),Ml(n,0);var r=n.nodes&&n.nodes.t;if(r!==null)for(const o of r)o.stop();Fw(n),n.f^=$h,n.f|=ir;var i=n.parent;i!==null&&i.first!==null&&Vw(n),n.next=n.prev=n.teardown=n.ctx=n.deps=n.fn=n.nodes=n.ac=n.b=null}function Hw(n,e){for(;n!==null;){var t=n===e?null:yc(n);n.remove(),n=t}}function Vw(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 is(n,e,t=!0){var r=[];Uw(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 Uw(n,e,t){if((n.f&Pn)===0){n.f^=Pn;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&Vi)===0){var s=(i.f&xo)!==0||(i.f&zr)!==0&&(n.f&ii)!==0;Uw(i,e,s?t:!1)}i=o}}}function Um(n){jw(n,!0)}function jw(n,e){if((n.f&Pn)!==0){n.f^=Pn,(n.f&rn)===0&&(qt(n,xn),Ui.ensure().schedule(n));for(var t=n.first;t!==null;){var r=t.next,i=(t.f&xo)!==0||(t.f&zr)!==0;jw(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 jm(n,e){if(n.nodes)for(var t=n.nodes.start,r=n.nodes.end;t!==null;){var i=t===r?null:yc(t);e.append(t),t=i}}let hd=!1,Wi=!1;function Ov(n){Wi=n}let ct=null,Ir=!1;function Cr(n){ct=n}let it=null;function ui(n){it=n}let wr=null;function Ww(n){ct!==null&&(wr===null?wr=[n]:wr.push(n))}let Kn=null,Gn=0,lr=null;function GC(n){lr=n}let Kw=1,Ko=0,ss=Ko;function Dv(n){ss=n}function qw(){return++Kw}function wc(n){var e=n.f;if((e&xn)!==0)return!0;if(e&Dn&&(n.f&=~ms),(e&di)!==0){for(var t=n.deps,r=t.length,i=0;i<r;i++){var o=t[i];if(wc(o)&&Aw(o),o.wv>n.wv)return!0}(e&br)!==0&&gn===null&&qt(n,rn)}return!1}function Jw(n,e,t=!0){var r=n.reactions;if(r!==null&&!(wr!==null&&ma.call(wr,n)))for(var i=0;i<r.length;i++){var o=r[i];(o.f&Dn)!==0?Jw(o,e,!1):e===o&&(t?qt(o,xn):(o.f&rn)!==0&&qt(o,di),Pm(o))}}function Yw(n){var v;var e=Kn,t=Gn,r=lr,i=ct,o=wr,s=Vt,a=Ir,l=ss,c=n.f;Kn=null,Gn=0,lr=null,ct=(c&(zr|Vi))===0?n:null,wr=null,va(n.ctx),Ir=!1,ss=++Ko,n.ac!==null&&(of(()=>{n.ac.abort(Mi)}),n.ac=null);try{n.f|=Nd;var d=n.fn,u=d();n.f|=Ds;var h=n.deps,p=Be==null?void 0:Be.is_fork;if(Kn!==null){var m;if(p||Ml(n,Gn),h!==null&&Gn>0)for(h.length=Gn+Kn.length,m=0;m<Kn.length;m++)h[Gn+m]=Kn[m];else n.deps=h=Kn;if(Fm()&&(n.f&br)!==0)for(m=Gn;m<h.length;m++)((v=h[m]).reactions??(v.reactions=[])).push(n)}else!p&&h!==null&&Gn<h.length&&(Ml(n,Gn),h.length=Gn);if(Ns()&&lr!==null&&!Ir&&h!==null&&(n.f&(Dn|di|xn))===0)for(m=0;m<lr.length;m++)Jw(lr[m],n);if(i!==null&&i!==n){if(Ko++,i.deps!==null)for(let g=0;g<t;g+=1)i.deps[g].rv=Ko;if(e!==null)for(const g of e)g.rv=Ko;lr!==null&&(r===null?r=lr:r.push(...lr))}return(n.f&mo)!==0&&(n.f^=mo),u}catch(g){return gw(g)}finally{n.f^=Nd,Kn=e,Gn=t,lr=r,ct=i,wr=o,va(s),Ir=a,ss=l}}function XC(n,e){let t=e.reactions;if(t!==null){var r=zS.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&Dn)!==0&&(Kn===null||!ma.call(Kn,e))){var o=e;(o.f&br)!==0&&(o.f^=br,o.f&=~ms),o.v!==tn&&Im(o),zC(o),Ml(o,0)}}function Ml(n,e){var t=n.deps;if(t!==null)for(var r=e;r<t.length;r++)XC(n,t[r])}function ya(n){var e=n.f;if((e&ir)===0){qt(n,rn);var t=it,r=hd;it=n,hd=!0;try{(e&(ii|aw))!==0?ZC(n):Vm(n),Fw(n);var i=Yw(n);n.teardown=typeof i=="function"?i:null,n.wv=Kw;var o;PS&&wC&&(n.f&xn)!==0&&n.deps}finally{hd=r,it=t}}}async function QC(){await Promise.resolve(),ww()}function f(n){var e=n.f,t=(e&Dn)!==0;if(ct!==null&&!Ir){var r=it!==null&&(it.f&ir)!==0;if(!r&&(wr===null||!ma.call(wr,n))){var i=ct.deps;if((ct.f&Nd)!==0)n.rv<Ko&&(n.rv=Ko,Kn===null&&i!==null&&i[Gn]===n?Gn++:Kn===null?Kn=[n]:Kn.push(n));else{(ct.deps??(ct.deps=[])).push(n);var o=n.reactions;o===null?n.reactions=[ct]:ma.call(o,ct)||o.push(ct)}}}if(Wi&&rs.has(n))return rs.get(n);if(t){var s=n;if(Wi){var a=s.v;return((s.f&rn)===0&&s.reactions!==null||Gw(s))&&(a=Bm(s)),rs.set(s,a),a}var l=(s.f&br)===0&&!Ir&&ct!==null&&(hd||(ct.f&br)!==0),c=(s.f&Ds)===0;wc(s)&&(l&&(s.f|=br),Aw(s)),l&&!c&&(Ew(s),Zw(s))}if(gn!=null&&gn.has(n))return gn.get(n);if((n.f&mo)!==0)throw n.v;return n.v}function Zw(n){if(n.f|=br,n.deps!==null)for(const e of n.deps)(e.reactions??(e.reactions=[])).push(n),(e.f&Dn)!==0&&(e.f&br)===0&&(Ew(e),Zw(e))}function Gw(n){if(n.v===tn)return!0;if(n.deps===null)return!1;for(const e of n.deps)if(rs.has(e)||(e.f&Dn)!==0&&Gw(e))return!0;return!1}function Yt(n){var e=Ir;try{return Ir=!0,n()}finally{Ir=e}}function $C(n){if(!(typeof n!="object"||!n||n instanceof EventTarget)){if(oi in n)lp(n);else if(!Array.isArray(n))for(let e in n){const t=n[e];typeof t=="object"&&t&&oi in t&&lp(t)}}}function lp(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{lp(n[r],e)}catch{}const t=Nm(n);if(t!==Object.prototype&&t!==Array.prototype&&t!==Map.prototype&&t!==Set.prototype&&t!==Date.prototype){const r=ow(t);for(let i in r){const o=r[i].get;if(o)try{o.call(n)}catch{}}}}}const eT=["touchstart","touchmove"];function tT(n){return eT.includes(n)}const qo=Symbol("events"),Xw=new Set,cp=new Set;function nT(n,e,t,r={}){function i(o){if(r.capture||dp.call(e,o),!o.cancelBubble)return of(()=>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 wt(n,e,t,r,i){var o={capture:r,passive:i},s=nT(n,e,t,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Hm(()=>{e.removeEventListener(n,s,o)})}function P(n,e,t){(e[qo]??(e[qo]={}))[n]=t}function $e(n){for(var e=0;e<n.length;e++)Xw.add(n[e]);for(var t of cp)t(n)}let Rv=null;function dp(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;Rv=n;var s=0,a=Rv===n&&n[qo];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){n[qo]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||n.target,o!==e){BS(n,"currentTarget",{configurable:!0,get(){return o||t}});var d=ct,u=it;Cr(null),ui(null);try{for(var h,p=[];o!==null;){var m=o.assignedSlot||o.parentNode||o.host||null;try{var v=(y=o[qo])==null?void 0:y[r];v!=null&&(!o.disabled||n.target===o)&&v.call(o,n)}catch(k){h?p.push(k):h=k}if(n.cancelBubble||m===e||m===null)break;o=m}if(h){for(let k of p)queueMicrotask(()=>{throw k});throw h}}finally{n[qo]=e,delete n.currentTarget,Cr(d),ui(u)}}}var rw;const qf=((rw=globalThis==null?void 0:globalThis.window)==null?void 0:rw.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:n=>n});function rT(n){return(qf==null?void 0:qf.createHTML(n))??n}function Qw(n){var e=Lw("template");return e.innerHTML=rT(n.replaceAll("<!>","<!---->")),e.content}function gs(n,e){var t=it;t.nodes===null&&(t.nodes={start:n,end:e,a:null,t:null})}function E(n,e){var t=(e&hC)!==0,r=(e&pC)!==0,i,o=!n.startsWith("<!>");return()=>{i===void 0&&(i=Qw(o?n:"<!>"+n),t||(i=ti(i)));var s=r||Dw?document.importNode(i,!0):i.cloneNode(!0);if(t){var a=ti(s),l=s.lastChild;gs(a,l)}else gs(s,s);return s}}function iT(n,e,t="svg"){var r=!n.startsWith("<!>"),i=`<${t}>${r?n:"<!>"+n}</${t}>`,o;return()=>{if(!o){var s=Qw(i),a=ti(s);o=ti(a)}var l=o.cloneNode(!0);return gs(l,l),l}}function Er(n,e){return iT(n,e,"svg")}function an(n=""){{var e=Pi(n+"");return gs(e,e),e}}function Rt(){var n=document.createDocumentFragment(),e=document.createComment(""),t=Pi();return n.append(e,t),gs(e,t),n}function T(n,e){n!==null&&n.before(e)}function te(n,e){var t=e==null?"":typeof e=="object"?`${e}`:e;t!==(n.__t??(n.__t=n.nodeValue))&&(n.__t=t,n.nodeValue=`${t}`)}function oT(n,e){return sT(n,e)}const zc=new Map;function sT(n,{target:e,anchor:t,props:r={},events:i,context:o,intro:s=!0,transformError:a}){HC();var l=void 0,c=JC(()=>{var d=t??e.appendChild(Pi());Sw(d,{pending:()=>{}},p=>{qe({});var m=Vt;o&&(m.c=o),i&&(r.$$events=i),l=n(p,r)||{},Je()},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=tT(v);for(const S of[e,document]){var y=zc.get(S);y===void 0&&(y=new Map,zc.set(S,y));var k=y.get(v);k===void 0?(S.addEventListener(v,dp,{passive:g}),y.set(v,1)):y.set(v,k+1)}}}};return h(tf(Xw)),cp.add(h),()=>{var g;for(var p of u)for(const y of[e,document]){var m=zc.get(y),v=m.get(p);--v==0?(y.removeEventListener(p,dp),m.delete(p),m.size===0&&zc.delete(y)):m.set(p,v)}cp.delete(h),d!==t&&((g=d.parentNode)==null||g.removeChild(d))}});return aT.set(l,c),l}let aT=new WeakMap;var Rr,$r,tr,ns,mc,gc,$u;class xc{constructor(e,t=!0){jn(this,"anchor");Ze(this,Rr,new Map);Ze(this,$r,new Map);Ze(this,tr,new Map);Ze(this,ns,new Set);Ze(this,mc,!0);Ze(this,gc,e=>{if(j(this,Rr).has(e)){var t=j(this,Rr).get(e),r=j(this,$r).get(t);if(r)Um(r),j(this,ns).delete(t);else{var i=j(this,tr).get(t);i&&(j(this,$r).set(t,i.effect),j(this,tr).delete(t),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[o,s]of j(this,Rr)){if(j(this,Rr).delete(o),o===e)break;const a=j(this,tr).get(s);a&&(zn(a.effect),j(this,tr).delete(s))}for(const[o,s]of j(this,$r)){if(o===t||j(this,ns).has(o))continue;const a=()=>{if(Array.from(j(this,Rr).values()).includes(o)){var c=document.createDocumentFragment();jm(s,c),c.append(Pi()),j(this,tr).set(o,{effect:s,fragment:c})}else zn(s);j(this,ns).delete(o),j(this,$r).delete(o)};j(this,mc)||!r?(j(this,ns).add(o),is(s,a,!1)):a()}}});Ze(this,$u,e=>{j(this,Rr).delete(e);const t=Array.from(j(this,Rr).values());for(const[r,i]of j(this,tr))t.includes(r)||(zn(i.effect),j(this,tr).delete(r))});this.anchor=e,st(this,mc,t)}ensure(e,t){var r=Be,i=Iw();if(t&&!j(this,$r).has(e)&&!j(this,tr).has(e))if(i){var o=document.createDocumentFragment(),s=Pi();o.append(s),j(this,tr).set(e,{effect:fr(()=>t(s)),fragment:o})}else j(this,$r).set(e,fr(()=>t(this.anchor)));if(j(this,Rr).set(r,e),i){for(const[a,l]of j(this,$r))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of j(this,tr))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(j(this,gc)),r.ondiscard(j(this,$u))}else j(this,gc).call(this,r)}}Rr=new WeakMap,$r=new WeakMap,tr=new WeakMap,ns=new WeakMap,mc=new WeakMap,gc=new WeakMap,$u=new WeakMap;const lT=0,Nv=1,cT=2;function dT(n,e,t,r,i){var o=Ns(),s=tn,a=o?ji(s):ap(s,!1,!1),l=o?ji(s):ap(s,!1,!1),c=new xc(n);Is(()=>{var d=Be;d.deactivate();var u=e();d.activate();var h=!1;if(VS(u)){var p=Cw(),m=!1;const v=g=>{if(!h){m=!0,p(!1),Ui.ensure();try{g()}finally{El(!1),Qs||ww()}}};u.then(g=>{v(()=>{Li(a,g),c.ensure(Nv,r&&(y=>r(y,a)))})},g=>{v(()=>{if(Li(l,g),c.ensure(cT,i&&(y=>i(y,l))),!i)throw l.v})}),si(()=>{m||v(()=>{c.ensure(lT,t)})})}else Li(a,u),c.ensure(Nv,r&&(v=>r(v,a)));return()=>{h=!0}})}function J(n,e,t=!1){var r=new xc(n),i=t?xo:0;function o(s,a){r.ensure(s,a)}Is(()=>{var s=!1;e((a,l=0)=>{s=!0,o(l,a)}),s||o(-1,null)},i)}const uT=Symbol("NaN");function up(n,e,t){var r=new xc(n),i=!Ns();Is(()=>{var o=e();o!==o&&(o=uT),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,t)})}function ba(n,e){return e}function fT(n,e,t){for(var r=[],i=e.length,o,s=e.length,a=0;a<i;a++){let u=e[a];is(u,()=>{if(o){if(o.pending.delete(u),o.done.add(u),o.pending.size===0){var h=n.outrogroups;fp(n,tf(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;VC(d),d.append(c),n.items.clear()}fp(n,e,!l)}else o={pending:new Set(e),done:new Set},(n.outrogroups??(n.outrogroups=new Set)).add(o)}function fp(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|=ei;const s=document.createDocumentFragment();jm(o,s)}else zn(e[i],t)}}var Iv;function mt(n,e,t,r,i,o=null){var s=n,a=new Map,l=(e&dw)!==0;if(l){var c=n;s=c.appendChild(Pi())}var d=null,u=zm(()=>{var S=t();return Rm(S)?S:S==null?[]:tf(S)}),h,p=new Map,m=!0;function v(S){(k.effect.f&ir)===0&&(k.pending.delete(S),k.fallback=d,hT(k,h,s,e,r),d!==null&&(h.length===0?(d.f&ei)===0?Um(d):(d.f^=ei,tl(d,null,s)):is(d,()=>{d=null})))}function g(S){k.pending.delete(S)}var y=Is(()=>{h=f(u);for(var S=h.length,C=new Set,A=Be,W=Iw(),z=0;z<S;z+=1){var D=h[z],O=r(D,z),U=m?null:a.get(O);U?(U.v&&Li(U.v,D),U.i&&Li(U.i,z),W&&A.unskip_effect(U.e)):(U=pT(a,m?s:Iv??(Iv=Pi()),D,O,z,i,e,t),m||(U.e.f|=ei),a.set(O,U)),C.add(O)}if(S===0&&o&&!d&&(m?d=fr(()=>o(s)):(d=fr(()=>o(Iv??(Iv=Pi()))),d.f|=ei)),S>C.size&&YS(),!m)if(p.set(A,C),W){for(const[ee,R]of a)C.has(ee)||A.skip_effect(R.e);A.oncommit(v),A.ondiscard(g)}else v(A);f(u)}),k={effect:y,items:a,pending:p,outrogroups:null,fallback:d};m=!1}function Ya(n){for(;n!==null&&(n.f&zr)===0;)n=n.next;return n}function hT(n,e,t,r,i){var U,ee,R,K,ne,X,N,q,L;var o=(r&sC)!==0,s=e.length,a=n.items,l=Ya(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&ei)===0&&((ee=(U=g.nodes)==null?void 0:U.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 V of n.outrogroups)V.pending.delete(g),V.done.delete(g);if((g.f&Pn)!==0&&(Um(g),o&&((K=(R=g.nodes)==null?void 0:R.a)==null||K.unfix(),(u??(u=new Set)).delete(g))),(g.f&ei)!==0)if(g.f^=ei,g===l)tl(g,null,t);else{var k=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),Zi(n,d,g),Zi(n,g,k),tl(g,k,t),d=g,h=[],p=[],l=Ya(d.next);continue}if(g!==l){if(c!==void 0&&c.has(g)){if(h.length<p.length){var S=p[0],C;d=S.prev;var A=h[0],W=h[h.length-1];for(C=0;C<h.length;C+=1)tl(h[C],S,t);for(C=0;C<p.length;C+=1)c.delete(p[C]);Zi(n,A.prev,W.next),Zi(n,d,A),Zi(n,W,S),l=S,d=W,y-=1,h=[],p=[]}else c.delete(g),tl(g,l,t),Zi(n,g.prev,g.next),Zi(n,g,d===null?n.effect.first:d.next),Zi(n,d,g),d=g;continue}for(h=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=Ya(l.next);if(l===null)continue}(g.f&ei)===0&&h.push(g),d=g,l=Ya(g.next)}if(n.outrogroups!==null){for(const V of n.outrogroups)V.pending.size===0&&(fp(n,tf(V.done)),(ne=n.outrogroups)==null||ne.delete(V));n.outrogroups.size===0&&(n.outrogroups=null)}if(l!==null||c!==void 0){var z=[];if(c!==void 0)for(g of c)(g.f&Pn)===0&&z.push(g);for(;l!==null;)(l.f&Pn)===0&&l!==n.fallback&&z.push(l),l=Ya(l.next);var D=z.length;if(D>0){var O=(r&dw)!==0&&s===0?t:null;if(o){for(y=0;y<D;y+=1)(N=(X=z[y].nodes)==null?void 0:X.a)==null||N.measure();for(y=0;y<D;y+=1)(L=(q=z[y].nodes)==null?void 0:q.a)==null||L.fix()}fT(n,z,O)}}o&&si(()=>{var V,re;if(u!==void 0)for(g of u)(re=(V=g.nodes)==null?void 0:V.a)==null||re.apply()})}function pT(n,e,t,r,i,o,s,a){var l=(s&iC)!==0?(s&aC)===0?ap(t,!1,!1):ji(t):null,c=(s&oC)!==0?ji(i):null;return{v:l,i:c,e:fr(()=>(o(e,l??t,c??i,a),()=>{n.delete(r)}))}}function tl(n,e,t){if(n.nodes)for(var r=n.nodes.start,i=n.nodes.end,o=e&&(e.f&ei)===0?e.nodes.start:t;r!==null;){var s=yc(r);if(o.before(r),r===i)return;r=s}}function Zi(n,e,t){e===null?n.effect.first=t:e.next=t,t===null?n.effect.last=e:t.prev=e}function mT(n,e,t=!1,r=!1,i=!1,o=!1){var s=n,a="";if(t)var l=n;Y(()=>{var c=it;if(a!==(a=e()??"")){if(t){c.nodes=null,l.innerHTML=a,a!==""&&gs(ti(l),l.lastChild);return}if(c.nodes!==null&&(Hw(c.nodes.start,c.nodes.end),c.nodes=null),a!==""){var d=r?mC:i?gC:void 0,u=Lw(r?"svg":i?"math":"template",d);u.innerHTML=a;var h=r||i?u:u.content;if(gs(ti(h),h.lastChild),r||i)for(;ti(h);)s.before(ti(h));else s.before(h)}}})}function Wm(n,e,...t){var r=new xc(n);Is(()=>{const i=e()??null;r.ensure(i,i&&(o=>i(o,...t)))},xo)}function gT(n,e,t){var r=new xc(n);Is(()=>{var i=e()??null;r.ensure(i,i&&(o=>t(o,i)))},xo)}function Ol(n,e,t){Bw(()=>{var r=Yt(()=>e(n,t==null?void 0:t())||{});if(t&&(r!=null&&r.update)){var i=!1,o={};bc(()=>{var s=t();$C(s),i&&hw(o,s)&&(o=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}const Lv=[...`
|
|
3
|
-
\r\f \v\uFEFF`];function vT(n,e,t){var r=""+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||Lv.includes(r[s-1]))&&(a===r.length||Lv.includes(r[a]))?r=(s===0?"":r.substring(0,s))+r.substring(a+1):s=a}}return r===""?null:r}function yT(n,e){return n==null?null:String(n)}function $w(n,e,t,r,i,o){var s=n.__className;if(s!==t||s===void 0){var a=vT(t,r,o);a==null?n.removeAttribute("class"):n.className=a,n.__className=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 oe(n,e,t,r){var i=n.__style;if(i!==e){var o=yT(e);o==null?n.removeAttribute("style"):n.style.cssText=o,n.__style=e}return r}function Km(n,e,t=!1){if(n.multiple){if(e==null)return;if(!Rm(e))return yC();for(var r of n.options)r.selected=e.includes(Pv(r));return}for(r of n.options){var i=Pv(r);if(FC(i,e)){r.selected=!0;return}}(!t||e!==void 0)&&(n.selectedIndex=-1)}function ex(n){var e=new MutationObserver(()=>{Km(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Hm(()=>{e.disconnect()})}function Pv(n){return"__value"in n?n.__value:n.value}const bT=Symbol("is custom element"),wT=Symbol("is html"),xT=qS?"progress":"PROGRESS";function Pr(n,e){var t=qm(n);t.value===(t.value=e??void 0)||n.value===e&&(e!==0||n.nodeName!==xT)||(n.value=e??"")}function vs(n,e){var t=qm(n);t.checked!==(t.checked=e??void 0)&&(n.checked=e)}function Z(n,e,t,r){var i=qm(n);i[e]!==(i[e]=t)&&(e==="loading"&&(n[KS]=t),t==null?n.removeAttribute(e):typeof t!="string"&&kT(n).includes(e)?n[e]=t:n.setAttribute(e,t))}function qm(n){return n.__attributes??(n.__attributes={[bT]:n.nodeName.includes("-"),[wT]:n.namespaceURI===uw})}var zv=new Map;function kT(n){var e=n.getAttribute("is")||n.nodeName,t=zv.get(e);if(t)return t;zv.set(e,t=[]);for(var r,i=n,o=Element.prototype;o!==i;){r=ow(i);for(var s in r)r[s].set&&t.push(s);i=Nm(i)}return t}function ys(n,e,t=e){var r=new WeakSet;Pw(n,"input",async i=>{var o=i?n.defaultValue:n.value;if(o=Yf(n)?Zf(o):o,t(o),Be!==null&&r.add(Be),await QC(),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))}}}),Yt(e)==null&&n.value&&(t(Yf(n)?Zf(n.value):n.value),Be!==null&&r.add(Be)),bc(()=>{var i=e();if(n===document.activeElement){var o=Be;if(r.has(o))return}Yf(n)&&i===Zf(n.value)||n.type==="date"&&!i&&!n.value||i!==n.value&&(n.value=i??"")})}function Jf(n,e,t=e){Pw(n,"change",r=>{var i=r?n.defaultChecked:n.checked;t(i)}),Yt(e)==null&&t(n.checked),bc(()=>{var r=e();n.checked=!!r})}function Yf(n){var e=n.type;return e==="number"||e==="range"}function Zf(n){return n===""?null:+n}function Bv(n,e){return n===e||(n==null?void 0:n[oi])===e}function kt(n={},e,t,r){var i=Vt.r,o=it;return Bw(()=>{var s,a;return bc(()=>{s=a,a=(r==null?void 0:r())||[],Yt(()=>{n!==t(...a)&&(e(n,...a),s&&Bv(t(...s),n)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&$h;)l=l.parent;const c=()=>{a&&Bv(t(...a),n)&&e(null,...a)},d=l.teardown;l.teardown=()=>{c(),d==null||d()}}}),n}const _T={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 ST(n,e,t){return new Proxy({props:n,exclude:e},_T)}const CT={get(n,e){let t=n.props.length;for(;t--;){let r=n.props[t];if(Ja(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];Ja(i)&&(i=i());const o=po(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(Ja(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r){const i=po(r,e);return i&&!i.configurable&&(i.configurable=!0),i}}},has(n,e){if(e===oi||e===lw)return!1;for(let t of n.props)if(Ja(t)&&(t=t()),t!=null&&e in t)return!0;return!1},ownKeys(n){const e=[];for(let t of n.props)if(Ja(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 Bc(...n){return new Proxy({props:n},CT)}function ft(n,e,t,r){var S;var i=!za||(t&cC)!==0,o=(t&uC)!==0,s=(t&fC)!==0,a=r,l=!0,c=()=>(l&&(l=!1,a=s?Yt(r):r),a);let d;if(o){var u=oi in n||lw in n;d=((S=po(n,e))==null?void 0:S.set)??(u&&e in n?C=>n[e]=C:void 0)}var h,p=!1;o?[h,p]=SC(()=>n[e]):h=n[e],h===void 0&&r!==void 0&&(h=c(),d&&(i&&$S(),d(h)));var m;if(i?m=()=>{var C=n[e];return C===void 0?c():(l=!0,C)}:m=()=>{var C=n[e];return C!==void 0&&(a=void 0),C===void 0?a:C},i&&(t&dC)===0)return m;if(d){var v=n.$$legacy;return(function(C,A){return arguments.length>0?((!i||!A||v||p)&&d(A?m():C),C):m()})}var g=!1,y=((t&lC)!==0?rf:zm)(()=>(g=!1,m()));o&&f(y);var k=it;return(function(C,A){if(arguments.length>0){const W=A?f(y):i&&o?dt(C):C;return b(y,W),g=!0,a!==void 0&&(a=W),C}return Wi&&g||(k.f&ir)!==0?y.v:f(y)})}function sf(n){Vt===null&&cw(),za&&Vt.l!==null?TT(Vt).m.push(n):de(()=>{const e=Yt(n);if(typeof e=="function")return e})}function yi(n){Vt===null&&cw(),sf(()=>()=>Yt(n))}function TT(n){var e=n.l;return e.u??(e.u={a:[],b:[],m:[]})}const AT="5";var iw;typeof window<"u"&&((iw=window.__svelte??(window.__svelte={})).v??(iw.v=new Set)).add(AT);xC();const ET="upload://";function MT(n){return n.startsWith(ET)}const pd=n=>n,bn=n=>n;var pt;(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})(pt||(pt={}));var Fv;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Fv||(Fv={}));const Ce=pt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Qi=n=>{switch(typeof n){case"undefined":return Ce.undefined;case"string":return Ce.string;case"number":return Number.isNaN(n)?Ce.nan:Ce.number;case"boolean":return Ce.boolean;case"function":return Ce.function;case"bigint":return Ce.bigint;case"symbol":return Ce.symbol;case"object":return Array.isArray(n)?Ce.array:n===null?Ce.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ce.promise:typeof Map<"u"&&n instanceof Map?Ce.map:typeof Set<"u"&&n instanceof Set?Ce.set:typeof Date<"u"&&n instanceof Date?Ce.date:Ce.object;default:return Ce.unknown}},me=pt.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 Ki 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 Ki))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pt.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()}}Ki.create=n=>new Ki(n);const hp=(n,e)=>{let t;switch(n.code){case me.invalid_type:n.received===Ce.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case me.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,pt.jsonStringifyReplacer)}`;break;case me.unrecognized_keys:t=`Unrecognized key(s) in object: ${pt.joinValues(n.keys,", ")}`;break;case me.invalid_union:t="Invalid input";break;case me.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${pt.joinValues(n.options)}`;break;case me.invalid_enum_value:t=`Invalid enum value. Expected ${pt.joinValues(n.options)}, received '${n.received}'`;break;case me.invalid_arguments:t="Invalid function arguments";break;case me.invalid_return_type:t="Invalid function return type";break;case me.invalid_date:t="Invalid date";break;case me.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}"`:pt.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case me.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 me.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 me.custom:t="Invalid input";break;case me.invalid_intersection_types:t="Intersection results could not be merged";break;case me.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case me.not_finite:t="Number must be finite";break;default:t=e.defaultError,pt.assertNever(n)}return{message:t}};let OT=hp;function DT(){return OT}const RT=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 we(n,e){const t=DT(),r=RT({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===hp?void 0:hp].filter(i=>!!i)});n.common.issues.push(r)}class or{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 je;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 or.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 je;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 je=Object.freeze({status:"aborted"}),nl=n=>({status:"dirty",value:n}),Mr=n=>({status:"valid",value:n}),Hv=n=>n.status==="aborted",Vv=n=>n.status==="dirty",wa=n=>n.status==="valid",Ld=n=>typeof Promise<"u"&&n instanceof Promise;var Me;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Me||(Me={}));class ko{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 Uv=(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 Ki(n.common.issues);return this._error=t,this._error}}};function ot(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 ht{get description(){return this._def.description}_getType(e){return Qi(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Qi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new or,ctx:{common:e.parent.common,data:e.data,parsedType:Qi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ld(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:Qi(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Uv(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:Qi(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:Qi(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(Ld(i)?i:Promise.resolve(i));return Uv(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:me.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 ka({schema:this,typeName:We.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 go.create(this,this._def)}nullable(){return _a.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ai.create(this)}promise(){return Fd.create(this,this._def)}or(e){return zd.create([this,e],this._def)}and(e){return Bd.create(this,e,this._def)}transform(e){return new ka({...ot(this._def),schema:this,typeName:We.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new mp({...ot(this._def),innerType:this,defaultValue:t,typeName:We.ZodDefault})}brand(){return new tA({typeName:We.ZodBranded,type:this,...ot(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new gp({...ot(this._def),innerType:this,catchValue:t,typeName:We.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Jm.create(this,e)}readonly(){return vp.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const NT=/^c[^\s-]{8,}$/i,IT=/^[0-9a-z]+$/,LT=/^[0-9A-HJKMNP-TV-Z]{26}$/i,PT=/^[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,zT=/^[a-z0-9_-]{21}$/i,BT=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,FT=/^[-+]?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)?)??$/,HT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,VT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Gf;const UT=/^(?:(?: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])$/,jT=/^(?:(?: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])$/,WT=/^(([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]))$/,KT=/^(([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])$/,qT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,JT=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tx="((\\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])))",YT=new RegExp(`^${tx}$`);function nx(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 ZT(n){return new RegExp(`^${nx(n)}$`)}function GT(n){let e=`${tx}T${nx(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 XT(n,e){return!!((e==="v4"||!e)&&UT.test(n)||(e==="v6"||!e)&&WT.test(n))}function QT(n,e){if(!BT.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 $T(n,e){return!!((e==="v4"||!e)&&jT.test(n)||(e==="v6"||!e)&&KT.test(n))}class Jo extends ht{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ce.string){const o=this._getOrReturnCtx(e);return we(o,{code:me.invalid_type,expected:Ce.string,received:o.parsedType}),je}const r=new or;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),we(i,{code:me.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),we(i,{code:me.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?we(i,{code:me.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&we(i,{code:me.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")HT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"email",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")Gf||(Gf=new RegExp(VT,"u")),Gf.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"emoji",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")PT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"uuid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")zT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"nanoid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")NT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"cuid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")IT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"cuid2",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")LT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"ulid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),we(i,{validation:"url",code:me.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),we(i,{validation:"regex",code:me.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),we(i,{code:me.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),we(i,{code:me.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),we(i,{code:me.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?GT(o).test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{code:me.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?YT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{code:me.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?ZT(o).test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{code:me.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?FT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"duration",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?XT(e.data,o.version)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"ip",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?QT(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"jwt",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?$T(e.data,o.version)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"cidr",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?qT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"base64",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?JT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"base64url",code:me.invalid_string,message:o.message}),r.dirty()):pt.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(i=>e.test(i),{validation:t,code:me.invalid_string,...Me.errToObj(r)})}_addCheck(e){return new Jo({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Me.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Me.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Me.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Me.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Me.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Me.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Me.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Me.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Me.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Me.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Me.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Me.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Me.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,...Me.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,...Me.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Me.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Me.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Me.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Me.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Me.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Me.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Me.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Me.errToObj(t)})}nonempty(e){return this.min(1,Me.errToObj(e))}trim(){return new Jo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Jo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Jo({...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}}Jo.create=n=>new Jo({checks:[],typeName:We.ZodString,coerce:(n==null?void 0:n.coerce)??!1,...ot(n)});function eA(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 Dl extends ht{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)!==Ce.number){const o=this._getOrReturnCtx(e);return we(o,{code:me.invalid_type,expected:Ce.number,received:o.parsedType}),je}let r;const i=new or;for(const o of this._def.checks)o.kind==="int"?pt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),we(r,{code:me.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),we(r,{code:me.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),we(r,{code:me.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?eA(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),we(r,{code:me.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),we(r,{code:me.not_finite,message:o.message}),i.dirty()):pt.assertNever(o);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Me.toString(t))}setLimit(e,t,r,i){return new Dl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Me.toString(i)}]})}_addCheck(e){return new Dl({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Me.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Me.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Me.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Me.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Me.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"&&pt.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)}}Dl.create=n=>new Dl({checks:[],typeName:We.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...ot(n)});class Rl extends ht{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)!==Ce.bigint)return this._getInvalidInput(e);let r;const i=new or;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),we(r,{code:me.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),we(r,{code:me.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),we(r,{code:me.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):pt.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return we(t,{code:me.invalid_type,expected:Ce.bigint,received:t.parsedType}),je}gte(e,t){return this.setLimit("min",e,!0,Me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Me.toString(t))}setLimit(e,t,r,i){return new Rl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Me.toString(i)}]})}_addCheck(e){return new Rl({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Me.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}}Rl.create=n=>new Rl({checks:[],typeName:We.ZodBigInt,coerce:(n==null?void 0:n.coerce)??!1,...ot(n)});class jv extends ht{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ce.boolean){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.boolean,received:r.parsedType}),je}return Mr(e.data)}}jv.create=n=>new jv({typeName:We.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...ot(n)});class Pd extends ht{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ce.date){const o=this._getOrReturnCtx(e);return we(o,{code:me.invalid_type,expected:Ce.date,received:o.parsedType}),je}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return we(o,{code:me.invalid_date}),je}const r=new or;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),we(i,{code:me.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),we(i,{code:me.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):pt.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Pd({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Me.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Me.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}}Pd.create=n=>new Pd({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:We.ZodDate,...ot(n)});class Wv extends ht{_parse(e){if(this._getType(e)!==Ce.symbol){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.symbol,received:r.parsedType}),je}return Mr(e.data)}}Wv.create=n=>new Wv({typeName:We.ZodSymbol,...ot(n)});class Kv extends ht{_parse(e){if(this._getType(e)!==Ce.undefined){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.undefined,received:r.parsedType}),je}return Mr(e.data)}}Kv.create=n=>new Kv({typeName:We.ZodUndefined,...ot(n)});class qv extends ht{_parse(e){if(this._getType(e)!==Ce.null){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.null,received:r.parsedType}),je}return Mr(e.data)}}qv.create=n=>new qv({typeName:We.ZodNull,...ot(n)});class Jv extends ht{constructor(){super(...arguments),this._any=!0}_parse(e){return Mr(e.data)}}Jv.create=n=>new Jv({typeName:We.ZodAny,...ot(n)});class Yv extends ht{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Mr(e.data)}}Yv.create=n=>new Yv({typeName:We.ZodUnknown,...ot(n)});class _o extends ht{_parse(e){const t=this._getOrReturnCtx(e);return we(t,{code:me.invalid_type,expected:Ce.never,received:t.parsedType}),je}}_o.create=n=>new _o({typeName:We.ZodNever,...ot(n)});class Zv extends ht{_parse(e){if(this._getType(e)!==Ce.undefined){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.void,received:r.parsedType}),je}return Mr(e.data)}}Zv.create=n=>new Zv({typeName:We.ZodVoid,...ot(n)});class ai extends ht{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==Ce.array)return we(t,{code:me.invalid_type,expected:Ce.array,received:t.parsedType}),je;if(i.exactLength!==null){const s=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(s||a)&&(we(t,{code:s?me.too_big:me.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&&(we(t,{code:me.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&&(we(t,{code:me.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 ko(t,s,t.path,a)))).then(s=>or.mergeArray(r,s));const o=[...t.data].map((s,a)=>i.type._parseSync(new ko(t,s,t.path,a)));return or.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new ai({...this._def,minLength:{value:e,message:Me.toString(t)}})}max(e,t){return new ai({...this._def,maxLength:{value:e,message:Me.toString(t)}})}length(e,t){return new ai({...this._def,exactLength:{value:e,message:Me.toString(t)}})}nonempty(e){return this.min(1,e)}}ai.create=(n,e)=>new ai({type:n,minLength:null,maxLength:null,exactLength:null,typeName:We.ZodArray,...ot(e)});function js(n){if(n instanceof nn){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=go.create(js(r))}return new nn({...n._def,shape:()=>e})}else return n instanceof ai?new ai({...n._def,type:js(n.element)}):n instanceof go?go.create(js(n.unwrap())):n instanceof _a?_a.create(js(n.unwrap())):n instanceof bs?bs.create(n.items.map(e=>js(e))):n}class nn extends ht{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=pt.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Ce.object){const c=this._getOrReturnCtx(e);return we(c,{code:me.invalid_type,expected:Ce.object,received:c.parsedType}),je}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof _o&&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 ko(i,u,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof _o){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&&(we(i,{code:me.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 ko(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=>or.mergeObjectSync(r,c)):or.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return Me.errToObj,new nn({...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:Me.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new nn({...this._def,unknownKeys:"strip"})}passthrough(){return new nn({...this._def,unknownKeys:"passthrough"})}extend(e){return new nn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new nn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:We.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new nn({...this._def,catchall:e})}pick(e){const t={};for(const r of pt.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new nn({...this._def,shape:()=>t})}omit(e){const t={};for(const r of pt.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new nn({...this._def,shape:()=>t})}deepPartial(){return js(this)}partial(e){const t={};for(const r of pt.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new nn({...this._def,shape:()=>t})}required(e){const t={};for(const r of pt.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof go;)o=o._def.innerType;t[r]=o}return new nn({...this._def,shape:()=>t})}keyof(){return rx(pt.objectKeys(this.shape))}}nn.create=(n,e)=>new nn({shape:()=>n,unknownKeys:"strip",catchall:_o.create(),typeName:We.ZodObject,...ot(e)});nn.strictCreate=(n,e)=>new nn({shape:()=>n,unknownKeys:"strict",catchall:_o.create(),typeName:We.ZodObject,...ot(e)});nn.lazycreate=(n,e)=>new nn({shape:n,unknownKeys:"strip",catchall:_o.create(),typeName:We.ZodObject,...ot(e)});class zd extends ht{_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 Ki(a.ctx.common.issues));return we(t,{code:me.invalid_union,unionErrors:s}),je}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 Ki(l));return we(t,{code:me.invalid_union,unionErrors:a}),je}}get options(){return this._def.options}}zd.create=(n,e)=>new zd({options:n,typeName:We.ZodUnion,...ot(e)});function pp(n,e){const t=Qi(n),r=Qi(e);if(n===e)return{valid:!0,data:n};if(t===Ce.object&&r===Ce.object){const i=pt.objectKeys(e),o=pt.objectKeys(n).filter(a=>i.indexOf(a)!==-1),s={...n,...e};for(const a of o){const l=pp(n[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(t===Ce.array&&r===Ce.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=pp(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===Ce.date&&r===Ce.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Bd extends ht{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(Hv(o)||Hv(s))return je;const a=pp(o.value,s.value);return a.valid?((Vv(o)||Vv(s))&&t.dirty(),{status:t.value,value:a.data}):(we(r,{code:me.invalid_intersection_types}),je)};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}))}}Bd.create=(n,e,t)=>new Bd({left:n,right:e,typeName:We.ZodIntersection,...ot(t)});class bs extends ht{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ce.array)return we(r,{code:me.invalid_type,expected:Ce.array,received:r.parsedType}),je;if(r.data.length<this._def.items.length)return we(r,{code:me.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),je;!this._def.rest&&r.data.length>this._def.items.length&&(we(r,{code:me.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 ko(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>or.mergeArray(t,s)):or.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new bs({...this._def,rest:e})}}bs.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new bs({items:n,typeName:We.ZodTuple,rest:null,...ot(e)})};class Gv extends ht{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!==Ce.map)return we(r,{code:me.invalid_type,expected:Ce.map,received:r.parsedType}),je;const i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new ko(r,a,r.path,[c,"key"])),value:o._parse(new ko(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 je;(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 je;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(c.value,d.value)}return{status:t.value,value:a}}}}Gv.create=(n,e,t)=>new Gv({valueType:e,keyType:n,typeName:We.ZodMap,...ot(t)});class Nl extends ht{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ce.set)return we(r,{code:me.invalid_type,expected:Ce.set,received:r.parsedType}),je;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(we(r,{code:me.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&&(we(r,{code:me.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 je;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 ko(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,t){return new Nl({...this._def,minSize:{value:e,message:Me.toString(t)}})}max(e,t){return new Nl({...this._def,maxSize:{value:e,message:Me.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Nl.create=(n,e)=>new Nl({valueType:n,minSize:null,maxSize:null,typeName:We.ZodSet,...ot(e)});class Xv extends ht{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})}}Xv.create=(n,e)=>new Xv({getter:n,typeName:We.ZodLazy,...ot(e)});class Qv extends ht{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return we(t,{received:t.data,code:me.invalid_literal,expected:this._def.value}),je}return{status:"valid",value:e.data}}get value(){return this._def.value}}Qv.create=(n,e)=>new Qv({value:n,typeName:We.ZodLiteral,...ot(e)});function rx(n,e){return new xa({values:n,typeName:We.ZodEnum,...ot(e)})}class xa extends ht{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return we(t,{expected:pt.joinValues(r),received:t.parsedType,code:me.invalid_type}),je}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 we(t,{received:t.data,code:me.invalid_enum_value,options:r}),je}return Mr(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 xa.create(e,{...this._def,...t})}exclude(e,t=this._def){return xa.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}xa.create=rx;class $v extends ht{_parse(e){const t=pt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Ce.string&&r.parsedType!==Ce.number){const i=pt.objectValues(t);return we(r,{expected:pt.joinValues(i),received:r.parsedType,code:me.invalid_type}),je}if(this._cache||(this._cache=new Set(pt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=pt.objectValues(t);return we(r,{received:r.data,code:me.invalid_enum_value,options:i}),je}return Mr(e.data)}get enum(){return this._def.values}}$v.create=(n,e)=>new $v({values:n,typeName:We.ZodNativeEnum,...ot(e)});class Fd extends ht{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ce.promise&&t.common.async===!1)return we(t,{code:me.invalid_type,expected:Ce.promise,received:t.parsedType}),je;const r=t.parsedType===Ce.promise?t.data:Promise.resolve(t.data);return Mr(r.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Fd.create=(n,e)=>new Fd({type:n,typeName:We.ZodPromise,...ot(e)});class ka extends ht{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===We.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=>{we(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 je;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?je:l.status==="dirty"||t.value==="dirty"?nl(l.value):l});{if(t.value==="aborted")return je;const a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?je:a.status==="dirty"||t.value==="dirty"?nl(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"?je:(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"?je:(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 je;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})):je);pt.assertNever(i)}}ka.create=(n,e,t)=>new ka({schema:n,typeName:We.ZodEffects,effect:e,...ot(t)});ka.createWithPreprocess=(n,e,t)=>new ka({schema:e,effect:{type:"preprocess",transform:n},typeName:We.ZodEffects,...ot(t)});class go extends ht{_parse(e){return this._getType(e)===Ce.undefined?Mr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}go.create=(n,e)=>new go({innerType:n,typeName:We.ZodOptional,...ot(e)});class _a extends ht{_parse(e){return this._getType(e)===Ce.null?Mr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_a.create=(n,e)=>new _a({innerType:n,typeName:We.ZodNullable,...ot(e)});class mp extends ht{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===Ce.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}mp.create=(n,e)=>new mp({innerType:n,typeName:We.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ot(e)});class gp extends ht{_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 Ld(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ki(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ki(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}gp.create=(n,e)=>new gp({innerType:n,typeName:We.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ot(e)});class ey extends ht{_parse(e){if(this._getType(e)!==Ce.nan){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.nan,received:r.parsedType}),je}return{status:"valid",value:e.data}}}ey.create=n=>new ey({typeName:We.ZodNaN,...ot(n)});class tA extends ht{_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 Jm extends ht{_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"?je:o.status==="dirty"?(t.dirty(),nl(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"?je: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 Jm({in:e,out:t,typeName:We.ZodPipeline})}}class vp extends ht{_parse(e){const t=this._def.innerType._parse(e),r=i=>(wa(i)&&(i.value=Object.freeze(i.value)),i);return Ld(t)?t.then(i=>r(i)):r(t)}unwrap(){return this._def.innerType}}vp.create=(n,e)=>new vp({innerType:n,typeName:We.ZodReadonly,...ot(e)});var We;(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"})(We||(We={}));_o.create;ai.create;zd.create;Bd.create;bs.create;const Ur=xa.create;Fd.create;go.create;_a.create;Ur(["highlight","note","comment"]);Ur(["pending","accepted","dismissed"]);Ur(["yellow","green","blue","pink"]);Ur(["info","warning","error","success"]);const nA=Ur(["solo","tandem"]);Ur(["user","claude","import"]);Ur(["user","claude"]);Ur(["accept","dismiss"]);Ur(["markdown","json"]);Ur(["md","txt","html","docx"]);Ur(["RANGE_GONE","RANGE_MOVED","FILE_LOCKED","FILE_NOT_FOUND","NO_DOCUMENT","INVALID_RANGE","FORMAT_ERROR","PERMISSION_DENIED"]);function rA(n){return n.author!=="user"}function Hd(n){return n.status==="pending"&&rA(n)}const ty=3478,kc=3479,ix="https://github.com/bloknayrb/tandem",iA=`${ix}/issues/new`,oA=new Set([".md",".txt",".html",".htm",".docx"]),sA=3e3,aA=3e3,lA=3e4,ox={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)"},Il={yellow:"var(--tandem-highlight-yellow)",green:"var(--tandem-highlight-green)",blue:"var(--tandem-highlight-blue)",pink:"var(--tandem-highlight-pink)"};function sx(n){return n&&n in ox?n:"yellow"}const ny="tandem",Fc="tandem:mode",ax="tandem:settings",cA="tandem-panel-width",dA="tandem-left-panel-width",lx={left:dA,right:cA},cx=1e3,Vd=500,Ud=3e3,uA="__tandem_ctrl__",So="annotations",dx="awareness",yp="userAwareness",fA="mode",hA="selectionDwellMs",ry="chat",md="documentMeta",pA="annotationReplies",iy="savedAtVersion",oy="authorship",sy="selection",ay="activity",bp="claude",Za="openDocuments",Ga="activeDocumentId",Xf="generationId",Qf="readOnly",$f="storeReadOnly",ux="tandem:showAuthorship",Ym="tandem:recentFiles",mA=20,Zm="tandem:userName",fx="You",wp="tandem:user-name-changed",Gm=40,ly={error:8e3,warning:6e3,info:4e3},gA=5,hx="tandem:tutorialCompleted",vA="tutorial-",px="tandem:coworkOnboardingSkipped",yA=3e4,q6=2e3,cy="tandem:zoomLevel",dy=.5,uy=2,Xa=1,Tr=`http://localhost:${kc}/api`;function bA(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 wA(n){return n.toLowerCase().endsWith(".docx")}async function mx(n){if(wA(n.name)){const e=await n.arrayBuffer();return bA(e)}return n.text()}const gx=["editor","navigation","view","document"];let gd=F(dt(new Map));function xA(n,e={}){if(f(gd).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(gd,new Map(f(gd)).set(n.id,n),!0),!0}function jd(){return f(gd)}let xp=null;function kA(n){xp=n}function eh(n,e){if(!xp){console.warn(`[actions] "${n}" invoked before App mounted — deps not wired yet`);return}e(xp)}let kp=F(!1);const _A={get saving(){return f(kp)}};let th=!1,nh=!1;async function Xm(){if(!nh){nh=!0;try{const n=await fetch(`${Tr}/scratchpad`,{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{nh=!1}}}async function vx(n){if(!(!n||th)){th=!0,b(kp,!0);try{const e=await fetch(`http://localhost:${kc}/api/save`,{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{th=!1,b(kp,!1)}}}const SA=[{id:"save",label:"Save document",group:"document",shortcut:"Ctrl+S",run(){eh("save",n=>void vx(n.getActiveTabId()))}},{id:"settings",label:"Open settings",group:"view",shortcut:"Ctrl+,",run(){eh("settings",n=>n.openSettings())}},{id:"toggle-mode",label:"Toggle Solo / Tandem mode",group:"document",run(){eh("toggle-mode",n=>n.toggleSoloMode())}},{id:"new-scratchpad",label:"New Scratchpad",group:"document",shortcut:"Ctrl+N",run(){Xm()}}];for(const n of SA)xA(n);function pn(n){this.content=n}pn.prototype={constructor:pn,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 pn(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 pn(t)},addToStart:function(n,e){return new pn([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new pn(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 pn(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=pn.from(n),n.size?new pn(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=pn.from(n),n.size?new pn(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=pn.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}};pn.from=function(n){if(n instanceof pn)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new pn(e)};function yx(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=yx(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function bx(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=bx(s.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}class ie{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 ie(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 ie(r,i)}cutByIndex(e,t){return e==t?ie.empty:e==0&&t==this.content.length?this:new ie(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 ie(i,o)}addToStart(e){return new ie([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ie(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 yx(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return bx(this,e,t,r)}findIndex(e){if(e==0)return Hc(0,e);if(e==this.size)return Hc(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?Hc(t+1,o):Hc(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 ie.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new ie(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ie.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 ie(t||e,r)}static from(e){if(!e)return ie.empty;if(e instanceof ie)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ie([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ie.empty=new ie([],0);const rh={index:0,offset:0};function Hc(n,e){return rh.index=n,rh.offset=e,rh}function Wd(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(!Wd(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Wd(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ct=class _p{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&&Wd(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 _p.none;if(e instanceof _p)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Ct.none=[];class Kd extends Error{}class ge{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=xx(this.content,e+this.openStart,t);return r&&new ge(r,this.openStart,this.openEnd)}removeBetween(e,t){return new ge(wx(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 ge.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 ge(ie.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 ge(e,r,i)}}ge.empty=new ge(ie.empty,0,0);function wx(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(wx(o.content,e-i-1,t-i-1)))}function xx(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=xx(s.content,e-o-1,t,s);return a&&n.replaceChild(i,s.copy(a))}function CA(n,e,t){if(t.openStart>n.depth)throw new Kd("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Kd("Inconsistent open depths");return kx(n,e,t,0)}function kx(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=kx(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 ls(s,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=TA(t,n);return ls(o,Sx(n,s,a,e,r))}else return ls(o,qd(n,e,r))}function _x(n,e){if(!e.type.compatibleContent(n.type))throw new Kd("Cannot join "+e.type.name+" onto "+n.type.name)}function Sp(n,e,t){let r=n.node(t);return _x(r,e.node(t)),r}function as(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 cl(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&&(as(n.nodeAfter,r),o++));for(let a=o;a<s;a++)as(i.child(a),r);e&&e.depth==t&&e.textOffset&&as(e.nodeBefore,r)}function ls(n,e){return n.type.checkContent(e),n.copy(e)}function Sx(n,e,t,r,i){let o=n.depth>i&&Sp(n,e,i+1),s=r.depth>i&&Sp(t,r,i+1),a=[];return cl(null,n,i,a),o&&s&&e.index(i)==t.index(i)?(_x(o,s),as(ls(o,Sx(n,e,t,r,i+1)),a)):(o&&as(ls(o,qd(n,e,i+1)),a),cl(e,t,i,a),s&&as(ls(s,qd(t,r,i+1)),a)),cl(r,null,i,a),new ie(a)}function qd(n,e,t){let r=[];if(cl(null,n,t,r),n.depth>t){let i=Sp(n,e,t+1);as(ls(i,qd(n,e,t+1)),r)}return cl(e,null,t,r),new ie(r)}function TA(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(ie.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Ll{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 Ct.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 Jd(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 Ll(t,r,o)}static resolveCached(e,t){let r=fy.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 fy.set(e,r=new AA);let i=r.elts[r.i]=Ll.resolve(e,t);return r.i=(r.i+1)%EA,i}}class AA{constructor(){this.elts=[],this.i=0}}const EA=12,fy=new WeakMap;class Jd{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 MA=Object.create(null);let vo=class Cp{constructor(e,t,r,i=Ct.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||ie.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&&Wd(this.attrs,t||e.defaultAttrs||MA)&&Ct.sameSet(this.marks,r||Ct.none)}copy(e=null){return e==this.content?this:new Cp(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Cp(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 ge.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 ge(c,i.depth-s,o.depth-s)}replace(e,t,r){return CA(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 Ll.resolveCached(this,e)}resolveNoCache(e){return Ll.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()+")"),Cx(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=ie.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=Ct.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(!Ct.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=ie.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};vo.prototype.text=void 0;class Yd extends vo{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):Cx(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 Yd(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Yd(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 Cx(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ws{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new OA(e,t);if(r.next==null)return ws.empty;let i=Tx(r);r.next&&r.err("Unexpected trailing text");let o=zA(PA(i));return BA(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 ie.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(`
|
|
2
|
+
var IS=Object.defineProperty;var kv=n=>{throw TypeError(n)};var LS=(n,e,t)=>e in n?IS(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var jn=(n,e,t)=>LS(n,typeof e!="symbol"?e+"":e,t),Wf=(n,e,t)=>e.has(n)||kv("Cannot "+t);var j=(n,e,t)=>(Wf(n,e,"read from private field"),t?t.call(n):e.get(n)),Ze=(n,e,t)=>e.has(n)?kv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),st=(n,e,t,r)=>(Wf(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Ot=(n,e,t)=>(Wf(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 PS=!1;var Rm=Array.isArray,zS=Array.prototype.indexOf,ma=Array.prototype.includes,tf=Array.from,BS=Object.defineProperty,po=Object.getOwnPropertyDescriptor,ow=Object.getOwnPropertyDescriptors,FS=Object.prototype,HS=Array.prototype,Nm=Object.getPrototypeOf,_v=Object.isExtensible;function Ja(n){return typeof n=="function"}const pr=()=>{};function VS(n){return typeof(n==null?void 0:n.then)=="function"}function US(n){for(var e=0;e<n.length;e++)n[e]()}function sw(){var n,e,t=new Promise((r,i)=>{n=r,e=i});return{promise:t,resolve:n,reject:e}}function Sv(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 Dn=2,ga=4,nf=8,aw=1<<24,ii=16,zr=32,Vi=64,Qh=128,br=512,rn=1024,xn=2048,di=4096,Pn=8192,ir=16384,Ds=32768,$h=1<<25,xo=65536,ep=1<<17,jS=1<<18,Rs=1<<19,WS=1<<20,ei=1<<25,ms=65536,Nd=1<<21,Al=1<<22,mo=1<<23,oi=Symbol("$state"),lw=Symbol("legacy props"),KS=Symbol(""),Mi=new class extends Error{constructor(){super(...arguments);jn(this,"name","StaleReactionError");jn(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var nw;const qS=!!((nw=globalThis.document)!=null&&nw.contentType)&&globalThis.document.contentType.includes("xml");function cw(n){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function JS(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function YS(n,e,t){throw new Error("https://svelte.dev/e/each_key_duplicate")}function ZS(n){throw new Error("https://svelte.dev/e/effect_in_teardown")}function GS(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function XS(n){throw new Error("https://svelte.dev/e/effect_orphan")}function QS(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function $S(n){throw new Error("https://svelte.dev/e/props_invalid_value")}function eC(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function tC(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function nC(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function rC(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const iC=1,oC=2,dw=4,sC=8,aC=16,lC=1,cC=2,dC=4,uC=8,fC=16,hC=1,pC=2,tn=Symbol(),uw="http://www.w3.org/1999/xhtml",mC="http://www.w3.org/2000/svg",gC="http://www.w3.org/1998/Math/MathML";function vC(){console.warn("https://svelte.dev/e/derived_inert")}function yC(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function bC(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function fw(n){return n===this.v}function hw(n,e){return n!=n?e==e:n!==e||n!==null&&typeof n=="object"||typeof n=="function"}function pw(n){return!hw(n,this.v)}let za=!1,wC=!1;function xC(){za=!0}let Ut=null;function va(n){Ut=n}function qe(n,e=!1,t){Ut={p:Ut,i:!1,c:null,e:null,s:n,x:null,r:it,l:za&&!e?{s:null,u:null,$:[]}:null}}function Je(n){var e=Ut,t=e.e;if(t!==null){e.e=null;for(var r of t)zw(r)}return e.i=!0,Ut=e.p,{}}function Ns(){return!za||Ut!==null&&Ut.l===null}let Wo=[];function mw(){var n=Wo;Wo=[],US(n)}function si(n){if(Wo.length===0&&!Qs){var e=Wo;queueMicrotask(()=>{e===Wo&&mw()})}Wo.push(n)}function kC(){for(;Wo.length>0;)mw()}function gw(n){var e=it;if(e===null)return ct.f|=mo,n;if((e.f&Ds)===0&&(e.f&ga)===0)throw n;lo(n,e)}function lo(n,e){for(;e!==null;){if((e.f&Qh)!==0){if((e.f&Ds)===0)throw n;try{e.b.error(n);return}catch(t){n=t}}e=e.parent}throw n}const _C=-7169;function Jt(n,e){n.f=n.f&_C|e}function Im(n){(n.f&br)!==0||n.deps===null?Jt(n,rn):Jt(n,di)}function vw(n){if(n!==null)for(const e of n)(e.f&Dn)===0||(e.f&ms)===0||(e.f^=ms,vw(e.deps))}function yw(n,e,t){(n.f&xn)!==0?e.add(n):(n.f&di)!==0&&t.add(n),vw(n.deps),Jt(n,rn)}let Pc=!1;function SC(n){var e=Pc;try{return Pc=!1,[n(),Pc]}finally{Pc=e}}const Bo=new Set;let Be=null,gn=null,tp=null,Qs=!1,Kf=!1,Ys=null,ad=null;var Cv=0;let CC=1;var da,ua,Qo,Oi,Xr,uc,$n,fc,so,Di,Qr,fa,ha,$o,Xt,ld,bw,cd,np,dd,TC;const Xu=class Xu{constructor(){Ze(this,Xt);jn(this,"id",CC++);jn(this,"current",new Map);jn(this,"previous",new Map);Ze(this,da,new Set);Ze(this,ua,new Set);Ze(this,Qo,new Set);Ze(this,Oi,new Map);Ze(this,Xr,new Map);Ze(this,uc,null);Ze(this,$n,[]);Ze(this,fc,[]);Ze(this,so,new Set);Ze(this,Di,new Set);Ze(this,Qr,new Map);Ze(this,fa,new Set);jn(this,"is_fork",!1);Ze(this,ha,!1);Ze(this,$o,new Set)}skip_effect(e){j(this,Qr).has(e)||j(this,Qr).set(e,{d:[],m:[]}),j(this,fa).delete(e)}unskip_effect(e,t=r=>this.schedule(r)){var r=j(this,Qr).get(e);if(r){j(this,Qr).delete(e);for(var i of r.d)Jt(i,xn),t(i);for(i of r.m)Jt(i,di),t(i)}j(this,fa).add(e)}capture(e,t,r=!1){e.v!==tn&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&mo)===0&&(this.current.set(e,[t,r]),gn==null||gn.set(e,t)),this.is_fork||(e.v=t)}activate(){Be=this}deactivate(){Be=null,gn=null}flush(){try{Kf=!0,Be=this,Ot(this,Xt,cd).call(this)}finally{Cv=0,tp=null,Ys=null,ad=null,Kf=!1,Be=null,gn=null,rs.clear()}}discard(){for(const e of j(this,ua))e(this);j(this,ua).clear(),j(this,Qo).clear(),Bo.delete(this)}register_created_effect(e){j(this,fc).push(e)}increment(e,t){let r=j(this,Oi).get(t)??0;if(j(this,Oi).set(t,r+1),e){let i=j(this,Xr).get(t)??0;j(this,Xr).set(t,i+1)}}decrement(e,t,r){let i=j(this,Oi).get(t)??0;if(i===1?j(this,Oi).delete(t):j(this,Oi).set(t,i-1),e){let o=j(this,Xr).get(t)??0;o===1?j(this,Xr).delete(t):j(this,Xr).set(t,o-1)}j(this,ha)||r||(st(this,ha,!0),si(()=>{st(this,ha,!1),this.flush()}))}transfer_effects(e,t){for(const r of e)j(this,so).add(r);for(const r of t)j(this,Di).add(r);e.clear(),t.clear()}oncommit(e){j(this,da).add(e)}ondiscard(e){j(this,ua).add(e)}on_fork_commit(e){j(this,Qo).add(e)}run_fork_commit_callbacks(){for(const e of j(this,Qo))e(this);j(this,Qo).clear()}settled(){return(j(this,uc)??st(this,uc,sw())).promise}static ensure(){if(Be===null){const e=Be=new Xu;Kf||(Bo.add(Be),Qs||si(()=>{Be===e&&e.flush()}))}return Be}apply(){{gn=null;return}}schedule(e){var i;if(tp=e,(i=e.b)!=null&&i.is_pending&&(e.f&(ga|nf|aw))!==0&&(e.f&Ds)===0){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var r=t.f;if(Ys!==null&&t===it&&(ct===null||(ct.f&Dn)===0))return;if((r&(Vi|zr))!==0){if((r&rn)===0)return;t.f^=rn}}j(this,$n).push(t)}};da=new WeakMap,ua=new WeakMap,Qo=new WeakMap,Oi=new WeakMap,Xr=new WeakMap,uc=new WeakMap,$n=new WeakMap,fc=new WeakMap,so=new WeakMap,Di=new WeakMap,Qr=new WeakMap,fa=new WeakMap,ha=new WeakMap,$o=new WeakMap,Xt=new WeakSet,ld=function(){return this.is_fork||j(this,Xr).size>0},bw=function(){for(const r of j(this,$o))for(const i of j(r,Xr).keys()){for(var e=!1,t=i;t.parent!==null;){if(j(this,Qr).has(t)){e=!0;break}t=t.parent}if(!e)return!0}return!1},cd=function(){var a,l;if(Cv++>1e3&&(Bo.delete(this),AC()),!Ot(this,Xt,ld).call(this)){for(const c of j(this,so))j(this,Di).delete(c),Jt(c,xn),this.schedule(c);for(const c of j(this,Di))Jt(c,di),this.schedule(c)}const e=j(this,$n);st(this,$n,[]),this.apply();var t=Ys=[],r=[],i=ad=[];for(const c of e)try{Ot(this,Xt,np).call(this,c,t,r)}catch(d){throw _w(c),d}if(Be=null,i.length>0){var o=Xu.ensure();for(const c of i)o.schedule(c)}if(Ys=null,ad=null,Ot(this,Xt,ld).call(this)||Ot(this,Xt,bw).call(this)){Ot(this,Xt,dd).call(this,r),Ot(this,Xt,dd).call(this,t);for(const[c,d]of j(this,Qr))kw(c,d)}else{j(this,Oi).size===0&&Bo.delete(this),j(this,so).clear(),j(this,Di).clear();for(const c of j(this,da))c(this);j(this,da).clear(),Tv(r),Tv(t),(a=j(this,uc))==null||a.resolve()}var s=Be;if(j(this,$n).length>0){const c=s??(s=this);j(c,$n).push(...j(this,$n).filter(d=>!j(c,$n).includes(d)))}s!==null&&(Bo.add(s),Ot(l=s,Xt,cd).call(l))},np=function(e,t,r){e.f^=rn;for(var i=e.first;i!==null;){var o=i.f,s=(o&(zr|Vi))!==0,a=s&&(o&rn)!==0,l=a||(o&Pn)!==0||j(this,Qr).has(i);if(!l&&i.fn!==null){s?i.f^=rn:(o&ga)!==0?t.push(i):wc(i)&&((o&ii)!==0&&j(this,Di).add(i),ya(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}}},dd=function(e){for(var t=0;t<e.length;t+=1)yw(e[t],j(this,so),j(this,Di))},TC=function(){var d,u,h;for(const p of Bo){var e=p.id<this.id,t=[];for(const[m,[v,g]]of this.current){if(p.current.has(m)){var r=p.current.get(m)[0];if(e&&v!==r)p.current.set(m,[v,g]);else continue}t.push(m)}var i=[...p.current.keys()].filter(m=>!this.current.has(m));if(i.length===0)e&&p.discard();else if(t.length>0){if(e)for(const m of j(this,fa))p.unskip_effect(m,v=>{var g;(v.f&(ii|Al))!==0?p.schedule(v):Ot(g=p,Xt,dd).call(g,[v])});p.activate();var o=new Set,s=new Map;for(var a of t)xw(a,i,o,s);s=new Map;var l=[...p.current.keys()].filter(m=>this.current.has(m)?this.current.get(m)[0]!==m:!0);for(const m of j(this,fc))(m.f&(ir|Pn|ep))===0&&Lm(m,l,s)&&((m.f&(Al|ii))!==0?(Jt(m,xn),p.schedule(m)):j(p,so).add(m));if(j(p,$n).length>0){p.apply();for(var c of j(p,$n))Ot(d=p,Xt,np).call(d,c,[],[]);st(p,$n,[])}p.deactivate()}}for(const p of Bo)j(p,$o).has(this)&&(j(p,$o).delete(this),j(p,$o).size===0&&!Ot(u=p,Xt,ld).call(u)&&(p.activate(),Ot(h=p,Xt,cd).call(h)))};let Ui=Xu;function ww(n){var e=Qs;Qs=!0;try{for(var t;;){if(kC(),Be===null)return t;Be.flush()}}finally{Qs=e}}function AC(){try{QS()}catch(n){lo(n,tp)}}let Dr=null;function Tv(n){var e=n.length;if(e!==0){for(var t=0;t<e;){var r=n[t++];if((r.f&(ir|Pn))===0&&wc(r)&&(Dr=new Set,ya(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Vw(r),(Dr==null?void 0:Dr.size)>0)){rs.clear();for(const i of Dr){if((i.f&(ir|Pn))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)Dr.has(s)&&(Dr.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){const l=o[a];(l.f&(ir|Pn))===0&&ya(l)}}Dr.clear()}}Dr=null}}function xw(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&Dn)!==0?xw(i,e,t,r):(o&(Al|ii))!==0&&(o&xn)===0&&Lm(i,e,r)&&(Jt(i,xn),Pm(i))}}function Lm(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(ma.call(e,i))return!0;if((i.f&Dn)!==0&&Lm(i,e,t))return t.set(i,!0),!0}return t.set(n,!1),!1}function Pm(n){Be.schedule(n)}function kw(n,e){if(!((n.f&zr)!==0&&(n.f&rn)!==0)){(n.f&xn)!==0?e.d.push(n):(n.f&di)!==0&&e.m.push(n),Jt(n,rn);for(var t=n.first;t!==null;)kw(t,e),t=t.next}}function _w(n){Jt(n,rn);for(var e=n.first;e!==null;)_w(e),e=e.next}function EC(n){let e=0,t=ji(0),r;return()=>{Fm()&&(f(t),bc(()=>(e===0&&(r=Pt(()=>n(()=>ll(t)))),e+=1,()=>{si(()=>{e-=1,e===0&&(r==null||r(),r=void 0,ll(t))})})))}}var MC=xo|Rs;function Sw(n,e,t,r){new OC(n,e,t,r)}var cr,Dm,dr,es,Wn,ur,Ln,er,Ri,ts,ao,pa,hc,pc,Ni,Qu,jt,DC,RC,NC,rp,ud,fd,ip,op;class OC{constructor(e,t,r,i){Ze(this,jt);jn(this,"parent");jn(this,"is_pending",!1);jn(this,"transform_error");Ze(this,cr);Ze(this,Dm,null);Ze(this,dr);Ze(this,es);Ze(this,Wn);Ze(this,ur,null);Ze(this,Ln,null);Ze(this,er,null);Ze(this,Ri,null);Ze(this,ts,0);Ze(this,ao,0);Ze(this,pa,!1);Ze(this,hc,new Set);Ze(this,pc,new Set);Ze(this,Ni,null);Ze(this,Qu,EC(()=>(st(this,Ni,ji(j(this,ts))),()=>{st(this,Ni,null)})));var o;st(this,cr,e),st(this,dr,t),st(this,es,s=>{var a=it;a.b=this,a.f|=Qh,r(s)}),this.parent=it.b,this.transform_error=i??((o=this.parent)==null?void 0:o.transform_error)??(s=>s),st(this,Wn,Is(()=>{Ot(this,jt,rp).call(this)},MC))}defer_effect(e){yw(e,j(this,hc),j(this,pc))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!j(this,dr).pending}update_pending_count(e,t){Ot(this,jt,ip).call(this,e,t),st(this,ts,j(this,ts)+e),!(!j(this,Ni)||j(this,pa))&&(st(this,pa,!0),si(()=>{st(this,pa,!1),j(this,Ni)&&Li(j(this,Ni),j(this,ts))}))}get_effect_pending(){return j(this,Qu).call(this),f(j(this,Ni))}error(e){if(!j(this,dr).onerror&&!j(this,dr).failed)throw e;Be!=null&&Be.is_fork?(j(this,ur)&&Be.skip_effect(j(this,ur)),j(this,Ln)&&Be.skip_effect(j(this,Ln)),j(this,er)&&Be.skip_effect(j(this,er)),Be.on_fork_commit(()=>{Ot(this,jt,op).call(this,e)})):Ot(this,jt,op).call(this,e)}}cr=new WeakMap,Dm=new WeakMap,dr=new WeakMap,es=new WeakMap,Wn=new WeakMap,ur=new WeakMap,Ln=new WeakMap,er=new WeakMap,Ri=new WeakMap,ts=new WeakMap,ao=new WeakMap,pa=new WeakMap,hc=new WeakMap,pc=new WeakMap,Ni=new WeakMap,Qu=new WeakMap,jt=new WeakSet,DC=function(){try{st(this,ur,fr(()=>j(this,es).call(this,j(this,cr))))}catch(e){this.error(e)}},RC=function(e){const t=j(this,dr).failed;t&&st(this,er,fr(()=>{t(j(this,cr),()=>e,()=>()=>{})}))},NC=function(){const e=j(this,dr).pending;e&&(this.is_pending=!0,st(this,Ln,fr(()=>e(j(this,cr)))),si(()=>{var t=st(this,Ri,document.createDocumentFragment()),r=Pi();t.append(r),st(this,ur,Ot(this,jt,fd).call(this,()=>fr(()=>j(this,es).call(this,r)))),j(this,ao)===0&&(j(this,cr).before(t),st(this,Ri,null),is(j(this,Ln),()=>{st(this,Ln,null)}),Ot(this,jt,ud).call(this,Be))}))},rp=function(){try{if(this.is_pending=this.has_pending_snippet(),st(this,ao,0),st(this,ts,0),st(this,ur,fr(()=>{j(this,es).call(this,j(this,cr))})),j(this,ao)>0){var e=st(this,Ri,document.createDocumentFragment());jm(j(this,ur),e);const t=j(this,dr).pending;st(this,Ln,fr(()=>t(j(this,cr))))}else Ot(this,jt,ud).call(this,Be)}catch(t){this.error(t)}},ud=function(e){this.is_pending=!1,e.transfer_effects(j(this,hc),j(this,pc))},fd=function(e){var t=it,r=ct,i=Ut;ui(j(this,Wn)),Cr(j(this,Wn)),va(j(this,Wn).ctx);try{return Ui.ensure(),e()}catch(o){return gw(o),null}finally{ui(t),Cr(r),va(i)}},ip=function(e,t){var r;if(!this.has_pending_snippet()){this.parent&&Ot(r=this.parent,jt,ip).call(r,e,t);return}st(this,ao,j(this,ao)+e),j(this,ao)===0&&(Ot(this,jt,ud).call(this,t),j(this,Ln)&&is(j(this,Ln),()=>{st(this,Ln,null)}),j(this,Ri)&&(j(this,cr).before(j(this,Ri)),st(this,Ri,null)))},op=function(e){j(this,ur)&&(zn(j(this,ur)),st(this,ur,null)),j(this,Ln)&&(zn(j(this,Ln)),st(this,Ln,null)),j(this,er)&&(zn(j(this,er)),st(this,er,null));var t=j(this,dr).onerror;let r=j(this,dr).failed;var i=!1,o=!1;const s=()=>{if(i){bC();return}i=!0,o&&rC(),j(this,er)!==null&&is(j(this,er),()=>{st(this,er,null)}),Ot(this,jt,fd).call(this,()=>{Ot(this,jt,rp).call(this)})},a=l=>{try{o=!0,t==null||t(l,s),o=!1}catch(c){lo(c,j(this,Wn)&&j(this,Wn).parent)}r&&st(this,er,Ot(this,jt,fd).call(this,()=>{try{return fr(()=>{var c=it;c.b=this,c.f|=Qh,r(j(this,cr),()=>l,()=>s)})}catch(c){return lo(c,j(this,Wn).parent),null}}))};si(()=>{var l;try{l=this.transform_error(e)}catch(c){lo(c,j(this,Wn)&&j(this,Wn).parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(a,c=>lo(c,j(this,Wn)&&j(this,Wn).parent)):a(l)})};function IC(n,e,t,r){const i=Ns()?rf:zm;var o=n.filter(h=>!h.settled);if(t.length===0&&o.length===0){r(e.map(i));return}var s=it,a=Cw(),l=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(h=>h.promise)):null;function c(h){a();try{r(h)}catch(p){(s.f&ir)===0&&lo(p,s)}El()}if(t.length===0){l.then(()=>c(e.map(i)));return}var d=Tw();function u(){Promise.all(t.map(h=>LC(h))).then(h=>c([...e.map(i),...h])).catch(h=>lo(h,s)).finally(()=>d())}l?l.then(()=>{a(),u(),El()}):u()}function Cw(){var n=it,e=ct,t=Ut,r=Be;return function(o=!0){ui(n),Cr(e),va(t),o&&(n.f&ir)===0&&(r==null||r.activate(),r==null||r.apply())}}function El(n=!0){ui(null),Cr(null),va(null),n&&(Be==null||Be.deactivate())}function Tw(){var n=it,e=n.b,t=Be,r=e.is_rendered();return e.update_pending_count(1,t),t.increment(r,n),(i=!1)=>{e.update_pending_count(-1,t),t.decrement(r,n,i)}}function rf(n){var e=Dn|xn;return it!==null&&(it.f|=Rs),{ctx:Ut,deps:null,effects:null,equals:fw,f:e,fn:n,reactions:null,rv:0,v:tn,wv:0,parent:it,ac:null}}function LC(n,e,t){let r=it;r===null&&JS();var i=void 0,o=ji(tn),s=!ct,a=new Map;return YC(()=>{var p;var l=it,c=sw();i=c.promise;try{Promise.resolve(n()).then(c.resolve,c.reject).finally(El)}catch(m){c.reject(m),El()}var d=Be;if(s){if((l.f&Ds)!==0)var u=Tw();if(r.b.is_rendered())(p=a.get(d))==null||p.reject(Mi),a.delete(d);else{for(const m of a.values())m.reject(Mi);a.clear()}a.set(d,c)}const h=(m,v=void 0)=>{if(u){var g=v===Mi;u(g)}if(!(v===Mi||(l.f&ir)!==0)){if(d.activate(),v)o.f|=mo,Li(o,v);else{(o.f&mo)!==0&&(o.f^=mo),Li(o,m);for(const[y,k]of a){if(a.delete(y),y===d)break;k.reject(Mi)}}d.deactivate()}};c.promise.then(h,m=>h(null,m||"unknown"))}),Hm(()=>{for(const l of a.values())l.reject(Mi)}),new Promise(l=>{function c(d){function u(){d===i?l(o):c(i)}d.then(u,u)}c(i)})}function H(n){const e=rf(n);return Ww(e),e}function zm(n){const e=rf(n);return e.equals=pw,e}function PC(n){var e=n.effects;if(e!==null){n.effects=null;for(var t=0;t<e.length;t+=1)zn(e[t])}}function Bm(n){var e,t=it,r=n.parent;if(!Wi&&r!==null&&(r.f&(ir|Pn))!==0)return vC(),n.v;ui(r);try{n.f&=~ms,PC(n),e=Yw(n)}finally{ui(t)}return e}function Aw(n){var e=Bm(n);if(!n.equals(e)&&(n.wv=qw(),(!(Be!=null&&Be.is_fork)||n.deps===null)&&(Be!==null?Be.capture(n,e,!0):n.v=e,n.deps===null))){Jt(n,rn);return}Wi||(gn!==null?(Fm()||Be!=null&&Be.is_fork)&&gn.set(n,e):Im(n))}function zC(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(Mi),r.teardown=pr,r.ac=null,Ml(r,0),Vm(r))}function Ew(n){if(n.effects!==null)for(const e of n.effects)e.teardown&&ya(e)}let sp=new Set;const rs=new Map;let Mw=!1;function ji(n,e){var t={f:0,v:n,reactions:null,equals:fw,rv:0,wv:0};return t}function F(n,e){const t=ji(n);return Ww(t),t}function ap(n,e=!1,t=!0){var i;const r=ji(n);return e||(r.equals=pw),za&&t&&Ut!==null&&Ut.l!==null&&((i=Ut.l).s??(i.s=[])).push(r),r}function b(n,e,t=!1){ct!==null&&(!Ir||(ct.f&ep)!==0)&&Ns()&&(ct.f&(Dn|ii|Al|ep))!==0&&(wr===null||!ma.call(wr,n))&&nC();let r=t?dt(e):e;return Li(n,r,ad)}function Li(n,e,t=null){if(!n.equals(e)){rs.set(n,Wi?e:n.v);var r=Ui.ensure();if(r.capture(n,e),(n.f&Dn)!==0){const i=n;(n.f&xn)!==0&&Bm(i),gn===null&&Im(i)}n.wv=qw(),Ow(n,xn,t),Ns()&&it!==null&&(it.f&rn)!==0&&(it.f&(zr|Vi))===0&&(lr===null?GC([n]):lr.push(n)),!r.is_fork&&sp.size>0&&!Mw&&BC()}return e}function BC(){Mw=!1;for(const n of sp)(n.f&rn)!==0&&Jt(n,di),wc(n)&&ya(n);sp.clear()}function Id(n,e=1){var t=f(n),r=e===1?t++:t--;return b(n,t),r}function ll(n){b(n,n.v+1)}function Ow(n,e,t){var r=n.reactions;if(r!==null)for(var i=Ns(),o=r.length,s=0;s<o;s++){var a=r[s],l=a.f;if(!(!i&&a===it)){var c=(l&xn)===0;if(c&&Jt(a,e),(l&Dn)!==0){var d=a;gn==null||gn.delete(d),(l&ms)===0&&(l&br&&(it===null||(it.f&Nd)===0)&&(a.f|=ms),Ow(d,di,t))}else if(c){var u=a;(l&ii)!==0&&Dr!==null&&Dr.add(u),t!==null?t.push(u):Pm(u)}}}}function dt(n){if(typeof n!="object"||n===null||oi in n)return n;const e=Nm(n);if(e!==FS&&e!==HS)return n;var t=new Map,r=Rm(n),i=F(0),o=ss,s=a=>{if(ss===o)return a();var l=ct,c=ss;Cr(null),Dv(o);var d=a();return Cr(l),Dv(c),d};return r&&t.set("length",F(n.length)),new Proxy(n,{defineProperty(a,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&eC();var d=t.get(l);return d===void 0?s(()=>{var u=F(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(()=>F(tn));t.set(l,d),ll(i)}}else b(c,tn),ll(i);return!0},get(a,l,c){var p;if(l===oi)return n;var d=t.get(l),u=l in a;if(d===void 0&&(!u||(p=po(a,l))!=null&&p.writable)&&(d=s(()=>{var m=dt(u?a[l]:tn),v=F(m);return v}),t.set(l,d)),d!==void 0){var h=f(d);return h===tn?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!==tn)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(a,l){var h;if(l===oi)return!0;var c=t.get(l),d=c!==void 0&&c.v!==tn||Reflect.has(a,l);if(c!==void 0||it!==null&&(!d||(h=po(a,l))!=null&&h.writable)){c===void 0&&(c=s(()=>{var p=d?dt(a[l]):tn,m=F(p);return m}),t.set(l,c));var u=f(c);if(u===tn)return!1}return d},set(a,l,c,d){var S;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,tn):p in a&&(m=s(()=>F(tn)),t.set(p+"",m))}if(u===void 0)(!h||(S=po(a,l))!=null&&S.writable)&&(u=s(()=>F(void 0)),b(u,dt(c)),t.set(l,u));else{h=u.v!==tn;var v=s(()=>dt(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"),k=Number(l);Number.isInteger(k)&&k>=y.v&&b(y,k+1)}ll(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!==tn});for(var[c,d]of t)d.v!==tn&&!(c in a)&&l.push(c);return l},setPrototypeOf(){tC()}})}function Av(n){try{if(n!==null&&typeof n=="object"&&oi in n)return n[oi]}catch{}return n}function FC(n,e){return Object.is(Av(n),Av(e))}var Ev,Dw,Rw,Nw;function HC(){if(Ev===void 0){Ev=window,Dw=/Firefox/.test(navigator.userAgent);var n=Element.prototype,e=Node.prototype,t=Text.prototype;Rw=po(e,"firstChild").get,Nw=po(e,"nextSibling").get,_v(n)&&(n.__click=void 0,n.__className=void 0,n.__attributes=null,n.__style=void 0,n.__e=void 0),_v(t)&&(t.__t=void 0)}}function Pi(n=""){return document.createTextNode(n)}function ti(n){return Rw.call(n)}function yc(n){return Nw.call(n)}function x(n,e){return ti(n)}function ze(n,e=!1){{var t=ti(n);return t instanceof Comment&&t.data===""?yc(t):t}}function _(n,e=1,t=!1){let r=n;for(;e--;)r=yc(r);return r}function VC(n){n.textContent=""}function Iw(){return!1}function Lw(n,e,t){return document.createElementNS(e??uw,n,void 0)}function UC(n,e){{const t=document.body;n.autofocus=!0,si(()=>{document.activeElement===t&&n.focus()})}}let Mv=!1;function jC(){Mv||(Mv=!0,document.addEventListener("reset",n=>{Promise.resolve().then(()=>{var e;if(!n.defaultPrevented)for(const t of n.target.elements)(e=t.__on_r)==null||e.call(t)})},{capture:!0}))}function of(n){var e=ct,t=it;Cr(null),ui(null);try{return n()}finally{Cr(e),ui(t)}}function Pw(n,e,t,r=t){n.addEventListener(e,()=>of(t));const i=n.__on_r;i?n.__on_r=()=>{i(),r(!0)}:n.__on_r=()=>r(!0),jC()}function WC(n){it===null&&(ct===null&&XS(),GS()),Wi&&ZS()}function KC(n,e){var t=e.last;t===null?e.last=e.first=n:(t.next=n,n.prev=t,e.last=n)}function vi(n,e){var t=it;t!==null&&(t.f&Pn)!==0&&(n|=Pn);var r={ctx:Ut,deps:null,nodes:null,f:n|xn|br,first:null,fn:e,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};Be==null||Be.register_created_effect(r);var i=r;if((n&ga)!==0)Ys!==null?Ys.push(r):Ui.ensure().schedule(r);else if(e!==null){try{ya(r)}catch(s){throw zn(r),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&Rs)===0&&(i=i.first,(n&ii)!==0&&(n&xo)!==0&&i!==null&&(i.f|=xo))}if(i!==null&&(i.parent=t,t!==null&&KC(i,t),ct!==null&&(ct.f&Dn)!==0&&(n&Vi)===0)){var o=ct;(o.effects??(o.effects=[])).push(i)}return r}function Fm(){return ct!==null&&!Ir}function Hm(n){const e=vi(nf,null);return Jt(e,rn),e.teardown=n,e}function de(n){WC();var e=it.f,t=!ct&&(e&zr)!==0&&(e&Ds)===0;if(t){var r=Ut;(r.e??(r.e=[])).push(n)}else return zw(n)}function zw(n){return vi(ga|WS,n)}function qC(n){Ui.ensure();const e=vi(Vi|Rs,n);return()=>{zn(e)}}function JC(n){Ui.ensure();const e=vi(Vi|Rs,n);return(t={})=>new Promise(r=>{t.outro?is(e,()=>{zn(e),r(void 0)}):(zn(e),r(void 0))})}function Bw(n){return vi(ga,n)}function YC(n){return vi(Al|Rs,n)}function bc(n,e=0){return vi(nf|e,n)}function Y(n,e=[],t=[],r=[]){IC(r,e,t,i=>{vi(nf,()=>n(...i.map(f)))})}function Is(n,e=0){var t=vi(ii|e,n);return t}function fr(n){return vi(zr|Rs,n)}function Fw(n){var e=n.teardown;if(e!==null){const t=Wi,r=ct;Ov(!0),Cr(null);try{e.call(null)}finally{Ov(t),Cr(r)}}}function Vm(n,e=!1){var t=n.first;for(n.first=n.last=null;t!==null;){const i=t.ac;i!==null&&of(()=>{i.abort(Mi)});var r=t.next;(t.f&Vi)!==0?t.parent=null:zn(t,e),t=r}}function ZC(n){for(var e=n.first;e!==null;){var t=e.next;(e.f&zr)===0&&zn(e),e=t}}function zn(n,e=!0){var t=!1;(e||(n.f&jS)!==0)&&n.nodes!==null&&n.nodes.end!==null&&(Hw(n.nodes.start,n.nodes.end),t=!0),Jt(n,$h),Vm(n,e&&!t),Ml(n,0);var r=n.nodes&&n.nodes.t;if(r!==null)for(const o of r)o.stop();Fw(n),n.f^=$h,n.f|=ir;var i=n.parent;i!==null&&i.first!==null&&Vw(n),n.next=n.prev=n.teardown=n.ctx=n.deps=n.fn=n.nodes=n.ac=n.b=null}function Hw(n,e){for(;n!==null;){var t=n===e?null:yc(n);n.remove(),n=t}}function Vw(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 is(n,e,t=!0){var r=[];Uw(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 Uw(n,e,t){if((n.f&Pn)===0){n.f^=Pn;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&Vi)===0){var s=(i.f&xo)!==0||(i.f&zr)!==0&&(n.f&ii)!==0;Uw(i,e,s?t:!1)}i=o}}}function Um(n){jw(n,!0)}function jw(n,e){if((n.f&Pn)!==0){n.f^=Pn,(n.f&rn)===0&&(Jt(n,xn),Ui.ensure().schedule(n));for(var t=n.first;t!==null;){var r=t.next,i=(t.f&xo)!==0||(t.f&zr)!==0;jw(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 jm(n,e){if(n.nodes)for(var t=n.nodes.start,r=n.nodes.end;t!==null;){var i=t===r?null:yc(t);e.append(t),t=i}}let hd=!1,Wi=!1;function Ov(n){Wi=n}let ct=null,Ir=!1;function Cr(n){ct=n}let it=null;function ui(n){it=n}let wr=null;function Ww(n){ct!==null&&(wr===null?wr=[n]:wr.push(n))}let Kn=null,Gn=0,lr=null;function GC(n){lr=n}let Kw=1,Ko=0,ss=Ko;function Dv(n){ss=n}function qw(){return++Kw}function wc(n){var e=n.f;if((e&xn)!==0)return!0;if(e&Dn&&(n.f&=~ms),(e&di)!==0){for(var t=n.deps,r=t.length,i=0;i<r;i++){var o=t[i];if(wc(o)&&Aw(o),o.wv>n.wv)return!0}(e&br)!==0&&gn===null&&Jt(n,rn)}return!1}function Jw(n,e,t=!0){var r=n.reactions;if(r!==null&&!(wr!==null&&ma.call(wr,n)))for(var i=0;i<r.length;i++){var o=r[i];(o.f&Dn)!==0?Jw(o,e,!1):e===o&&(t?Jt(o,xn):(o.f&rn)!==0&&Jt(o,di),Pm(o))}}function Yw(n){var v;var e=Kn,t=Gn,r=lr,i=ct,o=wr,s=Ut,a=Ir,l=ss,c=n.f;Kn=null,Gn=0,lr=null,ct=(c&(zr|Vi))===0?n:null,wr=null,va(n.ctx),Ir=!1,ss=++Ko,n.ac!==null&&(of(()=>{n.ac.abort(Mi)}),n.ac=null);try{n.f|=Nd;var d=n.fn,u=d();n.f|=Ds;var h=n.deps,p=Be==null?void 0:Be.is_fork;if(Kn!==null){var m;if(p||Ml(n,Gn),h!==null&&Gn>0)for(h.length=Gn+Kn.length,m=0;m<Kn.length;m++)h[Gn+m]=Kn[m];else n.deps=h=Kn;if(Fm()&&(n.f&br)!==0)for(m=Gn;m<h.length;m++)((v=h[m]).reactions??(v.reactions=[])).push(n)}else!p&&h!==null&&Gn<h.length&&(Ml(n,Gn),h.length=Gn);if(Ns()&&lr!==null&&!Ir&&h!==null&&(n.f&(Dn|di|xn))===0)for(m=0;m<lr.length;m++)Jw(lr[m],n);if(i!==null&&i!==n){if(Ko++,i.deps!==null)for(let g=0;g<t;g+=1)i.deps[g].rv=Ko;if(e!==null)for(const g of e)g.rv=Ko;lr!==null&&(r===null?r=lr:r.push(...lr))}return(n.f&mo)!==0&&(n.f^=mo),u}catch(g){return gw(g)}finally{n.f^=Nd,Kn=e,Gn=t,lr=r,ct=i,wr=o,va(s),Ir=a,ss=l}}function XC(n,e){let t=e.reactions;if(t!==null){var r=zS.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&Dn)!==0&&(Kn===null||!ma.call(Kn,e))){var o=e;(o.f&br)!==0&&(o.f^=br,o.f&=~ms),o.v!==tn&&Im(o),zC(o),Ml(o,0)}}function Ml(n,e){var t=n.deps;if(t!==null)for(var r=e;r<t.length;r++)XC(n,t[r])}function ya(n){var e=n.f;if((e&ir)===0){Jt(n,rn);var t=it,r=hd;it=n,hd=!0;try{(e&(ii|aw))!==0?ZC(n):Vm(n),Fw(n);var i=Yw(n);n.teardown=typeof i=="function"?i:null,n.wv=Kw;var o;PS&&wC&&(n.f&xn)!==0&&n.deps}finally{hd=r,it=t}}}async function QC(){await Promise.resolve(),ww()}function f(n){var e=n.f,t=(e&Dn)!==0;if(ct!==null&&!Ir){var r=it!==null&&(it.f&ir)!==0;if(!r&&(wr===null||!ma.call(wr,n))){var i=ct.deps;if((ct.f&Nd)!==0)n.rv<Ko&&(n.rv=Ko,Kn===null&&i!==null&&i[Gn]===n?Gn++:Kn===null?Kn=[n]:Kn.push(n));else{(ct.deps??(ct.deps=[])).push(n);var o=n.reactions;o===null?n.reactions=[ct]:ma.call(o,ct)||o.push(ct)}}}if(Wi&&rs.has(n))return rs.get(n);if(t){var s=n;if(Wi){var a=s.v;return((s.f&rn)===0&&s.reactions!==null||Gw(s))&&(a=Bm(s)),rs.set(s,a),a}var l=(s.f&br)===0&&!Ir&&ct!==null&&(hd||(ct.f&br)!==0),c=(s.f&Ds)===0;wc(s)&&(l&&(s.f|=br),Aw(s)),l&&!c&&(Ew(s),Zw(s))}if(gn!=null&&gn.has(n))return gn.get(n);if((n.f&mo)!==0)throw n.v;return n.v}function Zw(n){if(n.f|=br,n.deps!==null)for(const e of n.deps)(e.reactions??(e.reactions=[])).push(n),(e.f&Dn)!==0&&(e.f&br)===0&&(Ew(e),Zw(e))}function Gw(n){if(n.v===tn)return!0;if(n.deps===null)return!1;for(const e of n.deps)if(rs.has(e)||(e.f&Dn)!==0&&Gw(e))return!0;return!1}function Pt(n){var e=Ir;try{return Ir=!0,n()}finally{Ir=e}}function $C(n){if(!(typeof n!="object"||!n||n instanceof EventTarget)){if(oi in n)lp(n);else if(!Array.isArray(n))for(let e in n){const t=n[e];typeof t=="object"&&t&&oi in t&&lp(t)}}}function lp(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{lp(n[r],e)}catch{}const t=Nm(n);if(t!==Object.prototype&&t!==Array.prototype&&t!==Map.prototype&&t!==Set.prototype&&t!==Date.prototype){const r=ow(t);for(let i in r){const o=r[i].get;if(o)try{o.call(n)}catch{}}}}}const eT=["touchstart","touchmove"];function tT(n){return eT.includes(n)}const qo=Symbol("events"),Xw=new Set,cp=new Set;function nT(n,e,t,r={}){function i(o){if(r.capture||dp.call(e,o),!o.cancelBubble)return of(()=>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 wt(n,e,t,r,i){var o={capture:r,passive:i},s=nT(n,e,t,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Hm(()=>{e.removeEventListener(n,s,o)})}function P(n,e,t){(e[qo]??(e[qo]={}))[n]=t}function $e(n){for(var e=0;e<n.length;e++)Xw.add(n[e]);for(var t of cp)t(n)}let Rv=null;function dp(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;Rv=n;var s=0,a=Rv===n&&n[qo];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){n[qo]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||n.target,o!==e){BS(n,"currentTarget",{configurable:!0,get(){return o||t}});var d=ct,u=it;Cr(null),ui(null);try{for(var h,p=[];o!==null;){var m=o.assignedSlot||o.parentNode||o.host||null;try{var v=(y=o[qo])==null?void 0:y[r];v!=null&&(!o.disabled||n.target===o)&&v.call(o,n)}catch(k){h?p.push(k):h=k}if(n.cancelBubble||m===e||m===null)break;o=m}if(h){for(let k of p)queueMicrotask(()=>{throw k});throw h}}finally{n[qo]=e,delete n.currentTarget,Cr(d),ui(u)}}}var rw;const qf=((rw=globalThis==null?void 0:globalThis.window)==null?void 0:rw.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:n=>n});function rT(n){return(qf==null?void 0:qf.createHTML(n))??n}function Qw(n){var e=Lw("template");return e.innerHTML=rT(n.replaceAll("<!>","<!---->")),e.content}function gs(n,e){var t=it;t.nodes===null&&(t.nodes={start:n,end:e,a:null,t:null})}function E(n,e){var t=(e&hC)!==0,r=(e&pC)!==0,i,o=!n.startsWith("<!>");return()=>{i===void 0&&(i=Qw(o?n:"<!>"+n),t||(i=ti(i)));var s=r||Dw?document.importNode(i,!0):i.cloneNode(!0);if(t){var a=ti(s),l=s.lastChild;gs(a,l)}else gs(s,s);return s}}function iT(n,e,t="svg"){var r=!n.startsWith("<!>"),i=`<${t}>${r?n:"<!>"+n}</${t}>`,o;return()=>{if(!o){var s=Qw(i),a=ti(s);o=ti(a)}var l=o.cloneNode(!0);return gs(l,l),l}}function Er(n,e){return iT(n,e,"svg")}function an(n=""){{var e=Pi(n+"");return gs(e,e),e}}function Rt(){var n=document.createDocumentFragment(),e=document.createComment(""),t=Pi();return n.append(e,t),gs(e,t),n}function T(n,e){n!==null&&n.before(e)}function te(n,e){var t=e==null?"":typeof e=="object"?`${e}`:e;t!==(n.__t??(n.__t=n.nodeValue))&&(n.__t=t,n.nodeValue=`${t}`)}function oT(n,e){return sT(n,e)}const zc=new Map;function sT(n,{target:e,anchor:t,props:r={},events:i,context:o,intro:s=!0,transformError:a}){HC();var l=void 0,c=JC(()=>{var d=t??e.appendChild(Pi());Sw(d,{pending:()=>{}},p=>{qe({});var m=Ut;o&&(m.c=o),i&&(r.$$events=i),l=n(p,r)||{},Je()},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=tT(v);for(const S of[e,document]){var y=zc.get(S);y===void 0&&(y=new Map,zc.set(S,y));var k=y.get(v);k===void 0?(S.addEventListener(v,dp,{passive:g}),y.set(v,1)):y.set(v,k+1)}}}};return h(tf(Xw)),cp.add(h),()=>{var g;for(var p of u)for(const y of[e,document]){var m=zc.get(y),v=m.get(p);--v==0?(y.removeEventListener(p,dp),m.delete(p),m.size===0&&zc.delete(y)):m.set(p,v)}cp.delete(h),d!==t&&((g=d.parentNode)==null||g.removeChild(d))}});return aT.set(l,c),l}let aT=new WeakMap;var Rr,$r,tr,ns,mc,gc,$u;class xc{constructor(e,t=!0){jn(this,"anchor");Ze(this,Rr,new Map);Ze(this,$r,new Map);Ze(this,tr,new Map);Ze(this,ns,new Set);Ze(this,mc,!0);Ze(this,gc,e=>{if(j(this,Rr).has(e)){var t=j(this,Rr).get(e),r=j(this,$r).get(t);if(r)Um(r),j(this,ns).delete(t);else{var i=j(this,tr).get(t);i&&(j(this,$r).set(t,i.effect),j(this,tr).delete(t),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[o,s]of j(this,Rr)){if(j(this,Rr).delete(o),o===e)break;const a=j(this,tr).get(s);a&&(zn(a.effect),j(this,tr).delete(s))}for(const[o,s]of j(this,$r)){if(o===t||j(this,ns).has(o))continue;const a=()=>{if(Array.from(j(this,Rr).values()).includes(o)){var c=document.createDocumentFragment();jm(s,c),c.append(Pi()),j(this,tr).set(o,{effect:s,fragment:c})}else zn(s);j(this,ns).delete(o),j(this,$r).delete(o)};j(this,mc)||!r?(j(this,ns).add(o),is(s,a,!1)):a()}}});Ze(this,$u,e=>{j(this,Rr).delete(e);const t=Array.from(j(this,Rr).values());for(const[r,i]of j(this,tr))t.includes(r)||(zn(i.effect),j(this,tr).delete(r))});this.anchor=e,st(this,mc,t)}ensure(e,t){var r=Be,i=Iw();if(t&&!j(this,$r).has(e)&&!j(this,tr).has(e))if(i){var o=document.createDocumentFragment(),s=Pi();o.append(s),j(this,tr).set(e,{effect:fr(()=>t(s)),fragment:o})}else j(this,$r).set(e,fr(()=>t(this.anchor)));if(j(this,Rr).set(r,e),i){for(const[a,l]of j(this,$r))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of j(this,tr))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(j(this,gc)),r.ondiscard(j(this,$u))}else j(this,gc).call(this,r)}}Rr=new WeakMap,$r=new WeakMap,tr=new WeakMap,ns=new WeakMap,mc=new WeakMap,gc=new WeakMap,$u=new WeakMap;const lT=0,Nv=1,cT=2;function dT(n,e,t,r,i){var o=Ns(),s=tn,a=o?ji(s):ap(s,!1,!1),l=o?ji(s):ap(s,!1,!1),c=new xc(n);Is(()=>{var d=Be;d.deactivate();var u=e();d.activate();var h=!1;if(VS(u)){var p=Cw(),m=!1;const v=g=>{if(!h){m=!0,p(!1),Ui.ensure();try{g()}finally{El(!1),Qs||ww()}}};u.then(g=>{v(()=>{Li(a,g),c.ensure(Nv,r&&(y=>r(y,a)))})},g=>{v(()=>{if(Li(l,g),c.ensure(cT,i&&(y=>i(y,l))),!i)throw l.v})}),si(()=>{m||v(()=>{c.ensure(lT,t)})})}else Li(a,u),c.ensure(Nv,r&&(v=>r(v,a)));return()=>{h=!0}})}function J(n,e,t=!1){var r=new xc(n),i=t?xo:0;function o(s,a){r.ensure(s,a)}Is(()=>{var s=!1;e((a,l=0)=>{s=!0,o(l,a)}),s||o(-1,null)},i)}const uT=Symbol("NaN");function up(n,e,t){var r=new xc(n),i=!Ns();Is(()=>{var o=e();o!==o&&(o=uT),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,t)})}function ba(n,e){return e}function fT(n,e,t){for(var r=[],i=e.length,o,s=e.length,a=0;a<i;a++){let u=e[a];is(u,()=>{if(o){if(o.pending.delete(u),o.done.add(u),o.pending.size===0){var h=n.outrogroups;fp(n,tf(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;VC(d),d.append(c),n.items.clear()}fp(n,e,!l)}else o={pending:new Set(e),done:new Set},(n.outrogroups??(n.outrogroups=new Set)).add(o)}function fp(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|=ei;const s=document.createDocumentFragment();jm(o,s)}else zn(e[i],t)}}var Iv;function mt(n,e,t,r,i,o=null){var s=n,a=new Map,l=(e&dw)!==0;if(l){var c=n;s=c.appendChild(Pi())}var d=null,u=zm(()=>{var S=t();return Rm(S)?S:S==null?[]:tf(S)}),h,p=new Map,m=!0;function v(S){(k.effect.f&ir)===0&&(k.pending.delete(S),k.fallback=d,hT(k,h,s,e,r),d!==null&&(h.length===0?(d.f&ei)===0?Um(d):(d.f^=ei,tl(d,null,s)):is(d,()=>{d=null})))}function g(S){k.pending.delete(S)}var y=Is(()=>{h=f(u);for(var S=h.length,C=new Set,A=Be,W=Iw(),z=0;z<S;z+=1){var D=h[z],O=r(D,z),U=m?null:a.get(O);U?(U.v&&Li(U.v,D),U.i&&Li(U.i,z),W&&A.unskip_effect(U.e)):(U=pT(a,m?s:Iv??(Iv=Pi()),D,O,z,i,e,t),m||(U.e.f|=ei),a.set(O,U)),C.add(O)}if(S===0&&o&&!d&&(m?d=fr(()=>o(s)):(d=fr(()=>o(Iv??(Iv=Pi()))),d.f|=ei)),S>C.size&&YS(),!m)if(p.set(A,C),W){for(const[ee,R]of a)C.has(ee)||A.skip_effect(R.e);A.oncommit(v),A.ondiscard(g)}else v(A);f(u)}),k={effect:y,items:a,pending:p,outrogroups:null,fallback:d};m=!1}function Ya(n){for(;n!==null&&(n.f&zr)===0;)n=n.next;return n}function hT(n,e,t,r,i){var U,ee,R,K,ne,X,N,q,L;var o=(r&sC)!==0,s=e.length,a=n.items,l=Ya(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&ei)===0&&((ee=(U=g.nodes)==null?void 0:U.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 V of n.outrogroups)V.pending.delete(g),V.done.delete(g);if((g.f&Pn)!==0&&(Um(g),o&&((K=(R=g.nodes)==null?void 0:R.a)==null||K.unfix(),(u??(u=new Set)).delete(g))),(g.f&ei)!==0)if(g.f^=ei,g===l)tl(g,null,t);else{var k=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),Zi(n,d,g),Zi(n,g,k),tl(g,k,t),d=g,h=[],p=[],l=Ya(d.next);continue}if(g!==l){if(c!==void 0&&c.has(g)){if(h.length<p.length){var S=p[0],C;d=S.prev;var A=h[0],W=h[h.length-1];for(C=0;C<h.length;C+=1)tl(h[C],S,t);for(C=0;C<p.length;C+=1)c.delete(p[C]);Zi(n,A.prev,W.next),Zi(n,d,A),Zi(n,W,S),l=S,d=W,y-=1,h=[],p=[]}else c.delete(g),tl(g,l,t),Zi(n,g.prev,g.next),Zi(n,g,d===null?n.effect.first:d.next),Zi(n,d,g),d=g;continue}for(h=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=Ya(l.next);if(l===null)continue}(g.f&ei)===0&&h.push(g),d=g,l=Ya(g.next)}if(n.outrogroups!==null){for(const V of n.outrogroups)V.pending.size===0&&(fp(n,tf(V.done)),(ne=n.outrogroups)==null||ne.delete(V));n.outrogroups.size===0&&(n.outrogroups=null)}if(l!==null||c!==void 0){var z=[];if(c!==void 0)for(g of c)(g.f&Pn)===0&&z.push(g);for(;l!==null;)(l.f&Pn)===0&&l!==n.fallback&&z.push(l),l=Ya(l.next);var D=z.length;if(D>0){var O=(r&dw)!==0&&s===0?t:null;if(o){for(y=0;y<D;y+=1)(N=(X=z[y].nodes)==null?void 0:X.a)==null||N.measure();for(y=0;y<D;y+=1)(L=(q=z[y].nodes)==null?void 0:q.a)==null||L.fix()}fT(n,z,O)}}o&&si(()=>{var V,re;if(u!==void 0)for(g of u)(re=(V=g.nodes)==null?void 0:V.a)==null||re.apply()})}function pT(n,e,t,r,i,o,s,a){var l=(s&iC)!==0?(s&aC)===0?ap(t,!1,!1):ji(t):null,c=(s&oC)!==0?ji(i):null;return{v:l,i:c,e:fr(()=>(o(e,l??t,c??i,a),()=>{n.delete(r)}))}}function tl(n,e,t){if(n.nodes)for(var r=n.nodes.start,i=n.nodes.end,o=e&&(e.f&ei)===0?e.nodes.start:t;r!==null;){var s=yc(r);if(o.before(r),r===i)return;r=s}}function Zi(n,e,t){e===null?n.effect.first=t:e.next=t,t===null?n.effect.last=e:t.prev=e}function mT(n,e,t=!1,r=!1,i=!1,o=!1){var s=n,a="";if(t)var l=n;Y(()=>{var c=it;if(a!==(a=e()??"")){if(t){c.nodes=null,l.innerHTML=a,a!==""&&gs(ti(l),l.lastChild);return}if(c.nodes!==null&&(Hw(c.nodes.start,c.nodes.end),c.nodes=null),a!==""){var d=r?mC:i?gC:void 0,u=Lw(r?"svg":i?"math":"template",d);u.innerHTML=a;var h=r||i?u:u.content;if(gs(ti(h),h.lastChild),r||i)for(;ti(h);)s.before(ti(h));else s.before(h)}}})}function Wm(n,e,...t){var r=new xc(n);Is(()=>{const i=e()??null;r.ensure(i,i&&(o=>i(o,...t)))},xo)}function gT(n,e,t){var r=new xc(n);Is(()=>{var i=e()??null;r.ensure(i,i&&(o=>t(o,i)))},xo)}function Ol(n,e,t){Bw(()=>{var r=Pt(()=>e(n,t==null?void 0:t())||{});if(t&&(r!=null&&r.update)){var i=!1,o={};bc(()=>{var s=t();$C(s),i&&hw(o,s)&&(o=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}const Lv=[...`
|
|
3
|
+
\r\f \v\uFEFF`];function vT(n,e,t){var r=""+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||Lv.includes(r[s-1]))&&(a===r.length||Lv.includes(r[a]))?r=(s===0?"":r.substring(0,s))+r.substring(a+1):s=a}}return r===""?null:r}function yT(n,e){return n==null?null:String(n)}function $w(n,e,t,r,i,o){var s=n.__className;if(s!==t||s===void 0){var a=vT(t,r,o);a==null?n.removeAttribute("class"):n.className=a,n.__className=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 se(n,e,t,r){var i=n.__style;if(i!==e){var o=yT(e);o==null?n.removeAttribute("style"):n.style.cssText=o,n.__style=e}return r}function Km(n,e,t=!1){if(n.multiple){if(e==null)return;if(!Rm(e))return yC();for(var r of n.options)r.selected=e.includes(Pv(r));return}for(r of n.options){var i=Pv(r);if(FC(i,e)){r.selected=!0;return}}(!t||e!==void 0)&&(n.selectedIndex=-1)}function ex(n){var e=new MutationObserver(()=>{Km(n,n.__value)});e.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Hm(()=>{e.disconnect()})}function Pv(n){return"__value"in n?n.__value:n.value}const bT=Symbol("is custom element"),wT=Symbol("is html"),xT=qS?"progress":"PROGRESS";function Pr(n,e){var t=qm(n);t.value===(t.value=e??void 0)||n.value===e&&(e!==0||n.nodeName!==xT)||(n.value=e??"")}function vs(n,e){var t=qm(n);t.checked!==(t.checked=e??void 0)&&(n.checked=e)}function Z(n,e,t,r){var i=qm(n);i[e]!==(i[e]=t)&&(e==="loading"&&(n[KS]=t),t==null?n.removeAttribute(e):typeof t!="string"&&kT(n).includes(e)?n[e]=t:n.setAttribute(e,t))}function qm(n){return n.__attributes??(n.__attributes={[bT]:n.nodeName.includes("-"),[wT]:n.namespaceURI===uw})}var zv=new Map;function kT(n){var e=n.getAttribute("is")||n.nodeName,t=zv.get(e);if(t)return t;zv.set(e,t=[]);for(var r,i=n,o=Element.prototype;o!==i;){r=ow(i);for(var s in r)r[s].set&&t.push(s);i=Nm(i)}return t}function ys(n,e,t=e){var r=new WeakSet;Pw(n,"input",async i=>{var o=i?n.defaultValue:n.value;if(o=Yf(n)?Zf(o):o,t(o),Be!==null&&r.add(Be),await QC(),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))}}}),Pt(e)==null&&n.value&&(t(Yf(n)?Zf(n.value):n.value),Be!==null&&r.add(Be)),bc(()=>{var i=e();if(n===document.activeElement){var o=Be;if(r.has(o))return}Yf(n)&&i===Zf(n.value)||n.type==="date"&&!i&&!n.value||i!==n.value&&(n.value=i??"")})}function Jf(n,e,t=e){Pw(n,"change",r=>{var i=r?n.defaultChecked:n.checked;t(i)}),Pt(e)==null&&t(n.checked),bc(()=>{var r=e();n.checked=!!r})}function Yf(n){var e=n.type;return e==="number"||e==="range"}function Zf(n){return n===""?null:+n}function Bv(n,e){return n===e||(n==null?void 0:n[oi])===e}function kt(n={},e,t,r){var i=Ut.r,o=it;return Bw(()=>{var s,a;return bc(()=>{s=a,a=(r==null?void 0:r())||[],Pt(()=>{n!==t(...a)&&(e(n,...a),s&&Bv(t(...s),n)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&$h;)l=l.parent;const c=()=>{a&&Bv(t(...a),n)&&e(null,...a)},d=l.teardown;l.teardown=()=>{c(),d==null||d()}}}),n}const _T={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 ST(n,e,t){return new Proxy({props:n,exclude:e},_T)}const CT={get(n,e){let t=n.props.length;for(;t--;){let r=n.props[t];if(Ja(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];Ja(i)&&(i=i());const o=po(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(Ja(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r){const i=po(r,e);return i&&!i.configurable&&(i.configurable=!0),i}}},has(n,e){if(e===oi||e===lw)return!1;for(let t of n.props)if(Ja(t)&&(t=t()),t!=null&&e in t)return!0;return!1},ownKeys(n){const e=[];for(let t of n.props)if(Ja(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 Bc(...n){return new Proxy({props:n},CT)}function ft(n,e,t,r){var S;var i=!za||(t&cC)!==0,o=(t&uC)!==0,s=(t&fC)!==0,a=r,l=!0,c=()=>(l&&(l=!1,a=s?Pt(r):r),a);let d;if(o){var u=oi in n||lw in n;d=((S=po(n,e))==null?void 0:S.set)??(u&&e in n?C=>n[e]=C:void 0)}var h,p=!1;o?[h,p]=SC(()=>n[e]):h=n[e],h===void 0&&r!==void 0&&(h=c(),d&&(i&&$S(),d(h)));var m;if(i?m=()=>{var C=n[e];return C===void 0?c():(l=!0,C)}:m=()=>{var C=n[e];return C!==void 0&&(a=void 0),C===void 0?a:C},i&&(t&dC)===0)return m;if(d){var v=n.$$legacy;return(function(C,A){return arguments.length>0?((!i||!A||v||p)&&d(A?m():C),C):m()})}var g=!1,y=((t&lC)!==0?rf:zm)(()=>(g=!1,m()));o&&f(y);var k=it;return(function(C,A){if(arguments.length>0){const W=A?f(y):i&&o?dt(C):C;return b(y,W),g=!0,a!==void 0&&(a=W),C}return Wi&&g||(k.f&ir)!==0?y.v:f(y)})}function sf(n){Ut===null&&cw(),za&&Ut.l!==null?TT(Ut).m.push(n):de(()=>{const e=Pt(n);if(typeof e=="function")return e})}function yi(n){Ut===null&&cw(),sf(()=>()=>Pt(n))}function TT(n){var e=n.l;return e.u??(e.u={a:[],b:[],m:[]})}const AT="5";var iw;typeof window<"u"&&((iw=window.__svelte??(window.__svelte={})).v??(iw.v=new Set)).add(AT);xC();const ET="upload://";function MT(n){return n.startsWith(ET)}const pd=n=>n,bn=n=>n;var pt;(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})(pt||(pt={}));var Fv;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Fv||(Fv={}));const Ce=pt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Qi=n=>{switch(typeof n){case"undefined":return Ce.undefined;case"string":return Ce.string;case"number":return Number.isNaN(n)?Ce.nan:Ce.number;case"boolean":return Ce.boolean;case"function":return Ce.function;case"bigint":return Ce.bigint;case"symbol":return Ce.symbol;case"object":return Array.isArray(n)?Ce.array:n===null?Ce.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ce.promise:typeof Map<"u"&&n instanceof Map?Ce.map:typeof Set<"u"&&n instanceof Set?Ce.set:typeof Date<"u"&&n instanceof Date?Ce.date:Ce.object;default:return Ce.unknown}},me=pt.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 Ki 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 Ki))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pt.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()}}Ki.create=n=>new Ki(n);const hp=(n,e)=>{let t;switch(n.code){case me.invalid_type:n.received===Ce.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case me.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,pt.jsonStringifyReplacer)}`;break;case me.unrecognized_keys:t=`Unrecognized key(s) in object: ${pt.joinValues(n.keys,", ")}`;break;case me.invalid_union:t="Invalid input";break;case me.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${pt.joinValues(n.options)}`;break;case me.invalid_enum_value:t=`Invalid enum value. Expected ${pt.joinValues(n.options)}, received '${n.received}'`;break;case me.invalid_arguments:t="Invalid function arguments";break;case me.invalid_return_type:t="Invalid function return type";break;case me.invalid_date:t="Invalid date";break;case me.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}"`:pt.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case me.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 me.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 me.custom:t="Invalid input";break;case me.invalid_intersection_types:t="Intersection results could not be merged";break;case me.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case me.not_finite:t="Number must be finite";break;default:t=e.defaultError,pt.assertNever(n)}return{message:t}};let OT=hp;function DT(){return OT}const RT=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 we(n,e){const t=DT(),r=RT({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===hp?void 0:hp].filter(i=>!!i)});n.common.issues.push(r)}class or{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 je;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 or.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 je;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 je=Object.freeze({status:"aborted"}),nl=n=>({status:"dirty",value:n}),Mr=n=>({status:"valid",value:n}),Hv=n=>n.status==="aborted",Vv=n=>n.status==="dirty",wa=n=>n.status==="valid",Ld=n=>typeof Promise<"u"&&n instanceof Promise;var Me;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Me||(Me={}));class ko{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 Uv=(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 Ki(n.common.issues);return this._error=t,this._error}}};function ot(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 ht{get description(){return this._def.description}_getType(e){return Qi(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Qi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new or,ctx:{common:e.parent.common,data:e.data,parsedType:Qi(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ld(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:Qi(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Uv(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:Qi(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:Qi(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(Ld(i)?i:Promise.resolve(i));return Uv(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:me.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 ka({schema:this,typeName:We.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 go.create(this,this._def)}nullable(){return _a.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ai.create(this)}promise(){return Fd.create(this,this._def)}or(e){return zd.create([this,e],this._def)}and(e){return Bd.create(this,e,this._def)}transform(e){return new ka({...ot(this._def),schema:this,typeName:We.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new mp({...ot(this._def),innerType:this,defaultValue:t,typeName:We.ZodDefault})}brand(){return new tA({typeName:We.ZodBranded,type:this,...ot(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new gp({...ot(this._def),innerType:this,catchValue:t,typeName:We.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Jm.create(this,e)}readonly(){return vp.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const NT=/^c[^\s-]{8,}$/i,IT=/^[0-9a-z]+$/,LT=/^[0-9A-HJKMNP-TV-Z]{26}$/i,PT=/^[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,zT=/^[a-z0-9_-]{21}$/i,BT=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,FT=/^[-+]?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)?)??$/,HT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,VT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Gf;const UT=/^(?:(?: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])$/,jT=/^(?:(?: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])$/,WT=/^(([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]))$/,KT=/^(([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])$/,qT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,JT=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tx="((\\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])))",YT=new RegExp(`^${tx}$`);function nx(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 ZT(n){return new RegExp(`^${nx(n)}$`)}function GT(n){let e=`${tx}T${nx(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 XT(n,e){return!!((e==="v4"||!e)&&UT.test(n)||(e==="v6"||!e)&&WT.test(n))}function QT(n,e){if(!BT.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 $T(n,e){return!!((e==="v4"||!e)&&jT.test(n)||(e==="v6"||!e)&&KT.test(n))}class Jo extends ht{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ce.string){const o=this._getOrReturnCtx(e);return we(o,{code:me.invalid_type,expected:Ce.string,received:o.parsedType}),je}const r=new or;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),we(i,{code:me.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),we(i,{code:me.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?we(i,{code:me.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&we(i,{code:me.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")HT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"email",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")Gf||(Gf=new RegExp(VT,"u")),Gf.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"emoji",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")PT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"uuid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")zT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"nanoid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")NT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"cuid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")IT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"cuid2",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")LT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"ulid",code:me.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),we(i,{validation:"url",code:me.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),we(i,{validation:"regex",code:me.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),we(i,{code:me.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),we(i,{code:me.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),we(i,{code:me.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?GT(o).test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{code:me.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?YT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{code:me.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?ZT(o).test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{code:me.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?FT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"duration",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?XT(e.data,o.version)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"ip",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?QT(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"jwt",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?$T(e.data,o.version)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"cidr",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?qT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"base64",code:me.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?JT.test(e.data)||(i=this._getOrReturnCtx(e,i),we(i,{validation:"base64url",code:me.invalid_string,message:o.message}),r.dirty()):pt.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(i=>e.test(i),{validation:t,code:me.invalid_string,...Me.errToObj(r)})}_addCheck(e){return new Jo({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Me.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Me.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Me.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Me.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Me.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Me.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Me.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Me.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Me.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Me.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Me.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Me.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Me.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,...Me.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,...Me.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Me.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Me.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Me.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Me.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Me.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Me.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Me.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Me.errToObj(t)})}nonempty(e){return this.min(1,Me.errToObj(e))}trim(){return new Jo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Jo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Jo({...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}}Jo.create=n=>new Jo({checks:[],typeName:We.ZodString,coerce:(n==null?void 0:n.coerce)??!1,...ot(n)});function eA(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 Dl extends ht{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)!==Ce.number){const o=this._getOrReturnCtx(e);return we(o,{code:me.invalid_type,expected:Ce.number,received:o.parsedType}),je}let r;const i=new or;for(const o of this._def.checks)o.kind==="int"?pt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),we(r,{code:me.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),we(r,{code:me.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),we(r,{code:me.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?eA(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),we(r,{code:me.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),we(r,{code:me.not_finite,message:o.message}),i.dirty()):pt.assertNever(o);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Me.toString(t))}setLimit(e,t,r,i){return new Dl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Me.toString(i)}]})}_addCheck(e){return new Dl({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Me.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Me.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Me.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Me.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Me.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"&&pt.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)}}Dl.create=n=>new Dl({checks:[],typeName:We.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...ot(n)});class Rl extends ht{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)!==Ce.bigint)return this._getInvalidInput(e);let r;const i=new or;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),we(r,{code:me.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),we(r,{code:me.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),we(r,{code:me.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):pt.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return we(t,{code:me.invalid_type,expected:Ce.bigint,received:t.parsedType}),je}gte(e,t){return this.setLimit("min",e,!0,Me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Me.toString(t))}setLimit(e,t,r,i){return new Rl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:Me.toString(i)}]})}_addCheck(e){return new Rl({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Me.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}}Rl.create=n=>new Rl({checks:[],typeName:We.ZodBigInt,coerce:(n==null?void 0:n.coerce)??!1,...ot(n)});class jv extends ht{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ce.boolean){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.boolean,received:r.parsedType}),je}return Mr(e.data)}}jv.create=n=>new jv({typeName:We.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...ot(n)});class Pd extends ht{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ce.date){const o=this._getOrReturnCtx(e);return we(o,{code:me.invalid_type,expected:Ce.date,received:o.parsedType}),je}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return we(o,{code:me.invalid_date}),je}const r=new or;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),we(i,{code:me.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),we(i,{code:me.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):pt.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Pd({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Me.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Me.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}}Pd.create=n=>new Pd({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:We.ZodDate,...ot(n)});class Wv extends ht{_parse(e){if(this._getType(e)!==Ce.symbol){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.symbol,received:r.parsedType}),je}return Mr(e.data)}}Wv.create=n=>new Wv({typeName:We.ZodSymbol,...ot(n)});class Kv extends ht{_parse(e){if(this._getType(e)!==Ce.undefined){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.undefined,received:r.parsedType}),je}return Mr(e.data)}}Kv.create=n=>new Kv({typeName:We.ZodUndefined,...ot(n)});class qv extends ht{_parse(e){if(this._getType(e)!==Ce.null){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.null,received:r.parsedType}),je}return Mr(e.data)}}qv.create=n=>new qv({typeName:We.ZodNull,...ot(n)});class Jv extends ht{constructor(){super(...arguments),this._any=!0}_parse(e){return Mr(e.data)}}Jv.create=n=>new Jv({typeName:We.ZodAny,...ot(n)});class Yv extends ht{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Mr(e.data)}}Yv.create=n=>new Yv({typeName:We.ZodUnknown,...ot(n)});class _o extends ht{_parse(e){const t=this._getOrReturnCtx(e);return we(t,{code:me.invalid_type,expected:Ce.never,received:t.parsedType}),je}}_o.create=n=>new _o({typeName:We.ZodNever,...ot(n)});class Zv extends ht{_parse(e){if(this._getType(e)!==Ce.undefined){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.void,received:r.parsedType}),je}return Mr(e.data)}}Zv.create=n=>new Zv({typeName:We.ZodVoid,...ot(n)});class ai extends ht{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),i=this._def;if(t.parsedType!==Ce.array)return we(t,{code:me.invalid_type,expected:Ce.array,received:t.parsedType}),je;if(i.exactLength!==null){const s=t.data.length>i.exactLength.value,a=t.data.length<i.exactLength.value;(s||a)&&(we(t,{code:s?me.too_big:me.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&&(we(t,{code:me.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&&(we(t,{code:me.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 ko(t,s,t.path,a)))).then(s=>or.mergeArray(r,s));const o=[...t.data].map((s,a)=>i.type._parseSync(new ko(t,s,t.path,a)));return or.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new ai({...this._def,minLength:{value:e,message:Me.toString(t)}})}max(e,t){return new ai({...this._def,maxLength:{value:e,message:Me.toString(t)}})}length(e,t){return new ai({...this._def,exactLength:{value:e,message:Me.toString(t)}})}nonempty(e){return this.min(1,e)}}ai.create=(n,e)=>new ai({type:n,minLength:null,maxLength:null,exactLength:null,typeName:We.ZodArray,...ot(e)});function js(n){if(n instanceof nn){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=go.create(js(r))}return new nn({...n._def,shape:()=>e})}else return n instanceof ai?new ai({...n._def,type:js(n.element)}):n instanceof go?go.create(js(n.unwrap())):n instanceof _a?_a.create(js(n.unwrap())):n instanceof bs?bs.create(n.items.map(e=>js(e))):n}class nn extends ht{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=pt.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Ce.object){const c=this._getOrReturnCtx(e);return we(c,{code:me.invalid_type,expected:Ce.object,received:c.parsedType}),je}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof _o&&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 ko(i,u,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof _o){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&&(we(i,{code:me.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 ko(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=>or.mergeObjectSync(r,c)):or.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return Me.errToObj,new nn({...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:Me.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new nn({...this._def,unknownKeys:"strip"})}passthrough(){return new nn({...this._def,unknownKeys:"passthrough"})}extend(e){return new nn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new nn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:We.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new nn({...this._def,catchall:e})}pick(e){const t={};for(const r of pt.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new nn({...this._def,shape:()=>t})}omit(e){const t={};for(const r of pt.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new nn({...this._def,shape:()=>t})}deepPartial(){return js(this)}partial(e){const t={};for(const r of pt.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?t[r]=i:t[r]=i.optional()}return new nn({...this._def,shape:()=>t})}required(e){const t={};for(const r of pt.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof go;)o=o._def.innerType;t[r]=o}return new nn({...this._def,shape:()=>t})}keyof(){return rx(pt.objectKeys(this.shape))}}nn.create=(n,e)=>new nn({shape:()=>n,unknownKeys:"strip",catchall:_o.create(),typeName:We.ZodObject,...ot(e)});nn.strictCreate=(n,e)=>new nn({shape:()=>n,unknownKeys:"strict",catchall:_o.create(),typeName:We.ZodObject,...ot(e)});nn.lazycreate=(n,e)=>new nn({shape:n,unknownKeys:"strip",catchall:_o.create(),typeName:We.ZodObject,...ot(e)});class zd extends ht{_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 Ki(a.ctx.common.issues));return we(t,{code:me.invalid_union,unionErrors:s}),je}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 Ki(l));return we(t,{code:me.invalid_union,unionErrors:a}),je}}get options(){return this._def.options}}zd.create=(n,e)=>new zd({options:n,typeName:We.ZodUnion,...ot(e)});function pp(n,e){const t=Qi(n),r=Qi(e);if(n===e)return{valid:!0,data:n};if(t===Ce.object&&r===Ce.object){const i=pt.objectKeys(e),o=pt.objectKeys(n).filter(a=>i.indexOf(a)!==-1),s={...n,...e};for(const a of o){const l=pp(n[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(t===Ce.array&&r===Ce.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=pp(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===Ce.date&&r===Ce.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Bd extends ht{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(Hv(o)||Hv(s))return je;const a=pp(o.value,s.value);return a.valid?((Vv(o)||Vv(s))&&t.dirty(),{status:t.value,value:a.data}):(we(r,{code:me.invalid_intersection_types}),je)};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}))}}Bd.create=(n,e,t)=>new Bd({left:n,right:e,typeName:We.ZodIntersection,...ot(t)});class bs extends ht{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ce.array)return we(r,{code:me.invalid_type,expected:Ce.array,received:r.parsedType}),je;if(r.data.length<this._def.items.length)return we(r,{code:me.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),je;!this._def.rest&&r.data.length>this._def.items.length&&(we(r,{code:me.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 ko(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>or.mergeArray(t,s)):or.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new bs({...this._def,rest:e})}}bs.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new bs({items:n,typeName:We.ZodTuple,rest:null,...ot(e)})};class Gv extends ht{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!==Ce.map)return we(r,{code:me.invalid_type,expected:Ce.map,received:r.parsedType}),je;const i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new ko(r,a,r.path,[c,"key"])),value:o._parse(new ko(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 je;(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 je;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),a.set(c.value,d.value)}return{status:t.value,value:a}}}}Gv.create=(n,e,t)=>new Gv({valueType:e,keyType:n,typeName:We.ZodMap,...ot(t)});class Nl extends ht{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ce.set)return we(r,{code:me.invalid_type,expected:Ce.set,received:r.parsedType}),je;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(we(r,{code:me.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&&(we(r,{code:me.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 je;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 ko(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,t){return new Nl({...this._def,minSize:{value:e,message:Me.toString(t)}})}max(e,t){return new Nl({...this._def,maxSize:{value:e,message:Me.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Nl.create=(n,e)=>new Nl({valueType:n,minSize:null,maxSize:null,typeName:We.ZodSet,...ot(e)});class Xv extends ht{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})}}Xv.create=(n,e)=>new Xv({getter:n,typeName:We.ZodLazy,...ot(e)});class Qv extends ht{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return we(t,{received:t.data,code:me.invalid_literal,expected:this._def.value}),je}return{status:"valid",value:e.data}}get value(){return this._def.value}}Qv.create=(n,e)=>new Qv({value:n,typeName:We.ZodLiteral,...ot(e)});function rx(n,e){return new xa({values:n,typeName:We.ZodEnum,...ot(e)})}class xa extends ht{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return we(t,{expected:pt.joinValues(r),received:t.parsedType,code:me.invalid_type}),je}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 we(t,{received:t.data,code:me.invalid_enum_value,options:r}),je}return Mr(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 xa.create(e,{...this._def,...t})}exclude(e,t=this._def){return xa.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}xa.create=rx;class $v extends ht{_parse(e){const t=pt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Ce.string&&r.parsedType!==Ce.number){const i=pt.objectValues(t);return we(r,{expected:pt.joinValues(i),received:r.parsedType,code:me.invalid_type}),je}if(this._cache||(this._cache=new Set(pt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=pt.objectValues(t);return we(r,{received:r.data,code:me.invalid_enum_value,options:i}),je}return Mr(e.data)}get enum(){return this._def.values}}$v.create=(n,e)=>new $v({values:n,typeName:We.ZodNativeEnum,...ot(e)});class Fd extends ht{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ce.promise&&t.common.async===!1)return we(t,{code:me.invalid_type,expected:Ce.promise,received:t.parsedType}),je;const r=t.parsedType===Ce.promise?t.data:Promise.resolve(t.data);return Mr(r.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Fd.create=(n,e)=>new Fd({type:n,typeName:We.ZodPromise,...ot(e)});class ka extends ht{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===We.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=>{we(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 je;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?je:l.status==="dirty"||t.value==="dirty"?nl(l.value):l});{if(t.value==="aborted")return je;const a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?je:a.status==="dirty"||t.value==="dirty"?nl(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"?je:(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"?je:(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 je;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})):je);pt.assertNever(i)}}ka.create=(n,e,t)=>new ka({schema:n,typeName:We.ZodEffects,effect:e,...ot(t)});ka.createWithPreprocess=(n,e,t)=>new ka({schema:e,effect:{type:"preprocess",transform:n},typeName:We.ZodEffects,...ot(t)});class go extends ht{_parse(e){return this._getType(e)===Ce.undefined?Mr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}go.create=(n,e)=>new go({innerType:n,typeName:We.ZodOptional,...ot(e)});class _a extends ht{_parse(e){return this._getType(e)===Ce.null?Mr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_a.create=(n,e)=>new _a({innerType:n,typeName:We.ZodNullable,...ot(e)});class mp extends ht{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===Ce.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}mp.create=(n,e)=>new mp({innerType:n,typeName:We.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ot(e)});class gp extends ht{_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 Ld(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ki(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ki(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}gp.create=(n,e)=>new gp({innerType:n,typeName:We.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ot(e)});class ey extends ht{_parse(e){if(this._getType(e)!==Ce.nan){const r=this._getOrReturnCtx(e);return we(r,{code:me.invalid_type,expected:Ce.nan,received:r.parsedType}),je}return{status:"valid",value:e.data}}}ey.create=n=>new ey({typeName:We.ZodNaN,...ot(n)});class tA extends ht{_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 Jm extends ht{_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"?je:o.status==="dirty"?(t.dirty(),nl(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"?je: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 Jm({in:e,out:t,typeName:We.ZodPipeline})}}class vp extends ht{_parse(e){const t=this._def.innerType._parse(e),r=i=>(wa(i)&&(i.value=Object.freeze(i.value)),i);return Ld(t)?t.then(i=>r(i)):r(t)}unwrap(){return this._def.innerType}}vp.create=(n,e)=>new vp({innerType:n,typeName:We.ZodReadonly,...ot(e)});var We;(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"})(We||(We={}));_o.create;ai.create;zd.create;Bd.create;bs.create;const Ur=xa.create;Fd.create;go.create;_a.create;Ur(["highlight","note","comment"]);Ur(["pending","accepted","dismissed"]);Ur(["yellow","green","blue","pink"]);Ur(["info","warning","error","success"]);const nA=Ur(["solo","tandem"]);Ur(["user","claude","import"]);Ur(["user","claude"]);Ur(["accept","dismiss"]);Ur(["markdown","json"]);Ur(["md","txt","html","docx"]);Ur(["RANGE_GONE","RANGE_MOVED","FILE_LOCKED","FILE_NOT_FOUND","NO_DOCUMENT","INVALID_RANGE","FORMAT_ERROR","PERMISSION_DENIED"]);function rA(n){return n.author!=="user"}function Hd(n){return n.status==="pending"&&rA(n)}const ty=3478,kc=3479,ix="https://github.com/bloknayrb/tandem",iA=`${ix}/issues/new`,oA=new Set([".md",".txt",".html",".htm",".docx"]),sA=3e3,aA=3e3,lA=3e4,ox={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)"},Il={yellow:"var(--tandem-highlight-yellow)",green:"var(--tandem-highlight-green)",blue:"var(--tandem-highlight-blue)",pink:"var(--tandem-highlight-pink)"};function sx(n){return n&&n in ox?n:"yellow"}const ny="tandem",Fc="tandem:mode",ax="tandem:settings",cA="tandem-panel-width",dA="tandem-left-panel-width",lx={left:dA,right:cA},cx=1e3,Vd=500,Ud=3e3,uA="__tandem_ctrl__",So="annotations",dx="awareness",yp="userAwareness",fA="mode",hA="selectionDwellMs",ry="chat",md="documentMeta",pA="annotationReplies",iy="savedAtVersion",oy="authorship",sy="selection",ay="activity",bp="claude",Za="openDocuments",Ga="activeDocumentId",Xf="generationId",Qf="readOnly",$f="storeReadOnly",ux="tandem:showAuthorship",Ym="tandem:recentFiles",mA=20,Zm="tandem:userName",fx="You",wp="tandem:user-name-changed",Gm=40,ly={error:8e3,warning:6e3,info:4e3},gA=5,hx="tandem:tutorialCompleted",vA="tutorial-",px="tandem:coworkOnboardingSkipped",yA=3e4,q6=2e3,cy="tandem:zoomLevel",dy=.5,uy=2,Xa=1,Tr=`http://localhost:${kc}/api`;function bA(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 wA(n){return n.toLowerCase().endsWith(".docx")}async function mx(n){if(wA(n.name)){const e=await n.arrayBuffer();return bA(e)}return n.text()}const gx=["editor","navigation","view","document"];let gd=F(dt(new Map));function xA(n,e={}){if(f(gd).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(gd,new Map(f(gd)).set(n.id,n),!0),!0}function jd(){return f(gd)}let xp=null;function kA(n){xp=n}function eh(n,e){if(!xp){console.warn(`[actions] "${n}" invoked before App mounted — deps not wired yet`);return}e(xp)}let kp=F(!1);const _A={get saving(){return f(kp)}};let th=!1,nh=!1;async function Xm(){if(!nh){nh=!0;try{const n=await fetch(`${Tr}/scratchpad`,{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{nh=!1}}}async function vx(n){if(!(!n||th)){th=!0,b(kp,!0);try{const e=await fetch(`http://localhost:${kc}/api/save`,{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{th=!1,b(kp,!1)}}}const SA=[{id:"save",label:"Save document",group:"document",shortcut:"Ctrl+S",run(){eh("save",n=>void vx(n.getActiveTabId()))}},{id:"settings",label:"Open settings",group:"view",shortcut:"Ctrl+,",run(){eh("settings",n=>n.openSettings())}},{id:"toggle-mode",label:"Toggle Solo / Tandem mode",group:"document",run(){eh("toggle-mode",n=>n.toggleSoloMode())}},{id:"new-scratchpad",label:"New Scratchpad",group:"document",shortcut:"Ctrl+N",run(){Xm()}}];for(const n of SA)xA(n);function pn(n){this.content=n}pn.prototype={constructor:pn,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 pn(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 pn(t)},addToStart:function(n,e){return new pn([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new pn(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 pn(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=pn.from(n),n.size?new pn(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=pn.from(n),n.size?new pn(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=pn.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}};pn.from=function(n){if(n instanceof pn)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new pn(e)};function yx(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=yx(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function bx(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=bx(s.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}class ie{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 ie(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 ie(r,i)}cutByIndex(e,t){return e==t?ie.empty:e==0&&t==this.content.length?this:new ie(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 ie(i,o)}addToStart(e){return new ie([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ie(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 yx(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return bx(this,e,t,r)}findIndex(e){if(e==0)return Hc(0,e);if(e==this.size)return Hc(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?Hc(t+1,o):Hc(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 ie.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new ie(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ie.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 ie(t||e,r)}static from(e){if(!e)return ie.empty;if(e instanceof ie)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ie([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ie.empty=new ie([],0);const rh={index:0,offset:0};function Hc(n,e){return rh.index=n,rh.offset=e,rh}function Wd(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(!Wd(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Wd(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ct=class _p{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&&Wd(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 _p.none;if(e instanceof _p)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Ct.none=[];class Kd extends Error{}class ge{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=xx(this.content,e+this.openStart,t);return r&&new ge(r,this.openStart,this.openEnd)}removeBetween(e,t){return new ge(wx(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 ge.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 ge(ie.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 ge(e,r,i)}}ge.empty=new ge(ie.empty,0,0);function wx(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(wx(o.content,e-i-1,t-i-1)))}function xx(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=xx(s.content,e-o-1,t,s);return a&&n.replaceChild(i,s.copy(a))}function CA(n,e,t){if(t.openStart>n.depth)throw new Kd("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Kd("Inconsistent open depths");return kx(n,e,t,0)}function kx(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=kx(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 ls(s,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=TA(t,n);return ls(o,Sx(n,s,a,e,r))}else return ls(o,qd(n,e,r))}function _x(n,e){if(!e.type.compatibleContent(n.type))throw new Kd("Cannot join "+e.type.name+" onto "+n.type.name)}function Sp(n,e,t){let r=n.node(t);return _x(r,e.node(t)),r}function as(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 cl(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&&(as(n.nodeAfter,r),o++));for(let a=o;a<s;a++)as(i.child(a),r);e&&e.depth==t&&e.textOffset&&as(e.nodeBefore,r)}function ls(n,e){return n.type.checkContent(e),n.copy(e)}function Sx(n,e,t,r,i){let o=n.depth>i&&Sp(n,e,i+1),s=r.depth>i&&Sp(t,r,i+1),a=[];return cl(null,n,i,a),o&&s&&e.index(i)==t.index(i)?(_x(o,s),as(ls(o,Sx(n,e,t,r,i+1)),a)):(o&&as(ls(o,qd(n,e,i+1)),a),cl(e,t,i,a),s&&as(ls(s,qd(t,r,i+1)),a)),cl(r,null,i,a),new ie(a)}function qd(n,e,t){let r=[];if(cl(null,n,t,r),n.depth>t){let i=Sp(n,e,t+1);as(ls(i,qd(n,e,t+1)),r)}return cl(e,null,t,r),new ie(r)}function TA(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(ie.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Ll{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 Ct.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 Jd(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 Ll(t,r,o)}static resolveCached(e,t){let r=fy.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 fy.set(e,r=new AA);let i=r.elts[r.i]=Ll.resolve(e,t);return r.i=(r.i+1)%EA,i}}class AA{constructor(){this.elts=[],this.i=0}}const EA=12,fy=new WeakMap;class Jd{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 MA=Object.create(null);let vo=class Cp{constructor(e,t,r,i=Ct.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||ie.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&&Wd(this.attrs,t||e.defaultAttrs||MA)&&Ct.sameSet(this.marks,r||Ct.none)}copy(e=null){return e==this.content?this:new Cp(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Cp(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 ge.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 ge(c,i.depth-s,o.depth-s)}replace(e,t,r){return CA(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 Ll.resolveCached(this,e)}resolveNoCache(e){return Ll.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()+")"),Cx(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=ie.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=Ct.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(!Ct.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=ie.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};vo.prototype.text=void 0;class Yd extends vo{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):Cx(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 Yd(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Yd(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 Cx(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class ws{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new OA(e,t);if(r.next==null)return ws.empty;let i=Tx(r);r.next&&r.err("Unexpected trailing text");let o=zA(PA(i));return BA(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 ie.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
4
|
`)}}ws.empty=new ws(!0);class OA{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 Tx(n){let e=[];do e.push(DA(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function DA(n){let e=[];do e.push(RA(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function RA(n){let e=LA(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=NA(n,e);else break;return e}function hy(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function NA(n,e){let t=hy(n),r=t;return n.eat(",")&&(n.next!="}"?r=hy(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function IA(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 LA(n){if(n.eat("(")){let e=Tx(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=IA(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 PA(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 Ax(n,e){return e-n}function py(n,e){let t=[];return r(e),t.sort(Ax);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 zA(n){let e=Object.create(null);return t(py(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]);py(n,l).forEach(d=>{c||i.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new ws(r.indexOf(n.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(Ax);o.next.push({type:i[s][0],next:e[a.join(",")]||t(a)})}return o}}function BA(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 Ex(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 Mx(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 Ox(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 Dx(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new HA(n,r,e[r]);return t}let my=class Rx{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=Dx(e,r.attrs),this.defaultAttrs=Ex(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==ws.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:Mx(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new vo(this,this.computeAttrs(e),ie.from(t),Ct.setFrom(r))}createChecked(e=null,t,r){return t=ie.from(t),this.checkContent(t),new vo(this,this.computeAttrs(e),t,Ct.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=ie.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(ie.empty,!0);return o?new vo(this,e,t.append(o),Ct.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){Ox(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:Ct.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,s)=>r[o]=new Rx(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 FA(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 HA{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?FA(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class af{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Dx(e,i.attrs),this.excluded=null;let o=Ex(this.attrs);this.instance=o?new Ct(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Ct(this,Mx(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new af(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){Ox(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let Nx=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=pn.from(e.nodes),t.marks=pn.from(e.marks||{}),this.nodes=my.compile(this.spec.nodes,this),this.marks=af.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]=ws.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?gy(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==""?[]:gy(this,s.split(" "))}this.nodeFromJSON=i=>vo.fromJSON(this,i),this.markFromJSON=i=>Ct.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 my){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 Yd(r,r.defaultAttrs,e,Ct.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 gy(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 VA(n){return n.tag!=null}function UA(n){return n.style!=null}let dl=class Tp{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(VA(i))this.tags.push(i);else if(UA(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 yy(this,t,!1);return r.addAll(e,Ct.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new yy(this,t,!0);return r.addAll(e,Ct.none,t.from,t.to),ge.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(KA(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=by(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=by(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Tp(e,Tp.schemaRules(e)))}};const Ix={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},jA={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Lx={ol:!0,ul:!0},Pl=1,Ap=2,ul=4;function vy(n,e,t){return e!=null?(e?Pl:0)|(e==="full"?Ap:0):n&&n.whitespace=="pre"?Pl|Ap:t&~ul}class Vc{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=Ct.none,this.match=o||(s&ul?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(ie.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&Pl)){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=ie.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(ie.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&&!Ix.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class yy{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=vy(null,t.preserveWhitespace,0)|(r?ul:0);i?o=new Vc(i.type,i.attrs,Ct.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new Vc(null,null,Ct.none,!0,null,s):o=new Vc(e.schema.topNodeType,null,Ct.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&Ap?"full":this.localPreserveWS||(i.options&Pl)>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
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;Lx.hasOwnProperty(s)&&this.parser.normalizeLists&&WA(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:jA.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(Ix.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
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=Ct.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):wy(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=vy(e,o,s.options);s.options&ul&&s.content.length==0&&(a|=ul);let l=Ct.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):wy(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Vc(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|=Pl)}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 WA(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Lx.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function KA(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function by(n){let e={};for(let t in n)e[t]=n[t];return e}function wy(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 Ls{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=ih(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}=vd(ih(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&&vd(ih(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return vd(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ls(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=xy(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return xy(e.marks)}}function xy(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ih(n){return n.document||window.document}const ky=new WeakMap;function qA(n){let e=ky.get(n);return e===void 0&&ky.set(n,e=JA(n)),e}function JA(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 vd(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=qA(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}=vd(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 Px=65535,zx=Math.pow(2,16);function YA(n,e){return n+e*zx}function _y(n){return n&Px}function ZA(n){return(n-(n&Px))/zx}const Bx=1,Fx=2,yd=4,Hx=8;class Ep{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Hx)>0}get deletedBefore(){return(this.delInfo&(Bx|yd))>0}get deletedAfter(){return(this.delInfo&(Fx|yd))>0}get deletedAcross(){return(this.delInfo&yd)>0}}class nr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&nr.empty)return nr.empty}recover(e){let t=0,r=_y(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+ZA(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:YA(a/3,e-l),v=e==l?Fx:e==u?Bx:yd;return(t<0?e!=l:e!=u)&&(v|=Hx),new Ep(p,v,m)}i+=d-c}return r?e+i:new Ep(e+i,0,null)}touches(e,t){let r=0,i=_y(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 nr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?nr.empty:new nr(e<0?[0,-e,0]:[0,0,e])}}nr.empty=new nr([]);class zl{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 zl(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 zl;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 Ep(e,i,null)}}const oh=Object.create(null);class Rn{getMap(){return nr.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=oh[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 oh)throw new RangeError("Duplicate use of step JSON ID "+e);return oh[e]=t,t.prototype.jsonID=e,t}}class Zt{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Zt(e,null)}static fail(e){return new Zt(null,e)}static fromReplace(e,t,r,i){try{return Zt.ok(e.replace(t,r,i))}catch(o){if(o instanceof Kd)return Zt.fail(o.message);throw o}}}function Qm(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let o=n.child(i);o.content.size&&(o=o.copy(Qm(o.content,e,o))),o.isInline&&(o=e(o,t,i)),r.push(o)}return ie.fromArray(r)}class co extends Rn{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 ge(Qm(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 Zt.fromReplace(e,this.from,this.to,o)}invert(){return new ni(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 co(t.pos,r.pos,this.mark)}merge(e){return e instanceof co&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new co(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 co(t.from,t.to,e.markFromJSON(t.mark))}}Rn.jsonID("addMark",co);class ni extends Rn{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 ge(Qm(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Zt.fromReplace(e,this.from,this.to,r)}invert(){return new co(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 ni(t.pos,r.pos,this.mark)}merge(e){return e instanceof ni&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ni(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 ni(t.from,t.to,e.markFromJSON(t.mark))}}Rn.jsonID("removeMark",ni);class uo extends Rn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Zt.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Zt.fromReplace(e,this.pos,this.pos+1,new ge(ie.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 uo(this.pos,t.marks[i]);return new uo(this.pos,this.mark)}}return new xs(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new uo(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 uo(t.pos,e.markFromJSON(t.mark))}}Rn.jsonID("addNodeMark",uo);class xs extends Rn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Zt.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Zt.fromReplace(e,this.pos,this.pos+1,new ge(ie.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new uo(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xs(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 xs(t.pos,e.markFromJSON(t.mark))}}Rn.jsonID("removeNodeMark",xs);class ln extends Rn{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Mp(e,this.from,this.to)?Zt.fail("Structure replace would overwrite content"):Zt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new nr([this.from,this.to-this.from,this.slice.size])}invert(e){return new ln(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 ln(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ln)||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?ge.empty:new ge(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ln(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?ge.empty:new ge(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ln(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 ln(t.from,t.to,ge.fromJSON(e,t.slice),!!t.structure)}}Rn.jsonID("replace",ln);class cn extends Rn{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&&(Mp(e,this.from,this.gapFrom)||Mp(e,this.gapTo,this.to)))return Zt.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Zt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Zt.fromReplace(e,this.from,this.to,r):Zt.fail("Content does not fit in gap")}getMap(){return new nr([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 cn(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 cn(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 cn(t.from,t.to,t.gapFrom,t.gapTo,ge.fromJSON(e,t.slice),t.insert,!!t.structure)}}Rn.jsonID("replaceAround",cn);function Mp(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 GA(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 ni(h,p,u[v])));a&&a.to==h?a.to=p:o.push(a=new co(h,p,r))}}),i.forEach(l=>n.step(l)),o.forEach(l=>n.step(l))}function XA(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 af){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 ni(s.from,s.to,s.style)))}function $m(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 ln(a,d,ge.empty));else{r=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new ni(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 ge(ie.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new ln(a+h.index,a+h.index+h[0].length,m))}}a=d}if(!r.validEnd){let l=r.fillBefore(ie.empty,!0);n.replace(a,a,new ge(l,0,0))}for(let l=s.length-1;l>=0;l--)n.step(s[l])}function QA(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ba(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||!QA(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function $A(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=ie.empty,u=0;for(let m=o,v=!1;m>t;m--)v||r.index(m)>0?(v=!0,d=ie.from(r.node(m).copy(d)),u++):l--;let h=ie.empty,p=0;for(let m=o,v=!1;m>t;m--)v||i.after(m+1)<i.end(m)?(v=!0,h=ie.from(i.node(m).copy(h)),p++):c++;n.step(new cn(l,c,s,a,new ge(d.append(h),u,p),d.size-u,!0))}function eg(n,e,t=null,r=n){let i=eE(n,e),o=i&&tE(r,e);return o?i.map(Sy).concat({type:e,attrs:t}).concat(o.map(Sy)):null}function Sy(n){return{type:n,attrs:null}}function eE(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 tE(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 nE(n,e,t){let r=ie.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=ie.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new cn(i,o,i,o,new ge(r,0,0),t.length,!0))}function rE(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)&&iE(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&&Ux(n,s,a,o),$m(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 cn(u,h,u+1,h-1,new ge(ie.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&Vx(n,s,a,o),!1}})}function Vx(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 Ux(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(`
|
|
@@ -32,7 +32,7 @@ var IS=Object.defineProperty;var kv=n=>{throw TypeError(n)};var LS=(n,e,t)=>e in
|
|
|
32
32
|
border-top: 1px solid var(--tandem-border);
|
|
33
33
|
display: flex; gap: var(--tandem-space-3);
|
|
34
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 ME(n,e){qe(e,!0);let t=ft(e,"editor",3,null),r=ft(e,"annotations",19,()=>[]),i=F(""),o=F(0),s=F(null);const a=["#","@","?",">"],l=H(()=>a.find(D=>f(i).startsWith(D))??null),c=H(()=>(f(l)?f(i).slice(1):f(i)).trim().toLowerCase()),d=H(()=>{var ee;if(f(l)!==null&&f(l)!==">")return[];const D=jd(),O=f(c),U=[];for(const R of D.values())(!O||R.label.toLowerCase().includes(O)||R.group.toLowerCase().includes(O)||(((ee=R.shortcut)==null?void 0:ee.toLowerCase().includes(O))??!1))&&U.push({kind:"action",id:R.id,action:R});return U}),u=H(()=>{if(f(l)!=="#")return[];const D=t();if(!D||D.isDestroyed)return[];const O=f(c);return Dp(D).filter(U=>!O||U.text.toLowerCase().includes(O)).map((U,ee)=>({kind:"heading",id:`heading-${ee}`,...U}))}),h=H(()=>{if(f(l)!=="@")return[];const D=f(c);return r().filter(O=>{var U;return D?O.content.toLowerCase().includes(D)||((U=O.textSnapshot)==null?void 0:U.toLowerCase().includes(D)):!0}).slice(0,50).map(O=>({kind:"annotation",id:`annotation-${O.id}`,label:O.content?O.content.slice(0,60):"(no content)",snippet:O.textSnapshot??"",annotationType:O.type}))}),p=H(()=>{if(f(l)!=="?")return[];const D=f(c),O=jd(),U=[];for(const ee of O.values())ee.shortcut&&(!D||ee.label.toLowerCase().includes(D)||ee.shortcut.toLowerCase().includes(D))&&U.push({kind:"shortcut",id:`shortcut-registry-${ee.id}`,keys:ee.shortcut,description:ee.label,group:ee.group});for(let ee=0;ee<Op.length;ee++){const R=Op[ee];(!D||R.description.toLowerCase().includes(D)||R.keys.toLowerCase().includes(D))&&U.push({kind:"shortcut",id:`shortcut-static-${ee}`,keys:R.keys,description:R.description,group:"other"})}return U}),m=H(()=>[...f(d),...f(u),...f(h),...f(p)]);de(()=>{f(m),b(o,0)}),de(()=>{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=H(()=>f(l)?v[f(l)]:"Type a command, # headings, @ annotations, ? shortcuts…");function y(){e.onClose()}function k(D){var O;if(D.kind==="action")y(),D.action.run();else if(D.kind==="heading"){y();const U=t();if(!U||U.isDestroyed)return;const ee=D.pos;try{const R=U.state.doc.resolve(ee+1),K=Oe.near(R);U.view.dispatch(U.state.tr.setSelection(K).scrollIntoView()),U.view.focus()}catch{}}else D.kind==="annotation"&&(y(),(O=e.onFocusAnnotation)==null||O.call(e,D.id.replace("annotation-","")))}function S(D){const O=f(m).length;if(D.key==="ArrowDown")D.preventDefault(),b(o,(f(o)+1)%Math.max(1,O));else if(D.key==="ArrowUp")D.preventDefault(),b(o,(f(o)-1+Math.max(1,O))%Math.max(1,O));else if(D.key==="Enter"){D.preventDefault();const U=f(m)[f(o)];U&&k(U)}else D.key==="Escape"&&(D.preventDefault(),y())}function C(D){D.target===D.currentTarget&&y()}var A=Rt(),W=ze(A);{var z=D=>{var O=EE(),U=x(O),ee=x(U),R=x(ee);kt(R,V=>b(s,V),()=>f(s));var K=_(R,2);{var ne=V=>{var re=bE(),w=x(re);{var M=B=>{var G=an("Searching document headings");T(B,G)};J(w,B=>{f(l)==="#"&&B(M)})}var I=_(w,2);{var ae=B=>{var G=an("Searching annotations");T(B,G)};J(I,B=>{f(l)==="@"&&B(ae)})}var ve=_(I,2);{var ue=B=>{var G=an("Showing keyboard shortcuts");T(B,G)};J(ve,B=>{f(l)==="?"&&B(ue)})}var le=_(ve,2);{var he=B=>{var G=an("Filtering commands");T(B,G)};J(le,B=>{f(l)===">"&&B(he)})}T(V,re)};J(K,V=>{f(l)&&V(ne)})}var X=_(ee,2),N=x(X);{var q=V=>{var re=wE(),w=x(re);Y(()=>te(w,f(l)==="#"?"No headings found":f(l)==="@"?"No annotations found":f(l)==="?"?"No shortcuts found":"No commands match")),T(V,re)},L=V=>{var re=Rt(),w=ze(re);mt(w,19,()=>f(m),M=>M.id,(M,I,ae)=>{const ve=H(()=>f(ae)===f(o));var ue=AE(),le=x(ue);{var he=Te=>{var De=kE(),Ee=ze(De),
|
|
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 ME(n,e){qe(e,!0);let t=ft(e,"editor",3,null),r=ft(e,"annotations",19,()=>[]),i=F(""),o=F(0),s=F(null);const a=["#","@","?",">"],l=H(()=>a.find(D=>f(i).startsWith(D))??null),c=H(()=>(f(l)?f(i).slice(1):f(i)).trim().toLowerCase()),d=H(()=>{var ee;if(f(l)!==null&&f(l)!==">")return[];const D=jd(),O=f(c),U=[];for(const R of D.values())(!O||R.label.toLowerCase().includes(O)||R.group.toLowerCase().includes(O)||(((ee=R.shortcut)==null?void 0:ee.toLowerCase().includes(O))??!1))&&U.push({kind:"action",id:R.id,action:R});return U}),u=H(()=>{if(f(l)!=="#")return[];const D=t();if(!D||D.isDestroyed)return[];const O=f(c);return Dp(D).filter(U=>!O||U.text.toLowerCase().includes(O)).map((U,ee)=>({kind:"heading",id:`heading-${ee}`,...U}))}),h=H(()=>{if(f(l)!=="@")return[];const D=f(c);return r().filter(O=>{var U;return D?O.content.toLowerCase().includes(D)||((U=O.textSnapshot)==null?void 0:U.toLowerCase().includes(D)):!0}).slice(0,50).map(O=>({kind:"annotation",id:`annotation-${O.id}`,label:O.content?O.content.slice(0,60):"(no content)",snippet:O.textSnapshot??"",annotationType:O.type}))}),p=H(()=>{if(f(l)!=="?")return[];const D=f(c),O=jd(),U=[];for(const ee of O.values())ee.shortcut&&(!D||ee.label.toLowerCase().includes(D)||ee.shortcut.toLowerCase().includes(D))&&U.push({kind:"shortcut",id:`shortcut-registry-${ee.id}`,keys:ee.shortcut,description:ee.label,group:ee.group});for(let ee=0;ee<Op.length;ee++){const R=Op[ee];(!D||R.description.toLowerCase().includes(D)||R.keys.toLowerCase().includes(D))&&U.push({kind:"shortcut",id:`shortcut-static-${ee}`,keys:R.keys,description:R.description,group:"other"})}return U}),m=H(()=>[...f(d),...f(u),...f(h),...f(p)]);de(()=>{f(m),b(o,0)}),de(()=>{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=H(()=>f(l)?v[f(l)]:"Type a command, # headings, @ annotations, ? shortcuts…");function y(){e.onClose()}function k(D){var O;if(D.kind==="action")y(),D.action.run();else if(D.kind==="heading"){y();const U=t();if(!U||U.isDestroyed)return;const ee=D.pos;try{const R=U.state.doc.resolve(ee+1),K=Oe.near(R);U.view.dispatch(U.state.tr.setSelection(K).scrollIntoView()),U.view.focus()}catch{}}else D.kind==="annotation"&&(y(),(O=e.onFocusAnnotation)==null||O.call(e,D.id.replace("annotation-","")))}function S(D){const O=f(m).length;if(D.key==="ArrowDown")D.preventDefault(),b(o,(f(o)+1)%Math.max(1,O));else if(D.key==="ArrowUp")D.preventDefault(),b(o,(f(o)-1+Math.max(1,O))%Math.max(1,O));else if(D.key==="Enter"){D.preventDefault();const U=f(m)[f(o)];U&&k(U)}else D.key==="Escape"&&(D.preventDefault(),y())}function C(D){D.target===D.currentTarget&&y()}var A=Rt(),W=ze(A);{var z=D=>{var O=EE(),U=x(O),ee=x(U),R=x(ee);kt(R,V=>b(s,V),()=>f(s));var K=_(R,2);{var ne=V=>{var re=bE(),w=x(re);{var M=B=>{var G=an("Searching document headings");T(B,G)};J(w,B=>{f(l)==="#"&&B(M)})}var I=_(w,2);{var ae=B=>{var G=an("Searching annotations");T(B,G)};J(I,B=>{f(l)==="@"&&B(ae)})}var ve=_(I,2);{var ue=B=>{var G=an("Showing keyboard shortcuts");T(B,G)};J(ve,B=>{f(l)==="?"&&B(ue)})}var le=_(ve,2);{var he=B=>{var G=an("Filtering commands");T(B,G)};J(le,B=>{f(l)===">"&&B(he)})}T(V,re)};J(K,V=>{f(l)&&V(ne)})}var X=_(ee,2),N=x(X);{var q=V=>{var re=wE(),w=x(re);Y(()=>te(w,f(l)==="#"?"No headings found":f(l)==="@"?"No annotations found":f(l)==="?"?"No shortcuts found":"No commands match")),T(V,re)},L=V=>{var re=Rt(),w=ze(re);mt(w,19,()=>f(m),M=>M.id,(M,I,ae)=>{const ve=H(()=>f(ae)===f(o));var ue=AE(),le=x(ue);{var he=Te=>{var De=kE(),Ee=ze(De),oe=x(Ee),$=_(Ee,2);{var Q=pe=>{var fe=xE(),Le=x(fe);Y(()=>te(Le,f(I).action.shortcut)),T(pe,fe)};J($,pe=>{f(I).action.shortcut&&pe(Q)})}Y(()=>te(oe,f(I).action.label)),T(Te,De)},B=Te=>{var De=_E(),Ee=x(De),oe=x(Ee),$=_(Ee,2),Q=x($);Y(()=>{te(oe,`H${f(I).level??""}`),se($,`font-size: var(--tandem-text-sm); padding-left: calc(${f(I).level-1} * var(--tandem-space-2));`),te(Q,f(I).text)}),T(Te,De)},G=Te=>{var De=CE(),Ee=ze(De),oe=x(Ee),$=x(oe),Q=_(oe,2);{var pe=Ie=>{var ye=SE(),ke=x(ye);Y(()=>te(ke,`"${f(I).snippet??""}"`)),T(Ie,ye)};J(Q,Ie=>{f(I).snippet&&Ie(pe)})}var fe=_(Ee,2),Le=x(fe);Y(Ie=>{te($,f(I).label),te(Le,Ie)},[()=>f(I).annotationType.charAt(0).toUpperCase()+f(I).annotationType.slice(1)]),T(Te,De)},be=Te=>{var De=TE(),Ee=ze(De),oe=x(Ee),$=_(Ee,2),Q=x($);Y(()=>{te(oe,f(I).description),te(Q,f(I).keys)}),T(Te,De)};J(le,Te=>{f(I).kind==="action"?Te(he):f(I).kind==="heading"?Te(B,1):f(I).kind==="annotation"?Te(G,2):f(I).kind==="shortcut"&&Te(be,3)})}Y(()=>{Z(ue,"id",`palette-item-${f(I).id}`),Z(ue,"data-testid",`palette-item-${f(I).id}`),Z(ue,"aria-selected",f(ve)),se(ue,`
|
|
36
36
|
display: flex; align-items: center; justify-content: space-between;
|
|
37
37
|
padding: 8px var(--tandem-space-4);
|
|
38
38
|
cursor: ${f(I).kind==="shortcut"?"default":"pointer"};
|
|
@@ -42,11 +42,11 @@ var IS=Object.defineProperty;var kv=n=>{throw TypeError(n)};var LS=(n,e,t)=>e in
|
|
|
42
42
|
restart Tandem to restore normal operation.</div>`),HE=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>'),VE=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>'),UE=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>'),jE=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
43
|
it, Tandem can't safely be reached from inside the Cowork VM. Port 3479 is currently
|
|
44
44
|
blocked by a deny rule to protect your machine.</div> <!> <!></div></div>`);function WE(n,e){qe(e,!0);const t='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',r=r1(()=>!0),i=H(()=>{var g;return((g=r.status)==null?void 0:g.uacDeclined)===!0});let o=F(void 0),s=F(!1),a=F(!1),l=F(null);de(()=>{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)}}),de(()=>{if(!f(i))return;const g=y=>{if(y.key!=="Tab"||!f(o))return;const k=f(o).querySelectorAll(t);if(k.length===0)return;const S=k[0],C=k[k.length-1],A=document.activeElement;if(!f(o).contains(A)){y.preventDefault(),S.focus();return}y.shiftKey&&A===S?(y.preventDefault(),C.focus()):!y.shiftKey&&A===C&&(y.preventDefault(),S.focus())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)}),de(()=>{var g;f(i)&&((g=f(o))==null||g.focus())});async function c(g,y){b(a,!0),b(l,null);try{const k=await rg();await g(k)}catch(k){const S=k instanceof Error?k.message:String(k),C=Qx(S);b(l,`${y}: ${C}`)}finally{b(a,!1)}}async function d(){await c(async g=>{await BE(g),await r.refetch()},"Retry failed")}async function u(){await c(async g=>{await n1(g,!1),await r.refetch()},"Failed to disable Cowork"),b(s,!1)}var h=Rt(),p=ze(h);{var m=g=>{var y=FE();T(g,y)},v=g=>{var y=jE(),k=x(y);Z(k,"tabindex",-1);var S=_(x(k),4);{var C=D=>{var O=HE(),U=x(O);Y(()=>te(U,f(l))),T(D,O)};J(S,D=>{f(l)&&D(C)})}var A=_(S,2);{var W=D=>{var O=VE(),U=_(x(O),4),ee=x(U),R=_(ee,2);Y(()=>{ee.disabled=f(a),R.disabled=f(a)}),P("click",ee,()=>void u()),P("click",R,()=>{b(s,!1)}),T(D,O)},z=D=>{var O=UE(),U=x(O),ee=_(U,2);Y(()=>{U.disabled=f(a),ee.disabled=f(a)}),P("click",U,()=>{b(s,!0)}),P("click",ee,()=>void d()),T(D,O)};J(A,D=>{f(s)?D(W):D(z,-1)})}kt(k,D=>b(o,D),()=>f(o)),T(g,y)};J(p,g=>{r.error&&!r.status?g(m):f(i)&&g(v,1)})}T(n,h),Je()}$e(["click"]);var KE=E("<span>Cannot reach the Tandem server. Is it running?</span>"),qE=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>'),JE=E("<span>No document open. Click + in the tab bar or drop a file here.</span> <!>",1),YE=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 ZE(n,e){qe(e,!0);let t=F(!1);de(()=>{if(e.connected){b(t,!1);return}const a=setTimeout(()=>{b(t,!0)},aA);return()=>clearTimeout(a)});var r=YE(),i=x(r);{var o=a=>{var l=KE();T(a,l)},s=a=>{var l=JE(),c=_(ze(l),2);{var d=u=>{var h=qE();T(u,h)};J(c,u=>{e.connected&&!e.claudeActive&&u(d)})}T(a,l)};J(i,a=>{f(t)?a(o):a(s,-1)})}T(n,r),Je()}var GE=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),XE=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>'),QE=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),$E=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 eM(n,e){qe(e,!0);const t=H(()=>{const l=jd(),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 gx.map(d=>({title:d.charAt(0).toUpperCase()+d.slice(1),rows:c.get(d)??[]})).filter(d=>d.rows.length>0)});let r=F(null),i=null;de(()=>{if(!e.open)return;const l=Yt(()=>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()}}),de(()=>{if(!e.open)return;const l=c=>{c.key==="Escape"&&e.onClose()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)});var o=Rt(),s=ze(o);{var a=l=>{var c=$E(),d=x(c),u=x(d),h=_(x(u),2),p=_(u,2);mt(p,17,()=>f(t),g=>g.title,(g,y)=>{var k=XE(),S=x(k),C=x(S),A=_(S,2);mt(A,21,()=>f(y).rows,W=>W.description,(W,z)=>{var D=GE(),O=ze(D),U=x(O),ee=x(U),R=_(O,2),K=x(R);Y(()=>{te(ee,f(z).keys),te(K,f(z).description)}),T(W,D)}),Y(()=>te(C,f(y).title)),T(g,k)});var m=_(p,2),v=_(x(m),2);mt(v,21,()=>Op,g=>g.description,(g,y)=>{var k=QE(),S=ze(k),C=x(S),A=x(C),W=_(S,2),z=x(W);Y(()=>{te(A,f(y).keys),te(z,f(y).description)}),T(g,k)}),kt(d,g=>b(r,g),()=>f(r)),P("click",c,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),P("click",d,g=>g.stopPropagation()),P("keydown",d,g=>{if(g.key==="Escape"){e.onClose();return}if(g.stopPropagation(),g.key==="Tab"&&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 k=y[0],S=y[y.length-1];g.shiftKey&&document.activeElement===k?(g.preventDefault(),S.focus()):!g.shiftKey&&document.activeElement===S&&(g.preventDefault(),k.focus())}}),P("click",h,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),T(l,c)};J(s,l=>{e.open&&l(a)})}T(n,o),Je()}$e(["click","keydown"]);var tM=E("Detected VM subnet: <code> </code>.",1),nM=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>'),rM=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>'),iM=E('<button data-testid="cowork-onboarding-learn-more-btn" type="button">Learn more</button>'),oM=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>'),sM=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>'),aM=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 lM(n,e){qe(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=F(!1),o=F(!1),s=F(null);async function a(S,C){b(o,!0),b(s,null);try{const A=await rg();return await S(A),!0}catch(A){const W=A instanceof Error?A.message:String(A),z=Qx(W);return b(s,`${C}: ${z}`),!1}finally{b(o,!1)}}async function l(){await a(async C=>{await n1(C,!0)},"Failed to enable Cowork")&&e.onAdvance()}function c(){IE(),e.onAdvance()}var d=aM(),u=_(x(d),2),h=_(x(u));{var p=S=>{var C=tM(),A=_(ze(C)),W=x(A);Y(()=>te(W,e.status.vethernetCidr)),T(S,C)};J(h,S=>{e.status.vethernetCidr!==null&&S(p)})}var m=_(u,2);{var v=S=>{var C=nM(),A=x(C);Y(()=>te(A,f(s))),T(S,C)};J(m,S=>{f(s)&&S(v)})}var g=_(m,2);{var y=S=>{var C=rM(),A=_(x(C),4),W=x(A);oe(W,t);var z=_(W,2);oe(z,r),Y(()=>{W.disabled=f(o),z.disabled=f(o)}),P("click",W,()=>void l()),P("click",z,()=>{b(i,!1)}),T(S,C)},k=S=>{var C=sM(),A=x(C);oe(A,t);var W=_(A,2);oe(W,r);var z=_(W,2);{var D=U=>{var ee=iM();oe(ee,r),Y(()=>ee.disabled=f(o)),P("click",ee,function(...R){var K;(K=e.onLearnMore)==null||K.apply(this,R)}),T(U,ee)},O=U=>{var ee=oM();Y(()=>Z(ee,"href",`${ix}#cowork`)),T(U,ee)};J(z,U=>{e.onLearnMore?U(D):U(O,-1)})}Y(()=>{A.disabled=f(o),W.disabled=f(o)}),P("click",A,()=>{b(i,!0)}),P("click",W,c),T(S,C)};J(g,S=>{f(i)?S(y):S(k,-1)})}T(n,d),Je()}$e(["click"]);var cM=E("<div></div>"),dM=E('<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);"></div>'),uM=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),fM=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>'),hM=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 pM(n,e){qe(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=Ar(),i=e1(),o=H(()=>r&&$x(e.coworkStatus,i)),s=H(()=>t.filter(m=>m.id!=="cowork"||f(o))),a=H(()=>f(s).length-1),l=H(()=>f(s)[e.currentStep]),c=H(()=>e.currentStep>=f(a)),d=H(()=>{var m;return((m=f(l))==null?void 0:m.id)==="cowork"});var u=Rt(),h=ze(u);{var p=m=>{var v=hM(),g=x(v);{var y=z=>{var D=dM();mt(D,20,()=>Array.from({length:f(a)},(O,U)=>U),O=>O,(O,U)=>{var ee=cM();Y(()=>oe(ee,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${U<=e.currentStep?"var(--tandem-accent)":"var(--tandem-border)"}; transition: background 0.2s;`)),T(O,ee)}),T(z,D)};J(g,z=>{f(c)||z(y)})}var k=_(g,2);{var S=z=>{lM(z,{get status(){return e.coworkStatus},get onAdvance(){return e.onNext}})},C=z=>{var D=uM(),O=ze(D),U=x(O),ee=_(O,2),R=x(ee);Y(()=>{te(U,f(l).title),oe(ee,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${f(c)?0:14}px;`),te(R,f(l).text)}),T(z,D)};J(k,z=>{f(d)&&e.coworkStatus!==null?z(S):z(C,-1)})}var A=_(k,2);{var W=z=>{var D=fM(),O=x(D),U=x(O),ee=_(O,2),R=x(ee),K=_(R,2),ne=x(K);Y(()=>{te(U,`Step ${e.currentStep+1} of ${f(a)??""}`),te(ne,e.currentStep===f(a)-1?"Done":"Next")}),P("click",R,function(...X){var N;(N=e.onDismiss)==null||N.apply(this,X)}),P("click",K,function(...X){var N;(N=e.onNext)==null||N.apply(this,X)}),T(z,D)};J(A,z=>{!f(c)&&!f(d)&&z(W)})}T(m,v)};J(h,m=>{f(l)&&m(p)})}T(n,u),Je()}$e(["click"]);const xr=()=>new Map,Rp=n=>{const e=xr();return n.forEach((t,r)=>{e.set(r,t)}),e},bi=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},mM=(n,e)=>{const t=[];for(const[r,i]of n)t.push(e(i,r));return t},gM=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},ks=()=>new Set,uh=n=>n[n.length-1],vM=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},To=Array.from,ig=(n,e)=>{for(let t=0;t<n.length;t++)if(!e(n[t],t,n))return!1;return!0},og=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},yM=(n,e)=>{const t=new Array(n);for(let r=0;r<n;r++)t[r]=e(r,t);return t},Ca=Array.isArray;class i1{constructor(){this._observers=xr()}on(e,t){return bi(this._observers,e,ks).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 To((this._observers.get(e)||xr()).values()).forEach(r=>r(...t))}destroy(){this._observers=xr()}}const Br=Math.floor,bd=Math.abs,Bi=(n,e)=>n<e?n:e,Fr=(n,e)=>n>e?n:e,o1=n=>n!==0?n<0:1/n<0,Ry=1,Ny=2,fh=4,hh=8,Fl=32,Fi=64,Bn=128,bM=1<<29,uf=31,Np=63,cs=127,wM=2147483647,Zd=Number.MAX_SAFE_INTEGER,Iy=Number.MIN_SAFE_INTEGER,xM=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&Br(n)===n),s1=String.fromCharCode,kM=n=>n.toLowerCase(),_M=/^\s*/g,SM=n=>n.replace(_M,""),CM=/([A-Z])/g,Ly=(n,e)=>SM(n.replace(CM,t=>`${e}${kM(t)}`)),TM=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},Hl=typeof TextEncoder<"u"?new TextEncoder:null,AM=n=>Hl.encode(n),EM=Hl?AM:TM;let fl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});fl&&fl.decode(new Uint8Array).length===1&&(fl=null);const MM=(n,e)=>yM(e,()=>n).join("");let _c=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};const Sc=()=>new _c,OM=n=>{const e=Sc();return n(e),Lr(e)},DM=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},Lr=n=>{const e=new Uint8Array(DM(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},RM=(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(Fr(t,e)*2),n.cpos=0)},sn=(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},Ip=sn,at=(n,e)=>{for(;e>cs;)sn(n,Bn|cs&e),e=Br(e/128);sn(n,cs&e)},sg=(n,e)=>{const t=o1(e);for(t&&(e=-e),sn(n,(e>Np?Bn:0)|(t?Fi:0)|Np&e),e=Br(e/64);e>0;)sn(n,(e>cs?Bn:0)|cs&e),e=Br(e/128)},Lp=new Uint8Array(3e4),NM=Lp.length/3,IM=(n,e)=>{if(e.length<NM){const t=Hl.encodeInto(e,Lp).written||0;at(n,t);for(let r=0;r<t;r++)sn(n,Lp[r])}else Xn(n,EM(e))},LM=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;at(n,r);for(let i=0;i<r;i++)sn(n,t.codePointAt(i))},ea=Hl&&Hl.encodeInto?IM:LM,ff=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=Bi(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(Fr(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},Xn=(n,e)=>{at(n,e.byteLength),ff(n,e)},ag=(n,e)=>{RM(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},PM=(n,e)=>ag(n,4).setFloat32(0,e,!1),zM=(n,e)=>ag(n,8).setFloat64(0,e,!1),BM=(n,e)=>ag(n,8).setBigInt64(0,e,!1),Py=new DataView(new ArrayBuffer(4)),FM=n=>(Py.setFloat32(0,n),Py.getFloat32(0)===n),Ta=(n,e)=>{switch(typeof e){case"string":sn(n,119),ea(n,e);break;case"number":xM(e)&&bd(e)<=wM?(sn(n,125),sg(n,e)):FM(e)?(sn(n,124),PM(n,e)):(sn(n,123),zM(n,e));break;case"bigint":sn(n,122),BM(n,e);break;case"object":if(e===null)sn(n,126);else if(Ca(e)){sn(n,117),at(n,e.length);for(let t=0;t<e.length;t++)Ta(n,e[t])}else if(e instanceof Uint8Array)sn(n,116),Xn(n,e);else{sn(n,118);const t=Object.keys(e);at(n,t.length);for(let r=0;r<t.length;r++){const i=t[r];ea(n,i),Ta(n,e[i])}}break;case"boolean":sn(n,e?120:121);break;default:sn(n,127)}};class zy extends _c{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&at(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const By=n=>{n.count>0&&(sg(n.encoder,n.count===1?n.s:-n.s),n.count>1&&at(n.encoder,n.count-2))};class wd{constructor(){this.encoder=new _c,this.s=0,this.count=0}write(e){this.s===e?this.count++:(By(this),this.count=1,this.s=e)}toUint8Array(){return By(this),Lr(this.encoder)}}const Fy=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);sg(n.encoder,e),n.count>1&&at(n.encoder,n.count-2)}};class ph{constructor(){this.encoder=new _c,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Fy(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Fy(this),Lr(this.encoder)}}class HM{constructor(){this.sarr=[],this.s="",this.lensE=new wd}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 _c;return this.sarr.push(this.s),this.s="",ea(e,this.sarr.join("")),ff(e,this.lensE.toUint8Array()),Lr(e)}}const fi=n=>new Error(n),kr=()=>{throw fi("Method unimplemented")},En=()=>{throw fi("Unexpected case")},a1=fi("Unexpected end of array"),l1=fi("Integer out of Range");let hf=class{constructor(e){this.arr=e,this.pos=0}};const Fa=n=>new hf(n),VM=n=>n.pos!==n.arr.length,UM=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},Qn=n=>UM(n,nt(n)),Aa=n=>n.arr[n.pos++],nt=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&cs)*t,t*=128,i<Bn)return e;if(e>Zd)throw l1}throw a1},lg=n=>{let e=n.arr[n.pos++],t=e&Np,r=64;const i=(e&Fi)>0?-1:1;if((e&Bn)===0)return i*t;const o=n.arr.length;for(;n.pos<o;){if(e=n.arr[n.pos++],t=t+(e&cs)*r,r*=128,e<Bn)return i*t;if(t>Zd)throw l1}throw a1},jM=n=>{let e=nt(n);if(e===0)return"";{let t=String.fromCodePoint(Aa(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(Aa(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))}},WM=n=>fl.decode(Qn(n)),ta=fl?WM:jM,cg=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},KM=n=>cg(n,4).getFloat32(0,!1),qM=n=>cg(n,8).getFloat64(0,!1),JM=n=>cg(n,8).getBigInt64(0,!1),YM=[n=>{},n=>null,lg,KM,qM,JM,n=>!1,n=>!0,ta,n=>{const e=nt(n),t={};for(let r=0;r<e;r++){const i=ta(n);t[i]=Vl(n)}return t},n=>{const e=nt(n),t=[];for(let r=0;r<e;r++)t.push(Vl(n));return t},Qn],Vl=n=>YM[127-Aa(n)](n);class Hy extends hf{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),VM(this)?this.count=nt(this)+1:this.count=-1),this.count--,this.s}}class xd extends hf{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=lg(this);const e=o1(this.s);this.count=1,e&&(this.s=-this.s,this.count=nt(this)+2)}return this.count--,this.s}}class mh extends hf{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=lg(this),t=e&1;this.diff=Br(e/2),this.count=1,t&&(this.count=nt(this)+2)}return this.s+=this.diff,this.count--,this.s}}class ZM{constructor(e){this.decoder=new xd(e),this.str=ta(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 GM=crypto.getRandomValues.bind(crypto),XM=Math.random,c1=()=>GM(new Uint32Array(1))[0],QM=n=>n[Br(XM()*n.length)],$M="10000000-1000-4000-8000"+-1e11,e2=()=>$M.replace(/[018]/g,n=>(n^c1()&15>>n/4).toString(16)),t2=Date.now,Vy=n=>new Promise(n);Promise.all.bind(Promise);const Uy=n=>n===void 0?null:n;class n2{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let d1=new n2,r2=!0;try{typeof localStorage<"u"&&localStorage&&(d1=localStorage,r2=!1)}catch{}const i2=d1,Ul=Symbol("Equality"),u1=(n,e)=>{var t;return n===e||!!((t=n==null?void 0:n[Ul])!=null&&t.call(n,e))||!1},o2=n=>typeof n=="object",s2=Object.assign,f1=Object.keys,a2=(n,e)=>{for(const t in n)e(n[t],t)},Gd=n=>f1(n).length,l2=n=>{for(const e in n)return!1;return!0},Ha=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},dg=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),c2=(n,e)=>n===e||Gd(n)===Gd(e)&&Ha(n,(t,r)=>(t!==void 0||dg(e,r))&&u1(e[r],t)),d2=Object.freeze,h1=n=>{for(const e in n){const t=n[e];(typeof t=="object"||typeof t=="function")&&h1(n[e])}return d2(n)},ug=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&ug(n,e,t+1)}},u2=n=>n,kd=(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[Ul]!=null)return n[Ul](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)||!kd(n.get(t),e.get(t)))return!1;break}case void 0:case Object:if(Gd(n)!==Gd(e))return!1;for(const t in n)if(!dg(n,t)||!kd(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(!kd(n[t],e[t]))return!1;break;default:return!1}return!0},f2=(n,e)=>e.includes(n);var p1={};const Ea=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",m1=typeof window<"u"&&typeof document<"u"&&!Ea;let qr;const h2=()=>{if(qr===void 0)if(Ea){qr=xr();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&qr.set(e,""),e=r):e!==null&&(qr.set(e,r),e=null)}e!==null&&qr.set(e,"")}else typeof location=="object"?(qr=xr(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");qr.set(`--${Ly(e,"-")}`,t),qr.set(`-${Ly(e,"-")}`,t)}})):qr=xr();return qr},Pp=n=>h2().has(n),Xd=n=>Uy(Ea?p1[n.toUpperCase().replaceAll("-","_")]:i2.getItem(n)),g1=n=>Pp("--"+n)||Xd(n)!==null,p2=g1("production"),m2=Ea&&f2(p1.FORCE_COLOR,["true","1","2"]),g2=m2||!Pp("--no-colors")&&!g1("no-color")&&(!Ea||process.stdout.isTTY)&&(!Ea||Pp("--color")||Xd("COLORTERM")!==null||(Xd("TERM")||"").includes("color")),v2=n=>new Uint8Array(n),y2=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=s1(n[t]);return btoa(e)},b2=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),w2=m1?y2:b2,x2=n=>{const e=v2(n.byteLength);return e.set(n),e},k2=n=>OM(e=>Ta(e,n));class _2{constructor(e,t){this.left=e,this.right=t}}const xi=(n,e)=>new _2(n,e),jy=n=>n.next()>=.5,gh=(n,e,t)=>Br(n.next()*(t+1-e)+e),v1=(n,e,t)=>Br(n.next()*(t+1-e)+e),fg=(n,e,t)=>v1(n,e,t),S2=n=>s1(fg(n,97,122)),C2=(n,e=0,t=20)=>{const r=fg(n,e,t);let i="";for(let o=0;o<r;o++)i+=S2(n);return i},vh=(n,e)=>e[fg(n,0,e.length-1)],T2=Symbol("0schema");class A2{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(MM(" ",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
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 eM(n,e){qe(e,!0);const t=H(()=>{const l=jd(),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 gx.map(d=>({title:d.charAt(0).toUpperCase()+d.slice(1),rows:c.get(d)??[]})).filter(d=>d.rows.length>0)});let r=F(null),i=null;de(()=>{if(!e.open)return;const l=Pt(()=>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()}}),de(()=>{if(!e.open)return;const l=c=>{c.key==="Escape"&&e.onClose()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)});var o=Rt(),s=ze(o);{var a=l=>{var c=$E(),d=x(c),u=x(d),h=_(x(u),2),p=_(u,2);mt(p,17,()=>f(t),g=>g.title,(g,y)=>{var k=XE(),S=x(k),C=x(S),A=_(S,2);mt(A,21,()=>f(y).rows,W=>W.description,(W,z)=>{var D=GE(),O=ze(D),U=x(O),ee=x(U),R=_(O,2),K=x(R);Y(()=>{te(ee,f(z).keys),te(K,f(z).description)}),T(W,D)}),Y(()=>te(C,f(y).title)),T(g,k)});var m=_(p,2),v=_(x(m),2);mt(v,21,()=>Op,g=>g.description,(g,y)=>{var k=QE(),S=ze(k),C=x(S),A=x(C),W=_(S,2),z=x(W);Y(()=>{te(A,f(y).keys),te(z,f(y).description)}),T(g,k)}),kt(d,g=>b(r,g),()=>f(r)),P("click",c,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),P("click",d,g=>g.stopPropagation()),P("keydown",d,g=>{if(g.key==="Escape"){e.onClose();return}if(g.stopPropagation(),g.key==="Tab"&&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 k=y[0],S=y[y.length-1];g.shiftKey&&document.activeElement===k?(g.preventDefault(),S.focus()):!g.shiftKey&&document.activeElement===S&&(g.preventDefault(),k.focus())}}),P("click",h,function(...g){var y;(y=e.onClose)==null||y.apply(this,g)}),T(l,c)};J(s,l=>{e.open&&l(a)})}T(n,o),Je()}$e(["click","keydown"]);var tM=E("Detected VM subnet: <code> </code>.",1),nM=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>'),rM=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>'),iM=E('<button data-testid="cowork-onboarding-learn-more-btn" type="button">Learn more</button>'),oM=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>'),sM=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>'),aM=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 lM(n,e){qe(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=F(!1),o=F(!1),s=F(null);async function a(S,C){b(o,!0),b(s,null);try{const A=await rg();return await S(A),!0}catch(A){const W=A instanceof Error?A.message:String(A),z=Qx(W);return b(s,`${C}: ${z}`),!1}finally{b(o,!1)}}async function l(){await a(async C=>{await n1(C,!0)},"Failed to enable Cowork")&&e.onAdvance()}function c(){IE(),e.onAdvance()}var d=aM(),u=_(x(d),2),h=_(x(u));{var p=S=>{var C=tM(),A=_(ze(C)),W=x(A);Y(()=>te(W,e.status.vethernetCidr)),T(S,C)};J(h,S=>{e.status.vethernetCidr!==null&&S(p)})}var m=_(u,2);{var v=S=>{var C=nM(),A=x(C);Y(()=>te(A,f(s))),T(S,C)};J(m,S=>{f(s)&&S(v)})}var g=_(m,2);{var y=S=>{var C=rM(),A=_(x(C),4),W=x(A);se(W,t);var z=_(W,2);se(z,r),Y(()=>{W.disabled=f(o),z.disabled=f(o)}),P("click",W,()=>void l()),P("click",z,()=>{b(i,!1)}),T(S,C)},k=S=>{var C=sM(),A=x(C);se(A,t);var W=_(A,2);se(W,r);var z=_(W,2);{var D=U=>{var ee=iM();se(ee,r),Y(()=>ee.disabled=f(o)),P("click",ee,function(...R){var K;(K=e.onLearnMore)==null||K.apply(this,R)}),T(U,ee)},O=U=>{var ee=oM();Y(()=>Z(ee,"href",`${ix}#cowork`)),T(U,ee)};J(z,U=>{e.onLearnMore?U(D):U(O,-1)})}Y(()=>{A.disabled=f(o),W.disabled=f(o)}),P("click",A,()=>{b(i,!0)}),P("click",W,c),T(S,C)};J(g,S=>{f(i)?S(y):S(k,-1)})}T(n,d),Je()}$e(["click"]);var cM=E("<div></div>"),dM=E('<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);"></div>'),uM=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),fM=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>'),hM=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 pM(n,e){qe(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=Ar(),i=e1(),o=H(()=>r&&$x(e.coworkStatus,i)),s=H(()=>t.filter(m=>m.id!=="cowork"||f(o))),a=H(()=>f(s).length-1),l=H(()=>f(s)[e.currentStep]),c=H(()=>e.currentStep>=f(a)),d=H(()=>{var m;return((m=f(l))==null?void 0:m.id)==="cowork"});var u=Rt(),h=ze(u);{var p=m=>{var v=hM(),g=x(v);{var y=z=>{var D=dM();mt(D,20,()=>Array.from({length:f(a)},(O,U)=>U),O=>O,(O,U)=>{var ee=cM();Y(()=>se(ee,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${U<=e.currentStep?"var(--tandem-accent)":"var(--tandem-border)"}; transition: background 0.2s;`)),T(O,ee)}),T(z,D)};J(g,z=>{f(c)||z(y)})}var k=_(g,2);{var S=z=>{lM(z,{get status(){return e.coworkStatus},get onAdvance(){return e.onNext}})},C=z=>{var D=uM(),O=ze(D),U=x(O),ee=_(O,2),R=x(ee);Y(()=>{te(U,f(l).title),se(ee,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${f(c)?0:14}px;`),te(R,f(l).text)}),T(z,D)};J(k,z=>{f(d)&&e.coworkStatus!==null?z(S):z(C,-1)})}var A=_(k,2);{var W=z=>{var D=fM(),O=x(D),U=x(O),ee=_(O,2),R=x(ee),K=_(R,2),ne=x(K);Y(()=>{te(U,`Step ${e.currentStep+1} of ${f(a)??""}`),te(ne,e.currentStep===f(a)-1?"Done":"Next")}),P("click",R,function(...X){var N;(N=e.onDismiss)==null||N.apply(this,X)}),P("click",K,function(...X){var N;(N=e.onNext)==null||N.apply(this,X)}),T(z,D)};J(A,z=>{!f(c)&&!f(d)&&z(W)})}T(m,v)};J(h,m=>{f(l)&&m(p)})}T(n,u),Je()}$e(["click"]);const xr=()=>new Map,Rp=n=>{const e=xr();return n.forEach((t,r)=>{e.set(r,t)}),e},bi=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},mM=(n,e)=>{const t=[];for(const[r,i]of n)t.push(e(i,r));return t},gM=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},ks=()=>new Set,uh=n=>n[n.length-1],vM=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},To=Array.from,ig=(n,e)=>{for(let t=0;t<n.length;t++)if(!e(n[t],t,n))return!1;return!0},og=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},yM=(n,e)=>{const t=new Array(n);for(let r=0;r<n;r++)t[r]=e(r,t);return t},Ca=Array.isArray;class i1{constructor(){this._observers=xr()}on(e,t){return bi(this._observers,e,ks).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 To((this._observers.get(e)||xr()).values()).forEach(r=>r(...t))}destroy(){this._observers=xr()}}const Br=Math.floor,bd=Math.abs,Bi=(n,e)=>n<e?n:e,Fr=(n,e)=>n>e?n:e,o1=n=>n!==0?n<0:1/n<0,Ry=1,Ny=2,fh=4,hh=8,Fl=32,Fi=64,Bn=128,bM=1<<29,uf=31,Np=63,cs=127,wM=2147483647,Zd=Number.MAX_SAFE_INTEGER,Iy=Number.MIN_SAFE_INTEGER,xM=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&Br(n)===n),s1=String.fromCharCode,kM=n=>n.toLowerCase(),_M=/^\s*/g,SM=n=>n.replace(_M,""),CM=/([A-Z])/g,Ly=(n,e)=>SM(n.replace(CM,t=>`${e}${kM(t)}`)),TM=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},Hl=typeof TextEncoder<"u"?new TextEncoder:null,AM=n=>Hl.encode(n),EM=Hl?AM:TM;let fl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});fl&&fl.decode(new Uint8Array).length===1&&(fl=null);const MM=(n,e)=>yM(e,()=>n).join("");let _c=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};const Sc=()=>new _c,OM=n=>{const e=Sc();return n(e),Lr(e)},DM=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},Lr=n=>{const e=new Uint8Array(DM(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},RM=(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(Fr(t,e)*2),n.cpos=0)},sn=(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},Ip=sn,at=(n,e)=>{for(;e>cs;)sn(n,Bn|cs&e),e=Br(e/128);sn(n,cs&e)},sg=(n,e)=>{const t=o1(e);for(t&&(e=-e),sn(n,(e>Np?Bn:0)|(t?Fi:0)|Np&e),e=Br(e/64);e>0;)sn(n,(e>cs?Bn:0)|cs&e),e=Br(e/128)},Lp=new Uint8Array(3e4),NM=Lp.length/3,IM=(n,e)=>{if(e.length<NM){const t=Hl.encodeInto(e,Lp).written||0;at(n,t);for(let r=0;r<t;r++)sn(n,Lp[r])}else Xn(n,EM(e))},LM=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;at(n,r);for(let i=0;i<r;i++)sn(n,t.codePointAt(i))},ea=Hl&&Hl.encodeInto?IM:LM,ff=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=Bi(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(Fr(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},Xn=(n,e)=>{at(n,e.byteLength),ff(n,e)},ag=(n,e)=>{RM(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},PM=(n,e)=>ag(n,4).setFloat32(0,e,!1),zM=(n,e)=>ag(n,8).setFloat64(0,e,!1),BM=(n,e)=>ag(n,8).setBigInt64(0,e,!1),Py=new DataView(new ArrayBuffer(4)),FM=n=>(Py.setFloat32(0,n),Py.getFloat32(0)===n),Ta=(n,e)=>{switch(typeof e){case"string":sn(n,119),ea(n,e);break;case"number":xM(e)&&bd(e)<=wM?(sn(n,125),sg(n,e)):FM(e)?(sn(n,124),PM(n,e)):(sn(n,123),zM(n,e));break;case"bigint":sn(n,122),BM(n,e);break;case"object":if(e===null)sn(n,126);else if(Ca(e)){sn(n,117),at(n,e.length);for(let t=0;t<e.length;t++)Ta(n,e[t])}else if(e instanceof Uint8Array)sn(n,116),Xn(n,e);else{sn(n,118);const t=Object.keys(e);at(n,t.length);for(let r=0;r<t.length;r++){const i=t[r];ea(n,i),Ta(n,e[i])}}break;case"boolean":sn(n,e?120:121);break;default:sn(n,127)}};class zy extends _c{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&at(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const By=n=>{n.count>0&&(sg(n.encoder,n.count===1?n.s:-n.s),n.count>1&&at(n.encoder,n.count-2))};class wd{constructor(){this.encoder=new _c,this.s=0,this.count=0}write(e){this.s===e?this.count++:(By(this),this.count=1,this.s=e)}toUint8Array(){return By(this),Lr(this.encoder)}}const Fy=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);sg(n.encoder,e),n.count>1&&at(n.encoder,n.count-2)}};class ph{constructor(){this.encoder=new _c,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Fy(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Fy(this),Lr(this.encoder)}}class HM{constructor(){this.sarr=[],this.s="",this.lensE=new wd}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 _c;return this.sarr.push(this.s),this.s="",ea(e,this.sarr.join("")),ff(e,this.lensE.toUint8Array()),Lr(e)}}const fi=n=>new Error(n),kr=()=>{throw fi("Method unimplemented")},En=()=>{throw fi("Unexpected case")},a1=fi("Unexpected end of array"),l1=fi("Integer out of Range");let hf=class{constructor(e){this.arr=e,this.pos=0}};const Fa=n=>new hf(n),VM=n=>n.pos!==n.arr.length,UM=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},Qn=n=>UM(n,nt(n)),Aa=n=>n.arr[n.pos++],nt=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&cs)*t,t*=128,i<Bn)return e;if(e>Zd)throw l1}throw a1},lg=n=>{let e=n.arr[n.pos++],t=e&Np,r=64;const i=(e&Fi)>0?-1:1;if((e&Bn)===0)return i*t;const o=n.arr.length;for(;n.pos<o;){if(e=n.arr[n.pos++],t=t+(e&cs)*r,r*=128,e<Bn)return i*t;if(t>Zd)throw l1}throw a1},jM=n=>{let e=nt(n);if(e===0)return"";{let t=String.fromCodePoint(Aa(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(Aa(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))}},WM=n=>fl.decode(Qn(n)),ta=fl?WM:jM,cg=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},KM=n=>cg(n,4).getFloat32(0,!1),qM=n=>cg(n,8).getFloat64(0,!1),JM=n=>cg(n,8).getBigInt64(0,!1),YM=[n=>{},n=>null,lg,KM,qM,JM,n=>!1,n=>!0,ta,n=>{const e=nt(n),t={};for(let r=0;r<e;r++){const i=ta(n);t[i]=Vl(n)}return t},n=>{const e=nt(n),t=[];for(let r=0;r<e;r++)t.push(Vl(n));return t},Qn],Vl=n=>YM[127-Aa(n)](n);class Hy extends hf{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),VM(this)?this.count=nt(this)+1:this.count=-1),this.count--,this.s}}class xd extends hf{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=lg(this);const e=o1(this.s);this.count=1,e&&(this.s=-this.s,this.count=nt(this)+2)}return this.count--,this.s}}class mh extends hf{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=lg(this),t=e&1;this.diff=Br(e/2),this.count=1,t&&(this.count=nt(this)+2)}return this.s+=this.diff,this.count--,this.s}}class ZM{constructor(e){this.decoder=new xd(e),this.str=ta(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 GM=crypto.getRandomValues.bind(crypto),XM=Math.random,c1=()=>GM(new Uint32Array(1))[0],QM=n=>n[Br(XM()*n.length)],$M="10000000-1000-4000-8000"+-1e11,e2=()=>$M.replace(/[018]/g,n=>(n^c1()&15>>n/4).toString(16)),t2=Date.now,Vy=n=>new Promise(n);Promise.all.bind(Promise);const Uy=n=>n===void 0?null:n;class n2{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let d1=new n2,r2=!0;try{typeof localStorage<"u"&&localStorage&&(d1=localStorage,r2=!1)}catch{}const i2=d1,Ul=Symbol("Equality"),u1=(n,e)=>{var t;return n===e||!!((t=n==null?void 0:n[Ul])!=null&&t.call(n,e))||!1},o2=n=>typeof n=="object",s2=Object.assign,f1=Object.keys,a2=(n,e)=>{for(const t in n)e(n[t],t)},Gd=n=>f1(n).length,l2=n=>{for(const e in n)return!1;return!0},Ha=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},dg=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),c2=(n,e)=>n===e||Gd(n)===Gd(e)&&Ha(n,(t,r)=>(t!==void 0||dg(e,r))&&u1(e[r],t)),d2=Object.freeze,h1=n=>{for(const e in n){const t=n[e];(typeof t=="object"||typeof t=="function")&&h1(n[e])}return d2(n)},ug=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&ug(n,e,t+1)}},u2=n=>n,kd=(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[Ul]!=null)return n[Ul](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)||!kd(n.get(t),e.get(t)))return!1;break}case void 0:case Object:if(Gd(n)!==Gd(e))return!1;for(const t in n)if(!dg(n,t)||!kd(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(!kd(n[t],e[t]))return!1;break;default:return!1}return!0},f2=(n,e)=>e.includes(n);var p1={};const Ea=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",m1=typeof window<"u"&&typeof document<"u"&&!Ea;let qr;const h2=()=>{if(qr===void 0)if(Ea){qr=xr();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&qr.set(e,""),e=r):e!==null&&(qr.set(e,r),e=null)}e!==null&&qr.set(e,"")}else typeof location=="object"?(qr=xr(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");qr.set(`--${Ly(e,"-")}`,t),qr.set(`-${Ly(e,"-")}`,t)}})):qr=xr();return qr},Pp=n=>h2().has(n),Xd=n=>Uy(Ea?p1[n.toUpperCase().replaceAll("-","_")]:i2.getItem(n)),g1=n=>Pp("--"+n)||Xd(n)!==null,p2=g1("production"),m2=Ea&&f2(p1.FORCE_COLOR,["true","1","2"]),g2=m2||!Pp("--no-colors")&&!g1("no-color")&&(!Ea||process.stdout.isTTY)&&(!Ea||Pp("--color")||Xd("COLORTERM")!==null||(Xd("TERM")||"").includes("color")),v2=n=>new Uint8Array(n),y2=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=s1(n[t]);return btoa(e)},b2=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),w2=m1?y2:b2,x2=n=>{const e=v2(n.byteLength);return e.set(n),e},k2=n=>OM(e=>Ta(e,n));class _2{constructor(e,t){this.left=e,this.right=t}}const xi=(n,e)=>new _2(n,e),jy=n=>n.next()>=.5,gh=(n,e,t)=>Br(n.next()*(t+1-e)+e),v1=(n,e,t)=>Br(n.next()*(t+1-e)+e),fg=(n,e,t)=>v1(n,e,t),S2=n=>s1(fg(n,97,122)),C2=(n,e=0,t=20)=>{const r=fg(n,e,t);let i="";for(let o=0;o<r;o++)i+=S2(n);return i},vh=(n,e)=>e[fg(n,0,e.length-1)],T2=Symbol("0schema");class A2{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(MM(" ",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
46
46
|
`)}}const zp=(n,e)=>n===e?!0:n==null||e==null||n.constructor!==e.constructor?!1:n[Ul]?u1(n,e):Ca(n)?ig(n,t=>og(e,r=>zp(t,r))):o2(n)?Ha(n,(t,r)=>zp(t,e[r])):!1;class Nn{extends(e){let[t,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,t]=[t,r]),zp(t,r)}equals(e){return this.constructor===e.constructor&&kd(this.shape,e.shape)}[T2](){return!0}[Ul](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){kr()}get nullable(){return Va(this,yf)}get optional(){return new w1(this)}cast(e){return Wy(e,this),e}expect(e){return Wy(e,this),e}}jn(Nn,"_dilutes",!1);class hg extends Nn{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 $t=(n,e=null)=>new hg(n,e);$t(hg);class pg extends Nn{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 hn=n=>new pg(n);$t(pg);class pf extends Nn{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 mf=(...n)=>new pf(n),y1=$t(pf),E2=RegExp.escape||(n=>n.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),b1=n=>{if(Ma.check(n))return[E2(n)];if(y1.check(n))return n.shape.map(e=>e+"");if(M1.check(n))return["[+-]?\\d+.?\\d*"];if(O1.check(n))return[".*"];if($d.check(n))return n.shape.map(b1).flat(1);En()};class M2 extends Nn{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(b1).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}}$t(M2);const O2=Symbol("optional");class w1 extends Nn{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[O2](){return!0}}const D2=$t(w1);class R2 extends Nn{check(e,t){return t==null||t.extend(null,"never",typeof e),!1}}$t(R2);const ef=class ef extends Nn{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}get partial(){return new ef(this.shape,!0)}check(e,t){return e==null?(t==null||t.extend(null,"object","null"),!1):Ha(this.shape,(r,i)=>{const o=this._isPartial&&!dg(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})}};jn(ef,"_dilutes",!0);let Qd=ef;const N2=n=>new Qd(n),I2=$t(Qd),L2=hn(n=>n!=null&&(n.constructor===Object||n.constructor==null));class x1 extends Nn{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Ha(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 k1=(n,e)=>new x1(n,e),P2=$t(x1);class _1 extends Nn{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Ha(this.shape,(r,i)=>{const o=r.check(e[i],t);return!o&&(t==null||t.extend(i.toString(),"Tuple",typeof r)),o})}}const z2=(...n)=>new _1(n);$t(_1);class S1 extends Nn{constructor(e){super(),this.shape=e.length===1?e[0]:new gf(e)}check(e,t){const r=Ca(e)&&ig(e,i=>this.shape.check(i));return!r&&(t==null||t.extend(null,"Array","")),r}}const C1=(...n)=>new S1(n),B2=$t(S1),F2=hn(n=>Ca(n));class T1 extends Nn{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 H2=(n,e=null)=>new T1(n,e);$t(T1);const V2=H2(Nn);class U2 extends Nn{constructor(e){super(),this.len=e.length-1,this.args=z2(...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 j2=$t(U2),W2=hn(n=>typeof n=="function");class K2 extends Nn{constructor(e){super(),this.shape=e}check(e,t){const r=ig(this.shape,i=>i.check(e,t));return!r&&(t==null||t.extend(null,"Intersectinon",typeof e)),r}}$t(K2,n=>n.shape.length>0);class gf extends Nn{constructor(e){super(),this.shape=e}check(e,t){const r=og(this.shape,i=>i.check(e,t));return t==null||t.extend(null,"Union",typeof e),r}}jn(gf,"_dilutes",!0);const Va=(...n)=>n.findIndex(e=>$d.check(e))>=0?Va(...n.map(e=>jl(e)).map(e=>$d.check(e)?e.shape:[e]).flat(1)):n.length===1?n[0]:new gf(n),$d=$t(gf),A1=()=>!0,eu=hn(A1),q2=$t(pg,n=>n.shape===A1),mg=hn(n=>typeof n=="bigint"),J2=hn(n=>n===mg),E1=hn(n=>typeof n=="symbol");hn(n=>n===E1);const na=hn(n=>typeof n=="number"),M1=hn(n=>n===na),Ma=hn(n=>typeof n=="string"),O1=hn(n=>n===Ma),vf=hn(n=>typeof n=="boolean"),Y2=hn(n=>n===vf),D1=mf(void 0);$t(pf,n=>n.shape.length===1&&n.shape[0]===void 0);mf(void 0);const yf=mf(null),Z2=$t(pf,n=>n.shape.length===1&&n.shape[0]===null);$t(Uint8Array);$t(hg,n=>n.shape===Uint8Array);const G2=Va(na,Ma,yf,D1,mg,vf,E1);(()=>{const n=C1(eu),e=k1(Ma,eu),t=Va(na,Ma,yf,vf,n,e);return n.shape=t,e.shape.values=t,t})();const jl=n=>{if(V2.check(n))return n;if(L2.check(n)){const e={};for(const t in n)e[t]=jl(n[t]);return N2(e)}else{if(F2.check(n))return Va(...n.map(jl));if(G2.check(n))return mf(n);if(W2.check(n))return $t(n)}En()},Wy=p2?()=>{}:(n,e)=>{const t=new A2;if(!e.check(n,t))throw fi(`Expected value to be of type ${e.constructor.name}.
|
|
47
|
-
${t.toString()}`)};class X2{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:jl(e),h:t}),this}else(e){return this.if(eu,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 fi("Unhandled pattern")}}}const Q2=n=>new X2(n),R1=Q2(eu).if(M1,(n,e)=>gh(e,Iy,Zd)).if(O1,(n,e)=>C2(e)).if(Y2,(n,e)=>jy(e)).if(J2,(n,e)=>BigInt(gh(e,Iy,Zd))).if($d,(n,e)=>Bs(e,vh(e,n.shape))).if(I2,(n,e)=>{const t={};for(const r in n.shape){let i=n.shape[r];if(D2.check(i)){if(jy(e))continue;i=i.shape}t[r]=R1(i,e)}return t}).if(B2,(n,e)=>{const t=[],r=v1(e,0,42);for(let i=0;i<r;i++)t.push(Bs(e,n.shape));return t}).if(y1,(n,e)=>vh(e,n.shape)).if(Z2,(n,e)=>null).if(j2,(n,e)=>{const t=Bs(e,n.res);return()=>t}).if(q2,(n,e)=>Bs(e,vh(e,[na,Ma,yf,D1,mg,vf,C1(na),k1(Va("a","b","c"),na)]))).if(P2,(n,e)=>{const t={},r=gh(e,0,3);for(let i=0;i<r;i++){const o=Bs(e,n.shape.keys),s=Bs(e,n.shape.values);t[o]=s}return t}).done(),Bs=(n,e)=>R1(jl(e),n),Cc=typeof document<"u"?document:{};hn(n=>n.nodeType===rO);typeof DOMParser<"u"&&new DOMParser;hn(n=>n.nodeType===eO);hn(n=>n.nodeType===tO);const $2=n=>mM(n,(e,t)=>`${t}:${e};`).join(""),eO=Cc.ELEMENT_NODE,tO=Cc.TEXT_NODE,nO=Cc.DOCUMENT_NODE,rO=Cc.DOCUMENT_FRAGMENT_NODE;hn(n=>n.nodeType===nO);const iO=n=>class{constructor(t){this._=t}destroy(){n(this._)}},oO=iO(clearTimeout),gg=(n,e)=>new oO(setTimeout(e,n)),Ji=Symbol,N1=Ji(),I1=Ji(),sO=Ji(),aO=Ji(),lO=Ji(),L1=Ji(),cO=Ji(),vg=Ji(),dO=Ji(),uO=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},fO={[N1]:xi("font-weight","bold"),[I1]:xi("font-weight","normal"),[sO]:xi("color","blue"),[lO]:xi("color","green"),[aO]:xi("color","grey"),[L1]:xi("color","red"),[cO]:xi("color","purple"),[vg]:xi("color","orange"),[dO]:xi("color","black")},hO=n=>{var s;n.length===1&&((s=n[0])==null?void 0:s.constructor)===Function&&(n=n[0]());const e=[],t=[],r=xr();let i=[],o=0;for(;o<n.length;o++){const a=n[o],l=fO[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=$2(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},P1=g2?hO:uO,pO=(...n)=>{console.log(...P1(n)),B1.forEach(e=>e.print(n))},z1=(...n)=>{console.warn(...P1(n)),n.unshift(vg),B1.forEach(e=>e.print(n))},B1=ks(),F1=n=>({[Symbol.iterator](){return this},next:n}),mO=(n,e)=>F1(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),yh=(n,e)=>F1(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class bf{constructor(e,t){this.clock=e,this.len=t}}class Ua{constructor(){this.clients=new Map}}const Ao=(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])$1(n,o,c.clock,c.len,t)}}),gO=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const i=Br((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},ja=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&gO(t,e.clock)!==null},yg=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 bf(i.clock,Fr(i.len,o.clock+o.len-i.clock)):(r<t&&(e[r]=o),r++)}e.length=r})},Bp=n=>{const e=new Ua;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++)vM(o,n[s].clients.get(i)||[]);e.clients.set(i,o)}});return yg(e),e},Wl=(n,e,t,r)=>{bi(n.clients,e,()=>[]).push(new bf(t,r))},H1=()=>new Ua,V1=n=>{const e=H1();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 bf(a,l))}}i.length>0&&e.clients.set(r,i)}),e},Wa=(n,e)=>{at(n.restEncoder,e.clients.size),To(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),at(n.restEncoder,t);const i=r.length;at(n.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];n.writeDsClock(s.clock),n.writeDsLen(s.len)}})},bg=n=>{const e=new Ua,t=nt(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const i=nt(n.restDecoder),o=nt(n.restDecoder);if(o>0){const s=bi(e.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new bf(n.readDsClock(),n.readDsLen()))}}return e},Ky=(n,e,t)=>{const r=new Ua,i=nt(n.restDecoder);for(let o=0;o<i;o++){n.resetDsCurVal();const s=nt(n.restDecoder),a=nt(n.restDecoder),l=t.clients.get(s)||[],c=Jt(t,s);for(let d=0;d<a;d++){const u=n.readDsClock(),h=u+n.readDsLen();if(u<c){c<h&&Wl(r,s,c,h-c);let p=Hr(l,u),m=l[p];for(!m.deleted&&m.id.clock<u&&(l.splice(p+1,0,au(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,au(e,m,h-m.id.clock)),m.delete(e))}else Wl(r,s,u,h-u)}}if(r.clients.size>0){const o=new _s;return at(o.restEncoder,0),Wa(o,r),o.toUint8Array()}return null},U1=c1;class hi extends i1{constructor({guid:e=e2(),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=U1(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new X1,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=Vy(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Vy(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&&St(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(To(this.subdocs).map(e=>e.guid))}transact(e,t=null){return St(this,e,t)}get(e,t=dn){const r=bi(this.share,e,()=>{const o=new t;return o._integrate(this,null),o}),i=r.constructor;if(t!==dn&&i!==t)if(i===dn){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,oa)}getText(e=""){return this.get(e,Eo)}getMap(e=""){return this.get(e,Da)}getXmlElement(e=""){return this.get(e,Gt)}getXmlFragment(e=""){return this.get(e,Ss)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,To(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new hi({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,St(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 j1{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return nt(this.restDecoder)}readDsLen(){return nt(this.restDecoder)}}class W1 extends j1{readLeftID(){return Ke(nt(this.restDecoder),nt(this.restDecoder))}readRightID(){return Ke(nt(this.restDecoder),nt(this.restDecoder))}readClient(){return nt(this.restDecoder)}readInfo(){return Aa(this.restDecoder)}readString(){return ta(this.restDecoder)}readParentInfo(){return nt(this.restDecoder)===1}readTypeRef(){return nt(this.restDecoder)}readLen(){return nt(this.restDecoder)}readAny(){return Vl(this.restDecoder)}readBuf(){return x2(Qn(this.restDecoder))}readJSON(){return JSON.parse(ta(this.restDecoder))}readKey(){return ta(this.restDecoder)}}class vO{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=nt(this.restDecoder),this.dsCurrVal}readDsLen(){const e=nt(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Oa extends vO{constructor(e){super(e),this.keys=[],nt(e),this.keyClockDecoder=new mh(Qn(e)),this.clientDecoder=new xd(Qn(e)),this.leftClockDecoder=new mh(Qn(e)),this.rightClockDecoder=new mh(Qn(e)),this.infoDecoder=new Hy(Qn(e),Aa),this.stringDecoder=new ZM(Qn(e)),this.parentInfoDecoder=new Hy(Qn(e),Aa),this.typeRefDecoder=new xd(Qn(e)),this.lenDecoder=new xd(Qn(e))}readLeftID(){return new ra(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ra(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Vl(this.restDecoder)}readBuf(){return Qn(this.restDecoder)}readJSON(){return Vl(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 K1{constructor(){this.restEncoder=Sc()}toUint8Array(){return Lr(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){at(this.restEncoder,e)}writeDsLen(e){at(this.restEncoder,e)}}class Tc extends K1{writeLeftID(e){at(this.restEncoder,e.client),at(this.restEncoder,e.clock)}writeRightID(e){at(this.restEncoder,e.client),at(this.restEncoder,e.clock)}writeClient(e){at(this.restEncoder,e)}writeInfo(e){Ip(this.restEncoder,e)}writeString(e){ea(this.restEncoder,e)}writeParentInfo(e){at(this.restEncoder,e?1:0)}writeTypeRef(e){at(this.restEncoder,e)}writeLen(e){at(this.restEncoder,e)}writeAny(e){Ta(this.restEncoder,e)}writeBuf(e){Xn(this.restEncoder,e)}writeJSON(e){ea(this.restEncoder,JSON.stringify(e))}writeKey(e){ea(this.restEncoder,e)}}class q1{constructor(){this.restEncoder=Sc(),this.dsCurrVal=0}toUint8Array(){return Lr(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,at(this.restEncoder,t)}writeDsLen(e){e===0&&En(),at(this.restEncoder,e-1),this.dsCurrVal+=e}}class _s extends q1{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ph,this.clientEncoder=new wd,this.leftClockEncoder=new ph,this.rightClockEncoder=new ph,this.infoEncoder=new zy(Ip),this.stringEncoder=new HM,this.parentInfoEncoder=new zy(Ip),this.typeRefEncoder=new wd,this.lenEncoder=new wd}toUint8Array(){const e=Sc();return at(e,0),Xn(e,this.keyClockEncoder.toUint8Array()),Xn(e,this.clientEncoder.toUint8Array()),Xn(e,this.leftClockEncoder.toUint8Array()),Xn(e,this.rightClockEncoder.toUint8Array()),Xn(e,Lr(this.infoEncoder)),Xn(e,this.stringEncoder.toUint8Array()),Xn(e,Lr(this.parentInfoEncoder)),Xn(e,this.typeRefEncoder.toUint8Array()),Xn(e,this.lenEncoder.toUint8Array()),ff(e,Lr(this.restEncoder)),Lr(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){Ta(this.restEncoder,e)}writeBuf(e){Xn(this.restEncoder,e)}writeJSON(e){Ta(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 yO=(n,e,t,r)=>{r=Fr(r,e[0].id.clock);const i=Hr(e,r);at(n.restEncoder,e.length-i),n.writeClient(t),at(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)},wg=(n,e,t)=>{const r=new Map;t.forEach((i,o)=>{Jt(e,o)>i&&r.set(o,i)}),Ac(e).forEach((i,o)=>{t.has(o)||r.set(o,0)}),at(n.restEncoder,r.size),To(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{yO(n,e.clients.get(i),i,o)})},bO=(n,e)=>{const t=xr(),r=nt(n.restDecoder);for(let i=0;i<r;i++){const o=nt(n.restDecoder),s=new Array(o),a=n.readClient();let l=nt(n.restDecoder);t.set(a,{i:0,refs:s});for(let c=0;c<o;c++){const d=n.readInfo();switch(uf&d){case 0:{const u=n.readLen();s[c]=new gr(Ke(a,l),u),l+=u;break}case 10:{const u=nt(n.restDecoder);s[c]=new vr(Ke(a,l),u),l+=u;break}default:{const u=(d&(Fi|Bn))===0,h=new Et(Ke(a,l),null,(d&Bn)===Bn?n.readLeftID():null,null,(d&Fi)===Fi?n.readRightID():null,u?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,u&&(d&Fl)===Fl?n.readString():null,xk(n,d));s[c]=h,l+=h.length}}}}return t},wO=(n,e,t)=>{const r=[];let i=To(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 X1,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!==vr){const m=bi(u,d.id.client,()=>Jt(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,Jt(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 _s;return wg(p,a,new Map),at(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},xO=(n,e)=>wg(n,e.doc.store,e.beforeState),kO=(n,e,t,r=new Oa(n))=>St(e,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=bO(r,s),c=wO(i,a,l),d=a.pendingStructs;if(d){for(const[h,p]of d.missing)if(p<Jt(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=nu([d.update,c.update])}}else a.pendingStructs=c;const u=Ky(r,i,a);if(a.pendingDs){const h=new Oa(Fa(a.pendingDs));nt(h.restDecoder);const p=Ky(h,i,a);u&&p?a.pendingDs=nu([u,p]):a.pendingDs=u||p}else a.pendingDs=u;if(o){const h=a.pendingStructs.update;a.pendingStructs=null,tu(i.doc,h)}},t,!1),tu=(n,e,t,r=Oa)=>{const i=Fa(e);kO(i,n,t,new r(i))},_O=(n,e,t)=>tu(n,e,t,W1),SO=(n,e,t=new Map)=>{wg(n,e.store,t),Wa(n,V1(e.store))},CO=(n,e=new Uint8Array([0]),t=new _s)=>{const r=J1(e);SO(t,n,r);const i=[t.toUint8Array()];if(n.store.pendingDs&&i.push(n.store.pendingDs),n.store.pendingStructs&&i.push(WO(n.store.pendingStructs.update,e)),i.length>1){if(t.constructor===Tc)return UO(i.map((o,s)=>s===0?o:qO(o)));if(t.constructor===_s)return nu(i)}return i[0]},TO=(n,e)=>CO(n,e,new Tc),AO=n=>{const e=new Map,t=nt(n.restDecoder);for(let r=0;r<t;r++){const i=nt(n.restDecoder),o=nt(n.restDecoder);e.set(i,o)}return e},J1=n=>AO(new j1(Fa(n))),Y1=(n,e)=>(at(n.restEncoder,e.size),To(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{at(n.restEncoder,t),at(n.restEncoder,r)}),n),EO=(n,e)=>Y1(n,Ac(e.store)),MO=(n,e=new q1)=>(n instanceof Map?Y1(e,n):EO(e,n),e.toUint8Array()),OO=n=>MO(n,new K1);class DO{constructor(){this.l=[]}}const qy=()=>new DO,Jy=(n,e)=>n.l.push(e),Yy=(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.")},Z1=(n,e,t)=>ug(n.l,[e,t]);class ra{constructor(e,t){this.client=e,this.clock=t}}const Gs=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,Ke=(n,e)=>new ra(n,e),Kl=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw En()},ql=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class Jl{constructor(e,t,r,i=0){this.type=e,this.tname=t,this.item=r,this.assoc=i}}const ds=n=>new Jl(n.type==null?null:Ke(n.type.client,n.type.clock),n.tname??null,n.item==null?null:Ke(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class RO{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const NO=(n,e,t=0)=>new RO(n,e,t),jc=(n,e,t)=>{let r=null,i=null;return n._item===null?i=Kl(n):r=Ke(n._item.id.client,n._item.id.clock),new Jl(r,i,e,t)},bh=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return jc(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return jc(n,Ke(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return jc(n,r.lastId,t);r=r.right}return jc(n,null,t)},IO=(n,e)=>{const t=ia(n,e),r=e.clock-t.id.clock;return{item:t,diff:r}},Fp=(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(Jt(r,i.client)<=i.clock)return null;const d=t?jp(r,i):IO(r,i),u=d.item;if(!(u instanceof Et))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(Jt(r,o.client)<=o.clock)return null;const{item:d}=t?jp(r,o):{item:ia(r,o)};if(d instanceof Et&&d.content instanceof jr)l=d.content.type;else return null}else throw En();a>=0?c=l._length:c=0}return NO(l,c,n.assoc)},Zy=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&Gs(n.item,e.item)&&Gs(n.type,e.type)&&n.assoc===e.assoc;class xg{constructor(e,t){this.ds=e,this.sv=t}}const G1=(n,e)=>new xg(n,e),wh=n=>G1(V1(n.store),Ac(n.store)),Vo=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!ja(e.ds,n.id),Hp=(n,e)=>{const t=bi(n.meta,Hp,ks),r=n.doc.store;t.has(e)||(e.sv.forEach((i,o)=>{i<Jt(r,o)&&Jn(n,Ke(o,i))}),Ao(n,e.ds,i=>{}),t.add(e))};class X1{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Ac=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},Jt=(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},Q1=(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 En()}t.push(e)},Hr=(n,e)=>{let t=0,r=n.length-1,i=n[r],o=i.id.clock;if(o===e)return r;let s=Br(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=Br((t+r)/2)}throw En()},LO=(n,e)=>{const t=n.clients.get(e.client);return t[Hr(t,e.clock)]},ia=LO,Vp=(n,e,t)=>{const r=Hr(e,t),i=e[r];return i.id.clock<t&&i instanceof Et?(e.splice(r+1,0,au(n,i,t-i.id.clock)),r+1):r},Jn=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[Vp(n,t,e.clock)]},Gy=(n,e,t)=>{const r=e.clients.get(t.client),i=Hr(r,t.clock),o=r[i];return t.clock!==o.id.clock+o.length-1&&o.constructor!==gr&&r.splice(i+1,0,au(n,o,t.clock-o.id.clock+1)),o},PO=(n,e,t)=>{const r=n.clients.get(e.id.client);r[Hr(r,e.id.clock)]=t},$1=(n,e,t,r,i)=>{if(r===0)return;const o=t+r;let s=Vp(n,e,t),a;do a=e[s++],o<a.id.clock+a.length&&Vp(n,e,o),i(a);while(s<e.length&&e[s].id.clock<o)};class zO{constructor(e,t,r){this.doc=e,this.deleteSet=new Ua,this.beforeState=Ac(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 Xy=(n,e)=>e.deleteSet.clients.size===0&&!gM(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(yg(e.deleteSet),xO(n,e),Wa(n,e.deleteSet),!0),Qy=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&bi(n.changed,e,ks).add(t)},_d=(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 Et&&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},BO=(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=Hr(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 Et&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},FO=(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=Bi(i.length-1,1+Hr(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+_d(i,l)}})},ek=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,i=r.store,o=t.deleteSet,s=t._mergeStructs;try{yg(o),t.afterState=Ac(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(()=>{Z1(c._dEH,l,t)}))}),a.push(()=>r.emit("afterTransaction",[t,r])),a.push(()=>{t._needFormattingCleanup&&sD(t)})}),ug(a,[])}finally{r.gc&&BO(o,i,r.gcFilter),FO(o,i),t.afterState.forEach((d,u)=>{const h=t.beforeState.get(u)||0;if(h!==d){const p=i.clients.get(u),m=Fr(Hr(p,h),1);for(let v=p.length-1;v>=m;)v-=1+_d(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=Hr(p,h);m+1<p.length&&_d(p,m+1)>1||m>0&&_d(p,m)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(pO(vg,N1,"[yjs] ",I1,L1,"Changed the client-id because another client seems to be using it."),r.clientID=U1()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const d=new Tc;Xy(d,t)&&r.emit("update",[d.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const d=new _s;Xy(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])):ek(n,e+1)}}},St=(n,e,t=null,r=!0)=>{const i=n._transactionCleanups;let o=!1,s=null;n._transaction===null&&(o=!0,n._transaction=new zO(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&&ek(i,0)}}return s};class HO{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const $y=(n,e,t)=>{Ao(n,t.deletions,r=>{r instanceof Et&&e.scope.some(i=>i===n.doc||ql(i,r))&&Mg(r,!1)})},eb=(n,e,t)=>{let r=null;const i=n.doc,o=n.scope;St(i,a=>{for(;e.length>0&&n.currStackItem===null;){const l=i.store,c=e.pop(),d=new Set,u=[];let h=!1;Ao(a,c.insertions,p=>{if(p instanceof Et){if(p.redone!==null){let{item:m,diff:v}=jp(l,p.id);v>0&&(m=Jn(a,Ke(m.id.client,m.id.clock+v))),p=m}!p.deleted&&o.some(m=>m===a.doc||ql(m,p))&&u.push(p)}}),Ao(a,c.deletions,p=>{p instanceof Et&&o.some(m=>m===a.doc||ql(m,p))&&!ja(c.insertions,p.id)&&d.add(p)}),d.forEach(p=>{h=wk(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 tk extends i1{constructor(e,{captureTimeout:t=500,captureTransaction:r=l=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:a=Ca(e)?e[0].doc:e instanceof hi?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 Ua;l.afterState.forEach((g,y)=>{const k=l.beforeState.get(y)||0,S=g-k;S>0&&Wl(h,y,k,S)});const p=t2();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=Bp([g.deletions,l.deleteSet]),g.insertions=Bp([g.insertions,h])}else u.push(new HO(l.deleteSet,h)),m=!0;!c&&!d&&(this.lastChange=p),Ao(l,l.deleteSet,g=>{g instanceof Et&&this.scope.some(y=>y===l.doc||ql(y,g))&&Mg(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=Ca(e)?e:[e],e.forEach(r=>{t.has(r)||(t.add(r),(r instanceof dn?r.doc!==this.doc:r!==this.doc)&&z1("[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=>$y(r,this,i)),this.undoStack=[]),t&&(this.redoStack.forEach(i=>$y(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=eb(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=eb(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*VO(n){const e=nt(n.restDecoder);for(let t=0;t<e;t++){const r=nt(n.restDecoder),i=n.readClient();let o=nt(n.restDecoder);for(let s=0;s<r;s++){const a=n.readInfo();if(a===10){const l=nt(n.restDecoder);yield new vr(Ke(i,o),l),o+=l}else if((uf&a)!==0){const l=(a&(Fi|Bn))===0,c=new Et(Ke(i,o),null,(a&Bn)===Bn?n.readLeftID():null,null,(a&Fi)===Fi?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(a&Fl)===Fl?n.readString():null,xk(n,a));yield c,o+=c.length}else{const l=n.readLen();yield new gr(Ke(i,o),l),o+=l}}}}class kg{constructor(e,t){this.gen=VO(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===vr);return this.curr}}class _g{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const UO=n=>nu(n,W1,Tc),jO=(n,e)=>{if(n.constructor===gr){const{client:t,clock:r}=n.id;return new gr(Ke(t,r+e),n.length-e)}else if(n.constructor===vr){const{client:t,clock:r}=n.id;return new vr(Ke(t,r+e),n.length-e)}else{const t=n,{client:r,clock:i}=t.id;return new Et(Ke(r,i+e),null,Ke(r,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},nu=(n,e=Oa,t=_s)=>{if(n.length===1)return n[0];const r=n.map(d=>new e(Fa(d)));let i=r.map(d=>new kg(d,!0)),o=null;const s=new t,a=new _g(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===vr?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)no(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===vr)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{no(a,o.struct,o.offset);const m=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new vr(Ke(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===vr?o.struct.length-=m:h=jO(h,m)),o.struct.mergeWith(h)||(no(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!==vr;h=d.next())no(a,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(no(a,o.struct,o.offset),o=null),Sg(a);const l=r.map(d=>bg(d)),c=Bp(l);return Wa(s,c),s.toUint8Array()},WO=(n,e,t=Oa,r=_s)=>{const i=J1(e),o=new r,s=new _g(o),a=new t(Fa(n)),l=new kg(a,!1);for(;l.curr;){const d=l.curr,u=d.id.client,h=i.get(u)||0;if(l.curr.constructor===vr){l.next();continue}if(d.id.clock+d.length>h)for(no(s,d,Fr(h-d.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)no(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()}Sg(s);const c=bg(a);return Wa(o,c),o.toUint8Array()},nk=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:Lr(n.encoder.restEncoder)}),n.encoder.restEncoder=Sc(),n.written=0)},no=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&nk(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),at(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},Sg=n=>{nk(n);const e=n.encoder.restEncoder;at(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];at(e,r.written),ff(e,r.restEncoder)}},KO=(n,e,t,r)=>{const i=new t(Fa(n)),o=new kg(i,!1),s=new r,a=new _g(s);for(let c=o.curr;c!==null;c=o.next())no(a,e(c),0);Sg(a);const l=bg(i);return Wa(s,l),s.toUint8Array()},qO=n=>KO(n,u2,Oa,Tc),tb="You must not compute changes after the event-handler fired.";class wf{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=JO(this.currentTarget,this.target))}deletes(e){return ja(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw fi(tb);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=uh(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",a=uh(l.content.getContent())):(s="add",a=void 0)}else if(this.deletes(o))s="delete",a=uh(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 fi(tb);const t=this.target,r=ks(),i=ks(),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 JO=(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},Tn=()=>{z1("Invalid access: Add Yjs type to a document before reading data.")},rk=80;let Cg=0;class YO{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Cg++}}const ZO=n=>{n.timestamp=Cg++},ik=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=Cg++},GO=(n,e,t)=>{if(n.length>=rk){const r=n.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return ik(r,e,t),r}else{const r=new YO(e,t);return n.push(r),r}},xf=(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)=>bd(e-o.index)<bd(e-s.index)?o:s);let r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,ZO(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&&bd(t.index-i)<r.parent.length/rk?(ik(t,r,i),t):GO(n._searchMarker,r,i)},Yl=(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=Fr(e,i.index+t))}},kf=(n,e,t)=>{const r=n,i=e.changedParentTypes;for(;bi(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;Z1(r._eH,t,e)};class dn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=qy(),this._dEH=qy(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw kr()}clone(){throw kr()}_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){Jy(this._eH,e)}observeDeep(e){Jy(this._dEH,e)}unobserve(e){Yy(this._eH,e)}unobserveDeep(e){Yy(this._dEH,e)}toJSON(){}}const ok=(n,e,t)=>{n.doc??Tn(),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},sk=n=>{n.doc??Tn();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},ak=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&Vo(r,e)){const i=r.content.getContent();for(let o=0;o<i.length;o++)t.push(i[o])}r=r.right}return t},Zl=(n,e)=>{let t=0,r=n._start;for(n.doc??Tn();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}},lk=(n,e)=>{const t=[];return Zl(n,(r,i)=>{t.push(e(r,i,n))}),t},XO=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}}}},ck=(n,e)=>{n.doc??Tn();const t=xf(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}},ru=(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 Et(Ke(s,Jt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Cs(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 Et(Ke(s,Jt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Ec(new Uint8Array(u))),i.integrate(n,0);break;case hi:i=new Et(Ke(s,Jt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Mc(u)),i.integrate(n,0);break;default:if(u instanceof dn)i=new Et(Ke(s,Jt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new jr(u)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},dk=()=>fi("Length exceeded!"),uk=(n,e,t,r)=>{if(t>e._length)throw dk();if(t===0)return e._searchMarker&&Yl(e._searchMarker,t,r.length),ru(n,e,null,r);const i=t,o=xf(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&&Jn(n,Ke(s.id.client,s.id.clock+t));break}t-=s.length}return e._searchMarker&&Yl(e._searchMarker,i,r.length),ru(n,e,s,r)},QO=(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 ru(n,e,i,t)},fk=(n,e,t,r)=>{if(r===0)return;const i=t,o=r,s=xf(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&&Jn(n,Ke(a.id.client,a.id.clock+t)),t-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Jn(n,Ke(a.id.client,a.id.clock+r)),a.delete(n),r-=a.length),a=a.right;if(r>0)throw dk();e._searchMarker&&Yl(e._searchMarker,i,-o+r)},iu=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},Tg=(n,e,t,r)=>{const i=e._map.get(t)||null,o=n.doc,s=o.clientID;let a;if(r==null)a=new Cs([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new Cs([r]);break;case Uint8Array:a=new Ec(r);break;case hi:a=new Mc(r);break;default:if(r instanceof dn)a=new jr(r);else throw new Error("Unexpected content type")}new Et(Ke(s,Jt(o.store,s)),i,i&&i.lastId,null,null,e,t,a).integrate(n,0)},Ag=(n,e)=>{n.doc??Tn();const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},hk=n=>{const e={};return n.doc??Tn(),n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},pk=(n,e)=>{n.doc??Tn();const t=n._map.get(e);return t!==void 0&&!t.deleted},$O=(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&&Vo(o,e)&&(t[i]=o.content.getContent()[o.length-1])}),t},Wc=n=>(n.doc??Tn(),mO(n._map.entries(),e=>!e[1].deleted));class eD extends wf{}class oa extends dn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new oa;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new oa}clone(){const e=new oa;return e.insert(0,this.toArray().map(t=>t instanceof dn?t.clone():t)),e}get length(){return this.doc??Tn(),this._length}_callObserver(e,t){super._callObserver(e,t),kf(this,e,new eD(this,e))}insert(e,t){this.doc!==null?St(this.doc,r=>{uk(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?St(this.doc,t=>{QO(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?St(this.doc,r=>{fk(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return ck(this,e)}toArray(){return sk(this)}slice(e=0,t=this.length){return ok(this,e,t)}toJSON(){return this.map(e=>e instanceof dn?e.toJSON():e)}map(e){return lk(this,e)}forEach(e){Zl(this,e)}[Symbol.iterator](){return XO(this)}_write(e){e.writeTypeRef(CD)}}const tD=n=>new oa;class nD extends wf{constructor(e,t,r){super(e,t),this.keysChanged=r}}class Da extends dn{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 Da}clone(){const e=new Da;return this.forEach((t,r)=>{e.set(r,t instanceof dn?t.clone():t)}),e}_callObserver(e,t){kf(this,e,new nD(this,e,t))}toJSON(){this.doc??Tn();const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[r]=i instanceof dn?i.toJSON():i}}),e}get size(){return[...Wc(this)].length}keys(){return yh(Wc(this),e=>e[0])}values(){return yh(Wc(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return yh(Wc(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Tn(),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?St(this.doc,t=>{iu(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?St(this.doc,r=>{Tg(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return Ag(this,e)}has(e){return pk(this,e)}clear(){this.doc!==null?St(this.doc,e=>{this.forEach(function(t,r,i){iu(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(TD)}}const rD=n=>new Da,fo=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&c2(n,e);class Up{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&En(),this.right.content.constructor){case Qt:this.right.deleted||Ka(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 nb=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case Qt:e.right.deleted||Ka(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&Jn(n,Ke(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},Kc=(n,e,t,r)=>{const i=new Map,o=r?xf(e,t):null;if(o){const s=new Up(o.p.left,o.p,o.index,i);return nb(n,s,t-o.index)}else{const s=new Up(null,e._start,0,i);return nb(n,s,t)}},mk=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===Qt&&fo(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 Et(Ke(o,Jt(i.store,o)),l,l&&l.lastId,c,c&&c.id,e,null,new Qt(a,s));d.integrate(n,0),t.right=d,t.forward()})},Ka=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},gk=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===Qt&&fo(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},vk=(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(!fo(c,l)){s.set(a,c);const{left:d,right:u}=t;t.right=new Et(Ke(o,Jt(i.store,o)),d,d&&d.lastId,u,u&&u.id,e,null,new Qt(a,l)),t.right.integrate(n,0),t.forward()}}return s},xh=(n,e,t,r,i)=>{t.currentAttributes.forEach((h,p)=>{i[p]===void 0&&(i[p]=null)});const o=n.doc,s=o.clientID;gk(t,i);const a=vk(n,e,t,i),l=r.constructor===String?new Vr(r):r instanceof dn?new jr(r):new Ps(r);let{left:c,right:d,index:u}=t;e._searchMarker&&Yl(e._searchMarker,t.index,l.getLength()),d=new Et(Ke(s,Jt(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(),mk(n,e,t,a)},rb=(n,e,t,r,i)=>{const o=n.doc,s=o.clientID;gk(t,i);const a=vk(n,e,t,i);e:for(;t.right!==null&&(r>0||a.size>0&&(t.right.deleted||t.right.content.constructor===Qt));){if(!t.right.deleted)switch(t.right.content.constructor){case Qt:{const{key:l,value:c}=t.right.content,d=i[l];if(d!==void 0){if(fo(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&&Jn(n,Ke(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 Et(Ke(s,
|
|
49
|
-
`?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&xh(r,this,i,a,s.attributes||{})}else s.retain!==void 0?rb(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&ib(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??Tn();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(Vo(l,e)||t!==void 0&&Vo(l,t))switch(l.content.constructor){case Vr:{const u=o.get("ychange");e!==void 0&&!Vo(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&&!Vo(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 jr:case Ps:{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 Qt:Vo(l,e)&&(c(),Ka(o,l.content));break}l=l.right}c()};return e||t?St(s,u=>{e&&Hp(u,e),t&&Hp(u,t),d()},"cleanup"):d(),i}insert(e,t,r){if(t.length<=0)return;const i=this.doc;i!==null?St(i,o=>{const s=Kc(o,this,e,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),xh(o,this,s,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const i=this.doc;i!==null?St(i,o=>{const s=Kc(o,this,e,!r);xh(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?St(r,i=>{ib(i,Kc(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?St(i,o=>{const s=Kc(o,this,e,!1);s.right!==null&&rb(o,this,s,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?St(this.doc,t=>{iu(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?St(this.doc,r=>{Tg(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return Ag(this,e)}getAttributes(){return hk(this)}_write(e){e.writeTypeRef(AD)}}const lD=n=>new Eo;class kh{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Tn()}[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===Gt||t.constructor===Ss)&&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 Ss extends dn{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 Ss}clone(){const e=new Ss;return e.insert(0,this.toArray().map(t=>t instanceof dn?t.clone():t)),e}get length(){return this.doc??Tn(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new kh(this,e)}querySelector(e){e=e.toUpperCase();const r=new kh(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),To(new kh(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){kf(this,e,new uD(this,t,e))}toString(){return lk(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),Zl(this,o=>{i.insertBefore(o.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?St(this.doc,r=>{uk(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)St(this.doc,r=>{const i=e&&e instanceof dn?e._item:e;ru(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 fi("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?St(this.doc,r=>{fk(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return sk(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ck(this,e)}slice(e=0,t=this.length){return ok(this,e,t)}forEach(e){Zl(this,e)}_write(e){e.writeTypeRef(MD)}}const cD=n=>new Ss;class Gt extends Ss{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 Gt(this.nodeName)}clone(){const e=new Gt(this.nodeName),t=this.getAttributes();return a2(t,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof dn?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?St(this.doc,t=>{iu(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?St(this.doc,r=>{Tg(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return Ag(this,e)}hasAttribute(e){return pk(this,e)}getAttributes(e){return e?$O(this,e):hk(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 Zl(this,s=>{i.appendChild(s.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(ED),e.writeKey(this.nodeName)}}const dD=n=>new Gt(n.readKey());class uD extends wf{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 ou extends Da{constructor(e){super(),this.hookName=e}_copy(){return new ou(this.hookName)}clone(){const e=new ou(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(OD),e.writeKey(this.hookName)}}const fD=n=>new ou(n.readKey());class kn extends Eo{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 kn}clone(){const e=new kn;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(DD)}}const hD=n=>new kn;class Eg{constructor(e,t){this.id=e,this.length=t}get deleted(){throw kr()}mergeWith(e){return!1}write(e,t,r){throw kr()}integrate(e,t){throw kr()}}const pD=0;class gr extends Eg{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),Q1(e.doc.store,this)}write(e,t){e.writeInfo(pD),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Ec{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ec(this.content)}splice(e){throw kr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const mD=n=>new Ec(n.readBuf());class Gl{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Gl(this.len)}splice(e){const t=new Gl(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Wl(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 gD=n=>new Gl(n.readLen()),bk=(n,e)=>new hi({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Mc{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 Mc(bk(this.doc.guid,this.opts))}splice(e){throw kr()}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 vD=n=>new Mc(bk(n.readString(),n.readAny()));class Ps{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Ps(this.embed)}splice(e){throw kr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const yD=n=>new Ps(n.readJSON());class Qt{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Qt(this.key,this.value)}splice(e){throw kr()}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 bD=n=>new Qt(n.readKey(),n.readJSON());class su{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new su(this.arr)}splice(e){const t=new su(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 wD=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 su(t)},xD=Xd("node_env")==="development";class Cs{constructor(e){this.arr=e,xD&&h1(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Cs(this.arr)}splice(e){const t=new Cs(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 kD=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new Cs(t)};class Vr{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Vr(this.str)}splice(e){const t=new Vr(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 _D=n=>new Vr(n.readString()),SD=[tD,rD,lD,dD,cD,fD,hD],CD=0,TD=1,AD=2,ED=3,MD=4,OD=5,DD=6;class jr{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new jr(this.type._copy())}splice(e){throw kr()}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 RD=n=>new jr(SD[n.readTypeRef()](n)),jp=(n,e)=>{let t=e,r=0,i;do r>0&&(t=Ke(t.client,t.clock+r)),i=ia(n,t),r=t.clock-i.id.clock,t=i.redone;while(t!==null&&i instanceof Et);return{item:i,diff:r}},Mg=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},au=(n,e,t)=>{const{client:r,clock:i}=e.id,o=new Et(Ke(r,i+t),e,Ke(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=Ke(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},ob=(n,e)=>og(n,t=>ja(t.deletions,e)),wk=(n,e,t,r,i,o)=>{const s=n.doc,a=s.store,l=s.clientID,c=e.redone;if(c!==null)return Jn(n,c);let d=e.parent._item,u=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!t.has(d)||wk(n,d,t,r,i,o)===null))return null;for(;d.redone!==null;)d=Jn(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:Jn(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:Jn(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||ja(r,u.right.id)||ob(o.undoStack,u.right.id)||ob(o.redoStack,u.right.id));)for(u=u.right;u.redone;)u=Jn(n,u.redone);if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;const m=Jt(a,l),v=Ke(l,m),g=new Et(v,u,u&&u.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=v,Mg(g,!0),g.integrate(n,0),g};let Et=class Wp extends Eg{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()?Ny:0}set marker(e){(this.info&hh)>0!==e&&(this.info^=hh)}get marker(){return(this.info&hh)>0}get keep(){return(this.info&Ry)>0}set keep(e){this.keep!==e&&(this.info^=Ry)}get countable(){return(this.info&Ny)>0}get deleted(){return(this.info&fh)>0}set deleted(e){this.deleted!==e&&(this.info^=fh)}markDeleted(){this.info|=fh}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Jt(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Jt(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ra&&this.id.client!==this.parent.client&&this.parent.clock>=Jt(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Gy(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Jn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===gr||this.right&&this.right.constructor===gr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Wp?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Wp&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ra){const r=ia(t,this.parent);r.constructor===gr?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Gy(e,e.doc.store,Ke(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),Gs(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(Gs(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(ia(e.doc.store,i.origin)))o.has(ia(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),Q1(e.doc.store,this),this.content.integrate(e,this),Qy(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new gr(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:Ke(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Gs(e.origin,this.lastId)&&this.right===e&&Gs(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(),Wl(e.deleteSet,this.id.client,this.id.clock,this.length),Qy(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw En();this.content.gc(e),t?PO(e,this,new gr(this.id,this.length)):this.content=new Gl(this.length)}write(e,t){const r=t>0?Ke(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&uf|(r===null?0:Bn)|(i===null?0:Fi)|(o===null?0:Fl);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=Kl(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===ra?(e.writeParentInfo(!1),e.writeLeftID(a)):En();o!==null&&e.writeString(o)}this.content.write(e,t)}};const xk=(n,e)=>ND[e&uf](n),ND=[()=>{En()},gD,wD,mD,_D,yD,bD,RD,kD,vD,()=>{En()}],ID=10;class vr extends Eg{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){En()}write(e,t){e.writeInfo(ID),at(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const kk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},_k="__ $YJS$ __";kk[_k]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");kk[_k]=!0;function Og(n){return`${n}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Kp(){return Og("ann")}function LD(){return Og("msg")}function PD(n){return Og(n)}function Sk(n){return n?n+1:0}function _f(n){let e=0;return n.forEach(t=>{t.isText?e+=t.text.length:t.type.name==="hardBreak"&&(e+=1)}),e}function Oc(n){if(n.isTextblock)return _f(n);let e=0;for(let t=0;t<n.childCount;t++)t>0&&(e+=1),e+=Oc(n.child(t));return e}function Ck(n,e,t){if(n.isTextblock)return bn(t+Math.min(e,_f(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=Oc(s);if(r+l>e)return Ck(s,e-r,a);r+=l,i+=s.nodeSize}return bn(t+n.content.size)}function Mo(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"?Sk(s.attrs.level||1):0,c=Oc(s),d=l+c;if(t+d>e){const u=e-t,h=Math.max(0,u-l);return Ck(s,h,a)}if(t+=d,r+=s.nodeSize,o<i-1&&(t+=1,t>e))return bn(a+s.content.size)}return bn(n.content.size)}function Tk(n,e,t){if(n.isTextblock)return Math.min(e-t,_f(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+Tk(s,e,a);r+=Oc(s),i+=s.nodeSize}return r}function ri(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"?Sk(s.attrs.level||1):0,c=Oc(s),d=r+s.nodeSize;if(e<d)return e<=a?pd(t+l):pd(t+l+Tk(s,e,a));t+=l+c,r+=s.nodeSize,o<i-1&&(t+=1)}return pd(t)}function Ak(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 kn){if(l===r.type)return bn(t+Math.min(s+r.index,_f(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 Gt){const d=Ak(a,l,c,r);if(d!==null)return d}i+=l.nodeSize}return null}function sb(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 Gt){const c=Ak(s,a,l,t);if(c!==null)return c}r+=a.nodeSize}return null}function Ek(n,e,t){let r,i;try{const l=ds(t.fromRel),c=ds(t.toRel);r=Fp(l,n),i=Fp(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=sb(e,o,r),a=sb(e,o,i);return s===null||a===null?null:{from:s,to:a}}function lu(n,e,t){if(n.relRange&&t){const r=Ek(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:Mo(e,n.range.from),to:Mo(e,n.range.to),method:"flat"}:null}function Mk(n,e){return{from:ri(n,e.from),to:ri(n,e.to)}}function zD(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function BD(n){const e=zD(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 FD=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>'),HD=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>'),VD=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>'),UD=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>'),jD=E('<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>'),WD=E('<div class="chat-markdown svelte-15oag3v"></div>'),KD=E('<div style="white-space: pre-wrap; word-break: break-word;"> </div>'),qD=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>'),JD=E("<span></span>"),YD=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>'),ZD=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>'),GD=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 ab(n,e){qe(e,!0);const t=[0,.2,.4];let r=ft(e,"inputEl",15,null);const i=H(()=>e.reduceMotion?"auto":"smooth");let o=F(dt([])),s=F(""),a=F(void 0),l=F(void 0);de(()=>{r(f(l)??null)}),de(()=>{if(!e.ctrlYdoc)return;const w=e.ctrlYdoc.getMap(ry),M=()=>{const I=[];w.forEach(ae=>{I.push(ae)}),I.sort((ae,ve)=>ae.timestamp-ve.timestamp||ae.id.localeCompare(ve.id)),b(o,I,!0)};return w.observe(M),M(),()=>w.unobserve(M)});let c=!1;de(()=>{var I;f(o);const w=!!e.claudeActive,M=f(i);if(!w&&c){c=!1;return}c=w,(I=f(a))==null||I.scrollIntoView({behavior:M})}),de(()=>{var I;const w=e.visible,M=f(i);w&&((I=f(a))==null||I.scrollIntoView({behavior:M}))});const d=H(()=>f(o).filter(w=>w.author==="claude"&&!w.read).length);function u(){if(!e.ctrlYdoc||!f(s).trim())return;const w=e.ctrlYdoc.getMap(ry),M={id:LD(),author:"user",text:f(s).trim(),timestamp:Date.now(),...e.activeDocId?{documentId:e.activeDocId}:{},...e.capturedAnchor?{anchor:e.capturedAnchor}:{},read:!1};w.set(M.id,M),b(s,""),e.onCapturedAnchorChange(null)}function h(w){w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),u())}function p(w,M){if(!(!e.editor||M&&M!==e.activeDocId))try{const I=Mo(e.editor.state.doc,w.from),ae=Mo(e.editor.state.doc,w.to);e.editor.chain().focus().setTextSelection({from:I,to:ae}).scrollIntoView().run()}catch(I){console.warn("[ChatPanel] Could not scroll to anchor:",I instanceof Error?I.message:I)}}function m(w){if(!w)return null;const M=e.openDocs.find(I=>I.id===w);return(M==null?void 0:M.fileName)??null}async function v(){try{await fetch(`http://localhost:${kc}/api/chat`,{method:"DELETE"})}catch(w){console.warn("[ChatPanel] Failed to clear chat:",w)}}let g=F(dt(new Set));function y(w){const M=new Set(f(g));M.has(w)?M.delete(w):M.add(w),b(g,M,!0)}var k=GD(),S=x(k),C=_(x(S)),A=x(C);{var W=w=>{var M=FD(),I=x(M);Y(()=>te(I,f(d))),T(w,M)};J(A,w=>{f(d)>0&&w(W)})}var z=_(A,2);{var D=w=>{var M=HD();P("click",M,v),T(w,M)};J(z,w=>{f(o).length>0&&w(D)})}var O=_(S,2),U=x(O);{var ee=w=>{var M=VD();T(w,M)};J(U,w=>{f(o).length===0&&w(ee)})}var R=_(U,2);mt(R,17,()=>f(o),w=>w.id,(w,M)=>{var I=qD(),ae=x(I),ve=x(ae),ue=x(ve),le=_(ve,2);{var he=$=>{var Q=UD(),pe=x(Q);Y(fe=>te(pe,fe),[()=>m(f(M).documentId)??f(M).documentId]),T($,Q)};J(le,$=>{f(M).documentId&&$(he)})}var B=_(le,2),G=x(B),be=_(ae,2);{var Te=$=>{var Q=jD(),pe=x(Q);Y(fe=>{oe(Q,`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: ${fe??""}; overflow: hidden; transition: max-height 0.3s ease;`),te(pe,f(M).anchor.textSnapshot)},[()=>f(g).has(f(M).id)?"500px":"60px"]),P("click",Q,()=>p(f(M).anchor,f(M).documentId)),wt("mouseenter",Q,()=>y(f(M).id)),wt("mouseleave",Q,()=>y(f(M).id)),T($,Q)};J(be,$=>{f(M).anchor&&$(Te)})}var De=_(be,2);{var Ee=$=>{var Q=WD();mT(Q,()=>BD(f(M).text),!0),T($,Q)},se=$=>{var Q=KD(),pe=x(Q);Y(()=>te(pe,f(M).text)),T($,Q)};J(De,$=>{f(M).author==="claude"?$(Ee):$(se,-1)})}Y($=>{oe(I,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${f(M).author==="user"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; border: 1px solid ${f(M).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);`),oe(ve,`font-weight: 600; font-size: 11px; color: ${f(M).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"}; text-transform: uppercase;`),te(ue,f(M).author),te(G,$)},[()=>new Date(f(M).timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]),T(w,I)});var K=_(R,2);{var ne=w=>{var M=YD(),I=x(M);mt(I,20,()=>t,ue=>ue,(ue,le)=>{var he=JD();Y(()=>oe(he,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${le??""}s infinite;`)),T(ue,he)});var ae=_(I,2),ve=x(ae);Y(()=>te(ve,e.claudeStatus??"Claude is thinking...")),T(w,M)};J(K,w=>{e.claudeActive&&w(ne)})}var X=_(K,2);kt(X,w=>b(a,w),()=>f(a));var N=_(O,2);{var q=w=>{var M=ZD(),I=x(M),ae=x(I),ve=_(I,2);Y(ue=>te(ae,`with selection: “${ue??""}${e.capturedAnchor.textSnapshot.length>40?"...":""}”`),[()=>e.capturedAnchor.textSnapshot.slice(0,40)]),P("click",ve,()=>e.onCapturedAnchorChange(null)),T(w,M)};J(N,w=>{e.capturedAnchor&&w(q)})}var L=_(N,2),V=x(L);Z(V,"rows",2),kt(V,w=>b(l,w),()=>f(l));var re=_(V,2);Y((w,M,I,ae)=>{Pr(V,f(s)),re.disabled=w,oe(re,`padding: var(--tandem-space-2) var(--tandem-space-3); background: ${M??""}; color: ${I??""}; border: none; border-radius: var(--tandem-r-3); cursor: ${ae??""}; 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"]),P("input",V,w=>b(s,w.target.value,!0)),P("keydown",V,h),P("click",re,u),T(n,k),Je()}$e(["click","input","keydown"]);function Ra(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 XD=E('<button type="button" data-testid="apply-changes-btn"> </button>');function QD(n,e){qe(e,!0);let t=F(!1);const r=H(()=>e.annotations.filter(d=>d.status==="accepted")),i=H(()=>e.annotations.filter(d=>d.status==="pending")),o=H(()=>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?
|
|
47
|
+
${t.toString()}`)};class X2{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:jl(e),h:t}),this}else(e){return this.if(eu,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 fi("Unhandled pattern")}}}const Q2=n=>new X2(n),R1=Q2(eu).if(M1,(n,e)=>gh(e,Iy,Zd)).if(O1,(n,e)=>C2(e)).if(Y2,(n,e)=>jy(e)).if(J2,(n,e)=>BigInt(gh(e,Iy,Zd))).if($d,(n,e)=>Bs(e,vh(e,n.shape))).if(I2,(n,e)=>{const t={};for(const r in n.shape){let i=n.shape[r];if(D2.check(i)){if(jy(e))continue;i=i.shape}t[r]=R1(i,e)}return t}).if(B2,(n,e)=>{const t=[],r=v1(e,0,42);for(let i=0;i<r;i++)t.push(Bs(e,n.shape));return t}).if(y1,(n,e)=>vh(e,n.shape)).if(Z2,(n,e)=>null).if(j2,(n,e)=>{const t=Bs(e,n.res);return()=>t}).if(q2,(n,e)=>Bs(e,vh(e,[na,Ma,yf,D1,mg,vf,C1(na),k1(Va("a","b","c"),na)]))).if(P2,(n,e)=>{const t={},r=gh(e,0,3);for(let i=0;i<r;i++){const o=Bs(e,n.shape.keys),s=Bs(e,n.shape.values);t[o]=s}return t}).done(),Bs=(n,e)=>R1(jl(e),n),Cc=typeof document<"u"?document:{};hn(n=>n.nodeType===rO);typeof DOMParser<"u"&&new DOMParser;hn(n=>n.nodeType===eO);hn(n=>n.nodeType===tO);const $2=n=>mM(n,(e,t)=>`${t}:${e};`).join(""),eO=Cc.ELEMENT_NODE,tO=Cc.TEXT_NODE,nO=Cc.DOCUMENT_NODE,rO=Cc.DOCUMENT_FRAGMENT_NODE;hn(n=>n.nodeType===nO);const iO=n=>class{constructor(t){this._=t}destroy(){n(this._)}},oO=iO(clearTimeout),gg=(n,e)=>new oO(setTimeout(e,n)),Ji=Symbol,N1=Ji(),I1=Ji(),sO=Ji(),aO=Ji(),lO=Ji(),L1=Ji(),cO=Ji(),vg=Ji(),dO=Ji(),uO=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},fO={[N1]:xi("font-weight","bold"),[I1]:xi("font-weight","normal"),[sO]:xi("color","blue"),[lO]:xi("color","green"),[aO]:xi("color","grey"),[L1]:xi("color","red"),[cO]:xi("color","purple"),[vg]:xi("color","orange"),[dO]:xi("color","black")},hO=n=>{var s;n.length===1&&((s=n[0])==null?void 0:s.constructor)===Function&&(n=n[0]());const e=[],t=[],r=xr();let i=[],o=0;for(;o<n.length;o++){const a=n[o],l=fO[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=$2(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},P1=g2?hO:uO,pO=(...n)=>{console.log(...P1(n)),B1.forEach(e=>e.print(n))},z1=(...n)=>{console.warn(...P1(n)),n.unshift(vg),B1.forEach(e=>e.print(n))},B1=ks(),F1=n=>({[Symbol.iterator](){return this},next:n}),mO=(n,e)=>F1(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),yh=(n,e)=>F1(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class bf{constructor(e,t){this.clock=e,this.len=t}}class Ua{constructor(){this.clients=new Map}}const Ao=(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])$1(n,o,c.clock,c.len,t)}}),gO=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const i=Br((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},ja=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&gO(t,e.clock)!==null},yg=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 bf(i.clock,Fr(i.len,o.clock+o.len-i.clock)):(r<t&&(e[r]=o),r++)}e.length=r})},Bp=n=>{const e=new Ua;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++)vM(o,n[s].clients.get(i)||[]);e.clients.set(i,o)}});return yg(e),e},Wl=(n,e,t,r)=>{bi(n.clients,e,()=>[]).push(new bf(t,r))},H1=()=>new Ua,V1=n=>{const e=H1();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 bf(a,l))}}i.length>0&&e.clients.set(r,i)}),e},Wa=(n,e)=>{at(n.restEncoder,e.clients.size),To(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),at(n.restEncoder,t);const i=r.length;at(n.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];n.writeDsClock(s.clock),n.writeDsLen(s.len)}})},bg=n=>{const e=new Ua,t=nt(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const i=nt(n.restDecoder),o=nt(n.restDecoder);if(o>0){const s=bi(e.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new bf(n.readDsClock(),n.readDsLen()))}}return e},Ky=(n,e,t)=>{const r=new Ua,i=nt(n.restDecoder);for(let o=0;o<i;o++){n.resetDsCurVal();const s=nt(n.restDecoder),a=nt(n.restDecoder),l=t.clients.get(s)||[],c=Yt(t,s);for(let d=0;d<a;d++){const u=n.readDsClock(),h=u+n.readDsLen();if(u<c){c<h&&Wl(r,s,c,h-c);let p=Hr(l,u),m=l[p];for(!m.deleted&&m.id.clock<u&&(l.splice(p+1,0,au(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,au(e,m,h-m.id.clock)),m.delete(e))}else Wl(r,s,u,h-u)}}if(r.clients.size>0){const o=new _s;return at(o.restEncoder,0),Wa(o,r),o.toUint8Array()}return null},U1=c1;class hi extends i1{constructor({guid:e=e2(),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=U1(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new X1,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=Vy(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Vy(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&&St(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(To(this.subdocs).map(e=>e.guid))}transact(e,t=null){return St(this,e,t)}get(e,t=dn){const r=bi(this.share,e,()=>{const o=new t;return o._integrate(this,null),o}),i=r.constructor;if(t!==dn&&i!==t)if(i===dn){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,oa)}getText(e=""){return this.get(e,Eo)}getMap(e=""){return this.get(e,Da)}getXmlElement(e=""){return this.get(e,Gt)}getXmlFragment(e=""){return this.get(e,Ss)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,To(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new hi({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,St(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 j1{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return nt(this.restDecoder)}readDsLen(){return nt(this.restDecoder)}}class W1 extends j1{readLeftID(){return Ke(nt(this.restDecoder),nt(this.restDecoder))}readRightID(){return Ke(nt(this.restDecoder),nt(this.restDecoder))}readClient(){return nt(this.restDecoder)}readInfo(){return Aa(this.restDecoder)}readString(){return ta(this.restDecoder)}readParentInfo(){return nt(this.restDecoder)===1}readTypeRef(){return nt(this.restDecoder)}readLen(){return nt(this.restDecoder)}readAny(){return Vl(this.restDecoder)}readBuf(){return x2(Qn(this.restDecoder))}readJSON(){return JSON.parse(ta(this.restDecoder))}readKey(){return ta(this.restDecoder)}}class vO{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=nt(this.restDecoder),this.dsCurrVal}readDsLen(){const e=nt(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Oa extends vO{constructor(e){super(e),this.keys=[],nt(e),this.keyClockDecoder=new mh(Qn(e)),this.clientDecoder=new xd(Qn(e)),this.leftClockDecoder=new mh(Qn(e)),this.rightClockDecoder=new mh(Qn(e)),this.infoDecoder=new Hy(Qn(e),Aa),this.stringDecoder=new ZM(Qn(e)),this.parentInfoDecoder=new Hy(Qn(e),Aa),this.typeRefDecoder=new xd(Qn(e)),this.lenDecoder=new xd(Qn(e))}readLeftID(){return new ra(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ra(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Vl(this.restDecoder)}readBuf(){return Qn(this.restDecoder)}readJSON(){return Vl(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 K1{constructor(){this.restEncoder=Sc()}toUint8Array(){return Lr(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){at(this.restEncoder,e)}writeDsLen(e){at(this.restEncoder,e)}}class Tc extends K1{writeLeftID(e){at(this.restEncoder,e.client),at(this.restEncoder,e.clock)}writeRightID(e){at(this.restEncoder,e.client),at(this.restEncoder,e.clock)}writeClient(e){at(this.restEncoder,e)}writeInfo(e){Ip(this.restEncoder,e)}writeString(e){ea(this.restEncoder,e)}writeParentInfo(e){at(this.restEncoder,e?1:0)}writeTypeRef(e){at(this.restEncoder,e)}writeLen(e){at(this.restEncoder,e)}writeAny(e){Ta(this.restEncoder,e)}writeBuf(e){Xn(this.restEncoder,e)}writeJSON(e){ea(this.restEncoder,JSON.stringify(e))}writeKey(e){ea(this.restEncoder,e)}}class q1{constructor(){this.restEncoder=Sc(),this.dsCurrVal=0}toUint8Array(){return Lr(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,at(this.restEncoder,t)}writeDsLen(e){e===0&&En(),at(this.restEncoder,e-1),this.dsCurrVal+=e}}class _s extends q1{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ph,this.clientEncoder=new wd,this.leftClockEncoder=new ph,this.rightClockEncoder=new ph,this.infoEncoder=new zy(Ip),this.stringEncoder=new HM,this.parentInfoEncoder=new zy(Ip),this.typeRefEncoder=new wd,this.lenEncoder=new wd}toUint8Array(){const e=Sc();return at(e,0),Xn(e,this.keyClockEncoder.toUint8Array()),Xn(e,this.clientEncoder.toUint8Array()),Xn(e,this.leftClockEncoder.toUint8Array()),Xn(e,this.rightClockEncoder.toUint8Array()),Xn(e,Lr(this.infoEncoder)),Xn(e,this.stringEncoder.toUint8Array()),Xn(e,Lr(this.parentInfoEncoder)),Xn(e,this.typeRefEncoder.toUint8Array()),Xn(e,this.lenEncoder.toUint8Array()),ff(e,Lr(this.restEncoder)),Lr(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){Ta(this.restEncoder,e)}writeBuf(e){Xn(this.restEncoder,e)}writeJSON(e){Ta(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 yO=(n,e,t,r)=>{r=Fr(r,e[0].id.clock);const i=Hr(e,r);at(n.restEncoder,e.length-i),n.writeClient(t),at(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)},wg=(n,e,t)=>{const r=new Map;t.forEach((i,o)=>{Yt(e,o)>i&&r.set(o,i)}),Ac(e).forEach((i,o)=>{t.has(o)||r.set(o,0)}),at(n.restEncoder,r.size),To(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{yO(n,e.clients.get(i),i,o)})},bO=(n,e)=>{const t=xr(),r=nt(n.restDecoder);for(let i=0;i<r;i++){const o=nt(n.restDecoder),s=new Array(o),a=n.readClient();let l=nt(n.restDecoder);t.set(a,{i:0,refs:s});for(let c=0;c<o;c++){const d=n.readInfo();switch(uf&d){case 0:{const u=n.readLen();s[c]=new gr(Ke(a,l),u),l+=u;break}case 10:{const u=nt(n.restDecoder);s[c]=new vr(Ke(a,l),u),l+=u;break}default:{const u=(d&(Fi|Bn))===0,h=new Et(Ke(a,l),null,(d&Bn)===Bn?n.readLeftID():null,null,(d&Fi)===Fi?n.readRightID():null,u?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,u&&(d&Fl)===Fl?n.readString():null,xk(n,d));s[c]=h,l+=h.length}}}}return t},wO=(n,e,t)=>{const r=[];let i=To(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 X1,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!==vr){const m=bi(u,d.id.client,()=>Yt(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,Yt(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 _s;return wg(p,a,new Map),at(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},xO=(n,e)=>wg(n,e.doc.store,e.beforeState),kO=(n,e,t,r=new Oa(n))=>St(e,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=bO(r,s),c=wO(i,a,l),d=a.pendingStructs;if(d){for(const[h,p]of d.missing)if(p<Yt(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=nu([d.update,c.update])}}else a.pendingStructs=c;const u=Ky(r,i,a);if(a.pendingDs){const h=new Oa(Fa(a.pendingDs));nt(h.restDecoder);const p=Ky(h,i,a);u&&p?a.pendingDs=nu([u,p]):a.pendingDs=u||p}else a.pendingDs=u;if(o){const h=a.pendingStructs.update;a.pendingStructs=null,tu(i.doc,h)}},t,!1),tu=(n,e,t,r=Oa)=>{const i=Fa(e);kO(i,n,t,new r(i))},_O=(n,e,t)=>tu(n,e,t,W1),SO=(n,e,t=new Map)=>{wg(n,e.store,t),Wa(n,V1(e.store))},CO=(n,e=new Uint8Array([0]),t=new _s)=>{const r=J1(e);SO(t,n,r);const i=[t.toUint8Array()];if(n.store.pendingDs&&i.push(n.store.pendingDs),n.store.pendingStructs&&i.push(WO(n.store.pendingStructs.update,e)),i.length>1){if(t.constructor===Tc)return UO(i.map((o,s)=>s===0?o:qO(o)));if(t.constructor===_s)return nu(i)}return i[0]},TO=(n,e)=>CO(n,e,new Tc),AO=n=>{const e=new Map,t=nt(n.restDecoder);for(let r=0;r<t;r++){const i=nt(n.restDecoder),o=nt(n.restDecoder);e.set(i,o)}return e},J1=n=>AO(new j1(Fa(n))),Y1=(n,e)=>(at(n.restEncoder,e.size),To(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{at(n.restEncoder,t),at(n.restEncoder,r)}),n),EO=(n,e)=>Y1(n,Ac(e.store)),MO=(n,e=new q1)=>(n instanceof Map?Y1(e,n):EO(e,n),e.toUint8Array()),OO=n=>MO(n,new K1);class DO{constructor(){this.l=[]}}const qy=()=>new DO,Jy=(n,e)=>n.l.push(e),Yy=(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.")},Z1=(n,e,t)=>ug(n.l,[e,t]);class ra{constructor(e,t){this.client=e,this.clock=t}}const Gs=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,Ke=(n,e)=>new ra(n,e),Kl=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw En()},ql=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class Jl{constructor(e,t,r,i=0){this.type=e,this.tname=t,this.item=r,this.assoc=i}}const ds=n=>new Jl(n.type==null?null:Ke(n.type.client,n.type.clock),n.tname??null,n.item==null?null:Ke(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class RO{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const NO=(n,e,t=0)=>new RO(n,e,t),jc=(n,e,t)=>{let r=null,i=null;return n._item===null?i=Kl(n):r=Ke(n._item.id.client,n._item.id.clock),new Jl(r,i,e,t)},bh=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return jc(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return jc(n,Ke(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return jc(n,r.lastId,t);r=r.right}return jc(n,null,t)},IO=(n,e)=>{const t=ia(n,e),r=e.clock-t.id.clock;return{item:t,diff:r}},Fp=(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(Yt(r,i.client)<=i.clock)return null;const d=t?jp(r,i):IO(r,i),u=d.item;if(!(u instanceof Et))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(Yt(r,o.client)<=o.clock)return null;const{item:d}=t?jp(r,o):{item:ia(r,o)};if(d instanceof Et&&d.content instanceof jr)l=d.content.type;else return null}else throw En();a>=0?c=l._length:c=0}return NO(l,c,n.assoc)},Zy=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&Gs(n.item,e.item)&&Gs(n.type,e.type)&&n.assoc===e.assoc;class xg{constructor(e,t){this.ds=e,this.sv=t}}const G1=(n,e)=>new xg(n,e),wh=n=>G1(V1(n.store),Ac(n.store)),Vo=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!ja(e.ds,n.id),Hp=(n,e)=>{const t=bi(n.meta,Hp,ks),r=n.doc.store;t.has(e)||(e.sv.forEach((i,o)=>{i<Yt(r,o)&&Jn(n,Ke(o,i))}),Ao(n,e.ds,i=>{}),t.add(e))};class X1{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Ac=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},Yt=(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},Q1=(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 En()}t.push(e)},Hr=(n,e)=>{let t=0,r=n.length-1,i=n[r],o=i.id.clock;if(o===e)return r;let s=Br(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=Br((t+r)/2)}throw En()},LO=(n,e)=>{const t=n.clients.get(e.client);return t[Hr(t,e.clock)]},ia=LO,Vp=(n,e,t)=>{const r=Hr(e,t),i=e[r];return i.id.clock<t&&i instanceof Et?(e.splice(r+1,0,au(n,i,t-i.id.clock)),r+1):r},Jn=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[Vp(n,t,e.clock)]},Gy=(n,e,t)=>{const r=e.clients.get(t.client),i=Hr(r,t.clock),o=r[i];return t.clock!==o.id.clock+o.length-1&&o.constructor!==gr&&r.splice(i+1,0,au(n,o,t.clock-o.id.clock+1)),o},PO=(n,e,t)=>{const r=n.clients.get(e.id.client);r[Hr(r,e.id.clock)]=t},$1=(n,e,t,r,i)=>{if(r===0)return;const o=t+r;let s=Vp(n,e,t),a;do a=e[s++],o<a.id.clock+a.length&&Vp(n,e,o),i(a);while(s<e.length&&e[s].id.clock<o)};class zO{constructor(e,t,r){this.doc=e,this.deleteSet=new Ua,this.beforeState=Ac(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 Xy=(n,e)=>e.deleteSet.clients.size===0&&!gM(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(yg(e.deleteSet),xO(n,e),Wa(n,e.deleteSet),!0),Qy=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&bi(n.changed,e,ks).add(t)},_d=(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 Et&&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},BO=(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=Hr(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 Et&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},FO=(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=Bi(i.length-1,1+Hr(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+_d(i,l)}})},ek=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,i=r.store,o=t.deleteSet,s=t._mergeStructs;try{yg(o),t.afterState=Ac(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(()=>{Z1(c._dEH,l,t)}))}),a.push(()=>r.emit("afterTransaction",[t,r])),a.push(()=>{t._needFormattingCleanup&&sD(t)})}),ug(a,[])}finally{r.gc&&BO(o,i,r.gcFilter),FO(o,i),t.afterState.forEach((d,u)=>{const h=t.beforeState.get(u)||0;if(h!==d){const p=i.clients.get(u),m=Fr(Hr(p,h),1);for(let v=p.length-1;v>=m;)v-=1+_d(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=Hr(p,h);m+1<p.length&&_d(p,m+1)>1||m>0&&_d(p,m)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(pO(vg,N1,"[yjs] ",I1,L1,"Changed the client-id because another client seems to be using it."),r.clientID=U1()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const d=new Tc;Xy(d,t)&&r.emit("update",[d.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const d=new _s;Xy(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])):ek(n,e+1)}}},St=(n,e,t=null,r=!0)=>{const i=n._transactionCleanups;let o=!1,s=null;n._transaction===null&&(o=!0,n._transaction=new zO(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&&ek(i,0)}}return s};class HO{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const $y=(n,e,t)=>{Ao(n,t.deletions,r=>{r instanceof Et&&e.scope.some(i=>i===n.doc||ql(i,r))&&Mg(r,!1)})},eb=(n,e,t)=>{let r=null;const i=n.doc,o=n.scope;St(i,a=>{for(;e.length>0&&n.currStackItem===null;){const l=i.store,c=e.pop(),d=new Set,u=[];let h=!1;Ao(a,c.insertions,p=>{if(p instanceof Et){if(p.redone!==null){let{item:m,diff:v}=jp(l,p.id);v>0&&(m=Jn(a,Ke(m.id.client,m.id.clock+v))),p=m}!p.deleted&&o.some(m=>m===a.doc||ql(m,p))&&u.push(p)}}),Ao(a,c.deletions,p=>{p instanceof Et&&o.some(m=>m===a.doc||ql(m,p))&&!ja(c.insertions,p.id)&&d.add(p)}),d.forEach(p=>{h=wk(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 tk extends i1{constructor(e,{captureTimeout:t=500,captureTransaction:r=l=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:a=Ca(e)?e[0].doc:e instanceof hi?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 Ua;l.afterState.forEach((g,y)=>{const k=l.beforeState.get(y)||0,S=g-k;S>0&&Wl(h,y,k,S)});const p=t2();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=Bp([g.deletions,l.deleteSet]),g.insertions=Bp([g.insertions,h])}else u.push(new HO(l.deleteSet,h)),m=!0;!c&&!d&&(this.lastChange=p),Ao(l,l.deleteSet,g=>{g instanceof Et&&this.scope.some(y=>y===l.doc||ql(y,g))&&Mg(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=Ca(e)?e:[e],e.forEach(r=>{t.has(r)||(t.add(r),(r instanceof dn?r.doc!==this.doc:r!==this.doc)&&z1("[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=>$y(r,this,i)),this.undoStack=[]),t&&(this.redoStack.forEach(i=>$y(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=eb(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=eb(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*VO(n){const e=nt(n.restDecoder);for(let t=0;t<e;t++){const r=nt(n.restDecoder),i=n.readClient();let o=nt(n.restDecoder);for(let s=0;s<r;s++){const a=n.readInfo();if(a===10){const l=nt(n.restDecoder);yield new vr(Ke(i,o),l),o+=l}else if((uf&a)!==0){const l=(a&(Fi|Bn))===0,c=new Et(Ke(i,o),null,(a&Bn)===Bn?n.readLeftID():null,null,(a&Fi)===Fi?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(a&Fl)===Fl?n.readString():null,xk(n,a));yield c,o+=c.length}else{const l=n.readLen();yield new gr(Ke(i,o),l),o+=l}}}}class kg{constructor(e,t){this.gen=VO(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===vr);return this.curr}}class _g{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const UO=n=>nu(n,W1,Tc),jO=(n,e)=>{if(n.constructor===gr){const{client:t,clock:r}=n.id;return new gr(Ke(t,r+e),n.length-e)}else if(n.constructor===vr){const{client:t,clock:r}=n.id;return new vr(Ke(t,r+e),n.length-e)}else{const t=n,{client:r,clock:i}=t.id;return new Et(Ke(r,i+e),null,Ke(r,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},nu=(n,e=Oa,t=_s)=>{if(n.length===1)return n[0];const r=n.map(d=>new e(Fa(d)));let i=r.map(d=>new kg(d,!0)),o=null;const s=new t,a=new _g(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===vr?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)no(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===vr)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{no(a,o.struct,o.offset);const m=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new vr(Ke(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===vr?o.struct.length-=m:h=jO(h,m)),o.struct.mergeWith(h)||(no(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!==vr;h=d.next())no(a,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(no(a,o.struct,o.offset),o=null),Sg(a);const l=r.map(d=>bg(d)),c=Bp(l);return Wa(s,c),s.toUint8Array()},WO=(n,e,t=Oa,r=_s)=>{const i=J1(e),o=new r,s=new _g(o),a=new t(Fa(n)),l=new kg(a,!1);for(;l.curr;){const d=l.curr,u=d.id.client,h=i.get(u)||0;if(l.curr.constructor===vr){l.next();continue}if(d.id.clock+d.length>h)for(no(s,d,Fr(h-d.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)no(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()}Sg(s);const c=bg(a);return Wa(o,c),o.toUint8Array()},nk=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:Lr(n.encoder.restEncoder)}),n.encoder.restEncoder=Sc(),n.written=0)},no=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&nk(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),at(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},Sg=n=>{nk(n);const e=n.encoder.restEncoder;at(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];at(e,r.written),ff(e,r.restEncoder)}},KO=(n,e,t,r)=>{const i=new t(Fa(n)),o=new kg(i,!1),s=new r,a=new _g(s);for(let c=o.curr;c!==null;c=o.next())no(a,e(c),0);Sg(a);const l=bg(i);return Wa(s,l),s.toUint8Array()},qO=n=>KO(n,u2,Oa,Tc),tb="You must not compute changes after the event-handler fired.";class wf{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=JO(this.currentTarget,this.target))}deletes(e){return ja(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw fi(tb);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=uh(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",a=uh(l.content.getContent())):(s="add",a=void 0)}else if(this.deletes(o))s="delete",a=uh(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 fi(tb);const t=this.target,r=ks(),i=ks(),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 JO=(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},Tn=()=>{z1("Invalid access: Add Yjs type to a document before reading data.")},rk=80;let Cg=0;class YO{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Cg++}}const ZO=n=>{n.timestamp=Cg++},ik=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=Cg++},GO=(n,e,t)=>{if(n.length>=rk){const r=n.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return ik(r,e,t),r}else{const r=new YO(e,t);return n.push(r),r}},xf=(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)=>bd(e-o.index)<bd(e-s.index)?o:s);let r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,ZO(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&&bd(t.index-i)<r.parent.length/rk?(ik(t,r,i),t):GO(n._searchMarker,r,i)},Yl=(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=Fr(e,i.index+t))}},kf=(n,e,t)=>{const r=n,i=e.changedParentTypes;for(;bi(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;Z1(r._eH,t,e)};class dn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=qy(),this._dEH=qy(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw kr()}clone(){throw kr()}_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){Jy(this._eH,e)}observeDeep(e){Jy(this._dEH,e)}unobserve(e){Yy(this._eH,e)}unobserveDeep(e){Yy(this._dEH,e)}toJSON(){}}const ok=(n,e,t)=>{n.doc??Tn(),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},sk=n=>{n.doc??Tn();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},ak=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&Vo(r,e)){const i=r.content.getContent();for(let o=0;o<i.length;o++)t.push(i[o])}r=r.right}return t},Zl=(n,e)=>{let t=0,r=n._start;for(n.doc??Tn();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}},lk=(n,e)=>{const t=[];return Zl(n,(r,i)=>{t.push(e(r,i,n))}),t},XO=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}}}},ck=(n,e)=>{n.doc??Tn();const t=xf(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}},ru=(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 Et(Ke(s,Yt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Cs(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 Et(Ke(s,Yt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Ec(new Uint8Array(u))),i.integrate(n,0);break;case hi:i=new Et(Ke(s,Yt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Mc(u)),i.integrate(n,0);break;default:if(u instanceof dn)i=new Et(Ke(s,Yt(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new jr(u)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},dk=()=>fi("Length exceeded!"),uk=(n,e,t,r)=>{if(t>e._length)throw dk();if(t===0)return e._searchMarker&&Yl(e._searchMarker,t,r.length),ru(n,e,null,r);const i=t,o=xf(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&&Jn(n,Ke(s.id.client,s.id.clock+t));break}t-=s.length}return e._searchMarker&&Yl(e._searchMarker,i,r.length),ru(n,e,s,r)},QO=(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 ru(n,e,i,t)},fk=(n,e,t,r)=>{if(r===0)return;const i=t,o=r,s=xf(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&&Jn(n,Ke(a.id.client,a.id.clock+t)),t-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Jn(n,Ke(a.id.client,a.id.clock+r)),a.delete(n),r-=a.length),a=a.right;if(r>0)throw dk();e._searchMarker&&Yl(e._searchMarker,i,-o+r)},iu=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},Tg=(n,e,t,r)=>{const i=e._map.get(t)||null,o=n.doc,s=o.clientID;let a;if(r==null)a=new Cs([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new Cs([r]);break;case Uint8Array:a=new Ec(r);break;case hi:a=new Mc(r);break;default:if(r instanceof dn)a=new jr(r);else throw new Error("Unexpected content type")}new Et(Ke(s,Yt(o.store,s)),i,i&&i.lastId,null,null,e,t,a).integrate(n,0)},Ag=(n,e)=>{n.doc??Tn();const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},hk=n=>{const e={};return n.doc??Tn(),n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},pk=(n,e)=>{n.doc??Tn();const t=n._map.get(e);return t!==void 0&&!t.deleted},$O=(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&&Vo(o,e)&&(t[i]=o.content.getContent()[o.length-1])}),t},Wc=n=>(n.doc??Tn(),mO(n._map.entries(),e=>!e[1].deleted));class eD extends wf{}class oa extends dn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new oa;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new oa}clone(){const e=new oa;return e.insert(0,this.toArray().map(t=>t instanceof dn?t.clone():t)),e}get length(){return this.doc??Tn(),this._length}_callObserver(e,t){super._callObserver(e,t),kf(this,e,new eD(this,e))}insert(e,t){this.doc!==null?St(this.doc,r=>{uk(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?St(this.doc,t=>{QO(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?St(this.doc,r=>{fk(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return ck(this,e)}toArray(){return sk(this)}slice(e=0,t=this.length){return ok(this,e,t)}toJSON(){return this.map(e=>e instanceof dn?e.toJSON():e)}map(e){return lk(this,e)}forEach(e){Zl(this,e)}[Symbol.iterator](){return XO(this)}_write(e){e.writeTypeRef(CD)}}const tD=n=>new oa;class nD extends wf{constructor(e,t,r){super(e,t),this.keysChanged=r}}class Da extends dn{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 Da}clone(){const e=new Da;return this.forEach((t,r)=>{e.set(r,t instanceof dn?t.clone():t)}),e}_callObserver(e,t){kf(this,e,new nD(this,e,t))}toJSON(){this.doc??Tn();const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[r]=i instanceof dn?i.toJSON():i}}),e}get size(){return[...Wc(this)].length}keys(){return yh(Wc(this),e=>e[0])}values(){return yh(Wc(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return yh(Wc(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Tn(),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?St(this.doc,t=>{iu(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?St(this.doc,r=>{Tg(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return Ag(this,e)}has(e){return pk(this,e)}clear(){this.doc!==null?St(this.doc,e=>{this.forEach(function(t,r,i){iu(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(TD)}}const rD=n=>new Da,fo=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&c2(n,e);class Up{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&En(),this.right.content.constructor){case Qt:this.right.deleted||Ka(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 nb=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case Qt:e.right.deleted||Ka(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&Jn(n,Ke(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},Kc=(n,e,t,r)=>{const i=new Map,o=r?xf(e,t):null;if(o){const s=new Up(o.p.left,o.p,o.index,i);return nb(n,s,t-o.index)}else{const s=new Up(null,e._start,0,i);return nb(n,s,t)}},mk=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===Qt&&fo(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 Et(Ke(o,Yt(i.store,o)),l,l&&l.lastId,c,c&&c.id,e,null,new Qt(a,s));d.integrate(n,0),t.right=d,t.forward()})},Ka=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},gk=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===Qt&&fo(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},vk=(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(!fo(c,l)){s.set(a,c);const{left:d,right:u}=t;t.right=new Et(Ke(o,Yt(i.store,o)),d,d&&d.lastId,u,u&&u.id,e,null,new Qt(a,l)),t.right.integrate(n,0),t.forward()}}return s},xh=(n,e,t,r,i)=>{t.currentAttributes.forEach((h,p)=>{i[p]===void 0&&(i[p]=null)});const o=n.doc,s=o.clientID;gk(t,i);const a=vk(n,e,t,i),l=r.constructor===String?new Vr(r):r instanceof dn?new jr(r):new Ps(r);let{left:c,right:d,index:u}=t;e._searchMarker&&Yl(e._searchMarker,t.index,l.getLength()),d=new Et(Ke(s,Yt(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(),mk(n,e,t,a)},rb=(n,e,t,r,i)=>{const o=n.doc,s=o.clientID;gk(t,i);const a=vk(n,e,t,i);e:for(;t.right!==null&&(r>0||a.size>0&&(t.right.deleted||t.right.content.constructor===Qt));){if(!t.right.deleted)switch(t.right.content.constructor){case Qt:{const{key:l,value:c}=t.right.content,d=i[l];if(d!==void 0){if(fo(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&&Jn(n,Ke(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 Et(Ke(s,Yt(o.store,s)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new Vr(l)),t.right.integrate(n,0),t.forward()}mk(n,e,t,a)},yk=(n,e,t,r,i)=>{let o=e;const s=xr();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===Qt){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 Qt:{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&&Ka(i,c);break}}}e=e.right}return a},iD=(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===Qt){const r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},oD=n=>{let e=0;return St(n.doc,t=>{let r=n._start,i=n._start,o=xr();const s=Rp(o);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Qt:Ka(s,i.content);break;default:e+=yk(t,r,i,o,s),o=Rp(s),r=i;break}i=i.right}}),e},sD=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&&$1(n,t.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===Qt&&s.constructor!==gr&&e.add(s.parent)})}St(t,r=>{Ao(n,n.deleteSet,i=>{if(i instanceof gr||!i.parent._hasFormatting||e.has(i.parent))return;const o=i.parent;i.content.constructor===Qt?e.add(o):iD(r,i)});for(const i of e)oD(i)})},ib=(n,e,t)=>{const r=t,i=Rp(e.currentAttributes),o=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case jr:case Ps:case Vr:t<e.right.length&&Jn(n,Ke(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}o&&yk(n,o,e.right,i,e.currentAttributes);const s=(e.left||e.right).parent;return s._searchMarker&&Yl(s._searchMarker,e.index,-r+t),e};class aD extends wf{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=[];St(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},l2(l)||(p.attributes=s2({},l))),d=0;break}p&&t.push(p),a=null}};for(;s!==null;){switch(s.content.constructor){case jr:case Ps: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 Vr: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 Qt:{const{key:p,value:m}=s.content;if(this.adds(s)){if(!this.deletes(s)){const v=i.get(p)??null;fo(v,m)?m!==null&&s.delete(r):(a==="retain"&&h(),fo(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;fo(v,m)||(a==="retain"&&h(),l[p]=v)}else if(!s.deleted){o.set(p,m);const v=l[p];v!==void 0&&(fo(v,m)?v!==null&&s.delete(r):(a==="retain"&&h(),m===null?delete l[p]:l[p]=m))}s.deleted||(a==="insert"&&h(),Ka(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 Eo extends dn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Tn(),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 Eo}clone(){const e=new Eo;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const r=new aD(this,e,t);kf(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Tn();let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Vr&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?St(this.doc,r=>{const i=new Up(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)&&xh(r,this,i,a,s.attributes||{})}else s.retain!==void 0?rb(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&ib(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??Tn();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(Vo(l,e)||t!==void 0&&Vo(l,t))switch(l.content.constructor){case Vr:{const u=o.get("ychange");e!==void 0&&!Vo(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&&!Vo(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 jr:case Ps:{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 Qt:Vo(l,e)&&(c(),Ka(o,l.content));break}l=l.right}c()};return e||t?St(s,u=>{e&&Hp(u,e),t&&Hp(u,t),d()},"cleanup"):d(),i}insert(e,t,r){if(t.length<=0)return;const i=this.doc;i!==null?St(i,o=>{const s=Kc(o,this,e,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),xh(o,this,s,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const i=this.doc;i!==null?St(i,o=>{const s=Kc(o,this,e,!r);xh(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?St(r,i=>{ib(i,Kc(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?St(i,o=>{const s=Kc(o,this,e,!1);s.right!==null&&rb(o,this,s,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?St(this.doc,t=>{iu(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?St(this.doc,r=>{Tg(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return Ag(this,e)}getAttributes(){return hk(this)}_write(e){e.writeTypeRef(AD)}}const lD=n=>new Eo;class kh{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Tn()}[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===Gt||t.constructor===Ss)&&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 Ss extends dn{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 Ss}clone(){const e=new Ss;return e.insert(0,this.toArray().map(t=>t instanceof dn?t.clone():t)),e}get length(){return this.doc??Tn(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new kh(this,e)}querySelector(e){e=e.toUpperCase();const r=new kh(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),To(new kh(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){kf(this,e,new uD(this,t,e))}toString(){return lk(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),Zl(this,o=>{i.insertBefore(o.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?St(this.doc,r=>{uk(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)St(this.doc,r=>{const i=e&&e instanceof dn?e._item:e;ru(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 fi("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?St(this.doc,r=>{fk(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return sk(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ck(this,e)}slice(e=0,t=this.length){return ok(this,e,t)}forEach(e){Zl(this,e)}_write(e){e.writeTypeRef(MD)}}const cD=n=>new Ss;class Gt extends Ss{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 Gt(this.nodeName)}clone(){const e=new Gt(this.nodeName),t=this.getAttributes();return a2(t,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof dn?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?St(this.doc,t=>{iu(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?St(this.doc,r=>{Tg(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return Ag(this,e)}hasAttribute(e){return pk(this,e)}getAttributes(e){return e?$O(this,e):hk(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 Zl(this,s=>{i.appendChild(s.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(ED),e.writeKey(this.nodeName)}}const dD=n=>new Gt(n.readKey());class uD extends wf{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 ou extends Da{constructor(e){super(),this.hookName=e}_copy(){return new ou(this.hookName)}clone(){const e=new ou(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(OD),e.writeKey(this.hookName)}}const fD=n=>new ou(n.readKey());class kn extends Eo{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 kn}clone(){const e=new kn;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(DD)}}const hD=n=>new kn;class Eg{constructor(e,t){this.id=e,this.length=t}get deleted(){throw kr()}mergeWith(e){return!1}write(e,t,r){throw kr()}integrate(e,t){throw kr()}}const pD=0;class gr extends Eg{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),Q1(e.doc.store,this)}write(e,t){e.writeInfo(pD),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Ec{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ec(this.content)}splice(e){throw kr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const mD=n=>new Ec(n.readBuf());class Gl{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Gl(this.len)}splice(e){const t=new Gl(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Wl(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 gD=n=>new Gl(n.readLen()),bk=(n,e)=>new hi({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Mc{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 Mc(bk(this.doc.guid,this.opts))}splice(e){throw kr()}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 vD=n=>new Mc(bk(n.readString(),n.readAny()));class Ps{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Ps(this.embed)}splice(e){throw kr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const yD=n=>new Ps(n.readJSON());class Qt{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Qt(this.key,this.value)}splice(e){throw kr()}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 bD=n=>new Qt(n.readKey(),n.readJSON());class su{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new su(this.arr)}splice(e){const t=new su(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 wD=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 su(t)},xD=Xd("node_env")==="development";class Cs{constructor(e){this.arr=e,xD&&h1(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Cs(this.arr)}splice(e){const t=new Cs(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 kD=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new Cs(t)};class Vr{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Vr(this.str)}splice(e){const t=new Vr(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 _D=n=>new Vr(n.readString()),SD=[tD,rD,lD,dD,cD,fD,hD],CD=0,TD=1,AD=2,ED=3,MD=4,OD=5,DD=6;class jr{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new jr(this.type._copy())}splice(e){throw kr()}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 RD=n=>new jr(SD[n.readTypeRef()](n)),jp=(n,e)=>{let t=e,r=0,i;do r>0&&(t=Ke(t.client,t.clock+r)),i=ia(n,t),r=t.clock-i.id.clock,t=i.redone;while(t!==null&&i instanceof Et);return{item:i,diff:r}},Mg=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},au=(n,e,t)=>{const{client:r,clock:i}=e.id,o=new Et(Ke(r,i+t),e,Ke(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=Ke(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},ob=(n,e)=>og(n,t=>ja(t.deletions,e)),wk=(n,e,t,r,i,o)=>{const s=n.doc,a=s.store,l=s.clientID,c=e.redone;if(c!==null)return Jn(n,c);let d=e.parent._item,u=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!t.has(d)||wk(n,d,t,r,i,o)===null))return null;for(;d.redone!==null;)d=Jn(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:Jn(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:Jn(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||ja(r,u.right.id)||ob(o.undoStack,u.right.id)||ob(o.redoStack,u.right.id));)for(u=u.right;u.redone;)u=Jn(n,u.redone);if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;const m=Yt(a,l),v=Ke(l,m),g=new Et(v,u,u&&u.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=v,Mg(g,!0),g.integrate(n,0),g};let Et=class Wp extends Eg{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()?Ny:0}set marker(e){(this.info&hh)>0!==e&&(this.info^=hh)}get marker(){return(this.info&hh)>0}get keep(){return(this.info&Ry)>0}set keep(e){this.keep!==e&&(this.info^=Ry)}get countable(){return(this.info&Ny)>0}get deleted(){return(this.info&fh)>0}set deleted(e){this.deleted!==e&&(this.info^=fh)}markDeleted(){this.info|=fh}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Yt(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Yt(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ra&&this.id.client!==this.parent.client&&this.parent.clock>=Yt(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Gy(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Jn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===gr||this.right&&this.right.constructor===gr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Wp?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Wp&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ra){const r=ia(t,this.parent);r.constructor===gr?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Gy(e,e.doc.store,Ke(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),Gs(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(Gs(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(ia(e.doc.store,i.origin)))o.has(ia(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),Q1(e.doc.store,this),this.content.integrate(e,this),Qy(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new gr(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:Ke(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Gs(e.origin,this.lastId)&&this.right===e&&Gs(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(),Wl(e.deleteSet,this.id.client,this.id.clock,this.length),Qy(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw En();this.content.gc(e),t?PO(e,this,new gr(this.id,this.length)):this.content=new Gl(this.length)}write(e,t){const r=t>0?Ke(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&uf|(r===null?0:Bn)|(i===null?0:Fi)|(o===null?0:Fl);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=Kl(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===ra?(e.writeParentInfo(!1),e.writeLeftID(a)):En();o!==null&&e.writeString(o)}this.content.write(e,t)}};const xk=(n,e)=>ND[e&uf](n),ND=[()=>{En()},gD,wD,mD,_D,yD,bD,RD,kD,vD,()=>{En()}],ID=10;class vr extends Eg{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){En()}write(e,t){e.writeInfo(ID),at(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const kk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},_k="__ $YJS$ __";kk[_k]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");kk[_k]=!0;function Og(n){return`${n}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Kp(){return Og("ann")}function LD(){return Og("msg")}function PD(n){return Og(n)}function Sk(n){return n?n+1:0}function _f(n){let e=0;return n.forEach(t=>{t.isText?e+=t.text.length:t.type.name==="hardBreak"&&(e+=1)}),e}function Oc(n){if(n.isTextblock)return _f(n);let e=0;for(let t=0;t<n.childCount;t++)t>0&&(e+=1),e+=Oc(n.child(t));return e}function Ck(n,e,t){if(n.isTextblock)return bn(t+Math.min(e,_f(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=Oc(s);if(r+l>e)return Ck(s,e-r,a);r+=l,i+=s.nodeSize}return bn(t+n.content.size)}function Mo(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"?Sk(s.attrs.level||1):0,c=Oc(s),d=l+c;if(t+d>e){const u=e-t,h=Math.max(0,u-l);return Ck(s,h,a)}if(t+=d,r+=s.nodeSize,o<i-1&&(t+=1,t>e))return bn(a+s.content.size)}return bn(n.content.size)}function Tk(n,e,t){if(n.isTextblock)return Math.min(e-t,_f(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+Tk(s,e,a);r+=Oc(s),i+=s.nodeSize}return r}function ri(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"?Sk(s.attrs.level||1):0,c=Oc(s),d=r+s.nodeSize;if(e<d)return e<=a?pd(t+l):pd(t+l+Tk(s,e,a));t+=l+c,r+=s.nodeSize,o<i-1&&(t+=1)}return pd(t)}function Ak(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 kn){if(l===r.type)return bn(t+Math.min(s+r.index,_f(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 Gt){const d=Ak(a,l,c,r);if(d!==null)return d}i+=l.nodeSize}return null}function sb(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 Gt){const c=Ak(s,a,l,t);if(c!==null)return c}r+=a.nodeSize}return null}function Ek(n,e,t){let r,i;try{const l=ds(t.fromRel),c=ds(t.toRel);r=Fp(l,n),i=Fp(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=sb(e,o,r),a=sb(e,o,i);return s===null||a===null?null:{from:s,to:a}}function lu(n,e,t){if(n.relRange&&t){const r=Ek(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:Mo(e,n.range.from),to:Mo(e,n.range.to),method:"flat"}:null}function Mk(n,e){return{from:ri(n,e.from),to:ri(n,e.to)}}function zD(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function BD(n){const e=zD(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 FD=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>'),HD=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>'),VD=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>'),UD=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>'),jD=E('<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>'),WD=E('<div class="chat-markdown svelte-15oag3v"></div>'),KD=E('<div style="white-space: pre-wrap; word-break: break-word;"> </div>'),qD=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>'),JD=E("<span></span>"),YD=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>'),ZD=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>'),GD=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 ab(n,e){qe(e,!0);const t=[0,.2,.4];let r=ft(e,"inputEl",15,null);const i=H(()=>e.reduceMotion?"auto":"smooth");let o=F(dt([])),s=F(""),a=F(void 0),l=F(void 0);de(()=>{r(f(l)??null)}),de(()=>{if(!e.ctrlYdoc)return;const w=e.ctrlYdoc.getMap(ry),M=()=>{const I=[];w.forEach(ae=>{I.push(ae)}),I.sort((ae,ve)=>ae.timestamp-ve.timestamp||ae.id.localeCompare(ve.id)),b(o,I,!0)};return w.observe(M),M(),()=>w.unobserve(M)});let c=!1;de(()=>{var I;f(o);const w=!!e.claudeActive,M=f(i);if(!w&&c){c=!1;return}c=w,(I=f(a))==null||I.scrollIntoView({behavior:M})}),de(()=>{var I;const w=e.visible,M=f(i);w&&((I=f(a))==null||I.scrollIntoView({behavior:M}))});const d=H(()=>f(o).filter(w=>w.author==="claude"&&!w.read).length);function u(){if(!e.ctrlYdoc||!f(s).trim())return;const w=e.ctrlYdoc.getMap(ry),M={id:LD(),author:"user",text:f(s).trim(),timestamp:Date.now(),...e.activeDocId?{documentId:e.activeDocId}:{},...e.capturedAnchor?{anchor:e.capturedAnchor}:{},read:!1};w.set(M.id,M),b(s,""),e.onCapturedAnchorChange(null)}function h(w){w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),u())}function p(w,M){if(!(!e.editor||M&&M!==e.activeDocId))try{const I=Mo(e.editor.state.doc,w.from),ae=Mo(e.editor.state.doc,w.to);e.editor.chain().focus().setTextSelection({from:I,to:ae}).scrollIntoView().run()}catch(I){console.warn("[ChatPanel] Could not scroll to anchor:",I instanceof Error?I.message:I)}}function m(w){if(!w)return null;const M=e.openDocs.find(I=>I.id===w);return(M==null?void 0:M.fileName)??null}async function v(){try{await fetch(`http://localhost:${kc}/api/chat`,{method:"DELETE"})}catch(w){console.warn("[ChatPanel] Failed to clear chat:",w)}}let g=F(dt(new Set));function y(w){const M=new Set(f(g));M.has(w)?M.delete(w):M.add(w),b(g,M,!0)}var k=GD(),S=x(k),C=_(x(S)),A=x(C);{var W=w=>{var M=FD(),I=x(M);Y(()=>te(I,f(d))),T(w,M)};J(A,w=>{f(d)>0&&w(W)})}var z=_(A,2);{var D=w=>{var M=HD();P("click",M,v),T(w,M)};J(z,w=>{f(o).length>0&&w(D)})}var O=_(S,2),U=x(O);{var ee=w=>{var M=VD();T(w,M)};J(U,w=>{f(o).length===0&&w(ee)})}var R=_(U,2);mt(R,17,()=>f(o),w=>w.id,(w,M)=>{var I=qD(),ae=x(I),ve=x(ae),ue=x(ve),le=_(ve,2);{var he=$=>{var Q=UD(),pe=x(Q);Y(fe=>te(pe,fe),[()=>m(f(M).documentId)??f(M).documentId]),T($,Q)};J(le,$=>{f(M).documentId&&$(he)})}var B=_(le,2),G=x(B),be=_(ae,2);{var Te=$=>{var Q=jD(),pe=x(Q);Y(fe=>{se(Q,`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: ${fe??""}; overflow: hidden; transition: max-height 0.3s ease;`),te(pe,f(M).anchor.textSnapshot)},[()=>f(g).has(f(M).id)?"500px":"60px"]),P("click",Q,()=>p(f(M).anchor,f(M).documentId)),wt("mouseenter",Q,()=>y(f(M).id)),wt("mouseleave",Q,()=>y(f(M).id)),T($,Q)};J(be,$=>{f(M).anchor&&$(Te)})}var De=_(be,2);{var Ee=$=>{var Q=WD();mT(Q,()=>BD(f(M).text),!0),T($,Q)},oe=$=>{var Q=KD(),pe=x(Q);Y(()=>te(pe,f(M).text)),T($,Q)};J(De,$=>{f(M).author==="claude"?$(Ee):$(oe,-1)})}Y($=>{se(I,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${f(M).author==="user"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; border: 1px solid ${f(M).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);`),se(ve,`font-weight: 600; font-size: 11px; color: ${f(M).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"}; text-transform: uppercase;`),te(ue,f(M).author),te(G,$)},[()=>new Date(f(M).timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]),T(w,I)});var K=_(R,2);{var ne=w=>{var M=YD(),I=x(M);mt(I,20,()=>t,ue=>ue,(ue,le)=>{var he=JD();Y(()=>se(he,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${le??""}s infinite;`)),T(ue,he)});var ae=_(I,2),ve=x(ae);Y(()=>te(ve,e.claudeStatus??"Claude is thinking...")),T(w,M)};J(K,w=>{e.claudeActive&&w(ne)})}var X=_(K,2);kt(X,w=>b(a,w),()=>f(a));var N=_(O,2);{var q=w=>{var M=ZD(),I=x(M),ae=x(I),ve=_(I,2);Y(ue=>te(ae,`with selection: “${ue??""}${e.capturedAnchor.textSnapshot.length>40?"...":""}”`),[()=>e.capturedAnchor.textSnapshot.slice(0,40)]),P("click",ve,()=>e.onCapturedAnchorChange(null)),T(w,M)};J(N,w=>{e.capturedAnchor&&w(q)})}var L=_(N,2),V=x(L);Z(V,"rows",2),kt(V,w=>b(l,w),()=>f(l));var re=_(V,2);Y((w,M,I,ae)=>{Pr(V,f(s)),re.disabled=w,se(re,`padding: var(--tandem-space-2) var(--tandem-space-3); background: ${M??""}; color: ${I??""}; border: none; border-radius: var(--tandem-r-3); cursor: ${ae??""}; 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"]),P("input",V,w=>b(s,w.target.value,!0)),P("keydown",V,h),P("click",re,u),T(n,k),Je()}$e(["click","input","keydown"]);function Ra(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 XD=E('<button type="button" data-testid="apply-changes-btn"> </button>');function QD(n,e){qe(e,!0);let t=F(!1);const r=H(()=>e.annotations.filter(d=>d.status==="accepted")),i=H(()=>e.annotations.filter(d=>d.status==="pending")),o=H(()=>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
50
|
|
|
51
51
|
The changes will appear as tracked revisions in Word — you can Accept or Reject each one individually.
|
|
52
52
|
|
|
@@ -54,10 +54,10 @@ Your original file will be backed up.`;if(f(i).length>0&&(d+=`
|
|
|
54
54
|
|
|
55
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(`${Tr}/apply-changes`,{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
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=Rt(),l=ze(a);{var c=d=>{var u=XD(),h=x(u);Y(()=>{u.disabled=f(o),Z(u,"title",f(r).length===0?"No accepted suggestions to apply":void 0),oe(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;`),te(h,f(t)?"Applying…":`Apply as Tracked Changes (${f(r).length})`)}),P("click",u,s),T(d,u)};J(l,d=>{e.activeDocFormat==="docx"&&d(c)})}T(n,a),Je()}$e(["click"]);const Fo={background:"var(--tandem-warning-bg)",border:"var(--tandem-warning-border)",color:"var(--tandem-warning-fg-strong)"};var $D=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>'),eR=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>'),tR=E('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),nR=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>'),rR=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>'),iR=E('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),oR=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>'),sR=E(`<div style="font-size: var(--tandem-text-xs); color: var(--tandem-error-fg); margin-top: 2px;">Can't undo — text has changed.</div>`),aR=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 lR(n,e){qe(e,!0);let t=F(!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))}yi(i);var s=Rt(),a=ze(s);{var l=h=>{var p=tR(),m=x(p);{var v=k=>{var S=$D();Y(()=>Z(S,"data-testid",`accept-btn-${e.annotationId??""}`)),P("click",S,C=>{C.stopPropagation(),e.onAccept(e.annotationId)}),T(k,S)};J(m,k=>{e.onAccept&&k(v)})}var g=_(m,2);{var y=k=>{var S=eR();Y(()=>Z(S,"data-testid",`dismiss-btn-${e.annotationId??""}`)),P("click",S,C=>{C.stopPropagation(),e.onDismiss(e.annotationId)}),T(k,S)};J(g,k=>{e.onDismiss&&k(y)})}T(h,p)},c=h=>{var p=iR(),m=x(p);{var v=k=>{var S=nR();Y(()=>Z(S,"data-testid",`archive-btn-${e.annotationId??""}`)),P("click",S,C=>{C.stopPropagation(),e.onRemove(e.annotationId)}),T(k,S)};J(m,k=>{e.onRemove&&k(v)})}var g=_(m,2);{var y=k=>{var S=rR();Y(()=>Z(S,"data-testid",`send-to-claude-btn-${e.annotationId??""}`)),P("click",S,C=>{C.stopPropagation(),e.onSendToClaude(e.annotationId)}),T(k,S)};J(g,k=>{e.onSendToClaude&&k(y)})}T(h,p)},d=h=>{var p=oR();Y(()=>Z(p,"data-testid",`remove-btn-${e.annotationId??""}`)),P("click",p,m=>{m.stopPropagation(),e.onRemove(e.annotationId)}),T(h,p)},u=h=>{var p=aR(),m=x(p),v=_(m,2);{var g=y=>{var k=sR();T(y,k)};J(v,y=>{f(t)&&y(g)})}P("click",m,o),T(h,p)};J(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)})}T(n,s),Je()}$e(["click"]);const Sd="width: 100%; padding: 4px 6px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); resize: vertical; font-family: inherit; min-height: 40px; box-sizing: border-box; background: var(--tandem-surface); color: var(--tandem-fg);";var cR=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),dR=E("<textarea></textarea>"),uR=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 fR(n,e){qe(e,!0);let t=F(null);de(()=>{var d;(d=f(t))==null||d.focus()});var r=uR(),i=x(r);{var o=d=>{var u=cR(),h=ze(u),p=_(h,2);kt(p,g=>b(t,g),()=>f(t));var m=_(p,2),v=_(m,2);Y(()=>{Z(h,"for",`edit-newtext-${e.annotationId??""}`),Z(p,"id",`edit-newtext-${e.annotationId??""}`),Z(p,"data-testid",`edit-newtext-${e.annotationId??""}`),Pr(p,e.editNewText),oe(p,Sd),Z(m,"for",`edit-reason-${e.annotationId??""}`),Z(v,"id",`edit-reason-${e.annotationId??""}`),Z(v,"data-testid",`edit-reason-${e.annotationId??""}`),Pr(v,e.editReason),oe(v,Sd)}),P("input",p,g=>e.onChangeEditNewText(g.target.value)),P("keydown",p,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),P("input",v,g=>e.onChangeEditReason(g.target.value)),P("keydown",v,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),T(d,u)},s=d=>{var u=dR();kt(u,h=>b(t,h),()=>f(t)),Y(()=>{Z(u,"data-testid",`edit-text-${e.annotationId??""}`),Pr(u,e.editText),oe(u,Sd)}),P("input",u,h=>e.onChangeEditText(h.target.value)),P("keydown",u,function(...h){var p;(p=e.onKeyDown)==null||p.apply(this,h)}),T(d,u)};J(i,d=>{e.hasSuggestedText?d(o):d(s,-1)})}var a=_(i,2),l=x(a),c=_(l,2);Y(()=>{Z(l,"data-testid",`edit-save-btn-${e.annotationId??""}`),Z(c,"data-testid",`edit-cancel-btn-${e.annotationId??""}`)}),P("click",r,d=>d.stopPropagation()),P("keydown",r,d=>d.stopPropagation()),P("click",l,d=>{d.stopPropagation(),e.onSave()}),P("click",c,d=>{d.stopPropagation(),e.onCancel()}),T(n,r),Je()}$e(["click","keydown","input"]);var hR=E('<span style="font-style: italic; margin-right: 4px;">(edited)</span>'),pR=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>'),mR=E('<div data-testid="comment-thread" style="margin-top: 6px; padding-left: 8px; border-left: 2px solid var(--tandem-border);"></div>');function gR(n,e){qe(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=Rt(),i=ze(r);{var o=s=>{var a=mR();mt(a,21,()=>e.replies,l=>l.id,(l,c)=>{var d=pR(),u=x(d),h=x(u),p=x(h),m=_(h,2),v=x(m);{var g=C=>{var A=hR();T(C,A)};J(v,C=>{f(c).editedAt&&C(g)})}var y=_(v),k=_(u,2),S=x(k);Y(C=>{Z(d,"data-testid",`reply-${f(c).id??""}`),oe(h,`font-weight: 600; font-size: 11px; color: ${f(c).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};`),te(p,f(c).author==="claude"?"Claude":"You"),te(y,` ${C??""}`),te(S,f(c).text)},[()=>t(f(c).timestamp)]),T(l,d)}),T(s,a)};J(i,s=>{e.replies.length>0&&s(o)})}T(n,r),Je()}var vR=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>'),yR=E('<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;"> </button>'),bR=E('<div style="margin-top: 6px;"><!></div>'),wR=E('<div style="margin-top: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </div>'),xR=E("<!> <!> <!>",1);function kR(n,e){qe(e,!0);let t=F(!1),r=F(""),i=F(!1),o=F(null);const s=H(()=>!!f(r).trim());de(()=>{var v;f(t)&&((v=f(o))==null||v.focus())});function a(v){v.key==="Escape"&&(v.stopPropagation(),b(t,!1),b(r,""))}async function l(){var g;const v=f(r).trim();if(!(!v||f(i))){b(i,!0);try{await((g=e.onReply)==null?void 0:g.call(e,e.annotationId,v))!==!1&&(b(r,""),b(t,!1))}finally{b(i,!1)}}}var c=xR(),d=ze(c);gR(d,{get replies(){return e.replies}});var u=_(d,2);{var h=v=>{var g=bR(),y=x(g);{var k=C=>{var A=vR(),W=x(A);kt(W,U=>b(o,U),()=>f(o));var z=_(W,2),D=x(z),O=_(D,2);Y(()=>{Z(W,"data-testid",`reply-input-${e.annotationId??""}`),Pr(W,f(r)),oe(W,Sd),Z(D,"data-testid",`reply-send-btn-${e.annotationId??""}`),D.disabled=!f(s)||f(i),oe(D,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${f(s)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${f(s)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${f(s)?"pointer":"default"};`),Z(O,"data-testid",`reply-cancel-btn-${e.annotationId??""}`)}),P("input",W,U=>b(r,U.target.value,!0)),P("keydown",W,a),P("click",D,l),P("click",O,()=>{b(t,!1),b(r,"")}),T(C,A)},S=C=>{var A=yR(),W=x(A);Y(()=>{Z(A,"data-testid",`reply-btn-${e.annotationId??""}`),te(W,`Reply${e.replies.length>0?` (${e.replies.length})`:""}`)}),P("click",A,()=>b(t,!0)),T(C,A)};J(y,C=>{f(t)?C(k):C(S,-1)})}P("click",g,C=>C.stopPropagation()),P("keydown",g,C=>C.stopPropagation()),T(v,g)};J(u,v=>{e.isPending&&e.onReply&&!e.isEditing&&v(h)})}var p=_(u,2);{var m=v=>{var g=wR(),y=x(g);Y(()=>te(y,`${e.replies.length??""}
|
|
58
|
-
${e.replies.length===1?"reply":"replies"}`)),T(v,g)};J(p,v=>{!e.isPending&&e.replies.length>0&&!e.onReply&&v(m)})}T(n,c),Je()}$e(["click","keydown","input"]);var _R=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>'),SR=E("<span> </span>"),CR=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>`),TR=E('<span style="font-style: italic; font-size: 10px; color: var(--tandem-fg-subtle);">(edited)</span>'),AR=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>'),ER=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>'),MR=E('<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>'),OR=E('<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> <!>',1),DR=E('<p style="margin: 0;"> </p>'),RR=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><!></div>'),NR=E('<div role="listitem"><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-3ascys"> </span> <!> <!> <!></span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); display: flex; align-items: center; gap: 4px;"><!> </span></div> <!> <!> <!> <!></div>');function lb(n,e){qe(e,!0);let t=ft(e,"replies",19,()=>[]),r=F(!1),i=F(""),o=F(""),s=F("");const a=H(()=>e.annotation.status==="pending"),l=H(()=>e.annotation.suggestedText!==void 0);function c(B){return B.suggestedText!==void 0?"replacement":B.type}function d(B){return B==="claude"?"Claude":B==="import"?"Imported":"You"}function u(B){return B.color?Il[sx(B.color)]:B.suggestedText!==void 0?"var(--tandem-suggestion)":B.type==="note"?"var(--tandem-warning)":"var(--tandem-author-user)"}function h(B,G){return G?"var(--tandem-accent-bg)":(B.type==="note","var(--tandem-surface)")}const p=H(()=>c(e.annotation)),m=H(()=>u(e.annotation)),v=H(()=>h(e.annotation,e.isReviewTarget)),g=H(()=>e.annotation.type==="note"),y=H(()=>e.annotation.content?e.annotation.content.length>60?e.annotation.content.slice(0,57)+"...":e.annotation.content:""),k=H(()=>`${f(g)?"private ":""}${f(p)} annotation${f(y)?": "+f(y):""}, ${e.annotation.status}`);function S(){f(l)?(b(o,e.annotation.suggestedText??"",!0),b(s,e.annotation.content,!0)):b(i,e.annotation.content,!0),b(r,!0)}function C(){var G;const B=f(l)?JSON.stringify({suggestedText:f(o),content:f(s)}):f(i);(G=e.onEdit)==null||G.call(e,e.annotation.id,B),b(r,!1)}function A(){b(r,!1)}function W(B){B.key==="Escape"&&(B.stopPropagation(),A())}var z=NR(),D=x(z),O=x(D),U=x(O),ee=x(U),R=_(U,2);{var K=B=>{var G=_R();T(B,G)};J(R,B=>{f(g)&&B(K)})}var ne=_(R,2);{var X=B=>{var G=SR(),be=x(G);Y(()=>{
|
|
59
|
-
${f(i)??""}`),
|
|
60
|
-
won't be saved. Close the other instance and restart.</span> <button data-testid="store-readonly-dismiss" class="svelte-l26r3u">Dismiss</button></div>`),JR=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>'),YR=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>'),ZR=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>'),GR=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>'),XR=E('<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>'),QR=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 db(n,e){qe(e,!0);let t=ft(e,"heldCount",3,0),r=ft(e,"storeReadOnly",3,!1);const i=H(()=>e.reduceMotion?"auto":"smooth"),o="tandem:storeReadOnlyBannerDismissed";function s(){try{return localStorage.getItem(o)==="true"}catch{return!1}}let a=F(dt(s()));de(()=>{if(!r()){b(a,!1);try{localStorage.removeItem(o)}catch{}}});function l(){try{localStorage.setItem(o,"true")}catch{}b(a,!0)}let c=F("all"),d=F("all"),u=F("all"),h=F(!1),p=F(null),m=F(void 0),v=F(null);de(()=>{var B;f(p)&&((B=f(v))==null||B.focus())}),de(()=>{f(c),f(d),f(u),b(p,null)}),de(()=>{var B;(B=e.onFilterChange)==null||B.call(e,f(c),f(d),f(u))});let g=F(dt(new Map));de(()=>{if(!e.ydoc){b(g,new Map,!0);return}const B=e.ydoc.getMap(pA);function G(){const be=new Map;B.forEach(Te=>{const De=Te;if(De&&typeof De=="object"&&De.annotationId){const Ee=be.get(De.annotationId)??[];Ee.push(De),be.set(De.annotationId,Ee)}});for(const Te of be.values())Te.sort((De,Ee)=>De.timestamp-Ee.timestamp);b(g,be,!0)}return G(),B.observe(G),()=>B.unobserve(G)});const y=H(()=>{const B=[],G=[];for(const se of e.annotations){se.status==="pending"&&G.push(se);let $;f(c)==="all"?$=!0:f(c)==="with-replacement"?$=se.suggestedText!==void 0:$=se.type===f(c);const Q=f(d)==="all"||se.author===f(d),pe=f(u)==="all"||se.status===f(u);$&&Q&&pe&&B.push(se)}const be=B.filter(se=>se.status==="pending"),Te=B.filter(Hd),De=B.filter(se=>se.status!=="pending"),Ee=e.annotations.filter(Hd);return{filtered:B,pending:be,reviewPending:Te,resolved:De,allPending:G,reviewAllPending:Ee}}),k=H(()=>f(c)!=="all"||f(d)!=="all"||f(u)!=="all"),S=KR({getYdoc:()=>e.ydoc,getEditor:()=>e.editor,getAnnotations:()=>e.annotations,onActiveAnnotationChange:B=>e.onActiveAnnotationChange(B),getScrollBehavior:()=>f(i)});let C=!1;de(()=>{if(f(c),f(d),f(u),!C){C=!0;return}Yt(()=>{var B;if(e.activeAnnotationId){const G=document.querySelector(`[data-testid="annotation-card-${e.activeAnnotationId}"]`);if(G){G.scrollIntoView({block:"center"});return}console.warn(`[tandem] SidePanel: active annotation ${e.activeAnnotationId} not found on filter change; scrolling to top`)}(B=f(m))==null||B.scrollTo({top:0})})}),de(()=>{const B=e.activeAnnotationId;if(!B)return;const G=f(i),be=setTimeout(()=>{const Te=document.querySelector(`[data-testid="annotation-card-${B}"]`);if(Te){Te.scrollIntoView({behavior:G,block:"nearest"}),Te.classList.add("tandem-annotation-flash");const De=()=>Te.classList.remove("tandem-annotation-flash");Te.addEventListener("animationend",De,{once:!0})}else console.warn(`[tandem] SidePanel: active annotation ${B} not found after 50ms delay; scroll-to-card skipped`)},50);return()=>clearTimeout(be)});function A(B,G){if(!e.ydoc)return;const be=e.ydoc.getMap(So),Te=be.get(B);if(!Te)return;const De=Ra(Te,Ee=>{console.warn("[sanitize]",Ee)});if(De.suggestedText!==void 0){try{const Ee=JSON.parse(G);be.set(B,{...De,suggestedText:Ee.suggestedText,content:Ee.content,editedAt:Date.now()})}catch{console.warn(`[SidePanel] Failed to parse edit payload for annotation ${B}`)}return}be.set(B,{...De,content:G,editedAt:Date.now()})}function W(B){if(!e.ydoc)return;const G=e.ydoc.getMap(So),be=G.get(B);if(!be)return;const Te=Ra(be,De=>{console.warn("[sanitize]",De)});G.set(B,{...Te,type:"comment"})}async function z(B){try{const G=await fetch(`${Tr}/remove-annotation`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:B,documentId:e.documentId})});if(!G.ok){const be=await G.json().catch(()=>({message:"Unknown error"}));console.error("[Tandem] Remove annotation failed:",be)}}catch(G){console.error("[Tandem] Remove annotation failed:",G)}}async function D(B,G){try{const be=await fetch(`${Tr}/annotation-reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:B,text:G,documentId:e.documentId})});if(!be.ok){const Te=await be.json().catch(()=>({}));return console.warn(`[SidePanel] Reply failed (${be.status}): ${Te.message??"unknown error"}`),!1}return!0}catch(be){return console.error("[SidePanel] Reply request failed:",be),!1}}function O(B){for(const G of f(y).reviewPending)S.resolveAnnotation(G.id,B);b(p,null)}var U=QR(),ee=x(U);{var R=B=>{var G=qR(),be=_(x(G),2);Y(()=>{oe(G,`padding: 10px 14px; margin: 10px 14px 0; background: ${Fo.background}; border: 1px solid ${Fo.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${Fo.color}; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;`),oe(be,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${Fo.color}; cursor: pointer; font-weight: 500;`)}),P("click",be,l),T(B,G)};J(ee,B=>{r()&&!f(a)&&B(R)})}var K=_(ee,2);{var ne=B=>{var G=JR(),be=x(G),Te=x(be),De=_(be,2);Y(()=>{oe(G,`padding: 10px 14px; margin: 10px 14px 0; background: ${Fo.background}; border: 1px solid ${Fo.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${Fo.color}; display: flex; justify-content: space-between; align-items: center; gap: 10px;`),te(Te,`${t()??""} annotation${t()!==1?"s":""} held`)}),P("click",De,()=>{var Ee;return(Ee=e.onModeChange)==null?void 0:Ee.call(e,"tandem")}),T(B,G)};J(K,B=>{t()>0&&B(ne)})}var X=_(K,2),N=x(X),q=x(N),L=_(x(q));{var V=B=>{var G=YR(),be=x(G);Y(()=>te(be,f(y).allPending.length)),T(B,G)};J(L,B=>{f(y).allPending.length>0&&B(V)})}var re=_(q,2),w=x(re),M=_(X,2);jR(M,{get filterType(){return f(c)},get filterAuthor(){return f(d)},get filterStatus(){return f(u)},get hasFilters(){return f(k)},get open(){return f(h)},get totalCount(){return f(y).filtered.length},onToggleOpen:()=>b(h,!f(h)),onSetFilterType:B=>{b(c,B,!0)},onSetFilterAuthor:B=>{b(d,B,!0)},onSetFilterStatus:B=>{b(u,B,!0)},onClearFilters:()=>{b(c,"all"),b(d,"all"),b(u,"all")}});var I=_(M,2),ae=x(I);QD(ae,{get annotations(){return e.annotations},get activeDocFormat(){return e.activeDocFormat},get documentId(){return e.documentId}});var ve=_(I,2);zR(ve,{get bulkConfirm(){return f(p)},get pendingCount(){return f(y).reviewPending.length},get allPendingCount(){return f(y).reviewAllPending.length},onConfirmAccept:()=>O("accepted"),onConfirmDismiss:()=>O("dismissed"),onCancel:()=>b(p,null),onRequestAccept:()=>b(p,"accept"),onRequestDismiss:()=>b(p,"dismiss"),get confirmRef(){return f(v)},set confirmRef(B){b(v,B,!0)}});var ue=_(ve,2);{var le=B=>{var G=ZR(),be=x(G),Te=x(be);Y(()=>te(Te,f(k)?"No annotations match filters.":"No annotations yet. Open a document to get started.")),T(B,G)},he=B=>{var G=XR(),be=x(G);mt(be,17,()=>f(y).pending,Ee=>Ee.id,(Ee,se)=>{const $=H(()=>{var Q;return((Q=S.getActiveReviewAnn())==null?void 0:Q.id)===f(se).id});{let Q=H(()=>f(g).get(f(se).id)??[]),pe=H(()=>f(se).author!=="user"?S.handleAccept:void 0),fe=H(()=>f(se).author!=="user"?S.handleDismiss:void 0),Le=H(()=>f(se).author==="user"?z:void 0),Ie=H(()=>f(se).type==="note"?W:void 0);lb(Ee,{get annotation(){return f(se)},get replies(){return f(Q)},get isReviewTarget(){return f($)},get onAccept(){return f(pe)},get onDismiss(){return f(fe)},get onRemove(){return f(Le)},get onSendToClaude(){return f(Ie)},onEdit:A,onReply:D,onClick:()=>S.scrollToAnnotation(f(se))})}});var Te=_(be,2);{var De=Ee=>{var se=GR(),$=x(se),Q=x($),pe=_($,2);mt(pe,21,()=>f(y).resolved,fe=>fe.id,(fe,Le)=>{{let Ie=H(()=>f(g).get(f(Le).id)??[]),ye=H(()=>S.getRecentlyResolved().has(f(Le).id));lb(fe,{get annotation(){return f(Le)},get replies(){return f(Ie)},get onUndo(){return S.undoResolveAnnotation},get undoable(){return f(ye)},onClick:()=>S.scrollToAnnotation(f(Le))})}}),Y(()=>te(Q,`${f(y).resolved.length??""} resolved`)),T(Ee,se)};J(Te,Ee=>{f(y).resolved.length>0&&Ee(De)})}T(B,G)};J(ue,B=>{f(y).filtered.length===0?B(le):B(he,-1)})}kt(U,B=>b(m,B),()=>f(m)),Y(()=>te(w,`${f(y).allPending.length??""} pending annotation${f(y).allPending.length!==1?"s":""}`)),T(n,U),Je()}$e(["click"]);var $R=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>'),eN=E(`<span style="
|
|
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=Rt(),l=ze(a);{var c=d=>{var u=XD(),h=x(u);Y(()=>{u.disabled=f(o),Z(u,"title",f(r).length===0?"No accepted suggestions to apply":void 0),se(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;`),te(h,f(t)?"Applying…":`Apply as Tracked Changes (${f(r).length})`)}),P("click",u,s),T(d,u)};J(l,d=>{e.activeDocFormat==="docx"&&d(c)})}T(n,a),Je()}$e(["click"]);const Fo={background:"var(--tandem-warning-bg)",border:"var(--tandem-warning-border)",color:"var(--tandem-warning-fg-strong)"};var $D=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>'),eR=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>'),tR=E('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),nR=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>'),rR=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>'),iR=E('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),oR=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>'),sR=E(`<div style="font-size: var(--tandem-text-xs); color: var(--tandem-error-fg); margin-top: 2px;">Can't undo — text has changed.</div>`),aR=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 lR(n,e){qe(e,!0);let t=F(!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))}yi(i);var s=Rt(),a=ze(s);{var l=h=>{var p=tR(),m=x(p);{var v=k=>{var S=$D();Y(()=>Z(S,"data-testid",`accept-btn-${e.annotationId??""}`)),P("click",S,C=>{C.stopPropagation(),e.onAccept(e.annotationId)}),T(k,S)};J(m,k=>{e.onAccept&&k(v)})}var g=_(m,2);{var y=k=>{var S=eR();Y(()=>Z(S,"data-testid",`dismiss-btn-${e.annotationId??""}`)),P("click",S,C=>{C.stopPropagation(),e.onDismiss(e.annotationId)}),T(k,S)};J(g,k=>{e.onDismiss&&k(y)})}T(h,p)},c=h=>{var p=iR(),m=x(p);{var v=k=>{var S=nR();Y(()=>Z(S,"data-testid",`archive-btn-${e.annotationId??""}`)),P("click",S,C=>{C.stopPropagation(),e.onRemove(e.annotationId)}),T(k,S)};J(m,k=>{e.onRemove&&k(v)})}var g=_(m,2);{var y=k=>{var S=rR();Y(()=>Z(S,"data-testid",`send-to-claude-btn-${e.annotationId??""}`)),P("click",S,C=>{C.stopPropagation(),e.onSendToClaude(e.annotationId)}),T(k,S)};J(g,k=>{e.onSendToClaude&&k(y)})}T(h,p)},d=h=>{var p=oR();Y(()=>Z(p,"data-testid",`remove-btn-${e.annotationId??""}`)),P("click",p,m=>{m.stopPropagation(),e.onRemove(e.annotationId)}),T(h,p)},u=h=>{var p=aR(),m=x(p),v=_(m,2);{var g=y=>{var k=sR();T(y,k)};J(v,y=>{f(t)&&y(g)})}P("click",m,o),T(h,p)};J(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)})}T(n,s),Je()}$e(["click"]);const Sd="width: 100%; padding: 4px 6px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); resize: vertical; font-family: inherit; min-height: 40px; box-sizing: border-box; background: var(--tandem-surface); color: var(--tandem-fg);";var cR=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),dR=E("<textarea></textarea>"),uR=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 fR(n,e){qe(e,!0);let t=F(null);de(()=>{var d;(d=f(t))==null||d.focus()});var r=uR(),i=x(r);{var o=d=>{var u=cR(),h=ze(u),p=_(h,2);kt(p,g=>b(t,g),()=>f(t));var m=_(p,2),v=_(m,2);Y(()=>{Z(h,"for",`edit-newtext-${e.annotationId??""}`),Z(p,"id",`edit-newtext-${e.annotationId??""}`),Z(p,"data-testid",`edit-newtext-${e.annotationId??""}`),Pr(p,e.editNewText),se(p,Sd),Z(m,"for",`edit-reason-${e.annotationId??""}`),Z(v,"id",`edit-reason-${e.annotationId??""}`),Z(v,"data-testid",`edit-reason-${e.annotationId??""}`),Pr(v,e.editReason),se(v,Sd)}),P("input",p,g=>e.onChangeEditNewText(g.target.value)),P("keydown",p,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),P("input",v,g=>e.onChangeEditReason(g.target.value)),P("keydown",v,function(...g){var y;(y=e.onKeyDown)==null||y.apply(this,g)}),T(d,u)},s=d=>{var u=dR();kt(u,h=>b(t,h),()=>f(t)),Y(()=>{Z(u,"data-testid",`edit-text-${e.annotationId??""}`),Pr(u,e.editText),se(u,Sd)}),P("input",u,h=>e.onChangeEditText(h.target.value)),P("keydown",u,function(...h){var p;(p=e.onKeyDown)==null||p.apply(this,h)}),T(d,u)};J(i,d=>{e.hasSuggestedText?d(o):d(s,-1)})}var a=_(i,2),l=x(a),c=_(l,2);Y(()=>{Z(l,"data-testid",`edit-save-btn-${e.annotationId??""}`),Z(c,"data-testid",`edit-cancel-btn-${e.annotationId??""}`)}),P("click",r,d=>d.stopPropagation()),P("keydown",r,d=>d.stopPropagation()),P("click",l,d=>{d.stopPropagation(),e.onSave()}),P("click",c,d=>{d.stopPropagation(),e.onCancel()}),T(n,r),Je()}$e(["click","keydown","input"]);var hR=E('<span style="font-style: italic; margin-right: 4px;">(edited)</span>'),pR=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>'),mR=E('<div data-testid="comment-thread" style="margin-top: 6px; padding-left: 8px; border-left: 2px solid var(--tandem-border);"></div>');function gR(n,e){qe(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=Rt(),i=ze(r);{var o=s=>{var a=mR();mt(a,21,()=>e.replies,l=>l.id,(l,c)=>{var d=pR(),u=x(d),h=x(u),p=x(h),m=_(h,2),v=x(m);{var g=C=>{var A=hR();T(C,A)};J(v,C=>{f(c).editedAt&&C(g)})}var y=_(v),k=_(u,2),S=x(k);Y(C=>{Z(d,"data-testid",`reply-${f(c).id??""}`),se(h,`font-weight: 600; font-size: 11px; color: ${f(c).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};`),te(p,f(c).author==="claude"?"Claude":"You"),te(y,` ${C??""}`),te(S,f(c).text)},[()=>t(f(c).timestamp)]),T(l,d)}),T(s,a)};J(i,s=>{e.replies.length>0&&s(o)})}T(n,r),Je()}var vR=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>'),yR=E('<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;"> </button>'),bR=E('<div style="margin-top: 6px;"><!></div>'),wR=E('<div style="margin-top: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </div>'),xR=E("<!> <!> <!>",1);function kR(n,e){qe(e,!0);let t=F(!1),r=F(""),i=F(!1),o=F(null);const s=H(()=>!!f(r).trim());de(()=>{var v;f(t)&&((v=f(o))==null||v.focus())});function a(v){v.key==="Escape"&&(v.stopPropagation(),b(t,!1),b(r,""))}async function l(){var g;const v=f(r).trim();if(!(!v||f(i))){b(i,!0);try{await((g=e.onReply)==null?void 0:g.call(e,e.annotationId,v))!==!1&&(b(r,""),b(t,!1))}finally{b(i,!1)}}}var c=xR(),d=ze(c);gR(d,{get replies(){return e.replies}});var u=_(d,2);{var h=v=>{var g=bR(),y=x(g);{var k=C=>{var A=vR(),W=x(A);kt(W,U=>b(o,U),()=>f(o));var z=_(W,2),D=x(z),O=_(D,2);Y(()=>{Z(W,"data-testid",`reply-input-${e.annotationId??""}`),Pr(W,f(r)),se(W,Sd),Z(D,"data-testid",`reply-send-btn-${e.annotationId??""}`),D.disabled=!f(s)||f(i),se(D,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${f(s)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${f(s)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${f(s)?"pointer":"default"};`),Z(O,"data-testid",`reply-cancel-btn-${e.annotationId??""}`)}),P("input",W,U=>b(r,U.target.value,!0)),P("keydown",W,a),P("click",D,l),P("click",O,()=>{b(t,!1),b(r,"")}),T(C,A)},S=C=>{var A=yR(),W=x(A);Y(()=>{Z(A,"data-testid",`reply-btn-${e.annotationId??""}`),te(W,`Reply${e.replies.length>0?` (${e.replies.length})`:""}`)}),P("click",A,()=>b(t,!0)),T(C,A)};J(y,C=>{f(t)?C(k):C(S,-1)})}P("click",g,C=>C.stopPropagation()),P("keydown",g,C=>C.stopPropagation()),T(v,g)};J(u,v=>{e.isPending&&e.onReply&&!e.isEditing&&v(h)})}var p=_(u,2);{var m=v=>{var g=wR(),y=x(g);Y(()=>te(y,`${e.replies.length??""}
|
|
58
|
+
${e.replies.length===1?"reply":"replies"}`)),T(v,g)};J(p,v=>{!e.isPending&&e.replies.length>0&&!e.onReply&&v(m)})}T(n,c),Je()}$e(["click","keydown","input"]);var _R=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>'),SR=E("<span> </span>"),CR=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>`),TR=E('<span style="font-style: italic; font-size: 10px; color: var(--tandem-fg-subtle);">(edited)</span>'),AR=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>'),ER=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>'),MR=E('<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>'),OR=E('<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> <!>',1),DR=E('<p style="margin: 0;"> </p>'),RR=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><!></div>'),NR=E('<div role="listitem"><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-3ascys"> </span> <!> <!> <!></span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); display: flex; align-items: center; gap: 4px;"><!> </span></div> <!> <!> <!> <!></div>');function lb(n,e){qe(e,!0);let t=ft(e,"replies",19,()=>[]),r=F(!1),i=F(""),o=F(""),s=F("");const a=H(()=>e.annotation.status==="pending"),l=H(()=>e.annotation.suggestedText!==void 0);function c(B){return B.suggestedText!==void 0?"replacement":B.type}function d(B){return B==="claude"?"Claude":B==="import"?"Imported":"You"}function u(B){return B.color?Il[sx(B.color)]:B.suggestedText!==void 0?"var(--tandem-suggestion)":B.type==="note"?"var(--tandem-warning)":"var(--tandem-author-user)"}function h(B,G){return G?"var(--tandem-accent-bg)":(B.type==="note","var(--tandem-surface)")}const p=H(()=>c(e.annotation)),m=H(()=>u(e.annotation)),v=H(()=>h(e.annotation,e.isReviewTarget)),g=H(()=>e.annotation.type==="note"),y=H(()=>e.annotation.content?e.annotation.content.length>60?e.annotation.content.slice(0,57)+"...":e.annotation.content:""),k=H(()=>`${f(g)?"private ":""}${f(p)} annotation${f(y)?": "+f(y):""}, ${e.annotation.status}`);function S(){f(l)?(b(o,e.annotation.suggestedText??"",!0),b(s,e.annotation.content,!0)):b(i,e.annotation.content,!0),b(r,!0)}function C(){var G;const B=f(l)?JSON.stringify({suggestedText:f(o),content:f(s)}):f(i);(G=e.onEdit)==null||G.call(e,e.annotation.id,B),b(r,!1)}function A(){b(r,!1)}function W(B){B.key==="Escape"&&(B.stopPropagation(),A())}var z=NR(),D=x(z),O=x(D),U=x(O),ee=x(U),R=_(U,2);{var K=B=>{var G=_R();T(B,G)};J(R,B=>{f(g)&&B(K)})}var ne=_(R,2);{var X=B=>{var G=SR(),be=x(G);Y(()=>{se(G,`margin-left: 6px; font-size: 10px; color: ${e.annotation.status==="accepted"?"var(--tandem-success)":"var(--tandem-error)"}; font-weight: 600;`),te(be,e.annotation.status)}),T(B,G)};J(ne,B=>{f(a)||B(X)})}var N=_(ne,2);{var q=B=>{var G=CR();Y(()=>Z(G,"data-testid",`edit-btn-${e.annotation.id??""}`)),P("click",G,be=>{be.stopPropagation(),S()}),T(B,G)};J(N,B=>{f(a)&&e.onEdit&&!e.isReviewTarget&&!f(r)&&B(q)})}var L=_(O,2),V=x(L);{var re=B=>{var G=TR();T(B,G)};J(V,B=>{e.annotation.editedAt&&B(re)})}var w=_(V),M=_(D,2);{var I=B=>{var G=AR(),be=x(G);Y(Te=>{Z(G,"data-testid",`annotation-snippet-${e.annotation.id??""}`),te(be,Te)},[()=>e.annotation.textSnapshot.length>80?e.annotation.textSnapshot.slice(0,77)+"...":e.annotation.textSnapshot]),T(B,G)};J(M,B=>{e.annotation.textSnapshot&&B(I)})}var ae=_(M,2);{var ve=B=>{fR(B,{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:G=>b(i,G,!0),onChangeEditNewText:G=>b(o,G,!0),onChangeEditReason:G=>b(s,G,!0),onKeyDown:W,onSave:C,onCancel:A})},ue=B=>{var G=RR(),be=x(G);{var Te=Ee=>{var oe=OR(),$=ze(oe),Q=x($);{var pe=Pe=>{var lt=ER(),At=x(lt);Y(()=>te(At,e.annotation.textSnapshot)),T(Pe,lt)};J(Q,Pe=>{e.annotation.textSnapshot&&Pe(pe)})}var fe=_(Q,2);{var Le=Pe=>{var lt=an();lt.nodeValue=" → ",T(Pe,lt)};J(fe,Pe=>{e.annotation.textSnapshot&&Pe(Le)})}var Ie=_(fe,2),ye=x(Ie),ke=_($,2);{var Ae=Pe=>{var lt=MR(),At=x(lt);Y(()=>te(At,e.annotation.content)),T(Pe,lt)};J(ke,Pe=>{e.annotation.content&&Pe(Ae)})}Y(()=>{Z($,"data-testid",`suggestion-diff-${e.annotation.id??""}`),se($,`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;`),te(ye,e.annotation.suggestedText)}),T(Ee,oe)},De=Ee=>{var oe=DR(),$=x(oe);Y(()=>te($,e.annotation.content||"(no note)")),T(Ee,oe)};J(be,Ee=>{f(l)?Ee(Te):Ee(De,-1)})}T(B,G)};J(ae,B=>{f(r)?B(ve):B(ue,-1)})}var le=_(ae,2);lR(le,{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 he=_(le,2);kR(he,{get annotationId(){return e.annotation.id},get replies(){return t()},get isPending(){return f(a)},get isEditing(){return f(r)},get onReply(){return e.onReply}}),Y(B=>{Z(z,"data-testid",`annotation-card-${e.annotation.id??""}`),Z(z,"aria-label",f(k)),Z(z,"aria-current",e.isReviewTarget?"true":void 0),se(z,`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;`),se(U,`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: ${f(l)?"var(--tandem-suggestion-bg)":e.annotation.type==="note"?"var(--tandem-warning-bg)":"var(--tandem-surface-sunk)"}; color: ${f(l)?"var(--tandem-suggestion-fg-strong)":e.annotation.type==="note"?"var(--tandem-warning-fg-strong)":"var(--tandem-fg-muted)"};`),te(ee,f(p)),te(w,` ${B??""}`)},[()=>d(e.annotation.author)]),P("click",z,function(...B){var G;(G=e.onClick)==null||G.apply(this,B)}),T(n,z),Je()}$e(["click"]);var IR=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),LR=E('<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>',1),PR=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 zR(n,e){qe(e,!0);let t=ft(e,"confirmRef",15,null);const r=H(()=>e.bulkConfirm==="accept"),i=H(()=>e.pendingCount===e.allPendingCount?`${e.pendingCount} annotations?`:`${e.pendingCount} of ${e.allPendingCount} pending?`);var o=Rt(),s=ze(o);{var a=l=>{var c=PR(),d=x(c);{var u=p=>{var m=IR(),v=ze(m),g=x(v),y=_(v,2);kt(y,S=>t(S),()=>t());var k=_(y,2);se(k,"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);"),Y(()=>{te(g,`${f(r)?"Accept":"Reject"}
|
|
59
|
+
${f(i)??""}`),se(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;`)}),P("click",y,function(...S){var C;(C=f(r)?e.onConfirmAccept:e.onConfirmDismiss)==null||C.apply(this,S)}),P("click",k,function(...S){var C;(C=e.onCancel)==null||C.apply(this,S)}),T(p,m)},h=p=>{var m=LR(),v=ze(m);se(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=_(v,2);se(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);"),Y(()=>te(g,`Accept All (${e.pendingCount??""})`)),P("click",v,function(...k){var S;(S=e.onRequestAccept)==null||S.apply(this,k)}),P("click",y,function(...k){var S;(S=e.onRequestDismiss)==null||S.apply(this,k)}),T(p,m)};J(d,p=>{e.bulkConfirm?p(u):p(h,-1)})}T(l,c)};J(s,l=>{e.pendingCount>1&&l(a)})}T(n,o),Je()}$e(["click"]);var BR=E("<option> </option>"),FR=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 _h(n,e){qe(e,!0);var t=FR();mt(t,21,()=>e.options,i=>i.value,(i,o)=>{var s=BR(),a=x(s),l={};Y(()=>{te(a,f(o).label),l!==(l=f(o).value)&&(s.value=(s.__value=f(o).value)??"")}),T(i,s)});var r;ex(t),Y(()=>{Z(t,"data-testid",e.testId),Z(t,"aria-label",e.ariaLabel),r!==(r=e.value)&&(t.value=(t.__value=e.value)??"",Km(t,e.value))}),P("change",t,i=>e.onChange(i.target.value)),T(n,t),Je()}$e(["change"]);var HR=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>'),VR=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>'),UR=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 jR(n,e){qe(e,!0);const t=H(()=>{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=Rt(),i=ze(r);{var o=a=>{var l=HR(),c=x(l),d=x(c),u=x(d);Y(()=>te(u,`${f(t)??""} ${e.totalCount??""}`)),P("click",c,function(...h){var p;(p=e.onToggleOpen)==null||p.apply(this,h)}),T(a,l)},s=a=>{var l=UR(),c=x(l);_h(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=_(c,2);_h(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=_(d,2);_h(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=_(u,2);{var p=v=>{var g=VR();P("click",g,function(...y){var k;(k=e.onClearFilters)==null||k.apply(this,y)}),T(v,g)};J(h,v=>{e.hasFilters&&v(p)})}var m=_(h,2);P("click",m,function(...v){var g;(g=e.onToggleOpen)==null||g.apply(this,v)}),T(a,l)};J(i,a=>{e.open?a(s,-1):a(o)})}T(n,r),Je()}$e(["click"]);const cb=n=>{console.warn("[sanitize]",n)};function WR(n,e,t){if(n.suggestedText===void 0)return!1;const r=n.suggestedText,i=lu(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 KR({getYdoc:n,getEditor:e,getAnnotations:t,onActiveAnnotationChange:r,getScrollBehavior:i}){let o=F(0),s=F(dt(new Set));const a=new Map,l=null;yi(()=>{for(const k of a.values())clearTimeout(k);a.clear()});function c(){return t().filter(Hd)}function d(){const k=c();return k.length>0?k[f(o)]??null:null}function u(k,S){const C=n();if(!C)return;const A=C.getMap(So),W=A.get(k);if(!W)return;const z=Ra(W,cb);if(A.set(k,{...z,status:S}),S==="accepted"&&z.suggestedText!==void 0){const D=e();if(D&&!WR(z,D,C)){A.set(k,{...z,status:"pending"});return}}b(s,new Set(f(s)).add(k),!0)}function h(k){const S=a.get(k);S&&clearTimeout(S),a.set(k,setTimeout(()=>{a.delete(k);const C=new Set(f(s));C.delete(k),b(s,C,!0)},3e3))}function p(k){const S=a.get(k);S&&(clearTimeout(S),a.delete(k));const C=new Set(f(s));C.delete(k),b(s,C,!0)}function m(k){const S=n();if(!S)return!1;const C=S.getMap(So),A=C.get(k);if(!A||A.status==="pending")return p(k),!1;const W=Ra(A,cb),z=e();if(W.status==="accepted"&&W.suggestedText!==void 0&&z)try{const D=W.suggestedText,O=W.textSnapshot;if(typeof D=="string"&&typeof O=="string"){const U=lu(W,z.state.doc,S);if(!U)return console.warn(`[undo] Cannot resolve range for annotation ${k}, skipping`),h(k),!1;if(z.state.doc.textBetween(U.from,U.to)!==D)return console.warn(`[undo] Text changed since accept for annotation ${k}, skipping`),h(k),!1;z.chain().focus().deleteRange({from:U.from,to:U.to}).insertContentAt(U.from,O).run()}}catch(D){return console.warn(`[undo] Failed to revert text for annotation ${k}:`,D),h(k),!1}return C.set(k,{...W,status:"pending"}),p(k),!0}function v(k){u(k,"accepted")}function g(k){u(k,"dismissed")}function y(k){const S=e();if(!S)return;const C=lu(k,S.state.doc,n());if(!C)return;S.chain().focus().setTextSelection({from:C.from,to:C.to}).run();const A=S.view.domAtPos(C.from),W=A.node instanceof HTMLElement?A.node:A.node.parentElement;W==null||W.scrollIntoView({behavior:i(),block:"center"})}return de(()=>{var S;const k=c();r(((S=k[f(o)])==null?void 0:S.id)??null)}),de(()=>{const k=c();f(o)>=k.length&&b(o,Math.max(0,k.length-1),!0)}),{resolveAnnotation:u,undoResolveAnnotation:m,handleAccept:v,handleDismiss:g,scrollToAnnotation:y,getRecentlyResolved:()=>f(s),getReviewIndex:()=>f(o),getReviewTargets:c,getActiveReviewAnn:d,confirmEl:l}}var qR=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
|
|
60
|
+
won't be saved. Close the other instance and restart.</span> <button data-testid="store-readonly-dismiss" class="svelte-l26r3u">Dismiss</button></div>`),JR=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>'),YR=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>'),ZR=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>'),GR=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>'),XR=E('<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>'),QR=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 db(n,e){qe(e,!0);let t=ft(e,"heldCount",3,0),r=ft(e,"storeReadOnly",3,!1);const i=H(()=>e.reduceMotion?"auto":"smooth"),o="tandem:storeReadOnlyBannerDismissed";function s(){try{return localStorage.getItem(o)==="true"}catch{return!1}}let a=F(dt(s()));de(()=>{if(!r()){b(a,!1);try{localStorage.removeItem(o)}catch{}}});function l(){try{localStorage.setItem(o,"true")}catch{}b(a,!0)}let c=F("all"),d=F("all"),u=F("all"),h=F(!1),p=F(null),m=F(void 0),v=F(null);de(()=>{var B;f(p)&&((B=f(v))==null||B.focus())}),de(()=>{f(c),f(d),f(u),b(p,null)}),de(()=>{var B;(B=e.onFilterChange)==null||B.call(e,f(c),f(d),f(u))});let g=F(dt(new Map));de(()=>{if(!e.ydoc){b(g,new Map,!0);return}const B=e.ydoc.getMap(pA);function G(){const be=new Map;B.forEach(Te=>{const De=Te;if(De&&typeof De=="object"&&De.annotationId){const Ee=be.get(De.annotationId)??[];Ee.push(De),be.set(De.annotationId,Ee)}});for(const Te of be.values())Te.sort((De,Ee)=>De.timestamp-Ee.timestamp);b(g,be,!0)}return G(),B.observe(G),()=>B.unobserve(G)});const y=H(()=>{const B=[],G=[];for(const oe of e.annotations){oe.status==="pending"&&G.push(oe);let $;f(c)==="all"?$=!0:f(c)==="with-replacement"?$=oe.suggestedText!==void 0:$=oe.type===f(c);const Q=f(d)==="all"||oe.author===f(d),pe=f(u)==="all"||oe.status===f(u);$&&Q&&pe&&B.push(oe)}const be=B.filter(oe=>oe.status==="pending"),Te=B.filter(Hd),De=B.filter(oe=>oe.status!=="pending"),Ee=e.annotations.filter(Hd);return{filtered:B,pending:be,reviewPending:Te,resolved:De,allPending:G,reviewAllPending:Ee}}),k=H(()=>f(c)!=="all"||f(d)!=="all"||f(u)!=="all"),S=KR({getYdoc:()=>e.ydoc,getEditor:()=>e.editor,getAnnotations:()=>e.annotations,onActiveAnnotationChange:B=>e.onActiveAnnotationChange(B),getScrollBehavior:()=>f(i)});let C=!1;de(()=>{if(f(c),f(d),f(u),!C){C=!0;return}Pt(()=>{var B;if(e.activeAnnotationId){const G=document.querySelector(`[data-testid="annotation-card-${e.activeAnnotationId}"]`);if(G){G.scrollIntoView({block:"center"});return}console.warn(`[tandem] SidePanel: active annotation ${e.activeAnnotationId} not found on filter change; scrolling to top`)}(B=f(m))==null||B.scrollTo({top:0})})}),de(()=>{const B=e.activeAnnotationId;if(!B)return;const G=f(i),be=setTimeout(()=>{const Te=document.querySelector(`[data-testid="annotation-card-${B}"]`);if(Te){Te.scrollIntoView({behavior:G,block:"nearest"}),Te.classList.add("tandem-annotation-flash");const De=()=>Te.classList.remove("tandem-annotation-flash");Te.addEventListener("animationend",De,{once:!0})}else console.warn(`[tandem] SidePanel: active annotation ${B} not found after 50ms delay; scroll-to-card skipped`)},50);return()=>clearTimeout(be)});function A(B,G){if(!e.ydoc)return;const be=e.ydoc.getMap(So),Te=be.get(B);if(!Te)return;const De=Ra(Te,Ee=>{console.warn("[sanitize]",Ee)});if(De.suggestedText!==void 0){try{const Ee=JSON.parse(G);be.set(B,{...De,suggestedText:Ee.suggestedText,content:Ee.content,editedAt:Date.now()})}catch{console.warn(`[SidePanel] Failed to parse edit payload for annotation ${B}`)}return}be.set(B,{...De,content:G,editedAt:Date.now()})}function W(B){if(!e.ydoc)return;const G=e.ydoc.getMap(So),be=G.get(B);if(!be)return;const Te=Ra(be,De=>{console.warn("[sanitize]",De)});G.set(B,{...Te,type:"comment"})}async function z(B){try{const G=await fetch(`${Tr}/remove-annotation`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:B,documentId:e.documentId})});if(!G.ok){const be=await G.json().catch(()=>({message:"Unknown error"}));console.error("[Tandem] Remove annotation failed:",be)}}catch(G){console.error("[Tandem] Remove annotation failed:",G)}}async function D(B,G){try{const be=await fetch(`${Tr}/annotation-reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:B,text:G,documentId:e.documentId})});if(!be.ok){const Te=await be.json().catch(()=>({}));return console.warn(`[SidePanel] Reply failed (${be.status}): ${Te.message??"unknown error"}`),!1}return!0}catch(be){return console.error("[SidePanel] Reply request failed:",be),!1}}function O(B){for(const G of f(y).reviewPending)S.resolveAnnotation(G.id,B);b(p,null)}var U=QR(),ee=x(U);{var R=B=>{var G=qR(),be=_(x(G),2);Y(()=>{se(G,`padding: 10px 14px; margin: 10px 14px 0; background: ${Fo.background}; border: 1px solid ${Fo.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${Fo.color}; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;`),se(be,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${Fo.color}; cursor: pointer; font-weight: 500;`)}),P("click",be,l),T(B,G)};J(ee,B=>{r()&&!f(a)&&B(R)})}var K=_(ee,2);{var ne=B=>{var G=JR(),be=x(G),Te=x(be),De=_(be,2);Y(()=>{se(G,`padding: 10px 14px; margin: 10px 14px 0; background: ${Fo.background}; border: 1px solid ${Fo.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${Fo.color}; display: flex; justify-content: space-between; align-items: center; gap: 10px;`),te(Te,`${t()??""} annotation${t()!==1?"s":""} held`)}),P("click",De,()=>{var Ee;return(Ee=e.onModeChange)==null?void 0:Ee.call(e,"tandem")}),T(B,G)};J(K,B=>{t()>0&&B(ne)})}var X=_(K,2),N=x(X),q=x(N),L=_(x(q));{var V=B=>{var G=YR(),be=x(G);Y(()=>te(be,f(y).allPending.length)),T(B,G)};J(L,B=>{f(y).allPending.length>0&&B(V)})}var re=_(q,2),w=x(re),M=_(X,2);jR(M,{get filterType(){return f(c)},get filterAuthor(){return f(d)},get filterStatus(){return f(u)},get hasFilters(){return f(k)},get open(){return f(h)},get totalCount(){return f(y).filtered.length},onToggleOpen:()=>b(h,!f(h)),onSetFilterType:B=>{b(c,B,!0)},onSetFilterAuthor:B=>{b(d,B,!0)},onSetFilterStatus:B=>{b(u,B,!0)},onClearFilters:()=>{b(c,"all"),b(d,"all"),b(u,"all")}});var I=_(M,2),ae=x(I);QD(ae,{get annotations(){return e.annotations},get activeDocFormat(){return e.activeDocFormat},get documentId(){return e.documentId}});var ve=_(I,2);zR(ve,{get bulkConfirm(){return f(p)},get pendingCount(){return f(y).reviewPending.length},get allPendingCount(){return f(y).reviewAllPending.length},onConfirmAccept:()=>O("accepted"),onConfirmDismiss:()=>O("dismissed"),onCancel:()=>b(p,null),onRequestAccept:()=>b(p,"accept"),onRequestDismiss:()=>b(p,"dismiss"),get confirmRef(){return f(v)},set confirmRef(B){b(v,B,!0)}});var ue=_(ve,2);{var le=B=>{var G=ZR(),be=x(G),Te=x(be);Y(()=>te(Te,f(k)?"No annotations match filters.":"No annotations yet. Open a document to get started.")),T(B,G)},he=B=>{var G=XR(),be=x(G);mt(be,17,()=>f(y).pending,Ee=>Ee.id,(Ee,oe)=>{const $=H(()=>{var Q;return((Q=S.getActiveReviewAnn())==null?void 0:Q.id)===f(oe).id});{let Q=H(()=>f(g).get(f(oe).id)??[]),pe=H(()=>f(oe).author!=="user"?S.handleAccept:void 0),fe=H(()=>f(oe).author!=="user"?S.handleDismiss:void 0),Le=H(()=>f(oe).author==="user"?z:void 0),Ie=H(()=>f(oe).type==="note"?W:void 0);lb(Ee,{get annotation(){return f(oe)},get replies(){return f(Q)},get isReviewTarget(){return f($)},get onAccept(){return f(pe)},get onDismiss(){return f(fe)},get onRemove(){return f(Le)},get onSendToClaude(){return f(Ie)},onEdit:A,onReply:D,onClick:()=>S.scrollToAnnotation(f(oe))})}});var Te=_(be,2);{var De=Ee=>{var oe=GR(),$=x(oe),Q=x($),pe=_($,2);mt(pe,21,()=>f(y).resolved,fe=>fe.id,(fe,Le)=>{{let Ie=H(()=>f(g).get(f(Le).id)??[]),ye=H(()=>S.getRecentlyResolved().has(f(Le).id));lb(fe,{get annotation(){return f(Le)},get replies(){return f(Ie)},get onUndo(){return S.undoResolveAnnotation},get undoable(){return f(ye)},onClick:()=>S.scrollToAnnotation(f(Le))})}}),Y(()=>te(Q,`${f(y).resolved.length??""} resolved`)),T(Ee,oe)};J(Te,Ee=>{f(y).resolved.length>0&&Ee(De)})}T(B,G)};J(ue,B=>{f(y).filtered.length===0?B(le):B(he,-1)})}kt(U,B=>b(m,B),()=>f(m)),Y(()=>te(w,`${f(y).allPending.length??""} pending annotation${f(y).allPending.length!==1?"s":""}`)),T(n,U),Je()}$e(["click"]);var $R=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>'),eN=E(`<span style="
|
|
61
61
|
flex-shrink: 0;
|
|
62
62
|
font-size: var(--tandem-text-2xs, 10px);
|
|
63
63
|
font-weight: 500;
|
|
@@ -77,7 +77,7 @@ ${p.backupPath}`),alert(m.join(" "))}else alert("Changes applied successfully.")
|
|
|
77
77
|
background: var(--tandem-surface);
|
|
78
78
|
color: var(--tandem-fg);
|
|
79
79
|
outline: none;
|
|
80
|
-
"/></div> <div style="flex: 1; overflow-y: auto; padding: var(--tandem-space-2) 0;"><!></div></nav>`);function ub(n,e){qe(e,!0);let t=ft(e,"annotations",19,()=>[]),r=ft(e,"focusTrigger",3,0),i=ft(e,"activeFilterType",3,"all"),o=ft(e,"activeFilterAuthor",3,"all"),s=ft(e,"activeFilterStatus",3,"all"),a=F(dt([])),l=F(-1),c=F(dt([])),d=F(""),u=F(null),h=F(-1);de(()=>{const O=e.editor;if(!O||O.isDestroyed){b(a,[],!0);return}b(a,Dp(O),!0),
|
|
80
|
+
"/></div> <div style="flex: 1; overflow-y: auto; padding: var(--tandem-space-2) 0;"><!></div></nav>`);function ub(n,e){qe(e,!0);let t=ft(e,"annotations",19,()=>[]),r=ft(e,"focusTrigger",3,0),i=ft(e,"activeFilterType",3,"all"),o=ft(e,"activeFilterAuthor",3,"all"),s=ft(e,"activeFilterStatus",3,"all"),a=F(dt([])),l=F(-1),c=F(dt([])),d=F(""),u=F(null),h=F(-1);de(()=>{const O=e.editor;if(!O||O.isDestroyed){b(a,[],!0);return}b(a,Dp(O),!0),Pt(()=>{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 U=()=>{b(a,Dp(O),!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 O.on("update",U),()=>{O.isDestroyed||O.off("update",U),b(a,[],!0)}}),de(()=>{var O,U;r()>0&&((O=f(u))==null||O.focus(),(U=f(u))==null||U.select())}),de(()=>{const O=e.editor;if(!O||O.isDestroyed)return;function U(){if(!O||O.isDestroyed||f(a).length===0){b(h,-1);return}const K=O.view.dom.getBoundingClientRect().top+48;let ne=-1;for(let X=0;X<f(a).length;X++)try{O.view.coordsAtPos(f(a)[X].pos+1).top<=K&&(ne=X)}catch{}b(h,ne,!0)}U();const ee=O.view.dom.closest(".editor-scroll")??O.view.dom.parentElement;return ee==null||ee.addEventListener("scroll",U),()=>ee==null?void 0:ee.removeEventListener("scroll",U)});function p(){const O=e.editor;!O||O.isDestroyed||(f(d)?O.commands.find({query:f(d),caseSensitive:!1,wholeWord:!1,regexMode:!1}):O.commands.findClose())}function m(O){var U,ee,R,K;O.key==="Enter"?(O.preventDefault(),O.shiftKey?(U=e.editor)==null||U.commands.findPrev():(ee=e.editor)==null||ee.commands.findNext()):O.key==="Escape"&&(O.preventDefault(),b(d,""),(R=e.editor)==null||R.commands.findClose(),(K=f(u))==null||K.blur())}const v=H(()=>{const O=e.editor;if(!O||O.isDestroyed||f(a).length===0)return[];const U=O.state.doc.content.size,ee=[];for(const R of t()){if(i()!=="all"){if(i()==="with-replacement"){if(!R.suggestedText)continue}else if(R.type!==i())continue}if(!(o()!=="all"&&R.author!==o())&&!(s()!=="all"&&R.status!==s()))try{ee.push(Mo(O.state.doc,R.range.from))}catch{}}return f(a).map((R,K)=>{const ne=K+1<f(a).length?f(a)[K+1].pos:U;return ee.filter(X=>X>=R.pos&&X<ne).length})});function g(O,U){const ee=e.editor;if(!ee||ee.isDestroyed)return;const{state:R}=ee;try{const K=R.doc.resolve(O.pos+1),ne=Oe.near(K);ee.view.dispatch(R.tr.setSelection(ne)),ee.view.focus();const{node:X}=ee.view.domAtPos(O.pos+1),N=X instanceof Element?X:X.parentElement,q=ee.view.dom.closest(".editor-scroll")??ee.view.dom.parentElement;if(N&&q){const L=N.getBoundingClientRect().top,V=q.getBoundingClientRect().top;q.scrollTop+=L-V-q.clientHeight*.05}}catch{}b(l,U,!0)}function y(O){var U,ee,R,K;if(f(a).length!==0)if(O.key==="ArrowDown"){O.preventDefault();const ne=(f(l)+1)%f(a).length;b(l,ne),(U=f(c)[ne])==null||U.focus()}else if(O.key==="ArrowUp"){O.preventDefault();const ne=(f(l)-1+f(a).length)%f(a).length;b(l,ne),(ee=f(c)[ne])==null||ee.focus()}else O.key==="Home"?(O.preventDefault(),b(l,0),(R=f(c)[0])==null||R.focus()):O.key==="End"&&(O.preventDefault(),b(l,f(a).length-1),(K=f(c)[f(a).length-1])==null||K.focus())}var k=rN(),S=x(k),C=x(S);kt(C,O=>b(u,O),()=>f(u));var A=_(S,2),W=x(A);{var z=O=>{var U=$R();T(O,U)},D=O=>{var U=nN();mt(U,21,()=>f(a),ba,(ee,R,K)=>{const ne=H(()=>f(h)===K),X=H(()=>f(v)[K]??0);var N=tN(),q=x(N),L=x(q),V=x(L),re=_(L,2);{var w=M=>{var I=eN(),ae=x(I);Y(()=>{Z(I,"title",`${f(X)??""} annotation${f(X)!==1?"s":""}`),te(ae,f(X))}),T(M,I)};J(re,M=>{f(X)>0&&M(w)})}kt(q,(M,I)=>f(c)[I]=M,M=>{var I;return(I=f(c))==null?void 0:I[M]},()=>[K]),Y(()=>{Z(q,"data-testid",`outline-heading-${f(R).level}-${K}`),Z(q,"tabindex",f(l)===K||f(l)===-1&&K===0?0:-1),se(q,`
|
|
81
81
|
display: flex; align-items: center; width: 100%; text-align: left;
|
|
82
82
|
padding: var(--tandem-space-1) var(--tandem-space-3);
|
|
83
83
|
padding-left: calc(var(--tandem-space-1) + ${(f(R).level-1)*12}px);
|
|
@@ -88,14 +88,14 @@ ${p.backupPath}`),alert(m.join(" "))}else alert("Changes applied successfully.")
|
|
|
88
88
|
border: none; cursor: pointer; line-height: 1.5;
|
|
89
89
|
transition: color 0.1s, background 0.1s;
|
|
90
90
|
gap: var(--tandem-space-2);
|
|
91
|
-
`),Z(q,"title",f(R).text),te(V,f(R).text||"(untitled)")}),P("click",q,()=>g(f(R),K)),wt("focus",q,()=>b(l,K,!0)),wt("mouseenter",q,M=>{f(ne)||(M.currentTarget.style.background="var(--tandem-surface-hover, var(--tandem-surface-muted))")}),wt("mouseleave",q,M=>{f(ne)||(M.currentTarget.style.background="none")}),T(ee,N)}),T(O,U)};J(W,O=>{f(a).length===0?O(z):O(D,-1)})}P("keydown",k,y),P("input",C,p),P("keydown",C,m),ys(C,()=>f(d),O=>b(d,O)),T(n,k),Je()}$e(["keydown","input","click"]);var iN=E("<div><!></div>");function Fs(n,e){qe(e,!0);let t=ST(e,["$$slots","$$events","$$legacy","kind","visible"]);const r=H(()=>e.visible!==void 0?`display: ${e.visible?"flex":"none"}; flex-direction: column; flex: 1; min-height: 0;`:void 0);var i=Rt(),o=ze(i);{var s=d=>{var u=iN(),h=x(u);{var p=g=>{ab(g,Bc(()=>t,{get visible(){return e.visible}}))},m=g=>{ub(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=>{db(g,Bc(()=>t))};J(h,g=>{e.kind==="chat"?g(p):e.kind==="outline"?g(m,1):g(v,-1)})}Y(()=>
|
|
92
|
-
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 lN(n,e){qe(e,!0);const t="tandem:reviewOnlyBannerDismissed";function r(){try{return localStorage.getItem(t)==="true"}catch{return!1}}let i=F(dt(r())),o=F(!1),s=F(null);async function a(){if(!(!e.documentId||f(o))){b(o,!0),b(s,null);try{const h=await fetch(`${Tr}/convert`,{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=Rt(),d=ze(c);{var u=h=>{var p=aN(),m=_(x(p),2),v=x(m);{var g=C=>{var A=oN(),W=x(A);Y(()=>te(W,f(s))),T(C,A)};J(v,C=>{f(s)&&C(g)})}var y=_(v,2);{var k=C=>{var A=sN(),W=x(A);Y(()=>{A.disabled=f(o),oe(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};`),te(W,f(o)?"Converting…":"Convert to Markdown")}),P("click",A,a),T(C,A)};J(y,C=>{e.documentId&&C(k)})}var S=_(y,2);P("click",S,l),T(h,p)};J(d,h=>{e.visible&&!f(i)&&h(u)})}T(n,c),Je()}$e(["click"]);let Sh=null;async function cN(n){if(Sh!==null)return Sh;const e=await fetch(`${Tr}/info`,{signal:n});if(!e.ok)throw new Error(`/api/info responded ${e.status} ${e.statusText}`);const t=await e.json();return Sh=t,t}function Ok(n){let e=F(null),t=F(!1);return de(()=>{if(!n())return;let r=!1;const i=new AbortController,o=setTimeout(()=>i.abort(),3e3);return b(t,!0),cN(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)}}}function Dg(n){const e=n==null?void 0:n.trim();return e?e.slice(0,Gm):fx}function Rg(){try{return Dg(localStorage.getItem(Zm))}catch{return fx}}function dN(n){const e=Dg(n);try{localStorage.setItem(Zm,e)}catch{}return typeof window<"u"&&window.dispatchEvent(new Event(wp)),e}function Dk(n){const e=()=>n(Rg()),t=r=>{r.key===Zm&&n(Dg(r.newValue))};return window.addEventListener(wp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(wp,e),window.removeEventListener("storage",t)}}function Rk(){let n=F(dt(Rg()));const e=Dk(r=>{b(n,r,!0)});return yi(e),{get userName(){return f(n)},setUserName:r=>{const i=dN(r);b(n,i,!0)}}}var uN=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 fN(n,e){qe(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=uN(),i=ze(r),o=x(i);oe(o,t);var s=_(o,2),a=x(s),l=_(i,2),c=x(l);oe(c,t);var d=_(c,2),u=x(d);Y(()=>{vs(a,e.settings.highContrast),vs(u,e.settings.annotationPatterns)}),P("change",a,h=>e.onUpdate({highContrast:h.target.checked})),P("change",u,h=>e.onUpdate({annotationPatterns:h.target.checked})),T(n,r),Je()}$e(["change"]);function Qa(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 hN=E('<button role="radio"> </button>'),pN=E('<button role="radio"> </button>'),mN=E('<button role="radio"> </button>'),gN=E('<button role="radio"> </button>'),vN=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 yN(n,e){qe(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(L,V){return["flex: 1;","padding: var(--tandem-space-2);","min-height: 24px;",`border: 2px solid ${L?"var(--tandem-accent)":"var(--tandem-border)"};`,"border-radius: var(--tandem-r-3);",`background: ${L?"var(--tandem-accent-bg)":"var(--tandem-surface)"};`,"cursor: pointer;","text-align: center;","font-size: 11px;",`color: ${L?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"};`,`font-weight: ${L?600:400};`,"opacity: 1;","transition: border-color 0.15s, background 0.15s;"].join(" ")}const i=Qa(()=>e.settings.theme,["light","dark","system"],L=>e.onUpdate({theme:L})),o=Qa(()=>e.settings.primaryTab,["chat","annotations"],L=>e.onUpdate({primaryTab:L})),s=Qa(()=>e.settings.textSize,["s","m","l"],L=>e.onUpdate({textSize:L})),a=Qa(()=>e.settings.editorFont,["sans","serif","mono"],L=>e.onUpdate({editorFont:L})),l=Qa(()=>e.settings.density,["compact","cozy","spacious"],L=>e.onUpdate({density:L}));var c=vN(),d=ze(c),u=x(d);oe(u,t);var h=_(u,2);mt(h,20,()=>["light","dark","system"],L=>L,(L,V)=>{var re=hN(),w=x(re);Y((M,I)=>{Z(re,"data-testid",`theme-${V}-btn`),Z(re,"aria-checked",e.settings.theme===V),Z(re,"tabindex",M),oe(re,I),te(w,V==="light"?"Light":V==="dark"?"Dark":"System")},[()=>i.tabIndexFor(V),()=>r(e.settings.theme===V)]),P("click",re,()=>e.onUpdate({theme:V})),T(L,re)});var p=_(d,2),m=x(p);oe(m,t);var v=_(m,2),g=x(v),y=_(g,2),k=_(p,2),S=x(k);oe(S,t);var C=_(S,2);mt(C,20,()=>["s","m","l"],L=>L,(L,V)=>{var re=pN(),w=x(re);Y((M,I)=>{Z(re,"data-testid",`text-size-${V}-btn`),Z(re,"aria-checked",e.settings.textSize===V),Z(re,"tabindex",M),oe(re,I),te(w,V==="s"?"Small":V==="m"?"Medium":"Large")},[()=>s.tabIndexFor(V),()=>r(e.settings.textSize===V)]),P("click",re,()=>e.onUpdate({textSize:V})),T(L,re)});var A=_(k,2),W=x(A);oe(W,t);var z=_(W,2),D=_(x(z),2),O=_(A,2),U=x(O);oe(U,t);var ee=_(U,2);mt(ee,20,()=>[["sans","Sans-serif"],["serif","Serif"],["mono","Monospace"]],([L,V])=>L,(L,V)=>{var re=H(()=>Sv(V,2));let w=()=>f(re)[0],M=()=>f(re)[1];var I=mN(),ae=x(I);Y((ve,ue)=>{Z(I,"data-testid",`editor-font-${w()}-btn`),Z(I,"aria-checked",e.settings.editorFont===w()),Z(I,"tabindex",ve),oe(I,ue),te(ae,M())},[()=>a.tabIndexFor(w()),()=>r(e.settings.editorFont===w())]),P("click",I,()=>e.onUpdate({editorFont:w()})),T(L,I)});var R=_(O,2),K=x(R);oe(K,t);var ne=_(K,2);mt(ne,20,()=>[["compact","Compact"],["cozy","Cozy"],["spacious","Spacious"]],([L,V])=>L,(L,V)=>{var re=H(()=>Sv(V,2));let w=()=>f(re)[0],M=()=>f(re)[1];var I=gN(),ae=x(I);Y((ve,ue)=>{Z(I,"data-testid",`density-${w()}-btn`),Z(I,"aria-checked",e.settings.density===w()),Z(I,"tabindex",ve),oe(I,ue),te(ae,M())},[()=>l.tabIndexFor(w()),()=>r(e.settings.density===w())]),P("click",I,()=>e.onUpdate({density:w()})),T(L,I)});var X=_(R,2),N=x(X),q=x(N);Y((L,V,re,w)=>{Z(g,"aria-checked",e.settings.primaryTab==="chat"),Z(g,"tabindex",L),oe(g,V),Z(y,"aria-checked",e.settings.primaryTab==="annotations"),Z(y,"tabindex",re),oe(y,w),Pr(D,e.settings.accentHue),vs(q,e.settings.reduceMotion)},[()=>o.tabIndexFor("chat"),()=>r(e.settings.primaryTab==="chat"),()=>o.tabIndexFor("annotations"),()=>r(e.settings.primaryTab==="annotations")]),P("keydown",h,function(...L){var V;(V=i.handleKeyDown)==null||V.apply(this,L)}),P("keydown",v,function(...L){var V;(V=o.handleKeyDown)==null||V.apply(this,L)}),P("click",g,()=>e.onUpdate({primaryTab:"chat"})),P("click",y,()=>e.onUpdate({primaryTab:"annotations"})),P("keydown",C,function(...L){var V;(V=s.handleKeyDown)==null||V.apply(this,L)}),P("input",D,L=>e.onUpdate({accentHue:Number(L.target.value)})),P("keydown",ee,function(...L){var V;(V=a.handleKeyDown)==null||V.apply(this,L)}),P("keydown",ne,function(...L){var V;(V=l.handleKeyDown)==null||V.apply(this,L)}),P("change",q,L=>e.onUpdate({reduceMotion:L.target.checked})),T(n,c),Je()}$e(["keydown","click","input","change"]);var bN=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 wN(n,e){qe(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=bN(),i=x(r);oe(i,t);var o=_(x(i)),s=x(o),a=_(i,4);Z(a,"min",40),Z(a,"max",100),Z(a,"step",5),Y(()=>{te(s,`${e.settings.editorWidthPercent??""}%`),Pr(a,e.settings.editorWidthPercent)}),P("input",a,l=>e.onUpdate({editorWidthPercent:Number(l.target.value)})),T(n,r),Je()}$e(["input"]);var xN=E('<span style="color: var(--tandem-fg-subtle);"> </span>'),kN=E('<button type="button" data-testid="network-restart-sidecar"> </button>'),_N=E('<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop && tandem start</code> to restart</span>'),SN=E('<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>'),CN=E("<span><strong>Host:</strong> </span>"),TN=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>'),AN=E("<option> </option>"),EN=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>'),MN=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 ON(n,e){qe(e,!0);const t=Ok(()=>e.open),r=Ar();let i=F(null),o=F(!1);async function s(){if(r){b(o,!0),b(i,null);try{const{invoke:Q}=await Co(async()=>{const{invoke:pe}=await import("./core-DhEqZVGG.js");return{invoke:pe}},[]);await Q("restart_sidecar")}catch(Q){b(i,Q instanceof Error?Q.message:String(Q),!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=H(()=>{var Q;return(Q=t.info)==null?void 0:Q.transport}),h=H(()=>{var Q;return(Q=t.info)==null?void 0:Q.bindHost}),p=H(()=>{var Q;return(Q=t.info)==null?void 0:Q.bindPort}),m=H(()=>f(u)==="http"),v=H(()=>{var Q;return(Q=t.info)==null?void 0:Q.tokenRotatedAt});var g=MN(),y=ze(g),k=x(y);oe(k,l);var S=_(k,2),C=x(S),A=_(C,2),W=x(A),z=_(W);{var D=Q=>{var pe=xN(),fe=x(pe);Y(()=>te(fe,`· ${e.reconnectAttempts??""} retry attempt${e.reconnectAttempts===1?"":"s"}`)),T(Q,pe)};J(z,Q=>{e.reconnectAttempts>0&&Q(D)})}var O=_(A,2);{var U=Q=>{var pe=kN(),fe=x(pe);Y(()=>{pe.disabled=f(o),oe(pe,`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};`),te(fe,f(o)?"Restarting…":"Restart sidecar")}),P("click",pe,s),T(Q,pe)},ee=Q=>{var pe=_N();T(Q,pe)};J(O,Q=>{r?Q(U):Q(ee,-1)})}var R=_(S,2);{var K=Q=>{var pe=SN(),fe=x(pe);Y(()=>te(fe,f(i))),T(Q,pe)};J(R,Q=>{f(i)&&Q(K)})}var ne=_(y,2),X=x(ne);oe(X,l);var N=_(X,2),q=x(N),L=_(x(q)),V=_(q,2);{var re=Q=>{var pe=CN(),fe=_(x(pe));Y(()=>te(fe,` ${f(h)??""}`)),T(Q,pe)};J(V,Q=>{f(h)&&Q(re)})}var w=_(ne,2);{var M=Q=>{var pe=TN(),fe=x(pe);oe(fe,l);var Le=_(fe,2),Ie=x(Le),ye=_(Le,2);oe(ye,d),Y(()=>te(Ie,f(p)??"—")),T(Q,pe)};J(w,Q=>{f(m)&&Q(M)})}var I=_(w,2),ae=x(I);oe(ae,l);var ve=_(x(ae)),ue=x(ve),le=_(ae,2),he=_(I,2),B=x(he);oe(B,l);var G=_(B,2);mt(G,21,()=>a,Q=>Q.value,(Q,pe)=>{var fe=AN(),Le=x(fe),Ie={};Y(()=>{te(Le,f(pe).label),Ie!==(Ie=f(pe).value)&&(fe.value=(fe.__value=f(pe).value)??"")}),T(Q,fe)});var be;ex(G);var Te=_(he,2);oe(Te,c);var De=x(Te),Ee=_(Te,2);oe(Ee,d);var se=_(Ee,2);{var $=Q=>{var pe=EN(),fe=x(pe);oe(fe,l);var Le=_(fe,2),Ie=x(Le),ye=_(Le,2);oe(ye,d),Y(ke=>te(Ie,ke),[()=>f(v)===null?"Auth token not yet created":`Last rotated: ${new Date(f(v)).toLocaleString()}`]),T(Q,pe)};J(se,Q=>{f(v)!==void 0&&Q($)})}Y(Q=>{oe(C,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${e.connected?"var(--tandem-success)":"var(--tandem-error)"}; flex-shrink: 0;`),te(W,`${e.connected?"Connected to claude-sidecar":"Disconnected"} `),te(L,` ${Q??""}`),te(ue,`${e.settings.degradedBannerDelayMs/1e3}s`),Pr(le,e.settings.degradedBannerDelayMs),be!==(be=e.settings.sidecarRetryStrategy)&&(G.value=(G.__value=e.settings.sidecarRetryStrategy)??"",Km(G,e.settings.sidecarRetryStrategy)),vs(De,e.settings.holdAnnotationsWhileOffline)},[()=>f(u)?f(u).toUpperCase():"—"]),P("input",le,Q=>e.onUpdate({degradedBannerDelayMs:Number(Q.target.value)})),P("change",G,Q=>e.onUpdate({sidecarRetryStrategy:Q.target.value})),P("change",De,Q=>e.onUpdate({holdAnnotationsWhileOffline:Q.target.checked})),T(n,g),Je()}$e(["click","input","change"]);var DN=E('<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>'),RN=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>'),NN=E('<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),IN=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
|
|
93
|
-
restores when you return to Tandem.</div>`,1),LN=E('<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),PN=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> <!>',1),zN=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),BN=E('<section><div> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section>'),FN=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),HN=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>'),VN=E('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),UN=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),jN=E('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),WN=E('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),KN=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),qN=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),JN=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 YN(n,e){qe(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=H(()=>{const R=jd(),K=new Map;for(const ne of R.values()){if(!ne.shortcut)continue;const X=ne.group,N=K.get(X)??[];N.push({keys:ne.shortcut,description:ne.label}),K.set(X,N)}return gx.map(ne=>({title:ne.charAt(0).toUpperCase()+ne.slice(1),rows:K.get(ne)??[]})).filter(ne=>ne.rows.length>0)});let a=ft(e,"connected",3,!1),l=ft(e,"reconnectAttempts",3,0),c=F(void 0),d=F(void 0);const u=Rk();let h=F(dt(u.userName));const p=Ok(()=>e.open);let m=F(!1),v=F(null),g=F(!1),y=F(null),k=F("appearance");de(()=>{f(k),b(v,null),b(y,null)}),de(()=>{const R=u.userName;f(h)!==R&&document.activeElement!==f(d)&&b(h,R,!0)}),de(()=>{var R;if(e.open)return(R=f(c))==null||R.focus(),()=>{var K;(K=e.returnFocusEl)==null||K.focus()}}),de(()=>{if(!e.open)return;const R=ne=>{var N;const X=ne.target;(N=e.anchorEl)!=null&&N.contains(X)||f(c)&&!f(c).contains(X)&&e.onClose()},K=setTimeout(()=>document.addEventListener("pointerdown",R),0);return()=>{clearTimeout(K),document.removeEventListener("pointerdown",R)}}),de(()=>{if(!e.open)return;const R=K=>{if(K.key==="Escape"){e.onClose();return}if(K.key!=="Tab"||!f(c))return;const ne=f(c).querySelectorAll(r);if(ne.length===0)return;const X=ne[0],N=ne[ne.length-1],q=document.activeElement;if(!f(c).contains(q)){K.preventDefault(),X.focus();return}K.shiftKey&&q===X?(K.preventDefault(),N.focus()):!K.shiftKey&&q===N&&(K.preventDefault(),X.focus())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)});async function S(R,K,ne,X){if(!R){ne(X.notFound);return}K(!0),ne(null);try{const N=await fetch(`${Tr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:R,readOnly:!0})});if(!N.ok){let q=X.failed;try{const L=await N.json();L.message&&(q=L.message)}catch{}N.status===404&&(q=X.notFound),ne(q);return}e.onClose()}catch(N){console.warn("[Tandem] Failed to open read-only file:",N),ne("Server unavailable.")}finally{K(!1)}}function C(){var R;return S((R=p.info)==null?void 0:R.workflowsPath,K=>b(g,K,!0),K=>b(y,K,!0),{notFound:"Documentation file not found.",failed:"Failed to open documentation."})}function A(){var R;return S((R=p.info)==null?void 0:R.changelogPath,K=>b(m,K,!0),K=>b(v,K,!0),{notFound:"Changelog file not found.",failed:"Failed to open changelog."})}const W="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";function z(R){var K;return((K=i.find(ne=>ne.id===R))==null?void 0:K.label)??"Settings"}function D(){var ne;const R=p.info;if(!R)return[];const K=[{label:"Version",value:`Tandem v${R.version}`},{label:"Tools",value:R.toolCount===null?"Tool count unavailable":`${R.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${R.mcpSdkVersion}`},{label:"Transport",value:((ne=R.transport)==null?void 0:ne.toUpperCase())??"—"}];return R.storagePath&&K.push({label:"Storage",value:R.storagePath}),R.tokenRotatedAt!==void 0&&K.push({label:"Token",value:R.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(R.tokenRotatedAt).toLocaleString()}`}),R.changelogPath&&K.push({label:"Changelog",value:R.changelogPath}),K}var O=Rt(),U=ze(O);{var ee=R=>{var K=JN(),ne=ze(K),X=_(ne,2);Z(X,"aria-labelledby",t),Z(X,"tabindex",-1);var N=x(X),q=x(N),L=x(q);Z(L,"id",t);var V=_(L,2);{var re=xe=>{var Ye=DN(),bt=x(Ye);Y(()=>te(bt,`v${p.info.version??""}`)),T(xe,Ye)};J(V,xe=>{p.info&&xe(re)})}var w=_(q,2);mt(w,21,()=>i,xe=>xe.id,(xe,Ye)=>{var bt=RN(),ut=x(bt),_t=x(ut),_n=_(ut,2),xt=x(_n);Y(()=>{Z(bt,"aria-current",f(k)===f(Ye).id?"page":void 0),Z(bt,"data-active",f(k)===f(Ye).id?"true":"false"),Z(_t,"d",f(Ye).icon),te(xt,f(Ye).label)}),P("click",bt,()=>b(k,f(Ye).id,!0)),T(xe,bt)});var M=_(w,2),I=x(M),ae=x(I),ve=_(I,2);{var ue=xe=>{var Ye=NN(),bt=x(Ye);Y(()=>te(bt,f(v))),T(xe,Ye)};J(ve,xe=>{f(v)&&xe(ue)})}var le=_(ve,2),he=_(le,2),B=x(he),G=_(B,2),be=x(G);{var Te=xe=>{var Ye=an("MCP connected");T(xe,Ye)},De=xe=>{var Ye=an("Reconnecting…");T(xe,Ye)},Ee=xe=>{var Ye=an("MCP offline");T(xe,Ye)};J(be,xe=>{a()?xe(Te):l()>0?xe(De,1):xe(Ee,-1)})}var se=_(N,2),$=x(se),Q=x($),pe=x(Q),fe=_(Q,2),Le=_($,2),Ie=x(Le),ye=x(Ie);{var ke=xe=>{var Ye=IN(),bt=ze(Ye),ut=x(bt);oe(ut,W);var _t=_(ut,2);kt(_t,Ve=>b(d,Ve),()=>f(d));var _n=_(bt,2),xt=x(_n);oe(xt,W);var Ge=_(xt,2),He=x(Ge),Re=_(He,2),et=_(_n,2),Ue=x(et);Y(()=>{Pr(_t,f(h)),Z(_t,"maxlength",Gm),Z(He,"aria-checked",e.settings.defaultMode==="tandem"),oe(He,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="tandem"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="tandem"?600:400}; cursor: pointer;`),Z(Re,"aria-checked",e.settings.defaultMode==="solo"),oe(Re,`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;`),vs(Ue,e.settings.soloRailHidden)}),P("input",_t,Ve=>{b(h,Ve.target.value,!0)}),wt("blur",_t,()=>u.setUserName(f(h))),P("keydown",_t,Ve=>{Ve.key==="Enter"&&Ve.currentTarget.blur(),Ve.key==="Escape"&&(b(h,u.userName,!0),Ve.currentTarget.blur())}),P("click",He,()=>e.onUpdate({defaultMode:"tandem"})),P("click",Re,()=>e.onUpdate({defaultMode:"solo"})),P("change",Ue,Ve=>e.onUpdate({soloRailHidden:Ve.target.checked})),T(xe,Ye)},Ae=xe=>{yN(xe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},Pe=xe=>{wN(xe,{get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},lt=xe=>{ON(xe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return a()},get reconnectAttempts(){return l()}})},At=xe=>{fN(xe,{get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},Se=xe=>{var Ye=PN(),bt=ze(Ye),ut=x(bt);oe(ut,W);var _t=_(x(ut)),_n=x(_t),xt=_(ut,4);Z(xt,"step",100);var Ge=_(xt,2),He=x(Ge),Re=x(He),et=_(He,2),Ue=x(et),Ve=_(bt,2),tt=x(Ve),gt=_(Ve,2);{var zt=on=>{var Or=Rt(),Yi=ze(Or);dT(Yi,()=>Co(()=>import("./CoworkSettings-BfROGjTw.js"),[]),Lo=>{var Po=LN();T(Lo,Po)},(Lo,Po)=>{const Ic=H(()=>f(Po).default);var Lc=Rt(),Vf=ze(Lc);gT(Vf,()=>f(Ic),(Uf,jf)=>{jf(Uf,{})}),T(Lo,Lc)}),T(on,Or)},Un=H(()=>Ar());J(gt,on=>{f(Un)&&on(zt)})}Y((on,Or,Yi)=>{te(_n,`${on??""}s`),Z(xt,"min",Vd),Z(xt,"max",Ud),Pr(xt,e.settings.selectionDwellMs),te(Re,`${Or??""}s`),te(Ue,`${Yi??""}s`),vs(tt,e.settings.selectionToolbar)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(Vd/1e3).toFixed(1),()=>(Ud/1e3).toFixed(1)]),P("input",xt,on=>e.onUpdate({selectionDwellMs:Number(on.target.value)})),P("change",tt,on=>e.onUpdate({selectionToolbar:on.target.checked})),T(xe,Ye)},vt=xe=>{var Ye=HN(),bt=x(Ye);mt(bt,17,()=>f(s),xt=>xt.title,(xt,Ge)=>{var He=BN(),Re=x(He);oe(Re,W);var et=x(Re),Ue=_(Re,2);mt(Ue,21,()=>f(Ge).rows,Ve=>Ve.keys+Ve.description,(Ve,tt)=>{var gt=zN(),zt=ze(gt),Un=x(zt),on=_(zt,2),Or=x(on);Y(()=>{te(Un,f(tt).keys),te(Or,f(tt).description)}),T(Ve,gt)}),Y(()=>te(et,f(Ge).title)),T(xt,He)});var ut=_(bt,2),_t=x(ut);oe(_t,W);var _n=_(_t,2);mt(_n,21,()=>o,xt=>xt.keys+xt.description,(xt,Ge)=>{var He=FN(),Re=ze(He),et=x(Re),Ue=_(Re,2),Ve=x(Ue);Y(()=>{te(et,f(Ge).keys),te(Ve,f(Ge).description)}),T(xt,He)}),T(xe,Ye)},Pt=xe=>{var Ye=qN(),bt=ze(Ye),ut=x(bt),_t=x(ut),_n=_(ut,2);{var xt=tt=>{var gt=VN(),zt=x(gt);Y(()=>te(zt,f(y))),T(tt,gt)};J(_n,tt=>{f(y)&&tt(xt)})}var Ge=_(bt,2),He=x(Ge);oe(He,W);var Re=_(He,2);{var et=tt=>{var gt=UN();T(tt,gt)},Ue=tt=>{var gt=WN();mt(gt,21,D,zt=>zt.label,(zt,Un)=>{var on=jN(),Or=ze(on),Yi=x(Or),Lo=_(Or,2),Po=x(Lo);Y(()=>{te(Yi,f(Un).label),te(Po,f(Un).value)}),T(zt,on)}),T(tt,gt)},Ve=tt=>{var gt=KN();T(tt,gt)};J(Re,tt=>{p.loading?tt(et):p.info?tt(Ue,1):tt(Ve,-1)})}Y(()=>{ut.disabled=f(g)||p.loading,oe(ut,`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};`),te(_t,f(g)?"Opening…":"View Documentation")}),P("click",ut,()=>void C()),T(xe,Ye)};J(ye,xe=>{f(k)==="collaboration"?xe(ke):f(k)==="appearance"?xe(Ae,1):f(k)==="editor"?xe(Pe,2):f(k)==="network"?xe(lt,3):f(k)==="accessibility"?xe(At,4):f(k)==="claude-code"?xe(Se,5):f(k)==="shortcuts"?xe(vt,6):xe(Pt,-1)})}kt(X,xe=>b(c,xe),()=>f(c)),Y(xe=>{I.disabled=f(m)||p.loading,te(ae,f(m)?"Opening…":"Changelog"),Z(le,"href",iA),Z(B,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),te(pe,xe)},[()=>z(f(k))]),P("click",ne,function(...xe){var Ye;(Ye=e.onClose)==null||Ye.apply(this,xe)}),P("click",I,()=>void A()),P("click",fe,function(...xe){var Ye;(Ye=e.onClose)==null||Ye.apply(this,xe)}),T(R,K)};J(U,R=>{e.open&&R(ee)})}T(n,O),Je()}$e(["click","input","keydown","change"]);var ZN=E('<span class="toast-badge svelte-nsu1aw"> </span>'),GN=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>'),XN=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 QN(n,e){qe(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=Rt(),s=ze(o);{var a=l=>{var c=XN();mt(c,21,()=>e.toasts,d=>d.id,(d,u)=>{const h=H(()=>t[f(u).severity]),p=H(()=>r[f(u).severity]),m=H(()=>i[f(u).severity]),v=H(()=>f(u).severity==="info"?"status":"alert");var g=GN(),y=x(g),k=x(y),S=_(y,2);{var C=W=>{var z=ZN(),D=x(z);Y(()=>{Z(z,"data-testid",`toast-count-${f(u).id}`),oe(z,`margin-left: 6px; font-size: 11px; font-weight: 600; color: ${f(m)??""}; background: ${f(p)??""}; padding: 1px 5px; border-radius: var(--tandem-r-4);`),te(D,`×${f(u).count??""}`)}),T(W,z)};J(S,W=>{f(u).count>1&&W(C)})}var A=_(S,2);Y(()=>{Z(g,"role",f(v)),Z(g,"data-testid",`toast-${f(u).id}`),oe(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);`),te(k,f(u).message),Z(A,"data-testid",`toast-dismiss-${f(u).id}`)}),P("click",A,()=>e.onDismiss(f(u).id)),T(d,g)}),T(l,c)};J(s,l=>{e.toasts.length>0&&l(a)})}T(n,o),Je()}$e(["click"]);var $N=E('<div class="docx-canvas svelte-wm6yrp"><div class="docx-sheet svelte-wm6yrp"><!></div></div>');function eI(n,e){var t=$N(),r=x(t),i=x(r);Wm(i,()=>e.children),T(n,t)}const tI=Math.floor,nI=(n,e)=>n<e?n:e,rI=(n,e)=>n>e?n:e,Nk=128,Cd=127,iI=Number.MAX_SAFE_INTEGER,oI=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},Xl=typeof TextEncoder<"u"?new TextEncoder:null,sI=n=>Xl.encode(n),aI=Xl?sI:oI;let hl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});hl&&hl.decode(new Uint8Array).length===1&&(hl=null);const cu=(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},Sf=(n,e)=>{for(;e>Cd;)cu(n,Nk|Cd&e),e=tI(e/128);cu(n,Cd&e)},qp=new Uint8Array(3e4),lI=qp.length/3,cI=(n,e)=>{if(e.length<lI){const t=Xl.encodeInto(e,qp).written||0;Sf(n,t);for(let r=0;r<t;r++)cu(n,qp[r])}else hI(n,aI(e))},dI=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;Sf(n,r);for(let i=0;i<r;i++)cu(n,t.codePointAt(i))},uI=Xl&&Xl.encodeInto?cI:dI,fI=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=nI(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(rI(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},hI=(n,e)=>{Sf(n,e.byteLength),fI(n,e)},Ik=n=>new Error(n),pI=Ik("Unexpected end of array"),mI=Ik("Integer out of Range"),gI=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},vI=n=>gI(n,Ng(n)),fb=n=>n.arr[n.pos++],Ng=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&Cd)*t,t*=128,i<Nk)return e;if(e>iI)throw mI}throw pI},yI=n=>{let e=Ng(n);if(e===0)return"";{let t=String.fromCodePoint(fb(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(fb(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))}},bI=n=>hl.decode(vI(n)),hb=hl?bI:yI;var sa;(function(n){n[n.Token=0]="Token",n[n.PermissionDenied=1]="PermissionDenied",n[n.Authenticated=2]="Authenticated"})(sa||(sa={}));const wI=(n,e)=>{Sf(n,sa.Token),uI(n,e)},xI=(n,e,t,r)=>{switch(Ng(n)){case sa.Token:{e();break}case sa.PermissionDenied:{t(hb(n));break}case sa.Authenticated:{r(hb(n));break}}},pb=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t}));var Jp;(function(n){n[n.Connecting=0]="Connecting",n[n.Open=1]="Open",n[n.Closing=2]="Closing",n[n.Closed=3]="Closed"})(Jp||(Jp={}));function kI(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 Ch(n){return new Promise(e=>setTimeout(e,n))}function _I(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 SI(n,e){const t=kI(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||_I;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 Ch(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 Ch(s),r.attemptNum<1&&t.initialJitter){const a=i(r,t);a&&await Ch(a)}return o()}const Lk=Math.floor,CI=(n,e)=>n<e?n:e,TI=(n,e)=>n>e?n:e,AI=64,du=128,EI=63,pl=127,Pk=Number.MAX_SAFE_INTEGER,MI=()=>new Set,OI=Array.from,DI=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},Ql=typeof TextEncoder<"u"?new TextEncoder:null,RI=n=>Ql.encode(n),NI=Ql?RI:DI;let ml=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ml&&ml.decode(new Uint8Array).length===1&&(ml=null);class II{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Ig=()=>new II,zk=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},Lg=n=>{const e=new Uint8Array(zk(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},uu=(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},An=(n,e)=>{for(;e>pl;)uu(n,du|pl&e),e=Lk(e/128);uu(n,pl&e)},Yp=new Uint8Array(3e4),LI=Yp.length/3,PI=(n,e)=>{if(e.length<LI){const t=Ql.encodeInto(e,Yp).written||0;An(n,t);for(let r=0;r<t;r++)uu(n,Yp[r])}else qa(n,NI(e))},zI=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;An(n,r);for(let i=0;i<r;i++)uu(n,t.codePointAt(i))},qi=Ql&&Ql.encodeInto?PI:zI,BI=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=CI(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(TI(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},qa=(n,e)=>{An(n,e.byteLength),BI(n,e)},Bk=n=>new Error(n),Fk=Bk("Unexpected end of array"),Hk=Bk("Integer out of Range");class FI{constructor(e){this.arr=e,this.pos=0}}const Vk=n=>new FI(n),HI=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},Cf=n=>HI(n,us(n)),mb=n=>n.arr[n.pos++],us=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&pl)*t,t*=128,i<du)return e;if(e>Pk)throw Hk}throw Fk},VI=n=>{let e=n.arr[n.pos++],t=e&EI,r=64;const i=(e&AI)>0?-1:1;if((e&du)===0)return i*t;const o=n.arr.length;for(;n.pos<o;){if(e=n.arr[n.pos++],t=t+(e&pl)*r,r*=128,e<du)return i*t;if(t>Pk)throw Hk}throw Fk},UI=n=>{let e=us(n);if(e===0)return"";{let t=String.fromCodePoint(mb(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(mb(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))}},jI=n=>ml.decode(Cf(n)),$l=ml?jI:UI,WI=n=>{const e=n.pos,t=$l(n);return n.pos=e,t},Na=Date.now,Th=()=>new Map,KI=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r};class qI{constructor(){this._observers=Th()}on(e,t){KI(this._observers,e,MI).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 OI((this._observers.get(e)||Th()).values()).forEach(r=>r(...t))}destroy(){this._observers=Th()}}const JI=Object.keys,gb=n=>JI(n).length,YI=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),ZI=(n,e)=>n===e,gl=(n,e)=>{if(n==null||e==null)return ZI(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)||!gl(n.get(t),e.get(t)))return!1;break}case Object:if(gb(n)!==gb(e))return!1;for(const t in n)if(!YI(n,t)||!gl(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(!gl(n[t],e[t]))return!1;break;default:return!1}return!0},Ah=3e4;class GI extends qI{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Na();this.getLocalState()!==null&&Ah/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,o)=>{o!==this.clientID&&Ah<=t-i.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&Td(this,r,"timeout")},Lk(Ah/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:Na()});const s=[],a=[],l=[],c=[];e===null?c.push(t):o==null?e!=null&&s.push(t):(a.push(t),gl(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 Td=(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:Na()})}r.push(o)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},t]),n.emit("update",[{added:[],updated:[],removed:r},t]))},Zp=(n,e,t=n.states)=>{const r=e.length,i=Ig();An(i,r);for(let o=0;o<r;o++){const s=e[o],a=t.get(s)||null,l=n.meta.get(s).clock;An(i,s),An(i,l),qi(i,JSON.stringify(a))}return Lg(i)},XI=(n,e,t)=>{const r=Vk(e),i=Na(),o=[],s=[],a=[],l=[],c=us(r);for(let d=0;d<c;d++){const u=us(r);let h=us(r);const p=JSON.parse($l(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&&(gl(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 Uk=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 Gp{constructor(e){this.data=e,this.encoder=Ig(),this.decoder=Vk(new Uint8Array(this.data))}peekVarString(){return WI(this.decoder)}readVarUint(){return us(this.decoder)}readVarString(){return $l(this.decoder)}readVarUint8Array(){return Cf(this.decoder)}writeVarUint(e){return An(this.encoder,e)}writeVarString(e){return qi(this.encoder,e)}writeVarUint8Array(e){return qa(this.encoder,e)}length(){return zk(this.encoder)}}var mn;(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"})(mn||(mn={}));var In;(function(n){n.Connecting="connecting",n.Connected="connected",n.Disconnected="disconnected"})(In||(In={}));class zs{constructor(){this.encoder=Ig()}get(e){return e.encoder}toUint8Array(){return Lg(this.encoder)}}class QI extends zs{constructor(){super(...arguments),this.type=mn.CLOSE,this.description="Ask the server to close the connection"}get(e){return qi(this.encoder,e.documentName),An(this.encoder,this.type),this.encoder}}class $I extends Uk{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=In.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=In.Connected,this.emit("status",{status:In.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===In.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===In.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(QI,{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===In.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const e=()=>{let i=!1;return{retryPromise:SI(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=In.Connecting,this.emit("status",{status:In.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){var t;this.resolveConnectionAttempt(),this.lastMessageReceived=Na();const i=new Gp(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=In.Connected,this.emit("status",{status:In.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===In.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Na()-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)===Jp.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=In.Disconnected,this.emit("status",{status:In.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 jk=0,Pg=1,Wk=2,eL=(n,e)=>{An(n,jk);const t=OO(e);qa(n,t)},tL=(n,e,t)=>{An(n,Pg),qa(n,TO(e,t))},nL=(n,e,t)=>tL(e,t,Cf(n)),Kk=(n,e,t)=>{try{_O(e,Cf(n),t)}catch(r){console.error("Caught error while handling a Yjs update",r)}},rL=(n,e)=>{An(n,Wk),qa(n,e)},iL=Kk,oL=(n,e,t,r)=>{const i=us(n);switch(i){case jk:nL(n,e,t);break;case Pg:Kk(n,t,r);break;case Wk:iL(n,t,r);break;default:throw new Error("Unknown message type")}return i};class sL{constructor(e){this.message=e}apply(e,t){const{message:r}=this,i=r.readVarUint(),o=r.length();switch(i){case mn.Sync:this.applySyncMessage(e,t);break;case mn.Awareness:this.applyAwarenessMessage(e);break;case mn.Auth:this.applyAuthMessage(e);break;case mn.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case mn.Stateless:e.receiveStateless($l(r.decoder));break;case mn.SyncStatus:this.applySyncStatusMessage(e,VI(r.decoder)===1);break;case mn.CLOSE:const s={code:1e3,reason:$l(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(zs,{encoder:r.encoder})}applySyncMessage(e,t){const{message:r}=this;r.writeVarUint(mn.Sync);const i=oL(r.decoder,r.encoder,e.document,e);t&&i===Pg&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;XI(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;xI(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(mn.Awareness),t.writeVarUint8Array(Zp(e.awareness,Array.from(e.awareness.getStates().keys())))}}class aL{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Lg(this.encoder)}send(e){e==null||e.send(this.create())}}class lL extends zs{constructor(){super(...arguments),this.type=mn.Auth,this.description="Authentication"}get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return qi(this.encoder,e.documentName),An(this.encoder,this.type),wI(this.encoder,e.token),this.encoder}}class vb extends zs{constructor(){super(...arguments),this.type=mn.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");qi(this.encoder,e.documentName),An(this.encoder,this.type);let t;return e.states===void 0?t=Zp(e.awareness,e.clients):t=Zp(e.awareness,e.clients,e.states),qa(this.encoder,t),this.encoder}}class cL extends zs{constructor(){super(...arguments),this.type=mn.Stateless,this.description="A stateless message"}get(e){var t;return qi(this.encoder,e.documentName),An(this.encoder,this.type),qi(this.encoder,(t=e.payload)!==null&&t!==void 0?t:""),this.encoder}}class yb extends zs{constructor(){super(...arguments),this.type=mn.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 qi(this.encoder,e.documentName),An(this.encoder,this.type),eL(this.encoder,e.document),this.encoder}}class dL extends zs{constructor(){super(...arguments),this.type=mn.Sync,this.description="A document update"}get(e){return qi(this.encoder,e.documentName),An(this.encoder,this.type),rL(this.encoder,e.update),this.encoder}}class uL extends Error{constructor(){super(...arguments),this.code=1001}}class bb extends Uk{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 hi,this.configuration.awareness=e.awareness!==void 0?e.awareness:new GI(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:pb(this.awareness.getStates())})}),(r=this.awareness)===null||r===void 0||r.on("change",()=>{this.emit("awarenessChange",{states:pb(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 $I(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(yb,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Td(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(cL,{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(lL,{token:e??"",documentName:this.configuration.name})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(dL,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:t,removed:r},i){const o=e.concat(t).concat(r);this.send(vb,{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(yb,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(vb,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t){if(!this._isAttached)return;const r=new aL(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new Gp(e.data),r=t.readVarString();t.writeVarString(r),this.emit("message",{event:e,message:new Gp(e.data)}),new sL(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Td(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&&(Td(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 uL(`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 vn=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ia=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Xp=null;const Ei=function(n,e,t){let r=Xp||(Xp=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},fL=function(){Xp=null},Ts=function(n,e,t,r){return t&&(wb(n,e,t,r,-1)||wb(n,e,t,r,1))},hL=/^(img|br|input|textarea|hr)$/i;function wb(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:yr(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Dc(n)||hL.test(n.nodeName)||n.contentEditable=="false")return!1;e=vn(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?yr(n):0}else return!1}}function yr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function pL(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=yr(n)}else if(n.parentNode&&!Dc(n))e=vn(n),n=n.parentNode;else return null}}function mL(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&&!Dc(n))e=vn(n)+1,n=n.parentNode;else return null}}function gL(n,e,t){for(let r=e==0,i=e==yr(n);r||i;){if(n==t)return!0;let o=vn(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==yr(n)}}function Dc(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 Tf=function(n){return n.focusNode&&Ts(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Uo(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function vL(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function yL(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(yr(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(yr(r.startContainer),r.startOffset)}}}const pi=typeof navigator<"u"?navigator:null,xb=typeof document<"u"?document:null,No=pi&&pi.userAgent||"",Qp=/Edge\/(\d+)/.exec(No),qk=/MSIE \d/.exec(No),$p=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(No),Zn=!!(qk||$p||Qp),yo=qk?document.documentMode:$p?+$p[1]:Qp?+Qp[1]:0,_r=!Zn&&/gecko\/(\d+)/i.test(No);_r&&+(/Firefox\/(\d+)/.exec(No)||[0,0])[1];const em=!Zn&&/Chrome\/(\d+)/.exec(No),wn=!!em,Jk=em?+em[1]:0,Mn=!Zn&&!!pi&&/Apple Computer/.test(pi.vendor),La=Mn&&(/Mobile\/\w+/.test(No)||!!pi&&pi.maxTouchPoints>2),hr=La||(pi?/Mac/.test(pi.platform):!1),Yk=pi?/Win/.test(pi.platform):!1,Ii=/Android \d/.test(No),Rc=!!xb&&"webkitFontSmoothing"in xb.documentElement.style,bL=Rc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function wL(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 ki(n,e){return typeof n=="number"?n:n[e]}function xL(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 kb(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=Ia(s);continue}let a=s,l=a==o.body,c=l?wL(o):xL(a),d=0,u=0;if(e.top<c.top+ki(r,"top")?u=-(c.top-e.top+ki(i,"top")):e.bottom>c.bottom-ki(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+ki(i,"top")-c.top:e.bottom-c.bottom+ki(i,"bottom")),e.left<c.left+ki(r,"left")?d=-(c.left-e.left+ki(i,"left")):e.right>c.right-ki(r,"right")&&(d=e.right-c.right+ki(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:Ia(s)}}function kL(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:Zk(n.dom)}}function Zk(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Ia(r));return e}function _L({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Gk(t,r==0?0:r-e)}function Gk(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 Hs=null;function SL(n){if(n.setActive)return n.setActive();if(Hs)return n.focus(Hs);let e=Zk(n);n.focus(Hs==null?{get preventScroll(){return Hs={preventScroll:!0},!0}}:void 0),Hs||(Hs=!1,Gk(e,0))}function Xk(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=Ei(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?CL(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Xk(t,i)}function CL(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=Xi(r,1);if(s.top!=s.bottom&&zg(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 zg(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function TL(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function AL(n,e,t){let{node:r,offset:i}=Xk(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 EL(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 Qk(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(zg(e,c))return Qk(s,e,c)}}if((o=(o+1)%r)==i)break}return n}function ML(n,e){let t=n.dom.ownerDocument,r,i=0,o=yL(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(!zg(e,c)||(s=Qk(n.dom,e,c),!s))return null}if(Mn)for(let c=s;r&&c;c=Ia(c))c.draggable&&(r=void 0);if(s=TL(s,e),r){if(_r&&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;Rc&&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=EL(n,r,i,e))}a==null&&(a=AL(n,s,e));let l=n.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function _b(n){return n.top<n.bottom||n.left<n.right}function Xi(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(_b(r))return r}return Array.prototype.find.call(t,_b)||n.getBoundingClientRect()}const OL=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function $k(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=Rc||_r;if(r.nodeType==3)if(s&&(OL.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let l=Xi(Ei(r,i,i),t);if(_r&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Xi(Ei(r,i-1,i-1),-1);if(c.top==l.top){let d=Xi(Ei(r,i,i+1),-1);if(d.top!=l.top)return $a(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++,$a(Xi(Ei(r,l,c),d),d<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==yr(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return Eh(l.getBoundingClientRect(),!1)}if(o==null&&i<yr(r)){let l=r.childNodes[i];if(l.nodeType==1)return Eh(l.getBoundingClientRect(),!0)}return Eh(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==yr(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Ei(l,yr(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return $a(Xi(c,1),!1)}if(o==null&&i<yr(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Ei(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return $a(Xi(c,-1),!0)}return $a(Xi(r.nodeType==3?Ei(r):r,-t),t>=0)}function $a(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 Eh(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 e_(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 DL(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return e_(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=$k(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=Ei(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 RL=/[\u0590-\u08ac]/;function NL(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?!RL.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?o:s:e_(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 Sb=null,Cb=null,Tb=!1;function IL(n,e,t){return Sb==e&&Cb==t?Tb:(Sb=e,Cb=t,Tb=t=="up"||t=="down"?DL(n,e,t):NL(n,e,t))}const Sr=0,Ab=1,Yo=2,mi=3;class Nc{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Sr,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>vn(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 n_){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 t_&&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?vn(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?vn(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=vn(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=vn(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((_r||Mn)&&e==t){let{node:p,offset:m}=a;if(p.nodeType==3){if(u=!!(m&&p.nodeValue[m-1]==`
|
|
91
|
+
`),Z(q,"title",f(R).text),te(V,f(R).text||"(untitled)")}),P("click",q,()=>g(f(R),K)),wt("focus",q,()=>b(l,K,!0)),wt("mouseenter",q,M=>{f(ne)||(M.currentTarget.style.background="var(--tandem-surface-hover, var(--tandem-surface-muted))")}),wt("mouseleave",q,M=>{f(ne)||(M.currentTarget.style.background="none")}),T(ee,N)}),T(O,U)};J(W,O=>{f(a).length===0?O(z):O(D,-1)})}P("keydown",k,y),P("input",C,p),P("keydown",C,m),ys(C,()=>f(d),O=>b(d,O)),T(n,k),Je()}$e(["keydown","input","click"]);var iN=E("<div><!></div>");function Fs(n,e){qe(e,!0);let t=ST(e,["$$slots","$$events","$$legacy","kind","visible"]);const r=H(()=>e.visible!==void 0?`display: ${e.visible?"flex":"none"}; flex-direction: column; flex: 1; min-height: 0;`:void 0);var i=Rt(),o=ze(i);{var s=d=>{var u=iN(),h=x(u);{var p=g=>{ab(g,Bc(()=>t,{get visible(){return e.visible}}))},m=g=>{ub(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=>{db(g,Bc(()=>t))};J(h,g=>{e.kind==="chat"?g(p):e.kind==="outline"?g(m,1):g(v,-1)})}Y(()=>se(u,f(r))),T(d,u)},a=d=>{ab(d,Bc(()=>t))},l=d=>{ub(d,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType}})},c=d=>{db(d,Bc(()=>t))};J(o,d=>{f(r)?d(s):e.kind==="chat"?d(a,1):e.kind==="outline"?d(l,2):d(c,-1)})}T(n,i),Je()}var oN=E('<span style="color: var(--tandem-error-fg-strong); font-size: 12px; max-width: 200px;"> </span>'),sN=E('<button type="button" data-testid="convert-to-markdown-btn"> </button>'),aN=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
|
|
92
|
+
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 lN(n,e){qe(e,!0);const t="tandem:reviewOnlyBannerDismissed";function r(){try{return localStorage.getItem(t)==="true"}catch{return!1}}let i=F(dt(r())),o=F(!1),s=F(null);async function a(){if(!(!e.documentId||f(o))){b(o,!0),b(s,null);try{const h=await fetch(`${Tr}/convert`,{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=Rt(),d=ze(c);{var u=h=>{var p=aN(),m=_(x(p),2),v=x(m);{var g=C=>{var A=oN(),W=x(A);Y(()=>te(W,f(s))),T(C,A)};J(v,C=>{f(s)&&C(g)})}var y=_(v,2);{var k=C=>{var A=sN(),W=x(A);Y(()=>{A.disabled=f(o),se(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};`),te(W,f(o)?"Converting…":"Convert to Markdown")}),P("click",A,a),T(C,A)};J(y,C=>{e.documentId&&C(k)})}var S=_(y,2);P("click",S,l),T(h,p)};J(d,h=>{e.visible&&!f(i)&&h(u)})}T(n,c),Je()}$e(["click"]);let Sh=null;async function cN(n){if(Sh!==null)return Sh;const e=await fetch(`${Tr}/info`,{signal:n});if(!e.ok)throw new Error(`/api/info responded ${e.status} ${e.statusText}`);const t=await e.json();return Sh=t,t}function Ok(n){let e=F(null),t=F(!1);return de(()=>{if(!n())return;let r=!1;const i=new AbortController,o=setTimeout(()=>i.abort(),3e3);return b(t,!0),cN(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)}}}function Dg(n){const e=n==null?void 0:n.trim();return e?e.slice(0,Gm):fx}function Rg(){try{return Dg(localStorage.getItem(Zm))}catch{return fx}}function dN(n){const e=Dg(n);try{localStorage.setItem(Zm,e)}catch{}return typeof window<"u"&&window.dispatchEvent(new Event(wp)),e}function Dk(n){const e=()=>n(Rg()),t=r=>{r.key===Zm&&n(Dg(r.newValue))};return window.addEventListener(wp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(wp,e),window.removeEventListener("storage",t)}}function Rk(){let n=F(dt(Rg()));const e=Dk(r=>{b(n,r,!0)});return yi(e),{get userName(){return f(n)},setUserName:r=>{const i=dN(r);b(n,i,!0)}}}var uN=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 fN(n,e){qe(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=uN(),i=ze(r),o=x(i);se(o,t);var s=_(o,2),a=x(s),l=_(i,2),c=x(l);se(c,t);var d=_(c,2),u=x(d);Y(()=>{vs(a,e.settings.highContrast),vs(u,e.settings.annotationPatterns)}),P("change",a,h=>e.onUpdate({highContrast:h.target.checked})),P("change",u,h=>e.onUpdate({annotationPatterns:h.target.checked})),T(n,r),Je()}$e(["change"]);function Qa(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 hN=E('<button role="radio"> </button>'),pN=E('<button role="radio"> </button>'),mN=E('<button role="radio"> </button>'),gN=E('<button role="radio"> </button>'),vN=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 yN(n,e){qe(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(L,V){return["flex: 1;","padding: var(--tandem-space-2);","min-height: 24px;",`border: 2px solid ${L?"var(--tandem-accent)":"var(--tandem-border)"};`,"border-radius: var(--tandem-r-3);",`background: ${L?"var(--tandem-accent-bg)":"var(--tandem-surface)"};`,"cursor: pointer;","text-align: center;","font-size: 11px;",`color: ${L?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"};`,`font-weight: ${L?600:400};`,"opacity: 1;","transition: border-color 0.15s, background 0.15s;"].join(" ")}const i=Qa(()=>e.settings.theme,["light","dark","system"],L=>e.onUpdate({theme:L})),o=Qa(()=>e.settings.primaryTab,["chat","annotations"],L=>e.onUpdate({primaryTab:L})),s=Qa(()=>e.settings.textSize,["s","m","l"],L=>e.onUpdate({textSize:L})),a=Qa(()=>e.settings.editorFont,["sans","serif","mono"],L=>e.onUpdate({editorFont:L})),l=Qa(()=>e.settings.density,["compact","cozy","spacious"],L=>e.onUpdate({density:L}));var c=vN(),d=ze(c),u=x(d);se(u,t);var h=_(u,2);mt(h,20,()=>["light","dark","system"],L=>L,(L,V)=>{var re=hN(),w=x(re);Y((M,I)=>{Z(re,"data-testid",`theme-${V}-btn`),Z(re,"aria-checked",e.settings.theme===V),Z(re,"tabindex",M),se(re,I),te(w,V==="light"?"Light":V==="dark"?"Dark":"System")},[()=>i.tabIndexFor(V),()=>r(e.settings.theme===V)]),P("click",re,()=>e.onUpdate({theme:V})),T(L,re)});var p=_(d,2),m=x(p);se(m,t);var v=_(m,2),g=x(v),y=_(g,2),k=_(p,2),S=x(k);se(S,t);var C=_(S,2);mt(C,20,()=>["s","m","l"],L=>L,(L,V)=>{var re=pN(),w=x(re);Y((M,I)=>{Z(re,"data-testid",`text-size-${V}-btn`),Z(re,"aria-checked",e.settings.textSize===V),Z(re,"tabindex",M),se(re,I),te(w,V==="s"?"Small":V==="m"?"Medium":"Large")},[()=>s.tabIndexFor(V),()=>r(e.settings.textSize===V)]),P("click",re,()=>e.onUpdate({textSize:V})),T(L,re)});var A=_(k,2),W=x(A);se(W,t);var z=_(W,2),D=_(x(z),2),O=_(A,2),U=x(O);se(U,t);var ee=_(U,2);mt(ee,20,()=>[["sans","Sans-serif"],["serif","Serif"],["mono","Monospace"]],([L,V])=>L,(L,V)=>{var re=H(()=>Sv(V,2));let w=()=>f(re)[0],M=()=>f(re)[1];var I=mN(),ae=x(I);Y((ve,ue)=>{Z(I,"data-testid",`editor-font-${w()}-btn`),Z(I,"aria-checked",e.settings.editorFont===w()),Z(I,"tabindex",ve),se(I,ue),te(ae,M())},[()=>a.tabIndexFor(w()),()=>r(e.settings.editorFont===w())]),P("click",I,()=>e.onUpdate({editorFont:w()})),T(L,I)});var R=_(O,2),K=x(R);se(K,t);var ne=_(K,2);mt(ne,20,()=>[["compact","Compact"],["cozy","Cozy"],["spacious","Spacious"]],([L,V])=>L,(L,V)=>{var re=H(()=>Sv(V,2));let w=()=>f(re)[0],M=()=>f(re)[1];var I=gN(),ae=x(I);Y((ve,ue)=>{Z(I,"data-testid",`density-${w()}-btn`),Z(I,"aria-checked",e.settings.density===w()),Z(I,"tabindex",ve),se(I,ue),te(ae,M())},[()=>l.tabIndexFor(w()),()=>r(e.settings.density===w())]),P("click",I,()=>e.onUpdate({density:w()})),T(L,I)});var X=_(R,2),N=x(X),q=x(N);Y((L,V,re,w)=>{Z(g,"aria-checked",e.settings.primaryTab==="chat"),Z(g,"tabindex",L),se(g,V),Z(y,"aria-checked",e.settings.primaryTab==="annotations"),Z(y,"tabindex",re),se(y,w),Pr(D,e.settings.accentHue),vs(q,e.settings.reduceMotion)},[()=>o.tabIndexFor("chat"),()=>r(e.settings.primaryTab==="chat"),()=>o.tabIndexFor("annotations"),()=>r(e.settings.primaryTab==="annotations")]),P("keydown",h,function(...L){var V;(V=i.handleKeyDown)==null||V.apply(this,L)}),P("keydown",v,function(...L){var V;(V=o.handleKeyDown)==null||V.apply(this,L)}),P("click",g,()=>e.onUpdate({primaryTab:"chat"})),P("click",y,()=>e.onUpdate({primaryTab:"annotations"})),P("keydown",C,function(...L){var V;(V=s.handleKeyDown)==null||V.apply(this,L)}),P("input",D,L=>e.onUpdate({accentHue:Number(L.target.value)})),P("keydown",ee,function(...L){var V;(V=a.handleKeyDown)==null||V.apply(this,L)}),P("keydown",ne,function(...L){var V;(V=l.handleKeyDown)==null||V.apply(this,L)}),P("change",q,L=>e.onUpdate({reduceMotion:L.target.checked})),T(n,c),Je()}$e(["keydown","click","input","change"]);var bN=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 wN(n,e){qe(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=bN(),i=x(r);se(i,t);var o=_(x(i)),s=x(o),a=_(i,4);Z(a,"min",40),Z(a,"max",100),Z(a,"step",5),Y(()=>{te(s,`${e.settings.editorWidthPercent??""}%`),Pr(a,e.settings.editorWidthPercent)}),P("input",a,l=>e.onUpdate({editorWidthPercent:Number(l.target.value)})),T(n,r),Je()}$e(["input"]);var xN=E('<span style="color: var(--tandem-fg-subtle);"> </span>'),kN=E('<button type="button" data-testid="network-restart-sidecar"> </button>'),_N=E('<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop && tandem start</code> to restart</span>'),SN=E('<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>'),CN=E("<span><strong>Host:</strong> </span>"),TN=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>'),AN=E("<option> </option>"),EN=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>'),MN=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 ON(n,e){qe(e,!0);const t=Ok(()=>e.open),r=Ar();let i=F(null),o=F(!1);async function s(){if(r){b(o,!0),b(i,null);try{const{invoke:Q}=await Co(async()=>{const{invoke:pe}=await import("./core-DhEqZVGG.js");return{invoke:pe}},[]);await Q("restart_sidecar")}catch(Q){b(i,Q instanceof Error?Q.message:String(Q),!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=H(()=>{var Q;return(Q=t.info)==null?void 0:Q.transport}),h=H(()=>{var Q;return(Q=t.info)==null?void 0:Q.bindHost}),p=H(()=>{var Q;return(Q=t.info)==null?void 0:Q.bindPort}),m=H(()=>f(u)==="http"),v=H(()=>{var Q;return(Q=t.info)==null?void 0:Q.tokenRotatedAt});var g=MN(),y=ze(g),k=x(y);se(k,l);var S=_(k,2),C=x(S),A=_(C,2),W=x(A),z=_(W);{var D=Q=>{var pe=xN(),fe=x(pe);Y(()=>te(fe,`· ${e.reconnectAttempts??""} retry attempt${e.reconnectAttempts===1?"":"s"}`)),T(Q,pe)};J(z,Q=>{e.reconnectAttempts>0&&Q(D)})}var O=_(A,2);{var U=Q=>{var pe=kN(),fe=x(pe);Y(()=>{pe.disabled=f(o),se(pe,`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};`),te(fe,f(o)?"Restarting…":"Restart sidecar")}),P("click",pe,s),T(Q,pe)},ee=Q=>{var pe=_N();T(Q,pe)};J(O,Q=>{r?Q(U):Q(ee,-1)})}var R=_(S,2);{var K=Q=>{var pe=SN(),fe=x(pe);Y(()=>te(fe,f(i))),T(Q,pe)};J(R,Q=>{f(i)&&Q(K)})}var ne=_(y,2),X=x(ne);se(X,l);var N=_(X,2),q=x(N),L=_(x(q)),V=_(q,2);{var re=Q=>{var pe=CN(),fe=_(x(pe));Y(()=>te(fe,` ${f(h)??""}`)),T(Q,pe)};J(V,Q=>{f(h)&&Q(re)})}var w=_(ne,2);{var M=Q=>{var pe=TN(),fe=x(pe);se(fe,l);var Le=_(fe,2),Ie=x(Le),ye=_(Le,2);se(ye,d),Y(()=>te(Ie,f(p)??"—")),T(Q,pe)};J(w,Q=>{f(m)&&Q(M)})}var I=_(w,2),ae=x(I);se(ae,l);var ve=_(x(ae)),ue=x(ve),le=_(ae,2),he=_(I,2),B=x(he);se(B,l);var G=_(B,2);mt(G,21,()=>a,Q=>Q.value,(Q,pe)=>{var fe=AN(),Le=x(fe),Ie={};Y(()=>{te(Le,f(pe).label),Ie!==(Ie=f(pe).value)&&(fe.value=(fe.__value=f(pe).value)??"")}),T(Q,fe)});var be;ex(G);var Te=_(he,2);se(Te,c);var De=x(Te),Ee=_(Te,2);se(Ee,d);var oe=_(Ee,2);{var $=Q=>{var pe=EN(),fe=x(pe);se(fe,l);var Le=_(fe,2),Ie=x(Le),ye=_(Le,2);se(ye,d),Y(ke=>te(Ie,ke),[()=>f(v)===null?"Auth token not yet created":`Last rotated: ${new Date(f(v)).toLocaleString()}`]),T(Q,pe)};J(oe,Q=>{f(v)!==void 0&&Q($)})}Y(Q=>{se(C,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${e.connected?"var(--tandem-success)":"var(--tandem-error)"}; flex-shrink: 0;`),te(W,`${e.connected?"Connected to claude-sidecar":"Disconnected"} `),te(L,` ${Q??""}`),te(ue,`${e.settings.degradedBannerDelayMs/1e3}s`),Pr(le,e.settings.degradedBannerDelayMs),be!==(be=e.settings.sidecarRetryStrategy)&&(G.value=(G.__value=e.settings.sidecarRetryStrategy)??"",Km(G,e.settings.sidecarRetryStrategy)),vs(De,e.settings.holdAnnotationsWhileOffline)},[()=>f(u)?f(u).toUpperCase():"—"]),P("input",le,Q=>e.onUpdate({degradedBannerDelayMs:Number(Q.target.value)})),P("change",G,Q=>e.onUpdate({sidecarRetryStrategy:Q.target.value})),P("change",De,Q=>e.onUpdate({holdAnnotationsWhileOffline:Q.target.checked})),T(n,g),Je()}$e(["click","input","change"]);var DN=E('<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>'),RN=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>'),NN=E('<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),IN=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
|
|
93
|
+
restores when you return to Tandem.</div>`,1),LN=E('<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),PN=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> <!>',1),zN=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),BN=E('<section><div> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section>'),FN=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),HN=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>'),VN=E('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),UN=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),jN=E('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),WN=E('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),KN=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),qN=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),JN=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 YN(n,e){qe(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=H(()=>{const R=jd(),K=new Map;for(const ne of R.values()){if(!ne.shortcut)continue;const X=ne.group,N=K.get(X)??[];N.push({keys:ne.shortcut,description:ne.label}),K.set(X,N)}return gx.map(ne=>({title:ne.charAt(0).toUpperCase()+ne.slice(1),rows:K.get(ne)??[]})).filter(ne=>ne.rows.length>0)});let a=ft(e,"connected",3,!1),l=ft(e,"reconnectAttempts",3,0),c=F(void 0),d=F(void 0);const u=Rk();let h=F(dt(u.userName));const p=Ok(()=>e.open);let m=F(!1),v=F(null),g=F(!1),y=F(null),k=F("appearance");de(()=>{f(k),f(v)!==null&&b(v,null),f(y)!==null&&b(y,null)}),de(()=>{const R=u.userName;f(h)!==R&&document.activeElement!==f(d)&&b(h,R,!0)}),de(()=>{var R;if(e.open)return(R=f(c))==null||R.focus(),()=>{var K;(K=e.returnFocusEl)==null||K.focus()}}),de(()=>{if(!e.open)return;const R=ne=>{var N;const X=ne.target;(N=e.anchorEl)!=null&&N.contains(X)||f(c)&&!f(c).contains(X)&&e.onClose()},K=setTimeout(()=>document.addEventListener("pointerdown",R),0);return()=>{clearTimeout(K),document.removeEventListener("pointerdown",R)}}),de(()=>{if(!e.open)return;const R=K=>{if(K.key==="Escape"){e.onClose();return}if(K.key!=="Tab"||!f(c))return;const ne=f(c).querySelectorAll(r);if(ne.length===0)return;const X=ne[0],N=ne[ne.length-1],q=document.activeElement;if(!f(c).contains(q)){K.preventDefault(),X.focus();return}K.shiftKey&&q===X?(K.preventDefault(),N.focus()):!K.shiftKey&&q===N&&(K.preventDefault(),X.focus())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)});async function S(R,K,ne,X){if(!R){ne(X.notFound);return}K(!0),ne(null);try{const N=await fetch(`${Tr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:R,readOnly:!0})});if(!N.ok){let q=X.failed;try{const L=await N.json();L.message&&(q=L.message)}catch{}N.status===404&&(q=X.notFound),ne(q);return}e.onClose()}catch(N){console.warn("[Tandem] Failed to open read-only file:",N),ne("Server unavailable.")}finally{K(!1)}}function C(){var R;return S((R=p.info)==null?void 0:R.workflowsPath,K=>b(g,K,!0),K=>b(y,K,!0),{notFound:"Documentation file not found.",failed:"Failed to open documentation."})}function A(){var R;return S((R=p.info)==null?void 0:R.changelogPath,K=>b(m,K,!0),K=>b(v,K,!0),{notFound:"Changelog file not found.",failed:"Failed to open changelog."})}const W="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";function z(R){var K;return((K=i.find(ne=>ne.id===R))==null?void 0:K.label)??"Settings"}function D(){var ne;const R=p.info;if(!R)return[];const K=[{label:"Version",value:`Tandem v${R.version}`},{label:"Tools",value:R.toolCount===null?"Tool count unavailable":`${R.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${R.mcpSdkVersion}`},{label:"Transport",value:((ne=R.transport)==null?void 0:ne.toUpperCase())??"—"}];return R.storagePath&&K.push({label:"Storage",value:R.storagePath}),R.tokenRotatedAt!==void 0&&K.push({label:"Token",value:R.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(R.tokenRotatedAt).toLocaleString()}`}),R.changelogPath&&K.push({label:"Changelog",value:R.changelogPath}),K}var O=Rt(),U=ze(O);{var ee=R=>{var K=JN(),ne=ze(K),X=_(ne,2);Z(X,"aria-labelledby",t),Z(X,"tabindex",-1);var N=x(X),q=x(N),L=x(q);Z(L,"id",t);var V=_(L,2);{var re=xe=>{var Ye=DN(),bt=x(Ye);Y(()=>te(bt,`v${p.info.version??""}`)),T(xe,Ye)};J(V,xe=>{p.info&&xe(re)})}var w=_(q,2);mt(w,21,()=>i,xe=>xe.id,(xe,Ye)=>{var bt=RN(),ut=x(bt),_t=x(ut),_n=_(ut,2),xt=x(_n);Y(()=>{Z(bt,"aria-current",f(k)===f(Ye).id?"page":void 0),Z(bt,"data-active",f(k)===f(Ye).id?"true":"false"),Z(_t,"d",f(Ye).icon),te(xt,f(Ye).label)}),P("click",bt,()=>b(k,f(Ye).id,!0)),T(xe,bt)});var M=_(w,2),I=x(M),ae=x(I),ve=_(I,2);{var ue=xe=>{var Ye=NN(),bt=x(Ye);Y(()=>te(bt,f(v))),T(xe,Ye)};J(ve,xe=>{f(v)&&xe(ue)})}var le=_(ve,2),he=_(le,2),B=x(he),G=_(B,2),be=x(G);{var Te=xe=>{var Ye=an("MCP connected");T(xe,Ye)},De=xe=>{var Ye=an("Reconnecting…");T(xe,Ye)},Ee=xe=>{var Ye=an("MCP offline");T(xe,Ye)};J(be,xe=>{a()?xe(Te):l()>0?xe(De,1):xe(Ee,-1)})}var oe=_(N,2),$=x(oe),Q=x($),pe=x(Q),fe=_(Q,2),Le=_($,2),Ie=x(Le),ye=x(Ie);{var ke=xe=>{var Ye=IN(),bt=ze(Ye),ut=x(bt);se(ut,W);var _t=_(ut,2);kt(_t,Ve=>b(d,Ve),()=>f(d));var _n=_(bt,2),xt=x(_n);se(xt,W);var Ge=_(xt,2),He=x(Ge),Re=_(He,2),et=_(_n,2),Ue=x(et);Y(()=>{Pr(_t,f(h)),Z(_t,"maxlength",Gm),Z(He,"aria-checked",e.settings.defaultMode==="tandem"),se(He,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="tandem"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="tandem"?600:400}; cursor: pointer;`),Z(Re,"aria-checked",e.settings.defaultMode==="solo"),se(Re,`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;`),vs(Ue,e.settings.soloRailHidden)}),P("input",_t,Ve=>{b(h,Ve.target.value,!0)}),wt("blur",_t,()=>u.setUserName(f(h))),P("keydown",_t,Ve=>{Ve.key==="Enter"&&Ve.currentTarget.blur(),Ve.key==="Escape"&&(b(h,u.userName,!0),Ve.currentTarget.blur())}),P("click",He,()=>e.onUpdate({defaultMode:"tandem"})),P("click",Re,()=>e.onUpdate({defaultMode:"solo"})),P("change",Ue,Ve=>e.onUpdate({soloRailHidden:Ve.target.checked})),T(xe,Ye)},Ae=xe=>{yN(xe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},Pe=xe=>{wN(xe,{get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},lt=xe=>{ON(xe,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return a()},get reconnectAttempts(){return l()}})},At=xe=>{fN(xe,{get settings(){return e.settings},get onUpdate(){return e.onUpdate}})},Se=xe=>{var Ye=PN(),bt=ze(Ye),ut=x(bt);se(ut,W);var _t=_(x(ut)),_n=x(_t),xt=_(ut,4);Z(xt,"step",100);var Ge=_(xt,2),He=x(Ge),Re=x(He),et=_(He,2),Ue=x(et),Ve=_(bt,2),tt=x(Ve),gt=_(Ve,2);{var Bt=on=>{var Or=Rt(),Yi=ze(Or);dT(Yi,()=>Co(()=>import("./CoworkSettings-DK3jjdwK.js"),[]),Lo=>{var Po=LN();T(Lo,Po)},(Lo,Po)=>{const Ic=H(()=>f(Po).default);var Lc=Rt(),Vf=ze(Lc);gT(Vf,()=>f(Ic),(Uf,jf)=>{jf(Uf,{})}),T(Lo,Lc)}),T(on,Or)},Un=H(()=>Ar());J(gt,on=>{f(Un)&&on(Bt)})}Y((on,Or,Yi)=>{te(_n,`${on??""}s`),Z(xt,"min",Vd),Z(xt,"max",Ud),Pr(xt,e.settings.selectionDwellMs),te(Re,`${Or??""}s`),te(Ue,`${Yi??""}s`),vs(tt,e.settings.selectionToolbar)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(Vd/1e3).toFixed(1),()=>(Ud/1e3).toFixed(1)]),P("input",xt,on=>e.onUpdate({selectionDwellMs:Number(on.target.value)})),P("change",tt,on=>e.onUpdate({selectionToolbar:on.target.checked})),T(xe,Ye)},vt=xe=>{var Ye=HN(),bt=x(Ye);mt(bt,17,()=>f(s),xt=>xt.title,(xt,Ge)=>{var He=BN(),Re=x(He);se(Re,W);var et=x(Re),Ue=_(Re,2);mt(Ue,21,()=>f(Ge).rows,Ve=>Ve.keys+Ve.description,(Ve,tt)=>{var gt=zN(),Bt=ze(gt),Un=x(Bt),on=_(Bt,2),Or=x(on);Y(()=>{te(Un,f(tt).keys),te(Or,f(tt).description)}),T(Ve,gt)}),Y(()=>te(et,f(Ge).title)),T(xt,He)});var ut=_(bt,2),_t=x(ut);se(_t,W);var _n=_(_t,2);mt(_n,21,()=>o,xt=>xt.keys+xt.description,(xt,Ge)=>{var He=FN(),Re=ze(He),et=x(Re),Ue=_(Re,2),Ve=x(Ue);Y(()=>{te(et,f(Ge).keys),te(Ve,f(Ge).description)}),T(xt,He)}),T(xe,Ye)},zt=xe=>{var Ye=qN(),bt=ze(Ye),ut=x(bt),_t=x(ut),_n=_(ut,2);{var xt=tt=>{var gt=VN(),Bt=x(gt);Y(()=>te(Bt,f(y))),T(tt,gt)};J(_n,tt=>{f(y)&&tt(xt)})}var Ge=_(bt,2),He=x(Ge);se(He,W);var Re=_(He,2);{var et=tt=>{var gt=UN();T(tt,gt)},Ue=tt=>{var gt=WN();mt(gt,21,D,Bt=>Bt.label,(Bt,Un)=>{var on=jN(),Or=ze(on),Yi=x(Or),Lo=_(Or,2),Po=x(Lo);Y(()=>{te(Yi,f(Un).label),te(Po,f(Un).value)}),T(Bt,on)}),T(tt,gt)},Ve=tt=>{var gt=KN();T(tt,gt)};J(Re,tt=>{p.loading?tt(et):p.info?tt(Ue,1):tt(Ve,-1)})}Y(()=>{ut.disabled=f(g)||p.loading,se(ut,`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};`),te(_t,f(g)?"Opening…":"View Documentation")}),P("click",ut,()=>void C()),T(xe,Ye)};J(ye,xe=>{f(k)==="collaboration"?xe(ke):f(k)==="appearance"?xe(Ae,1):f(k)==="editor"?xe(Pe,2):f(k)==="network"?xe(lt,3):f(k)==="accessibility"?xe(At,4):f(k)==="claude-code"?xe(Se,5):f(k)==="shortcuts"?xe(vt,6):xe(zt,-1)})}kt(X,xe=>b(c,xe),()=>f(c)),Y(xe=>{I.disabled=f(m)||p.loading,te(ae,f(m)?"Opening…":"Changelog"),Z(le,"href",iA),Z(B,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),te(pe,xe)},[()=>z(f(k))]),P("click",ne,function(...xe){var Ye;(Ye=e.onClose)==null||Ye.apply(this,xe)}),P("click",I,()=>void A()),P("click",fe,function(...xe){var Ye;(Ye=e.onClose)==null||Ye.apply(this,xe)}),T(R,K)};J(U,R=>{e.open&&R(ee)})}T(n,O),Je()}$e(["click","input","keydown","change"]);var ZN=E('<span class="toast-badge svelte-nsu1aw"> </span>'),GN=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>'),XN=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 QN(n,e){qe(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=Rt(),s=ze(o);{var a=l=>{var c=XN();mt(c,21,()=>e.toasts,d=>d.id,(d,u)=>{const h=H(()=>t[f(u).severity]),p=H(()=>r[f(u).severity]),m=H(()=>i[f(u).severity]),v=H(()=>f(u).severity==="info"?"status":"alert");var g=GN(),y=x(g),k=x(y),S=_(y,2);{var C=W=>{var z=ZN(),D=x(z);Y(()=>{Z(z,"data-testid",`toast-count-${f(u).id}`),se(z,`margin-left: 6px; font-size: 11px; font-weight: 600; color: ${f(m)??""}; background: ${f(p)??""}; padding: 1px 5px; border-radius: var(--tandem-r-4);`),te(D,`×${f(u).count??""}`)}),T(W,z)};J(S,W=>{f(u).count>1&&W(C)})}var A=_(S,2);Y(()=>{Z(g,"role",f(v)),Z(g,"data-testid",`toast-${f(u).id}`),se(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);`),te(k,f(u).message),Z(A,"data-testid",`toast-dismiss-${f(u).id}`)}),P("click",A,()=>e.onDismiss(f(u).id)),T(d,g)}),T(l,c)};J(s,l=>{e.toasts.length>0&&l(a)})}T(n,o),Je()}$e(["click"]);var $N=E('<div class="docx-canvas svelte-wm6yrp"><div class="docx-sheet svelte-wm6yrp"><!></div></div>');function eI(n,e){var t=$N(),r=x(t),i=x(r);Wm(i,()=>e.children),T(n,t)}const tI=Math.floor,nI=(n,e)=>n<e?n:e,rI=(n,e)=>n>e?n:e,Nk=128,Cd=127,iI=Number.MAX_SAFE_INTEGER,oI=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},Xl=typeof TextEncoder<"u"?new TextEncoder:null,sI=n=>Xl.encode(n),aI=Xl?sI:oI;let hl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});hl&&hl.decode(new Uint8Array).length===1&&(hl=null);const cu=(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},Sf=(n,e)=>{for(;e>Cd;)cu(n,Nk|Cd&e),e=tI(e/128);cu(n,Cd&e)},qp=new Uint8Array(3e4),lI=qp.length/3,cI=(n,e)=>{if(e.length<lI){const t=Xl.encodeInto(e,qp).written||0;Sf(n,t);for(let r=0;r<t;r++)cu(n,qp[r])}else hI(n,aI(e))},dI=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;Sf(n,r);for(let i=0;i<r;i++)cu(n,t.codePointAt(i))},uI=Xl&&Xl.encodeInto?cI:dI,fI=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=nI(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(rI(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},hI=(n,e)=>{Sf(n,e.byteLength),fI(n,e)},Ik=n=>new Error(n),pI=Ik("Unexpected end of array"),mI=Ik("Integer out of Range"),gI=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},vI=n=>gI(n,Ng(n)),fb=n=>n.arr[n.pos++],Ng=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&Cd)*t,t*=128,i<Nk)return e;if(e>iI)throw mI}throw pI},yI=n=>{let e=Ng(n);if(e===0)return"";{let t=String.fromCodePoint(fb(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(fb(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))}},bI=n=>hl.decode(vI(n)),hb=hl?bI:yI;var sa;(function(n){n[n.Token=0]="Token",n[n.PermissionDenied=1]="PermissionDenied",n[n.Authenticated=2]="Authenticated"})(sa||(sa={}));const wI=(n,e)=>{Sf(n,sa.Token),uI(n,e)},xI=(n,e,t,r)=>{switch(Ng(n)){case sa.Token:{e();break}case sa.PermissionDenied:{t(hb(n));break}case sa.Authenticated:{r(hb(n));break}}},pb=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t}));var Jp;(function(n){n[n.Connecting=0]="Connecting",n[n.Open=1]="Open",n[n.Closing=2]="Closing",n[n.Closed=3]="Closed"})(Jp||(Jp={}));function kI(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 Ch(n){return new Promise(e=>setTimeout(e,n))}function _I(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 SI(n,e){const t=kI(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||_I;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 Ch(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 Ch(s),r.attemptNum<1&&t.initialJitter){const a=i(r,t);a&&await Ch(a)}return o()}const Lk=Math.floor,CI=(n,e)=>n<e?n:e,TI=(n,e)=>n>e?n:e,AI=64,du=128,EI=63,pl=127,Pk=Number.MAX_SAFE_INTEGER,MI=()=>new Set,OI=Array.from,DI=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},Ql=typeof TextEncoder<"u"?new TextEncoder:null,RI=n=>Ql.encode(n),NI=Ql?RI:DI;let ml=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ml&&ml.decode(new Uint8Array).length===1&&(ml=null);class II{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Ig=()=>new II,zk=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},Lg=n=>{const e=new Uint8Array(zk(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},uu=(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},An=(n,e)=>{for(;e>pl;)uu(n,du|pl&e),e=Lk(e/128);uu(n,pl&e)},Yp=new Uint8Array(3e4),LI=Yp.length/3,PI=(n,e)=>{if(e.length<LI){const t=Ql.encodeInto(e,Yp).written||0;An(n,t);for(let r=0;r<t;r++)uu(n,Yp[r])}else qa(n,NI(e))},zI=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;An(n,r);for(let i=0;i<r;i++)uu(n,t.codePointAt(i))},qi=Ql&&Ql.encodeInto?PI:zI,BI=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=CI(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(TI(t*2,o)),n.cbuf.set(e.subarray(i)),n.cpos=o)},qa=(n,e)=>{An(n,e.byteLength),BI(n,e)},Bk=n=>new Error(n),Fk=Bk("Unexpected end of array"),Hk=Bk("Integer out of Range");class FI{constructor(e){this.arr=e,this.pos=0}}const Vk=n=>new FI(n),HI=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},Cf=n=>HI(n,us(n)),mb=n=>n.arr[n.pos++],us=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&pl)*t,t*=128,i<du)return e;if(e>Pk)throw Hk}throw Fk},VI=n=>{let e=n.arr[n.pos++],t=e&EI,r=64;const i=(e&AI)>0?-1:1;if((e&du)===0)return i*t;const o=n.arr.length;for(;n.pos<o;){if(e=n.arr[n.pos++],t=t+(e&pl)*r,r*=128,e<du)return i*t;if(t>Pk)throw Hk}throw Fk},UI=n=>{let e=us(n);if(e===0)return"";{let t=String.fromCodePoint(mb(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(mb(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))}},jI=n=>ml.decode(Cf(n)),$l=ml?jI:UI,WI=n=>{const e=n.pos,t=$l(n);return n.pos=e,t},Na=Date.now,Th=()=>new Map,KI=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r};class qI{constructor(){this._observers=Th()}on(e,t){KI(this._observers,e,MI).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 OI((this._observers.get(e)||Th()).values()).forEach(r=>r(...t))}destroy(){this._observers=Th()}}const JI=Object.keys,gb=n=>JI(n).length,YI=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),ZI=(n,e)=>n===e,gl=(n,e)=>{if(n==null||e==null)return ZI(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)||!gl(n.get(t),e.get(t)))return!1;break}case Object:if(gb(n)!==gb(e))return!1;for(const t in n)if(!YI(n,t)||!gl(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(!gl(n[t],e[t]))return!1;break;default:return!1}return!0},Ah=3e4;class GI extends qI{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Na();this.getLocalState()!==null&&Ah/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,o)=>{o!==this.clientID&&Ah<=t-i.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&Td(this,r,"timeout")},Lk(Ah/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:Na()});const s=[],a=[],l=[],c=[];e===null?c.push(t):o==null?e!=null&&s.push(t):(a.push(t),gl(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 Td=(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:Na()})}r.push(o)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},t]),n.emit("update",[{added:[],updated:[],removed:r},t]))},Zp=(n,e,t=n.states)=>{const r=e.length,i=Ig();An(i,r);for(let o=0;o<r;o++){const s=e[o],a=t.get(s)||null,l=n.meta.get(s).clock;An(i,s),An(i,l),qi(i,JSON.stringify(a))}return Lg(i)},XI=(n,e,t)=>{const r=Vk(e),i=Na(),o=[],s=[],a=[],l=[],c=us(r);for(let d=0;d<c;d++){const u=us(r);let h=us(r);const p=JSON.parse($l(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&&(gl(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 Uk=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 Gp{constructor(e){this.data=e,this.encoder=Ig(),this.decoder=Vk(new Uint8Array(this.data))}peekVarString(){return WI(this.decoder)}readVarUint(){return us(this.decoder)}readVarString(){return $l(this.decoder)}readVarUint8Array(){return Cf(this.decoder)}writeVarUint(e){return An(this.encoder,e)}writeVarString(e){return qi(this.encoder,e)}writeVarUint8Array(e){return qa(this.encoder,e)}length(){return zk(this.encoder)}}var mn;(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"})(mn||(mn={}));var In;(function(n){n.Connecting="connecting",n.Connected="connected",n.Disconnected="disconnected"})(In||(In={}));class zs{constructor(){this.encoder=Ig()}get(e){return e.encoder}toUint8Array(){return Lg(this.encoder)}}class QI extends zs{constructor(){super(...arguments),this.type=mn.CLOSE,this.description="Ask the server to close the connection"}get(e){return qi(this.encoder,e.documentName),An(this.encoder,this.type),this.encoder}}class $I extends Uk{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=In.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=In.Connected,this.emit("status",{status:In.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===In.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===In.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(QI,{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===In.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const e=()=>{let i=!1;return{retryPromise:SI(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=In.Connecting,this.emit("status",{status:In.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){var t;this.resolveConnectionAttempt(),this.lastMessageReceived=Na();const i=new Gp(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=In.Connected,this.emit("status",{status:In.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===In.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=Na()-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)===Jp.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=In.Disconnected,this.emit("status",{status:In.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 jk=0,Pg=1,Wk=2,eL=(n,e)=>{An(n,jk);const t=OO(e);qa(n,t)},tL=(n,e,t)=>{An(n,Pg),qa(n,TO(e,t))},nL=(n,e,t)=>tL(e,t,Cf(n)),Kk=(n,e,t)=>{try{_O(e,Cf(n),t)}catch(r){console.error("Caught error while handling a Yjs update",r)}},rL=(n,e)=>{An(n,Wk),qa(n,e)},iL=Kk,oL=(n,e,t,r)=>{const i=us(n);switch(i){case jk:nL(n,e,t);break;case Pg:Kk(n,t,r);break;case Wk:iL(n,t,r);break;default:throw new Error("Unknown message type")}return i};class sL{constructor(e){this.message=e}apply(e,t){const{message:r}=this,i=r.readVarUint(),o=r.length();switch(i){case mn.Sync:this.applySyncMessage(e,t);break;case mn.Awareness:this.applyAwarenessMessage(e);break;case mn.Auth:this.applyAuthMessage(e);break;case mn.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case mn.Stateless:e.receiveStateless($l(r.decoder));break;case mn.SyncStatus:this.applySyncStatusMessage(e,VI(r.decoder)===1);break;case mn.CLOSE:const s={code:1e3,reason:$l(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(zs,{encoder:r.encoder})}applySyncMessage(e,t){const{message:r}=this;r.writeVarUint(mn.Sync);const i=oL(r.decoder,r.encoder,e.document,e);t&&i===Pg&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:t}=this;XI(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){const{message:t}=this;xI(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(mn.Awareness),t.writeVarUint8Array(Zp(e.awareness,Array.from(e.awareness.getStates().keys())))}}class aL{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return Lg(this.encoder)}send(e){e==null||e.send(this.create())}}class lL extends zs{constructor(){super(...arguments),this.type=mn.Auth,this.description="Authentication"}get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return qi(this.encoder,e.documentName),An(this.encoder,this.type),wI(this.encoder,e.token),this.encoder}}class vb extends zs{constructor(){super(...arguments),this.type=mn.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");qi(this.encoder,e.documentName),An(this.encoder,this.type);let t;return e.states===void 0?t=Zp(e.awareness,e.clients):t=Zp(e.awareness,e.clients,e.states),qa(this.encoder,t),this.encoder}}class cL extends zs{constructor(){super(...arguments),this.type=mn.Stateless,this.description="A stateless message"}get(e){var t;return qi(this.encoder,e.documentName),An(this.encoder,this.type),qi(this.encoder,(t=e.payload)!==null&&t!==void 0?t:""),this.encoder}}class yb extends zs{constructor(){super(...arguments),this.type=mn.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 qi(this.encoder,e.documentName),An(this.encoder,this.type),eL(this.encoder,e.document),this.encoder}}class dL extends zs{constructor(){super(...arguments),this.type=mn.Sync,this.description="A document update"}get(e){return qi(this.encoder,e.documentName),An(this.encoder,this.type),rL(this.encoder,e.update),this.encoder}}class uL extends Error{constructor(){super(...arguments),this.code=1001}}class bb extends Uk{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 hi,this.configuration.awareness=e.awareness!==void 0?e.awareness:new GI(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:pb(this.awareness.getStates())})}),(r=this.awareness)===null||r===void 0||r.on("change",()=>{this.emit("awarenessChange",{states:pb(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 $I(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(yb,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Td(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(cL,{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(lL,{token:e??"",documentName:this.configuration.name})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(dL,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:t,removed:r},i){const o=e.concat(t).concat(r);this.send(vb,{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(yb,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(vb,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t){if(!this._isAttached)return;const r=new aL(e,t);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const t=new Gp(e.data),r=t.readVarString();t.writeVarString(r),this.emit("message",{event:e,message:new Gp(e.data)}),new sL(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Td(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&&(Td(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 uL(`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 vn=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ia=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Xp=null;const Ei=function(n,e,t){let r=Xp||(Xp=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},fL=function(){Xp=null},Ts=function(n,e,t,r){return t&&(wb(n,e,t,r,-1)||wb(n,e,t,r,1))},hL=/^(img|br|input|textarea|hr)$/i;function wb(n,e,t,r,i){for(var o;;){if(n==t&&e==r)return!0;if(e==(i<0?0:yr(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Dc(n)||hL.test(n.nodeName)||n.contentEditable=="false")return!1;e=vn(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?yr(n):0}else return!1}}function yr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function pL(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=yr(n)}else if(n.parentNode&&!Dc(n))e=vn(n),n=n.parentNode;else return null}}function mL(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&&!Dc(n))e=vn(n)+1,n=n.parentNode;else return null}}function gL(n,e,t){for(let r=e==0,i=e==yr(n);r||i;){if(n==t)return!0;let o=vn(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==yr(n)}}function Dc(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 Tf=function(n){return n.focusNode&&Ts(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Uo(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function vL(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function yL(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(yr(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(yr(r.startContainer),r.startOffset)}}}const pi=typeof navigator<"u"?navigator:null,xb=typeof document<"u"?document:null,No=pi&&pi.userAgent||"",Qp=/Edge\/(\d+)/.exec(No),qk=/MSIE \d/.exec(No),$p=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(No),Zn=!!(qk||$p||Qp),yo=qk?document.documentMode:$p?+$p[1]:Qp?+Qp[1]:0,_r=!Zn&&/gecko\/(\d+)/i.test(No);_r&&+(/Firefox\/(\d+)/.exec(No)||[0,0])[1];const em=!Zn&&/Chrome\/(\d+)/.exec(No),wn=!!em,Jk=em?+em[1]:0,Mn=!Zn&&!!pi&&/Apple Computer/.test(pi.vendor),La=Mn&&(/Mobile\/\w+/.test(No)||!!pi&&pi.maxTouchPoints>2),hr=La||(pi?/Mac/.test(pi.platform):!1),Yk=pi?/Win/.test(pi.platform):!1,Ii=/Android \d/.test(No),Rc=!!xb&&"webkitFontSmoothing"in xb.documentElement.style,bL=Rc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function wL(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 ki(n,e){return typeof n=="number"?n:n[e]}function xL(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 kb(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=Ia(s);continue}let a=s,l=a==o.body,c=l?wL(o):xL(a),d=0,u=0;if(e.top<c.top+ki(r,"top")?u=-(c.top-e.top+ki(i,"top")):e.bottom>c.bottom-ki(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+ki(i,"top")-c.top:e.bottom-c.bottom+ki(i,"bottom")),e.left<c.left+ki(r,"left")?d=-(c.left-e.left+ki(i,"left")):e.right>c.right-ki(r,"right")&&(d=e.right-c.right+ki(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:Ia(s)}}function kL(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:Zk(n.dom)}}function Zk(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Ia(r));return e}function _L({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Gk(t,r==0?0:r-e)}function Gk(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 Hs=null;function SL(n){if(n.setActive)return n.setActive();if(Hs)return n.focus(Hs);let e=Zk(n);n.focus(Hs==null?{get preventScroll(){return Hs={preventScroll:!0},!0}}:void 0),Hs||(Hs=!1,Gk(e,0))}function Xk(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=Ei(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?CL(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Xk(t,i)}function CL(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=Xi(r,1);if(s.top!=s.bottom&&zg(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 zg(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function TL(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function AL(n,e,t){let{node:r,offset:i}=Xk(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 EL(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 Qk(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(zg(e,c))return Qk(s,e,c)}}if((o=(o+1)%r)==i)break}return n}function ML(n,e){let t=n.dom.ownerDocument,r,i=0,o=yL(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(!zg(e,c)||(s=Qk(n.dom,e,c),!s))return null}if(Mn)for(let c=s;r&&c;c=Ia(c))c.draggable&&(r=void 0);if(s=TL(s,e),r){if(_r&&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;Rc&&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=EL(n,r,i,e))}a==null&&(a=AL(n,s,e));let l=n.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function _b(n){return n.top<n.bottom||n.left<n.right}function Xi(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(_b(r))return r}return Array.prototype.find.call(t,_b)||n.getBoundingClientRect()}const OL=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function $k(n,e,t){let{node:r,offset:i,atom:o}=n.docView.domFromPos(e,t<0?-1:1),s=Rc||_r;if(r.nodeType==3)if(s&&(OL.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let l=Xi(Ei(r,i,i),t);if(_r&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Xi(Ei(r,i-1,i-1),-1);if(c.top==l.top){let d=Xi(Ei(r,i,i+1),-1);if(d.top!=l.top)return $a(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++,$a(Xi(Ei(r,l,c),d),d<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==yr(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return Eh(l.getBoundingClientRect(),!1)}if(o==null&&i<yr(r)){let l=r.childNodes[i];if(l.nodeType==1)return Eh(l.getBoundingClientRect(),!0)}return Eh(r.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==yr(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Ei(l,yr(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return $a(Xi(c,1),!1)}if(o==null&&i<yr(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Ei(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return $a(Xi(c,-1),!0)}return $a(Xi(r.nodeType==3?Ei(r):r,-t),t>=0)}function $a(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 Eh(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 e_(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 DL(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return e_(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=$k(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=Ei(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 RL=/[\u0590-\u08ac]/;function NL(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?!RL.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?o:s:e_(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 Sb=null,Cb=null,Tb=!1;function IL(n,e,t){return Sb==e&&Cb==t?Tb:(Sb=e,Cb=t,Tb=t=="up"||t=="down"?DL(n,e,t):NL(n,e,t))}const Sr=0,Ab=1,Yo=2,mi=3;class Nc{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Sr,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>vn(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 n_){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 t_&&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?vn(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?vn(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=vn(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=vn(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((_r||Mn)&&e==t){let{node:p,offset:m}=a;if(p.nodeType==3){if(u=!!(m&&p.nodeValue[m-1]==`
|
|
94
94
|
`),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:vn(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(_r&&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&&Mn)&&Ts(a.node,a.offset,d.anchorNode,d.anchorOffset)&&Ts(l.node,l.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!(u&&_r)){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?Yo:Ab,e==a&&t==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=mi:o.markDirty(e-a,t-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Yo:mi}r=s}this.dirty=Yo}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Yo:Ab;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class t_ extends Nc{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==Sr&&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 LL extends Nc{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 As extends Nc{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=Ls.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new As(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&mi||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=mi&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Sr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Sr}}slice(e,t,r){let i=As.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;t<s&&(o=nm(o,t,s,r)),e>0&&(o=nm(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 Nc{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}=Ls.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=o_(d,r,t),c?l=new PL(e,t,r,i,d,u||null,h,c,o,s+1):t.isText?new Af(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=()=>ie.empty)}return e}matchesNode(e,t,r){return this.dirty==Sr&&e.eq(this.node)&&fu(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 BL(this,s&&s.node,e);VL(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?Ct.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==Yo)&&(s&&this.protectLocalComposition(e,s),r_(this.contentDOM,this.children,e),La&&UL(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Oe)||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=jL(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 LL(this,o,t,i);e.input.compositionNodes.push(s),this.children=nm(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==mi||!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=Sr}updateOuterDeco(e){if(fu(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=i_(this.dom,this.nodeDOM,tm(this.outerDeco,this.node,t),tm(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 Eb(n,e,t,r,i){o_(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 Af 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==mi||this.dirty!=Sr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Sr||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=Sr,!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 Af(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=mi)}get domAtom(){return!1}isText(e){return this.node.text==e}}class n_ extends Nc{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Sr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class PL 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==mi)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 r_(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=Mb(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(a,r);if(s instanceof As){let l=r?r.previousSibling:n.lastChild;r_(s.contentDOM,s.children,t),r=l?l.nextSibling:n.firstChild}}for(;r;)r=Mb(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const vl=function(n){n&&(this.nodeName=n)};vl.prototype=Object.create(null);const Zo=[new vl];function tm(n,e,t){if(n.length==0)return Zo;let r=t?Zo[0]:new vl,i=[r];for(let o=0;o<n.length;o++){let s=n[o].type.attrs;if(s){s.nodeName&&i.push(r=new vl(s.nodeName));for(let a in s){let l=s[a];l!=null&&(t&&i.length==1&&i.push(r=new vl(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 i_(n,e,t,r){if(t==Zo&&r==Zo)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=Zo[0]),i=l}zL(i,a||Zo[0],s)}return i}function zL(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 o_(n,e,t){return i_(n,n,Zo,tm(e,t,n.nodeType!=1))}function fu(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 Mb(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class BL{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=FL(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=Sr,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=As.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==mi&&s.dom==s.contentDOM&&(s.dirty=Yo),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!=mi&&fu(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=Yo,u.updateChildren(i,s+1),u.dirty=Sr),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)||!fu(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 t_(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 As;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Af)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Mn||wn)&&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 n_(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 FL(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 As)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 HL(n,e){return n.type.side-e.type.side}function VL(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(HL);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 UL(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 jL(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 nm(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 Bg(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(Tf(t)){for(l=s;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&Ne.isSelectable(u)&&i.parent&&!(u.isInline&&gL(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;c=new Ne(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=Fg(n,d,a,u)}return c}function s_(n){return n.editable?n.hasFocus():l_(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Hi(n,e=!1){let t=n.state.selection;if(a_(n,t),!!s_(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&wn){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Ts(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)KL(n);else{let{anchor:r,head:i}=t,o,s;Ob&&!(t instanceof Oe)&&(t.$from.parent.inlineContent||(o=Db(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Db(n,t.to))),n.docView.setSelection(r,i,n,e),Ob&&(o&&Rb(o),s&&Rb(s)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&WL(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ob=Mn||wn&&Jk<63;function Db(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(Mn&&i&&i.contentEditable=="false")return Mh(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return Mh(i);if(o)return Mh(o)}}function Mh(n){return n.contentEditable="true",Mn&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Rb(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function WL(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(()=>{(!s_(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function KL(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,vn(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Zn&&yo<=11&&(t.disabled=!0,t.disabled=!1)}function a_(n,e){if(e instanceof Ne){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Nb(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Nb(n)}function Nb(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Fg(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||Oe.between(e,t,r)}function Ib(n){return n.editable&&!n.hasFocus()?!1:l_(n)}function l_(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 qL(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ts(e.node,e.offset,t.anchorNode,t.anchorOffset)}function rm(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&&Fe.findFrom(o,e)}function $i(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Lb(n,e,t){let r=n.state.selection;if(r instanceof Oe)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 $i(n,new Oe(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=rm(n.state,e);return i&&i instanceof Ne?$i(n,i):!1}else if(!(hr&&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?Ne.isSelectable(o)?$i(n,new Ne(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Rc?$i(n,new Oe(n.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ne&&r.node.isInline)return $i(n,new Oe(e>0?r.$to:r.$from));{let i=rm(n.state,e);return i?$i(n,i):!1}}}function hu(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function yl(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Vs(n,e){return e<0?JL(n):YL(n)}function JL(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(_r&&t.nodeType==1&&r<hu(t)&&yl(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(yl(a,-1))i=t,o=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(c_(t))break;{let a=t.previousSibling;for(;a&&yl(a,-1);)i=t.parentNode,o=vn(a),a=a.previousSibling;if(a)t=a,r=hu(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?im(n,t,r):i&&im(n,i,o)}function YL(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=hu(t),o,s;for(;;)if(r<i){if(t.nodeType!=1)break;let a=t.childNodes[r];if(yl(a,1))o=t,s=++r;else break}else{if(c_(t))break;{let a=t.nextSibling;for(;a&&yl(a,1);)o=a.parentNode,s=vn(a)+1,a=a.nextSibling;if(a)t=a,r=0,i=hu(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}o&&im(n,o,s)}function c_(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function ZL(n,e){for(;n&&e==n.childNodes.length&&!Dc(n);)e=vn(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 GL(n,e){for(;n&&!e&&!Dc(n);)e=vn(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 im(n,e,t){if(e.nodeType!=3){let o,s;(s=ZL(e,t))?(e=s,t=0):(o=GL(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Tf(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&&Hi(n)},50)}function Pb(n,e){let t=n.state.doc.resolve(e);if(!(wn||Yk)&&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 zb(n,e,t){let r=n.state.selection;if(r instanceof Oe&&!r.empty||t.indexOf("s")>-1||hr&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=rm(n.state,e);if(s&&s instanceof Ne)return $i(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof Yn?Fe.near(s,e):Fe.findFrom(s,e);return a?$i(n,a):!1}return!1}function Bb(n,e){if(!(n.state.selection instanceof Oe))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 Fb(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function XL(n){if(!Mn||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;Fb(n,r,"true"),setTimeout(()=>Fb(n,r,"false"),20)}return!1}function QL(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function $L(n,e){let t=e.keyCode,r=QL(e);if(t==8||hr&&t==72&&r=="c")return Bb(n,-1)||Vs(n,-1);if(t==46&&!e.shiftKey||hr&&t==68&&r=="c")return Bb(n,1)||Vs(n,1);if(t==13||t==27)return!0;if(t==37||hr&&t==66&&r=="c"){let i=t==37?Pb(n,n.state.selection.from)=="ltr"?-1:1:-1;return Lb(n,i,r)||Vs(n,i)}else if(t==39||hr&&t==70&&r=="c"){let i=t==39?Pb(n,n.state.selection.from)=="ltr"?1:-1:1;return Lb(n,i,r)||Vs(n,i)}else{if(t==38||hr&&t==80&&r=="c")return zb(n,-1,r)||Vs(n,-1);if(t==40||hr&&t==78&&r=="c")return XL(n)||zb(n,1,r)||Vs(n,1);if(r==(hr?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Hg(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")||Ls.fromSchema(n.state.schema),a=m_(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=p_[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,`
|
|
95
95
|
|
|
96
96
|
`);return{dom:l,text:h,slice:e}}function d_(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 ge(ie.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
97
97
|
`))),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=Ls.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=rP(t),Rc&&iP(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")||dl.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!eP.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)a=oP(Hb(a,+d[1],+d[2]),d[4]);else if(a=ge.maxOpen(tP(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=Hb(a,u,h)}return n.someProp("transformPasted",u=>{a=u(a,n,l)}),a}const eP=/^(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 tP(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&&f_(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=h_(s[s.length-1],o.length));let d=u_(a,l);s.push(d),i=i.matchType(d.type),o=l}}),s)return ie.from(s)}return n}function u_(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,ie.from(n));return n}function f_(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let o=f_(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(ie.from(u_(t,n,i+1))))}}function h_(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,h_(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(ie.empty,!0);return n.copy(t.append(r))}function om(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=om(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(ie.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(a))}function Hb(n,e,t){return e<n.openStart&&(n=new ge(om(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new ge(om(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const p_={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 Vb=null;function m_(){return Vb||(Vb=document.implementation.createHTMLDocument("title"))}let Oh=null;function nP(n){let e=window.trustedTypes;return e?(Oh||(Oh=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Oh.createHTML(n)):n}function rP(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=m_().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&p_[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=nP(n),i)for(let o=0;o<i.length;o++)t=t.querySelector(i[o])||t;return t}function iP(n){let e=n.querySelectorAll(wn?"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 oP(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=ie.from(l.create(r[a+1],i)),o++,s++}return new ge(i,o,s)}const Fn={},Hn={},sP={touchstart:!0,touchmove:!0};class aP{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 lP(n){for(let e in Fn){let t=Fn[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{dP(n,r)&&!Vg(n,r)&&(n.editable||!(r.type in Hn))&&t(n,r)},sP[e]?{passive:!0}:void 0)}Mn&&n.dom.addEventListener("input",()=>null),sm(n)}function ho(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function cP(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 sm(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Vg(n,r))})}function Vg(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function dP(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 uP(n,e){!Vg(n,e)&&Fn[e.type]&&(n.editable||!(e.type in Hn))&&Fn[e.type](n,e)}Hn.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!v_(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Ii&&wn&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),La&&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,Uo(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||$L(n,t)?t.preventDefault():ho(n,"key")};Hn.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Hn.keypress=(n,e)=>{let t=e;if(v_(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||hr&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof Oe)||!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 Ef(n){return{left:n.clientX,top:n.clientY}}function fP(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ug(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 aa(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 hP(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&Ne.isSelectable(r)?(aa(n,new Ne(t)),!0):!1}function pP(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof Ne&&(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(Ne.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?(aa(n,Ne.create(n.state.doc,i)),!0):!1}function mP(n,e,t,r,i){return Ug(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?pP(n,t):hP(n,t))}function gP(n,e,t,r){return Ug(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function vP(n,e,t,r){return Ug(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||yP(n,t,r)}function yP(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(aa(n,Oe.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)aa(n,Oe.create(r,a+1,a+1+s.content.size));else if(Ne.isSelectable(s))aa(n,Ne.create(r,a));else continue;return!0}}function jg(n){return pu(n)}const g_=hr?"metaKey":"ctrlKey";Fn.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=jg(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&fP(t,n.input.lastClick)&&!t[g_]&&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(Ef(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new bP(n,s,t,!!r)):(o=="doubleClick"?gP:vP)(n,s.pos,s.inside,t)?t.preventDefault():ho(n,"pointer"))};class bP{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[g_],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 Ne&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&_r&&!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)),ho(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(()=>Hi(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(Ef(e))),this.updateAllowDefault(e),this.allowDefault||!t?ho(this.view,"pointer"):mP(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Mn&&this.mightDrag&&!this.mightDrag.node.isAtom||wn&&!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)?(aa(this.view,Fe.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ho(this.view,"pointer")}move(e){this.updateAllowDefault(e),ho(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)}}Fn.touchstart=n=>{n.input.lastTouch=Date.now(),jg(n),ho(n,"pointer")};Fn.touchmove=n=>{n.input.lastTouch=Date.now(),ho(n,"pointer")};Fn.contextmenu=n=>jg(n);function v_(n,e){return n.composing?!0:Mn&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const wP=Ii?5e3:-1;Hn.compositionstart=Hn.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof Oe&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||wn&&Yk&&xP(n)))n.markCursor=n.state.storedMarks||t.marks(),pu(n,!0),n.markCursor=null;else if(pu(n,!e.selection.empty),_r&&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}y_(n,wP)};function xP(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"}Hn.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++,y_(n,20))};function y_(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>pu(n),e))}function b_(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=_P());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function kP(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=pL(e.focusNode,e.focusOffset),r=mL(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 _P(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function pu(n,e=!1){if(!(Ii&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),b_(n),e||n.docView&&n.docView.dirty){let t=Bg(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 SP(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 ec=Zn&&yo<15||La&&bL<604;Fn.copy=Hn.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=ec?null:t.clipboardData,s=r.content(),{dom:a,text:l}=Hg(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):SP(n,a),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function CP(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function TP(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?tc(n,r.value,null,i,e):tc(n,r.textContent,r.innerHTML,i,e)},50)}function tc(n,e,t,r,i){let o=d_(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,i,o||ge.empty)))return!0;if(!o)return!1;let s=CP(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 w_(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," "):""}Hn.paste=(n,e)=>{let t=e;if(n.composing&&!Ii)return;let r=ec?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&tc(n,w_(r),r.getData("text/html"),i,t)?t.preventDefault():TP(n,t)};class x_{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const AP=hr?"altKey":"ctrlKey";function k_(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[AP]}Fn.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(Ef(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof Ne?i.to-1:i.to))){if(r&&r.mightDrag)s=Ne.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=Ne.create(n.state.doc,u.posBefore))}}let a=(s||n.state.selection).content(),{dom:l,text:c,slice:d}=Hg(n,a);(!t.dataTransfer.files.length||!wn||Jk>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ec?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",ec||t.dataTransfer.setData("text/plain",c),n.dragging=new x_(d,k_(n,t),s)};Fn.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Hn.dragover=Hn.dragenter=(n,e)=>e.preventDefault();Hn.drop=(n,e)=>{try{EP(n,e,n.dragging)}finally{n.dragging=null}};function EP(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Ef(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=d_(n,w_(e.dataTransfer),ec?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&k_(n,e));if(n.someProp("handleDrop",p=>p(n,e,o||ge.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?Wx(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&&Ne.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new Ne(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(Fg(n,h,l.doc.resolve(p)))}n.focus(),n.dispatch(l.setMeta("uiEvent","drop"))}Fn.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())&&Hi(n)},20))};Fn.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)};Fn.beforeinput=(n,e)=>{if(wn&&Ii&&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,Uo(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 Hn)Fn[n]=Hn[n];function nc(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 mu{constructor(e,t){this.toDOM=e,this.spec=t||fs,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 Nt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof mu&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&nc(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class wo{constructor(e,t){this.attrs=e,this.spec=t||fs}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 Nt(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof wo&&nc(this.attrs,e.attrs)&&nc(this.spec,e.spec)}static is(e){return e.type instanceof wo}destroy(){}}class Wg{constructor(e,t){this.attrs=e,this.spec=t||fs}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 Nt(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 Wg&&nc(this.attrs,e.attrs)&&nc(this.spec,e.spec)}destroy(){}}class Nt{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Nt(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 Nt(e,e,new mu(t,r))}static inline(e,t,r,i){return new Nt(e,t,new wo(r,i))}static node(e,t,r,i){return new Nt(e,t,new Wg(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof wo}get widget(){return this.type instanceof mu}}const Ks=[],fs={};class rt{constructor(e,t){this.local=e.length?e:Ks,this.children=t.length?t:Ks}static create(e,t){return t.length?gu(t,e,0,fs):Cn}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==Cn||e.maps.length==0?this:this.mapInner(e,t,0,0,r||fs)}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?MP(this.children,s||[],e,t,r,i,o):s?new rt(s.sort(hs),Ks):Cn}add(e,t){return t.length?this==Cn?rt.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=S_(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,gu(d,a,c+1,fs)),o+=3}});let s=__(o?C_(t):t,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new rt(s.length?this.local.concat(s).sort(hs):this.local,i||this.children)}remove(e){return e.length==0||this==Cn?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!=Cn?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 rt(i,r):Cn}forChild(e,t){if(this==Cn)return this;if(t.isLeaf)return rt.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 wo){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 rt(i.sort(hs),Ks);return r?new ro([a,r]):a}return r||Cn}eq(e){if(this==e)return!0;if(!(e instanceof rt)||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 Kg(this.localsInner(e))}localsInner(e){if(this==Cn)return Ks;if(e.inlineContent||!this.local.some(wo.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof wo||t.push(this.local[r]);return t}forEachSet(e){e(this)}}rt.empty=new rt([],[]);rt.removeOverlap=Kg;const Cn=rt.empty;class ro{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,fs));return ro.from(r)}forChild(e,t){if(t.isLeaf)return rt.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=Cn&&(o instanceof ro?r=r.concat(o.members):r.push(o))}return ro.from(r)}eq(e){if(!(e instanceof ro)||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?Kg(r?t:t.sort(hs)):Ks}static from(e){switch(e.length){case 0:return Cn;case 1:return e[0];default:return new ro(e.every(t=>t instanceof rt)?e:e.reduce((t,r)=>t.concat(r instanceof rt?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function MP(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 k=a[y+1];if(k<0||h>k+d-u)continue;let S=a[y]+d-u;p>=S?a[y+1]=h<=S?-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!=Cn?(a[c]=u,a[c+1]=p,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=OP(a,n,e,t,i,o,s),d=gu(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 rt(e.sort(hs),a)}function __(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 Nt(i.from+e,i.to+e,i.type))}return t}function OP(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 S_(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 C_(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function gu(n,e,t,r){let i=[],o=!1;e.forEach((a,l)=>{let c=S_(n,a,l+t);if(c){o=!0;let d=gu(c,a,t+l+1,r);d!=Cn&&i.push(l,l+a.nodeSize,d)}});let s=__(o?C_(n):n,-t).sort(hs);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 rt(s,i):Cn}function hs(n,e){return n.from-e.from||n.to-e.to}function Kg(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),Ub(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),Ub(e,i,r.copy(o.from,r.to)));break}}}return e}function Ub(n,e,t){for(;e<n.length&&hs(t,n[e])>0;)e++;n.splice(e,0,t)}function Dh(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Cn&&e.push(r)}),n.cursorWrapper&&e.push(rt.create(n.state.doc,[n.cursorWrapper.deco])),ro.from(e)}const DP={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},RP=Zn&&yo<=11;class NP{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 IP{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new NP,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]);Zn&&yo<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Mn&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),RP&&(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,DP)),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(Ib(this.view)){if(this.suppressingSelectionUpdates)return Hi(this.view);if(Zn&&yo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ts(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=Ia(o))t.add(o);for(let o=e.anchorNode;o;o=Ia(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)&&Ib(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(_r&&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||zP(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&&Tf(r)&&(c=Bg(e))&&c.eq(Fe.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Hi(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),LP(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,BP(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Hi(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(Zn&&yo<=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?vn(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?vn(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 jb=new WeakMap,Wb=!1;function LP(n){if(!jb.has(n)&&(jb.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=_r,Wb)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."),Wb=!0}}function Kb(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return Ts(s.node,s.offset,i,o)&&([t,r,i,o]=[i,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:o}}function PP(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Kb(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?Kb(n,t):null}function zP(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 BP(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 FP(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}],Tf(l)||c.push({node:l.focusNode,offset:l.focusOffset})),wn&&n.input.lastKeyCode===8)for(let g=o;g>i;g--){let y=r.childNodes[g-1],k=y.pmViewDesc;if(y.nodeName=="BR"&&!k){o=g;break}if(!k||k.size)break}let u=n.state.doc,h=n.someProp("domParser")||dl.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:HP,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 HP(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Mn&&/^(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||Mn&&/^(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 VP=/^(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 UP(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let z=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,D=Bg(n,z);if(D&&!n.state.selection.eq(D)){if(wn&&Ii&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",U=>U(n,Uo(13,"Enter"))))return;let O=n.state.tr.setSelection(D);z=="pointer"?O.setMeta("pointer",!0):z=="key"&&O.scrollIntoView(),o&&O.setMeta("composition",o),n.dispatch(O)}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=FP(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=KP(u.content,c.doc.content,c.from,h,p);if(m&&n.input.domChangeCount++,(La&&n.input.lastIOSEnter>Date.now()-225||Ii)&&i.some(z=>z.nodeType==1&&!VP.test(z.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",z=>z(n,Uo(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof Oe&&!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 z=qb(n,n.state.doc,c.sel);if(z&&!z.eq(n.state.selection)){let D=n.state.tr.setSelection(z);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 Oe&&(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)),Zn&&yo<=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),k=v.sameParent(g)&&v.parent.inlineContent&&y.end()>=m.endA;if((La&&n.input.lastIOSEnter>Date.now()-225&&(!k||i.some(z=>z.nodeName=="DIV"||z.nodeName=="P"))||!k&&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",z=>z(n,Uo(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&WP(d,m.start,m.endA,v,g)&&n.someProp("handleKeyDown",z=>z(n,Uo(8,"Backspace")))){Ii&&wn&&n.domObserver.suppressSelectionUpdates();return}wn&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Ii&&!k&&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(z){return z(n,Uo(13,"Enter"))})},20));let S=m.start,C=m.endA,A=z=>{let D=z||n.state.tr.replace(S,C,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let O=qb(n,D.doc,c.sel);O&&!(wn&&n.composing&&O.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(O.head==S||O.head==D.mapping.map(C)-1)||Zn&&O.empty&&O.head==S)&&D.setSelection(O)}return o&&D.setMeta("composition",o),D.scrollIntoView()},W;if(k)if(v.pos==g.pos){Zn&&yo<=11&&v.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Hi(n),20));let z=A(n.state.tr.delete(S,C)),D=d.resolve(m.start).marksAcross(d.resolve(m.endA));D&&z.ensureMarks(D),n.dispatch(z)}else if(m.endA==m.endB&&(W=jP(v.parent.content.cut(v.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let z=A(n.state.tr);W.type=="add"?z.addMark(S,C,W.mark):z.removeMark(S,C,W.mark),n.dispatch(z)}else if(v.parent.child(v.index()).isText&&v.index()==g.index()-(g.textOffset?0:1)){let z=v.parent.textBetween(v.parentOffset,g.parentOffset),D=()=>A(n.state.tr.insertText(z,S,C));n.someProp("handleTextInput",O=>O(n,S,C,z,D))||n.dispatch(D())}else n.dispatch(A());else n.dispatch(A())}function qb(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Fg(n,e.resolve(t.anchor),e.resolve(t.head))}function jP(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(ie.from(c).eq(n))return{mark:a,type:s}}function WP(n,e,t,r,i){if(t-e<=i.pos-r.pos||Rh(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(Rh(o,!0,!0));return!s.parent.isTextblock||s.pos>t||Rh(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Rh(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 KP(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&&Jb(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&&Jb(n.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function Jb(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 T_{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 aP,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Qb),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=Gb(this),Zb(this),this.nodeViews=Xb(this),this.docView=Eb(this.state.doc,Yb(this),Dh(this),this.dom,this),this.domObserver=new IP(this,(r,i,o,s)=>UP(this,r,i,o,s)),this.domObserver.start(),lP(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&&sm(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Qb),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&&(b_(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=Xb(this);JP(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&sm(this),this.editable=Gb(this),Zb(this);let l=Dh(this),c=Yb(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&&kL(this);if(s){this.domObserver.stop();let p=u&&(Zn||wn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&qP(i.selection,e.selection);if(u){let m=wn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=kP(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Eb(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())&&qL(this))?Hi(this,p):(a_(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&&_L(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 Ne){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&kb(this,t.getBoundingClientRect(),e)}else kb(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 x_(e.slice,e.move,i<0?void 0:Ne.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(Zn){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&&SL(this.dom),Hi(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 ML(this,e)}coordsAtPos(e,t=1){return $k(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 IL(this,t||this.state,e)}pasteHTML(e,t){return tc(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return tc(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Hg(this,e)}destroy(){this.docView&&(cP(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Dh(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,fL())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return uP(this,e)}domSelectionRange(){let e=this.domSelection();return e?Mn&&this.root.nodeType===11&&vL(this.dom.ownerDocument)==this.dom&&PP(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}T_.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Yb(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"),[Nt.node(0,n.state.doc.content.size,e)]}function Zb(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:Nt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Gb(n){return!n.someProp("editable",e=>e(n.state)===!1)}function qP(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 Xb(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 JP(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 Qb(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 Oo={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:"'"},vu={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},YP=typeof navigator<"u"&&/Mac/.test(navigator.platform),ZP=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var yn=0;yn<10;yn++)Oo[48+yn]=Oo[96+yn]=String(yn);for(var yn=1;yn<=24;yn++)Oo[yn+111]="F"+yn;for(var yn=65;yn<=90;yn++)Oo[yn]=String.fromCharCode(yn+32),vu[yn]=String.fromCharCode(yn);for(var Nh in Oo)vu.hasOwnProperty(Nh)||(vu[Nh]=Oo[Nh]);function GP(n){var e=YP&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||ZP&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?vu:Oo)[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 XP=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),QP=typeof navigator<"u"&&/Win/.test(navigator.platform);function $P(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))XP?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 e3(n){let e=Object.create(null);for(let t in n)e[$P(t)]=n[t];return e}function Ih(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 t3(n){return new yt({props:{handleKeyDown:qg(n)}})}function qg(n){let e=e3(n);return function(t,r){let i=GP(r),o,s=e[Ih(i,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[Ih(i,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(QP&&r.ctrlKey&&r.altKey)&&(o=Oo[r.keyCode])&&o!=i){let a=e[Ih(o,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}const Jg=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function A_(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const E_=(n,e,t)=>{let r=A_(n,t);if(!r)return!1;let i=Yg(r);if(!i){let s=r.blockRange(),a=s&&Ba(s);return a==null?!1:(e&&e(n.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(z_(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Pa(o,"end")||Ne.isSelectable(o)))for(let s=r.depth;;s--){let a=cf(n.doc,r.before(s),r.after(s),ge.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(Pa(o,"end")?Fe.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Ne.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},n3=(n,e,t)=>{let r=A_(n,t);if(!r)return!1;let i=Yg(r);return i?M_(n,i,e):!1},r3=(n,e,t)=>{let r=D_(n,t);if(!r)return!1;let i=Zg(r);return i?M_(n,i,e):!1};function M_(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=cf(n.doc,o,l,ge.empty);if(!c||c.from!=o||c instanceof ln&&c.slice.size>=l-o)return!1;if(t){let d=n.tr.step(c);d.setSelection(Oe.create(d.doc,o)),t(d.scrollIntoView())}return!0}function Pa(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 O_=(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=Yg(r)}let s=o&&o.nodeBefore;return!s||!Ne.isSelectable(s)?!1:(e&&e(n.tr.setSelection(Ne.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Yg(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 D_(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const R_=(n,e,t)=>{let r=D_(n,t);if(!r)return!1;let i=Zg(r);if(!i)return!1;let o=i.nodeAfter;if(z_(n,i,e,1))return!0;if(r.parent.content.size==0&&(Pa(o,"start")||Ne.isSelectable(o))){let s=cf(n.doc,r.before(),r.after(),ge.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=n.tr.step(s);a.setSelection(Pa(o,"start")?Fe.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):Ne.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},N_=(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=Zg(r)}let s=o&&o.nodeAfter;return!s||!Ne.isSelectable(s)?!1:(e&&e(n.tr.setSelection(Ne.create(n.doc,o.pos)).scrollIntoView()),!0)};function Zg(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 i3=(n,e)=>{let t=n.selection,r=t instanceof Ne,i;if(r){if(t.node.isTextblock||!Ro(n.doc,t.from))return!1;i=t.from}else if(i=lf(n.doc,t.from,-1),i==null)return!1;if(e){let o=n.tr.join(i);r&&o.setSelection(Ne.create(o.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},o3=(n,e)=>{let t=n.selection,r;if(t instanceof Ne){if(t.node.isTextblock||!Ro(n.doc,t.to))return!1;r=t.to}else if(r=lf(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},s3=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),o=i&&Ba(i);return o==null?!1:(e&&e(n.tr.lift(i,o).scrollIntoView()),!0)},I_=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
98
|
-
`).scrollIntoView()),!0)};function Gg(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 a3=(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=Gg(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(Fe.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},L_=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Yn||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Gg(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(Oe.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},P_=(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(zi(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ba(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function l3(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ne&&e.selection.node.isBlock)return!r.parentOffset||!zi(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=Gg(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 Oe||e.selection instanceof Yn)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=zi(d.doc,u,o.length,o);if(h||(o[0]=a?{type:a}:null,h=zi(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 c3=l3(),d3=(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(Ne.create(n.doc,i))),!0)};function u3(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||Ro(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function z_(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&u3(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=ie.empty;for(let y=s.length-1;y>=0;y--)m=ie.from(s[y].create(null,m));m=ie.from(i.copy(m));let v=n.tr.step(new cn(e.pos-1,p,e.pos,p,new ge(m,1,0),s.length,!0)),g=v.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ro(v.doc,g.pos)&&v.join(g.pos),t(v.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&l?null:Fe.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&Ba(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&Pa(o,"start",!0)&&Pa(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=ie.empty;for(let S=m.length-1;S>=0;S--)y=ie.from(m[S].copy(y));let k=n.tr.step(new cn(e.pos-m.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new ge(y,m.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function B_(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(Oe.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}const f3=B_(-1),h3=B_(1);function p3(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),a=s&&eg(s,n,e);return a?(r&&r(t.tr.wrap(s,a).scrollIntoView()),!0):!1}}function $b(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 Xg(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}Xg(Jg,E_,O_);Xg(Jg,R_,N_);Xg(I_,L_,P_,c3);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function m3(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 g3(a,s,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function g3(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 Jd(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Jd(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=eg(o,t,r,e);return a?(n&&v3(n,e,a,i,t),!0):!1}function v3(n,e,t,r,i){let o=ie.empty;for(let d=t.length-1;d>=0;d--)o=ie.from(t[d].type.create(t[d].attrs,o));n.step(new cn(e.start-(r?2:0),e.end,e.start,e.end,new ge(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&&zi(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return n}function y3(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?b3(e,t,n,o):w3(e,t,o):!0:!1}}function b3(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new cn(o-1,s,o,s,new ge(ie.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Jd(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=Ba(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return Ro(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function w3(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?ie.empty:ie.from(i))))return!1;let u=o.pos,h=u+s.nodeSize;return r.step(new cn(u-(a?1:0),h+(l?1:0),u+1,h-1,new ge((a?ie.empty:ie.from(i.copy(ie.empty))).append(l?ie.empty:ie.from(i.copy(ie.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function x3(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=ie.from(c?n.create():null),u=new ge(ie.from(n.create(null,ie.from(a.type.create(null,d)))),c?3:1,0),h=o.start,p=o.end;t(e.tr.step(new cn(h-(c?3:1),p,h,p,u,1,!0)).scrollIntoView())}return!0}}function Mf(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 Of{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:Mf({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 k3{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 _e(n,e,t){return n.config[e]===void 0&&n.parent?_e(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?_e(n.parent,e,t):null}):n.config[e]}function Df(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 F_(n){const e=[],{nodeExtensions:t,markExtensions:r}=Df(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=_e(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=_e(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 fn(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 jt(...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 am(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)=>jt(t,r),{})}function H_(n){return typeof n=="function"}function Qe(n,e=void 0,...t){return H_(n)?e?n.bind(e)(...t):n(...t):n}function _3(n={}){return Object.keys(n).length===0&&n.constructor===Object}function S3(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function e0(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):S3(t.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function t0(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&_3(t)?!1:t!=null))}function C3(n,e){var t;const r=F_(n),{nodeExtensions:i,markExtensions:o}=Df(n),s=(t=i.find(c=>_e(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,k)=>{const S=_e(k,"extendNodeSchema",u);return{...y,...S?S(c):{}}},{}),p=t0({...h,content:Qe(_e(c,"content",u)),marks:Qe(_e(c,"marks",u)),group:Qe(_e(c,"group",u)),inline:Qe(_e(c,"inline",u)),atom:Qe(_e(c,"atom",u)),selectable:Qe(_e(c,"selectable",u)),draggable:Qe(_e(c,"draggable",u)),code:Qe(_e(c,"code",u)),whitespace:Qe(_e(c,"whitespace",u)),linebreakReplacement:Qe(_e(c,"linebreakReplacement",u)),defining:Qe(_e(c,"defining",u)),isolating:Qe(_e(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var k;return[y.name,{default:(k=y==null?void 0:y.attribute)===null||k===void 0?void 0:k.default}]}))}),m=Qe(_e(c,"parseHTML",u));m&&(p.parseDOM=m.map(y=>e0(y,d)));const v=_e(c,"renderHTML",u);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:am(y,d)}));const g=_e(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 k=_e(y,"extendMarkSchema",u);return{...g,...k?k(c):{}}},{}),p=t0({...h,inclusive:Qe(_e(c,"inclusive",u)),excludes:Qe(_e(c,"excludes",u)),group:Qe(_e(c,"group",u)),spanning:Qe(_e(c,"spanning",u)),code:Qe(_e(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=Qe(_e(c,"parseHTML",u));m&&(p.parseDOM=m.map(g=>e0(g,d)));const v=_e(c,"renderHTML",u);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:am(g,d)})),[c.name,p]}));return new Nx({topNode:s,nodes:a,marks:l})}function Lh(n,e){return e.nodes[n]||e.marks[n]||null}function n0(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Qg(n,e){const t=Ls.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const T3=(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 $g(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Rf{constructor(e){this.find=e.find,this.handler=e.handler}}const A3=(n,e)=>{if($g(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 qc(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=T3(c)+o;return s.forEach(h=>{if(d)return;const p=A3(u,h.find);if(!p)return;const m=l.state.tr,v=Mf({state:l.state,transaction:m}),g={from:r-(p[0].length-o.length),to:i},{commands:y,chain:k,can:S}=new Of({editor:t,state:v});h.handler({state:v,range:g,match:p,commands:y,chain:k,can:S})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:i,text:o}),l.dispatch(m),d=!0)}),d}function E3(n){const{editor:e,rules:t}=n,r=new yt({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=Qg(ie.from(d),s.schema);const{from:u}=l,h=u+d.length;qc({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 qc({editor:e,from:o,to:s,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&qc({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?qc({editor:e,from:s.pos,to:s.pos,text:`
|
|
98
|
+
`).scrollIntoView()),!0)};function Gg(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 a3=(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=Gg(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(Fe.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},L_=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Yn||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Gg(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(Oe.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},P_=(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(zi(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ba(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function l3(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ne&&e.selection.node.isBlock)return!r.parentOffset||!zi(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=Gg(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 Oe||e.selection instanceof Yn)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=zi(d.doc,u,o.length,o);if(h||(o[0]=a?{type:a}:null,h=zi(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 c3=l3(),d3=(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(Ne.create(n.doc,i))),!0)};function u3(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||Ro(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function z_(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&u3(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=ie.empty;for(let y=s.length-1;y>=0;y--)m=ie.from(s[y].create(null,m));m=ie.from(i.copy(m));let v=n.tr.step(new cn(e.pos-1,p,e.pos,p,new ge(m,1,0),s.length,!0)),g=v.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ro(v.doc,g.pos)&&v.join(g.pos),t(v.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&l?null:Fe.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&Ba(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&Pa(o,"start",!0)&&Pa(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=ie.empty;for(let S=m.length-1;S>=0;S--)y=ie.from(m[S].copy(y));let k=n.tr.step(new cn(e.pos-m.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new ge(y,m.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function B_(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(Oe.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}const f3=B_(-1),h3=B_(1);function p3(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),a=s&&eg(s,n,e);return a?(r&&r(t.tr.wrap(s,a).scrollIntoView()),!0):!1}}function $b(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 Xg(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}Xg(Jg,E_,O_);Xg(Jg,R_,N_);Xg(I_,L_,P_,c3);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function m3(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 g3(a,s,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function g3(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 Jd(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Jd(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=eg(o,t,r,e);return a?(n&&v3(n,e,a,i,t),!0):!1}function v3(n,e,t,r,i){let o=ie.empty;for(let d=t.length-1;d>=0;d--)o=ie.from(t[d].type.create(t[d].attrs,o));n.step(new cn(e.start-(r?2:0),e.end,e.start,e.end,new ge(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&&zi(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return n}function y3(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?b3(e,t,n,o):w3(e,t,o):!0:!1}}function b3(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new cn(o-1,s,o,s,new ge(ie.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Jd(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=Ba(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return Ro(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function w3(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?ie.empty:ie.from(i))))return!1;let u=o.pos,h=u+s.nodeSize;return r.step(new cn(u-(a?1:0),h+(l?1:0),u+1,h-1,new ge((a?ie.empty:ie.from(i.copy(ie.empty))).append(l?ie.empty:ie.from(i.copy(ie.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function x3(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=ie.from(c?n.create():null),u=new ge(ie.from(n.create(null,ie.from(a.type.create(null,d)))),c?3:1,0),h=o.start,p=o.end;t(e.tr.step(new cn(h-(c?3:1),p,h,p,u,1,!0)).scrollIntoView())}return!0}}function Mf(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 Of{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:Mf({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 k3{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 _e(n,e,t){return n.config[e]===void 0&&n.parent?_e(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?_e(n.parent,e,t):null}):n.config[e]}function Df(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 F_(n){const e=[],{nodeExtensions:t,markExtensions:r}=Df(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=_e(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=_e(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 fn(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 Wt(...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 am(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)=>Wt(t,r),{})}function H_(n){return typeof n=="function"}function Qe(n,e=void 0,...t){return H_(n)?e?n.bind(e)(...t):n(...t):n}function _3(n={}){return Object.keys(n).length===0&&n.constructor===Object}function S3(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function e0(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):S3(t.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function t0(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&_3(t)?!1:t!=null))}function C3(n,e){var t;const r=F_(n),{nodeExtensions:i,markExtensions:o}=Df(n),s=(t=i.find(c=>_e(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,k)=>{const S=_e(k,"extendNodeSchema",u);return{...y,...S?S(c):{}}},{}),p=t0({...h,content:Qe(_e(c,"content",u)),marks:Qe(_e(c,"marks",u)),group:Qe(_e(c,"group",u)),inline:Qe(_e(c,"inline",u)),atom:Qe(_e(c,"atom",u)),selectable:Qe(_e(c,"selectable",u)),draggable:Qe(_e(c,"draggable",u)),code:Qe(_e(c,"code",u)),whitespace:Qe(_e(c,"whitespace",u)),linebreakReplacement:Qe(_e(c,"linebreakReplacement",u)),defining:Qe(_e(c,"defining",u)),isolating:Qe(_e(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var k;return[y.name,{default:(k=y==null?void 0:y.attribute)===null||k===void 0?void 0:k.default}]}))}),m=Qe(_e(c,"parseHTML",u));m&&(p.parseDOM=m.map(y=>e0(y,d)));const v=_e(c,"renderHTML",u);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:am(y,d)}));const g=_e(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 k=_e(y,"extendMarkSchema",u);return{...g,...k?k(c):{}}},{}),p=t0({...h,inclusive:Qe(_e(c,"inclusive",u)),excludes:Qe(_e(c,"excludes",u)),group:Qe(_e(c,"group",u)),spanning:Qe(_e(c,"spanning",u)),code:Qe(_e(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=Qe(_e(c,"parseHTML",u));m&&(p.parseDOM=m.map(g=>e0(g,d)));const v=_e(c,"renderHTML",u);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:am(g,d)})),[c.name,p]}));return new Nx({topNode:s,nodes:a,marks:l})}function Lh(n,e){return e.nodes[n]||e.marks[n]||null}function n0(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Qg(n,e){const t=Ls.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const T3=(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 $g(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Rf{constructor(e){this.find=e.find,this.handler=e.handler}}const A3=(n,e)=>{if($g(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 qc(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=T3(c)+o;return s.forEach(h=>{if(d)return;const p=A3(u,h.find);if(!p)return;const m=l.state.tr,v=Mf({state:l.state,transaction:m}),g={from:r-(p[0].length-o.length),to:i},{commands:y,chain:k,can:S}=new Of({editor:t,state:v});h.handler({state:v,range:g,match:p,commands:y,chain:k,can:S})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:i,text:o}),l.dispatch(m),d=!0)}),d}function E3(n){const{editor:e,rules:t}=n,r=new yt({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=Qg(ie.from(d),s.schema);const{from:u}=l,h=u+d.length;qc({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 qc({editor:e,from:o,to:s,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&qc({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?qc({editor:e,from:s.pos,to:s.pos,text:`
|
|
99
99
|
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function M3(n){return Object.prototype.toString.call(n).slice(8,-1)}function Jc(n){return M3(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Nf(n,e){const t={...n};return Jc(n)&&Jc(e)&&Object.keys(e).forEach(r=>{Jc(e[r])&&Jc(n[r])?t[r]=Nf(n[r],e[r]):t[r]=e[r]}),t}class gi{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=Qe(_e(this,"addOptions",{name:this.name}))),this.storage=Qe(_e(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new gi(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Nf(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new gi(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=Qe(_e(t,"addOptions",{name:t.name})),t.storage=Qe(_e(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 O3(n){return typeof n=="number"}class D3{constructor(e){this.find=e.find,this.handler=e.handler}}const R3=(n,e,t)=>{if($g(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 N3(n){const{editor:e,state:t,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=n,{commands:l,chain:c,can:d}=new Of({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,"");R3(y,o.find,s).forEach(S=>{if(S.index===void 0)return;const C=v+S.index+1,A=C+S[0].length,W={from:t.tr.mapping.map(C),to:t.tr.mapping.map(A)},z=o.handler({state:t,range:W,match:S,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});u.push(z)})}),u.every(p=>p!==null)}let Yc=null;const I3=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 L3(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=Mf({state:d,transaction:v});if(!(!N3({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 yt({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&&(Yc=e)},p=()=>{Yc&&(Yc=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=Yc;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"),k=!!y;if(!v&&!g&&!k)return;if(k){let{text:A}=y;typeof A=="string"?A=A:A=Qg(ie.from(A),p.schema);const{from:W}=y,z=W+A.length,D=I3(A);return l({rule:d,state:p,from:W,to:{b:z},pasteEvt:D})}const S=h.doc.content.findDiffStart(p.doc.content),C=h.doc.content.findDiffEnd(p.doc.content);if(!(!O3(S)||!C||S===C.b))return l({rule:d,state:p,from:S,to:C,pasteEvt:s})}}))}function P3(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class Xs{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Xs.resolve(e),this.schema=C3(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Xs.sort(Xs.flatten(e)),r=P3(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=_e(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{const o=_e(r,"priority")||100,s=_e(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:Lh(t.name,this.schema)},i=_e(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=Xs.sort([...this.extensions].reverse()),r=[],i=[],o=t.map(s=>{const a={name:s.name,options:s.options,storage:s.storage,editor:e,type:Lh(s.name,this.schema)},l=[],c=_e(s,"addKeyboardShortcuts",a);let d={};if(s.type==="mark"&&_e(s,"exitable",a)&&(d.ArrowRight=()=>gi.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=t3(d);l.push(u);const h=_e(s,"addInputRules",a);n0(s,e.options.enableInputRules)&&h&&r.push(...h());const p=_e(s,"addPasteRules",a);n0(s,e.options.enablePasteRules)&&p&&i.push(...p());const m=_e(s,"addProseMirrorPlugins",a);if(m){const v=m();l.push(...v)}return l}).flat();return[E3({editor:e,rules:r}),...L3({editor:e,rules:i}),...o]}get attributes(){return F_(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Df(this.extensions);return Object.fromEntries(t.filter(r=>!!_e(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:fn(r.name,this.schema)},s=_e(r,"addNodeView",o);if(!s)return[];const a=(l,c,d,u,h)=>{const p=am(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:Lh(e.name,this.schema)};e.type==="mark"&&(!((t=Qe(_e(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=_e(e,"onBeforeCreate",r),o=_e(e,"onCreate",r),s=_e(e,"onUpdate",r),a=_e(e,"onSelectionUpdate",r),l=_e(e,"onTransaction",r),c=_e(e,"onFocus",r),d=_e(e,"onBlur",r),u=_e(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 It{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=Qe(_e(this,"addOptions",{name:this.name}))),this.storage=Qe(_e(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new It(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Nf(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new It({...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=Qe(_e(t,"addOptions",{name:t.name})),t.storage=Qe(_e(t,"addStorage",{name:t.name,options:t.options})),t}}function V_(n,e,t){const{from:r,to:i}=e,{blockSeparator:o=`
|
|
100
100
|
|
|
101
101
|
`,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 U_(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const z3=It.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new yt({key:new Tt("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=U_(t);return V_(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),B3=()=>({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),F3=(n=!1)=>({commands:e})=>e.setContent("",n),H3=()=>({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=Ba(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},V3=n=>e=>n(e),U3=()=>({state:n,dispatch:e})=>L_(n,e),j3=(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 Oe(r.doc.resolve(Math.max(s-1,0)))),!0},W3=()=>({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},K3=n=>({tr:e,state:t,dispatch:r})=>{const i=fn(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},q3=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},J3=()=>({state:n,dispatch:e})=>Jg(n,e),Y3=()=>({commands:n})=>n.keyboardShortcut("Enter"),Z3=()=>({state:n,dispatch:e})=>a3(n,e);function yu(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:$g(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function j_(n,e,t={}){return n.find(r=>r.type===e&&yu(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function r0(n,e,t={}){return!!j_(n,e,t)}function ev(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),!j_([...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&&r0([...n.parent.child(s-1).marks],e,t);)s-=1,a-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&r0([...n.parent.child(l).marks],e,t);)c+=n.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function Io(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 G3=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const o=Io(n,r.schema),{doc:s,selection:a}=t,{$from:l,from:c,to:d}=a;if(i){const u=ev(l,o,e);if(u&&u.from<=c&&u.to>=d){const h=Oe.create(s,u.from,u.to);t.setSelection(h)}}return!0},X3=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 W_(n){return n instanceof Oe}function Go(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function K_(n,e=null){if(!e)return null;const t=Fe.atStart(n),r=Fe.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,o=r.to;return e==="all"?Oe.create(n,Go(0,i,o),Go(n.content.size,i,o)):Oe.create(n,Go(e,i,o),Go(e,i,o))}function i0(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function bu(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Q3(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const $3=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(bu()||i0())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),Q3()&&!bu()&&!i0()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!W_(t.state.selection))return s(),!0;const a=K_(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},ez=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),tz=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),q_=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&&q_(r)}return n};function Zc(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return q_(t)}function rc(n,e,t){if(n instanceof vo||n instanceof ie)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 ie.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),rc("",e,t)}if(i){if(t.errorOnInvalidContent){let s=!1,a="";const l=new Nx({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?dl.fromSchema(l).parseSlice(Zc(n),t.parseOptions):dl.fromSchema(l).parse(Zc(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=dl.fromSchema(e);return t.slice?o.parseSlice(Zc(n),t.parseOptions).content:o.parse(Zc(n),t.parseOptions)}return rc("",e,t)}function nz(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof ln||i instanceof cn))return;const o=n.mapping.maps[r];let s=0;o.forEach((a,l,c,d)=>{s===0&&(s=d)}),n.setSelection(Fe.near(n.doc.resolve(s),t))}const rz=n=>!("type"in n),iz=(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{rc(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=rc(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((rz(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 ie){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&&nz(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},oz=()=>({state:n,dispatch:e})=>i3(n,e),sz=()=>({state:n,dispatch:e})=>o3(n,e),az=()=>({state:n,dispatch:e})=>E_(n,e),lz=()=>({state:n,dispatch:e})=>R_(n,e),cz=()=>({state:n,dispatch:e,tr:t})=>{try{const r=lf(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},dz=()=>({state:n,dispatch:e,tr:t})=>{try{const r=lf(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},uz=()=>({state:n,dispatch:e})=>n3(n,e),fz=()=>({state:n,dispatch:e})=>r3(n,e);function J_(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function hz(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))bu()||J_()?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 pz=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const o=hz(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 ic(n,e,t={}){const{from:r,to:i,empty:o}=n.selection,s=e?fn(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=>yu(u.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=l}const mz=(n,e={})=>({state:t,dispatch:r})=>{const i=fn(n,t.schema);return ic(t,i,e)?s3(t,r):!1},gz=()=>({state:n,dispatch:e})=>P_(n,e),vz=n=>({state:e,dispatch:t})=>{const r=fn(n,e.schema);return y3(r)(e,t)},yz=()=>({state:n,dispatch:e})=>I_(n,e);function If(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function o0(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 bz=(n,e)=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null;const a=If(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(o=fn(n,r.schema)),a==="mark"&&(s=Io(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,o0(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(u=>{s===u.type&&t.addMark(d,d+c.nodeSize,s.create(o0(u.attrs,e)))})})}),!0):!1},wz=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),xz=()=>({tr:n,dispatch:e})=>{if(e){const t=new Yn(n.doc);n.setSelection(t)}return!0},kz=()=>({state:n,dispatch:e})=>O_(n,e),_z=()=>({state:n,dispatch:e})=>N_(n,e),Sz=()=>({state:n,dispatch:e})=>d3(n,e),Cz=()=>({state:n,dispatch:e})=>h3(n,e),Tz=()=>({state:n,dispatch:e})=>f3(n,e);function lm(n,e,t={},r={}){return rc(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const Az=(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=lm(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 Y_(n,e){const t=Io(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 Ez(n,e){const t=new tg(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function Mz(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 Oz(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,o)=>{t(i)&&r.push({node:i,pos:o})}),r}function Z_(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 tv(n){return e=>Z_(e.$from,n)}function Dz(n,e){const t={from:0,to:n.content.size};return V_(n,t,e)}function Rz(n,e){const t=fn(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 G_(n,e){const t=If(typeof e=="string"?e:e.name,n.schema);return t==="node"?Rz(n,e):t==="mark"?Y_(n,e):{}}function Nz(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 Iz(n){const e=Nz(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 Lz(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}})})}),Iz(r)}function nv(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const o=t.resolve(n),s=ev(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 Ad(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 cm(n,e,t={}){const{empty:r,ranges:i}=n.selection,o=e?Io(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>o?o.name===u.type.name:!0).find(u=>yu(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),k=Math.min(m,g+v.nodeSize),S=k-y;s+=S,a.push(...v.marks.map(C=>({mark:C,from:y,to:k})))})}),s===0)return!1;const l=a.filter(u=>o?o.name===u.mark.type.name:!0).filter(u=>yu(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 Pz(n,e,t={}){if(!e)return ic(n,null,t)||cm(n,null,t);const r=If(e,n.schema);return r==="node"?ic(n,e,t):r==="mark"?cm(n,e,t):!1}function s0(n,e){const{nodeExtensions:t}=Df(e),r=t.find(s=>s.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=Qe(_e(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function Lf(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&&(Lf(o,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function zz(n){return n instanceof Ne}function Bz(n,e,t){var r;const{selection:i}=e;let o=null;if(W_(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 Fz=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:o}=t,{empty:s,ranges:a}=o,l=Io(n,r.schema);if(i)if(s){const c=Y_(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 Bz(r,t,l)},Hz=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Vz=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const o=fn(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})=>$b(o,{...s,...e})(t)?!0:a.clearNodes()).command(({state:a})=>$b(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Uz=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=Go(n,0,r.content.size),o=Ne.create(r,i);e.setSelection(o)}return!0},jz=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:o}=typeof n=="number"?{from:n,to:n}:n,s=Oe.atStart(r).from,a=Oe.atEnd(r).to,l=Go(i,s,a),c=Go(o,s,a),d=Oe.create(r,l,c);e.setSelection(d)}return!0},Wz=n=>({state:e,dispatch:t})=>{const r=fn(n,e.schema);return x3(r)(e,t)};function a0(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 Kz=({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=Ad(c,a.node().type.name,a.node().attrs);if(o instanceof Ne&&o.node.isBlock)return!a.parentOffset||!zi(s,a.pos)?!1:(r&&(n&&a0(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:Mz(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=u&&h?[{type:h,attrs:d}]:void 0,m=zi(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&zi(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 Oe&&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&&a0(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},qz=(n,e={})=>({tr:t,state:r,dispatch:i,editor:o})=>{var s;const a=fn(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=ie.empty;const k=l.index(-1)?1:l.index(-2)?2:3;for(let D=l.depth-k;D>=l.depth-3;D-=1)y=ie.from(l.node(D).copy(y));const S=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,C={...Ad(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(ie.from(a.createAndFill(null,A)||void 0));const W=l.before(l.depth-(k-1));t.replace(W,l.after(-S),new ge(y,4-k,0));let z=-1;t.doc.nodesBetween(W,t.doc.content.size,(D,O)=>{if(z>-1)return!1;D.isTextblock&&D.content.size===0&&(z=O+1)}),z>-1&&t.setSelection(Oe.near(t.doc.resolve(z))),t.scrollIntoView()}return!0}const p=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,m={...Ad(h,u.type.name,u.attrs),...e},v={...Ad(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(!zi(t.doc,l.pos,2))return!1;if(i){const{selection:y,storedMarks:k}=r,{splittableMarks:S}=o.extensionManager,C=k||y.$to.parentOffset&&y.$from.marks();if(t.split(l.pos,2,g).scrollIntoView(),!C||!i)return!0;const A=C.filter(W=>S.includes(W.type.name));t.ensureMarks(A)}return!0},Ph=(n,e)=>{const t=tv(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)&&Ro(n.doc,t.pos)&&n.join(t.pos),!0},zh=(n,e)=>{const t=tv(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)&&Ro(n.doc,r)&&n.join(r),!0},Jz=(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=fn(n,s.schema),m=fn(e,s.schema),{selection:v,storedMarks:g}=s,{$from:y,$to:k}=v,S=y.blockRange(k),C=g||v.$to.parentOffset&&v.$from.marks();if(!S)return!1;const A=tv(W=>s0(W.type.name,u))(v);if(S.depth>=1&&A&&S.depth-A.depth<=1){if(A.node.type===p)return c.liftListItem(m);if(s0(A.node.type.name,u)&&p.validContent(A.node.content)&&a)return l().command(()=>(o.setNodeMarkup(A.pos,p),!0)).command(()=>Ph(o,p)).command(()=>zh(o,p)).run()}return!t||!C||!a?l().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>Ph(o,p)).command(()=>zh(o,p)).run():l().command(()=>{const W=d().wrapInList(p,r),z=C.filter(D=>h.includes(D.type.name));return o.ensureMarks(z),W?!0:c.clearNodes()}).wrapInList(p,r).command(()=>Ph(o,p)).command(()=>zh(o,p)).run()},Yz=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=t,s=Io(n,r.schema);return cm(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},Zz=(n,e,t={})=>({state:r,commands:i})=>{const o=fn(n,r.schema),s=fn(e,r.schema),a=ic(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})},Gz=(n,e={})=>({state:t,commands:r})=>{const i=fn(n,t.schema);return ic(t,i,e)?r.lift(i):r.wrapIn(i,e)},Xz=()=>({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},Qz=()=>({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},$z=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=t,l=Io(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=ev(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},e4=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null;const a=If(typeof n=="string"?n:n.name,r.schema);return a?(a==="node"&&(o=fn(n,r.schema)),a==="mark"&&(s=Io(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 k=Math.max(g,c),S=Math.min(g+v.nodeSize,d);t.addMark(k,S,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},t4=(n,e={})=>({state:t,dispatch:r})=>{const i=fn(n,t.schema);return p3(i,e)(t,r)},n4=(n,e={})=>({state:t,dispatch:r})=>{const i=fn(n,t.schema);return m3(i,e)(t,r)};var r4=Object.freeze({__proto__:null,blur:B3,clearContent:F3,clearNodes:H3,command:V3,createParagraphNear:U3,cut:j3,deleteCurrentNode:W3,deleteNode:K3,deleteRange:q3,deleteSelection:J3,enter:Y3,exitCode:Z3,extendMarkRange:G3,first:X3,focus:$3,forEach:ez,insertContent:tz,insertContentAt:iz,joinBackward:az,joinDown:sz,joinForward:lz,joinItemBackward:cz,joinItemForward:dz,joinTextblockBackward:uz,joinTextblockForward:fz,joinUp:oz,keyboardShortcut:pz,lift:mz,liftEmptyBlock:gz,liftListItem:vz,newlineInCode:yz,resetAttributes:bz,scrollIntoView:wz,selectAll:xz,selectNodeBackward:kz,selectNodeForward:_z,selectParentNode:Sz,selectTextblockEnd:Cz,selectTextblockStart:Tz,setContent:Az,setMark:Fz,setMeta:Hz,setNode:Vz,setNodeSelection:Uz,setTextSelection:jz,sinkListItem:Wz,splitBlock:Kz,splitListItem:qz,toggleList:Jz,toggleMark:Yz,toggleNode:Zz,toggleWrap:Gz,undoInputRule:Xz,unsetAllMarks:Qz,unsetMark:$z,updateAttributes:e4,wrapIn:t4,wrapInList:n4});const i4=It.create({name:"commands",addCommands(){return{...r4}}}),o4=It.create({name:"drop",addProseMirrorPlugins(){return[new yt({key:new Tt("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),s4=It.create({name:"editable",addProseMirrorPlugins(){return[new yt({key:new Tt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),a4=new Tt("focusEvents"),l4=It.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new yt({key:a4,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}}}})]}}),c4=It.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:Fe.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 bu()||J_()?o:i},addProseMirrorPlugins(){return[new yt({key:new Tt("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=Fe.atStart(e.doc).from,c=Fe.atEnd(e.doc).to;if(o||!(s===l&&a===c)||!Lf(t.doc))return;const h=t.tr,p=Mf({state:t,transaction:h}),{commands:m}=new Of({editor:this.editor,state:p});if(m.clearNodes(),!!h.steps.length)return h}})]}}),d4=It.create({name:"paste",addProseMirrorPlugins(){return[new yt({key:new Tt("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),u4=It.create({name:"tabindex",addProseMirrorPlugins(){return[new yt({key:new Tt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class jo{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 jo(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 jo(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 jo(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 jo(a,this.editor,i,i?t:null);i&&(l.actualDepth=this.depth+1),e.push(new jo(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 f4=`.ProseMirror {
|
|
@@ -174,18 +174,18 @@ img.ProseMirror-separator {
|
|
|
174
174
|
opacity: 0
|
|
175
175
|
}`;function h4(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 p4=class extends k3{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=h4(f4,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=H_(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?[s4,z3.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),i4,l4,c4,u4,o4,d4].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 Xs(i,this)}createCommandManager(){this.commandManager=new Of({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=lm(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=lm(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=K_(t,this.options.autofocus);this.view=new T_(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:Zs.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 G_(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return Pz(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Qg(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
|
|
176
176
|
|
|
177
|
-
`,textSerializers:r={}}=e||{};return Dz(this.state.doc,{blockSeparator:t,textSerializers:{...U_(this.schema),...r}})}get isEmpty(){return Lf(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 jo(t,this)}get $doc(){return this.$pos(0)}};function Es(n){return new Rf({find:n.find,handler:({state:e,range:t,match:r})=>{const i=Qe(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(nv(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 m4(n){return new Rf({find:n.find,handler:({state:e,range:t,match:r})=>{const i=Qe(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 dm(n){return new Rf({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),o=Qe(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 oc(n){return new Rf({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const o=Qe(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),l=s.doc.resolve(t.from).blockRange(),c=l&&eg(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&&Ro(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&s.join(t.from-1)}})}let Vn=class um{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=Qe(_e(this,"addOptions",{name:this.name}))),this.storage=Qe(_e(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new um(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Nf(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new um(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=Qe(_e(t,"addOptions",{name:t.name})),t.storage=Qe(_e(t,"addStorage",{name:t.name,options:t.options})),t}};function Do(n){return new D3({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const o=Qe(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(nv(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 g4(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof Ne){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 v4=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},y4=/[\uD800-\uDBFF]/,b4=/[\uDC00-\uDFFF]/,w4=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&y4.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&&b4.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},x4=w4,Lt=new Tt("y-sync"),li=new Tt("y-undo"),Gc=new Tt("yjs-cursor"),ci=(n,e)=>n>>>e|n<<32-e,k4=n=>ci(n,2)^ci(n,13)^ci(n,22),_4=n=>ci(n,6)^ci(n,11)^ci(n,25),S4=n=>ci(n,7)^ci(n,18)^n>>>3,C4=n=>ci(n,17)^ci(n,19)^n>>>10,T4=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]),A4=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class E4{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(A4),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,t=this._W;for(let u=16;u<64;u++)t[u]=C4(t[u-2])+t[u-7]+S4(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+_4(a)+(a&l^~a&c)+T4[u]+t[u]>>>0,p=k4(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]|=Bn<<(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)]|=Bn<<(3-t%4)*8),this._W[14]=e.byteLength/bM,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 M4=n=>new E4().digest(n),O4=n=>{for(let t=6;t<n.length;t++)n[t%6]=n[t%6]^n[t];return n.slice(0,6)},D4=n=>w2(O4(M4(k2(n)))),wu=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!ja(e.ds,n.id),R4=[{light:"#ecd44433",dark:"#ecd444"}],N4=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){const r=ks();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,QM(e))}return n.get(t)},I4=(n,{colors:e=R4,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let s=!1;const a=new P4(n,o),l=new yt({props:{editable:c=>{const d=Lt.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:Lt,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(Lt);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)&&gg(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=li.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)},Lt)})}},destroy:()=>{a.destroy()}})});return l},L4=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")n.setSelection(new Yn(n.doc));else if(e.type==="node"){const r=la(t.doc,t.type,e.anchor,t.mapping);n.setSelection(Ne.create(n.doc,r))}else{const r=la(t.doc,t.type,e.anchor,t.mapping),i=la(t.doc,t.type,e.head,t.mapping);if(r!==null&&i!==null){const o=Oe.between(n.doc.resolve(r),n.doc.resolve(i));n.setSelection(o)}}},fm=(n,e)=>({type:e.selection.jsonID,anchor:ku(e.selection.anchor,n.type,n.mapping),head:ku(e.selection.head,n.type,n.mapping)});class P4{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=v4(),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=fm(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()?(m1&&this._domSelectionInView===null&&(gg(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=Cc.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=G1(H1(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Lt,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Ed(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ge(ie.from(e),0,0));t.setMeta(Lt,{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=>Ed(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ge(ie.from(t),0,0));if(e){const i=Bi(Fr(e.anchor,0),r.doc.content.size),o=Bi(Fr(e.head,0),r.doc.content.size);r.setSelection(Oe.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(Lt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let i=this.doc,o=this.type;if(e||(e=wh(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&En(),i=new hi({gc:!1}),tu(i,t),t=wh(i),tu(i,e),e=wh(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=Hr(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=>{Ao(s,u,h=>{})});const l=(u,h)=>{const p=u==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:p,type:u,color:N4(r.colorMapping,r.colors,p)}},c=ak(o,new xg(t.ds,e.sv)).map(u=>!u._item.deleted||wu(u._item,e)||wu(u._item,t)?Ed(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 ge(ie.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(Lt,{isChangeOrigin:!0}))},Lt)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;const r=Lt.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);Ao(t,t.deleteSet,a=>{if(a.constructor===Et){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=>X_(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ge(ie.from(o),0,0));L4(s,this.beforeTransactionSelection,this),s=s.setMeta(Lt,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof tk}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{pm(this.doc,this.type,e,this),this.beforeTransactionSelection=fm(this,this.prosemirrorView.state)},Lt)}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 X_=(n,e,t,r,i,o)=>{const s=t.mapping.get(n);if(s===void 0){if(n instanceof Gt)return Ed(n,e,t,r,i,o);throw kr()}return s},Ed=(n,e,t,r,i,o)=>{const s=[],a=l=>{var c,d;if(l instanceof Gt){const u=X_(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 Eo&&!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=z4(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):ak(n,new xg(i.ds,r.sv)).forEach(a);try{const l=n.getAttributes(r);r!==void 0&&(wu(n._item,r)?wu(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)},Lt),t.mapping.delete(n),null}},z4=(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,j4(c.attributes,e)))}}catch{return n.doc.transact(c=>{n._item.delete(c)},Lt),null}return s},B4=(n,e)=>{const t=new kn,r=n.map(i=>({insert:i.text,attributes:$_(i.marks,e)}));return t.applyDelta(r),e.mapping.set(t,n),t},F4=(n,e)=>{const t=new Gt(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,Pf(n).map(r=>hm(r,e))),e.mapping.set(t,n),t},hm=(n,e)=>n instanceof Array?B4(n,e):F4(n,e),l0=n=>typeof n=="object"&&n!==null,rv=(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||l0(s)&&l0(a)&&rv(s,a)}return r},Pf=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},Q_=(n,e)=>{const t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&f1(r.attributes||{}).length===e[i].marks.length&&Ha(r.attributes,(o,s)=>{var c;const a=iv(s),l=e[i].marks;return rv(o,(c=l.find(d=>d.type.name===a))==null?void 0:c.attrs)}))},sc=(n,e)=>{if(n instanceof Gt&&!(e instanceof Array)&&mm(n,e)){const t=Pf(e);return n._length===t.length&&rv(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>sc(r,t[i]))}return n instanceof kn&&e instanceof Array&&Q_(n,e)},xu=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),c0=(n,e,t)=>{const r=n.toArray(),i=Pf(e),o=i.length,s=r.length,a=Bi(s,o);let l=0,c=0,d=!1;for(;l<a;l++){const u=r[l],h=i[l];if(xu(t.mapping.get(u),h))d=!0;else if(!sc(u,h))break}for(;l+c<a;c++){const u=r[s-c-1],h=i[o-c-1];if(xu(t.mapping.get(u),h))d=!0;else if(!sc(u,h))break}return{equalityFactor:l+c,foundMappedChild:d}},H4=n=>{let e="",t=n._start;const r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof Vr?e+=t.content.str:t.content instanceof Qt&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},V4=(n,e,t)=>{t.mapping.set(n,e);const{nAttrs:r,str:i}=H4(n),o=e.map(c=>({insert:c.text,attributes:Object.assign({},r,$_(c.marks,t))})),{insert:s,remove:a,index:l}=x4(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})))},U4=/(.*)(--[a-zA-Z0-9+/=]{8})$/,iv=n=>{var e;return((e=U4.exec(n))==null?void 0:e[1])??n},j4=(n,e)=>{const t=[];for(const r in n)t.push(e.mark(iv(r),n[r]));return t},$_=(n,e)=>{const t={};return n.forEach(r=>{if(r.type.name!=="ychange"){const i=bi(e.isOMark,r.type,()=>!r.type.excludes(r.type));t[i?`${r.type.name}--${D4(r.toJSON())}`:r.type.name]=r.attrs}}),t},pm=(n,e,t,r)=>{if(e instanceof Gt&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,t),e instanceof Gt){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=Pf(t),o=i.length,s=e.toArray(),a=s.length,l=Bi(o,a);let c=0,d=0;for(;c<l;c++){const u=s[c],h=i[c];if(!xu(r.mapping.get(u),h))if(sc(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(!xu(r.mapping.get(u),h))if(sc(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 kn&&p instanceof Array)Q_(h,p)||V4(h,p,r),c+=1;else{let g=h instanceof Gt&&mm(h,p),y=m instanceof Gt&&mm(m,v);if(g&&y){const k=c0(h,p,r),S=c0(m,v,r);k.foundMappedChild&&!S.foundMappedChild?y=!1:!k.foundMappedChild&&S.foundMappedChild||k.equalityFactor<S.equalityFactor?g=!1:y=!1}g?(pm(n,h,p,r),c+=1):y?(pm(n,m,v,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[hm(p,r)]),c+=1)}}const u=a-c-d;if(a===1&&o===0&&s[0]instanceof kn?(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(hm(i[p],r));e.insert(c,h)}},Lt)},mm=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;let bl=null;const W4=()=>{const n=bl;bl=null,n.forEach((e,t)=>{const r=t.state.tr,i=Lt.getState(t.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((o,s)=>{r.setMeta(s,o)}),t.dispatch(r))})},K4=(n,e,t)=>{bl||(bl=new Map,gg(0,W4)),bi(bl,n,xr).set(e,t)},ku=(n,e,t)=>{if(n===0)return bh(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 kn){if(r._length>=n)return bh(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 Jl(r._item===null?null:r._item.id,r._item===null?Kl(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 Jl(r._item===null?null:r._item.id,r._item===null?Kl(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 En();if(n===0&&r.constructor!==kn&&r!==e)return q4(r._item.parent,r._item)}return bh(e,e._length,e.length===0?-1:0)},q4=(n,e)=>{let t=null,r=null;return n._item===null?r=Kl(n):t=Ke(n._item.id.client,n._item.id.clock),new Jl(t,r,e.id)},la=(n,e,t,r)=>{const i=Fp(t,n);if(i===null||i.type!==e&&!ql(e,i.type._item))return null;let o=i.type,s=0;if(o.constructor===kn)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 kn?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 kn?s+=c._length:s+=r.get(c).nodeSize),l=l.right}}o=a}return s-1};function J4(n){const e=n.toArray(),t=r=>{let i;if(r instanceof kn)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:iv(l)};return Object.keys(c)&&(u.attrs=c),u})),a});else if(r instanceof Gt){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 En();return i};return{type:"doc",content:e.map(t)}}const Y4=(n,e,t)=>n!==e,Z4=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},eS=n=>({style:`background-color: ${n.color}70`,class:"ProseMirror-yjs-selection"}),G4=/^#[0-9a-fA-F]{6}$/,d0=(n,e,t,r,i)=>{const o=Lt.getState(n),s=o.doc,a=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?rt.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":G4.test(d.color)||console.warn("A user uses an unsupported color format",d),d.name==null&&(d.name=`User: ${c}`);let u=la(s,o.type,ds(l.cursor.anchor),o.binding.mapping),h=la(s,o.type,ds(l.cursor.head),o.binding.mapping);if(u!==null&&h!==null){const p=Fr(n.doc.content.size-1,0);u=Bi(u,p),h=Bi(h,p),a.push(Nt.widget(h,()=>r(d,c),{key:c+"",side:10}));const m=Bi(u,h),v=Fr(u,h);a.push(Nt.inline(m,v,i(d,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),rt.create(n.doc,a))},X4=(n,{awarenessStateFilter:e=Y4,cursorBuilder:t=Z4,selectionBuilder:r=eS,getSelection:i=s=>s.selection}={},o="cursor")=>new yt({key:Gc,state:{init(s,a){return d0(a,n,e,t,r)},apply(s,a,l,c){const d=Lt.getState(c),u=s.getMeta(Gc);return d&&d.isChangeOrigin||u&&u.awarenessUpdated?d0(c,n,e,t,r):a.map(s.mapping,s.doc)}},props:{decorations:s=>Gc.getState(s)},view:s=>{const a=()=>{s.docView&&K4(s,Gc,{awarenessUpdated:!0})},l=()=>{const c=Lt.getState(s.state),d=n.getLocalState()||{};if(s.hasFocus()){const u=i(s.state),h=ku(u.anchor,c.type,c.binding.mapping),p=ku(u.head,c.type,c.binding.mapping);(d.cursor==null||!Zy(ds(d.cursor.anchor),h)||!Zy(ds(d.cursor.head),p))&&n.setLocalStateField(o,{anchor:h,head:p})}else d.cursor!=null&&la(c.doc,c.type,ds(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)}}}}),Q4=n=>{var e,t;return((t=(e=li.getState(n))==null?void 0:e.undoManager)==null?void 0:t.undo())!=null},$4=n=>{var e,t;return((t=(e=li.getState(n))==null?void 0:e.undoManager)==null?void 0:t.redo())!=null},eB=new Set(["paragraph"]),tB=(n,e)=>!(n instanceof Et)||!(n.content instanceof jr)||!(n.content.type instanceof Eo||n.content.type instanceof Gt&&e.has(n.content.type.nodeName))||n.content.type._length===0,nB=({protectedNodes:n=eB,trackedOrigins:e=[],undoManager:t=null}={})=>new yt({key:li,state:{init:(r,i)=>{const o=Lt.getState(i),s=t||new tk(o.type,{trackedOrigins:new Set([Lt].concat(e)),deleteFilter:a=>tB(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=Lt.getState(s).binding,l=i.undoManager,c=l.undoStack.length>0,d=l.redoStack.length>0;return a?{undoManager:l,prevSel:fm(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=Lt.getState(r.state),o=li.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:s})=>{const a=i.binding;a&&s.meta.set(a,li.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()}}}}),rB=It.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),li.getState(e).undoManager.undoStack.length===0?!1:t?Q4(e):!0),redo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),li.getState(e).undoManager.redoStack.length===0?!1:t?$4(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=nB(this.options.yUndoOptions),r=t.spec.view;t.spec.view=s=>{const{undoManager:a}=li.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=I4(e,i);return this.editor.options.enableContentCheck&&((n=e.doc)===null||n===void 0||n.on("beforeTransaction",()=>{try{const s=J4(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 yt({key:new Tt("filterInvalidContent"),filterTransaction:()=>{var s;return this.storage.isDisabled&&((s=e.doc)===null||s===void 0||s.destroy()),!0}})].filter(Boolean)}}),u0=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t.user})),f0=()=>null,iB=It.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:eS,onUpdate:f0}},onCreate(){if(this.options.onUpdate!==f0&&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[X4((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=u0(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=u0(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),oB=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,sB=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,aB=gi.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",jt(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[Es({find:oB,type:this.type})]},addPasteRules(){return[Do({find:sB,type:this.type})]}}),lB="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",cB="ελ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",gm="numeric",vm="ascii",ym="alpha",wl="asciinumeric",sl="alphanumeric",bm="domain",tS="emoji",dB="scheme",uB="slashscheme",Bh="whitespace";function fB(n,e){return n in e||(e[n]=[]),e[n]}function Xo(n,e,t){e[gm]&&(e[wl]=!0,e[sl]=!0),e[vm]&&(e[wl]=!0,e[ym]=!0),e[wl]&&(e[sl]=!0),e[ym]&&(e[sl]=!0),e[sl]&&(e[bm]=!0),e[tS]&&(e[bm]=!0);for(const r in e){const i=fB(r,t);i.indexOf(n)<0&&i.push(n)}}function hB(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function qn(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}qn.groups={};qn.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||qn.groups;let i;return e&&e.j?i=e:(i=new qn(e),t&&r&&Xo(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||qn.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 qn,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new qn,o){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(hB(s.t,r),t);Xo(o,l,r)}else t&&Xo(o,t,r);s.t=o}return i.j[n]=s,s}};const Xe=(n,e,t,r,i)=>n.ta(e,t,r,i),Bt=(n,e,t,r,i)=>n.tr(e,t,r,i),h0=(n,e,t,r,i)=>n.ts(e,t,r,i),ce=(n,e,t,r,i)=>n.tt(e,t,r,i),Ci="WORD",wm="UWORD",nS="ASCIINUMERICAL",rS="ALPHANUMERICAL",ac="LOCALHOST",xm="TLD",km="UTLD",Md="SCHEME",qs="SLASH_SCHEME",ov="NUM",_m="WS",sv="NL",xl="OPENBRACE",kl="CLOSEBRACE",_u="OPENBRACKET",Su="CLOSEBRACKET",Cu="OPENPAREN",Tu="CLOSEPAREN",Au="OPENANGLEBRACKET",Eu="CLOSEANGLEBRACKET",Mu="FULLWIDTHLEFTPAREN",Ou="FULLWIDTHRIGHTPAREN",Du="LEFTCORNERBRACKET",Ru="RIGHTCORNERBRACKET",Nu="LEFTWHITECORNERBRACKET",Iu="RIGHTWHITECORNERBRACKET",Lu="FULLWIDTHLESSTHAN",Pu="FULLWIDTHGREATERTHAN",zu="AMPERSAND",Bu="APOSTROPHE",Fu="ASTERISK",eo="AT",Hu="BACKSLASH",Vu="BACKTICK",Uu="CARET",io="COLON",av="COMMA",ju="DOLLAR",Jr="DOT",Wu="EQUALS",lv="EXCLAMATION",ar="HYPHEN",_l="PERCENT",Ku="PIPE",qu="PLUS",Ju="POUND",Sl="QUERY",cv="QUOTE",iS="FULLWIDTHMIDDLEDOT",dv="SEMI",Yr="SLASH",Cl="TILDE",Yu="UNDERSCORE",oS="EMOJI",Zu="SYM";var sS=Object.freeze({__proto__:null,ALPHANUMERICAL:rS,AMPERSAND:zu,APOSTROPHE:Bu,ASCIINUMERICAL:nS,ASTERISK:Fu,AT:eo,BACKSLASH:Hu,BACKTICK:Vu,CARET:Uu,CLOSEANGLEBRACKET:Eu,CLOSEBRACE:kl,CLOSEBRACKET:Su,CLOSEPAREN:Tu,COLON:io,COMMA:av,DOLLAR:ju,DOT:Jr,EMOJI:oS,EQUALS:Wu,EXCLAMATION:lv,FULLWIDTHGREATERTHAN:Pu,FULLWIDTHLEFTPAREN:Mu,FULLWIDTHLESSTHAN:Lu,FULLWIDTHMIDDLEDOT:iS,FULLWIDTHRIGHTPAREN:Ou,HYPHEN:ar,LEFTCORNERBRACKET:Du,LEFTWHITECORNERBRACKET:Nu,LOCALHOST:ac,NL:sv,NUM:ov,OPENANGLEBRACKET:Au,OPENBRACE:xl,OPENBRACKET:_u,OPENPAREN:Cu,PERCENT:_l,PIPE:Ku,PLUS:qu,POUND:Ju,QUERY:Sl,QUOTE:cv,RIGHTCORNERBRACKET:Ru,RIGHTWHITECORNERBRACKET:Iu,SCHEME:Md,SEMI:dv,SLASH:Yr,SLASH_SCHEME:qs,SYM:Zu,TILDE:Cl,TLD:xm,UNDERSCORE:Yu,UTLD:km,UWORD:wm,WORD:Ci,WS:_m});const _i=/[a-z]/,el=new RegExp("\\p{L}","u"),Fh=new RegExp("\\p{Emoji}","u"),Si=/\d/,Hh=/\s/,p0="\r",Vh=`
|
|
178
|
-
`,pB="️",mB="",Uh="";let Xc=null,Qc=null;function gB(n=[]){const e={};qn.groups=e;const t=new qn;Xc==null&&(Xc=m0(lB)),Qc==null&&(Qc=m0(cB)),ce(t,"'",Bu),ce(t,"{",xl),ce(t,"}",kl),ce(t,"[",_u),ce(t,"]",Su),ce(t,"(",Cu),ce(t,")",Tu),ce(t,"<",Au),ce(t,">",Eu),ce(t,"(",Mu),ce(t,")",Ou),ce(t,"「",Du),ce(t,"」",Ru),ce(t,"『",Nu),ce(t,"』",Iu),ce(t,"<",Lu),ce(t,">",Pu),ce(t,"&",zu),ce(t,"*",Fu),ce(t,"@",eo),ce(t,"`",Vu),ce(t,"^",Uu),ce(t,":",io),ce(t,",",av),ce(t,"$",ju),ce(t,".",Jr),ce(t,"=",Wu),ce(t,"!",lv),ce(t,"-",ar),ce(t,"%",_l),ce(t,"|",Ku),ce(t,"+",qu),ce(t,"#",Ju),ce(t,"?",Sl),ce(t,'"',cv),ce(t,"/",Yr),ce(t,";",dv),ce(t,"~",Cl),ce(t,"_",Yu),ce(t,"\\",Hu),ce(t,"・",iS);const r=
|
|
177
|
+
`,textSerializers:r={}}=e||{};return Dz(this.state.doc,{blockSeparator:t,textSerializers:{...U_(this.schema),...r}})}get isEmpty(){return Lf(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 jo(t,this)}get $doc(){return this.$pos(0)}};function Es(n){return new Rf({find:n.find,handler:({state:e,range:t,match:r})=>{const i=Qe(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(nv(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 m4(n){return new Rf({find:n.find,handler:({state:e,range:t,match:r})=>{const i=Qe(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 dm(n){return new Rf({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),o=Qe(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 oc(n){return new Rf({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const o=Qe(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),l=s.doc.resolve(t.from).blockRange(),c=l&&eg(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&&Ro(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&s.join(t.from-1)}})}let Vn=class um{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=Qe(_e(this,"addOptions",{name:this.name}))),this.storage=Qe(_e(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new um(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Nf(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new um(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=Qe(_e(t,"addOptions",{name:t.name})),t.storage=Qe(_e(t,"addStorage",{name:t.name,options:t.options})),t}};function Do(n){return new D3({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const o=Qe(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(nv(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 g4(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof Ne){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 v4=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},y4=/[\uD800-\uDBFF]/,b4=/[\uDC00-\uDFFF]/,w4=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&y4.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&&b4.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},x4=w4,Lt=new Tt("y-sync"),li=new Tt("y-undo"),Gc=new Tt("yjs-cursor"),ci=(n,e)=>n>>>e|n<<32-e,k4=n=>ci(n,2)^ci(n,13)^ci(n,22),_4=n=>ci(n,6)^ci(n,11)^ci(n,25),S4=n=>ci(n,7)^ci(n,18)^n>>>3,C4=n=>ci(n,17)^ci(n,19)^n>>>10,T4=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]),A4=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class E4{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(A4),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,t=this._W;for(let u=16;u<64;u++)t[u]=C4(t[u-2])+t[u-7]+S4(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+_4(a)+(a&l^~a&c)+T4[u]+t[u]>>>0,p=k4(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]|=Bn<<(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)]|=Bn<<(3-t%4)*8),this._W[14]=e.byteLength/bM,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 M4=n=>new E4().digest(n),O4=n=>{for(let t=6;t<n.length;t++)n[t%6]=n[t%6]^n[t];return n.slice(0,6)},D4=n=>w2(O4(M4(k2(n)))),wu=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!ja(e.ds,n.id),R4=[{light:"#ecd44433",dark:"#ecd444"}],N4=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){const r=ks();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,QM(e))}return n.get(t)},I4=(n,{colors:e=R4,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let s=!1;const a=new P4(n,o),l=new yt({props:{editable:c=>{const d=Lt.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:Lt,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(Lt);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)&&gg(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=li.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)},Lt)})}},destroy:()=>{a.destroy()}})});return l},L4=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")n.setSelection(new Yn(n.doc));else if(e.type==="node"){const r=la(t.doc,t.type,e.anchor,t.mapping);n.setSelection(Ne.create(n.doc,r))}else{const r=la(t.doc,t.type,e.anchor,t.mapping),i=la(t.doc,t.type,e.head,t.mapping);if(r!==null&&i!==null){const o=Oe.between(n.doc.resolve(r),n.doc.resolve(i));n.setSelection(o)}}},fm=(n,e)=>({type:e.selection.jsonID,anchor:ku(e.selection.anchor,n.type,n.mapping),head:ku(e.selection.head,n.type,n.mapping)});class P4{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=v4(),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=fm(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()?(m1&&this._domSelectionInView===null&&(gg(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=Cc.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=G1(H1(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Lt,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Ed(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ge(ie.from(e),0,0));t.setMeta(Lt,{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=>Ed(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ge(ie.from(t),0,0));if(e){const i=Bi(Fr(e.anchor,0),r.doc.content.size),o=Bi(Fr(e.head,0),r.doc.content.size);r.setSelection(Oe.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(Lt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let i=this.doc,o=this.type;if(e||(e=wh(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&En(),i=new hi({gc:!1}),tu(i,t),t=wh(i),tu(i,e),e=wh(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=Hr(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=>{Ao(s,u,h=>{})});const l=(u,h)=>{const p=u==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:p,type:u,color:N4(r.colorMapping,r.colors,p)}},c=ak(o,new xg(t.ds,e.sv)).map(u=>!u._item.deleted||wu(u._item,e)||wu(u._item,t)?Ed(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 ge(ie.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(Lt,{isChangeOrigin:!0}))},Lt)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;const r=Lt.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);Ao(t,t.deleteSet,a=>{if(a.constructor===Et){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=>X_(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ge(ie.from(o),0,0));L4(s,this.beforeTransactionSelection,this),s=s.setMeta(Lt,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof tk}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{pm(this.doc,this.type,e,this),this.beforeTransactionSelection=fm(this,this.prosemirrorView.state)},Lt)}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 X_=(n,e,t,r,i,o)=>{const s=t.mapping.get(n);if(s===void 0){if(n instanceof Gt)return Ed(n,e,t,r,i,o);throw kr()}return s},Ed=(n,e,t,r,i,o)=>{const s=[],a=l=>{var c,d;if(l instanceof Gt){const u=X_(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 Eo&&!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=z4(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):ak(n,new xg(i.ds,r.sv)).forEach(a);try{const l=n.getAttributes(r);r!==void 0&&(wu(n._item,r)?wu(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)},Lt),t.mapping.delete(n),null}},z4=(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,j4(c.attributes,e)))}}catch{return n.doc.transact(c=>{n._item.delete(c)},Lt),null}return s},B4=(n,e)=>{const t=new kn,r=n.map(i=>({insert:i.text,attributes:$_(i.marks,e)}));return t.applyDelta(r),e.mapping.set(t,n),t},F4=(n,e)=>{const t=new Gt(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,Pf(n).map(r=>hm(r,e))),e.mapping.set(t,n),t},hm=(n,e)=>n instanceof Array?B4(n,e):F4(n,e),l0=n=>typeof n=="object"&&n!==null,rv=(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||l0(s)&&l0(a)&&rv(s,a)}return r},Pf=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},Q_=(n,e)=>{const t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&f1(r.attributes||{}).length===e[i].marks.length&&Ha(r.attributes,(o,s)=>{var c;const a=iv(s),l=e[i].marks;return rv(o,(c=l.find(d=>d.type.name===a))==null?void 0:c.attrs)}))},sc=(n,e)=>{if(n instanceof Gt&&!(e instanceof Array)&&mm(n,e)){const t=Pf(e);return n._length===t.length&&rv(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>sc(r,t[i]))}return n instanceof kn&&e instanceof Array&&Q_(n,e)},xu=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),c0=(n,e,t)=>{const r=n.toArray(),i=Pf(e),o=i.length,s=r.length,a=Bi(s,o);let l=0,c=0,d=!1;for(;l<a;l++){const u=r[l],h=i[l];if(xu(t.mapping.get(u),h))d=!0;else if(!sc(u,h))break}for(;l+c<a;c++){const u=r[s-c-1],h=i[o-c-1];if(xu(t.mapping.get(u),h))d=!0;else if(!sc(u,h))break}return{equalityFactor:l+c,foundMappedChild:d}},H4=n=>{let e="",t=n._start;const r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof Vr?e+=t.content.str:t.content instanceof Qt&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},V4=(n,e,t)=>{t.mapping.set(n,e);const{nAttrs:r,str:i}=H4(n),o=e.map(c=>({insert:c.text,attributes:Object.assign({},r,$_(c.marks,t))})),{insert:s,remove:a,index:l}=x4(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})))},U4=/(.*)(--[a-zA-Z0-9+/=]{8})$/,iv=n=>{var e;return((e=U4.exec(n))==null?void 0:e[1])??n},j4=(n,e)=>{const t=[];for(const r in n)t.push(e.mark(iv(r),n[r]));return t},$_=(n,e)=>{const t={};return n.forEach(r=>{if(r.type.name!=="ychange"){const i=bi(e.isOMark,r.type,()=>!r.type.excludes(r.type));t[i?`${r.type.name}--${D4(r.toJSON())}`:r.type.name]=r.attrs}}),t},pm=(n,e,t,r)=>{if(e instanceof Gt&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,t),e instanceof Gt){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=Pf(t),o=i.length,s=e.toArray(),a=s.length,l=Bi(o,a);let c=0,d=0;for(;c<l;c++){const u=s[c],h=i[c];if(!xu(r.mapping.get(u),h))if(sc(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(!xu(r.mapping.get(u),h))if(sc(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 kn&&p instanceof Array)Q_(h,p)||V4(h,p,r),c+=1;else{let g=h instanceof Gt&&mm(h,p),y=m instanceof Gt&&mm(m,v);if(g&&y){const k=c0(h,p,r),S=c0(m,v,r);k.foundMappedChild&&!S.foundMappedChild?y=!1:!k.foundMappedChild&&S.foundMappedChild||k.equalityFactor<S.equalityFactor?g=!1:y=!1}g?(pm(n,h,p,r),c+=1):y?(pm(n,m,v,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[hm(p,r)]),c+=1)}}const u=a-c-d;if(a===1&&o===0&&s[0]instanceof kn?(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(hm(i[p],r));e.insert(c,h)}},Lt)},mm=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;let bl=null;const W4=()=>{const n=bl;bl=null,n.forEach((e,t)=>{const r=t.state.tr,i=Lt.getState(t.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((o,s)=>{r.setMeta(s,o)}),t.dispatch(r))})},K4=(n,e,t)=>{bl||(bl=new Map,gg(0,W4)),bi(bl,n,xr).set(e,t)},ku=(n,e,t)=>{if(n===0)return bh(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 kn){if(r._length>=n)return bh(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 Jl(r._item===null?null:r._item.id,r._item===null?Kl(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 Jl(r._item===null?null:r._item.id,r._item===null?Kl(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 En();if(n===0&&r.constructor!==kn&&r!==e)return q4(r._item.parent,r._item)}return bh(e,e._length,e.length===0?-1:0)},q4=(n,e)=>{let t=null,r=null;return n._item===null?r=Kl(n):t=Ke(n._item.id.client,n._item.id.clock),new Jl(t,r,e.id)},la=(n,e,t,r)=>{const i=Fp(t,n);if(i===null||i.type!==e&&!ql(e,i.type._item))return null;let o=i.type,s=0;if(o.constructor===kn)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 kn?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 kn?s+=c._length:s+=r.get(c).nodeSize),l=l.right}}o=a}return s-1};function J4(n){const e=n.toArray(),t=r=>{let i;if(r instanceof kn)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:iv(l)};return Object.keys(c)&&(u.attrs=c),u})),a});else if(r instanceof Gt){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 En();return i};return{type:"doc",content:e.map(t)}}const Y4=(n,e,t)=>n!==e,Z4=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},eS=n=>({style:`background-color: ${n.color}70`,class:"ProseMirror-yjs-selection"}),G4=/^#[0-9a-fA-F]{6}$/,d0=(n,e,t,r,i)=>{const o=Lt.getState(n),s=o.doc,a=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?rt.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":G4.test(d.color)||console.warn("A user uses an unsupported color format",d),d.name==null&&(d.name=`User: ${c}`);let u=la(s,o.type,ds(l.cursor.anchor),o.binding.mapping),h=la(s,o.type,ds(l.cursor.head),o.binding.mapping);if(u!==null&&h!==null){const p=Fr(n.doc.content.size-1,0);u=Bi(u,p),h=Bi(h,p),a.push(Nt.widget(h,()=>r(d,c),{key:c+"",side:10}));const m=Bi(u,h),v=Fr(u,h);a.push(Nt.inline(m,v,i(d,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),rt.create(n.doc,a))},X4=(n,{awarenessStateFilter:e=Y4,cursorBuilder:t=Z4,selectionBuilder:r=eS,getSelection:i=s=>s.selection}={},o="cursor")=>new yt({key:Gc,state:{init(s,a){return d0(a,n,e,t,r)},apply(s,a,l,c){const d=Lt.getState(c),u=s.getMeta(Gc);return d&&d.isChangeOrigin||u&&u.awarenessUpdated?d0(c,n,e,t,r):a.map(s.mapping,s.doc)}},props:{decorations:s=>Gc.getState(s)},view:s=>{const a=()=>{s.docView&&K4(s,Gc,{awarenessUpdated:!0})},l=()=>{const c=Lt.getState(s.state),d=n.getLocalState()||{};if(s.hasFocus()){const u=i(s.state),h=ku(u.anchor,c.type,c.binding.mapping),p=ku(u.head,c.type,c.binding.mapping);(d.cursor==null||!Zy(ds(d.cursor.anchor),h)||!Zy(ds(d.cursor.head),p))&&n.setLocalStateField(o,{anchor:h,head:p})}else d.cursor!=null&&la(c.doc,c.type,ds(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)}}}}),Q4=n=>{var e,t;return((t=(e=li.getState(n))==null?void 0:e.undoManager)==null?void 0:t.undo())!=null},$4=n=>{var e,t;return((t=(e=li.getState(n))==null?void 0:e.undoManager)==null?void 0:t.redo())!=null},eB=new Set(["paragraph"]),tB=(n,e)=>!(n instanceof Et)||!(n.content instanceof jr)||!(n.content.type instanceof Eo||n.content.type instanceof Gt&&e.has(n.content.type.nodeName))||n.content.type._length===0,nB=({protectedNodes:n=eB,trackedOrigins:e=[],undoManager:t=null}={})=>new yt({key:li,state:{init:(r,i)=>{const o=Lt.getState(i),s=t||new tk(o.type,{trackedOrigins:new Set([Lt].concat(e)),deleteFilter:a=>tB(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=Lt.getState(s).binding,l=i.undoManager,c=l.undoStack.length>0,d=l.redoStack.length>0;return a?{undoManager:l,prevSel:fm(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=Lt.getState(r.state),o=li.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:s})=>{const a=i.binding;a&&s.meta.set(a,li.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()}}}}),rB=It.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),li.getState(e).undoManager.undoStack.length===0?!1:t?Q4(e):!0),redo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),li.getState(e).undoManager.redoStack.length===0?!1:t?$4(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=nB(this.options.yUndoOptions),r=t.spec.view;t.spec.view=s=>{const{undoManager:a}=li.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=I4(e,i);return this.editor.options.enableContentCheck&&((n=e.doc)===null||n===void 0||n.on("beforeTransaction",()=>{try{const s=J4(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 yt({key:new Tt("filterInvalidContent"),filterTransaction:()=>{var s;return this.storage.isDisabled&&((s=e.doc)===null||s===void 0||s.destroy()),!0}})].filter(Boolean)}}),u0=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t.user})),f0=()=>null,iB=It.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:eS,onUpdate:f0}},onCreate(){if(this.options.onUpdate!==f0&&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[X4((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=u0(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=u0(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),oB=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,sB=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,aB=gi.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",Wt(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[Es({find:oB,type:this.type})]},addPasteRules(){return[Do({find:sB,type:this.type})]}}),lB="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",cB="ελ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",gm="numeric",vm="ascii",ym="alpha",wl="asciinumeric",sl="alphanumeric",bm="domain",tS="emoji",dB="scheme",uB="slashscheme",Bh="whitespace";function fB(n,e){return n in e||(e[n]=[]),e[n]}function Xo(n,e,t){e[gm]&&(e[wl]=!0,e[sl]=!0),e[vm]&&(e[wl]=!0,e[ym]=!0),e[wl]&&(e[sl]=!0),e[ym]&&(e[sl]=!0),e[sl]&&(e[bm]=!0),e[tS]&&(e[bm]=!0);for(const r in e){const i=fB(r,t);i.indexOf(n)<0&&i.push(n)}}function hB(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function qn(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}qn.groups={};qn.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||qn.groups;let i;return e&&e.j?i=e:(i=new qn(e),t&&r&&Xo(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||qn.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 qn,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new qn,o){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(hB(s.t,r),t);Xo(o,l,r)}else t&&Xo(o,t,r);s.t=o}return i.j[n]=s,s}};const Xe=(n,e,t,r,i)=>n.ta(e,t,r,i),Ft=(n,e,t,r,i)=>n.tr(e,t,r,i),h0=(n,e,t,r,i)=>n.ts(e,t,r,i),ce=(n,e,t,r,i)=>n.tt(e,t,r,i),Ci="WORD",wm="UWORD",nS="ASCIINUMERICAL",rS="ALPHANUMERICAL",ac="LOCALHOST",xm="TLD",km="UTLD",Md="SCHEME",qs="SLASH_SCHEME",ov="NUM",_m="WS",sv="NL",xl="OPENBRACE",kl="CLOSEBRACE",_u="OPENBRACKET",Su="CLOSEBRACKET",Cu="OPENPAREN",Tu="CLOSEPAREN",Au="OPENANGLEBRACKET",Eu="CLOSEANGLEBRACKET",Mu="FULLWIDTHLEFTPAREN",Ou="FULLWIDTHRIGHTPAREN",Du="LEFTCORNERBRACKET",Ru="RIGHTCORNERBRACKET",Nu="LEFTWHITECORNERBRACKET",Iu="RIGHTWHITECORNERBRACKET",Lu="FULLWIDTHLESSTHAN",Pu="FULLWIDTHGREATERTHAN",zu="AMPERSAND",Bu="APOSTROPHE",Fu="ASTERISK",eo="AT",Hu="BACKSLASH",Vu="BACKTICK",Uu="CARET",io="COLON",av="COMMA",ju="DOLLAR",Jr="DOT",Wu="EQUALS",lv="EXCLAMATION",ar="HYPHEN",_l="PERCENT",Ku="PIPE",qu="PLUS",Ju="POUND",Sl="QUERY",cv="QUOTE",iS="FULLWIDTHMIDDLEDOT",dv="SEMI",Yr="SLASH",Cl="TILDE",Yu="UNDERSCORE",oS="EMOJI",Zu="SYM";var sS=Object.freeze({__proto__:null,ALPHANUMERICAL:rS,AMPERSAND:zu,APOSTROPHE:Bu,ASCIINUMERICAL:nS,ASTERISK:Fu,AT:eo,BACKSLASH:Hu,BACKTICK:Vu,CARET:Uu,CLOSEANGLEBRACKET:Eu,CLOSEBRACE:kl,CLOSEBRACKET:Su,CLOSEPAREN:Tu,COLON:io,COMMA:av,DOLLAR:ju,DOT:Jr,EMOJI:oS,EQUALS:Wu,EXCLAMATION:lv,FULLWIDTHGREATERTHAN:Pu,FULLWIDTHLEFTPAREN:Mu,FULLWIDTHLESSTHAN:Lu,FULLWIDTHMIDDLEDOT:iS,FULLWIDTHRIGHTPAREN:Ou,HYPHEN:ar,LEFTCORNERBRACKET:Du,LEFTWHITECORNERBRACKET:Nu,LOCALHOST:ac,NL:sv,NUM:ov,OPENANGLEBRACKET:Au,OPENBRACE:xl,OPENBRACKET:_u,OPENPAREN:Cu,PERCENT:_l,PIPE:Ku,PLUS:qu,POUND:Ju,QUERY:Sl,QUOTE:cv,RIGHTCORNERBRACKET:Ru,RIGHTWHITECORNERBRACKET:Iu,SCHEME:Md,SEMI:dv,SLASH:Yr,SLASH_SCHEME:qs,SYM:Zu,TILDE:Cl,TLD:xm,UNDERSCORE:Yu,UTLD:km,UWORD:wm,WORD:Ci,WS:_m});const _i=/[a-z]/,el=new RegExp("\\p{L}","u"),Fh=new RegExp("\\p{Emoji}","u"),Si=/\d/,Hh=/\s/,p0="\r",Vh=`
|
|
178
|
+
`,pB="️",mB="",Uh="";let Xc=null,Qc=null;function gB(n=[]){const e={};qn.groups=e;const t=new qn;Xc==null&&(Xc=m0(lB)),Qc==null&&(Qc=m0(cB)),ce(t,"'",Bu),ce(t,"{",xl),ce(t,"}",kl),ce(t,"[",_u),ce(t,"]",Su),ce(t,"(",Cu),ce(t,")",Tu),ce(t,"<",Au),ce(t,">",Eu),ce(t,"(",Mu),ce(t,")",Ou),ce(t,"「",Du),ce(t,"」",Ru),ce(t,"『",Nu),ce(t,"』",Iu),ce(t,"<",Lu),ce(t,">",Pu),ce(t,"&",zu),ce(t,"*",Fu),ce(t,"@",eo),ce(t,"`",Vu),ce(t,"^",Uu),ce(t,":",io),ce(t,",",av),ce(t,"$",ju),ce(t,".",Jr),ce(t,"=",Wu),ce(t,"!",lv),ce(t,"-",ar),ce(t,"%",_l),ce(t,"|",Ku),ce(t,"+",qu),ce(t,"#",Ju),ce(t,"?",Sl),ce(t,'"',cv),ce(t,"/",Yr),ce(t,";",dv),ce(t,"~",Cl),ce(t,"_",Yu),ce(t,"\\",Hu),ce(t,"・",iS);const r=Ft(t,Si,ov,{[gm]:!0});Ft(r,Si,r);const i=Ft(r,_i,nS,{[wl]:!0}),o=Ft(r,el,rS,{[sl]:!0}),s=Ft(t,_i,Ci,{[vm]:!0});Ft(s,Si,i),Ft(s,_i,s),Ft(i,Si,i),Ft(i,_i,i);const a=Ft(t,el,wm,{[ym]:!0});Ft(a,_i),Ft(a,Si,o),Ft(a,el,a),Ft(o,Si,o),Ft(o,_i),Ft(o,el,o);const l=ce(t,Vh,sv,{[Bh]:!0}),c=ce(t,p0,_m,{[Bh]:!0}),d=Ft(t,Hh,_m,{[Bh]:!0});ce(t,Uh,d),ce(c,Vh,l),ce(c,Uh,d),Ft(c,Hh,d),ce(d,p0),ce(d,Vh),Ft(d,Hh,d),ce(d,Uh,d);const u=Ft(t,Fh,oS,{[tS]:!0});ce(u,"#"),Ft(u,Fh,u),ce(u,pB,u);const h=ce(u,mB);ce(h,"#"),Ft(h,Fh,u);const p=[[_i,s],[Si,i]],m=[[_i,null],[el,a],[Si,o]];for(let v=0;v<Xc.length;v++)Gi(t,Xc[v],xm,Ci,p);for(let v=0;v<Qc.length;v++)Gi(t,Qc[v],km,wm,m);Xo(xm,{tld:!0,ascii:!0},e),Xo(km,{utld:!0,alpha:!0},e),Gi(t,"file",Md,Ci,p),Gi(t,"mailto",Md,Ci,p),Gi(t,"http",qs,Ci,p),Gi(t,"https",qs,Ci,p),Gi(t,"ftp",qs,Ci,p),Gi(t,"ftps",qs,Ci,p),Xo(Md,{scheme:!0,ascii:!0},e),Xo(qs,{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],k=n[v][1]?{[dB]:!0}:{[uB]:!0};g.indexOf("-")>=0?k[bm]=!0:_i.test(g)?Si.test(g)?k[wl]=!0:k[vm]=!0:k[gm]=!0,h0(t,g,g,k)}return h0(t,"localhost",ac,{ascii:!0}),t.jd=new qn(Zu),{start:t,tokens:Object.assign({groups:e},sS)}}function aS(n,e){const t=vB(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 vB(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 Gi(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 qn(r),o.jr=i.slice(),n.j[l]=o),n=o}return o=new qn(t),o.jr=i.slice(),n.j[e[s-1]]=o,o}function m0(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 lc={defaultProtocol:"http",events:null,format:g0,formatHref:g0,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function uv(n,e=null){let t=Object.assign({},lc);n&&(t=Object.assign(t,n instanceof uv?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}uv.prototype={o:lc,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]:lc[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 g0(n){return n}function lS(n,e){this.t="token",this.v=n,this.tk=e}lS.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=lc.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 zf(n,e){class t extends lS{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 v0=zf("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),y0=zf("text"),yB=zf("nl"),$c=zf("url",{isLink:!0,toHref(n=lc.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==ac&&n[1].t===io}}),sr=n=>new qn(n);function bB({groups:n}){const e=n.domain.concat([zu,Fu,eo,Hu,Vu,Uu,ju,Wu,ar,ov,_l,Ku,qu,Ju,Yr,Zu,Cl,Yu]),t=[Bu,io,av,Jr,lv,_l,Sl,cv,dv,Au,Eu,xl,kl,Su,_u,Cu,Tu,Mu,Ou,Du,Ru,Nu,Iu,Lu,Pu],r=[zu,Bu,Fu,Hu,Vu,Uu,ju,Wu,ar,xl,kl,_l,Ku,qu,Ju,Sl,Yr,Zu,Cl,Yu],i=sr(),o=ce(i,Cl);Xe(o,r,o),Xe(o,n.domain,o);const s=sr(),a=sr(),l=sr();Xe(i,n.domain,s),Xe(i,n.scheme,a),Xe(i,n.slashscheme,l),Xe(s,r,o),Xe(s,n.domain,s);const c=ce(s,eo);ce(o,eo,c),ce(a,eo,c),ce(l,eo,c);const d=ce(o,Jr);Xe(d,r,o),Xe(d,n.domain,o);const u=sr();Xe(c,n.domain,u),Xe(u,n.domain,u);const h=ce(u,Jr);Xe(h,n.domain,u);const p=sr(v0);Xe(h,n.tld,p),Xe(h,n.utld,p),ce(c,ac,p);const m=ce(u,ar);ce(m,ar,m),Xe(m,n.domain,u),Xe(p,n.domain,u),ce(p,Jr,h),ce(p,ar,m);const v=ce(p,io);Xe(v,n.numeric,v0);const g=ce(s,ar),y=ce(s,Jr);ce(g,ar,g),Xe(g,n.domain,s),Xe(y,r,o),Xe(y,n.domain,s);const k=sr($c);Xe(y,n.tld,k),Xe(y,n.utld,k),Xe(k,n.domain,s),Xe(k,r,o),ce(k,Jr,y),ce(k,ar,g),ce(k,eo,c);const S=ce(k,io),C=sr($c);Xe(S,n.numeric,C);const A=sr($c),W=sr();Xe(A,e,A),Xe(A,t,W),Xe(W,e,A),Xe(W,t,W),ce(k,Yr,A),ce(C,Yr,A);const z=ce(a,io),D=ce(l,io),O=ce(D,Yr),U=ce(O,Yr);Xe(a,n.domain,s),ce(a,Jr,y),ce(a,ar,g),Xe(l,n.domain,s),ce(l,Jr,y),ce(l,ar,g),Xe(z,n.domain,A),ce(z,Yr,A),ce(z,Sl,A),Xe(U,n.domain,A),Xe(U,e,A),ce(U,Yr,A);const ee=[[xl,kl],[_u,Su],[Cu,Tu],[Au,Eu],[Mu,Ou],[Du,Ru],[Nu,Iu],[Lu,Pu]];for(let R=0;R<ee.length;R++){const[K,ne]=ee[R],X=ce(A,K);ce(W,K,X),ce(X,ne,A);const N=sr($c);Xe(X,e,N);const q=sr();Xe(X,t),Xe(N,e,N),Xe(N,t,q),Xe(q,e,N),Xe(q,t,q),ce(N,ne,A),ce(q,ne,A)}return ce(i,ac,k),ce(i,sv,yB),{start:i,tokens:sS}}function wB(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(jh(y0,e,s)),s=[]),i-=h,d-=h;const p=u.t,m=t.slice(i-d,i);o.push(jh(p,e,m))}}return s.length>0&&o.push(jh(y0,e,s)),o}function jh(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 xB=typeof console<"u"&&console&&console.warn||(()=>{}),kB="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Dt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function _B(){return qn.groups={},Dt.scanner=null,Dt.parser=null,Dt.tokenQueue=[],Dt.pluginQueue=[],Dt.customSchemes=[],Dt.initialized=!1,Dt}function b0(n,e=!1){if(Dt.initialized&&xB(`linkifyjs: already initialized - will not register custom scheme "${n}" ${kB}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
179
179
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
180
180
|
2. Cannot start or end with "-"
|
|
181
|
-
3. "-" cannot repeat`);Dt.customSchemes.push([n,e])}function SB(){Dt.scanner=gB(Dt.customSchemes);for(let n=0;n<Dt.tokenQueue.length;n++)Dt.tokenQueue[n][1]({scanner:Dt.scanner});Dt.parser=bB(Dt.scanner.tokens);for(let n=0;n<Dt.pluginQueue.length;n++)Dt.pluginQueue[n][1]({scanner:Dt.scanner,parser:Dt.parser});return Dt.initialized=!0,Dt}function fv(n){return Dt.initialized||SB(),wB(Dt.parser.start,n,aS(Dt.scanner.start,n))}fv.scan=aS;function cS(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 uv(t),i=fv(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 hv="[\0- -\u2029 ]",CB=new RegExp(hv),TB=new RegExp(`${hv}$`),AB=new RegExp(hv,"g");function EB(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function MB(n){return new yt({key:new Tt("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=Ez(t.doc,[...e]);if(Lz(a).forEach(({newRange:c})=>{const d=Oz(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(!TB.test(p))return;u=d[0],h=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&h){const p=h.split(CB).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=fv(m).map(y=>y.toObject(n.defaultProtocol));if(!EB(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=>{nv(y.from,y.to,r.doc).some(k=>k.mark.type===n.type)||s.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function OB(n){return new yt({key:new Tt("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=G_(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 DB(n){return new yt({key:new Tt("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=cS(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 Ho(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(AB,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const RB=gi.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"){b0(n);return}b0(n.scheme,n.optionalSlashes)})},onDestroy(){_B()},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)=>!!Ho(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=>!!Ho(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=>!!Ho(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",jt(this.options.HTMLAttributes,n),0]:["a",jt(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Ho(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=>!!Ho(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[Do({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=cS(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!Ho(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(MB({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ho(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(OB({type:this.type})),this.options.linkOnPaste&&n.push(DB({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),NB=It.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new yt({key:new Tt("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&&Lf(s);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=Nt.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}),rt.create(n,i)}}})]}});let Sm,Cm;if(typeof WeakMap<"u"){let n=new WeakMap;Sm=e=>n.get(e),Cm=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Sm=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},Cm=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var Ht=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 Sm(n)||Cm(n,IB(n))}};function IB(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=LB(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:k}=v.attrs;for(let S=0;S<y;S++){if(S+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:y-S});break}const C=i+S*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 W=k&&k[A];if(W){const z=(C+A)%e*2,D=s[z];D==null||D!=W&&s[z+1]==1?(s[z]=W,s[z+1]=1):D==W&&s[z+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 Ht(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&&PB(a,s,n),a}function LB(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 PB(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=zB(l)))[c]=d)}a&&n.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function zB(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function On(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 oo=new Tt("selectingCells");function Ms(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 BB(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 Wr(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 Bf(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=Ms(e.$head)||FB(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function FB(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 Tm(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function HB(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function pv(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function dS(n,e,t){const r=n.node(-1),i=Ht.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 Os(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 uS(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 VB(n,e,t){const r=On(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 Mt=class Ti extends Fe{constructor(e,t=e){const r=e.node(-1),i=Ht.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 Zx(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(Tm(r)&&Tm(i)&&pv(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Ti.rowSelection(r,i):o&&this.isColSelection()?Ti.colSelection(r,i):new Ti(r,i)}return Oe.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=Ht.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=Os(y,0,v)),g>0&&(y=Os(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(ie.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new ge(ie.from(a),1,1)}replace(e,t=ge.empty){const r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:a,$to:l}=i[s],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),s?ge.empty:t)}const o=Fe.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new ge(ie.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Ht.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=Ht.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 Ti(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Ht.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 Ti&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=Ht.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 Ti(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Ti(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Ti(e.resolve(t),e.resolve(r))}getBookmark(){return new UB(this.$anchorCell.pos,this.$headCell.pos)}};Mt.prototype.visible=!1;Fe.jsonID("cell",Mt);var UB=class fS{constructor(e,t){this.anchor=e,this.head=t}map(e){return new fS(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&&pv(t,r)?new Mt(t,r):Fe.near(r,1)}};function jB(n){if(!(n.selection instanceof Mt))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(Nt.node(r,r+t.nodeSize,{class:"selectedCell"}))}),rt.create(n.doc,e)}function WB({$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 KB({$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 qB(n,e,t){const r=(e||n).selection,i=(e||n).doc;let o,s;if(r instanceof Ne&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=Mt.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=Mt.rowSelection(a,a)}else if(!t){const a=Ht.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];o=Mt.create(i,l+1,c)}}else r instanceof Oe&&WB(r)?o=Oe.create(i,r.from):r instanceof Oe&&KB(r)&&(o=Oe.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=n.tr)).setSelection(o),e}const JB=new Tt("fix-tables");function hS(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)?hS(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function pS(n,e){let t;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(t=YB(n,i,o,t))};return e?e.doc!=n.doc&&hS(e.doc,n.doc,0,r):n.doc.descendants(r),t}function YB(n,e,t,r){const i=Ht.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,Os(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=On(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(JB,{fixTables:!0})}function wi(n){const e=n.selection,t=Bf(n),r=t.node(-1),i=t.start(-1),o=Ht.get(r);return{...e instanceof Mt?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(t.pos-i),tableStart:i,map:o,table:r}}function mS(n,{map:e,tableStart:t,table:r},i){let o=i>0?-1:0;VB(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,uS(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?On(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 ZB(n,e){if(!Wr(n))return!1;if(e){const t=wi(n);e(mS(n.tr,t,t.left))}return!0}function GB(n,e){if(!Wr(n))return!1;if(e){const t=wi(n);e(mS(n.tr,t,t.right))}return!0}function XB(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,Os(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 QB(n,e){if(!Wr(n))return!1;if(e){const t=wi(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;XB(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=Ht.get(o)}e(r)}return!0}function $B(n,e,t){var r;const i=On(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 gS(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;$B(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?On(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,On(r.type.schema).row.create(null,s)),n}function eF(n,e){if(!Wr(n))return!1;if(e){const t=wi(n);e(gS(n.tr,t,t.top))}return!0}function tF(n,e){if(!Wr(n))return!1;if(e){const t=wi(n);e(gS(n.tr,t,t.bottom))}return!0}function nF(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 rF(n,e){if(!Wr(n))return!1;if(e){const t=wi(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;nF(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=Ht.get(t.table)}e(r)}return!0}function w0(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function iF({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 x0(n,e){const t=n.selection;if(!(t instanceof Mt)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=wi(n),{map:i}=r;if(iF(i,r))return!1;if(e){const o=n.tr,s={};let a=ie.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{w0(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,{...uS(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=w0(c)?l+1:d;o.replaceWith(u+r.tableStart,d+r.tableStart,a)}o.setSelection(new Mt(o.doc.resolve(l+r.tableStart))),e(o)}return!0}function k0(n,e){const t=On(n.schema);return oF(({node:r})=>t[r.type.spec.tableRole])(n,e)}function oF(n){return(e,t)=>{const r=e.selection;let i,o;if(r instanceof Mt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var s;if(i=BB(r.$from),!i)return!1;o=(s=Ms(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=wi(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 Mt&&u.setSelection(new Mt(u.doc.resolve(r.$anchorCell.pos),h?u.doc.resolve(h):void 0)),t(u)}return!0}}function sF(n,e){return function(t,r){if(!Wr(t))return!1;const i=Bf(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){const o=t.tr;t.selection instanceof Mt?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 aF(n){return function(e,t){if(!Wr(e))return!1;if(t){const r=On(e.schema),i=wi(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 _0(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 cc(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?aF(n):function(t,r){if(!Wr(t))return!1;if(r){const i=On(t.schema),o=wi(t),s=t.tr,a=_0("row",o,i),l=_0("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}}cc("row",{useDeprecatedLogic:!0});cc("column",{useDeprecatedLogic:!0});const lF=cc("cell",{useDeprecatedLogic:!0});function cF(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 S0(n){return function(e,t){if(!Wr(e))return!1;const r=cF(Bf(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(Oe.between(i,HB(i))).scrollIntoView())}return!0}}function dF(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 ed(n,e){const t=n.selection;if(!(t instanceof Mt))return!1;if(e){const r=n.tr,i=On(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 ge(i,0,0))}),r.docChanged&&e(r)}return!0}function uF(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=Am(On(s).row,new ge(c,d,u)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(t||r?Am(On(s).row,new ge(e,t,r)).content:e);else return null;return fF(s,a)}function fF(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(ie.empty),t[i]<r){const o=On(n).cell.createAndFill(),s=[];for(let a=t[i];a<r;a++)s.push(o);e[i]=e[i].append(ie.from(s))}return{height:e.length,width:r,rows:e}}function Am(n,e){const t=n.createAndFill();return new tg(t).replace(0,t.content.size,e).doc}function hF({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(Os(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(ie.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(ie.from(l))}t=o,e=i}return{width:n,height:e,rows:t}}function pF(n,e,t,r,i,o,s){const a=n.doc.type.schema,l=On(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,ie.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 C0(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 T0(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,Os(h.attrs,s-p,h.attrs.colspan-(s-p))),n.insert(m+h.nodeSize,h.type.createAndFill(Os(h.attrs,0,s-p))),c+=h.attrs.rowspan-1}}return l}function A0(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=Ht.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=Ht.get(o),h=u.mapping.maps.length}pF(u,s,o,t,c,d,h)&&p(),C0(u,s,o,t,l,c,a,h)&&p(),C0(u,s,o,t,l,c,d,h)&&p(),T0(u,s,o,t,a,d,l,h)&&p(),T0(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 ge(i.rows[m-a],0,0))}p(),u.setSelection(new Mt(u.doc.resolve(t+s.positionAt(a,l,o)),u.doc.resolve(t+s.positionAt(d-1,c-1,o)))),e(u)}const mF=qg({ArrowLeft:td("horiz",-1),ArrowRight:td("horiz",1),ArrowUp:td("vert",-1),ArrowDown:td("vert",1),"Shift-ArrowLeft":nd("horiz",-1),"Shift-ArrowRight":nd("horiz",1),"Shift-ArrowUp":nd("vert",-1),"Shift-ArrowDown":nd("vert",1),Backspace:ed,"Mod-Backspace":ed,Delete:ed,"Mod-Delete":ed});function Od(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function td(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;if(o instanceof Mt)return Od(t,r,Fe.near(o.$headCell,e));if(n!="horiz"&&!o.empty)return!1;const s=vS(i,n,e);if(s==null)return!1;if(n=="horiz")return Od(t,r,Fe.near(t.doc.resolve(o.head+e),e));{const a=t.doc.resolve(s),l=dS(a,n,e);let c;return l?c=Fe.near(l,1):e<0?c=Fe.near(t.doc.resolve(a.before(-1)),-1):c=Fe.near(t.doc.resolve(a.after(-1)),1),Od(t,r,c)}}}function nd(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof Mt)s=o;else{const l=vS(i,n,e);if(l==null)return!1;s=new Mt(t.doc.resolve(l))}const a=dS(s.$headCell,n,e);return a?Od(t,r,new Mt(s.$anchorCell,a)):!1}}function gF(n,e){const t=n.state.doc,r=Ms(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Mt(r))),!0):!1}function vF(n,e,t){if(!Wr(n.state))return!1;let r=uF(t);const i=n.state.selection;if(i instanceof Mt){r||(r={width:1,height:1,rows:[ie.from(Am(On(n.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=Ht.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=hF(r,a.right-a.left,a.bottom-a.top),A0(n.state,n.dispatch,s,a,r),!0}else if(r){const o=Bf(n.state),s=o.start(-1);return A0(n.state,n.dispatch,s,Ht.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function yF(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=E0(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof Mt)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Ms(n.state.selection.$anchor))!=null&&((t=Wh(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=Wh(n,c);const u=oo.getState(n.state)==null;if(!d||!pv(l,d))if(u)d=l;else return;const h=new Mt(l,d);if(u||!n.state.selection.eq(h)){const p=n.state.tr.setSelection(h);u&&p.setMeta(oo,l.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",a),oo.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(oo,-1))}function a(l){const c=l,d=oo.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(E0(n,c.target)!=r&&(u=Wh(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 vS(n,e,t){if(!(n.state.selection instanceof Oe))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 E0(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Wh(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&&Ms(n.state.doc.resolve(r))||Ms(n.state.doc.resolve(i))}var bF=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")),Em(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,Em(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Em(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 k=document.createElement("col");k.style.width=y,e.appendChild(k)}}}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 rr=new Tt("tableColumnResizing");function wF({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=bF,lastColumnResizable:i=!0}={}){const o=new yt({key:rr,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=On(a.schema).table.name;return r&&c&&(c[d]=(u,h)=>new r(u,t,h)),new xF(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=rr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{kF(s,a,n,i)},mouseleave:s=>{_F(s)},mousedown:(s,a)=>{SF(s,a,e,t)}},decorations:s=>{const a=rr.getState(s);if(a&&a.activeHandle>-1)return MF(s,a.activeHandle)},nodeViews:{}}});return o}var xF=class Dd{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(rr);if(r&&r.setHandle!=null)return new Dd(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Dd(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return Tm(e.doc.resolve(i))||(i=-1),new Dd(i,t.dragging)}return t}};function kF(n,e,t,r){if(!n.editable)return;const i=rr.getState(n.state);if(i&&!i.dragging){const o=TF(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=t?s=M0(n,e,"left",t):l-e.clientX<=t&&(s=M0(n,e,"right",t))}if(s!=i.activeHandle){if(!r&&s!==-1){const a=n.state.doc.resolve(s),l=a.node(-1),c=Ht.get(l),d=a.start(-1);if(c.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==c.width-1)return}yS(n,s)}}}function _F(n){if(!n.editable)return;const e=rr.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&yS(n,-1)}function SF(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=rr.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=n.state.doc.nodeAt(s.activeHandle),l=CF(n,s.activeHandle,a.attrs);n.dispatch(n.state.tr.setMeta(rr,{setDragging:{startX:e.clientX,startWidth:l}}));function c(u){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",d);const h=rr.getState(n.state);h!=null&&h.dragging&&(AF(n,h.activeHandle,O0(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(rr,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=rr.getState(n.state);if(h&&h.dragging){const p=O0(h.dragging,u,t);D0(n,h.activeHandle,p,r)}}return D0(n,s.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",d),e.preventDefault(),!0}function CF(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 TF(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function M0(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=Ms(n.state.doc.resolve(s));if(!a)return-1;if(t=="right")return a.pos;const l=Ht.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 O0(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function yS(n,e){n.dispatch(n.state.tr.setMeta(rr,{setHandle:e}))}function AF(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),o=Ht.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():EF(h.colspan);m[p]=t,l.setNodeMarkup(s+u,null,{...h,colwidth:m})}l.docChanged&&n.dispatch(l)}function D0(n,e,t,r){const i=n.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=Ht.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&&Em(o,l.firstChild,l,r,a,t)}function EF(n){return Array(n).fill(0)}function MF(n,e){const t=[],r=n.doc.resolve(e),i=r.node(-1);if(!i)return rt.empty;const o=Ht.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=rr.getState(n))===null||l===void 0)&&l.dragging&&t.push(Nt.node(s+u,s+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),t.push(Nt.widget(h,p))}}return rt.create(n.doc,t)}function OF({allowTableNodeSelection:n=!1}={}){return new yt({key:oo,state:{init(){return null},apply(e,t){const r=e.getMeta(oo);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:jB,handleDOMEvents:{mousedown:yF},createSelectionBetween(e){return oo.getState(e.state)!=null?e.state.selection:null},handleTripleClick:gF,handleKeyDown:mF,handlePaste:vF},appendTransaction(e,t,r){return qB(r,pS(r,t),n)}})}function Mm(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function R0(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[k,S]=Mm(r,g);c.style.setProperty(k,S)}c=c.nextSibling}else{const k=document.createElement("col"),[S,C]=Mm(r,g);k.style.setProperty(S,C),e.appendChild(k)}}}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 DF{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")),R0(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,R0(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function RF(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,k]=Mm(e,g);s.push(["col",{style:`${y}: ${k}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:c}}function N0(n,e){return n.createAndFill()}function NF(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 IF(n,e,t,r,i){const o=NF(n),s=[],a=[];for(let c=0;c<t;c+=1){const d=N0(o.cell);if(d&&a.push(d),r){const u=N0(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 LF(n){return n instanceof Mt}const rd=({editor:n})=>{const{selection:e}=n.state;if(!LF(e))return!1;let t=0;const r=Z_(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},PF=Vn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:DF,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}=RF(n,this.options.cellMinWidth),o=["table",jt(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=IF(o.schema,n,e,t);if(i){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Oe.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>ZB(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>GB(n,e),deleteColumn:()=>({state:n,dispatch:e})=>QB(n,e),addRowBefore:()=>({state:n,dispatch:e})=>eF(n,e),addRowAfter:()=>({state:n,dispatch:e})=>tF(n,e),deleteRow:()=>({state:n,dispatch:e})=>rF(n,e),deleteTable:()=>({state:n,dispatch:e})=>dF(n,e),mergeCells:()=>({state:n,dispatch:e})=>x0(n,e),splitCell:()=>({state:n,dispatch:e})=>k0(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>cc("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>cc("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>lF(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>x0(n,e)?!0:k0(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>sF(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>S0(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>S0(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&pS(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Mt.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:rd,"Mod-Backspace":rd,Delete:rd,"Mod-Delete":rd}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[wF({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],OF({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Qe(_e(n,"tableRole",e))}}}),zF=Vn.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",jt(this.options.HTMLAttributes,n),0]}}),BF=Vn.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",jt(this.options.HTMLAttributes,n),0]}}),FF=Vn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",jt(this.options.HTMLAttributes,n),0]}}),HF=/^\s*>\s$/,VF=Vn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",jt(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[oc({find:HF,type:this.type})]}}),UF=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,jF=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,WF=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,KF=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,qF=gi.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",jt(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[Es({find:UF,type:this.type}),Es({find:WF,type:this.type})]},addPasteRules(){return[Do({find:jF,type:this.type}),Do({find:KF,type:this.type})]}}),JF="listItem",I0="textStyle",L0=/^\s*([-+*])\s$/,YF=Vn.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",jt(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(JF,this.editor.getAttributes(I0)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=oc({find:L0,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=oc({find:L0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(I0),editor:this.editor})),[n]}}),ZF=/(^|[^`])`([^`]+)`(?!`)/,GF=/(^|[^`])`([^`]+)`(?!`)/g,XF=gi.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",jt(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[Es({find:ZF,type:this.type})]},addPasteRules(){return[Do({find:GF,type:this.type})]}}),QF=/^```([a-z]+)?[\s\n]$/,$F=/^~~~([a-z]+)?[\s\n]$/,e5=Vn.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",jt(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(`
|
|
181
|
+
3. "-" cannot repeat`);Dt.customSchemes.push([n,e])}function SB(){Dt.scanner=gB(Dt.customSchemes);for(let n=0;n<Dt.tokenQueue.length;n++)Dt.tokenQueue[n][1]({scanner:Dt.scanner});Dt.parser=bB(Dt.scanner.tokens);for(let n=0;n<Dt.pluginQueue.length;n++)Dt.pluginQueue[n][1]({scanner:Dt.scanner,parser:Dt.parser});return Dt.initialized=!0,Dt}function fv(n){return Dt.initialized||SB(),wB(Dt.parser.start,n,aS(Dt.scanner.start,n))}fv.scan=aS;function cS(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 uv(t),i=fv(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 hv="[\0- -\u2029 ]",CB=new RegExp(hv),TB=new RegExp(`${hv}$`),AB=new RegExp(hv,"g");function EB(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function MB(n){return new yt({key:new Tt("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=Ez(t.doc,[...e]);if(Lz(a).forEach(({newRange:c})=>{const d=Oz(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(!TB.test(p))return;u=d[0],h=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&h){const p=h.split(CB).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=fv(m).map(y=>y.toObject(n.defaultProtocol));if(!EB(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=>{nv(y.from,y.to,r.doc).some(k=>k.mark.type===n.type)||s.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function OB(n){return new yt({key:new Tt("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=G_(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 DB(n){return new yt({key:new Tt("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=cS(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 Ho(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(AB,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const RB=gi.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"){b0(n);return}b0(n.scheme,n.optionalSlashes)})},onDestroy(){_B()},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)=>!!Ho(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=>!!Ho(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=>!!Ho(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Wt(this.options.HTMLAttributes,n),0]:["a",Wt(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Ho(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=>!!Ho(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[Do({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=cS(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!Ho(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(MB({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ho(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(OB({type:this.type})),this.options.linkOnPaste&&n.push(DB({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),NB=It.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new yt({key:new Tt("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&&Lf(s);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=Nt.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}),rt.create(n,i)}}})]}});let Sm,Cm;if(typeof WeakMap<"u"){let n=new WeakMap;Sm=e=>n.get(e),Cm=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Sm=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},Cm=(r,i)=>(t==10&&(t=0),n[t++]=r,n[t++]=i)}var Vt=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 Sm(n)||Cm(n,IB(n))}};function IB(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=LB(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:k}=v.attrs;for(let S=0;S<y;S++){if(S+c>=t){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:y-S});break}const C=i+S*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 W=k&&k[A];if(W){const z=(C+A)%e*2,D=s[z];D==null||D!=W&&s[z+1]==1?(s[z]=W,s[z+1]=1):D==W&&s[z+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 Vt(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&&PB(a,s,n),a}function LB(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 PB(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=zB(l)))[c]=d)}a&&n.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function zB(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function On(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 oo=new Tt("selectingCells");function Ms(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 BB(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 Wr(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 Bf(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=Ms(e.$head)||FB(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function FB(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 Tm(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function HB(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function pv(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function dS(n,e,t){const r=n.node(-1),i=Vt.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 Os(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 uS(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 VB(n,e,t){const r=On(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 Mt=class Ti extends Fe{constructor(e,t=e){const r=e.node(-1),i=Vt.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 Zx(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(Tm(r)&&Tm(i)&&pv(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Ti.rowSelection(r,i):o&&this.isColSelection()?Ti.colSelection(r,i):new Ti(r,i)}return Oe.between(r,i)}content(){const e=this.$anchorCell.node(-1),t=Vt.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=Os(y,0,v)),g>0&&(y=Os(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(ie.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new ge(ie.from(a),1,1)}replace(e,t=ge.empty){const r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:a,$to:l}=i[s],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),s?ge.empty:t)}const o=Fe.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,t){this.replace(e,new ge(ie.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Vt.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=Vt.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 Ti(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Vt.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 Ti&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),i=Vt.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 Ti(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Ti(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Ti(e.resolve(t),e.resolve(r))}getBookmark(){return new UB(this.$anchorCell.pos,this.$headCell.pos)}};Mt.prototype.visible=!1;Fe.jsonID("cell",Mt);var UB=class fS{constructor(e,t){this.anchor=e,this.head=t}map(e){return new fS(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&&pv(t,r)?new Mt(t,r):Fe.near(r,1)}};function jB(n){if(!(n.selection instanceof Mt))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(Nt.node(r,r+t.nodeSize,{class:"selectedCell"}))}),rt.create(n.doc,e)}function WB({$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 KB({$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 qB(n,e,t){const r=(e||n).selection,i=(e||n).doc;let o,s;if(r instanceof Ne&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=Mt.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=Mt.rowSelection(a,a)}else if(!t){const a=Vt.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];o=Mt.create(i,l+1,c)}}else r instanceof Oe&&WB(r)?o=Oe.create(i,r.from):r instanceof Oe&&KB(r)&&(o=Oe.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=n.tr)).setSelection(o),e}const JB=new Tt("fix-tables");function hS(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)?hS(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function pS(n,e){let t;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(t=YB(n,i,o,t))};return e?e.doc!=n.doc&&hS(e.doc,n.doc,0,r):n.doc.descendants(r),t}function YB(n,e,t,r){const i=Vt.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,Os(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=On(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(JB,{fixTables:!0})}function wi(n){const e=n.selection,t=Bf(n),r=t.node(-1),i=t.start(-1),o=Vt.get(r);return{...e instanceof Mt?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(t.pos-i),tableStart:i,map:o,table:r}}function mS(n,{map:e,tableStart:t,table:r},i){let o=i>0?-1:0;VB(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,uS(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?On(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 ZB(n,e){if(!Wr(n))return!1;if(e){const t=wi(n);e(mS(n.tr,t,t.left))}return!0}function GB(n,e){if(!Wr(n))return!1;if(e){const t=wi(n);e(mS(n.tr,t,t.right))}return!0}function XB(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,Os(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 QB(n,e){if(!Wr(n))return!1;if(e){const t=wi(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;XB(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=Vt.get(o)}e(r)}return!0}function $B(n,e,t){var r;const i=On(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 gS(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;$B(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?On(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,On(r.type.schema).row.create(null,s)),n}function eF(n,e){if(!Wr(n))return!1;if(e){const t=wi(n);e(gS(n.tr,t,t.top))}return!0}function tF(n,e){if(!Wr(n))return!1;if(e){const t=wi(n);e(gS(n.tr,t,t.bottom))}return!0}function nF(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 rF(n,e){if(!Wr(n))return!1;if(e){const t=wi(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;nF(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=Vt.get(t.table)}e(r)}return!0}function w0(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function iF({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 x0(n,e){const t=n.selection;if(!(t instanceof Mt)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=wi(n),{map:i}=r;if(iF(i,r))return!1;if(e){const o=n.tr,s={};let a=ie.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{w0(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,{...uS(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=w0(c)?l+1:d;o.replaceWith(u+r.tableStart,d+r.tableStart,a)}o.setSelection(new Mt(o.doc.resolve(l+r.tableStart))),e(o)}return!0}function k0(n,e){const t=On(n.schema);return oF(({node:r})=>t[r.type.spec.tableRole])(n,e)}function oF(n){return(e,t)=>{const r=e.selection;let i,o;if(r instanceof Mt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var s;if(i=BB(r.$from),!i)return!1;o=(s=Ms(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=wi(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 Mt&&u.setSelection(new Mt(u.doc.resolve(r.$anchorCell.pos),h?u.doc.resolve(h):void 0)),t(u)}return!0}}function sF(n,e){return function(t,r){if(!Wr(t))return!1;const i=Bf(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){const o=t.tr;t.selection instanceof Mt?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 aF(n){return function(e,t){if(!Wr(e))return!1;if(t){const r=On(e.schema),i=wi(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 _0(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 cc(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?aF(n):function(t,r){if(!Wr(t))return!1;if(r){const i=On(t.schema),o=wi(t),s=t.tr,a=_0("row",o,i),l=_0("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}}cc("row",{useDeprecatedLogic:!0});cc("column",{useDeprecatedLogic:!0});const lF=cc("cell",{useDeprecatedLogic:!0});function cF(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 S0(n){return function(e,t){if(!Wr(e))return!1;const r=cF(Bf(e),n);if(r==null)return!1;if(t){const i=e.doc.resolve(r);t(e.tr.setSelection(Oe.between(i,HB(i))).scrollIntoView())}return!0}}function dF(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 ed(n,e){const t=n.selection;if(!(t instanceof Mt))return!1;if(e){const r=n.tr,i=On(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 ge(i,0,0))}),r.docChanged&&e(r)}return!0}function uF(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=Am(On(s).row,new ge(c,d,u)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(t||r?Am(On(s).row,new ge(e,t,r)).content:e);else return null;return fF(s,a)}function fF(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(ie.empty),t[i]<r){const o=On(n).cell.createAndFill(),s=[];for(let a=t[i];a<r;a++)s.push(o);e[i]=e[i].append(ie.from(s))}return{height:e.length,width:r,rows:e}}function Am(n,e){const t=n.createAndFill();return new tg(t).replace(0,t.content.size,e).doc}function hF({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(Os(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(ie.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(ie.from(l))}t=o,e=i}return{width:n,height:e,rows:t}}function pF(n,e,t,r,i,o,s){const a=n.doc.type.schema,l=On(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,ie.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 C0(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 T0(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,Os(h.attrs,s-p,h.attrs.colspan-(s-p))),n.insert(m+h.nodeSize,h.type.createAndFill(Os(h.attrs,0,s-p))),c+=h.attrs.rowspan-1}}return l}function A0(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=Vt.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=Vt.get(o),h=u.mapping.maps.length}pF(u,s,o,t,c,d,h)&&p(),C0(u,s,o,t,l,c,a,h)&&p(),C0(u,s,o,t,l,c,d,h)&&p(),T0(u,s,o,t,a,d,l,h)&&p(),T0(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 ge(i.rows[m-a],0,0))}p(),u.setSelection(new Mt(u.doc.resolve(t+s.positionAt(a,l,o)),u.doc.resolve(t+s.positionAt(d-1,c-1,o)))),e(u)}const mF=qg({ArrowLeft:td("horiz",-1),ArrowRight:td("horiz",1),ArrowUp:td("vert",-1),ArrowDown:td("vert",1),"Shift-ArrowLeft":nd("horiz",-1),"Shift-ArrowRight":nd("horiz",1),"Shift-ArrowUp":nd("vert",-1),"Shift-ArrowDown":nd("vert",1),Backspace:ed,"Mod-Backspace":ed,Delete:ed,"Mod-Delete":ed});function Od(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function td(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;if(o instanceof Mt)return Od(t,r,Fe.near(o.$headCell,e));if(n!="horiz"&&!o.empty)return!1;const s=vS(i,n,e);if(s==null)return!1;if(n=="horiz")return Od(t,r,Fe.near(t.doc.resolve(o.head+e),e));{const a=t.doc.resolve(s),l=dS(a,n,e);let c;return l?c=Fe.near(l,1):e<0?c=Fe.near(t.doc.resolve(a.before(-1)),-1):c=Fe.near(t.doc.resolve(a.after(-1)),1),Od(t,r,c)}}}function nd(n,e){return(t,r,i)=>{if(!i)return!1;const o=t.selection;let s;if(o instanceof Mt)s=o;else{const l=vS(i,n,e);if(l==null)return!1;s=new Mt(t.doc.resolve(l))}const a=dS(s.$headCell,n,e);return a?Od(t,r,new Mt(s.$anchorCell,a)):!1}}function gF(n,e){const t=n.state.doc,r=Ms(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Mt(r))),!0):!1}function vF(n,e,t){if(!Wr(n.state))return!1;let r=uF(t);const i=n.state.selection;if(i instanceof Mt){r||(r={width:1,height:1,rows:[ie.from(Am(On(n.state.schema).cell,t))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=Vt.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=hF(r,a.right-a.left,a.bottom-a.top),A0(n.state,n.dispatch,s,a,r),!0}else if(r){const o=Bf(n.state),s=o.start(-1);return A0(n.state,n.dispatch,s,Vt.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function yF(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=E0(n,e.target);let i;if(e.shiftKey&&n.state.selection instanceof Mt)o(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Ms(n.state.selection.$anchor))!=null&&((t=Wh(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=Wh(n,c);const u=oo.getState(n.state)==null;if(!d||!pv(l,d))if(u)d=l;else return;const h=new Mt(l,d);if(u||!n.state.selection.eq(h)){const p=n.state.tr.setSelection(h);u&&p.setMeta(oo,l.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",a),oo.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(oo,-1))}function a(l){const c=l,d=oo.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(E0(n,c.target)!=r&&(u=Wh(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 vS(n,e,t){if(!(n.state.selection instanceof Oe))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 E0(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Wh(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&&Ms(n.state.doc.resolve(r))||Ms(n.state.doc.resolve(i))}var bF=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")),Em(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,Em(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Em(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 k=document.createElement("col");k.style.width=y,e.appendChild(k)}}}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 rr=new Tt("tableColumnResizing");function wF({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=bF,lastColumnResizable:i=!0}={}){const o=new yt({key:rr,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=On(a.schema).table.name;return r&&c&&(c[d]=(u,h)=>new r(u,t,h)),new xF(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=rr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{kF(s,a,n,i)},mouseleave:s=>{_F(s)},mousedown:(s,a)=>{SF(s,a,e,t)}},decorations:s=>{const a=rr.getState(s);if(a&&a.activeHandle>-1)return MF(s,a.activeHandle)},nodeViews:{}}});return o}var xF=class Dd{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(rr);if(r&&r.setHandle!=null)return new Dd(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Dd(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);return Tm(e.doc.resolve(i))||(i=-1),new Dd(i,t.dragging)}return t}};function kF(n,e,t,r){if(!n.editable)return;const i=rr.getState(n.state);if(i&&!i.dragging){const o=TF(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=t?s=M0(n,e,"left",t):l-e.clientX<=t&&(s=M0(n,e,"right",t))}if(s!=i.activeHandle){if(!r&&s!==-1){const a=n.state.doc.resolve(s),l=a.node(-1),c=Vt.get(l),d=a.start(-1);if(c.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==c.width-1)return}yS(n,s)}}}function _F(n){if(!n.editable)return;const e=rr.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&yS(n,-1)}function SF(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=rr.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=n.state.doc.nodeAt(s.activeHandle),l=CF(n,s.activeHandle,a.attrs);n.dispatch(n.state.tr.setMeta(rr,{setDragging:{startX:e.clientX,startWidth:l}}));function c(u){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",d);const h=rr.getState(n.state);h!=null&&h.dragging&&(AF(n,h.activeHandle,O0(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(rr,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=rr.getState(n.state);if(h&&h.dragging){const p=O0(h.dragging,u,t);D0(n,h.activeHandle,p,r)}}return D0(n,s.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",d),e.preventDefault(),!0}function CF(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 TF(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function M0(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=Ms(n.state.doc.resolve(s));if(!a)return-1;if(t=="right")return a.pos;const l=Vt.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 O0(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function yS(n,e){n.dispatch(n.state.tr.setMeta(rr,{setHandle:e}))}function AF(n,e,t){const r=n.state.doc.resolve(e),i=r.node(-1),o=Vt.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():EF(h.colspan);m[p]=t,l.setNodeMarkup(s+u,null,{...h,colwidth:m})}l.docChanged&&n.dispatch(l)}function D0(n,e,t,r){const i=n.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=Vt.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&&Em(o,l.firstChild,l,r,a,t)}function EF(n){return Array(n).fill(0)}function MF(n,e){const t=[],r=n.doc.resolve(e),i=r.node(-1);if(!i)return rt.empty;const o=Vt.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=rr.getState(n))===null||l===void 0)&&l.dragging&&t.push(Nt.node(s+u,s+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),t.push(Nt.widget(h,p))}}return rt.create(n.doc,t)}function OF({allowTableNodeSelection:n=!1}={}){return new yt({key:oo,state:{init(){return null},apply(e,t){const r=e.getMeta(oo);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:jB,handleDOMEvents:{mousedown:yF},createSelectionBetween(e){return oo.getState(e.state)!=null?e.state.selection:null},handleTripleClick:gF,handleKeyDown:mF,handlePaste:vF},appendTransaction(e,t,r){return qB(r,pS(r,t),n)}})}function Mm(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function R0(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[k,S]=Mm(r,g);c.style.setProperty(k,S)}c=c.nextSibling}else{const k=document.createElement("col"),[S,C]=Mm(r,g);k.style.setProperty(S,C),e.appendChild(k)}}}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 DF{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")),R0(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,R0(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function RF(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,k]=Mm(e,g);s.push(["col",{style:`${y}: ${k}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:c}}function N0(n,e){return n.createAndFill()}function NF(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 IF(n,e,t,r,i){const o=NF(n),s=[],a=[];for(let c=0;c<t;c+=1){const d=N0(o.cell);if(d&&a.push(d),r){const u=N0(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 LF(n){return n instanceof Mt}const rd=({editor:n})=>{const{selection:e}=n.state;if(!LF(e))return!1;let t=0;const r=Z_(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},PF=Vn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:DF,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}=RF(n,this.options.cellMinWidth),o=["table",Wt(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=IF(o.schema,n,e,t);if(i){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Oe.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>ZB(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>GB(n,e),deleteColumn:()=>({state:n,dispatch:e})=>QB(n,e),addRowBefore:()=>({state:n,dispatch:e})=>eF(n,e),addRowAfter:()=>({state:n,dispatch:e})=>tF(n,e),deleteRow:()=>({state:n,dispatch:e})=>rF(n,e),deleteTable:()=>({state:n,dispatch:e})=>dF(n,e),mergeCells:()=>({state:n,dispatch:e})=>x0(n,e),splitCell:()=>({state:n,dispatch:e})=>k0(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>cc("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>cc("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>lF(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>x0(n,e)?!0:k0(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>sF(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>S0(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>S0(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&pS(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Mt.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:rd,"Mod-Backspace":rd,Delete:rd,"Mod-Delete":rd}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[wF({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],OF({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Qe(_e(n,"tableRole",e))}}}),zF=Vn.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",Wt(this.options.HTMLAttributes,n),0]}}),BF=Vn.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",Wt(this.options.HTMLAttributes,n),0]}}),FF=Vn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",Wt(this.options.HTMLAttributes,n),0]}}),HF=/^\s*>\s$/,VF=Vn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",Wt(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[oc({find:HF,type:this.type})]}}),UF=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,jF=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,WF=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,KF=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,qF=gi.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",Wt(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[Es({find:UF,type:this.type}),Es({find:WF,type:this.type})]},addPasteRules(){return[Do({find:jF,type:this.type}),Do({find:KF,type:this.type})]}}),JF="listItem",I0="textStyle",L0=/^\s*([-+*])\s$/,YF=Vn.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",Wt(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(JF,this.editor.getAttributes(I0)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=oc({find:L0,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=oc({find:L0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(I0),editor:this.editor})),[n]}}),ZF=/(^|[^`])`([^`]+)`(?!`)/,GF=/(^|[^`])`([^`]+)`(?!`)/g,XF=gi.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",Wt(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[Es({find:ZF,type:this.type})]},addPasteRules(){return[Do({find:GF,type:this.type})]}}),QF=/^```([a-z]+)?[\s\n]$/,$F=/^~~~([a-z]+)?[\s\n]$/,e5=Vn.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",Wt(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(`
|
|
182
182
|
|
|
183
183
|
`);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(Fe.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[dm({find:QF,type:this.type,getAttributes:n=>({language:n[1]})}),dm({find:$F,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new yt({key:new Tt("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,`
|
|
184
|
-
`));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Oe.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}}),t5=Vn.create({name:"doc",topNode:!0,content:"block+"});function n5(n={}){return new yt({view(e){return new r5(e,n)}})}class r5{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=Wx(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 i5=It.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[n5(this.options)]}});class
|
|
185
|
-
`},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()}}}),p5=Vn.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]}`,jt(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=>dm({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Gu=200,un=function(){};un.prototype.append=function(e){return e.length?(e=un.from(e),!this.length&&e||e.length<Gu&&this.leafAppend(e)||this.length<Gu&&e.leafPrepend(this)||this.appendInner(e)):this};un.prototype.prepend=function(e){return e.length?un.from(e).append(this):this};un.prototype.appendInner=function(e){return new m5(this,e)};un.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?un.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};un.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};un.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)};un.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};un.from=function(e){return e instanceof un?e:e&&e.length?new wS(e):un.empty};var wS=(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<=Gu)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Gu)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})(un);un.empty=new wS([]);var m5=(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})(un);const g5=500;class Nr{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 Zr(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 Zr(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 Nr(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 Zr(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>y5&&(a=v5(a,c),s-=c),new Nr(a.append(o),s)}remapping(e,t){let r=new zl;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 Nr(this.items.append(e.map(t=>new Zr(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 Zr(m,v,g))}else r.push(new Zr(m))},i);let c=[];for(let h=t;h<s;h++)c.push(new Zr(o.maps[h]));let d=this.items.slice(0,i).append(c).append(r),u=new Nr(d,a);return u.emptyItemCount()>g5&&(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 Zr(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 Nr(un.from(i.reverse()),o)}}Nr.empty=new Nr(un.empty,0);function v5(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class Zr{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 Zr(t.getMap().invert(),t,this.selection)}}}class to{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const y5=20;function b5(n,e,t,r){let i=t.getMeta(ps),o;if(i)return i.historyState;t.getMeta(k5)&&(n=new to(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(ps))return s.getMeta(ps).redo?new to(n.done.addTransform(t,void 0,r,Rd(e)),n.undone,P0(t.mapping.maps),n.prevTime,n.prevComposition):new to(n.done,n.undone.addTransform(t,void 0,r,Rd(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||!w5(t,n.prevRanges)),c=s?Kh(n.prevRanges,t.mapping):P0(t.mapping.maps);return new to(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,Rd(e)),Nr.empty,c,t.time,a??n.prevComposition)}else return(o=t.getMeta("rebased"))?new to(n.done.rebased(t,o),n.undone.rebased(t,o),Kh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new to(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Kh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function w5(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 P0(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 Kh(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 x5(n,e,t){let r=Rd(e),i=ps.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 to(t?a:o.remaining,t?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(ps,{redo:t,historyState:l})}let qh=!1,z0=null;function Rd(n){let e=n.plugins;if(z0!=e){qh=!1,z0=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){qh=!0;break}}return qh}const ps=new Tt("history"),k5=new Tt("closeHistory");function _5(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new yt({key:ps,state:{init(){return new to(Nr.empty,Nr.empty,null,0,-1)},apply(e,t,r){return b5(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?kS:r=="historyRedo"?_S:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function xS(n,e){return(t,r)=>{let i=ps.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=x5(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const kS=xS(!1,!0),_S=xS(!0,!0),S5=It.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>kS(n,e),redo:()=>({state:n,dispatch:e})=>_S(n,e)}},addProseMirrorPlugins(){return[_5(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()}}}),C5=Vn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",jt(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!g4(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}):zz(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(Oe.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(Ne.create(s.doc,c.pos)):s.setSelection(Oe.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(Oe.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[m4({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),T5=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,A5=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,E5=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,M5=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,O5=gi.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",jt(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[Es({find:T5,type:this.type}),Es({find:E5,type:this.type})]},addPasteRules(){return[Do({find:A5,type:this.type}),Do({find:M5,type:this.type})]}}),D5=Vn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",jt(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)}}}),R5="listItem",B0="textStyle",F0=/^(\d+)\.\s$/,N5=Vn.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",jt(this.options.HTMLAttributes,t),0]:["ol",jt(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(R5,this.editor.getAttributes(B0)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=oc({find:F0,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=oc({find:F0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(B0)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),I5=Vn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",jt(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),L5=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,P5=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,z5=gi.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",jt(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[Es({find:L5,type:this.type})]},addPasteRules(){return[Do({find:P5,type:this.type})]}}),B5=Vn.create({name:"text",group:"inline"}),F5=It.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(qF.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(VF.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(YF.configure(this.options.bulletList)),this.options.code!==!1&&n.push(XF.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(e5.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(t5.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(i5.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(f5.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(h5.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(p5.configure(this.options.heading)),this.options.history!==!1&&n.push(S5.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(C5.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(O5.configure(this.options.italic)),this.options.listItem!==!1&&n.push(D5.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(N5.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(I5.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(z5.configure(this.options.strike)),this.options.text!==!1&&n.push(B5.configure(this.options.text)),n}}),od=new Tt("tandemAnnotations");function Jh(n,e,t){const r=[],i=n.content.size;return e.forEach(o=>{const s=Ra(o,u=>{console.warn("[sanitize]",u)});if(s.status!=="pending"||!s.range&&!s.relRange)return;const a=lu(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=sx(s.color),h=Il[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(Nt.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)}}),rt.create(n,r)}const H5=It.create({name:"tandemAnnotations",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(So);let t=e.size>0,r=!1;return[new yt({key:od,state:{init(i,o){return Jh(o.doc,e,n)},apply(i,o,s,a){if(i.getMeta(od))return Jh(a.doc,e,n);if(i.docChanged){if(!r&&o===rt.empty&&t){const l=Jh(a.doc,e,n);return l!==rt.empty&&(r=!0),l}return o.map(i.mapping,i.doc)}return o}},props:{decorations(i){return od.getState(i)}},view(i){const o=()=>{t=e.size>0,r=!1;const s=i.state.tr.setMeta(od,!0);i.dispatch(s)};return e.observe(o),{destroy(){e.unobserve(o)}}}})]}}),Js=new Tt("tandemAuthorship"),V5=new Set(["paragraph","heading"]);function U5(n,e,t){if(n.relRange){const r=Ek(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=Mo(e,n.range.from),i=Mo(e,n.range.to);if(r<i)return{from:r,to:i}}return null}function Yh(n,e,t,r){if(!r)return rt.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=U5(l,n,t);if(!c)return;const{from:d,to:u}=c;if(!(d>=u||d<0||u>o)){try{i.push(Nt.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(!V5.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(Nt.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)}}),rt.create(n,i)}const j5=It.create({name:"tandemAuthorship",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(oy);let t=!1;try{t=localStorage.getItem(ux)==="true"}catch(r){console.warn("[authorship] localStorage unavailable",r)}return[new yt({key:Js,state:{init(r,i){return{visible:t,decorations:Yh(i.doc,e,n,t)}},apply(r,i,o,s){const a=r.getMeta(Js);if((a==null?void 0:a.type)==="toggle"){const l=a.visible;return{visible:l,decorations:Yh(s.doc,e,n,l)}}return(a==null?void 0:a.type)==="rebuild"?{visible:i.visible,decorations:Yh(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=Js.getState(r))==null?void 0:i.decorations)??rt.empty}},view(r){const i=()=>{const s=r.state.tr.setMeta(Js,{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(Js)||!n.docChanged)return;const t=e.getMap(oy),r=n.doc;n.steps.forEach(i=>{i.getMap().forEach((s,a,l,c)=>{if(c-l-(a-s)>0)try{const u=ri(r,bn(l)),h=ri(r,bn(c));if(h<=u)return;const p=PD("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)}})})}}),sd=new Tt("tandemAwareness");function H0(n,e){if(!e)return rt.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(Nt.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=Mo(n,pd(i)),a=o===!1?" tandem-claude-cursor-idle":"";t.push(Nt.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?rt.empty:rt.create(n,t)}const W5=It.create({name:"tandemAwareness",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(dx),t=n.getMap(yp);return[new yt({key:sd,state:{init(r,i){const o=e.get(bp);return H0(i.doc,o??null)},apply(r,i,o,s){if(r.getMeta(sd)){const a=e.get(bp);return H0(s.doc,a??null)}return r.docChanged?i.map(r.mapping,r.doc):i}},props:{decorations(r){return sd.getState(r)}},view(r){const i=()=>{const o=r.state.tr.setMeta(sd,!0);r.dispatch(o)};return e.observe(i),{destroy(){e.unobserve(i)}}}}),new yt({key:new Tt("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=Mk(d.doc,{from:bn(d.selection.from),to:bn(d.selection.to)});if(d.selection.from===d.selection.to)o&&(clearTimeout(o),o=null),t.set(sy,{...u,timestamp:Date.now()});else{const h=d.doc.textBetween(d.selection.from,d.selection.to,`
|
|
184
|
+
`));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Oe.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}}),t5=Vn.create({name:"doc",topNode:!0,content:"block+"});function n5(n={}){return new yt({view(e){return new r5(e,n)}})}class r5{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=Wx(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 i5=It.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[n5(this.options)]}});class Ht extends Fe{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return Ht.valid(r)?new Ht(r):Fe.near(r)}content(){return ge.empty}eq(e){return e instanceof Ht&&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 Ht(e.resolve(t.pos))}getBookmark(){return new mv(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!o5(e)||!s5(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&&Ht.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(Ht.valid(l))return l}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!Ne.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(Ht.valid(a))return a}return null}}}Ht.prototype.visible=!1;Ht.findFrom=Ht.findGapCursorFrom;Fe.jsonID("gapcursor",Ht);class mv{constructor(e){this.pos=e}map(e){return new mv(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ht.valid(t)?new Ht(t):Fe.near(t)}}function bS(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function o5(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||bS(i.type))return!0;if(i.inlineContent)return!1}}return!0}function s5(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||bS(i.type))return!0;if(i.inlineContent)return!1}}return!0}function a5(){return new yt({props:{decorations:u5,createSelectionBetween(n,e,t){return e.pos==t.pos&&Ht.valid(t)?new Ht(t):null},handleClick:c5,handleKeyDown:l5,handleDOMEvents:{beforeinput:d5}}})}const l5=qg({ArrowLeft:id("horiz",-1),ArrowRight:id("horiz",1),ArrowUp:id("vert",-1),ArrowDown:id("vert",1)});function id(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 Oe){if(!o.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=Ht.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new Ht(c))),!0):!1}}function c5(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Ht.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&Ne.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Ht(r))),!0)}function d5(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Ht))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=ie.empty;for(let s=r.length-1;s>=0;s--)i=ie.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new ge(i,0,0));return o.setSelection(Oe.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function u5(n){if(!(n.selection instanceof Ht))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",rt.create(n.doc,[Nt.widget(n.selection.head,e,{key:"gapcursor"})])}const f5=It.create({name:"gapCursor",addProseMirrorPlugins(){return[a5()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Qe(_e(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),h5=Vn.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",Wt(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
185
|
+
`},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()}}}),p5=Vn.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]}`,Wt(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=>dm({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Gu=200,un=function(){};un.prototype.append=function(e){return e.length?(e=un.from(e),!this.length&&e||e.length<Gu&&this.leafAppend(e)||this.length<Gu&&e.leafPrepend(this)||this.appendInner(e)):this};un.prototype.prepend=function(e){return e.length?un.from(e).append(this):this};un.prototype.appendInner=function(e){return new m5(this,e)};un.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?un.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};un.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};un.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)};un.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};un.from=function(e){return e instanceof un?e:e&&e.length?new wS(e):un.empty};var wS=(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<=Gu)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Gu)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})(un);un.empty=new wS([]);var m5=(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})(un);const g5=500;class Nr{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 Zr(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 Zr(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 Nr(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 Zr(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>y5&&(a=v5(a,c),s-=c),new Nr(a.append(o),s)}remapping(e,t){let r=new zl;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 Nr(this.items.append(e.map(t=>new Zr(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 Zr(m,v,g))}else r.push(new Zr(m))},i);let c=[];for(let h=t;h<s;h++)c.push(new Zr(o.maps[h]));let d=this.items.slice(0,i).append(c).append(r),u=new Nr(d,a);return u.emptyItemCount()>g5&&(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 Zr(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 Nr(un.from(i.reverse()),o)}}Nr.empty=new Nr(un.empty,0);function v5(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class Zr{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 Zr(t.getMap().invert(),t,this.selection)}}}class to{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const y5=20;function b5(n,e,t,r){let i=t.getMeta(ps),o;if(i)return i.historyState;t.getMeta(k5)&&(n=new to(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(ps))return s.getMeta(ps).redo?new to(n.done.addTransform(t,void 0,r,Rd(e)),n.undone,P0(t.mapping.maps),n.prevTime,n.prevComposition):new to(n.done,n.undone.addTransform(t,void 0,r,Rd(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||!w5(t,n.prevRanges)),c=s?Kh(n.prevRanges,t.mapping):P0(t.mapping.maps);return new to(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,Rd(e)),Nr.empty,c,t.time,a??n.prevComposition)}else return(o=t.getMeta("rebased"))?new to(n.done.rebased(t,o),n.undone.rebased(t,o),Kh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new to(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Kh(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function w5(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 P0(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 Kh(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 x5(n,e,t){let r=Rd(e),i=ps.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 to(t?a:o.remaining,t?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(ps,{redo:t,historyState:l})}let qh=!1,z0=null;function Rd(n){let e=n.plugins;if(z0!=e){qh=!1,z0=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){qh=!0;break}}return qh}const ps=new Tt("history"),k5=new Tt("closeHistory");function _5(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new yt({key:ps,state:{init(){return new to(Nr.empty,Nr.empty,null,0,-1)},apply(e,t,r){return b5(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?kS:r=="historyRedo"?_S:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function xS(n,e){return(t,r)=>{let i=ps.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=x5(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const kS=xS(!1,!0),_S=xS(!0,!0),S5=It.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>kS(n,e),redo:()=>({state:n,dispatch:e})=>_S(n,e)}},addProseMirrorPlugins(){return[_5(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()}}}),C5=Vn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",Wt(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!g4(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}):zz(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(Oe.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(Ne.create(s.doc,c.pos)):s.setSelection(Oe.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(Oe.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[m4({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),T5=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,A5=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,E5=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,M5=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,O5=gi.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",Wt(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[Es({find:T5,type:this.type}),Es({find:E5,type:this.type})]},addPasteRules(){return[Do({find:A5,type:this.type}),Do({find:M5,type:this.type})]}}),D5=Vn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Wt(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)}}}),R5="listItem",B0="textStyle",F0=/^(\d+)\.\s$/,N5=Vn.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",Wt(this.options.HTMLAttributes,t),0]:["ol",Wt(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(R5,this.editor.getAttributes(B0)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=oc({find:F0,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=oc({find:F0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(B0)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),I5=Vn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Wt(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),L5=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,P5=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,z5=gi.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",Wt(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[Es({find:L5,type:this.type})]},addPasteRules(){return[Do({find:P5,type:this.type})]}}),B5=Vn.create({name:"text",group:"inline"}),F5=It.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(qF.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(VF.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(YF.configure(this.options.bulletList)),this.options.code!==!1&&n.push(XF.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(e5.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(t5.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(i5.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(f5.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(h5.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(p5.configure(this.options.heading)),this.options.history!==!1&&n.push(S5.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(C5.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(O5.configure(this.options.italic)),this.options.listItem!==!1&&n.push(D5.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(N5.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(I5.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(z5.configure(this.options.strike)),this.options.text!==!1&&n.push(B5.configure(this.options.text)),n}}),od=new Tt("tandemAnnotations");function Jh(n,e,t){const r=[],i=n.content.size;return e.forEach(o=>{const s=Ra(o,u=>{console.warn("[sanitize]",u)});if(s.status!=="pending"||!s.range&&!s.relRange)return;const a=lu(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=sx(s.color),h=Il[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(Nt.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)}}),rt.create(n,r)}const H5=It.create({name:"tandemAnnotations",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(So);let t=e.size>0,r=!1;return[new yt({key:od,state:{init(i,o){return Jh(o.doc,e,n)},apply(i,o,s,a){if(i.getMeta(od))return Jh(a.doc,e,n);if(i.docChanged){if(!r&&o===rt.empty&&t){const l=Jh(a.doc,e,n);return l!==rt.empty&&(r=!0),l}return o.map(i.mapping,i.doc)}return o}},props:{decorations(i){return od.getState(i)}},view(i){const o=()=>{t=e.size>0,r=!1;const s=i.state.tr.setMeta(od,!0);i.dispatch(s)};return e.observe(o),{destroy(){e.unobserve(o)}}}})]}}),Js=new Tt("tandemAuthorship"),V5=new Set(["paragraph","heading"]);function U5(n,e,t){if(n.relRange){const r=Ek(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=Mo(e,n.range.from),i=Mo(e,n.range.to);if(r<i)return{from:r,to:i}}return null}function Yh(n,e,t,r){if(!r)return rt.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=U5(l,n,t);if(!c)return;const{from:d,to:u}=c;if(!(d>=u||d<0||u>o)){try{i.push(Nt.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(!V5.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(Nt.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)}}),rt.create(n,i)}const j5=It.create({name:"tandemAuthorship",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(oy);let t=!1;try{t=localStorage.getItem(ux)==="true"}catch(r){console.warn("[authorship] localStorage unavailable",r)}return[new yt({key:Js,state:{init(r,i){return{visible:t,decorations:Yh(i.doc,e,n,t)}},apply(r,i,o,s){const a=r.getMeta(Js);if((a==null?void 0:a.type)==="toggle"){const l=a.visible;return{visible:l,decorations:Yh(s.doc,e,n,l)}}return(a==null?void 0:a.type)==="rebuild"?{visible:i.visible,decorations:Yh(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=Js.getState(r))==null?void 0:i.decorations)??rt.empty}},view(r){const i=()=>{const s=r.state.tr.setMeta(Js,{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(Js)||!n.docChanged)return;const t=e.getMap(oy),r=n.doc;n.steps.forEach(i=>{i.getMap().forEach((s,a,l,c)=>{if(c-l-(a-s)>0)try{const u=ri(r,bn(l)),h=ri(r,bn(c));if(h<=u)return;const p=PD("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)}})})}}),sd=new Tt("tandemAwareness");function H0(n,e){if(!e)return rt.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(Nt.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=Mo(n,pd(i)),a=o===!1?" tandem-claude-cursor-idle":"";t.push(Nt.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?rt.empty:rt.create(n,t)}const W5=It.create({name:"tandemAwareness",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const n=this.options.ydoc;if(!n)return[];const e=n.getMap(dx),t=n.getMap(yp);return[new yt({key:sd,state:{init(r,i){const o=e.get(bp);return H0(i.doc,o??null)},apply(r,i,o,s){if(r.getMeta(sd)){const a=e.get(bp);return H0(s.doc,a??null)}return r.docChanged?i.map(r.mapping,r.doc):i}},props:{decorations(r){return sd.getState(r)}},view(r){const i=()=>{const o=r.state.tr.setMeta(sd,!0);r.dispatch(o)};return e.observe(i),{destroy(){e.unobserve(i)}}}}),new yt({key:new Tt("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=Mk(d.doc,{from:bn(d.selection.from),to:bn(d.selection.to)});if(d.selection.from===d.selection.to)o&&(clearTimeout(o),o=null),t.set(sy,{...u,timestamp:Date.now()});else{const h=d.doc.textBetween(d.selection.from,d.selection.to,`
|
|
186
186
|
`),p=h.length>200?h.slice(0,197)+"...":h;o&&clearTimeout(o),o=setTimeout(()=>{o=null,t.set(sy,{...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(ay,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200)),r&&clearTimeout(r),r=setTimeout(()=>{s=!1,t.set(ay,{isTyping:!1,cursor:l.state.selection.from,lastEdit:Date.now()})},sA))},destroy(){r&&clearTimeout(r),i&&clearTimeout(i),o&&clearTimeout(o)}}}})]}}),Gr=new Tt("tandemFindReplace"),SS={query:"",caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:rt.empty};function K5(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q5(n){if(!n.query)return null;try{const e=n.regexMode?n.query:K5(n.query),t=n.caseSensitive?"g":"gi",r=n.wholeWord?`\\b${e}\\b`:e;return new RegExp(r,t)}catch{return null}}function CS(n,e){const t=q5(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 Tl(n,e,t){if(e.length===0)return rt.empty;const r=[];for(let i=0;i<e.length;i++){const{from:o,to:s}=e[i];try{r.push(Nt.inline(o,s,{class:i===t?"tandem-find-active":"tandem-find-match"}))}catch{}}return rt.create(n,r)}function Om(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 J5(n,e,t){if(n.type==="close")return SS;if(n.type==="find"){const i=n.opts,o=CS(t.doc,i),s=t.selection.from,a=Om(o,s);return{...i,matches:o,activeIndex:a,decoSet:Tl(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:Tl(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:Tl(t.doc,e.matches,i)}}return n}const Y5=It.create({name:"tandemFindReplace",addProseMirrorPlugins(){return[new yt({key:Gr,state:{init:()=>SS,apply(n,e,t,r){const i=n.getMeta(Gr);if(i)return J5(i,e,r);if(!e.query)return e;if(n.docChanged){const a=CS(r.doc,e),l=r.selection.from,c=Om(a,l);return{...e,matches:a,activeIndex:c,decoSet:Tl(r.doc,a,c)}}const o=r.selection.from,s=Om(e.matches,o);return s===e.activeIndex?e:{...e,activeIndex:s,decoSet:Tl(r.doc,e.matches,s)}}},props:{decorations(n){var e;return((e=Gr.getState(n))==null?void 0:e.decoSet)??rt.empty}}})]},addCommands(){return{find:n=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(Gr,{type:"find",opts:n})),!0),findNext:()=>({dispatch:n,tr:e})=>(n&&n(e.setMeta(Gr,{type:"next"})),!0),findPrev:()=>({dispatch:n,tr:e})=>(n&&n(e.setMeta(Gr,{type:"prev"})),!0),findClose:()=>({dispatch:n,tr:e})=>(n&&n(e.setMeta(Gr,{type:"close"})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:n})=>{const e=Gr.getState(n.state);return e!=null&&e.query?(n.commands.findClose(),!0):!1}}}});function gv(n){return Gr.getState(n)}function Z5(n,e){const t=gv(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(Gr,{type:"next"});return n.dispatch(o),!0}async function G5(n,e,t){let i=0,o=!1;for(let s=0;s<50;s++){const a=gv(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 X5=It.create({name:"markdownHtml",addGlobalAttributes(){return[{types:["paragraph"],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}}]}}),Ai=new Tt("tandemSlashCommand");function Us(n){return n.chain().focus()}const V0=[{id:"heading-1",label:"Heading 1",keywords:["h1","heading","title"],run:n=>Us(n).toggleHeading({level:1}).run()},{id:"heading-2",label:"Heading 2",keywords:["h2","heading","subtitle"],run:n=>Us(n).toggleHeading({level:2}).run()},{id:"bullet-list",label:"Bullet list",keywords:["bullet","ul","list"],run:n=>Us(n).toggleBulletList().run()},{id:"numbered-list",label:"Numbered list",keywords:["numbered","ordered","ol","list"],run:n=>Us(n).toggleOrderedList().run()},{id:"quote",label:"Quote",keywords:["blockquote","quote"],run:n=>Us(n).toggleBlockquote().run()},{id:"code-block",label:"Code block",keywords:["code","pre"],run:n=>Us(n).toggleCodeBlock().run()}];function Q5(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 Ff(n){const e=n.trim().toLowerCase();return e?V0.filter(t=>[t.label,...t.keywords].join(" ").toLowerCase().includes(e)):V0}function TS(n){return`${n.from}:${n.to}:${n.query}`}function U0(n,e=0){const{selection:t}=n;if(!t.empty)return null;const r=t.$from,i=r.parent.textBetween(0,r.parentOffset,`
|
|
187
187
|
`,`
|
|
188
|
-
`),o=Q5(i);if(!o)return null;const s=r.start()+o.fromOffset,a=r.pos,l=Ff(o.query);return l.length===0?null:{from:s,to:a,query:o.query,selectedIndex:Math.min(e,l.length-1)}}function $5(n,e){const t=n.getMeta(Ai);return t?t.type==="close"?{active:null,dismissedKey:e.active?TS(e.active):e.dismissedKey}:t.type==="select"&&e.active?{...e,active:{...e.active,selectedIndex:t.selectedIndex??e.active.selectedIndex}}:e:null}function eH(n,e,t,r,i){const o=Ff(e.query);n.innerHTML="",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 tH(n,e){const t=Ff(e.query)[e.selectedIndex];return t?(n.chain().focus().deleteRange({from:e.from,to:e.to}).run(),t.run(n),!0):!1}const nH=It.create({name:"slashCommand",addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){const n=this.editor,e=this.options.onOpenChange;return[new yt({key:Ai,state:{init:(t,r)=>({active:U0(r),dismissedKey:null}),apply(t,r,i,o){var l;const s=$5(t,r);if(s)return s;const a=U0(o,((l=r.active)==null?void 0:l.selectedIndex)??0);return a&&TS(a)===r.dismissedKey?{active:null,dismissedKey:r.dismissedKey}:{active:a,dismissedKey:a?null:r.dismissedKey}}},props:{handleKeyDown(t,r){const i=Ai.getState(t.state),o=i==null?void 0:i.active;if(!o)return!1;const s=Ff(o.query);if(r.key==="ArrowDown"){r.preventDefault();const a=(o.selectedIndex+1)%s.length;return t.dispatch(t.state.tr.setMeta(Ai,{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(Ai,{type:"select",selectedIndex:a})),!0}return r.key==="Enter"?(r.preventDefault(),tH(n,o)):r.key==="Escape"?(r.preventDefault(),t.dispatch(t.state.tr.setMeta(Ai,{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",r.innerHTML="",o(!1)},a=()=>{var c;const l=(c=Ai.getState(t.state))==null?void 0:c.active;if(!l){s();return}eH(r,l,n,d=>{t.dispatch(t.state.tr.setMeta(Ai,{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(Ai,{type:"close"}))}),o(!0)};return a(),{update:a,destroy(){o(!1),r.remove()}}}})]}});var rH=E('<div role="presentation"></div>');function iH(n,e){qe(e,!0);const t=new Set([...oA].filter(d=>d!==".docx")),r=["http://","https://","mailto:","ftp://","//"];function i(d){return r.some(u=>d.startsWith(u))}function o(d,u){const h=u.includes("\\")?"\\":"/",p=d.indexOf("#"),m=p>=0?d.slice(0,p):d;if(!m)return null;const v=m.match(/\.[^./\\]+$/),g=v?v[0].toLowerCase():"";if(!t.has(g))return null;const y=u.split(h);y.pop();const S=m.replace(/\//g,h).split(h),C=[...y];for(const A of S)A===".."?C.length>0&&C.pop():A!=="."&&C.push(A);return C.join(h)}let s=F(null),a=null;de(()=>{if(e.ydoc,e.provider,!a)return;const d=new p4({element:a,extensions:[F5.configure({history:!1}),aB.configure({multicolor:!0}),RB.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),NB.configure({placeholder:"Start typing…"}),PF.configure({resizable:!0}),FF,zF,BF,X5,rB.configure({document:e.ydoc}),iB.configure({provider:e.provider,user:{name:Rg(),color:"var(--tandem-warning)"}}),H5.configure({ydoc:e.ydoc}),j5.configure({ydoc:e.ydoc}),W5.configure({ydoc:e.ydoc}),nH.configure({onOpenChange:e.onSlashCommandMenuChange}),Y5],editorProps:{attributes:{class:"tandem-editor",style:"outline: none; min-height: 500px; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;"}},editable:
|
|
188
|
+
`),o=Q5(i);if(!o)return null;const s=r.start()+o.fromOffset,a=r.pos,l=Ff(o.query);return l.length===0?null:{from:s,to:a,query:o.query,selectedIndex:Math.min(e,l.length-1)}}function $5(n,e){const t=n.getMeta(Ai);return t?t.type==="close"?{active:null,dismissedKey:e.active?TS(e.active):e.dismissedKey}:t.type==="select"&&e.active?{...e,active:{...e.active,selectedIndex:t.selectedIndex??e.active.selectedIndex}}:e:null}function eH(n,e,t,r,i){const o=Ff(e.query);n.innerHTML="",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 tH(n,e){const t=Ff(e.query)[e.selectedIndex];return t?(n.chain().focus().deleteRange({from:e.from,to:e.to}).run(),t.run(n),!0):!1}const nH=It.create({name:"slashCommand",addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){const n=this.editor,e=this.options.onOpenChange;return[new yt({key:Ai,state:{init:(t,r)=>({active:U0(r),dismissedKey:null}),apply(t,r,i,o){var l;const s=$5(t,r);if(s)return s;const a=U0(o,((l=r.active)==null?void 0:l.selectedIndex)??0);return a&&TS(a)===r.dismissedKey?{active:null,dismissedKey:r.dismissedKey}:{active:a,dismissedKey:a?null:r.dismissedKey}}},props:{handleKeyDown(t,r){const i=Ai.getState(t.state),o=i==null?void 0:i.active;if(!o)return!1;const s=Ff(o.query);if(r.key==="ArrowDown"){r.preventDefault();const a=(o.selectedIndex+1)%s.length;return t.dispatch(t.state.tr.setMeta(Ai,{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(Ai,{type:"select",selectedIndex:a})),!0}return r.key==="Enter"?(r.preventDefault(),tH(n,o)):r.key==="Escape"?(r.preventDefault(),t.dispatch(t.state.tr.setMeta(Ai,{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",r.innerHTML="",o(!1)},a=()=>{var c;const l=(c=Ai.getState(t.state))==null?void 0:c.active;if(!l){s();return}eH(r,l,n,d=>{t.dispatch(t.state.tr.setMeta(Ai,{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(Ai,{type:"close"}))}),o(!0)};return a(),{update:a,destroy(){o(!1),r.remove()}}}})]}});var rH=E('<div role="presentation"></div>');function iH(n,e){qe(e,!0);const t=new Set([...oA].filter(d=>d!==".docx")),r=["http://","https://","mailto:","ftp://","//"];function i(d){return r.some(u=>d.startsWith(u))}function o(d,u){const h=u.includes("\\")?"\\":"/",p=d.indexOf("#"),m=p>=0?d.slice(0,p):d;if(!m)return null;const v=m.match(/\.[^./\\]+$/),g=v?v[0].toLowerCase():"";if(!t.has(g))return null;const y=u.split(h);y.pop();const S=m.replace(/\//g,h).split(h),C=[...y];for(const A of S)A===".."?C.length>0&&C.pop():A!=="."&&C.push(A);return C.join(h)}let s=F(null),a=null;de(()=>{if(e.ydoc,e.provider,!a)return;const d=new p4({element:a,extensions:[F5.configure({history:!1}),aB.configure({multicolor:!0}),RB.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),NB.configure({placeholder:"Start typing…"}),PF.configure({resizable:!0}),FF,zF,BF,X5,rB.configure({document:e.ydoc}),iB.configure({provider:e.provider,user:{name:Rg(),color:"var(--tandem-warning)"}}),H5.configure({ydoc:e.ydoc}),j5.configure({ydoc:e.ydoc}),W5.configure({ydoc:e.ydoc}),nH.configure({onOpenChange:e.onSlashCommandMenuChange}),Y5],editorProps:{attributes:{class:"tandem-editor",style:"outline: none; min-height: 500px; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;"}},editable:Pt(()=>!e.readOnly),autofocus:Pt(()=>!e.readOnly)});return b(s,d,!0),Pt(()=>{var u;return(u=e.onEditorReady)==null?void 0:u.call(e,d)}),()=>{Pt(()=>{var u;return(u=e.onEditorReady)==null?void 0:u.call(e,null)}),d.destroy(),f(s)===d&&b(s,null)}}),de(()=>{const d=f(s);d&&d.setEditable(!e.readOnly)}),de(()=>{const d=f(s);if(d)return Dk(u=>d.commands.updateUser({name:u}))}),de(()=>{const d=f(s);if(!d)return;const u=d.view.dom;u.querySelectorAll(".tandem-annotation-active").forEach(h=>{h.classList.remove("tandem-annotation-active")}),e.activeAnnotationId&&u.querySelectorAll(`[data-annotation-id="${CSS.escape(e.activeAnnotationId)}"]`).forEach(h=>{h.classList.add("tandem-annotation-active")})});async function l(d){const u=d.target.closest("a[href]");if(u){const m=u.getAttribute("href")??"";if(!m||m.startsWith("#"))return;if(d.preventDefault(),i(m)){window.open(m,"_blank","noopener,noreferrer");return}if(e.currentFilePath){const v=o(m,e.currentFilePath);if(v)try{const g=await fetch(`${Tr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:v})});if(!g.ok){const y=await g.json().catch(()=>({}));console.warn(`[tandem] Could not open linked file "${v}": ${y.message??g.statusText}`)}}catch(g){console.warn("[tandem] Failed to open relative link:",g)}}return}const h=d.target.closest("[data-annotation-id]");if(!h)return;const p=h.getAttribute("data-annotation-id");p&&e.onAnnotationClick&&e.onAnnotationClick(p)}var c=rH();kt(c,d=>a=d,()=>a),P("click",c,l),T(n,c),Je()}$e(["click"]);var oH=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>'),sH=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-error-fg);" role="alert"> </div>'),aH=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-warning-fg); padding: 2px 0;" role="status"> </div>'),lH=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);">Searching…</div>'),cH=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);">No matches in open tabs</div>'),dH=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>'),uH=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>'),fH=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>'),hH=E(`<div data-testid="find-replace-bar" role="dialog" tabindex="-1" aria-modal="false" aria-label="Find and replace" style="
|
|
189
189
|
position: absolute; bottom: 0; right: 0;
|
|
190
190
|
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
191
191
|
border-radius: var(--tandem-r-3) var(--tandem-r-3) 0 0;
|
|
@@ -198,48 +198,48 @@ img.ProseMirror-separator {
|
|
|
198
198
|
flex: 1; padding: 4px 8px; font-size: var(--tandem-text-sm);
|
|
199
199
|
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
200
200
|
background: var(--tandem-surface); color: var(--tandem-fg); outline: none;
|
|
201
|
-
"/> <button data-testid="replace-btn">Replace</button> <button data-testid="replace-all-btn"><!></button></div> <!> <!></div>`);function pH(n,e){qe(e,!0);let t=ft(e,"tabs",19,()=>[]),r=F("doc"),i=F(dt([])),o=F(!1);de(()=>{t().length<=1&&f(r)==="tabs"&&(b(r,"doc"),b(i,[],!0),b(o,!1))});function s(N){const q=N.getXmlFragment("default"),L=[];function V(re){if(re instanceof kn)L.push(re.toString());else{for(let w=0;w<re.length;w++){const M=re.get(w);(M instanceof kn||M instanceof Gt)&&V(M)}re instanceof Gt&&re.nodeName!=="text"&&L.push(" ")}}return V(q),L.join("")}function a(N,q,L){const V=s(N),re=L?q:q.toLowerCase(),w=L?V:V.toLowerCase(),M=[];let I=0,ae=0;for(;(ae=w.indexOf(re,ae))!==-1;){if(I++,M.length<3){const ve=Math.max(0,ae-30),ue=Math.min(V.length,ae+re.length+30),le=V.slice(ve,ue).replace(/\s+/g," ").trim();M.push((ve>0?"…":"")+le+(ue<V.length?"…":""))}ae+=re.length}return{count:I,snippets:M}}let l;yi(()=>clearTimeout(l));function c(N,q){if(clearTimeout(l),!N){b(i,[],!0),b(o,!1);return}b(o,!0),l=setTimeout(()=>{const L=[];for(const V of t()){if(!V.ydoc)continue;const{count:re,snippets:w}=a(V.ydoc,N,q);re>0&&L.push({tabId:V.id,fileName:V.fileName,count:re,snippets:w})}b(i,L,!0),b(o,!1)},300)}let d=F(""),u=F(""),h=F(!1),p=F(!1),m=F(!1),v=F(null),g=F(!1),y=F(null),k=F(null),S=F(0);const C=H(()=>(f(S),e.editor?gv(e.editor.state):void 0)),A=H(()=>{var N;return((N=f(C))==null?void 0:N.matches.length)??0}),W=H(()=>{var N;return((N=f(C))==null?void 0:N.activeIndex)??-1});let z=F(null);de(()=>{var N;e.open&&((N=f(z))==null||N.focus())}),de(()=>{const N=e.editor;if(!N||N.isDestroyed)return;const q=()=>Id(S);return N.on("update",q),N.on("selectionUpdate",q),()=>{N.isDestroyed||(N.off("update",q),N.off("selectionUpdate",q))}});function D(){if(f(r)==="tabs"){c(f(d),f(h));return}const N=e.editor;if(!N||!f(d)){b(v,null),N==null||N.commands.findClose();return}if(f(m))try{new RegExp(f(d)),b(v,null)}catch(L){b(v,L instanceof Error?L.message:"Invalid regex",!0);return}else b(v,null);const q={query:f(d),caseSensitive:f(h),wholeWord:f(p),regexMode:f(m)};N.commands.find(q)}function O(N){var q;b(r,N,!0),N==="tabs"?((q=e.editor)==null||q.commands.findClose(),c(f(d),f(h))):(b(i,[],!0),clearTimeout(l),D())}function U(N){var q,L;if(N.key==="Enter"){N.preventDefault(),N.shiftKey?(q=e.editor)==null||q.commands.findPrev():(L=e.editor)==null||L.commands.findNext();return}N.key==="Escape"&&ee()}function ee(){var N;(N=e.editor)==null||N.commands.findClose(),e.onClose()}async function R(){const N=e.editor;if(!N||!f(d)||f(g))return;const q=f(A);if(q>500&&!window.confirm(`Replace all ${q} occurrences? This cannot be undone as a single action.`))return;b(g,!0),b(k,null),b(y,{replaced:0,total:q},!0);const{replaced:L,partial:V}=await G5(N.view,f(u),(re,w)=>{b(y,{replaced:re,total:w},!0)});b(y,null),b(g,!1),V&&b(k,`Replaced ${L} of ${q}; re-run to continue`)}var K=Rt(),ne=ze(K);{var X=N=>{var q=hH(),L=x(q);{var V=Se=>{var vt=oH(),
|
|
201
|
+
"/> <button data-testid="replace-btn">Replace</button> <button data-testid="replace-all-btn"><!></button></div> <!> <!></div>`);function pH(n,e){qe(e,!0);let t=ft(e,"tabs",19,()=>[]),r=F("doc"),i=F(dt([])),o=F(!1);de(()=>{t().length<=1&&f(r)==="tabs"&&(b(r,"doc"),b(i,[],!0),b(o,!1))});function s(N){const q=N.getXmlFragment("default"),L=[];function V(re){if(re instanceof kn)L.push(re.toString());else{for(let w=0;w<re.length;w++){const M=re.get(w);(M instanceof kn||M instanceof Gt)&&V(M)}re instanceof Gt&&re.nodeName!=="text"&&L.push(" ")}}return V(q),L.join("")}function a(N,q,L){const V=s(N),re=L?q:q.toLowerCase(),w=L?V:V.toLowerCase(),M=[];let I=0,ae=0;for(;(ae=w.indexOf(re,ae))!==-1;){if(I++,M.length<3){const ve=Math.max(0,ae-30),ue=Math.min(V.length,ae+re.length+30),le=V.slice(ve,ue).replace(/\s+/g," ").trim();M.push((ve>0?"…":"")+le+(ue<V.length?"…":""))}ae+=re.length}return{count:I,snippets:M}}let l;yi(()=>clearTimeout(l));function c(N,q){if(clearTimeout(l),!N){b(i,[],!0),b(o,!1);return}b(o,!0),l=setTimeout(()=>{const L=[];for(const V of t()){if(!V.ydoc)continue;const{count:re,snippets:w}=a(V.ydoc,N,q);re>0&&L.push({tabId:V.id,fileName:V.fileName,count:re,snippets:w})}b(i,L,!0),b(o,!1)},300)}let d=F(""),u=F(""),h=F(!1),p=F(!1),m=F(!1),v=F(null),g=F(!1),y=F(null),k=F(null),S=F(0);const C=H(()=>(f(S),e.editor?gv(e.editor.state):void 0)),A=H(()=>{var N;return((N=f(C))==null?void 0:N.matches.length)??0}),W=H(()=>{var N;return((N=f(C))==null?void 0:N.activeIndex)??-1});let z=F(null);de(()=>{var N;e.open&&((N=f(z))==null||N.focus())}),de(()=>{const N=e.editor;if(!N||N.isDestroyed)return;const q=()=>Id(S);return N.on("update",q),N.on("selectionUpdate",q),()=>{N.isDestroyed||(N.off("update",q),N.off("selectionUpdate",q))}});function D(){if(f(r)==="tabs"){c(f(d),f(h));return}const N=e.editor;if(!N||!f(d)){b(v,null),N==null||N.commands.findClose();return}if(f(m))try{new RegExp(f(d)),b(v,null)}catch(L){b(v,L instanceof Error?L.message:"Invalid regex",!0);return}else b(v,null);const q={query:f(d),caseSensitive:f(h),wholeWord:f(p),regexMode:f(m)};N.commands.find(q)}function O(N){var q;b(r,N,!0),N==="tabs"?((q=e.editor)==null||q.commands.findClose(),c(f(d),f(h))):(b(i,[],!0),clearTimeout(l),D())}function U(N){var q,L;if(N.key==="Enter"){N.preventDefault(),N.shiftKey?(q=e.editor)==null||q.commands.findPrev():(L=e.editor)==null||L.commands.findNext();return}N.key==="Escape"&&ee()}function ee(){var N;(N=e.editor)==null||N.commands.findClose(),e.onClose()}async function R(){const N=e.editor;if(!N||!f(d)||f(g))return;const q=f(A);if(q>500&&!window.confirm(`Replace all ${q} occurrences? This cannot be undone as a single action.`))return;b(g,!0),b(k,null),b(y,{replaced:0,total:q},!0);const{replaced:L,partial:V}=await G5(N.view,f(u),(re,w)=>{b(y,{replaced:re,total:w},!0)});b(y,null),b(g,!1),V&&b(k,`Replaced ${L} of ${q}; re-run to continue`)}var K=Rt(),ne=ze(K);{var X=N=>{var q=hH(),L=x(q);{var V=Se=>{var vt=oH(),zt=x(vt),xe=_(zt,2);Y(()=>{Z(zt,"aria-pressed",f(r)==="doc"),se(zt,`
|
|
202
202
|
padding: 2px var(--tandem-space-2); font-size: var(--tandem-text-xs);
|
|
203
203
|
border: 1px solid ${f(r)==="doc"?"var(--tandem-accent-border)":"var(--tandem-border)"};
|
|
204
204
|
border-radius: var(--tandem-r-pill);
|
|
205
205
|
background: ${f(r)==="doc"?"var(--tandem-accent-bg)":"var(--tandem-surface)"};
|
|
206
206
|
color: ${f(r)==="doc"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};
|
|
207
207
|
cursor: pointer;
|
|
208
|
-
`),Z(xe,"aria-pressed",f(r)==="tabs"),
|
|
208
|
+
`),Z(xe,"aria-pressed",f(r)==="tabs"),se(xe,`
|
|
209
209
|
padding: 2px var(--tandem-space-2); font-size: var(--tandem-text-xs);
|
|
210
210
|
border: 1px solid ${f(r)==="tabs"?"var(--tandem-accent-border)":"var(--tandem-border)"};
|
|
211
211
|
border-radius: var(--tandem-r-pill);
|
|
212
212
|
background: ${f(r)==="tabs"?"var(--tandem-accent-bg)":"var(--tandem-surface)"};
|
|
213
213
|
color: ${f(r)==="tabs"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};
|
|
214
214
|
cursor: pointer;
|
|
215
|
-
`)}),P("click",
|
|
215
|
+
`)}),P("click",zt,()=>O("doc")),P("click",xe,()=>O("tabs")),T(Se,vt)};J(L,Se=>{t().length>1&&Se(V)})}var re=_(L,2),w=x(re);kt(w,Se=>b(z,Se),()=>f(z));var M=_(w,2),I=x(M);{var ae=Se=>{var vt=an();Y(()=>te(vt,f(A)===0?"No matches":`${f(W)+1} / ${f(A)}`)),T(Se,vt)};J(I,Se=>{f(d)&&Se(ae)})}var ve=_(M,2),ue=_(ve,2),le=_(ue,2),he=_(re,2);{var B=Se=>{var vt=sH(),zt=x(vt);Y(()=>te(zt,f(v))),T(Se,vt)};J(he,Se=>{f(v)&&Se(B)})}var G=_(he,2),be=x(G),Te=x(be),De=_(be,2),Ee=x(De),oe=_(De,2),$=x(oe),Q=_(G,2),pe=x(Q),fe=_(pe,2),Le=_(fe,2),Ie=x(Le);{var ye=Se=>{var vt=an();Y(()=>te(vt,`${f(y).replaced??""}/${f(y).total??""}`)),T(Se,vt)},ke=Se=>{var vt=an("All");T(Se,vt)};J(Ie,Se=>{f(g)&&f(y)?Se(ye):Se(ke,-1)})}var Ae=_(Q,2);{var Pe=Se=>{var vt=aH(),zt=x(vt);Y(()=>te(zt,f(k))),T(Se,vt)};J(Ae,Se=>{f(k)&&Se(Pe)})}var lt=_(Ae,2);{var At=Se=>{var vt=fH(),zt=x(vt);{var xe=ut=>{var _t=lH();T(ut,_t)},Ye=ut=>{var _t=cH();T(ut,_t)},bt=ut=>{var _t=Rt(),_n=ze(_t);mt(_n,17,()=>f(i),ba,(xt,Ge)=>{var He=uH(),Re=x(He),et=x(Re),Ue=_(et),Ve=x(Ue),tt=_(Re,2);mt(tt,17,()=>f(Ge).snippets,ba,(gt,Bt)=>{var Un=dH(),on=x(Un);Y(()=>te(on,f(Bt))),T(gt,Un)}),Y(()=>{te(et,`${f(Ge).fileName??""} `),te(Ve,`(${f(Ge).count??""} ${f(Ge).count===1?"match":"matches"})`)}),T(xt,He)}),T(ut,_t)};J(zt,ut=>{f(o)?ut(xe):f(d)&&f(i).length===0?ut(Ye,1):ut(bt,-1)})}T(Se,vt)};J(lt,Se=>{f(r)==="tabs"&&Se(At)})}Y(()=>{se(w,`
|
|
216
216
|
flex: 1; padding: 4px 8px; font-size: var(--tandem-text-sm);
|
|
217
217
|
border: 1px solid ${f(v)?"var(--tandem-error)":"var(--tandem-border)"};
|
|
218
218
|
border-radius: var(--tandem-r-2); background: var(--tandem-surface);
|
|
219
219
|
color: var(--tandem-fg); outline: none;
|
|
220
|
-
`),ve.disabled=f(A)===0,
|
|
220
|
+
`),ve.disabled=f(A)===0,se(ve,`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};`),ue.disabled=f(A)===0,se(ue,`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};`),fe.disabled=f(A)===0||f(g)||f(r)==="tabs",Z(fe,"title",f(r)==="tabs"?"Replace is not available in Open tabs mode":void 0),se(fe,`
|
|
221
221
|
padding: 4px 10px; font-size: var(--tandem-text-xs); cursor: pointer;
|
|
222
222
|
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
223
223
|
background: var(--tandem-surface); color: var(--tandem-fg-muted);
|
|
224
224
|
opacity: ${f(A)===0||f(g)||f(r)==="tabs"?.4:1};
|
|
225
|
-
`),Le.disabled=f(A)===0||f(g)||f(r)==="tabs",Z(Le,"title",f(r)==="tabs"?"Replace All is not available in Open tabs mode":void 0),
|
|
225
|
+
`),Le.disabled=f(A)===0||f(g)||f(r)==="tabs",Z(Le,"title",f(r)==="tabs"?"Replace All is not available in Open tabs mode":void 0),se(Le,`
|
|
226
226
|
padding: 4px 10px; font-size: var(--tandem-text-xs); cursor: pointer;
|
|
227
227
|
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
228
228
|
background: var(--tandem-surface); color: var(--tandem-fg-muted);
|
|
229
229
|
opacity: ${f(A)===0||f(g)||f(r)==="tabs"?.4:1};
|
|
230
|
-
`)}),P("keydown",q,U),P("input",w,D),ys(w,()=>f(d),Se=>b(d,Se)),P("click",ve,()=>{var Se;return(Se=e.editor)==null?void 0:Se.commands.findPrev()}),P("click",ue,()=>{var Se;return(Se=e.editor)==null?void 0:Se.commands.findNext()}),P("click",le,ee),P("change",Te,D),Jf(Te,()=>f(h),Se=>b(h,Se)),P("change",Ee,D),Jf(Ee,()=>f(p),Se=>b(p,Se)),P("change",$,D),Jf($,()=>f(m),Se=>b(m,Se)),ys(pe,()=>f(u),Se=>b(u,Se)),P("click",fe,()=>{e.editor&&(Z5(e.editor.view,f(u)),Id(S))}),P("click",Le,R),T(N,q)};J(ne,N=>{e.open&&N(X)})}T(n,K),Je()}$e(["keydown","click","input","change"]);function AS(n,e,t){const r=n.getMap(So);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=Kp(),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=Kp(),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 j0=48,Zh=8,mH=10;function gH({start:n,end:e,toolbarHeight:t,toolbarWidth:r,viewportHeight:i,viewportWidth:o}){const s=(n.left+e.right)/2,a=r/2,l=Zh+a,c=Math.max(l,o-Zh-a),d=Math.min(n.top,e.top)-mH-t,u=Math.max(j0,i-t-Zh);return{left:Math.min(Math.max(s,l),c),top:Math.min(Math.max(d,j0),u)}}function vH(n,e){return n.on("selectionUpdate",e),()=>n.off("selectionUpdate",e)}var yH=E('<button type="button"><!></button>');function Sn(n,e){const t=ft(e,"disabled",3,!1),r=ft(e,"active",3,!1),i=ft(e,"style",3,""),o=H(()=>{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=H(()=>e.ariaLabel??(typeof e.label=="string"?e.label:void 0)),a=H(()=>f(s)??""),l=H(()=>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=H(()=>`${c} cursor: ${t()?"not-allowed":"pointer"}; ${i()}; border: ${f(o).border}; background: ${f(o).background}; color: ${f(o).color};`);var u=yH(),h=x(u);{var p=v=>{var g=Rt(),y=ze(g);Wm(y,()=>e.children),T(v,g)},m=v=>{var g=an();Y(()=>te(g,e.label)),T(v,g)};J(h,v=>{e.children?v(p):v(m,-1)})}Y(()=>{Z(u,"data-testid",e.testId),u.disabled=t(),Z(u,"title",f(l)),Z(u,"aria-label",f(s)),oe(u,f(d))}),P("mousedown",u,function(...v){var g;(g=e.onMouseDown)==null||g.apply(this,v)}),P("click",u,function(...v){var g;(g=e.onClick)==null||g.apply(this,v)}),T(n,u)}$e(["mousedown","click"]);var bH=E('<button type="button"></button>'),wH=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 xH(n,e){qe(e,!0);let t=ft(e,"selectionToolbar",3,!0),r=ft(e,"suppressSelectionToolbar",3,!1),i=F(!1),o=F(null),s=F(null),a=F(""),l=F(null),c=F(null),d=F(0),u=F(0),h=F(dt(window.innerHeight)),p=F(dt(window.innerWidth));const m=Object.keys(ox),v=H(()=>!!e.editor&&!!e.ydoc&&f(i)),g=H(()=>t()&&!r()&&f(v)&&f(o)!==null),y=H(()=>f(a).trim());function k(X){const{from:N,to:q}=X.state.selection,L=N!==q;if(b(i,L),!L){b(o,null);return}try{const V=X.view.coordsAtPos(N),re=X.view.coordsAtPos(q),w=gH({start:V,end:re,toolbarHeight:f(d),toolbarWidth:f(u),viewportHeight:f(h),viewportWidth:f(p)});if(f(o)&&f(o).left===w.left&&f(o).top===w.top)return;b(o,w,!0)}catch{b(o,null)}}de(()=>{if(!e.editor)return;const X=e.editor;function N(){k(X)}const q=vH(X,N);return N(),q}),de(()=>{if(!e.editor||!f(o))return;const X=e.editor;let N=0;function q(){cancelAnimationFrame(N),N=requestAnimationFrame(()=>{b(h,window.innerHeight,!0),b(p,window.innerWidth,!0),k(X)})}return window.addEventListener("resize",q),document.addEventListener("scroll",z,!0),()=>{cancelAnimationFrame(N),window.removeEventListener("resize",q),document.removeEventListener("scroll",z,!0)}}),de(()=>{const X=e.editor,N=f(s);if(!X||!N||!f(o))return;const q=()=>{if(document.activeElement===f(c))return;const V=N.getBoundingClientRect();b(d,V.height,!0),b(u,V.width,!0),k(X)};q();const L=new ResizeObserver(q);return L.observe(N),()=>L.disconnect()}),de(()=>{f(g)&&!f(l)&&C(),f(g)||(b(l,null),document.activeElement!==f(c)&&b(a,""))}),de(()=>{f(g)&&Yt(()=>{var X;return(X=f(c))==null?void 0:X.focus()})}),de(()=>{if(!f(g))return;function X(N){N.key==="Escape"&&(N.preventDefault(),D())}return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)});function S(X,N,q){if(!e.editor||!e.ydoc)return;const L=f(l)??e.editor.state.selection,{from:V,to:re}=L;if(V===re)return;const w=ri(e.editor.state.doc,bn(V)),M=ri(e.editor.state.doc,bn(re)),I=Kp(),ve={id:I,author:"user",type:X,audience:X==="highlight"||X==="note"?"private":"outbound",range:{from:w,to:M},content:N,status:"pending",timestamp:Date.now()};e.ydoc.getMap(So).set(I,ve),b(l,null)}function C(){if(!e.editor)return;const{from:X,to:N}=e.editor.state.selection;b(l,{from:X,to:N},!0)}function A(X){if(!e.editor||!e.ydoc)return;const N=f(l)??e.editor.state.selection,{from:q,to:L}=N;if(q===L)return;const V=ri(e.editor.state.doc,bn(q)),re=ri(e.editor.state.doc,bn(L));AS(e.ydoc,{from:V,to:re},X),b(l,null)}function W(X){return N=>{N.detail===0&&X(N)}}function z(X){f(s)&&X.target instanceof Node&&f(s).contains(X.target)||document.activeElement!==f(c)&&D()}function D(){var X;b(i,!1),b(o,null),b(l,null),b(a,""),(X=e.editor)==null||X.chain().focus().run()}function O(){f(y)&&(S("comment",f(y)),D())}function U(){S("note",f(y)),D()}function ee(X){X.key==="Enter"&&!X.shiftKey?(X.preventDefault(),O()):X.key==="Escape"&&(X.preventDefault(),D())}var R=Rt(),K=ze(R);{var ne=X=>{var N=wH(),q=x(N),L=x(q);Sn(L,{label:"B",ariaLabel:"Bold",style:"font-weight: 700; min-width: 28px;",onMouseDown:ue=>ue.preventDefault(),onClick:()=>{var ue;return(ue=e.editor)==null?void 0:ue.chain().focus().toggleBold().run()}});var V=_(L,2);Sn(V,{label:"I",ariaLabel:"Italic",style:"font-style: italic; min-width: 28px;",onMouseDown:ue=>ue.preventDefault(),onClick:()=>{var ue;return(ue=e.editor)==null?void 0:ue.chain().focus().toggleItalic().run()}});var re=_(V,4);mt(re,21,()=>m,ba,(ue,le)=>{var he=bH(),B=H(()=>W(()=>{var G;A(f(le)),(G=e.editor)==null||G.chain().focus().run()}));Y(()=>{Z(he,"data-testid",`popup-highlight-${f(le)}`),Z(he,"aria-label",`Highlight ${f(le)}`),Z(he,"title",`Highlight ${f(le)}`),oe(he,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${Il[f(le)]}; cursor: pointer; padding: 0;`)}),P("mousedown",he,G=>{var be;G.preventDefault(),A(f(le)),(be=e.editor)==null||be.chain().focus().run()}),P("click",he,function(...G){var be;(be=f(B))==null||be.apply(this,G)}),T(ue,he)});var w=_(q,2),M=x(w);Z(M,"rows",1),kt(M,ue=>b(c,ue),()=>f(c));var I=_(w,2),ae=x(I),ve=_(ae,2);kt(N,ue=>b(s,ue),()=>f(s)),Y(()=>{oe(N,`position: fixed; left: ${f(o).left}px; top: ${f(o).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;`),ve.disabled=!f(y)}),P("keydown",M,ee),ys(M,()=>f(a),ue=>b(a,ue)),P("click",ae,U),P("click",ve,O),T(X,N)};J(K,X=>{f(g)&&f(o)&&X(ne)})}T(n,R),Je()}$e(["mousedown","click","keydown"]);function kH(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 _H(n){de(()=>kH(n()))}function SH(n,e=document.documentElement){return n?e.setAttribute("data-annotation-patterns","true"):e.removeAttribute("data-annotation-patterns"),()=>e.removeAttribute("data-annotation-patterns")}function CH(n){de(()=>SH(n()))}function TH(n,e=()=>lA){let t=F(!1),r=F(!1);return de(()=>{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 AH(n,e=document.documentElement){return e.setAttribute("data-density",n),()=>e.removeAttribute("data-density")}function EH(n){de(()=>AH(n()))}const ca=200,dc=600,MH=300;function W0(n){const e=lx[n];try{const t=localStorage.getItem(e);if(t){const r=parseInt(t,10);if(Number.isFinite(r))return Math.max(ca,Math.min(dc,r));console.warn(`[tandem] ignoring non-numeric panel width for ${e}: ${t}`)}}catch(t){console.warn(`[tandem] localStorage unavailable reading ${e}:`,t)}return MH}function K0(n){const{side:e}=n,t=lx[e];let r=F(dt(n.initialWidth)),i=null;return de(()=>{!n.getVisible()&&i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),i=null,document.body.style.userSelect="",document.body.style.cursor="")}),de(()=>()=>{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(ca,Math.min(dc,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(ca,Math.min(dc,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 OH={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 DH(n){const e=document.documentElement;return e.style.setProperty("--tandem-editor-font-family",OH[n]),()=>e.style.removeProperty("--tandem-editor-font-family")}function RH(n){de(()=>DH(n()))}function NH(){let n=F(!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 mx(o);try{const l=await fetch(`${Tr}/upload`,{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 IH(n,e=document.documentElement){return n?e.setAttribute("data-high-contrast","true"):e.removeAttribute("data-high-contrast"),()=>e.removeAttribute("data-high-contrast")}function LH(n){de(()=>IH(n()))}function PH(n,e){return n.status!=="pending"||e==="tandem"?!0:n.author!=="claude"}function zH(){let n=F(dt([]));const e=new Map,t=a=>{const l=e.get(a);l&&(clearTimeout(l),e.delete(a))},r=(a,l)=>{const c=e.get(a);c&&clearTimeout(c);const d=ly[l]??ly.info,u=setTimeout(()=>{b(n,f(n).filter(h=>h.id!==a),!0),e.delete(a)},d);e.set(a,u)},i=a=>{b(n,f(n).filter(l=>l.id!==a),!0),t(a)},o=`http://localhost:${kc}/api/notify-stream`,s=new EventSource(o);return s.onmessage=a=>{let l;try{l=JSON.parse(a.data)}catch{console.warn("[useNotifications] Malformed SSE data:",a.data);return}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>gA;){const u=d.shift();t(u.id)}b(n,d,!0),r(c.id,c.severity)},s.onerror=()=>{s.readyState===EventSource.CLOSED&&console.warn("[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?")},yi(()=>{s.close();for(const a of e.values())clearTimeout(a);e.clear()}),{get toasts(){return f(n)},dismiss:i}}function BH(n){return n.isComposing||n.code!=="Comma"?!1:n.ctrlKey||n.metaKey}function FH(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 HH(n,e,t){let r=null;sf(()=>{r=i=>{if(!i.ctrlKey&&!i.metaKey||i.key!=="Tab")return;const o=FH(n(),e(),i.shiftKey);o&&(i.preventDefault(),t(o))},window.addEventListener("keydown",r)}),yi(()=>{r&&window.removeEventListener("keydown",r)})}function q0(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 VH(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 UH(n){let e=F(dt([]));de(()=>{const o=n().map(a=>a.id),s=q0(f(e),o);(f(e).length!==s.length||f(e).some((a,l)=>a!==s[l]))&&b(e,s,!0)});const t=H(()=>{const i=n(),o=new Map(i.map(l=>[l.id,l])),s=i.map(l=>l.id);return q0(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,VH(f(e),i,o,l,s),!0)}}}function jH(n,e){let t=F(dt((()=>{try{const r=localStorage.getItem(Fc),i=nA.safeParse(r);return i.success?i.data:ny}catch(r){return console.warn(`[tandem] localStorage unavailable reading ${Fc}:`,r),ny}})()));return de(()=>{const r=f(t);try{localStorage.setItem(Fc,r)}catch(i){console.warn(`[tandem] failed to persist ${Fc}:`,i)}}),de(()=>{const r=n(),i=f(t);if(r)try{r.getMap(yp).set(fA,i)}catch(o){console.warn("[tandem] failed to broadcast tandem mode to Y.Map:",o)}}),de(()=>{const r=n(),i=e();if(r)try{r.getMap(yp).set(hA,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 WH={system:"dark",dark:"light",light:"system"},KH={light:"Switch to system theme",dark:"Switch to light theme",system:"Switch to dark theme"},qH={s:14,m:16,l:18};function J0(){try{return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}const en={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:2,primaryTab:"annotations",panelOrder:"chat-editor-annotations",editorWidthPercent:100,selectionDwellMs:cx,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},JH=["annotations","chat","outline"];function Y0(n,e){if(Array.isArray(n)){const t=n.filter(r=>JH.includes(r));return t.length>0?t:e}return e}function YH(){let n;try{n=localStorage.getItem(ax)}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=en.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)||en.editorWidthPercent)),selectionDwellMs:Math.max(Vd,Math.min(Ud,Number(e.selectionDwellMs)||cx)),showAuthorship:e.showAuthorship===!1?!1:en.showAuthorship,reduceMotion:typeof e.reduceMotion=="boolean"?e.reduceMotion:J0(),textSize:e.textSize==="s"||e.textSize==="m"||e.textSize==="l"?e.textSize:en.textSize,theme:e.theme==="light"||e.theme==="dark"||e.theme==="system"?e.theme:en.theme,accentHue:typeof e.accentHue=="number"&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:en.accentHue,editorFont:e.editorFont==="serif"||e.editorFont==="sans"||e.editorFont==="mono"?e.editorFont:en.editorFont,density:e.density==="compact"||e.density==="cozy"||e.density==="spacious"?e.density:en.density,defaultMode:e.defaultMode==="solo"||e.defaultMode==="tandem"?e.defaultMode:en.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:en.selectionToolbar,soloRailHidden:e.soloRailHidden===!1?!1:en.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs=="number"&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:en.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy==="exponential"||e.sidecarRetryStrategy==="constant-2s"||e.sidecarRetryStrategy==="manual"?e.sidecarRetryStrategy:en.sidecarRetryStrategy,holdAnnotationsWhileOffline:typeof e.holdAnnotationsWhileOffline=="boolean"?e.holdAnnotationsWhileOffline:en.holdAnnotationsWhileOffline,leftRailTabs:Y0(e.leftRailTabs,t),rightRailTabs:Y0(e.rightRailTabs,en.rightRailTabs)}}catch(e){console.warn("[tandem] settings JSON is corrupt, resetting to defaults:",e)}return{...en,reduceMotion:J0()}}function ZH(n,e){const t={...n,...e};return{...t,editorWidthPercent:Math.max(40,Math.min(100,t.editorWidthPercent)),selectionDwellMs:Math.max(Vd,Math.min(Ud,t.selectionDwellMs)),accentHue:Number.isFinite(t.accentHue)?Math.max(0,Math.min(360,t.accentHue)):en.accentHue,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,t.degradedBannerDelayMs)),leftRailTabs:t.leftRailTabs.length>0?t.leftRailTabs:en.leftRailTabs,rightRailTabs:t.rightRailTabs.length>0?t.rightRailTabs:en.rightRailTabs}}function GH(){let n=F(dt(YH()));return{get settings(){return f(n)},updateSettings:t=>{const r=ZH(f(n),t);try{localStorage.setItem(ax,JSON.stringify(r)),localStorage.setItem(ux,String(r.showAuthorship))}catch{}b(n,r,!0)}}}var vc;class XH{constructor(){Ze(this,vc,F(dt(Ar()?window.__TANDEM_INITIAL_THEME__??null:null)))}get current(){return f(j(this,vc))}set current(e){b(j(this,vc),e,!0)}}vc=new WeakMap;const Hf=new XH;let Z0=!1;function Gh(n){Hf.current=n,typeof window<"u"&&(window.__TANDEM_INITIAL_THEME__=n)}function QH(){if(Z0||!Ar())return;Z0=!0;let n=null;Co(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]).then(({invoke:i})=>{n=i,i("get_app_theme").then(o=>{Gh(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] get_app_theme failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri API import failed:",i)}),Co(async()=>{const{getCurrentWindow:i}=await import("./window-BxBvHL5k.js").then(o=>o.w);return{getCurrentWindow:i}},__vite__mapDeps([0,1])).then(({getCurrentWindow:i})=>{i().onThemeChanged(({payload:o})=>{Gh(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";Hf.current!==o&&(Gh(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 ES(){try{if(typeof window>"u")return"light";if(Ar()){const n=Hf.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 $H(n){return n==="system"?ES():n}function G0(n){try{const e=document.querySelector('meta[name="theme-color"]');e&&(e.content=n==="dark"?"#1c1c24":"#fafaf9")}catch{}}function eV(n){const e=document.documentElement,t=$H(n);if(e.setAttribute("data-theme",t),G0(t),n!=="system")return()=>e.removeAttribute("data-theme");if(Ar())return()=>e.removeAttribute("data-theme");const r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>{const o=ES();e.setAttribute("data-theme",o),G0(o)};return r.addEventListener("change",i),()=>{r.removeEventListener("change",i),e.removeAttribute("data-theme")}}function tV(n){QH(),de(()=>{const e=n();return Hf.current,eV(e)})}function nV(){try{return localStorage.getItem(hx)==="true"}catch{return!1}}function X0(){try{localStorage.setItem(hx,"true")}catch{}}function rV(n,e,t){let r=F(dt(nV())),i=F(0),o=0;const s=e1(),a=H(()=>t()==="welcome.md"),l=H(()=>!f(r)&&f(a)),c=Ar(),d=r1(()=>c&&f(l)),u=H(()=>!c||d.status!==null||d.error!==null),h=H(()=>c&&$x(d.status,s)),p=H(()=>f(u)?f(h)?4:3:1/0);return de(()=>{if(!f(l)||f(i)!==0)return;const y=n().filter(S=>S.id.startsWith(vA));if(y.length===0)return;y.some(S=>S.status!=="pending")&&(o=Date.now(),b(i,1))}),de(()=>{if(!f(l)||f(i)!==1)return;n().some(k=>k.author==="user")&&(o=Date.now(),b(i,2))}),de(()=>{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)}}),de(()=>{if(!f(l)||!isFinite(f(p))||f(i)!==f(p))return;const g=setTimeout(()=>{X0(),b(r,!0)},3e3);return()=>clearTimeout(g)}),de(()=>{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:()=>{X0(),b(r,!0)},nextStep:()=>{o=Date.now(),b(i,Math.min(f(i)+1,f(p)),!0)}}}function iV(){let n=null;sf(()=>{let e=!1,t;Co(async()=>{const{getCurrentWebview:r}=await import("./webview-Ben21ZLJ.js");return{getCurrentWebview:r}},__vite__mapDeps([2,0,1])).then(({getCurrentWebview:r})=>{if(e)return;const i=r();let o=Xa;try{const d=localStorage.getItem(cy);if(d!==null){const u=Number(d);Number.isFinite(u)?o=Math.max(dy,Math.min(uy,u)):console.warn(`[tandem] ignoring invalid stored zoom: ${d}`)}}catch{}o!==Xa&&i.setZoom(o).catch(d=>{console.warn("[tandem] failed to restore zoom level:",d)});function s(d){try{localStorage.setItem(cy,String(d))}catch{}}const a=d=>{!(d.metaKey||d.ctrlKey)||d.key!=="0"||(d.preventDefault(),d.stopPropagation(),o=Xa,i.setZoom(Xa).catch(h=>{console.warn("[tandem] failed to reset zoom:",h)}),s(Xa))},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(dy,Math.min(uy,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()}}),yi(()=>{n==null||n()})}function oV(n,e,t){return n.filter(r=>!e.has(r.id)&&!t.has(r.id))}function sV(){let n=F(dt([])),e=F(null),t=F(!1),r=F("connecting"),i=F(0),o=F(null),s=F(dt([])),a=F(null),l=F(!1),c=F(!1),d=F(!1),u=F(!1),h=F(!1),p=F(null),m=null,v=!1,g=null;const y=new Set,k=new Map,S=new Map,C=new Map;let A=!1;const W=N=>{const{ydoc:q}=N,L=q.getMap(So),V=()=>{const he=[];L.forEach(B=>{he.push(Ra(B,G=>{console.warn("[sanitize]",G)}))}),b(s,he,!0)};L.observe(V),V();const re=q.getMap(dx);let w=null,M=!1;const I=()=>{const he=re.get(bp),B=(he==null?void 0:he.status)??null,G=(he==null?void 0:he.active)??!1;B!==w&&(w=B,b(a,B,!0)),G!==M&&(M=G,b(l,G,!0))};re.observe(I),I();const ae=q.getMap(md);let ve=!1;const ue=he=>{if(!he.keysChanged.has(Qf))return;const B=ae.get(Qf)===!0;B!==ve&&(ve=B,b(c,B))};ae.observe(ue);const le=ae.get(Qf)===!0;return le!==ve&&(ve=le,b(c,le)),()=>{L.unobserve(V),re.unobserve(I),ae.unobserve(ue)}},z=(N,q)=>{var ve,ue;const L=f(n),V=new Set(L.map(le=>le.id)),re=new Set(N.map(le=>le.id));for(const le of L)y.delete(le.id),k.delete(le.id);for(const[le,he]of k)re.has(le)||((ve=C.get(le))==null||ve(),C.delete(le),he.provider.destroy(),he.ydoc.destroy(),k.delete(le),y.delete(le));const w=oV(N,V,y),M=[];for(const le of w){y.add(le.id);const he=new hi,B=new bb({url:`ws://localhost:${ty}`,name:le.id,document:he});k.set(le.id,{ydoc:he,provider:B});const G=he.getMap(md),be=Te=>{if(!Te.keysChanged.has(Za)&&!Te.keysChanged.has(Ga))return;const De=G.get(Za),Ee=G.get(Ga);De&&z(De,Ee??null)};G.observe(be),C.set(le.id,()=>G.unobserve(be)),M.push({...le,ydoc:he,provider:B})}const I=L.filter(le=>!re.has(le.id));for(const le of I){const he=S.get(le.id);he&&(he.cleanup(),S.delete(le.id)),(ue=C.get(le.id))==null||ue(),C.delete(le.id),y.delete(le.id),k.delete(le.id),le.provider.destroy(),le.ydoc.destroy()}const ae=L.filter(le=>re.has(le.id));if(b(n,[...ae,...M],!0),q!==null){const le=f(e);le===null?b(e,q,!0):re.has(le)&&I.length>0&&q===le||b(e,q,!0)}};let D=null,O=null;{const N=new hi,q=new bb({url:`ws://localhost:${ty}`,name:uA,document:N});b(p,N,!0),O=q,q.on("status",({status:I})=>{b(t,I==="connected"),b(r,["connected","connecting","disconnected"].includes(I)?I:"connecting",!0),I==="connected"?(v=!0,b(i,0),b(o,null)):I==="disconnected"?f(o)===null&&b(o,Date.now(),!0):I==="connecting"&&(v&&b(i,f(i)+1),f(o)===null&&b(o,Date.now(),!0))});const L=N.getMap(md),V=I=>{if(I.keysChanged.has(Xf)){const ae=L.get(Xf);ae&&g&&ae!==g&&(console.warn("[Tandem] Server restarted — refreshing documents"),b(h,!0),m&&clearTimeout(m),m=setTimeout(()=>{b(h,!1)},5e3)),ae&&(g=ae)}if(I.keysChanged.has(Za)||I.keysChanged.has(Ga)){const ae=L.get(Za),ve=L.get(Ga);ae&&z(ae,ve??null)}I.keysChanged.has($f)&&b(d,L.get($f)===!0)};L.observe(V);const re=L.get(Xf);re&&(g=re);const w=L.get(Za),M=L.get(Ga);w&&z(w,M??null),b(d,L.get($f)===!0),D=()=>{L.unobserve(V),m&&(clearTimeout(m),m=null),q.destroy(),N.destroy(),b(p,null),O=null},b(u,!0)}const U=H(()=>f(n).find(N=>N.id===f(e))??null),ee=H(()=>{var N;return((N=f(U))==null?void 0:N.ydoc)??null}),R=qC(()=>{de(()=>{f(ee);const N=f(U);for(const q of S.values())q.cleanup();if(S.clear(),N){const q=W(N);S.set(N.id,{cleanup:q})}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:N=>{b(e,N,!0)},handleTabClose:N=>{if(f(e)===N){const q=f(n),L=q.findIndex(re=>re.id===N),V=q.filter(re=>re.id!==N);V.length===0?b(e,null):b(e,V[Math.min(L,V.length-1)].id,!0)}fetch(`http://localhost:${kc}/api/close`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:N})}).then(q=>{q.ok||console.warn("[Tandem] Server rejected close:",q.status)}).catch(q=>{console.warn("[Tandem] Failed to close document on server:",q)})},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,R();for(const N of S.values())N.cleanup();S.clear();for(const N of C.values())N();C.clear();for(const N of k.values())N.provider.destroy(),N.ydoc.destroy();k.clear(),y.clear();for(const N of f(n))N.provider.destroy(),N.ydoc.destroy();D==null||D(),b(n,[],!0),b(s,[],!0),b(e,null),b(u,!1)}},reconnect(){O==null||O.connect();for(const N of f(n))N.provider.connect()}}}function mr(n,e){function t(r){n.contains(r.target)||e(r)}return document.addEventListener("mousedown",t),{destroy(){document.removeEventListener("mousedown",t)}}}var aV=E('<label><input type="checkbox" style="accent-color: var(--tandem-accent);"/> </label>'),lV=E("<div></div>"),cV=E(`<div class="rail-tab-picker" style="display: flex; align-items: center;"><button aria-label="Configure tabs" style="
|
|
230
|
+
`)}),P("keydown",q,U),P("input",w,D),ys(w,()=>f(d),Se=>b(d,Se)),P("click",ve,()=>{var Se;return(Se=e.editor)==null?void 0:Se.commands.findPrev()}),P("click",ue,()=>{var Se;return(Se=e.editor)==null?void 0:Se.commands.findNext()}),P("click",le,ee),P("change",Te,D),Jf(Te,()=>f(h),Se=>b(h,Se)),P("change",Ee,D),Jf(Ee,()=>f(p),Se=>b(p,Se)),P("change",$,D),Jf($,()=>f(m),Se=>b(m,Se)),ys(pe,()=>f(u),Se=>b(u,Se)),P("click",fe,()=>{e.editor&&(Z5(e.editor.view,f(u)),Id(S))}),P("click",Le,R),T(N,q)};J(ne,N=>{e.open&&N(X)})}T(n,K),Je()}$e(["keydown","click","input","change"]);function AS(n,e,t){const r=n.getMap(So);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=Kp(),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=Kp(),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 j0=48,Zh=8,mH=10;function gH({start:n,end:e,toolbarHeight:t,toolbarWidth:r,viewportHeight:i,viewportWidth:o}){const s=(n.left+e.right)/2,a=r/2,l=Zh+a,c=Math.max(l,o-Zh-a),d=Math.min(n.top,e.top)-mH-t,u=Math.max(j0,i-t-Zh);return{left:Math.min(Math.max(s,l),c),top:Math.min(Math.max(d,j0),u)}}function vH(n,e){return n.on("selectionUpdate",e),()=>n.off("selectionUpdate",e)}var yH=E('<button type="button"><!></button>');function Sn(n,e){const t=ft(e,"disabled",3,!1),r=ft(e,"active",3,!1),i=ft(e,"style",3,""),o=H(()=>{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=H(()=>e.ariaLabel??(typeof e.label=="string"?e.label:void 0)),a=H(()=>f(s)??""),l=H(()=>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=H(()=>`${c} cursor: ${t()?"not-allowed":"pointer"}; ${i()}; border: ${f(o).border}; background: ${f(o).background}; color: ${f(o).color};`);var u=yH(),h=x(u);{var p=v=>{var g=Rt(),y=ze(g);Wm(y,()=>e.children),T(v,g)},m=v=>{var g=an();Y(()=>te(g,e.label)),T(v,g)};J(h,v=>{e.children?v(p):v(m,-1)})}Y(()=>{Z(u,"data-testid",e.testId),u.disabled=t(),Z(u,"title",f(l)),Z(u,"aria-label",f(s)),se(u,f(d))}),P("mousedown",u,function(...v){var g;(g=e.onMouseDown)==null||g.apply(this,v)}),P("click",u,function(...v){var g;(g=e.onClick)==null||g.apply(this,v)}),T(n,u)}$e(["mousedown","click"]);var bH=E('<button type="button"></button>'),wH=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 xH(n,e){qe(e,!0);let t=ft(e,"selectionToolbar",3,!0),r=ft(e,"suppressSelectionToolbar",3,!1),i=F(!1),o=F(null),s=F(null),a=F(""),l=F(null),c=F(null),d=F(0),u=F(0),h=F(dt(window.innerHeight)),p=F(dt(window.innerWidth));const m=Object.keys(ox),v=H(()=>!!e.editor&&!!e.ydoc&&f(i)),g=H(()=>t()&&!r()&&f(v)&&f(o)!==null),y=H(()=>f(a).trim());function k(X){const{from:N,to:q}=X.state.selection,L=N!==q;if(b(i,L),!L){b(o,null);return}try{const V=X.view.coordsAtPos(N),re=X.view.coordsAtPos(q),w=gH({start:V,end:re,toolbarHeight:f(d),toolbarWidth:f(u),viewportHeight:f(h),viewportWidth:f(p)});if(f(o)&&f(o).left===w.left&&f(o).top===w.top)return;b(o,w,!0)}catch{b(o,null)}}de(()=>{if(!e.editor)return;const X=e.editor;function N(){k(X)}const q=vH(X,N);return N(),q}),de(()=>{if(!e.editor||!f(o))return;const X=e.editor;let N=0;function q(){cancelAnimationFrame(N),N=requestAnimationFrame(()=>{b(h,window.innerHeight,!0),b(p,window.innerWidth,!0),k(X)})}return window.addEventListener("resize",q),document.addEventListener("scroll",z,!0),()=>{cancelAnimationFrame(N),window.removeEventListener("resize",q),document.removeEventListener("scroll",z,!0)}}),de(()=>{const X=e.editor,N=f(s);if(!X||!N||!f(o))return;const q=()=>{if(document.activeElement===f(c))return;const V=N.getBoundingClientRect();b(d,V.height,!0),b(u,V.width,!0),k(X)};q();const L=new ResizeObserver(q);return L.observe(N),()=>L.disconnect()}),de(()=>{f(g)&&!f(l)&&C(),f(g)||(b(l,null),document.activeElement!==f(c)&&b(a,""))}),de(()=>{f(g)&&Pt(()=>{var X;return(X=f(c))==null?void 0:X.focus()})}),de(()=>{if(!f(g))return;function X(N){N.key==="Escape"&&(N.preventDefault(),D())}return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)});function S(X,N,q){if(!e.editor||!e.ydoc)return;const L=f(l)??e.editor.state.selection,{from:V,to:re}=L;if(V===re)return;const w=ri(e.editor.state.doc,bn(V)),M=ri(e.editor.state.doc,bn(re)),I=Kp(),ve={id:I,author:"user",type:X,audience:X==="highlight"||X==="note"?"private":"outbound",range:{from:w,to:M},content:N,status:"pending",timestamp:Date.now()};e.ydoc.getMap(So).set(I,ve),b(l,null)}function C(){if(!e.editor)return;const{from:X,to:N}=e.editor.state.selection;b(l,{from:X,to:N},!0)}function A(X){if(!e.editor||!e.ydoc)return;const N=f(l)??e.editor.state.selection,{from:q,to:L}=N;if(q===L)return;const V=ri(e.editor.state.doc,bn(q)),re=ri(e.editor.state.doc,bn(L));AS(e.ydoc,{from:V,to:re},X),b(l,null)}function W(X){return N=>{N.detail===0&&X(N)}}function z(X){f(s)&&X.target instanceof Node&&f(s).contains(X.target)||document.activeElement!==f(c)&&D()}function D(){var X;b(i,!1),b(o,null),b(l,null),b(a,""),(X=e.editor)==null||X.chain().focus().run()}function O(){f(y)&&(S("comment",f(y)),D())}function U(){S("note",f(y)),D()}function ee(X){X.key==="Enter"&&!X.shiftKey?(X.preventDefault(),O()):X.key==="Escape"&&(X.preventDefault(),D())}var R=Rt(),K=ze(R);{var ne=X=>{var N=wH(),q=x(N),L=x(q);Sn(L,{label:"B",ariaLabel:"Bold",style:"font-weight: 700; min-width: 28px;",onMouseDown:ue=>ue.preventDefault(),onClick:()=>{var ue;return(ue=e.editor)==null?void 0:ue.chain().focus().toggleBold().run()}});var V=_(L,2);Sn(V,{label:"I",ariaLabel:"Italic",style:"font-style: italic; min-width: 28px;",onMouseDown:ue=>ue.preventDefault(),onClick:()=>{var ue;return(ue=e.editor)==null?void 0:ue.chain().focus().toggleItalic().run()}});var re=_(V,4);mt(re,21,()=>m,ba,(ue,le)=>{var he=bH(),B=H(()=>W(()=>{var G;A(f(le)),(G=e.editor)==null||G.chain().focus().run()}));Y(()=>{Z(he,"data-testid",`popup-highlight-${f(le)}`),Z(he,"aria-label",`Highlight ${f(le)}`),Z(he,"title",`Highlight ${f(le)}`),se(he,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${Il[f(le)]}; cursor: pointer; padding: 0;`)}),P("mousedown",he,G=>{var be;G.preventDefault(),A(f(le)),(be=e.editor)==null||be.chain().focus().run()}),P("click",he,function(...G){var be;(be=f(B))==null||be.apply(this,G)}),T(ue,he)});var w=_(q,2),M=x(w);Z(M,"rows",1),kt(M,ue=>b(c,ue),()=>f(c));var I=_(w,2),ae=x(I),ve=_(ae,2);kt(N,ue=>b(s,ue),()=>f(s)),Y(()=>{se(N,`position: fixed; left: ${f(o).left}px; top: ${f(o).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;`),ve.disabled=!f(y)}),P("keydown",M,ee),ys(M,()=>f(a),ue=>b(a,ue)),P("click",ae,U),P("click",ve,O),T(X,N)};J(K,X=>{f(g)&&f(o)&&X(ne)})}T(n,R),Je()}$e(["mousedown","click","keydown"]);function kH(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 _H(n){de(()=>kH(n()))}function SH(n,e=document.documentElement){return n?e.setAttribute("data-annotation-patterns","true"):e.removeAttribute("data-annotation-patterns"),()=>e.removeAttribute("data-annotation-patterns")}function CH(n){de(()=>SH(n()))}function TH(n,e=()=>lA){let t=F(!1),r=F(!1);return de(()=>{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 AH(n,e=document.documentElement){return e.setAttribute("data-density",n),()=>e.removeAttribute("data-density")}function EH(n){de(()=>AH(n()))}const ca=200,dc=600,MH=300;function W0(n){const e=lx[n];try{const t=localStorage.getItem(e);if(t){const r=parseInt(t,10);if(Number.isFinite(r))return Math.max(ca,Math.min(dc,r));console.warn(`[tandem] ignoring non-numeric panel width for ${e}: ${t}`)}}catch(t){console.warn(`[tandem] localStorage unavailable reading ${e}:`,t)}return MH}function K0(n){const{side:e}=n,t=lx[e];let r=F(dt(n.initialWidth)),i=null;return de(()=>{!n.getVisible()&&i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),i=null,document.body.style.userSelect="",document.body.style.cursor="")}),de(()=>()=>{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(ca,Math.min(dc,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(ca,Math.min(dc,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 OH={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 DH(n){const e=document.documentElement;return e.style.setProperty("--tandem-editor-font-family",OH[n]),()=>e.style.removeProperty("--tandem-editor-font-family")}function RH(n){de(()=>DH(n()))}function NH(){let n=F(!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 mx(o);try{const l=await fetch(`${Tr}/upload`,{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 IH(n,e=document.documentElement){return n?e.setAttribute("data-high-contrast","true"):e.removeAttribute("data-high-contrast"),()=>e.removeAttribute("data-high-contrast")}function LH(n){de(()=>IH(n()))}function PH(n,e){return n.status!=="pending"||e==="tandem"?!0:n.author!=="claude"}function zH(){let n=F(dt([]));const e=new Map,t=a=>{const l=e.get(a);l&&(clearTimeout(l),e.delete(a))},r=(a,l)=>{const c=e.get(a);c&&clearTimeout(c);const d=ly[l]??ly.info,u=setTimeout(()=>{b(n,f(n).filter(h=>h.id!==a),!0),e.delete(a)},d);e.set(a,u)},i=a=>{b(n,f(n).filter(l=>l.id!==a),!0),t(a)},o=`http://localhost:${kc}/api/notify-stream`,s=new EventSource(o);return s.onmessage=a=>{let l;try{l=JSON.parse(a.data)}catch{console.warn("[useNotifications] Malformed SSE data:",a.data);return}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>gA;){const u=d.shift();t(u.id)}b(n,d,!0),r(c.id,c.severity)},s.onerror=()=>{s.readyState===EventSource.CLOSED&&console.warn("[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?")},yi(()=>{s.close();for(const a of e.values())clearTimeout(a);e.clear()}),{get toasts(){return f(n)},dismiss:i}}function BH(n){return n.isComposing||n.code!=="Comma"?!1:n.ctrlKey||n.metaKey}function FH(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 HH(n,e,t){let r=null;sf(()=>{r=i=>{if(!i.ctrlKey&&!i.metaKey||i.key!=="Tab")return;const o=FH(n(),e(),i.shiftKey);o&&(i.preventDefault(),t(o))},window.addEventListener("keydown",r)}),yi(()=>{r&&window.removeEventListener("keydown",r)})}function q0(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 VH(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 UH(n){let e=F(dt([]));de(()=>{const o=n().map(a=>a.id),s=q0(f(e),o);(f(e).length!==s.length||f(e).some((a,l)=>a!==s[l]))&&b(e,s,!0)});const t=H(()=>{const i=n(),o=new Map(i.map(l=>[l.id,l])),s=i.map(l=>l.id);return q0(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,VH(f(e),i,o,l,s),!0)}}}function jH(n,e){let t=F(dt((()=>{try{const r=localStorage.getItem(Fc),i=nA.safeParse(r);return i.success?i.data:ny}catch(r){return console.warn(`[tandem] localStorage unavailable reading ${Fc}:`,r),ny}})()));return de(()=>{const r=f(t);try{localStorage.setItem(Fc,r)}catch(i){console.warn(`[tandem] failed to persist ${Fc}:`,i)}}),de(()=>{const r=n(),i=f(t);if(r)try{r.getMap(yp).set(fA,i)}catch(o){console.warn("[tandem] failed to broadcast tandem mode to Y.Map:",o)}}),de(()=>{const r=n(),i=e();if(r)try{r.getMap(yp).set(hA,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 WH={system:"dark",dark:"light",light:"system"},KH={light:"Switch to system theme",dark:"Switch to light theme",system:"Switch to dark theme"},qH={s:14,m:16,l:18};function J0(){try{return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}const en={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:2,primaryTab:"annotations",panelOrder:"chat-editor-annotations",editorWidthPercent:100,selectionDwellMs:cx,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},JH=["annotations","chat","outline"];function Y0(n,e){if(Array.isArray(n)){const t=n.filter(r=>JH.includes(r));return t.length>0?t:e}return e}function YH(){let n;try{n=localStorage.getItem(ax)}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=en.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)||en.editorWidthPercent)),selectionDwellMs:Math.max(Vd,Math.min(Ud,Number(e.selectionDwellMs)||cx)),showAuthorship:e.showAuthorship===!1?!1:en.showAuthorship,reduceMotion:typeof e.reduceMotion=="boolean"?e.reduceMotion:J0(),textSize:e.textSize==="s"||e.textSize==="m"||e.textSize==="l"?e.textSize:en.textSize,theme:e.theme==="light"||e.theme==="dark"||e.theme==="system"?e.theme:en.theme,accentHue:typeof e.accentHue=="number"&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:en.accentHue,editorFont:e.editorFont==="serif"||e.editorFont==="sans"||e.editorFont==="mono"?e.editorFont:en.editorFont,density:e.density==="compact"||e.density==="cozy"||e.density==="spacious"?e.density:en.density,defaultMode:e.defaultMode==="solo"||e.defaultMode==="tandem"?e.defaultMode:en.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:en.selectionToolbar,soloRailHidden:e.soloRailHidden===!1?!1:en.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs=="number"&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:en.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy==="exponential"||e.sidecarRetryStrategy==="constant-2s"||e.sidecarRetryStrategy==="manual"?e.sidecarRetryStrategy:en.sidecarRetryStrategy,holdAnnotationsWhileOffline:typeof e.holdAnnotationsWhileOffline=="boolean"?e.holdAnnotationsWhileOffline:en.holdAnnotationsWhileOffline,leftRailTabs:Y0(e.leftRailTabs,t),rightRailTabs:Y0(e.rightRailTabs,en.rightRailTabs)}}catch(e){console.warn("[tandem] settings JSON is corrupt, resetting to defaults:",e)}return{...en,reduceMotion:J0()}}function ZH(n,e){const t={...n,...e};return{...t,editorWidthPercent:Math.max(40,Math.min(100,t.editorWidthPercent)),selectionDwellMs:Math.max(Vd,Math.min(Ud,t.selectionDwellMs)),accentHue:Number.isFinite(t.accentHue)?Math.max(0,Math.min(360,t.accentHue)):en.accentHue,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,t.degradedBannerDelayMs)),leftRailTabs:t.leftRailTabs.length>0?t.leftRailTabs:en.leftRailTabs,rightRailTabs:t.rightRailTabs.length>0?t.rightRailTabs:en.rightRailTabs}}function GH(){let n=F(dt(YH()));return{get settings(){return f(n)},updateSettings:t=>{const r=ZH(f(n),t);try{localStorage.setItem(ax,JSON.stringify(r)),localStorage.setItem(ux,String(r.showAuthorship))}catch{}b(n,r,!0)}}}var vc;class XH{constructor(){Ze(this,vc,F(dt(Ar()?window.__TANDEM_INITIAL_THEME__??null:null)))}get current(){return f(j(this,vc))}set current(e){b(j(this,vc),e,!0)}}vc=new WeakMap;const Hf=new XH;let Z0=!1;function Gh(n){Hf.current=n,typeof window<"u"&&(window.__TANDEM_INITIAL_THEME__=n)}function QH(){if(Z0||!Ar())return;Z0=!0;let n=null;Co(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]).then(({invoke:i})=>{n=i,i("get_app_theme").then(o=>{Gh(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] get_app_theme failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri API import failed:",i)}),Co(async()=>{const{getCurrentWindow:i}=await import("./window-BxBvHL5k.js").then(o=>o.w);return{getCurrentWindow:i}},__vite__mapDeps([0,1])).then(({getCurrentWindow:i})=>{i().onThemeChanged(({payload:o})=>{Gh(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";Hf.current!==o&&(Gh(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 ES(){try{if(typeof window>"u")return"light";if(Ar()){const n=Hf.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 $H(n){return n==="system"?ES():n}function G0(n){try{const e=document.querySelector('meta[name="theme-color"]');e&&(e.content=n==="dark"?"#1c1c24":"#fafaf9")}catch{}}function eV(n){const e=document.documentElement,t=$H(n);if(e.setAttribute("data-theme",t),G0(t),n!=="system")return()=>e.removeAttribute("data-theme");if(Ar())return()=>e.removeAttribute("data-theme");const r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>{const o=ES();e.setAttribute("data-theme",o),G0(o)};return r.addEventListener("change",i),()=>{r.removeEventListener("change",i),e.removeAttribute("data-theme")}}function tV(n){QH(),de(()=>{const e=n();return Hf.current,eV(e)})}function nV(){try{return localStorage.getItem(hx)==="true"}catch{return!1}}function X0(){try{localStorage.setItem(hx,"true")}catch{}}function rV(n,e,t){let r=F(dt(nV())),i=F(0),o=0;const s=e1(),a=H(()=>t()==="welcome.md"),l=H(()=>!f(r)&&f(a)),c=Ar(),d=r1(()=>c&&f(l)),u=H(()=>!c||d.status!==null||d.error!==null),h=H(()=>c&&$x(d.status,s)),p=H(()=>f(u)?f(h)?4:3:1/0);return de(()=>{if(!f(l)||f(i)!==0)return;const y=n().filter(S=>S.id.startsWith(vA));if(y.length===0)return;y.some(S=>S.status!=="pending")&&(o=Date.now(),b(i,1))}),de(()=>{if(!f(l)||f(i)!==1)return;n().some(k=>k.author==="user")&&(o=Date.now(),b(i,2))}),de(()=>{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)}}),de(()=>{if(!f(l)||!isFinite(f(p))||f(i)!==f(p))return;const g=setTimeout(()=>{X0(),b(r,!0)},3e3);return()=>clearTimeout(g)}),de(()=>{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:()=>{X0(),b(r,!0)},nextStep:()=>{o=Date.now(),b(i,Math.min(f(i)+1,f(p)),!0)}}}function iV(){let n=null;sf(()=>{let e=!1,t;Co(async()=>{const{getCurrentWebview:r}=await import("./webview-Ben21ZLJ.js");return{getCurrentWebview:r}},__vite__mapDeps([2,0,1])).then(({getCurrentWebview:r})=>{if(e)return;const i=r();let o=Xa;try{const d=localStorage.getItem(cy);if(d!==null){const u=Number(d);Number.isFinite(u)?o=Math.max(dy,Math.min(uy,u)):console.warn(`[tandem] ignoring invalid stored zoom: ${d}`)}}catch{}o!==Xa&&i.setZoom(o).catch(d=>{console.warn("[tandem] failed to restore zoom level:",d)});function s(d){try{localStorage.setItem(cy,String(d))}catch{}}const a=d=>{!(d.metaKey||d.ctrlKey)||d.key!=="0"||(d.preventDefault(),d.stopPropagation(),o=Xa,i.setZoom(Xa).catch(h=>{console.warn("[tandem] failed to reset zoom:",h)}),s(Xa))},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(dy,Math.min(uy,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()}}),yi(()=>{n==null||n()})}function oV(n,e,t){return n.filter(r=>!e.has(r.id)&&!t.has(r.id))}function sV(){let n=F(dt([])),e=F(null),t=F(!1),r=F("connecting"),i=F(0),o=F(null),s=F(dt([])),a=F(null),l=F(!1),c=F(!1),d=F(!1),u=F(!1),h=F(!1),p=F(null),m=null,v=!1,g=null;const y=new Set,k=new Map,S=new Map,C=new Map;let A=!1;const W=N=>{const{ydoc:q}=N,L=q.getMap(So),V=()=>{const he=[];L.forEach(B=>{he.push(Ra(B,G=>{console.warn("[sanitize]",G)}))}),b(s,he,!0)};L.observe(V),V();const re=q.getMap(dx);let w=null,M=!1;const I=()=>{const he=re.get(bp),B=(he==null?void 0:he.status)??null,G=(he==null?void 0:he.active)??!1;B!==w&&(w=B,b(a,B,!0)),G!==M&&(M=G,b(l,G,!0))};re.observe(I),I();const ae=q.getMap(md);let ve=!1;const ue=he=>{if(!he.keysChanged.has(Qf))return;const B=ae.get(Qf)===!0;B!==ve&&(ve=B,b(c,B))};ae.observe(ue);const le=ae.get(Qf)===!0;return le!==ve&&(ve=le,b(c,le)),()=>{L.unobserve(V),re.unobserve(I),ae.unobserve(ue)}},z=(N,q)=>{var ve,ue;const L=f(n),V=new Set(L.map(le=>le.id)),re=new Set(N.map(le=>le.id));for(const le of L)y.delete(le.id),k.delete(le.id);for(const[le,he]of k)re.has(le)||((ve=C.get(le))==null||ve(),C.delete(le),he.provider.destroy(),he.ydoc.destroy(),k.delete(le),y.delete(le));const w=oV(N,V,y),M=[];for(const le of w){y.add(le.id);const he=new hi,B=new bb({url:`ws://localhost:${ty}`,name:le.id,document:he});k.set(le.id,{ydoc:he,provider:B});const G=he.getMap(md),be=Te=>{if(!Te.keysChanged.has(Za)&&!Te.keysChanged.has(Ga))return;const De=G.get(Za),Ee=G.get(Ga);De&&z(De,Ee??null)};G.observe(be),C.set(le.id,()=>G.unobserve(be)),M.push({...le,ydoc:he,provider:B})}const I=L.filter(le=>!re.has(le.id));for(const le of I){const he=S.get(le.id);he&&(he.cleanup(),S.delete(le.id)),(ue=C.get(le.id))==null||ue(),C.delete(le.id),y.delete(le.id),k.delete(le.id),le.provider.destroy(),le.ydoc.destroy()}const ae=L.filter(le=>re.has(le.id));if(b(n,[...ae,...M],!0),q!==null){const le=f(e);le===null?b(e,q,!0):re.has(le)&&I.length>0&&q===le||b(e,q,!0)}};let D=null,O=null;{const N=new hi,q=new bb({url:`ws://localhost:${ty}`,name:uA,document:N});b(p,N,!0),O=q,q.on("status",({status:I})=>{b(t,I==="connected"),b(r,["connected","connecting","disconnected"].includes(I)?I:"connecting",!0),I==="connected"?(v=!0,b(i,0),b(o,null)):I==="disconnected"?f(o)===null&&b(o,Date.now(),!0):I==="connecting"&&(v&&b(i,f(i)+1),f(o)===null&&b(o,Date.now(),!0))});const L=N.getMap(md),V=I=>{if(I.keysChanged.has(Xf)){const ae=L.get(Xf);ae&&g&&ae!==g&&(console.warn("[Tandem] Server restarted — refreshing documents"),b(h,!0),m&&clearTimeout(m),m=setTimeout(()=>{b(h,!1)},5e3)),ae&&(g=ae)}if(I.keysChanged.has(Za)||I.keysChanged.has(Ga)){const ae=L.get(Za),ve=L.get(Ga);ae&&z(ae,ve??null)}I.keysChanged.has($f)&&b(d,L.get($f)===!0)};L.observe(V);const re=L.get(Xf);re&&(g=re);const w=L.get(Za),M=L.get(Ga);w&&z(w,M??null),b(d,L.get($f)===!0),D=()=>{L.unobserve(V),m&&(clearTimeout(m),m=null),q.destroy(),N.destroy(),b(p,null),O=null},b(u,!0)}const U=H(()=>f(n).find(N=>N.id===f(e))??null),ee=H(()=>{var N;return((N=f(U))==null?void 0:N.ydoc)??null}),R=qC(()=>{de(()=>{f(ee);const N=f(U);for(const q of S.values())q.cleanup();if(S.clear(),N){const q=W(N);S.set(N.id,{cleanup:q})}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:N=>{b(e,N,!0)},handleTabClose:N=>{if(f(e)===N){const q=f(n),L=q.findIndex(re=>re.id===N),V=q.filter(re=>re.id!==N);V.length===0?b(e,null):b(e,V[Math.min(L,V.length-1)].id,!0)}fetch(`http://localhost:${kc}/api/close`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:N})}).then(q=>{q.ok||console.warn("[Tandem] Server rejected close:",q.status)}).catch(q=>{console.warn("[Tandem] Failed to close document on server:",q)})},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,R();for(const N of S.values())N.cleanup();S.clear();for(const N of C.values())N();C.clear();for(const N of k.values())N.provider.destroy(),N.ydoc.destroy();k.clear(),y.clear();for(const N of f(n))N.provider.destroy(),N.ydoc.destroy();D==null||D(),b(n,[],!0),b(s,[],!0),b(e,null),b(u,!1)}},reconnect(){O==null||O.connect();for(const N of f(n))N.provider.connect()}}}function mr(n,e){function t(r){n.contains(r.target)||e(r)}return document.addEventListener("mousedown",t),{destroy(){document.removeEventListener("mousedown",t)}}}var aV=E('<label><input type="checkbox" style="accent-color: var(--tandem-accent);"/> </label>'),lV=E("<div></div>"),cV=E(`<div class="rail-tab-picker" style="display: flex; align-items: center;"><button aria-label="Configure tabs" style="
|
|
231
231
|
width: 22px; height: 22px; border: none; background: transparent;
|
|
232
232
|
cursor: pointer; border-radius: var(--tandem-r-2);
|
|
233
233
|
color: var(--tandem-fg-subtle); font-size: 14px; line-height: 1;
|
|
234
234
|
display: flex; align-items: center; justify-content: center;
|
|
235
235
|
padding: 0;
|
|
236
|
-
">+</button> <!></div>`);function Q0(n,e){qe(e,!0);let t=ft(e,"disabledTabs",19,()=>[]),r=ft(e,"testIdPrefix",3,""),i=F(!1),o=F(null),s=F(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)}de(()=>{f(i)||b(s,null)});var d=cV(),u=x(d);kt(u,m=>b(o,m),()=>f(o));var h=_(u,2);{var p=m=>{var v=lV();mt(v,21,()=>a,ba,(g,y)=>{const k=H(()=>e.enabledTabs.length===1&&e.enabledTabs.includes(f(y).id)),S=H(()=>t().includes(f(y).id)||f(k));var C=aV(),A=x(C),W=_(A);Y(z=>{Z(C,"title",f(S)?"Each rail must keep at least one tab":void 0),
|
|
236
|
+
">+</button> <!></div>`);function Q0(n,e){qe(e,!0);let t=ft(e,"disabledTabs",19,()=>[]),r=ft(e,"testIdPrefix",3,""),i=F(!1),o=F(null),s=F(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)}de(()=>{f(i)||b(s,null)});var d=cV(),u=x(d);kt(u,m=>b(o,m),()=>f(o));var h=_(u,2);{var p=m=>{var v=lV();mt(v,21,()=>a,ba,(g,y)=>{const k=H(()=>e.enabledTabs.length===1&&e.enabledTabs.includes(f(y).id)),S=H(()=>t().includes(f(y).id)||f(k));var C=aV(),A=x(C),W=_(A);Y(z=>{Z(C,"title",f(S)?"Each rail must keep at least one tab":void 0),se(C,`
|
|
237
237
|
display: flex; align-items: center; gap: var(--tandem-space-2);
|
|
238
238
|
padding: var(--tandem-space-1) var(--tandem-space-2);
|
|
239
239
|
cursor: ${f(S)?"not-allowed":"pointer"}; border-radius: var(--tandem-r-2);
|
|
240
240
|
font-size: var(--tandem-text-sm); color: ${f(S)?"var(--tandem-fg-subtle)":"var(--tandem-fg)"};
|
|
241
241
|
opacity: ${f(S)?.5:1};
|
|
242
|
-
`),Z(A,"data-testid",`${r()}rail-tab-picker-${f(y).id}`),vs(A,z),A.disabled=f(S),te(W,` ${f(y).label??""}`)},[()=>e.enabledTabs.includes(f(y).id)]),P("change",A,()=>l(f(y).id)),T(g,C)}),Y(()=>{Z(v,"data-testid",`${r()}rail-tab-picker-dropdown`),
|
|
242
|
+
`),Z(A,"data-testid",`${r()}rail-tab-picker-${f(y).id}`),vs(A,z),A.disabled=f(S),te(W,` ${f(y).label??""}`)},[()=>e.enabledTabs.includes(f(y).id)]),P("change",A,()=>l(f(y).id)),T(g,C)}),Y(()=>{Z(v,"data-testid",`${r()}rail-tab-picker-dropdown`),se(v,`
|
|
243
243
|
position: fixed; top: ${f(s).top??""}px; right: ${f(s).right??""}px;
|
|
244
244
|
z-index: var(--tandem-z-dropdown, 200);
|
|
245
245
|
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
@@ -260,38 +260,38 @@ img.ProseMirror-separator {
|
|
|
260
260
|
color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
|
|
261
261
|
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;
|
|
262
262
|
border: 1px solid var(--tandem-border); background: transparent;
|
|
263
|
-
color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),bV=Er('<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>'),wV=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 xV(n,e){qe(e,!0);const t=ft(e,"disabled",3,!1),r=[1,2,3],i={1:700,2:600,3:500};let o=F(0),s=F(!1),a=F(!1),l=F(""),c=F(null);de(()=>{if(!e.editor)return;const w=()=>{e.editor.isDestroyed||Id(o)};return e.editor.on("transaction",w),()=>{e.editor.off("transaction",w)}}),de(()=>{var w,M;f(a)&&((w=f(c))==null||w.focus(),(M=f(c))==null||M.select())});function d(w){for(const M of r)if(w.isActive("heading",{level:M}))return M;return null}const u=H(()=>e.editor?e.editor.isEditable:!1),h=H(()=>!f(u)||!!t()),p=H(()=>(f(o),e.editor?li.getState(e.editor.state):null)),m=H(()=>{var w,M;return!f(h)&&(((M=(w=f(p))==null?void 0:w.undoManager)==null?void 0:M.undoStack.length)??0)>0}),v=H(()=>{var w,M;return!f(h)&&(((M=(w=f(p))==null?void 0:w.undoManager)==null?void 0:M.redoStack.length)??0)>0}),g=H(()=>(f(o),e.editor?d(e.editor):null)),y=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("bold"))}),k=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("italic"))}),S=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("strike"))}),C=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("code"))}),A=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("bulletList"))}),W=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("orderedList"))}),z=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("blockquote"))}),D=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("codeBlock"))}),O=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("link"))}),U=H(()=>(f(o),e.editor?f(h)||!e.editor.isActive("link")&&e.editor.state.selection.from===e.editor.state.selection.to:!0)),ee=H(()=>f(g)?`H${f(g)}`:"H");function R(w){return M=>{M.preventDefault(),w()}}function K(w){return M=>{M.preventDefault(),!(!e.editor||e.editor.isDestroyed)&&(e.editor.chain().focus().toggleHeading({level:w}).run(),b(s,!1))}}function ne(w){w.preventDefault(),e.editor&&(b(l,e.editor.getAttributes("link").href??"",!0),b(a,!0))}function X(){if(!e.editor)return;const w=f(l).trim();w?e.editor.chain().focus().setLink({href:w}).run():e.editor.isActive("link")&&e.editor.chain().focus().unsetLink().run(),N()}function N(){b(a,!1),b(l,"")}function q(w){w.key==="Enter"?(w.preventDefault(),X()):w.key==="Escape"&&(w.preventDefault(),N())}var L=Rt(),V=ze(L);{var re=w=>{var M=wV(),I=x(M);{const ye=Pe=>{var lt=dV();T(Pe,lt)};let ke=H(()=>!f(m)),Ae=H(()=>R(()=>e.editor.commands.undo()));Sn(I,{ariaLabel:"Undo",shortcut:"Ctrl+Z",get disabled(){return f(ke)},get onMouseDown(){return f(Ae)},style:"min-width: 30px; padding: 4px 6px;",children:ye,$$slots:{default:!0}})}var ae=_(I,2);{const ye=Pe=>{var lt=uV();T(Pe,lt)};let ke=H(()=>!f(v)),Ae=H(()=>R(()=>e.editor.commands.redo()));Sn(ae,{ariaLabel:"Redo",shortcut:"Ctrl+Shift+Z",get disabled(){return f(ke)},get onMouseDown(){return f(Ae)},style:"min-width: 30px; padding: 4px 6px;",children:ye,$$slots:{default:!0}})}var ve=_(ae,4);{let ye=H(()=>R(()=>e.editor.chain().focus().toggleBold().run()));Sn(ve,{label:"B",shortcut:"Ctrl+B",get disabled(){return f(h)},get active(){return f(y)},get onMouseDown(){return f(ye)},style:"font-weight: 700; min-width: 30px;"})}var ue=_(ve,2);{let ye=H(()=>R(()=>e.editor.chain().focus().toggleItalic().run()));Sn(ue,{label:"I",shortcut:"Ctrl+I",get disabled(){return f(h)},get active(){return f(k)},get onMouseDown(){return f(ye)},style:"font-style: italic; min-width: 30px;"})}var le=_(ue,2);{let ye=H(()=>R(()=>e.editor.chain().focus().toggleStrike().run()));Sn(le,{label:"S",shortcut:"Ctrl+Shift+X",get disabled(){return f(h)},get active(){return f(S)},get onMouseDown(){return f(ye)},style:"text-decoration: line-through; min-width: 30px;"})}var he=_(le,2);{let ye=H(()=>R(()=>e.editor.chain().focus().toggleCode().run()));Sn(he,{label:"<>",shortcut:"Ctrl+E",get disabled(){return f(h)},get active(){return f(C)},get onMouseDown(){return f(ye)},style:"font-family: monospace; min-width: 30px;"})}var B=_(he,2),G=x(B);{let ye=H(()=>f(g)!==null);Sn(G,{get label(){return f(ee)},get disabled(){return f(h)},get active(){return f(ye)},onMouseDown:ke=>{ke.preventDefault(),b(s,!f(s))},style:"min-width: 30px;"})}var be=_(G,2);{var Te=ye=>{var ke=hV();mt(ke,20,()=>r,Ae=>Ae,(Ae,Pe)=>{var lt=fV(),At=H(()=>K(Pe)),Se=x(lt);Y(()=>{
|
|
263
|
+
color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),bV=Er('<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>'),wV=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 xV(n,e){qe(e,!0);const t=ft(e,"disabled",3,!1),r=[1,2,3],i={1:700,2:600,3:500};let o=F(0),s=F(!1),a=F(!1),l=F(""),c=F(null);de(()=>{if(!e.editor)return;const w=()=>{e.editor.isDestroyed||Id(o)};return e.editor.on("transaction",w),()=>{e.editor.off("transaction",w)}}),de(()=>{var w,M;f(a)&&((w=f(c))==null||w.focus(),(M=f(c))==null||M.select())});function d(w){for(const M of r)if(w.isActive("heading",{level:M}))return M;return null}const u=H(()=>e.editor?e.editor.isEditable:!1),h=H(()=>!f(u)||!!t()),p=H(()=>(f(o),e.editor?li.getState(e.editor.state):null)),m=H(()=>{var w,M;return!f(h)&&(((M=(w=f(p))==null?void 0:w.undoManager)==null?void 0:M.undoStack.length)??0)>0}),v=H(()=>{var w,M;return!f(h)&&(((M=(w=f(p))==null?void 0:w.undoManager)==null?void 0:M.redoStack.length)??0)>0}),g=H(()=>(f(o),e.editor?d(e.editor):null)),y=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("bold"))}),k=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("italic"))}),S=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("strike"))}),C=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("code"))}),A=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("bulletList"))}),W=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("orderedList"))}),z=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("blockquote"))}),D=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("codeBlock"))}),O=H(()=>{var w;return f(o),!!((w=e.editor)!=null&&w.isActive("link"))}),U=H(()=>(f(o),e.editor?f(h)||!e.editor.isActive("link")&&e.editor.state.selection.from===e.editor.state.selection.to:!0)),ee=H(()=>f(g)?`H${f(g)}`:"H");function R(w){return M=>{M.preventDefault(),w()}}function K(w){return M=>{M.preventDefault(),!(!e.editor||e.editor.isDestroyed)&&(e.editor.chain().focus().toggleHeading({level:w}).run(),b(s,!1))}}function ne(w){w.preventDefault(),e.editor&&(b(l,e.editor.getAttributes("link").href??"",!0),b(a,!0))}function X(){if(!e.editor)return;const w=f(l).trim();w?e.editor.chain().focus().setLink({href:w}).run():e.editor.isActive("link")&&e.editor.chain().focus().unsetLink().run(),N()}function N(){b(a,!1),b(l,"")}function q(w){w.key==="Enter"?(w.preventDefault(),X()):w.key==="Escape"&&(w.preventDefault(),N())}var L=Rt(),V=ze(L);{var re=w=>{var M=wV(),I=x(M);{const ye=Pe=>{var lt=dV();T(Pe,lt)};let ke=H(()=>!f(m)),Ae=H(()=>R(()=>e.editor.commands.undo()));Sn(I,{ariaLabel:"Undo",shortcut:"Ctrl+Z",get disabled(){return f(ke)},get onMouseDown(){return f(Ae)},style:"min-width: 30px; padding: 4px 6px;",children:ye,$$slots:{default:!0}})}var ae=_(I,2);{const ye=Pe=>{var lt=uV();T(Pe,lt)};let ke=H(()=>!f(v)),Ae=H(()=>R(()=>e.editor.commands.redo()));Sn(ae,{ariaLabel:"Redo",shortcut:"Ctrl+Shift+Z",get disabled(){return f(ke)},get onMouseDown(){return f(Ae)},style:"min-width: 30px; padding: 4px 6px;",children:ye,$$slots:{default:!0}})}var ve=_(ae,4);{let ye=H(()=>R(()=>e.editor.chain().focus().toggleBold().run()));Sn(ve,{label:"B",shortcut:"Ctrl+B",get disabled(){return f(h)},get active(){return f(y)},get onMouseDown(){return f(ye)},style:"font-weight: 700; min-width: 30px;"})}var ue=_(ve,2);{let ye=H(()=>R(()=>e.editor.chain().focus().toggleItalic().run()));Sn(ue,{label:"I",shortcut:"Ctrl+I",get disabled(){return f(h)},get active(){return f(k)},get onMouseDown(){return f(ye)},style:"font-style: italic; min-width: 30px;"})}var le=_(ue,2);{let ye=H(()=>R(()=>e.editor.chain().focus().toggleStrike().run()));Sn(le,{label:"S",shortcut:"Ctrl+Shift+X",get disabled(){return f(h)},get active(){return f(S)},get onMouseDown(){return f(ye)},style:"text-decoration: line-through; min-width: 30px;"})}var he=_(le,2);{let ye=H(()=>R(()=>e.editor.chain().focus().toggleCode().run()));Sn(he,{label:"<>",shortcut:"Ctrl+E",get disabled(){return f(h)},get active(){return f(C)},get onMouseDown(){return f(ye)},style:"font-family: monospace; min-width: 30px;"})}var B=_(he,2),G=x(B);{let ye=H(()=>f(g)!==null);Sn(G,{get label(){return f(ee)},get disabled(){return f(h)},get active(){return f(ye)},onMouseDown:ke=>{ke.preventDefault(),b(s,!f(s))},style:"min-width: 30px;"})}var be=_(G,2);{var Te=ye=>{var ke=hV();mt(ke,20,()=>r,Ae=>Ae,(Ae,Pe)=>{var lt=fV(),At=H(()=>K(Pe)),Se=x(lt);Y(()=>{se(lt,`padding: 4px 12px; font-size: 13px; border: none;
|
|
264
264
|
border-radius: var(--tandem-r-2);
|
|
265
265
|
background: ${f(g)===Pe?"var(--tandem-accent-bg)":"transparent"};
|
|
266
266
|
color: ${f(g)===Pe?"var(--tandem-accent)":"var(--tandem-fg)"};
|
|
267
267
|
cursor: pointer; text-align: left;
|
|
268
|
-
font-weight: ${i[Pe]??""}; white-space: nowrap;`),te(Se,`Heading ${Pe??""}`)}),P("mousedown",lt,function(...vt){var
|
|
268
|
+
font-weight: ${i[Pe]??""}; white-space: nowrap;`),te(Se,`Heading ${Pe??""}`)}),P("mousedown",lt,function(...vt){var zt;(zt=f(At))==null||zt.apply(this,vt)}),T(Ae,lt)}),T(ye,ke)};J(be,ye=>{f(s)&&ye(Te)})}Ol(B,(ye,ke)=>mr==null?void 0:mr(ye,ke),()=>()=>b(s,!1));var De=_(B,4);{const ye=Ae=>{var Pe=pV();T(Ae,Pe)};let ke=H(()=>R(()=>e.editor.chain().focus().toggleBulletList().run()));Sn(De,{ariaLabel:"Bullet list",shortcut:"Ctrl+Shift+8",get disabled(){return f(h)},get active(){return f(A)},get onMouseDown(){return f(ke)},style:"min-width: 30px; padding: 4px 6px;",children:ye,$$slots:{default:!0}})}var Ee=_(De,2);{const ye=Ae=>{var Pe=mV();T(Ae,Pe)};let ke=H(()=>R(()=>e.editor.chain().focus().toggleOrderedList().run()));Sn(Ee,{ariaLabel:"Ordered list",shortcut:"Ctrl+Shift+7",get disabled(){return f(h)},get active(){return f(W)},get onMouseDown(){return f(ke)},style:"min-width: 30px; padding: 4px 6px;",children:ye,$$slots:{default:!0}})}var oe=_(Ee,2);{const ye=Ae=>{var Pe=gV();T(Ae,Pe)};let ke=H(()=>R(()=>e.editor.chain().focus().toggleBlockquote().run()));Sn(oe,{ariaLabel:"Blockquote",shortcut:"Ctrl+Shift+B",get disabled(){return f(h)},get active(){return f(z)},get onMouseDown(){return f(ke)},style:"min-width: 30px; padding: 4px 6px;",children:ye,$$slots:{default:!0}})}var $=_(oe,4),Q=x($);{const ye=Ae=>{var Pe=vV();T(Ae,Pe)};let ke=H(()=>f(O)||f(a));Sn(Q,{ariaLabel:"Link",shortcut:"Ctrl+K",get disabled(){return f(U)},get active(){return f(ke)},onMouseDown:ne,style:"min-width: 30px; padding: 4px 6px;",children:ye,$$slots:{default:!0}})}var pe=_(Q,2);{var fe=ye=>{var ke=yV(),Ae=x(ke);kt(Ae,At=>b(c,At),()=>f(c));var Pe=_(Ae,2),lt=_(Pe,2);P("keydown",Ae,q),ys(Ae,()=>f(l),At=>b(l,At)),P("mousedown",Pe,At=>{At.preventDefault(),X()}),P("mousedown",lt,At=>{At.preventDefault(),N()}),T(ye,ke)};J(pe,ye=>{f(a)&&ye(fe)})}Ol($,(ye,ke)=>mr==null?void 0:mr(ye,ke),()=>N);var Le=_($,2);{let ye=H(()=>R(()=>e.editor.chain().focus().setHorizontalRule().run()));Sn(Le,{label:"—",ariaLabel:"Horizontal rule",get disabled(){return f(h)},get onMouseDown(){return f(ye)},style:"min-width: 30px;"})}var Ie=_(Le,2);{const ye=Ae=>{var Pe=bV();T(Ae,Pe)};let ke=H(()=>R(()=>e.editor.chain().focus().toggleCodeBlock().run()));Sn(Ie,{ariaLabel:"Code block",get disabled(){return f(h)},get active(){return f(D)},get onMouseDown(){return f(ke)},style:"min-width: 30px; padding: 4px 6px;",children:ye,$$slots:{default:!0}})}P("keydown",B,ye=>{ye.key==="Escape"&&b(s,!1)}),P("keydown",$,ye=>{ye.key==="Escape"&&N()}),T(w,M)};J(V,w=>{e.editor&&w(re)})}T(n,L),Je()}$e(["keydown","mousedown"]);var kV=E("<button></button>"),_V=E(`<div style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
269
269
|
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
270
270
|
border-radius: var(--tandem-r-3); padding: 6px; display: flex; gap: 4px;
|
|
271
271
|
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);
|
|
272
272
|
border: 1px solid var(--tandem-border);
|
|
273
273
|
background: var(--tandem-surface-muted); cursor: pointer; padding: 0;
|
|
274
274
|
font-size: 13px; color: var(--tandem-fg-muted);
|
|
275
|
-
display: flex; align-items: center; justify-content: center;">✕</button></div>`),SV=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 CV(n,e){qe(e,!0);const t=[{value:"yellow",label:"Yellow"},{value:"green",label:"Green"},{value:"blue",label:"Blue"},{value:"pink",label:"Pink"}],r=ft(e,"disabled",3,!1);let i=F("yellow"),o=F(!1),s=F(null);de(()=>{if(!f(o))return;function g(y){f(s)&&!f(s).contains(y.target)&&b(o,!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)});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=SV(),u=x(d);Sn(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=_(u,2),p=x(h),m=_(h,2);{var v=g=>{var y=_V(),k=x(y);mt(k,17,()=>t,({value:C,label:A})=>C,(C,A)=>{let W=()=>f(A).value,z=()=>f(A).label;var D=kV();Y(()=>{Z(D,"data-testid",`toolbar-highlight-color-${W()}`),Z(D,"title",z()),Z(D,"aria-label",z()),
|
|
275
|
+
display: flex; align-items: center; justify-content: center;">✕</button></div>`),SV=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 CV(n,e){qe(e,!0);const t=[{value:"yellow",label:"Yellow"},{value:"green",label:"Green"},{value:"blue",label:"Blue"},{value:"pink",label:"Pink"}],r=ft(e,"disabled",3,!1);let i=F("yellow"),o=F(!1),s=F(null);de(()=>{if(!f(o))return;function g(y){f(s)&&!f(s).contains(y.target)&&b(o,!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)});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=SV(),u=x(d);Sn(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=_(u,2),p=x(h),m=_(h,2);{var v=g=>{var y=_V(),k=x(y);mt(k,17,()=>t,({value:C,label:A})=>C,(C,A)=>{let W=()=>f(A).value,z=()=>f(A).label;var D=kV();Y(()=>{Z(D,"data-testid",`toolbar-highlight-color-${W()}`),Z(D,"title",z()),Z(D,"aria-label",z()),se(D,`width: 24px; height: 24px; border-radius: var(--tandem-r-2);
|
|
276
276
|
border: ${W()===f(i)?"2px solid var(--tandem-fg)":"1px solid var(--tandem-border)"};
|
|
277
277
|
background: ${Il[W()]??""};
|
|
278
|
-
cursor: pointer; padding: 0;`)}),P("click",D,()=>c(W())),T(C,D)});var S=_(k,2);kt(y,C=>b(s,C),()=>f(s)),P("click",S,()=>b(o,!1)),T(g,y)};J(m,g=>{f(o)&&g(v)})}Y(()=>{h.disabled=r(),
|
|
278
|
+
cursor: pointer; padding: 0;`)}),P("click",D,()=>c(W())),T(C,D)});var S=_(k,2);kt(y,C=>b(s,C),()=>f(s)),P("click",S,()=>b(o,!1)),T(g,y)};J(m,g=>{f(o)&&g(v)})}Y(()=>{h.disabled=r(),se(h,`padding: 4px 6px; font-size: 13px; border: 1px solid var(--tandem-border);
|
|
279
279
|
border-radius: 0 var(--tandem-r-2) var(--tandem-r-2) 0;
|
|
280
280
|
background: ${r()?"var(--tandem-surface-muted)":"var(--tandem-surface)"};
|
|
281
281
|
cursor: ${r()?"not-allowed":"pointer"};
|
|
282
|
-
display: flex; align-items: center;`),
|
|
282
|
+
display: flex; align-items: center;`),se(p,`display: inline-block; width: 12px; height: 12px; border-radius: var(--tandem-r-1);
|
|
283
283
|
background: ${Il[f(i)]??""};
|
|
284
284
|
border: 1px solid var(--tandem-border);`)}),P("mousedown",h,l),T(n,d),Je()}$e(["mousedown","click"]);var TV=E(`<div data-testid="formatting-bar" style="display: flex; align-items: center; height: var(--tandem-h-fmtbar, 36px);
|
|
285
285
|
padding: 0 var(--tandem-space-3);
|
|
286
286
|
border-bottom: 1px solid var(--tandem-border);
|
|
287
287
|
background: var(--tandem-surface-muted);
|
|
288
|
-
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 AV(n,e){qe(e,!0);let t=F(0);de(()=>{const c=e.editor;if(!c||c.isDestroyed)return;const d=()=>{c.isDestroyed||Id(t)};return c.on("selectionUpdate",d),c.on("transaction",d),()=>{c.off("selectionUpdate",d),c.off("transaction",d)}});const r=H(()=>(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=ri(d.doc,bn(u)),m=ri(d.doc,bn(h));if(p===null||m===null){console.warn("[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded",{from:u,to:h});return}AS(e.ydoc,{from:p,to:m},c)}var o=TV(),s=x(o),a=x(s);xV(a,{get editor(){return e.editor}});var l=_(a,4);{let c=H(()=>!f(r));CV(l,{get disabled(){return f(c)},onHighlight:i})}T(n,o),Je()}var EV=E('<span style="width: 6px; height: 6px; border-radius: var(--tandem-r-circle); background: var(--tandem-fg-subtle); display: inline-block;"></span>'),MV=E('<span style="width: 6px; height: 6px; border-radius: var(--tandem-r-circle); background: var(--tandem-success); display: inline-block;"></span>'),OV=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 DV(n,e){qe(e,!0);var t=OV(),r=x(t),i=x(r);{var o=c=>{var d=EV();T(c,d)};J(i,c=>{e.tandemMode==="solo"&&c(o)})}var s=_(r,2),a=x(s);{var l=c=>{var d=MV();T(c,d)};J(a,c=>{e.tandemMode==="tandem"&&c(l)})}Y(()=>{Z(r,"aria-pressed",e.tandemMode==="solo"),
|
|
288
|
+
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 AV(n,e){qe(e,!0);let t=F(0);de(()=>{const c=e.editor;if(!c||c.isDestroyed)return;const d=()=>{c.isDestroyed||Id(t)};return c.on("selectionUpdate",d),c.on("transaction",d),()=>{c.off("selectionUpdate",d),c.off("transaction",d)}});const r=H(()=>(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=ri(d.doc,bn(u)),m=ri(d.doc,bn(h));if(p===null||m===null){console.warn("[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded",{from:u,to:h});return}AS(e.ydoc,{from:p,to:m},c)}var o=TV(),s=x(o),a=x(s);xV(a,{get editor(){return e.editor}});var l=_(a,4);{let c=H(()=>!f(r));CV(l,{get disabled(){return f(c)},onHighlight:i})}T(n,o),Je()}var EV=E('<span style="width: 6px; height: 6px; border-radius: var(--tandem-r-circle); background: var(--tandem-fg-subtle); display: inline-block;"></span>'),MV=E('<span style="width: 6px; height: 6px; border-radius: var(--tandem-r-circle); background: var(--tandem-success); display: inline-block;"></span>'),OV=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 DV(n,e){qe(e,!0);var t=OV(),r=x(t),i=x(r);{var o=c=>{var d=EV();T(c,d)};J(i,c=>{e.tandemMode==="solo"&&c(o)})}var s=_(r,2),a=x(s);{var l=c=>{var d=MV();T(c,d)};J(a,c=>{e.tandemMode==="tandem"&&c(l)})}Y(()=>{Z(r,"aria-pressed",e.tandemMode==="solo"),se(r,`height: 24px; padding: 0 10px; font-size: 12px; border: none; border-radius: var(--tandem-r-1); cursor: pointer;
|
|
289
289
|
background: ${e.tandemMode==="solo"?"var(--tandem-surface)":"transparent"};
|
|
290
290
|
color: ${e.tandemMode==="solo"?"var(--tandem-fg)":"var(--tandem-fg-muted)"};
|
|
291
291
|
font-weight: 500;
|
|
292
|
-
display: flex; align-items: center; gap: 5px;`),Z(s,"aria-pressed",e.tandemMode==="tandem"),
|
|
292
|
+
display: flex; align-items: center; gap: 5px;`),Z(s,"aria-pressed",e.tandemMode==="tandem"),se(s,`height: 24px; padding: 0 10px; font-size: 12px; border: none; border-radius: var(--tandem-r-1); cursor: pointer;
|
|
293
293
|
background: ${e.tandemMode==="tandem"?"var(--tandem-surface)":"transparent"};
|
|
294
294
|
color: ${e.tandemMode==="tandem"?"var(--tandem-fg)":"var(--tandem-fg-muted)"};
|
|
295
295
|
font-weight: 500;
|
|
296
|
-
display: flex; align-items: center; gap: 5px;`)}),P("click",r,()=>e.onModeChange("solo")),P("click",s,()=>e.onModeChange("tandem")),T(n,t),Je()}$e(["click"]);const $0=(n,e=pr,t=pr,r=pr)=>{const i=H(()=>t()?`Hide ${e()} panel`:`Show ${e()} panel`);var o=RV();let s;var a=x(o),l=_(x(a));Y(()=>{s=$w(o,1,"icon-btn svelte-12l7ydf",null,s,{active:t()}),Z(o,"data-testid",`titlebar-toggle-${e()}`),Z(o,"aria-label",f(i)),Z(o,"aria-pressed",t()),Z(o,"title",f(i)),Z(l,"x",e()==="left"?1.5:9.5)}),P("click",o,function(...c){var d;(d=r())==null||d.apply(this,c)}),T(n,o)};var RV=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>'),NV=E('<span class="status-dot svelte-12l7ydf" title="Claude is connected" aria-label="Claude is connected"></span>'),IV=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>'),LV=Er('<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>'),PV=Er('<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>'),zV=Er('<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>'),BV=E('<button type="button" class="icon-btn svelte-12l7ydf" data-testid="titlebar-theme-toggle"><!></button>'),FV=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>'),HV=E('<button type="button" class="icon-btn svelte-12l7ydf" data-testid="settings-btn" aria-label="Settings" 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>'),VV=Er('<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>'),UV=Er('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>'),jV=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>'),WV=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 KV(n,e){qe(e,!0);let t=ft(e,"claudeActive",3,!1),r=ft(e,"leftPanelVisible",3,!1),i=ft(e,"rightPanelVisible",3,!1),o=ft(e,"theme",3,"system"),s=ft(e,"showAuthorship",3,!1),a=ft(e,"settingsBtn",15,null),l=F(null),c=F(!1),d=[],u=!0;sf(async()=>{if(Ar())try{const[{invoke:w},{getCurrentWindow:M}]=await Promise.all([Co(()=>import("./core-DhEqZVGG.js"),[]),Co(()=>import("./window-BxBvHL5k.js").then(ue=>ue.w),__vite__mapDeps([0,1]))]);if(!u||(await w("setup_overlay_titlebar").catch(ue=>{console.error("[TitleBar] setup_overlay_titlebar failed:",ue)}),!u))return;const I=M();if(b(l,I,!0),b(c,await I.isMaximized(),!0),!u)return;const ae=await I.onResized(async()=>{try{b(c,await I.isMaximized(),!0)}catch(ue){console.warn("[TitleBar] isMaximized check failed on resize:",ue)}});if(!u){ae();return}d.push(ae);const ve=await I.onMoved(async()=>{try{b(c,await I.isMaximized(),!0)}catch(ue){console.warn("[TitleBar] isMaximized check failed on move:",ue)}});if(!u){ve();return}d.push(ve)}catch(w){console.error("[TitleBar] Window API initialization failed:",w)}}),yi(()=>{u=!1,d.forEach(w=>w())});async function h(){var w;try{await((w=f(l))==null?void 0:w.minimize())}catch(M){console.error("[TitleBar] minimize failed:",M)}}async function p(){var w;try{await((w=f(l))==null?void 0:w.toggleMaximize())}catch(M){console.error("[TitleBar] toggleMaximize failed:",M)}}async function m(){var w;try{await((w=f(l))==null?void 0:w.close())}catch(M){console.error("[TitleBar] close failed:",M)}}const v=H(()=>KH[o()]);var g=WV(),y=_(x(g),4),k=x(y);{var S=w=>{DV(w,{get tandemMode(){return e.tandemMode},get onModeChange(){return e.onModeChange}})};J(k,w=>{e.tandemMode&&e.onModeChange&&w(S)})}var C=_(k,2);{var A=w=>{var M=NV();T(w,M)};J(C,w=>{t()&&w(A)})}var W=_(C,2);{var z=w=>{var M=IV();let I;Y(()=>{I=$w(M,1,"icon-btn svelte-12l7ydf",null,I,{active:s()}),Z(M,"aria-label",s()?"Hide authorship colors":"Show authorship colors"),Z(M,"aria-pressed",s()),Z(M,"title",s()?"Hide authorship colors":"Show authorship colors")}),P("click",M,()=>e.onAuthorshipChange(!s())),T(w,M)};J(W,w=>{e.onAuthorshipChange&&w(z)})}var D=_(W,4);{var O=w=>{$0(w,()=>"left",r,()=>e.onToggleLeftPanel)};J(D,w=>{e.onToggleLeftPanel&&w(O)})}var U=_(D,2);{var ee=w=>{$0(w,()=>"right",i,()=>e.onToggleRightPanel)};J(U,w=>{e.onToggleRightPanel&&w(ee)})}var R=_(U,2);{var K=w=>{var M=BV(),I=x(M);{var ae=le=>{var he=LV();T(le,he)},ve=le=>{var he=PV();T(le,he)},ue=le=>{var he=zV();T(le,he)};J(I,le=>{o()==="light"?le(ae):o()==="dark"?le(ve,1):le(ue,-1)})}Y(()=>{Z(M,"aria-label",f(v)),Z(M,"title",f(v))}),P("click",M,function(...le){var he;(he=e.onCycleTheme)==null||he.apply(this,le)}),T(w,M)};J(R,w=>{e.onCycleTheme&&w(K)})}var ne=_(R,2);{var X=w=>{var M=FV();P("click",M,function(...I){var ae;(ae=e.onOpenHelp)==null||ae.apply(this,I)}),T(w,M)};J(ne,w=>{e.onOpenHelp&&w(X)})}var N=_(ne,2);{var q=w=>{var M=HV();kt(M,I=>a(I),()=>a()),P("click",M,function(...I){var ae;(ae=e.onOpenSettings)==null||ae.apply(this,I)}),T(w,M)};J(N,w=>{e.onOpenSettings&&w(q)})}var L=_(y,2);{var V=w=>{var M=jV(),I=x(M),ae=_(I,2),ve=x(ae);{var ue=B=>{var G=VV();T(B,G)},le=B=>{var G=UV();T(B,G)};J(ve,B=>{f(c)?B(ue):B(le,-1)})}var he=_(ae,2);Y(()=>{I.disabled=f(l)===null,Z(ae,"aria-label",f(c)?"Restore":"Maximize"),ae.disabled=f(l)===null,he.disabled=f(l)===null}),P("click",I,h),P("click",ae,p),P("click",he,m),T(w,M)},re=H(()=>Ar());J(L,w=>{f(re)&&w(V)})}T(n,g),Je()}$e(["click"]);var qV=E('<span style="color: var(--tandem-fg-subtle);"> </span>'),JV=E('<span data-testid="save-indicator" style="color: var(--tandem-accent);">Saving...</span>'),YV=E('<button data-testid="sb-held" title="Show held annotations — switches to Tandem" style="display: inline-flex; align-items: center; gap: var(--tandem-space-1); padding: 1px 8px; font-size: var(--tandem-text-xs); font-weight: 600; border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-pill); background: var(--tandem-warning-bg); color: var(--tandem-warning-fg-strong); cursor: pointer;"><span style="width: 6px; height: 6px; border-radius: 50%; background: var(--tandem-warning-fg-strong); display: inline-block;"></span> </button>'),ZV=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>'),GV=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 XV(n,e){qe(e,!0);let t=ft(e,"documentCount",3,0),r=ft(e,"saving",3,!1);const i=2e3,o=Rk();let s=F(dt(o.userName)),a=F(void 0);de(()=>{const L=o.userName;f(s)!==L&&document.activeElement!==f(a)&&b(s,L,!0)});let l=F(!1),c=F(0),d=Yt(()=>e.connected);de(()=>{const L=d;if(d=e.connected,e.connected&&!L){b(l,!0);const V=setTimeout(()=>{b(l,!1)},i);return()=>clearTimeout(V)}}),de(()=>{if(e.disconnectedSince==null){b(c,0);return}b(c,Math.floor((Date.now()-e.disconnectedSince)/1e3),!0);const L=setInterval(()=>{b(c,Math.floor((Date.now()-(e.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(L)});const u=H(()=>e.connectionStatus==="connecting"),h=H(()=>e.connected?"var(--tandem-success)":f(u)?"var(--tandem-warning)":"var(--tandem-error)"),p=H(()=>f(l)?"Reconnected":e.connectionStatus==="connected"?"Connected":e.connectionStatus==="connecting"?(()=>{const L=["Reconnecting…"];if(e.reconnectAttempts>0||f(c)>0){const V=[];e.reconnectAttempts>0&&V.push(`attempt ${e.reconnectAttempts}`),f(c)>0&&V.push(`${f(c)}s`),L.push(`(${V.join(", ")})`)}return L.join(" ")})():"Disconnected — check that the server is running");function m(){o.setUserName(f(s))}var v=GV(),g=x(v),y=x(g),k=_(y,2),S=x(k),C=_(k,2);{var A=L=>{var V=qV(),re=x(V);Y(()=>te(re,`${t()??""} doc${t()!==1?"s":""} open`)),T(L,V)};J(C,L=>{t()>0&&L(A)})}var W=_(C,2);{var z=L=>{var V=JV();T(L,V)};J(W,L=>{r()&&L(z)})}var D=_(g,2),O=_(x(D),2);kt(O,L=>b(a,L),()=>f(a));var U=_(D,2);{var ee=L=>{var V=YV(),re=_(x(V));Y(()=>te(re,` ${e.heldCount??""} held`)),P("click",V,function(...w){var M;(M=e.onShowHeld)==null||M.apply(this,w)}),T(L,V)};J(U,L=>{(e.heldCount??0)>0&&e.mode==="solo"&&L(ee)})}var R=_(U,2);{var K=L=>{var V=ZV();T(L,V)};J(R,L=>{e.readOnly&&L(K)})}var ne=_(R,2),X=x(ne),N=_(X,2),q=x(N);Y(()=>{oe(y,`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"};`),te(S,f(p)),Pr(O,f(s)),Z(O,"maxlength",Gm),oe(X,`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"};`),oe(N,`transition: color 0.3s ease; color: ${e.claudeActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"};`),te(q,e.claudeStatus?`Claude · ${e.claudeStatus}`:"Claude · idle")}),P("input",O,L=>{b(s,L.target.value,!0)}),wt("blur",O,m),P("keydown",O,L=>{L.key==="Enter"&&L.currentTarget.blur(),L.key==="Escape"&&(b(s,o.userName,!0),L.currentTarget.blur())}),T(n,v),Je()}$e(["input","keydown","click"]);function vv(n,e,t=mA){const r=n.filter(i=>i!==e);return[e,...r].slice(0,t)}function yv(){try{const n=localStorage.getItem(Ym);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 bv(n){try{localStorage.setItem(Ym,JSON.stringify(n)),MS()}catch(e){console.warn("[tandem] failed to save recent files:",e)}}function QV(){try{localStorage.removeItem(Ym),MS()}catch(n){console.warn("[tandem] failed to clear recent files:",n)}}const $V=3e4;let al=null;function ew(){const n=Date.now();if(al&&n-al.ts<$V)return al.files;const e=yv();return al={files:e,ts:n},e}function MS(){al=null}var e6=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>'),t6=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>'),n6=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>'),r6=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>'),i6=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>'),o6=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 s6(n,e){qe(e,!0);let t=F("upload"),r=F(""),i=F(null),o=F(!1),s=F(!1),a=F(void 0),l=F(dt(yv()));function c(R){b(l,(()=>{const K=vv(f(l),R);return bv(K),K})(),!0)}function d(){QV(),b(l,[],!0)}async function u(R){if(!f(o)){b(i,null),b(o,!0);try{const K=await fetch(`${Tr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:R})}),ne=await K.json();if(!K.ok){b(i,ne.message??"Failed to open file",!0);return}c(R),e.onClose()}catch(K){console.error("FileOpenDialog: path open failed",K),K instanceof SyntaxError?b(i,"Server returned an unexpected response"):K 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(R){if(!f(o)){b(i,null),b(o,!0);try{const K=await mx(R),ne=await fetch(`${Tr}/upload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:R.name,content:K})}),X=await ne.json();if(!ne.ok){b(i,X.message??"Failed to open file",!0);return}e.onClose()}catch(K){console.error("FileOpenDialog: upload failed",K),K instanceof SyntaxError?b(i,"Server returned an unexpected response"):K instanceof TypeError?b(i,"Unexpected response format"):b(i,"Cannot reach server. Is it running?")}finally{b(o,!1)}}}function m(R){var ne;R.preventDefault(),b(s,!1);const K=(ne=R.dataTransfer)==null?void 0:ne.files[0];K&&p(K)}function v(R){var X;const ne=(X=R.target.files)==null?void 0:X[0];ne&&p(ne)}var g=o6();Z(g,"tabindex",-1);var y=x(g),k=x(y),S=_(x(k),2),C=_(k,2),A=x(C),W=_(A,2),z=_(C,2);{var D=R=>{var K=n6(),ne=x(K);UC(ne);var X=_(ne,2),N=x(X),q=_(X,2);{var L=V=>{var re=t6(),w=x(re),M=_(x(w),2),I=_(w,2);mt(I,22,()=>f(l),ae=>ae,(ae,ve,ue)=>{const le=H(()=>ve.split(/[/\\]/)),he=H(()=>f(le).at(-1)??ve),B=H(()=>f(le).slice(0,-1).join("/")||"/");var G=e6(),be=x(G),Te=x(be),De=_(be,2),Ee=x(De);Y(()=>{Z(G,"data-testid",`recent-file-${f(ue)}`),te(Te,f(he)),te(Ee,f(B))}),P("click",G,()=>{b(r,ve,!0),u(ve)}),wt("mouseenter",G,se=>{se.currentTarget.style.background="var(--tandem-surface-muted)"}),wt("mouseleave",G,se=>{se.currentTarget.style.background="transparent"}),T(ae,G)}),P("click",M,d),T(V,re)};J(q,V=>{f(l).length>0&&V(L)})}Y((V,re)=>{X.disabled=V,oe(X,re),te(N,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};`]),P("keydown",ne,V=>{V.key==="Enter"&&h()}),ys(ne,()=>f(r),V=>b(r,V)),P("click",X,h),T(R,K)},O=R=>{var K=r6();Z(K,"tabindex",0);var ne=x(K);kt(ne,q=>b(a,q),()=>f(a));var X=_(ne,2),N=x(X);Y(()=>{oe(K,`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;`),te(N,f(o)?"Opening...":"Drop a file here or click to browse")}),wt("dragover",K,q=>{q.preventDefault(),b(s,!0)}),wt("dragleave",K,()=>b(s,!1)),wt("drop",K,m),P("click",K,()=>{var q;return(q=f(a))==null?void 0:q.click()}),P("keydown",K,q=>{var L;(q.key==="Enter"||q.key===" ")&&((L=f(a))==null||L.click())}),P("change",ne,v),T(R,K)};J(z,R=>{f(t)==="path"?R(D):R(O,-1)})}var U=_(z,2);{var ee=R=>{var K=i6(),ne=x(K);Y(()=>te(ne,f(i))),T(R,K)};J(U,R=>{f(i)&&R(ee)})}Y(()=>{oe(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)"};`),oe(W,`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)"};`)}),P("click",g,R=>{R.target===R.currentTarget&&e.onClose()}),P("keydown",g,R=>{R.key==="Escape"&&e.onClose()}),P("click",S,function(...R){var K;(K=e.onClose)==null||K.apply(this,R)}),P("click",A,()=>b(t,"path")),P("click",W,()=>b(t,"upload")),T(n,g),Je()}$e(["click","keydown","change"]);function Xh(n){return document.body.appendChild(n),{destroy(){n.remove()}}}var a6=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>'),l6=E('<div class="new-tab-menu-divider svelte-7c4il0"></div>'),c6=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 d6(n,e){qe(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 k=o(),S=k.indexOf(document.activeElement);(g=k[(S+1)%k.length])==null||g.focus()}else if(v.key==="ArrowUp"){v.preventDefault();const k=o(),S=k.indexOf(document.activeElement);(y=k[(S-1+k.length)%k.length])==null||y.focus()}}function o(){var v;return Array.from(((v=f(s))==null?void 0:v.querySelectorAll("[role='menuitem']"))??[])}let s=F(null);function a(v){var y,k;const g=v.target;g&&((y=e.anchorEl)!=null&&y.contains(g)||(k=g.closest)!=null&&k.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,k=v.bottom+4,S=v.left;S+g>y-8?(f(s).style.right="8px",f(s).style.left="auto"):(f(s).style.left=`${S}px`,f(s).style.right="auto"),f(s).style.top=`${k}px`}de(()=>{var v;f(s)&&(l(),(v=o()[0])==null||v.focus())});var c=c6(),d=_(x(c),2);mt(d,17,()=>e.recentFiles,ba,(v,g)=>{var y=a6(),k=x(y),S=x(k),C=_(k,2),A=x(C);Y((W,z)=>{Z(y,"title",f(g)),te(S,W),te(A,z)},[()=>r(f(g)),()=>t(f(g))]),P("click",y,()=>e.onOpen(f(g))),T(v,y)});var u=_(d,2);{var h=v=>{var g=l6();T(v,g)};J(u,v=>{e.recentFiles.length>0&&v(h)})}var p=_(u,2),m=_(p,2);Ol(c,v=>Xh==null?void 0:Xh(v)),Ol(c,(v,g)=>mr==null?void 0:mr(v,g),()=>a),kt(c,v=>b(s,v),()=>f(s)),P("keydown",c,i),P("click",p,function(...v){var g;(g=e.onNewScratchpad)==null||g.apply(this,v)}),P("click",m,function(...v){var g;(g=e.onBrowse)==null||g.apply(this,v)}),T(n,c),Je()}$e(["keydown","click"]);var u6=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>'),f6=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 h6(n,e){qe(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=H(()=>r[e.tab.format]??"var(--tandem-fg-faint)");let o=F(!1),s=null;de(()=>{const{ydoc:C,readOnly:A}=e.tab;if(A){b(o,!1);return}const W=C.getXmlFragment("default"),z=C.getMap(md);let D=!1;const O=setTimeout(()=>{D=!0,s=z.get(iy)??0,b(o,!1)},500),U=()=>{D&&b(o,!0)};W.observeDeep(U);const ee=()=>{if(!D)return;const R=z.get(iy);R!==void 0&&R!==s&&(s=R,b(o,!1))};return z.observe(ee),()=>{clearTimeout(O),W.unobserveDeep(U),z.unobserve(ee)}});const a=H(()=>["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=F(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=f6();Z(u,"tabindex",0);var h=x(u),p=_(h,2),m=x(p),v=_(p,2),g=x(v),y=_(v,2);{var k=C=>{var A=u6();T(C,A)};J(y,C=>{e.tab.readOnly&&C(k)})}var S=_(y,2);kt(S,C=>b(l,C),()=>f(l)),Y(C=>{Z(u,"data-testid",`tab-${e.tab.id}`),Z(u,"data-active",e.isActive),Z(u,"aria-selected",e.isActive),Z(u,"aria-label",e.tab.fileName),Z(u,"draggable",e.draggable),oe(u,f(a)),Z(h,"data-testid",`unsaved-indicator-${e.tab.id}`),oe(h,`color: var(--tandem-warning); font-size: 10px; visibility: ${f(o)?"visible":"hidden"};`),Z(h,"aria-hidden",!f(o)),Z(p,"data-testid",`tab-format-badge-${e.tab.id}`),Z(p,"aria-label",`Format: ${e.tab.format}`),oe(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;`),te(m,C),Z(v,"data-testid",`tab-name-${e.tab.id}`),Z(v,"title",e.tab.filePath),oe(v,`font-weight: ${e.isActive?500:400}; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),te(g,e.tab.fileName),Z(S,"aria-label",`Close ${e.tab.fileName}`)},[()=>t[e.tab.format]??e.tab.format.toUpperCase()]),P("click",u,()=>e.onswitch(e.tab.id)),wt("dragstart",u,C=>e.ondragstart(C,e.tab.id)),wt("dragover",u,C=>e.ondragover(C,e.tab.id)),wt("drop",u,C=>e.ondrop(C,e.tab.id)),wt("dragend",u,function(...C){var A;(A=e.ondragend)==null||A.apply(this,C)}),wt("dragleave",u,function(...C){var A;(A=e.ondragleave)==null||A.apply(this,C)}),P("keydown",u,C=>e.onkeydown(C,e.tab.id)),P("click",S,C=>{C.stopPropagation(),e.onclose(e.tab.id)}),wt("dragover",S,C=>{C.stopPropagation(),C.preventDefault()}),wt("drop",S,C=>{C.stopPropagation(),C.preventDefault()}),wt("mouseenter",S,c),wt("mouseleave",S,d),T(n,u),Je()}$e(["click","keydown"]);var p6=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>'),m6=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>'),g6=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 v6(n,e){qe(e,!0);const t=ft(e,"reduceMotion",3,!1),r=H(()=>t()?"auto":"smooth");let i=F(!1),o=F(!1),s=F(dt([])),a=F(null),l=new Set;de(()=>{const w=new Set(e.tabs.map(M=>M.id));for(const M of l)w.has(M)||l.delete(M)});function c(w){l.has(w)||(l.add(w),e.onTabClose(w))}let d=F(void 0),u=F(!1),h=F(!1),p=F(null),m=F(null);function v(){b(p,null),b(m,null)}function g(){const w=f(d);w&&(b(u,w.scrollLeft>0),b(h,w.scrollLeft+w.clientWidth<w.scrollWidth-1))}de(()=>{const w=f(d);if(!w)return;g(),w.addEventListener("scroll",g,{passive:!0});const M=new ResizeObserver(g);return M.observe(w),()=>{w.removeEventListener("scroll",g),M.disconnect()}}),de(()=>{e.tabs.length,g()}),de(()=>{if(!e.activeTabId||!f(d))return;const w=f(d).querySelector(`[data-testid="tab-${e.activeTabId}"]`);w&&w.scrollIntoView({inline:"nearest",block:"nearest",behavior:f(r)})}),de(()=>{e.tabs.length,v()});function y(w,M){b(p,M,!0),w.dataTransfer&&(w.dataTransfer.setData("text/plain",M),w.dataTransfer.effectAllowed="move")}function k(w,M){if(w.preventDefault(),!f(p)||f(p)===M){b(m,null);return}const I=w.currentTarget.getBoundingClientRect(),ae=I.left+I.width/2,ve=w.clientX<ae?"left":"right";b(m,{id:M,side:ve},!0)}function S(w,M){var ae;w.preventDefault();const I=(ae=w.dataTransfer)==null?void 0:ae.getData("text/plain");if(I&&I!==M&&e.reorder){const ve=w.currentTarget.getBoundingClientRect(),ue=ve.left+ve.width/2,le=w.clientX<ue?"left":"right";e.reorder(I,M,le)}v()}function C(){v()}function A(){b(m,null)}function W(w,M){if(!w.altKey||!e.reorder||w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault();const I=e.tabs.findIndex(ae=>ae.id===M);I!==-1&&(w.key==="ArrowLeft"&&I>0?e.reorder(M,e.tabs[I-1].id):w.key==="ArrowRight"&&I<e.tabs.length-1&&e.reorder(e.tabs[I+1].id,M))}function z(){var w;(w=f(d))==null||w.scrollBy({left:-150,behavior:f(r)})}function D(){var w;(w=f(d))==null||w.scrollBy({left:150,behavior:f(r)})}const O=H(()=>e.tabs.length<=1);de(()=>{if(!f(o))return;function w(M){var ae,ve,ue;const I=M.target;I&&((ae=f(a))!=null&&ae.contains(I)||(ve=I.closest)!=null&&ve.call(I,".new-tab-menu")||(ue=I.closest)!=null&&ue.call(I,"[data-tauri-drag-region]")||b(o,!1))}return window.addEventListener("pointerdown",w,!0),()=>window.removeEventListener("pointerdown",w,!0)});var U=g6(),ee=x(U);{var R=w=>{var M=p6();P("click",M,z),T(w,M)};J(ee,w=>{f(u)&&w(R)})}var K=_(ee,2);mt(K,21,()=>e.tabs,w=>w.id,(w,M)=>{{let I=H(()=>f(M).id===e.activeTabId),ae=H(()=>!f(O)),ve=H(()=>{var ue;return((ue=f(m))==null?void 0:ue.id)===f(M).id?f(m).side:null});h6(w,{get tab(){return f(M)},get isActive(){return f(I)},get onswitch(){return e.onTabSwitch},onclose:c,get draggable(){return f(ae)},ondragstart:y,ondragover:k,ondrop:S,ondragend:C,ondragleave:A,get dropIndicator(){return f(ve)},onkeydown:W})}}),kt(K,w=>b(d,w),()=>f(d));var ne=_(K,2);kt(ne,w=>b(a,w),()=>f(a));var X=_(ne,2);{var N=w=>{var M=m6();P("click",M,D),T(w,M)};J(X,w=>{f(h)&&w(N)})}var q=_(X,2);{var L=w=>{d6(w,{get recentFiles(){return f(s)},get anchorEl(){return f(a)},onOpen:async M=>{b(o,!1);try{const I=await fetch(`${Tr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:M})});if(I.ok)bv(vv(ew(),M));else{const ae=await I.text();console.warn("[tandem] failed to open recent file:",ae)}}catch(I){console.warn("[tandem] failed to open recent file:",I)}},onNewScratchpad:()=>{b(o,!1),Xm()},onBrowse:()=>{b(o,!1),b(i,!0)},onClose:()=>b(o,!1)})};J(q,w=>{f(o)&&w(L)})}var V=_(q,2);{var re=w=>{s6(w,{onClose:()=>b(i,!1)})};J(V,w=>{f(i)&&w(re)})}P("click",ne,()=>{b(s,ew(),!0),b(o,!f(o))}),wt("mouseenter",ne,w=>{w.currentTarget.style.color="var(--tandem-accent)",w.currentTarget.style.borderColor="var(--tandem-accent)"}),wt("mouseleave",ne,w=>{w.currentTarget.style.color="var(--tandem-fg-muted)",w.currentTarget.style.borderColor="var(--tandem-border-strong)"}),T(n,U),Je()}$e(["click"]);var y6=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>'),b6=E("<div><!></div>"),w6=E('<div class="editor-scroll" role="region" aria-label="Document editor"><!> <!> <!></div>'),x6=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>'),k6=E('<button data-testid="annotations-tab"><!> <!></button>'),_6=E('<button data-testid="chat-tab"><!></button>'),S6=E('<button data-testid="outline-tab"><!></button>'),C6=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>'),T6=E('<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>'),A6=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>'),E6=E('<button data-testid="left-annotations-tab"> </button>'),M6=E('<button data-testid="left-chat-tab"> </button>'),O6=E('<button data-testid="left-outline-tab"> </button>'),D6=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),R6=E("<!> <!>",1),N6=E('<!> <!> <!> <!> <!> <div style="display: flex; flex: 1; overflow: hidden; background: var(--tandem-bg);"><!> <!> <!></div> <!> <!> <!> <!> <!> <!> <!>',1),I6=E('<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>');function L6(n,e){qe(e,!0);const t=(se,$=pr,Q=pr,pe=pr,fe=pr)=>{var Le=y6();Z(Le,"aria-valuemin",0),Z(Le,"aria-valuemax",100),Y(Ie=>{Z(Le,"data-testid",pe()??`${$()}-panel-resize-handle`),Z(Le,"aria-label",$()==="left"?"Resize left panel":"Resize right panel"),Z(Le,"aria-valuenow",Ie)},[()=>fe()!==void 0?Math.round((fe()-ca)/(dc-ca)*100):50]),P("mousedown",Le,function(...Ie){var ye;(ye=Q())==null||ye.apply(this,Ie)}),P("keydown",Le,Ie=>{let Ae=null;Ie.key==="ArrowRight"||Ie.key==="ArrowUp"?Ae=16:Ie.key==="ArrowLeft"||Ie.key==="ArrowDown"?Ae=-16:Ie.key==="PageUp"?Ae=80:Ie.key==="PageDown"?Ae=-80:Ie.key==="Home"?Ae=ca-($()==="left"?q.width:L.width):Ie.key==="End"&&(Ae=dc-($()==="left"?q.width:L.width)),Ae!==null&&(Ie.preventDefault(),Ie.stopPropagation(),$()==="left"?q.handleResizeStep(Ae):L.handleResizeStep(Ae))}),P("keyup",Le,()=>{}),wt("mouseenter",Le,Ie=>{Ie.currentTarget.style.background="var(--tandem-border-strong)"}),wt("mouseleave",Le,Ie=>{Ie.currentTarget.style.background="transparent"}),T(se,Le)},r=se=>{var $=w6();{const ye=ke=>{iH(ke,{get ydoc(){return f(he).ydoc},get provider(){return f(he).provider},get readOnly(){return o.readOnly},get currentFilePath(){return f(he).filePath},get activeAnnotationId(){return f(z)},onEditorReady:Ae=>b(U,Ae,!0),onAnnotationClick:Ae=>{b(C,"annotations"),b(z,Ae,!0)},onSlashCommandMenuChange:Ae=>b(ee,Ae,!0)})};var Q=x($);{let ke=H(()=>{var Pe,lt;return((Pe=f(he))==null?void 0:Pe.readOnly)===!0&&((lt=f(he))==null?void 0:lt.format)==="docx"}),Ae=H(()=>{var Pe;return(Pe=f(he))==null?void 0:Pe.id});lN(Q,{get visible(){return f(ke)},get documentId(){return f(Ae)}})}var pe=_(Q,2);{var fe=ke=>{eI(ke,{children:(Ae,Pe)=>{var lt=Rt(),At=ze(lt);up(At,()=>f(he).id,Se=>{ye(Se)}),T(Ae,lt)}})},Le=ke=>{var Ae=b6(),Pe=x(Ae);{var lt=Se=>{var vt=Rt(),Pt=ze(vt);up(Pt,()=>f(he).id,xe=>{ye(xe)}),T(Se,vt)},At=Se=>{ZE(Se,{get connected(){return o.connected},get claudeActive(){return o.claudeActive}})};J(Pe,Se=>{f(he)?Se(lt):Se(At,-1)})}Y(()=>oe(Ae,`max-width: ${f(ve)??"68ch"}; margin: ${f(ue)??"0 auto"};`)),T(ke,Ae)};J(pe,ke=>{var Ae;((Ae=f(he))==null?void 0:Ae.format)==="docx"?ke(fe):ke(Le,-1)})}var Ie=_(pe,2);pH(Ie,{get editor(){return f(U)},get open(){return f(R)},onClose:()=>b(R,!1),get tabs(){return o.tabs}})}Y(()=>oe($,`position: relative; flex: 1; overflow: auto; padding: var(--tandem-space-7) var(--tandem-space-5); border: ${p.fileDragOver?"2px dashed var(--tandem-accent)":"2px solid transparent"}; background: ${p.fileDragOver?"var(--tandem-accent-bg)":"var(--tandem-bg)"}; transition: border-color 0.15s, background 0.15s; border-radius: ${p.fileDragOver?"var(--tandem-r-5)":"0"};`)),wt("dragover",$,function(...ye){var ke;(ke=p.handleEditorDragOver)==null||ke.apply(this,ye)}),wt("dragleave",$,function(...ye){var ke;(ke=p.handleEditorDragLeave)==null||ke.apply(this,ye)}),wt("drop",$,function(...ye){var ke;(ke=p.handleEditorDrop)==null||ke.apply(this,ye)}),T(se,$)},i=(se,$=pr,Q=pr)=>{const pe=H(()=>a.settings.rightRailTabs),fe=H(()=>f(pe).length>3);var Le=C6(),Ie=x(Le),ye=x(Ie);{var ke=Ge=>{var He=k6(),Re=x(He);{var et=gt=>{var zt=an("◨");T(gt,zt)},Ue=gt=>{var zt=an("Annotations");T(gt,zt)};J(Re,gt=>{f(fe)?gt(et):gt(Ue,-1)})}var Ve=_(Re,2);{var tt=gt=>{var zt=x6(),Un=x(zt);Y(()=>te(Un,f(W)>9?"9+":f(W))),T(gt,zt)};J(Ve,gt=>{f(C)!=="annotations"&&f(W)>0&>(tt)})}Y(()=>{oe(He,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(C)==="annotations"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(C)==="annotations"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; position: relative; white-space: nowrap;`),Z(He,"title",f(fe)?"Annotations":void 0)}),P("click",He,()=>{b(C,"annotations")}),T(Ge,He)},Ae=H(()=>f(pe).includes("annotations"));J(ye,Ge=>{f(Ae)&&Ge(ke)})}var Pe=_(ye,2);{var lt=Ge=>{var He=_6(),Re=x(He);{var et=Ve=>{var tt=an("💬");T(Ve,tt)},Ue=Ve=>{var tt=an("Chat");T(Ve,tt)};J(Re,Ve=>{f(fe)?Ve(et):Ve(Ue,-1)})}Y(()=>{oe(He,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(C)==="chat"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(C)==="chat"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(He,"title",f(fe)?"Chat":void 0)}),P("mousedown",He,le),P("click",He,()=>{b(C,"chat")}),T(Ge,He)},At=H(()=>f(pe).includes("chat"));J(Pe,Ge=>{f(At)&&Ge(lt)})}var Se=_(Pe,2);{var vt=Ge=>{var He=S6(),Re=x(He);{var et=Ve=>{var tt=an("≡");T(Ve,tt)},Ue=Ve=>{var tt=an("Outline");T(Ve,tt)};J(Re,Ve=>{f(fe)?Ve(et):Ve(Ue,-1)})}Y(()=>{oe(He,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(C)==="outline"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(C)==="outline"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(He,"title",f(fe)?"Outline":void 0)}),P("click",He,()=>{b(C,"outline")}),T(Ge,He)},Pt=H(()=>f(pe).includes("outline"));J(Se,Ge=>{f(Pt)&&Ge(vt)})}var xe=_(Se,2),Ye=x(xe);{let Ge=H(()=>a.settings.leftRailTabs.length===1?a.settings.leftRailTabs:[]);Q0(Ye,{get enabledTabs(){return a.settings.rightRailTabs},get disabledTabs(){return f(Ge)},onTabsChange:He=>{I("right",He)}})}var bt=_(Ie,2);{let Ge=H(()=>f(C)==="chat"&&f(pe).includes("chat"));Fs(bt,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return f(U)},get activeDocId(){return o.activeTabId},get openDocs(){return f(u)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return f(O)},onCapturedAnchorChange:He=>b(O,He,!0),get reduceMotion(){return a.settings.reduceMotion},get visible(){return f(Ge)}})}var ut=_(bt,2);{let Ge=H(()=>{var Ue;return((Ue=f(he))==null?void 0:Ue.ydoc)??null}),He=H(()=>{var Ue;return(Ue=f(he))==null?void 0:Ue.format}),Re=H(()=>{var Ue;return(Ue=f(he))==null?void 0:Ue.id}),et=H(()=>f(C)==="annotations"&&f(pe).includes("annotations"));Fs(ut,{kind:"side",get annotations(){return f(c).visibleAnnotations},get editor(){return f(U)},get ydoc(){return f(Ge)},get heldCount(){return f(c).heldCount},get tandemMode(){return l.tandemMode},get onModeChange(){return l.setTandemMode},get activeDocFormat(){return f(He)},get documentId(){return f(Re)},get activeAnnotationId(){return f(z)},onActiveAnnotationChange:Ue=>b(z,Ue,!0),get reduceMotion(){return a.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},onFilterChange:(Ue,Ve,tt)=>{b(ne,{type:Ue,author:Ve,status:tt},!0)},get visible(){return f(et)}})}var _t=_(ut,2);{var _n=Ge=>{{let He=H(()=>f(C)==="outline");Fs(Ge,{kind:"outline",get editor(){return f(U)},get annotations(){return f(c).visibleAnnotations},get focusTrigger(){return f(K)},get activeFilterType(){return f(ne).type},get visible(){return f(He)}})}},xt=H(()=>f(pe).includes("outline"));J(_t,Ge=>{f(xt)&&Ge(_n)})}Y(()=>oe(Le,`display: flex; flex-direction: column; width: ${$()}px; ${Q()==="left"?"border-right":"border-left"}: 1px solid var(--tandem-border); background: var(--tandem-surface-muted);`)),T(se,Le)},o=sV();yi(()=>o.destroy());const s=UH(()=>o.tabs);HH(()=>s.orderedTabs,()=>o.activeTabId,se=>o.setActiveTabId(se)),de(()=>{const se=o.tabs;if(se.length!==0)try{const $=yv();let Q=$;for(const pe of se)MT(pe.filePath)||(Q=vv(Q,pe.filePath));(Q.length!==$.length||Q.some((pe,fe)=>pe!==$[fe]))&&bv(Q)}catch($){console.warn("[tandem] failed to sync recent files:",$)}});const a=GH(),l=jH(()=>o.bootstrapYdoc,()=>a.settings.selectionDwellMs),c=H(()=>{const se=o.annotations,$=l.tandemMode,Q=[];let pe=0;for(const fe of se)PH(fe,$)?Q.push(fe):fe.status==="pending"&&pe++;return{visibleAnnotations:Q,heldCount:pe}}),d=TH(()=>o.disconnectedSince,()=>a.settings.degradedBannerDelayMs);iV();const u=H(()=>o.tabs.map(se=>({id:se.id,fileName:se.fileName}))),h=zH(),p=NH();let m=F(!1),v=F(null),g=F(!1);function y(){b(m,!f(m))}function k(){a.updateSettings({theme:WH[a.settings.theme]})}kA({getActiveTabId:()=>o.activeTabId,openSettings:()=>b(m,!0),toggleSoloMode:()=>l.setTandemMode(l.tandemMode==="solo"?"tandem":"solo"),openFindBar:()=>{}});let S;de(()=>{const se=f(U);if(!se)return;const $=a.settings.showAuthorship;if(S===$)return;S=$;const Q=se.state.tr.setMeta(Js,{type:"toggle",visible:$});se.view.dispatch(Q)}),de(()=>(document.body.classList.toggle("tandem-reduce-motion",a.settings.reduceMotion),()=>document.body.classList.remove("tandem-reduce-motion"))),tV(()=>a.settings.theme),_H(()=>a.settings.accentHue),RH(()=>a.settings.editorFont),EH(()=>a.settings.density),LH(()=>a.settings.highContrast),CH(()=>a.settings.annotationPatterns),de(()=>{const se=qH[a.settings.textSize];return document.documentElement.style.setProperty("--tandem-editor-font-size",`${se}px`),()=>document.documentElement.style.removeProperty("--tandem-editor-font-size")});let C=F(dt(a.settings.primaryTab==="chat"?"chat":"annotations")),A=F(dt(a.settings.leftRailTabs[0]??"annotations"));de(()=>{a.settings.leftRailTabs.includes(f(A))||b(A,a.settings.leftRailTabs[0]??"annotations",!0)}),de(()=>{a.settings.rightRailTabs.includes(f(C))||b(C,a.settings.rightRailTabs[0]??"chat",!0)});const W=H(()=>f(C)==="annotations"?0:f(c).visibleAnnotations.filter(Hd).length);let z=F(null),D=F(!1),O=F(null),U=F(null),ee=F(!1),R=F(!1),K=F(0),ne=F(dt({type:"all",author:"all",status:"all"}));const X=W0("left"),N=W0("right"),q=K0({side:"left",initialWidth:X,getVisible:()=>f(V)}),L=K0({side:"right",initialWidth:N,getVisible:()=>f(re)}),V=H(()=>a.settings.leftPanelVisible),re=H(()=>a.settings.rightPanelVisible&&!(l.tandemMode==="solo"&&a.settings.soloRailHidden));function w(){a.updateSettings({leftPanelVisible:!a.settings.leftPanelVisible})}function M(){f(re)?a.updateSettings({rightPanelVisible:!1}):a.updateSettings({rightPanelVisible:!0,...l.tandemMode==="solo"?{soloRailHidden:!1}:{}})}function I(se,$){const Q=a.settings.leftRailTabs,pe=a.settings.rightRailTabs,fe=se==="left"?Q:pe,Le=se==="left"?pe:Q,Ie=$.filter(ke=>!fe.includes(ke));if(Ie.length===0)return a.updateSettings(se==="left"?{leftRailTabs:$}:{rightRailTabs:$}),!0;const ye=Le.filter(ke=>!Ie.includes(ke));return ye.length===0?(console.warn("[tandem] cross-rail tab move blocked — would leave the %s rail empty",se==="left"?"right":"left"),!1):(a.updateSettings(se==="left"?{leftRailTabs:$,rightRailTabs:ye}:{rightRailTabs:$,leftRailTabs:ye}),!0)}function ae(se,$,Q){b(ne,{type:se,author:$,status:Q},!0)}const ve=H(()=>a.settings.editorWidthPercent<100?`${a.settings.editorWidthPercent}%`:void 0),ue=H(()=>a.settings.editorWidthPercent<100?"0 auto":void 0);function le(){if(f(C)==="chat"||!f(U))return;const{from:se,to:$}=f(U).state.selection;if(se===$)return;const Q=Mk(f(U).state.doc,{from:bn(se),to:bn($)}),pe=f(U).state.doc.textBetween(se,$,`
|
|
297
|
-
`);b(O,{...Q,textSnapshot:pe.length>200?pe.slice(0,197)+"...":pe},!0)}de(()=>{function se($){var Q,pe;if($.key==="?"){const fe=$.target;if(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA"||fe.isContentEditable)return;b(D,Yt(()=>!f(D)),!0);return}if($.ctrlKey||$.metaKey){if($.key==="a"){const fe=document.activeElement;if(fe instanceof HTMLInputElement||fe instanceof HTMLTextAreaElement||(Q=fe==null?void 0:fe.closest)!=null&&Q.call(fe,".ProseMirror"))return;$.preventDefault(),(pe=f(U))==null||pe.commands.selectAll()}else if($.key==="s")$.preventDefault(),vx(o.activeTabId);else if(BH($))$.preventDefault(),b(m,!0);else if($.shiftKey&&$.key==="P")$.preventDefault(),b(g,!Yt(()=>f(g)));else if($.key==="n"){const fe=$.target;if(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA")return;$.preventDefault(),Xm()}else if($.key==="/"){const fe=$.target;if(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA"||fe.isContentEditable)return;$.preventDefault(),b(D,Yt(()=>!f(D)),!0)}}($.ctrlKey||$.metaKey)&&$.key==="f"&&($.preventDefault(),f(V)&&f(A)==="outline"||f(re)&&f(C)==="outline"?b(K,f(K)+1):b(R,!0))}return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)});const he=H(()=>o.tabs.find(se=>se.id===o.activeTabId)),B=rV(()=>f(c).visibleAnnotations,()=>f(U),()=>{var se;return(se=f(he))==null?void 0:se.fileName});var G=I6(),be=x(G);KV(be,{get tandemMode(){return l.tandemMode},get onModeChange(){return l.setTandemMode},get claudeActive(){return o.claudeActive},get leftPanelVisible(){return f(V)},onToggleLeftPanel:w,get rightPanelVisible(){return f(re)},onToggleRightPanel:M,get theme(){return a.settings.theme},onCycleTheme:k,get showAuthorship(){return a.settings.showAuthorship},onAuthorshipChange:se=>a.updateSettings({showAuthorship:se}),onOpenHelp:()=>b(D,!0),onOpenSettings:y,get settingsBtn(){return f(v)},set settingsBtn(se){b(v,se,!0)}});var Te=_(be,2);{var De=se=>{var $=T6();T(se,$)},Ee=se=>{var $=N6(),Q=ze($);{var pe=Re=>{var et=A6();T(Re,et)};J(Q,Re=>{o.serverRestarted&&Re(pe)})}var fe=_(Q,2);{var Le=Re=>{DE(Re,{get onDismiss(){return d.dismiss},onRetry:()=>{o.reconnect()}})};J(fe,Re=>{d.showBanner&&Re(Le)})}var Ie=_(fe,2);{let Re=H(()=>{var Ue;return((Ue=f(he))==null?void 0:Ue.ydoc)??null}),et=H(()=>f(ee)||f(R)||f(g));xH(Ie,{get editor(){return f(U)},get ydoc(){return f(Re)},get selectionToolbar(){return a.settings.selectionToolbar},get suppressSelectionToolbar(){return f(et)}})}var ye=_(Ie,2);v6(ye,{get tabs(){return s.orderedTabs},get activeTabId(){return o.activeTabId},get onTabSwitch(){return o.setActiveTabId},get onTabClose(){return o.handleTabClose},get reorder(){return s.reorder},get reduceMotion(){return a.settings.reduceMotion}});var ke=_(ye,2);{let Re=H(()=>{var et;return((et=f(he))==null?void 0:et.ydoc)??null});AV(ke,{get editor(){return f(U)},get ydoc(){return f(Re)}})}var Ae=_(ke,2),Pe=x(Ae);{var lt=Re=>{const et=H(()=>a.settings.leftRailTabs),Ue=H(()=>f(et).length>3),Ve=H(()=>a.settings.rightRailTabs.length===1?a.settings.rightRailTabs:[]);var tt=D6(),gt=ze(tt),zt=x(gt),Un=x(zt);{var on=Wt=>{var Kt=E6(),zo=x(Kt);Y(()=>{oe(Kt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(A)==="annotations"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(A)==="annotations"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(Kt,"title",f(Ue)?"Annotations":void 0),te(zo,f(Ue)?"◨":"Annotations")}),P("click",Kt,()=>{b(A,"annotations")}),T(Wt,Kt)},Or=H(()=>f(et).includes("annotations"));J(Un,Wt=>{f(Or)&&Wt(on)})}var Yi=_(Un,2);{var Lo=Wt=>{var Kt=M6(),zo=x(Kt);Y(()=>{oe(Kt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(A)==="chat"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(A)==="chat"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(Kt,"title",f(Ue)?"Chat":void 0),te(zo,f(Ue)?"💬":"Chat")}),P("click",Kt,()=>{b(A,"chat")}),T(Wt,Kt)},Po=H(()=>f(et).includes("chat"));J(Yi,Wt=>{f(Po)&&Wt(Lo)})}var Ic=_(Yi,2);{var Lc=Wt=>{var Kt=O6(),zo=x(Kt);Y(()=>{oe(Kt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(A)==="outline"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(A)==="outline"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(Kt,"title",f(Ue)?"Outline":void 0),te(zo,f(Ue)?"≡":"Outline")}),P("click",Kt,()=>{b(A,"outline")}),T(Wt,Kt)},Vf=H(()=>f(et).includes("outline"));J(Ic,Wt=>{f(Vf)&&Wt(Lc)})}var Uf=_(Ic,2),jf=x(Uf);Q0(jf,{get enabledTabs(){return f(et)},get disabledTabs(){return f(Ve)},testIdPrefix:"left-",onTabsChange:Wt=>{I("left",Wt)}});var OS=_(zt,2),wv=x(OS);{let Wt=H(()=>f(A)==="chat"&&f(et).includes("chat"));Fs(wv,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return f(U)},get activeDocId(){return o.activeTabId},get openDocs(){return f(u)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return f(O)},onCapturedAnchorChange:Kt=>b(O,Kt,!0),get reduceMotion(){return a.settings.reduceMotion},get visible(){return f(Wt)}})}var xv=_(wv,2);{let Wt=H(()=>{var Kr;return((Kr=f(he))==null?void 0:Kr.ydoc)??null}),Kt=H(()=>{var Kr;return(Kr=f(he))==null?void 0:Kr.format}),zo=H(()=>{var Kr;return(Kr=f(he))==null?void 0:Kr.id}),NS=H(()=>f(A)==="annotations"&&f(et).includes("annotations"));Fs(xv,{kind:"side",get annotations(){return f(c).visibleAnnotations},get activeFilterType(){return f(ne).type},get activeFilterAuthor(){return f(ne).author},get activeFilterStatus(){return f(ne).status},onFilterChange:ae,get editor(){return f(U)},get ydoc(){return f(Wt)},get heldCount(){return f(c).heldCount},get tandemMode(){return l.tandemMode},get onModeChange(){return l.setTandemMode},get activeDocFormat(){return f(Kt)},get documentId(){return f(zo)},get activeAnnotationId(){return f(z)},onActiveAnnotationChange:Kr=>b(z,Kr,!0),get reduceMotion(){return a.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get visible(){return f(NS)}})}var DS=_(xv,2);{let Wt=H(()=>f(A)==="outline"&&f(et).includes("outline"));Fs(DS,{kind:"outline",get focusTrigger(){return f(K)},get editor(){return f(U)},get visible(){return f(Wt)}})}var RS=_(gt,2);t(RS,()=>"left",()=>Wt=>q.handleResizeStart(Wt),()=>{},()=>q.width),Y(()=>oe(gt,`display: flex; flex-direction: column; width: ${q.width}px; border-right: 1px solid var(--tandem-border); background: var(--tandem-surface-muted);`)),T(Re,tt)};J(Pe,Re=>{f(V)&&Re(lt)})}var At=_(Pe,2);r(At);var Se=_(At,2);{var vt=Re=>{var et=R6(),Ue=ze(et);t(Ue,()=>"right",()=>tt=>L.handleResizeStart(tt),()=>"panel-resize-handle",()=>L.width);var Ve=_(Ue,2);i(Ve,()=>L.width,()=>"right"),T(Re,et)};J(Se,Re=>{f(re)&&Re(vt)})}var Pt=_(Ae,2);XV(Pt,{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 _A.saving},get heldCount(){return f(c).heldCount},get mode(){return l.tandemMode},onShowHeld:()=>l.setTandemMode("tandem")});var xe=_(Pt,2);YN(xe,{get open(){return f(m)},onClose:()=>b(m,!1),get settings(){return a.settings},get onUpdate(){return a.updateSettings},get returnFocusEl(){return f(v)},get anchorEl(){return f(v)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts}});var Ye=_(xe,2);eM(Ye,{get open(){return f(D)},onClose:()=>b(D,!1)});var bt=_(Ye,2);ME(bt,{get open(){return f(g)},onClose:()=>b(g,!1),get editor(){return f(U)},get annotations(){return f(c).visibleAnnotations},onFocusAnnotation:Re=>{b(z,Re,!0)}});var ut=_(bt,2);QN(ut,{get toasts(){return h.toasts},get onDismiss(){return h.dismiss}});var _t=_(ut,2);{var _n=Re=>{WE(Re,{})},xt=H(()=>Ar());J(_t,Re=>{f(xt)&&Re(_n)})}var Ge=_(_t,2);{var He=Re=>{pM(Re,{get currentStep(){return B.currentStep},get onNext(){return B.nextStep},get onDismiss(){return B.dismissTutorial},get coworkStatus(){return B.coworkStatus}})};J(Ge,Re=>{B.tutorialActive&&Re(He)})}T(se,$)};J(Te,se=>{o.ready?se(Ee,-1):se(De)})}T(n,G),Je()}$e(["mousedown","keydown","keyup","click"]);const tw=3,P6="error-boundary-recover-btn",z6="error-boundary-reload-btn";function B6(n,e){qe(e,!0),de(()=>{e.onSuccess()}),Je()}var F6=E('<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>'),H6=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>'),V6=E("<!> <!>",1);function U6(n,e){let t=F(0),r=F(0);var i=Rt(),o=ze(i);Sw(o,{onerror:()=>{b(r,f(r)+1)},failed:(a,l=pr,c=pr)=>{var d=Rt(),u=ze(d);up(u,()=>f(r),h=>{var p=H6(),m=_(x(p),2),v=x(m),g=_(m,2),y=x(g),k=_(g,2);{var S=A=>{var W=F6();Y(()=>Z(W,"data-testid",P6)),P("click",W,()=>{b(t,f(t)+1),c()()}),T(A,W)};J(k,A=>{f(t)<tw&&A(S)})}var C=_(k,2);Y(A=>{te(v,f(t)>=tw?"Recovery attempts exhausted. Reload the page to continue.":"The editor encountered an unexpected error."),te(y,A),Z(C,"data-testid",z6)},[()=>l()instanceof Error?l().message:String(l())]),P("click",C,()=>window.location.reload()),T(h,p)}),T(a,d)}},a=>{var l=V6(),c=ze(l);Wm(c,()=>e.children);var d=_(c,2);B6(d,{onSuccess:()=>{b(t,0)}}),T(a,l)}),T(n,i)}$e(["click"]);function j6(n){U6(n,{children:(e,t)=>{L6(e,{})}})}oT(j6,{target:document.getElementById("root")});export{mt as A,Q6 as B,q6 as C,G6 as D,$e as E,tU as F,X6 as G,ix as T,_ as a,T as b,r1 as c,Je as d,F as e,Z6 as f,f as g,x as h,J as i,Z as j,ze as k,vs as l,$6 as m,te as n,yi as o,qe as p,P as q,b as r,oe as s,Y as t,H as u,E as v,rg as w,Qx as x,n1 as y,eU as z};
|
|
296
|
+
display: flex; align-items: center; gap: 5px;`)}),P("click",r,()=>e.onModeChange("solo")),P("click",s,()=>e.onModeChange("tandem")),T(n,t),Je()}$e(["click"]);const $0=(n,e=pr,t=pr,r=pr)=>{const i=H(()=>t()?`Hide ${e()} panel`:`Show ${e()} panel`);var o=RV();let s;var a=x(o),l=_(x(a));Y(()=>{s=$w(o,1,"icon-btn svelte-12l7ydf",null,s,{active:t()}),Z(o,"data-testid",`titlebar-toggle-${e()}`),Z(o,"aria-label",f(i)),Z(o,"aria-pressed",t()),Z(o,"title",f(i)),Z(l,"x",e()==="left"?1.5:9.5)}),P("click",o,function(...c){var d;(d=r())==null||d.apply(this,c)}),T(n,o)};var RV=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>'),NV=E('<span class="status-dot svelte-12l7ydf" title="Claude is connected" aria-label="Claude is connected"></span>'),IV=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>'),LV=Er('<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>'),PV=Er('<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>'),zV=Er('<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>'),BV=E('<button type="button" class="icon-btn svelte-12l7ydf" data-testid="titlebar-theme-toggle"><!></button>'),FV=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>'),HV=E('<button type="button" class="icon-btn svelte-12l7ydf" data-testid="settings-btn" aria-label="Settings" 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>'),VV=Er('<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>'),UV=Er('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>'),jV=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>'),WV=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 KV(n,e){qe(e,!0);let t=ft(e,"claudeActive",3,!1),r=ft(e,"leftPanelVisible",3,!1),i=ft(e,"rightPanelVisible",3,!1),o=ft(e,"theme",3,"system"),s=ft(e,"showAuthorship",3,!1),a=ft(e,"settingsBtn",15,null),l=F(null),c=F(!1),d=[],u=!0;sf(async()=>{if(Ar())try{const[{invoke:w},{getCurrentWindow:M}]=await Promise.all([Co(()=>import("./core-DhEqZVGG.js"),[]),Co(()=>import("./window-BxBvHL5k.js").then(ue=>ue.w),__vite__mapDeps([0,1]))]);if(!u||(await w("setup_overlay_titlebar").catch(ue=>{console.error("[TitleBar] setup_overlay_titlebar failed:",ue)}),!u))return;const I=M();if(b(l,I,!0),b(c,await I.isMaximized(),!0),!u)return;const ae=await I.onResized(async()=>{try{b(c,await I.isMaximized(),!0)}catch(ue){console.warn("[TitleBar] isMaximized check failed on resize:",ue)}});if(!u){ae();return}d.push(ae);const ve=await I.onMoved(async()=>{try{b(c,await I.isMaximized(),!0)}catch(ue){console.warn("[TitleBar] isMaximized check failed on move:",ue)}});if(!u){ve();return}d.push(ve)}catch(w){console.error("[TitleBar] Window API initialization failed:",w)}}),yi(()=>{u=!1,d.forEach(w=>w())});async function h(){var w;try{await((w=f(l))==null?void 0:w.minimize())}catch(M){console.error("[TitleBar] minimize failed:",M)}}async function p(){var w;try{await((w=f(l))==null?void 0:w.toggleMaximize())}catch(M){console.error("[TitleBar] toggleMaximize failed:",M)}}async function m(){var w;try{await((w=f(l))==null?void 0:w.close())}catch(M){console.error("[TitleBar] close failed:",M)}}const v=H(()=>KH[o()]);var g=WV(),y=_(x(g),4),k=x(y);{var S=w=>{DV(w,{get tandemMode(){return e.tandemMode},get onModeChange(){return e.onModeChange}})};J(k,w=>{e.tandemMode&&e.onModeChange&&w(S)})}var C=_(k,2);{var A=w=>{var M=NV();T(w,M)};J(C,w=>{t()&&w(A)})}var W=_(C,2);{var z=w=>{var M=IV();let I;Y(()=>{I=$w(M,1,"icon-btn svelte-12l7ydf",null,I,{active:s()}),Z(M,"aria-label",s()?"Hide authorship colors":"Show authorship colors"),Z(M,"aria-pressed",s()),Z(M,"title",s()?"Hide authorship colors":"Show authorship colors")}),P("click",M,()=>e.onAuthorshipChange(!s())),T(w,M)};J(W,w=>{e.onAuthorshipChange&&w(z)})}var D=_(W,4);{var O=w=>{$0(w,()=>"left",r,()=>e.onToggleLeftPanel)};J(D,w=>{e.onToggleLeftPanel&&w(O)})}var U=_(D,2);{var ee=w=>{$0(w,()=>"right",i,()=>e.onToggleRightPanel)};J(U,w=>{e.onToggleRightPanel&&w(ee)})}var R=_(U,2);{var K=w=>{var M=BV(),I=x(M);{var ae=le=>{var he=LV();T(le,he)},ve=le=>{var he=PV();T(le,he)},ue=le=>{var he=zV();T(le,he)};J(I,le=>{o()==="light"?le(ae):o()==="dark"?le(ve,1):le(ue,-1)})}Y(()=>{Z(M,"aria-label",f(v)),Z(M,"title",f(v))}),P("click",M,function(...le){var he;(he=e.onCycleTheme)==null||he.apply(this,le)}),T(w,M)};J(R,w=>{e.onCycleTheme&&w(K)})}var ne=_(R,2);{var X=w=>{var M=FV();P("click",M,function(...I){var ae;(ae=e.onOpenHelp)==null||ae.apply(this,I)}),T(w,M)};J(ne,w=>{e.onOpenHelp&&w(X)})}var N=_(ne,2);{var q=w=>{var M=HV();kt(M,I=>a(I),()=>a()),P("click",M,function(...I){var ae;(ae=e.onOpenSettings)==null||ae.apply(this,I)}),T(w,M)};J(N,w=>{e.onOpenSettings&&w(q)})}var L=_(y,2);{var V=w=>{var M=jV(),I=x(M),ae=_(I,2),ve=x(ae);{var ue=B=>{var G=VV();T(B,G)},le=B=>{var G=UV();T(B,G)};J(ve,B=>{f(c)?B(ue):B(le,-1)})}var he=_(ae,2);Y(()=>{I.disabled=f(l)===null,Z(ae,"aria-label",f(c)?"Restore":"Maximize"),ae.disabled=f(l)===null,he.disabled=f(l)===null}),P("click",I,h),P("click",ae,p),P("click",he,m),T(w,M)},re=H(()=>Ar());J(L,w=>{f(re)&&w(V)})}T(n,g),Je()}$e(["click"]);var qV=E('<span style="color: var(--tandem-fg-subtle);"> </span>'),JV=E('<span data-testid="save-indicator" style="color: var(--tandem-accent);">Saving...</span>'),YV=E('<button data-testid="sb-held" title="Show held annotations — switches to Tandem" style="display: inline-flex; align-items: center; gap: var(--tandem-space-1); padding: 1px 8px; font-size: var(--tandem-text-xs); font-weight: 600; border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-pill); background: var(--tandem-warning-bg); color: var(--tandem-warning-fg-strong); cursor: pointer;"><span style="width: 6px; height: 6px; border-radius: 50%; background: var(--tandem-warning-fg-strong); display: inline-block;"></span> </button>'),ZV=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>'),GV=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 XV(n,e){qe(e,!0);let t=ft(e,"documentCount",3,0),r=ft(e,"saving",3,!1);const i=2e3,o=Rk();let s=F(dt(o.userName)),a=F(void 0);de(()=>{const L=o.userName;f(s)!==L&&document.activeElement!==f(a)&&b(s,L,!0)});let l=F(!1),c=F(0),d=Pt(()=>e.connected);de(()=>{const L=d;if(d=e.connected,e.connected&&!L){b(l,!0);const V=setTimeout(()=>{b(l,!1)},i);return()=>clearTimeout(V)}}),de(()=>{if(e.disconnectedSince==null){b(c,0);return}b(c,Math.floor((Date.now()-e.disconnectedSince)/1e3),!0);const L=setInterval(()=>{b(c,Math.floor((Date.now()-(e.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(L)});const u=H(()=>e.connectionStatus==="connecting"),h=H(()=>e.connected?"var(--tandem-success)":f(u)?"var(--tandem-warning)":"var(--tandem-error)"),p=H(()=>f(l)?"Reconnected":e.connectionStatus==="connected"?"Connected":e.connectionStatus==="connecting"?(()=>{const L=["Reconnecting…"];if(e.reconnectAttempts>0||f(c)>0){const V=[];e.reconnectAttempts>0&&V.push(`attempt ${e.reconnectAttempts}`),f(c)>0&&V.push(`${f(c)}s`),L.push(`(${V.join(", ")})`)}return L.join(" ")})():"Disconnected — check that the server is running");function m(){o.setUserName(f(s))}var v=GV(),g=x(v),y=x(g),k=_(y,2),S=x(k),C=_(k,2);{var A=L=>{var V=qV(),re=x(V);Y(()=>te(re,`${t()??""} doc${t()!==1?"s":""} open`)),T(L,V)};J(C,L=>{t()>0&&L(A)})}var W=_(C,2);{var z=L=>{var V=JV();T(L,V)};J(W,L=>{r()&&L(z)})}var D=_(g,2),O=_(x(D),2);kt(O,L=>b(a,L),()=>f(a));var U=_(D,2);{var ee=L=>{var V=YV(),re=_(x(V));Y(()=>te(re,` ${e.heldCount??""} held`)),P("click",V,function(...w){var M;(M=e.onShowHeld)==null||M.apply(this,w)}),T(L,V)};J(U,L=>{(e.heldCount??0)>0&&e.mode==="solo"&&L(ee)})}var R=_(U,2);{var K=L=>{var V=ZV();T(L,V)};J(R,L=>{e.readOnly&&L(K)})}var ne=_(R,2),X=x(ne),N=_(X,2),q=x(N);Y(()=>{se(y,`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"};`),te(S,f(p)),Pr(O,f(s)),Z(O,"maxlength",Gm),se(X,`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"};`),se(N,`transition: color 0.3s ease; color: ${e.claudeActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"};`),te(q,e.claudeStatus?`Claude · ${e.claudeStatus}`:"Claude · idle")}),P("input",O,L=>{b(s,L.target.value,!0)}),wt("blur",O,m),P("keydown",O,L=>{L.key==="Enter"&&L.currentTarget.blur(),L.key==="Escape"&&(b(s,o.userName,!0),L.currentTarget.blur())}),T(n,v),Je()}$e(["input","keydown","click"]);function vv(n,e,t=mA){const r=n.filter(i=>i!==e);return[e,...r].slice(0,t)}function yv(){try{const n=localStorage.getItem(Ym);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 bv(n){try{localStorage.setItem(Ym,JSON.stringify(n)),MS()}catch(e){console.warn("[tandem] failed to save recent files:",e)}}function QV(){try{localStorage.removeItem(Ym),MS()}catch(n){console.warn("[tandem] failed to clear recent files:",n)}}const $V=3e4;let al=null;function ew(){const n=Date.now();if(al&&n-al.ts<$V)return al.files;const e=yv();return al={files:e,ts:n},e}function MS(){al=null}var e6=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>'),t6=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>'),n6=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>'),r6=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>'),i6=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>'),o6=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 s6(n,e){qe(e,!0);let t=F("upload"),r=F(""),i=F(null),o=F(!1),s=F(!1),a=F(void 0),l=F(dt(yv()));function c(R){b(l,(()=>{const K=vv(f(l),R);return bv(K),K})(),!0)}function d(){QV(),b(l,[],!0)}async function u(R){if(!f(o)){b(i,null),b(o,!0);try{const K=await fetch(`${Tr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:R})}),ne=await K.json();if(!K.ok){b(i,ne.message??"Failed to open file",!0);return}c(R),e.onClose()}catch(K){console.error("FileOpenDialog: path open failed",K),K instanceof SyntaxError?b(i,"Server returned an unexpected response"):K 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(R){if(!f(o)){b(i,null),b(o,!0);try{const K=await mx(R),ne=await fetch(`${Tr}/upload`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:R.name,content:K})}),X=await ne.json();if(!ne.ok){b(i,X.message??"Failed to open file",!0);return}e.onClose()}catch(K){console.error("FileOpenDialog: upload failed",K),K instanceof SyntaxError?b(i,"Server returned an unexpected response"):K instanceof TypeError?b(i,"Unexpected response format"):b(i,"Cannot reach server. Is it running?")}finally{b(o,!1)}}}function m(R){var ne;R.preventDefault(),b(s,!1);const K=(ne=R.dataTransfer)==null?void 0:ne.files[0];K&&p(K)}function v(R){var X;const ne=(X=R.target.files)==null?void 0:X[0];ne&&p(ne)}var g=o6();Z(g,"tabindex",-1);var y=x(g),k=x(y),S=_(x(k),2),C=_(k,2),A=x(C),W=_(A,2),z=_(C,2);{var D=R=>{var K=n6(),ne=x(K);UC(ne);var X=_(ne,2),N=x(X),q=_(X,2);{var L=V=>{var re=t6(),w=x(re),M=_(x(w),2),I=_(w,2);mt(I,22,()=>f(l),ae=>ae,(ae,ve,ue)=>{const le=H(()=>ve.split(/[/\\]/)),he=H(()=>f(le).at(-1)??ve),B=H(()=>f(le).slice(0,-1).join("/")||"/");var G=e6(),be=x(G),Te=x(be),De=_(be,2),Ee=x(De);Y(()=>{Z(G,"data-testid",`recent-file-${f(ue)}`),te(Te,f(he)),te(Ee,f(B))}),P("click",G,()=>{b(r,ve,!0),u(ve)}),wt("mouseenter",G,oe=>{oe.currentTarget.style.background="var(--tandem-surface-muted)"}),wt("mouseleave",G,oe=>{oe.currentTarget.style.background="transparent"}),T(ae,G)}),P("click",M,d),T(V,re)};J(q,V=>{f(l).length>0&&V(L)})}Y((V,re)=>{X.disabled=V,se(X,re),te(N,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};`]),P("keydown",ne,V=>{V.key==="Enter"&&h()}),ys(ne,()=>f(r),V=>b(r,V)),P("click",X,h),T(R,K)},O=R=>{var K=r6();Z(K,"tabindex",0);var ne=x(K);kt(ne,q=>b(a,q),()=>f(a));var X=_(ne,2),N=x(X);Y(()=>{se(K,`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;`),te(N,f(o)?"Opening...":"Drop a file here or click to browse")}),wt("dragover",K,q=>{q.preventDefault(),b(s,!0)}),wt("dragleave",K,()=>b(s,!1)),wt("drop",K,m),P("click",K,()=>{var q;return(q=f(a))==null?void 0:q.click()}),P("keydown",K,q=>{var L;(q.key==="Enter"||q.key===" ")&&((L=f(a))==null||L.click())}),P("change",ne,v),T(R,K)};J(z,R=>{f(t)==="path"?R(D):R(O,-1)})}var U=_(z,2);{var ee=R=>{var K=i6(),ne=x(K);Y(()=>te(ne,f(i))),T(R,K)};J(U,R=>{f(i)&&R(ee)})}Y(()=>{se(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)"};`),se(W,`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)"};`)}),P("click",g,R=>{R.target===R.currentTarget&&e.onClose()}),P("keydown",g,R=>{R.key==="Escape"&&e.onClose()}),P("click",S,function(...R){var K;(K=e.onClose)==null||K.apply(this,R)}),P("click",A,()=>b(t,"path")),P("click",W,()=>b(t,"upload")),T(n,g),Je()}$e(["click","keydown","change"]);function Xh(n){return document.body.appendChild(n),{destroy(){n.remove()}}}var a6=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>'),l6=E('<div class="new-tab-menu-divider svelte-7c4il0"></div>'),c6=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 d6(n,e){qe(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 k=o(),S=k.indexOf(document.activeElement);(g=k[(S+1)%k.length])==null||g.focus()}else if(v.key==="ArrowUp"){v.preventDefault();const k=o(),S=k.indexOf(document.activeElement);(y=k[(S-1+k.length)%k.length])==null||y.focus()}}function o(){var v;return Array.from(((v=f(s))==null?void 0:v.querySelectorAll("[role='menuitem']"))??[])}let s=F(null);function a(v){var y,k;const g=v.target;g&&((y=e.anchorEl)!=null&&y.contains(g)||(k=g.closest)!=null&&k.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,k=v.bottom+4,S=v.left;S+g>y-8?(f(s).style.right="8px",f(s).style.left="auto"):(f(s).style.left=`${S}px`,f(s).style.right="auto"),f(s).style.top=`${k}px`}de(()=>{var v;f(s)&&(l(),(v=o()[0])==null||v.focus())});var c=c6(),d=_(x(c),2);mt(d,17,()=>e.recentFiles,ba,(v,g)=>{var y=a6(),k=x(y),S=x(k),C=_(k,2),A=x(C);Y((W,z)=>{Z(y,"title",f(g)),te(S,W),te(A,z)},[()=>r(f(g)),()=>t(f(g))]),P("click",y,()=>e.onOpen(f(g))),T(v,y)});var u=_(d,2);{var h=v=>{var g=l6();T(v,g)};J(u,v=>{e.recentFiles.length>0&&v(h)})}var p=_(u,2),m=_(p,2);Ol(c,v=>Xh==null?void 0:Xh(v)),Ol(c,(v,g)=>mr==null?void 0:mr(v,g),()=>a),kt(c,v=>b(s,v),()=>f(s)),P("keydown",c,i),P("click",p,function(...v){var g;(g=e.onNewScratchpad)==null||g.apply(this,v)}),P("click",m,function(...v){var g;(g=e.onBrowse)==null||g.apply(this,v)}),T(n,c),Je()}$e(["keydown","click"]);var u6=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>'),f6=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 h6(n,e){qe(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=H(()=>r[e.tab.format]??"var(--tandem-fg-faint)");let o=F(!1),s=null;de(()=>{const{ydoc:C,readOnly:A}=e.tab;if(A){b(o,!1);return}const W=C.getXmlFragment("default"),z=C.getMap(md);let D=!1;const O=setTimeout(()=>{D=!0,s=z.get(iy)??0,b(o,!1)},500),U=()=>{D&&b(o,!0)};W.observeDeep(U);const ee=()=>{if(!D)return;const R=z.get(iy);R!==void 0&&R!==s&&(s=R,b(o,!1))};return z.observe(ee),()=>{clearTimeout(O),W.unobserveDeep(U),z.unobserve(ee)}});const a=H(()=>["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=F(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=f6();Z(u,"tabindex",0);var h=x(u),p=_(h,2),m=x(p),v=_(p,2),g=x(v),y=_(v,2);{var k=C=>{var A=u6();T(C,A)};J(y,C=>{e.tab.readOnly&&C(k)})}var S=_(y,2);kt(S,C=>b(l,C),()=>f(l)),Y(C=>{Z(u,"data-testid",`tab-${e.tab.id}`),Z(u,"data-active",e.isActive),Z(u,"aria-selected",e.isActive),Z(u,"aria-label",e.tab.fileName),Z(u,"draggable",e.draggable),se(u,f(a)),Z(h,"data-testid",`unsaved-indicator-${e.tab.id}`),se(h,`color: var(--tandem-warning); font-size: 10px; visibility: ${f(o)?"visible":"hidden"};`),Z(h,"aria-hidden",!f(o)),Z(p,"data-testid",`tab-format-badge-${e.tab.id}`),Z(p,"aria-label",`Format: ${e.tab.format}`),se(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;`),te(m,C),Z(v,"data-testid",`tab-name-${e.tab.id}`),Z(v,"title",e.tab.filePath),se(v,`font-weight: ${e.isActive?500:400}; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),te(g,e.tab.fileName),Z(S,"aria-label",`Close ${e.tab.fileName}`)},[()=>t[e.tab.format]??e.tab.format.toUpperCase()]),P("click",u,()=>e.onswitch(e.tab.id)),wt("dragstart",u,C=>e.ondragstart(C,e.tab.id)),wt("dragover",u,C=>e.ondragover(C,e.tab.id)),wt("drop",u,C=>e.ondrop(C,e.tab.id)),wt("dragend",u,function(...C){var A;(A=e.ondragend)==null||A.apply(this,C)}),wt("dragleave",u,function(...C){var A;(A=e.ondragleave)==null||A.apply(this,C)}),P("keydown",u,C=>e.onkeydown(C,e.tab.id)),P("click",S,C=>{C.stopPropagation(),e.onclose(e.tab.id)}),wt("dragover",S,C=>{C.stopPropagation(),C.preventDefault()}),wt("drop",S,C=>{C.stopPropagation(),C.preventDefault()}),wt("mouseenter",S,c),wt("mouseleave",S,d),T(n,u),Je()}$e(["click","keydown"]);var p6=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>'),m6=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>'),g6=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 v6(n,e){qe(e,!0);const t=ft(e,"reduceMotion",3,!1),r=H(()=>t()?"auto":"smooth");let i=F(!1),o=F(!1),s=F(dt([])),a=F(null),l=new Set;de(()=>{const w=new Set(e.tabs.map(M=>M.id));for(const M of l)w.has(M)||l.delete(M)});function c(w){l.has(w)||(l.add(w),e.onTabClose(w))}let d=F(void 0),u=F(!1),h=F(!1),p=F(null),m=F(null);function v(){b(p,null),b(m,null)}function g(){const w=f(d);w&&(b(u,w.scrollLeft>0),b(h,w.scrollLeft+w.clientWidth<w.scrollWidth-1))}de(()=>{const w=f(d);if(!w)return;g(),w.addEventListener("scroll",g,{passive:!0});const M=new ResizeObserver(g);return M.observe(w),()=>{w.removeEventListener("scroll",g),M.disconnect()}}),de(()=>{e.tabs.length,g()}),de(()=>{if(!e.activeTabId||!f(d))return;const w=f(d).querySelector(`[data-testid="tab-${e.activeTabId}"]`);w&&w.scrollIntoView({inline:"nearest",block:"nearest",behavior:f(r)})}),de(()=>{e.tabs.length,v()});function y(w,M){b(p,M,!0),w.dataTransfer&&(w.dataTransfer.setData("text/plain",M),w.dataTransfer.effectAllowed="move")}function k(w,M){if(w.preventDefault(),!f(p)||f(p)===M){b(m,null);return}const I=w.currentTarget.getBoundingClientRect(),ae=I.left+I.width/2,ve=w.clientX<ae?"left":"right";b(m,{id:M,side:ve},!0)}function S(w,M){var ae;w.preventDefault();const I=(ae=w.dataTransfer)==null?void 0:ae.getData("text/plain");if(I&&I!==M&&e.reorder){const ve=w.currentTarget.getBoundingClientRect(),ue=ve.left+ve.width/2,le=w.clientX<ue?"left":"right";e.reorder(I,M,le)}v()}function C(){v()}function A(){b(m,null)}function W(w,M){if(!w.altKey||!e.reorder||w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault();const I=e.tabs.findIndex(ae=>ae.id===M);I!==-1&&(w.key==="ArrowLeft"&&I>0?e.reorder(M,e.tabs[I-1].id):w.key==="ArrowRight"&&I<e.tabs.length-1&&e.reorder(e.tabs[I+1].id,M))}function z(){var w;(w=f(d))==null||w.scrollBy({left:-150,behavior:f(r)})}function D(){var w;(w=f(d))==null||w.scrollBy({left:150,behavior:f(r)})}const O=H(()=>e.tabs.length<=1);de(()=>{if(!f(o))return;function w(M){var ae,ve,ue;const I=M.target;I&&((ae=f(a))!=null&&ae.contains(I)||(ve=I.closest)!=null&&ve.call(I,".new-tab-menu")||(ue=I.closest)!=null&&ue.call(I,"[data-tauri-drag-region]")||b(o,!1))}return window.addEventListener("pointerdown",w,!0),()=>window.removeEventListener("pointerdown",w,!0)});var U=g6(),ee=x(U);{var R=w=>{var M=p6();P("click",M,z),T(w,M)};J(ee,w=>{f(u)&&w(R)})}var K=_(ee,2);mt(K,21,()=>e.tabs,w=>w.id,(w,M)=>{{let I=H(()=>f(M).id===e.activeTabId),ae=H(()=>!f(O)),ve=H(()=>{var ue;return((ue=f(m))==null?void 0:ue.id)===f(M).id?f(m).side:null});h6(w,{get tab(){return f(M)},get isActive(){return f(I)},get onswitch(){return e.onTabSwitch},onclose:c,get draggable(){return f(ae)},ondragstart:y,ondragover:k,ondrop:S,ondragend:C,ondragleave:A,get dropIndicator(){return f(ve)},onkeydown:W})}}),kt(K,w=>b(d,w),()=>f(d));var ne=_(K,2);kt(ne,w=>b(a,w),()=>f(a));var X=_(ne,2);{var N=w=>{var M=m6();P("click",M,D),T(w,M)};J(X,w=>{f(h)&&w(N)})}var q=_(X,2);{var L=w=>{d6(w,{get recentFiles(){return f(s)},get anchorEl(){return f(a)},onOpen:async M=>{b(o,!1);try{const I=await fetch(`${Tr}/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:M})});if(I.ok)bv(vv(ew(),M));else{const ae=await I.text();console.warn("[tandem] failed to open recent file:",ae)}}catch(I){console.warn("[tandem] failed to open recent file:",I)}},onNewScratchpad:()=>{b(o,!1),Xm()},onBrowse:()=>{b(o,!1),b(i,!0)},onClose:()=>b(o,!1)})};J(q,w=>{f(o)&&w(L)})}var V=_(q,2);{var re=w=>{s6(w,{onClose:()=>b(i,!1)})};J(V,w=>{f(i)&&w(re)})}P("click",ne,()=>{b(s,ew(),!0),b(o,!f(o))}),wt("mouseenter",ne,w=>{w.currentTarget.style.color="var(--tandem-accent)",w.currentTarget.style.borderColor="var(--tandem-accent)"}),wt("mouseleave",ne,w=>{w.currentTarget.style.color="var(--tandem-fg-muted)",w.currentTarget.style.borderColor="var(--tandem-border-strong)"}),T(n,U),Je()}$e(["click"]);var y6=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>'),b6=E("<div><!></div>"),w6=E('<div class="editor-scroll" role="region" aria-label="Document editor"><!> <!> <!></div>'),x6=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>'),k6=E('<button data-testid="annotations-tab"><!> <!></button>'),_6=E('<button data-testid="chat-tab"><!></button>'),S6=E('<button data-testid="outline-tab"><!></button>'),C6=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>'),T6=E('<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>'),A6=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>'),E6=E('<button data-testid="left-annotations-tab"> </button>'),M6=E('<button data-testid="left-chat-tab"> </button>'),O6=E('<button data-testid="left-outline-tab"> </button>'),D6=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),R6=E("<!> <!>",1),N6=E('<!> <!> <!> <!> <!> <div style="display: flex; flex: 1; overflow: hidden; background: var(--tandem-bg);"><!> <!> <!></div> <!> <!> <!> <!> <!> <!> <!>',1),I6=E('<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>');function L6(n,e){qe(e,!0);const t=(oe,$=pr,Q=pr,pe=pr,fe=pr)=>{var Le=y6();Z(Le,"aria-valuemin",0),Z(Le,"aria-valuemax",100),Y(Ie=>{Z(Le,"data-testid",pe()??`${$()}-panel-resize-handle`),Z(Le,"aria-label",$()==="left"?"Resize left panel":"Resize right panel"),Z(Le,"aria-valuenow",Ie)},[()=>fe()!==void 0?Math.round((fe()-ca)/(dc-ca)*100):50]),P("mousedown",Le,function(...Ie){var ye;(ye=Q())==null||ye.apply(this,Ie)}),P("keydown",Le,Ie=>{let Ae=null;Ie.key==="ArrowRight"||Ie.key==="ArrowUp"?Ae=16:Ie.key==="ArrowLeft"||Ie.key==="ArrowDown"?Ae=-16:Ie.key==="PageUp"?Ae=80:Ie.key==="PageDown"?Ae=-80:Ie.key==="Home"?Ae=ca-($()==="left"?q.width:L.width):Ie.key==="End"&&(Ae=dc-($()==="left"?q.width:L.width)),Ae!==null&&(Ie.preventDefault(),Ie.stopPropagation(),$()==="left"?q.handleResizeStep(Ae):L.handleResizeStep(Ae))}),P("keyup",Le,()=>{}),wt("mouseenter",Le,Ie=>{Ie.currentTarget.style.background="var(--tandem-border-strong)"}),wt("mouseleave",Le,Ie=>{Ie.currentTarget.style.background="transparent"}),T(oe,Le)},r=oe=>{var $=w6();{const ye=ke=>{iH(ke,{get ydoc(){return f(he).ydoc},get provider(){return f(he).provider},get readOnly(){return o.readOnly},get currentFilePath(){return f(he).filePath},get activeAnnotationId(){return f(z)},onEditorReady:Ae=>b(U,Ae,!0),onAnnotationClick:Ae=>{b(C,"annotations"),b(z,Ae,!0)},onSlashCommandMenuChange:Ae=>b(ee,Ae,!0)})};var Q=x($);{let ke=H(()=>{var Pe,lt;return((Pe=f(he))==null?void 0:Pe.readOnly)===!0&&((lt=f(he))==null?void 0:lt.format)==="docx"}),Ae=H(()=>{var Pe;return(Pe=f(he))==null?void 0:Pe.id});lN(Q,{get visible(){return f(ke)},get documentId(){return f(Ae)}})}var pe=_(Q,2);{var fe=ke=>{eI(ke,{children:(Ae,Pe)=>{var lt=Rt(),At=ze(lt);up(At,()=>f(he).id,Se=>{ye(Se)}),T(Ae,lt)}})},Le=ke=>{var Ae=b6(),Pe=x(Ae);{var lt=Se=>{var vt=Rt(),zt=ze(vt);up(zt,()=>f(he).id,xe=>{ye(xe)}),T(Se,vt)},At=Se=>{ZE(Se,{get connected(){return o.connected},get claudeActive(){return o.claudeActive}})};J(Pe,Se=>{f(he)?Se(lt):Se(At,-1)})}Y(()=>se(Ae,`max-width: ${f(ve)??"68ch"}; margin: ${f(ue)??"0 auto"};`)),T(ke,Ae)};J(pe,ke=>{var Ae;((Ae=f(he))==null?void 0:Ae.format)==="docx"?ke(fe):ke(Le,-1)})}var Ie=_(pe,2);pH(Ie,{get editor(){return f(U)},get open(){return f(R)},onClose:()=>b(R,!1),get tabs(){return o.tabs}})}Y(()=>se($,`position: relative; flex: 1; overflow: auto; padding: var(--tandem-space-7) var(--tandem-space-5); border: ${p.fileDragOver?"2px dashed var(--tandem-accent)":"2px solid transparent"}; background: ${p.fileDragOver?"var(--tandem-accent-bg)":"var(--tandem-bg)"}; transition: border-color 0.15s, background 0.15s; border-radius: ${p.fileDragOver?"var(--tandem-r-5)":"0"};`)),wt("dragover",$,function(...ye){var ke;(ke=p.handleEditorDragOver)==null||ke.apply(this,ye)}),wt("dragleave",$,function(...ye){var ke;(ke=p.handleEditorDragLeave)==null||ke.apply(this,ye)}),wt("drop",$,function(...ye){var ke;(ke=p.handleEditorDrop)==null||ke.apply(this,ye)}),T(oe,$)},i=(oe,$=pr,Q=pr)=>{const pe=H(()=>a.settings.rightRailTabs),fe=H(()=>f(pe).length>3);var Le=C6(),Ie=x(Le),ye=x(Ie);{var ke=Ge=>{var He=k6(),Re=x(He);{var et=gt=>{var Bt=an("◨");T(gt,Bt)},Ue=gt=>{var Bt=an("Annotations");T(gt,Bt)};J(Re,gt=>{f(fe)?gt(et):gt(Ue,-1)})}var Ve=_(Re,2);{var tt=gt=>{var Bt=x6(),Un=x(Bt);Y(()=>te(Un,f(W)>9?"9+":f(W))),T(gt,Bt)};J(Ve,gt=>{f(C)!=="annotations"&&f(W)>0&>(tt)})}Y(()=>{se(He,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(C)==="annotations"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(C)==="annotations"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; position: relative; white-space: nowrap;`),Z(He,"title",f(fe)?"Annotations":void 0)}),P("click",He,()=>{b(C,"annotations")}),T(Ge,He)},Ae=H(()=>f(pe).includes("annotations"));J(ye,Ge=>{f(Ae)&&Ge(ke)})}var Pe=_(ye,2);{var lt=Ge=>{var He=_6(),Re=x(He);{var et=Ve=>{var tt=an("💬");T(Ve,tt)},Ue=Ve=>{var tt=an("Chat");T(Ve,tt)};J(Re,Ve=>{f(fe)?Ve(et):Ve(Ue,-1)})}Y(()=>{se(He,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(C)==="chat"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(C)==="chat"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(He,"title",f(fe)?"Chat":void 0)}),P("mousedown",He,le),P("click",He,()=>{b(C,"chat")}),T(Ge,He)},At=H(()=>f(pe).includes("chat"));J(Pe,Ge=>{f(At)&&Ge(lt)})}var Se=_(Pe,2);{var vt=Ge=>{var He=S6(),Re=x(He);{var et=Ve=>{var tt=an("≡");T(Ve,tt)},Ue=Ve=>{var tt=an("Outline");T(Ve,tt)};J(Re,Ve=>{f(fe)?Ve(et):Ve(Ue,-1)})}Y(()=>{se(He,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(C)==="outline"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(C)==="outline"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(He,"title",f(fe)?"Outline":void 0)}),P("click",He,()=>{b(C,"outline")}),T(Ge,He)},zt=H(()=>f(pe).includes("outline"));J(Se,Ge=>{f(zt)&&Ge(vt)})}var xe=_(Se,2),Ye=x(xe);{let Ge=H(()=>a.settings.leftRailTabs.length===1?a.settings.leftRailTabs:[]);Q0(Ye,{get enabledTabs(){return a.settings.rightRailTabs},get disabledTabs(){return f(Ge)},onTabsChange:He=>{I("right",He)}})}var bt=_(Ie,2);{let Ge=H(()=>f(C)==="chat"&&f(pe).includes("chat"));Fs(bt,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return f(U)},get activeDocId(){return o.activeTabId},get openDocs(){return f(u)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return f(O)},onCapturedAnchorChange:He=>b(O,He,!0),get reduceMotion(){return a.settings.reduceMotion},get visible(){return f(Ge)}})}var ut=_(bt,2);{let Ge=H(()=>{var Ue;return((Ue=f(he))==null?void 0:Ue.ydoc)??null}),He=H(()=>{var Ue;return(Ue=f(he))==null?void 0:Ue.format}),Re=H(()=>{var Ue;return(Ue=f(he))==null?void 0:Ue.id}),et=H(()=>f(C)==="annotations"&&f(pe).includes("annotations"));Fs(ut,{kind:"side",get annotations(){return f(c).visibleAnnotations},get editor(){return f(U)},get ydoc(){return f(Ge)},get heldCount(){return f(c).heldCount},get tandemMode(){return l.tandemMode},get onModeChange(){return l.setTandemMode},get activeDocFormat(){return f(He)},get documentId(){return f(Re)},get activeAnnotationId(){return f(z)},onActiveAnnotationChange:Ue=>b(z,Ue,!0),get reduceMotion(){return a.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},onFilterChange:(Ue,Ve,tt)=>{b(ne,{type:Ue,author:Ve,status:tt},!0)},get visible(){return f(et)}})}var _t=_(ut,2);{var _n=Ge=>{{let He=H(()=>f(C)==="outline");Fs(Ge,{kind:"outline",get editor(){return f(U)},get annotations(){return f(c).visibleAnnotations},get focusTrigger(){return f(K)},get activeFilterType(){return f(ne).type},get visible(){return f(He)}})}},xt=H(()=>f(pe).includes("outline"));J(_t,Ge=>{f(xt)&&Ge(_n)})}Y(()=>se(Le,`display: flex; flex-direction: column; width: ${$()}px; ${Q()==="left"?"border-right":"border-left"}: 1px solid var(--tandem-border); background: var(--tandem-surface-muted);`)),T(oe,Le)},o=sV();yi(()=>o.destroy());const s=UH(()=>o.tabs);HH(()=>s.orderedTabs,()=>o.activeTabId,oe=>o.setActiveTabId(oe)),de(()=>{const oe=o.tabs;if(oe.length!==0)try{const $=yv();let Q=$;for(const pe of oe)MT(pe.filePath)||(Q=vv(Q,pe.filePath));(Q.length!==$.length||Q.some((pe,fe)=>pe!==$[fe]))&&bv(Q)}catch($){console.warn("[tandem] failed to sync recent files:",$)}});const a=GH(),l=jH(()=>o.bootstrapYdoc,()=>a.settings.selectionDwellMs),c=H(()=>{const oe=o.annotations,$=l.tandemMode,Q=[];let pe=0;for(const fe of oe)PH(fe,$)?Q.push(fe):fe.status==="pending"&&pe++;return{visibleAnnotations:Q,heldCount:pe}}),d=TH(()=>o.disconnectedSince,()=>a.settings.degradedBannerDelayMs);iV();const u=H(()=>o.tabs.map(oe=>({id:oe.id,fileName:oe.fileName}))),h=zH(),p=NH();let m=F(!1),v=F(null),g=F(!1);function y(){b(m,!f(m))}function k(){a.updateSettings({theme:WH[a.settings.theme]})}kA({getActiveTabId:()=>o.activeTabId,openSettings:()=>b(m,!0),toggleSoloMode:()=>l.setTandemMode(l.tandemMode==="solo"?"tandem":"solo"),openFindBar:()=>{}});let S;de(()=>{const oe=f(U);if(!oe)return;const $=a.settings.showAuthorship;if(S===void 0){S=$;return}S!==$&&(S=$,Pt(()=>{const Q=oe.state.tr.setMeta(Js,{type:"toggle",visible:$});oe.view.dispatch(Q)}))}),de(()=>(document.body.classList.toggle("tandem-reduce-motion",a.settings.reduceMotion),()=>document.body.classList.remove("tandem-reduce-motion"))),tV(()=>a.settings.theme),_H(()=>a.settings.accentHue),RH(()=>a.settings.editorFont),EH(()=>a.settings.density),LH(()=>a.settings.highContrast),CH(()=>a.settings.annotationPatterns),de(()=>{const oe=qH[a.settings.textSize];return document.documentElement.style.setProperty("--tandem-editor-font-size",`${oe}px`),()=>document.documentElement.style.removeProperty("--tandem-editor-font-size")});let C=F(dt(a.settings.primaryTab==="chat"?"chat":"annotations")),A=F(dt(a.settings.leftRailTabs[0]??"annotations"));de(()=>{const oe=a.settings.leftRailTabs;oe.includes(f(A))||Pt(()=>{b(A,oe[0]??"annotations",!0)})}),de(()=>{const oe=a.settings.rightRailTabs;oe.includes(f(C))||Pt(()=>{b(C,oe[0]??"chat",!0)})});const W=H(()=>f(C)==="annotations"?0:f(c).visibleAnnotations.filter(Hd).length);let z=F(null),D=F(!1),O=F(null),U=F(null),ee=F(!1),R=F(!1),K=F(0),ne=F(dt({type:"all",author:"all",status:"all"}));const X=W0("left"),N=W0("right"),q=K0({side:"left",initialWidth:X,getVisible:()=>f(V)}),L=K0({side:"right",initialWidth:N,getVisible:()=>f(re)}),V=H(()=>a.settings.leftPanelVisible),re=H(()=>a.settings.rightPanelVisible&&!(l.tandemMode==="solo"&&a.settings.soloRailHidden));function w(){a.updateSettings({leftPanelVisible:!a.settings.leftPanelVisible})}function M(){f(re)?a.updateSettings({rightPanelVisible:!1}):a.updateSettings({rightPanelVisible:!0,...l.tandemMode==="solo"?{soloRailHidden:!1}:{}})}function I(oe,$){const Q=a.settings.leftRailTabs,pe=a.settings.rightRailTabs,fe=oe==="left"?Q:pe,Le=oe==="left"?pe:Q,Ie=$.filter(ke=>!fe.includes(ke));if(Ie.length===0)return a.updateSettings(oe==="left"?{leftRailTabs:$}:{rightRailTabs:$}),!0;const ye=Le.filter(ke=>!Ie.includes(ke));return ye.length===0?(console.warn("[tandem] cross-rail tab move blocked — would leave the %s rail empty",oe==="left"?"right":"left"),!1):(a.updateSettings(oe==="left"?{leftRailTabs:$,rightRailTabs:ye}:{rightRailTabs:$,leftRailTabs:ye}),!0)}function ae(oe,$,Q){b(ne,{type:oe,author:$,status:Q},!0)}const ve=H(()=>a.settings.editorWidthPercent<100?`${a.settings.editorWidthPercent}%`:void 0),ue=H(()=>a.settings.editorWidthPercent<100?"0 auto":void 0);function le(){if(f(C)==="chat"||!f(U))return;const{from:oe,to:$}=f(U).state.selection;if(oe===$)return;const Q=Mk(f(U).state.doc,{from:bn(oe),to:bn($)}),pe=f(U).state.doc.textBetween(oe,$,`
|
|
297
|
+
`);b(O,{...Q,textSnapshot:pe.length>200?pe.slice(0,197)+"...":pe},!0)}de(()=>{function oe($){var Q,pe;if($.key==="?"){const fe=$.target;if(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA"||fe.isContentEditable)return;b(D,Pt(()=>!f(D)),!0);return}if($.ctrlKey||$.metaKey){if($.key==="a"){const fe=document.activeElement;if(fe instanceof HTMLInputElement||fe instanceof HTMLTextAreaElement||(Q=fe==null?void 0:fe.closest)!=null&&Q.call(fe,".ProseMirror"))return;$.preventDefault(),(pe=f(U))==null||pe.commands.selectAll()}else if($.key==="s")$.preventDefault(),vx(o.activeTabId);else if(BH($))$.preventDefault(),b(m,!0);else if($.shiftKey&&$.key==="P")$.preventDefault(),b(g,!Pt(()=>f(g)));else if($.key==="n"){const fe=$.target;if(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA")return;$.preventDefault(),Xm()}else if($.key==="/"){const fe=$.target;if(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA"||fe.isContentEditable)return;$.preventDefault(),b(D,Pt(()=>!f(D)),!0)}}($.ctrlKey||$.metaKey)&&$.key==="f"&&($.preventDefault(),f(V)&&f(A)==="outline"||f(re)&&f(C)==="outline"?b(K,f(K)+1):b(R,!0))}return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)});const he=H(()=>o.tabs.find(oe=>oe.id===o.activeTabId)),B=rV(()=>f(c).visibleAnnotations,()=>f(U),()=>{var oe;return(oe=f(he))==null?void 0:oe.fileName});var G=I6(),be=x(G);KV(be,{get tandemMode(){return l.tandemMode},get onModeChange(){return l.setTandemMode},get claudeActive(){return o.claudeActive},get leftPanelVisible(){return f(V)},onToggleLeftPanel:w,get rightPanelVisible(){return f(re)},onToggleRightPanel:M,get theme(){return a.settings.theme},onCycleTheme:k,get showAuthorship(){return a.settings.showAuthorship},onAuthorshipChange:oe=>a.updateSettings({showAuthorship:oe}),onOpenHelp:()=>b(D,!0),onOpenSettings:y,get settingsBtn(){return f(v)},set settingsBtn(oe){b(v,oe,!0)}});var Te=_(be,2);{var De=oe=>{var $=T6();T(oe,$)},Ee=oe=>{var $=N6(),Q=ze($);{var pe=Re=>{var et=A6();T(Re,et)};J(Q,Re=>{o.serverRestarted&&Re(pe)})}var fe=_(Q,2);{var Le=Re=>{DE(Re,{get onDismiss(){return d.dismiss},onRetry:()=>{o.reconnect()}})};J(fe,Re=>{d.showBanner&&Re(Le)})}var Ie=_(fe,2);{let Re=H(()=>{var Ue;return((Ue=f(he))==null?void 0:Ue.ydoc)??null}),et=H(()=>f(ee)||f(R)||f(g));xH(Ie,{get editor(){return f(U)},get ydoc(){return f(Re)},get selectionToolbar(){return a.settings.selectionToolbar},get suppressSelectionToolbar(){return f(et)}})}var ye=_(Ie,2);v6(ye,{get tabs(){return s.orderedTabs},get activeTabId(){return o.activeTabId},get onTabSwitch(){return o.setActiveTabId},get onTabClose(){return o.handleTabClose},get reorder(){return s.reorder},get reduceMotion(){return a.settings.reduceMotion}});var ke=_(ye,2);{let Re=H(()=>{var et;return((et=f(he))==null?void 0:et.ydoc)??null});AV(ke,{get editor(){return f(U)},get ydoc(){return f(Re)}})}var Ae=_(ke,2),Pe=x(Ae);{var lt=Re=>{const et=H(()=>a.settings.leftRailTabs),Ue=H(()=>f(et).length>3),Ve=H(()=>a.settings.rightRailTabs.length===1?a.settings.rightRailTabs:[]);var tt=D6(),gt=ze(tt),Bt=x(gt),Un=x(Bt);{var on=Kt=>{var qt=E6(),zo=x(qt);Y(()=>{se(qt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(A)==="annotations"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(A)==="annotations"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(qt,"title",f(Ue)?"Annotations":void 0),te(zo,f(Ue)?"◨":"Annotations")}),P("click",qt,()=>{b(A,"annotations")}),T(Kt,qt)},Or=H(()=>f(et).includes("annotations"));J(Un,Kt=>{f(Or)&&Kt(on)})}var Yi=_(Un,2);{var Lo=Kt=>{var qt=M6(),zo=x(qt);Y(()=>{se(qt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(A)==="chat"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(A)==="chat"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(qt,"title",f(Ue)?"Chat":void 0),te(zo,f(Ue)?"💬":"Chat")}),P("click",qt,()=>{b(A,"chat")}),T(Kt,qt)},Po=H(()=>f(et).includes("chat"));J(Yi,Kt=>{f(Po)&&Kt(Lo)})}var Ic=_(Yi,2);{var Lc=Kt=>{var qt=O6(),zo=x(qt);Y(()=>{se(qt,`flex: 1; padding: 0 var(--tandem-space-2); font-size: 12px; font-weight: 500; border: none; border-bottom: ${f(A)==="outline"?"2px solid var(--tandem-accent)":"2px solid transparent"}; background: transparent; cursor: pointer; color: ${f(A)==="outline"?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}; white-space: nowrap;`),Z(qt,"title",f(Ue)?"Outline":void 0),te(zo,f(Ue)?"≡":"Outline")}),P("click",qt,()=>{b(A,"outline")}),T(Kt,qt)},Vf=H(()=>f(et).includes("outline"));J(Ic,Kt=>{f(Vf)&&Kt(Lc)})}var Uf=_(Ic,2),jf=x(Uf);Q0(jf,{get enabledTabs(){return f(et)},get disabledTabs(){return f(Ve)},testIdPrefix:"left-",onTabsChange:Kt=>{I("left",Kt)}});var OS=_(Bt,2),wv=x(OS);{let Kt=H(()=>f(A)==="chat"&&f(et).includes("chat"));Fs(wv,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return f(U)},get activeDocId(){return o.activeTabId},get openDocs(){return f(u)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return f(O)},onCapturedAnchorChange:qt=>b(O,qt,!0),get reduceMotion(){return a.settings.reduceMotion},get visible(){return f(Kt)}})}var xv=_(wv,2);{let Kt=H(()=>{var Kr;return((Kr=f(he))==null?void 0:Kr.ydoc)??null}),qt=H(()=>{var Kr;return(Kr=f(he))==null?void 0:Kr.format}),zo=H(()=>{var Kr;return(Kr=f(he))==null?void 0:Kr.id}),NS=H(()=>f(A)==="annotations"&&f(et).includes("annotations"));Fs(xv,{kind:"side",get annotations(){return f(c).visibleAnnotations},get activeFilterType(){return f(ne).type},get activeFilterAuthor(){return f(ne).author},get activeFilterStatus(){return f(ne).status},onFilterChange:ae,get editor(){return f(U)},get ydoc(){return f(Kt)},get heldCount(){return f(c).heldCount},get tandemMode(){return l.tandemMode},get onModeChange(){return l.setTandemMode},get activeDocFormat(){return f(qt)},get documentId(){return f(zo)},get activeAnnotationId(){return f(z)},onActiveAnnotationChange:Kr=>b(z,Kr,!0),get reduceMotion(){return a.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get visible(){return f(NS)}})}var DS=_(xv,2);{let Kt=H(()=>f(A)==="outline"&&f(et).includes("outline"));Fs(DS,{kind:"outline",get focusTrigger(){return f(K)},get editor(){return f(U)},get visible(){return f(Kt)}})}var RS=_(gt,2);t(RS,()=>"left",()=>Kt=>q.handleResizeStart(Kt),()=>{},()=>q.width),Y(()=>se(gt,`display: flex; flex-direction: column; width: ${q.width}px; border-right: 1px solid var(--tandem-border); background: var(--tandem-surface-muted);`)),T(Re,tt)};J(Pe,Re=>{f(V)&&Re(lt)})}var At=_(Pe,2);r(At);var Se=_(At,2);{var vt=Re=>{var et=R6(),Ue=ze(et);t(Ue,()=>"right",()=>tt=>L.handleResizeStart(tt),()=>"panel-resize-handle",()=>L.width);var Ve=_(Ue,2);i(Ve,()=>L.width,()=>"right"),T(Re,et)};J(Se,Re=>{f(re)&&Re(vt)})}var zt=_(Ae,2);XV(zt,{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 _A.saving},get heldCount(){return f(c).heldCount},get mode(){return l.tandemMode},onShowHeld:()=>l.setTandemMode("tandem")});var xe=_(zt,2);YN(xe,{get open(){return f(m)},onClose:()=>b(m,!1),get settings(){return a.settings},get onUpdate(){return a.updateSettings},get returnFocusEl(){return f(v)},get anchorEl(){return f(v)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts}});var Ye=_(xe,2);eM(Ye,{get open(){return f(D)},onClose:()=>b(D,!1)});var bt=_(Ye,2);ME(bt,{get open(){return f(g)},onClose:()=>b(g,!1),get editor(){return f(U)},get annotations(){return f(c).visibleAnnotations},onFocusAnnotation:Re=>{b(z,Re,!0)}});var ut=_(bt,2);QN(ut,{get toasts(){return h.toasts},get onDismiss(){return h.dismiss}});var _t=_(ut,2);{var _n=Re=>{WE(Re,{})},xt=H(()=>Ar());J(_t,Re=>{f(xt)&&Re(_n)})}var Ge=_(_t,2);{var He=Re=>{pM(Re,{get currentStep(){return B.currentStep},get onNext(){return B.nextStep},get onDismiss(){return B.dismissTutorial},get coworkStatus(){return B.coworkStatus}})};J(Ge,Re=>{B.tutorialActive&&Re(He)})}T(oe,$)};J(Te,oe=>{o.ready?oe(Ee,-1):oe(De)})}T(n,G),Je()}$e(["mousedown","keydown","keyup","click"]);const tw=3,P6="error-boundary-recover-btn",z6="error-boundary-reload-btn";function B6(n,e){qe(e,!0),de(()=>{e.onSuccess()}),Je()}var F6=E('<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>'),H6=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>'),V6=E("<!> <!>",1);function U6(n,e){let t=F(0),r=F(0);var i=Rt(),o=ze(i);Sw(o,{onerror:()=>{b(r,f(r)+1)},failed:(a,l=pr,c=pr)=>{var d=Rt(),u=ze(d);up(u,()=>f(r),h=>{var p=H6(),m=_(x(p),2),v=x(m),g=_(m,2),y=x(g),k=_(g,2);{var S=A=>{var W=F6();Y(()=>Z(W,"data-testid",P6)),P("click",W,()=>{b(t,f(t)+1),c()()}),T(A,W)};J(k,A=>{f(t)<tw&&A(S)})}var C=_(k,2);Y(A=>{te(v,f(t)>=tw?"Recovery attempts exhausted. Reload the page to continue.":"The editor encountered an unexpected error."),te(y,A),Z(C,"data-testid",z6)},[()=>l()instanceof Error?l().message:String(l())]),P("click",C,()=>window.location.reload()),T(h,p)}),T(a,d)}},a=>{var l=V6(),c=ze(l);Wm(c,()=>e.children);var d=_(c,2);B6(d,{onSuccess:()=>{b(t,0)}}),T(a,l)}),T(n,i)}$e(["click"]);function j6(n){U6(n,{children:(e,t)=>{L6(e,{})}})}oT(j6,{target:document.getElementById("root")});export{mt as A,Q6 as B,q6 as C,G6 as D,$e as E,tU as F,X6 as G,ix as T,_ as a,T as b,r1 as c,Je as d,F as e,Z6 as f,f as g,x as h,J as i,Z as j,ze as k,vs as l,$6 as m,te as n,yi as o,qe as p,P as q,b as r,se as s,Y as t,H as u,E as v,rg as w,Qx as x,n1 as y,eU as z};
|