tandem-editor 0.11.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +3 -3
- package/CHANGELOG.md +201 -72
- package/README.md +141 -238
- package/dist/channel/index.js +211 -81
- package/dist/channel/index.js.map +1 -1
- package/dist/cli/index.js +749 -170
- package/dist/cli/index.js.map +1 -1
- package/dist/client/assets/CoworkSettings-BOYbyKul.js +3 -0
- package/dist/client/assets/event-CNdo2oXa.js +1 -0
- package/dist/client/assets/index-D8uS4cj7.css +1 -0
- package/dist/client/assets/index-Dm_QtxGQ.js +1 -0
- package/dist/client/assets/index-g-KwmRn9.js +271 -0
- package/dist/client/assets/webview-KiZyy_pC.js +1 -0
- package/dist/client/assets/window-DePn7tLG.js +1 -0
- package/dist/client/fonts/OFL-Hanuman.txt +93 -0
- package/dist/client/fonts/OFL-InterTight.txt +93 -0
- package/dist/client/fonts/OFL-JetBrainsMono.txt +93 -0
- package/dist/client/fonts/OFL-SNPro.txt +93 -0
- package/dist/client/fonts/OFL-Sono.txt +93 -0
- package/dist/client/fonts/OFL-SourceSerif4.txt +93 -0
- package/dist/client/fonts/hanuman-latin.woff2 +0 -0
- package/dist/client/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/dist/client/fonts/sn-pro-latin.woff2 +0 -0
- package/dist/client/fonts/sono-latin.woff2 +0 -0
- package/dist/client/fonts/source-serif-4-latin.woff2 +0 -0
- package/dist/client/index.html +206 -17
- package/dist/client/logo.png +0 -0
- package/dist/monitor/index.js +241 -160
- package/dist/monitor/index.js.map +1 -1
- package/dist/server/index.js +22828 -19659
- package/dist/server/index.js.map +1 -1
- package/package.json +12 -4
- package/sample/welcome.md +6 -6
- package/skills/tandem/SKILL.md +15 -0
- package/dist/client/assets/CoworkSettings-DK3jjdwK.js +0 -3
- package/dist/client/assets/index-CfT503n4.js +0 -297
- package/dist/client/assets/index-DeJe09pn.css +0 -1
- package/dist/client/assets/webview-Ben21ZLJ.js +0 -1
- package/dist/client/assets/window-BxBvHL5k.js +0 -1
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dm_QtxGQ.js","assets/core-DhEqZVGG.js","assets/webview-KiZyy_pC.js","assets/window-DePn7tLG.js","assets/event-CNdo2oXa.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var BE=Object.defineProperty;var Eb=t=>{throw TypeError(t)};var VE=(t,e,n)=>e in t?BE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var pn=(t,e,n)=>VE(t,typeof e!="symbol"?e+"":e,n),kp=(t,e,n)=>e.has(t)||Eb("Cannot "+n);var ne=(t,e,n)=>(kp(t,e,"read from private field"),n?n.call(t):e.get(t)),Ze=(t,e,n)=>e.has(t)?Eb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Qe=(t,e,n,r)=>(kp(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),mt=(t,e,n)=>(kp(t,e,"access private method"),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();const xx=!1;var Av=Array.isArray,HE=Array.prototype.indexOf,el=Array.prototype.includes,Eh=Array.from,UE=Object.defineProperty,Go=Object.getOwnPropertyDescriptor,kx=Object.getOwnPropertyDescriptors,jE=Object.prototype,WE=Array.prototype,Mv=Object.getPrototypeOf,Ab=Object.isExtensible;function wa(t){return typeof t=="function"}const ur=()=>{};function KE(t){return typeof(t==null?void 0:t.then)=="function"}function qE(t){for(var e=0;e<t.length;e++)t[e]()}function _x(){var t,e,n=new Promise((r,i)=>{t=r,e=i});return{promise:n,resolve:t,reject:e}}function Mb(t,e){if(Array.isArray(t))return t;if(!(Symbol.iterator in t))return Array.from(t);const n=[];for(const r of t)if(n.push(r),n.length===e)break;return n}const In=2,tl=4,Ah=8,Sx=1<<24,Ur=16,di=32,mo=64,Vm=128,jr=512,fn=1024,vn=2048,Ni=4096,Xn=8192,Wr=16384,cs=32768,Hm=1<<25,go=65536,nf=1<<17,GE=1<<18,aa=1<<19,JE=1<<20,Ti=1<<25,qs=65536,rf=1<<21,Ia=1<<22,Jo=1<<23,Oi=Symbol("$state"),Cx=Symbol("legacy props"),YE=Symbol(""),Au=Symbol("attributes"),Um=Symbol("class"),jm=Symbol("style"),Kl=Symbol("text"),Mu=Symbol("form reset"),Mh=new class extends Error{constructor(){super(...arguments);pn(this,"name","StaleReactionError");pn(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var yx;const ZE=!!((yx=globalThis.document)!=null&&yx.contentType)&&globalThis.document.contentType.includes("xml");function Tx(t){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function XE(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function QE(t,e,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function $E(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function eA(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function tA(t){throw new Error("https://svelte.dev/e/effect_orphan")}function nA(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function rA(t){throw new Error("https://svelte.dev/e/props_invalid_value")}function iA(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function oA(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function sA(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function aA(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const lA=1,cA=2,Ex=4,dA=8,uA=16,fA=1,hA=2,pA=4,mA=8,gA=16,vA=4,yA=1,bA=2,dn=Symbol(),Ax="http://www.w3.org/1999/xhtml",wA="http://www.w3.org/2000/svg",xA="http://www.w3.org/1998/Math/MathML";function kA(){console.warn("https://svelte.dev/e/derived_inert")}function _A(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function SA(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Mx(t){return t===this.v}function Ox(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function Dx(t){return!Ox(t,this.v)}let kl=!1,CA=!1;function TA(){kl=!0}let $t=null;function nl(t){$t=t}function Pe(t,e=!1,n){$t={p:$t,i:!1,c:null,e:null,s:t,x:null,r:at,l:kl&&!e?{s:null,u:null,$:[]}:null}}function Le(t){var e=$t,n=e.e;if(n!==null){e.e=null;for(var r of n)ek(r)}return t!==void 0&&(e.x=t),e.i=!0,$t=e.p,t??{}}function la(){return!kl||$t!==null&&$t.l===null}let ws=[];function Ix(){var t=ws;ws=[],qE(t)}function ci(t){if(ws.length===0&&!Ra){var e=ws;queueMicrotask(()=>{e===ws&&Ix()})}ws.push(t)}function EA(){for(;ws.length>0;)Ix()}function Rx(t){var e=at;if(e===null)return ht.f|=Jo,t;if((e.f&cs)===0&&(e.f&tl)===0)throw t;Uo(t,e)}function Uo(t,e){for(;e!==null;){if((e.f&Vm)!==0){if((e.f&cs)===0)throw t;try{e.b.error(t);return}catch(n){t=n}}e=e.parent}throw t}const AA=-7169;function Xt(t,e){t.f=t.f&AA|e}function Ov(t){(t.f&jr)!==0||t.deps===null?Xt(t,fn):Xt(t,Ni)}function Nx(t){if(t!==null)for(const e of t)(e.f&In)===0||(e.f&qs)===0||(e.f^=qs,Nx(e.deps))}function Px(t,e,n){(t.f&vn)!==0?e.add(t):(t.f&Ni)!==0&&n.add(t),Nx(t.deps),Xt(t,fn)}let Jd=!1;function MA(t){var e=Jd;try{return Jd=!1,[t(),Jd]}finally{Jd=e}}let _p=null,ga=null,je=null,nc=null,Tn=null,Wm=null,Ra=!1,Sp=!1,Aa=null,Ou=null;var Ob=0;let OA=1;var qa,Fo,Ms,Ga,Ja,Os,Ya,ro,fd,xr,hd,Bo,_i,Si,Za,Xa,kt,Km,ql,qm,Lx,zx,Du,DA,Gm,xa;const xh=class xh{constructor(){Ze(this,kt);pn(this,"id",OA++);Ze(this,qa,!1);pn(this,"linked",!0);Ze(this,Fo,null);Ze(this,Ms,null);pn(this,"async_deriveds",new Map);pn(this,"current",new Map);pn(this,"previous",new Map);pn(this,"unblocked",new Set);Ze(this,Ga,new Set);Ze(this,Ja,new Set);Ze(this,Os,new Set);Ze(this,Ya,0);Ze(this,ro,new Map);Ze(this,fd,null);Ze(this,xr,[]);Ze(this,hd,[]);Ze(this,Bo,new Set);Ze(this,_i,new Set);Ze(this,Si,new Map);Ze(this,Za,new Set);pn(this,"is_fork",!1);Ze(this,Xa,!1)}skip_effect(e){ne(this,Si).has(e)||ne(this,Si).set(e,{d:[],m:[]}),ne(this,Za).delete(e)}unskip_effect(e,n=r=>this.schedule(r)){var r=ne(this,Si).get(e);if(r){ne(this,Si).delete(e);for(var i of r.d)Xt(i,vn),n(i);for(i of r.m)Xt(i,Ni),n(i)}ne(this,Za).add(e)}capture(e,n,r=!1){e.v!==dn&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&Jo)===0&&(this.current.set(e,[n,r]),Tn==null||Tn.set(e,n)),this.is_fork||(e.v=n)}activate(){je=this}deactivate(){je=null,Tn=null}flush(){try{Sp=!0,je=this,mt(this,kt,ql).call(this)}finally{Ob=0,Wm=null,Aa=null,Ou=null,Sp=!1,je=null,Tn=null,Ns.clear()}}discard(){for(const e of ne(this,Ja))e(this);ne(this,Ja).clear(),ne(this,Os).clear(),mt(this,kt,xa).call(this)}register_created_effect(e){ne(this,hd).push(e)}increment(e,n){if(Qe(this,Ya,ne(this,Ya)+1),e){let r=ne(this,ro).get(n)??0;ne(this,ro).set(n,r+1)}}decrement(e,n){if(Qe(this,Ya,ne(this,Ya)-1),e){let r=ne(this,ro).get(n)??0;r===1?ne(this,ro).delete(n):ne(this,ro).set(n,r-1)}ne(this,Xa)||(Qe(this,Xa,!0),ci(()=>{Qe(this,Xa,!1),this.linked&&this.flush()}))}transfer_effects(e,n){for(const r of e)ne(this,Bo).add(r);for(const r of n)ne(this,_i).add(r);e.clear(),n.clear()}oncommit(e){ne(this,Ga).add(e)}ondiscard(e){ne(this,Ja).add(e)}on_fork_commit(e){ne(this,Os).add(e)}run_fork_commit_callbacks(){for(const e of ne(this,Os))e(this);ne(this,Os).clear()}settled(){return(ne(this,fd)??Qe(this,fd,_x())).promise}static ensure(){var e;if(je===null){const n=je=new xh;mt(e=n,kt,Gm).call(e),!Sp&&!Ra&&ci(()=>{ne(n,qa)||n.flush()})}return je}apply(){{Tn=null;return}}schedule(e){var i;if(Wm=e,(i=e.b)!=null&&i.is_pending&&(e.f&(tl|Ah|Sx))!==0&&(e.f&cs)===0){e.b.defer_effect(e);return}for(var n=e;n.parent!==null;){n=n.parent;var r=n.f;if(Aa!==null&&n===at&&(ht===null||(ht.f&In)===0))return;if((r&(mo|di))!==0){if((r&fn)===0)return;n.f^=fn}}ne(this,xr).push(n)}};qa=new WeakMap,Fo=new WeakMap,Ms=new WeakMap,Ga=new WeakMap,Ja=new WeakMap,Os=new WeakMap,Ya=new WeakMap,ro=new WeakMap,fd=new WeakMap,xr=new WeakMap,hd=new WeakMap,Bo=new WeakMap,_i=new WeakMap,Si=new WeakMap,Za=new WeakMap,Xa=new WeakMap,kt=new WeakSet,Km=function(){if(this.is_fork)return!0;for(const r of ne(this,ro).keys()){for(var e=r,n=!1;e.parent!==null;){if(ne(this,Si).has(e)){n=!0;break}e=e.parent}if(!n)return!0}return!1},ql=function(){var l,c,d,f;if(Qe(this,qa,!0),Ob++>1e3&&(mt(this,kt,xa).call(this),IA()),!mt(this,kt,Km).call(this)){for(const h of ne(this,Bo))ne(this,_i).delete(h),Xt(h,vn),this.schedule(h);for(const h of ne(this,_i))Xt(h,Ni),this.schedule(h)}const e=ne(this,xr);Qe(this,xr,[]),this.apply();var n=Aa=[],r=[],i=Ou=[];for(const h of e)try{mt(this,kt,qm).call(this,h,n,r)}catch(p){throw Hx(h),p}if(je=null,i.length>0){var o=xh.ensure();for(const h of i)o.schedule(h)}if(Aa=null,Ou=null,mt(this,kt,Km).call(this)){mt(this,kt,Du).call(this,r),mt(this,kt,Du).call(this,n);for(const[h,p]of ne(this,Si))Vx(h,p);i.length>0&&mt(l=je,kt,ql).call(l);return}const s=mt(this,kt,Lx).call(this);if(s){mt(c=s,kt,zx).call(c,this);return}ne(this,Bo).clear(),ne(this,_i).clear();for(const h of ne(this,Ga))h(this);ne(this,Ga).clear(),nc=this,Db(r),Db(n),nc=null,(d=ne(this,fd))==null||d.resolve();var a=je;if(this.linked&&ne(this,Ya)===0&&mt(this,kt,xa).call(this),ne(this,xr).length>0){a===null&&(a=this,mt(this,kt,Gm).call(this));const h=a;ne(h,xr).push(...ne(this,xr).filter(p=>!ne(h,xr).includes(p)))}a!==null&&mt(f=a,kt,ql).call(f)},qm=function(e,n,r){e.f^=fn;for(var i=e.first;i!==null;){var o=i.f,s=(o&(di|mo))!==0,a=s&&(o&fn)!==0,l=a||(o&Xn)!==0||ne(this,Si).has(i);if(!l&&i.fn!==null){s?i.f^=fn:(o&tl)!==0?n.push(i):_d(i)&&((o&Ur)!==0&&ne(this,_i).add(i),rl(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}}},Lx=function(){for(var e=ne(this,Fo);e!==null;){if(!e.is_fork){for(const[n,[,r]]of this.current)if(e.current.has(n)&&!r)return e}e=ne(e,Fo)}return null},zx=function(e){var r;for(const[i,o]of e.current)!this.previous.has(i)&&e.previous.has(i)&&this.previous.set(i,e.previous.get(i)),this.current.set(i,o);for(const[i,o]of e.async_deriveds){const s=this.async_deriveds.get(i);s&&o.promise.then(s.resolve)}const n=i=>{var o=i.reactions;if(o!==null)for(const l of o){var s=l.f;if((s&In)!==0)n(l);else{var a=l;s&(Ia|Ur)&&!this.async_deriveds.has(a)&&(ne(this,_i).delete(a),Xt(a,vn),this.schedule(a))}}};for(const i of this.current.keys())n(i);this.oncommit(()=>e.discard()),mt(r=e,kt,xa).call(r),je=this,mt(this,kt,ql).call(this)},Du=function(e){for(var n=0;n<e.length;n+=1)Px(e[n],ne(this,Bo),ne(this,_i))},DA=function(){var d;mt(this,kt,xa).call(this);for(let f=_p;f!==null;f=ne(f,Ms)){var e=f.id<this.id,n=[];for(const[h,[p,m]]of this.current){if(f.current.has(h)){var r=f.current.get(h)[0];if(e&&p!==r)f.current.set(h,[p,m]);else continue}n.push(h)}if(e)for(const[h,p]of this.async_deriveds){const m=f.async_deriveds.get(h);m&&p.promise.then(m.resolve)}if(ne(f,qa)){var i=[...f.current.keys()].filter(h=>!this.current.has(h));if(i.length===0)e&&f.discard();else if(n.length>0){if(e)for(const h of ne(this,Za))f.unskip_effect(h,p=>{var m;(p.f&(Ur|Ia))!==0?f.schedule(p):mt(m=f,kt,Du).call(m,[p])});f.activate();var o=new Set,s=new Map;for(var a of n)Bx(a,i,o,s);s=new Map;var l=[...f.current.keys()].filter(h=>this.current.has(h)?this.current.get(h)[0]!==h.v:!0);if(l.length>0)for(const h of ne(this,hd))(h.f&(Wr|Xn|nf))===0&&Dv(h,l,s)&&((h.f&(Ia|Ur))!==0?(Xt(h,vn),f.schedule(h)):ne(f,Bo).add(h));if(ne(f,xr).length>0){f.apply();for(var c of ne(f,xr))mt(d=f,kt,qm).call(d,c,[],[]);Qe(f,xr,[])}f.deactivate()}}}},Gm=function(){ga===null?_p=ga=this:(Qe(ga,Ms,this),Qe(this,Fo,ga)),ga=this},xa=function(){var e=ne(this,Fo),n=ne(this,Ms);e===null?_p=n:Qe(e,Ms,n),n===null?ga=e:Qe(n,Fo,e),this.linked=!1};let vo=xh;function Fx(t){var e=Ra;Ra=!0;try{for(var n;;){if(EA(),je===null)return n;je.flush()}}finally{Ra=e}}function IA(){try{nA()}catch(t){Uo(t,Wm)}}let ii=null;function Db(t){var e=t.length;if(e!==0){for(var n=0;n<e;){var r=t[n++];if((r.f&(Wr|Xn))===0&&_d(r)&&(ii=new Set,rl(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&rk(r),(ii==null?void 0:ii.size)>0)){Ns.clear();for(const i of ii){if((i.f&(Wr|Xn))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)ii.has(s)&&(ii.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){const l=o[a];(l.f&(Wr|Xn))===0&&rl(l)}}ii.clear()}}ii=null}}function Bx(t,e,n,r){if(!n.has(t)&&(n.add(t),t.reactions!==null))for(const i of t.reactions){const o=i.f;(o&In)!==0?Bx(i,e,n,r):(o&(Ia|Ur))!==0&&(o&vn)===0&&Dv(i,e,r)&&(Xt(i,vn),Iv(i))}}function Dv(t,e,n){const r=n.get(t);if(r!==void 0)return r;if(t.deps!==null)for(const i of t.deps){if(el.call(e,i))return!0;if((i.f&In)!==0&&Dv(i,e,n))return n.set(i,!0),!0}return n.set(t,!1),!1}function Iv(t){je.schedule(t)}function Vx(t,e){if(!((t.f&di)!==0&&(t.f&fn)!==0)){(t.f&vn)!==0?e.d.push(t):(t.f&Ni)!==0&&e.m.push(t),Xt(t,fn);for(var n=t.first;n!==null;)Vx(n,e),n=n.next}}function Hx(t){Xt(t,fn);for(var e=t.first;e!==null;)Hx(e),e=e.next}function RA(t){let e=0,n=yo(0),r;return()=>{Lv()&&(u(n),kd(()=>(e===0&&(r=vt(()=>t(()=>rc(n)))),e+=1,()=>{ci(()=>{e-=1,e===0&&(r==null||r(),r=void 0,rc(n))})})))}}var NA=go|aa;function Ux(t,e,n,r){new PA(t,e,n,r)}var Nr,Ev,Pr,Ds,lr,Lr,Zn,kr,io,Is,Vo,Qa,pd,md,oo,kh,en,LA,zA,FA,Jm,Iu,Ru,Ym,Zm;class PA{constructor(e,n,r,i){Ze(this,en);pn(this,"parent");pn(this,"is_pending",!1);pn(this,"transform_error");Ze(this,Nr);Ze(this,Ev,null);Ze(this,Pr);Ze(this,Ds);Ze(this,lr);Ze(this,Lr,null);Ze(this,Zn,null);Ze(this,kr,null);Ze(this,io,null);Ze(this,Is,0);Ze(this,Vo,0);Ze(this,Qa,!1);Ze(this,pd,new Set);Ze(this,md,new Set);Ze(this,oo,null);Ze(this,kh,RA(()=>(Qe(this,oo,yo(ne(this,Is))),()=>{Qe(this,oo,null)})));var o;Qe(this,Nr,e),Qe(this,Pr,n),Qe(this,Ds,s=>{var a=at;a.b=this,a.f|=Vm,r(s)}),this.parent=at.b,this.transform_error=i??((o=this.parent)==null?void 0:o.transform_error)??(s=>s),Qe(this,lr,ca(()=>{mt(this,en,Jm).call(this)},NA))}defer_effect(e){Px(e,ne(this,pd),ne(this,md))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!ne(this,Pr).pending}update_pending_count(e,n){mt(this,en,Ym).call(this,e,n),Qe(this,Is,ne(this,Is)+e),!(!ne(this,oo)||ne(this,Qa))&&(Qe(this,Qa,!0),ci(()=>{Qe(this,Qa,!1),ne(this,oo)&&lo(ne(this,oo),ne(this,Is))}))}get_effect_pending(){return ne(this,kh).call(this),u(ne(this,oo))}error(e){if(!ne(this,Pr).onerror&&!ne(this,Pr).failed)throw e;je!=null&&je.is_fork?(ne(this,Lr)&&je.skip_effect(ne(this,Lr)),ne(this,Zn)&&je.skip_effect(ne(this,Zn)),ne(this,kr)&&je.skip_effect(ne(this,kr)),je.on_fork_commit(()=>{mt(this,en,Zm).call(this,e)})):mt(this,en,Zm).call(this,e)}}Nr=new WeakMap,Ev=new WeakMap,Pr=new WeakMap,Ds=new WeakMap,lr=new WeakMap,Lr=new WeakMap,Zn=new WeakMap,kr=new WeakMap,io=new WeakMap,Is=new WeakMap,Vo=new WeakMap,Qa=new WeakMap,pd=new WeakMap,md=new WeakMap,oo=new WeakMap,kh=new WeakMap,en=new WeakSet,LA=function(){try{Qe(this,Lr,zr(()=>ne(this,Ds).call(this,ne(this,Nr))))}catch(e){this.error(e)}},zA=function(e){const n=ne(this,Pr).failed;n&&Qe(this,kr,zr(()=>{n(ne(this,Nr),()=>e,()=>()=>{})}))},FA=function(){const e=ne(this,Pr).pending;e&&(this.is_pending=!0,Qe(this,Zn,zr(()=>e(ne(this,Nr)))),ci(()=>{var n=Qe(this,io,document.createDocumentFragment()),r=co();n.append(r),Qe(this,Lr,mt(this,en,Ru).call(this,()=>zr(()=>ne(this,Ds).call(this,r)))),ne(this,Vo)===0&&(ne(this,Nr).before(n),Qe(this,io,null),Ps(ne(this,Zn),()=>{Qe(this,Zn,null)}),mt(this,en,Iu).call(this,je))}))},Jm=function(){try{if(this.is_pending=this.has_pending_snippet(),Qe(this,Vo,0),Qe(this,Is,0),Qe(this,Lr,zr(()=>{ne(this,Ds).call(this,ne(this,Nr))})),ne(this,Vo)>0){var e=Qe(this,io,document.createDocumentFragment());Vv(ne(this,Lr),e);const n=ne(this,Pr).pending;Qe(this,Zn,zr(()=>n(ne(this,Nr))))}else mt(this,en,Iu).call(this,je)}catch(n){this.error(n)}},Iu=function(e){this.is_pending=!1,e.transfer_effects(ne(this,pd),ne(this,md))},Ru=function(e){var n=at,r=ht,i=$t;Pi(ne(this,lr)),Zr(ne(this,lr)),nl(ne(this,lr).ctx);try{return vo.ensure(),e()}catch(o){return Rx(o),null}finally{Pi(n),Zr(r),nl(i)}},Ym=function(e,n){var r;if(!this.has_pending_snippet()){this.parent&&mt(r=this.parent,en,Ym).call(r,e,n);return}Qe(this,Vo,ne(this,Vo)+e),ne(this,Vo)===0&&(mt(this,en,Iu).call(this,n),ne(this,Zn)&&Ps(ne(this,Zn),()=>{Qe(this,Zn,null)}),ne(this,io)&&(ne(this,Nr).before(ne(this,io)),Qe(this,io,null)))},Zm=function(e){ne(this,Lr)&&(Qn(ne(this,Lr)),Qe(this,Lr,null)),ne(this,Zn)&&(Qn(ne(this,Zn)),Qe(this,Zn,null)),ne(this,kr)&&(Qn(ne(this,kr)),Qe(this,kr,null));var n=ne(this,Pr).onerror;let r=ne(this,Pr).failed;var i=!1,o=!1;const s=()=>{if(i){SA();return}i=!0,o&&aA(),ne(this,kr)!==null&&Ps(ne(this,kr),()=>{Qe(this,kr,null)}),mt(this,en,Ru).call(this,()=>{mt(this,en,Jm).call(this)})},a=l=>{try{o=!0,n==null||n(l,s),o=!1}catch(c){Uo(c,ne(this,lr)&&ne(this,lr).parent)}r&&Qe(this,kr,mt(this,en,Ru).call(this,()=>{try{return zr(()=>{var c=at;c.b=this,c.f|=Vm,r(ne(this,Nr),()=>l,()=>s)})}catch(c){return Uo(c,ne(this,lr).parent),null}}))};ci(()=>{var l;try{l=this.transform_error(e)}catch(c){Uo(c,ne(this,lr)&&ne(this,lr).parent);return}l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(a,c=>Uo(c,ne(this,lr)&&ne(this,lr).parent)):a(l)})};function BA(t,e,n,r){const i=la()?Cc:Rv;var o=t.filter(h=>!h.settled);if(n.length===0&&o.length===0){r(e.map(i));return}var s=at,a=jx(),l=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(h=>h.promise)):null;function c(h){if((s.f&Wr)===0){a();try{r(h)}catch(p){Uo(p,s)}Sc()}}var d=Wx();if(n.length===0){l.then(()=>c(e.map(i))).finally(d);return}function f(){Promise.all(n.map(h=>VA(h))).then(h=>c([...e.map(i),...h])).catch(h=>Uo(h,s)).finally(d)}l?l.then(()=>{a(),f(),Sc()}):f()}function jx(){var t=at,e=ht,n=$t,r=je;return function(o=!0){Pi(t),Zr(e),nl(n),o&&(t.f&Wr)===0&&(r==null||r.activate(),r==null||r.apply())}}function Sc(t=!0){Pi(null),Zr(null),nl(null),t&&(je==null||je.deactivate())}function Wx(){var t=at,e=t.b,n=je,r=e.is_rendered();return e.update_pending_count(1,n),n.increment(r,t),()=>{e.update_pending_count(-1,n),n.decrement(r,t)}}function Cc(t){var e=In|vn;return at!==null&&(at.f|=aa),{ctx:$t,deps:null,effects:null,equals:Mx,f:e,fn:t,reactions:null,rv:0,v:dn,wv:0,parent:at,ac:null}}const Yd=Symbol("obsolete");function VA(t,e,n){let r=at;r===null&&XE();var i=void 0,o=yo(dn),s=!ht,a=new Set;return $A(()=>{var p;var l=at,c=_x();i=c.promise;try{Promise.resolve(t()).then(c.resolve,m=>{m!==Mh&&c.reject(m)}).finally(Sc)}catch(m){c.reject(m),Sc()}var d=je;if(s){if((l.f&cs)!==0)var f=Wx();if(r.b.is_rendered())(p=d.async_deriveds.get(l))==null||p.reject(Yd);else for(const m of a.values())m.reject(Yd);a.add(c),d.async_deriveds.set(l,c)}const h=(m,v=void 0)=>{f==null||f(),a.delete(c),v!==Yd&&(d.activate(),v?(o.f|=Jo,lo(o,v)):((o.f&Jo)!==0&&(o.f^=Jo),lo(o,m)),d.deactivate())};c.promise.then(h,m=>h(null,m||"unknown"))}),zv(()=>{for(const l of a)l.reject(Yd)}),new Promise(l=>{function c(d){function f(){d===i?l(o):c(i)}d.then(f,f)}c(i)})}function F(t){const e=Cc(t);return sk(e),e}function Rv(t){const e=Cc(t);return e.equals=Dx,e}function HA(t){var e=t.effects;if(e!==null){t.effects=null;for(var n=0;n<e.length;n+=1)Qn(e[n])}}function Nv(t){var e,n=at,r=t.parent;if(!bo&&r!==null&&(r.f&(Wr|Xn))!==0)return kA(),t.v;Pi(r);try{t.f&=~qs,HA(t),e=dk(t)}finally{Pi(n)}return e}function Kx(t){var e=Nv(t);if(!t.equals(e)&&(t.wv=lk(),(!(je!=null&&je.is_fork)||t.deps===null)&&(je!==null?(je.capture(t,e,!0),nc==null||nc.capture(t,e,!0)):t.v=e,t.deps===null))){Xt(t,fn);return}bo||(Tn!==null?(Lv()||je!=null&&je.is_fork)&&Tn.set(t,e):Ov(t))}function UA(t){var e,n;if(t.effects!==null)for(const r of t.effects)(r.teardown||r.ac)&&((e=r.teardown)==null||e.call(r),(n=r.ac)==null||n.abort(Mh),r.teardown=ur,r.ac=null,Ec(r,0),Fv(r))}function qx(t){if(t.effects!==null)for(const e of t.effects)e.teardown&&rl(e)}let of=new Set;const Ns=new Map;let Gx=!1;function yo(t,e){var n={f:0,v:t,reactions:null,equals:Mx,rv:0,wv:0};return n}function I(t,e){const n=yo(t);return sk(n),n}function Xm(t,e=!1,n=!0){var i;const r=yo(t);return e||(r.equals=Dx),kl&&n&&$t!==null&&$t.l!==null&&((i=$t.l).s??(i.s=[])).push(r),r}function y(t,e,n=!1){ht!==null&&(!ai||(ht.f&nf)!==0)&&la()&&(ht.f&(In|Ur|Ia|nf))!==0&&(Kr===null||!el.call(Kr,t))&&sA();let r=n?We(e):e;return lo(t,r,Ou)}function lo(t,e,n=null){if(!t.equals(e)){Ns.set(t,bo?e:t.v);var r=vo.ensure();if(r.capture(t,e),(t.f&In)!==0){const i=t;(t.f&vn)!==0&&Nv(i),Tn===null&&Ov(i)}t.wv=lk(),Jx(t,vn,n),la()&&at!==null&&(at.f&fn)!==0&&(at.f&(di|mo))===0&&(Rr===null?t2([t]):Rr.push(t)),!r.is_fork&&of.size>0&&!Gx&&jA()}return e}function jA(){Gx=!1;for(const t of of){(t.f&fn)!==0&&Xt(t,Ni);let e;try{e=_d(t)}catch{e=!0}e&&rl(t)}of.clear()}function Tc(t,e=1){var n=u(t),r=e===1?n++:n--;return y(t,n),r}function rc(t){y(t,t.v+1)}function Jx(t,e,n){var r=t.reactions;if(r!==null)for(var i=la(),o=r.length,s=0;s<o;s++){var a=r[s],l=a.f;if(!(!i&&a===at)){var c=(l&vn)===0;if(c&&Xt(a,e),(l&nf)!==0)of.add(a);else if((l&In)!==0){var d=a;Tn==null||Tn.delete(d),(l&qs)===0&&(l&jr&&(at===null||(at.f&rf)===0)&&(a.f|=qs),Jx(d,Ni,n))}else if(c){var f=a;(l&Ur)!==0&&ii!==null&&ii.add(f),n!==null?n.push(f):Iv(f)}}}}function We(t){if(typeof t!="object"||t===null||Oi in t)return t;const e=Mv(t);if(e!==jE&&e!==WE)return t;var n=new Map,r=Av(t),i=I(0),o=Ls,s=a=>{if(Ls===o)return a();var l=ht,c=Ls;Zr(null),Lb(o);var d=a();return Zr(l),Lb(c),d};return r&&n.set("length",I(t.length)),new Proxy(t,{defineProperty(a,l,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&iA();var d=n.get(l);return d===void 0?s(()=>{var f=I(c.value);return n.set(l,f),f}):y(d,c.value,!0),!0},deleteProperty(a,l){var c=n.get(l);if(c===void 0){if(l in a){const d=s(()=>I(dn));n.set(l,d),rc(i)}}else y(c,dn),rc(i);return!0},get(a,l,c){var p;if(l===Oi)return t;var d=n.get(l),f=l in a;if(d===void 0&&(!f||(p=Go(a,l))!=null&&p.writable)&&(d=s(()=>{var m=We(f?a[l]:dn),v=I(m);return v}),n.set(l,d)),d!==void 0){var h=u(d);return h===dn?void 0:h}return Reflect.get(a,l,c)},getOwnPropertyDescriptor(a,l){var c=Reflect.getOwnPropertyDescriptor(a,l);if(c&&"value"in c){var d=n.get(l);d&&(c.value=u(d))}else if(c===void 0){var f=n.get(l),h=f==null?void 0:f.v;if(f!==void 0&&h!==dn)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return c},has(a,l){var h;if(l===Oi)return!0;var c=n.get(l),d=c!==void 0&&c.v!==dn||Reflect.has(a,l);if(c!==void 0||at!==null&&(!d||(h=Go(a,l))!=null&&h.writable)){c===void 0&&(c=s(()=>{var p=d?We(a[l]):dn,m=I(p);return m}),n.set(l,c));var f=u(c);if(f===dn)return!1}return d},set(a,l,c,d){var _;var f=n.get(l),h=l in a;if(r&&l==="length")for(var p=c;p<f.v;p+=1){var m=n.get(p+"");m!==void 0?y(m,dn):p in a&&(m=s(()=>I(dn)),n.set(p+"",m))}if(f===void 0)(!h||(_=Go(a,l))!=null&&_.writable)&&(f=s(()=>I(void 0)),y(f,We(c)),n.set(l,f));else{h=f.v!==dn;var v=s(()=>We(c));y(f,v)}var g=Reflect.getOwnPropertyDescriptor(a,l);if(g!=null&&g.set&&g.set.call(d,c),!h){if(r&&typeof l=="string"){var b=n.get("length"),x=Number(l);Number.isInteger(x)&&x>=b.v&&y(b,x+1)}rc(i)}return!0},ownKeys(a){u(i);var l=Reflect.ownKeys(a).filter(f=>{var h=n.get(f);return h===void 0||h.v!==dn});for(var[c,d]of n)d.v!==dn&&!(c in a)&&l.push(c);return l},setPrototypeOf(){oA()}})}function Ib(t){try{if(t!==null&&typeof t=="object"&&Oi in t)return t[Oi]}catch{}return t}function WA(t,e){return Object.is(Ib(t),Ib(e))}var Rb,Yx,Zx,Xx;function KA(){if(Rb===void 0){Rb=window,Yx=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,n=Text.prototype;Zx=Go(e,"firstChild").get,Xx=Go(e,"nextSibling").get,Ab(t)&&(t[Um]=void 0,t[Au]=null,t[jm]=void 0,t.__e=void 0),Ab(n)&&(n[Kl]=void 0)}}function co(t=""){return document.createTextNode(t)}function Ei(t){return Zx.call(t)}function wd(t){return Xx.call(t)}function w(t,e){return Ei(t)}function Se(t,e=!1){{var n=Ei(t);return n instanceof Comment&&n.data===""?wd(n):n}}function k(t,e=1,n=!1){let r=t;for(;e--;)r=wd(r);return r}function qA(t){t.textContent=""}function Qx(){return!1}function $x(t,e,n){return document.createElementNS(e??Ax,t,void 0)}function GA(t,e){{const n=document.body;t.autofocus=!0,ci(()=>{document.activeElement===n&&t.focus()})}}let Nb=!1;function JA(){Nb||(Nb=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{var e;if(!t.defaultPrevented)for(const n of t.target.elements)(e=n[Mu])==null||e.call(n)})},{capture:!0}))}function _l(t){var e=ht,n=at;Zr(null),Pi(null);try{return t()}finally{Zr(e),Pi(n)}}function Pv(t,e,n,r=n){t.addEventListener(e,()=>_l(n));const i=t[Mu];i?t[Mu]=()=>{i(),r(!0)}:t[Mu]=()=>r(!0),JA()}function YA(t){at===null&&(ht===null&&tA(),eA()),bo&&$E()}function ZA(t,e){var n=e.last;n===null?e.last=e.first=t:(n.next=t,t.prev=n,e.last=t)}function Hi(t,e){var n=at;n!==null&&(n.f&Xn)!==0&&(t|=Xn);var r={ctx:$t,deps:null,nodes:null,f:t|vn|jr,first:null,fn:e,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};je==null||je.register_created_effect(r);var i=r;if((t&tl)!==0)Aa!==null?Aa.push(r):vo.ensure().schedule(r);else if(e!==null){try{rl(r)}catch(s){throw Qn(r),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&aa)===0&&(i=i.first,(t&Ur)!==0&&(t&go)!==0&&i!==null&&(i.f|=go))}if(i!==null&&(i.parent=n,n!==null&&ZA(i,n),ht!==null&&(ht.f&In)!==0&&(t&mo)===0)){var o=ht;(o.effects??(o.effects=[])).push(i)}return r}function Lv(){return ht!==null&&!ai}function zv(t){const e=Hi(Ah,null);return Xt(e,fn),e.teardown=t,e}function he(t){YA();var e=at.f,n=!ht&&(e&di)!==0&&(e&cs)===0;if(n){var r=$t;(r.e??(r.e=[])).push(t)}else return ek(t)}function ek(t){return Hi(tl|JE,t)}function XA(t){vo.ensure();const e=Hi(mo|aa,t);return()=>{Qn(e)}}function QA(t){vo.ensure();const e=Hi(mo|aa,t);return(n={})=>new Promise(r=>{n.outro?Ps(e,()=>{Qn(e),r(void 0)}):(Qn(e),r(void 0))})}function xd(t){return Hi(tl,t)}function $A(t){return Hi(Ia|aa,t)}function kd(t,e=0){return Hi(Ah|e,t)}function U(t,e=[],n=[],r=[]){BA(r,e,n,i=>{Hi(Ah,()=>t(...i.map(u)))})}function ca(t,e=0){var n=Hi(Ur|e,t);return n}function zr(t){return Hi(di|aa,t)}function tk(t){var e=t.teardown;if(e!==null){const n=bo,r=ht;Pb(!0),Zr(null);try{e.call(null)}finally{Pb(n),Zr(r)}}}function Fv(t,e=!1){var n=t.first;for(t.first=t.last=null;n!==null;){const i=n.ac;i!==null&&_l(()=>{i.abort(Mh)});var r=n.next;(n.f&mo)!==0?n.parent=null:Qn(n,e),n=r}}function e2(t){for(var e=t.first;e!==null;){var n=e.next;(e.f&di)===0&&Qn(e),e=n}}function Qn(t,e=!0){var n=!1;(e||(t.f&GE)!==0)&&t.nodes!==null&&t.nodes.end!==null&&(nk(t.nodes.start,t.nodes.end),n=!0),Xt(t,Hm),Fv(t,e&&!n),Ec(t,0);var r=t.nodes&&t.nodes.t;if(r!==null)for(const o of r)o.stop();tk(t),t.f^=Hm,t.f|=Wr;var i=t.parent;i!==null&&i.first!==null&&rk(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes=t.ac=t.b=null}function nk(t,e){for(;t!==null;){var n=t===e?null:wd(t);t.remove(),t=n}}function rk(t){var e=t.parent,n=t.prev,r=t.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),e!==null&&(e.first===t&&(e.first=r),e.last===t&&(e.last=n))}function Ps(t,e,n=!0){var r=[];ik(t,r,!0);var i=()=>{n&&Qn(t),e&&e()},o=r.length;if(o>0){var s=()=>--o||i();for(var a of r)a.out(s)}else i()}function ik(t,e,n){if((t.f&Xn)===0){t.f^=Xn;var r=t.nodes&&t.nodes.t;if(r!==null)for(const a of r)(a.is_global||n)&&e.push(a);for(var i=t.first;i!==null;){var o=i.next;if((i.f&mo)===0){var s=(i.f&go)!==0||(i.f&di)!==0&&(t.f&Ur)!==0;ik(i,e,s?n:!1)}i=o}}}function Bv(t){ok(t,!0)}function ok(t,e){if((t.f&Xn)!==0){t.f^=Xn,(t.f&fn)===0&&(Xt(t,vn),vo.ensure().schedule(t));for(var n=t.first;n!==null;){var r=n.next,i=(n.f&go)!==0||(n.f&di)!==0;ok(n,i?e:!1),n=r}var o=t.nodes&&t.nodes.t;if(o!==null)for(const s of o)(s.is_global||e)&&s.in()}}function Vv(t,e){if(t.nodes)for(var n=t.nodes.start,r=t.nodes.end;n!==null;){var i=n===r?null:wd(n);e.append(n),n=i}}let Nu=!1,bo=!1;function Pb(t){bo=t}let ht=null,ai=!1;function Zr(t){ht=t}let at=null;function Pi(t){at=t}let Kr=null;function sk(t){ht!==null&&(Kr===null?Kr=[t]:Kr.push(t))}let cr=null,vr=0,Rr=null;function t2(t){Rr=t}let ak=1,xs=0,Ls=xs;function Lb(t){Ls=t}function lk(){return++ak}function _d(t){var e=t.f;if((e&vn)!==0)return!0;if(e&In&&(t.f&=~qs),(e&Ni)!==0){for(var n=t.deps,r=n.length,i=0;i<r;i++){var o=n[i];if(_d(o)&&Kx(o),o.wv>t.wv)return!0}(e&jr)!==0&&Tn===null&&Xt(t,fn)}return!1}function ck(t,e,n=!0){var r=t.reactions;if(r!==null&&!(Kr!==null&&el.call(Kr,t)))for(var i=0;i<r.length;i++){var o=r[i];(o.f&In)!==0?ck(o,e,!1):e===o&&(n?Xt(o,vn):(o.f&fn)!==0&&Xt(o,Ni),Iv(o))}}function dk(t){var v;var e=cr,n=vr,r=Rr,i=ht,o=Kr,s=$t,a=ai,l=Ls,c=t.f;cr=null,vr=0,Rr=null,ht=(c&(di|mo))===0?t:null,Kr=null,nl(t.ctx),ai=!1,Ls=++xs,t.ac!==null&&(_l(()=>{t.ac.abort(Mh)}),t.ac=null);try{t.f|=rf;var d=t.fn,f=d();t.f|=cs;var h=t.deps,p=je==null?void 0:je.is_fork;if(cr!==null){var m;if(p||Ec(t,vr),h!==null&&vr>0)for(h.length=vr+cr.length,m=0;m<cr.length;m++)h[vr+m]=cr[m];else t.deps=h=cr;if(Lv()&&(t.f&jr)!==0)for(m=vr;m<h.length;m++)((v=h[m]).reactions??(v.reactions=[])).push(t)}else!p&&h!==null&&vr<h.length&&(Ec(t,vr),h.length=vr);if(la()&&Rr!==null&&!ai&&h!==null&&(t.f&(In|Ni|vn))===0)for(m=0;m<Rr.length;m++)ck(Rr[m],t);if(i!==null&&i!==t){if(xs++,i.deps!==null)for(let g=0;g<n;g+=1)i.deps[g].rv=xs;if(e!==null)for(const g of e)g.rv=xs;Rr!==null&&(r===null?r=Rr:r.push(...Rr))}return(t.f&Jo)!==0&&(t.f^=Jo),f}catch(g){return Rx(g)}finally{t.f^=rf,cr=e,vr=n,Rr=r,ht=i,Kr=o,nl(s),ai=a,Ls=l}}function n2(t,e){let n=e.reactions;if(n!==null){var r=HE.call(n,t);if(r!==-1){var i=n.length-1;i===0?n=e.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&(e.f&In)!==0&&(cr===null||!el.call(cr,e))){var o=e;(o.f&jr)!==0&&(o.f^=jr,o.f&=~qs),o.v!==dn&&Ov(o),UA(o),Ec(o,0)}}function Ec(t,e){var n=t.deps;if(n!==null)for(var r=e;r<n.length;r++)n2(t,n[r])}function rl(t){var e=t.f;if((e&Wr)===0){Xt(t,fn);var n=at,r=Nu;at=t,Nu=!0;try{(e&(Ur|Sx))!==0?e2(t):Fv(t),tk(t);var i=dk(t);t.teardown=typeof i=="function"?i:null,t.wv=ak;var o;xx&&CA&&(t.f&vn)!==0&&t.deps}finally{Nu=r,at=n}}}async function r2(){await Promise.resolve(),Fx()}function u(t){var e=t.f,n=(e&In)!==0;if(ht!==null&&!ai){var r=at!==null&&(at.f&Wr)!==0;if(!r&&(Kr===null||!el.call(Kr,t))){var i=ht.deps;if((ht.f&rf)!==0)t.rv<xs&&(t.rv=xs,cr===null&&i!==null&&i[vr]===t?vr++:cr===null?cr=[t]:cr.push(t));else{(ht.deps??(ht.deps=[])).push(t);var o=t.reactions;o===null?t.reactions=[ht]:el.call(o,ht)||o.push(ht)}}}if(bo&&Ns.has(t))return Ns.get(t);if(n){var s=t;if(bo){var a=s.v;return((s.f&fn)===0&&s.reactions!==null||fk(s))&&(a=Nv(s)),Ns.set(s,a),a}var l=(s.f&jr)===0&&!ai&&ht!==null&&(Nu||(ht.f&jr)!==0),c=(s.f&cs)===0;_d(s)&&(l&&(s.f|=jr),Kx(s)),l&&!c&&(qx(s),uk(s))}if(Tn!=null&&Tn.has(t))return Tn.get(t);if((t.f&Jo)!==0)throw t.v;return t.v}function uk(t){if(t.f|=jr,t.deps!==null)for(const e of t.deps)(e.reactions??(e.reactions=[])).push(t),(e.f&In)!==0&&(e.f&jr)===0&&(qx(e),uk(e))}function fk(t){if(t.v===dn)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(Ns.has(e)||(e.f&In)!==0&&fk(e))return!0;return!1}function vt(t){var e=ai;try{return ai=!0,t()}finally{ai=e}}function i2(t){if(!(typeof t!="object"||!t||t instanceof EventTarget)){if(Oi in t)Qm(t);else if(!Array.isArray(t))for(let e in t){const n=t[e];typeof n=="object"&&n&&Oi in n&&Qm(n)}}}function Qm(t,e=new Set){if(typeof t=="object"&&t!==null&&!(t instanceof EventTarget)&&!e.has(t)){e.add(t),t instanceof Date&&t.getTime();for(let r in t)try{Qm(t[r],e)}catch{}const n=Mv(t);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const r=kx(n);for(let i in r){const o=r[i].get;if(o)try{o.call(t)}catch{}}}}}const o2=["touchstart","touchmove"];function s2(t){return o2.includes(t)}const ks=Symbol("events"),hk=new Set,$m=new Set;function a2(t,e,n,r={}){function i(o){if(r.capture||eg.call(e,o),!o.cancelBubble)return _l(()=>n==null?void 0:n.call(this,o))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?ci(()=>{e.addEventListener(t,i,r)}):e.addEventListener(t,i,r),i}function Tt(t,e,n,r,i){var o={capture:r,passive:i},s=a2(t,e,n,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&zv(()=>{e.removeEventListener(t,s,o)})}function R(t,e,n){(e[ks]??(e[ks]={}))[t]=n}function Ke(t){for(var e=0;e<t.length;e++)hk.add(t[e]);for(var n of $m)n(t)}let zb=null;function eg(t){var g,b;var e=this,n=e.ownerDocument,r=t.type,i=((g=t.composedPath)==null?void 0:g.call(t))||[],o=i[0]||t.target;zb=t;var s=0,a=zb===t&&t[ks];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){t[ks]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||t.target,o!==e){UE(t,"currentTarget",{configurable:!0,get(){return o||n}});var d=ht,f=at;Zr(null),Pi(null);try{for(var h,p=[];o!==null;){var m=o.assignedSlot||o.parentNode||o.host||null;try{var v=(b=o[ks])==null?void 0:b[r];v!=null&&(!o.disabled||t.target===o)&&v.call(o,t)}catch(x){h?p.push(x):h=x}if(t.cancelBubble||m===e||m===null)break;o=m}if(h){for(let x of p)queueMicrotask(()=>{throw x});throw h}}finally{t[ks]=e,delete t.currentTarget,Zr(d),Pi(f)}}}var bx;const Cp=((bx=globalThis==null?void 0:globalThis.window)==null?void 0:bx.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:t=>t});function l2(t){return(Cp==null?void 0:Cp.createHTML(t))??t}function pk(t){var e=$x("template");return e.innerHTML=l2(t.replaceAll("<!>","<!---->")),e.content}function Gs(t,e){var n=at;n.nodes===null&&(n.nodes={start:t,end:e,a:null,t:null})}function E(t,e){var n=(e&yA)!==0,r=(e&bA)!==0,i,o=!t.startsWith("<!>");return()=>{i===void 0&&(i=pk(o?t:"<!>"+t),n||(i=Ei(i)));var s=r||Yx?document.importNode(i,!0):i.cloneNode(!0);if(n){var a=Ei(s),l=s.lastChild;Gs(a,l)}else Gs(s,s);return s}}function c2(t,e,n="svg"){var r=!t.startsWith("<!>"),i=`<${n}>${r?t:"<!>"+t}</${n}>`,o;return()=>{if(!o){var s=pk(i),a=Ei(s);o=Ei(a)}var l=o.cloneNode(!0);return Gs(l,l),l}}function Ui(t,e){return c2(t,e,"svg")}function hr(t=""){{var e=co(t+"");return Gs(e,e),e}}function ft(){var t=document.createDocumentFragment(),e=document.createComment(""),n=co();return t.append(e,n),Gs(e,n),t}function S(t,e){t!==null&&t.before(e)}let tg=!0;function te(t,e){var n=e==null?"":typeof e=="object"?`${e}`:e;n!==(t[Kl]??(t[Kl]=t.nodeValue))&&(t[Kl]=n,t.nodeValue=`${n}`)}function d2(t,e){return u2(t,e)}const Zd=new Map;function u2(t,{target:e,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:a}){KA();var l=void 0,c=QA(()=>{var d=n??e.appendChild(co());Ux(d,{pending:()=>{}},p=>{Pe({});var m=$t;o&&(m.c=o),i&&(r.$$events=i),tg=s,l=t(p,r)||{},tg=!0,Le()},a);var f=new Set,h=p=>{for(var m=0;m<p.length;m++){var v=p[m];if(!f.has(v)){f.add(v);var g=s2(v);for(const _ of[e,document]){var b=Zd.get(_);b===void 0&&(b=new Map,Zd.set(_,b));var x=b.get(v);x===void 0?(_.addEventListener(v,eg,{passive:g}),b.set(v,1)):b.set(v,x+1)}}}};return h(Eh(hk)),$m.add(h),()=>{var g;for(var p of f)for(const b of[e,document]){var m=Zd.get(b),v=m.get(p);--v==0?(b.removeEventListener(p,eg),m.delete(p),m.size===0&&Zd.delete(b)):m.set(p,v)}$m.delete(h),d!==n&&((g=d.parentNode)==null||g.removeChild(d))}});return f2.set(l,c),l}let f2=new WeakMap;var oi,Ci,_r,Rs,gd,vd,_h;class Sd{constructor(e,n=!0){pn(this,"anchor");Ze(this,oi,new Map);Ze(this,Ci,new Map);Ze(this,_r,new Map);Ze(this,Rs,new Set);Ze(this,gd,!0);Ze(this,vd,e=>{if(ne(this,oi).has(e)){var n=ne(this,oi).get(e),r=ne(this,Ci).get(n);if(r)Bv(r),ne(this,Rs).delete(n);else{var i=ne(this,_r).get(n);i&&(ne(this,Ci).set(n,i.effect),ne(this,_r).delete(n),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),r=i.effect)}for(const[o,s]of ne(this,oi)){if(ne(this,oi).delete(o),o===e)break;const a=ne(this,_r).get(s);a&&(Qn(a.effect),ne(this,_r).delete(s))}for(const[o,s]of ne(this,Ci)){if(o===n||ne(this,Rs).has(o))continue;const a=()=>{if(Array.from(ne(this,oi).values()).includes(o)){var c=document.createDocumentFragment();Vv(s,c),c.append(co()),ne(this,_r).set(o,{effect:s,fragment:c})}else Qn(s);ne(this,Rs).delete(o),ne(this,Ci).delete(o)};ne(this,gd)||!r?(ne(this,Rs).add(o),Ps(s,a,!1)):a()}}});Ze(this,_h,e=>{ne(this,oi).delete(e);const n=Array.from(ne(this,oi).values());for(const[r,i]of ne(this,_r))n.includes(r)||(Qn(i.effect),ne(this,_r).delete(r))});this.anchor=e,Qe(this,gd,n)}ensure(e,n){var r=je,i=Qx();if(n&&!ne(this,Ci).has(e)&&!ne(this,_r).has(e))if(i){var o=document.createDocumentFragment(),s=co();o.append(s),ne(this,_r).set(e,{effect:zr(()=>n(s)),fragment:o})}else ne(this,Ci).set(e,zr(()=>n(this.anchor)));if(ne(this,oi).set(r,e),i){for(const[a,l]of ne(this,Ci))a===e?r.unskip_effect(l):r.skip_effect(l);for(const[a,l]of ne(this,_r))a===e?r.unskip_effect(l.effect):r.skip_effect(l.effect);r.oncommit(ne(this,vd)),r.ondiscard(ne(this,_h))}else ne(this,vd).call(this,r)}}oi=new WeakMap,Ci=new WeakMap,_r=new WeakMap,Rs=new WeakMap,gd=new WeakMap,vd=new WeakMap,_h=new WeakMap;const h2=0,Fb=1,p2=2;function mk(t,e,n,r,i){var o=la(),s=dn,a=o?yo(s):Xm(s,!1,!1),l=o?yo(s):Xm(s,!1,!1),c=new Sd(t);ca(()=>{var d=je;d.deactivate();var f=e();d.activate();var h=!1;if(KE(f)){var p=jx(),m=!1;const v=g=>{if(!h){m=!0,p(!1),vo.ensure();try{g()}finally{Sc(!1),Ra||Fx()}}};f.then(g=>{v(()=>{lo(a,g),c.ensure(Fb,r&&(b=>r(b,a)))})},g=>{v(()=>{if(lo(l,g),c.ensure(p2,i&&(b=>i(b,l))),!i)throw l.v})}),ci(()=>{m||v(()=>{c.ensure(h2,n)})})}else lo(a,f),c.ensure(Fb,r&&(v=>r(v,a)));return()=>{h=!0}})}function J(t,e,n=!1){var r=new Sd(t),i=n?go:0;function o(s,a){r.ensure(s,a)}ca(()=>{var s=!1;e((a,l=0)=>{s=!0,o(l,a)}),s||o(-1,null)},i)}const m2=Symbol("NaN");function sf(t,e,n){var r=new Sd(t),i=!la();ca(()=>{var o=e();o!==o&&(o=m2),i&&o!==null&&typeof o=="object"&&(o={}),r.ensure(o,n)})}function Ac(t,e){return e}function g2(t,e,n){for(var r=[],i=e.length,o,s=e.length,a=0;a<i;a++){let f=e[a];Ps(f,()=>{if(o){if(o.pending.delete(f),o.done.add(f),o.pending.size===0){var h=t.outrogroups;ng(t,Eh(o.done)),h.delete(o),h.size===0&&(t.outrogroups=null)}}else s-=1},!1)}if(s===0){var l=r.length===0&&n!==null;if(l){var c=n,d=c.parentNode;qA(d),d.append(c),t.items.clear()}ng(t,e,!l)}else o={pending:new Set(e),done:new Set},(t.outrogroups??(t.outrogroups=new Set)).add(o)}function ng(t,e,n=!0){var r;if(t.pending.size>0){r=new Set;for(const s of t.pending.values())for(const a of s)r.add(t.items.get(a).e)}for(var i=0;i<e.length;i++){var o=e[i];if(r!=null&&r.has(o)){o.f|=Ti;const s=document.createDocumentFragment();Vv(o,s)}else Qn(e[i],n)}}var Bb;function Ye(t,e,n,r,i,o=null){var s=t,a=new Map,l=(e&Ex)!==0;if(l){var c=t;s=c.appendChild(co())}var d=null,f=Rv(()=>{var _=n();return Av(_)?_:_==null?[]:Eh(_)}),h,p=new Map,m=!0;function v(_){(x.effect.f&Wr)===0&&(x.pending.delete(_),x.fallback=d,v2(x,h,s,e,r),d!==null&&(h.length===0?(d.f&Ti)===0?Bv(d):(d.f^=Ti,Gl(d,null,s)):Ps(d,()=>{d=null})))}function g(_){x.pending.delete(_)}var b=ca(()=>{h=u(f);for(var _=h.length,A=new Set,M=je,P=Qx(),D=0;D<_;D+=1){var L=h[D],X=r(L,D),z=m?null:a.get(X);z?(z.v&&lo(z.v,L),z.i&&lo(z.i,D),P&&M.unskip_effect(z.e)):(z=y2(a,m?s:Bb??(Bb=co()),L,X,D,i,e,n),m||(z.e.f|=Ti),a.set(X,z)),A.add(X)}if(_===0&&o&&!d&&(m?d=zr(()=>o(s)):(d=zr(()=>o(Bb??(Bb=co()))),d.f|=Ti)),_>A.size&&QE(),!m)if(p.set(M,A),P){for(const[re,Q]of a)A.has(re)||M.skip_effect(Q.e);M.oncommit(v),M.ondiscard(g)}else v(M);u(f)}),x={effect:b,items:a,pending:p,outrogroups:null,fallback:d};m=!1}function Ll(t){for(;t!==null&&(t.f&di)===0;)t=t.next;return t}function v2(t,e,n,r,i){var z,re,Q,N,B,j,H,W,ee;var o=(r&dA)!==0,s=e.length,a=t.items,l=Ll(t.effect.first),c,d=null,f,h=[],p=[],m,v,g,b;if(o)for(b=0;b<s;b+=1)m=e[b],v=i(m,b),g=a.get(v).e,(g.f&Ti)===0&&((re=(z=g.nodes)==null?void 0:z.a)==null||re.measure(),(f??(f=new Set)).add(g));for(b=0;b<s;b+=1){if(m=e[b],v=i(m,b),g=a.get(v).e,t.outrogroups!==null)for(const ie of t.outrogroups)ie.pending.delete(g),ie.done.delete(g);if((g.f&Xn)!==0&&(Bv(g),o&&((N=(Q=g.nodes)==null?void 0:Q.a)==null||N.unfix(),(f??(f=new Set)).delete(g))),(g.f&Ti)!==0)if(g.f^=Ti,g===l)Gl(g,null,n);else{var x=d?d.next:l;g===t.effect.last&&(t.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),To(t,d,g),To(t,g,x),Gl(g,x,n),d=g,h=[],p=[],l=Ll(d.next);continue}if(g!==l){if(c!==void 0&&c.has(g)){if(h.length<p.length){var _=p[0],A;d=_.prev;var M=h[0],P=h[h.length-1];for(A=0;A<h.length;A+=1)Gl(h[A],_,n);for(A=0;A<p.length;A+=1)c.delete(p[A]);To(t,M.prev,P.next),To(t,d,M),To(t,P,_),l=_,d=P,b-=1,h=[],p=[]}else c.delete(g),Gl(g,l,n),To(t,g.prev,g.next),To(t,g,d===null?t.effect.first:d.next),To(t,d,g),d=g;continue}for(h=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=Ll(l.next);if(l===null)continue}(g.f&Ti)===0&&h.push(g),d=g,l=Ll(g.next)}if(t.outrogroups!==null){for(const ie of t.outrogroups)ie.pending.size===0&&(ng(t,Eh(ie.done)),(B=t.outrogroups)==null||B.delete(ie));t.outrogroups.size===0&&(t.outrogroups=null)}if(l!==null||c!==void 0){var D=[];if(c!==void 0)for(g of c)(g.f&Xn)===0&&D.push(g);for(;l!==null;)(l.f&Xn)===0&&l!==t.fallback&&D.push(l),l=Ll(l.next);var L=D.length;if(L>0){var X=(r&Ex)!==0&&s===0?n:null;if(o){for(b=0;b<L;b+=1)(H=(j=D[b].nodes)==null?void 0:j.a)==null||H.measure();for(b=0;b<L;b+=1)(ee=(W=D[b].nodes)==null?void 0:W.a)==null||ee.fix()}g2(t,D,X)}}o&&ci(()=>{var ie,K;if(f!==void 0)for(g of f)(K=(ie=g.nodes)==null?void 0:ie.a)==null||K.apply()})}function y2(t,e,n,r,i,o,s,a){var l=(s&lA)!==0?(s&uA)===0?Xm(n,!1,!1):yo(n):null,c=(s&cA)!==0?yo(i):null;return{v:l,i:c,e:zr(()=>(o(e,l??n,c??i,a),()=>{t.delete(r)}))}}function Gl(t,e,n){if(t.nodes)for(var r=t.nodes.start,i=t.nodes.end,o=e&&(e.f&Ti)===0?e.nodes.start:n;r!==null;){var s=wd(r);if(o.before(r),r===i)return;r=s}}function To(t,e,n){e===null?t.effect.first=n:e.next=n,n===null?t.effect.last=e:n.prev=e}function b2(t,e,n=!1,r=!1,i=!1,o=!1){var s=t,a="";if(n)var l=t;U(()=>{var c=at;if(a!==(a=e()??"")){if(n){c.nodes=null,l.innerHTML=a,a!==""&&Gs(Ei(l),l.lastChild);return}if(c.nodes!==null&&(nk(c.nodes.start,c.nodes.end),c.nodes=null),a!==""){var d=r?wA:i?xA:void 0,f=$x(r?"svg":i?"math":"template",d);f.innerHTML=a;var h=r||i?f:f.content;if(Gs(Ei(h),h.lastChild),r||i)for(;Ei(h);)s.before(Ei(h));else s.before(h)}}})}function Cd(t,e,...n){var r=new Sd(t);ca(()=>{const i=e()??null;r.ensure(i,i&&(o=>i(o,...n)))},go)}function Hv(t,e,n){var r=new Sd(t);ca(()=>{var i=e()??null;r.ensure(i,i&&(o=>n(o,i)))},go)}const w2=()=>performance.now(),so={tick:t=>requestAnimationFrame(t),now:()=>w2(),tasks:new Set};function gk(){const t=so.now();so.tasks.forEach(e=>{e.c(t)||(so.tasks.delete(e),e.f())}),so.tasks.size!==0&&so.tick(gk)}function x2(t){let e;return so.tasks.size===0&&so.tick(gk),{promise:new Promise(n=>{so.tasks.add(e={c:t,f:n})}),abort(){so.tasks.delete(e)}}}function Xd(t,e){_l(()=>{t.dispatchEvent(new CustomEvent(e))})}function k2(t){if(t==="float")return"cssFloat";if(t==="offset")return"cssOffset";if(t.startsWith("--"))return t;const e=t.split("-");return e.length===1?e[0]:e[0]+e.slice(1).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function Vb(t){const e={},n=t.split(";");for(const r of n){const[i,o]=r.split(":");if(!i||o===void 0)break;const s=k2(i.trim());e[s]=o.trim()}return e}const _2=t=>t;function Hb(t,e,n,r){var g;var i=(t&vA)!==0,o="both",s,a=e.inert,l=e.style.overflow,c,d;function f(){return _l(()=>s??(s=n()(e,(r==null?void 0:r())??{},{direction:o})))}var h={is_global:i,in(){e.inert=a,c=rg(e,f(),d,1,()=>{Xd(e,"introstart")},()=>{Xd(e,"introend"),c==null||c.abort(),c=s=void 0,e.style.overflow=l})},out(b){e.inert=!0,d=rg(e,f(),c,0,()=>{Xd(e,"outrostart")},()=>{Xd(e,"outroend"),b==null||b()})},stop:()=>{c==null||c.abort(),d==null||d.abort()}},p=at;if(((g=p.nodes).t??(g.t=[])).push(h),tg){var m=i;if(!m){for(var v=p.parent;v&&(v.f&go)!==0;)for(;(v=v.parent)&&(v.f&Ur)===0;);m=!v||(v.f&cs)!==0}m&&xd(()=>{vt(()=>h.in())})}}function rg(t,e,n,r,i,o){var s=r===1;if(wa(e)){var a,l=!1;return ci(()=>{if(!l){var b=e({direction:s?"in":"out"});a=rg(t,b,n,r,i,o)}}),{abort:()=>{l=!0,a==null||a.abort()},deactivate:()=>a.deactivate(),reset:()=>a.reset(),t:()=>a.t()}}if(n==null||n.deactivate(),!(e!=null&&e.duration)&&!(e!=null&&e.delay))return i(),o(),{abort:ur,deactivate:ur,reset:ur,t:()=>r};const{delay:c=0,css:d,tick:f,easing:h=_2}=e;var p=[];if(s&&n===void 0&&(f&&f(0,1),d)){var m=Vb(d(0,1));p.push(m,m)}var v=()=>1-r,g=t.animate(p,{duration:c,fill:"forwards"});return g.onfinish=()=>{g.cancel(),i();var b=(n==null?void 0:n.t())??1-r;n==null||n.abort();var x=r-b,_=e.duration*Math.abs(x),A=[];if(_>0){var M=!1;if(d)for(var P=Math.ceil(_/16.666666666666668),D=0;D<=P;D+=1){var L=b+x*h(D/P),X=Vb(d(L,1-L));A.push(X),M||(M=X.overflow==="hidden")}M&&(t.style.overflow="hidden"),v=()=>{var z=g.currentTime;return b+x*h(z/_)},f&&x2(()=>{if(g.playState!=="running")return!1;var z=v();return f(z,1-z),!0})}g=t.animate(A,{duration:_,fill:"forwards"}),g.onfinish=()=>{v=()=>r,f==null||f(r,1-r),o()}},{abort:()=>{g&&(g.cancel(),g.effect=null,g.onfinish=ur)},deactivate:()=>{o=ur},reset:()=>{r===0&&(f==null||f(1,0))},t:()=>v()}}function Tr(t,e,n){xd(()=>{var r=vt(()=>e(t,n==null?void 0:n())||{});if(n&&(r!=null&&r.update)){var i=!1,o={};kd(()=>{var s=n();i2(s),i&&Ox(o,s)&&(o=s,r.update(s))}),i=!0}if(r!=null&&r.destroy)return()=>r.destroy()})}function vk(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=vk(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function S2(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=vk(t))&&(r&&(r+=" "),r+=e);return r}function ig(t){return typeof t=="object"?S2(t):t??""}const Ub=[...`
|
|
3
|
+
\r\f \v\uFEFF`];function C2(t,e,n){var r=t==null?"":""+t;if(e&&(r=r?r+" "+e:e),n){for(var i of Object.keys(n))if(n[i])r=r?r+" "+i:i;else if(r.length)for(var o=i.length,s=0;(s=r.indexOf(i,s))>=0;){var a=s+o;(s===0||Ub.includes(r[s-1]))&&(a===r.length||Ub.includes(r[a]))?r=(s===0?"":r.substring(0,s))+r.substring(a+1):s=a}}return r===""?null:r}function T2(t,e){return t==null?null:String(t)}function Xr(t,e,n,r,i,o){var s=t[Um];if(s!==n||s===void 0){var a=C2(n,r,o);a==null?t.removeAttribute("class"):t.className=a,t[Um]=n}else if(o&&i!==o)for(var l in o){var c=!!o[l];(i==null||c!==!!i[l])&&t.classList.toggle(l,c)}return o}function ve(t,e,n,r){var i=t[jm];if(i!==e){var o=T2(e);o==null?t.removeAttribute("style"):t.style.cssText=o,t[jm]=e}return r}function Oh(t,e,n=!1){if(t.multiple){if(e==null)return;if(!Av(e))return _A();for(var r of t.options)r.selected=e.includes(ic(r));return}for(r of t.options){var i=ic(r);if(WA(i,e)){r.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function Uv(t){var e=new MutationObserver(()=>{Oh(t,t.__value)});e.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),zv(()=>{e.disconnect()})}function E2(t,e,n=e){var r=new WeakSet,i=!0;Pv(t,"change",o=>{var s=o?"[selected]":":checked",a;if(t.multiple)a=[].map.call(t.querySelectorAll(s),ic);else{var l=t.querySelector(s)??t.querySelector("option:not([disabled])");a=l&&ic(l)}n(a),t.__value=a,je!==null&&r.add(je)}),xd(()=>{var o=e();if(t===document.activeElement){var s=je;if(r.has(s))return}if(Oh(t,o,i),i&&o===void 0){var a=t.querySelector(":checked");a!==null&&(o=ic(a),n(o))}t.__value=o,i=!1}),Uv(t)}function ic(t){return"__value"in t?t.__value:t.value}const A2=Symbol("is custom element"),M2=Symbol("is html"),O2=ZE?"progress":"PROGRESS";function $n(t,e){var n=jv(t);n.value===(n.value=e??void 0)||t.value===e&&(e!==0||t.nodeName!==O2)||(t.value=e??"")}function Vn(t,e){var n=jv(t);n.checked!==(n.checked=e??void 0)&&(t.checked=e)}function G(t,e,n,r){var i=jv(t);i[e]!==(i[e]=n)&&(e==="loading"&&(t[YE]=n),n==null?t.removeAttribute(e):typeof n!="string"&&D2(t).includes(e)?t[e]=n:t.setAttribute(e,n))}function jv(t){return t[Au]??(t[Au]={[A2]:t.nodeName.includes("-"),[M2]:t.namespaceURI===Ax})}var jb=new Map;function D2(t){var e=t.getAttribute("is")||t.nodeName,n=jb.get(e);if(n)return n;jb.set(e,n=[]);for(var r,i=t,o=Element.prototype;o!==i;){r=kx(i);for(var s in r)r[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&n.push(s);i=Mv(i)}return n}function Bn(t,e,n=e){var r=new WeakSet;Pv(t,"input",async i=>{var o=i?t.defaultValue:t.value;if(o=Tp(t)?Ep(o):o,n(o),je!==null&&r.add(je),await r2(),o!==(o=e())){var s=t.selectionStart,a=t.selectionEnd,l=t.value.length;if(t.value=o??"",a!==null){var c=t.value.length;s===a&&a===l&&c>l?(t.selectionStart=c,t.selectionEnd=c):(t.selectionStart=s,t.selectionEnd=Math.min(a,c))}}}),vt(e)==null&&t.value&&(n(Tp(t)?Ep(t.value):t.value),je!==null&&r.add(je)),kd(()=>{var i=e();if(t===document.activeElement){var o=je;if(r.has(o))return}Tp(t)&&i===Ep(t.value)||t.type==="date"&&!i&&!t.value||i!==t.value&&(t.value=i??"")})}function Pu(t,e,n=e){Pv(t,"change",r=>{var i=r?t.defaultChecked:t.checked;n(i)}),vt(e)==null&&n(t.checked),kd(()=>{var r=e();t.checked=!!r})}function Tp(t){var e=t.type;return e==="number"||e==="range"}function Ep(t){return t===""?null:+t}var Ho,$a,yd,Sh,yk;const Ch=class Ch{constructor(e){Ze(this,Sh);Ze(this,Ho,new WeakMap);Ze(this,$a);Ze(this,yd);Qe(this,yd,e)}observe(e,n){var r=ne(this,Ho).get(e)||new Set;return r.add(n),ne(this,Ho).set(e,r),mt(this,Sh,yk).call(this).observe(e,ne(this,yd)),()=>{var i=ne(this,Ho).get(e);i.delete(n),i.size===0&&(ne(this,Ho).delete(e),ne(this,$a).unobserve(e))}}};Ho=new WeakMap,$a=new WeakMap,yd=new WeakMap,Sh=new WeakSet,yk=function(){return ne(this,$a)??Qe(this,$a,new ResizeObserver(e=>{for(var n of e){Ch.entries.set(n.target,n);for(var r of ne(this,Ho).get(n.target)||[])r(n)}}))},pn(Ch,"entries",new WeakMap);let og=Ch;var I2=new og({box:"border-box"});function R2(t,e,n){var r=I2.observe(t,()=>n(t[e]));xd(()=>(vt(()=>n(t[e])),r))}function Ap(t,e){return t===e||(t==null?void 0:t[Oi])===e}function pt(t={},e,n,r){var i=$t.r,o=at;return xd(()=>{var s,a;return kd(()=>{s=a,a=(r==null?void 0:r())||[],vt(()=>{Ap(n(...a),t)||(e(t,...a),s&&Ap(n(...s),t)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&Hm;)l=l.parent;const c=()=>{a&&Ap(n(...a),t)&&e(null,...a)},d=l.teardown;l.teardown=()=>{c(),d==null||d()}}}),t}const N2={get(t,e){if(!t.exclude.includes(e))return t.props[e]},set(t,e){return!1},getOwnPropertyDescriptor(t,e){if(!t.exclude.includes(e)&&e in t.props)return{enumerable:!0,configurable:!0,value:t.props[e]}},has(t,e){return t.exclude.includes(e)?!1:e in t.props},ownKeys(t){return Reflect.ownKeys(t.props).filter(e=>!t.exclude.includes(e))}};function P2(t,e,n){return new Proxy({props:t,exclude:e},N2)}const L2={get(t,e){let n=t.props.length;for(;n--;){let r=t.props[n];if(wa(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r)return r[e]}},set(t,e,n){let r=t.props.length;for(;r--;){let i=t.props[r];wa(i)&&(i=i());const o=Go(i,e);if(o&&o.set)return o.set(n),!0}return!1},getOwnPropertyDescriptor(t,e){let n=t.props.length;for(;n--;){let r=t.props[n];if(wa(r)&&(r=r()),typeof r=="object"&&r!==null&&e in r){const i=Go(r,e);return i&&!i.configurable&&(i.configurable=!0),i}}},has(t,e){if(e===Oi||e===Cx)return!1;for(let n of t.props)if(wa(n)&&(n=n()),n!=null&&e in n)return!0;return!1},ownKeys(t){const e=[];for(let n of t.props)if(wa(n)&&(n=n()),!!n){for(const r in n)e.includes(r)||e.push(r);for(const r of Object.getOwnPropertySymbols(n))e.includes(r)||e.push(r)}return e}};function Jl(...t){return new Proxy({props:t},L2)}function nt(t,e,n,r){var A;var i=!kl||(n&hA)!==0,o=(n&mA)!==0,s=(n&gA)!==0,a=r,l=!0,c=void 0,d=()=>s&&i?(c??(c=Cc(r)),u(c)):(l&&(l=!1,a=s?vt(r):r),a);let f;if(o){var h=Oi in t||Cx in t;f=((A=Go(t,e))==null?void 0:A.set)??(h&&e in t?M=>t[e]=M:void 0)}var p,m=!1;o?[p,m]=MA(()=>t[e]):p=t[e],p===void 0&&r!==void 0&&(p=d(),f&&(i&&rA(),f(p)));var v;if(i?v=()=>{var M=t[e];return M===void 0?d():(l=!0,M)}:v=()=>{var M=t[e];return M!==void 0&&(a=void 0),M===void 0?a:M},i&&(n&pA)===0)return v;if(f){var g=t.$$legacy;return(function(M,P){return arguments.length>0?((!i||!P||g||m)&&f(P?v():M),M):v()})}var b=!1,x=((n&fA)!==0?Cc:Rv)(()=>(b=!1,v()));o&&u(x);var _=at;return(function(M,P){if(arguments.length>0){const D=P?u(x):i&&o?We(M):M;return y(x,D),b=!0,a!==void 0&&(a=D),M}return bo&&b||(_.f&Wr)!==0?x.v:u(x)})}function Td(t){$t===null&&Tx(),kl&&$t.l!==null?z2($t).m.push(t):he(()=>{const e=vt(t);if(typeof e=="function")return e})}function Qr(t){$t===null&&Tx(),Td(()=>()=>vt(t))}function z2(t){var e=t.l;return e.u??(e.u={a:[],b:[],m:[]})}const F2="5";var wx;typeof window<"u"&&((wx=window.__svelte??(window.__svelte={})).v??(wx.v=new Set)).add(F2);TA();const B2="modulepreload",V2=function(t){return"/"+t},Wb={},Rn=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){let s=function(c){return Promise.all(c.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=s(n.map(c=>{if(c=V2(c),c in Wb)return;Wb[c]=!0;const d=c.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":B2,d||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),d)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return e().catch(o)})};function H2(t){const e=t-1;return e*e*e+1}const U2="upload://";function zl(t){return t.startsWith(U2)}const Lu=t=>t,Mn=t=>t;var bt;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const o={};for(const s of i)o[s]=s;return o},t.getValidEnumValues=i=>{const o=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(const a of o)s[a]=i[a];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const o=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},t.find=(i,o)=>{for(const s of i)if(o(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(bt||(bt={}));var Kb;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Kb||(Kb={}));const Ne=bt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Oo=t=>{switch(typeof t){case"undefined":return Ne.undefined;case"string":return Ne.string;case"number":return Number.isNaN(t)?Ne.nan:Ne.number;case"boolean":return Ne.boolean;case"function":return Ne.function;case"bigint":return Ne.bigint;case"symbol":return Ne.symbol;case"object":return Array.isArray(t)?Ne.array:t===null?Ne.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Ne.promise:typeof Map<"u"&&t instanceof Map?Ne.map:typeof Set<"u"&&t instanceof Set?Ne.set:typeof Date<"u"&&t instanceof Date?Ne.date:Ne.object;default:return Ne.unknown}},xe=bt.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 wo extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(o){return o.message},r={_errors:[]},i=o=>{for(const s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let a=r,l=0;for(;l<s.path.length;){const c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(s))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(e){if(!(e instanceof wo))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,bt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const o=i.path[0];n[o]=n[o]||[],n[o].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}wo.create=t=>new wo(t);const sg=(t,e)=>{let n;switch(t.code){case xe.invalid_type:t.received===Ne.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case xe.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,bt.jsonStringifyReplacer)}`;break;case xe.unrecognized_keys:n=`Unrecognized key(s) in object: ${bt.joinValues(t.keys,", ")}`;break;case xe.invalid_union:n="Invalid input";break;case xe.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${bt.joinValues(t.options)}`;break;case xe.invalid_enum_value:n=`Invalid enum value. Expected ${bt.joinValues(t.options)}, received '${t.received}'`;break;case xe.invalid_arguments:n="Invalid function arguments";break;case xe.invalid_return_type:n="Invalid function return type";break;case xe.invalid_date:n="Invalid date";break;case xe.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:bt.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case xe.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case xe.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case xe.custom:n="Invalid input";break;case xe.invalid_intersection_types:n="Intersection results could not be merged";break;case xe.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case xe.not_finite:n="Number must be finite";break;default:n=e.defaultError,bt.assertNever(t)}return{message:n}};let j2=sg;function W2(){return j2}const K2=t=>{const{data:e,path:n,errorMaps:r,issueData:i}=t,o=[...n,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(s,{data:e,defaultError:a}).message;return{...i,path:o,message:a}};function Ae(t,e){const n=W2(),r=K2({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===sg?void 0:sg].filter(i=>!!i)});t.common.issues.push(r)}class Er{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const i of n){if(i.status==="aborted")return $e;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const i of n){const o=await i.key,s=await i.value;r.push({key:o,value:s})}return Er.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const i of n){const{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return $e;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 $e=Object.freeze({status:"aborted"}),Yl=t=>({status:"dirty",value:t}),$r=t=>({status:"valid",value:t}),qb=t=>t.status==="aborted",Gb=t=>t.status==="dirty",il=t=>t.status==="valid",af=t=>typeof Promise<"u"&&t instanceof Promise;var Fe;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Fe||(Fe={}));class es{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Jb=(t,e)=>{if(il(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new wo(t.common.issues);return this._error=n,this._error}}};function ct(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:i}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,a)=>{const{message:l}=t;return s.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class yt{get description(){return this._def.description}_getType(e){return Oo(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Oo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Er,ctx:{common:e.parent.common,data:e.data,parsedType:Oo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(af(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Oo(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Jb(r,i)}"~validate"(e){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Oo(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:n});return il(o)?{value:o.value}:{issues:n.common.issues}}catch(o){(i=(r=o==null?void 0:o.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(o=>il(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Oo(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(af(i)?i:Promise.resolve(i));return Jb(r,o)}refine(e,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,o)=>{const s=e(i),a=()=>o.addIssue({code:xe.custom,...r(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new sl({schema:this,typeName:et.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Yo.create(this,this._def)}nullable(){return al.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Di.create(this)}promise(){return uf.create(this,this._def)}or(e){return cf.create([this,e],this._def)}and(e){return df.create(this,e,this._def)}transform(e){return new sl({...ct(this._def),schema:this,typeName:et.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new lg({...ct(this._def),innerType:this,defaultValue:n,typeName:et.ZodDefault})}brand(){return new pM({typeName:et.ZodBranded,type:this,...ct(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new cg({...ct(this._def),innerType:this,catchValue:n,typeName:et.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Wv.create(this,e)}readonly(){return dg.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const q2=/^c[^\s-]{8,}$/i,G2=/^[0-9a-z]+$/,J2=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Y2=/^[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,Z2=/^[a-z0-9_-]{21}$/i,X2=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Q2=/^[-+]?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)?)??$/,$2=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,eM="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Mp;const tM=/^(?:(?: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])$/,nM=/^(?:(?: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])$/,rM=/^(([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]))$/,iM=/^(([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])$/,oM=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sM=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bk="((\\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])))",aM=new RegExp(`^${bk}$`);function wk(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function lM(t){return new RegExp(`^${wk(t)}$`)}function cM(t){let e=`${bk}T${wk(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function dM(t,e){return!!((e==="v4"||!e)&&tM.test(t)||(e==="v6"||!e)&&rM.test(t))}function uM(t,e){if(!X2.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function fM(t,e){return!!((e==="v4"||!e)&&nM.test(t)||(e==="v6"||!e)&&iM.test(t))}class _s extends yt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ne.string){const o=this._getOrReturnCtx(e);return Ae(o,{code:xe.invalid_type,expected:Ne.string,received:o.parsedType}),$e}const r=new Er;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),Ae(i,{code:xe.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),Ae(i,{code:xe.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?Ae(i,{code:xe.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&Ae(i,{code:xe.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")$2.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"email",code:xe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")Mp||(Mp=new RegExp(eM,"u")),Mp.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"emoji",code:xe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")Y2.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"uuid",code:xe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")Z2.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"nanoid",code:xe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")q2.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"cuid",code:xe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")G2.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"cuid2",code:xe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")J2.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"ulid",code:xe.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Ae(i,{validation:"url",code:xe.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),Ae(i,{validation:"regex",code:xe.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),Ae(i,{code:xe.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),Ae(i,{code:xe.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),Ae(i,{code:xe.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?cM(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{code:xe.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?aM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{code:xe.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?lM(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{code:xe.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?Q2.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"duration",code:xe.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?dM(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"ip",code:xe.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?uM(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"jwt",code:xe.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?fM(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"cidr",code:xe.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?oM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"base64",code:xe.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?sM.test(e.data)||(i=this._getOrReturnCtx(e,i),Ae(i,{validation:"base64url",code:xe.invalid_string,message:o.message}),r.dirty()):bt.assertNever(o);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:xe.invalid_string,...Fe.errToObj(r)})}_addCheck(e){return new _s({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Fe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Fe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Fe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Fe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Fe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Fe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Fe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Fe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Fe.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Fe.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Fe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Fe.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Fe.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,...Fe.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,...Fe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Fe.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...Fe.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...Fe.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...Fe.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...Fe.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...Fe.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...Fe.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...Fe.errToObj(n)})}nonempty(e){return this.min(1,Fe.errToObj(e))}trim(){return new _s({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new _s({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new _s({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}_s.create=t=>new _s({checks:[],typeName:et.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...ct(t)});function hM(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,o=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return o%s/10**i}class Mc extends yt{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)!==Ne.number){const o=this._getOrReturnCtx(e);return Ae(o,{code:xe.invalid_type,expected:Ne.number,received:o.parsedType}),$e}let r;const i=new Er;for(const o of this._def.checks)o.kind==="int"?bt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),Ae(r,{code:xe.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),Ae(r,{code:xe.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),Ae(r,{code:xe.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?hM(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),Ae(r,{code:xe.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),Ae(r,{code:xe.not_finite,message:o.message}),i.dirty()):bt.assertNever(o);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,Fe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Fe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Fe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Fe.toString(n))}setLimit(e,n,r,i){return new Mc({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Fe.toString(i)}]})}_addCheck(e){return new Mc({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Fe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Fe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Fe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Fe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Fe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Fe.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:Fe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Fe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Fe.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&bt.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Mc.create=t=>new Mc({checks:[],typeName:et.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...ct(t)});class Oc extends yt{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)!==Ne.bigint)return this._getInvalidInput(e);let r;const i=new Er;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),Ae(r,{code:xe.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),Ae(r,{code:xe.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),Ae(r,{code:xe.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):bt.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return Ae(n,{code:xe.invalid_type,expected:Ne.bigint,received:n.parsedType}),$e}gte(e,n){return this.setLimit("min",e,!0,Fe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Fe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Fe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Fe.toString(n))}setLimit(e,n,r,i){return new Oc({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Fe.toString(i)}]})}_addCheck(e){return new Oc({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Fe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Fe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Fe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Fe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Fe.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Oc.create=t=>new Oc({checks:[],typeName:et.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...ct(t)});class Yb extends yt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ne.boolean){const r=this._getOrReturnCtx(e);return Ae(r,{code:xe.invalid_type,expected:Ne.boolean,received:r.parsedType}),$e}return $r(e.data)}}Yb.create=t=>new Yb({typeName:et.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...ct(t)});class lf extends yt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ne.date){const o=this._getOrReturnCtx(e);return Ae(o,{code:xe.invalid_type,expected:Ne.date,received:o.parsedType}),$e}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return Ae(o,{code:xe.invalid_date}),$e}const r=new Er;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),Ae(i,{code:xe.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),Ae(i,{code:xe.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):bt.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new lf({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:Fe.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:Fe.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}lf.create=t=>new lf({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:et.ZodDate,...ct(t)});class Zb extends yt{_parse(e){if(this._getType(e)!==Ne.symbol){const r=this._getOrReturnCtx(e);return Ae(r,{code:xe.invalid_type,expected:Ne.symbol,received:r.parsedType}),$e}return $r(e.data)}}Zb.create=t=>new Zb({typeName:et.ZodSymbol,...ct(t)});class Xb extends yt{_parse(e){if(this._getType(e)!==Ne.undefined){const r=this._getOrReturnCtx(e);return Ae(r,{code:xe.invalid_type,expected:Ne.undefined,received:r.parsedType}),$e}return $r(e.data)}}Xb.create=t=>new Xb({typeName:et.ZodUndefined,...ct(t)});class Qb extends yt{_parse(e){if(this._getType(e)!==Ne.null){const r=this._getOrReturnCtx(e);return Ae(r,{code:xe.invalid_type,expected:Ne.null,received:r.parsedType}),$e}return $r(e.data)}}Qb.create=t=>new Qb({typeName:et.ZodNull,...ct(t)});class $b extends yt{constructor(){super(...arguments),this._any=!0}_parse(e){return $r(e.data)}}$b.create=t=>new $b({typeName:et.ZodAny,...ct(t)});class ew extends yt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $r(e.data)}}ew.create=t=>new ew({typeName:et.ZodUnknown,...ct(t)});class ts extends yt{_parse(e){const n=this._getOrReturnCtx(e);return Ae(n,{code:xe.invalid_type,expected:Ne.never,received:n.parsedType}),$e}}ts.create=t=>new ts({typeName:et.ZodNever,...ct(t)});class tw extends yt{_parse(e){if(this._getType(e)!==Ne.undefined){const r=this._getOrReturnCtx(e);return Ae(r,{code:xe.invalid_type,expected:Ne.void,received:r.parsedType}),$e}return $r(e.data)}}tw.create=t=>new tw({typeName:et.ZodVoid,...ct(t)});class Di extends yt{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==Ne.array)return Ae(n,{code:xe.invalid_type,expected:Ne.array,received:n.parsedType}),$e;if(i.exactLength!==null){const s=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(s||a)&&(Ae(n,{code:s?xe.too_big:xe.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(Ae(n,{code:xe.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(Ae(n,{code:xe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((s,a)=>i.type._parseAsync(new es(n,s,n.path,a)))).then(s=>Er.mergeArray(r,s));const o=[...n.data].map((s,a)=>i.type._parseSync(new es(n,s,n.path,a)));return Er.mergeArray(r,o)}get element(){return this._def.type}min(e,n){return new Di({...this._def,minLength:{value:e,message:Fe.toString(n)}})}max(e,n){return new Di({...this._def,maxLength:{value:e,message:Fe.toString(n)}})}length(e,n){return new Di({...this._def,exactLength:{value:e,message:Fe.toString(n)}})}nonempty(e){return this.min(1,e)}}Di.create=(t,e)=>new Di({type:t,minLength:null,maxLength:null,exactLength:null,typeName:et.ZodArray,...ct(e)});function ka(t){if(t instanceof un){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Yo.create(ka(r))}return new un({...t._def,shape:()=>e})}else return t instanceof Di?new Di({...t._def,type:ka(t.element)}):t instanceof Yo?Yo.create(ka(t.unwrap())):t instanceof al?al.create(ka(t.unwrap())):t instanceof Js?Js.create(t.items.map(e=>ka(e))):t}class un extends yt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=bt.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==Ne.object){const c=this._getOrReturnCtx(e);return Ae(c,{code:xe.invalid_type,expected:Ne.object,received:c.parsedType}),$e}const{status:r,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof ts&&this._def.unknownKeys==="strip"))for(const c in i.data)s.includes(c)||a.push(c);const l=[];for(const c of s){const d=o[c],f=i.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new es(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof ts){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&&(Ae(i,{code:xe.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of a){const f=i.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new es(i,f,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const f=await d.key,h=await d.value;c.push({key:f,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>Er.mergeObjectSync(r,c)):Er.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return Fe.errToObj,new un({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var o,s;const i=((s=(o=this._def).errorMap)==null?void 0:s.call(o,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:Fe.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new un({...this._def,unknownKeys:"strip"})}passthrough(){return new un({...this._def,unknownKeys:"passthrough"})}extend(e){return new un({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new un({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:et.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new un({...this._def,catchall:e})}pick(e){const n={};for(const r of bt.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new un({...this._def,shape:()=>n})}omit(e){const n={};for(const r of bt.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new un({...this._def,shape:()=>n})}deepPartial(){return ka(this)}partial(e){const n={};for(const r of bt.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new un({...this._def,shape:()=>n})}required(e){const n={};for(const r of bt.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof Yo;)o=o._def.innerType;n[r]=o}return new un({...this._def,shape:()=>n})}keyof(){return xk(bt.objectKeys(this.shape))}}un.create=(t,e)=>new un({shape:()=>t,unknownKeys:"strip",catchall:ts.create(),typeName:et.ZodObject,...ct(e)});un.strictCreate=(t,e)=>new un({shape:()=>t,unknownKeys:"strict",catchall:ts.create(),typeName:et.ZodObject,...ct(e)});un.lazycreate=(t,e)=>new un({shape:t,unknownKeys:"strip",catchall:ts.create(),typeName:et.ZodObject,...ct(e)});class cf extends yt{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function i(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const s=o.map(a=>new wo(a.ctx.common.issues));return Ae(n,{code:xe.invalid_union,unionErrors:s}),$e}if(n.common.async)return Promise.all(r.map(async o=>{const s={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(i);{let o;const s=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(l=>new wo(l));return Ae(n,{code:xe.invalid_union,unionErrors:a}),$e}}get options(){return this._def.options}}cf.create=(t,e)=>new cf({options:t,typeName:et.ZodUnion,...ct(e)});function ag(t,e){const n=Oo(t),r=Oo(e);if(t===e)return{valid:!0,data:t};if(n===Ne.object&&r===Ne.object){const i=bt.objectKeys(e),o=bt.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...e};for(const a of o){const l=ag(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===Ne.array&&r===Ne.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let o=0;o<t.length;o++){const s=t[o],a=e[o],l=ag(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===Ne.date&&r===Ne.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class df extends yt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(qb(o)||qb(s))return $e;const a=ag(o.value,s.value);return a.valid?((Gb(o)||Gb(s))&&n.dirty(),{status:n.value,value:a.data}):(Ae(r,{code:xe.invalid_intersection_types}),$e)};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}))}}df.create=(t,e,n)=>new df({left:t,right:e,typeName:et.ZodIntersection,...ct(n)});class Js extends yt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ne.array)return Ae(r,{code:xe.invalid_type,expected:Ne.array,received:r.parsedType}),$e;if(r.data.length<this._def.items.length)return Ae(r,{code:xe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$e;!this._def.rest&&r.data.length>this._def.items.length&&(Ae(r,{code:xe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...r.data].map((s,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new es(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>Er.mergeArray(n,s)):Er.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new Js({...this._def,rest:e})}}Js.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Js({items:t,typeName:et.ZodTuple,rest:null,...ct(e)})};class nw extends yt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ne.map)return Ae(r,{code:xe.invalid_type,expected:Ne.map,received:r.parsedType}),$e;const i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new es(r,a,r.path,[c,"key"])),value:o._parse(new es(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 $e;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of s){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return $e;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}}}}nw.create=(t,e,n)=>new nw({valueType:e,keyType:t,typeName:et.ZodMap,...ct(n)});class Dc extends yt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==Ne.set)return Ae(r,{code:xe.invalid_type,expected:Ne.set,received:r.parsedType}),$e;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Ae(r,{code:xe.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(Ae(r,{code:xe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const o=this._def.valueType;function s(l){const c=new Set;for(const d of l){if(d.status==="aborted")return $e;d.status==="dirty"&&n.dirty(),c.add(d.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>o._parse(new es(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,n){return new Dc({...this._def,minSize:{value:e,message:Fe.toString(n)}})}max(e,n){return new Dc({...this._def,maxSize:{value:e,message:Fe.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Dc.create=(t,e)=>new Dc({valueType:t,minSize:null,maxSize:null,typeName:et.ZodSet,...ct(e)});class rw extends yt{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}rw.create=(t,e)=>new rw({getter:t,typeName:et.ZodLazy,...ct(e)});class iw extends yt{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return Ae(n,{received:n.data,code:xe.invalid_literal,expected:this._def.value}),$e}return{status:"valid",value:e.data}}get value(){return this._def.value}}iw.create=(t,e)=>new iw({value:t,typeName:et.ZodLiteral,...ct(e)});function xk(t,e){return new ol({values:t,typeName:et.ZodEnum,...ct(e)})}class ol extends yt{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return Ae(n,{expected:bt.joinValues(r),received:n.parsedType,code:xe.invalid_type}),$e}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return Ae(n,{received:n.data,code:xe.invalid_enum_value,options:r}),$e}return $r(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return ol.create(e,{...this._def,...n})}exclude(e,n=this._def){return ol.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}ol.create=xk;class ow extends yt{_parse(e){const n=bt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Ne.string&&r.parsedType!==Ne.number){const i=bt.objectValues(n);return Ae(r,{expected:bt.joinValues(i),received:r.parsedType,code:xe.invalid_type}),$e}if(this._cache||(this._cache=new Set(bt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=bt.objectValues(n);return Ae(r,{received:r.data,code:xe.invalid_enum_value,options:i}),$e}return $r(e.data)}get enum(){return this._def.values}}ow.create=(t,e)=>new ow({values:t,typeName:et.ZodNativeEnum,...ct(e)});class uf extends yt{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==Ne.promise&&n.common.async===!1)return Ae(n,{code:xe.invalid_type,expected:Ne.promise,received:n.parsedType}),$e;const r=n.parsedType===Ne.promise?n.data:Promise.resolve(n.data);return $r(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}uf.create=(t,e)=>new uf({type:t,typeName:et.ZodPromise,...ct(e)});class sl extends yt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===et.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:s=>{Ae(r,s),s.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const s=i.transform(r.data,o);if(r.common.async)return Promise.resolve(s).then(async a=>{if(n.value==="aborted")return $e;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?$e:l.status==="dirty"||n.value==="dirty"?Yl(l.value):l});{if(n.value==="aborted")return $e;const a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?$e:a.status==="dirty"||n.value==="dirty"?Yl(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"?$e:(a.status==="dirty"&&n.dirty(),s(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?$e:(a.status==="dirty"&&n.dirty(),s(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!il(s))return $e;const a=i.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>il(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:n.value,value:a})):$e);bt.assertNever(i)}}sl.create=(t,e,n)=>new sl({schema:t,typeName:et.ZodEffects,effect:e,...ct(n)});sl.createWithPreprocess=(t,e,n)=>new sl({schema:e,effect:{type:"preprocess",transform:t},typeName:et.ZodEffects,...ct(n)});class Yo extends yt{_parse(e){return this._getType(e)===Ne.undefined?$r(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Yo.create=(t,e)=>new Yo({innerType:t,typeName:et.ZodOptional,...ct(e)});class al extends yt{_parse(e){return this._getType(e)===Ne.null?$r(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}al.create=(t,e)=>new al({innerType:t,typeName:et.ZodNullable,...ct(e)});class lg extends yt{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===Ne.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}lg.create=(t,e)=>new lg({innerType:t,typeName:et.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ct(e)});class cg extends yt{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return af(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new wo(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new wo(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}cg.create=(t,e)=>new cg({innerType:t,typeName:et.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ct(e)});class sw extends yt{_parse(e){if(this._getType(e)!==Ne.nan){const r=this._getOrReturnCtx(e);return Ae(r,{code:xe.invalid_type,expected:Ne.nan,received:r.parsedType}),$e}return{status:"valid",value:e.data}}}sw.create=t=>new sw({typeName:et.ZodNaN,...ct(t)});class pM extends yt{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Wv extends yt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?$e:o.status==="dirty"?(n.dirty(),Yl(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"?$e:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new Wv({in:e,out:n,typeName:et.ZodPipeline})}}class dg extends yt{_parse(e){const n=this._def.innerType._parse(e),r=i=>(il(i)&&(i.value=Object.freeze(i.value)),i);return af(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}dg.create=(t,e)=>new dg({innerType:t,typeName:et.ZodReadonly,...ct(e)});var et;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(et||(et={}));ts.create;Di.create;cf.create;df.create;Js.create;const ei=ol.create;uf.create;Yo.create;al.create;ei(["highlight","note","comment"]);ei(["pending","accepted","dismissed"]);ei(["yellow","green","blue","pink"]);ei(["info","warning","error","success"]);const mM=ei(["solo","tandem"]);ei(["user","claude","import"]);ei(["user","claude"]);ei(["accept","dismiss"]);ei(["markdown","json"]);ei(["md","txt","html","docx"]);ei(["RANGE_GONE","RANGE_MOVED","FILE_LOCKED","FILE_NOT_FOUND","NO_DOCUMENT","INVALID_RANGE","INVALID_ARGUMENT","NOT_FOUND","ANNOTATION_RESOLVED","FORMAT_ERROR","PERMISSION_DENIED"]);ei(["CHANNEL_CONNECT_FAILED","MONITOR_CONNECT_FAILED"]);function gM(t){return t.author!=="user"}function ff(t){return t.status==="pending"&&gM(t)}function Dh(t){return`${t}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function ug(){return Dh("ann")}function vM(){return Dh("msg")}function Qd(){return Dh("ntf")}function yM(t){return Dh(t)}const bM="/api/notify-stream",aw="/api/info",wM="/api/open",xM="/api/close",Kv="/api/save",kk="/api/upload",kM="/api/scratchpad",_M="/api/convert",SM="/api/apply-changes",CM="/api/annotation-reply",TM="/api/remove-annotation",EM="/api/chat",AM="/api/launcher/status",MM="/api/launcher/nonce",OM="/api/launcher/relaunch",DM="/api/launcher/start-fresh",IM="/api/launcher/working-directory",lw=3478,Sl=3479,_k="https://github.com/bloknayrb/tandem",Sk=`${_k}/issues/new`,Ih=new Set([".md",".txt",".html",".htm",".docx"]),RM=3e3,NM=3e3,PM=3e4,Ck={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)"},Ic={yellow:"var(--tandem-highlight-yellow)",green:"var(--tandem-highlight-green)",blue:"var(--tandem-highlight-blue)",pink:"var(--tandem-highlight-pink)"};function Tk(t){return t&&t in Ck?t:"yellow"}const cw="tandem",$d="tandem:mode",Ek="tandem:settings",LM="tandem-panel-width",zM="tandem-left-panel-width",Ak={left:zM,right:LM},Mk=1e3,ll=500,cl=3e3,FM="__tandem_ctrl__",xo="annotations",Ok="awareness",fg="userAwareness",BM="mode",VM="selectionDwellMs",dw="chat",zu="documentMeta",Dk="annotationReplies",uw="savedAtVersion",fw="authorship",hw="selection",pw="activity",hg="claude",Fl="openDocuments",Bl="activeDocumentId",Vl="activeDocumentEpoch",Op="generationId",Dp="readOnly",Ip="storeReadOnly",Ik="tandem:showAuthorship",Rk="tandem:showAnnotationDecorations",qv="tandem:recentFiles",HM=20,Gv="tandem:userName",Nk="You",pg="tandem:user-name-changed",Rh=40,mw={error:8e3,warning:6e3,info:4e3},UM=5,Pk="tandem:tutorialCompleted",Lk="tutorial-",zk="tandem:coworkOnboardingSkipped",jM=3e4,S7=2e3,gw="tandem:zoomLevel",vw=.5,yw=2,Hl=1,Nn=`http://127.0.0.1:${Sl}`;function WM(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return btoa(n)}function KM(t){return t.toLowerCase().endsWith(".docx")}async function Fk(t){if(KM(t.name)){const e=await t.arrayBuffer();return WM(e)}return t.text()}const Jv=["editor","navigation","view","document","annotations","claude"];let Fu=I(We(new Map));function qM(t,e={}){if(u(Fu).has(t.id)&&!e.replace){const n=`[actions] id collision: "${t.id}" — existing action silently replaced. Pass { replace: true } to suppress this warning.`;console.warn(n)}return y(Fu,new Map(u(Fu)).set(t.id,t),!0),!0}function Rc(){return u(Fu)}let mg=null;function GM(t){mg=t}function Jt(t,e){if(!mg){console.warn(`[actions] "${t}" invoked before App mounted — deps not wired yet`);return}e(mg)}let gg=I(!1);const JM={get saving(){return u(gg)}};let Rp=!1,Np=!1;async function Yv(){if(!Np){Np=!0;try{const t=await fetch(`${Nn}${kM}`,{method:"POST"});if(!t.ok){const e=await t.json().catch(()=>({}));console.warn("[Tandem] New Scratchpad failed:",e.message??t.statusText)}}catch(t){console.warn("[Tandem] New Scratchpad request failed:",t)}finally{Np=!1}}}function YM(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}let Pp=!1;function ZM(t,e){const n=`.${e}`,r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return t.slice(r+1).includes(".")?t.slice(t.lastIndexOf(".")).toLowerCase()===n?t:`${t.slice(0,t.lastIndexOf("."))}${n}`:`${t}${n}`}function XM(t,e,n){const r=new Blob([t],{type:n}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),setTimeout(()=>URL.revokeObjectURL(i),0)}async function bw(t){if(Pp)return;const{activeDocId:e,notify:n,defaultName:r,sourceFormat:i}=t;if(!e){n("warning","No active document to save.");return}Pp=!0;try{YM()?await QM(e,n,r??"Scratchpad.md"):await $M(e,n,i)}finally{Pp=!1}}async function QM(t,e,n){var a;let r;try{const{save:l}=await Rn(async()=>{const{save:c}=await import("./index-Dm_QtxGQ.js");return{save:c}},__vite__mapDeps([0,1]));r=await l({defaultPath:n,filters:[{name:"Markdown",extensions:["md"]},{name:"Plain Text",extensions:["txt"]}]})}catch(l){e("error",`Save As dialog unavailable: ${l instanceof Error?l.message:l}`);return}if(typeof r!="string"||r.length===0)return;const o=r.toLowerCase().endsWith(".txt")?"txt":"md",s=ZM(r,o);s!==r&&e("info",`Saving as ${o.toUpperCase()} — only .md and .txt are supported.`);try{const l=await fetch(`${Nn}${Kv}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t,targetPath:s,format:o})});if(!l.ok){const f=await l.json().catch(()=>({}));e("error",`Save As failed: ${f.message??l.statusText}`);return}const c=await l.json().catch(()=>null),d=((a=c==null?void 0:c.data)==null?void 0:a.fileName)??s;e("info",`Saved to ${d}.`)}catch(l){e("error",`Save As request failed: ${l instanceof Error?l.message:l}`)}}async function $M(t,e,n){var i,o;const r=n==="txt"?"txt":"md";try{const s=await fetch(`${Nn}${Kv}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t,serialize:!0,format:r})});if(!s.ok){const d=await s.json().catch(()=>({}));e("error",`Save As failed: ${d.message??s.statusText}`);return}const a=await s.json().catch(()=>null),l=(i=a==null?void 0:a.data)==null?void 0:i.content,c=((o=a==null?void 0:a.data)==null?void 0:o.fileName)??`Scratchpad.${r}`;if(typeof l!="string"){e("error","Save As returned no content.");return}XM(l,c,r==="md"?"text/markdown":"text/plain"),e("info","Downloaded; scratchpad remains in-session.")}catch(s){e("error",`Save As request failed: ${s instanceof Error?s.message:s}`)}}async function Bk(t){if(!(!t||Rp)){Rp=!0,y(gg,!0);try{const e=await fetch(`${Nn}${Kv}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:t})});if(!e.ok){const n=await e.json().catch(()=>({}));console.warn("[Tandem] Save failed:",n.message??e.statusText)}}catch(e){console.warn("[Tandem] Save request failed:",e)}finally{Rp=!1,y(gg,!1)}}}let Nc=!1;async function eO(){let t;try{t=await fetch(`${Nn}${AM}`)}catch(e){return{ok:!1,kind:"network",detail:e instanceof Error?e.message:String(e)}}return t.status===404?{ok:!1,kind:"not-built"}:t.ok?{ok:!0,value:await t.json()}:{ok:!1,kind:"server-error",detail:`HTTP ${t.status}`}}async function tO(){let t;try{t=await fetch(`${Nn}${MM}`,{method:"GET"})}catch(n){return{ok:!1,kind:"network",detail:n instanceof Error?n.message:String(n)}}if(t.status===404)return{ok:!1,kind:"not-built"};if(!t.ok)return{ok:!1,kind:"server-error",detail:`HTTP ${t.status}`};const e=await t.json();return typeof e.nonce!="string"?{ok:!1,kind:"server-error",detail:"malformed nonce response"}:{ok:!0,value:e.nonce}}function nO(t){if(!t||/^[a-z]+:\/\//.test(t))return null;const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>0?t.slice(0,e):null}async function Vk(t,e,n,r){const i=await tO();if(!i.ok){t.notify("error",`Failed to acquire launcher nonce: ${i.kind}${i.detail?` (${i.detail})`:""}.`);return}const o=i.value;try{const s=await fetch(`${Nn}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...n,nonce:o})});if(!s.ok){const a=await s.json().catch(()=>({}));t.notify("error",`${r.failPrefix}: ${a.message??s.statusText}`);return}t.notify("info",r.successMessage)}catch(s){t.notify("error",`${r.requestFailPrefix}: ${s instanceof Error?s.message:s}`)}}async function Hk(t){if(Nc)return!1;const e=await eO();if(!e.ok)return e.kind==="not-built"?t.notify("warning","Claude launcher not active in this Tandem build."):e.kind==="network"?t.notify("error",`Cannot reach Tandem server${e.detail?`: ${e.detail}`:""}.`):t.notify("error",`Launcher status check failed${e.detail?`: ${e.detail}`:""}.`),!1;const n=e.value;return n.available?("skillRefresh"in n&&n.skillRefresh&&t.notify("warning",`Bundled skill refresh failed: ${n.skillRefresh.message}. Run \`tandem setup\` to retry.`),!0):(t.notify("warning","Claude launcher not active in this Tandem build."),!1)}async function rO(t){if(!await Hk(t))return;const e=nO(t.getActiveDocumentPath());if(!e){t.notify("warning","Active document isn't saved to a folder. Set a working directory in Settings → Claude Code.");return}if(confirm(`Restart Claude in:
|
|
4
|
+
${e}
|
|
5
|
+
|
|
6
|
+
Your current task may be interrupted.`)){Nc=!0;try{await Vk(t,OM,{cwd:e},{failPrefix:"Relaunch failed",requestFailPrefix:"Relaunch request failed",successMessage:`Claude restarting in ${e}.`})}finally{Nc=!1}}}async function iO(t){if(await Hk(t)&&confirm("Drop Claude's saved conversation and restart fresh. This cannot be undone.")){Nc=!0;try{await Vk(t,DM,{},{failPrefix:"Start fresh failed",requestFailPrefix:"Start-fresh request failed",successMessage:"Claude restarting with a fresh conversation."})}finally{Nc=!1}}}const oO=[{id:"save",label:"Save document",group:"document",shortcut:"Ctrl+S",run(){Jt("save",t=>void Bk(t.getActiveTabId()))}},{id:"settings",label:"Open settings",group:"view",shortcut:"Ctrl+,",run(){Jt("settings",t=>t.openSettings())}},{id:"settings-modal",label:"Open settings (new)",group:"view",shortcut:"Ctrl+Shift+,",run(){Jt("settings-modal",t=>t.openSettingsModal())}},{id:"toggle-mode",label:"Toggle Solo / Tandem mode",group:"document",shortcut:"Ctrl+Shift+M",run(){Jt("toggle-mode",t=>t.toggleSoloMode())}},{id:"new-scratchpad",label:"New Scratchpad",group:"document",shortcut:"Ctrl+N",run(){Yv()}},{id:"save-as",label:"Save As…",group:"document",shortcut:"Ctrl+Shift+S",run(){Jt("save-as",t=>void t.saveAs())}},{id:"close-tab",label:"Close active tab",group:"document",shortcut:"Ctrl+W",run(){Jt("close-tab",t=>t.closeActiveTab())}},{id:"open-file",label:"Open file…",group:"document",shortcut:"Ctrl+O",run(){Jt("open-file",t=>t.openFileDialog())}},{id:"find",label:"Find / Replace",group:"navigation",shortcut:"Ctrl+F",run(){Jt("find",t=>t.openFindBar())}},{id:"find-in-tabs",label:"Find in open tabs",group:"navigation",shortcut:"Ctrl+Shift+F",run(){Jt("find-in-tabs",t=>t.openFindBarTabs())}},{id:"find-next",label:"Find next match",group:"navigation",shortcut:"Ctrl+G",run(){Jt("find-next",t=>t.findNext())}},{id:"find-previous",label:"Find previous match",group:"navigation",shortcut:"Ctrl+Shift+G",run(){Jt("find-previous",t=>t.findPrev())}},{id:"toggle-left-panel",label:"Toggle left panel",group:"view",shortcut:"Alt+Shift+Left",run(){Jt("toggle-left-panel",t=>t.toggleLeftPanel())}},{id:"toggle-right-panel",label:"Toggle right panel",group:"view",shortcut:"Alt+Shift+Right",run(){Jt("toggle-right-panel",t=>t.toggleRightPanel())}},{id:"reopen-closed-tab",label:"Reopen closed tab (this session)",group:"document",shortcut:"Ctrl+Alt+T",run(){Jt("reopen-closed-tab",t=>t.reopenClosedTab())}},{id:"annotation-next",label:"Next annotation",group:"annotations",shortcut:"Alt+]",run(){Jt("annotation-next",t=>t.annotationNext())}},{id:"annotation-previous",label:"Previous annotation",group:"annotations",shortcut:"Alt+[",run(){Jt("annotation-previous",t=>t.annotationPrev())}},{id:"annotation-accept",label:"Accept focused annotation",group:"annotations",shortcut:"Ctrl+Enter",run(){Jt("annotation-accept",t=>t.annotationAccept())}},{id:"annotation-dismiss",label:"Dismiss focused annotation",group:"annotations",shortcut:"Ctrl+Shift+Enter",run(){Jt("annotation-dismiss",t=>t.annotationDismiss())}},{id:"select-block",label:"Select containing block",group:"editor",shortcut:"Alt+L",run(){Jt("select-block",t=>t.selectBlock())}},{id:"toggle-authorship",label:"Toggle authorship colors",group:"view",shortcut:"Ctrl+Alt+A",run(){Jt("toggle-authorship",t=>t.toggleAuthorship())}},{id:"launcher-relaunch-here",label:"Relaunch Claude in this folder",group:"claude",run(){Jt("launcher-relaunch-here",t=>void rO(t))}},{id:"launcher-start-fresh",label:"Start fresh Claude conversation",group:"claude",run(){Jt("launcher-start-fresh",t=>void iO(t))}}];for(const t of oO)qM(t);function Dt(t,e="y"){function n(){if(t.isConnected){if(e==="y"||e==="both"){const o=t.scrollTop>0,s=t.scrollTop+t.clientHeight<t.scrollHeight-1;r("data-overflow-top",o),r("data-overflow-bottom",s)}if(e==="x"||e==="both"){const o=t.scrollLeft>0,s=t.scrollLeft+t.clientWidth<t.scrollWidth-1;r("data-overflow-left",o),r("data-overflow-right",s)}}}function r(o,s){s?t.setAttribute(o,"true"):t.removeAttribute(o)}n(),t.addEventListener("scroll",n,{passive:!0});let i=null;try{i=new ResizeObserver(n),i.observe(t)}catch(o){console.warn("[tandem:scrollFade] ResizeObserver init failed",o)}return{destroy(){t.removeEventListener("scroll",n),i==null||i.disconnect()}}}function Sn(t){this.content=t}Sn.prototype={constructor:Sn,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),o=r.content.slice();return i==-1?o.push(n||t,e):(o[i+1]=e,n&&(o[i]=n)),new Sn(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Sn(n)},addToStart:function(t,e){return new Sn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Sn(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),o=r.find(t);return i.splice(o==-1?i.length:o,0,e,n),new Sn(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Sn.from(t),t.size?new Sn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Sn.from(t),t.size?new Sn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Sn.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Sn.from=function(t){if(t instanceof Sn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Sn(e)};function Uk(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)n++;return n}if(i.content.size||o.content.size){let s=Uk(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function jk(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=t.child(--i),a=e.child(--o),l=s.nodeSize;if(s==a){n-=l,r-=l;continue}if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let c=0,d=Math.min(s.text.length,a.text.length);for(;c<d&&s.text[s.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let c=jk(s.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class me{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,o){for(let s=0,a=0;a<n;s++){let l=this.content[s],c=a+l.nodeSize;if(c>e&&r(l,i+a,o||null,s)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),r,i+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",s=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new me(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let o=0,s=0;s<n;o++){let a=this.content[o],l=s+a.nodeSize;l>e&&((s<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-s),Math.min(a.text.length,n-s)):a=a.cut(Math.max(0,e-s-1),Math.min(a.content.size,n-s-1))),r.push(a),i+=a.nodeSize),s=l}return new me(r,i)}cutByIndex(e,n){return e==n?me.empty:e==0&&n==this.content.length?this:new me(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new me(i,o)}addToStart(e){return new me([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new me(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Uk(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return jk(this,e,n,r)}findIndex(e){if(e==0)return eu(0,e);if(e==this.size)return eu(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),o=r+i.nodeSize;if(o>=e)return o==e?eu(n+1,o):eu(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return me.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new me(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return me.empty;let n,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(n||(n=e.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new me(n||e,r)}static from(e){if(!e)return me.empty;if(e instanceof me)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new me([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}me.empty=new me([],0);const Lp={index:0,offset:0};function eu(t,e){return Lp.index=t,Lp.offset=e,Lp}function hf(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!hf(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!hf(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let It=class vg{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hf(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return vg.none;if(e instanceof vg)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};It.none=[];class pf extends Error{}class Ce{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Kk(this.content,e+this.openStart,n);return r&&new Ce(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ce(Wk(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Ce.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ce(me.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new Ce(e,r,i)}}Ce.empty=new Ce(me.empty,0,0);function Wk(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:s,offset:a}=t.findIndex(n);if(i==e||o.isText){if(a!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(Wk(o.content,e-i-1,n-i-1)))}function Kk(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),s=t.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=Kk(s.content,e-o-1,n,s);return a&&t.replaceChild(i,s.copy(a))}function sO(t,e,n){if(n.openStart>t.depth)throw new pf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new pf("Inconsistent open depths");return qk(t,e,n,0)}function qk(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=qk(t,e,n,r+1);return o.copy(o.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,a=s.content;return Fs(s,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:s,end:a}=aO(n,t);return Fs(o,Jk(t,s,a,e,r))}else return Fs(o,mf(t,e,r))}function Gk(t,e){if(!e.type.compatibleContent(t.type))throw new pf("Cannot join "+e.type.name+" onto "+t.type.name)}function yg(t,e,n){let r=t.node(n);return Gk(r,e.node(n)),r}function zs(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function oc(t,e,n,r){let i=(e||t).node(n),o=0,s=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(zs(t.nodeAfter,r),o++));for(let a=o;a<s;a++)zs(i.child(a),r);e&&e.depth==n&&e.textOffset&&zs(e.nodeBefore,r)}function Fs(t,e){return t.type.checkContent(e),t.copy(e)}function Jk(t,e,n,r,i){let o=t.depth>i&&yg(t,e,i+1),s=r.depth>i&&yg(n,r,i+1),a=[];return oc(null,t,i,a),o&&s&&e.index(i)==n.index(i)?(Gk(o,s),zs(Fs(o,Jk(t,e,n,r,i+1)),a)):(o&&zs(Fs(o,mf(t,e,i+1)),a),oc(e,n,i,a),s&&zs(Fs(s,mf(n,r,i+1)),a)),oc(r,null,i,a),new me(a)}function mf(t,e,n){let r=[];if(oc(null,t,n,r),t.depth>n){let i=yg(t,e,n+1);zs(Fs(i,mf(t,e,n+1)),r)}return oc(e,null,n,r),new me(r)}function aO(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(me.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Pc{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return It.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let a=r;r=i,i=a}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new gf(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let s=e;;){let{index:a,offset:l}=s.content.findIndex(o),c=o-l;if(r.push(s,a,i+l),!c||(s=s.child(a),s.isText))break;o=c-1,i+=l+1}return new Pc(n,r,o)}static resolveCached(e,n){let r=ww.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==n)return s}else ww.set(e,r=new lO);let i=r.elts[r.i]=Pc.resolve(e,n);return r.i=(r.i+1)%cO,i}}class lO{constructor(){this.elts=[],this.i=0}}const cO=12,ww=new WeakMap;class gf{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const dO=Object.create(null);let Zo=class bg{constructor(e,n,r,i=It.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||me.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&hf(this.attrs,n||e.defaultAttrs||dO)&&It.sameSet(this.marks,r||It.none)}copy(e=null){return e==this.content?this:new bg(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new bg(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Ce.empty;let i=this.resolve(e),o=this.resolve(n),s=r?0:i.sharedDepth(n),a=i.start(s),c=i.node(s).content.cut(i.pos-a,o.pos-a);return new Ce(c,i.depth-s,o.depth-s)}replace(e,n,r){return sO(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return Pc.resolveCached(this,e)}resolveNoCache(e){return Pc.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Yk(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=me.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),a=s&&s.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;l<o;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=It.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!It.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=me.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};Zo.prototype.text=void 0;class vf extends Zo{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Yk(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new vf(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new vf(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Yk(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ys{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new uO(e,n);if(r.next==null)return Ys.empty;let i=Zk(r);r.next&&r.err("Unexpected trailing text");let o=yO(vO(i));return bO(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let o=n;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function o(s,a){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return me.from(a.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:f}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let h=o(f,a.concat(d));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let a=i;a.type;a=a.via)s.push(a.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:a,next:l}=o.next[s];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(`
|
|
7
|
+
`)}}Ys.empty=new Ys(!0);class uO{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Zk(t){let e=[];do e.push(fO(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function fO(t){let e=[];do e.push(hO(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function hO(t){let e=gO(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=pO(t,e);else break;return e}function xw(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function pO(t,e){let n=xw(t),r=n;return t.eat(",")&&(t.next!="}"?r=xw(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function mO(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function gO(t){if(t.eat("(")){let e=Zk(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=mO(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function vO(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(s,a,l){let c={term:l,to:a};return e[s].push(c),c}function i(s,a){s.forEach(l=>l.to=a)}function o(s,a){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(o(c,a)),[]);if(s.type=="seq")for(let l=0;;l++){let c=o(s.exprs[l],a);if(l==s.exprs.length-1)return c;i(c,a=n())}else if(s.type=="star"){let l=n();return r(a,l),i(o(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return i(o(s.expr,a),l),i(o(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(a)].concat(o(s.expr,a));if(s.type=="range"){let l=a;for(let c=0;c<s.min;c++){let d=n();i(o(s.expr,l),d),l=d}if(s.max==-1)i(o(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let d=n();r(l,d),i(o(s.expr,l),d),l=d}return[r(l)]}else{if(s.type=="name")return[r(a,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Xk(t,e){return e-t}function kw(t,e){let n=[];return r(e),n.sort(Xk);function r(i){let o=t[i];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(i);for(let s=0;s<o.length;s++){let{term:a,to:l}=o[s];!a&&n.indexOf(l)==-1&&r(l)}}}function yO(t){let e=Object.create(null);return n(kw(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<i.length;d++)i[d][0]==a&&(c=i[d][1]);kw(t,l).forEach(d=>{c||i.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new Ys(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let a=i[s][1].sort(Xk);o.next.push({type:i[s][0],next:e[a.join(",")]||n(a)})}return o}}function bO(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],o=!i.validEnd,s=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];s.push(l.name),o&&!(l.isText||l.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Qk(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function $k(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let o=t[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function e_(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let o=t[i];o.validate&&o.validate(e[i])}}function t_(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new xO(t,r,e[r]);return n}let _w=class n_{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=t_(e,r.attrs),this.defaultAttrs=Qk(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==Ys.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:$k(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Zo(this,this.computeAttrs(e),me.from(n),It.setFrom(r))}createChecked(e=null,n,r){return n=me.from(n),this.checkContent(n),new Zo(this,this.computeAttrs(e),n,It.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=me.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),o=i&&i.fillBefore(me.empty,!0);return o?new Zo(this,e,n.append(o),It.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){e_(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:It.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new n_(o,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function wO(t,e,n){let r=n.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class xO{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?wO(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Nh{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=t_(e,i.attrs),this.excluded=null;let o=Qk(this.attrs);this.instance=o?new It(this,o):null}create(e=null){return!e&&this.instance?this.instance:new It(this,$k(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new Nh(o,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){e_(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let r_=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Sn.from(e.nodes),n.marks=Sn.from(e.marks||{}),this.nodes=_w.compile(this.spec.nodes,this),this.marks=Nh.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]=Ys.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?Sw(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==""?[]:Sw(this,s.split(" "))}this.nodeFromJSON=i=>Zo.fromJSON(this,i),this.markFromJSON=i=>It.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof _w){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new vf(r,r.defaultAttrs,e,It.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Sw(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],o=t.marks[i],s=o;if(o)n.push(o);else for(let a in t.marks){let l=t.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function kO(t){return t.tag!=null}function _O(t){return t.style!=null}let sc=class wg{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(kO(i))this.tags.push(i);else if(_O(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new Tw(this,n,!1);return r.addAll(e,It.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Tw(this,n,!0);return r.addAll(e,It.none,n.from,n.to),Ce.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(TO(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,n,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],a=s.style;if(!(a.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let a=n[s];if((a.priority==null?50:a.priority)<o)break}n.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Ew(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=Ew(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new wg(e,wg.schemaRules(e)))}};const i_={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},SO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},o_={ol:!0,ul:!0},Lc=1,xg=2,ac=4;function Cw(t,e,n){return e!=null?(e?Lc:0)|(e==="full"?xg:0):t&&t.whitespace=="pre"?Lc|xg:n&~ac}class tu{constructor(e,n,r,i,o,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=It.none,this.match=o||(s&ac?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(me.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Lc)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=me.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(me.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!i_.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Tw{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,o,s=Cw(null,n.preserveWhitespace,0)|(r?ac:0);i?o=new tu(i.type,i.attrs,It.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new tu(null,null,It.none,!0,null,s):o=new tu(e.schema.topNodeType,null,It.none,!0,null,s),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,o=i.options&xg?"full":this.localPreserveWS||(i.options&Lc)>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,`
|
|
8
|
+
`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(s.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),a;o_.hasOwnProperty(s)&&this.parser.normalizeLists&&CO(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:SO.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(i_.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),c&&this.sync(o),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
9
|
+
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let a=void 0;;){let l=this.parser.matchStyle(o,s,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,i){let o,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(o=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}o&&this.sync(a)&&this.open--}addAll(e,n,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];s!=a;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,n);this.findAtPoint(e,o)}findPlace(e,n,r){let i,o;for(let s=this.open,a=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,o=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(o);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=It.none;for(let a of i.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):Aw(a.type,e.type))&&(s=a.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,i)),o}enterInner(e,n,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let a=Cw(e,o,s.options);s.options&ac&&s.content.length==0&&(a|=ac);let l=It.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Aw(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new tu(e,n,l,i,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Lc)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=o;l--)if(s(a-1,l))return!0;return!1}else{let d=l>0||l==0&&i?this.nodes[l].type:r&&l>=o?r.node(l-o).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function CO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&o_.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function TO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ew(t){let e={};for(let n in t)e[n]=t[n];return e}function Aw(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],s=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||o.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class da{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=zp(n).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let a=0,l=0;for(;a<o.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(o[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)i=o.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],d=this.serializeMark(c,s.isInline,n);d&&(o.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=Bu(zp(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Bu(zp(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Bu(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new da(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Mw(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Mw(e.marks)}}function Mw(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function zp(t){return t.document||window.document}const Ow=new WeakMap;function EO(t){let e=Ow.get(t);return e===void 0&&Ow.set(t,e=AO(t)),e}function AO(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function Bu(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=EO(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let f in c)if(c[f]!=null){let h=f.indexOf(" ");h>0?l.setAttributeNS(f.slice(0,h),f.slice(h+1),c[f]):f=="style"&&l.style?l.style.cssText=c[f]:l.setAttribute(f,c[f])}}for(let f=d;f<e.length;f++){let h=e[f];if(h===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:m}=Bu(t,h,n,r);if(l.appendChild(p),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const s_=65535,a_=Math.pow(2,16);function MO(t,e){return t+e*a_}function Dw(t){return t&s_}function OO(t){return(t-(t&s_))/a_}const l_=1,c_=2,Vu=4,d_=8;class kg{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&d_)>0}get deletedBefore(){return(this.delInfo&(l_|Vu))>0}get deletedAfter(){return(this.delInfo&(c_|Vu))>0}get deletedAcross(){return(this.delInfo&Vu)>0}}class Sr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Sr.empty)return Sr.empty}recover(e){let n=0,r=Dw(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+OO(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+o],d=this.ranges[a+s],f=l+c;if(e<=f){let h=c?e==l?-1:e==f?1:n:n,p=l+i+(h<0?0:d);if(r)return p;let m=e==(n<0?l:f)?null:MO(a/3,e-l),v=e==l?c_:e==f?l_:Vu;return(n<0?e!=l:e!=f)&&(v|=d_),new kg(p,v,m)}i+=d-c}return r?e+i:new kg(e+i,0,null)}touches(e,n){let r=0,i=Dw(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+o],d=l+c;if(e<=d&&a==i*3)return!0;r+=this.ranges[a+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],a=s-(this.inverted?o:0),l=s+(this.inverted?0:o),c=this.ranges[i+n],d=this.ranges[i+r];e(a,a+c,l,l+d),o+=d-c}}invert(){return new Sr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Sr.empty:new Sr(e<0?[0,-e,0]:[0,0,e])}}Sr.empty=new Sr([]);class zc{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new zc(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new zc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],a=s.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new kg(e,i,null)}}const Fp=Object.create(null);class qn{getMap(){return Sr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Fp[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Fp)throw new RangeError("Duplicate use of step JSON ID "+e);return Fp[e]=n,n.prototype.jsonID=e,n}}class on{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new on(e,null)}static fail(e){return new on(null,e)}static fromReplace(e,n,r,i){try{return on.ok(e.replace(n,r,i))}catch(o){if(o instanceof pf)return on.fail(o.message);throw o}}}function Zv(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(Zv(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return me.fromArray(r)}class jo extends qn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new Ce(Zv(n.content,(s,a)=>!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return on.fromReplace(e,this.from,this.to,o)}invert(){return new Ai(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new jo(n.pos,r.pos,this.mark)}merge(e){return e instanceof jo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new jo(n.from,n.to,e.markFromJSON(n.mark))}}qn.jsonID("addMark",jo);class Ai extends qn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Ce(Zv(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return on.fromReplace(e,this.from,this.to,r)}invert(){return new jo(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ai(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ai&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ai(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ai(n.from,n.to,e.markFromJSON(n.mark))}}qn.jsonID("removeMark",Ai);class Wo extends qn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return on.fromReplace(e,this.pos,this.pos+1,new Ce(me.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Wo(this.pos,n.marks[i]);return new Wo(this.pos,this.mark)}}return new Zs(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Wo(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Wo(n.pos,e.markFromJSON(n.mark))}}qn.jsonID("addNodeMark",Wo);class Zs extends qn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return on.fromReplace(e,this.pos,this.pos+1,new Ce(me.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Wo(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Zs(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Zs(n.pos,e.markFromJSON(n.mark))}}qn.jsonID("removeNodeMark",Zs);class gn extends qn{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&_g(e,this.from,this.to)?on.fail("Structure replace would overwrite content"):on.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Sr([this.from,this.to-this.from,this.slice.size])}invert(e){return new gn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new gn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof gn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Ce.empty:new Ce(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new gn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Ce.empty:new Ce(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new gn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new gn(n.from,n.to,Ce.fromJSON(e,n.slice),!!n.structure)}}qn.jsonID("replace",gn);class yn extends qn{constructor(e,n,r,i,o,s,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=a}apply(e){if(this.structure&&(_g(e,this.from,this.gapFrom)||_g(e,this.gapTo,this.to)))return on.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return on.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?on.fromReplace(e,this.from,this.to,r):on.fail("Content does not fit in gap")}getMap(){return new Sr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new yn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new yn(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new yn(n.from,n.to,n.gapFrom,n.gapTo,Ce.fromJSON(e,n.slice),n.insert,!!n.structure)}}qn.jsonID("replaceAround",yn);function _g(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function DO(t,e,n,r){let i=[],o=[],s,a;t.doc.nodesBetween(e,n,(l,c,d)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+l.nodeSize,n),m=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(m)||(s&&s.to==h&&s.mark.eq(f[v])?s.to=p:i.push(s=new Ai(h,p,f[v])));a&&a.to==h?a.to=p:o.push(a=new jo(h,p,r))}}),i.forEach(l=>t.step(l)),o.forEach(l=>t.step(l))}function IO(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,a)=>{if(!s.isInline)return;o++;let l=null;if(r instanceof Nh){let c=s.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,n);for(let d=0;d<l.length;d++){let f=l[d],h;for(let p=0;p<i.length;p++){let m=i[p];m.step==o-1&&f.eq(i[p].style)&&(h=m)}h?(h.to=c,h.step=o):i.push({style:f,from:Math.max(a,e),to:c,step:o})}}}),i.forEach(s=>t.step(new Ai(s.from,s.to,s.style)))}function Xv(t,e,n,r=n.contentMatch,i=!0){let o=t.doc.nodeAt(e),s=[],a=e+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),d=a+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new gn(a,d,Ce.empty));else{r=f;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Ai(a,d,c.marks[h]));if(i&&c.isText&&n.whitespace!="pre"){let h,p=/\r?\n|\r/g,m;for(;h=p.exec(c.text);)m||(m=new Ce(me.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new gn(a+h.index,a+h.index+h[0].length,m))}}a=d}if(!r.validEnd){let l=r.fillBefore(me.empty,!0);t.replace(a,a,new Ce(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function RO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Cl(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,o=0;;--r){let s=t.$from.node(r),a=t.$from.index(r)+i,l=t.$to.indexAfter(r)-o;if(r<t.depth&&s.canReplace(a,l,n))return r;if(r==0||s.type.spec.isolating||!RO(s,a,l))break;a&&(i=1),l<s.childCount&&(o=1)}return null}function NO(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),a=i.after(o+1),l=s,c=a,d=me.empty,f=0;for(let m=o,v=!1;m>n;m--)v||r.index(m)>0?(v=!0,d=me.from(r.node(m).copy(d)),f++):l--;let h=me.empty,p=0;for(let m=o,v=!1;m>n;m--)v||i.after(m+1)<i.end(m)?(v=!0,h=me.from(i.node(m).copy(h)),p++):c++;t.step(new yn(l,c,s,a,new Ce(d.append(h),f,p),d.size-f,!0))}function Qv(t,e,n=null,r=t){let i=PO(t,e),o=i&&LO(r,e);return o?i.map(Iw).concat({type:e,attrs:n}).concat(o.map(Iw)):null}function Iw(t){return{type:t,attrs:null}}function PO(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return n.canReplaceWith(r,i,s)?o:null}function LO(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:s}function zO(t,e,n){let r=me.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let a=n[s].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=me.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new yn(i,o,i,o,new Ce(r,0,0),n.length,!0))}function FO(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,a)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&BO(t.doc,t.mapping.slice(o).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!m?c=!1:!p&&m&&(c=!0)}c===!1&&f_(t,s,a,o),Xv(t,t.mapping.slice(o).map(a,1),r,void 0,c===null);let d=t.mapping.slice(o),f=d.map(a,1),h=d.map(a+s.nodeSize,1);return t.step(new yn(f,h,f+1,h-1,new Ce(me.from(r.create(l,null,s.marks)),0,0),1,!0)),c===!0&&u_(t,s,a,o),!1}})}function u_(t,e,n,r){e.forEach((i,o)=>{if(i.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(i.text);){let l=t.mapping.slice(r).map(n+1+o+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function f_(t,e,n,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+o);t.replaceWith(s,s+1,e.type.schema.text(`
|
|
10
|
+
`))}})}function BO(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function VO(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new yn(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new Ce(me.from(s),0,0),1,!0))}function uo(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=n-2;c>o;c--,d--){let f=i.node(c),h=i.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(h,f.childCount),m=r&&r[d+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let v=r&&r[d]||f;if(!f.canReplace(h+1,f.childCount)||!v.type.validContent(p))return!1}let a=i.indexAfter(o),l=r&&r[0];return i.node(o).canReplaceWith(a,a,l?l.type:i.node(o+1).type)}function HO(t,e,n=1,r){let i=t.doc.resolve(e),o=me.empty,s=me.empty;for(let a=i.depth,l=i.depth-n,c=n-1;a>l;a--,c--){o=me.from(i.node(a).copy(o));let d=r&&r[c];s=me.from(d?d.type.create(d.attrs,s):i.node(a).copy(s))}t.step(new gn(e,e,new Ce(o.append(s),n,n),!0))}function ds(t,e){let n=t.resolve(e),r=n.index();return h_(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function UO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function h_(t,e){return!!(t&&e&&!t.isLeaf&&UO(t,e))}function Ph(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let o,s,a=r.index(i);if(i==r.depth?(o=r.nodeBefore,s=r.nodeAfter):n>0?(o=r.node(i+1),a++,s=r.node(i).maybeChild(a)):(o=r.node(i).maybeChild(a-1),s=r.node(i+1)),o&&!o.isTextblock&&h_(o,s)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function jO(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),s=o.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let a=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);f_(t,d.node(),d.before(),a)}s.inlineContent&&Xv(t,e+n-1,s,o.node().contentMatchAt(o.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new gn(c,l.map(e+n,-1),Ce.empty,!0)),r===!0){let d=t.doc.resolve(c);u_(t,d.node(),d.before(),t.steps.length)}return t}function WO(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function p_(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let s=r.depth;s>=0;s--){let a=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,l=r.index(s)+(a>0?1:0),c=r.node(s),d=!1;if(o==1)d=c.canReplace(l,l,i);else{let f=c.contentMatchAt(l).findWrapping(i.firstChild.type);d=f&&c.canReplaceWith(l,l,f[0])}if(d)return a==0?r.pos:a<0?r.before(s+1):r.after(s+1)}return null}function Lh(t,e,n=e,r=Ce.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return m_(i,o,r)?new gn(e,n,r):new KO(i,o,r).fit()}function m_(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class KO{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=me.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=me.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,a=i.depth;for(;s&&a&&o.childCount==1;)o=o.firstChild.content,s--,a--;let l=new Ce(o,s,a);return e>-1?new yn(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new gn(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Bp(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,f=null;if(n==1&&(s?c.matchType(s.type)||(f=c.fillBefore(me.from(s),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:f};if(n==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:d};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Bp(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ce(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Bp(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new Ce(Zl(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new Ce(Zl(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let v=0;v<o.length;v++)this.openFrontierNode(o[v]);let s=this.unplaced,a=r?r.content:s.content,l=s.openStart-e,c=0,d=[],{match:f,type:h}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}let p=a.size+e-(s.content.size-s.openEnd);for(;c<a.childCount;){let v=a.child(c),g=f.matchType(v.type);if(!g)break;c++,(c>1||l==0||v.content.size)&&(f=g,d.push(g_(v.mark(h.allowedMarks(v.marks)),c==1?l:0,c==a.childCount?p:-1)))}let m=c==a.childCount;m||(p=-1),this.placed=Xl(this.placed,n,me.from(d)),this.frontier[n].match=f,m&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,g=a;v<p;v++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=m?e==0?Ce.empty:new Ce(Zl(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new Ce(Zl(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Vp(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=Vp(e,n,i,r,o);if(s){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=Vp(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Xl(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Xl(this.placed,this.depth,me.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(me.empty,!0);n.childCount&&(this.placed=Xl(this.placed,this.frontier.length,n))}}function Zl(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Zl(t.firstChild.content,e-1,n)))}function Xl(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Xl(t.lastChild.content,e-1,n)))}function Bp(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function g_(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,g_(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(me.empty,!0)))),t.copy(r)}function Vp(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,s);return a&&!qO(n,o.content,s)?a:null}function qO(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function GO(t){return t.spec.defining||t.spec.definingForContent}function JO(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(m_(i,o,r))return t.step(new gn(e,n,r));let s=y_(i,o);s[s.length-1]==0&&s.pop();let a=-(i.depth+1);s.unshift(a);for(let h=i.depth,p=i.pos-1;h>0;h--,p--){let m=i.node(h).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;s.indexOf(h)>-1?a=h:i.before(h)==p&&s.splice(1,0,-h)}let l=s.indexOf(a),c=[],d=r.openStart;for(let h=r.content,p=0;;p++){let m=h.firstChild;if(c.push(m),p==r.openStart)break;h=m.content}for(let h=d-1;h>=0;h--){let p=c[h],m=GO(p.type);if(m&&!p.sameMarkup(i.node(Math.abs(a)-1)))d=h;else if(m||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+d+1)%(r.openStart+1),m=c[p];if(m)for(let v=0;v<s.length;v++){let g=s[(v+l)%s.length],b=!0;g<0&&(b=!1,g=-g);let x=i.node(g-1),_=i.index(g-1);if(x.canReplaceWith(_,_,m.type,m.marks))return t.replace(i.before(g),b?o.after(g):n,new Ce(v_(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let h=s.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>f));h--){let p=s[h];p<0||(e=i.before(p),n=o.after(p))}}function v_(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(v_(o.content,e+1,n,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(me.empty,!0))}return t}function YO(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=WO(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ce(me.from(r),0,0))}function ZO(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=y_(r,i);for(let s=0;s<o.length;s++){let a=o[s],l=s==o.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return t.delete(r.start(a),i.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return t.delete(r.before(a),i.after(a))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function y_(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(o<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class Na extends qn{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return on.fromReplace(e,this.pos,this.pos+1,new Ce(me.from(i),0,n.isLeaf?0:1))}getMap(){return Sr.empty}invert(e){return new Na(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Na(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Na(n.pos,n.attr,n.value)}}qn.jsonID("attr",Na);class Fc extends qn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return on.ok(r)}getMap(){return Sr.empty}invert(e){return new Fc(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Fc(n.attr,n.value)}}qn.jsonID("docAttr",Fc);let dl=class extends Error{};dl=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};dl.prototype=Object.create(Error.prototype);dl.prototype.constructor=dl;dl.prototype.name="TransformError";class $v{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new zc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new dl(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((o,s,a,l)=>{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Ce.empty){let i=Lh(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ce(me.from(r),0,0))}delete(e,n){return this.replace(e,n,Ce.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return JO(this,e,n,r),this}replaceRangeWith(e,n,r){return YO(this,e,n,r),this}deleteRange(e,n){return ZO(this,e,n),this}lift(e,n){return NO(this,e,n),this}join(e,n=1){return jO(this,e,n),this}wrap(e,n){return zO(this,e,n),this}setBlockType(e,n=e,r,i=null){return FO(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return VO(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Na(e,n,r)),this}setDocAttribute(e,n){return this.step(new Fc(e,n)),this}addNodeMark(e,n){return this.step(new Wo(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof It)n.isInSet(r.marks)&&this.step(new Zs(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Zs(e,o)),i=o.removeFromSet(i);for(let a=s.length-1;a>=0;a--)this.step(s[a])}return this}split(e,n=1,r){return HO(this,e,n,r),this}addMark(e,n,r){return DO(this,e,n,r),this}removeMark(e,n,r){return IO(this,e,n,r),this}clearIncompatible(e,n,r){return Xv(this,e,n,r),this}}const Hp=Object.create(null);class Je{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new b_(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Ce.empty){let r=n.content.lastChild,i=null;for(let a=0;a<n.openEnd;a++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){let{$from:l,$to:c}=s[a],d=e.mapping.slice(o);e.replaceRange(d.map(l.pos),d.map(c.pos),a?Ce.empty:n),a==0&&Pw(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:a}=i[o],l=e.mapping.slice(r),c=l.map(s.pos),d=l.map(a.pos);o?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),Pw(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Be(e):_a(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=n<0?_a(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):_a(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new pr(e.node(0))}static atStart(e){return _a(e,e,0,0,1)||new pr(e)}static atEnd(e){return _a(e,e,e.content.size,e.childCount,-1)||new pr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Hp[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Hp)throw new RangeError("Duplicate use of selection JSON ID "+e);return Hp[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Be.between(this.$anchor,this.$head).getBookmark()}}Je.prototype.visible=!0;class b_{constructor(e,n){this.$from=e,this.$to=n}}let Rw=!1;function Nw(t){!Rw&&!t.parent.inlineContent&&(Rw=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Be extends Je{constructor(e,n=e){Nw(e),Nw(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Je.near(r);let i=e.resolve(n.map(this.anchor));return new Be(i.parent.inlineContent?i:r,r)}replace(e,n=Ce.empty){if(super.replace(e,n),n==Ce.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Be&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new zh(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Be(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=Je.findFrom(n,r,!0)||Je.findFrom(n,-r,!0);if(o)n=o.$head;else return Je.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Je.findFrom(e,-r,!0)||Je.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Be(e,n)}}Je.jsonID("text",Be);class zh{constructor(e,n){this.anchor=e,this.head=n}map(e){return new zh(e.map(this.anchor),e.map(this.head))}resolve(e){return Be.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ue extends Je{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=e.resolve(i);return r?Je.near(o):new Ue(o)}content(){return new Ce(me.from(this.node),0,0)}eq(e){return e instanceof Ue&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ey(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ue(e.resolve(n.anchor))}static create(e,n){return new Ue(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ue.prototype.visible=!1;Je.jsonID("node",Ue);class ey{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new zh(r,r):new ey(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ue.isSelectable(r)?new Ue(n):Je.near(n)}}class pr extends Je{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ce.empty){if(n==Ce.empty){e.delete(0,e.doc.content.size);let r=Je.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new pr(e)}map(e){return new pr(e)}eq(e){return e instanceof pr}getBookmark(){return XO}}Je.jsonID("all",pr);const XO={map(){return this},resolve(t){return new pr(t)}};function _a(t,e,n,r,i,o=!1){if(e.inlineContent)return Be.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let a=e.child(s);if(a.isAtom){if(!o&&Ue.isSelectable(a))return Ue.create(t,n-(i<0?a.nodeSize:0))}else{let l=_a(t,a,n+i,i<0?a.childCount:0,i,o);if(l)return l}n+=a.nodeSize*i}return null}function Pw(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof gn||i instanceof yn))return;let o=t.mapping.maps[r],s;o.forEach((a,l,c,d)=>{s==null&&(s=d)}),t.setSelection(Je.near(t.doc.resolve(s),n))}const Lw=1,nu=2,zw=4;let QO=class extends $v{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Lw)&~nu,this.storedMarks=null,this}get selectionSet(){return(this.updated&Lw)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=nu,this}ensureMarks(e){return It.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&nu)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~nu,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||It.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Je.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=zw,this}get scrolledIntoView(){return(this.updated&zw)>0}};function Fw(t,e){return!e||!t?t:t.bind(e)}class Ql{constructor(e,n,r){this.name=e,this.init=Fw(n.init,r),this.apply=Fw(n.apply,r)}}const $O=[new Ql("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ql("selection",{init(t,e){return t.selection||Je.atStart(e.doc)},apply(t){return t.selection}}),new Ql("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ql("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Up{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=$O.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ql(r.key,r.spec.state,r))})}}class Ma{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let a=this.config.plugins[s];if(a.spec.appendTransaction){let l=i?i[s].n:0,c=i?i[s].state:this,d=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,c,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),o=!0}i&&(i[s]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Ma(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new QO(this)}static create(e){let n=new Up(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ma(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new Up(this.schema,e.plugins),r=n.fields,i=new Ma(n);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Up(e.schema,e.plugins),o=new Ma(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Zo.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=Je.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){o[s.name]=c.fromJSON.call(l,e,n[a],o);return}}o[s.name]=s.init(e,o)}}),o}}function w_(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=w_(i,e,{})),n[r]=i}return n}class wt{constructor(e){this.spec=e,this.props={},e.props&&w_(e.props,this,this.props),this.key=e.key?e.key.key:x_("plugin")}getState(e){return e[this.key]}}const jp=Object.create(null);function x_(t){return t in jp?t+"$"+ ++jp[t]:(jp[t]=0,t+"$")}class Et{constructor(e="key"){this.key=x_(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Sg=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"Ctrl+N",description:"New scratchpad"},{keys:"? or Ctrl+/",description:"Show keyboard shortcuts"},{keys:"Ctrl+Tab",description:"Next document tab"},{keys:"Ctrl+Shift+Tab",description:"Previous document tab"},{keys:"Ctrl+1 – Ctrl+9",description:"Jump to tab by number"},{keys:"Ctrl+Alt+M",description:"Comment on selection (in editor)"},{keys:"Ctrl+Alt+1",description:"Heading 1"},{keys:"Ctrl+Alt+2",description:"Heading 2"},{keys:"Ctrl+Alt+3",description:"Heading 3"},{keys:"Ctrl+Alt+4",description:"Heading 4"},{keys:"Ctrl+Alt+5",description:"Heading 5"},{keys:"Ctrl+Alt+6",description:"Heading 6"}];function Cg(t){const e=[];return t.state.doc.descendants((n,r)=>{n.type.name==="heading"&&n.attrs.level<=3&&e.push({text:n.textContent,level:n.attrs.level,pos:r})}),e}var eD=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>'),tD=E('<li data-testid="palette-empty" style="padding: var(--tandem-space-3) var(--tandem-space-4); font-size: var(--tandem-text-sm); color: var(--tandem-fg-faint); font-style: italic;"> </li>'),nD=E('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>'),rD=E('<span style="font-size: var(--tandem-text-sm);"> </span> <!>',1),iD=E(`<span style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="
|
|
11
|
+
font-size: var(--tandem-text-xs);
|
|
12
|
+
color: var(--tandem-fg-subtle);
|
|
13
|
+
font-family: var(--tandem-font-mono);
|
|
14
|
+
min-width: 20px;
|
|
15
|
+
"> </span> <span> </span></span>`),oD=E('<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>'),sD=E('<span style="display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0;"><span style="font-size: var(--tandem-text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></span> <span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); flex-shrink: 0; margin-left: var(--tandem-space-2);"> </span>',1),aD=E('<span style="font-size: var(--tandem-text-sm);"> </span> <span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>',1),lD=E('<li role="option"><!></li>'),cD=E(`<div role="presentation" style="
|
|
16
|
+
position: fixed; inset: 0;
|
|
17
|
+
background: rgba(0,0,0,0.4);
|
|
18
|
+
z-index: var(--tandem-z-overlay, 200);
|
|
19
|
+
display: flex; align-items: flex-start; justify-content: center;
|
|
20
|
+
padding-top: 15vh;
|
|
21
|
+
"><div data-testid="command-palette" role="dialog" tabindex="-1" aria-modal="true" aria-label="Command palette" style="
|
|
22
|
+
width: 560px; max-width: 90vw;
|
|
23
|
+
background: var(--tandem-surface);
|
|
24
|
+
border: 1px solid var(--tandem-border);
|
|
25
|
+
border-radius: var(--tandem-r-4);
|
|
26
|
+
box-shadow: var(--tandem-shadow-4);
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
display: flex; flex-direction: column;
|
|
29
|
+
"><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);"><input data-testid="palette-input" type="text" aria-label="Search commands" aria-controls="palette-results" style="
|
|
30
|
+
width: 100%; padding: 6px 0;
|
|
31
|
+
font-size: var(--tandem-text-md); color: var(--tandem-fg);
|
|
32
|
+
background: transparent; border: none; outline: none;
|
|
33
|
+
"/> <!></div> <ul id="palette-results" role="listbox" aria-label="Results" class="tandem-scroll-fade-y" style="max-height: 400px; overflow-y: auto; padding: var(--tandem-space-1) 0; list-style: none; margin: 0;"><!></ul> <div style="
|
|
34
|
+
padding: var(--tandem-space-2) var(--tandem-space-4);
|
|
35
|
+
border-top: 1px solid var(--tandem-border);
|
|
36
|
+
display: flex; gap: var(--tandem-space-3);
|
|
37
|
+
font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);
|
|
38
|
+
"><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 dD(t,e){Pe(e,!0);let n=nt(e,"editor",3,null),r=nt(e,"annotations",19,()=>[]),i=I(""),o=I(0),s=I(null);const a=["#","@","?",">"],l=F(()=>a.find(L=>u(i).startsWith(L))??null),c=F(()=>(u(l)?u(i).slice(1):u(i)).trim().toLowerCase()),d=F(()=>{var re;if(u(l)!==null&&u(l)!==">")return[];const L=Rc(),X=u(c),z=[];for(const Q of L.values())(!X||Q.label.toLowerCase().includes(X)||Q.group.toLowerCase().includes(X)||(((re=Q.shortcut)==null?void 0:re.toLowerCase().includes(X))??!1))&&z.push({kind:"action",id:Q.id,action:Q});return z}),f=F(()=>{if(u(l)!=="#")return[];const L=n();if(!L||L.isDestroyed)return[];const X=u(c);return Cg(L).filter(z=>!X||z.text.toLowerCase().includes(X)).map((z,re)=>({kind:"heading",id:`heading-${re}`,...z}))}),h=F(()=>{if(u(l)!=="@")return[];const L=u(c);return r().filter(X=>{var z;return L?X.content.toLowerCase().includes(L)||((z=X.textSnapshot)==null?void 0:z.toLowerCase().includes(L)):!0}).slice(0,50).map(X=>({kind:"annotation",id:`annotation-${X.id}`,label:X.content?X.content.slice(0,60):"(no content)",snippet:X.textSnapshot??"",annotationType:X.type}))}),p=F(()=>{if(u(l)!=="?")return[];const L=u(c),X=Rc(),z=[];for(const re of X.values())re.shortcut&&(!L||re.label.toLowerCase().includes(L)||re.shortcut.toLowerCase().includes(L))&&z.push({kind:"shortcut",id:`shortcut-registry-${re.id}`,keys:re.shortcut,description:re.label,group:re.group});for(let re=0;re<Sg.length;re++){const Q=Sg[re];(!L||Q.description.toLowerCase().includes(L)||Q.keys.toLowerCase().includes(L))&&z.push({kind:"shortcut",id:`shortcut-static-${re}`,keys:Q.keys,description:Q.description,group:"other"})}return z}),m=F(()=>[...u(d),...u(f),...u(h),...u(p)]);he(()=>{u(m),y(o,0)}),he(()=>{e.open&&(y(i,""),y(o,0),Promise.resolve().then(()=>{var L;return(L=u(s))==null?void 0:L.focus()}))});const v={"#":"Search headings…","@":"Search annotations…","?":"Search shortcuts…",">":"Search commands…"},g=F(()=>u(l)?v[u(l)]:"Type a command, # headings, @ annotations, ? shortcuts…");function b(){e.onClose()}function x(L){var X;if(L.kind==="action")b(),L.action.run();else if(L.kind==="heading"){b();const z=n();if(!z||z.isDestroyed)return;const re=L.pos;try{const Q=z.state.doc.resolve(re+1),N=Be.near(Q);z.view.dispatch(z.state.tr.setSelection(N).scrollIntoView()),z.view.focus()}catch{}}else L.kind==="annotation"&&(b(),(X=e.onFocusAnnotation)==null||X.call(e,L.id.replace("annotation-","")))}function _(L){const X=u(m).length;if(L.key==="ArrowDown")L.preventDefault(),y(o,(u(o)+1)%Math.max(1,X));else if(L.key==="ArrowUp")L.preventDefault(),y(o,(u(o)-1+Math.max(1,X))%Math.max(1,X));else if(L.key==="Enter"){L.preventDefault();const z=u(m)[u(o)];z&&x(z)}else L.key==="Escape"&&(L.preventDefault(),b())}function A(L){L.target===L.currentTarget&&b()}var M=ft(),P=Se(M);{var D=L=>{var X=cD(),z=w(X),re=w(z),Q=w(re);pt(Q,ie=>y(s,ie),()=>u(s));var N=k(Q,2);{var B=ie=>{var K=eD(),Y=w(K);{var O=$=>{var le=hr("Searching document headings");S($,le)};J(Y,$=>{u(l)==="#"&&$(O)})}var T=k(Y,2);{var C=$=>{var le=hr("Searching annotations");S($,le)};J(T,$=>{u(l)==="@"&&$(C)})}var Z=k(T,2);{var q=$=>{var le=hr("Showing keyboard shortcuts");S($,le)};J(Z,$=>{u(l)==="?"&&$(q)})}var oe=k(Z,2);{var ge=$=>{var le=hr("Filtering commands");S($,le)};J(oe,$=>{u(l)===">"&&$(ge)})}S(ie,K)};J(N,ie=>{u(l)&&ie(B)})}var j=k(re,2),H=w(j);{var W=ie=>{var K=tD(),Y=w(K);U(()=>te(Y,u(l)==="#"?"No headings found":u(l)==="@"?"No annotations found":u(l)==="?"?"No shortcuts found":"No commands match")),S(ie,K)},ee=ie=>{var K=ft(),Y=Se(K);Ye(Y,19,()=>u(m),O=>O.id,(O,T,C)=>{const Z=F(()=>u(C)===u(o));var q=lD(),oe=w(q);{var ge=ue=>{var pe=rD(),_e=Se(pe),ae=w(_e),de=k(_e,2);{var ye=ke=>{var Ve=nD(),qe=w(Ve);U(()=>te(qe,u(T).action.shortcut)),S(ke,Ve)};J(de,ke=>{u(T).action.shortcut&&ke(ye)})}U(()=>te(ae,u(T).action.label)),S(ue,pe)},$=ue=>{var pe=iD(),_e=w(pe),ae=w(_e),de=k(_e,2),ye=w(de);U(()=>{te(ae,`H${u(T).level??""}`),ve(de,`font-size: var(--tandem-text-sm); padding-left: calc(${u(T).level-1} * var(--tandem-space-2));`),te(ye,u(T).text)}),S(ue,pe)},le=ue=>{var pe=sD(),_e=Se(pe),ae=w(_e),de=w(ae),ye=k(ae,2);{var ke=fe=>{var Ee=oD(),Re=w(Ee);U(()=>te(Re,`"${u(T).snippet??""}"`)),S(fe,Ee)};J(ye,fe=>{u(T).snippet&&fe(ke)})}var Ve=k(_e,2),qe=w(Ve);U(fe=>{te(de,u(T).label),te(qe,fe)},[()=>u(T).annotationType.charAt(0).toUpperCase()+u(T).annotationType.slice(1)]),S(ue,pe)},ce=ue=>{var pe=aD(),_e=Se(pe),ae=w(_e),de=k(_e,2),ye=w(de);U(()=>{te(ae,u(T).description),te(ye,u(T).keys)}),S(ue,pe)};J(oe,ue=>{u(T).kind==="action"?ue(ge):u(T).kind==="heading"?ue($,1):u(T).kind==="annotation"?ue(le,2):u(T).kind==="shortcut"&&ue(ce,3)})}U(()=>{G(q,"id",`palette-item-${u(T).id}`),G(q,"data-testid",`palette-item-${u(T).id}`),G(q,"aria-selected",u(Z)),ve(q,`
|
|
39
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
40
|
+
padding: 8px var(--tandem-space-4);
|
|
41
|
+
cursor: ${u(T).kind==="shortcut"?"default":"pointer"};
|
|
42
|
+
background: ${u(Z)?"var(--tandem-accent-bg)":"transparent"};
|
|
43
|
+
color: ${u(Z)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg)"};
|
|
44
|
+
`)}),R("click",q,()=>x(u(T))),Tt("mouseenter",q,()=>y(o,u(C),!0)),S(O,q)}),S(ie,K)};J(H,ie=>{u(m).length===0?ie(W):ie(ee,-1)})}Tr(j,(ie,K)=>Dt==null?void 0:Dt(ie,K),()=>"y"),U(()=>{G(Q,"placeholder",u(g)),G(Q,"aria-activedescendant",u(m)[u(o)]?`palette-item-${u(m)[u(o)].id}`:void 0)}),R("click",X,A),R("keydown",X,ie=>{ie.key==="Escape"&&b()}),R("keydown",z,_),Bn(Q,()=>u(i),ie=>y(i,ie)),S(L,X)};J(P,L=>{e.open&&L(D)})}S(t,M),Le()}Ke(["click","keydown"]);var uD=E('<div class="tandem-banner tandem-banner--info" role="status" aria-live="polite" data-testid="connection-banner"><span class="tandem-banner__icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 2l20 20"></path><path d="M5.16 5.26A6 6 0 008 17h11a4 4 0 00.74-7.93"></path><path d="M12 7a5 5 0 014.9 4"></path></svg></span> <span class="tandem-banner__message">Connection to the Tandem server has been lost. Ensure the server is running.</span> <button type="button" class="tandem-banner__cta" data-testid="connection-banner-retry">Retry now</button> <button type="button" class="tandem-banner__dismiss" aria-label="Dismiss connection banner"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>');function fD(t,e){var n=uD(),r=k(w(n),4),i=k(r,2);R("click",r,function(...o){var s;(s=e.onRetry)==null||s.apply(this,o)}),R("click",i,function(...o){var s;(s=e.onDismiss)==null||s.apply(this,o)}),S(t,n)}Ke(["click"]);function E7(t){return t?t.osSupported?t.coworkDetected?"normal":"undetected":"unsupported":"loading"}function hD(t){switch(t.kind){case"adminDeclined":return"Admin permission was denied. Retry with admin, or disable Cowork integration.";case"netshNotFound":return"Windows Firewall command (netsh) was not found on PATH. Confirm your Windows install is intact.";case"netshFailure":return`Windows Firewall command failed (exit ${t.exitCode}). Details: ${pD(t.stderrTail)}`;case"subnetDetectionFailed":return"Could not detect the Hyper-V / Cowork VM subnet. Is Claude Desktop Cowork actually set up on this machine?";case"adapterEnumerationFailed":return"Could not enumerate Hyper-V network adapters. Run Tandem as administrator or reboot to refresh the adapter list.";default:return`Unexpected firewall error (${t.kind}). Please restart Tandem.`}}function pD(t){const e=t.trim();return e.length===0?"(no output)":e.length<=200?e:`${e.slice(0,197)}...`}function k_(t){try{const e=JSON.parse(t);if(typeof e=="object"&&e!==null&&"kind"in e&&typeof e.kind=="string")try{return hD(e)}catch(n){return console.error("[cowork] firewallErrorHint failed for:",e,n),t}return t}catch{return t}}function A7(t){switch(t){case"ok":return"Installed";case"alreadyPresent":return"Already installed";case"locked":return"Locked (retrying)";case"schemaDrift":return"Schema drift";case"insecureAcl":return"Insecure ACL";case"failed":return"Failed"}}function M7(t){switch(t){case"ok":case"alreadyPresent":return"success";case"locked":return"warning";case"schemaDrift":case"insecureAcl":case"failed":return"error"}}function O7(t){const e=["failed","schemaDrift","insecureAcl","locked","alreadyPresent","ok"],n=[t.installedPlugins,t.knownMarketplaces,t.coworkSettings];for(const r of e)if(n.includes(r))return r;return"ok"}function __(t,e){return!(!t||e||!t.osSupported||!t.coworkDetected||t.enabled)}function S_(){try{return localStorage.getItem(zk)==="true"}catch{return!1}}function mD(){try{localStorage.setItem(zk,"true")}catch{}}function Nt(){try{return typeof window<"u"&&"__TAURI_INTERNALS__"in window}catch{return!1}}function D7(t){let e=null;return{schedule(n){e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,n()},t)},cancel(){e!==null&&(clearTimeout(e),e=null)}}}const C_="Tauri runtime not available";async function ty(){try{return(await Rn(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Nt()&&console.error("[cowork] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(C_)))}}function gD(t){return t("cowork_get_status")}function T_(t,e){return t("cowork_toggle_integration",{enabled:e})}function I7(t){return t("cowork_rescan")}function R7(t,e){return t("cowork_set_lan_ip_override",{enabled:e})}function vD(t){return t("cowork_retry_admin_elevation")}function E_(t){let e=I(null),n=I(!1),r=I(null),i=null,o=!1,s=!0,a=null;Qr(()=>{s=!1,a!==null&&(clearInterval(a),a=null)});const l=async()=>{if(o){s&&y(n,!1);return}const c=i;if(c)try{const d=await gD(c);if(!s)return;y(e,d,!0),y(r,null)}catch(d){if(!s)return;const f=d instanceof Error?d.message:String(d);if(f===C_){o=!0,a!==null&&(clearInterval(a),a=null),y(n,!1);return}y(r,f,!0)}finally{s&&y(n,!1)}};return he(()=>{if(!t()){y(n,!1);return}let d=!1;return ty().then(f=>{if(!d)return i=f,y(n,!0),l()}).catch(f=>{if(d)return;const h=f instanceof Error?f.message:String(f);y(r,h,!0),y(n,!1)}),a=setInterval(()=>{d||o||l()},jM),()=>{d=!0,a!==null&&(clearInterval(a),a=null)}}),{get status(){return u(e)},get loading(){return u(n)},get error(){return u(r)},refetch:l}}var yD=E(`<div data-testid="cowork-admin-declined-status-error" role="alert" style="position: fixed; bottom: 16px; right: 16px; z-index: 10000; max-width: 400px; border: 1px solid var(--tandem-error-border); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); border-radius: var(--tandem-r-3); padding: 10px 14px; font-size: 12px; line-height: 1.5;">Cowork status check failed: unable to determine if admin elevation was declined. Please
|
|
45
|
+
restart Tandem to restore normal operation.</div>`),bD=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>'),wD=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>'),xD=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>'),kD=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
|
|
46
|
+
it, Tandem can't safely be reached from inside the Cowork VM. Port 3479 is currently
|
|
47
|
+
blocked by a deny rule to protect your machine.</div> <!> <!></div></div>`);function _D(t,e){Pe(e,!0);const n='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',r=E_(()=>!0),i=F(()=>{var g;return((g=r.status)==null?void 0:g.uacDeclined)===!0});let o=I(void 0),s=I(!1),a=I(!1),l=I(null);he(()=>{if(!u(i))return;const g=typeof document<"u"?document.title:null;return typeof document<"u"&&!document.title.startsWith("⚠")&&(document.title=`⚠ ${document.title}`),()=>{typeof document<"u"&&g!==null&&(document.title=g)}}),he(()=>{if(!u(i))return;const g=b=>{if(b.key!=="Tab"||!u(o))return;const x=u(o).querySelectorAll(n);if(x.length===0)return;const _=x[0],A=x[x.length-1],M=document.activeElement;if(!u(o).contains(M)){b.preventDefault(),_.focus();return}b.shiftKey&&M===_?(b.preventDefault(),A.focus()):!b.shiftKey&&M===A&&(b.preventDefault(),_.focus())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)}),he(()=>{var g;u(i)&&((g=u(o))==null||g.focus())});async function c(g,b){y(a,!0),y(l,null);try{const x=await ty();await g(x)}catch(x){const _=x instanceof Error?x.message:String(x),A=k_(_);y(l,`${b}: ${A}`)}finally{y(a,!1)}}async function d(){await c(async g=>{await vD(g),await r.refetch()},"Retry failed")}async function f(){await c(async g=>{await T_(g,!1),await r.refetch()},"Failed to disable Cowork"),y(s,!1)}var h=ft(),p=Se(h);{var m=g=>{var b=yD();S(g,b)},v=g=>{var b=kD(),x=w(b);G(x,"tabindex",-1);var _=k(w(x),4);{var A=L=>{var X=bD(),z=w(X);U(()=>te(z,u(l))),S(L,X)};J(_,L=>{u(l)&&L(A)})}var M=k(_,2);{var P=L=>{var X=wD(),z=k(w(X),4),re=w(z),Q=k(re,2);U(()=>{re.disabled=u(a),Q.disabled=u(a)}),R("click",re,()=>void f()),R("click",Q,()=>{y(s,!1)}),S(L,X)},D=L=>{var X=xD(),z=w(X),re=k(z,2);U(()=>{z.disabled=u(a),re.disabled=u(a)}),R("click",z,()=>{y(s,!0)}),R("click",re,()=>void d()),S(L,X)};J(M,L=>{u(s)?L(P):L(D,-1)})}pt(x,L=>y(o,L),()=>u(o)),S(g,b)};J(p,g=>{r.error&&!r.status?g(m):u(i)&&g(v,1)})}S(t,h),Le()}Ke(["click"]);var SD=E("<span>Cannot reach the Tandem server. Is it running?</span>"),CD=E('<span style="font-family: var(--tandem-font-sans); font-size: 13px; color: var(--tandem-fg-subtle);">Tandem works alongside Claude (the default integration) or any MCP-capable AI client.</span>'),TD=E("<span>No document open. Click + in the tab bar or drop a file here.</span> <!>",1),ED=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 AD(t,e){Pe(e,!0);let n=I(!1);he(()=>{if(e.connected){y(n,!1);return}const a=setTimeout(()=>{y(n,!0)},NM);return()=>clearTimeout(a)});var r=ED(),i=w(r);{var o=a=>{var l=SD();S(a,l)},s=a=>{var l=TD(),c=k(Se(l),2);{var d=f=>{var h=CD();S(f,h)};J(c,f=>{e.connected&&!e.claudeActive&&f(d)})}S(a,l)};J(i,a=>{u(n)?a(o):a(s,-1)})}S(t,r),Le()}function ny(t,e,n=HM){const r=t.filter(i=>i!==e);return[e,...r].slice(0,n)}function ry(){try{const t=localStorage.getItem(qv);if(!t)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}catch(t){return console.warn("[tandem] failed to load recent files:",t),[]}}function iy(t){try{localStorage.setItem(qv,JSON.stringify(t)),A_()}catch(e){console.warn("[tandem] failed to save recent files:",e)}}function MD(){try{localStorage.removeItem(qv),A_()}catch(t){console.warn("[tandem] failed to clear recent files:",t)}}const OD=3e4;let $l=null;function Bw(){const t=Date.now();if($l&&t-$l.ts<OD)return $l.files;const e=ry();return $l={files:e,ts:t},e}function A_(){$l=null}async function us(t,e={}){const{readOnly:n=!1,notFoundMessage:r="File not found.",failureMessage:i="Failed to open file."}=e;try{const o=await fetch(`${Nn}${wM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:t,readOnly:n})});if(!o.ok){let s=i;try{const a=await o.json();a.message&&(s=a.message)}catch{}return o.status===404&&(s=r),{ok:!1,error:s}}return{ok:!0}}catch(o){return console.warn("[tandem] openServerPath failed:",o),{ok:!1,error:"Server unavailable."}}}var DD=E('<input type="file" style="display: none;"/>'),ID=E('<p style="margin: 8px 0 0; font-size: 11px; color: var(--tandem-fg-subtle); text-align: center;">…or drop a file anywhere in the window</p>'),RD=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>'),ND=E('<div data-testid="recent-files-list" style="margin-top: 16px;"><div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;"><span style="font-size: 11px; color: var(--tandem-fg-subtle); text-transform: uppercase; letter-spacing: 0.05em;">Recent</span> <button data-testid="clear-recent-files" type="button" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline;">Clear all</button></div> <div class="tandem-scroll-fade-y" style="max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div></div>'),PD=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>'),LD=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> <button type="button" data-testid="file-open-browse"> </button> <!> <!> <!> <!></div></div>');function zD(t,e){Pe(e,!0);let n=I(null),r=I(!1),i=I(void 0),o=I(We(ry()));const s=Array.from(Ih).sort(),a=s.join(","),l=s.map(H=>H.replace(/^\./,""));function c(H){y(o,(()=>{const W=ny(u(o),H);return iy(W),W})(),!0)}function d(){MD(),y(o,[],!0)}async function f(H){if(!u(r)){y(n,null),y(r,!0);try{const W=await us(H);if(!W.ok){y(n,W.error,!0);return}c(H),e.onClose()}finally{y(r,!1)}}}async function h(){if(!u(r))try{const{open:H}=await Rn(async()=>{const{open:ee}=await import("./index-Dm_QtxGQ.js");return{open:ee}},__vite__mapDeps([0,1])),W=await H({multiple:!1,directory:!1,title:"Open file in Tandem",filters:[{name:"Documents",extensions:l}]});typeof W=="string"&&await f(W)}catch(H){y(n,`File picker unavailable: ${H instanceof Error?H.message:H}`)}}async function p(H){if(!u(r)){y(n,null),y(r,!0);try{const W=await Fk(H),ee=await fetch(`${Nn}${kk}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:H.name,content:W})}),ie=await ee.json();if(!ee.ok){y(n,ie.message??"Failed to open file",!0);return}e.onClose()}catch(W){console.error("FileOpenDialog: upload failed",W),W instanceof SyntaxError?y(n,"Server returned an unexpected response"):W instanceof TypeError?y(n,"Unexpected response format"):y(n,"Cannot reach server. Is it running?")}finally{y(r,!1)}}}function m(H){var ie;const ee=(ie=H.target.files)==null?void 0:ie[0];ee&&p(ee)}function v(){var H;Nt()?h():(H=u(i))==null||H.click()}var g=LD();G(g,"tabindex",-1);var b=w(g),x=w(b),_=k(w(x),2),A=k(x,2);GA(A);var M=w(A),P=k(A,2);{var D=H=>{var W=DD();pt(W,ee=>y(i,ee),()=>u(i)),U(()=>G(W,"accept",a)),R("change",W,m),S(H,W)},L=F(()=>!Nt());J(P,H=>{u(L)&&H(D)})}var X=k(P,2);{var z=H=>{var W=ID();S(H,W)},re=F(()=>Nt());J(X,H=>{u(re)&&H(z)})}var Q=k(X,2);{var N=H=>{var W=ND(),ee=w(W),ie=k(w(ee),2),K=k(ee,2);Ye(K,22,()=>u(o),Y=>Y,(Y,O,T)=>{const C=F(()=>O.split(/[/\\]/)),Z=F(()=>u(C).at(-1)??O),q=F(()=>u(C).slice(0,-1).join("/")||"/");var oe=RD(),ge=w(oe),$=w(ge),le=k(ge,2),ce=w(le);U(()=>{G(oe,"data-testid",`recent-file-${u(T)}`),te($,u(Z)),te(ce,u(q))}),R("click",oe,()=>f(O)),Tt("mouseenter",oe,ue=>{ue.currentTarget.style.background="var(--tandem-surface-muted)"}),Tt("mouseleave",oe,ue=>{ue.currentTarget.style.background="transparent"}),S(Y,oe)}),Tr(K,(Y,O)=>Dt==null?void 0:Dt(Y,O),()=>"y"),R("click",ie,d),S(H,W)};J(Q,H=>{u(o).length>0&&H(N)})}var B=k(Q,2);{var j=H=>{var W=PD(),ee=w(W);U(()=>te(ee,u(n))),S(H,W)};J(B,H=>{u(n)&&H(j)})}U(()=>{A.disabled=u(r),ve(A,`width: 100%; padding: 12px; font-size: 14px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: ${u(r)?"wait":"pointer"}; background: ${u(r)?"var(--tandem-fg-subtle)":"var(--tandem-accent)"}; color: var(--tandem-accent-fg);`),te(M,u(r)?"Opening…":"Browse…")}),R("click",g,H=>{H.target===H.currentTarget&&e.onClose()}),R("keydown",g,H=>{H.key==="Escape"&&e.onClose()}),R("click",_,function(...H){var W;(W=e.onClose)==null||W.apply(this,H)}),R("click",A,v),S(t,g),Le()}Ke(["click","keydown","change"]);const FD="/api/integrations/existing",BD="/api/integrations",VD="/api/integrations/apply",HD="/api/integrations/first-run-needed";function UD(t){return`/api/integrations/secrets/${encodeURIComponent(t)}`}function jD(t){return`/api/models/secrets/${encodeURIComponent(t)}`}const WD=3,KD="KEYCHAIN_UNAVAILABLE",qD="Tauri runtime not available";async function GD(){try{return(await Rn(()=>import("./core-DhEqZVGG.js"),[])).invoke}catch(t){return Nt()&&console.error("[keychain] Failed to load @tauri-apps/api/core:",t),(()=>Promise.reject(new Error(qD)))}}function JD(t,e,n){return t("keychain_set",{account:e,secret:n})}function YD(t,e){return t("keychain_delete",{account:e})}function ZD(t={}){const e=t.fetchFn??((...i)=>globalThis.fetch(...i)),n=t.baseUrl??"",r=t.pathFor??UD;return{async set(i,o){try{const s=await e(`${n}${r(i)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({secret:o})});if(s.status===503){const a=await s.json().catch(()=>null);if((a==null?void 0:a.code)===KD)return{status:"unavailable"}}return s.ok?{status:"ok"}:{status:"error",message:`HTTP ${s.status}`}}catch(s){return{status:"error",message:s instanceof Error?s.message:String(s)}}},async delete(i){await e(`${n}${r(i)}`,{method:"DELETE"}).catch(()=>{})}}}const XD=["keychain-init","Platform secure storage failure","Couldn't access platform secure storage"];function QD(t){return XD.some(e=>t.includes(e))}function $D(t={}){const e=()=>t.invoke?Promise.resolve(t.invoke):GD();return{async set(n,r){try{const i=await e();return await JD(i,n,r),{status:"ok"}}catch(i){const o=i instanceof Error?i.message:String(i);return QD(o)?{status:"unavailable"}:{status:"error",message:o}}},async delete(n){try{const r=await e();await YD(r,n)}catch{}}}}function M_(t={}){return t.force==="tauri"||t.force!=="http"&&Nt()?$D({invoke:t.invoke}):ZD({fetchFn:t.fetchFn,baseUrl:t.baseUrl,pathFor:t.pathFor})}const O_=["anthropic","openai","gemini","local-ollama","local-llamacpp"],eI=50,tI={s:14,m:16,l:18};function D_(){try{return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}const Ln={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:8,primaryTab:"annotations",panelOrder:"chat-editor-annotations",editorWidthPercent:100,selectionDwellMs:Mk,showAuthorship:!0,reduceMotion:!1,textSize:"m",theme:"system",accentHue:275,editorFont:"sans",density:"cozy",defaultMode:"tandem",highContrast:!1,annotationPatterns:!1,selectionToolbar:!0,soloRailHidden:!0,degradedBannerDelayMs:3e4,sidecarRetryStrategy:"exponential",holdAnnotationsWhileOffline:!0,marginView:!1,showAnnotationDecorations:!0,models:[],defaultModelId:null},nI=64,rI=512;function I_(t){if(!Array.isArray(t))return[];const e=[];for(const n of t){if(e.length>=eI)break;if(!n||typeof n!="object")continue;const r=n;if(typeof r.id!="string"||r.id.length===0||r.id.length>64||typeof r.provider!="string"||!O_.includes(r.provider)||typeof r.displayName!="string"||r.displayName.length>256||typeof r.modelId!="string"||r.modelId.length===0||r.modelId.length>256||typeof r.enabled!="boolean")continue;const i={id:r.id,provider:r.provider,displayName:r.displayName,modelId:r.modelId,enabled:r.enabled};if(typeof r.apiKeyRef=="string"&&r.apiKeyRef.length>0&&r.apiKeyRef.length<=nI&&/^[A-Za-z0-9_-]+$/.test(r.apiKeyRef)?i.apiKeyRef=r.apiKeyRef:typeof r.apiKey=="string"&&r.apiKey.length<=rI&&(i._legacyApiKey=r.apiKey),typeof r.endpoint=="string"&&r.endpoint.length<=2048&&(i.endpoint=r.endpoint),r.params&&typeof r.params=="object"&&!Array.isArray(r.params)){const o={};for(const[s,a]of Object.entries(r.params))(typeof a=="number"||typeof a=="string"||typeof a=="boolean")&&(o[s]=a);i.params=o}e.push(i)}return e}const Tg=8;function Vw(t){return{leftPanelVisible:t.leftPanelVisible===!0,rightPanelVisible:t.rightPanelVisible!==!1,schemaVersion:Tg,primaryTab:t.primaryTab==="annotations"?"annotations":"chat",panelOrder:t.panelOrder==="annotations-editor-chat"?"annotations-editor-chat":"chat-editor-annotations",editorWidthPercent:Math.max(40,Math.min(100,Number(t.editorWidthPercent)||Ln.editorWidthPercent)),selectionDwellMs:Math.max(ll,Math.min(cl,Number(t.selectionDwellMs)||Mk)),showAuthorship:t.showAuthorship===!1?!1:Ln.showAuthorship,reduceMotion:typeof t.reduceMotion=="boolean"?t.reduceMotion:D_(),textSize:t.textSize==="s"||t.textSize==="m"||t.textSize==="l"?t.textSize:Ln.textSize,theme:t.theme==="light"||t.theme==="dark"||t.theme==="warm"||t.theme==="system"?t.theme:Ln.theme,accentHue:typeof t.accentHue=="number"&&t.accentHue>=0&&t.accentHue<=360?t.accentHue:Ln.accentHue,editorFont:t.editorFont==="serif"||t.editorFont==="sans"||t.editorFont==="mono"?t.editorFont:Ln.editorFont,density:t.density==="compact"||t.density==="cozy"||t.density==="spacious"?t.density:Ln.density,defaultMode:t.defaultMode==="solo"||t.defaultMode==="tandem"?t.defaultMode:Ln.defaultMode,highContrast:t.highContrast===!0,annotationPatterns:t.annotationPatterns===!0,selectionToolbar:t.selectionToolbar===!1?!1:Ln.selectionToolbar,soloRailHidden:t.soloRailHidden===!1?!1:Ln.soloRailHidden,degradedBannerDelayMs:typeof t.degradedBannerDelayMs=="number"&&t.degradedBannerDelayMs>=5e3&&t.degradedBannerDelayMs<=12e4?t.degradedBannerDelayMs:Ln.degradedBannerDelayMs,sidecarRetryStrategy:t.sidecarRetryStrategy==="exponential"||t.sidecarRetryStrategy==="constant-2s"||t.sidecarRetryStrategy==="manual"?t.sidecarRetryStrategy:Ln.sidecarRetryStrategy,holdAnnotationsWhileOffline:typeof t.holdAnnotationsWhileOffline=="boolean"?t.holdAnnotationsWhileOffline:Ln.holdAnnotationsWhileOffline,marginView:t.marginView===!0,showAnnotationDecorations:t.showAnnotationDecorations===!1?!1:Ln.showAnnotationDecorations,models:I_(t.models),defaultModelId:typeof t.defaultModelId=="string"&&t.defaultModelId.length>0?t.defaultModelId:null}}function iI(){let t;try{t=localStorage.getItem(Ek)}catch{t=null}if(t)try{let e=JSON.parse(t);if((!e||typeof e!="object"||Array.isArray(e))&&(e={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:1}),(typeof e.schemaVersion=="number"?e.schemaVersion:1)===1){const r=e.panelHidden===!0;let i=!1,o=!0;r?(i=!1,o=!1):e.layout==="three-panel"?(i=!0,o=!0):e.layout==="tabbed-left"&&(i=!0,o=!1),e={...e,leftPanelVisible:i,rightPanelVisible:o,schemaVersion:2},delete e.layout,delete e.panelHidden}if(e.schemaVersion===2&&(e={...e,models:[],schemaVersion:3}),e.schemaVersion===3&&(e={...e,schemaVersion:4}),e.schemaVersion===4){const r={...e,schemaVersion:5};delete r.leftRailTabs,delete r.rightRailTabs,e=r}if(e.schemaVersion===5){const r={...e,schemaVersion:6};delete r.showIntegrationWizard,e=r}if(e.schemaVersion===6){const i=(Array.isArray(e.models)?e.models:[]).find(o=>typeof(o==null?void 0:o.id)=="string"&&o.enabled===!0);e={...e,schemaVersion:7,defaultModelId:i&&typeof i.id=="string"?i.id:null}}if(e.schemaVersion===7&&(e={...e,schemaVersion:8}),typeof e.schemaVersion=="number"&&e.schemaVersion>Tg){console.warn(`[tandem] settings schemaVersion=${e.schemaVersion} is newer than v${Tg}; loading defensively without writing.`);const r=Vw(e),i=new Set(Object.keys(r)),o=new Set(["leftRailTabs","rightRailTabs","showIntegrationWizard"]),s={};for(const[a,l]of Object.entries(e))!i.has(a)&&a!=="_readOnly"&&!o.has(a)&&(s[a]=l);return{...r,...s,_readOnly:!0}}return Vw(e)}catch(e){console.warn("[tandem] settings JSON is corrupt, resetting to defaults:",e)}return{...Ln,reduceMotion:D_()}}function oI(t,e){const n={...t,...e},r=I_(n.models);return{...n,editorWidthPercent:Math.max(40,Math.min(100,n.editorWidthPercent)),selectionDwellMs:Math.max(ll,Math.min(cl,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):Ln.accentHue,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,n.degradedBannerDelayMs)),models:r,defaultModelId:typeof n.defaultModelId=="string"&&r.some(i=>i.id===n.defaultModelId)?n.defaultModelId:null}}let ru=null;function oy(){if(ru)return ru;let t=I(We(iI()));return ru={get settings(){return u(t)},updateSettings:n=>{if(u(t)._readOnly)return;const r=oI(u(t),n);try{localStorage.setItem(Ek,JSON.stringify(r)),localStorage.setItem(Ik,String(r.showAuthorship)),localStorage.setItem(Rk,String(r.showAnnotationDecorations))}catch{}y(t,r,!0)}},ru}const Eg=M_({baseUrl:`http://127.0.0.1:${Sl}`,pathFor:jD});function Wp(){const t=new Uint8Array(16);crypto.getRandomValues(t);let e="";for(const n of t)e+=String.fromCharCode(n);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function sI(){return crypto.randomUUID()}function Hw(t){if(t.provider!==void 0&&!O_.includes(t.provider))throw new Error(`Invalid model provider: ${String(t.provider)}`)}async function Kp(t,e){const n=await Eg.set(t,e);if(n.status==="ok")return;const r=n.status==="unavailable"?"KEYCHAIN_UNAVAILABLE":"STORE_FAILED";throw new Error(`Failed to store model key (${r})`)}function R_(t){return{get models(){return t.settings.models},get defaultModelId(){return t.settings.defaultModelId},get hasLegacyKeys(){return t.settings.models.some(e=>typeof e._legacyApiKey=="string")},async addModel(e,n){Hw(e);const r=sI();let i;n&&n.length>0&&(i=Wp(),await Kp(i,n));const o={...e,id:r,...i?{apiKeyRef:i}:{}};return t.updateSettings({models:[...t.settings.models,o]}),r},async updateModel(e,n,r){Hw(n);const i=t.settings.models.find(s=>s.id===e);if(!i)return;let o;r!==void 0&&r.length>0&&(o=Wp(),await Promise.all([Kp(o,r),i.apiKeyRef?Eg.delete(i.apiKeyRef):Promise.resolve()])),t.updateSettings({models:t.settings.models.map(s=>s.id===e?{...s,...n,...o?{apiKeyRef:o}:{}}:s)})},async deleteModel(e){const n=t.settings.models.find(r=>r.id===e);n!=null&&n.apiKeyRef&&await Eg.delete(n.apiKeyRef),t.updateSettings({models:t.settings.models.filter(r=>r.id!==e),defaultModelId:t.settings.defaultModelId===e?null:t.settings.defaultModelId})},toggleEnabled(e){t.updateSettings({models:t.settings.models.map(n=>n.id===e?{...n,enabled:!n.enabled}:n)})},setDefault(e){t.updateSettings({defaultModelId:e})},async migrateLegacyKeys(){const e=t.settings.models,n=e.map((l,c)=>typeof l._legacyApiKey=="string"?c:-1).filter(l=>l>=0);if(n.length===0)return{migrated:0,failed:0};const r=n.map(()=>Wp()),i=await Promise.allSettled(n.map((l,c)=>Kp(r[c],e[l]._legacyApiKey))),o=e.slice();let s=0,a=0;return i.forEach((l,c)=>{const d=n[c];if(l.status==="fulfilled"){const f={...e[d],apiKeyRef:r[c]};delete f._legacyApiKey,o[d]=f,s++}else a++}),s>0&&t.updateSettings({models:o}),{migrated:s,failed:a}}}}var aI=E('<label class="frm-provider-row svelte-1hpwfc5"><input type="radio" name="first-run-provider"/> <span> </span></label>'),lI=E('<label class="frm-field svelte-1hpwfc5"><span class="frm-label svelte-1hpwfc5">API key</span> <input type="password" data-testid="first-run-apikey" autocomplete="off" class="frm-mono svelte-1hpwfc5" placeholder="Paste your provider API key"/></label>'),cI=E('<label class="frm-field svelte-1hpwfc5"><span class="frm-label svelte-1hpwfc5">Endpoint URL</span> <input type="text" data-testid="first-run-endpoint" autocomplete="off" class="frm-mono svelte-1hpwfc5"/></label>'),dI=E('<div role="alert" class="frm-error svelte-1hpwfc5" data-testid="first-run-error"> </div>'),uI=E('<div role="presentation" class="frm-scrim svelte-1hpwfc5" data-testid="first-run-model-modal"><div role="dialog" aria-modal="true" aria-label="Connect an AI model" class="frm-dialog svelte-1hpwfc5"><header class="frm-header svelte-1hpwfc5"><div><h2 class="frm-title svelte-1hpwfc5">Connect an AI model</h2> <div class="frm-step svelte-1hpwfc5">Step 1 of 2 — Tandem stores your key in the OS keychain.</div></div> <button type="button" class="frm-close svelte-1hpwfc5" data-testid="first-run-skip" aria-label="Skip for now">×</button></header> <form class="frm-form svelte-1hpwfc5"><fieldset class="frm-providers svelte-1hpwfc5" data-testid="first-run-providers"><legend class="frm-label svelte-1hpwfc5">Provider</legend> <!></fieldset> <label class="frm-field svelte-1hpwfc5"><span class="frm-label svelte-1hpwfc5">Display name (optional)</span> <input type="text" data-testid="first-run-displayname" autocomplete="off" class="svelte-1hpwfc5"/></label> <label class="frm-field svelte-1hpwfc5"><span class="frm-label svelte-1hpwfc5">Model ID</span> <input type="text" data-testid="first-run-modelid" autocomplete="off" class="frm-mono svelte-1hpwfc5"/></label> <!> <!> <div class="frm-actions svelte-1hpwfc5"><button type="button" data-testid="first-run-skip-secondary" class="frm-btn frm-btn-secondary svelte-1hpwfc5">Skip for now</button> <button type="submit" data-testid="first-run-save" class="frm-btn frm-btn-primary svelte-1hpwfc5"> </button></div></form></div></div>');function fI(t,e){Pe(e,!0);const n=oy(),r=R_(n),i=[{value:"anthropic",label:"Anthropic (Claude)",defaultModelId:"claude-sonnet-4-6",isCloud:!0},{value:"openai",label:"OpenAI",defaultModelId:"gpt-4o",isCloud:!0},{value:"gemini",label:"Gemini (Google)",defaultModelId:"gemini-2.0-flash",isCloud:!0},{value:"local-ollama",label:"Ollama (local)",defaultModelId:"llama3.1:70b",isCloud:!1},{value:"local-llamacpp",label:"llama.cpp (local)",defaultModelId:"local-model",isCloud:!1}];let o=I("anthropic"),s=I(""),a=I(We(i[0].defaultModelId)),l=I(""),c=I("http://localhost:11434"),d=I(!1),f=I(null),h=I(null),p=null;const m=F(()=>i.find(C=>C.value===u(o))??i[0]),v=F(()=>u(m).isCloud),g=F(()=>u(a).trim().length>0&&(u(v)?u(l).trim().length>0:u(c).trim().length>0));he(()=>{const C=vt(()=>u(h));if(C)return p=document.activeElement,C.focus(),()=>{p instanceof HTMLElement&&document.contains(p)&&p.focus()}});function b(C){const Z=i.find(oe=>oe.value===u(o)),q=i.find(oe=>oe.value===C);q&&Z&&u(a)===Z.defaultModelId&&y(a,q.defaultModelId,!0),y(o,C,!0)}async function x(C){if(C.preventDefault(),!(!u(g)||u(d))){y(d,!0),y(f,null);try{const Z=await r.addModel({provider:u(o),displayName:u(s).trim()||u(m).label,modelId:u(a).trim(),enabled:!0,...u(v)?{}:{endpoint:u(c).trim()}},u(v)?u(l).trim():void 0);r.setDefault(Z),e.onComplete()}catch(Z){y(f,Z instanceof Error?Z.message:"Failed to save",!0)}finally{y(d,!1)}}}function _(){e.onComplete()}var A=uI(),M=w(A);G(M,"tabindex",-1);var P=w(M),D=k(w(P),2),L=k(P,2),X=w(L),z=k(w(X),2);Ye(z,17,()=>i,C=>C.value,(C,Z)=>{var q=aI(),oe=w(q),ge=k(oe,2),$=w(ge);U(()=>{$n(oe,u(Z).value),Vn(oe,u(o)===u(Z).value),G(oe,"data-testid",`first-run-provider-${u(Z).value}`),te($,u(Z).label)}),R("change",oe,()=>b(u(Z).value)),S(C,q)});var re=k(X,2),Q=k(w(re),2),N=k(re,2),B=k(w(N),2),j=k(N,2);{var H=C=>{var Z=lI(),q=k(w(Z),2);Bn(q,()=>u(l),oe=>y(l,oe)),S(C,Z)},W=C=>{var Z=cI(),q=k(w(Z),2);Bn(q,()=>u(c),oe=>y(c,oe)),S(C,Z)};J(j,C=>{u(v)?C(H):C(W,-1)})}var ee=k(j,2);{var ie=C=>{var Z=dI(),q=w(Z);U(()=>te(q,u(f))),S(C,Z)};J(ee,C=>{u(f)&&C(ie)})}var K=k(ee,2),Y=w(K),O=k(Y,2),T=w(O);pt(M,C=>y(h,C),()=>u(h)),U(()=>{G(Q,"placeholder",u(m).label),O.disabled=!u(g)||u(d),te(T,u(d)?"Saving…":"Save and continue")}),R("click",A,C=>{C.target===C.currentTarget&&_()}),R("keydown",M,C=>{C.key==="Escape"&&_(),C.key!=="Tab"&&C.stopPropagation()}),R("click",D,_),Tt("submit",L,x),Bn(Q,()=>u(s),C=>y(s,C)),Bn(B,()=>u(a),C=>y(a,C)),R("click",Y,_),S(t,A),Le()}Ke(["click","keydown","change"]);var hI=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),pI=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>'),mI=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),gI=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" class="tandem-scroll-fade-y" 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>,
|
|
48
|
+
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 vI(t,e){Pe(e,!0);const n=F(()=>{const l=Rc(),c=new Map;for(const d of l.values()){if(!d.shortcut)continue;const f=c.get(d.group)??[];f.push({keys:d.shortcut,description:d.label}),c.set(d.group,f)}return Jv.map(d=>({title:d.charAt(0).toUpperCase()+d.slice(1),rows:c.get(d)??[]})).filter(d=>d.rows.length>0)});let r=I(null),i=null;he(()=>{if(!e.open)return;const l=vt(()=>u(r));if(!l)return;i=document.activeElement,l.focus();const c=d=>{l&&!l.contains(d.target)&&l.focus()};return document.addEventListener("focusin",c),()=>{document.removeEventListener("focusin",c),i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),he(()=>{if(!e.open)return;const l=c=>{c.key==="Escape"&&e.onClose()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)});var o=ft(),s=Se(o);{var a=l=>{var c=gI(),d=w(c),f=w(d),h=k(w(f),2),p=k(f,2);Ye(p,17,()=>u(n),g=>g.title,(g,b)=>{var x=pI(),_=w(x),A=w(_),M=k(_,2);Ye(M,21,()=>u(b).rows,P=>P.description,(P,D)=>{var L=hI(),X=Se(L),z=w(X),re=w(z),Q=k(X,2),N=w(Q);U(()=>{te(re,u(D).keys),te(N,u(D).description)}),S(P,L)}),U(()=>te(A,u(b).title)),S(g,x)});var m=k(p,2),v=k(w(m),2);Ye(v,21,()=>Sg,g=>g.description,(g,b)=>{var x=mI(),_=Se(x),A=w(_),M=w(A),P=k(_,2),D=w(P);U(()=>{te(M,u(b).keys),te(D,u(b).description)}),S(g,x)}),pt(d,g=>y(r,g),()=>u(r)),Tr(d,(g,b)=>Dt==null?void 0:Dt(g,b),()=>"y"),R("click",c,function(...g){var b;(b=e.onClose)==null||b.apply(this,g)}),R("click",d,g=>g.stopPropagation()),R("keydown",d,g=>{if(g.key==="Escape"){e.onClose();return}if(g.stopPropagation(),g.key==="Tab"&&u(r)){const b=Array.from(u(r).querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(A=>!A.closest("[hidden]"));if(b.length===0){g.preventDefault();return}const x=b[0],_=b[b.length-1];g.shiftKey&&document.activeElement===x?(g.preventDefault(),_.focus()):!g.shiftKey&&document.activeElement===_&&(g.preventDefault(),x.focus())}}),R("click",h,function(...g){var b;(b=e.onClose)==null||b.apply(this,g)}),S(l,c)};J(s,l=>{e.open&&l(a)})}S(t,o),Le()}Ke(["click","keydown"]);function yI(t){const e=crypto.randomUUID().replace(/-/g,"").slice(0,12);return`${t}-${e}`}function bI(t={}){const e=t.fetchFn??globalThis.fetch.bind(globalThis),n=t.baseUrl??"",r=t.keychainBackend??M_({fetchFn:e,baseUrl:n});let i=I("detect"),o=I(We([])),s=I(We([])),a=I(null),l=I(We([])),c=I(!1),d=0;const f=M=>{y(a,M,!0),y(i,"error")},h=async()=>{const M=++d;y(i,"detect"),y(a,null);try{const P=await e(`${n}${FD}`);if(M!==d)return;if(!P.ok){f(`Could not load existing entries (HTTP ${P.status}).`);return}const D=await P.json();if(M!==d)return;y(o,D.installs,!0)}catch(P){if(M!==d)return;f(P instanceof Error?P.message:String(P))}},p=()=>{y(i,"pick")},m=M=>{y(s,M,!0)},v=()=>{y(i,"secrets")},g=async(M,P)=>{const D=yI(M.id),L=await r.set(D,P);if(L.status==="unavailable"){y(c,!0),y(s,u(s).map(X=>X.id===M.id?{...X,keychainUnavailable:!0,pendingSecret:void 0}:X),!0);return}if(L.status==="error"){f(`Could not store secret: ${L.message}`);return}y(s,u(s).map(X=>X.id===M.id?{...X,config:{...X.config,tokenSecretRef:D},hasStoredSecret:!0,pendingSecret:void 0,keychainUnavailable:!1}:X),!0)},b=()=>{y(i,"review")},x=async()=>{const M=u(s).map(P=>P.config.tokenSecretRef).filter(P=>typeof P=="string"&&P.length>0);await Promise.all(M.map(P=>r.delete(P)))};return{get step(){return u(i)},get existing(){return u(o)},get picked(){return u(s)},get errorMessage(){return u(a)},get applyResults(){return u(l)},get keychainUnavailable(){return u(c)},begin:h,advanceToPick:p,setPicked:m,advanceToSecrets:v,submitSecret:g,advanceToReview:b,save:async()=>{y(i,"saving");const M=u(s).map(D=>{if(D.config.kind==="other-mcp")return{...D.config,apply:"skip"};const L=D.config.configPath,X=u(o).find(re=>re.target.configPath===L),z=(X==null?void 0:X.tandemValidation)!==void 0&&X.tandemValidation.status!=="valid";return{...D.config,apply:z?"skip":"create"}}),P={schemaVersion:WD,integrations:M};try{const D=await e(`${n}${BD}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(P)});if(!D.ok){const re=await D.json().catch(()=>null);await x(),f((re==null?void 0:re.message)??`Could not save (HTTP ${D.status}).`);return}const L=await D.json(),X=await e(`${n}${VD}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:L.ids,confirmationNonce:L.confirmationNonce})});if(!X.ok){const re=await X.json().catch(()=>null);f((re==null?void 0:re.message)??`Could not apply (HTTP ${X.status}).`);return}const z=await X.json();y(l,z.results,!0),y(i,"done")}catch(D){await x(),f(D instanceof Error?D.message:String(D))}},reset:()=>{y(i,"detect"),y(o,[],!0),y(s,[],!0),y(a,null),y(l,[],!0),y(c,!1)}}}var wI=E('<span class="iw-hint svelte-bt94ms">Tandem is already configured here.</span>'),xI=E('<li class="svelte-bt94ms"><strong> </strong> <span> </span> <!></li>'),kI=E('<ul class="iw-existing svelte-bt94ms"></ul>'),_I=E('<section data-testid="integration-wizard-step-detect"><p>Looking for existing AI integrations on your system…</p> <!> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-continue-detect" class="svelte-bt94ms">Continue</button></div></section>'),SI=E('<li class="svelte-bt94ms"><label><input type="checkbox"/> <strong> </strong> <small> </small></label></li>'),CI=E('<section data-testid="integration-wizard-step-pick"><p>Select which AI integrations to register with Tandem.</p> <ul class="iw-pick-list svelte-bt94ms"></ul> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-continue-pick" class="svelte-bt94ms">Continue</button></div></section>'),TI=E(`<p class="iw-warning svelte-bt94ms" data-testid="integration-wizard-keychain-fallback">Your operating system keychain isn't reachable from this Tandem build. Tokens
|
|
49
|
+
entered here can't be saved. Use the environment variable <code>TANDEM_INTEGRATION_<id>_TOKEN</code> instead, or skip this step and
|
|
50
|
+
add the token via your AI client's own configuration.</p>`),EI=E('<em class="iw-stored svelte-bt94ms">Token saved.</em>'),AI=E('<em class="iw-skipped svelte-bt94ms">Skipped (keychain unavailable).</em>'),MI=E('<div class="iw-secret-input svelte-bt94ms"><input type="password" placeholder="Paste auth token (optional)" class="svelte-bt94ms"/> <button type="button">Save token</button></div>'),OI=E('<li class="svelte-bt94ms"><div class="iw-secret-row svelte-bt94ms"><strong> </strong> <small> </small></div> <!></li>'),DI=E(`<section data-testid="integration-wizard-step-secrets"><p>Optional — store an auth token for each integration. Tandem keeps these in your
|
|
51
|
+
operating system's keychain, never in plain text.</p> <!> <ul class="iw-secrets-list svelte-bt94ms"></ul> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-continue-secrets" class="svelte-bt94ms">Continue</button></div></section>`),II=E('<span class="iw-token-badge svelte-bt94ms">Token stored</span>'),RI=E('<li class="svelte-bt94ms"><strong> </strong> <small> </small> <!></li>'),NI=E('<section data-testid="integration-wizard-step-review"><p>Ready to save. Tandem will register these integrations:</p> <ul class="iw-review-list svelte-bt94ms"></ul> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-save" class="svelte-bt94ms">Save and finish</button></div></section>'),PI=E('<section data-testid="integration-wizard-step-saving"><p>Saving integration configuration…</p></section>'),LI=E('<span class="iw-apply-result-message svelte-bt94ms"> </span>'),zI=E('<li><span class="iw-apply-result-id svelte-bt94ms"> </span> <span class="iw-apply-result-status svelte-bt94ms"> </span> <!></li>'),FI=E('<ul class="iw-apply-results svelte-bt94ms"></ul>'),BI=E('<section data-testid="integration-wizard-step-done"><p>Done — Tandem is connected to your AI client(s).</p> <!> <div class="iw-actions svelte-bt94ms"><button type="button" data-testid="integration-wizard-done-close" class="svelte-bt94ms">Close</button></div></section>'),VI=E('<section data-testid="integration-wizard-step-error"><p class="iw-error svelte-bt94ms"> </p> <div class="iw-actions svelte-bt94ms"><button type="button" class="svelte-bt94ms">Start over</button> <button type="button" class="svelte-bt94ms">Close</button></div></section>'),HI=E('<div role="presentation" class="iw-scrim svelte-bt94ms" data-testid="integration-wizard"><div role="dialog" aria-modal="true" aria-label="Integration Setup Wizard" tabindex="-1" class="iw-dialog svelte-bt94ms"><header class="iw-header svelte-bt94ms"><h2 class="iw-title svelte-bt94ms">Connect an AI assistant</h2> <button type="button" class="iw-close svelte-bt94ms" aria-label="Close wizard" data-testid="integration-wizard-close">×</button></header> <!></div></div>');function UI(t,e){Pe(e,!0);const n=bI({baseUrl:`http://127.0.0.1:${Sl}`});let r=I(null),i=null,o=I(We({}));he(()=>{if(!e.open)return;const b=vt(()=>u(r));if(b)return i=document.activeElement,b.focus(),()=>{i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),he(()=>{e.open&&n.begin()}),he(()=>{if(!e.open)return;const b=x=>{x.key==="Escape"&&e.onClose()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)});function s(){n.reset(),y(o,{},!0),e.onClose()}function a(b){return`${b}-${crypto.randomUUID().slice(0,8)}`}function l(b){var x;if(b.target.kind==="claude-code"){const _=((x=b.tandemEntry)==null?void 0:x.url)??"http://127.0.0.1:3479",A=a("claude-code");return{id:A,config:{kind:"claude-code",id:A,label:b.target.label,configPath:b.target.configPath,transport:"http",url:_},hasStoredSecret:!1,keychainUnavailable:!1}}if(b.target.kind==="claude-desktop"){const _=a("claude-desktop");return{id:_,config:{kind:"claude-desktop",id:_,label:b.target.label,configPath:b.target.configPath,transport:"stdio"},hasStoredSecret:!1,keychainUnavailable:!1}}return null}function c(){const b=n.existing.filter(x=>x.status==="ok"||x.status==="missing").map(l).filter(x=>x!==null);n.setPicked(b),n.advanceToPick()}function d(b){const x=n.picked.findIndex(A=>A.config.kind===b.target.kind&&A.config.label===b.target.label);if(x>=0){n.setPicked(n.picked.filter((A,M)=>M!==x));return}const _=l(b);_&&n.setPicked([...n.picked,_])}function f(b){return n.picked.some(x=>x.config.kind===b.target.kind&&x.config.label===b.target.label)}async function h(b){const x=u(o)[b.id]??"";x.length!==0&&(await n.submitSecret(b,x),y(o,{...u(o),[b.id]:""},!0))}function p(b){return b.kind==="claude-code"?"Claude Code · HTTP":b.kind==="claude-desktop"?"Claude Desktop · stdio":`Other MCP · ${b.transport}`}var m=ft(),v=Se(m);{var g=b=>{var x=HI(),_=w(x),A=w(_),M=k(w(A),2),P=k(A,2);{var D=B=>{var j=_I(),H=k(w(j),2);{var W=K=>{var Y=kI();Ye(Y,21,()=>n.existing,O=>O.target.configPath,(O,T)=>{var C=xI(),Z=w(C),q=w(Z),oe=k(Z,2),ge=w(oe),$=k(oe,2);{var le=ce=>{var ue=wI();S(ce,ue)};J($,ce=>{u(T).tandemEntry&&ce(le)})}U(()=>{te(q,u(T).target.label),Xr(oe,1,`iw-status iw-status-${u(T).status??""}`,"svelte-bt94ms"),te(ge,u(T).status)}),S(O,C)}),S(K,Y)};J(H,K=>{n.existing.length>0&&K(W)})}var ee=k(H,2),ie=w(ee);R("click",ie,c),S(B,j)},L=B=>{var j=CI(),H=k(w(j),2);Ye(H,21,()=>n.existing,ie=>ie.target.configPath,(ie,K)=>{var Y=SI(),O=w(Y),T=w(O),C=k(T,2),Z=w(C),q=k(C,2),oe=w(q);U(ge=>{Vn(T,ge),G(T,"data-testid",`integration-wizard-pick-${u(K).target.kind??""}`),te(Z,u(K).target.label),te(oe,u(K).target.configPath)},[()=>f(u(K))]),R("change",T,()=>d(u(K))),S(ie,Y)});var W=k(H,2),ee=w(W);R("click",ee,()=>n.advanceToSecrets()),S(B,j)},X=B=>{var j=DI(),H=k(w(j),2);{var W=Y=>{var O=TI();S(Y,O)};J(H,Y=>{n.keychainUnavailable&&Y(W)})}var ee=k(H,2);Ye(ee,21,()=>n.picked,Y=>Y.id,(Y,O)=>{var T=OI(),C=w(T),Z=w(C),q=w(Z),oe=k(Z,2),ge=w(oe),$=k(C,2);{var le=pe=>{var _e=EI();S(pe,_e)},ce=pe=>{var _e=AI();S(pe,_e)},ue=pe=>{var _e=MI(),ae=w(_e),de=k(ae,2);U(()=>{G(ae,"data-testid",`integration-wizard-secret-input-${u(O).id??""}`),de.disabled=!u(o)[u(O).id],G(de,"data-testid",`integration-wizard-secret-submit-${u(O).id??""}`)}),Bn(ae,()=>u(o)[u(O).id],ye=>u(o)[u(O).id]=ye),R("click",de,()=>h(u(O))),S(pe,_e)};J($,pe=>{u(O).hasStoredSecret?pe(le):u(O).keychainUnavailable?pe(ce,1):pe(ue,-1)})}U(pe=>{te(q,u(O).config.label),te(ge,pe)},[()=>p(u(O).config)]),S(Y,T)});var ie=k(ee,2),K=w(ie);R("click",K,()=>n.advanceToReview()),S(B,j)},z=B=>{var j=NI(),H=k(w(j),2);Ye(H,21,()=>n.picked,ie=>ie.id,(ie,K)=>{var Y=RI(),O=w(Y),T=w(O),C=k(O,2),Z=w(C),q=k(C,2);{var oe=ge=>{var $=II();S(ge,$)};J(q,ge=>{u(K).config.tokenSecretRef&&ge(oe)})}U(ge=>{te(T,u(K).config.label),te(Z,ge)},[()=>p(u(K).config)]),S(ie,Y)});var W=k(H,2),ee=w(W);R("click",ee,()=>n.save()),S(B,j)},re=B=>{var j=PI();S(B,j)},Q=B=>{var j=BI(),H=k(w(j),2);{var W=K=>{var Y=FI();Ye(Y,21,()=>n.applyResults,O=>O.id,(O,T)=>{var C=zI(),Z=w(C),q=w(Z),oe=k(Z,2),ge=w(oe),$=k(oe,2);{var le=ce=>{var ue=LI(),pe=w(ue);U(()=>te(pe,u(T).message)),S(ce,ue)};J($,ce=>{u(T).status==="error"&&u(T).message&&ce(le)})}U(()=>{Xr(C,1,`iw-apply-result iw-apply-result-${u(T).status??""}`,"svelte-bt94ms"),G(C,"data-testid",`integration-wizard-apply-result-${u(T).id??""}`),te(q,u(T).id),te(ge,u(T).status)}),S(O,C)}),S(K,Y)};J(H,K=>{n.applyResults.length>0&&K(W)})}var ee=k(H,2),ie=w(ee);R("click",ie,s),S(B,j)},N=B=>{var j=VI(),H=w(j),W=w(H),ee=k(H,2),ie=w(ee),K=k(ie,2);U(()=>te(W,`Something went wrong: ${n.errorMessage??""}`)),R("click",ie,()=>n.reset()),R("click",K,s),S(B,j)};J(P,B=>{n.step==="detect"?B(D):n.step==="pick"?B(L,1):n.step==="secrets"?B(X,2):n.step==="review"?B(z,3):n.step==="saving"?B(re,4):n.step==="done"?B(Q,5):n.step==="error"&&B(N,6)})}pt(_,B=>y(r,B),()=>u(r)),R("click",x,s),R("click",_,B=>B.stopPropagation()),R("keydown",_,B=>{if(B.key==="Escape"){s();return}B.key!=="Tab"&&B.stopPropagation()}),R("click",M,s),S(b,x)};J(v,b=>{e.open&&b(g)})}S(t,m),Le()}Ke(["click","keydown","change"]);var jI=E("Detected VM subnet: <code> </code>.",1),WI=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>'),KI=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>'),qI=E('<button data-testid="cowork-onboarding-learn-more-btn" type="button">Learn more</button>'),GI=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>'),JI=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>'),YI=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 ZI(t,e){Pe(e,!0);const n="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=I(!1),o=I(!1),s=I(null);async function a(_,A){y(o,!0),y(s,null);try{const M=await ty();return await _(M),!0}catch(M){const P=M instanceof Error?M.message:String(M),D=k_(P);return y(s,`${A}: ${D}`),!1}finally{y(o,!1)}}async function l(){await a(async A=>{await T_(A,!0)},"Failed to enable Cowork")&&e.onAdvance()}function c(){mD(),e.onAdvance()}var d=YI(),f=k(w(d),2),h=k(w(f));{var p=_=>{var A=jI(),M=k(Se(A)),P=w(M);U(()=>te(P,e.status.vethernetCidr)),S(_,A)};J(h,_=>{e.status.vethernetCidr!==null&&_(p)})}var m=k(f,2);{var v=_=>{var A=WI(),M=w(A);U(()=>te(M,u(s))),S(_,A)};J(m,_=>{u(s)&&_(v)})}var g=k(m,2);{var b=_=>{var A=KI(),M=k(w(A),4),P=w(M);ve(P,n);var D=k(P,2);ve(D,r),U(()=>{P.disabled=u(o),D.disabled=u(o)}),R("click",P,()=>void l()),R("click",D,()=>{y(i,!1)}),S(_,A)},x=_=>{var A=JI(),M=w(A);ve(M,n);var P=k(M,2);ve(P,r);var D=k(P,2);{var L=z=>{var re=qI();ve(re,r),U(()=>re.disabled=u(o)),R("click",re,function(...Q){var N;(N=e.onLearnMore)==null||N.apply(this,Q)}),S(z,re)},X=z=>{var re=GI();U(()=>G(re,"href",`${_k}#cowork`)),S(z,re)};J(D,z=>{e.onLearnMore?z(L):z(X,-1)})}U(()=>{M.disabled=u(o),P.disabled=u(o)}),R("click",M,()=>{y(i,!0)}),R("click",P,c),S(_,A)};J(g,_=>{u(i)?_(b):_(x,-1)})}S(t,d),Le()}Ke(["click"]);var XI=E("<div></div>"),QI=E('<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);"></div>'),$I=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),eR=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>'),tR=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 nR(t,e){Pe(e,!0);const n=[{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 your AI (Claude, in the default setup) — 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=Nt(),i=S_(),o=F(()=>r&&__(e.coworkStatus,i)),s=F(()=>n.filter(m=>m.id!=="cowork"||u(o))),a=F(()=>u(s).length-1),l=F(()=>u(s)[e.currentStep]),c=F(()=>e.currentStep>=u(a)),d=F(()=>{var m;return((m=u(l))==null?void 0:m.id)==="cowork"});var f=ft(),h=Se(f);{var p=m=>{var v=tR(),g=w(v);{var b=D=>{var L=QI();Ye(L,20,()=>Array.from({length:u(a)},(X,z)=>z),X=>X,(X,z)=>{var re=XI();U(()=>ve(re,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${z<=e.currentStep?"var(--tandem-accent)":"var(--tandem-border)"}; transition: background 0.2s;`)),S(X,re)}),S(D,L)};J(g,D=>{u(c)||D(b)})}var x=k(g,2);{var _=D=>{ZI(D,{get status(){return e.coworkStatus},get onAdvance(){return e.onNext}})},A=D=>{var L=$I(),X=Se(L),z=w(X),re=k(X,2),Q=w(re);U(()=>{te(z,u(l).title),ve(re,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${u(c)?0:14}px;`),te(Q,u(l).text)}),S(D,L)};J(x,D=>{u(d)&&e.coworkStatus!==null?D(_):D(A,-1)})}var M=k(x,2);{var P=D=>{var L=eR(),X=w(L),z=w(X),re=k(X,2),Q=w(re),N=k(Q,2),B=w(N);U(()=>{te(z,`Step ${e.currentStep+1} of ${u(a)??""}`),te(B,e.currentStep===u(a)-1?"Done":"Next")}),R("click",Q,function(...j){var H;(H=e.onDismiss)==null||H.apply(this,j)}),R("click",N,function(...j){var H;(H=e.onNext)==null||H.apply(this,j)}),S(D,L)};J(M,D=>{!u(c)&&!u(d)&&D(P)})}S(m,v)};J(h,m=>{u(l)&&m(p)})}S(t,f),Le()}Ke(["click"]);const qr=()=>new Map,Ag=t=>{const e=qr();return t.forEach((n,r)=>{e.set(r,n)}),e},ji=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},rR=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},iR=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Xs=()=>new Set,qp=t=>t[t.length-1],oR=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},ns=Array.from,sy=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},ay=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},sR=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},ul=Array.isArray;class N_{constructor(){this._observers=qr()}on(e,n){return ji(this._observers,e,Xs).add(n),n}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return ns((this._observers.get(e)||qr()).values()).forEach(r=>r(...n))}destroy(){this._observers=qr()}}const ui=Math.floor,Hu=Math.abs,fo=(t,e)=>t<e?t:e,fi=(t,e)=>t>e?t:e,P_=t=>t!==0?t<0:1/t<0,Uw=1,jw=2,Gp=4,Jp=8,Bc=32,ho=64,er=128,aR=1<<29,Fh=31,Mg=63,Bs=127,lR=2147483647,yf=Number.MAX_SAFE_INTEGER,Ww=Number.MIN_SAFE_INTEGER,cR=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&ui(t)===t),L_=String.fromCharCode,dR=t=>t.toLowerCase(),uR=/^\s*/g,fR=t=>t.replace(uR,""),hR=/([A-Z])/g,Kw=(t,e)=>fR(t.replace(hR,n=>`${e}${dR(n)}`)),pR=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},Vc=typeof TextEncoder<"u"?new TextEncoder:null,mR=t=>Vc.encode(t),gR=Vc?mR:pR;let lc=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});lc&&lc.decode(new Uint8Array).length===1&&(lc=null);const vR=(t,e)=>sR(e,()=>t).join("");let Ed=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}};const Ad=()=>new Ed,yR=t=>{const e=Ad();return t(e),li(e)},bR=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},li=t=>{const e=new Uint8Array(bR(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},wR=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(fi(n,e)*2),t.cpos=0)},mn=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Og=mn,ut=(t,e)=>{for(;e>Bs;)mn(t,er|Bs&e),e=ui(e/128);mn(t,Bs&e)},ly=(t,e)=>{const n=P_(e);for(n&&(e=-e),mn(t,(e>Mg?er:0)|(n?ho:0)|Mg&e),e=ui(e/64);e>0;)mn(t,(e>Bs?er:0)|Bs&e),e=ui(e/128)},Dg=new Uint8Array(3e4),xR=Dg.length/3,kR=(t,e)=>{if(e.length<xR){const n=Vc.encodeInto(e,Dg).written||0;ut(t,n);for(let r=0;r<n;r++)mn(t,Dg[r])}else br(t,gR(e))},_R=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ut(t,r);for(let i=0;i<r;i++)mn(t,n.codePointAt(i))},Pa=Vc&&Vc.encodeInto?kR:_R,Bh=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=fo(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(fi(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},br=(t,e)=>{ut(t,e.byteLength),Bh(t,e)},cy=(t,e)=>{wR(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},SR=(t,e)=>cy(t,4).setFloat32(0,e,!1),CR=(t,e)=>cy(t,8).setFloat64(0,e,!1),TR=(t,e)=>cy(t,8).setBigInt64(0,e,!1),qw=new DataView(new ArrayBuffer(4)),ER=t=>(qw.setFloat32(0,t),qw.getFloat32(0)===t),fl=(t,e)=>{switch(typeof e){case"string":mn(t,119),Pa(t,e);break;case"number":cR(e)&&Hu(e)<=lR?(mn(t,125),ly(t,e)):ER(e)?(mn(t,124),SR(t,e)):(mn(t,123),CR(t,e));break;case"bigint":mn(t,122),TR(t,e);break;case"object":if(e===null)mn(t,126);else if(ul(e)){mn(t,117),ut(t,e.length);for(let n=0;n<e.length;n++)fl(t,e[n])}else if(e instanceof Uint8Array)mn(t,116),br(t,e);else{mn(t,118);const n=Object.keys(e);ut(t,n.length);for(let r=0;r<n.length;r++){const i=n[r];Pa(t,i),fl(t,e[i])}}break;case"boolean":mn(t,e?120:121);break;default:mn(t,127)}};class Gw extends Ed{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ut(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Jw=t=>{t.count>0&&(ly(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ut(t.encoder,t.count-2))};class Uu{constructor(){this.encoder=new Ed,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Jw(this),this.count=1,this.s=e)}toUint8Array(){return Jw(this),li(this.encoder)}}const Yw=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);ly(t.encoder,e),t.count>1&&ut(t.encoder,t.count-2)}};class Yp{constructor(){this.encoder=new Ed,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Yw(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Yw(this),li(this.encoder)}}class AR{constructor(){this.sarr=[],this.s="",this.lensE=new Uu}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 Ed;return this.sarr.push(this.s),this.s="",Pa(e,this.sarr.join("")),Bh(e,this.lensE.toUint8Array()),li(e)}}const Li=t=>new Error(t),Gr=()=>{throw Li("Method unimplemented")},jn=()=>{throw Li("Unexpected case")},z_=Li("Unexpected end of array"),F_=Li("Integer out of Range");let Vh=class{constructor(e){this.arr=e,this.pos=0}};const Tl=t=>new Vh(t),MR=t=>t.pos!==t.arr.length,OR=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},wr=t=>OR(t,lt(t)),hl=t=>t.arr[t.pos++],lt=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&Bs)*n,n*=128,i<er)return e;if(e>yf)throw F_}throw z_},dy=t=>{let e=t.arr[t.pos++],n=e&Mg,r=64;const i=(e&ho)>0?-1:1;if((e&er)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&Bs)*r,r*=128,e<er)return i*n;if(n>yf)throw F_}throw z_},DR=t=>{let e=lt(t);if(e===0)return"";{let n=String.fromCodePoint(hl(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(hl(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},IR=t=>lc.decode(wr(t)),La=lc?IR:DR,uy=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},RR=t=>uy(t,4).getFloat32(0,!1),NR=t=>uy(t,8).getFloat64(0,!1),PR=t=>uy(t,8).getBigInt64(0,!1),LR=[t=>{},t=>null,dy,RR,NR,PR,t=>!1,t=>!0,La,t=>{const e=lt(t),n={};for(let r=0;r<e;r++){const i=La(t);n[i]=Hc(t)}return n},t=>{const e=lt(t),n=[];for(let r=0;r<e;r++)n.push(Hc(t));return n},wr],Hc=t=>LR[127-hl(t)](t);class Zw extends Vh{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),MR(this)?this.count=lt(this)+1:this.count=-1),this.count--,this.s}}class ju extends Vh{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=dy(this);const e=P_(this.s);this.count=1,e&&(this.s=-this.s,this.count=lt(this)+2)}return this.count--,this.s}}class Zp extends Vh{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=dy(this),n=e&1;this.diff=ui(e/2),this.count=1,n&&(this.count=lt(this)+2)}return this.s+=this.diff,this.count--,this.s}}class zR{constructor(e){this.decoder=new ju(e),this.str=La(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const FR=crypto.getRandomValues.bind(crypto),BR=Math.random,B_=()=>FR(new Uint32Array(1))[0],VR=t=>t[ui(BR()*t.length)],HR="10000000-1000-4000-8000"+-1e11,UR=()=>HR.replace(/[018]/g,t=>(t^B_()&15>>t/4).toString(16)),jR=Date.now,Xw=t=>new Promise(t);Promise.all.bind(Promise);const Qw=t=>t===void 0?null:t;class WR{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let V_=new WR,KR=!0;try{typeof localStorage<"u"&&localStorage&&(V_=localStorage,KR=!1)}catch{}const qR=V_,Uc=Symbol("Equality"),H_=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[Uc])!=null&&n.call(t,e))||!1},GR=t=>typeof t=="object",JR=Object.assign,U_=Object.keys,YR=(t,e)=>{for(const n in t)e(t[n],n)},bf=t=>U_(t).length,ZR=t=>{for(const e in t)return!1;return!0},El=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},fy=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),XR=(t,e)=>t===e||bf(t)===bf(e)&&El(t,(n,r)=>(n!==void 0||fy(e,r))&&H_(e[r],n)),QR=Object.freeze,j_=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&j_(t[e])}return QR(t)},hy=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&hy(t,e,n+1)}},$R=t=>t,Wu=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[Uc]!=null)return t[Uc](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Wu(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(bf(t)!==bf(e))return!1;for(const n in t)if(!fy(t,n)||!Wu(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Wu(t[n],e[n]))return!1;break;default:return!1}return!0},eN=(t,e)=>e.includes(t);var W_={};const pl=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",K_=typeof window<"u"&&typeof document<"u"&&!pl;let yi;const tN=()=>{if(yi===void 0)if(pl){yi=qr();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&yi.set(e,""),e=r):e!==null&&(yi.set(e,r),e=null)}e!==null&&yi.set(e,"")}else typeof location=="object"?(yi=qr(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");yi.set(`--${Kw(e,"-")}`,n),yi.set(`-${Kw(e,"-")}`,n)}})):yi=qr();return yi},Ig=t=>tN().has(t),wf=t=>Qw(pl?W_[t.toUpperCase().replaceAll("-","_")]:qR.getItem(t)),q_=t=>Ig("--"+t)||wf(t)!==null,nN=q_("production"),rN=pl&&eN(W_.FORCE_COLOR,["true","1","2"]),iN=rN||!Ig("--no-colors")&&!q_("no-color")&&(!pl||process.stdout.isTTY)&&(!pl||Ig("--color")||wf("COLORTERM")!==null||(wf("TERM")||"").includes("color")),oN=t=>new Uint8Array(t),sN=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=L_(t[n]);return btoa(e)},aN=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),lN=K_?sN:aN,cN=t=>{const e=oN(t.byteLength);return e.set(t),e},dN=t=>yR(e=>fl(e,t));class uN{constructor(e,n){this.left=e,this.right=n}}const Ji=(t,e)=>new uN(t,e),$w=t=>t.next()>=.5,Xp=(t,e,n)=>ui(t.next()*(n+1-e)+e),G_=(t,e,n)=>ui(t.next()*(n+1-e)+e),py=(t,e,n)=>G_(t,e,n),fN=t=>L_(py(t,97,122)),hN=(t,e=0,n=20)=>{const r=py(t,e,n);let i="";for(let o=0;o<r;o++)i+=fN(t);return i},Qp=(t,e)=>e[py(t,0,e.length-1)],pN=Symbol("0schema");class mN{constructor(){this._rerrs=[]}extend(e,n,r,i=null){this._rerrs.push({path:e,expected:n,has:r,message:i})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(vR(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
|
|
52
|
+
`)}}const Rg=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[Uc]?H_(t,e):ul(t)?sy(t,n=>ay(e,r=>Rg(n,r))):GR(t)?El(t,(n,r)=>Rg(n,e[r])):!1;class Gn{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),Rg(n,r)}equals(e){return this.constructor===e.constructor&&Wu(this.shape,e.shape)}[pN](){return!0}[Uc](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Gr()}get nullable(){return Al(this,Kh)}get optional(){return new Z_(this)}cast(e){return e0(e,this),e}expect(e){return e0(e,this),e}}pn(Gn,"_dilutes",!1);class my extends Gn{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=(e==null?void 0:e.constructor)===this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name,(e==null?void 0:e.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}}const ln=(t,e=null)=>new my(t,e);ln(my);class gy extends Gn{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&(n==null||n.extend(null,"custom prop",e==null?void 0:e.constructor.name,"failed to check custom prop")),r}}const kn=t=>new gy(t);ln(gy);class Hh extends Gn{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(i=>i===e);return!r&&(n==null||n.extend(null,this.shape.join(" | "),e.toString())),r}}const Uh=(...t)=>new Hh(t),J_=ln(Hh),gN=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Y_=t=>{if(ml.check(t))return[gN(t)];if(J_.check(t))return t.shape.map(e=>e+"");if(oS.check(t))return["[+-]?\\d+.?\\d*"];if(sS.check(t))return[".*"];if(kf.check(t))return t.shape.map(Y_).flat(1);jn()};class vN extends Gn{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Y_).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&(n==null||n.extend(null,this._r.toString(),e.toString(),"String doesn't match string template.")),r}}ln(vN);const yN=Symbol("optional");class Z_ extends Gn{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&(n==null||n.extend(null,"undefined (optional)","()")),r}get[yN](){return!0}}const bN=ln(Z_);class wN extends Gn{check(e,n){return n==null||n.extend(null,"never",typeof e),!1}}ln(wN);const Th=class Th extends Gn{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new Th(this.shape,!0)}check(e,n){return e==null?(n==null||n.extend(null,"object","null"),!1):El(this.shape,(r,i)=>{const o=this._isPartial&&!fy(e,i)||r.check(e[i],n);return!o&&(n==null||n.extend(i.toString(),r.toString(),typeof e[i],"Object property does not match")),o})}};pn(Th,"_dilutes",!0);let xf=Th;const xN=t=>new xf(t),kN=ln(xf),_N=kn(t=>t!=null&&(t.constructor===Object||t.constructor==null));class X_ extends Gn{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&El(e,(r,i)=>{const o=this.shape.keys.check(i,n);return!o&&(n==null||n.extend(i+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value")),o&&this.shape.values.check(r,n)})}}const Q_=(t,e)=>new X_(t,e),SN=ln(X_);class $_ extends Gn{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&El(this.shape,(r,i)=>{const o=r.check(e[i],n);return!o&&(n==null||n.extend(i.toString(),"Tuple",typeof r)),o})}}const CN=(...t)=>new $_(t);ln($_);class eS extends Gn{constructor(e){super(),this.shape=e.length===1?e[0]:new jh(e)}check(e,n){const r=ul(e)&&sy(e,i=>this.shape.check(i));return!r&&(n==null||n.extend(null,"Array","")),r}}const tS=(...t)=>new eS(t),TN=ln(eS),EN=kn(t=>ul(t));class nS extends Gn{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name)),r}}const AN=(t,e=null)=>new nS(t,e);ln(nS);const MN=AN(Gn);class ON extends Gn{constructor(e){super(),this.len=e.length-1,this.args=CN(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&(n==null||n.extend(null,"function",typeof e)),r}}const DN=ln(ON),IN=kn(t=>typeof t=="function");class RN extends Gn{constructor(e){super(),this.shape=e}check(e,n){const r=sy(this.shape,i=>i.check(e,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof e)),r}}ln(RN,t=>t.shape.length>0);class jh extends Gn{constructor(e){super(),this.shape=e}check(e,n){const r=ay(this.shape,i=>i.check(e,n));return n==null||n.extend(null,"Union",typeof e),r}}pn(jh,"_dilutes",!0);const Al=(...t)=>t.findIndex(e=>kf.check(e))>=0?Al(...t.map(e=>jc(e)).map(e=>kf.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new jh(t),kf=ln(jh),rS=()=>!0,_f=kn(rS),NN=ln(gy,t=>t.shape===rS),vy=kn(t=>typeof t=="bigint"),PN=kn(t=>t===vy),iS=kn(t=>typeof t=="symbol");kn(t=>t===iS);const za=kn(t=>typeof t=="number"),oS=kn(t=>t===za),ml=kn(t=>typeof t=="string"),sS=kn(t=>t===ml),Wh=kn(t=>typeof t=="boolean"),LN=kn(t=>t===Wh),aS=Uh(void 0);ln(Hh,t=>t.shape.length===1&&t.shape[0]===void 0);Uh(void 0);const Kh=Uh(null),zN=ln(Hh,t=>t.shape.length===1&&t.shape[0]===null);ln(Uint8Array);ln(my,t=>t.shape===Uint8Array);const FN=Al(za,ml,Kh,aS,vy,Wh,iS);(()=>{const t=tS(_f),e=Q_(ml,_f),n=Al(za,ml,Kh,Wh,t,e);return t.shape=n,e.shape.values=n,n})();const jc=t=>{if(MN.check(t))return t;if(_N.check(t)){const e={};for(const n in t)e[n]=jc(t[n]);return xN(e)}else{if(EN.check(t))return Al(...t.map(jc));if(FN.check(t))return Uh(t);if(IN.check(t))return ln(t)}jn()},e0=nN?()=>{}:(t,e)=>{const n=new mN;if(!e.check(t,n))throw Li(`Expected value to be of type ${e.constructor.name}.
|
|
53
|
+
${n.toString()}`)};class BN{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:jc(e),h:n}),this}else(e){return this.if(_f,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const i=this.patterns[r];if(i.if.check(e))return i.h(e,n)}throw Li("Unhandled pattern")}}}const VN=t=>new BN(t),lS=VN(_f).if(oS,(t,e)=>Xp(e,Ww,yf)).if(sS,(t,e)=>hN(e)).if(LN,(t,e)=>$w(e)).if(PN,(t,e)=>BigInt(Xp(e,Ww,yf))).if(kf,(t,e)=>va(e,Qp(e,t.shape))).if(kN,(t,e)=>{const n={};for(const r in t.shape){let i=t.shape[r];if(bN.check(i)){if($w(e))continue;i=i.shape}n[r]=lS(i,e)}return n}).if(TN,(t,e)=>{const n=[],r=G_(e,0,42);for(let i=0;i<r;i++)n.push(va(e,t.shape));return n}).if(J_,(t,e)=>Qp(e,t.shape)).if(zN,(t,e)=>null).if(DN,(t,e)=>{const n=va(e,t.res);return()=>n}).if(NN,(t,e)=>va(e,Qp(e,[za,ml,Kh,aS,vy,Wh,tS(za),Q_(Al("a","b","c"),za)]))).if(SN,(t,e)=>{const n={},r=Xp(e,0,3);for(let i=0;i<r;i++){const o=va(e,t.shape.keys),s=va(e,t.shape.values);n[o]=s}return n}).done(),va=(t,e)=>lS(jc(e),t),Md=typeof document<"u"?document:{};kn(t=>t.nodeType===KN);typeof DOMParser<"u"&&new DOMParser;kn(t=>t.nodeType===UN);kn(t=>t.nodeType===jN);const HN=t=>rR(t,(e,n)=>`${n}:${e};`).join(""),UN=Md.ELEMENT_NODE,jN=Md.TEXT_NODE,WN=Md.DOCUMENT_NODE,KN=Md.DOCUMENT_FRAGMENT_NODE;kn(t=>t.nodeType===WN);const qN=t=>class{constructor(n){this._=n}destroy(){t(this._)}},GN=qN(clearTimeout),yy=(t,e)=>new GN(setTimeout(e,t)),_o=Symbol,cS=_o(),dS=_o(),JN=_o(),YN=_o(),ZN=_o(),uS=_o(),XN=_o(),by=_o(),QN=_o(),$N=t=>{var i;t.length===1&&((i=t[0])==null?void 0:i.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const o=t[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)e.push(o);else if(o.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const o=t[r];o instanceof Symbol||n.push(o)}return n},eP={[cS]:Ji("font-weight","bold"),[dS]:Ji("font-weight","normal"),[JN]:Ji("color","blue"),[ZN]:Ji("color","green"),[YN]:Ji("color","grey"),[uS]:Ji("color","red"),[XN]:Ji("color","purple"),[by]:Ji("color","orange"),[QN]:Ji("color","black")},tP=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[],r=qr();let i=[],o=0;for(;o<t.length;o++){const a=t[o],l=eP[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=HN(r);o>0||c.length>0?(e.push("%c"+a),n.push(c)):e.push(a)}else break}}for(o>0&&(i=n,i.unshift(e.join("")));o<t.length;o++){const a=t[o];a instanceof Symbol||i.push(a)}return i},fS=iN?tP:$N,nP=(...t)=>{console.log(...fS(t)),pS.forEach(e=>e.print(t))},hS=(...t)=>{console.warn(...fS(t)),t.unshift(by),pS.forEach(e=>e.print(t))},pS=Xs(),mS=t=>({[Symbol.iterator](){return this},next:t}),rP=(t,e)=>mS(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),$p=(t,e)=>mS(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class qh{constructor(e,n){this.clock=e,this.len=n}}class Ml{constructor(){this.clients=new Map}}const rs=(t,e,n)=>e.clients.forEach((r,i)=>{const o=t.doc.store.clients.get(i);if(o!=null){const s=o[o.length-1],a=s.id.clock+s.length;for(let l=0,c=r[l];l<r.length&&c.clock<a;c=r[++l])MS(t,o,c.clock,c.len,n)}}),iP=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const i=ui((n+r)/2),o=t[i],s=o.clock;if(s<=e){if(e<s+o.len)return i;n=i+1}else r=i-1}return null},Ol=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&iP(n,e.clock)!==null},wy=t=>{t.clients.forEach(e=>{e.sort((i,o)=>i.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){const i=e[r-1],o=e[n];i.clock+i.len>=o.clock?e[r-1]=new qh(i.clock,fi(i.len,o.clock+o.len-i.clock)):(r<n&&(e[r]=o),r++)}e.length=r})},Ng=t=>{const e=new Ml;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,i)=>{if(!e.clients.has(i)){const o=r.slice();for(let s=n+1;s<t.length;s++)oR(o,t[s].clients.get(i)||[]);e.clients.set(i,o)}});return wy(e),e},Wc=(t,e,n,r)=>{ji(t.clients,e,()=>[]).push(new qh(n,r))},gS=()=>new Ml,vS=t=>{const e=gS();return t.clients.forEach((n,r)=>{const i=[];for(let o=0;o<n.length;o++){const s=n[o];if(s.deleted){const a=s.id.clock;let l=s.length;if(o+1<n.length)for(let c=n[o+1];o+1<n.length&&c.deleted;c=n[++o+1])l+=c.length;i.push(new qh(a,l))}}i.length>0&&e.clients.set(r,i)}),e},Dl=(t,e)=>{ut(t.restEncoder,e.clients.size),ns(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ut(t.restEncoder,n);const i=r.length;ut(t.restEncoder,i);for(let o=0;o<i;o++){const s=r[o];t.writeDsClock(s.clock),t.writeDsLen(s.len)}})},xy=t=>{const e=new Ml,n=lt(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const i=lt(t.restDecoder),o=lt(t.restDecoder);if(o>0){const s=ji(e.clients,i,()=>[]);for(let a=0;a<o;a++)s.push(new qh(t.readDsClock(),t.readDsLen()))}}return e},t0=(t,e,n)=>{const r=new Ml,i=lt(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();const s=lt(t.restDecoder),a=lt(t.restDecoder),l=n.clients.get(s)||[],c=nn(n,s);for(let d=0;d<a;d++){const f=t.readDsClock(),h=f+t.readDsLen();if(f<c){c<h&&Wc(r,s,c,h-c);let p=hi(l,f),m=l[p];for(!m.deleted&&m.id.clock<f&&(l.splice(p+1,0,Of(e,m,f-m.id.clock)),p++);p<l.length&&(m=l[p++],m.id.clock<h);)m.deleted||(h<m.id.clock+m.length&&l.splice(p,0,Of(e,m,h-m.id.clock)),m.delete(e))}else Wc(r,s,f,h-f)}}if(r.clients.size>0){const o=new Qs;return ut(o.restEncoder,0),Dl(o,r),o.toUint8Array()}return null},yS=B_;class zi extends N_{constructor({guid:e=UR(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=yS(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new ES,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=Xw(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Xw(c=>{const d=f=>{(f===void 0||f===!0)&&(this.off("sync",d),c())};this.on("sync",d)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Ot(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ns(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Ot(this,e,n)}get(e,n=bn){const r=ji(this.share,e,()=>{const o=new n;return o._integrate(this,null),o}),i=r.constructor;if(n!==bn&&i!==n)if(i===bn){const o=new n;o._map=r._map,r._map.forEach(s=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,Va)}getText(e=""){return this.get(e,is)}getMap(e=""){return this.get(e,vl)}getXmlElement(e=""){return this.get(e,sn)}getXmlFragment(e=""){return this.get(e,$s)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,ns(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new zi({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Ot(e.parent.doc,r=>{const i=n.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class bS{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return lt(this.restDecoder)}readDsLen(){return lt(this.restDecoder)}}class wS extends bS{readLeftID(){return rt(lt(this.restDecoder),lt(this.restDecoder))}readRightID(){return rt(lt(this.restDecoder),lt(this.restDecoder))}readClient(){return lt(this.restDecoder)}readInfo(){return hl(this.restDecoder)}readString(){return La(this.restDecoder)}readParentInfo(){return lt(this.restDecoder)===1}readTypeRef(){return lt(this.restDecoder)}readLen(){return lt(this.restDecoder)}readAny(){return Hc(this.restDecoder)}readBuf(){return cN(wr(this.restDecoder))}readJSON(){return JSON.parse(La(this.restDecoder))}readKey(){return La(this.restDecoder)}}class oP{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=lt(this.restDecoder),this.dsCurrVal}readDsLen(){const e=lt(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class gl extends oP{constructor(e){super(e),this.keys=[],lt(e),this.keyClockDecoder=new Zp(wr(e)),this.clientDecoder=new ju(wr(e)),this.leftClockDecoder=new Zp(wr(e)),this.rightClockDecoder=new Zp(wr(e)),this.infoDecoder=new Zw(wr(e),hl),this.stringDecoder=new zR(wr(e)),this.parentInfoDecoder=new Zw(wr(e),hl),this.typeRefDecoder=new ju(wr(e)),this.lenDecoder=new ju(wr(e))}readLeftID(){return new Fa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Fa(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 Hc(this.restDecoder)}readBuf(){return wr(this.restDecoder)}readJSON(){return Hc(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class xS{constructor(){this.restEncoder=Ad()}toUint8Array(){return li(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ut(this.restEncoder,e)}writeDsLen(e){ut(this.restEncoder,e)}}class Od extends xS{writeLeftID(e){ut(this.restEncoder,e.client),ut(this.restEncoder,e.clock)}writeRightID(e){ut(this.restEncoder,e.client),ut(this.restEncoder,e.clock)}writeClient(e){ut(this.restEncoder,e)}writeInfo(e){Og(this.restEncoder,e)}writeString(e){Pa(this.restEncoder,e)}writeParentInfo(e){ut(this.restEncoder,e?1:0)}writeTypeRef(e){ut(this.restEncoder,e)}writeLen(e){ut(this.restEncoder,e)}writeAny(e){fl(this.restEncoder,e)}writeBuf(e){br(this.restEncoder,e)}writeJSON(e){Pa(this.restEncoder,JSON.stringify(e))}writeKey(e){Pa(this.restEncoder,e)}}class kS{constructor(){this.restEncoder=Ad(),this.dsCurrVal=0}toUint8Array(){return li(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ut(this.restEncoder,n)}writeDsLen(e){e===0&&jn(),ut(this.restEncoder,e-1),this.dsCurrVal+=e}}class Qs extends kS{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Yp,this.clientEncoder=new Uu,this.leftClockEncoder=new Yp,this.rightClockEncoder=new Yp,this.infoEncoder=new Gw(Og),this.stringEncoder=new AR,this.parentInfoEncoder=new Gw(Og),this.typeRefEncoder=new Uu,this.lenEncoder=new Uu}toUint8Array(){const e=Ad();return ut(e,0),br(e,this.keyClockEncoder.toUint8Array()),br(e,this.clientEncoder.toUint8Array()),br(e,this.leftClockEncoder.toUint8Array()),br(e,this.rightClockEncoder.toUint8Array()),br(e,li(this.infoEncoder)),br(e,this.stringEncoder.toUint8Array()),br(e,li(this.parentInfoEncoder)),br(e,this.typeRefEncoder.toUint8Array()),br(e,this.lenEncoder.toUint8Array()),Bh(e,li(this.restEncoder)),li(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){fl(this.restEncoder,e)}writeBuf(e){br(this.restEncoder,e)}writeJSON(e){fl(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const sP=(t,e,n,r)=>{r=fi(r,e[0].id.clock);const i=hi(e,r);ut(t.restEncoder,e.length-i),t.writeClient(n),ut(t.restEncoder,r);const o=e[i];o.write(t,r-o.id.clock);for(let s=i+1;s<e.length;s++)e[s].write(t,0)},ky=(t,e,n)=>{const r=new Map;n.forEach((i,o)=>{nn(e,o)>i&&r.set(o,i)}),Dd(e).forEach((i,o)=>{n.has(o)||r.set(o,0)}),ut(t.restEncoder,r.size),ns(r.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{sP(t,e.clients.get(i),i,o)})},aP=(t,e)=>{const n=qr(),r=lt(t.restDecoder);for(let i=0;i<r;i++){const o=lt(t.restDecoder),s=new Array(o),a=t.readClient();let l=lt(t.restDecoder);n.set(a,{i:0,refs:s});for(let c=0;c<o;c++){const d=t.readInfo();switch(Fh&d){case 0:{const f=t.readLen();s[c]=new Br(rt(a,l),f),l+=f;break}case 10:{const f=lt(t.restDecoder);s[c]=new Vr(rt(a,l),f),l+=f;break}default:{const f=(d&(ho|er))===0,h=new zt(rt(a,l),null,(d&er)===er?t.readLeftID():null,null,(d&ho)===ho?t.readRightID():null,f?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,f&&(d&Bc)===Bc?t.readString():null,XS(t,d));s[c]=h,l+=h.length}}}}return n},lP=(t,e,n)=>{const r=[];let i=ns(n.keys()).sort((p,m)=>p-m);if(i.length===0)return null;const o=()=>{if(i.length===0)return null;let p=n.get(i[i.length-1]);for(;p.refs.length===p.i;)if(i.pop(),i.length>0)p=n.get(i[i.length-1]);else return null;return p};let s=o();if(s===null)return null;const a=new ES,l=new Map,c=(p,m)=>{const v=l.get(p);(v==null||v>m)&&l.set(p,m)};let d=s.refs[s.i++];const f=new Map,h=()=>{for(const p of r){const m=p.id.client,v=n.get(m);v?(v.i--,a.clients.set(m,v.refs.slice(v.i)),n.delete(m),v.i=0,v.refs=[]):a.clients.set(m,[p]),i=i.filter(g=>g!==m)}r.length=0};for(;;){if(d.constructor!==Vr){const m=ji(f,d.id.client,()=>nn(e,d.id.client))-d.id.clock;if(m<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{const v=d.getMissing(t,e);if(v!==null){r.push(d);const g=n.get(v)||{refs:[],i:0};if(g.refs.length===g.i)c(v,nn(e,v)),h();else{d=g.refs[g.i++];continue}}else(m===0||m<d.length)&&(d.integrate(t,m),f.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(s!==null&&s.i<s.refs.length)d=s.refs[s.i++];else{if(s=o(),s===null)break;d=s.refs[s.i++]}}if(a.clients.size>0){const p=new Qs;return ky(p,a,new Map),ut(p.restEncoder,0),{missing:l,update:p.toUint8Array()}}return null},cP=(t,e)=>ky(t,e.doc.store,e.beforeState),dP=(t,e,n,r=new gl(t))=>Ot(e,i=>{i.local=!1;let o=!1;const s=i.doc,a=s.store,l=aP(r,s),c=lP(i,a,l),d=a.pendingStructs;if(d){for(const[h,p]of d.missing)if(p<nn(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=Cf([d.update,c.update])}}else a.pendingStructs=c;const f=t0(r,i,a);if(a.pendingDs){const h=new gl(Tl(a.pendingDs));lt(h.restDecoder);const p=t0(h,i,a);f&&p?a.pendingDs=Cf([f,p]):a.pendingDs=f||p}else a.pendingDs=f;if(o){const h=a.pendingStructs.update;a.pendingStructs=null,Sf(i.doc,h)}},n,!1),Sf=(t,e,n,r=gl)=>{const i=Tl(e);dP(i,t,n,new r(i))},uP=(t,e,n)=>Sf(t,e,n,wS),fP=(t,e,n=new Map)=>{ky(t,e.store,n),Dl(t,vS(e.store))},hP=(t,e=new Uint8Array([0]),n=new Qs)=>{const r=_S(e);fP(n,t,r);const i=[n.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(IP(t.store.pendingStructs.update,e)),i.length>1){if(n.constructor===Od)return OP(i.map((o,s)=>s===0?o:NP(o)));if(n.constructor===Qs)return Cf(i)}return i[0]},pP=(t,e)=>hP(t,e,new Od),mP=t=>{const e=new Map,n=lt(t.restDecoder);for(let r=0;r<n;r++){const i=lt(t.restDecoder),o=lt(t.restDecoder);e.set(i,o)}return e},_S=t=>mP(new bS(Tl(t))),SS=(t,e)=>(ut(t.restEncoder,e.size),ns(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{ut(t.restEncoder,n),ut(t.restEncoder,r)}),t),gP=(t,e)=>SS(t,Dd(e.store)),vP=(t,e=new kS)=>(t instanceof Map?SS(e,t):gP(e,t),e.toUint8Array()),yP=t=>vP(t,new xS);class bP{constructor(){this.l=[]}}const n0=()=>new bP,r0=(t,e)=>t.l.push(e),i0=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(i=>e!==i),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},CS=(t,e,n)=>hy(t.l,[e,n]);class Fa{constructor(e,n){this.client=e,this.clock=n}}const Oa=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,rt=(t,e)=>new Fa(t,e),Kc=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw jn()},qc=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Gc{constructor(e,n,r,i=0){this.type=e,this.tname=n,this.item=r,this.assoc=i}}const Vs=t=>new Gc(t.type==null?null:rt(t.type.client,t.type.clock),t.tname??null,t.item==null?null:rt(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class wP{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const xP=(t,e,n=0)=>new wP(t,e,n),iu=(t,e,n)=>{let r=null,i=null;return t._item===null?i=Kc(t):r=rt(t._item.id.client,t._item.id.clock),new Gc(r,i,e,n)},em=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return iu(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return iu(t,rt(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return iu(t,r.lastId,n);r=r.right}return iu(t,null,n)},kP=(t,e)=>{const n=Ba(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},Pg=(t,e,n=!0)=>{const r=e.store,i=t.item,o=t.type,s=t.tname,a=t.assoc;let l=null,c=0;if(i!==null){if(nn(r,i.client)<=i.clock)return null;const d=n?Bg(r,i):kP(r,i),f=d.item;if(!(f instanceof zt))return null;if(l=f.parent,l._item===null||!l._item.deleted){c=f.deleted||!f.countable?0:d.diff+(a>=0?0:1);let h=f.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(s!==null)l=e.get(s);else if(o!==null){if(nn(r,o.client)<=o.clock)return null;const{item:d}=n?Bg(r,o):{item:Ba(r,o)};if(d instanceof zt&&d.content instanceof mi)l=d.content.type;else return null}else throw jn();a>=0?c=l._length:c=0}return xP(l,c,t.assoc)},o0=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&Oa(t.item,e.item)&&Oa(t.type,e.type)&&t.assoc===e.assoc;class _y{constructor(e,n){this.ds=e,this.sv=n}}const TS=(t,e)=>new _y(t,e),tm=t=>TS(vS(t.store),Dd(t.store)),vs=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Ol(e.ds,t.id),Lg=(t,e)=>{const n=ji(t.meta,Lg,Xs),r=t.doc.store;n.has(e)||(e.sv.forEach((i,o)=>{i<nn(r,o)&&fr(t,rt(o,i))}),rs(t,e.ds,i=>{}),n.add(e))};class ES{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Dd=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const i=n[n.length-1];e.set(r,i.id.clock+i.length)}),e},nn=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},AS=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw jn()}n.push(e)},hi=(t,e)=>{let n=0,r=t.length-1,i=t[r],o=i.id.clock;if(o===e)return r;let s=ui(e/(o+i.length-1)*r);for(;n<=r;){if(i=t[s],o=i.id.clock,o<=e){if(e<o+i.length)return s;n=s+1}else r=s-1;s=ui((n+r)/2)}throw jn()},_P=(t,e)=>{const n=t.clients.get(e.client);return n[hi(n,e.clock)]},Ba=_P,zg=(t,e,n)=>{const r=hi(e,n),i=e[r];return i.id.clock<n&&i instanceof zt?(e.splice(r+1,0,Of(t,i,n-i.id.clock)),r+1):r},fr=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[zg(t,n,e.clock)]},s0=(t,e,n)=>{const r=e.clients.get(n.client),i=hi(r,n.clock),o=r[i];return n.clock!==o.id.clock+o.length-1&&o.constructor!==Br&&r.splice(i+1,0,Of(t,o,n.clock-o.id.clock+1)),o},SP=(t,e,n)=>{const r=t.clients.get(e.id.client);r[hi(r,e.id.clock)]=n},MS=(t,e,n,r,i)=>{if(r===0)return;const o=n+r;let s=zg(t,e,n),a;do a=e[s++],o<a.id.clock+a.length&&zg(t,e,o),i(a);while(s<e.length&&e[s].id.clock<o)};class CP{constructor(e,n,r){this.doc=e,this.deleteSet=new Ml,this.beforeState=Dd(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const a0=(t,e)=>e.deleteSet.clients.size===0&&!iR(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(wy(e.deleteSet),cP(t,e),Dl(t,e.deleteSet),!0),l0=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&ji(t.changed,e,Xs).add(n)},Ku=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0;n=r,r=t[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof zt&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const o=e-i;return o&&t.splice(e+1-o,o),o},TP=(t,e,n)=>{for(const[r,i]of t.clients.entries()){const o=e.clients.get(r);for(let s=i.length-1;s>=0;s--){const a=i[s],l=a.clock+a.len;for(let c=hi(o,a.clock),d=o[c];c<o.length&&d.id.clock<l;d=o[++c]){const f=o[c];if(a.clock+a.len<=f.id.clock)break;f instanceof zt&&f.deleted&&!f.keep&&n(f)&&f.gc(e,!1)}}}},EP=(t,e)=>{t.clients.forEach((n,r)=>{const i=e.clients.get(r);for(let o=n.length-1;o>=0;o--){const s=n[o],a=fo(i.length-1,1+hi(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+Ku(i,l)}})},OS=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,i=r.store,o=n.deleteSet,s=n._mergeStructs;try{wy(o),n.afterState=Dd(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(d=>d.target._item===null||!d.target._item.deleted),l.forEach(d=>{d.currentTarget=c,d._path=null}),l.sort((d,f)=>d.path.length-f.path.length),a.push(()=>{CS(c._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&JP(n)})}),hy(a,[])}finally{r.gc&&TP(o,i,r.gcFilter),EP(o,i),n.afterState.forEach((d,f)=>{const h=n.beforeState.get(f)||0;if(h!==d){const p=i.clients.get(f),m=fi(hi(p,h),1);for(let v=p.length-1;v>=m;)v-=1+Ku(p,v)}});for(let d=s.length-1;d>=0;d--){const{client:f,clock:h}=s[d].id,p=i.clients.get(f),m=hi(p,h);m+1<p.length&&Ku(p,m+1)>1||m>0&&Ku(p,m)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(nP(by,cS,"[yjs] ",dS,uS,"Changed the client-id because another client seems to be using it."),r.clientID=yS()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const d=new Od;a0(d,n)&&r.emit("update",[d.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const d=new Qs;a0(d,n)&&r.emit("updateV2",[d.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=n;(a.size>0||c.size>0||l.size>0)&&(a.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),c.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,n]),c.forEach(d=>d.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):OS(t,e+1)}}},Ot=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let o=!1,s=null;t._transaction===null&&(o=!0,t._transaction=new CP(t,n,r),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{s=e(t._transaction)}finally{if(o){const a=t._transaction===i[0];t._transaction=null,a&&OS(i,0)}}return s};class AP{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const c0=(t,e,n)=>{rs(t,n.deletions,r=>{r instanceof zt&&e.scope.some(i=>i===t.doc||qc(i,r))&&Dy(r,!1)})},d0=(t,e,n)=>{let r=null;const i=t.doc,o=t.scope;Ot(i,a=>{for(;e.length>0&&t.currStackItem===null;){const l=i.store,c=e.pop(),d=new Set,f=[];let h=!1;rs(a,c.insertions,p=>{if(p instanceof zt){if(p.redone!==null){let{item:m,diff:v}=Bg(l,p.id);v>0&&(m=fr(a,rt(m.id.client,m.id.clock+v))),p=m}!p.deleted&&o.some(m=>m===a.doc||qc(m,p))&&f.push(p)}}),rs(a,c.deletions,p=>{p instanceof zt&&o.some(m=>m===a.doc||qc(m,p))&&!Ol(c.insertions,p.id)&&d.add(p)}),d.forEach(p=>{h=ZS(a,p,d,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let p=f.length-1;p>=0;p--){const m=f[p];t.deleteFilter(m)&&(m.delete(a),h=!0)}t.currStackItem=h?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},t);const s=t.currStackItem;if(s!=null){const a=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:s,type:n,changedParentTypes:a,origin:t},t]),t.currStackItem=null}return s};class DS extends N_{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:i=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:a=ul(e)?e[0].doc:e instanceof zi?e:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=i,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=s,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(g=>l.changedParentTypes.has(g)||g===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const c=this.undoing,d=this.redoing,f=c?this.redoStack:this.undoStack;c?this.stopCapturing():d||this.clear(!1,!0);const h=new Ml;l.afterState.forEach((g,b)=>{const x=l.beforeState.get(b)||0,_=g-x;_>0&&Wc(h,b,x,_)});const p=jR();let m=!1;if(this.lastChange>0&&p-this.lastChange<this.captureTimeout&&f.length>0&&!c&&!d){const g=f[f.length-1];g.deletions=Ng([g.deletions,l.deleteSet]),g.insertions=Ng([g.insertions,h])}else f.push(new AP(l.deleteSet,h)),m=!0;!c&&!d&&(this.lastChange=p),rs(l,l.deleteSet,g=>{g instanceof zt&&this.scope.some(b=>b===l.doc||qc(b,g))&&Dy(g,!0)});const v=[{stackItem:f[f.length-1],origin:l.origin,type:c?"redo":"undo",changedParentTypes:l.changedParentTypes},this];m?this.emit("stack-item-added",v):this.emit("stack-item-updated",v)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=ul(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof bn?r.doc!==this.doc:r!==this.doc)&&hS("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>c0(r,this,i)),this.undoStack=[]),n&&(this.redoStack.forEach(i=>c0(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=d0(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=d0(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*MP(t){const e=lt(t.restDecoder);for(let n=0;n<e;n++){const r=lt(t.restDecoder),i=t.readClient();let o=lt(t.restDecoder);for(let s=0;s<r;s++){const a=t.readInfo();if(a===10){const l=lt(t.restDecoder);yield new Vr(rt(i,o),l),o+=l}else if((Fh&a)!==0){const l=(a&(ho|er))===0,c=new zt(rt(i,o),null,(a&er)===er?t.readLeftID():null,null,(a&ho)===ho?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(a&Bc)===Bc?t.readString():null,XS(t,a));yield c,o+=c.length}else{const l=t.readLen();yield new Br(rt(i,o),l),o+=l}}}}class Sy{constructor(e,n){this.gen=MP(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Vr);return this.curr}}class Cy{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const OP=t=>Cf(t,wS,Od),DP=(t,e)=>{if(t.constructor===Br){const{client:n,clock:r}=t.id;return new Br(rt(n,r+e),t.length-e)}else if(t.constructor===Vr){const{client:n,clock:r}=t.id;return new Vr(rt(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new zt(rt(r,i+e),null,rt(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},Cf=(t,e=gl,n=Qs)=>{if(t.length===1)return t[0];const r=t.map(d=>new e(Tl(d)));let i=r.map(d=>new Sy(d,!0)),o=null;const s=new n,a=new Cy(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],f=d.curr.id.client;if(o!==null){let h=d.curr,p=!1;for(;h!==null&&h.id.clock+h.length<=o.struct.id.clock+o.struct.length&&h.id.client>=o.struct.id.client;)h=d.next(),p=!0;if(h===null||h.id.client!==f||p&&h.id.clock>o.struct.id.clock+o.struct.length)continue;if(f!==o.struct.id.client)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(rt(f,o.struct.id.clock+o.struct.length),m),offset:0}}else{const m=o.struct.id.clock+o.struct.length-h.id.clock;m>0&&(o.struct.constructor===Vr?o.struct.length-=m:h=DP(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===f&&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),Ty(a);const l=r.map(d=>xy(d)),c=Ng(l);return Dl(s,c),s.toUint8Array()},IP=(t,e,n=gl,r=Qs)=>{const i=_S(e),o=new r,s=new Cy(o),a=new n(Tl(t)),l=new Sy(a,!1);for(;l.curr;){const d=l.curr,f=d.id.client,h=i.get(f)||0;if(l.curr.constructor===Vr){l.next();continue}if(d.id.clock+d.length>h)for(No(s,d,fi(h-d.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)No(s,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=h;)l.next()}Ty(s);const c=xy(a);return Dl(o,c),o.toUint8Array()},IS=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:li(t.encoder.restEncoder)}),t.encoder.restEncoder=Ad(),t.written=0)},No=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&IS(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ut(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},Ty=t=>{IS(t);const e=t.encoder.restEncoder;ut(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ut(e,r.written),Bh(e,r.restEncoder)}},RP=(t,e,n,r)=>{const i=new n(Tl(t)),o=new Sy(i,!1),s=new r,a=new Cy(s);for(let c=o.curr;c!==null;c=o.next())No(a,e(c),0);Ty(a);const l=xy(i);return Dl(s,l),s.toUint8Array()},NP=t=>RP(t,$R,gl,Od),u0="You must not compute changes after the event-handler fired.";class Gh{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=PP(this.currentTarget,this.target))}deletes(e){return Ol(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Li(u0);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(i=>{if(i!==null){const o=n._map.get(i);let s,a;if(this.adds(o)){let l=o.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(o))if(l!==null&&this.deletes(l))s="delete",a=qp(l.content.getContent());else return;else l!==null&&this.deletes(l)?(s="update",a=qp(l.content.getContent())):(s="add",a=void 0)}else if(this.deletes(o))s="delete",a=qp(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 Li(u0);const n=this.target,r=Xs(),i=Xs(),o=[];if(e={added:r,deleted:i,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let a=null;const l=()=>{a&&o.push(a)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,i.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const PP=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)!i.deleted&&i.countable&&(r+=i.length),i=i.right;n.unshift(r)}e=e._item.parent}return n},Hn=()=>{hS("Invalid access: Add Yjs type to a document before reading data.")},RS=80;let Ey=0;class LP{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Ey++}}const zP=t=>{t.timestamp=Ey++},NS=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Ey++},FP=(t,e,n)=>{if(t.length>=RS){const r=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return NS(r,e,n),r}else{const r=new LP(e,n);return t.push(r),r}},Jh=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,s)=>Hu(e-o.index)<Hu(e-s.index)?o:s);let r=t._start,i=0;for(n!==null&&(r=n.p,i=n.index,zP(n));r.right!==null&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>e;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&Hu(n.index-i)<r.parent.length/RS?(NS(n,r,i),n):FP(t._searchMarker,r,i)},Jc=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let o=i.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(i.index-=o.length);if(o===null||o.marker===!0){t.splice(r,1);continue}i.p=o,o.marker=!0}(e<i.index||n>0&&e===i.index)&&(i.index=fi(e,i.index+n))}},Yh=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;ji(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;CS(r._eH,n,e)};class bn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=n0(),this._dEH=n0(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Gr()}clone(){throw Gr()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){r0(this._eH,e)}observeDeep(e){r0(this._dEH,e)}unobserve(e){i0(this._eH,e)}unobserveDeep(e){i0(this._dEH,e)}toJSON(){}}const PS=(t,e,n)=>{t.doc??Hn(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let o=t._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const s=o.content.getContent();if(s.length<=e)e-=s.length;else{for(let a=e;a<s.length&&r>0;a++)i.push(s[a]),r--;e=0}}o=o.right}return i},LS=t=>{t.doc??Hn();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}n=n.right}return e},zS=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&vs(r,e)){const i=r.content.getContent();for(let o=0;o<i.length;o++)n.push(i[o])}r=r.right}return n},Yc=(t,e)=>{let n=0,r=t._start;for(t.doc??Hn();r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let o=0;o<i.length;o++)e(i[o],n++,t)}r=r.right}},FS=(t,e)=>{const n=[];return Yc(t,(r,i)=>{n.push(e(r,i,t))}),n},BP=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},BS=(t,e)=>{t.doc??Hn();const n=Jh(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Tf=(t,e,n,r)=>{let i=n;const o=t.doc,s=o.clientID,a=o.store,l=n===null?e._start:n.right;let c=[];const d=()=>{c.length>0&&(i=new zt(rt(s,nn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new ea(c)),i.integrate(t,0),c=[])};r.forEach(f=>{if(f===null)c.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(f);break;default:switch(d(),f.constructor){case Uint8Array:case ArrayBuffer:i=new zt(rt(s,nn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Id(new Uint8Array(f))),i.integrate(t,0);break;case zi:i=new zt(rt(s,nn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new Rd(f)),i.integrate(t,0);break;default:if(f instanceof bn)i=new zt(rt(s,nn(a,s)),i,i&&i.lastId,l,l&&l.id,e,null,new mi(f)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},VS=()=>Li("Length exceeded!"),HS=(t,e,n,r)=>{if(n>e._length)throw VS();if(n===0)return e._searchMarker&&Jc(e._searchMarker,n,r.length),Tf(t,e,null,r);const i=n,o=Jh(e,n);let s=e._start;for(o!==null&&(s=o.p,n-=o.index,n===0&&(s=s.prev,n+=s&&s.countable&&!s.deleted?s.length:0));s!==null;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&fr(t,rt(s.id.client,s.id.clock+n));break}n-=s.length}return e._searchMarker&&Jc(e._searchMarker,i,r.length),Tf(t,e,s,r)},VP=(t,e,n)=>{let i=(e._searchMarker||[]).reduce((o,s)=>s.index>o.index?s:o,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return Tf(t,e,i,n)},US=(t,e,n,r)=>{if(r===0)return;const i=n,o=r,s=Jh(e,n);let a=e._start;for(s!==null&&(a=s.p,n-=s.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&fr(t,rt(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&fr(t,rt(a.id.client,a.id.clock+r)),a.delete(t),r-=a.length),a=a.right;if(r>0)throw VS();e._searchMarker&&Jc(e._searchMarker,i,-o+r)},Ef=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},Ay=(t,e,n,r)=>{const i=e._map.get(n)||null,o=t.doc,s=o.clientID;let a;if(r==null)a=new ea([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new ea([r]);break;case Uint8Array:a=new Id(r);break;case zi:a=new Rd(r);break;default:if(r instanceof bn)a=new mi(r);else throw new Error("Unexpected content type")}new zt(rt(s,nn(o.store,s)),i,i&&i.lastId,null,null,e,n,a).integrate(t,0)},My=(t,e)=>{t.doc??Hn();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},jS=t=>{const e={};return t.doc??Hn(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},WS=(t,e)=>{t.doc??Hn();const n=t._map.get(e);return n!==void 0&&!n.deleted},HP=(t,e)=>{const n={};return t._map.forEach((r,i)=>{let o=r;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&vs(o,e)&&(n[i]=o.content.getContent()[o.length-1])}),n},ou=t=>(t.doc??Hn(),rP(t._map.entries(),e=>!e[1].deleted));class UP extends Gh{}class Va extends bn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new Va;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Va}clone(){const e=new Va;return e.insert(0,this.toArray().map(n=>n instanceof bn?n.clone():n)),e}get length(){return this.doc??Hn(),this._length}_callObserver(e,n){super._callObserver(e,n),Yh(this,e,new UP(this,e))}insert(e,n){this.doc!==null?Ot(this.doc,r=>{HS(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Ot(this.doc,n=>{VP(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Ot(this.doc,r=>{US(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return BS(this,e)}toArray(){return LS(this)}slice(e=0,n=this.length){return PS(this,e,n)}toJSON(){return this.map(e=>e instanceof bn?e.toJSON():e)}map(e){return FS(this,e)}forEach(e){Yc(this,e)}[Symbol.iterator](){return BP(this)}_write(e){e.writeTypeRef(hL)}}const jP=t=>new Va;class WP extends Gh{constructor(e,n,r){super(e,n),this.keysChanged=r}}class vl extends bn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new vl}clone(){const e=new vl;return this.forEach((n,r)=>{e.set(r,n instanceof bn?n.clone():n)}),e}_callObserver(e,n){Yh(this,e,new WP(this,e,n))}toJSON(){this.doc??Hn();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof bn?i.toJSON():i}}),e}get size(){return[...ou(this)].length}keys(){return $p(ou(this),e=>e[0])}values(){return $p(ou(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return $p(ou(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Hn(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Ot(this.doc,n=>{Ef(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Ot(this.doc,r=>{Ay(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return My(this,e)}has(e){return WS(this,e)}clear(){this.doc!==null?Ot(this.doc,e=>{this.forEach(function(n,r,i){Ef(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(pL)}}const KP=t=>new vl,Ko=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&XR(t,e);class Fg{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&jn(),this.right.content.constructor){case an:this.right.deleted||Il(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 f0=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case an:e.right.deleted||Il(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&fr(t,rt(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},su=(t,e,n,r)=>{const i=new Map,o=r?Jh(e,n):null;if(o){const s=new Fg(o.p.left,o.p,o.index,i);return f0(t,s,n-o.index)}else{const s=new Fg(null,e._start,0,i);return f0(t,s,n)}},KS=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===an&&Ko(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,o=i.clientID;r.forEach((s,a)=>{const l=n.left,c=n.right,d=new zt(rt(o,nn(i.store,o)),l,l&&l.lastId,c,c&&c.id,e,null,new an(a,s));d.integrate(t,0),n.right=d,n.forward()})},Il=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},qS=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===an&&Ko(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},GS=(t,e,n,r)=>{const i=t.doc,o=i.clientID,s=new Map;for(const a in r){const l=r[a],c=n.currentAttributes.get(a)??null;if(!Ko(c,l)){s.set(a,c);const{left:d,right:f}=n;n.right=new zt(rt(o,nn(i.store,o)),d,d&&d.lastId,f,f&&f.id,e,null,new an(a,l)),n.right.integrate(t,0),n.forward()}}return s},nm=(t,e,n,r,i)=>{n.currentAttributes.forEach((h,p)=>{i[p]===void 0&&(i[p]=null)});const o=t.doc,s=o.clientID;qS(n,i);const a=GS(t,e,n,i),l=r.constructor===String?new pi(r):r instanceof bn?new mi(r):new ua(r);let{left:c,right:d,index:f}=n;e._searchMarker&&Jc(e._searchMarker,n.index,l.getLength()),d=new zt(rt(s,nn(o.store,s)),c,c&&c.lastId,d,d&&d.id,e,null,l),d.integrate(t,0),n.right=d,n.index=f,n.forward(),KS(t,e,n,a)},h0=(t,e,n,r,i)=>{const o=t.doc,s=o.clientID;qS(n,i);const a=GS(t,e,n,i);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===an));){if(!n.right.deleted)switch(n.right.content.constructor){case an:{const{key:l,value:c}=n.right.content,d=i[l];if(d!==void 0){if(Ko(d,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}n.right.delete(t)}else n.currentAttributes.set(l,c);break}default:r<n.right.length&&fr(t,rt(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
54
|
+
`;n.right=new zt(rt(s,nn(o.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new pi(l)),n.right.integrate(t,0),n.forward()}KS(t,e,n,a)},JS=(t,e,n,r,i)=>{let o=e;const s=qr();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===an){const c=o.content;s.set(c.key,c)}o=o.right}let a=0,l=!1;for(;e!==o;){if(n===e&&(l=!0),!e.deleted){const c=e.content;switch(c.constructor){case an:{const{key:d,value:f}=c,h=r.get(d)??null;(s.get(d)!==c||h===f)&&(e.delete(t),a++,!l&&(i.get(d)??null)===f&&h!==f&&(h===null?i.delete(d):i.set(d,h))),!l&&!e.deleted&&Il(i,c);break}}}e=e.right}return a},qP=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===an){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},GP=t=>{let e=0;return Ot(t.doc,n=>{let r=t._start,i=t._start,o=qr();const s=Ag(o);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case an:Il(s,i.content);break;default:e+=JS(n,r,i,o,s),o=Ag(s),r=i;break}i=i.right}}),e},JP=t=>{const e=new Set,n=t.doc;for(const[r,i]of t.afterState.entries()){const o=t.beforeState.get(r)||0;i!==o&&MS(t,n.store.clients.get(r),o,i,s=>{!s.deleted&&s.content.constructor===an&&s.constructor!==Br&&e.add(s.parent)})}Ot(n,r=>{rs(t,t.deleteSet,i=>{if(i instanceof Br||!i.parent._hasFormatting||e.has(i.parent))return;const o=i.parent;i.content.constructor===an?e.add(o):qP(r,i)});for(const i of e)GP(i)})},p0=(t,e,n)=>{const r=n,i=Ag(e.currentAttributes),o=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case mi:case ua:case pi:n<e.right.length&&fr(t,rt(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}o&&JS(t,o,e.right,i,e.currentAttributes);const s=(e.left||e.right).parent;return s._searchMarker&&Jc(s._searchMarker,e.index,-r+n),e};class YP extends Gh{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];Ot(e,r=>{const i=new Map,o=new Map;let s=this.target._start,a=null;const l={};let c="",d=0,f=0;const h=()=>{if(a!==null){let p=null;switch(a){case"delete":f>0&&(p={delete:f}),f=0;break;case"insert":(typeof c=="object"||c.length>0)&&(p={insert:c},i.size>0&&(p.attributes={},i.forEach((m,v)=>{m!==null&&(p.attributes[v]=m)}))),c="";break;case"retain":d>0&&(p={retain:d},ZR(l)||(p.attributes=JR({},l))),d=0;break}p&&n.push(p),a=null}};for(;s!==null;){switch(s.content.constructor){case mi:case ua:this.adds(s)?this.deletes(s)||(h(),a="insert",c=s.content.getContent()[0],h()):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),f+=1):s.deleted||(a!=="retain"&&(h(),a="retain"),d+=1);break;case pi:this.adds(s)?this.deletes(s)||(a!=="insert"&&(h(),a="insert"),c+=s.content.str):this.deletes(s)?(a!=="delete"&&(h(),a="delete"),f+=s.length):s.deleted||(a!=="retain"&&(h(),a="retain"),d+=s.length);break;case an:{const{key:p,value:m}=s.content;if(this.adds(s)){if(!this.deletes(s)){const v=i.get(p)??null;Ko(v,m)?m!==null&&s.delete(r):(a==="retain"&&h(),Ko(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;Ko(v,m)||(a==="retain"&&h(),l[p]=v)}else if(!s.deleted){o.set(p,m);const v=l[p];v!==void 0&&(Ko(v,m)?v!==null&&s.delete(r):(a==="retain"&&h(),m===null?delete l[p]:l[p]=m))}s.deleted||(a==="insert"&&h(),Il(i,s.content));break}}s=s.right}for(h();n.length>0;){const p=n[n.length-1];if(p.retain!==void 0&&p.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class is extends bn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Hn(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new is}clone(){const e=new is;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new YP(this,e,n);Yh(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Hn();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===pi&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Ot(this.doc,r=>{const i=new Fg(null,this._start,0,new Map);for(let o=0;o<e.length;o++){const s=e[o];if(s.insert!==void 0){const a=!n&&typeof s.insert=="string"&&o===e.length-1&&i.right===null&&s.insert.slice(-1)===`
|
|
55
|
+
`?s.insert.slice(0,-1):s.insert;(typeof a!="string"||a.length>0)&&nm(r,this,i,a,s.attributes||{})}else s.retain!==void 0?h0(r,this,i,s.retain,s.attributes||{}):s.delete!==void 0&&p0(r,i,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??Hn();const i=[],o=new Map,s=this.doc;let a="",l=this._start;function c(){if(a.length>0){const f={};let h=!1;o.forEach((m,v)=>{h=!0,f[v]=m});const p={insert:a};h&&(p.attributes=f),i.push(p),a=""}}const d=()=>{for(;l!==null;){if(vs(l,e)||n!==void 0&&vs(l,n))switch(l.content.constructor){case pi:{const f=o.get("ychange");e!==void 0&&!vs(l,e)?(f===void 0||f.user!==l.id.client||f.type!=="removed")&&(c(),o.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!vs(l,n)?(f===void 0||f.user!==l.id.client||f.type!=="added")&&(c(),o.set("ychange",r?r("added",l.id):{type:"added"})):f!==void 0&&(c(),o.delete("ychange")),a+=l.content.str;break}case mi:case ua:{c();const f={insert:l.content.getContent()[0]};if(o.size>0){const h={};f.attributes=h,o.forEach((p,m)=>{h[m]=p})}i.push(f);break}case an:vs(l,e)&&(c(),Il(o,l.content));break}l=l.right}c()};return e||n?Ot(s,f=>{e&&Lg(f,e),n&&Lg(f,n),d()},"cleanup"):d(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?Ot(i,o=>{const s=su(o,this,e,!r);r||(r={},s.currentAttributes.forEach((a,l)=>{r[l]=a})),nm(o,this,s,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?Ot(i,o=>{const s=su(o,this,e,!r);nm(o,this,s,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Ot(r,i=>{p0(i,su(i,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const i=this.doc;i!==null?Ot(i,o=>{const s=su(o,this,e,!1);s.right!==null&&h0(o,this,s,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Ot(this.doc,n=>{Ef(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Ot(this.doc,r=>{Ay(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return My(this,e)}getAttributes(){return jS(this)}_write(e){e.writeTypeRef(mL)}}const ZP=t=>new is;class rm{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Hn()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===sn||n.constructor===$s)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class $s extends bn{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new $s}clone(){const e=new $s;return e.insert(0,this.toArray().map(n=>n instanceof bn?n.clone():n)),e}get length(){return this.doc??Hn(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new rm(this,e)}querySelector(e){e=e.toUpperCase();const r=new rm(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),ns(new rm(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Yh(this,e,new $P(this,n,e))}toString(){return FS(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Yc(this,o=>{i.insertBefore(o.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?Ot(this.doc,r=>{HS(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Ot(this.doc,r=>{const i=e&&e instanceof bn?e._item:e;Tf(r,this,i,n)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(o=>o===e)+1;if(i===0&&e!==null)throw Li("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?Ot(this.doc,r=>{US(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return LS(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return BS(this,e)}slice(e=0,n=this.length){return PS(this,e,n)}forEach(e){Yc(this,e)}_write(e){e.writeTypeRef(vL)}}const XP=t=>new $s;class sn extends $s{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new sn(this.nodeName)}clone(){const e=new sn(this.nodeName),n=this.getAttributes();return YR(n,(r,i)=>{e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof bn?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const a in e)r.push(a);r.sort();const i=r.length;for(let a=0;a<i;a++){const l=r[a];n.push(l+'="'+e[l]+'"')}const o=this.nodeName.toLocaleLowerCase(),s=n.length>0?" "+n.join(" "):"";return`<${o}${s}>${super.toString()}</${o}>`}removeAttribute(e){this.doc!==null?Ot(this.doc,n=>{Ef(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Ot(this.doc,r=>{Ay(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return My(this,e)}hasAttribute(e){return WS(this,e)}getAttributes(e){return e?HP(this,e):jS(this)}toDOM(e=document,n={},r){const i=e.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const a=o[s];typeof a=="string"&&i.setAttribute(s,a)}return Yc(this,s=>{i.appendChild(s.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(gL),e.writeKey(this.nodeName)}}const QP=t=>new sn(t.readKey());class $P extends Gh{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class Af extends vl{constructor(e){super(),this.hookName=e}_copy(){return new Af(this.hookName)}clone(){const e=new Af(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const i=n[this.hookName];let o;return i!==void 0?o=i.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(yL),e.writeKey(this.hookName)}}const eL=t=>new Af(t.readKey());class Dn extends is{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 Dn}clone(){const e=new Dn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const n=[];for(const i in e.attributes){const o=[];for(const s in e.attributes[i])o.push({key:s,value:e.attributes[i][s]});o.sort((s,a)=>s.key<a.key?-1:1),n.push({nodeName:i,attrs:o})}n.sort((i,o)=>i.nodeName<o.nodeName?-1:1);let r="";for(let i=0;i<n.length;i++){const o=n[i];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){const a=o.attrs[s];r+=` ${a.key}="${a.value}"`}r+=">"}r+=e.insert;for(let i=n.length-1;i>=0;i--)r+=`</${n[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(bL)}}const tL=t=>new Dn;class Oy{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Gr()}mergeWith(e){return!1}write(e,n,r){throw Gr()}integrate(e,n){throw Gr()}}const nL=0;class Br extends Oy{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),AS(e.doc.store,this)}write(e,n){e.writeInfo(nL),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Id{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Id(this.content)}splice(e){throw Gr()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const rL=t=>new Id(t.readBuf());class Zc{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Zc(this.len)}splice(e){const n=new Zc(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Wc(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const iL=t=>new Zc(t.readLen()),YS=(t,e)=>new zi({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Rd{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Rd(YS(this.doc.guid,this.opts))}splice(e){throw Gr()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const oL=t=>new Rd(YS(t.readString(),t.readAny()));class ua{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ua(this.embed)}splice(e){throw Gr()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const sL=t=>new ua(t.readJSON());class an{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new an(this.key,this.value)}splice(e){throw Gr()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const aL=t=>new an(t.readKey(),t.readJSON());class Mf{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Mf(this.arr)}splice(e){const n=new Mf(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}const lL=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const i=t.readString();i==="undefined"?n.push(void 0):n.push(JSON.parse(i))}return new Mf(n)},cL=wf("node_env")==="development";class ea{constructor(e){this.arr=e,cL&&j_(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ea(this.arr)}splice(e){const n=new ea(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let i=n;i<r;i++){const o=this.arr[i];e.writeAny(o)}}getRef(){return 8}}const dL=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new ea(n)};class pi{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new pi(this.str)}splice(e){const n=new pi(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const uL=t=>new pi(t.readString()),fL=[jP,KP,ZP,QP,XP,eL,tL],hL=0,pL=1,mL=2,gL=3,vL=4,yL=5,bL=6;class mi{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new mi(this.type._copy())}splice(e){throw Gr()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const wL=t=>new mi(fL[t.readTypeRef()](t)),Bg=(t,e)=>{let n=e,r=0,i;do r>0&&(n=rt(n.client,n.clock+r)),i=Ba(t,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof zt);return{item:i,diff:r}},Dy=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Of=(t,e,n)=>{const{client:r,clock:i}=e.id,o=new zt(rt(r,i+n),e,rt(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=rt(e.redone.client,e.redone.clock+n)),e.right=o,o.right!==null&&(o.right.left=o),t._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=n,o},m0=(t,e)=>ay(t,n=>Ol(n.deletions,e)),ZS=(t,e,n,r,i,o)=>{const s=t.doc,a=s.store,l=s.clientID,c=e.redone;if(c!==null)return fr(t,c);let d=e.parent._item,f=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!n.has(d)||ZS(t,d,n,r,i,o)===null))return null;for(;d.redone!==null;)d=fr(t,d.redone)}const p=d===null?e.parent:d.content.type;if(e.parentSub===null){for(f=e.left,h=e;f!==null;){let b=f;for(;b!==null&&b.parent._item!==d;)b=b.redone===null?null:fr(t,b.redone);if(b!==null&&b.parent._item===d){f=b;break}f=f.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==d;)b=b.redone===null?null:fr(t,b.redone);if(b!==null&&b.parent._item===d){h=b;break}h=h.right}}else if(h=null,e.right&&!i){for(f=e;f!==null&&f.right!==null&&(f.right.redone||Ol(r,f.right.id)||m0(o.undoStack,f.right.id)||m0(o.redoStack,f.right.id));)for(f=f.right;f.redone;)f=fr(t,f.redone);if(f&&f.right!==null)return null}else f=p._map.get(e.parentSub)||null;const m=nn(a,l),v=rt(l,m),g=new zt(v,f,f&&f.lastId,h,h&&h.id,p,e.parentSub,e.content.copy());return e.redone=v,Dy(g,!0),g.integrate(t,0),g};let zt=class Vg extends Oy{constructor(e,n,r,i,o,s,a,l){super(e,l.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=o,this.parent=s,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?jw:0}set marker(e){(this.info&Jp)>0!==e&&(this.info^=Jp)}get marker(){return(this.info&Jp)>0}get keep(){return(this.info&Uw)>0}set keep(e){this.keep!==e&&(this.info^=Uw)}get countable(){return(this.info&jw)>0}get deleted(){return(this.info&Gp)>0}set deleted(e){this.deleted!==e&&(this.info^=Gp)}markDeleted(){this.info|=Gp}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=nn(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=nn(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Fa&&this.id.client!==this.parent.client&&this.parent.clock>=nn(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=s0(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=fr(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Br||this.right&&this.right.constructor===Br)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Vg?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Vg&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Fa){const r=Ba(n,this.parent);r.constructor===Br?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=s0(e,e.doc.store,rt(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const o=new Set,s=new Set;for(;i!==null&&i!==this.right;){if(s.add(i),o.add(i),Oa(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,o.clear();else if(Oa(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&s.has(Ba(e.doc.store,i.origin)))o.has(Ba(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),AS(e.doc.store,this),this.content.integrate(e,this),l0(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Br(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:rt(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Oa(e.origin,this.lastId)&&this.right===e&&Oa(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Wc(e.deleteSet,this.id.client,this.id.clock,this.length),l0(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw jn();this.content.gc(e),n?SP(e,this,new Br(this.id,this.length)):this.content=new Zc(this.length)}write(e,n){const r=n>0?rt(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&Fh|(r===null?0:er)|(i===null?0:ho)|(o===null?0:Bc);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=Kc(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===Fa?(e.writeParentInfo(!1),e.writeLeftID(a)):jn();o!==null&&e.writeString(o)}this.content.write(e,n)}};const XS=(t,e)=>xL[e&Fh](t),xL=[()=>{jn()},iL,lL,rL,uL,sL,aL,wL,dL,oL,()=>{jn()}],kL=10;class Vr extends Oy{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){jn()}write(e,n){e.writeInfo(kL),ut(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const QS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},$S="__ $YJS$ __";QS[$S]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");QS[$S]=!0;function eC(t){return t?t+1:0}function Zh(t){let e=0;return t.forEach(n=>{n.isText?e+=n.text.length:n.type.name==="hardBreak"&&(e+=1)}),e}function Nd(t){if(t.isTextblock)return Zh(t);let e=0;for(let n=0;n<t.childCount;n++)n>0&&(e+=1),e+=Nd(t.child(n));return e}function tC(t,e,n){if(t.isTextblock)return Mn(n+Math.min(e,Zh(t)));let r=0,i=n;for(let o=0;o<t.childCount;o++){const s=t.child(o),a=i+1;o>0&&(r+=1);const l=Nd(s);if(r+l>e)return tC(s,e-r,a);r+=l,i+=s.nodeSize}return Mn(n+t.content.size)}function ss(t,e){let n=0,r=0;const i=t.childCount;for(let o=0;o<i;o++){const s=t.child(o),a=r+1,l=s.type.name==="heading"?eC(s.attrs.level||1):0,c=Nd(s),d=l+c;if(n+d>e){const f=e-n,h=Math.max(0,f-l);return tC(s,h,a)}if(n+=d,r+=s.nodeSize,o<i-1&&(n+=1,n>e))return Mn(a+s.content.size)}return Mn(t.content.size)}function nC(t,e,n){if(t.isTextblock)return Math.min(e-n,Zh(t));let r=0,i=n;for(let o=0;o<t.childCount;o++){const s=t.child(o),a=i+1;o>0&&(r+=1);const l=i+s.nodeSize;if(e<l)return e<=a?r:r+nC(s,e,a);r+=Nd(s),i+=s.nodeSize}return r}function Mi(t,e){let n=0,r=0;const i=t.childCount;for(let o=0;o<i;o++){const s=t.child(o),a=r+1,l=s.type.name==="heading"?eC(s.attrs.level||1):0,c=Nd(s),d=r+s.nodeSize;if(e<d)return e<=a?Lu(n+l):Lu(n+l+nC(s,e,a));n+=l+c,r+=s.nodeSize,o<i-1&&(n+=1)}return Lu(n)}function rC(t,e,n,r){if(e.isTextblock){let s=0;for(let a=0;a<t.length;a++){const l=t.get(a);if(l instanceof Dn){if(l===r.type)return Mn(n+Math.min(s+r.index,Zh(e)));s+=l.length}}return null}let i=n;t.length!==e.childCount&&console.warn(`[positions] Y.js/PM child count mismatch: yEl(${t.nodeName}).length=${t.length} vs pmNode(${e.type.name}).childCount=${e.childCount}`);const o=Math.min(t.length,e.childCount);for(let s=0;s<o;s++){const a=t.get(s),l=e.child(s),c=i+1;if(a instanceof sn){const d=rC(a,l,c,r);if(d!==null)return d}i+=l.nodeSize}return null}function g0(t,e,n){let r=0;const i=Math.min(t.childCount,e.length);for(let o=0;o<i;o++){const s=e.get(o),a=t.child(o),l=r+1;if(s instanceof sn){const c=rC(s,a,l,n);if(c!==null)return c}r+=a.nodeSize}return null}function iC(t,e,n){let r,i;try{const l=Vs(n.fromRel),c=Vs(n.toRel);r=Pg(l,t),i=Pg(c,t)}catch(l){return console.warn("[positions] relRangeToPmPositions: failed to resolve relRange:",l),null}if(!r||!i)return null;const o=t.getXmlFragment("default"),s=g0(e,o,r),a=g0(e,o,i);return s===null||a===null?null:{from:s,to:a}}function Xc(t,e,n){if(t.relRange&&n){const r=iC(n,e,t.relRange);if(r&&r.from<=r.to)return{...r,method:"rel"};console.warn(r?`[positions] annotationToPmRange: inverted rel range for ${t.id}, falling back to flat`:`[positions] annotationToPmRange: relRange resolved to null for ${t.id}, falling back to flat`)}return t.range?{from:ss(e,t.range.from),to:ss(e,t.range.to),method:"flat"}:null}function oC(t,e){return{from:Mi(t,e.from),to:Mi(t,e.to)}}function _L(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function SL(t){const e=_L(t),n=[];let r=e.replace(/```(\w*)\n?([\s\S]*?)```/g,(i,o,s)=>{const a=n.length,l=o?` class="language-${o}"`:"";return n.push(`<pre><code${l}>${s.trimEnd()}</code></pre>`),`\0BLOCK${a}\0`});r=r.replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`([^`\n]+)`/g,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,(i,o,s)=>{const a=s.trim();return/^(https?:\/\/|mailto:|#)/i.test(a)?`<a href="${a}" target="_blank" rel="noopener noreferrer">${o}</a>`:o}).replace(/^[*-] (.+)$/gm,"<li>$1</li>").replace(/\n\n/g,"</p><p>").replace(/\n/g,"<br>");for(let i=0;i<n.length;i++)r=r.replace(`\0BLOCK${i}\0`,n[i]);return r}var CL=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>'),TL=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>'),EL=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 your AI.</div>'),AL=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>'),ML=E('<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>'),OL=E('<div class="chat-markdown svelte-15oag3v"></div>'),DL=E('<div style="white-space: pre-wrap; word-break: break-word;"> </div>'),IL=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>'),RL=E("<span></span>"),NL=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>'),PL=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>'),LL=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 class="tandem-scroll-fade-y" style="flex: 1; overflow: auto; padding: var(--tandem-space-3); min-height: 0;"><!> <!> <!> <div></div></div> <!> <div class="chat-composer-outer svelte-15oag3v"><div class="chat-composer svelte-15oag3v"><textarea placeholder="Message your AI..." class="chat-composer-input svelte-15oag3v"></textarea> <button>Send</button></div></div></div>');function v0(t,e){Pe(e,!0);const n=[0,.2,.4];let r=nt(e,"inputEl",15,null);const i=F(()=>e.reduceMotion?"auto":"smooth");let o=I(We([])),s=I(""),a=I(void 0),l=I(void 0);he(()=>{r(u(l)??null)}),he(()=>{if(!e.ctrlYdoc)return;const O=e.ctrlYdoc.getMap(dw),T=()=>{const C=[];O.forEach(Z=>{C.push(Z)}),C.sort((Z,q)=>Z.timestamp-q.timestamp||Z.id.localeCompare(q.id)),y(o,C,!0)};return O.observe(T),T(),()=>O.unobserve(T)});let c=!1;he(()=>{var C;u(o);const O=!!e.claudeActive,T=vt(()=>u(i));if(!O&&c){c=!1;return}c=O,(C=u(a))==null||C.scrollIntoView({behavior:T})}),he(()=>{var C;const O=e.visible,T=vt(()=>u(i));O&&((C=u(a))==null||C.scrollIntoView({behavior:T}))});const d=F(()=>u(o).filter(O=>O.author==="claude"&&!O.read).length);function f(){if(!e.ctrlYdoc||!u(s).trim())return;const O=e.ctrlYdoc.getMap(dw),T={id:vM(),author:"user",text:u(s).trim(),timestamp:Date.now(),...e.activeDocId?{documentId:e.activeDocId}:{},...e.capturedAnchor?{anchor:e.capturedAnchor}:{},read:!1};O.set(T.id,T),y(s,""),e.onCapturedAnchorChange(null)}function h(O){O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),f())}function p(O,T){if(!(!e.editor||T&&T!==e.activeDocId))try{const C=ss(e.editor.state.doc,O.from),Z=ss(e.editor.state.doc,O.to);e.editor.chain().focus().setTextSelection({from:C,to:Z}).scrollIntoView().run()}catch(C){console.warn("[ChatPanel] Could not scroll to anchor:",C instanceof Error?C.message:C)}}function m(O){if(!O)return null;const T=e.openDocs.find(C=>C.id===O);return(T==null?void 0:T.fileName)??null}async function v(){try{await fetch(`http://127.0.0.1:${Sl}${EM}`,{method:"DELETE"})}catch(O){console.warn("[ChatPanel] Failed to clear chat:",O)}}let g=I(We(new Set));function b(O){const T=new Set(u(g));T.has(O)?T.delete(O):T.add(O),y(g,T,!0)}var x=LL(),_=w(x),A=k(w(_)),M=w(A);{var P=O=>{var T=CL(),C=w(T);U(()=>te(C,u(d))),S(O,T)};J(M,O=>{u(d)>0&&O(P)})}var D=k(M,2);{var L=O=>{var T=TL();R("click",T,v),S(O,T)};J(D,O=>{u(o).length>0&&O(L)})}var X=k(_,2),z=w(X);{var re=O=>{var T=EL();S(O,T)};J(z,O=>{u(o).length===0&&O(re)})}var Q=k(z,2);Ye(Q,17,()=>u(o),O=>O.id,(O,T)=>{var C=IL(),Z=w(C),q=w(Z),oe=w(q),ge=k(q,2);{var $=ye=>{var ke=AL(),Ve=w(ke);U(qe=>te(Ve,qe),[()=>m(u(T).documentId)??u(T).documentId]),S(ye,ke)};J(ge,ye=>{u(T).documentId&&ye($)})}var le=k(ge,2),ce=w(le),ue=k(Z,2);{var pe=ye=>{var ke=ML(),Ve=w(ke);U(qe=>{ve(ke,`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: ${qe??""}; overflow: hidden; transition: max-height 0.3s ease;`),te(Ve,u(T).anchor.textSnapshot)},[()=>u(g).has(u(T).id)?"500px":"60px"]),R("click",ke,()=>p(u(T).anchor,u(T).documentId)),Tt("mouseenter",ke,()=>b(u(T).id)),Tt("mouseleave",ke,()=>b(u(T).id)),S(ye,ke)};J(ue,ye=>{u(T).anchor&&ye(pe)})}var _e=k(ue,2);{var ae=ye=>{var ke=OL();b2(ke,()=>SL(u(T).text),!0),S(ye,ke)},de=ye=>{var ke=DL(),Ve=w(ke);U(()=>te(Ve,u(T).text)),S(ye,ke)};J(_e,ye=>{u(T).author==="claude"?ye(ae):ye(de,-1)})}U(ye=>{ve(C,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${u(T).author==="user"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; border: 1px solid ${u(T).author==="user"?"var(--tandem-accent-border)":"var(--tandem-border)"}; font-size: var(--tandem-text-base); color: var(--tandem-fg); box-shadow: var(--tandem-shadow-1);`),ve(q,`font-weight: 600; font-size: 11px; color: ${u(T).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"}; text-transform: uppercase;`),te(oe,u(T).author),te(ce,ye)},[()=>new Date(u(T).timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]),S(O,C)});var N=k(Q,2);{var B=O=>{var T=NL(),C=w(T);Ye(C,20,()=>n,oe=>oe,(oe,ge)=>{var $=RL();U(()=>ve($,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${ge??""}s infinite;`)),S(oe,$)});var Z=k(C,2),q=w(Z);U(()=>te(q,e.claudeStatus??"Your AI is thinking...")),S(O,T)};J(N,O=>{e.claudeActive&&O(B)})}var j=k(N,2);pt(j,O=>y(a,O),()=>u(a)),Tr(X,(O,T)=>Dt==null?void 0:Dt(O,T),()=>"y");var H=k(X,2);{var W=O=>{var T=PL(),C=w(T),Z=w(C),q=k(C,2);U(oe=>te(Z,`with selection: “${oe??""}${e.capturedAnchor.textSnapshot.length>40?"...":""}”`),[()=>e.capturedAnchor.textSnapshot.slice(0,40)]),R("click",q,()=>e.onCapturedAnchorChange(null)),S(O,T)};J(H,O=>{e.capturedAnchor&&O(W)})}var ee=k(H,2),ie=w(ee),K=w(ie);G(K,"rows",2),pt(K,O=>y(l,O),()=>u(l));var Y=k(K,2);U((O,T)=>{$n(K,u(s)),Y.disabled=O,Xr(Y,1,T,"svelte-15oag3v")},[()=>!u(s).trim(),()=>"chat-composer-send"+(u(s).trim()?" on":"")]),R("input",K,O=>y(s,O.target.value,!0)),R("keydown",K,h),R("click",Y,f),S(t,x),Le()}Ke(["click","input","keydown"]);var zL=E('<button type="button" data-testid="apply-changes-btn"> </button>');function FL(t,e){Pe(e,!0);let n=I(!1);const r=F(()=>e.annotations.filter(d=>d.status==="accepted")),i=F(()=>e.annotations.filter(d=>d.status==="pending")),o=F(()=>u(r).length===0||u(n));async function s(){if(u(o)||!e.documentId)return;let d=`Apply ${u(r).length} change(s) as tracked revisions?
|
|
56
|
+
|
|
57
|
+
The changes will appear as tracked revisions in Word — you can Accept or Reject each one individually.
|
|
58
|
+
|
|
59
|
+
Your original file will be backed up.`;if(u(i).length>0&&(d+=`
|
|
60
|
+
|
|
61
|
+
⚠ ${u(i).length} annotation(s) are still pending review and will not be applied.`),!!confirm(d)){y(n,!0);try{const f=await fetch(`${Nn}${SM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})}),h=await f.json().catch(m=>(console.error("[ApplyChanges] Failed to parse response JSON:",m),null));if(!f.ok){alert((h==null?void 0:h.message)??`Apply failed (HTTP ${f.status}).`);return}const p=h==null?void 0:h.data;if(p){const m=[`Applied ${p.applied??0} tracked change(s).`];p.rejected>0&&m.push(`${p.rejected} could not be applied.`),p.backupPath&&m.push(`
|
|
62
|
+
Backup saved to:
|
|
63
|
+
${p.backupPath}`),alert(m.join(" "))}else alert("Changes applied successfully.")}catch(f){console.error("[ApplyChanges] Request failed:",f),alert(f instanceof TypeError?"Could not reach the server.":`Apply failed: ${f instanceof Error?f.message:String(f)}`)}finally{y(n,!1)}}}var a=ft(),l=Se(a);{var c=d=>{var f=zL(),h=w(f);U(()=>{f.disabled=u(o),G(f,"title",u(r).length===0?"No accepted suggestions to apply":void 0),ve(f,`width: 100%; padding: var(--tandem-space-1) var(--tandem-space-3); font-size: var(--tandem-text-xs); font-weight: 500; border: 1px solid ${u(o)?"var(--tandem-border)":"var(--tandem-info-border)"}; border-radius: var(--tandem-r-2); background: ${u(o)?"var(--tandem-surface-muted)":"var(--tandem-info)"}; color: ${u(o)?"var(--tandem-fg-subtle)":"var(--tandem-info-fg)"}; cursor: ${u(o)?"default":"pointer"}; opacity: ${u(n)?.6:1}; white-space: nowrap;`),te(h,u(n)?"Applying…":`Apply as Tracked Changes (${u(r).length})`)}),R("click",f,s),S(d,f)};J(l,d=>{e.activeDocFormat==="docx"&&d(c)})}S(t,a),Le()}Ke(["click"]);const au={background:"var(--tandem-warning-bg)",border:"var(--tandem-warning-border)",color:"var(--tandem-warning-fg-strong)"};function Xh(t,e){return t.type!=="comment"?[]:e??[]}var BL=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>'),VL=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>'),HL=E('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),UL=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>'),jL=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>'),WL=E('<div style="display: flex; gap: 4px; margin-top: 4px;"><!> <!></div>'),KL=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>'),qL=E(`<div style="font-size: var(--tandem-text-xs); color: var(--tandem-error-fg); margin-top: 2px;">Can't undo — text has changed.</div>`),GL=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 JL(t,e){Pe(e,!0);let n=I(!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(),y(n,!1);return}p||(y(n,!0),i(),r=setTimeout(()=>{y(n,!1),r=null},3e3))}Qr(i);var s=ft(),a=Se(s);{var l=h=>{var p=HL(),m=w(p);{var v=x=>{var _=BL();U(()=>G(_,"data-testid",`accept-btn-${e.annotationId??""}`)),R("click",_,A=>{A.stopPropagation(),e.onAccept(e.annotationId)}),S(x,_)};J(m,x=>{e.onAccept&&x(v)})}var g=k(m,2);{var b=x=>{var _=VL();U(()=>G(_,"data-testid",`dismiss-btn-${e.annotationId??""}`)),R("click",_,A=>{A.stopPropagation(),e.onDismiss(e.annotationId)}),S(x,_)};J(g,x=>{e.onDismiss&&x(b)})}S(h,p)},c=h=>{var p=WL(),m=w(p);{var v=x=>{var _=UL();U(()=>G(_,"data-testid",`archive-btn-${e.annotationId??""}`)),R("click",_,A=>{A.stopPropagation(),e.onRemove(e.annotationId)}),S(x,_)};J(m,x=>{e.onRemove&&x(v)})}var g=k(m,2);{var b=x=>{var _=jL();U(()=>G(_,"data-testid",`send-to-claude-btn-${e.annotationId??""}`)),R("click",_,A=>{A.stopPropagation(),e.onSendToClaude(e.annotationId)}),S(x,_)};J(g,x=>{e.onSendToClaude&&x(b)})}S(h,p)},d=h=>{var p=KL();U(()=>G(p,"data-testid",`remove-btn-${e.annotationId??""}`)),R("click",p,m=>{m.stopPropagation(),e.onRemove(e.annotationId)}),S(h,p)},f=h=>{var p=GL(),m=w(p),v=k(m,2);{var g=b=>{var x=qL();S(b,x)};J(v,b=>{u(n)&&b(g)})}R("click",m,o),S(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(f,3)})}S(t,s),Le()}Ke(["click"]);const cc="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);",y0="padding: 4px 10px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;";var YL=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),ZL=E("<textarea></textarea>"),XL=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 QL(t,e){Pe(e,!0);let n=I(null);he(()=>{var d;(d=u(n))==null||d.focus()});var r=XL(),i=w(r);{var o=d=>{var f=YL(),h=Se(f),p=k(h,2);pt(p,g=>y(n,g),()=>u(n));var m=k(p,2),v=k(m,2);U(()=>{G(h,"for",`edit-newtext-${e.annotationId??""}`),G(p,"id",`edit-newtext-${e.annotationId??""}`),G(p,"data-testid",`edit-newtext-${e.annotationId??""}`),$n(p,e.editNewText),ve(p,cc),G(m,"for",`edit-reason-${e.annotationId??""}`),G(v,"id",`edit-reason-${e.annotationId??""}`),G(v,"data-testid",`edit-reason-${e.annotationId??""}`),$n(v,e.editReason),ve(v,cc)}),R("input",p,g=>e.onChangeEditNewText(g.target.value)),R("keydown",p,function(...g){var b;(b=e.onKeyDown)==null||b.apply(this,g)}),R("input",v,g=>e.onChangeEditReason(g.target.value)),R("keydown",v,function(...g){var b;(b=e.onKeyDown)==null||b.apply(this,g)}),S(d,f)},s=d=>{var f=ZL();pt(f,h=>y(n,h),()=>u(n)),U(()=>{G(f,"data-testid",`edit-text-${e.annotationId??""}`),$n(f,e.editText),ve(f,cc)}),R("input",f,h=>e.onChangeEditText(h.target.value)),R("keydown",f,function(...h){var p;(p=e.onKeyDown)==null||p.apply(this,h)}),S(d,f)};J(i,d=>{e.hasSuggestedText?d(o):d(s,-1)})}var a=k(i,2),l=w(a),c=k(l,2);U(()=>{G(l,"data-testid",`edit-save-btn-${e.annotationId??""}`),G(c,"data-testid",`edit-cancel-btn-${e.annotationId??""}`)}),R("click",r,d=>d.stopPropagation()),R("keydown",r,d=>d.stopPropagation()),R("click",l,d=>{d.stopPropagation(),e.onSave()}),R("click",c,d=>{d.stopPropagation(),e.onCancel()}),S(t,r),Le()}Ke(["click","keydown","input"]);function $L(t){return t==="claude"?"Claude":t==="import"?"Imported":"You"}function sC(t){return t.suggestedText!==void 0?"replacement":t.type}function e3(t,e){return t?t.length>e?t.slice(0,e-3)+"...":t:""}function t3(t){const e=sC(t),n=e3(t.content,60);return`${t.type==="note"?"private ":""}${e} annotation${n?": "+n:""}, ${t.status}`}function n3(t){return t.type==="highlight"&&t.color?Ic[Tk(t.color)]:"var(--tandem-author-user)"}var r3=E("<span> </span>"),i3=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>`),o3=E('<span style="font-style: italic; font-size: 10px; color: var(--tandem-fg-subtle);">(edited)</span>'),s3=E('<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px;"><span style="font-weight: 600; text-transform: capitalize; display: flex; align-items: center; gap: 6px; color: var(--tandem-fg-muted); font-size: 11px;"><span class="annotation-type-badge svelte-d1dbnh"> </span> <!> <!> <!></span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); display: flex; align-items: center; gap: 4px;"><!> </span></div>');function Pd(t,e){Pe(e,!0);const n=F(()=>sC(e.annotation)),r=F(()=>$L(e.annotation.author));var i=s3(),o=w(i),s=w(o),a=w(s),l=k(s,2);{var c=x=>{var _=ft(),A=Se(_);Cd(A,()=>e.extraPill),S(x,_)};J(l,x=>{e.extraPill&&x(c)})}var d=k(l,2);{var f=x=>{var _=r3(),A=w(_);U(()=>{ve(_,`margin-left: 6px; font-size: 10px; color: ${e.annotation.status==="accepted"?"var(--tandem-success)":"var(--tandem-error)"}; font-weight: 600;`),te(A,e.annotation.status)}),S(x,_)};J(d,x=>{e.isPending||x(f)})}var h=k(d,2);{var p=x=>{var _=i3();U(()=>G(_,"data-testid",`edit-btn-${e.annotation.id??""}`)),R("click",_,A=>{A.stopPropagation(),e.onEnterEdit()}),S(x,_)};J(h,x=>{e.isPending&&e.canEdit&&!e.isReviewTarget&&!e.isEditing&&x(p)})}var m=k(o,2),v=w(m);{var g=x=>{var _=o3();S(x,_)};J(v,x=>{e.annotation.editedAt&&x(g)})}var b=k(v);U(()=>{ve(s,`font-family: var(--tandem-font-mono); font-size: var(--tandem-text-2xs); letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 7px; border-radius: var(--tandem-r-pill); background: ${e.badgeBg??""}; color: ${e.badgeFg??""};`),te(a,u(n)),te(b,` ${u(r)??""}`)}),S(t,i),Le()}Ke(["click"]);var a3=E('<div style="padding: 4px 8px; margin-bottom: 6px; border-left: 3px solid var(--tandem-border-strong); color: var(--tandem-fg-muted); font-size: 12px; font-style: italic; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-1);"> </div>');function Ld(t,e){Pe(e,!0);const n=F(()=>e.text?e.text.length>80?e.text.slice(0,77)+"...":e.text:"");var r=ft(),i=Se(r);{var o=s=>{var a=a3(),l=w(a);U(()=>{G(a,"data-testid",`annotation-snippet-${e.annotationId??""}`),te(l,u(n))}),S(s,a)};J(i,s=>{e.text&&s(o)})}S(t,r),Le()}var l3=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),c3=E("<!> <!> <!>",1);function d3(t,e){Pe(e,!0);var n=c3(),r=Se(n);Pd(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);Ld(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=l3(),c=w(l),d=w(c);U(()=>te(d,e.annotation.content||"(no note)")),S(a,l)};J(o,a=>{e.isEditing||a(s)})}S(t,n),Le()}var u3=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),f3=E("<!> <!> <!>",1);function h3(t,e){Pe(e,!0);var n=f3(),r=Se(n);Pd(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);Ld(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=u3(),c=w(l),d=w(c);U(()=>te(d,e.annotation.content||"(no note)")),S(a,l)};J(o,a=>{e.isEditing||a(s)})}S(t,n),Le()}var p3=E('<input type="checkbox" style="margin-top: 4px; flex-shrink: 0; cursor: pointer;"/>'),m3=E('<div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-bottom: 4px;">From: <span style="font-weight: 500;"> </span></div>'),g3=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),v3=E('<div style="display: flex; align-items: flex-start; gap: var(--tandem-space-2);"><!> <div style="flex: 1; min-width: 0;"><!> <!> <!> <!></div></div>');function y3(t,e){Pe(e,!0);let n=nt(e,"selected",3,!1);var r=v3(),i=w(r);{var o=p=>{var m=p3();U(()=>{var v;G(m,"data-testid",`annotation-select-checkbox-${e.annotation.id??""}`),Vn(m,n()),G(m,"aria-label",`Select ${((v=e.annotation.importSource)==null?void 0:v.author)??"import"} comment for batch promote`)}),R("click",m,v=>v.stopPropagation()),R("change",m,()=>{var v;return(v=e.onToggleSelect)==null?void 0:v.call(e,e.annotation.id)}),S(p,m)};J(i,p=>{e.onToggleSelect&&p(o)})}var s=k(i,2),a=w(s);Pd(a,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-surface-sunk)",badgeFg:"var(--tandem-fg-muted)",get onEnterEdit(){return e.onEnterEdit}});var l=k(a,2);{var c=p=>{var m=m3(),v=k(w(m)),g=w(v);U(()=>{G(m,"data-testid",`annotation-import-byline-${e.annotation.id??""}`),te(g,e.annotation.importSource.author)}),S(p,m)};J(l,p=>{var m;(m=e.annotation.importSource)!=null&&m.author&&p(c)})}var d=k(l,2);Ld(d,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var f=k(d,2);{var h=p=>{var m=g3(),v=w(m),g=w(v);U(()=>te(g,e.annotation.content||"(no note)")),S(p,m)};J(f,p=>{e.isEditing||p(h)})}S(t,r),Le()}Ke(["click","change"]);var b3=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>'),w3=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>'),x3=E("<!> <!> <!>",1);function k3(t,e){Pe(e,!0);var n=x3(),r=Se(n);Pd(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-warning-bg)",badgeFg:"var(--tandem-warning-fg-strong)",get onEnterEdit(){return e.onEnterEdit},extraPill:l=>{var c=b3();S(l,c)},$$slots:{extraPill:!0}});var i=k(r,2);Ld(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=w3(),c=w(l),d=w(c);U(()=>te(d,e.annotation.content||"(no note)")),S(a,l)};J(o,a=>{e.isEditing||a(s)})}S(t,n),Le()}var _3=E('<span style="font-style: italic; margin-right: 4px;">(edited)</span>'),S3=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>'),C3=E('<div data-testid="comment-thread" style="margin-top: 6px; padding-left: 8px; border-left: 2px solid var(--tandem-border);"></div>');function aC(t,e){Pe(e,!0);function n(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 f=Math.floor(d/60);return f<24?`${f}h ago`:a.toLocaleDateString()}var r=ft(),i=Se(r);{var o=s=>{var a=C3();Ye(a,21,()=>e.replies,l=>l.id,(l,c)=>{var d=S3(),f=w(d),h=w(f),p=w(h),m=k(h,2),v=w(m);{var g=A=>{var M=_3();S(A,M)};J(v,A=>{u(c).editedAt&&A(g)})}var b=k(v),x=k(f,2),_=w(x);U(A=>{G(d,"data-testid",`reply-${u(c).id??""}`),ve(h,`font-weight: 600; font-size: 11px; color: ${u(c).author==="claude"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};`),te(p,u(c).author==="claude"?"Claude":"You"),te(b,` ${A??""}`),te(_,u(c).text)},[()=>n(u(c).timestamp)]),S(l,d)}),S(s,a)};J(i,s=>{e.replies.length>0&&s(o)})}S(t,r),Le()}var T3=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>'),E3=E('<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;"> </button>'),A3=E('<div style="margin-top: 6px;"><!></div>'),M3=E('<div style="margin-top: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);"> </div>'),O3=E("<!> <!> <!>",1);function D3(t,e){Pe(e,!0);const n=F(()=>Xh(e.annotation,e.replies)),r=F(()=>e.annotation.id);let i=I(!1),o=I(""),s=I(!1),a=I(null);const l=F(()=>!!u(o).trim());he(()=>{var b;u(i)&&((b=u(a))==null||b.focus())});function c(b){b.key==="Escape"&&(b.stopPropagation(),y(i,!1),y(o,""))}async function d(){var x;const b=u(o).trim();if(!(!b||u(s))){y(s,!0);try{await((x=e.onReply)==null?void 0:x.call(e,u(r),b))!==!1&&(y(o,""),y(i,!1))}finally{y(s,!1)}}}var f=O3(),h=Se(f);aC(h,{get replies(){return u(n)}});var p=k(h,2);{var m=b=>{var x=A3(),_=w(x);{var A=P=>{var D=T3(),L=w(D);pt(L,Q=>y(a,Q),()=>u(a));var X=k(L,2),z=w(X),re=k(z,2);U(()=>{G(L,"data-testid",`reply-input-${u(r)??""}`),$n(L,u(o)),ve(L,cc),G(z,"data-testid",`reply-send-btn-${u(r)??""}`),z.disabled=!u(l)||u(s),ve(z,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${u(l)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${u(l)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${u(l)?"pointer":"default"};`),G(re,"data-testid",`reply-cancel-btn-${u(r)??""}`)}),R("input",L,Q=>y(o,Q.target.value,!0)),R("keydown",L,c),R("click",z,d),R("click",re,()=>{y(i,!1),y(o,"")}),S(P,D)},M=P=>{var D=E3(),L=w(D);U(()=>{G(D,"data-testid",`reply-btn-${u(r)??""}`),te(L,`Reply${u(n).length>0?` (${u(n).length})`:""}`)}),R("click",D,()=>y(i,!0)),S(P,D)};J(_,P=>{u(i)?P(A):P(M,-1)})}R("click",x,P=>P.stopPropagation()),R("keydown",x,P=>P.stopPropagation()),S(b,x)};J(p,b=>{e.isPending&&e.onReply&&!e.isEditing&&b(m)})}var v=k(p,2);{var g=b=>{var x=M3(),_=w(x);U(()=>te(_,`${u(n).length??""}
|
|
64
|
+
${u(n).length===1?"reply":"replies"}`)),S(b,x)};J(v,b=>{!e.isPending&&u(n).length>0&&!e.onReply&&b(g)})}S(t,f),Le()}Ke(["click","keydown","input"]);var I3=E('<p style="margin: 0; font-size: var(--tandem-text-sm); color: var(--tandem-fg-subtle);">No replies yet.</p>'),R3=E('<textarea data-testid="reply-thread-overlay-input" placeholder="Write a reply..."></textarea> <div style="display: flex; gap: var(--tandem-space-2); margin-top: var(--tandem-space-2);"><button type="button" data-testid="reply-thread-overlay-send">Send</button> <button type="button" data-testid="reply-thread-overlay-cancel">Cancel</button></div>',1),N3=E('<button type="button" data-testid="reply-thread-overlay-reply">Reply</button>'),P3=E('<div style="border-top: 1px solid var(--tandem-border); padding-top: var(--tandem-space-3);"><!></div>'),L3=E('<div role="presentation" data-testid="reply-thread-overlay" style="position: fixed; inset: 0; background-color: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: 1000;"><div role="dialog" aria-modal="true" aria-label="Reply thread" tabindex="-1" style="background-color: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-3); padding: var(--tandem-space-4) var(--tandem-space-5); width: 520px; max-width: 90vw; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--tandem-space-3);"><div style="display: flex; align-items: center; justify-content: space-between;"><h2 style="margin: 0; font-size: var(--tandem-text-lg); font-weight: 600; color: var(--tandem-fg);">Reply thread <span style="font-weight: 400; color: var(--tandem-fg-subtle); font-size: var(--tandem-text-sm); margin-left: var(--tandem-space-2);"> </span></h2> <button type="button" data-testid="reply-thread-overlay-close" aria-label="Close reply thread" style="background: none; border: none; cursor: pointer; font-size: 18px; color: var(--tandem-fg-muted); line-height: 1; padding: 2px 6px; border-radius: var(--tandem-r-2);">✕</button></div> <div style="padding: var(--tandem-space-2) var(--tandem-space-3); background: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); border-left: 3px solid var(--tandem-author-claude); font-size: var(--tandem-text-sm); color: var(--tandem-fg-muted); white-space: pre-wrap;"> </div> <!> <!></div></div>');function z3(t,e){Pe(e,!0);const n=F(()=>Xh(e.annotation,e.replies));let r=I(null),i=I(null),o=null,s=I(!1),a=I(""),l=I(!1);const c=F(()=>!!u(a).trim());he(()=>{if(!e.open)return;const g=vt(()=>u(r));if(!g)return;o=document.activeElement,g.focus();const b=x=>{g&&!g.contains(x.target)&&g.focus()};return document.addEventListener("focusin",b),()=>{document.removeEventListener("focusin",b),o instanceof HTMLElement&&document.contains(o)&&o.focus()}}),he(()=>{e.open||(y(s,!1),y(a,""),y(l,!1))}),he(()=>{var g;u(s)&&((g=u(i))==null||g.focus())});function d(g){g.key==="Escape"&&(g.stopPropagation(),y(s,!1),y(a,""))}async function f(){const g=u(a).trim();if(!(!g||u(l)||!e.onReply)){y(l,!0);try{await e.onReply(e.annotation.id,g)!==!1&&(y(a,""),y(s,!1))}finally{y(l,!1)}}}function h(g){if(g.key==="Escape"){e.onClose();return}if(g.stopPropagation(),g.key!=="Tab"||!u(r))return;const b=Array.from(u(r).querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(A=>!A.closest("[hidden]"));if(b.length===0){g.preventDefault();return}const x=b[0],_=b[b.length-1];g.shiftKey&&document.activeElement===x?(g.preventDefault(),_.focus()):!g.shiftKey&&document.activeElement===_&&(g.preventDefault(),x.focus())}var p=ft(),m=Se(p);{var v=g=>{var b=L3(),x=w(b),_=w(x),A=w(_),M=k(w(A)),P=w(M),D=k(A,2),L=k(_,2),X=w(L),z=k(L,2);{var re=j=>{var H=I3();S(j,H)},Q=j=>{aC(j,{get replies(){return u(n)}})};J(z,j=>{u(n).length===0?j(re):j(Q,-1)})}var N=k(z,2);{var B=j=>{var H=P3(),W=w(H);{var ee=K=>{var Y=R3(),O=Se(Y);pt(O,q=>y(i,q),()=>u(i));var T=k(O,2),C=w(T),Z=k(C,2);U(()=>{ve(O,cc),C.disabled=!u(c)||u(l),ve(C,`padding: 4px 10px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${u(c)?"var(--tandem-accent-bg)":"var(--tandem-surface-muted)"}; color: ${u(c)?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-subtle)"}; cursor: ${u(c)&&!u(l)?"pointer":"default"};`),ve(Z,y0)}),R("keydown",O,d),Bn(O,()=>u(a),q=>y(a,q)),R("click",C,f),R("click",Z,()=>{y(s,!1),y(a,"")}),S(K,Y)},ie=K=>{var Y=N3();U(()=>ve(Y,y0)),R("click",Y,()=>y(s,!0)),S(K,Y)};J(W,K=>{u(s)?K(ee):K(ie,-1)})}S(j,H)};J(N,j=>{e.onReply&&j(B)})}pt(x,j=>y(r,j),()=>u(r)),U(()=>{te(P,`(${u(n).length??""}
|
|
65
|
+
${u(n).length===1?"reply":"replies"})`),te(X,e.annotation.content)}),R("click",b,function(...j){var H;(H=e.onClose)==null||H.apply(this,j)}),R("keydown",b,()=>{}),R("click",x,j=>j.stopPropagation()),R("keydown",x,h),R("click",D,function(...j){var H;(H=e.onClose)==null||H.apply(this,j)}),S(g,b)};J(m,g=>{e.open&&g(v)})}S(t,p),Le()}Ke(["click","keydown"]);var F3=E('<span style="text-decoration: line-through; color: var(--tandem-error); background-color: var(--tandem-error-bg); padding: 0 2px; border-radius: var(--tandem-r-1);"> </span> ',1),B3=E('<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>'),V3=E('<div style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><div><!> <span style="color: var(--tandem-success-fg-strong); background-color: var(--tandem-success-bg); padding: 0 2px; border-radius: var(--tandem-r-1);"> </span></div> <!></div>'),H3=E("<!> <!> <!>",1);function U3(t,e){Pe(e,!0);var n=H3(),r=Se(n);Pd(r,{get annotation(){return e.annotation},get isPending(){return e.isPending},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return e.isEditing},get canEdit(){return e.canEdit},badgeBg:"var(--tandem-suggestion-bg)",badgeFg:"var(--tandem-suggestion-fg-strong)",get onEnterEdit(){return e.onEnterEdit}});var i=k(r,2);Ld(i,{get annotationId(){return e.annotation.id},get text(){return e.annotation.textSnapshot}});var o=k(i,2);{var s=a=>{var l=V3(),c=w(l),d=w(c);{var f=g=>{var b=F3(),x=Se(b),_=w(x),A=k(x);A.nodeValue=" → ",U(()=>te(_,e.annotation.textSnapshot)),S(g,b)};J(d,g=>{e.annotation.textSnapshot&&g(f)})}var h=k(d,2),p=w(h),m=k(c,2);{var v=g=>{var b=B3(),x=w(b);U(()=>te(x,e.annotation.content)),S(g,b)};J(m,g=>{e.annotation.content&&g(v)})}U(()=>{G(c,"data-testid",`suggestion-diff-${e.annotation.id??""}`),ve(c,`padding: 4px 8px; margin-bottom: ${e.annotation.content?"4px":"0"}; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); font-size: 12px; line-height: 1.5;`),te(p,e.annotation.suggestedText)}),S(a,l)};J(o,a=>{e.isEditing||a(s)})}S(t,n),Le()}var j3=E('<div class="tandem-claude-typing svelte-3ascys" role="status" aria-live="polite" aria-label="Claude is working on this annotation" title="Claude is working on this annotation"><span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span></div>'),W3=E('<button type="button" style="margin-top: var(--tandem-space-1); padding: var(--tandem-space-1) var(--tandem-space-2); font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;" class="svelte-3ascys">Expand thread</button>'),K3=E('<div class="tandem-annotation-card svelte-3ascys" role="listitem"><!> <!> <!> <!> <!> <!></div> <!>',1);function Hg(t,e){Pe(e,!0);let n=nt(e,"replies",19,()=>[]),r=nt(e,"claudeTyping",3,!1),i=nt(e,"selected",3,!1),o=I(!1),s=I(""),a=I(""),l=I("");const c=F(()=>e.annotation.status==="pending"),d=F(()=>e.annotation.suggestedText!==void 0),f=F(()=>e.onEdit!==void 0),h=F(()=>t3(e.annotation)),p=F(()=>Xh(e.annotation,n())),m=F(()=>u(p).length>=1);let v=I(!1);const g=F(()=>e.annotation.type==="highlight"?n3(e.annotation):e.annotation.suggestedText!==void 0?"var(--tandem-suggestion)":e.annotation.type==="note"?"var(--tandem-warning)":"var(--tandem-author-user)"),b=F(()=>e.isReviewTarget?"var(--tandem-accent-bg)":"var(--tandem-surface)");function x(){u(d)?(y(a,e.annotation.suggestedText??"",!0),y(l,e.annotation.content,!0)):y(s,e.annotation.content,!0),y(o,!0)}function _(){var Z;const C=u(d)?JSON.stringify({suggestedText:u(a),content:u(l)}):u(s);(Z=e.onEdit)==null||Z.call(e,e.annotation.id,C),y(o,!1)}function A(){y(o,!1)}function M(C){C.key==="Escape"&&(C.stopPropagation(),A())}var P=K3(),D=Se(P),L=w(D);{var X=C=>{var Z=j3();U(()=>G(Z,"data-testid",`claude-typing-indicator-${e.annotation.id??""}`)),S(C,Z)};J(L,C=>{r()&&C(X)})}var z=k(L,2);{var re=C=>{y3(C,{get annotation(){return e.annotation},get isPending(){return u(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(o)},get canEdit(){return u(f)},onEnterEdit:x,get selected(){return i()},get onToggleSelect(){return e.onToggleSelect}})},Q=C=>{h3(C,{get annotation(){return e.annotation},get isPending(){return u(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(o)},get canEdit(){return u(f)},onEnterEdit:x})},N=C=>{k3(C,{get annotation(){return e.annotation},get isPending(){return u(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(o)},get canEdit(){return u(f)},onEnterEdit:x})},B=C=>{U3(C,{get annotation(){return e.annotation},get isPending(){return u(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(o)},get canEdit(){return u(f)},onEnterEdit:x})},j=C=>{d3(C,{get annotation(){return e.annotation},get isPending(){return u(c)},get isReviewTarget(){return e.isReviewTarget},get isEditing(){return u(o)},get canEdit(){return u(f)},onEnterEdit:x})};J(z,C=>{e.annotation.author==="import"?C(re):e.annotation.type==="highlight"?C(Q,1):e.annotation.type==="note"?C(N,2):e.annotation.suggestedText!==void 0?C(B,3):C(j,-1)})}var H=k(z,2);{var W=C=>{QL(C,{get annotationId(){return e.annotation.id},get hasSuggestedText(){return u(d)},get editText(){return u(s)},get editNewText(){return u(a)},get editReason(){return u(l)},onChangeEditText:Z=>y(s,Z,!0),onChangeEditNewText:Z=>y(a,Z,!0),onChangeEditReason:Z=>y(l,Z,!0),onKeyDown:M,onSave:_,onCancel:A})};J(H,C=>{u(o)&&C(W)})}var ee=k(H,2);JL(ee,{get annotationId(){return e.annotation.id},get annotationType(){return e.annotation.type},get isPending(){return u(c)},get isEditing(){return u(o)},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 ie=k(ee,2);D3(ie,{get annotation(){return e.annotation},get replies(){return u(p)},get isPending(){return u(c)},get isEditing(){return u(o)},get onReply(){return e.onReply}});var K=k(ie,2);{var Y=C=>{var Z=W3();U(()=>G(Z,"data-testid",`reply-thread-expand-${e.annotation.id??""}`)),R("click",Z,q=>{q.stopPropagation(),y(v,!0)}),S(C,Z)};J(K,C=>{u(m)&&C(Y)})}var O=k(D,2);{var T=C=>{z3(C,{get open(){return u(v)},get annotation(){return e.annotation},get replies(){return u(p)},get onReply(){return e.onReply},onClose:()=>y(v,!1)})};J(O,C=>{(u(m)||u(v))&&C(T)})}U(()=>{G(D,"data-testid",`annotation-card-${e.annotation.id??""}`),G(D,"data-annotation-type",e.annotation.type),G(D,"data-claude-typing",r()?"true":void 0),G(D,"aria-label",u(h)),G(D,"aria-current",e.isReviewTarget?"true":void 0),ve(D,`position: relative; padding: var(--tandem-space-3); margin-bottom: var(--tandem-space-2); border: 1px solid var(--tandem-border); border-left: 3px solid ${u(g)??""}; background: ${u(b)??""}; border-radius: var(--tandem-r-3); font-size: var(--tandem-text-base); opacity: ${u(c)?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;`)}),R("click",D,function(...C){var Z;(Z=e.onClick)==null||Z.apply(this,C)}),S(t,P),Le()}Ke(["click"]);const q3="browser";function G3(t,e,n){let r,i=!1;if(t.transact(()=>{r=e(),i=!0},n),!i)throw new Error(`origins: transact callback did not run (origin=${n})`);return r}function Hs(t,e){return G3(t,e,q3)}function ta(t,e){const n=t,r=s=>{try{e(s)}catch(a){console.warn(`[sanitizeAnnotation] onLossy threw for ${s.kind}:`,a)}},i=n.audience==="private"||n.audience==="outbound"?n.audience:n.author==="import"||n.type==="highlight"||n.type==="note"||n.type==="flag"?"private":"outbound",o={id:n.id,author:n.author,range:n.range,content:n.content,status:n.status,timestamp:n.timestamp,...n.relRange!==void 0?{relRange:n.relRange}:{},...n.textSnapshot!==void 0?{textSnapshot:n.textSnapshot}:{},...n.editedAt!==void 0?{editedAt:n.editedAt}:{},...typeof n.rev=="number"?{rev:n.rev}:{},audience:i,...n.promotedFrom!==void 0?{promotedFrom:n.promotedFrom}:{},...n.importSource!==void 0?{importSource:n.importSource}:{}};if(o.audience==="outbound"&&n.author==="user"&&(n.type==="note"||n.type==="highlight"||n.type==="flag")&&(o.audience="private",r({kind:"audience-conflict-resolved",id:n.id})),n.type==="suggestion"){let s,a;try{const l=JSON.parse(n.content);s=l.newText,a=l.reason??""}catch{r({kind:"malformed-suggestion-json",id:n.id}),a=n.content}return{...o,type:"comment",content:a,suggestedText:s}}return n.type==="question"?(r({kind:"question-to-comment",id:n.id}),{...o,type:"comment"}):n.type==="highlight"?{...o,type:"highlight",color:n.color}:n.type==="flag"||n.type==="note"?(n.type==="flag"&&r({kind:"flag-to-note",id:n.id}),{...o,type:"note"}):n.type==="comment"?{...o,type:"comment",...n.suggestedText!==void 0?{suggestedText:n.suggestedText}:{}}:(r({kind:"unknown-type",id:n.id,rawType:n.type}),{...o,type:"comment"})}const Iy=t=>{console.warn("[sanitize]",t)};function lC(t,e,n){if(!t)return;const r=t.getMap(xo),i=r.get(e);if(!i)return;const o=ta(i,Iy);Hs(t,()=>{if(o.suggestedText!==void 0){try{const s=JSON.parse(n);r.set(e,{...o,suggestedText:s.suggestedText,content:s.content,editedAt:Date.now(),rev:(o.rev??0)+1})}catch{console.warn(`[annotation-actions] Failed to parse edit payload for annotation ${e}`)}return}r.set(e,{...o,content:n,editedAt:Date.now(),rev:(o.rev??0)+1})})}function cC(t){const{color:e,suggestedText:n,...r}=t;return{...r,type:"comment",author:t.author==="import"?"user":t.author,audience:"outbound",promotedFrom:"note",rev:(t.rev??0)+1}}function dC(t,e){if(!t)return;const n=t.getMap(xo),r=n.get(e);if(!r)return;const i=ta(r,Iy);i.type==="note"&&Hs(t,()=>{n.set(e,cC(i))})}function J3(t,e){if(!t||e.length===0)return 0;const n=t.getMap(xo);let r=0;return Hs(t,()=>{for(const i of e){const o=n.get(i);if(!o)continue;const s=ta(o,Iy);s.type==="note"&&(n.set(i,cC(s)),r++)}}),r}async function uC(t,e){try{const n=await fetch(`${Nn}${TM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:t,documentId:e})});if(!n.ok){const r=await n.json().catch(()=>({message:"Unknown error"}));console.error("[Tandem] Remove annotation failed:",r)}}catch(n){console.error("[Tandem] Remove annotation failed:",n)}}async function fC(t,e,n){try{const r=await fetch(`${Nn}${CM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({annotationId:t,text:e,documentId:n})});if(!r.ok){const i=await r.json().catch(()=>({}));return console.warn(`[annotation-actions] Reply failed (${r.status}): ${i.message??"unknown error"}`),!1}return!0}catch(r){return console.error("[annotation-actions] Reply request failed:",r),!1}}var Y3=E('<div data-testid="batch-promote-bar" role="region" aria-label="Batch promote imported notes" style="position: sticky; top: 0; z-index: var(--tandem-z-base); display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-4); background: var(--tandem-accent-bg); border-bottom: 1px solid var(--tandem-accent-border); font-size: var(--tandem-text-xs); color: var(--tandem-accent-fg-strong);"><span data-testid="batch-promote-count" style="flex: 1; font-weight: 500;"> </span> <button data-testid="batch-promote-clear" style="padding: 3px 10px; border: 1px solid transparent; background: none; color: var(--tandem-fg-subtle); border-radius: var(--tandem-r-pill); cursor: pointer; font-size: var(--tandem-text-xs);">Clear</button> <button data-testid="batch-promote-confirm" style="padding: 3px 12px; border: 1px solid var(--tandem-accent); background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill); cursor: pointer; font-size: var(--tandem-text-xs); font-weight: 500;"> </button></div>');function Z3(t,e){var n=ft(),r=Se(n);{var i=o=>{var s=Y3(),a=w(s),l=w(a),c=k(a,2),d=k(c,2),f=w(d);U(()=>{te(l,`${e.selectedCount??""} selected`),te(f,`Send ${e.selectedCount??""} to Claude`)}),R("click",c,function(...h){var p;(p=e.onClear)==null||p.apply(this,h)}),R("click",d,function(...h){var p;(p=e.onPromote)==null||p.apply(this,h)}),S(o,s)};J(r,o=>{e.selectedCount>0&&o(i)})}S(t,n)}Ke(["click"]);var X3=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),Q3=E('<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>',1),$3=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 ez(t,e){Pe(e,!0);let n=nt(e,"confirmRef",15,null);const r=F(()=>e.bulkConfirm==="accept"),i=F(()=>e.pendingCount===e.allPendingCount?`${e.pendingCount} annotations?`:`${e.pendingCount} of ${e.allPendingCount} pending?`);var o=ft(),s=Se(o);{var a=l=>{var c=$3(),d=w(c);{var f=p=>{var m=X3(),v=Se(m),g=w(v),b=k(v,2);pt(b,_=>n(_),()=>n());var x=k(b,2);ve(x,"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);"),U(()=>{te(g,`${u(r)?"Accept":"Reject"}
|
|
66
|
+
${u(i)??""}`),ve(b,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: ${u(r)?"var(--tandem-success-bg)":"var(--tandem-error-bg)"}; color: ${u(r)?"var(--tandem-success-fg-strong)":"var(--tandem-error-fg-strong)"}; font-weight: 600;`)}),R("click",b,function(..._){var A;(A=u(r)?e.onConfirmAccept:e.onConfirmDismiss)==null||A.apply(this,_)}),R("click",x,function(..._){var A;(A=e.onCancel)==null||A.apply(this,_)}),S(p,m)},h=p=>{var m=Q3(),v=Se(m);ve(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=w(v),b=k(v,2);ve(b,"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);"),U(()=>te(g,`Accept All (${e.pendingCount??""})`)),R("click",v,function(...x){var _;(_=e.onRequestAccept)==null||_.apply(this,x)}),R("click",b,function(...x){var _;(_=e.onRequestDismiss)==null||_.apply(this,x)}),S(p,m)};J(d,p=>{e.bulkConfirm?p(f):p(h,-1)})}S(l,c)};J(s,l=>{e.pendingCount>1&&l(a)})}S(t,o),Le()}Ke(["click"]);var tz=E("<option> </option>"),nz=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 im(t,e){Pe(e,!0);var n=nz();Ye(n,21,()=>e.options,i=>i.value,(i,o)=>{var s=tz(),a=w(s),l={};U(()=>{te(a,u(o).label),l!==(l=u(o).value)&&(s.value=(s.__value=u(o).value)??"")}),S(i,s)});var r;Uv(n),U(()=>{G(n,"data-testid",e.testId),G(n,"aria-label",e.ariaLabel),r!==(r=e.value)&&(n.value=(n.__value=e.value)??"",Oh(n,e.value))}),R("change",n,i=>e.onChange(i.target.value)),S(t,n),Le()}Ke(["change"]);var rz=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>'),iz=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 oz(t,e){Pe(e,!0);var n=ft(),r=Se(n);{var i=o=>{var s=iz(),a=w(s);im(a,{testId:"filter-type",ariaLabel:"Filter by type",get value(){return e.filterType},onChange:p=>e.onSetFilterType(p),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 l=k(a,2);im(l,{testId:"filter-author",ariaLabel:"Filter by author",get value(){return e.filterAuthor},onChange:p=>e.onSetFilterAuthor(p),options:[{value:"all",label:"Anyone"},{value:"claude",label:"Claude"},{value:"user",label:"You"},{value:"import",label:"Imported"}]});var c=k(l,2);im(c,{testId:"filter-status",ariaLabel:"Filter by status",get value(){return e.filterStatus},onChange:p=>e.onSetFilterStatus(p),options:[{value:"all",label:"Any status"},{value:"pending",label:"Pending"},{value:"accepted",label:"Accepted"},{value:"dismissed",label:"Dismissed"}]});var d=k(c,2);{var f=p=>{var m=rz();R("click",m,function(...v){var g;(g=e.onClearFilters)==null||g.apply(this,v)}),S(p,m)};J(d,p=>{e.hasFilters&&p(f)})}var h=k(d,2);R("click",h,function(...p){var m;(m=e.onToggleOpen)==null||m.apply(this,p)}),S(o,s)};J(r,o=>{e.open&&o(i)})}S(t,n),Le()}Ke(["click"]);var sz=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
|
|
67
|
+
won't be saved. Close the other instance and restart.</span> <button data-testid="store-readonly-dismiss" class="svelte-l26r3u">Dismiss</button></div>`),az=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>'),lz=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>'),cz=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>'),dz=E('<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>'),uz=E('<div data-testid="annotation-list-scroll-container" class="tandem-scroll-fade-y svelte-l26r3u" style="width: 100%; background: var(--tandem-surface-muted); display: flex; flex-direction: column; overflow-y: auto;"><!> <div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);" class="svelte-l26r3u"><div style="display: flex; justify-content: space-between; align-items: center;" class="svelte-l26r3u"><h3 style="font-size: 13px; font-weight: 600; margin: 0;" class="svelte-l26r3u">Annotations <!></h3> <span aria-live="polite" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);" class="svelte-l26r3u"> </span> <button data-testid="filter-bar-toggle" style="display: flex; align-items: center; gap: 4px; background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-pill); padding: 3px 10px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); cursor: pointer; white-space: nowrap;" class="svelte-l26r3u"><span class="svelte-l26r3u"> </span> <span style="font-size: 9px; opacity: 0.7;" class="svelte-l26r3u">▾</span> <span class="svelte-l26r3u">Filter</span></button></div></div> <!> <div style="padding: var(--tandem-space-1) var(--tandem-space-4) 0;" class="svelte-l26r3u"><!></div> <!> <!> <!></div>');function b0(t,e){Pe(e,!0);let n=nt(e,"storeReadOnly",3,!1),r=nt(e,"claudeWorkingAnnotationId",3,null);const i=F(()=>e.reduceMotion?"auto":"smooth"),o="tandem:storeReadOnlyBannerDismissed";function s(){try{return localStorage.getItem(o)==="true"}catch{return!1}}let a=I(We(s()));he(()=>{if(!n()){y(a,!1);try{localStorage.removeItem(o)}catch{}}});function l(){try{localStorage.setItem(o,"true")}catch{}y(a,!0)}let c=I("all"),d=I("all"),f=I("all"),h=I(!1),p=I(null),m=I(void 0),v=I(null);he(()=>{var ae;u(p)&&((ae=u(v))==null||ae.focus())}),he(()=>{u(c),u(d),u(f),y(p,null)}),he(()=>{var ae;(ae=e.onFilterChange)==null||ae.call(e,u(c),u(d),u(f))});let g=I(We(new Map));he(()=>{if(!e.ydoc){y(g,new Map,!0);return}const ae=e.ydoc.getMap(Dk);function de(){const ye=new Map;ae.forEach(ke=>{const Ve=ke;if(Ve&&typeof Ve=="object"&&Ve.annotationId){const qe=ye.get(Ve.annotationId)??[];qe.push(Ve),ye.set(Ve.annotationId,qe)}});for(const ke of ye.values())ke.sort((Ve,qe)=>Ve.timestamp-qe.timestamp);y(g,ye,!0)}return de(),ae.observe(de),()=>ae.unobserve(de)});const b=F(()=>{const ae=[],de=[];for(const fe of e.annotations){fe.status==="pending"&&de.push(fe);let Ee;u(c)==="all"?Ee=!0:u(c)==="with-replacement"?Ee=fe.suggestedText!==void 0:Ee=fe.type===u(c);const Re=u(d)==="all"||fe.author===u(d),Ge=u(f)==="all"||fe.status===u(f);Ee&&Re&&Ge&&ae.push(fe)}const ye=ae.filter(fe=>fe.status==="pending"),ke=ae.filter(ff),Ve=ae.filter(fe=>fe.status!=="pending"),qe=e.annotations.filter(ff);return{filtered:ae,pending:ye,reviewPending:ke,resolved:Ve,allPending:de,reviewAllPending:qe}}),x=F(()=>u(c)!=="all"||u(d)!=="all"||u(f)!=="all"),_=F(()=>{if(!u(x))return"All";const ae=[];if(u(c)!=="all"){const de={all:"All",highlight:"Highlights",comment:"Comments",note:"Notes","with-replacement":"With replacement"};ae.push(de[u(c)])}if(u(d)!=="all"){const de={all:"Anyone",claude:"Claude",user:"You",import:"Imported"};ae.push(de[u(d)])}if(u(f)!=="all"){const de={all:"Any status",pending:"Pending",accepted:"Accepted",dismissed:"Dismissed"};ae.push(de[u(f)])}return ae.join(" · ")||"All"});let A=!1;he(()=>{if(u(c),u(d),u(f),!A){A=!0;return}vt(()=>{var ae;if(e.activeAnnotationId){const de=document.querySelector(`[data-testid="annotation-card-${e.activeAnnotationId}"]`);if(de){de.scrollIntoView({block:"center"});return}console.warn(`[tandem] SidePanel: active annotation ${e.activeAnnotationId} not found on filter change; scrolling to top`)}(ae=u(m))==null||ae.scrollTo({top:0})})}),he(()=>{const ae=e.activeAnnotationId;if(!ae)return;const de=u(i),ye=setTimeout(()=>{const ke=document.querySelector(`[data-testid="annotation-card-${ae}"]`);if(ke){ke.scrollIntoView({behavior:de,block:"nearest"}),ke.classList.add("tandem-annotation-flash");const Ve=()=>ke.classList.remove("tandem-annotation-flash");ke.addEventListener("animationend",Ve,{once:!0})}else console.warn(`[tandem] SidePanel: active annotation ${ae} not found after 50ms delay; scroll-to-card skipped`)},50);return()=>clearTimeout(ye)});const M=(ae,de)=>lC(e.ydoc,ae,de),P=ae=>dC(e.ydoc,ae),D=ae=>uC(ae,e.documentId),L=(ae,de)=>fC(ae,de,e.documentId);function X(ae){for(const de of u(b).reviewPending)e.review.resolveAnnotation(de.id,ae);y(p,null)}let z=I(We(new Set));he(()=>{const ae=new Set(u(b).pending.filter(de=>de.author==="import"&&de.type==="note").map(de=>de.id));vt(()=>{const de=new Set([...u(z)].filter(ye=>ae.has(ye)));de.size!==u(z).size&&y(z,de,!0)})});function re(ae){const de=new Set(u(z));de.has(ae)?de.delete(ae):de.add(ae),y(z,de,!0)}function Q(){const ae=Array.from(u(z));J3(e.ydoc,ae),y(z,new Set,!0)}function N(){y(z,new Set,!0)}var B=uz(),j=w(B);{var H=ae=>{var de=sz(),ye=k(w(de),2);U(()=>{ve(de,`padding: 10px 14px; margin: 10px 14px 0; background: ${au.background}; border: 1px solid ${au.border}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${au.color}; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;`),ve(ye,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${au.color}; cursor: pointer; font-weight: 500;`)}),R("click",ye,l),S(ae,de)};J(j,ae=>{n()&&!u(a)&&ae(H)})}var W=k(j,2),ee=w(W),ie=w(ee),K=k(w(ie));{var Y=ae=>{var de=az(),ye=w(de);U(()=>te(ye,u(b).allPending.length)),S(ae,de)};J(K,ae=>{u(b).allPending.length>0&&ae(Y)})}var O=k(ie,2),T=w(O),C=k(O,2),Z=w(C),q=w(Z),oe=k(W,2);oz(oe,{get filterType(){return u(c)},get filterAuthor(){return u(d)},get filterStatus(){return u(f)},get hasFilters(){return u(x)},get open(){return u(h)},onToggleOpen:()=>y(h,!u(h)),onSetFilterType:ae=>{y(c,ae,!0)},onSetFilterAuthor:ae=>{y(d,ae,!0)},onSetFilterStatus:ae=>{y(f,ae,!0)},onClearFilters:()=>{y(c,"all"),y(d,"all"),y(f,"all")}});var ge=k(oe,2),$=w(ge);FL($,{get annotations(){return e.annotations},get activeDocFormat(){return e.activeDocFormat},get documentId(){return e.documentId}});var le=k(ge,2);Z3(le,{get selectedCount(){return u(z).size},onPromote:Q,onClear:N});var ce=k(le,2);ez(ce,{get bulkConfirm(){return u(p)},get pendingCount(){return u(b).reviewPending.length},get allPendingCount(){return u(b).reviewAllPending.length},onConfirmAccept:()=>X("accepted"),onConfirmDismiss:()=>X("dismissed"),onCancel:()=>y(p,null),onRequestAccept:()=>y(p,"accept"),onRequestDismiss:()=>y(p,"dismiss"),get confirmRef(){return u(v)},set confirmRef(ae){y(v,ae,!0)}});var ue=k(ce,2);{var pe=ae=>{var de=lz(),ye=w(de),ke=w(ye);U(()=>te(ke,u(x)?"No annotations match filters.":"No annotations yet. Open a document to get started.")),S(ae,de)},_e=ae=>{var de=dz(),ye=w(de);Ye(ye,17,()=>u(b).pending,qe=>qe.id,(qe,fe)=>{const Ee=F(()=>{var Re;return e.activeAnnotationId!==null?e.activeAnnotationId===u(fe).id:((Re=e.review.getActiveReviewAnn())==null?void 0:Re.id)===u(fe).id});{let Re=F(()=>u(g).get(u(fe).id)??[]),Ge=F(()=>r()===u(fe).id),Te=F(()=>u(fe).author!=="user"?e.review.handleAccept:void 0),Me=F(()=>u(fe).author!=="user"?e.review.handleDismiss:void 0),dt=F(()=>u(fe).author==="user"?D:void 0),Kt=F(()=>u(fe).type==="note"?P:void 0),ze=F(()=>u(z).has(u(fe).id)),_t=F(()=>u(fe).author==="import"&&u(fe).type==="note"?re:void 0);Hg(qe,{get annotation(){return u(fe)},get replies(){return u(Re)},get isReviewTarget(){return u(Ee)},get claudeTyping(){return u(Ge)},get onAccept(){return u(Te)},get onDismiss(){return u(Me)},get onRemove(){return u(dt)},get onSendToClaude(){return u(Kt)},onEdit:M,onReply:L,onClick:()=>e.review.scrollToAnnotation(u(fe)),get selected(){return u(ze)},get onToggleSelect(){return u(_t)}})}});var ke=k(ye,2);{var Ve=qe=>{var fe=cz(),Ee=w(fe),Re=w(Ee),Ge=k(Ee,2);Ye(Ge,21,()=>u(b).resolved,Te=>Te.id,(Te,Me)=>{{let dt=F(()=>u(g).get(u(Me).id)??[]),Kt=F(()=>e.review.getRecentlyResolved().has(u(Me).id));Hg(Te,{get annotation(){return u(Me)},get replies(){return u(dt)},get onUndo(){return e.review.undoResolveAnnotation},get undoable(){return u(Kt)},onClick:()=>e.review.scrollToAnnotation(u(Me))})}}),U(()=>te(Re,`${u(b).resolved.length??""} resolved`)),S(qe,fe)};J(ke,qe=>{u(b).resolved.length>0&&qe(Ve)})}S(ae,de)};J(ue,ae=>{u(b).filtered.length===0?ae(pe):ae(_e,-1)})}pt(B,ae=>y(m,ae),()=>u(m)),Tr(B,(ae,de)=>Dt==null?void 0:Dt(ae,de),()=>"y"),U(()=>{te(T,`${u(b).allPending.length??""} pending annotation${u(b).allPending.length!==1?"s":""}`),te(q,`${u(_)??""} ${u(b).filtered.length??""}`)}),R("click",C,()=>y(h,!u(h))),S(t,B),Le()}Ke(["click"]);var fz=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>'),hz=E(`<span style="
|
|
68
|
+
flex-shrink: 0;
|
|
69
|
+
font-size: var(--tandem-text-2xs, 10px);
|
|
70
|
+
font-weight: 500;
|
|
71
|
+
color: var(--tandem-fg-subtle);
|
|
72
|
+
background: var(--tandem-surface-muted);
|
|
73
|
+
border-radius: var(--tandem-r-pill);
|
|
74
|
+
padding: 0 var(--tandem-space-1);
|
|
75
|
+
min-width: 16px;
|
|
76
|
+
text-align: center;
|
|
77
|
+
line-height: 16px;
|
|
78
|
+
"> </span>`),pz=E('<li><button><span style="flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></button></li>'),mz=E('<ul style="list-style: none; margin: 0; padding: 0;"></ul>'),gz=E('<nav data-testid="outline-panel" aria-label="Document outline" style="display: flex; flex-direction: column; flex: 1; overflow-y: auto;"><div style="padding: var(--tandem-space-3) var(--tandem-space-3) var(--tandem-space-2);"><div class="outline-search-pill svelte-or41wm"><svg class="outline-search-icon svelte-or41wm" width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="7" cy="7" r="4.3" stroke="currentColor" stroke-width="1.4" fill="none"></circle><line x1="10.2" y1="10.2" x2="13.5" y2="13.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></line></svg> <input type="search" placeholder="Search in document…" data-testid="outline-search-input" aria-label="Search document" class="outline-search-input svelte-or41wm"/></div></div> <div class="tandem-scroll-fade-y" style="flex: 1; overflow-y: auto; padding: var(--tandem-space-3) var(--tandem-space-3);"><!></div></nav>');function w0(t,e){Pe(e,!0);let n=nt(e,"annotations",19,()=>[]),r=nt(e,"focusTrigger",3,0),i=nt(e,"activeFilterType",3,"all"),o=nt(e,"activeFilterAuthor",3,"all"),s=nt(e,"activeFilterStatus",3,"all"),a=I(We([])),l=I(-1),c=I(We([])),d=I(""),f=I(null),h=I(-1);he(()=>{const z=e.editor;if(!z||z.isDestroyed){y(a,[],!0);return}y(a,Cg(z),!0),vt(()=>{y(c,u(c).slice(0,u(a).length),!0),u(l)>=u(a).length&&y(l,Math.max(0,u(a).length-1),!0)});const re=()=>{y(a,Cg(z),!0),y(c,u(c).slice(0,u(a).length),!0),u(l)>=u(a).length&&y(l,Math.max(0,u(a).length-1),!0)};return z.on("update",re),()=>{z.isDestroyed||z.off("update",re),y(a,[],!0)}}),he(()=>{var z,re;r()>0&&((z=u(f))==null||z.focus(),(re=u(f))==null||re.select())}),he(()=>{const z=e.editor;if(!z||z.isDestroyed)return;function re(){if(!z||z.isDestroyed||u(a).length===0){y(h,-1);return}const B=z.view.dom.getBoundingClientRect().top+48;let j=-1;for(let H=0;H<u(a).length;H++)try{z.view.coordsAtPos(u(a)[H].pos+1).top<=B&&(j=H)}catch{}y(h,j,!0)}re();const Q=z.view.dom.closest(".editor-scroll")??z.view.dom.parentElement;return Q==null||Q.addEventListener("scroll",re),()=>Q==null?void 0:Q.removeEventListener("scroll",re)});function p(){const z=e.editor;!z||z.isDestroyed||(u(d)?z.commands.find({query:u(d),caseSensitive:!1,wholeWord:!1,regexMode:!1}):z.commands.findClose())}function m(z){var re,Q,N,B;z.key==="Enter"?(z.preventDefault(),z.shiftKey?(re=e.editor)==null||re.commands.findPrev():(Q=e.editor)==null||Q.commands.findNext()):z.key==="Escape"&&(z.preventDefault(),y(d,""),(N=e.editor)==null||N.commands.findClose(),(B=u(f))==null||B.blur())}const v=F(()=>{const z=e.editor;if(!z||z.isDestroyed||u(a).length===0)return[];const re=z.state.doc.content.size,Q=[];for(const N of n()){if(i()!=="all"){if(i()==="with-replacement"){if(!N.suggestedText)continue}else if(N.type!==i())continue}if(!(o()!=="all"&&N.author!==o())&&!(s()!=="all"&&N.status!==s()))try{Q.push(ss(z.state.doc,N.range.from))}catch{}}return u(a).map((N,B)=>{const j=B+1<u(a).length?u(a)[B+1].pos:re;return Q.filter(H=>H>=N.pos&&H<j).length})});function g(z,re){const Q=e.editor;if(!Q||Q.isDestroyed)return;const{state:N}=Q;try{const B=N.doc.resolve(z.pos+1),j=Be.near(B);Q.view.dispatch(N.tr.setSelection(j)),Q.view.focus();const{node:H}=Q.view.domAtPos(z.pos+1),W=H instanceof Element?H:H.parentElement,ee=Q.view.dom.closest(".editor-scroll")??Q.view.dom.parentElement;if(W&&ee){const ie=W.getBoundingClientRect().top,K=ee.getBoundingClientRect().top;ee.scrollTop+=ie-K-ee.clientHeight*.05}}catch{}y(l,re,!0)}function b(z){var re,Q,N,B;if(u(a).length!==0)if(z.key==="ArrowDown"){z.preventDefault();const j=(u(l)+1)%u(a).length;y(l,j),(re=u(c)[j])==null||re.focus()}else if(z.key==="ArrowUp"){z.preventDefault();const j=(u(l)-1+u(a).length)%u(a).length;y(l,j),(Q=u(c)[j])==null||Q.focus()}else z.key==="Home"?(z.preventDefault(),y(l,0),(N=u(c)[0])==null||N.focus()):z.key==="End"&&(z.preventDefault(),y(l,u(a).length-1),(B=u(c)[u(a).length-1])==null||B.focus())}var x=gz(),_=w(x),A=w(_),M=k(w(A),2);pt(M,z=>y(f,z),()=>u(f));var P=k(_,2),D=w(P);{var L=z=>{var re=fz();S(z,re)},X=z=>{var re=mz();Ye(re,21,()=>u(a),Ac,(Q,N,B)=>{const j=F(()=>u(h)===B),H=F(()=>u(v)[B]??0);var W=pz(),ee=w(W),ie=w(ee),K=w(ie),Y=k(ie,2);{var O=T=>{var C=hz(),Z=w(C);U(()=>{G(C,"title",`${u(H)??""} annotation${u(H)!==1?"s":""}`),te(Z,u(H))}),S(T,C)};J(Y,T=>{u(H)>0&&T(O)})}pt(ee,(T,C)=>u(c)[C]=T,T=>{var C;return(C=u(c))==null?void 0:C[T]},()=>[B]),U(()=>{G(ee,"data-testid",`outline-heading-${u(N).level}-${B}`),G(ee,"tabindex",u(l)===B||u(l)===-1&&B===0?0:-1),ve(ee,`
|
|
79
|
+
display: flex; align-items: center; width: 100%; text-align: left;
|
|
80
|
+
padding: var(--tandem-space-1) var(--tandem-space-3);
|
|
81
|
+
padding-left: calc(var(--tandem-space-1) + ${(u(N).level-1)*12}px);
|
|
82
|
+
font-size: ${u(N).level===1?"var(--tandem-text-sm)":"var(--tandem-text-xs)"};
|
|
83
|
+
font-weight: ${u(N).level===1?600:u(N).level===2?500:400};
|
|
84
|
+
color: ${u(j)?"var(--tandem-accent)":u(N).level===1?"var(--tandem-fg)":u(N).level===2?"var(--tandem-fg-subtle)":"var(--tandem-fg-muted)"};
|
|
85
|
+
background: ${u(j)?"var(--tandem-accent-bg)":"none"};
|
|
86
|
+
border: none; cursor: pointer; line-height: 1.5;
|
|
87
|
+
transition: color 0.1s, background 0.1s;
|
|
88
|
+
gap: var(--tandem-space-2);
|
|
89
|
+
`),G(ee,"title",u(N).text),te(K,u(N).text||"(untitled)")}),R("click",ee,()=>g(u(N),B)),Tt("focus",ee,()=>y(l,B,!0)),Tt("mouseenter",ee,T=>{u(j)||(T.currentTarget.style.background="var(--tandem-surface-hover, var(--tandem-surface-muted))")}),Tt("mouseleave",ee,T=>{u(j)||(T.currentTarget.style.background="none")}),S(Q,W)}),S(z,re)};J(D,z=>{u(a).length===0?z(L):z(X,-1)})}Tr(P,(z,re)=>Dt==null?void 0:Dt(z,re),()=>"y"),R("keydown",x,b),R("input",M,p),R("keydown",M,m),Bn(M,()=>u(d),z=>y(d,z)),S(t,x),Le()}Ke(["keydown","input","click"]);var vz=E("<div><!></div>");function om(t,e){Pe(e,!0);let n=P2(e,["$$slots","$$events","$$legacy","kind","visible"]);const r=F(()=>e.visible!==void 0?`display: ${e.visible?"flex":"none"}; flex-direction: column; flex: 1; min-height: 0;${e.kind==="outline"?" padding-bottom: var(--tandem-status-clearance-total, 88px);":""}`:void 0);var i=ft(),o=Se(i);{var s=d=>{var f=vz(),h=w(f);{var p=g=>{v0(g,Jl(()=>n,{get visible(){return e.visible}}))},m=g=>{w0(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=>{b0(g,Jl(()=>n))};J(h,g=>{e.kind==="chat"?g(p):e.kind==="outline"?g(m,1):g(v,-1)})}U(()=>ve(f,u(r))),S(d,f)},a=d=>{v0(d,Jl(()=>n))},l=d=>{w0(d,{get editor(){return e.editor},get annotations(){return e.annotations},get focusTrigger(){return e.focusTrigger},get activeFilterType(){return e.activeFilterType}})},c=d=>{b0(d,Jl(()=>n))};J(o,d=>{u(r)?d(s):e.kind==="chat"?d(a,1):e.kind==="outline"?d(l,2):d(c,-1)})}S(t,i),Le()}var yz=E('<span style="color: var(--tandem-error-fg-strong); font-size: 12px; max-width: 200px;"> </span>'),bz=E('<button type="button" data-testid="convert-to-markdown-btn"> </button>'),wz=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
|
|
90
|
+
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 xz(t,e){Pe(e,!0);const n="tandem:reviewOnlyBannerDismissed";function r(){try{return localStorage.getItem(n)==="true"}catch{return!1}}let i=I(We(r())),o=I(!1),s=I(null);async function a(){if(!(!e.documentId||u(o))){y(o,!0),y(s,null);try{const h=await fetch(`${Nn}${_M}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:e.documentId})});if(!h.ok){const p=await h.json().catch(()=>null);y(s,(p==null?void 0:p.message)??`Conversion failed (HTTP ${h.status}).`,!0)}}catch{y(s,"Could not reach the server.")}finally{y(o,!1)}}}function l(){try{localStorage.setItem(n,"true")}catch{}y(i,!0)}var c=ft(),d=Se(c);{var f=h=>{var p=wz(),m=k(w(p),2),v=w(m);{var g=A=>{var M=yz(),P=w(M);U(()=>te(P,u(s))),S(A,M)};J(v,A=>{u(s)&&A(g)})}var b=k(v,2);{var x=A=>{var M=bz(),P=w(M);U(()=>{M.disabled=u(o),ve(M,`background: var(--tandem-info); border: none; color: var(--tandem-info-fg); cursor: ${u(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: ${u(o)?.6:1};`),te(P,u(o)?"Converting…":"Convert to Markdown")}),R("click",M,a),S(A,M)};J(b,A=>{e.documentId&&A(x)})}var _=k(b,2);R("click",_,l),S(h,p)};J(d,h=>{e.visible&&!u(i)&&h(f)})}S(t,c),Le()}Ke(["click"]);let sm=null;async function kz(t){if(sm!==null)return sm;const e=await fetch(`${Nn}${aw}`,{signal:t});if(!e.ok)throw new Error(`${aw} responded ${e.status} ${e.statusText}`);const n=await e.json();return sm=n,n}function Qh(t){let e=I(null),n=I(!1);return he(()=>{if(!t())return;let r=!1;const i=new AbortController,o=setTimeout(()=>i.abort(),3e3);return y(n,!0),kz(i.signal).then(s=>{r||y(e,s,!0)}).catch(s=>{s instanceof Error&&s.name!=="AbortError"&&console.warn("[useAppInfo] failed to load /api/info:",s)}).finally(()=>{clearTimeout(o),r||y(n,!1)}),()=>{r=!0,clearTimeout(o),i.abort()}}),{get info(){return u(e)},get loading(){return u(n)}}}var _z=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 hC(t,e){Pe(e,!0);const n="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";var r=_z(),i=Se(r),o=w(i);ve(o,n);var s=k(o,2),a=w(s),l=k(i,2),c=w(l);ve(c,n);var d=k(c,2),f=w(d);U(()=>{Vn(a,e.settings.highContrast),Vn(f,e.settings.annotationPatterns)}),R("change",a,h=>e.onUpdate({highContrast:h.target.checked})),R("change",f,h=>e.onUpdate({annotationPatterns:h.target.checked})),S(t,r),Le()}Ke(["change"]);function Ul(t,e,n,r){return{handleKeyDown:s=>{var b;const{key:a}=s;if(a!=="ArrowLeft"&&a!=="ArrowRight"&&a!=="ArrowUp"&&a!=="ArrowDown"&&a!=="Home"&&a!=="End")return;const l=e;if(l.length===0)return;s.preventDefault();const c=t(),d=l.indexOf(c),f=l.length-1;let h;a==="Home"?h=0:a==="End"?h=f:a==="ArrowLeft"||a==="ArrowUp"?h=d<=0?f:d-1:h=d>=f?0:d+1;const p=l[h];n(p);const m=s.currentTarget,v=m==null?void 0:m.querySelectorAll('[role="radio"]'),g=e.indexOf(p);(b=v==null?void 0:v[g])==null||b.focus()},tabIndexFor:s=>{const l=t();return s===l?0:-1}}}var Sz=E('<button role="radio"> </button>'),Cz=E('<button role="radio"> </button>'),Tz=E('<button role="radio"> </button>'),Ez=E('<button role="radio"> </button>'),Az=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="annotation-decorations-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show annotation marks in editor</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Turn off to hide inline highlight, note, comment, and suggestion marks in the editor.
|
|
91
|
+
Annotation cards in the side panel stay visible.</div></div> <div><label data-testid="reduce-motion-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Reduce motion</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Disables smooth autoscroll and the annotation flash animation.</div></div>`,1);function pC(t,e){Pe(e,!0);const n="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";function r(Y,O){return["flex: 1;","padding: var(--tandem-space-2);","min-height: 24px;",`border: 2px solid ${Y?"var(--tandem-accent)":"var(--tandem-border)"};`,"border-radius: var(--tandem-r-3);",`background: ${Y?"var(--tandem-accent-bg)":"var(--tandem-surface)"};`,"cursor: pointer;","text-align: center;","font-size: 11px;",`color: ${Y?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"};`,`font-weight: ${Y?600:400};`,"opacity: 1;","transition: border-color 0.15s, background 0.15s;"].join(" ")}const i=Ul(()=>e.settings.theme,["light","warm","dark","system"],Y=>e.onUpdate({theme:Y})),o=Ul(()=>e.settings.primaryTab,["chat","annotations"],Y=>e.onUpdate({primaryTab:Y})),s=Ul(()=>e.settings.textSize,["s","m","l"],Y=>e.onUpdate({textSize:Y})),a=Ul(()=>e.settings.editorFont,["sans","serif","mono"],Y=>e.onUpdate({editorFont:Y})),l=Ul(()=>e.settings.density,["compact","cozy","spacious"],Y=>e.onUpdate({density:Y}));var c=Az(),d=Se(c),f=w(d);ve(f,n);var h=k(f,2);Ye(h,20,()=>["light","warm","dark","system"],Y=>Y,(Y,O)=>{var T=Sz(),C=w(T);U((Z,q)=>{G(T,"data-testid",`theme-${O}-btn`),G(T,"aria-checked",e.settings.theme===O),G(T,"tabindex",Z),ve(T,q),te(C,O==="light"?"Light":O==="warm"?"Warm":O==="dark"?"Dark":"System")},[()=>i.tabIndexFor(O),()=>r(e.settings.theme===O)]),R("click",T,()=>e.onUpdate({theme:O})),S(Y,T)});var p=k(d,2),m=w(p);ve(m,n);var v=k(m,2),g=w(v),b=k(g,2),x=k(p,2),_=w(x);ve(_,n);var A=k(_,2);Ye(A,20,()=>["s","m","l"],Y=>Y,(Y,O)=>{var T=Cz(),C=w(T);U((Z,q)=>{G(T,"data-testid",`text-size-${O}-btn`),G(T,"aria-checked",e.settings.textSize===O),G(T,"tabindex",Z),ve(T,q),te(C,O==="s"?"Small":O==="m"?"Medium":"Large")},[()=>s.tabIndexFor(O),()=>r(e.settings.textSize===O)]),R("click",T,()=>e.onUpdate({textSize:O})),S(Y,T)});var M=k(x,2),P=w(M);ve(P,n);var D=k(P,2),L=k(w(D),2),X=k(M,2),z=w(X);ve(z,n);var re=k(z,2);Ye(re,20,()=>[["sans","Sans-serif"],["serif","Serif (Source Serif 4)"],["mono","Monospace"]],([Y,O])=>Y,(Y,O)=>{var T=F(()=>Mb(O,2));let C=()=>u(T)[0],Z=()=>u(T)[1];var q=Tz(),oe=w(q);U((ge,$)=>{G(q,"data-testid",`editor-font-${C()}-btn`),G(q,"aria-checked",e.settings.editorFont===C()),G(q,"tabindex",ge),ve(q,$),te(oe,Z())},[()=>a.tabIndexFor(C()),()=>r(e.settings.editorFont===C())]),R("click",q,()=>e.onUpdate({editorFont:C()})),S(Y,q)});var Q=k(X,2),N=w(Q);ve(N,n);var B=k(N,2);Ye(B,20,()=>[["compact","Compact"],["cozy","Cozy"],["spacious","Spacious"]],([Y,O])=>Y,(Y,O)=>{var T=F(()=>Mb(O,2));let C=()=>u(T)[0],Z=()=>u(T)[1];var q=Ez(),oe=w(q);U((ge,$)=>{G(q,"data-testid",`density-${C()}-btn`),G(q,"aria-checked",e.settings.density===C()),G(q,"tabindex",ge),ve(q,$),te(oe,Z())},[()=>l.tabIndexFor(C()),()=>r(e.settings.density===C())]),R("click",q,()=>e.onUpdate({density:C()})),S(Y,q)});var j=k(Q,2),H=w(j),W=w(H),ee=k(j,2),ie=w(ee),K=w(ie);U((Y,O,T,C)=>{G(g,"aria-checked",e.settings.primaryTab==="chat"),G(g,"tabindex",Y),ve(g,O),G(b,"aria-checked",e.settings.primaryTab==="annotations"),G(b,"tabindex",T),ve(b,C),$n(L,e.settings.accentHue),Vn(W,e.settings.showAnnotationDecorations),Vn(K,e.settings.reduceMotion)},[()=>o.tabIndexFor("chat"),()=>r(e.settings.primaryTab==="chat"),()=>o.tabIndexFor("annotations"),()=>r(e.settings.primaryTab==="annotations")]),R("keydown",h,function(...Y){var O;(O=i.handleKeyDown)==null||O.apply(this,Y)}),R("keydown",v,function(...Y){var O;(O=o.handleKeyDown)==null||O.apply(this,Y)}),R("click",g,()=>e.onUpdate({primaryTab:"chat"})),R("click",b,()=>e.onUpdate({primaryTab:"annotations"})),R("keydown",A,function(...Y){var O;(O=s.handleKeyDown)==null||O.apply(this,Y)}),R("input",L,Y=>e.onUpdate({accentHue:Number(Y.target.value)})),R("keydown",re,function(...Y){var O;(O=a.handleKeyDown)==null||O.apply(this,Y)}),R("keydown",B,function(...Y){var O;(O=l.handleKeyDown)==null||O.apply(this,Y)}),R("change",W,Y=>e.onUpdate({showAnnotationDecorations:Y.target.checked})),R("change",K,Y=>e.onUpdate({reduceMotion:Y.target.checked})),S(t,c),Le()}Ke(["keydown","click","input","change"]);var Mz=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 mC(t,e){Pe(e,!0);const n="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;";var r=Mz(),i=w(r);ve(i,n);var o=k(w(i)),s=w(o),a=k(i,4);G(a,"min",40),G(a,"max",100),G(a,"step",5),U(()=>{te(s,`${e.settings.editorWidthPercent??""}%`),$n(a,e.settings.editorWidthPercent)}),R("input",a,l=>e.onUpdate({editorWidthPercent:Number(l.target.value)})),S(t,r),Le()}Ke(["input"]);var Oz=E('<details><summary class="svelte-x76129"> </summary> <div><!></div></details>');function gC(t,e){const n=nt(e,"defaultOpen",3,!1),r="font-size: 11px; font-weight: 600; color: var(--tandem-fg); cursor: pointer; padding: var(--tandem-space-2) 0; text-transform: uppercase; letter-spacing: 0.5px; user-select: none; list-style: none;",i="display: flex; flex-direction: column; gap: var(--tandem-space-3); padding-top: var(--tandem-space-2);";var o=Oz(),s=w(o);ve(s,r);var a=w(s),l=k(s,2);ve(l,i);var c=w(l);Cd(c,()=>e.children),U(()=>{G(o,"data-testid",e.testid),o.open=n(),G(s,"data-testid",e.testid?`${e.testid}-toggle`:void 0),te(a,e.label)}),S(t,o)}var Dz=E('<span style="color: var(--tandem-fg-subtle);"> </span>'),Iz=E('<button type="button" data-testid="network-restart-sidecar"> </button>'),Rz=E('<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop && tandem start</code> to restart</span>'),Nz=E('<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>'),Pz=E("<span><strong>Host:</strong> </span>"),Lz=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>'),zz=E("<option> </option>"),Fz=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>'),Bz=E('<!> <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),Vz=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> <!>',1);function vC(t,e){Pe(e,!0);const n=Qh(()=>e.open),r=Nt();let i=I(null),o=I(!1);async function s(){if(r){y(o,!0),y(i,null);try{const{invoke:O}=await Rn(async()=>{const{invoke:T}=await import("./core-DhEqZVGG.js");return{invoke:T}},[]);await O("restart_sidecar")}catch(O){y(i,O instanceof Error?O.message:String(O),!0)}finally{y(o,!1)}}}const a=[{value:"exponential",label:"Exponential backoff"},{value:"constant-2s",label:"Constant (2s)"},{value:"manual",label:"Manual only"}],l="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",c="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;",d="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);",f=F(()=>{var O;return(O=n.info)==null?void 0:O.transport}),h=F(()=>{var O;return(O=n.info)==null?void 0:O.bindHost}),p=F(()=>{var O;return(O=n.info)==null?void 0:O.bindPort}),m=F(()=>u(f)==="http"),v=F(()=>{var O;return(O=n.info)==null?void 0:O.tokenRotatedAt});var g=Vz(),b=Se(g),x=w(b);ve(x,l);var _=k(x,2),A=w(_),M=k(A,2),P=w(M),D=k(P);{var L=O=>{var T=Dz(),C=w(T);U(()=>te(C,`· ${e.reconnectAttempts??""} retry attempt${e.reconnectAttempts===1?"":"s"}`)),S(O,T)};J(D,O=>{e.reconnectAttempts>0&&O(L)})}var X=k(M,2);{var z=O=>{var T=Iz(),C=w(T);U(()=>{T.disabled=u(o),ve(T,`padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; opacity: ${u(o)?.5:1};`),te(C,u(o)?"Restarting…":"Restart sidecar")}),R("click",T,s),S(O,T)},re=O=>{var T=Rz();S(O,T)};J(X,O=>{r?O(z):O(re,-1)})}var Q=k(_,2);{var N=O=>{var T=Nz(),C=w(T);U(()=>te(C,u(i))),S(O,T)};J(Q,O=>{u(i)&&O(N)})}var B=k(b,2),j=w(B);ve(j,l);var H=k(j,2),W=w(H),ee=k(w(W)),ie=k(W,2);{var K=O=>{var T=Pz(),C=k(w(T));U(()=>te(C,` ${u(h)??""}`)),S(O,T)};J(ie,O=>{u(h)&&O(K)})}var Y=k(B,2);gC(Y,{label:"Advanced",testid:"network-advanced",children:(O,T)=>{var C=Bz(),Z=Se(C);{var q=fe=>{var Ee=Lz(),Re=w(Ee);ve(Re,l);var Ge=k(Re,2),Te=w(Ge),Me=k(Ge,2);ve(Me,d),U(()=>te(Te,u(p)??"—")),S(fe,Ee)};J(Z,fe=>{u(m)&&fe(q)})}var oe=k(Z,2),ge=w(oe);ve(ge,l);var $=k(w(ge)),le=w($),ce=k(ge,2),ue=k(oe,2),pe=w(ue);ve(pe,l);var _e=k(pe,2);Ye(_e,21,()=>a,fe=>fe.value,(fe,Ee)=>{var Re=zz(),Ge=w(Re),Te={};U(()=>{te(Ge,u(Ee).label),Te!==(Te=u(Ee).value)&&(Re.value=(Re.__value=u(Ee).value)??"")}),S(fe,Re)});var ae;Uv(_e);var de=k(ue,2);ve(de,c);var ye=w(de),ke=k(de,2);ve(ke,d);var Ve=k(ke,2);{var qe=fe=>{var Ee=Fz(),Re=w(Ee);ve(Re,l);var Ge=k(Re,2),Te=w(Ge),Me=k(Ge,2);ve(Me,d),U(dt=>te(Te,dt),[()=>u(v)===null?"Auth token not yet created":`Last rotated: ${new Date(u(v)).toLocaleString()}`]),S(fe,Ee)};J(Ve,fe=>{u(v)!==void 0&&fe(qe)})}U(()=>{te(le,`${e.settings.degradedBannerDelayMs/1e3}s`),$n(ce,e.settings.degradedBannerDelayMs),ae!==(ae=e.settings.sidecarRetryStrategy)&&(_e.value=(_e.__value=e.settings.sidecarRetryStrategy)??"",Oh(_e,e.settings.sidecarRetryStrategy)),Vn(ye,e.settings.holdAnnotationsWhileOffline)}),R("input",ce,fe=>e.onUpdate({degradedBannerDelayMs:Number(fe.target.value)})),R("change",_e,fe=>e.onUpdate({sidecarRetryStrategy:fe.target.value})),R("change",ye,fe=>e.onUpdate({holdAnnotationsWhileOffline:fe.target.checked})),S(O,C)},$$slots:{default:!0}}),U(O=>{ve(A,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${e.connected?"var(--tandem-success)":"var(--tandem-error)"}; flex-shrink: 0;`),te(P,`${e.connected?"Connected to Tandem server":"Disconnected"} `),te(ee,` ${O??""}`)},[()=>u(f)?u(f).toUpperCase():"—"]),S(t,g),Le()}Ke(["click","input","change"]);const Hz="INVALID_BODY",Uz="PATH_REJECTED",jz="LAUNCHER_IN_PROGRESS",Wz="LAUNCHER_NOT_AVAILABLE",Kz="NO_CLAUDE_INTEGRATION";var qz=E('<div role="alert" data-testid="settings-modal-working-directory-load-error" style="font-size: 11px; color: var(--tandem-error-fg); background: var(--tandem-error-bg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); padding: var(--tandem-space-2);"> </div>'),Gz=E('<button type="button" data-testid="settings-modal-working-directory-pick" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-elevated); color: var(--tandem-fg); cursor: pointer;">Choose folder…</button>'),Jz=E('<div role="alert" style="font-size: 11px; color: var(--tandem-error-fg);"> </div>'),Yz=E('<div data-testid="settings-modal-working-directory" style="display: flex; flex-direction: column; gap: var(--tandem-space-2);"><div class="settings-section-label">Claude working directory</div> <div style="font-size: 10px; color: var(--tandem-fg-subtle);">Folder where Claude launches. Defaults to your home directory if empty.</div> <form style="display: flex; gap: var(--tandem-space-2);"><input type="text" name="wd" data-testid="settings-modal-working-directory-input" style="flex: 1; font-size: 12px; padding: var(--tandem-space-2); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface); color: var(--tandem-fg); font-family: var(--tandem-font-mono);"/> <button type="submit" data-testid="settings-modal-working-directory-save" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-elevated); color: var(--tandem-fg); cursor: pointer;">Save</button></form> <div style="display: flex; gap: var(--tandem-space-2);"><!> <button type="button" data-testid="settings-modal-working-directory-reset" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: transparent; color: var(--tandem-fg-muted); cursor: pointer;">Reset to default</button></div> <!></div>'),Zz=E('<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),Xz=E(`<p style="font-size: 12px; line-height: 1.5; color: var(--tandem-fg-muted); margin: 0 0 var(--tandem-space-3);">Tandem connects to any MCP-capable AI client over its MCP endpoint. Claude (Claude Code and
|
|
92
|
+
Claude Desktop) is the default integration — auto-configured, tested, and the only client whose
|
|
93
|
+
channel-push, cowork, and auto-launch extras are validated today. Other clients can connect
|
|
94
|
+
manually using the MCP endpoint on the Network tab.</p> <div><div class="settings-section-label">Selection Sensitivity: <span style="font-weight: 400; text-transform: none;"> </span></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 6px;">How long you must hold a selection before your AI notices it</div> <input data-testid="settings-modal-dwell-time-slider" type="range" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Selection dwell time"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span> </span> <span> </span></div></div> <label data-testid="settings-modal-selection-toolbar-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show floating selection toolbar</span></label> <label data-testid="settings-modal-margin-view-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Margin annotation view (Word-style)</span></label> <!> <!> <button type="button" data-testid="settings-modal-open-integration-wizard" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-elevated); color: var(--tandem-fg); cursor: pointer; align-self: flex-start;">Reopen integration wizard…</button> <!>`,1);function Qz(t,e){Pe(e,!0);function n(T){switch(T){case Uz:return"Working directory must be a folder inside your home directory.";case Hz:return"Working directory path is invalid.";case jz:return"Another working-directory update is in progress. Try again.";case Kz:return"No Claude Code integration is configured.";case Wz:return"Auto-launcher is not available in this Tandem build.";default:return"Couldn't save working directory."}}function r(){window.dispatchEvent(new CustomEvent("tandem:open-integration-wizard"))}let i=I(null),o=I(!1),s=I(null),a=I(!1),l=I(!1),c=I(null),d=!0;Qr(()=>{d=!1});async function f(){var T;try{const C=await fetch(`${Nn}/api/integrations`);if(!d)return;if(!C.ok){y(c,`Failed to load integrations (HTTP ${C.status}).`);return}const Z=await C.json();if(!d)return;const q=(T=Z.integrations)==null?void 0:T.find(oe=>oe.kind==="claude-code");q&&(y(l,!0),y(i,q.workingDirectory??null,!0))}catch(C){if(!d)return;console.warn("[Settings] Failed to load workingDirectory:",C),y(c,"Couldn't load Claude working directory.")}finally{d&&y(a,!0)}}f();async function h(T){y(o,!0),y(s,null);try{const C=await fetch(`${Nn}${IM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDirectory:T})});if(!d)return;if(!C.ok){const q=await C.json().catch(()=>({}));if(!d)return;y(s,n(q.code),!0);return}const Z=await C.json();if(!d)return;y(i,Z.workingDirectory??null,!0),e.notify("info","Working directory saved.")}catch(C){if(!d)return;console.warn("[Settings] Failed to save workingDirectory:",C),y(s,"Couldn't save working directory.")}finally{d&&y(o,!1)}}async function p(){let T;try{({open:T}=await Rn(()=>import("./index-Dm_QtxGQ.js"),__vite__mapDeps([0,1])))}catch(C){console.warn("[Settings] Folder picker import failed:",C),e.notify("error","Folder picker plugin unavailable");return}try{const C=await T({directory:!0,multiple:!1,title:"Choose Claude working directory"});typeof C=="string"&&h(C)}catch(C){console.warn("[Settings] Folder picker open() failed:",C),e.notify("error","Folder picker permission denied or IPC error")}}function m(T){T.preventDefault();const C=T.target.elements.namedItem("wd"),Z=C==null?void 0:C.value.trim();h(Z||null)}function v(){h(null)}var g=Xz(),b=k(Se(g),2),x=w(b),_=k(w(x)),A=w(_),M=k(x,4);G(M,"step",100);var P=k(M,2),D=w(P),L=w(D),X=k(D,2),z=w(X),re=k(b,2),Q=w(re),N=k(re,2),B=w(N),j=k(N,2);{var H=T=>{var C=qz(),Z=w(C);U(()=>te(Z,u(c))),S(T,C)};J(j,T=>{u(a)&&!u(l)&&u(c)&&T(H)})}var W=k(j,2);{var ee=T=>{var C=Yz(),Z=k(w(C),4),q=w(Z);G(q,"placeholder","(default: home)");var oe=k(q,2),ge=k(Z,2),$=w(ge);{var le=ae=>{var de=Gz();U(()=>de.disabled=u(o)),R("click",de,p),S(ae,de)},ce=F(()=>Nt());J($,ae=>{u(ce)&&ae(le)})}var ue=k($,2),pe=k(ge,2);{var _e=ae=>{var de=Jz(),ye=w(de);U(()=>te(ye,u(s))),S(ae,de)};J(pe,ae=>{u(s)&&ae(_e)})}U(()=>{$n(q,u(i)??""),q.disabled=u(o),oe.disabled=u(o),ue.disabled=u(o)||u(i)===null}),Tt("submit",Z,m),R("click",ue,v),S(T,C)};J(W,T=>{u(a)&&u(l)&&T(ee)})}var ie=k(W,2),K=k(ie,2);{var Y=T=>{var C=ft(),Z=Se(C);mk(Z,()=>Rn(()=>import("./CoworkSettings-BOYbyKul.js"),[]),q=>{var oe=Zz();S(q,oe)},(q,oe)=>{const ge=F(()=>u(oe).default);var $=ft(),le=Se($);Hv(le,()=>u(ge),(ce,ue)=>{ue(ce,{})}),S(q,$)}),S(T,C)},O=F(()=>Nt());J(K,T=>{u(O)&&T(Y)})}U((T,C,Z)=>{te(A,`${T??""}s`),G(M,"min",ll),G(M,"max",cl),$n(M,e.settings.selectionDwellMs),te(L,`${C??""}s`),te(z,`${Z??""}s`),Vn(Q,e.settings.selectionToolbar),Vn(B,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(ll/1e3).toFixed(1),()=>(cl/1e3).toFixed(1)]),R("input",M,T=>e.onUpdate({selectionDwellMs:Number(T.target.value)})),R("change",Q,T=>e.onUpdate({selectionToolbar:T.target.checked})),R("change",B,T=>e.onUpdate({marginView:T.target.checked})),R("click",ie,r),S(t,g),Le()}Ke(["input","change","click"]);function Ry(t){const e=t==null?void 0:t.trim();return e?e.slice(0,Rh):Nk}function Ny(){try{return Ry(localStorage.getItem(Gv))}catch{return Nk}}function $z(t){const e=Ry(t);try{localStorage.setItem(Gv,e)}catch{}return typeof window<"u"&&window.dispatchEvent(new Event(pg)),e}function yC(t){const e=()=>t(Ny()),n=r=>{r.key===Gv&&t(Ry(r.newValue))};return window.addEventListener(pg,e),window.addEventListener("storage",n),()=>{window.removeEventListener(pg,e),window.removeEventListener("storage",n)}}function Py(){let t=I(We(Ny()));const e=yC(r=>{y(t,r,!0)});return Qr(e),{get userName(){return u(t)},setUserName:r=>{const i=$z(r);y(t,i,!0)}}}var e4=E(`<div><label for="settings-modal-display-name" class="settings-section-label">Display Name</label> <input id="settings-modal-display-name" data-testid="settings-modal-display-name" type="text" style="width: 100%; padding: 8px 10px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); outline: none;"/></div> <div><div id="settings-modal-default-mode-label" class="settings-section-label">Default Mode</div> <div role="radiogroup" aria-labelledby="settings-modal-default-mode-label" style="display: flex; gap: var(--tandem-space-2);"><button type="button" data-testid="settings-modal-default-mode-tandem-btn" role="radio">Tandem</button> <button type="button" data-testid="settings-modal-default-mode-solo-btn" role="radio">Solo</button></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Sets the preferred starting mode for new sessions.</div></div> <label data-testid="settings-modal-solo-rail-hidden-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Hide side panel in Solo mode</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">When enabled, the annotation panel hides automatically when you enter Solo mode and
|
|
95
|
+
restores when you return to Tandem.</div>`,1);function t4(t,e){Pe(e,!0);const n=Py();let r=I(We(n.userName)),i=I(void 0);he(()=>{const m=n.userName;u(r)!==m&&document.activeElement!==u(i)&&y(r,m,!0)});var o=e4(),s=Se(o),a=k(w(s),2);pt(a,m=>y(i,m),()=>u(i));var l=k(s,2),c=k(w(l),2),d=w(c),f=k(d,2),h=k(l,2),p=w(h);U(()=>{$n(a,u(r)),G(a,"maxlength",Rh),G(d,"aria-checked",e.settings.defaultMode==="tandem"),ve(d,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="tandem"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="tandem"?600:400}; cursor: pointer;`),G(f,"aria-checked",e.settings.defaultMode==="solo"),ve(f,`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;`),Vn(p,e.settings.soloRailHidden)}),R("input",a,m=>{y(r,m.target.value,!0)}),Tt("blur",a,()=>n.setUserName(u(r))),R("keydown",a,m=>{m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(y(r,n.userName,!0),m.currentTarget.blur())}),R("click",d,()=>e.onUpdate({defaultMode:"tandem"})),R("click",f,()=>e.onUpdate({defaultMode:"solo"})),R("change",p,m=>e.onUpdate({soloRailHidden:m.target.checked})),S(t,o),Le()}Ke(["input","keydown","click","change"]);var n4=E("<option> </option>"),r4=E('<div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="flex: 1; padding: 6px 8px; font-size: 13px; color: var(--tandem-fg-muted); background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); font-family: var(--tandem-font-mono);" aria-label="Existing API key (masked)"> </span> <button type="button" data-testid="model-edit-apikey-replace-btn" style="padding: 4px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer;">Replace key</button></div>'),i4=E('<input data-testid="model-edit-apikey" type="password" autocomplete="off" style="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); font-family: var(--tandem-font-mono);"/>'),o4=E('<label style="display: flex; flex-direction: column; gap: 4px;"><span style="font-size: 11px; font-weight: 600; color: var(--tandem-fg); text-transform: uppercase; letter-spacing: 0.5px;">API key</span> <!></label>'),s4=E('<label style="display: flex; flex-direction: column; gap: 4px;"><span style="font-size: 11px; font-weight: 600; color: var(--tandem-fg); text-transform: uppercase; letter-spacing: 0.5px;">Endpoint</span> <input data-testid="model-edit-endpoint" type="text" autocomplete="off" placeholder="http://localhost:11434" style="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); font-family: var(--tandem-font-mono);"/></label>'),a4=E('<p style="font-size: 11px; color: var(--tandem-fg-subtle); margin: 0;">Per-model parameter overrides (temperature, max tokens, etc.) are not editable in\n this preview. The data model accepts a `params` map for forward-compat with\n Wave 6 surfaces.</p>'),l4=E('<div role="dialog" aria-modal="true" data-testid="model-edit-modal" style="position: fixed; inset: 0; z-index: var(--tandem-z-modal); display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; background: rgba(0,0,0,0.3);"><form style="background: var(--tandem-surface); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-3); width: 480px; padding: 20px; display: flex; flex-direction: column; gap: var(--tandem-space-3);"><div style="display: flex; justify-content: space-between; align-items: center;"><h3 style="margin: 0; font-size: 15px; font-weight: 600; color: var(--tandem-fg);"> </h3> <button type="button" data-testid="model-edit-cancel" style="background: none; border: none; cursor: pointer; font-size: 16px; color: var(--tandem-fg-subtle);" aria-label="Close">×</button></div> <label style="display: flex; flex-direction: column; gap: 4px;"><span style="font-size: 11px; font-weight: 600; color: var(--tandem-fg); text-transform: uppercase; letter-spacing: 0.5px;">Provider</span> <select data-testid="model-edit-provider" style="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;"></select></label> <label style="display: flex; flex-direction: column; gap: 4px;"><span style="font-size: 11px; font-weight: 600; color: var(--tandem-fg); text-transform: uppercase; letter-spacing: 0.5px;">Display name</span> <input data-testid="model-edit-displayname" type="text" autocomplete="off" placeholder="My Anthropic key" style="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);"/></label> <label style="display: flex; flex-direction: column; gap: 4px;"><span style="font-size: 11px; font-weight: 600; color: var(--tandem-fg); text-transform: uppercase; letter-spacing: 0.5px;">Model ID</span> <input data-testid="model-edit-modelid" type="text" autocomplete="off" placeholder="e.g. claude-opus-4-7" style="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); font-family: var(--tandem-font-mono);"/></label> <!> <!> <label style="display: flex; align-items: center; gap: var(--tandem-space-2); font-size: 12px; color: var(--tandem-fg);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Enabled</span></label> <!> <div style="display: flex; justify-content: flex-end; gap: var(--tandem-space-2); margin-top: var(--tandem-space-2);"><button type="button" style="padding: 6px var(--tandem-space-3); font-size: 13px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer;">Cancel</button> <button type="submit" data-testid="model-edit-save"> </button></div></form></div>');function c4(t,e){Pe(e,!0);const n=[{value:"anthropic",label:"Anthropic"},{value:"openai",label:"OpenAI"},{value:"gemini",label:"Gemini"},{value:"local-ollama",label:"Ollama (local)"},{value:"local-llamacpp",label:"llama.cpp (local)"}],r=vt(()=>e.entry);let i=I(We((r==null?void 0:r.provider)??"anthropic")),o=I(We((r==null?void 0:r.displayName)??"")),s=I(We((r==null?void 0:r.modelId)??"")),a=I(We((r==null?void 0:r.endpoint)??"")),l=I(We((r==null?void 0:r.enabled)??!0)),c=I("");const d=r!==void 0&&!!r.apiKeyRef;let f=I(We(r===void 0||!d));const h=r!==void 0,p=F(()=>u(i)==="anthropic"||u(i)==="openai"||u(i)==="gemini"),m=F(()=>u(i).startsWith("local-")),v=r!=null&&r.apiKeyRef?r.apiKeyRef.slice(-4):"",g=F(()=>u(o).trim().length>0&&u(s).trim().length>0&&(!u(p)||!u(f)||u(c).trim().length>0));function b(q){if(q.preventDefault(),!u(g))return;const oe={provider:u(i),displayName:u(o).trim(),modelId:u(s).trim(),enabled:u(l)};u(p)&&u(f)&&u(c).trim()&&(oe.plaintextApiKey=u(c).trim()),u(m)&&u(a).trim()&&(oe.endpoint=u(a).trim()),e.onSave(oe)}function x(){y(f,!0),y(c,"")}var _=l4();G(_,"tabindex",-1);var A=w(_),M=w(A),P=w(M),D=w(P),L=k(P,2),X=k(M,2),z=k(w(X),2);Ye(z,21,()=>n,q=>q.value,(q,oe)=>{var ge=n4(),$=w(ge),le={};U(()=>{te($,u(oe).label),le!==(le=u(oe).value)&&(ge.value=(ge.__value=u(oe).value)??"")}),S(q,ge)});var re=k(X,2),Q=k(w(re),2),N=k(re,2),B=k(w(N),2),j=k(N,2);{var H=q=>{var oe=o4(),ge=k(w(oe),2);{var $=ce=>{var ue=r4(),pe=w(ue),_e=w(pe),ae=k(pe,2);U(()=>te(_e,`••••••••${v??""}`)),R("click",ae,x),S(ce,ue)},le=ce=>{var ue=i4();U(()=>G(ue,"placeholder",h?"Enter new key":"Paste your API key")),Bn(ue,()=>u(c),pe=>y(c,pe)),S(ce,ue)};J(ge,ce=>{h&&(r!=null&&r.apiKeyRef)&&!u(f)?ce($):ce(le,-1)})}S(q,oe)};J(j,q=>{u(p)&&q(H)})}var W=k(j,2);{var ee=q=>{var oe=s4(),ge=k(w(oe),2);Bn(ge,()=>u(a),$=>y(a,$)),S(q,oe)};J(W,q=>{u(m)&&q(ee)})}var ie=k(W,2),K=w(ie),Y=k(ie,2);gC(Y,{label:"Advanced parameters",testid:"model-edit-advanced",children:(q,oe)=>{var ge=a4();S(q,ge)},$$slots:{default:!0}});var O=k(Y,2),T=w(O),C=k(T,2),Z=w(C);U(()=>{G(_,"aria-label",h?"Edit model":"Add model"),te(D,h?"Edit model":"Add model"),C.disabled=!u(g),ve(C,`padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: ${u(g)?"pointer":"not-allowed"}; background: var(--tandem-accent); color: var(--tandem-accent-fg); opacity: ${u(g)?1:.5};`),te(Z,h?"Save changes":"Add model")}),R("click",_,q=>{q.target===q.currentTarget&&e.onCancel()}),R("keydown",_,q=>{q.key==="Escape"&&e.onCancel()}),Tt("submit",A,b),R("click",L,function(...q){var oe;(oe=e.onCancel)==null||oe.apply(this,q)}),E2(z,()=>u(i),q=>y(i,q)),Bn(Q,()=>u(o),q=>y(o,q)),Bn(B,()=>u(s),q=>y(s,q)),Pu(K,()=>u(l),q=>y(l,q)),R("click",T,function(...q){var oe;(oe=e.onCancel)==null||oe.apply(this,q)}),S(t,_),Le()}Ke(["click","keydown"]);var d4=E('<span data-testid="models-legacy-migration-status"> </span>'),u4=E(`<div data-testid="models-legacy-migration-banner" role="note" style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-3); background: var(--tandem-warning-bg); color: var(--tandem-warning-fg-strong); font-size: 12px; line-height: 1.5; display: flex; flex-direction: column; gap: var(--tandem-space-2);"><div><strong style="font-weight: 600;">Move API keys to OS keychain.</strong> Existing keys were stored unencrypted in browser storage. Move them now to
|
|
96
|
+
encrypt them with your operating system's credential store.</div> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><button type="button" data-testid="models-legacy-migrate-btn"> </button> <!></div></div>`),f4=E('<div data-testid="models-empty-state" style="padding: var(--tandem-space-5) var(--tandem-space-3); text-align: center; border: 1px dashed var(--tandem-border-strong); border-radius: var(--tandem-r-3); color: var(--tandem-fg-muted); font-size: 13px;"><p style="margin: 0 0 var(--tandem-space-3) 0;">No models configured.</p> <button type="button" data-testid="model-add-btn" style="padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: pointer; background: var(--tandem-accent); color: var(--tandem-accent-fg);">Add your first model</button></div>'),h4=E('<button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); cursor: pointer;">Confirm</button> <button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button>',1),p4=E('<button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-error-fg); cursor: pointer;">Delete</button>'),m4=E('<div style="display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface);"><div style="flex: 1; min-width: 0;"><div style="font-size: 13px; color: var(--tandem-fg); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </div> <div style="font-size: 11px; color: var(--tandem-fg-subtle); font-family: var(--tandem-font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </div></div> <label style="display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tandem-fg-muted);" title="Use as the default model"><input type="radio" name="default-model" style="accent-color: var(--tandem-accent);"/> <span>Default</span></label> <label style="display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tandem-fg-muted);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span> </span></label> <button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer;">Edit</button> <!></div>'),g4=E('<div><div style="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;"> </div> <div style="display: flex; flex-direction: column; gap: 4px;"></div></div>'),v4=E('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"></div> <button type="button" data-testid="model-add-btn" style="align-self: flex-start; padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-accent-border); border-radius: var(--tandem-r-2); cursor: pointer; background: var(--tandem-surface); color: var(--tandem-accent);">+ Add model</button>',1),y4=E('<div role="alert" data-testid="models-save-error" style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-3); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); font-size: 12px;"> </div>'),b4=E('<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"><!> <!></div> <!> <!>',1);function w4(t,e){Pe(e,!0);const n=oy(),r=R_(n),i={anthropic:"Anthropic",openai:"OpenAI",gemini:"Gemini","local-ollama":"Ollama (local)","local-llamacpp":"llama.cpp (local)"},o=["anthropic","openai","gemini","local-ollama","local-llamacpp"],s=F(()=>{const N=new Map;for(const B of o)N.set(B,[]);for(const B of r.models){const j=N.get(B.provider);j&&j.push(B)}return N});let a=I(void 0),l=I(!1),c=I(null),d=I(null),f=I(!1),h=I(null);function p(){y(a,void 0),y(d,null),y(l,!0)}function m(N){y(a,N,!0),y(d,null),y(l,!0)}async function v(N){const{plaintextApiKey:B,...j}=N;try{u(a)?await r.updateModel(u(a).id,j,B):await r.addModel(j,B),y(l,!1),y(a,void 0),y(d,null)}catch(H){y(d,H instanceof Error?H.message:"Failed to save",!0)}}async function g(N){await r.deleteModel(N),y(c,null)}async function b(){y(f,!0),y(h,null);try{const N=await r.migrateLegacyKeys();N.failed>0?y(h,`Migrated ${N.migrated}; ${N.failed} failed. Retry?`):N.migrated>0&&y(h,`Migrated ${N.migrated} ${N.migrated===1?"key":"keys"} to OS keychain.`)}finally{y(f,!1)}}var x=b4(),_=Se(x),A=w(_);{var M=N=>{var B=u4(),j=k(w(B),2),H=w(j),W=w(H),ee=k(H,2);{var ie=K=>{var Y=d4(),O=w(Y);U(()=>te(O,u(h))),S(K,Y)};J(ee,K=>{u(h)&&K(ie)})}U(()=>{H.disabled=u(f),ve(H,`padding: 4px var(--tandem-space-3); font-size: 12px; font-weight: 500; border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-warning-fg-strong); cursor: ${u(f)?"wait":"pointer"};`),te(W,u(f)?"Migrating…":"Migrate keys")}),R("click",H,b),S(N,B)};J(A,N=>{r.hasLegacyKeys&&N(M)})}var P=k(A,2);{var D=N=>{var B=f4(),j=k(w(B),2);R("click",j,p),S(N,B)},L=N=>{var B=v4(),j=Se(B);Ye(j,20,()=>o,W=>W,(W,ee)=>{const ie=F(()=>u(s).get(ee)??[]);var K=ft(),Y=Se(K);{var O=T=>{var C=g4(),Z=w(C),q=w(Z),oe=k(Z,2);Ye(oe,21,()=>u(ie),ge=>ge.id,(ge,$)=>{var le=m4(),ce=w(le),ue=w(ce),pe=w(ue),_e=k(ue,2),ae=w(_e),de=k(ce,2),ye=w(de),ke=k(de,2),Ve=w(ke),qe=k(Ve,2),fe=w(qe),Ee=k(ke,2),Re=k(Ee,2);{var Ge=Me=>{var dt=h4(),Kt=Se(dt),ze=k(Kt,2);U(()=>G(Kt,"data-testid",`model-delete-confirm-${u($).id}`)),R("click",Kt,()=>g(u($).id)),R("click",ze,()=>y(c,null)),S(Me,dt)},Te=Me=>{var dt=p4();U(()=>G(dt,"data-testid",`model-delete-btn-${u($).id}`)),R("click",dt,()=>y(c,u($).id,!0)),S(Me,dt)};J(Re,Me=>{u(c)===u($).id?Me(Ge):Me(Te,-1)})}U(()=>{G(le,"data-testid",`model-row-${u($).id}`),te(pe,u($).displayName),te(ae,u($).modelId),G(ye,"data-testid",`model-default-${u($).id}`),Vn(ye,r.defaultModelId===u($).id),G(Ve,"data-testid",`model-toggle-${u($).id}`),Vn(Ve,u($).enabled),te(fe,u($).enabled?"On":"Off"),G(Ee,"data-testid",`model-edit-btn-${u($).id}`)}),R("change",ye,()=>r.setDefault(u($).id)),R("change",Ve,()=>r.toggleEnabled(u($).id)),R("click",Ee,()=>m(u($))),S(ge,le)}),U(()=>te(q,i[ee])),S(T,C)};J(Y,T=>{u(ie).length>0&&T(O)})}S(W,K)});var H=k(j,2);R("click",H,p),S(N,B)};J(P,N=>{r.models.length===0?N(D):N(L,-1)})}var X=k(_,2);{var z=N=>{var B=y4(),j=w(B);U(()=>te(j,u(d))),S(N,B)};J(X,N=>{u(d)&&N(z)})}var re=k(X,2);{var Q=N=>{c4(N,{get entry(){return u(a)},onCancel:()=>{y(l,!1),y(a,void 0),y(d,null)},onSave:v})};J(re,N=>{u(l)&&N(Q)})}S(t,x),Le()}Ke(["click","change"]);var x4=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),k4=E('<section><div class="settings-section-label"> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section>'),_4=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),S4=E('<div data-testid="settings-modal-shortcuts-list" style="display: flex; flex-direction: column; gap: var(--tandem-space-4);"><!> <section><div class="settings-section-label">Other</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section></div>');function C4(t,e){Pe(e,!0),he(()=>{});const n=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"Ctrl+F",description:"Find / Replace"},{keys:"?",description:"Show keyboard shortcuts"},{keys:"Ctrl+Tab",description:"Next document tab"},{keys:"Ctrl+Shift+Tab",description:"Previous document tab"}],r=F(()=>{const l=Rc(),c=new Map;for(const d of l.values()){if(!d.shortcut)continue;const f=c.get(d.group)??[];f.push({keys:d.shortcut,description:d.label}),c.set(d.group,f)}return Jv.map(d=>({title:d.charAt(0).toUpperCase()+d.slice(1),rows:c.get(d)??[]})).filter(d=>d.rows.length>0)});var i=S4(),o=w(i);Ye(o,17,()=>u(r),l=>l.title,(l,c)=>{var d=k4(),f=w(d),h=w(f),p=k(f,2);Ye(p,21,()=>u(c).rows,m=>m.keys+m.description,(m,v)=>{var g=x4(),b=Se(g),x=w(b),_=k(b,2),A=w(_);U(()=>{te(x,u(v).keys),te(A,u(v).description)}),S(m,g)}),U(()=>te(h,u(c).title)),S(l,d)});var s=k(o,2),a=k(w(s),2);Ye(a,21,()=>n,l=>l.keys+l.description,(l,c)=>{var d=_4(),f=Se(d),h=w(f),p=k(f,2),m=w(p);U(()=>{te(h,u(c).keys),te(m,u(c).description)}),S(l,d)}),S(t,i),Le()}var T4=E('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),E4=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),A4=E('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),M4=E('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),O4=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),D4=E('<div><button type="button" data-testid="settings-modal-view-documentation-btn"> </button> <!></div> <div data-testid="settings-modal-app-info-footer" style="border-top: 1px solid var(--tandem-border); padding-top: 10px;"><div class="settings-section-label">About</div> <!></div>',1);function I4(t,e){Pe(e,!0);const n=Qh(()=>e.open);let r=I(!1),i=I(null);async function o(){var A;const x=(A=n.info)==null?void 0:A.workflowsPath;if(!x){y(i,"Documentation file not found.");return}y(r,!0),y(i,null);const _=await us(x,{readOnly:!0,notFoundMessage:"Documentation file not found.",failureMessage:"Failed to open documentation."});y(r,!1),_.ok||y(i,_.error,!0)}const s=F(()=>{var A;const x=n.info;if(!x)return[];const _=[{label:"Version",value:`Tandem v${x.version}`},{label:"Tools",value:x.toolCount===null?"Tool count unavailable":`${x.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${x.mcpSdkVersion}`},{label:"Transport",value:((A=x.transport)==null?void 0:A.toUpperCase())??"—"}];return x.storagePath&&_.push({label:"Storage",value:x.storagePath}),x.tokenRotatedAt!==void 0&&_.push({label:"Token",value:x.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(x.tokenRotatedAt).toLocaleString()}`}),x.changelogPath&&_.push({label:"Changelog",value:x.changelogPath}),_});var a=D4(),l=Se(a),c=w(l),d=w(c),f=k(c,2);{var h=x=>{var _=T4(),A=w(_);U(()=>te(A,u(i))),S(x,_)};J(f,x=>{u(i)&&x(h)})}var p=k(l,2),m=k(w(p),2);{var v=x=>{var _=E4();S(x,_)},g=x=>{var _=M4();Ye(_,21,()=>u(s),A=>A.label,(A,M)=>{var P=A4(),D=Se(P),L=w(D),X=k(D,2),z=w(X);U(()=>{te(L,u(M).label),te(z,u(M).value)}),S(A,P)}),S(x,_)},b=x=>{var _=O4();S(x,_)};J(m,x=>{n.loading?x(v):n.info?x(g,1):x(b,-1)})}U(()=>{c.disabled=u(r)||n.loading,ve(c,`width: 100%; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: ${u(r)||n.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${u(r)||n.loading?.6:1};`),te(d,u(r)?"Opening…":"View Documentation")}),R("click",c,()=>void o()),S(t,a),Le()}Ke(["click"]);const R4={models:"models"};var N4=E('<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>'),P4=E('<button type="button" class="settings-modal-nav-btn svelte-bbu5nk"><svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path></path></svg> <span> </span></button>'),L4=E('<div role="alert" data-testid="settings-modal-changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),z4=E('<div role="button" tabindex="-1" aria-label="Close settings" data-testid="settings-modal-scrim" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); z-index: 100000;"></div> <div data-testid="settings-modal" role="dialog" aria-modal="true" class="settings-modal svelte-bbu5nk"><aside class="settings-modal-sidebar tandem-scroll-fade-y svelte-bbu5nk"><div class="settings-modal-sidebar-head svelte-bbu5nk"><div class="settings-modal-sidebar-title svelte-bbu5nk">Settings</div> <!></div> <nav aria-label="Settings sections" class="settings-modal-sidebar-nav svelte-bbu5nk"></nav> <div class="settings-modal-sidebar-foot svelte-bbu5nk" data-testid="settings-modal-sidebar-footer"><button type="button" data-testid="settings-modal-view-changelog-btn" class="settings-modal-sidebar-link svelte-bbu5nk"> </button> <!> <a target="_blank" rel="noreferrer" data-testid="settings-modal-report-bug-link" class="settings-modal-sidebar-link svelte-bbu5nk">Report a bug</a> <div class="settings-modal-sidebar-status svelte-bbu5nk" data-testid="settings-modal-mcp-status" aria-live="polite"><span class="settings-modal-status-dot svelte-bbu5nk"></span> <span class="settings-modal-status-label svelte-bbu5nk"><!></span></div></div></aside> <section class="settings-modal-content svelte-bbu5nk" data-testid="settings-modal-content"><header class="settings-modal-content-head svelte-bbu5nk"><button type="button" class="settings-modal-narrow-hamburger svelte-bbu5nk" data-testid="settings-modal-narrow-hamburger"><svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="4" y1="7" x2="20" y2="7"></line><line x1="4" y1="12" x2="20" y2="12"></line><line x1="4" y1="17" x2="20" y2="17"></line></svg></button> <h2 class="settings-modal-content-title svelte-bbu5nk"> </h2> <button type="button" data-testid="settings-modal-close-btn" class="settings-modal-close svelte-bbu5nk" aria-label="Close settings">×</button></header> <div class="settings-modal-content-body tandem-scroll-fade-y svelte-bbu5nk"><div class="settings-modal-content-inner svelte-bbu5nk"><!></div></div></section></div>',1);function F4(t,e){Pe(e,!0);const n="tandem-settings-modal-heading",r='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',i=[{id:"appearance",label:"Appearance",icon:"M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z",component:pC},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16",component:mC},{id:"network",label:"Network",icon:"M3 12h18M3 12a9 9 0 0 1 18 0M3 12a9 9 0 0 0 18 0M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18",component:vC},{id:"accessibility",label:"Accessibility",icon:"M12 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4ZM4 9h16M9 9v5l-2 7M15 9v5l2 7M9 14h6",component:hC},{id:"collaboration",label:"Collaboration",icon:"M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM21 21v-2a4 4 0 0 0-3-3.87M16 3.13A4 4 0 0 1 16 11",component:t4},{id:"claude-code",label:"AI Assistant",icon:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z",component:Qz},{id:"models",label:"Models",icon:"M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z",component:w4},{id:"shortcuts",label:"Shortcuts",icon:"M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z",component:C4},{id:"about",label:"About",icon:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01",component:I4}];let o=nt(e,"returnFocusEl",3,null),s=nt(e,"triggerEl",3,null),a=nt(e,"connected",3,!1),l=nt(e,"reconnectAttempts",3,0),c=nt(e,"tabs",3,i),d=nt(e,"initialTabId",3,null),f=nt(e,"notify",3,()=>{}),h=I(void 0);const p=Qh(()=>e.open);let m=I(!1),v=I(null),g=I(!1);he(()=>{e.open&&y(g,!1)});let b=!1;he(()=>{if(e.open&&!b&&d()){const N=u(_).find(B=>B.id===d());N&&y(A,N.id,!0)}b=e.open});let x=I(!1);he(()=>{if(typeof window>"u"||!window.matchMedia)return;const N=window.matchMedia("(max-width: 860px)");y(x,N.matches,!0);const B=j=>{y(x,j.matches,!0)};return N.addEventListener("change",B),()=>N.removeEventListener("change",B)});const _=F(()=>c().length>0?c():i);let A=I(We(i[0].id));const M=F(()=>u(_).find(N=>N.id===u(A))??u(_)[0]),P=F(()=>u(M).label),D=F(()=>({open:e.open,settings:e.settings,onUpdate:e.onUpdate,connected:a(),reconnectAttempts:l(),notify:f()}));he(()=>{u(M)&&u(M).id!==u(A)&&y(A,u(M).id,!0)}),he(()=>{if(e.open)return vt(()=>{var N;return(N=u(h))==null?void 0:N.focus()}),()=>{var N;(N=o())==null||N.focus()}}),he(()=>{if(!e.open)return;const N=j=>{var W;const H=j.target;H&&((W=s())!=null&&W.contains(H)||u(h)&&!u(h).contains(H)&&e.onClose())},B=setTimeout(()=>document.addEventListener("pointerdown",N),0);return()=>{clearTimeout(B),document.removeEventListener("pointerdown",N)}}),Td(()=>{const N=B=>{if(B.key!=="Escape"||!e.open)return;const j=B.target;if(!(!u(h)||!j||!u(h).contains(j))){if(B.stopPropagation(),u(x)&&u(g)){y(g,!1);return}e.onClose()}};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)}),he(()=>{if(!e.open)return;const N=B=>{if(B.key!=="Tab"||!u(h))return;const j=u(h).querySelectorAll(r);if(j.length===0)return;const H=j[0],W=j[j.length-1],ee=document.activeElement;if(!u(h).contains(ee)){B.preventDefault(),H.focus();return}B.shiftKey&&ee===H?(B.preventDefault(),W.focus()):!B.shiftKey&&ee===W&&(B.preventDefault(),H.focus())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)}),he(()=>{u(A),y(v,null)});async function L(){var j;const N=(j=p.info)==null?void 0:j.changelogPath;if(!N){y(v,"Changelog file not found.");return}y(m,!0),y(v,null);const B=await us(N,{readOnly:!0,notFoundMessage:"Changelog file not found.",failureMessage:"Failed to open changelog."});y(m,!1),B.ok?e.onClose():y(v,B.error,!0)}var X={DEFAULT_SETTINGS_TABS:i},z=ft(),re=Se(z);{var Q=N=>{var B=z4(),j=Se(B),H=k(j,2);G(H,"aria-labelledby",n),G(H,"tabindex",-1);var W=w(H),ee=w(W),ie=w(ee);G(ie,"id",n);var K=k(ie,2);{var Y=Te=>{var Me=N4(),dt=w(Me);U(()=>te(dt,`v${p.info.version??""}`)),S(Te,Me)};J(K,Te=>{p.info&&Te(Y)})}var O=k(ee,2);Ye(O,21,()=>u(_),Te=>Te.id,(Te,Me)=>{var dt=P4(),Kt=w(dt),ze=w(Kt),_t=k(Kt,2),hn=w(_t);U(()=>{G(dt,"aria-current",u(A)===u(Me).id?"page":void 0),G(dt,"data-active",u(A)===u(Me).id?"true":"false"),G(dt,"data-testid",`settings-modal-tab-${u(Me).id}`),G(ze,"d",u(Me).icon),te(hn,u(Me).label)}),R("click",dt,()=>{y(A,u(Me).id,!0),y(g,!1)}),S(Te,dt)});var T=k(O,2),C=w(T),Z=w(C),q=k(C,2);{var oe=Te=>{var Me=L4(),dt=w(Me);U(()=>te(dt,u(v))),S(Te,Me)};J(q,Te=>{u(v)&&Te(oe)})}var ge=k(q,2),$=k(ge,2),le=w($),ce=k(le,2),ue=w(ce);{var pe=Te=>{var Me=hr("MCP connected");S(Te,Me)},_e=Te=>{var Me=hr("Reconnecting…");S(Te,Me)},ae=Te=>{var Me=hr("MCP offline");S(Te,Me)};J(ue,Te=>{a()?Te(pe):l()>0?Te(_e,1):Te(ae,-1)})}Tr(W,(Te,Me)=>Dt==null?void 0:Dt(Te,Me),()=>"y");var de=k(W,2),ye=w(de),ke=w(ye),Ve=k(ke,2),qe=w(Ve),fe=k(Ve,2),Ee=k(ye,2),Re=w(Ee),Ge=w(Re);sf(Ge,()=>u(M).id,Te=>{var Me=ft(),dt=Se(Me);Hv(dt,()=>u(M).component,(Kt,ze)=>{ze(Kt,Jl(()=>u(D)))}),S(Te,Me)}),Tr(Ee,(Te,Me)=>Dt==null?void 0:Dt(Te,Me),()=>"y"),pt(H,Te=>y(h,Te),()=>u(h)),U(()=>{G(H,"data-narrow-sidebar-open",u(g)?"true":"false"),W.inert=u(x)&&!u(g),C.disabled=u(m)||p.loading,te(Z,u(m)?"Opening…":"Changelog"),G(ge,"href",Sk),G(le,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),G(ke,"aria-label",u(g)?"Hide sections":"Show sections"),G(ke,"aria-expanded",u(g)),te(qe,u(P))}),R("click",j,function(...Te){var Me;(Me=e.onClose)==null||Me.apply(this,Te)}),R("keydown",j,Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),e.onClose())}),R("click",C,()=>void L()),R("click",ke,()=>{y(g,!u(g))}),R("click",fe,function(...Te){var Me;(Me=e.onClose)==null||Me.apply(this,Te)}),S(N,B)};J(re,N=>{e.open&&N(Q)})}return S(t,z),Le(X)}Ke(["click","keydown"]);var B4=E('<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>'),V4=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>'),H4=E('<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>'),U4=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
|
|
97
|
+
restores when you return to Tandem.</div>`,1),j4=E('<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>'),W4=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 your AI notices it</div> <input data-testid="dwell-time-slider" type="range" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Selection dwell time"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span> </span> <span> </span></div></div> <label data-testid="selection-toolbar-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show floating selection toolbar</span></label> <label data-testid="margin-view-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Margin annotation view (Word-style)</span></label> <!>',1),K4=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),q4=E('<section><div> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section>'),G4=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),J4=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>'),Y4=E('<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>'),Z4=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>'),X4=E('<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>',1),Q4=E('<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>'),$4=E('<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>'),eF=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),tF=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 nF(t,e){Pe(e,!0);const n="tandem-settings-heading",r='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',i=[{id:"appearance",label:"Appearance",icon:"M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z"},{id:"editor",label:"Editor",icon:"M4 4h11M4 9h16M4 14h11M4 19h16"},{id:"network",label:"Network",icon:"M3 12h18M3 12a9 9 0 0 1 18 0M3 12a9 9 0 0 0 18 0M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18"},{id:"accessibility",label:"Accessibility",icon:"M12 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4ZM4 9h16M9 9v5l-2 7M15 9v5l2 7M9 14h6"},{id:"collaboration",label:"Collaboration",icon:"M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM21 21v-2a4 4 0 0 0-3-3.87M16 3.13A4 4 0 0 1 16 11"},{id:"claude-code",label:"AI Assistant",icon:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z"},{id:"shortcuts",label:"Shortcuts",icon:"M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z"},{id:"about",label:"About",icon:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01"}],o=[{keys:"Ctrl+B",description:"Bold"},{keys:"Ctrl+I",description:"Italic"},{keys:"Ctrl+Z",description:"Undo"},{keys:"Ctrl+Y",description:"Redo"},{keys:"Ctrl+F",description:"Find / Replace"},{keys:"?",description:"Show keyboard shortcuts"},{keys:"Ctrl+Tab",description:"Next document tab"},{keys:"Ctrl+Shift+Tab",description:"Previous document tab"}],s=F(()=>{const N=Rc(),B=new Map;for(const j of N.values()){if(!j.shortcut)continue;const H=j.group,W=B.get(H)??[];W.push({keys:j.shortcut,description:j.label}),B.set(H,W)}return Jv.map(j=>({title:j.charAt(0).toUpperCase()+j.slice(1),rows:B.get(j)??[]})).filter(j=>j.rows.length>0)});let a=nt(e,"connected",3,!1),l=nt(e,"reconnectAttempts",3,0),c=I(void 0),d=I(void 0);const f=Py();let h=I(We(f.userName));const p=Qh(()=>e.open);let m=I(!1),v=I(null),g=I(!1),b=I(null),x=I("appearance");he(()=>{u(x),y(v,null),y(b,null)}),he(()=>{const N=f.userName;u(h)!==N&&document.activeElement!==u(d)&&y(h,N,!0)}),he(()=>{var N;if(e.open)return(N=u(c))==null||N.focus(),()=>{var B;(B=e.returnFocusEl)==null||B.focus()}}),he(()=>{if(!e.open)return;const N=j=>{var W;const H=j.target;(W=e.anchorEl)!=null&&W.contains(H)||u(c)&&!u(c).contains(H)&&e.onClose()},B=setTimeout(()=>document.addEventListener("pointerdown",N),0);return()=>{clearTimeout(B),document.removeEventListener("pointerdown",N)}}),he(()=>{if(!e.open)return;const N=B=>{if(B.key==="Escape"){e.onClose();return}if(B.key!=="Tab"||!u(c))return;const j=u(c).querySelectorAll(r);if(j.length===0)return;const H=j[0],W=j[j.length-1],ee=document.activeElement;if(!u(c).contains(ee)){B.preventDefault(),H.focus();return}B.shiftKey&&ee===H?(B.preventDefault(),W.focus()):!B.shiftKey&&ee===W&&(B.preventDefault(),H.focus())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)});async function _(N,B,j,H){if(!N){j(H.notFound);return}B(!0),j(null);try{const W=await us(N,{readOnly:!0,notFoundMessage:H.notFound,failureMessage:H.failed});if(!W.ok){j(W.error);return}e.onClose()}finally{B(!1)}}function A(){var N;return _((N=p.info)==null?void 0:N.workflowsPath,B=>y(g,B,!0),B=>y(b,B,!0),{notFound:"Documentation file not found.",failed:"Failed to open documentation."})}function M(){var N;return _((N=p.info)==null?void 0:N.changelogPath,B=>y(m,B,!0),B=>y(v,B,!0),{notFound:"Changelog file not found.",failed:"Failed to open changelog."})}const P="font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;",D=()=>{};function L(N){var B;return((B=i.find(j=>j.id===N))==null?void 0:B.label)??"Settings"}function X(){var j;const N=p.info;if(!N)return[];const B=[{label:"Version",value:`Tandem v${N.version}`},{label:"Tools",value:N.toolCount===null?"Tool count unavailable":`${N.toolCount} tools available`},{label:"MCP SDK",value:`MCP SDK ${N.mcpSdkVersion}`},{label:"Transport",value:((j=N.transport)==null?void 0:j.toUpperCase())??"—"}];return N.storagePath&&B.push({label:"Storage",value:N.storagePath}),N.tokenRotatedAt!==void 0&&B.push({label:"Token",value:N.tokenRotatedAt===null?"Token not created":`Token rotated ${new Date(N.tokenRotatedAt).toLocaleString()}`}),N.changelogPath&&B.push({label:"Changelog",value:N.changelogPath}),B}var z=ft(),re=Se(z);{var Q=N=>{var B=tF(),j=Se(B),H=k(j,2);G(H,"aria-labelledby",n),G(H,"tabindex",-1);var W=w(H),ee=w(W),ie=w(ee);G(ie,"id",n);var K=k(ie,2);{var Y=De=>{var it=B4(),Vt=w(it);U(()=>te(Vt,`v${p.info.version??""}`)),S(De,it)};J(K,De=>{p.info&&De(Y)})}var O=k(ee,2);Ye(O,21,()=>i,De=>De.id,(De,it)=>{var Vt=V4(),St=w(Vt),jt=w(St),ir=k(St,2),Pt=w(ir);U(()=>{G(Vt,"aria-current",u(x)===u(it).id?"page":void 0),G(Vt,"data-active",u(x)===u(it).id?"true":"false"),G(jt,"d",u(it).icon),te(Pt,u(it).label)}),R("click",Vt,()=>y(x,u(it).id,!0)),S(De,Vt)});var T=k(O,2),C=w(T),Z=w(C),q=k(C,2);{var oe=De=>{var it=H4(),Vt=w(it);U(()=>te(Vt,u(v))),S(De,it)};J(q,De=>{u(v)&&De(oe)})}var ge=k(q,2),$=k(ge,2),le=w($),ce=k(le,2),ue=w(ce);{var pe=De=>{var it=hr("MCP connected");S(De,it)},_e=De=>{var it=hr("Reconnecting…");S(De,it)},ae=De=>{var it=hr("MCP offline");S(De,it)};J(ue,De=>{a()?De(pe):l()>0?De(_e,1):De(ae,-1)})}var de=k(W,2),ye=w(de),ke=w(ye),Ve=w(ke),qe=k(ke,2),fe=k(ye,2),Ee=w(fe),Re=w(Ee);{var Ge=De=>{var it=U4(),Vt=Se(it),St=w(Vt);ve(St,P);var jt=k(St,2);pt(jt,Lt=>y(d,Lt),()=>u(d));var ir=k(Vt,2),Pt=w(ir);ve(Pt,P);var rn=k(Pt,2),At=w(rn),cn=k(At,2),or=k(ir,2),sr=w(or);U(()=>{$n(jt,u(h)),G(jt,"maxlength",Rh),G(At,"aria-checked",e.settings.defaultMode==="tandem"),ve(At,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${e.settings.defaultMode==="tandem"?"var(--tandem-accent)":"var(--tandem-border)"}; border-radius: var(--tandem-r-3); background: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-bg)":"var(--tandem-surface)"}; color: ${e.settings.defaultMode==="tandem"?"var(--tandem-accent-fg-strong)":"var(--tandem-fg-muted)"}; font-size: 12px; font-weight: ${e.settings.defaultMode==="tandem"?600:400}; cursor: pointer;`),G(cn,"aria-checked",e.settings.defaultMode==="solo"),ve(cn,`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;`),Vn(sr,e.settings.soloRailHidden)}),R("input",jt,Lt=>{y(h,Lt.target.value,!0)}),Tt("blur",jt,()=>f.setUserName(u(h))),R("keydown",jt,Lt=>{Lt.key==="Enter"&&Lt.currentTarget.blur(),Lt.key==="Escape"&&(y(h,f.userName,!0),Lt.currentTarget.blur())}),R("click",At,()=>e.onUpdate({defaultMode:"tandem"})),R("click",cn,()=>e.onUpdate({defaultMode:"solo"})),R("change",sr,Lt=>e.onUpdate({soloRailHidden:Lt.target.checked})),S(De,it)},Te=De=>{pC(De,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return a()},get reconnectAttempts(){return l()},notify:D})},Me=De=>{mC(De,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return a()},get reconnectAttempts(){return l()},notify:D})},dt=De=>{vC(De,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return a()},get reconnectAttempts(){return l()},notify:D})},Kt=De=>{hC(De,{get open(){return e.open},get settings(){return e.settings},get onUpdate(){return e.onUpdate},get connected(){return a()},get reconnectAttempts(){return l()},notify:D})},ze=De=>{var it=W4(),Vt=Se(it),St=w(Vt);ve(St,P);var jt=k(w(St)),ir=w(jt),Pt=k(St,4);G(Pt,"step",100);var rn=k(Pt,2),At=w(rn),cn=w(At),or=k(At,2),sr=w(or),Lt=k(Vt,2),Ht=w(Lt),tt=k(Lt,2),Ct=w(tt),Ar=k(tt,2);{var ti=Pn=>{var Jn=ft(),ni=Se(Jn);mk(ni,()=>Rn(()=>import("./CoworkSettings-BOYbyKul.js"),[]),ps=>{var ha=j4();S(ps,ha)},(ps,ha)=>{const gp=F(()=>u(ha).default);var Vd=ft(),vp=Se(Vd);Hv(vp,()=>u(gp),(V,se)=>{se(V,{})}),S(ps,Vd)}),S(Pn,Jn)},Ki=F(()=>Nt());J(Ar,Pn=>{u(Ki)&&Pn(ti)})}U((Pn,Jn,ni)=>{te(ir,`${Pn??""}s`),G(Pt,"min",ll),G(Pt,"max",cl),$n(Pt,e.settings.selectionDwellMs),te(cn,`${Jn??""}s`),te(sr,`${ni??""}s`),Vn(Ht,e.settings.selectionToolbar),Vn(Ct,e.settings.marginView)},[()=>(e.settings.selectionDwellMs/1e3).toFixed(1),()=>(ll/1e3).toFixed(1),()=>(cl/1e3).toFixed(1)]),R("input",Pt,Pn=>e.onUpdate({selectionDwellMs:Number(Pn.target.value)})),R("change",Ht,Pn=>e.onUpdate({selectionToolbar:Pn.target.checked})),R("change",Ct,Pn=>e.onUpdate({marginView:Pn.target.checked})),S(De,it)},_t=De=>{var it=J4(),Vt=w(it);Ye(Vt,17,()=>u(s),Pt=>Pt.title,(Pt,rn)=>{var At=q4(),cn=w(At);ve(cn,P);var or=w(cn),sr=k(cn,2);Ye(sr,21,()=>u(rn).rows,Lt=>Lt.keys+Lt.description,(Lt,Ht)=>{var tt=K4(),Ct=Se(tt),Ar=w(Ct),ti=k(Ct,2),Ki=w(ti);U(()=>{te(Ar,u(Ht).keys),te(Ki,u(Ht).description)}),S(Lt,tt)}),U(()=>te(or,u(rn).title)),S(Pt,At)});var St=k(Vt,2),jt=w(St);ve(jt,P);var ir=k(jt,2);Ye(ir,21,()=>o,Pt=>Pt.keys+Pt.description,(Pt,rn)=>{var At=G4(),cn=Se(At),or=w(cn),sr=k(cn,2),Lt=w(sr);U(()=>{te(or,u(rn).keys),te(Lt,u(rn).description)}),S(Pt,At)}),S(De,it)},hn=De=>{var it=eF(),Vt=Se(it),St=w(Vt),jt=w(St),ir=k(St,2);{var Pt=Ht=>{var tt=Y4(),Ct=w(tt);U(()=>te(Ct,u(b))),S(Ht,tt)};J(ir,Ht=>{u(b)&&Ht(Pt)})}var rn=k(Vt,2),At=w(rn);ve(At,P);var cn=k(At,2);{var or=Ht=>{var tt=Z4();S(Ht,tt)},sr=Ht=>{var tt=Q4();Ye(tt,21,X,Ct=>Ct.label,(Ct,Ar)=>{var ti=X4(),Ki=Se(ti),Pn=w(Ki),Jn=k(Ki,2),ni=w(Jn);U(()=>{te(Pn,u(Ar).label),te(ni,u(Ar).value)}),S(Ct,ti)}),S(Ht,tt)},Lt=Ht=>{var tt=$4();S(Ht,tt)};J(cn,Ht=>{p.loading?Ht(or):p.info?Ht(sr,1):Ht(Lt,-1)})}U(()=>{St.disabled=u(g)||p.loading,ve(St,`width: 100%; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: ${u(g)||p.loading?"not-allowed":"pointer"}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${u(g)||p.loading?.6:1};`),te(jt,u(g)?"Opening…":"View Documentation")}),R("click",St,()=>void A()),S(De,it)};J(Re,De=>{u(x)==="collaboration"?De(Ge):u(x)==="appearance"?De(Te,1):u(x)==="editor"?De(Me,2):u(x)==="network"?De(dt,3):u(x)==="accessibility"?De(Kt,4):u(x)==="claude-code"?De(ze,5):u(x)==="shortcuts"?De(_t,6):De(hn,-1)})}pt(H,De=>y(c,De),()=>u(c)),U(De=>{C.disabled=u(m)||p.loading,te(Z,u(m)?"Opening…":"Changelog"),G(ge,"href",Sk),G(le,"data-state",a()?"connected":l()>0?"reconnecting":"disconnected"),te(Ve,De)},[()=>L(u(x))]),R("click",j,function(...De){var it;(it=e.onClose)==null||it.apply(this,De)}),R("click",C,()=>void M()),R("click",qe,function(...De){var it;(it=e.onClose)==null||it.apply(this,De)}),S(N,B)};J(re,N=>{e.open&&N(Q)})}S(t,z),Le()}Ke(["click","input","keydown","change"]);var rF=E('<span class="toast-badge svelte-nsu1aw"> </span>'),iF=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>'),oF=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 sF(t,e){Pe(e,!0);const n={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=ft(),s=Se(o);{var a=l=>{var c=oF();Ye(c,21,()=>e.toasts,d=>d.id,(d,f)=>{const h=F(()=>n[u(f).severity]),p=F(()=>r[u(f).severity]),m=F(()=>i[u(f).severity]),v=F(()=>u(f).severity==="info"?"status":"alert");var g=iF(),b=w(g),x=w(b),_=k(b,2);{var A=P=>{var D=rF(),L=w(D);U(()=>{G(D,"data-testid",`toast-count-${u(f).id}`),ve(D,`margin-left: 6px; font-size: 11px; font-weight: 600; color: ${u(m)??""}; background: ${u(p)??""}; padding: 1px 5px; border-radius: var(--tandem-r-4);`),te(L,`×${u(f).count??""}`)}),S(P,D)};J(_,P=>{u(f).count>1&&P(A)})}var M=k(_,2);U(()=>{G(g,"role",u(v)),G(g,"data-testid",`toast-${u(f).id}`),ve(g,`pointer-events: auto; background: var(--tandem-surface); border-radius: var(--tandem-r-3); border-left: 4px solid ${u(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(x,u(f).message),G(M,"data-testid",`toast-dismiss-${u(f).id}`)}),R("click",M,()=>e.onDismiss(u(f).id)),S(d,g)}),S(l,c)};J(s,l=>{e.toasts.length>0&&l(a)})}S(t,o),Le()}Ke(["click"]);var aF=E('<div class="tandem-banner tandem-banner--info" role="status" aria-live="polite" data-testid="updater-banner"><span class="tandem-banner__icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25"></path><path d="M12 12v8"></path><path d="M8 16l4 4 4-4"></path></svg></span> <span class="tandem-banner__message"> </span> <button type="button" class="tandem-banner__cta" data-testid="updater-banner-install"> </button> <button type="button" class="tandem-banner__dismiss" data-testid="updater-banner-dismiss" aria-label="Dismiss update notification"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>');function lF(t,e){const n=F(()=>e.installing?"Installing…":"Restart to install");var r=aF(),i=k(w(r),2),o=w(i),s=k(i,2),a=w(s),l=k(s,2);U(()=>{te(o,`Tandem v${e.version??""} is available.`),s.disabled=e.installing,te(a,u(n))}),R("click",s,function(...c){var d;(d=e.onInstall)==null||d.apply(this,c)}),R("click",l,function(...c){var d;(d=e.onDismiss)==null||d.apply(this,c)}),S(t,r)}Ke(["click"]);const cF=Math.floor,dF=(t,e)=>t<e?t:e,uF=(t,e)=>t>e?t:e,bC=128,qu=127,fF=Number.MAX_SAFE_INTEGER,hF=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},Qc=typeof TextEncoder<"u"?new TextEncoder:null,pF=t=>Qc.encode(t),mF=Qc?pF:hF;let dc=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});dc&&dc.decode(new Uint8Array).length===1&&(dc=null);const Df=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},$h=(t,e)=>{for(;e>qu;)Df(t,bC|qu&e),e=cF(e/128);Df(t,qu&e)},Ug=new Uint8Array(3e4),gF=Ug.length/3,vF=(t,e)=>{if(e.length<gF){const n=Qc.encodeInto(e,Ug).written||0;$h(t,n);for(let r=0;r<n;r++)Df(t,Ug[r])}else xF(t,mF(e))},yF=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;$h(t,r);for(let i=0;i<r;i++)Df(t,n.codePointAt(i))},bF=Qc&&Qc.encodeInto?vF:yF,wF=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=dF(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(uF(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},xF=(t,e)=>{$h(t,e.byteLength),wF(t,e)},wC=t=>new Error(t),kF=wC("Unexpected end of array"),_F=wC("Integer out of Range"),SF=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},CF=t=>SF(t,Ly(t)),x0=t=>t.arr[t.pos++],Ly=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&qu)*n,n*=128,i<bC)return e;if(e>fF)throw _F}throw kF},TF=t=>{let e=Ly(t);if(e===0)return"";{let n=String.fromCodePoint(x0(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(x0(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},EF=t=>dc.decode(CF(t)),k0=dc?EF:TF;var Ha;(function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"})(Ha||(Ha={}));const AF=(t,e)=>{$h(t,Ha.Token),bF(t,e)},MF=(t,e,n,r)=>{switch(Ly(t)){case Ha.Token:{e();break}case Ha.PermissionDenied:{n(k0(t));break}case Ha.Authenticated:{r(k0(t));break}}},_0=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n}));var jg;(function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"})(jg||(jg={}));function OF(t){return t||(t={}),{delay:t.delay===void 0?200:t.delay,initialDelay:t.initialDelay===void 0?0:t.initialDelay,minDelay:t.minDelay===void 0?0:t.minDelay,maxDelay:t.maxDelay===void 0?0:t.maxDelay,factor:t.factor===void 0?0:t.factor,maxAttempts:t.maxAttempts===void 0?3:t.maxAttempts,timeout:t.timeout===void 0?0:t.timeout,jitter:t.jitter===!0,initialJitter:t.initialJitter===!0,handleError:t.handleError===void 0?null:t.handleError,handleTimeout:t.handleTimeout===void 0?null:t.handleTimeout,beforeAttempt:t.beforeAttempt===void 0?null:t.beforeAttempt,calculateDelay:t.calculateDelay===void 0?null:t.calculateDelay}}async function am(t){return new Promise(e=>setTimeout(e,t))}function DF(t,e){let n=e.delay;if(n===0)return 0;if(e.factor&&(n*=Math.pow(e.factor,t.attemptNum-1),e.maxDelay!==0&&(n=Math.min(n,e.maxDelay))),e.jitter){const r=Math.ceil(e.minDelay),i=Math.floor(n);n=Math.floor(Math.random()*(i-r+1))+r}return Math.round(n)}async function IF(t,e){const n=OF(e);for(const a of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const l=n[a];if(!Number.isInteger(l)||l<0)throw new Error(`Value for ${a} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw new Error("Value for factor must be a number greater than or equal to 0");if(n.delay<n.minDelay)throw new Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);const r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||DF;async function o(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){const l=new Error("Attempt aborted");throw l.code="ATTEMPT_ABORTED",l}const a=async l=>{if(n.handleError&&await n.handleError(l,r,n),r.aborted||r.attemptsRemaining===0)throw l;r.attemptNum++;const c=i(r,n);return c&&await am(c),o()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((l,c)=>{const d=setTimeout(()=>{if(n.handleTimeout)try{l(n.handleTimeout(r,n))}catch(f){c(f)}else{const f=new Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);f.code="ATTEMPT_TIMEOUT",c(f)}},n.timeout);t(r,n).then(f=>{clearTimeout(d),l(f)}).catch(f=>{clearTimeout(d),a(f).then(l).catch(c)})}):t(r,n).catch(a)}const s=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(s&&await am(s),r.attemptNum<1&&n.initialJitter){const a=i(r,n);a&&await am(a)}return o()}const xC=Math.floor,RF=(t,e)=>t<e?t:e,NF=(t,e)=>t>e?t:e,PF=64,If=128,LF=63,uc=127,kC=Number.MAX_SAFE_INTEGER,zF=()=>new Set,FF=Array.from,BF=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},$c=typeof TextEncoder<"u"?new TextEncoder:null,VF=t=>$c.encode(t),HF=$c?VF:BF;let fc=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});fc&&fc.decode(new Uint8Array).length===1&&(fc=null);class UF{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const zy=()=>new UF,_C=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Fy=t=>{const e=new Uint8Array(_C(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},Rf=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Un=(t,e)=>{for(;e>uc;)Rf(t,If|uc&e),e=xC(e/128);Rf(t,uc&e)},Wg=new Uint8Array(3e4),jF=Wg.length/3,WF=(t,e)=>{if(e.length<jF){const n=$c.encodeInto(e,Wg).written||0;Un(t,n);for(let r=0;r<n;r++)Rf(t,Wg[r])}else Rl(t,HF(e))},KF=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Un(t,r);for(let i=0;i<r;i++)Rf(t,n.codePointAt(i))},ko=$c&&$c.encodeInto?WF:KF,qF=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=RF(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(NF(n*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},Rl=(t,e)=>{Un(t,e.byteLength),qF(t,e)},SC=t=>new Error(t),CC=SC("Unexpected end of array"),TC=SC("Integer out of Range");class GF{constructor(e){this.arr=e,this.pos=0}}const EC=t=>new GF(t),JF=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},ep=t=>JF(t,Us(t)),S0=t=>t.arr[t.pos++],Us=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&uc)*n,n*=128,i<If)return e;if(e>kC)throw TC}throw CC},YF=t=>{let e=t.arr[t.pos++],n=e&LF,r=64;const i=(e&PF)>0?-1:1;if((e&If)===0)return i*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&uc)*r,r*=128,e<If)return i*n;if(n>kC)throw TC}throw CC},ZF=t=>{let e=Us(t);if(e===0)return"";{let n=String.fromCodePoint(S0(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(S0(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},XF=t=>fc.decode(ep(t)),ed=fc?XF:ZF,QF=t=>{const e=t.pos,n=ed(t);return t.pos=e,n},yl=Date.now,lm=()=>new Map,$F=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r};class eB{constructor(){this._observers=lm()}on(e,n){$F(this._observers,e,zF).add(n)}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return FF((this._observers.get(e)||lm()).values()).forEach(r=>r(...n))}destroy(){this._observers=lm()}}const tB=Object.keys,C0=t=>tB(t).length,nB=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),rB=(t,e)=>t===e,hc=(t,e)=>{if(t==null||e==null)return rB(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!hc(t.get(n),e.get(n)))return!1;break}case Object:if(C0(t)!==C0(e))return!1;for(const n in t)if(!nB(t,n)||!hc(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!hc(t[n],e[n]))return!1;break;default:return!1}return!0},cm=3e4;class iB extends eB{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=yl();this.getLocalState()!==null&&cm/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,o)=>{o!==this.clientID&&cm<=n-i.lastUpdated&&this.states.has(o)&&r.push(o)}),r.length>0&&Gu(this,r,"timeout")},xC(cm/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const n=this.clientID,r=this.meta.get(n),i=r===void 0?0:r.clock+1,o=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:i,lastUpdated:yl()});const s=[],a=[],l=[],c=[];e===null?c.push(n):o==null?e!=null&&s.push(n):(a.push(n),hc(o,e)||l.push(n)),(s.length>0||l.length>0||c.length>0)&&this.emit("change",[{added:s,updated:l,removed:c},"local"]),this.emit("update",[{added:s,updated:a,removed:c},"local"])}setLocalStateField(e,n){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:n})}getStates(){return this.states}}const Gu=(t,e,n)=>{const r=[];for(let i=0;i<e.length;i++){const o=e[i];if(t.states.has(o)){if(t.states.delete(o),o===t.clientID){const s=t.meta.get(o);t.meta.set(o,{clock:s.clock+1,lastUpdated:yl()})}r.push(o)}}r.length>0&&(t.emit("change",[{added:[],updated:[],removed:r},n]),t.emit("update",[{added:[],updated:[],removed:r},n]))},Kg=(t,e,n=t.states)=>{const r=e.length,i=zy();Un(i,r);for(let o=0;o<r;o++){const s=e[o],a=n.get(s)||null,l=t.meta.get(s).clock;Un(i,s),Un(i,l),ko(i,JSON.stringify(a))}return Fy(i)},oB=(t,e,n)=>{const r=EC(e),i=yl(),o=[],s=[],a=[],l=[],c=Us(r);for(let d=0;d<c;d++){const f=Us(r);let h=Us(r);const p=JSON.parse(ed(r)),m=t.meta.get(f),v=t.states.get(f),g=m===void 0?0:m.clock;(g<h||g===h&&p===null&&t.states.has(f))&&(p===null?f===t.clientID&&t.getLocalState()!=null?h++:t.states.delete(f):t.states.set(f,p),t.meta.set(f,{clock:h,lastUpdated:i}),m===void 0&&p!==null?o.push(f):m!==void 0&&p===null?l.push(f):p!==null&&(hc(p,v)||a.push(f),s.push(f)))}(o.length>0||a.length>0||l.length>0)&&t.emit("change",[{added:o,updated:a,removed:l},n]),(o.length>0||s.length>0||l.length>0)&&t.emit("update",[{added:o,updated:s,removed:l},n])};let AC=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}};class qg{constructor(e){this.data=e,this.encoder=zy(),this.decoder=EC(new Uint8Array(this.data))}peekVarString(){return QF(this.decoder)}readVarUint(){return Us(this.decoder)}readVarString(){return ed(this.decoder)}readVarUint8Array(){return ep(this.decoder)}writeVarUint(e){return Un(this.encoder,e)}writeVarString(e){return ko(this.encoder,e)}writeVarUint8Array(e){return Rl(this.encoder,e)}length(){return _C(this.encoder)}}var Cn;(function(t){t[t.Sync=0]="Sync",t[t.Awareness=1]="Awareness",t[t.Auth=2]="Auth",t[t.QueryAwareness=3]="QueryAwareness",t[t.Stateless=5]="Stateless",t[t.CLOSE=7]="CLOSE",t[t.SyncStatus=8]="SyncStatus"})(Cn||(Cn={}));var Yn;(function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"})(Yn||(Yn={}));class fa{constructor(){this.encoder=zy()}get(e){return e.encoder}toUint8Array(){return Fy(this.encoder)}}class sB extends fa{constructor(){super(...arguments),this.type=Cn.CLOSE,this.description="Ask the server to close the connection"}get(e){return ko(this.encoder,e.documentName),Un(this.encoder,this.type),this.encoder}}class aB extends AC{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=Yn.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=Yn.Connected,this.emit("status",{status:Yn.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===Yn.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===Yn.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(sB,{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===Yn.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const e=()=>{let i=!1;return{retryPromise:IF(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:s=>{(!this.shouldConnect||i)&&s.abort()}}).catch(s=>{if(s&&s.code!=="ATTEMPT_ABORTED")throw s}),cancelFunc:()=>{i=!0}}},{retryPromise:n,cancelFunc:r}=e();return this.cancelWebsocketRetry=r,n}attachWebSocketListeners(e,n){const{identifier:r}=e,i=c=>this.emit("message",c),o=c=>this.emit("close",{event:c}),s=c=>this.emit("open",c),a=c=>{n(c)};this.webSocketHandlers[r]={message:i,close:o,open:s,error:a};const l=this.webSocketHandlers[e.identifier];Object.keys(l).forEach(c=>{e.addEventListener(c,l[c])})}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:e}=this.webSocket,n=this.webSocketHandlers[e];Object.keys(n).forEach(r=>{var i;(i=this.webSocket)===null||i===void 0||i.removeEventListener(r,n[r]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,n)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const r=new this.configuration.WebSocketPolyfill(this.url);r.binaryType="arraybuffer",r.identifier=this.identifier,this.attachWebSocketListeners(r,n),this.webSocket=r,this.status=Yn.Connecting,this.emit("status",{status:Yn.Connecting}),this.connectionAttempt={resolve:e,reject:n}})}onMessage(e){var n;this.resolveConnectionAttempt(),this.lastMessageReceived=yl();const i=new qg(e.data).peekVarString();(n=this.configuration.providerMap.get(i))===null||n===void 0||n.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Yn.Connected,this.emit("status",{status:Yn.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===Yn.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=yl()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):((e=this.webSocket)===null||e===void 0||e.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]==="/";)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}send(e){var n;((n=this.webSocket)===null||n===void 0?void 0:n.readyState)===jg.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=Yn.Disconnected,this.emit("status",{status:Yn.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 MC=0,By=1,OC=2,lB=(t,e)=>{Un(t,MC);const n=yP(e);Rl(t,n)},cB=(t,e,n)=>{Un(t,By),Rl(t,pP(e,n))},dB=(t,e,n)=>cB(e,n,ep(t)),DC=(t,e,n)=>{try{uP(e,ep(t),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},uB=(t,e)=>{Un(t,OC),Rl(t,e)},fB=DC,hB=(t,e,n,r)=>{const i=Us(t);switch(i){case MC:dB(t,e,n);break;case By:DC(t,n,r);break;case OC:fB(t,n,r);break;default:throw new Error("Unknown message type")}return i};class pB{constructor(e){this.message=e}apply(e,n){const{message:r}=this,i=r.readVarUint(),o=r.length();switch(i){case Cn.Sync:this.applySyncMessage(e,n);break;case Cn.Awareness:this.applyAwarenessMessage(e);break;case Cn.Auth:this.applyAuthMessage(e);break;case Cn.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Cn.Stateless:e.receiveStateless(ed(r.decoder));break;case Cn.SyncStatus:this.applySyncStatusMessage(e,YF(r.decoder)===1);break;case Cn.CLOSE:const s={code:1e3,reason:ed(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(fa,{encoder:r.encoder})}applySyncMessage(e,n){const{message:r}=this;r.writeVarUint(Cn.Sync);const i=hB(r.decoder,r.encoder,e.document,e);n&&i===By&&(e.synced=!0)}applySyncStatusMessage(e,n){n&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;const{message:n}=this;oB(e.awareness,n.readVarUint8Array(),e)}applyAuthMessage(e){const{message:n}=this;MF(n.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;const{message:n}=this;n.writeVarUint(Cn.Awareness),n.writeVarUint8Array(Kg(e.awareness,Array.from(e.awareness.getStates().keys())))}}class mB{constructor(e,n={}){this.message=new e,this.encoder=this.message.get(n)}create(){return Fy(this.encoder)}send(e){e==null||e.send(this.create())}}class gB extends fa{constructor(){super(...arguments),this.type=Cn.Auth,this.description="Authentication"}get(e){if(typeof e.token>"u")throw new Error("The authentication message requires `token` as an argument.");return ko(this.encoder,e.documentName),Un(this.encoder,this.type),AF(this.encoder,e.token),this.encoder}}class T0 extends fa{constructor(){super(...arguments),this.type=Cn.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");ko(this.encoder,e.documentName),Un(this.encoder,this.type);let n;return e.states===void 0?n=Kg(e.awareness,e.clients):n=Kg(e.awareness,e.clients,e.states),Rl(this.encoder,n),this.encoder}}class vB extends fa{constructor(){super(...arguments),this.type=Cn.Stateless,this.description="A stateless message"}get(e){var n;return ko(this.encoder,e.documentName),Un(this.encoder,this.type),ko(this.encoder,(n=e.payload)!==null&&n!==void 0?n:""),this.encoder}}class E0 extends fa{constructor(){super(...arguments),this.type=Cn.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 ko(this.encoder,e.documentName),Un(this.encoder,this.type),lB(this.encoder,e.document),this.encoder}}class yB extends fa{constructor(){super(...arguments),this.type=Cn.Sync,this.description="A document update"}get(e){return ko(this.encoder,e.documentName),Un(this.encoder,this.type),uB(this.encoder,e.update),this.encoder}}class bB extends Error{constructor(){super(...arguments),this.code=1001}}class A0 extends AC{constructor(e){var n,r,i;super(),this.configuration={name:"",document:void 0,awareness:void 0,token:null,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit("connect"),this.forwardStatus=o=>this.emit("status",o),this.forwardClose=o=>this.emit("close",o),this.forwardDisconnect=o=>this.emit("disconnect",o),this.forwardDestroy=()=>this.emit("destroy"),this.setConfiguration(e),this.configuration.document=e.document?e.document:new zi,this.configuration.awareness=e.awareness!==void 0?e.awareness:new iB(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("unsyncedChanges",this.configuration.onUnsyncedChanges),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),(n=this.awareness)===null||n===void 0||n.on("update",()=>{this.emit("awarenessUpdate",{states:_0(this.awareness.getStates())})}),(r=this.awareness)===null||r===void 0||r.on("change",()=>{this.emit("awarenessChange",{states:_0(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 aB(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(E0,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&Gu(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){typeof window>"u"||!("addEventListener"in window)||window.addEventListener("pagehide",this.boundPageHide)}sendStateless(e){this.send(vB,{documentName:this.configuration.name,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(n){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${n}`);return}this.send(gB,{token:e??"",documentName:this.configuration.name})}documentUpdateHandler(e,n){n!==this&&(this.incrementUnsyncedChanges(),this.send(yB,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:n,removed:r},i){const o=e.concat(n).concat(r);this.send(T0,{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(E0,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(T0,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,n){if(!this._isAttached)return;const r=new mB(e,n);this.emit("outgoingMessage",{message:r.message}),r.send(this.configuration.websocketProvider)}onMessage(e){const n=new qg(e.data),r=n.readVarString();n.writeVarString(r),this.emit("message",{event:e,message:new qg(e.data)}),new pB(n).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Gu(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&&(Gu(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>"u"||!("removeEventListener"in window))&&window.removeEventListener("pagehide",this.boundPageHide)}detach(){this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("status",this.forwardStatus),this.configuration.websocketProvider.off("status",this.configuration.onStatus),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||(this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("status",this.configuration.onStatus),this.configuration.websocketProvider.on("status",this.forwardStatus),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.configuration.websocketProvider.attach(this),this._isAttached=!0)}permissionDeniedHandler(e){this.emit("authenticationFailed",{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit("authenticated",{scope:e})}setAwarenessField(e,n){if(!this.awareness)throw new bB(`Cannot set awareness field "${e}" to ${JSON.stringify(n)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,n)}}const En=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},bl=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Gg=null;const to=function(t,e,n){let r=Gg||(Gg=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},wB=function(){Gg=null},na=function(t,e,n,r){return n&&(M0(t,e,n,r,-1)||M0(t,e,n,r,1))},xB=/^(img|br|input|textarea|hr)$/i;function M0(t,e,n,r,i){for(var o;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Hr(t))){let s=t.parentNode;if(!s||s.nodeType!=1||zd(t)||xB.test(t.nodeName)||t.contentEditable=="false")return!1;e=En(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?Hr(t):0}else return!1}}function Hr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function kB(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Hr(t)}else if(t.parentNode&&!zd(t))e=En(t),t=t.parentNode;else return null}}function _B(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!zd(t))e=En(t)+1,t=t.parentNode;else return null}}function SB(t,e,n){for(let r=e==0,i=e==Hr(t);r||i;){if(t==n)return!0;let o=En(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==Hr(t)}}function zd(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const tp=function(t){return t.focusNode&&na(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function ys(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function CB(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function TB(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Hr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Hr(r.startContainer),r.startOffset)}}}const Fi=typeof navigator<"u"?navigator:null,O0=typeof document<"u"?document:null,fs=Fi&&Fi.userAgent||"",Jg=/Edge\/(\d+)/.exec(fs),IC=/MSIE \d/.exec(fs),Yg=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(fs),mr=!!(IC||Yg||Jg),Xo=IC?document.documentMode:Yg?+Yg[1]:Jg?+Jg[1]:0,Jr=!mr&&/gecko\/(\d+)/i.test(fs);Jr&&+(/Firefox\/(\d+)/.exec(fs)||[0,0])[1];const Zg=!mr&&/Chrome\/(\d+)/.exec(fs),On=!!Zg,RC=Zg?+Zg[1]:0,Wn=!mr&&!!Fi&&/Apple Computer/.test(Fi.vendor),wl=Wn&&(/Mobile\/\w+/.test(fs)||!!Fi&&Fi.maxTouchPoints>2),Fr=wl||(Fi?/Mac/.test(Fi.platform):!1),NC=Fi?/Win/.test(Fi.platform):!1,ao=/Android \d/.test(fs),Fd=!!O0&&"webkitFontSmoothing"in O0.documentElement.style,EB=Fd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function AB(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Yi(t,e){return typeof t=="number"?t:t[e]}function MB(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function D0(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=bl(s);continue}let a=s,l=a==o.body,c=l?AB(o):MB(a),d=0,f=0;if(e.top<c.top+Yi(r,"top")?f=-(c.top-e.top+Yi(i,"top")):e.bottom>c.bottom-Yi(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Yi(i,"top")-c.top:e.bottom-c.bottom+Yi(i,"bottom")),e.left<c.left+Yi(r,"left")?d=-(c.left-e.left+Yi(i,"left")):e.right>c.right-Yi(r,"right")&&(d=e.right-c.right+Yi(i,"right")),d||f)if(l)o.defaultView.scrollBy(d,f);else{let p=a.scrollLeft,m=a.scrollTop;f&&(a.scrollTop+=f),d&&(a.scrollLeft+=d);let v=a.scrollLeft-p,g=a.scrollTop-m;e={left:e.left-v,top:e.top-g,right:e.right-v,bottom:e.bottom-g}}let h=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:bl(s)}}function OB(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let a=t.root.elementFromPoint(o,s);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:PC(t.dom)}}function PC(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=bl(r));return e}function DB({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;LC(n,r==0?0:r-e)}function LC(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:o}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let ya=null;function IB(t){if(t.setActive)return t.setActive();if(ya)return t.focus(ya);let e=PC(t);t.focus(ya==null?{get preventScroll(){return ya={preventScroll:!0},!0}}:void 0),ya||(ya=!1,LC(e,0))}function zC(t,e){let n,r=2e8,i,o=0,s=e.top,a=e.top,l,c;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=to(d).getClientRects();else continue;for(let p=0;p<h.length;p++){let m=h[p];if(m.top<=s&&m.bottom>=a){s=Math.max(m.bottom,s),a=Math.min(m.top,a);let v=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,d.nodeType==1&&v&&(o=f+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=d,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!n&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=f+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?RB(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:zC(n,i)}function RB(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let s=Mo(r,1);if(s.top!=s.bottom&&Vy(e,s)){i={node:t,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function Vy(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function NB(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function PB(t,e,n){let{node:r,offset:i}=zC(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function LB(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let a=t.docView.nearestDesc(o,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!s&&l.left>r.left||l.top>r.top?i=a.posBefore:(!s&&l.right<r.left||l.bottom<r.top)&&(i=a.posAfter),s=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function FC(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let s=t.childNodes[o];if(s.nodeType==1){let a=s.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Vy(e,c))return FC(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function zB(t,e){let n=t.dom.ownerDocument,r,i=0,o=TB(n,e.left,e.top);o&&({node:r,offset:i}=o);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),a;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!Vy(e,c)||(s=FC(t.dom,e,c),!s))return null}if(Wn)for(let c=s;r&&c;c=bl(c))c.draggable&&(r=void 0);if(s=NB(s,e),r){if(Jr&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;Fd&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=LB(t,r,i,e))}a==null&&(a=PB(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function I0(t){return t.top<t.bottom||t.left<t.right}function Mo(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(I0(r))return r}return Array.prototype.find.call(n,I0)||t.getBoundingClientRect()}const FB=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function BC(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=Fd||Jr;if(r.nodeType==3)if(s&&(FB.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=Mo(to(r,i,i),n);if(Jr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Mo(to(r,i-1,i-1),-1);if(c.top==l.top){let d=Mo(to(r,i,i+1),-1);if(d.top!=l.top)return jl(d,d.left<c.left)}}return l}else{let l=i,c=i,d=n<0?1:-1;return n<0&&!i?(c++,d=-1):n>=0&&i==r.nodeValue.length?(l--,d=1):n<0?l--:c++,jl(Mo(to(r,l,c),d),d<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==Hr(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return dm(l.getBoundingClientRect(),!1)}if(o==null&&i<Hr(r)){let l=r.childNodes[i];if(l.nodeType==1)return dm(l.getBoundingClientRect(),!0)}return dm(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==Hr(r))){let l=r.childNodes[i-1],c=l.nodeType==3?to(l,Hr(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return jl(Mo(c,1),!1)}if(o==null&&i<Hr(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?to(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return jl(Mo(c,-1),!0)}return jl(Mo(r.nodeType==3?to(r):r,-n),n>=0)}function jl(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function dm(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function VC(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function BB(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return VC(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let s=BC(t,i.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=to(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const VB=/[\u0590-\u08ac]/;function HB(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,a=t.domSelection();return a?!VB.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:s:VC(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:m,focusOffset:v}=t.domSelectionRange(),g=m&&!p.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==v;try{a.collapse(d,f),l&&(l!=d||c!=f)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let R0=null,N0=null,P0=!1;function UB(t,e,n){return R0==e&&N0==n?P0:(R0=e,N0=n,P0=n=="up"||n=="down"?BB(t,e,n):HB(t,e,n))}const Yr=0,L0=1,Ss=2,Bi=3;class Bd{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Yr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>En(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let a=i.children[s];if(a.size){i=a;break}}return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],a=o+s.size;if(a>e||s instanceof UC){i=e-o;break}o=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof HC&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?En(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?En(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,a=0;;a++){let l=this.children[a],c=s+l.size;if(i==-1&&e<=c){let d=s+l.border;if(e>=d&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,d);e=s;for(let f=a;f>0;f--){let h=this.children[f-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=En(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>n||a==this.children.length-1)){n=c;for(let d=a+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=En(f.dom);break}n+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let o=Math.min(e,n),s=Math.max(e,n);for(let p=0,m=0;p<this.children.length;p++){let v=this.children[p],g=m+v.size;if(o>m&&s<g)return v.setSelection(e-m-v.border,n-m-v.border,r,i);m=g}let a=this.domFromPos(e,e?-1:1),l=n==e?a:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((Jr||Wn)&&e==n){let{node:p,offset:m}=a;if(p.nodeType==3){if(f=!!(m&&p.nodeValue[m-1]==`
|
|
98
|
+
`),f&&m==p.nodeValue.length)for(let v=p,g;v;v=v.parentNode){if(g=v.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:En(g)+1});break}let b=v.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let v=p.childNodes[m-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(Jr&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Wn)&&na(a.node,a.offset,d.anchorNode,d.anchorOffset)&&na(l.node,l.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(f&&Jr)){c.collapse(a.node,a.offset);try{e!=n&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>n){let m=a;a=l,l=m}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let a=r+o.border,l=s-o.border;if(e>=a&&n<=l){this.dirty=e==r||n==s?Ss:L0,e==a&&n==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Bi:o.markDirty(e-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ss:Bi}r=s}this.dirty=Ss}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ss:L0;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class HC extends Bd{constructor(e,n,r,i){let o,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==Yr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class jB extends Bd{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ra extends Bd{constructor(e,n,r,i,o){super(e,[],r,i),this.mark=n,this.spec=o}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=da.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new ra(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Bi||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Bi&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Yr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Yr}}slice(e,n,r){let i=ra.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Qg(o,n,s,r)),e>0&&(o=Qg(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 Qo extends Bd{constructor(e,n,r,i,o,s,a,l,c){super(e,[],o,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=a}static create(e,n,r,i,o,s){let a=o.nodeViews[n.type.name],l,c=a&&a(n,o,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},r,i),d=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=da.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let h=d;return d=KC(d,r,n),c?l=new WB(e,n,r,i,d,f||null,h,c,o,s+1):n.isText?new np(e,n,r,i,d,h,o):new Qo(e,n,r,i,d,f||null,h,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>me.empty)}return e}matchesNode(e,n,r){return this.dirty==Yr&&e.eq(this.node)&&Nf(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new qB(this,s&&s.node,e);YB(this.node,this.innerDeco,(c,d,f)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!f&&l.syncToMarks(d==this.node.childCount?It.none:this.node.child(d).marks,r,e,d),l.placeWidget(c,e,i)},(c,d,f,h)=>{l.syncToMarks(c.marks,r,e,h);let p;l.findNodeMatch(c,d,f,h)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(p=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(c,d,f,p,e)||l.updateNextNode(c,d,f,e,h,i)||l.addNode(c,d,f,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Ss)&&(s&&this.protectLocalComposition(e,s),jC(this.contentDOM,this.children,e),wl&&ZB(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Be)||r<n||i>n+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,a=XB(this.node.content,s,r-n,i-n);return a<0?null:{node:o,pos:a,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new jB(this,o,n,i);e.input.compositionNodes.push(s),this.children=Qg(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Bi||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Yr}updateOuterDeco(e){if(Nf(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=WC(this.dom,this.nodeDOM,Xg(this.outerDeco,this.node,n),Xg(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function z0(t,e,n,r,i){KC(r,e,t);let o=new Qo(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class np extends Qo{constructor(e,n,r,i,o,s,a){super(e,n,r,i,o,null,s,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Bi||this.dirty!=Yr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Yr||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=Yr,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new np(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Bi)}get domAtom(){return!1}isText(e){return this.node.text==e}}class UC extends Bd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Yr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class WB extends Qo{constructor(e,n,r,i,o,s,a,l,c,d){super(e,n,r,i,o,s,a,c,d),this.spec=l}update(e,n,r,i){if(this.dirty==Bi)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function jC(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=F0(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(a,r);if(s instanceof ra){let l=r?r.previousSibling:t.lastChild;jC(s.contentDOM,s.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=F0(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const pc=function(t){t&&(this.nodeName=t)};pc.prototype=Object.create(null);const Cs=[new pc];function Xg(t,e,n){if(t.length==0)return Cs;let r=n?Cs[0]:new pc,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new pc(s.nodeName));for(let a in s){let l=s[a];l!=null&&(n&&i.length==1&&i.push(r=new pc(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 WC(t,e,n,r){if(n==Cs&&r==Cs)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],a=n[o];if(o){let l;a&&a.nodeName==s.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=Cs[0]),i=l}KB(i,a||Cs[0],s)}return i}function KB(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&t.classList.add(i[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function KC(t,e,n){return WC(t,t,Cs,Xg(e,n,t.nodeType!=1))}function Nf(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function F0(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class qB{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=GB(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,i){let o=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;o<a&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Yr,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let f=this.top.children[d];if(f.matchesMark(e[s])&&!this.isLocked(f.dom)){l=d;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let d=ra.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,i,o){let s=this.top.children[i];return s.dirty==Bi&&s.dom==s.contentDOM&&(s.dirty=Ss),s.update(e,n,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,o,s){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Qo){let c=this.preMatch.matched.get(l);if(c!=null&&c!=o)return!1;let d=l.dom,f,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=Bi&&Nf(n,l.outerDeco));if(!h&&l.update(e,n,r,i))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(f=this.recreateWrapper(l,e,n,r,i,s)))return this.destroyBetween(this.index,a),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Ss,f.updateChildren(i,s+1),f.dirty=Yr),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,o,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Nf(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=Qo.create(this.top,n,r,i,o,s);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,n,r,i,o){let s=Qo.create(this.top,e,n,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new HC(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof ra;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof np)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Wn||On)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new UC(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function GB(t,e){let n=e,r=n.children.length,i=t.childCount,o=new Map,s=[];e:for(;i>0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof ra)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(i-1))break;--i,o.set(a,i),s.push(a)}}return{index:i,matched:o,matches:s.reverse()}}function JB(t,e){return t.type.side-e.type.side}function YB(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);r(d,i,e.forChild(o,d),c),o+=d.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,f;for(;s<i.length&&i[s].to==o;){let g=i[s++];g.widget&&(d?(f||(f=[d])).push(g):d=g)}if(d)if(f){f.sort(JB);for(let g=0;g<f.length;g++)n(f[g],c,!!l)}else n(d,c,!!l);let h,p;if(l)p=-1,h=l,l=null;else if(c<t.childCount)p=c,h=t.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=o&&a.splice(g--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)a.push(i[s++]);let m=o+h.nodeSize;if(h.isText){let g=m;s<i.length&&i[s].from<g&&(g=i[s].from);for(let b=0;b<a.length;b++)a[b].to<g&&(g=a[b].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 ZB(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function XB(t,e,n,r){for(let i=0,o=0;i<t.childCount&&o<=r;){let s=t.child(i++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;i<t.childCount;){let c=t.child(i++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=n){if(o>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Qg(t,e,n,r,i){let o=[];for(let s=0,a=0;s<t.length;s++){let l=t[s],c=a,d=a+=l.size;c>=n||d<=e?o.push(l):(c<e&&o.push(l.slice(0,e-c,r)),i&&(o.push(i),i=void 0),d>n&&o.push(l.slice(n-c,l.size,r)))}return o}function Hy(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a=r.resolve(s),l,c;if(tp(n)){for(l=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Ue.isSelectable(f)&&i.parent&&!(f.isInline&&SB(n.focusNode,n.focusOffset,i.dom))){let h=i.posBefore;c=new Ue(s==h?a:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,h=s;for(let p=0;p<n.rangeCount;p++){let m=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(f<0)return null;[l,s]=h==t.state.selection.anchor?[h,f]:[f,h],a=r.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let f=e=="pointer"||t.state.selection.head<a.pos&&!o?1:-1;c=Uy(t,d,a,f)}return c}function qC(t){return t.editable?t.hasFocus():JC(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function po(t,e=!1){let n=t.state.selection;if(GC(t,n),!!qC(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&On){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&na(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)$B(t);else{let{anchor:r,head:i}=n,o,s;B0&&!(n instanceof Be)&&(n.$from.parent.inlineContent||(o=V0(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=V0(t,n.to))),t.docView.setSelection(r,i,t,e),B0&&(o&&H0(o),s&&H0(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&QB(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const B0=Wn||On&&RC<63;function V0(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(Wn&&i&&i.contentEditable=="false")return um(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return um(i);if(o)return um(o)}}function um(t){return t.contentEditable="true",Wn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function H0(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function QB(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!qC(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function $B(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,En(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&mr&&Xo<=11&&(n.disabled=!0,n.disabled=!1)}function GC(t,e){if(e instanceof Ue){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(U0(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else U0(t)}function U0(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Uy(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Be.between(e,n,r)}function j0(t){return t.editable&&!t.hasFocus()?!1:JC(t)}function JC(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function eV(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return na(e.node,e.offset,n.anchorNode,n.anchorOffset)}function $g(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&Je.findFrom(o,e)}function Do(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function W0(t,e,n){let r=t.state.selection;if(r instanceof Be)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Do(t,new Be(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=$g(t.state,e);return i&&i instanceof Ue?Do(t,i):!1}else if(!(Fr&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let a=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(a))&&!s.contentDOM?Ue.isSelectable(o)?Do(t,new Ue(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):Fd?Do(t,new Be(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ue&&r.node.isInline)return Do(t,new Be(e>0?r.$to:r.$from));{let i=$g(t.state,e);return i?Do(t,i):!1}}}function Pf(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function mc(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ba(t,e){return e<0?tV(t):nV(t)}function tV(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(Jr&&n.nodeType==1&&r<Pf(n)&&mc(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(mc(a,-1))i=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(YC(n))break;{let a=n.previousSibling;for(;a&&mc(a,-1);)i=n.parentNode,o=En(a),a=a.previousSibling;if(a)n=a,r=Pf(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?ev(t,n,r):i&&ev(t,i,o)}function nV(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Pf(n),o,s;for(;;)if(r<i){if(n.nodeType!=1)break;let a=n.childNodes[r];if(mc(a,1))o=n,s=++r;else break}else{if(YC(n))break;{let a=n.nextSibling;for(;a&&mc(a,1);)o=a.parentNode,s=En(a)+1,a=a.nextSibling;if(a)n=a,r=0,i=Pf(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&ev(t,o,s)}function YC(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function rV(t,e){for(;t&&e==t.childNodes.length&&!zd(t);)e=En(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function iV(t,e){for(;t&&!e&&!zd(t);)e=En(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function ev(t,e,n){if(e.nodeType!=3){let o,s;(s=rV(e,n))?(e=s,n=0):(o=iV(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(tp(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&po(t)},50)}function K0(t,e){let n=t.state.doc.resolve(e);if(!(On||NC)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function q0(t,e,n){let r=t.state.selection;if(r instanceof Be&&!r.empty||n.indexOf("s")>-1||Fr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=$g(t.state,e);if(s&&s instanceof Ue)return Do(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,a=r instanceof pr?Je.near(s,e):Je.findFrom(s,e);return a?Do(t,a):!1}return!1}function G0(t,e){if(!(t.state.selection instanceof Be))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function J0(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function oV(t){if(!Wn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;J0(t,r,"true"),setTimeout(()=>J0(t,r,"false"),20)}return!1}function sV(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function aV(t,e){let n=e.keyCode,r=sV(e);if(n==8||Fr&&n==72&&r=="c")return G0(t,-1)||ba(t,-1);if(n==46&&!e.shiftKey||Fr&&n==68&&r=="c")return G0(t,1)||ba(t,1);if(n==13||n==27)return!0;if(n==37||Fr&&n==66&&r=="c"){let i=n==37?K0(t,t.state.selection.from)=="ltr"?-1:1:-1;return W0(t,i,r)||ba(t,i)}else if(n==39||Fr&&n==70&&r=="c"){let i=n==39?K0(t,t.state.selection.from)=="ltr"?1:-1:1;return W0(t,i,r)||ba(t,i)}else{if(n==38||Fr&&n==80&&r=="c")return q0(t,-1,r)||ba(t,-1);if(n==40||Fr&&n==78&&r=="c")return oV(t)||q0(t,1,r)||ba(t,1);if(r==(Fr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function jy(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||da.fromSchema(t.state.schema),a=tT(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c=l.firstChild,d,f=0;for(;c&&c.nodeType==1&&(d=eT[c.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let m=a.createElement(d[p]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),f++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
|
|
99
|
+
|
|
100
|
+
`);return{dom:l,text:h,slice:e}}function ZC(t,e,n,r,i){let o=i.parent.type.spec.code,s,a;if(!n&&!e)return null;let l=!!e&&(r||o||!n);if(l){if(t.someProp("transformPastedText",h=>{e=h(e,o||r,t)}),o)return a=new Ce(me.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
101
|
+
`))),0,0),t.someProp("transformPasted",h=>{a=h(a,t,!0)}),a;let f=t.someProp("clipboardTextParser",h=>h(e,i,r,t));if(f)a=f;else{let h=i.marks(),{schema:p}=t.state,m=da.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let g=s.appendChild(document.createElement("p"));v&&g.appendChild(m.serializeNode(p.text(v,h)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=uV(n),Fd&&fV(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||sc.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!lV.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)a=hV(Y0(a,+d[1],+d[2]),d[4]);else if(a=Ce.maxOpen(cV(a.content,i),!0),a.openStart||a.openEnd){let f=0,h=0;for(let p=a.content.firstChild;f<a.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=a.content.lastChild;h<a.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);a=Y0(a,f,h)}return t.someProp("transformPasted",f=>{a=f(a,t,l)}),a}const lV=/^(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 cV(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(a=>{if(!s)return;let l=i.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&o.length&&QC(l,o,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=$C(s[s.length-1],o.length));let d=XC(a,l);s.push(d),i=i.matchType(d.type),o=l}}),s)return me.from(s)}return t}function XC(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,me.from(t));return t}function QC(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=QC(t,e,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(me.from(XC(n,t,i+1))))}}function $C(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,$C(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(me.empty,!0);return t.copy(n.append(r))}function tv(t,e,n,r,i,o){let s=e<0?t.firstChild:t.lastChild,a=s.content;return t.childCount>1&&(o=0),i<r-1&&(a=tv(a,e,n,r,i+1,o)),i>=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,o<=i).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(me.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function Y0(t,e,n){return e<t.openStart&&(t=new Ce(tv(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ce(tv(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const eT={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 Z0=null;function tT(){return Z0||(Z0=document.implementation.createHTMLDocument("title"))}let fm=null;function dV(t){let e=window.trustedTypes;return e?(fm||(fm=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),fm.createHTML(t)):t}function uV(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=tT().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&eT[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=dV(t),i)for(let o=0;o<i.length;o++)n=n.querySelector(i[o])||n;return n}function fV(t){let e=t.querySelectorAll(On?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function hV(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:o,openEnd:s}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=me.from(l.create(r[a+1],i)),o++,s++}return new Ce(i,o,s)}const tr={},nr={},pV={touchstart:!0,touchmove:!0};class mV{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 gV(t){for(let e in tr){let n=tr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{yV(t,r)&&!Wy(t,r)&&(t.editable||!(r.type in nr))&&n(t,r)},pV[e]?{passive:!0}:void 0)}Wn&&t.dom.addEventListener("input",()=>null),nv(t)}function qo(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function vV(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function nv(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Wy(t,r))})}function Wy(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function yV(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function bV(t,e){!Wy(t,e)&&tr[e.type]&&(t.editable||!(e.type in nr))&&tr[e.type](t,e)}nr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!rT(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ao&&On&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),wl&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,ys(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||aV(t,n)?n.preventDefault():qo(t,"key")};nr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};nr.keypress=(t,e)=>{let n=e;if(rT(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Fr&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Be)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,o))&&t.dispatch(o()),n.preventDefault()}};function rp(t){return{left:t.clientX,top:t.clientY}}function wV(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ky(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,a=>s>o.depth?a(t,n,o.nodeAfter,o.before(s),i,!0):a(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function Ua(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function xV(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ue.isSelectable(r)?(Ua(t,new Ue(n)),!0):!1}function kV(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ue&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let a=s>o.depth?o.nodeAfter:o.node(s);if(Ue.isSelectable(a)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(Ua(t,Ue.create(t.state.doc,i)),!0):!1}function _V(t,e,n,r,i){return Ky(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?kV(t,n):xV(t,n))}function SV(t,e,n,r){return Ky(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function CV(t,e,n,r){return Ky(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||TV(t,n,r)}function TV(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Ua(t,Be.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)Ua(t,Be.create(r,a+1,a+1+s.content.size));else if(Ue.isSelectable(s))Ua(t,Ue.create(r,a));else continue;return!0}}function qy(t){return Lf(t)}const nT=Fr?"metaKey":"ctrlKey";tr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=qy(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&wV(n,t.input.lastClick)&&!n[nT]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o,button:n.button};let s=t.posAtCoords(rp(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new EV(t,s,n,!!r)):(o=="doubleClick"?SV:CV)(t,s.pos,s.inside,n)?n.preventDefault():qo(t,"pointer"))};class EV{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[nT],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);o=d.parent,s=d.depth?d.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof Ue&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Jr&&!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)),qo(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(()=>po(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(rp(e))),this.updateAllowDefault(e),this.allowDefault||!n?qo(this.view,"pointer"):_V(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Wn&&this.mightDrag&&!this.mightDrag.node.isAtom||On&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Ua(this.view,Je.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):qo(this.view,"pointer")}move(e){this.updateAllowDefault(e),qo(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}tr.touchstart=t=>{t.input.lastTouch=Date.now(),qy(t),qo(t,"pointer")};tr.touchmove=t=>{t.input.lastTouch=Date.now(),qo(t,"pointer")};tr.contextmenu=t=>qy(t);function rT(t,e){return t.composing?!0:Wn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const AV=ao?5e3:-1;nr.compositionstart=nr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Be&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||On&&NC&&MV(t)))t.markCursor=t.state.storedMarks||n.marks(),Lf(t,!0),t.markCursor=null;else if(Lf(t,!e.selection.empty),Jr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let a=t.domSelection();a&&a.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}iT(t,AV)};function MV(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}nr.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,iT(t,20))};function iT(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Lf(t),e))}function oT(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=DV());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function OV(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=kB(e.focusNode,e.focusOffset),r=_B(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function DV(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Lf(t,e=!1){if(!(ao&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),oT(t),e||t.docView&&t.docView.dirty){let n=Hy(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function IV(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const td=mr&&Xo<15||wl&&EB<604;tr.copy=nr.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=td?null:n.clipboardData,s=r.content(),{dom:a,text:l}=jy(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):IV(t,a),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function RV(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function NV(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?nd(t,r.value,null,i,e):nd(t,r.textContent,r.innerHTML,i,e)},50)}function nd(t,e,n,r,i){let o=ZC(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,o||Ce.empty)))return!0;if(!o)return!1;let s=RV(o),a=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function sT(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}nr.paste=(t,e)=>{let n=e;if(t.composing&&!ao)return;let r=td?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&nd(t,sT(r),r.getData("text/html"),i,n)?n.preventDefault():NV(t,n)};class aT{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const PV=Fr?"altKey":"ctrlKey";function lT(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[PV]}tr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(rp(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof Ue?i.to-1:i.to))){if(r&&r.mightDrag)s=Ue.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=Ue.create(t.state.doc,f.posBefore))}}let a=(s||t.state.selection).content(),{dom:l,text:c,slice:d}=jy(t,a);(!n.dataTransfer.files.length||!On||RC>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(td?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",td||n.dataTransfer.setData("text/plain",c),t.dragging=new aT(d,lT(t,n),s)};tr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};nr.dragover=nr.dragenter=(t,e)=>e.preventDefault();nr.drop=(t,e)=>{try{LV(t,e,t.dragging)}finally{t.dragging=null}};function LV(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(rp(e));if(!r)return;let i=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",p=>{o=p(o,t,!1)}):o=ZC(t,sT(e.dataTransfer),td?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(n&&lT(t,e));if(t.someProp("handleDrop",p=>p(t,e,o||Ce.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?p_(t.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let l=t.state.tr;if(s){let{node:p}=n;p?p.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=l.doc;if(d?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(f))return;let h=l.doc.resolve(c);if(d&&Ue.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new Ue(h));else{let p=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,v,g,b)=>p=b),l.setSelection(Uy(t,h,l.doc.resolve(p)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}tr.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&po(t)},20))};tr.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};tr.beforeinput=(t,e)=>{if(On&&ao&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,ys(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in nr)tr[t]=nr[t];function rd(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class zf{constructor(e,n){this.toDOM=e,this.spec=n||js,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Rt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof zf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&rd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class $o{constructor(e,n){this.attrs=e,this.spec=n||js}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Rt(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof $o&&rd(this.attrs,e.attrs)&&rd(this.spec,e.spec)}static is(e){return e.type instanceof $o}destroy(){}}class Gy{constructor(e,n){this.attrs=e,this.spec=n||js}map(e,n,r,i){let o=e.mapResult(n.from+i,1);if(o.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=o.pos?null:new Rt(o.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),o;return i==n.from&&!(o=e.child(r)).isText&&i+o.nodeSize==n.to}eq(e){return this==e||e instanceof Gy&&rd(this.attrs,e.attrs)&&rd(this.spec,e.spec)}destroy(){}}class Rt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Rt(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Rt(e,e,new zf(n,r))}static inline(e,n,r,i){return new Rt(e,n,new $o(r,i))}static node(e,n,r,i){return new Rt(e,n,new Gy(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof $o}get widget(){return this.type instanceof zf}}const Sa=[],js={};class Xe{constructor(e,n){this.local=e.length?e:Sa,this.children=n.length?n:Sa}static create(e,n){return n.length?Ff(n,e,0,js):Fn}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,o){for(let s=0;s<this.local.length;s++){let a=this.local[s];a.from<=n&&a.to>=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let a=this.children[s]+1;this.children[s+2].findInner(e-a,n-a,r,i+a,o)}}map(e,n,r){return this==Fn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||js)}mapInner(e,n,r,i,o){let s;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,i);l&&l.type.valid(n,l)?(s||(s=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?zV(this.children,s||[],e,n,r,i,o):s?new Xe(s.sort(Ws),Sa):Fn}add(e,n){return n.length?this==Fn?Xe.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,o=0;e.forEach((a,l)=>{let c=l+r,d;if(d=dT(n,a,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<l;)o+=3;i[o]==l?i[o+2]=i[o+2].addInner(a,d,c+1):i.splice(o,0,l,l+a.nodeSize,Ff(d,a,c+1,js)),o+=3}});let s=cT(o?uT(n):n,-r);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a])||s.splice(a--,1);return new Xe(s.length?this.local.concat(s).sort(Ws):this.local,i||this.children)}remove(e){return e.length==0||this==Fn?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,a=r[o]+n,l=r[o+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>a&&f.to<l&&(e[d]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,a+1);c!=Fn?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let a=0;a<i.length;a++)i[a].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Xe(i,r):Fn}forChild(e,n){if(this==Fn)return this;if(n.isLeaf)return Xe.empty;let r,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,s=o+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<s&&l.to>o&&l.type instanceof $o){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 Xe(i.sort(Ws),Sa);return r?new Po([a,r]):a}return r||Fn}eq(e){if(this==e)return!0;if(!(e instanceof Xe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Jy(this.localsInner(e))}localsInner(e){if(this==Fn)return Sa;if(e.inlineContent||!this.local.some($o.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof $o||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Xe.empty=new Xe([],[]);Xe.removeOverlap=Jy;const Fn=Xe.empty;class Po{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,js));return Po.from(r)}forChild(e,n){if(n.isLeaf)return Xe.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=Fn&&(o instanceof Po?r=r.concat(o.members):r.push(o))}return Po.from(r)}eq(e){if(!(e instanceof Po)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let s=0;s<o.length;s++)n.push(o[s])}}return n?Jy(r?n:n.sort(Ws)):Sa}static from(e){switch(e.length){case 0:return Fn;case 1:return e[0];default:return new Po(e.every(n=>n instanceof Xe)?e:e.reduce((n,r)=>n.concat(r instanceof Xe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function zV(t,e,n,r,i,o,s){let a=t.slice();for(let c=0,d=o;c<n.maps.length;c++){let f=0;n.maps[c].forEach((h,p,m,v)=>{let g=v-m-(p-h);for(let b=0;b<a.length;b+=3){let x=a[b+1];if(x<0||h>x+d-f)continue;let _=a[b]+d-f;p>=_?a[b+1]=h<=_?-2:-1:h>=d&&g&&(a[b]+=g,a[b+1]+=g)}f+=g}),d=n.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=n.map(t[c]+o),f=d-i;if(f<0||f>=r.content.size){l=!0;continue}let h=n.map(t[c+1]+o,-1),p=h-i,{index:m,offset:v}=r.content.findIndex(f),g=r.maybeChild(m);if(g&&v==f&&v+g.nodeSize==p){let b=a[c+2].mapInner(n,g,d+1,t[c]+o+1,s);b!=Fn?(a[c]=f,a[c+1]=p,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=FV(a,t,e,n,i,o,s),d=Ff(c,r,0,s);e=d.local;for(let f=0;f<a.length;f+=3)a[f+1]<0&&(a.splice(f,3),f-=3);for(let f=0,h=0;f<d.children.length;f+=3){let p=d.children[f];for(;h<a.length&&a[h]<p;)h+=3;a.splice(h,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Xe(e.sort(Ws),a)}function cT(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Rt(i.from+e,i.to+e,i.type))}return n}function FV(t,e,n,r,i,o,s){function a(l,c){for(let d=0;d<l.local.length;d++){let f=l.local[d].map(r,i,c);f?n.push(f):s.onRemove&&s.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+o+1);return n}function dT(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let o=0,s;o<t.length;o++)(s=t[o])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[o]=null);return i}function uT(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Ff(t,e,n,r){let i=[],o=!1;e.forEach((a,l)=>{let c=dT(t,a,l+n);if(c){o=!0;let d=Ff(c,a,n+l+1,r);d!=Fn&&i.push(l,l+a.nodeSize,d)}});let s=cT(o?uT(t):t,-n).sort(Ws);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 Xe(s,i):Fn}function Ws(t,e){return t.from-e.from||t.to-e.to}function Jy(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[i]=o.copy(o.from,r.to),X0(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),X0(e,i,r.copy(o.from,r.to)));break}}}return e}function X0(t,e,n){for(;e<t.length&&Ws(n,t[e])>0;)e++;t.splice(e,0,n)}function hm(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Fn&&e.push(r)}),t.cursorWrapper&&e.push(Xe.create(t.state.doc,[t.cursorWrapper.deco])),Po.from(e)}const BV={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},VV=mr&&Xo<=11;class HV{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 UV{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new HV,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]);mr&&Xo<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Wn&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),VV&&(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,BV)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(j0(this.view)){if(this.suppressingSelectionUpdates)return po(this.view);if(mr&&Xo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&na(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=bl(o))n.add(o);for(let o=e.anchorNode;o;o=bl(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&j0(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],l);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(a=!0))}if(l.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of l)if(d.nodeName=="BR"&&d.parentNode){let f=d.nextSibling;for(;f&&f.nodeType==1;){if(f.contentEditable=="false"){d.parentNode.removeChild(d);break}f=f.firstChild}}}else if(Jr&&l.length){let d=l.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,h]=d;f.parentNode&&f.parentNode.parentNode==h.parentNode?h.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let h of d){let p=h.parentNode;p&&p.nodeName=="LI"&&(!f||KV(e,f)!=p)&&h.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&tp(r)&&(c=Hy(e))&&c.eq(Je.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,po(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),jV(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,qV(e,l)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||po(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(mr&&Xo<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:h}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h)}let s=i&&i.parentNode==e.target?En(i)+1:0,a=r.localPosFromDOM(e.target,s,-1),l=o&&o.parentNode==e.target?En(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 Q0=new WeakMap,$0=!1;function jV(t){if(!Q0.has(t)&&(Q0.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Jr,$0)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."),$0=!0}}function e1(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return na(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function WV(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return e1(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?e1(t,n):null}function KV(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function qV(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let o of e)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let a=s;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(o,a.firstChild),r==o&&t.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function GV(t,e,n){let{node:r,fromOffset:i,toOffset:o,from:s,to:a}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,d=l.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],tp(l)||c.push({node:l.focusNode,offset:l.focusOffset})),On&&t.input.lastKeyCode===8)for(let g=o;g>i;g--){let b=r.childNodes[g-1],x=b.pmViewDesc;if(b.nodeName=="BR"&&!x){o=g;break}if(!x||x.size)break}let f=t.state.doc,h=t.someProp("domParser")||sc.fromSchema(t.state.schema),p=f.resolve(s),m=null,v=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:JV,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),m={anchor:g+s,head:b+s}}return{doc:v,sel:m,from:s,to:a}}function JV(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Wn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Wn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const YV=/^(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 ZV(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let D=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,L=Hy(t,D);if(L&&!t.state.selection.eq(L)){if(On&&ao&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",z=>z(t,ys(13,"Enter"))))return;let X=t.state.tr.setSelection(L);D=="pointer"?X.setMeta("pointer",!0):D=="key"&&X.scrollIntoView(),o&&X.setMeta("composition",o),t.dispatch(X)}return}let s=t.state.doc.resolve(e),a=s.sharedDepth(n);e=s.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=GV(t,e,n),d=t.state.doc,f=d.slice(c.from,c.to),h,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,p="end"):(h=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let m=$V(f.content,c.doc.content,c.from,h,p);if(m&&t.input.domChangeCount++,(wl&&t.input.lastIOSEnter>Date.now()-225||ao)&&i.some(D=>D.nodeType==1&&!YV.test(D.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",D=>D(t,ys(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof Be&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let D=t1(t,t.state.doc,c.sel);if(D&&!D.eq(t.state.selection)){let L=t.state.tr.setSelection(D);o&&L.setMeta("composition",o),t.dispatch(L)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof Be&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),mr&&Xo<=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),b=d.resolve(m.start),x=v.sameParent(g)&&v.parent.inlineContent&&b.end()>=m.endA;if((wl&&t.input.lastIOSEnter>Date.now()-225&&(!x||i.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!x&&v.pos<c.doc.content.size&&(!v.sameParent(g)||!v.parent.inlineContent)&&v.pos<g.pos&&!/\S/.test(c.doc.textBetween(v.pos,g.pos,"","")))&&t.someProp("handleKeyDown",D=>D(t,ys(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&QV(d,m.start,m.endA,v,g)&&t.someProp("handleKeyDown",D=>D(t,ys(8,"Backspace")))){ao&&On&&t.domObserver.suppressSelectionUpdates();return}On&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),ao&&!x&&v.start()!=g.start()&&g.parentOffset==0&&v.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,g=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(D){return D(t,ys(13,"Enter"))})},20));let _=m.start,A=m.endA,M=D=>{let L=D||t.state.tr.replace(_,A,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let X=t1(t,L.doc,c.sel);X&&!(On&&t.composing&&X.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(X.head==_||X.head==L.mapping.map(A)-1)||mr&&X.empty&&X.head==_)&&L.setSelection(X)}return o&&L.setMeta("composition",o),L.scrollIntoView()},P;if(x)if(v.pos==g.pos){mr&&Xo<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>po(t),20));let D=M(t.state.tr.delete(_,A)),L=d.resolve(m.start).marksAcross(d.resolve(m.endA));L&&D.ensureMarks(L),t.dispatch(D)}else if(m.endA==m.endB&&(P=XV(v.parent.content.cut(v.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let D=M(t.state.tr);P.type=="add"?D.addMark(_,A,P.mark):D.removeMark(_,A,P.mark),t.dispatch(D)}else if(v.parent.child(v.index()).isText&&v.index()==g.index()-(g.textOffset?0:1)){let D=v.parent.textBetween(v.parentOffset,g.parentOffset),L=()=>M(t.state.tr.insertText(D,_,A));t.someProp("handleTextInput",X=>X(t,_,A,D,L))||t.dispatch(L())}else t.dispatch(M());else t.dispatch(M())}function t1(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Uy(t,e.resolve(n.anchor),e.resolve(n.head))}function XV(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,a,l;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)o=n[d].removeFromSet(o);if(i.length==1&&o.length==0)a=i[0],s="add",l=d=>d.mark(a.addToSet(d.marks));else if(i.length==0&&o.length==1)a=o[0],s="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(me.from(c).eq(t))return{mark:a,type:s}}function QV(t,e,n,r,i){if(n-e<=i.pos-r.pos||pm(r,!0,!1)<i.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let a=o.nodeAfter;return a!=null&&n==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=t.resolve(pm(o,!0,!0));return!s.parent.isTextblock||s.pos>n||pm(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function pm(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function $V(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:s,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s<o&&t.size<e.size){let l=r<=o&&r>=s?o-r:0;o-=l,o&&o<e.size&&n1(e.textBetween(o-1,o+1))&&(o+=l?1:-1),a=o+(a-s),s=o}else if(a<o){let l=r<=o&&r>=a?o-r:0;o-=l,o&&o<t.size&&n1(t.textBetween(o-1,o+1))&&(o+=l?1:-1),s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}function n1(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class fT{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new mV,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(a1),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=o1(this),i1(this),this.nodeViews=s1(this),this.docView=z0(this.state.doc,r1(this),hm(this),this.dom,this),this.domObserver=new UV(this,(r,i,o,s)=>ZV(this,r,i,o,s)),this.domObserver.start(),gV(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&nv(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(a1),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(oT(this),s=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=s1(this);t5(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&nv(this),this.editable=o1(this),i1(this);let l=hm(this),c=r1(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,l);(f||!e.selection.eq(i.selection))&&(s=!0);let h=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&OB(this);if(s){this.domObserver.stop();let p=f&&(mr||On)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&e5(i.selection,e.selection);if(f){let m=On?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=OV(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=z0(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())&&eV(this))?po(this,p):(GC(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&&DB(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Ue){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&D0(this,n.getBoundingClientRect(),e)}else D0(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new aT(e.slice,e.move,i<0?void 0:Ue.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let a=this.directPlugins[s].props[e];if(a!=null&&(i=n?n(a):a))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let a=o[s].props[e];if(a!=null&&(i=n?n(a):a))return i}}hasFocus(){if(mr){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&&IB(this.dom),po(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return zB(this,e)}coordsAtPos(e,n=1){return BC(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return UB(this,n||this.state,e)}pasteHTML(e,n){return nd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return nd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return jy(this,e)}destroy(){this.docView&&(vV(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],hm(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,wB())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return bV(this,e)}domSelectionRange(){let e=this.domSelection();return e?Wn&&this.root.nodeType===11&&CB(this.dom.ownerDocument)==this.dom&&WV(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}fT.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function r1(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Rt.node(0,t.state.doc.content.size,e)]}function i1(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Rt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function o1(t){return!t.someProp("editable",e=>e(t.state)===!1)}function e5(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function s1(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function t5(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function a1(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var as={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:"'"},Bf={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},n5=typeof navigator<"u"&&/Mac/.test(navigator.platform),r5=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var An=0;An<10;An++)as[48+An]=as[96+An]=String(An);for(var An=1;An<=24;An++)as[An+111]="F"+An;for(var An=65;An<=90;An++)as[An]=String.fromCharCode(An+32),Bf[An]=String.fromCharCode(An);for(var mm in as)Bf.hasOwnProperty(mm)||(Bf[mm]=as[mm]);function i5(t){var e=n5&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||r5&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Bf:as)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const o5=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),s5=typeof navigator<"u"&&/Win/.test(navigator.platform);function a5(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))o5?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function l5(t){let e=Object.create(null);for(let n in t)e[a5(n)]=t[n];return e}function gm(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function c5(t){return new wt({props:{handleKeyDown:Yy(t)}})}function Yy(t){let e=l5(t);return function(n,r){let i=i5(r),o,s=e[gm(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[gm(i,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(s5&&r.ctrlKey&&r.altKey)&&(o=as[r.keyCode])&&o!=i){let a=e[gm(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}const Zy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function hT(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const pT=(t,e,n)=>{let r=hT(t,n);if(!r)return!1;let i=Xy(r);if(!i){let s=r.blockRange(),a=s&&Cl(s);return a==null?!1:(e&&e(t.tr.lift(s,a).scrollIntoView()),!0)}let o=i.nodeBefore;if(_T(t,i,e,-1))return!0;if(r.parent.content.size==0&&(xl(o,"end")||Ue.isSelectable(o)))for(let s=r.depth;;s--){let a=Lh(t.doc,r.before(s),r.after(s),Ce.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(xl(o,"end")?Je.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Ue.create(l.doc,i.pos-o.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},d5=(t,e,n)=>{let r=hT(t,n);if(!r)return!1;let i=Xy(r);return i?mT(t,i,e):!1},u5=(t,e,n)=>{let r=vT(t,n);if(!r)return!1;let i=Qy(r);return i?mT(t,i,e):!1};function mT(t,e,n){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let s=e.nodeAfter,a=s,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=Lh(t.doc,o,l,Ce.empty);if(!c||c.from!=o||c instanceof gn&&c.slice.size>=l-o)return!1;if(n){let d=t.tr.step(c);d.setSelection(Be.create(d.doc,o)),n(d.scrollIntoView())}return!0}function xl(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const gT=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=Xy(r)}let s=o&&o.nodeBefore;return!s||!Ue.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ue.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Xy(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function vT(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const yT=(t,e,n)=>{let r=vT(t,n);if(!r)return!1;let i=Qy(r);if(!i)return!1;let o=i.nodeAfter;if(_T(t,i,e,1))return!0;if(r.parent.content.size==0&&(xl(o,"start")||Ue.isSelectable(o))){let s=Lh(t.doc,r.before(),r.after(),Ce.empty);if(s&&s.slice.size<s.to-s.from){if(e){let a=t.tr.step(s);a.setSelection(xl(o,"start")?Je.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):Ue.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},bT=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=Qy(r)}let s=o&&o.nodeAfter;return!s||!Ue.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ue.create(t.doc,o.pos)).scrollIntoView()),!0)};function Qy(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const f5=(t,e)=>{let n=t.selection,r=n instanceof Ue,i;if(r){if(n.node.isTextblock||!ds(t.doc,n.from))return!1;i=n.from}else if(i=Ph(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(Ue.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},h5=(t,e)=>{let n=t.selection,r;if(n instanceof Ue){if(n.node.isTextblock||!ds(t.doc,n.to))return!1;r=n.to}else if(r=Ph(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},p5=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),o=i&&Cl(i);return o==null?!1:(e&&e(t.tr.lift(i,o).scrollIntoView()),!0)},wT=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
102
|
+
`).scrollIntoView()),!0)};function $y(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const m5=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=$y(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,s.createAndFill());l.setSelection(Je.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},xT=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof pr||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=$y(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,a=t.tr.insert(s,o.createAndFill());a.setSelection(Be.create(a.doc,s+1)),e(a.scrollIntoView())}return!0},kT=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(uo(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Cl(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function g5(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ue&&e.selection.node.isBlock)return!r.parentOffset||!uo(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,a,l=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),a=$y(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 Be||e.selection instanceof pr)&&d.deleteSelection();let f=d.mapping.map(r.pos),h=uo(d.doc,f,o.length,o);if(h||(o[0]=a?{type:a}:null,h=uo(d.doc,f,o.length,o)),!h)return!1;if(d.split(f,o.length,o),!l&&c&&r.node(s).type!=a){let p=d.mapping.map(r.before(s)),m=d.doc.resolve(p);a&&r.node(s-1).canReplaceWith(m.index(),m.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(s)),a)}return n&&n(d.scrollIntoView()),!0}}const v5=g5(),y5=(t,e)=>{let{$from:n,to:r}=t.selection,i,o=n.sharedDepth(r);return o==0?!1:(i=n.before(o),e&&e(t.tr.setSelection(Ue.create(t.doc,i))),!0)};function b5(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||ds(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function _T(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,a,l=i.type.spec.isolating||o.type.spec.isolating;if(!l&&b5(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(a=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&a.matchType(s[0]||o.type).validEnd){if(n){let p=e.pos+o.nodeSize,m=me.empty;for(let b=s.length-1;b>=0;b--)m=me.from(s[b].create(null,m));m=me.from(i.copy(m));let v=t.tr.step(new yn(e.pos-1,p,e.pos,p,new Ce(m,1,0),s.length,!0)),g=v.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&ds(v.doc,g.pos)&&v.join(g.pos),n(v.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&l?null:Je.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),h=f&&Cl(f);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(f,h).scrollIntoView()),!0;if(c&&xl(o,"start",!0)&&xl(i,"end")){let p=i,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let v=o,g=1;for(;!v.isTextblock;v=v.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(n){let b=me.empty;for(let _=m.length-1;_>=0;_--)b=me.from(m[_].copy(b));let x=t.tr.step(new yn(e.pos-m.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new Ce(b,m.length,0),0,!0));n(x.scrollIntoView())}return!0}}return!1}function ST(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(Be.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const w5=ST(-1),x5=ST(1);function k5(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o),a=s&&Qv(s,t,e);return a?(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0):!1}}function l1(t,e=null){return function(n,r){let i=!1;for(let o=0;o<n.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:a}}=n.selection.ranges[o];n.doc.nodesBetween(s,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let d=n.doc.resolve(c),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[s];o.setBlockType(a,l,t,e)}r(o.scrollIntoView())}return!0}}function eb(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}eb(Zy,pT,gT);eb(Zy,yT,bT);eb(wT,xT,kT,v5);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function _5(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o);if(!s)return!1;let a=r?n.tr:null;return S5(a,s,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function S5(t,e,n,r=null){let i=!1,o=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=s.resolve(e.start-2);o=new gf(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new gf(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=Qv(o,n,r,e);return a?(t&&C5(t,e,a,i,n),!0):!1}function C5(t,e,n,r,i){let o=me.empty;for(let d=n.length-1;d>=0;d--)o=me.from(n[d].type.create(n[d].attrs,o));t.step(new yn(e.start-(r?2:0),e.end,e.start,e.end,new Ce(o,0,0),n.length,!0));let s=0;for(let d=0;d<n.length;d++)n[d].type==i&&(s=d+1);let a=n.length-s,l=e.start+n.length-(r?2:0),c=e.parent;for(let d=e.startIndex,f=e.endIndex,h=!0;d<f;d++,h=!1)!h&&uo(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return t}function T5(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?E5(e,n,t,o):A5(e,n,o):!0:!1}}function E5(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new yn(o-1,s,o,s,new Ce(me.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new gf(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const a=Cl(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(o,-1)-1);return ds(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function A5(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,m=n.endIndex-1,v=n.startIndex;m>v;m--)p-=i.child(m).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==i.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?me.empty:me.from(i))))return!1;let f=o.pos,h=f+s.nodeSize;return r.step(new yn(f-(a?1:0),h+(l?1:0),f+1,h-1,new Ce((a?me.empty:me.from(i.copy(me.empty))).append(l?me.empty:me.from(i.copy(me.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function M5(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,d=me.from(c?t.create():null),f=new Ce(me.from(t.create(null,me.from(a.type.create(null,d)))),c?3:1,0),h=o.start,p=o.end;n(e.tr.step(new yn(h-(c?3:1),p,h,p,f,1,!0)).scrollIntoView())}return!0}}function ip(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}}}class op{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...d)=>{const f=l(...d)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a=[],l=!!e,c=e||o.tr,d=()=>(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),a.every(h=>h===!0)),f={...Object.fromEntries(Object.entries(r).map(([h,p])=>[h,(...v)=>{const g=this.buildProps(c,n),b=p(...v)(g);return a.push(b),f}])),run:d};return f}createCan(e){const{rawCommands:n,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...d)=>c(...d)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:s}=i,a={tr:e,editor:i,view:s,state:ip({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...d)=>c(...d)(a)]))}};return a}}class O5{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}once(e,n){const r=(...i)=>{this.off(e,r),n.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function Ie(t,e,n){return t.config[e]===void 0&&t.parent?Ie(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ie(t.parent,e,n):null}):t.config[e]}function sp(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function CT(t){const e=[],{nodeExtensions:n,markExtensions:r}=sp(t),i=[...n,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage,extensions:i},l=Ie(s,"addGlobalAttributes",a);if(!l)return;l().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([h,p])=>{e.push({type:f,name:h,attribute:{...o,...p}})})})})}),i.forEach(s=>{const a={name:s.name,options:s.options,storage:s.storage},l=Ie(s,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([d,f])=>{const h={...o,...f};typeof(h==null?void 0:h.default)=="function"&&(h.default=h.default()),h!=null&&h.isRequired&&(h==null?void 0:h.default)===void 0&&delete h.default,e.push({type:s.name,name:d,attribute:h})})}),e}function xn(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function tn(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){const a=o?String(o).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(d=>!l.includes(d));r[i]=[...l,...c].join(" ")}else if(i==="style"){const a=o?o.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;l.forEach(d=>{const[f,h]=d.split(":").map(p=>p.trim());c.set(f,h)}),a.forEach(d=>{const[f,h]=d.split(":").map(p=>p.trim());c.set(f,h)}),r[i]=Array.from(c.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=o}),r},{})}function rv(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>tn(n,r),{})}function TT(t){return typeof t=="function"}function st(t,e=void 0,...n){return TT(t)?e?t.bind(e)(...n):t(...n):t}function D5(t={}){return Object.keys(t).length===0&&t.constructor===Object}function I5(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function c1(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((o,s)=>{const a=s.attribute.parseHTML?s.attribute.parseHTML(n):I5(n.getAttribute(s.name));return a==null?o:{...o,[s.name]:a}},{});return{...r,...i}}}}function d1(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&D5(n)?!1:n!=null))}function R5(t,e){var n;const r=CT(t),{nodeExtensions:i,markExtensions:o}=sp(t),s=(n=i.find(c=>Ie(c,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(i.map(c=>{const d=r.filter(b=>b.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,x)=>{const _=Ie(x,"extendNodeSchema",f);return{...b,..._?_(c):{}}},{}),p=d1({...h,content:st(Ie(c,"content",f)),marks:st(Ie(c,"marks",f)),group:st(Ie(c,"group",f)),inline:st(Ie(c,"inline",f)),atom:st(Ie(c,"atom",f)),selectable:st(Ie(c,"selectable",f)),draggable:st(Ie(c,"draggable",f)),code:st(Ie(c,"code",f)),whitespace:st(Ie(c,"whitespace",f)),linebreakReplacement:st(Ie(c,"linebreakReplacement",f)),defining:st(Ie(c,"defining",f)),isolating:st(Ie(c,"isolating",f)),attrs:Object.fromEntries(d.map(b=>{var x;return[b.name,{default:(x=b==null?void 0:b.attribute)===null||x===void 0?void 0:x.default}]}))}),m=st(Ie(c,"parseHTML",f));m&&(p.parseDOM=m.map(b=>c1(b,d)));const v=Ie(c,"renderHTML",f);v&&(p.toDOM=b=>v({node:b,HTMLAttributes:rv(b,d)}));const g=Ie(c,"renderText",f);return g&&(p.toText=g),[c.name,p]})),l=Object.fromEntries(o.map(c=>{const d=r.filter(g=>g.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((g,b)=>{const x=Ie(b,"extendMarkSchema",f);return{...g,...x?x(c):{}}},{}),p=d1({...h,inclusive:st(Ie(c,"inclusive",f)),excludes:st(Ie(c,"excludes",f)),group:st(Ie(c,"group",f)),spanning:st(Ie(c,"spanning",f)),code:st(Ie(c,"code",f)),attrs:Object.fromEntries(d.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),m=st(Ie(c,"parseHTML",f));m&&(p.parseDOM=m.map(g=>c1(g,d)));const v=Ie(c,"renderHTML",f);return v&&(p.toDOM=g=>v({mark:g,HTMLAttributes:rv(g,d)})),[c.name,p]}));return new r_({topNode:s,nodes:a,marks:l})}function vm(t,e){return e.nodes[t]||e.marks[t]||null}function u1(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function tb(t,e){const n=da.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}const N5=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,a)=>{var l,c;const d=((c=(l=i.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:i,pos:o,parent:s,index:a}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-o))}),n};function nb(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class ap{constructor(e){this.find=e.find,this.handler=e.handler}}const P5=(t,e)=>{if(nb(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function lu(t){var e;const{editor:n,from:r,to:i,text:o,rules:s,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(h=>h.type.spec.code))return!1;let d=!1;const f=N5(c)+o;return s.forEach(h=>{if(d)return;const p=P5(f,h.find);if(!p)return;const m=l.state.tr,v=ip({state:l.state,transaction:m}),g={from:r-(p[0].length-o.length),to:i},{commands:b,chain:x,can:_}=new op({editor:n,state:v});h.handler({state:v,range:g,match:p,commands:b,chain:x,can:_})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:i,text:o}),l.dispatch(m),d=!0)}),d}function L5(t){const{editor:e,rules:n}=t,r=new wt({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=tb(me.from(d),s.schema);const{from:f}=l,h=f+d.length;lu({editor:e,from:f,to:h,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,a){return lu({editor:e,from:o,to:s,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:o}=i.state.selection;o&&lu({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?lu({editor:e,from:s.pos,to:s.pos,text:`
|
|
103
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function z5(t){return Object.prototype.toString.call(t).slice(8,-1)}function cu(t){return z5(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function lp(t,e){const n={...t};return cu(t)&&cu(e)&&Object.keys(e).forEach(r=>{cu(e[r])&&cu(t[r])?n[r]=lp(t[r],e[r]):n[r]=e[r]}),n}class Vi{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=st(Ie(this,"addOptions",{name:this.name}))),this.storage=st(Ie(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Vi(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>lp(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new Vi(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=st(Ie(n,"addOptions",{name:n.name})),n.storage=st(Ie(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const l=s.find(c=>(c==null?void 0:c.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function F5(t){return typeof t=="number"}class B5{constructor(e){this.find=e.find,this.handler=e.handler}}const V5=(t,e,n)=>{if(nb(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const o=[i.text];return o.index=i.index,o.input=t,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function H5(t){const{editor:e,state:n,from:r,to:i,rule:o,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:d}=new op({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,m)=>{if(!p.isTextblock||p.type.spec.code)return;const v=Math.max(r,m),g=Math.min(i,m+p.content.size),b=p.textBetween(v-m,g-m,void 0,"");V5(b,o.find,s).forEach(_=>{if(_.index===void 0)return;const A=v+_.index+1,M=A+_[0].length,P={from:n.tr.mapping.map(A),to:n.tr.mapping.map(M)},D=o.handler({state:n,range:P,match:_,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});f.push(D)})}),f.every(p=>p!==null)}let du=null;const U5=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function j5(t){const{editor:e,rules:n}=t;let r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:d,from:f,to:h,rule:p,pasteEvt:m})=>{const v=d.tr,g=ip({state:d,transaction:v});if(!(!H5({editor:e,state:g,from:Math.max(f-1,0),to:h.b-1,rule:p,pasteEvent:m,dropEvent:a})||!v.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new wt({view(f){const h=m=>{var v;r=!((v=f.dom.parentElement)===null||v===void 0)&&v.contains(m.target)?f.dom.parentElement:null,r&&(du=e)},p=()=>{du&&(du=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,h)=>{if(o=r===f.dom.parentElement,a=h,!o){const p=du;p!=null&&p.isEditable&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(f,h)=>{var p;const m=(p=h.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=h,i=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(f,h,p)=>{const m=f[0],v=m.getMeta("uiEvent")==="paste"&&!i,g=m.getMeta("uiEvent")==="drop"&&!o,b=m.getMeta("applyPasteRules"),x=!!b;if(!v&&!g&&!x)return;if(x){let{text:M}=b;typeof M=="string"?M=M:M=tb(me.from(M),p.schema);const{from:P}=b,D=P+M.length,L=U5(M);return l({rule:d,state:p,from:P,to:{b:D},pasteEvt:L})}const _=h.doc.content.findDiffStart(p.doc.content),A=h.doc.content.findDiffEnd(p.doc.content);if(!(!F5(_)||!A||_===A.b))return l({rule:d,state:p,from:_,to:A,pasteEvt:s})}}))}function W5(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}class Da{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=Da.resolve(e),this.schema=R5(this.extensions,n),this.setupExtensions()}static resolve(e){const n=Da.sort(Da.flatten(e)),r=W5(n.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},i=Ie(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{const o=Ie(r,"priority")||100,s=Ie(i,"priority")||100;return o>s?-1:o<s?1:0})}get commands(){return this.extensions.reduce((e,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:vm(n.name,this.schema)},i=Ie(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,n=Da.sort([...this.extensions].reverse()),r=[],i=[],o=n.map(s=>{const a={name:s.name,options:s.options,storage:s.storage,editor:e,type:vm(s.name,this.schema)},l=[],c=Ie(s,"addKeyboardShortcuts",a);let d={};if(s.type==="mark"&&Ie(s,"exitable",a)&&(d.ArrowRight=()=>Vi.handleExit({editor:e,mark:s})),c){const v=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));d={...d,...v}}const f=c5(d);l.push(f);const h=Ie(s,"addInputRules",a);u1(s,e.options.enableInputRules)&&h&&r.push(...h());const p=Ie(s,"addPasteRules",a);u1(s,e.options.enablePasteRules)&&p&&i.push(...p());const m=Ie(s,"addProseMirrorPlugins",a);if(m){const v=m();l.push(...v)}return l}).flat();return[L5({editor:e,rules:r}),...j5({editor:e,rules:i}),...o]}get attributes(){return CT(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:n}=sp(this.extensions);return Object.fromEntries(n.filter(r=>!!Ie(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:xn(r.name,this.schema)},s=Ie(r,"addNodeView",o);if(!s)return[];const a=(l,c,d,f,h)=>{const p=rv(l,i);return s()({node:l,view:c,getPos:d,decorations:f,innerDecorations:h,editor:e,extension:r,HTMLAttributes:p})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var n;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:vm(e.name,this.schema)};e.type==="mark"&&(!((n=st(Ie(e,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(e.name);const i=Ie(e,"onBeforeCreate",r),o=Ie(e,"onCreate",r),s=Ie(e,"onUpdate",r),a=Ie(e,"onSelectionUpdate",r),l=Ie(e,"onTransaction",r),c=Ie(e,"onFocus",r),d=Ie(e,"onBlur",r),f=Ie(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),s&&this.editor.on("update",s),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}}class Bt{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=st(Ie(this,"addOptions",{name:this.name}))),this.storage=st(Ie(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Bt(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>lp(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new Bt({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=st(Ie(n,"addOptions",{name:n.name})),n.storage=st(Ie(n,"addStorage",{name:n.name,options:n.options})),n}}function ET(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=`
|
|
104
|
+
|
|
105
|
+
`,textSerializers:s={}}=n||{};let a="";return t.nodesBetween(r,i,(l,c,d,f)=>{var h;l.isBlock&&c>r&&(a+=o);const p=s==null?void 0:s[l.type.name];if(p)return d&&(a+=p({node:l,pos:c,parent:d,index:f,range:e})),!1;l.isText&&(a+=(h=l==null?void 0:l.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,i-c))}),a}function AT(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const K5=Bt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new wt({key:new Et("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(d=>d.$from.pos)),a=Math.max(...o.map(d=>d.$to.pos)),l=AT(n);return ET(r,{from:s,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),q5=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),G5=(t=!1)=>({commands:e})=>e.setContent("",t),J5=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:s})=>{t.doc.nodesBetween(o.pos,s.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,f=c.resolve(d.map(l)),h=c.resolve(d.map(l+a.nodeSize)),p=f.blockRange(h);if(!p)return;const m=Cl(p);if(a.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,v)}(m||m===0)&&e.lift(p,m)})}),!0},Y5=t=>e=>t(e),Z5=()=>({state:t,dispatch:e})=>xT(t,e),X5=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,o=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new Be(r.doc.resolve(Math.max(s-1,0)))),!0},Q5=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){const a=i.before(o),l=i.after(o);t.delete(a,l).scrollIntoView()}return!0}return!1},$5=t=>({tr:e,state:n,dispatch:r})=>{const i=xn(t,n.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){const l=o.before(s),c=o.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},eH=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},tH=()=>({state:t,dispatch:e})=>Zy(t,e),nH=()=>({commands:t})=>t.keyboardShortcut("Enter"),rH=()=>({state:t,dispatch:e})=>m5(t,e);function Vf(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:nb(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function MT(t,e,n={}){return t.find(r=>r.type===e&&Vf(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function f1(t,e,n={}){return!!MT(t,e,n)}function rb(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!MT([...i.node.marks],e,n)))return;let s=i.index,a=t.start()+i.offset,l=s+1,c=a+i.node.nodeSize;for(;s>0&&f1([...t.parent.child(s-1).marks],e,n);)s-=1,a-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&f1([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function hs(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}const iH=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const o=hs(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a;if(i){const f=rb(l,o,e);if(f&&f.from<=c&&f.to>=d){const h=Be.create(s,f.from,f.to);n.setSelection(h)}}return!0},oH=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function OT(t){return t instanceof Be}function Ts(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function DT(t,e=null){if(!e)return null;const n=Je.atStart(t),r=Je.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,o=r.to;return e==="all"?Be.create(t,Ts(0,i,o),Ts(t.content.size,i,o)):Be.create(t,Ts(e,i,o),Ts(e,i,o))}function h1(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Hf(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function sH(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const aH=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const s=()=>{(Hf()||h1())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),sH()&&!Hf()&&!h1()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!OT(n.state.selection))return s(),!0;const a=DT(i.doc,t)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},lH=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),cH=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),IT=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&IT(r)}return t};function uu(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return IT(n)}function id(t,e,n){if(t instanceof Zo||t instanceof me)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return me.fromArray(t.map(a=>e.nodeFromJSON(a)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),id("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,a="";const l=new r_({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?sc.fromSchema(l).parseSlice(uu(t),n.parseOptions):sc.fromSchema(l).parse(uu(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=sc.fromSchema(e);return n.slice?o.parseSlice(uu(t),n.parseOptions).content:o.parse(uu(t),n.parseOptions)}return id("",e,n)}function dH(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof gn||i instanceof yn))return;const o=t.mapping.maps[r];let s=0;o.forEach((a,l,c,d)=>{s===0&&(s=d)}),t.setSelection(Je.near(t.doc.resolve(s),n))}const uH=t=>!("type"in t),fH=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{id(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=id(e,o.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(g){return l(g),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,p=!0;if((uH(a)?a:[a]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),d===f&&p){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,f+=1)}let v;if(h){if(Array.isArray(e))v=e.map(g=>g.text||"").join("");else if(e instanceof me){let g="";e.forEach(b=>{b.text&&(g+=b.text)}),v=g}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else v=a,r.replaceWith(d,f,v);n.updateSelection&&dH(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},hH=()=>({state:t,dispatch:e})=>f5(t,e),pH=()=>({state:t,dispatch:e})=>h5(t,e),mH=()=>({state:t,dispatch:e})=>pT(t,e),gH=()=>({state:t,dispatch:e})=>yT(t,e),vH=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ph(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},yH=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ph(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},bH=()=>({state:t,dispatch:e})=>d5(t,e),wH=()=>({state:t,dispatch:e})=>u5(t,e);function RT(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function xH(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,o,s;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))Hf()||RT()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const kH=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const o=xH(t).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l==null||l.steps.forEach(c=>{const d=c.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function od(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,s=e?xn(e,t.schema):null,a=[];t.doc.nodesBetween(r,i,(f,h)=>{if(f.isText)return;const p=Math.max(r,h),m=Math.min(i,h+f.nodeSize);a.push({node:f,from:p,to:m})});const l=i-r,c=a.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>Vf(f.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((f,h)=>f+h.to-h.from,0)>=l}const _H=(t,e={})=>({state:n,dispatch:r})=>{const i=xn(t,n.schema);return od(n,i,e)?p5(n,r):!1},SH=()=>({state:t,dispatch:e})=>kT(t,e),CH=t=>({state:e,dispatch:n})=>{const r=xn(t,e.schema);return T5(r)(e,n)},TH=()=>({state:t,dispatch:e})=>wT(t,e);function cp(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function p1(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const EH=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=cp(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=xn(t,r.schema)),a==="mark"&&(s=hs(t,r.schema)),i&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,d)=>{o&&o===c.type&&n.setNodeMarkup(d,void 0,p1(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(f=>{s===f.type&&n.addMark(d,d+c.nodeSize,s.create(p1(f.attrs,e)))})})}),!0):!1},AH=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),MH=()=>({tr:t,dispatch:e})=>{if(e){const n=new pr(t.doc);t.setSelection(n)}return!0},OH=()=>({state:t,dispatch:e})=>gT(t,e),DH=()=>({state:t,dispatch:e})=>bT(t,e),IH=()=>({state:t,dispatch:e})=>y5(t,e),RH=()=>({state:t,dispatch:e})=>x5(t,e),NH=()=>({state:t,dispatch:e})=>w5(t,e);function iv(t,e,n={},r={}){return id(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const PH=(t,e=!1,n={},r={})=>({editor:i,tr:o,dispatch:s,commands:a})=>{var l,c;const{doc:d}=o;if(n.preserveWhitespace!=="full"){const f=iv(t,i.schema,n,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:i.options.enableContentCheck});return s&&o.replaceWith(0,d.content.size,f).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:d.content.size},t,{parseOptions:n,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function NT(t,e){const n=hs(e,t.schema),{from:r,to:i,empty:o}=t.selection,s=[];o?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{s.push(...l.marks)});const a=s.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function LH(t,e){const n=new $v(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function zH(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function FH(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,o)=>{n(i)&&r.push({node:i,pos:o})}),r}function PT(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function ib(t){return e=>PT(e.$from,t)}function BH(t,e){const n={from:0,to:t.content.size};return ET(t,n,e)}function VH(t,e){const n=xn(e,t.schema),{from:r,to:i}=t.selection,o=[];t.doc.nodesBetween(r,i,a=>{o.push(a)});const s=o.reverse().find(a=>a.type.name===n.name);return s?{...s.attrs}:{}}function LT(t,e){const n=cp(typeof e=="string"?e:e.name,t.schema);return n==="node"?VH(t,e):n==="mark"?NT(t,e):{}}function HH(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function UH(t){const e=HH(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,s)=>s!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function jH(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,o)=>{const s=[];if(i.ranges.length)i.forEach((a,l)=>{s.push({from:a,to:l})});else{const{from:a,to:l}=n[o];if(a===void 0||l===void 0)return;s.push({from:a,to:l})}s.forEach(({from:a,to:l})=>{const c=e.slice(o).map(a,-1),d=e.slice(o).map(l),f=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:f,to:h},newRange:{from:c,to:d}})})}),UH(r)}function ob(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const o=n.resolve(t),s=rb(o,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,o)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function Ju(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function ov(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?hs(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>Vf(f.attrs,n,{strict:!1}));let s=0;const a=[];if(i.forEach(({$from:f,$to:h})=>{const p=f.pos,m=h.pos;t.doc.nodesBetween(p,m,(v,g)=>{if(!v.isText&&!v.marks.length)return;const b=Math.max(p,g),x=Math.min(m,g+v.nodeSize),_=x-b;s+=_,a.push(...v.marks.map(A=>({mark:A,from:b,to:x})))})}),s===0)return!1;const l=a.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>Vf(f.mark.attrs,n,{strict:!1})).reduce((f,h)=>f+h.to-h.from,0),c=a.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,h)=>f+h.to-h.from,0);return(l>0?l+c:l)>=s}function WH(t,e,n={}){if(!e)return od(t,null,n)||ov(t,null,n);const r=cp(e,t.schema);return r==="node"?od(t,e,n):r==="mark"?ov(t,e,n):!1}function m1(t,e){const{nodeExtensions:n}=sp(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=st(Ie(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function dp(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!==null&&r!==void 0?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(o=>{i!==!1&&(dp(o,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function KH(t){return t instanceof Ue}function qH(t,e,n){var r;const{selection:i}=e;let o=null;if(OT(i)&&(o=i.$cursor),o){const a=(r=t.storedMarks)!==null&&r!==void 0?r:o.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}const{ranges:s}=i;return s.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(d,f,h)=>{if(c)return!1;if(d.isInline){const p=!h||h.type.allowsMarkType(n),m=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));c=p&&m}return!c}),c})}const GH=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=hs(t,r.schema);if(i)if(s){const c=NT(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(d,f,(h,p)=>{const m=Math.max(p,d),v=Math.min(p+h.nodeSize,f);h.marks.find(b=>b.type===l)?h.marks.forEach(b=>{l===b.type&&n.addMark(m,v,l.create({...b.attrs,...e}))}):n.addMark(m,v,l.create(e))})});return qH(r,n,l)},JH=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),YH=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=xn(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:a})=>l1(o,{...s,...e})(n)?!0:a.clearNodes()).command(({state:a})=>l1(o,{...s,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ZH=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Ts(t,0,r.content.size),o=Ue.create(r,i);e.setSelection(o)}return!0},XH=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,s=Be.atStart(r).from,a=Be.atEnd(r).to,l=Ts(i,s,a),c=Ts(o,s,a),d=Be.create(r,l,c);e.setSelection(d)}return!0},QH=t=>({state:e,dispatch:n})=>{const r=xn(t,e.schema);return M5(r)(e,n)};function g1(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const $H=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:s}=e,{$from:a,$to:l}=o,c=i.extensionManager.attributes,d=Ju(c,a.node().type.name,a.node().attrs);if(o instanceof Ue&&o.node.isBlock)return!a.parentOffset||!uo(s,a.pos)?!1:(r&&(t&&g1(n,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const f=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:zH(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=f&&h?[{type:h,attrs:d}]:void 0,m=uo(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!m&&uo(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 Be&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),h&&!f&&!a.parentOffset&&a.parent.type!==h)){const v=e.mapping.map(a.before()),g=e.doc.resolve(v);a.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}t&&g1(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},eU=(t,e={})=>({tr:n,state:r,dispatch:i,editor:o})=>{var s;const a=xn(t,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const f=l.node(-1);if(f.type!==a)return!1;const h=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let b=me.empty;const x=l.index(-1)?1:l.index(-2)?2:3;for(let L=l.depth-x;L>=l.depth-3;L-=1)b=me.from(l.node(L).copy(b));const _=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A={...Ju(h,l.node().type.name,l.node().attrs),...e},M=((s=a.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(A))||void 0;b=b.append(me.from(a.createAndFill(null,M)||void 0));const P=l.before(l.depth-(x-1));n.replace(P,l.after(-_),new Ce(b,4-x,0));let D=-1;n.doc.nodesBetween(P,n.doc.content.size,(L,X)=>{if(D>-1)return!1;L.isTextblock&&L.content.size===0&&(D=X+1)}),D>-1&&n.setSelection(Be.near(n.doc.resolve(D))),n.scrollIntoView()}return!0}const p=c.pos===l.end()?f.contentMatchAt(0).defaultType:null,m={...Ju(h,f.type.name,f.attrs),...e},v={...Ju(h,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const g=p?[{type:a,attrs:m},{type:p,attrs:v}]:[{type:a,attrs:m}];if(!uo(n.doc,l.pos,2))return!1;if(i){const{selection:b,storedMarks:x}=r,{splittableMarks:_}=o.extensionManager,A=x||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!A||!i)return!0;const M=A.filter(P=>_.includes(P.type.name));n.ensureMarks(M)}return!0},ym=(t,e)=>{const n=ib(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&ds(t.doc,n.pos)&&t.join(n.pos),!0},bm=(t,e)=>{const n=ib(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&ds(t.doc,r)&&t.join(r),!0},tU=(t,e,n,r={})=>({editor:i,tr:o,state:s,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:f,splittableMarks:h}=i.extensionManager,p=xn(t,s.schema),m=xn(e,s.schema),{selection:v,storedMarks:g}=s,{$from:b,$to:x}=v,_=b.blockRange(x),A=g||v.$to.parentOffset&&v.$from.marks();if(!_)return!1;const M=ib(P=>m1(P.type.name,f))(v);if(_.depth>=1&&M&&_.depth-M.depth<=1){if(M.node.type===p)return c.liftListItem(m);if(m1(M.node.type.name,f)&&p.validContent(M.node.content)&&a)return l().command(()=>(o.setNodeMarkup(M.pos,p),!0)).command(()=>ym(o,p)).command(()=>bm(o,p)).run()}return!n||!A||!a?l().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>ym(o,p)).command(()=>bm(o,p)).run():l().command(()=>{const P=d().wrapInList(p,r),D=A.filter(L=>h.includes(L.type.name));return o.ensureMarks(D),P?!0:c.clearNodes()}).wrapInList(p,r).command(()=>ym(o,p)).command(()=>bm(o,p)).run()},nU=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,s=hs(t,r.schema);return ov(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},rU=(t,e,n={})=>({state:r,commands:i})=>{const o=xn(t,r.schema),s=xn(e,r.schema),a=od(r,o,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(s,l):i.setNode(o,{...l,...n})},iU=(t,e={})=>({state:n,commands:r})=>{const i=xn(t,n.schema);return od(n,i,e)?r.lift(i):r.wrapIn(i,e)},oU=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let o;if(i.spec.isInputRules&&(o=i.getState(t))){if(e){const s=t.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l-=1)s.step(a.steps[l].invert(a.docs[l]));if(o.text){const l=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,t.schema.text(o.text,l))}else s.delete(o.from,o.to)}return!0}}return!1},sU=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},aU=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=hs(t,r.schema),{$from:c,empty:d,ranges:f}=a;if(!i)return!0;if(d&&s){let{from:h,to:p}=a;const m=(o=c.marks().find(g=>g.type===l))===null||o===void 0?void 0:o.attrs,v=rb(c,l,m);v&&(h=v.from,p=v.to),n.removeMark(h,p,l)}else f.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,l)});return n.removeStoredMark(l),!0},lU=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,s=null;const a=cp(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(o=xn(t,r.schema)),a==="mark"&&(s=hs(t,r.schema)),i&&n.selection.ranges.forEach(l=>{const c=l.$from.pos,d=l.$to.pos;let f,h,p,m;n.selection.empty?r.doc.nodesBetween(c,d,(v,g)=>{o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,d),f=g,h=v)}):r.doc.nodesBetween(c,d,(v,g)=>{g<c&&o&&o===v.type&&(p=Math.max(g,c),m=Math.min(g+v.nodeSize,d),f=g,h=v),g>=c&&g<=d&&(o&&o===v.type&&n.setNodeMarkup(g,void 0,{...v.attrs,...e}),s&&v.marks.length&&v.marks.forEach(b=>{if(s===b.type){const x=Math.max(g,c),_=Math.min(g+v.nodeSize,d);n.addMark(x,_,s.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(v=>{s===v.type&&n.addMark(p,m,s.create({...v.attrs,...e}))}))}),!0):!1},cU=(t,e={})=>({state:n,dispatch:r})=>{const i=xn(t,n.schema);return k5(i,e)(n,r)},dU=(t,e={})=>({state:n,dispatch:r})=>{const i=xn(t,n.schema);return _5(i,e)(n,r)};var uU=Object.freeze({__proto__:null,blur:q5,clearContent:G5,clearNodes:J5,command:Y5,createParagraphNear:Z5,cut:X5,deleteCurrentNode:Q5,deleteNode:$5,deleteRange:eH,deleteSelection:tH,enter:nH,exitCode:rH,extendMarkRange:iH,first:oH,focus:aH,forEach:lH,insertContent:cH,insertContentAt:fH,joinBackward:mH,joinDown:pH,joinForward:gH,joinItemBackward:vH,joinItemForward:yH,joinTextblockBackward:bH,joinTextblockForward:wH,joinUp:hH,keyboardShortcut:kH,lift:_H,liftEmptyBlock:SH,liftListItem:CH,newlineInCode:TH,resetAttributes:EH,scrollIntoView:AH,selectAll:MH,selectNodeBackward:OH,selectNodeForward:DH,selectParentNode:IH,selectTextblockEnd:RH,selectTextblockStart:NH,setContent:PH,setMark:GH,setMeta:JH,setNode:YH,setNodeSelection:ZH,setTextSelection:XH,sinkListItem:QH,splitBlock:$H,splitListItem:eU,toggleList:tU,toggleMark:nU,toggleNode:rU,toggleWrap:iU,undoInputRule:oU,unsetAllMarks:sU,unsetMark:aU,updateAttributes:lU,wrapIn:cU,wrapInList:dU});const fU=Bt.create({name:"commands",addCommands(){return{...uU}}}),hU=Bt.create({name:"drop",addProseMirrorPlugins(){return[new wt({key:new Et("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),pU=Bt.create({name:"editable",addProseMirrorPlugins(){return[new wt({key:new Et("editable"),props:{editable:()=>this.editor.options.editable}})]}}),mU=new Et("focusEvents"),gU=Bt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new wt({key:mU,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),vU=Bt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:d,$anchor:f}=l,{pos:h,parent:p}=f,m=f.parent.isTextblock&&h>0?a.doc.resolve(h-1):f,v=m.parent.type.spec.isolating,g=f.pos-f.parentOffset,b=v&&m.parent.childCount===1?g===f.pos:Je.atStart(c).from===h;return!d||!p.type.isTextblock||p.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Hf()||RT()?o:i},addProseMirrorPlugins(){return[new wt({key:new Et("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:o,from:s,to:a}=e.selection,l=Je.atStart(e.doc).from,c=Je.atEnd(e.doc).to;if(o||!(s===l&&a===c)||!dp(n.doc))return;const h=n.tr,p=ip({state:n,transaction:h}),{commands:m}=new op({editor:this.editor,state:p});if(m.clearNodes(),!!h.steps.length)return h}})]}}),yU=Bt.create({name:"paste",addProseMirrorPlugins(){return[new wt({key:new Et("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),bU=Bt.create({name:"tabindex",addProseMirrorPlugins(){return[new wt({key:new Et("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class bs{get name(){return this.node.type.name}constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new bs(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new bs(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 bs(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,s=this.pos+r+(o?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(s);if(!i&&a.depth<=this.depth)return;const l=new bs(a,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new bs(a,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const o=i.node.attrs,s=Object.keys(n);for(let a=0;a<s.length;a+=1){const l=s[a];if(o[l]!==n[l])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const o=Object.keys(n);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&o.every(l=>n[l]===s.node.attrs[l])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}}const wU=`.ProseMirror {
|
|
106
|
+
position: relative;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.ProseMirror {
|
|
110
|
+
word-wrap: break-word;
|
|
111
|
+
white-space: pre-wrap;
|
|
112
|
+
white-space: break-spaces;
|
|
113
|
+
-webkit-font-variant-ligatures: none;
|
|
114
|
+
font-variant-ligatures: none;
|
|
115
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.ProseMirror [contenteditable="false"] {
|
|
119
|
+
white-space: normal;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
123
|
+
white-space: pre-wrap;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.ProseMirror pre {
|
|
127
|
+
white-space: pre-wrap;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
img.ProseMirror-separator {
|
|
131
|
+
display: inline !important;
|
|
132
|
+
border: none !important;
|
|
133
|
+
margin: 0 !important;
|
|
134
|
+
width: 0 !important;
|
|
135
|
+
height: 0 !important;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.ProseMirror-gapcursor {
|
|
139
|
+
display: none;
|
|
140
|
+
pointer-events: none;
|
|
141
|
+
position: absolute;
|
|
142
|
+
margin: 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.ProseMirror-gapcursor:after {
|
|
146
|
+
content: "";
|
|
147
|
+
display: block;
|
|
148
|
+
position: absolute;
|
|
149
|
+
top: -2px;
|
|
150
|
+
width: 20px;
|
|
151
|
+
border-top: 1px solid black;
|
|
152
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@keyframes ProseMirror-cursor-blink {
|
|
156
|
+
to {
|
|
157
|
+
visibility: hidden;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ProseMirror-hideselection *::selection {
|
|
162
|
+
background: transparent;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
166
|
+
background: transparent;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.ProseMirror-hideselection * {
|
|
170
|
+
caret-color: transparent;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
174
|
+
display: block;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
178
|
+
opacity: 0
|
|
179
|
+
}`;function xU(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}let kU=class extends O5{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:i})=>this.options.onDrop(n,r,i)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=xU(wU,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,n){const r=TT(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(e).forEach(o=>{const s=typeof o=="string"?`${o}$`:o.key;r=r.filter(a=>!a.key.startsWith(s))}),n.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,n;const i=[...this.options.enableCoreExtensions?[pU,K5.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),fU,gU,vU,bU,hU,yU].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 Da(i,this)}createCommandManager(){this.commandManager=new op({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let n;try{n=iv(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),n=iv(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=DT(n,this.options.autofocus);this.view=new fT(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:Ma.create({doc:n,selection:r||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(s)});return}const n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:n}),this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return LT(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return WH(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return tb(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
|
|
180
|
+
|
|
181
|
+
`,textSerializers:r={}}=e||{};return BH(this.state.doc,{blockSeparator:n,textSerializers:{...AT(this.schema),...r}})}get isEmpty(){return dp(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new bs(n,this)}get $doc(){return this.$pos(0)}};function ia(t){return new ap({find:t.find,handler:({state:e,range:n,match:r})=>{const i=st(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:o}=e,s=r[r.length-1],a=r[0];if(s){const l=a.search(/\S/),c=n.from+a.indexOf(s),d=c+s.length;if(ob(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>c).length)return null;d<n.to&&o.delete(d,n.to),c>n.from&&o.delete(n.from+l,c);const h=n.from+l+s.length;o.addMark(n.from+l,h,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}function _U(t){return new ap({find:t.find,handler:({state:e,range:n,match:r})=>{const i=st(t.getAttributes,void 0,r)||{},{tr:o}=e,s=n.from;let a=n.to;const l=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=s+c;d>a?d=a:a=d+r[1].length;const f=r[0][r[0].length-1];o.insertText(f,s+r[0].length-1),o.replaceWith(d,a,l)}else if(r[0]){const c=t.type.isInline?s:s-1;o.insert(c,t.type.create(i)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()}})}function sv(t){return new ap({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),o=st(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)}})}function sd(t){return new ap({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const o=st(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),c=l&&Qv(l,t.type,o);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){const{selection:f,storedMarks:h}=e,{splittableMarks:p}=t.editor.extensionManager,m=h||f.$to.parentOffset&&f.$from.marks();if(m){const v=m.filter(g=>p.includes(g.type.name));s.ensureMarks(v)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,o).run()}const d=s.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&ds(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)}})}let rr=class av{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=st(Ie(this,"addOptions",{name:this.name}))),this.storage=st(Ie(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new av(e)}configure(e={}){const n=this.extend({...this.config,addOptions:()=>lp(this.options,e)});return n.name=this.name,n.parent=this.parent,n}extend(e={}){const n=new av(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=st(Ie(n,"addOptions",{name:n.name})),n.storage=st(Ie(n,"addStorage",{name:n.name,options:n.options})),n}};function ls(t){return new B5({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const o=st(t.getAttributes,void 0,r,i);if(o===!1||o===null)return null;const{tr:s}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const d=l.search(/\S/),f=n.from+l.indexOf(a),h=f+a.length;if(ob(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(g=>g===t.type&&g!==m.mark.type)).filter(m=>m.to>f).length)return null;h<n.to&&s.delete(h,n.to),f>n.from&&s.delete(n.from+d,f),c=n.from+d+a.length,s.addMark(n.from+d,c,t.type.create(o||{})),s.removeStoredMark(t.type)}}})}function SU(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ue){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 CU=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},TU=/[\uD800-\uDBFF]/,EU=/[\uDC00-\uDFFF]/,AU=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&TU.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&EU.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},MU=AU,Gt=new Et("y-sync"),Ii=new Et("y-undo"),fu=new Et("yjs-cursor"),Ri=(t,e)=>t>>>e|t<<32-e,OU=t=>Ri(t,2)^Ri(t,13)^Ri(t,22),DU=t=>Ri(t,6)^Ri(t,11)^Ri(t,25),IU=t=>Ri(t,7)^Ri(t,18)^t>>>3,RU=t=>Ri(t,17)^Ri(t,19)^t>>>10,NU=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),PU=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class LU{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(PU),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let f=16;f<64;f++)n[f]=RU(n[f-2])+n[f-7]+IU(n[f-15])+n[f-16];let r=e[0],i=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],d=e[7];for(let f=0,h,p;f<64;f++)h=d+DU(a)+(a&l^~a&c)+NU[f]+n[f]>>>0,p=OU(r)+(r&i^r&o^i&o)>>>0,d=c,c=l,l=a,a=s+h>>>0,s=o,o=i,i=r,r=h+p>>>0;e[0]+=r,e[1]+=i,e[2]+=o,e[3]+=s,e[4]+=a,e[5]+=l,e[6]+=c,e[7]+=d}digest(e){let n=0;for(;n+56<=e.length;){let s=0;for(;s<16&&n+3<e.length;s++)this._W[s]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,s,16);n<e.length;)this._W[s]|=e[n]<<(3-n%4)*8,n++;this._W[s]|=er<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let i=0;for(;n<e.length;i++)for(let s=3;s>=0&&n<e.length;s--)this._W[i]|=e[n++]<<s*8;r||(this._W[i-(n%4===0?0:1)]|=er<<(3-n%4)*8),this._W[14]=e.byteLength/aR,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 zU=t=>new LU().digest(t),FU=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},BU=t=>lN(FU(zU(dN(t)))),Uf=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Ol(e.ds,t.id),VU=[{light:"#ecd44433",dark:"#ecd444"}],HU=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Xs();t.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}t.set(n,VR(e))}return t.get(n)},UU=(t,{colors:e=VU,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:o}={})=>{let s=!1;const a=new WU(t,o),l=new wt({props:{editable:c=>{const d=Gt.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:Gt,state:{init:(c,d)=>({type:t,doc:t.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,d)=>{const f=c.getMeta(Gt);if(f!==void 0){d=Object.assign({},d);for(const h in f)d[h]=f[h]}return d.addToHistory=c.getMeta("addToHistory")!==!1,d.isChangeOrigin=f!==void 0&&!!f.isChangeOrigin,d.isUndoRedoOperation=f!==void 0&&!!f.isChangeOrigin&&!!f.isUndoRedoOperation,a.prosemirrorView!==null&&f!==void 0&&(f.snapshot!=null||f.prevSnapshot!=null)&&yy(0,()=>{a.prosemirrorView!=null&&(f.restore==null?a._renderSnapshot(f.snapshot,f.prevSnapshot,d):(a._renderSnapshot(f.snapshot,f.snapshot,d),delete d.restore,delete d.snapshot,delete d.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),d}},view:c=>(a.initView(c),o==null&&a._forceRerender(),i(),{update:()=>{const d=l.getState(c.state);if(d.snapshot==null&&d.prevSnapshot==null&&(s||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(s=!0,d.addToHistory===!1&&!d.isChangeOrigin){const f=Ii.getState(c.state),h=f&&f.undoManager;h&&h.stopCapturing()}a.mux(()=>{d.doc.transact(f=>{f.meta.set("addToHistory",d.addToHistory),a._prosemirrorChanged(c.state.doc)},Gt)})}},destroy:()=>{a.destroy()}})});return l},jU=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new pr(t.doc));else if(e.type==="node"){const r=ja(n.doc,n.type,e.anchor,n.mapping);t.setSelection(Ue.create(t.doc,r))}else{const r=ja(n.doc,n.type,e.anchor,n.mapping),i=ja(n.doc,n.type,e.head,n.mapping);if(r!==null&&i!==null){const o=Be.between(t.doc.resolve(r),t.doc.resolve(i));t.setSelection(o)}}},lv=(t,e)=>({type:e.selection.jsonID,anchor:Wf(e.selection.anchor,t.type,t.mapping),head:Wf(e.selection.head,t.type,t.mapping)});class WU{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=CU(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=lv(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()?(K_&&this._domSelectionInView===null&&(yy(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const i=n.getBoundingClientRect(),o=Md.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||o.clientWidth||0)&&i.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(e,n){n||(n=TS(gS(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Gt,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Yu(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Ce(me.from(e),0,0));n.setMeta(Gt,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(i=>Yu(i,this.prosemirrorView.state.schema,this)).filter(i=>i!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Ce(me.from(n),0,0));if(e){const i=fo(fi(e.anchor,0),r.doc.content.size),o=fo(fi(e.head,0),r.doc.content.size);r.setSelection(Be.create(r.doc,i,o))}this.prosemirrorView.dispatch(r.setMeta(Gt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let i=this.doc,o=this.type;if(e||(e=tm(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&jn(),i=new zi({gc:!1}),Sf(i,n),n=tm(i),Sf(i,e),e=tm(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=hi(s,o._item.id.clock);o=s[a].content.type}this.mapping.clear(),this.mux(()=>{i.transact(s=>{const a=r.permanentUserData;a&&a.dss.forEach(f=>{rs(s,f,h=>{})});const l=(f,h)=>{const p=f==="added"?a.getUserByClientId(h.client):a.getUserByDeletedId(h);return{user:p,type:f,color:HU(r.colorMapping,r.colors,p)}},c=zS(o,new _y(n.ds,e.sv)).map(f=>!f._item.deleted||Uf(f._item,e)||Uf(f._item,n)?Yu(f,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,l):null).filter(f=>f!==null),d=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Ce(me.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(Gt,{isChangeOrigin:!0}))},Gt)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Gt.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);rs(n,n.deleteSet,a=>{if(a.constructor===zt){const l=a.content.type;l&&this.mapping.delete(l)}}),n.changed.forEach(i),n.changedParentTypes.forEach(i);const o=this.type.toArray().map(a=>zT(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Ce(me.from(o),0,0));jU(s,this.beforeTransactionSelection,this),s=s.setMeta(Gt,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof DS}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{dv(this.doc,this.type,e,this),this.beforeTransactionSelection=lv(this,this.prosemirrorView.state)},Gt)}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 zT=(t,e,n,r,i,o)=>{const s=n.mapping.get(t);if(s===void 0){if(t instanceof sn)return Yu(t,e,n,r,i,o);throw Gr()}return s},Yu=(t,e,n,r,i,o)=>{const s=[],a=l=>{var c,d;if(l instanceof sn){const f=zT(l,e,n,r,i,o);f!==null&&s.push(f)}else{const f=(d=(c=l._item.right)==null?void 0:c.content)==null?void 0:d.type;f instanceof is&&!f._item.deleted&&f._item.id.client===f.doc.clientID&&(l.applyDelta([{retain:l.length},...f.toDelta()]),f.doc.transact(p=>{f._item.delete(p)}));const h=KU(l,e,n,r,i,o);h!==null&&h.forEach(p=>{p!==null&&s.push(p)})}};r===void 0||i===void 0?t.toArray().forEach(a):zS(t,new _y(i.ds,r.sv)).forEach(a);try{const l=t.getAttributes(r);r!==void 0&&(Uf(t._item,r)?Uf(t._item,i)||(l.ychange=o?o("added",t._item.id):{type:"added"}):l.ychange=o?o("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,l,s);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Gt),n.mapping.delete(t),null}},KU=(t,e,n,r,i,o)=>{const s=[],a=t.toDelta(r,i,o);try{for(let l=0;l<a.length;l++){const c=a[l];s.push(e.text(c.insert,XU(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Gt),null}return s},qU=(t,e)=>{const n=new Dn,r=t.map(i=>({insert:i.text,attributes:BT(i.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},GU=(t,e)=>{const n=new sn(t.type.name);for(const r in t.attrs){const i=t.attrs[r];i!==null&&r!=="ychange"&&n.setAttribute(r,i)}return n.insert(0,up(t).map(r=>cv(r,e))),e.mapping.set(n,t),n},cv=(t,e)=>t instanceof Array?qU(t,e):GU(t,e),v1=t=>typeof t=="object"&&t!==null,sb=(t,e)=>{const n=Object.keys(t).filter(i=>t[i]!==null);let r=n.length===(e==null?0:Object.keys(e).filter(i=>e[i]!==null).length);for(let i=0;i<n.length&&r;i++){const o=n[i],s=t[o],a=e[o];r=o==="ychange"||s===a||v1(s)&&v1(a)&&sb(s,a)}return r},up=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const i=e[r];if(i.isText){const o=[];for(let s=e[r];r<e.length&&s.isText;s=e[++r])o.push(s);r--,n.push(o)}else n.push(i)}return n},FT=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,i)=>r.insert===e[i].text&&U_(r.attributes||{}).length===e[i].marks.length&&El(r.attributes,(o,s)=>{var c;const a=ab(s),l=e[i].marks;return sb(o,(c=l.find(d=>d.type.name===a))==null?void 0:c.attrs)}))},ad=(t,e)=>{if(t instanceof sn&&!(e instanceof Array)&&uv(t,e)){const n=up(e);return t._length===n.length&&sb(t.getAttributes(),e.attrs)&&t.toArray().every((r,i)=>ad(r,n[i]))}return t instanceof Dn&&e instanceof Array&&FT(t,e)},jf=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),y1=(t,e,n)=>{const r=t.toArray(),i=up(e),o=i.length,s=r.length,a=fo(s,o);let l=0,c=0,d=!1;for(;l<a;l++){const f=r[l],h=i[l];if(jf(n.mapping.get(f),h))d=!0;else if(!ad(f,h))break}for(;l+c<a;c++){const f=r[s-c-1],h=i[o-c-1];if(jf(n.mapping.get(f),h))d=!0;else if(!ad(f,h))break}return{equalityFactor:l+c,foundMappedChild:d}},JU=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof pi?e+=n.content.str:n.content instanceof an&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},YU=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:i}=JU(t),o=e.map(c=>({insert:c.text,attributes:Object.assign({},r,BT(c.marks,n))})),{insert:s,remove:a,index:l}=MU(i,o.map(c=>c.insert).join(""));t.delete(l,a),t.insert(l,s),t.applyDelta(o.map(c=>({retain:c.insert.length,attributes:c.attributes})))},ZU=/(.*)(--[a-zA-Z0-9+/=]{8})$/,ab=t=>{var e;return((e=ZU.exec(t))==null?void 0:e[1])??t},XU=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(ab(r),t[r]));return n},BT=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const i=ji(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[i?`${r.type.name}--${BU(r.toJSON())}`:r.type.name]=r.attrs}}),n},dv=(t,e,n,r)=>{if(e instanceof sn&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof sn){const f=e.getAttributes(),h=n.attrs;for(const p in h)h[p]!==null?f[p]!==h[p]&&p!=="ychange"&&e.setAttribute(p,h[p]):e.removeAttribute(p);for(const p in f)h[p]===void 0&&e.removeAttribute(p)}const i=up(n),o=i.length,s=e.toArray(),a=s.length,l=fo(o,a);let c=0,d=0;for(;c<l;c++){const f=s[c],h=i[c];if(!jf(r.mapping.get(f),h))if(ad(f,h))r.mapping.set(f,h);else break}for(;d+c<l;d++){const f=s[a-d-1],h=i[o-d-1];if(!jf(r.mapping.get(f),h))if(ad(f,h))r.mapping.set(f,h);else break}t.transact(()=>{for(;a-c-d>0&&o-c-d>0;){const h=s[c],p=i[c],m=s[a-d-1],v=i[o-d-1];if(h instanceof Dn&&p instanceof Array)FT(h,p)||YU(h,p,r),c+=1;else{let g=h instanceof sn&&uv(h,p),b=m instanceof sn&&uv(m,v);if(g&&b){const x=y1(h,p,r),_=y1(m,v,r);x.foundMappedChild&&!_.foundMappedChild?b=!1:!x.foundMappedChild&&_.foundMappedChild||x.equalityFactor<_.equalityFactor?g=!1:b=!1}g?(dv(t,h,p,r),c+=1):b?(dv(t,m,v,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[cv(p,r)]),c+=1)}}const f=a-c-d;if(a===1&&o===0&&s[0]instanceof Dn?(r.mapping.delete(s[0]),s[0].delete(0,s[0].length)):f>0&&(e.slice(c,c+f).forEach(h=>r.mapping.delete(h)),e.delete(c,f)),c+d<o){const h=[];for(let p=c;p<o-d;p++)h.push(cv(i[p],r));e.insert(c,h)}},Gt)},uv=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let gc=null;const QU=()=>{const t=gc;gc=null,t.forEach((e,n)=>{const r=n.state.tr,i=Gt.getState(n.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((o,s)=>{r.setMeta(s,o)}),n.dispatch(r))})},$U=(t,e,n)=>{gc||(gc=new Map,yy(0,QU)),ji(gc,t,qr).set(e,n)},Wf=(t,e,n)=>{if(t===0)return em(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 Dn){if(r._length>=t)return em(r,t,e.length===0?-1:0);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<i)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&i>1)return new Gc(r._item===null?null:r._item.id,r._item===null?Kc(r):null,null);if(t-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new Gc(r._item===null?null:r._item.id,r._item===null?Kc(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw jn();if(t===0&&r.constructor!==Dn&&r!==e)return e6(r._item.parent,r._item)}return em(e,e._length,e.length===0?-1:0)},e6=(t,e)=>{let n=null,r=null;return t._item===null?r=Kc(t):n=rt(t._item.id.client,t._item.id.clock),new Gc(n,r,e.id)},ja=(t,e,n,r)=>{const i=Pg(n,t);if(i===null||i.type!==e&&!qc(e,i.type._item))return null;let o=i.type,s=0;if(o.constructor===Dn)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 Dn?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 Dn?s+=c._length:s+=r.get(c).nodeSize),l=l.right}}o=a}return s-1};function t6(t){const e=t.toArray(),n=r=>{let i;if(r instanceof Dn)i=r.toDelta().map(s=>{const a={type:"text",text:s.insert};return s.attributes&&(a.marks=Object.keys(s.attributes).map(l=>{const c=s.attributes[l],f={type:ab(l)};return Object.keys(c)&&(f.attrs=c),f})),a});else if(r instanceof sn){i={type:r.nodeName};const o=r.getAttributes();Object.keys(o).length&&(i.attrs=o);const s=r.toArray();s.length&&(i.content=s.map(n).flat())}else jn();return i};return{type:"doc",content:e.map(n)}}const n6=(t,e,n)=>t!==e,r6=t=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null);const r=document.createTextNode(""),i=document.createTextNode("");return e.insertBefore(r,null),e.insertBefore(n,null),e.insertBefore(i,null),e},VT=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),i6=/^#[0-9a-fA-F]{6}$/,b1=(t,e,n,r,i)=>{const o=Gt.getState(t),s=o.doc,a=[];return o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0?Xe.create(t.doc,[]):(e.getStates().forEach((l,c)=>{if(n(s.clientID,c,l)&&l.cursor!=null){const d=l.user||{};d.color==null?d.color="#ffa500":i6.test(d.color)||console.warn("A user uses an unsupported color format",d),d.name==null&&(d.name=`User: ${c}`);let f=ja(s,o.type,Vs(l.cursor.anchor),o.binding.mapping),h=ja(s,o.type,Vs(l.cursor.head),o.binding.mapping);if(f!==null&&h!==null){const p=fi(t.doc.content.size-1,0);f=fo(f,p),h=fo(h,p),a.push(Rt.widget(h,()=>r(d,c),{key:c+"",side:10}));const m=fo(f,h),v=fi(f,h);a.push(Rt.inline(m,v,i(d,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),Xe.create(t.doc,a))},o6=(t,{awarenessStateFilter:e=n6,cursorBuilder:n=r6,selectionBuilder:r=VT,getSelection:i=s=>s.selection}={},o="cursor")=>new wt({key:fu,state:{init(s,a){return b1(a,t,e,n,r)},apply(s,a,l,c){const d=Gt.getState(c),f=s.getMeta(fu);return d&&d.isChangeOrigin||f&&f.awarenessUpdated?b1(c,t,e,n,r):a.map(s.mapping,s.doc)}},props:{decorations:s=>fu.getState(s)},view:s=>{const a=()=>{s.docView&&$U(s,fu,{awarenessUpdated:!0})},l=()=>{const c=Gt.getState(s.state),d=t.getLocalState()||{};if(s.hasFocus()){const f=i(s.state),h=Wf(f.anchor,c.type,c.binding.mapping),p=Wf(f.head,c.type,c.binding.mapping);(d.cursor==null||!o0(Vs(d.cursor.anchor),h)||!o0(Vs(d.cursor.head),p))&&t.setLocalStateField(o,{anchor:h,head:p})}else d.cursor!=null&&ja(c.doc,c.type,Vs(d.cursor.anchor),c.binding.mapping)!==null&&t.setLocalStateField(o,null)};return t.on("change",a),s.dom.addEventListener("focusin",l),s.dom.addEventListener("focusout",l),{update:l,destroy:()=>{s.dom.removeEventListener("focusin",l),s.dom.removeEventListener("focusout",l),t.off("change",a),t.setLocalStateField(o,null)}}}}),s6=t=>{var e,n;return((n=(e=Ii.getState(t))==null?void 0:e.undoManager)==null?void 0:n.undo())!=null},a6=t=>{var e,n;return((n=(e=Ii.getState(t))==null?void 0:e.undoManager)==null?void 0:n.redo())!=null},l6=new Set(["paragraph"]),c6=(t,e)=>!(t instanceof zt)||!(t.content instanceof mi)||!(t.content.type instanceof is||t.content.type instanceof sn&&e.has(t.content.type.nodeName))||t.content.type._length===0,d6=({protectedNodes:t=l6,trackedOrigins:e=[],undoManager:n=null}={})=>new wt({key:Ii,state:{init:(r,i)=>{const o=Gt.getState(i),s=n||new DS(o.type,{trackedOrigins:new Set([Gt].concat(e)),deleteFilter:a=>c6(a,t),captureTransaction:a=>a.meta.get("addToHistory")!==!1});return{undoManager:s,prevSel:null,hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0}},apply:(r,i,o,s)=>{const a=Gt.getState(s).binding,l=i.undoManager,c=l.undoStack.length>0,d=l.redoStack.length>0;return a?{undoManager:l,prevSel:lv(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=Gt.getState(r.state),o=Ii.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:s})=>{const a=i.binding;a&&s.meta.set(a,Ii.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()}}}}),u6=Bt.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="history")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Ii.getState(e).undoManager.undoStack.length===0?!1:n?s6(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Ii.getState(e).undoManager.redoStack.length===0?!1:n?a6(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=d6(this.options.yUndoOptions),r=n.spec.view;n.spec.view=s=>{const{undoManager:a}=Ii.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=UU(e,i);return this.editor.options.enableContentCheck&&((t=e.doc)===null||t===void 0||t.on("beforeTransaction",()=>{try{const s=t6(e);if(s.content.length===0)return;this.editor.schema.nodeFromJSON(s).check()}catch(s){return this.editor.emit("contentError",{error:s,editor:this.editor,disableCollaboration:()=>{var a;(a=e.doc)===null||a===void 0||a.destroy(),this.storage.isDisabled=!0}}),!1}})),[o,n,this.editor.options.enableContentCheck&&new wt({key:new Et("filterInvalidContent"),filterTransaction:()=>{var s;return this.storage.isDisabled&&((s=e.doc)===null||s===void 0||s.destroy()),!0}})].filter(Boolean)}}),w1=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n.user})),x1=()=>null,f6=Bt.create({name:"collaborationCursor",priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:t=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");return n.classList.add("collaboration-cursor__label"),n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null),e.insertBefore(n,null),e},selectionRender:VT,onUpdate:x1}},onCreate(){if(this.options.onUpdate!==x1&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),!this.options.provider)throw new Error('The "provider" option is required for the CollaborationCursor extension')},addStorage(){return{users:[]}},addCommands(){return{updateUser:t=>()=>(this.options.user=t,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:t=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),e.commands.updateUser(t))}},addProseMirrorPlugins(){return[o6((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=w1(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=w1(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),h6=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,p6=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,m6=Vi.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",tn(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ia({find:h6,type:this.type})]},addPasteRules(){return[ls({find:p6,type:this.type})]}}),g6="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",v6="ελ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",fv="numeric",hv="ascii",pv="alpha",vc="asciinumeric",ec="alphanumeric",mv="domain",HT="emoji",y6="scheme",b6="slashscheme",wm="whitespace";function w6(t,e){return t in e||(e[t]=[]),e[t]}function Es(t,e,n){e[fv]&&(e[vc]=!0,e[ec]=!0),e[hv]&&(e[vc]=!0,e[pv]=!0),e[vc]&&(e[ec]=!0),e[pv]&&(e[ec]=!0),e[ec]&&(e[mv]=!0),e[HT]&&(e[mv]=!0);for(const r in e){const i=w6(r,n);i.indexOf(t)<0&&i.push(t)}}function x6(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function dr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}dr.groups={};dr.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],o=e.jr[r][1];if(o&&i.test(t))return o}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||dr.groups;let i;return e&&e.j?i=e:(i=new dr(e),n&&r&&Es(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const o=t.length;if(!o)return i;for(let s=0;s<o-1;s++)i=i.tt(t[s]);return i.tt(t[o-1],e,n,r)},tt(t,e,n,r){r=r||dr.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const o=e;let s,a=i.go(t);if(a?(s=new dr,Object.assign(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new dr,o){if(r)if(s.t&&typeof s.t=="string"){const l=Object.assign(x6(s.t,r),n);Es(o,l,r)}else n&&Es(o,n,r);s.t=o}return i.j[t]=s,s}};const ot=(t,e,n,r,i)=>t.ta(e,n,r,i),Yt=(t,e,n,r,i)=>t.tr(e,n,r,i),k1=(t,e,n,r,i)=>t.ts(e,n,r,i),be=(t,e,n,r,i)=>t.tt(e,n,r,i),Qi="WORD",gv="UWORD",UT="ASCIINUMERICAL",jT="ALPHANUMERICAL",ld="LOCALHOST",vv="TLD",yv="UTLD",Zu="SCHEME",Ca="SLASH_SCHEME",lb="NUM",bv="WS",cb="NL",yc="OPENBRACE",bc="CLOSEBRACE",Kf="OPENBRACKET",qf="CLOSEBRACKET",Gf="OPENPAREN",Jf="CLOSEPAREN",Yf="OPENANGLEBRACKET",Zf="CLOSEANGLEBRACKET",Xf="FULLWIDTHLEFTPAREN",Qf="FULLWIDTHRIGHTPAREN",$f="LEFTCORNERBRACKET",eh="RIGHTCORNERBRACKET",th="LEFTWHITECORNERBRACKET",nh="RIGHTWHITECORNERBRACKET",rh="FULLWIDTHLESSTHAN",ih="FULLWIDTHGREATERTHAN",oh="AMPERSAND",sh="APOSTROPHE",ah="ASTERISK",Io="AT",lh="BACKSLASH",ch="BACKTICK",dh="CARET",Lo="COLON",db="COMMA",uh="DOLLAR",bi="DOT",fh="EQUALS",ub="EXCLAMATION",Ir="HYPHEN",wc="PERCENT",hh="PIPE",ph="PLUS",mh="POUND",xc="QUERY",fb="QUOTE",WT="FULLWIDTHMIDDLEDOT",hb="SEMI",wi="SLASH",kc="TILDE",gh="UNDERSCORE",KT="EMOJI",vh="SYM";var qT=Object.freeze({__proto__:null,ALPHANUMERICAL:jT,AMPERSAND:oh,APOSTROPHE:sh,ASCIINUMERICAL:UT,ASTERISK:ah,AT:Io,BACKSLASH:lh,BACKTICK:ch,CARET:dh,CLOSEANGLEBRACKET:Zf,CLOSEBRACE:bc,CLOSEBRACKET:qf,CLOSEPAREN:Jf,COLON:Lo,COMMA:db,DOLLAR:uh,DOT:bi,EMOJI:KT,EQUALS:fh,EXCLAMATION:ub,FULLWIDTHGREATERTHAN:ih,FULLWIDTHLEFTPAREN:Xf,FULLWIDTHLESSTHAN:rh,FULLWIDTHMIDDLEDOT:WT,FULLWIDTHRIGHTPAREN:Qf,HYPHEN:Ir,LEFTCORNERBRACKET:$f,LEFTWHITECORNERBRACKET:th,LOCALHOST:ld,NL:cb,NUM:lb,OPENANGLEBRACKET:Yf,OPENBRACE:yc,OPENBRACKET:Kf,OPENPAREN:Gf,PERCENT:wc,PIPE:hh,PLUS:ph,POUND:mh,QUERY:xc,QUOTE:fb,RIGHTCORNERBRACKET:eh,RIGHTWHITECORNERBRACKET:nh,SCHEME:Zu,SEMI:hb,SLASH:wi,SLASH_SCHEME:Ca,SYM:vh,TILDE:kc,TLD:vv,UNDERSCORE:gh,UTLD:yv,UWORD:gv,WORD:Qi,WS:bv});const Zi=/[a-z]/,Wl=new RegExp("\\p{L}","u"),xm=new RegExp("\\p{Emoji}","u"),Xi=/\d/,km=/\s/,_1="\r",_m=`
|
|
182
|
+
`,k6="️",_6="",Sm="";let hu=null,pu=null;function S6(t=[]){const e={};dr.groups=e;const n=new dr;hu==null&&(hu=S1(g6)),pu==null&&(pu=S1(v6)),be(n,"'",sh),be(n,"{",yc),be(n,"}",bc),be(n,"[",Kf),be(n,"]",qf),be(n,"(",Gf),be(n,")",Jf),be(n,"<",Yf),be(n,">",Zf),be(n,"(",Xf),be(n,")",Qf),be(n,"「",$f),be(n,"」",eh),be(n,"『",th),be(n,"』",nh),be(n,"<",rh),be(n,">",ih),be(n,"&",oh),be(n,"*",ah),be(n,"@",Io),be(n,"`",ch),be(n,"^",dh),be(n,":",Lo),be(n,",",db),be(n,"$",uh),be(n,".",bi),be(n,"=",fh),be(n,"!",ub),be(n,"-",Ir),be(n,"%",wc),be(n,"|",hh),be(n,"+",ph),be(n,"#",mh),be(n,"?",xc),be(n,'"',fb),be(n,"/",wi),be(n,";",hb),be(n,"~",kc),be(n,"_",gh),be(n,"\\",lh),be(n,"・",WT);const r=Yt(n,Xi,lb,{[fv]:!0});Yt(r,Xi,r);const i=Yt(r,Zi,UT,{[vc]:!0}),o=Yt(r,Wl,jT,{[ec]:!0}),s=Yt(n,Zi,Qi,{[hv]:!0});Yt(s,Xi,i),Yt(s,Zi,s),Yt(i,Xi,i),Yt(i,Zi,i);const a=Yt(n,Wl,gv,{[pv]:!0});Yt(a,Zi),Yt(a,Xi,o),Yt(a,Wl,a),Yt(o,Xi,o),Yt(o,Zi),Yt(o,Wl,o);const l=be(n,_m,cb,{[wm]:!0}),c=be(n,_1,bv,{[wm]:!0}),d=Yt(n,km,bv,{[wm]:!0});be(n,Sm,d),be(c,_m,l),be(c,Sm,d),Yt(c,km,d),be(d,_1),be(d,_m),Yt(d,km,d),be(d,Sm,d);const f=Yt(n,xm,KT,{[HT]:!0});be(f,"#"),Yt(f,xm,f),be(f,k6,f);const h=be(f,_6);be(h,"#"),Yt(h,xm,f);const p=[[Zi,s],[Xi,i]],m=[[Zi,null],[Wl,a],[Xi,o]];for(let v=0;v<hu.length;v++)Eo(n,hu[v],vv,Qi,p);for(let v=0;v<pu.length;v++)Eo(n,pu[v],yv,gv,m);Es(vv,{tld:!0,ascii:!0},e),Es(yv,{utld:!0,alpha:!0},e),Eo(n,"file",Zu,Qi,p),Eo(n,"mailto",Zu,Qi,p),Eo(n,"http",Ca,Qi,p),Eo(n,"https",Ca,Qi,p),Eo(n,"ftp",Ca,Qi,p),Eo(n,"ftps",Ca,Qi,p),Es(Zu,{scheme:!0,ascii:!0},e),Es(Ca,{slashscheme:!0,ascii:!0},e),t=t.sort((v,g)=>v[0]>g[0]?1:-1);for(let v=0;v<t.length;v++){const g=t[v][0],x=t[v][1]?{[y6]:!0}:{[b6]:!0};g.indexOf("-")>=0?x[mv]=!0:Zi.test(g)?Xi.test(g)?x[vc]=!0:x[hv]=!0:x[fv]=!0,k1(n,g,g,x)}return k1(n,"localhost",ld,{ascii:!0}),n.jd=new dr(vh),{start:n,tokens:Object.assign({groups:e},qT)}}function GT(t,e){const n=C6(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,i=[];let o=0,s=0;for(;s<r;){let a=t,l=null,c=0,d=null,f=-1,h=-1;for(;s<r&&(l=a.go(n[s]));)a=l,a.accepts()?(f=0,h=0,d=a):f>=0&&(f+=n[s].length,h++),c+=n[s].length,o+=n[s].length,s++;o-=f,s-=h,c-=f,i.push({t:d.t,v:e.slice(o-c,o),s:o-c,e:o})}return i}function C6(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),o,s=i<55296||i>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Eo(t,e,n,r,i){let o;const s=e.length;for(let a=0;a<s-1;a++){const l=e[a];t.j[l]?o=t.j[l]:(o=new dr(r),o.jr=i.slice(),t.j[l]=o),t=o}return o=new dr(n),o.jr=i.slice(),t.j[e[s-1]]=o,o}function S1(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let o=0;for(;i.indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+o),10);s>0;s--)n.pop();r+=o}else n.push(t[r]),r++}return e}const cd={defaultProtocol:"http",events:null,format:C1,formatHref:C1,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function pb(t,e=null){let n=Object.assign({},cd);t&&(n=Object.assign(n,t instanceof pb?t.o:t));const r=n.ignoreTags,i=[];for(let o=0;o<r.length;o++)i.push(r[o].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}pb.prototype={o:cd,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:cd[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function C1(t){return t}function JT(t,e){this.t="token",this.v=t,this.tk=e}JT.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=cd.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),o=this.toFormattedString(t),s={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:i,attributes:s,content:o,eventListeners:f}}};function fp(t,e){class n extends JT{constructor(i,o){super(i,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const T1=fp("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),E1=fp("text"),T6=fp("nl"),mu=fp("url",{isLink:!0,toHref(t=cd.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ld&&t[1].t===Lo}}),Or=t=>new dr(t);function E6({groups:t}){const e=t.domain.concat([oh,ah,Io,lh,ch,dh,uh,fh,Ir,lb,wc,hh,ph,mh,wi,vh,kc,gh]),n=[sh,Lo,db,bi,ub,wc,xc,fb,hb,Yf,Zf,yc,bc,qf,Kf,Gf,Jf,Xf,Qf,$f,eh,th,nh,rh,ih],r=[oh,sh,ah,lh,ch,dh,uh,fh,Ir,yc,bc,wc,hh,ph,mh,xc,wi,vh,kc,gh],i=Or(),o=be(i,kc);ot(o,r,o),ot(o,t.domain,o);const s=Or(),a=Or(),l=Or();ot(i,t.domain,s),ot(i,t.scheme,a),ot(i,t.slashscheme,l),ot(s,r,o),ot(s,t.domain,s);const c=be(s,Io);be(o,Io,c),be(a,Io,c),be(l,Io,c);const d=be(o,bi);ot(d,r,o),ot(d,t.domain,o);const f=Or();ot(c,t.domain,f),ot(f,t.domain,f);const h=be(f,bi);ot(h,t.domain,f);const p=Or(T1);ot(h,t.tld,p),ot(h,t.utld,p),be(c,ld,p);const m=be(f,Ir);be(m,Ir,m),ot(m,t.domain,f),ot(p,t.domain,f),be(p,bi,h),be(p,Ir,m);const v=be(p,Lo);ot(v,t.numeric,T1);const g=be(s,Ir),b=be(s,bi);be(g,Ir,g),ot(g,t.domain,s),ot(b,r,o),ot(b,t.domain,s);const x=Or(mu);ot(b,t.tld,x),ot(b,t.utld,x),ot(x,t.domain,s),ot(x,r,o),be(x,bi,b),be(x,Ir,g),be(x,Io,c);const _=be(x,Lo),A=Or(mu);ot(_,t.numeric,A);const M=Or(mu),P=Or();ot(M,e,M),ot(M,n,P),ot(P,e,M),ot(P,n,P),be(x,wi,M),be(A,wi,M);const D=be(a,Lo),L=be(l,Lo),X=be(L,wi),z=be(X,wi);ot(a,t.domain,s),be(a,bi,b),be(a,Ir,g),ot(l,t.domain,s),be(l,bi,b),be(l,Ir,g),ot(D,t.domain,M),be(D,wi,M),be(D,xc,M),ot(z,t.domain,M),ot(z,e,M),be(z,wi,M);const re=[[yc,bc],[Kf,qf],[Gf,Jf],[Yf,Zf],[Xf,Qf],[$f,eh],[th,nh],[rh,ih]];for(let Q=0;Q<re.length;Q++){const[N,B]=re[Q],j=be(M,N);be(P,N,j),be(j,B,M);const H=Or(mu);ot(j,e,H);const W=Or();ot(j,n),ot(H,e,H),ot(H,n,W),ot(W,e,H),ot(W,n,W),be(H,B,M),be(W,B,M)}return be(i,ld,x),be(i,cb,T6),{start:i,tokens:qT}}function A6(t,e,n){let r=n.length,i=0,o=[],s=[];for(;i<r;){let a=t,l=null,c=null,d=0,f=null,h=-1;for(;i<r&&!(l=a.go(n[i].t));)s.push(n[i++]);for(;i<r&&(c=l||a.go(n[i].t));)l=null,a=c,a.accepts()?(h=0,f=a):h>=0&&h++,i++,d++;if(h<0)i-=d,i<r&&(s.push(n[i]),i++);else{s.length>0&&(o.push(Cm(E1,e,s)),s=[]),i-=h,d-=h;const p=f.t,m=n.slice(i-d,i);o.push(Cm(p,e,m))}}return s.length>0&&o.push(Cm(E1,e,s)),o}function Cm(t,e,n){const r=n[0].s,i=n[n.length-1].e,o=e.slice(r,i);return new t(o,n)}const M6=typeof console<"u"&&console&&console.warn||(()=>{}),O6="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ut={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function D6(){return dr.groups={},Ut.scanner=null,Ut.parser=null,Ut.tokenQueue=[],Ut.pluginQueue=[],Ut.customSchemes=[],Ut.initialized=!1,Ut}function A1(t,e=!1){if(Ut.initialized&&M6(`linkifyjs: already initialized - will not register custom scheme "${t}" ${O6}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
183
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
184
|
+
2. Cannot start or end with "-"
|
|
185
|
+
3. "-" cannot repeat`);Ut.customSchemes.push([t,e])}function I6(){Ut.scanner=S6(Ut.customSchemes);for(let t=0;t<Ut.tokenQueue.length;t++)Ut.tokenQueue[t][1]({scanner:Ut.scanner});Ut.parser=E6(Ut.scanner.tokens);for(let t=0;t<Ut.pluginQueue.length;t++)Ut.pluginQueue[t][1]({scanner:Ut.scanner,parser:Ut.parser});return Ut.initialized=!0,Ut}function mb(t){return Ut.initialized||I6(),A6(Ut.parser.start,t,GT(Ut.scanner.start,t))}mb.scan=GT;function YT(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new pb(n),i=mb(t),o=[];for(let s=0;s<i.length;s++){const a=i[s];a.isLink&&(!e||a.t===e)&&r.check(a)&&o.push(a.toFormattedObject(r))}return o}const gb="[\0- -\u2029 ]",R6=new RegExp(gb),N6=new RegExp(`${gb}$`),P6=new RegExp(gb,"g");function L6(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function z6(t){return new wt({key:new Et("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!i||o)return;const{tr:s}=r,a=LH(n.doc,[...e]);if(jH(a).forEach(({newRange:c})=>{const d=FH(r.doc,c,p=>p.isTextblock);let f,h;if(d.length>1)f=d[0],h=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(c.from,c.to," "," ");if(!N6.test(p))return;f=d[0],h=r.doc.textBetween(f.pos,c.to,void 0," ")}if(f&&h){const p=h.split(R6).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],v=f.pos+h.lastIndexOf(m);if(!m)return!1;const g=mb(m).map(b=>b.toObject(t.defaultProtocol));if(!L6(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:v+b.start+1,to:v+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{ob(b.from,b.to,r.doc).some(x=>x.mark.type===t.type)||s.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function F6(t){return new wt({key:new Et("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let s=r.target;const a=[];for(;s.nodeName!=="DIV";)a.push(s),s=s.parentNode;if(!a.find(h=>h.nodeName==="A"))return!1;const l=LT(e.state,t.type.name),c=r.target,d=(i=c==null?void 0:c.href)!==null&&i!==void 0?i:l.href,f=(o=c==null?void 0:c.target)!==null&&o!==void 0?o:l.target;return c&&d?(window.open(d,f),!0):!1}}})}function B6(t){return new wt({key:new Et("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:i}=e,{selection:o}=i,{empty:s}=o;if(s)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=YT(a,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!l?!1:t.editor.commands.setMark(t.type,{href:l.href})}}})}function ms(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(P6,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const V6=Vi.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){A1(t);return}A1(t.scheme,t.optionalSlashes)})},onDestroy(){D6()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!ms(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!ms(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!ms(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",tn(this.options.HTMLAttributes,t),0]:["a",tn(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!ms(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!ms(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[ls({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=YT(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!ms(s,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(z6({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!ms(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(F6({type:this.type})),this.options.linkOnPaste&&t.push(B6({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),H6=Bt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new wt({key:new Et("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const o=this.editor.isEmpty;return t.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,c=!s.isLeaf&&dp(s);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const f=Rt.node(a,a+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),Xe.create(t,i)}}})]}});let wv,xv;if(typeof WeakMap<"u"){let t=new WeakMap;wv=e=>t.get(e),xv=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;wv=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},xv=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var Qt=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,i=e/this.width|0;let o=r+1,s=i+1;for(let a=1;o<this.width&&this.map[e+a]==n;a++)o++;for(let a=1;s<this.height&&this.map[e+this.width*a]==n;a++)s++;return{left:r,top:i,right:o,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:i,top:o,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:s==this.height)?null:this.map[r+this.width*(n<0?o-1:s)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:o}=this.findCell(t),{left:s,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(i,l),right:Math.max(r,a),bottom:Math.max(o,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const o=r*this.width+i,s=this.map[o];n[s]||(n[s]=!0,!(i==t.left&&i&&this.map[o-1]==s||r==t.top&&r&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const a=(t+1)*this.width;for(;s<a&&this.map[s]<i;)s++;return s==a?o-1:this.map[s]}i=o}}static get(t){return wv(t)||xv(t,U6(t))}};function U6(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=j6(t),n=t.childCount,r=[];let i=0,o=null;const s=[];for(let c=0,d=e*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){const f=t.child(c);d++;for(let m=0;;m++){for(;i<r.length&&r[i]!=0;)i++;if(m==f.childCount)break;const v=f.child(m),{colspan:g,rowspan:b,colwidth:x}=v.attrs;for(let _=0;_<b;_++){if(_+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:b-_});break}const A=i+_*e;for(let M=0;M<g;M++){r[A+M]==0?r[A+M]=d:(o||(o=[])).push({type:"collision",row:c,pos:d,n:g-M});const P=x&&x[M];if(P){const D=(A+M)%e*2,L=s[D];L==null||L!=P&&s[D+1]==1?(s[D]=P,s[D+1]=1):L==P&&s[D+1]++}}}i+=g,d+=v.nodeSize}const h=(c+1)*e;let p=0;for(;i<h;)r[i++]==0&&p++;p&&(o||(o=[])).push({type:"missing",row:c,n:p}),d++}(e===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new Qt(e,n,r,o);let l=!1;for(let c=0;!l&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(l=!0);return l&&W6(a,s,t),a}function j6(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let o=0;if(n)for(let s=0;s<r;s++){const a=t.child(s);for(let l=0;l<a.childCount;l++){const c=a.child(l);s+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const a=i.child(s);o+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function W6(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const o=t.map[i];if(r[o])continue;r[o]=!0;const s=n.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let a=null;const l=s.attrs;for(let c=0;c<l.colspan;c++){const d=e[(i+c)%t.width*2];d!=null&&(!l.colwidth||l.colwidth[c]!=d)&&((a||(a=K6(l)))[c]=d)}a&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function K6(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Kn(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const zo=new Et("selectingCells");function oa(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function q6(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function gi(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function hp(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=oa(e.$head)||G6(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function G6(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function kv(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function J6(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function vb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function ZT(t,e,n){const r=t.node(-1),i=Qt.get(r),o=t.start(-1),s=i.nextCell(t.pos-o,e,n);return s==null?null:t.node(0).resolve(o+s)}function sa(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function XT(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function Y6(t,e,n){const r=Kn(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}var Ft=class $i extends Je{constructor(e,n=e){const r=e.node(-1),i=Qt.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,n.pos-o),a=e.node(0),l=i.cellsInRect(s).filter(d=>d!=n.pos-o);l.unshift(n.pos-o);const c=l.map(d=>{const f=r.nodeAt(d);if(!f)throw new RangeError(`No cell with offset ${d} found`);const h=o+d+1;return new b_(a.resolve(h),a.resolve(h+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(kv(r)&&kv(i)&&vb(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?$i.rowSelection(r,i):o&&this.isColSelection()?$i.colSelection(r,i):new $i(r,i)}return Be.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=Qt.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let l=i.top;l<i.bottom;l++){const c=[];for(let d=l*n.width+i.left,f=i.left;f<i.right;f++,d++){const h=n.map[d];if(o[h])continue;o[h]=!0;const p=n.findCell(h);let m=e.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const v=i.left-p.left,g=p.right-i.right;if(v>0||g>0){let b=m.attrs;if(v>0&&(b=sa(b,0,v)),g>0&&(b=sa(b,b.colspan-g,g)),p.left<i.left){if(m=m.type.createAndFill(b),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else m=m.type.create(b,m.content)}if(p.top<i.top||p.bottom>i.bottom){const b={...m.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top<i.top?m=m.type.createAndFill(b):m=m.type.create(b,m.content)}c.push(m)}s.push(e.child(l).copy(me.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Ce(me.from(a),1,1)}replace(e,n=Ce.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?Ce.empty:n)}const o=Je.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new Ce(me.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Qt.get(n),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(n.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=Qt.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(n.pos-o),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(o+i.map[s.left])),a.bottom<i.height&&(n=l.resolve(o+i.map[i.width*(i.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(o+i.map[a.left])),s.bottom<i.height&&(e=l.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new $i(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Qt.get(e),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==n.width}eq(e){return e instanceof $i&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=Qt.get(r),o=e.start(-1),s=i.findCell(e.pos-o),a=i.findCell(n.pos-o),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(o+i.map[s.top*i.width])),a.right<i.width&&(n=l.resolve(o+i.map[i.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(o+i.map[a.top*i.width])),s.right<i.width&&(e=l.resolve(o+i.map[i.width*(s.top+1)-1]))),new $i(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new $i(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new $i(e.resolve(n),e.resolve(r))}getBookmark(){return new Z6(this.$anchorCell.pos,this.$headCell.pos)}};Ft.prototype.visible=!1;Je.jsonID("cell",Ft);var Z6=class QT{constructor(e,n){this.anchor=e,this.head=n}map(e){return new QT(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&vb(n,r)?new Ft(n,r):Je.near(r,1)}};function X6(t){if(!(t.selection instanceof Ft))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Rt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Xe.create(t.doc,e)}function Q6({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function $6({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function ej(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,s;if(r instanceof Ue&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=Ft.create(i,r.from);else if(s=="row"){const a=i.resolve(r.from+1);o=Ft.rowSelection(a,a)}else if(!n){const a=Qt.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];o=Ft.create(i,l+1,c)}}else r instanceof Be&&Q6(r)?o=Be.create(i,r.from):r instanceof Be&&$6(r)&&(o=Be.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}const tj=new Et("fix-tables");function $T(t,e,n,r){const i=t.childCount,o=e.childCount;e:for(let s=0,a=0;s<o;s++){const l=e.child(s);for(let c=a,d=Math.min(i,s+3);c<d;c++)if(t.child(c)==l){a=c+1,n+=l.nodeSize;continue e}r(l,n),a<i&&t.child(a).sameMarkup(l)?$T(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function eE(t,e){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=nj(t,i,o,n))};return e?e.doc!=t.doc&&$T(e.doc,t.doc,0,r):t.doc.descendants(r),n}function nj(t,e,n,r){const i=Qt.get(e);if(!i.problems)return r;r||(r=t.tr);const o=[];for(let l=0;l<i.height;l++)o.push(0);for(let l=0;l<i.problems.length;l++){const c=i.problems[l];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const f=d.attrs;for(let h=0;h<f.rowspan;h++)o[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,sa(f,f.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+e.nodeSize)}}let s,a;for(let l=0;l<o.length;l++)o[l]&&(s==null&&(s=l),a=l);for(let l=0,c=n+1;l<i.height;l++){const d=e.child(l),f=c+d.nodeSize,h=o[l];if(h>0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);const m=[];for(let g=0;g<h;g++){const b=Kn(t.schema)[p].createAndFill();b&&m.push(b)}const v=(l==0||s==l-1)&&a==l?c+1:f-1;r.insert(r.mapping.map(v),m)}c=f}return r.setMeta(tj,{fixTables:!0})}function Wi(t){const e=t.selection,n=hp(t),r=n.node(-1),i=n.start(-1),o=Qt.get(r);return{...e instanceof Ft?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function tE(t,{map:e,tableStart:n,table:r},i){let o=i>0?-1:0;Y6(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+i;if(i>0&&i<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],c=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,XT(c.attrs,i-e.colCount(l))),s+=c.attrs.rowspan-1}else{const l=o==null?Kn(r.type.schema).cell:r.nodeAt(e.map[a+o]).type,c=e.positionAt(s,i,r);t.insert(t.mapping.map(n+c),l.createAndFill())}}return t}function rj(t,e){if(!gi(t))return!1;if(e){const n=Wi(t);e(tE(t.tr,n,n.left))}return!0}function ij(t,e){if(!gi(t))return!1;if(e){const n=Wi(t);e(tE(t.tr,n,n.right))}return!0}function oj(t,{map:e,table:n,tableStart:r},i){const o=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+i,l=e.map[a],c=n.nodeAt(l),d=c.attrs;if(i>0&&e.map[a-1]==l||i<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(o).map(r+l),null,sa(d,i-e.colCount(l)));else{const f=t.mapping.slice(o).map(r+l);t.delete(f,f+c.nodeSize)}s+=d.rowspan}}function sj(t,e){if(!gi(t))return!1;if(e){const n=Wi(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;oj(r,n,i),i!=n.left;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=Qt.get(o)}e(r)}return!0}function aj(t,e,n){var r;const i=Kn(e.type.schema).header_cell;for(let o=0;o<t.width;o++)if(((r=e.nodeAt(t.map[o+n*t.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function nE(t,{map:e,tableStart:n,table:r},i){let o=n;for(let c=0;c<i;c++)o+=r.child(c).nodeSize;const s=[];let a=i>0?-1:0;aj(e,r,i+a)&&(a=i==0||i==e.height?null:0);for(let c=0,d=e.width*i;c<e.width;c++,d++)if(i>0&&i<e.height&&e.map[d]==e.map[d-e.width]){const f=e.map[d],h=r.nodeAt(f).attrs;t.setNodeMarkup(n+f,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var l;const f=a==null?Kn(r.type.schema).cell:(l=r.nodeAt(e.map[d+a*e.width]))===null||l===void 0?void 0:l.type,h=f==null?void 0:f.createAndFill();h&&s.push(h)}return t.insert(o,Kn(r.type.schema).row.create(null,s)),t}function lj(t,e){if(!gi(t))return!1;if(e){const n=Wi(t);e(nE(t.tr,n,n.top))}return!0}function cj(t,e){if(!gi(t))return!1;if(e){const n=Wi(t);e(nE(t.tr,n,n.bottom))}return!0}function dj(t,{map:e,table:n,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;const s=o+n.child(i).nodeSize,a=t.mapping.maps.length;t.delete(o+r,s+r);const l=new Set;for(let c=0,d=i*e.width;c<e.width;c++,d++){const f=e.map[d];if(!l.has(f)){if(l.add(f),i>0&&f==e.map[d-e.width]){const h=n.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(a).map(f+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<e.height&&f==e.map[d+e.width]){const h=n.nodeAt(f),p=h.attrs,m=h.type.create({...p,rowspan:h.attrs.rowspan-1},h.content),v=e.positionAt(i+1,c,n);t.insert(t.mapping.slice(a).map(r+v),m),c+=p.colspan-1}}}}function uj(t,e){if(!gi(t))return!1;if(e){const n=Wi(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;dj(r,n,i),i!=n.top;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw new RangeError("No table found");n.table=o,n.map=Qt.get(n.table)}e(r)}return!0}function M1(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function fj({width:t,height:e,map:n},r){let i=r.top*t+r.left,o=i,s=(r.bottom-1)*t+r.left,a=i+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[o]==n[o-1]||r.right<t&&n[a]==n[a+1])return!0;o+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[s]==n[s+t])return!0;i++,s++}return!1}function O1(t,e){const n=t.selection;if(!(n instanceof Ft)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Wi(t),{map:i}=r;if(fj(i,r))return!1;if(e){const o=t.tr,s={};let a=me.empty,l,c;for(let d=r.top;d<r.bottom;d++)for(let f=r.left;f<r.right;f++){const h=i.map[d*i.width+f],p=r.table.nodeAt(h);if(!(s[h]||!p))if(s[h]=!0,l==null)l=h,c=p;else{M1(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,{...XT(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const d=l+1+c.content.size,f=M1(c)?l+1:d;o.replaceWith(f+r.tableStart,d+r.tableStart,a)}o.setSelection(new Ft(o.doc.resolve(l+r.tableStart))),e(o)}return!0}function D1(t,e){const n=Kn(t.schema);return hj(({node:r})=>n[r.type.spec.tableRole])(t,e)}function hj(t){return(e,n)=>{const r=e.selection;let i,o;if(r instanceof Ft){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,o=r.$anchorCell.pos}else{var s;if(i=q6(r.$from),!i)return!1;o=(s=oa(r.$from))===null||s===void 0?void 0:s.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let a=i.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const d=Wi(e),f=e.tr;for(let p=0;p<d.right-d.left;p++)l.push(c?{...a,colwidth:c&&c[p]?[c[p]]:null}:a);let h;for(let p=d.top;p<d.bottom;p++){let m=d.map.positionAt(p,d.left,d.table);p==d.top&&(m+=i.nodeSize);for(let v=d.left,g=0;v<d.right;v++,g++)v==d.left&&p==d.top||f.insert(h=f.mapping.map(m+d.tableStart,1),t({node:i,row:p,col:v}).createAndFill(l[g]))}f.setNodeMarkup(o,t({node:i,row:d.top,col:d.left}),l[0]),r instanceof Ft&&f.setSelection(new Ft(f.doc.resolve(r.$anchorCell.pos),h?f.doc.resolve(h):void 0)),n(f)}return!0}}function pj(t,e){return function(n,r){if(!gi(n))return!1;const i=hp(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const o=n.tr;n.selection instanceof Ft?n.selection.forEachCell((s,a)=>{s.attrs[t]!==e&&o.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):o.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(o)}return!0}}function mj(t){return function(e,n){if(!gi(e))return!1;if(n){const r=Kn(e.schema),i=Wi(e),o=e.tr,s=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),a=s.map(l=>i.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&o.setNodeMarkup(i.tableStart+s[l],r.cell,a[l].attrs);if(o.steps.length===0)for(let l=0;l<s.length;l++)o.setNodeMarkup(i.tableStart+s[l],r.header_cell,a[l].attrs);n(o)}return!0}}function I1(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const o=e.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}function dd(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?mj(t):function(n,r){if(!gi(n))return!1;if(r){const i=Kn(n.schema),o=Wi(n),s=n.tr,a=I1("row",o,i),l=I1("column",o,i),c=(t==="column"?a:t==="row"&&l)?1:0,d=t=="column"?{left:0,top:c,right:1,bottom:o.map.height}:t=="row"?{left:c,top:0,right:o.map.width,bottom:1}:o,f=t=="column"?l?i.cell:i.header_cell:t=="row"?a?i.cell:i.header_cell:i.cell;o.map.cellsInRect(d).forEach(h=>{const p=h+o.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,f,m.attrs)}),r(s)}return!0}}dd("row",{useDeprecatedLogic:!0});dd("column",{useDeprecatedLogic:!0});const gj=dd("cell",{useDeprecatedLogic:!0});function vj(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const o=t.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),i=t.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function R1(t){return function(e,n){if(!gi(e))return!1;const r=vj(hp(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(Be.between(i,J6(i))).scrollIntoView())}return!0}}function yj(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function gu(t,e){const n=t.selection;if(!(n instanceof Ft))return!1;if(e){const r=t.tr,i=Kn(t.schema).cell.createAndFill().content;n.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new Ce(i,0,0))}),r.docChanged&&e(r)}return!0}function bj(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,a=[];if(o=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const d=l?0:Math.max(0,n-1),f=l<e.childCount-1?0:Math.max(0,r-1);(d||f)&&(c=_v(Kn(s).row,new Ce(c,d,f)).content),a.push(c)}else if(o=="cell"||o=="header_cell")a.push(n||r?_v(Kn(s).row,new Ce(e,n,r)).content:e);else return null;return wj(s,a)}function wj(t,e){const n=[];for(let i=0;i<e.length;i++){const o=e[i];for(let s=o.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=o.child(s).attrs;for(let c=i;c<i+a;c++)n[c]=(n[c]||0)+l}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(me.empty),n[i]<r){const o=Kn(t).cell.createAndFill(),s=[];for(let a=n[i];a<r;a++)s.push(o);e[i]=e[i].append(me.from(s))}return{height:e.length,width:r,rows:e}}function _v(t,e){const n=t.createAndFill();return new $v(n).replace(0,n.content.size,e).doc}function xj({width:t,height:e,rows:n},r,i){if(t!=r){const o=[],s=[];for(let a=0;a<n.length;a++){const l=n[a],c=[];for(let d=o[a]||0,f=0;d<r;f++){let h=l.child(f%l.childCount);d+h.attrs.colspan>r&&(h=h.type.createChecked(sa(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(me.from(c))}n=s,t=r}if(e!=i){const o=[];for(let s=0,a=0;s<i;s++,a++){const l=[],c=n[a%e];for(let d=0;d<c.childCount;d++){let f=c.child(d);s+f.attrs.rowspan>i&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),l.push(f)}o.push(me.from(l))}n=o,e=i}return{width:t,height:e,rows:n}}function kj(t,e,n,r,i,o,s){const a=t.doc.type.schema,l=Kn(a);let c,d;if(i>e.width)for(let f=0,h=0;f<e.height;f++){const p=n.child(f);h+=p.nodeSize;const m=[];let v;p.lastChild==null||p.lastChild.type==l.cell?v=c||(c=l.cell.createAndFill()):v=d||(d=l.header_cell.createAndFill());for(let g=e.width;g<i;g++)m.push(v);t.insert(t.mapping.slice(s).map(h-1+r),m)}if(o>e.height){const f=[];for(let m=0,v=(e.height-1)*e.width;m<Math.max(e.width,i);m++){const g=m>=e.width?!1:n.nodeAt(e.map[v+m]).type==l.header_cell;f.push(g?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,me.from(f)),p=[];for(let m=e.height;m<o;m++)p.push(h);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),p)}return!!(c||d)}function N1(t,e,n,r,i,o,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let c=i;c<o;c++){const d=s*e.width+c,f=e.map[d];if(e.map[d-e.width]==f){l=!0;const h=n.nodeAt(f),{top:p,left:m}=e.findCell(f);t.setNodeMarkup(t.mapping.slice(a).map(f+r),null,{...h.attrs,rowspan:s-p}),t.insert(t.mapping.slice(a).map(e.positionAt(s,m,n)),h.type.createAndFill({...h.attrs,rowspan:p+h.attrs.rowspan-s})),c+=h.attrs.colspan-1}}return l}function P1(t,e,n,r,i,o,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let c=i;c<o;c++){const d=c*e.width+s,f=e.map[d];if(e.map[d-1]==f){l=!0;const h=n.nodeAt(f),p=e.colCount(f),m=t.mapping.slice(a).map(f+r);t.setNodeMarkup(m,null,sa(h.attrs,s-p,h.attrs.colspan-(s-p))),t.insert(m+h.nodeSize,h.type.createAndFill(sa(h.attrs,0,s-p))),c+=h.attrs.rowspan-1}}return l}function L1(t,e,n,r,i){let o=n?t.doc.nodeAt(n-1):t.doc;if(!o)throw new Error("No table found");let s=Qt.get(o);const{top:a,left:l}=r,c=l+i.width,d=a+i.height,f=t.tr;let h=0;function p(){if(o=n?f.doc.nodeAt(n-1):f.doc,!o)throw new Error("No table found");s=Qt.get(o),h=f.mapping.maps.length}kj(f,s,o,n,c,d,h)&&p(),N1(f,s,o,n,l,c,a,h)&&p(),N1(f,s,o,n,l,c,d,h)&&p(),P1(f,s,o,n,a,d,l,h)&&p(),P1(f,s,o,n,a,d,c,h)&&p();for(let m=a;m<d;m++){const v=s.positionAt(m,l,o),g=s.positionAt(m,c,o);f.replace(f.mapping.slice(h).map(v+n),f.mapping.slice(h).map(g+n),new Ce(i.rows[m-a],0,0))}p(),f.setSelection(new Ft(f.doc.resolve(n+s.positionAt(a,l,o)),f.doc.resolve(n+s.positionAt(d-1,c-1,o)))),e(f)}const _j=Yy({ArrowLeft:vu("horiz",-1),ArrowRight:vu("horiz",1),ArrowUp:vu("vert",-1),ArrowDown:vu("vert",1),"Shift-ArrowLeft":yu("horiz",-1),"Shift-ArrowRight":yu("horiz",1),"Shift-ArrowUp":yu("vert",-1),"Shift-ArrowDown":yu("vert",1),Backspace:gu,"Mod-Backspace":gu,Delete:gu,"Mod-Delete":gu});function Xu(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function vu(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof Ft)return Xu(n,r,Je.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=rE(i,t,e);if(s==null)return!1;if(t=="horiz")return Xu(n,r,Je.near(n.doc.resolve(o.head+e),e));{const a=n.doc.resolve(s),l=ZT(a,t,e);let c;return l?c=Je.near(l,1):e<0?c=Je.near(n.doc.resolve(a.before(-1)),-1):c=Je.near(n.doc.resolve(a.after(-1)),1),Xu(n,r,c)}}}function yu(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof Ft)s=o;else{const l=rE(i,t,e);if(l==null)return!1;s=new Ft(n.doc.resolve(l))}const a=ZT(s.$headCell,t,e);return a?Xu(n,r,new Ft(s.$anchorCell,a)):!1}}function Sj(t,e){const n=t.state.doc,r=oa(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Ft(r))),!0):!1}function Cj(t,e,n){if(!gi(t.state))return!1;let r=bj(n);const i=t.state.selection;if(i instanceof Ft){r||(r={width:1,height:1,rows:[me.from(_v(Kn(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),a=Qt.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=xj(r,a.right-a.left,a.bottom-a.top),L1(t.state,t.dispatch,s,a,r),!0}else if(r){const o=hp(t.state),s=o.start(-1);return L1(t.state,t.dispatch,s,Qt.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function Tj(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=z1(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof Ft)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=oa(t.state.selection.$anchor))!=null&&((n=Tm(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(l,c){let d=Tm(t,c);const f=zo.getState(t.state)==null;if(!d||!vb(l,d))if(f)d=l;else return;const h=new Ft(l,d);if(f||!t.state.selection.eq(h)){const p=t.state.tr.setSelection(h);f&&p.setMeta(zo,l.pos),t.dispatch(p)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),zo.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(zo,-1))}function a(l){const c=l,d=zo.getState(t.state);let f;if(d!=null)f=t.state.doc.resolve(d);else if(z1(t,c.target)!=r&&(f=Tm(t,e),!f))return s();f&&o(f,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function rE(t,e,n){if(!(t.state.selection instanceof Be))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const s=r.before(i),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?s:null}}return null}function z1(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Tm(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&oa(t.state.doc.resolve(r))||oa(t.state.doc.resolve(i))}var Ej=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Sv(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Sv(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Sv(t,e,n,r,i,o){let s=0,a=!0,l=e.firstChild;const c=t.firstChild;if(c){for(let f=0,h=0;f<c.childCount;f++){const{colspan:p,colwidth:m}=c.child(f).attrs;for(let v=0;v<p;v++,h++){const g=i==h?o:m&&m[v],b=g?g+"px":"";if(s+=g||r,g||(a=!1),l)l.style.width!=b&&(l.style.width=b),l=l.nextSibling;else{const x=document.createElement("col");x.style.width=b,e.appendChild(x)}}}for(;l;){var d;const f=l.nextSibling;(d=l.parentNode)===null||d===void 0||d.removeChild(l),l=f}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const Cr=new Et("tableColumnResizing");function Aj({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=Ej,lastColumnResizable:i=!0}={}){const o=new wt({key:Cr,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=Kn(a.schema).table.name;return r&&c&&(c[d]=(f,h)=>new r(f,n,h)),new Mj(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=Cr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{Oj(s,a,t,i)},mouseleave:s=>{Dj(s)},mousedown:(s,a)=>{Ij(s,a,e,n)}},decorations:s=>{const a=Cr.getState(s);if(a&&a.activeHandle>-1)return zj(s,a.activeHandle)},nodeViews:{}}});return o}var Mj=class Qu{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Cr);if(r&&r.setHandle!=null)return new Qu(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Qu(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return kv(e.doc.resolve(i))||(i=-1),new Qu(i,n.dragging)}return n}};function Oj(t,e,n,r){if(!t.editable)return;const i=Cr.getState(t.state);if(i&&!i.dragging){const o=Nj(e.target);let s=-1;if(o){const{left:a,right:l}=o.getBoundingClientRect();e.clientX-a<=n?s=F1(t,e,"left",n):l-e.clientX<=n&&(s=F1(t,e,"right",n))}if(s!=i.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),c=Qt.get(l),d=a.start(-1);if(c.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==c.width-1)return}iE(t,s)}}}function Dj(t){if(!t.editable)return;const e=Cr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&iE(t,-1)}function Ij(t,e,n,r){var i;if(!t.editable)return!1;const o=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,s=Cr.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=Rj(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Cr,{setDragging:{startX:e.clientX,startWidth:l}}));function c(f){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",d);const h=Cr.getState(t.state);h!=null&&h.dragging&&(Pj(t,h.activeHandle,B1(h.dragging,f,n)),t.dispatch(t.state.tr.setMeta(Cr,{setDragging:null})))}function d(f){if(!f.which)return c(f);const h=Cr.getState(t.state);if(h&&h.dragging){const p=B1(h.dragging,f,n);V1(t,h.activeHandle,p,r)}}return V1(t,s.activeHandle,l,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",d),e.preventDefault(),!0}function Rj(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=t.domAtPos(e);let s=o.node.childNodes[o.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(s-=r[l],a--);return s/a}function Nj(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function F1(t,e,n,r){const i=n=="right"?-r:r,o=t.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,a=oa(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=Qt.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 B1(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function iE(t,e){t.dispatch(t.state.tr.setMeta(Cr,{setHandle:e}))}function Pj(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),o=Qt.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let c=0;c<o.height;c++){const d=c*o.width+a;if(c&&o.map[d]==o.map[d-o.width])continue;const f=o.map[d],h=i.nodeAt(f).attrs,p=h.colspan==1?0:a-o.colCount(f);if(h.colwidth&&h.colwidth[p]==n)continue;const m=h.colwidth?h.colwidth.slice():Lj(h.colspan);m[p]=n,l.setNodeMarkup(s+f,null,{...h,colwidth:m})}l.docChanged&&t.dispatch(l)}function V1(t,e,n,r){const i=t.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),a=Qt.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let l=t.domAtPos(i.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Sv(o,l.firstChild,l,r,a,n)}function Lj(t){return Array(t).fill(0)}function zj(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return Xe.empty;const o=Qt.get(i),s=r.start(-1),a=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const d=a+c*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(c==0||o.map[d]!=o.map[d-o.width])){var l;const f=o.map[d],h=s+f+i.nodeAt(f).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((l=Cr.getState(t))===null||l===void 0)&&l.dragging&&n.push(Rt.node(s+f,s+f+i.nodeAt(f).nodeSize,{class:"column-resize-dragging"})),n.push(Rt.widget(h,p))}}return Xe.create(t.doc,n)}function Fj({allowTableNodeSelection:t=!1}={}){return new wt({key:zo,state:{init(){return null},apply(e,n){const r=e.getMeta(zo);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:o}=e.mapping.mapResult(n);return i?null:o}},props:{decorations:X6,handleDOMEvents:{mousedown:Tj},createSelectionBetween(e){return zo.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Sj,handleKeyDown:_j,handlePaste:Cj},appendTransaction(e,n,r){return ej(r,eE(r,n),t)}})}function Cv(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function H1(t,e,n,r,i,o){var s;let a=0,l=!0,c=e.firstChild;const d=t.firstChild;if(d!==null)for(let f=0,h=0;f<d.childCount;f+=1){const{colspan:p,colwidth:m}=d.child(f).attrs;for(let v=0;v<p;v+=1,h+=1){const g=i===h?o:m&&m[v],b=g?`${g}px`:"";if(a+=g||r,g||(l=!1),c){if(c.style.width!==b){const[x,_]=Cv(r,g);c.style.setProperty(x,_)}c=c.nextSibling}else{const x=document.createElement("col"),[_,A]=Cv(r,g);x.style.setProperty(_,A),e.appendChild(x)}}}for(;c;){const f=c.nextSibling;(s=c.parentNode)===null||s===void 0||s.removeChild(c),c=f}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class Bj{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),H1(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,H1(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Vj(t,e,n,r){let i=0,o=!0;const s=[],a=t.firstChild;if(!a)return{};for(let f=0,h=0;f<a.childCount;f+=1){const{colspan:p,colwidth:m}=a.child(f).attrs;for(let v=0;v<p;v+=1,h+=1){const g=n===h?r:m&&m[v];i+=g||e,g||(o=!1);const[b,x]=Cv(e,g);s.push(["col",{style:`${b}: ${x}`}])}}const l=o?`${i}px`:"",c=o?"":`${i}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:c}}function U1(t,e){return t.createAndFill()}function Hj(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function Uj(t,e,n,r,i){const o=Hj(t),s=[],a=[];for(let c=0;c<n;c+=1){const d=U1(o.cell);if(d&&a.push(d),r){const f=U1(o.header_cell);f&&s.push(f)}}const l=[];for(let c=0;c<e;c+=1)l.push(o.row.createChecked(null,r&&c===0?s:a));return o.table.createChecked(null,l)}function jj(t){return t instanceof Ft}const bu=({editor:t})=>{const{selection:e}=t.state;if(!jj(e))return!1;let n=0;const r=PT(e.ranges[0].$from,o=>o.type.name==="table");return r==null||r.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Wj=rr.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Bj,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=Vj(t,this.options.cellMinWidth),o=["table",tn(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${i}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:o})=>{const s=Uj(o.schema,t,e,n);if(i){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Be.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>rj(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>ij(t,e),deleteColumn:()=>({state:t,dispatch:e})=>sj(t,e),addRowBefore:()=>({state:t,dispatch:e})=>lj(t,e),addRowAfter:()=>({state:t,dispatch:e})=>cj(t,e),deleteRow:()=>({state:t,dispatch:e})=>uj(t,e),deleteTable:()=>({state:t,dispatch:e})=>yj(t,e),mergeCells:()=>({state:t,dispatch:e})=>O1(t,e),splitCell:()=>({state:t,dispatch:e})=>D1(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>dd("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>dd("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>gj(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>O1(t,e)?!0:D1(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>pj(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>R1(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>R1(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&eE(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Ft.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:bu,"Mod-Backspace":bu,Delete:bu,"Mod-Delete":bu}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Aj({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Fj({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:st(Ie(t,"tableRole",e))}}}),Kj=rr.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",tn(this.options.HTMLAttributes,t),0]}}),qj=rr.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",tn(this.options.HTMLAttributes,t),0]}}),Gj=rr.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",tn(this.options.HTMLAttributes,t),0]}}),Jj=/^\s*>\s$/,Yj=rr.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",tn(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[sd({find:Jj,type:this.type})]}}),Zj=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Xj=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Qj=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,$j=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,e8=Vi.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",tn(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ia({find:Zj,type:this.type}),ia({find:Qj,type:this.type})]},addPasteRules(){return[ls({find:Xj,type:this.type}),ls({find:$j,type:this.type})]}}),t8="listItem",j1="textStyle",W1=/^\s*([-+*])\s$/,n8=rr.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",tn(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(t8,this.editor.getAttributes(j1)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=sd({find:W1,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=sd({find:W1,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(j1),editor:this.editor})),[t]}}),r8=/(^|[^`])`([^`]+)`(?!`)/,i8=/(^|[^`])`([^`]+)`(?!`)/g,o8=Vi.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",tn(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ia({find:r8,type:this.type})]},addPasteRules(){return[ls({find:i8,type:this.type})]}}),s8=/^```([a-z]+)?[\s\n]$/,a8=/^~~~([a-z]+)?[\s\n]$/,l8=rr.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,o=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",tn(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
|
|
186
|
+
|
|
187
|
+
`);return!o||!s?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:o}=n;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const a=i.after();return a===void 0?!1:r.nodeAt(a)?t.commands.command(({tr:c})=>(c.setSelection(Je.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[sv({find:s8,type:this.type,getAttributes:t=>({language:t[1]})}),sv({find:a8,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new wt({key:new Et("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i==null?void 0:i.mode;if(!n||!o)return!1;const{tr:s,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,`
|
|
188
|
+
`));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Be.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),c8=rr.create({name:"doc",topNode:!0,content:"block+"});function d8(t={}){return new wt({view(e){return new u8(e,t)}})}class u8{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,a=o.height/i.offsetHeight;if(n){let f=e.nodeBefore,h=e.nodeAfter;if(f||h){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let m=p.getBoundingClientRect(),v=f?m.bottom:m.top;f&&h&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:m.left,right:m.right,top:v-g,bottom:v+g}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;r={left:f.left-h,right:f.left+h,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let f=l.getBoundingClientRect(),h=f.width/l.offsetWidth,p=f.height/l.offsetHeight;c=f.left-l.scrollLeft*h,d=f.top-l.scrollTop*p}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/a+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!o){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=p_(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 f8=Bt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[d8(this.options)]}});class Zt extends Je{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Zt.valid(r)?new Zt(r):Je.near(r)}content(){return Ce.empty}eq(e){return e instanceof Zt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Zt(e.resolve(n.pos))}getBookmark(){return new yb(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!h8(e)||!p8(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Zt.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let a=e.node(s);if(n>0?e.indexAfter(s)<a.childCount:e.index(s)>0){o=a.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let l=e.doc.resolve(i);if(Zt.valid(l))return l}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!Ue.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let a=e.doc.resolve(i);if(Zt.valid(a))return a}return null}}}Zt.prototype.visible=!1;Zt.findFrom=Zt.findGapCursorFrom;Je.jsonID("gapcursor",Zt);class yb{constructor(e){this.pos=e}map(e){return new yb(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Zt.valid(n)?new Zt(n):Je.near(n)}}function oE(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function h8(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||oE(i.type))return!0;if(i.inlineContent)return!1}}return!0}function p8(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||oE(i.type))return!0;if(i.inlineContent)return!1}}return!0}function m8(){return new wt({props:{decorations:b8,createSelectionBetween(t,e,n){return e.pos==n.pos&&Zt.valid(n)?new Zt(n):null},handleClick:v8,handleKeyDown:g8,handleDOMEvents:{beforeinput:y8}}})}const g8=Yy({ArrowLeft:wu("horiz",-1),ArrowRight:wu("horiz",1),ArrowUp:wu("vert",-1),ArrowDown:wu("vert",1)});function wu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,a=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Be){if(!o.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=Zt.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new Zt(c))),!0):!1}}function v8(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Zt.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Ue.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Zt(r))),!0)}function y8(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Zt))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=me.empty;for(let s=r.length-1;s>=0;s--)i=me.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new Ce(i,0,0));return o.setSelection(Be.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function b8(t){if(!(t.selection instanceof Zt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Xe.create(t.doc,[Rt.widget(t.selection.head,e,{key:"gapcursor"})])}const w8=Bt.create({name:"gapCursor",addProseMirrorPlugins(){return[m8()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=st(Ie(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),x8=rr.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",tn(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
189
|
+
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:o}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:a}=r.extensionManager,l=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&s){const f=l.filter(h=>a.includes(h.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),k8=rr.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,tn(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>sv({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var yh=200,wn=function(){};wn.prototype.append=function(e){return e.length?(e=wn.from(e),!this.length&&e||e.length<yh&&this.leafAppend(e)||this.length<yh&&e.leafPrepend(this)||this.appendInner(e)):this};wn.prototype.prepend=function(e){return e.length?wn.from(e).append(this):this};wn.prototype.appendInner=function(e){return new _8(this,e)};wn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?wn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};wn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};wn.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};wn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},n,r),i};wn.from=function(e){return e instanceof wn?e:e&&e.length?new sE(e):wn.empty};var sE=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,a){for(var l=o;l<s;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,a){for(var l=o-1;l>=s;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=yh)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=yh)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(wn);wn.empty=new sE([]);var _8=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var a=this.left.length;if(i<a&&this.left.forEachInner(r,i,Math.min(o,a),s)===!1||o>a&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,o)-a,s+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(o,a)-a,s+a)===!1||o<a&&this.left.forEachInvertedInner(r,Math.min(i,a),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(wn);const S8=500;class si{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,a,l,c=[],d=[];return this.items.forEach((f,h)=>{if(!f.step){i||(i=this.remapping(r,h+1),o=i.maps.length),o--,d.push(f);return}if(i){d.push(new xi(f.map));let p=f.step.map(i.slice(o)),m;p&&s.maybeStep(p).doc&&(m=s.mapping.maps[s.mapping.maps.length-1],c.push(new xi(m,void 0,void 0,c.length+d.length))),o--,m&&i.appendMap(m,o)}else s.maybeStep(f.step);if(f.selection)return a=i?f.selection.map(i.slice(o)):f.selection,l=new si(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:a}}addTransform(e,n,r,i){let o=[],s=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),h=new xi(e.mapping.maps[d],f,n),p;(p=l&&l.merge(h))&&(h=p,d?o.pop():a=a.slice(0,a.length-1)),o.push(h),n&&(s++,n=void 0),i||(l=h)}let c=s-r.depth;return c>T8&&(a=C8(a,c),s-=c),new si(a.append(o),s)}remapping(e,n){let r=new zc;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new si(this.items.append(e.map(n=>new xi(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=e.mapping,s=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},i);let l=n;this.items.forEach(h=>{let p=o.getMirror(--l);if(p==null)return;s=Math.min(s,p);let m=o.maps[p];if(h.step){let v=e.steps[p].invert(e.docs[p]),g=h.selection&&h.selection.map(o.slice(l+1,p));g&&a++,r.push(new xi(m,v,g))}else r.push(new xi(m))},i);let c=[];for(let h=n;h<s;h++)c.push(new xi(o.maps[h]));let d=this.items.slice(0,i).append(c).append(r),f=new si(d,a);return f.emptyItemCount()>S8&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((s,a)=>{if(a>=e)i.push(s),s.selection&&o++;else if(s.step){let l=s.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let d=s.selection&&s.selection.map(n.slice(r));d&&o++;let f=new xi(c.invert(),l,d),h,p=i.length-1;(h=i.length&&i[p].merge(f))?i[p]=h:i.push(f)}}else s.map&&r--},this.items.length,0),new si(wn.from(i.reverse()),o)}}si.empty=new si(wn.empty,0);function C8(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class xi{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new xi(n.getMap().invert(),n,this.selection)}}}class Ro{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const T8=20;function E8(t,e,n,r){let i=n.getMeta(Ks),o;if(i)return i.historyState;n.getMeta(O8)&&(t=new Ro(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Ks))return s.getMeta(Ks).redo?new Ro(t.done.addTransform(n,void 0,r,$u(e)),t.undone,K1(n.mapping.maps),t.prevTime,t.prevComposition):new Ro(t.done,t.undone.addTransform(n,void 0,r,$u(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!A8(n,t.prevRanges)),c=s?Em(t.prevRanges,n.mapping):K1(n.mapping.maps);return new Ro(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,$u(e)),si.empty,c,n.time,a??t.prevComposition)}else return(o=n.getMeta("rebased"))?new Ro(t.done.rebased(n,o),t.undone.rebased(n,o),Em(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ro(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Em(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function A8(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(n=!0)}),n}function K1(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,o,s)=>e.push(o,s));return e}function Em(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),o=e.map(t[r+1],-1);i<=o&&n.push(i,o)}return n}function M8(t,e,n){let r=$u(e),i=Ks.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),l=new Ro(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(Ks,{redo:n,historyState:l})}let Am=!1,q1=null;function $u(t){let e=t.plugins;if(q1!=e){Am=!1,q1=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Am=!0;break}}return Am}const Ks=new Et("history"),O8=new Et("closeHistory");function D8(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new wt({key:Ks,state:{init(){return new Ro(si.empty,si.empty,null,0,-1)},apply(e,n,r){return E8(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?lE:r=="historyRedo"?cE:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function aE(t,e){return(n,r)=>{let i=Ks.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=M8(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const lE=aE(!1,!0),cE=aE(!0,!0),I8=Bt.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>lE(t,e),redo:()=>({state:t,dispatch:e})=>cE(t,e)}},addProseMirrorPlugins(){return[D8(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()}}}),R8=rr.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",tn(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!SU(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$from:r,$to:i}=n,o=t();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):KH(n)?o.insertContentAt(i.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:s,dispatch:a})=>{var l;if(a){const{$to:c}=s.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(Be.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(Ue.create(s.doc,c.pos)):s.setSelection(Be.create(s.doc,c.pos));else{const f=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();f&&(s.insert(d,f),s.setSelection(Be.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[_U({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),N8=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,P8=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,L8=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,z8=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,F8=Vi.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",tn(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ia({find:N8,type:this.type}),ia({find:L8,type:this.type})]},addPasteRules(){return[ls({find:P8,type:this.type}),ls({find:z8,type:this.type})]}}),B8=rr.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",tn(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),V8="listItem",G1="textStyle",J1=/^(\d+)\.\s$/,H8=rr.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",tn(this.options.HTMLAttributes,n),0]:["ol",tn(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(V8,this.editor.getAttributes(G1)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=sd({find:J1,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=sd({find:J1,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(G1)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),U8=rr.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",tn(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),j8=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,W8=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,K8=Vi.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",tn(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ia({find:j8,type:this.type})]},addPasteRules(){return[ls({find:W8,type:this.type})]}}),q8=rr.create({name:"text",group:"inline"}),G8=Bt.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(e8.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(Yj.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(n8.configure(this.options.bulletList)),this.options.code!==!1&&t.push(o8.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(l8.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(c8.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(f8.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(w8.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(x8.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(k8.configure(this.options.heading)),this.options.history!==!1&&t.push(I8.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(R8.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(F8.configure(this.options.italic)),this.options.listItem!==!1&&t.push(B8.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(H8.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(U8.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(K8.configure(this.options.strike)),this.options.text!==!1&&t.push(q8.configure(this.options.text)),t}}),tc=new Et("tandemAnnotations");function Mm(t,e,n){const r=[],i=t.content.size;return e.forEach(o=>{const s=ta(o,f=>{console.warn("[sanitize]",f)});if(s.status!=="pending"||!s.range&&!s.relRange)return;const a=Xc(s,t,n);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 f=Tk(s.color),h=Ic[f];d={class:`tandem-highlight tandem-highlight--${f}`,style:`background: ${h}; border-radius: var(--tandem-r-1); padding: 1px 0;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Highlight annotation (${f})`};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-type":s.type,"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-type":s.type,"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-type":s.type,"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-type":s.type,"data-annotation-author":s.author,"aria-label":"Note annotation"};break;default:{console.warn("[annotation] Unhandled annotation type in buildDecorations, skipping");return}}try{r.push(Rt.inline(l,c,d))}catch(f){if(!(f instanceof RangeError))throw f;console.debug("[annotation] RangeError for %s (from=%d, to=%d), skipping",s.id,l,c)}}),Xe.create(t,r)}const J8=Bt.create({name:"tandemAnnotations",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(xo);let n=e.size>0,r=!1,i=!0;try{localStorage.getItem(Rk)==="false"&&(i=!1)}catch(o){console.warn("[annotation] localStorage unavailable",o)}return[new wt({key:tc,state:{init(o,s){return i?Mm(s.doc,e,t):Xe.empty},apply(o,s,a,l){const c=o.getMeta(tc);if(c&&typeof c=="object"&&c.type==="toggle-decorations"&&(i=c.visible),c)return i?Mm(l.doc,e,t):Xe.empty;if(!i)return Xe.empty;if(o.docChanged){if(!r&&s===Xe.empty&&n){const d=Mm(l.doc,e,t);return d!==Xe.empty&&(r=!0),d}return s.map(o.mapping,o.doc)}return s}},props:{decorations(o){return tc.getState(o)}},view(o){let s=null,a=!1;function l(){s===null&&(s=requestAnimationFrame(()=>{s=null,a=!0;const f=o.state.tr.setMeta(tc,!0);o.dispatch(f)}))}const c=()=>{n=e.size>0,r=!1,l()};e.observe(c);const d=setTimeout(()=>{!a&&s===null&&e.size>0&&c()},500);return{destroy(){clearTimeout(d),s!==null&&cancelAnimationFrame(s),e.unobserve(c)}}}})]}}),Ta=new Et("tandemAuthorship"),Y8=new Set(["paragraph","heading"]);function Z8(t,e,n){if(t.relRange){const r=iC(n,e,t.relRange);if(r&&r.from<r.to)return r}if(t.range){console.warn("[authorship] Falling back to flat offsets for range",t.id);const r=ss(e,t.range.from),i=ss(e,t.range.to);if(r<i)return{from:r,to:i}}return null}function Om(t,e,n,r){if(!r)return Xe.empty;const i=[],o=t.content.size,s=[];return e.forEach(a=>{const l=a;if(!l.author||!l.range||l.author!=="user"&&l.author!=="claude")return;const c=Z8(l,t,n);if(!c)return;const{from:d,to:f}=c;if(!(d>=f||d<0||f>o)){try{i.push(Rt.inline(d,f,{"data-tandem-author":l.author}))}catch(h){if(!(h instanceof RangeError))throw h;console.warn("[authorship] Decoration RangeError for entry",l.id,h)}s.push({author:l.author,from:d,to:f})}}),t.descendants((a,l)=>{if(!Y8.has(a.type.name))return;const c=l,d=l+a.nodeSize;let f=0,h=0;for(const m of s){const v=Math.max(m.from,c),g=Math.min(m.to,d);if(g<=v)continue;const b=g-v;m.author==="user"?f+=b:h+=b}if(f===0&&h===0||a.content.size===0)return;const p=f>=h?"user":"claude";try{i.push(Rt.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)}}),Xe.create(t,i)}const X8=Bt.create({name:"tandemAuthorship",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(fw);let n=!1;try{n=localStorage.getItem(Ik)==="true"}catch(r){console.warn("[authorship] localStorage unavailable",r)}return[new wt({key:Ta,state:{init(r,i){return{visible:n,decorations:Om(i.doc,e,t,n)}},apply(r,i,o,s){const a=r.getMeta(Ta);if((a==null?void 0:a.type)==="toggle"){const l=a.visible;return{visible:l,decorations:Om(s.doc,e,t,l)}}return(a==null?void 0:a.type)==="rebuild"?{visible:i.visible,decorations:Om(s.doc,e,t,i.visible)}:r.docChanged&&i.visible?{visible:i.visible,decorations:i.decorations.map(r.mapping,r.doc)}:i}},props:{decorations(r){var i;return((i=Ta.getState(r))==null?void 0:i.decorations)??Xe.empty}},view(r){const i=()=>{const s=r.state.tr.setMeta(Ta,{type:"rebuild"});r.dispatch(s)};e.observe(i);const o=setTimeout(()=>{e.size>0&&i()},500);return{destroy(){clearTimeout(o),e.unobserve(i)}}}})]},onTransaction({transaction:t}){const e=this.options.ydoc;if(!e||t.getMeta("y-sync$")||t.getMeta(Ta)||!t.docChanged)return;const n=e.getMap(fw),r=t.doc;t.steps.forEach(i=>{i.getMap().forEach((s,a,l,c)=>{if(c-l-(a-s)>0)try{const f=Mi(r,Mn(l)),h=Mi(r,Mn(c));if(h<=f)return;const p=yM("user"),m={id:p,author:"user",range:{from:f,to:h},timestamp:Date.now()};n.set(p,m)}catch(f){console.warn("[authorship] Position conversion failed during user attribution",f)}})})}}),xu=new Et("tandemAwareness");function Y1(t,e){if(!e)return Xe.empty;const n=[],{focusParagraph:r,focusOffset:i,active:o}=e;if(r!==null&&r>=0){let s=0;t.forEach((a,l)=>{s===r&&n.push(Rt.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=ss(t,Lu(i)),a=o===!1?" tandem-claude-cursor-idle":"";n.push(Rt.widget(s,()=>{const l=document.createElement("span");l.className=`tandem-claude-cursor${a}`,l.setAttribute("aria-hidden","true");const c=document.createElement("span");return c.className="tandem-claude-cursor-label",c.textContent="AI",l.appendChild(c),l}))}catch(s){console.warn("[awareness] cursor decoration failed, falling back to gutter-only:",s)}return n.length===0?Xe.empty:Xe.create(t,n)}const Q8=Bt.create({name:"tandemAwareness",addOptions(){return{ydoc:null}},addProseMirrorPlugins(){const t=this.options.ydoc;if(!t)return[];const e=t.getMap(Ok),n=t.getMap(fg);return[new wt({key:xu,state:{init(r,i){const o=e.get(hg);return Y1(i.doc,o??null)},apply(r,i,o,s){if(r.getMeta(xu)){const a=e.get(hg);return Y1(s.doc,a??null)}return r.docChanged?i.map(r.mapping,r.doc):i}},props:{decorations(r){return xu.getState(r)}},view(r){const i=()=>{const o=r.state.tr.setMeta(xu,!0);r.dispatch(o)};return e.observe(i),{destroy(){e.unobserve(i)}}}}),new wt({key:new Et("tandemUserAwareness"),view(){let r=null,i=null,o=null,s=!1,a=-1;return{update(l,c){const{state:d}=l;if(!d.selection.eq(c.selection)){const f=oC(d.doc,{from:Mn(d.selection.from),to:Mn(d.selection.to)});if(d.selection.from===d.selection.to)o&&(clearTimeout(o),o=null),n.set(hw,{...f,timestamp:Date.now()});else{const h=d.doc.textBetween(d.selection.from,d.selection.to,`
|
|
190
|
+
`),p=h.length>200?h.slice(0,197)+"...":h;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n.set(hw,{...f,selectedText:p,timestamp:Date.now()})},150)}}d.doc!==c.doc&&(a=d.selection.from,s=!0,i||(i=setTimeout(()=>{i=null,s&&n.set(pw,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200)),r&&clearTimeout(r),r=setTimeout(()=>{s=!1,n.set(pw,{isTyping:!1,cursor:l.state.selection.from,lastEdit:Date.now()})},RM))},destroy(){r&&clearTimeout(r),i&&clearTimeout(i),o&&clearTimeout(o)}}}})]}}),ki=new Et("tandemFindReplace"),dE={query:"",caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:Xe.empty};function $8(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eW(t){if(!t.query)return null;try{const e=t.regexMode?t.query:$8(t.query),n=t.caseSensitive?"g":"gi",r=t.wholeWord?`\\b${e}\\b`:e;return new RegExp(r,n)}catch{return null}}function uE(t,e){const n=eW(e);if(!n)return[];const r=[];return t.descendants((i,o)=>{if(!i.isTextblock)return;const s=i.textContent;for(const a of s.matchAll(n)){const l=a.index??0;r.push({from:o+1+l,to:o+1+l+a[0].length})}}),r}function _c(t,e,n){if(e.length===0)return Xe.empty;const r=[];for(let i=0;i<e.length;i++){const{from:o,to:s}=e[i];try{r.push(Rt.inline(o,s,{class:i===n?"tandem-find-active":"tandem-find-match"}))}catch{}}return Xe.create(t,r)}function Tv(t,e){if(t.length===0)return-1;for(let n=0;n<t.length;n++)if(t[n].from<=e&&e<=t[n].to)return n;for(let n=0;n<t.length;n++)if(t[n].from>e)return n;return 0}function tW(t,e,n){if(t.type==="close")return dE;if(t.type==="find"){const i=t.opts,o=uE(n.doc,i),s=n.selection.from,a=Tv(o,s);return{...i,matches:o,activeIndex:a,decoSet:_c(n.doc,o,a)}}if(t.type==="next"){const i=e.matches.length===0?-1:(e.activeIndex+1)%e.matches.length;return{...e,activeIndex:i,decoSet:_c(n.doc,e.matches,i)}}if(t.type==="prev"){const i=e.matches.length===0?-1:(e.activeIndex-1+e.matches.length)%e.matches.length;return{...e,activeIndex:i,decoSet:_c(n.doc,e.matches,i)}}return t}const nW=Bt.create({name:"tandemFindReplace",addProseMirrorPlugins(){return[new wt({key:ki,state:{init:()=>dE,apply(t,e,n,r){const i=t.getMeta(ki);if(i)return tW(i,e,r);if(!e.query)return e;if(t.docChanged){const a=uE(r.doc,e),l=r.selection.from,c=Tv(a,l);return{...e,matches:a,activeIndex:c,decoSet:_c(r.doc,a,c)}}const o=r.selection.from,s=Tv(e.matches,o);return s===e.activeIndex?e:{...e,activeIndex:s,decoSet:_c(r.doc,e.matches,s)}}},props:{decorations(t){var e;return((e=ki.getState(t))==null?void 0:e.decoSet)??Xe.empty}}})]},addCommands(){return{find:t=>({dispatch:e,tr:n})=>(e&&e(n.setMeta(ki,{type:"find",opts:t})),!0),findNext:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(ki,{type:"next"})),!0),findPrev:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(ki,{type:"prev"})),!0),findClose:()=>({dispatch:t,tr:e})=>(t&&t(e.setMeta(ki,{type:"close"})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:t})=>{const e=ki.getState(t.state);return e!=null&&e.query?(t.commands.findClose(),!0):!1}}}});function Wa(t){return ki.getState(t)}function rW(t,e){const n=Wa(t.state);if(!n||n.activeIndex<0||n.matches.length===0)return!1;const{from:r,to:i}=n.matches[n.activeIndex],o=t.state.tr.insertText(e,r,i).setMeta(ki,{type:"next"});return t.dispatch(o),!0}async function iW(t,e,n){let i=0,o=!1;for(let s=0;s<50;s++){const a=Wa(t.state);if(!(a!=null&&a.query)||a.matches.length===0)break;const l=a.matches.slice(0,100);try{let c=t.state.tr;for(let d=l.length-1;d>=0;d--){const{from:f,to:h}=l[d];c=c.insertText(e,f,h)}t.dispatch(c),i+=l.length,n==null||n(i,i+(a.matches.length-l.length))}catch(c){o=!0,console.warn("[find-replace] replaceAll chunk failed at pass",s,c);break}if(l.length<100)break;await new Promise(c=>setTimeout(c,0))}return{replaced:i,partial:o}}const gs=new Et("tandemHeadingCollapse"),oW="tandem:headingCollapse:";function fE(t){return!t||t.startsWith("upload://")?null:oW+t}function Z1(t){const e=fE(t);if(!e)return new Set;try{const n=window.localStorage.getItem(e);if(!n)return new Set;const r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(i=>typeof i=="string")):new Set}catch{return new Set}}function bh(t,e){const n=fE(t);if(n)try{e.size===0?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(Array.from(e)))}catch{}}function sW(t){return t.trim().toLowerCase().replace(/\s+/g," ")}function Dm(t){const e=[],n=new Map;return t.descendants((r,i,o)=>{if(r.type.name!=="heading")return!0;if(o!==t)return!1;const s=r.attrs.level??1,a=sW(r.textContent),l=`${s}::${a}`,c=n.get(l)??0;n.set(l,c+1);const d=`${l}::${c}`;return e.push({pos:i,level:s,hash:d}),!1}),e}function aW(t,e,n,r){if(n.size===0)return n;const i=new Set(e.map(a=>a.hash));if(t.length===e.length){const a=[];for(let h=0;h<t.length;h++)t[h].hash!==e[h].hash&&a.push(h);if(a.length!==1)return n;const l=a[0],c=t[l].hash,d=e[l].hash;if(!n.has(c))return n;const f=new Set(n);return f.delete(c),f.add(d),bh(r,f),f}if(e.length>t.length||e.length===0)return n;let o=!1;const s=new Set;for(const a of n)i.has(a)?s.add(a):o=!0;return o?(bh(r,s),s):n}function lW(t,e,n){return Rt.widget(t+1,r=>{const i=document.createElement("button");return i.type="button",i.className="tandem-heading-chevron",i.dataset.testid="heading-chevron",i.dataset.headingHash=e,i.dataset.collapsed=String(n),i.setAttribute("aria-label",n?"Expand section":"Collapse section"),i.setAttribute("aria-expanded",String(!n)),i.contentEditable="false",i.textContent=n?"▶":"▼",i.addEventListener("mousedown",o=>{o.preventDefault()}),i.addEventListener("click",o=>{o.stopPropagation(),o.preventDefault();const s=r.state.tr.setMeta(gs,{type:"toggle",hash:e});r.dispatch(s)}),i},{side:-1,ignoreSelection:!0,stopEvent:()=>!0,key:`chevron:${e}:${n?"c":"e"}`})}function cW(t,e,n){const r=e[n];let i=t.content.size;for(let s=n+1;s<e.length;s++)if(e[s].level<=r.level){i=e[s].pos;break}const o=[];return t.forEach((s,a)=>{if(a>r.pos&&a<i){const l=a,c=a+s.nodeSize;o.push(Rt.node(l,c,{class:"tandem-heading-collapsed-hidden",style:"display: none;"}))}}),o}function ku(t,e,n){const r=[];for(let i=0;i<e.length;i++){const o=e[i],s=n.has(o.hash);try{r.push(lW(o.pos,o.hash,s)),s&&r.push(...cW(t,e,i))}catch{}}return r.length===0?Xe.empty:Xe.create(t,r)}const dW=Bt.create({name:"tandemHeadingCollapse",addOptions(){return{filePath:null}},addProseMirrorPlugins(){const t=this.options.filePath;return[new wt({key:gs,state:{init(e,n){const r=Z1(t),i=Dm(n.doc);return{collapsed:r,headings:i,decoSet:ku(n.doc,i,r),hasSeenContent:i.length>0}},apply(e,n,r,i){const o=e.getMeta(gs);if((o==null?void 0:o.type)==="toggle"){const c=new Set(n.collapsed);return c.has(o.hash)?c.delete(o.hash):c.add(o.hash),bh(t,c),{collapsed:c,headings:n.headings,decoSet:ku(i.doc,n.headings,c),hasSeenContent:n.hasSeenContent}}if((o==null?void 0:o.type)==="rehydrate"){const c=Dm(i.doc),d=Z1(t),f=new Set(c.map(p=>p.hash)),h=new Set;for(const p of d)f.has(p)&&h.add(p);return h.size!==d.size&&bh(t,h),{collapsed:h,headings:c,decoSet:ku(i.doc,c,h),hasSeenContent:!0}}if(!e.docChanged)return n;const s=Dm(i.doc),a=n.hasSeenContent||s.length>0;let l=n.collapsed;return n.hasSeenContent&&(l=aW(n.headings,s,n.collapsed,t)),{collapsed:l,headings:s,decoSet:ku(i.doc,s,l),hasSeenContent:a}}},view(e){let n=!1,r=null;function i(){n||r!==null||(r=requestAnimationFrame(()=>{if(r=null,n)return;const o=gs.getState(e.state);if(!o||o.headings.length===0)return;n=!0;const s=e.state.tr.setMeta(gs,{type:"rehydrate"}).setMeta("addToHistory",!1);e.dispatch(s)}))}return i(),{update(o){if(n)return;const s=gs.getState(o.state);!s||s.headings.length===0||i()},destroy(){r!==null&&cancelAnimationFrame(r)}}},props:{decorations(e){var n;return((n=gs.getState(e))==null?void 0:n.decoSet)??Xe.empty}}})]}}),uW=Bt.create({name:"markdownHtml",addGlobalAttributes(){return[{types:["paragraph"],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}}]}}),fW=new Et("tandemSelectionDecoration"),hW=Bt.create({name:"tandemSelectionDecoration",addProseMirrorPlugins(){return[new wt({key:fW,props:{decorations(t){const{selection:e}=t;if(!(e instanceof Be))return Xe.empty;const{from:n,to:r}=e;return n===r?Xe.empty:Xe.create(t.doc,[Rt.inline(n,r,{class:"tandem-selection-blurred"})])}}})]}});function Ao(t){return t.chain().focus()}const X1=[{id:"heading-1",label:"Heading 1",keywords:["h1","heading","title"],run:t=>Ao(t).toggleHeading({level:1}).run()},{id:"heading-2",label:"Heading 2",keywords:["h2","heading","subtitle"],run:t=>Ao(t).toggleHeading({level:2}).run()},{id:"heading-3",label:"Heading 3",keywords:["h3","heading","subheading"],run:t=>Ao(t).toggleHeading({level:3}).run()},{id:"bullet-list",label:"Bullet list",keywords:["bullet","ul","list"],run:t=>Ao(t).toggleBulletList().run()},{id:"numbered-list",label:"Numbered list",keywords:["numbered","ordered","ol","list"],run:t=>Ao(t).toggleOrderedList().run()},{id:"quote",label:"Quote",keywords:["blockquote","quote"],run:t=>Ao(t).toggleBlockquote().run()},{id:"code-block",label:"Code block",keywords:["code","pre","snippet"],run:t=>Ao(t).toggleCodeBlock().run()},{id:"horizontal-rule",label:"Horizontal rule",keywords:["hr","divider","rule","separator"],run:t=>Ao(t).setHorizontalRule().run()}];function pW(t){const e=/(?:^|\s)\/([A-Za-z0-9 -]*)$/.exec(t);if(!e)return null;const n=e[1]??"";return{fromOffset:t.length-n.length-1,query:n}}function pp(t){const e=t.trim().toLowerCase();return e?X1.filter(n=>[n.label,...n.keywords].join(" ").toLowerCase().includes(e)):X1}const mW=["popup-annotation-input","popup-note-submit","popup-comment-submit","popup-highlight-yellow","popup-highlight-green","popup-highlight-blue","popup-highlight-pink"];function gW(t){const e=document.querySelector(`[data-testid="${t}"]`);return e?document.activeElement===e:!1}function vW(t){for(const e of t)if(document.querySelector(`[data-testid="${e}"]`))return!0;return!1}function yW(){return typeof document>"u"?!1:!!(gW("find-input")||document.querySelector('[data-testid="command-palette"]')||vW(mW))}const eo=new Et("tandemSlashCommand");function hE(t){return`${t.from}:${t.to}:${t.query}`}function Q1(t,e=0){if(yW())return null;const{selection:n}=t;if(!n.empty)return null;const r=n.$from,i=r.parent.textBetween(0,r.parentOffset,`
|
|
191
|
+
`,`
|
|
192
|
+
`),o=pW(i);if(!o)return null;const s=r.start()+o.fromOffset,a=r.pos,l=pp(o.query);return l.length===0?null:{from:s,to:a,query:o.query,selectedIndex:Math.min(e,l.length-1)}}function bW(t,e){const n=t.getMeta(eo);return n?n.type==="close"?{active:null,dismissedKey:e.active?hE(e.active):e.dismissedKey}:n.type==="select"&&e.active?{...e,active:{...e.active,selectedIndex:n.selectedIndex??e.active.selectedIndex}}:e:null}function pE(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function wW(){const t=document.createElement("div");t.className="tandem-slash-menu__hint";const e=[["↑↓","navigate"],["↵","insert"],["esc","close"]];for(const[n,r]of e){const i=document.createElement("span"),o=document.createElement("kbd");o.textContent=n,i.appendChild(o),i.appendChild(document.createTextNode(` ${r}`)),t.appendChild(i)}return t}function xW(t,e,n,r,i){const o=pp(e.query);pE(t),t.className="tandem-floating-pill tandem-slash-menu";const s=document.createElement("div");s.setAttribute("role","listbox"),s.setAttribute("aria-label","Slash commands"),o.forEach((l,c)=>{const d=document.createElement("button");d.type="button",d.role="option",d.id=`slash-command-${l.id}`,d.className="tandem-slash-menu__item",d.setAttribute("aria-selected",String(c===e.selectedIndex)),d.textContent=l.label,d.dataset.commandId=l.id,d.addEventListener("mouseenter",()=>r(c)),d.addEventListener("mousedown",f=>{f.preventDefault(),i(l)}),s.appendChild(d)}),t.appendChild(s),t.appendChild(wW());const a=n.view.coordsAtPos(e.from);t.style.display="block",t.style.position="fixed",t.style.left=`${Math.max(8,a.left)}px`,t.style.top=`${a.bottom+8}px`}function kW(t,e){const n=pp(e.query)[e.selectedIndex];return n?(t.chain().focus().deleteRange({from:e.from,to:e.to}).run(),n.run(t),!0):!1}const _W=Bt.create({name:"slashCommand",addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){const t=this.editor,e=this.options.onOpenChange;return[new wt({key:eo,state:{init:(n,r)=>({active:Q1(r),dismissedKey:null}),apply(n,r,i,o){var l;const s=bW(n,r);if(s)return s;const a=Q1(o,((l=r.active)==null?void 0:l.selectedIndex)??0);return a&&hE(a)===r.dismissedKey?{active:null,dismissedKey:r.dismissedKey}:{active:a,dismissedKey:a?null:r.dismissedKey}}},props:{handleKeyDown(n,r){const i=eo.getState(n.state),o=i==null?void 0:i.active;if(!o)return!1;const s=pp(o.query);if(r.key==="ArrowDown"){r.preventDefault();const a=(o.selectedIndex+1)%s.length;return n.dispatch(n.state.tr.setMeta(eo,{type:"select",selectedIndex:a})),!0}if(r.key==="ArrowUp"){r.preventDefault();const a=(o.selectedIndex-1+s.length)%s.length;return n.dispatch(n.state.tr.setMeta(eo,{type:"select",selectedIndex:a})),!0}return r.key==="Enter"?(r.preventDefault(),kW(t,o)):r.key==="Escape"?(r.preventDefault(),n.dispatch(n.state.tr.setMeta(eo,{type:"close"})),!0):!1}},view(n){const r=document.createElement("div");r.dataset.testid="slash-command-menu",r.style.display="none",document.body.appendChild(r);let i=!1;const o=l=>{l!==i&&(i=l,e==null||e(l))},s=()=>{r.style.display="none",pE(r),o(!1)},a=()=>{var c;const l=(c=eo.getState(n.state))==null?void 0:c.active;if(!l){s();return}xW(r,l,t,d=>{n.dispatch(n.state.tr.setMeta(eo,{type:"select",selectedIndex:d}))},d=>{t.chain().focus().deleteRange({from:l.from,to:l.to}).run(),d.run(t),s(),n.dispatch(n.state.tr.setMeta(eo,{type:"close"}))}),o(!0)};return a(),{update:a,destroy(){o(!1),r.remove()}}}})]}});var SW=E('<div role="presentation" data-testid="editor-root"></div>');function CW(t,e){Pe(e,!0);const n=new Set([...Ih].filter(p=>p!==".docx")),r=["http://","https://","mailto:","ftp://","//"];function i(p){return r.some(m=>p.startsWith(m))}function o(p,m){const v=m.includes("\\")?"\\":"/",g=p.indexOf("#"),b=g>=0?p.slice(0,g):p;if(!b)return null;const x=b.match(/\.[^./\\]+$/),_=x?x[0].toLowerCase():"";if(!n.has(_))return null;const A=m.split(v);A.pop();const P=b.replace(/\//g,v).split(v),D=[...A];for(const L of P)L===".."?D.length>0&&D.pop():L!=="."&&D.push(L);return D.join(v)}let s=I(null),a=null;const l=F(()=>e.format==="docx");he(()=>{if(e.ydoc,e.provider,!a)return;const p=new kU({element:a,extensions:[G8.configure({history:!1}),m6.configure({multicolor:!0}),V6.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}}),H6.configure({placeholder:"Start typing…"}),Wj.configure({resizable:!0}),Gj,Kj,qj,uW,u6.configure({document:e.ydoc}),f6.configure({provider:e.provider,user:{name:Ny(),color:"var(--tandem-warning)"}}),J8.configure({ydoc:e.ydoc}),dW.configure({filePath:vt(()=>e.currentFilePath??null)}),X8.configure({ydoc:e.ydoc}),Q8.configure({ydoc:e.ydoc}),_W.configure({onOpenChange:e.onSlashCommandMenuChange}),nW,hW],editorProps:{attributes:{class:"tandem-editor",style:"outline: none; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;"}},editable:vt(()=>!e.readOnly),autofocus:vt(()=>!e.readOnly)});return y(s,p,!0),vt(()=>{var m;return(m=e.onEditorReady)==null?void 0:m.call(e,p)}),()=>{vt(()=>{var m;return(m=e.onEditorReady)==null?void 0:m.call(e,null)}),p.destroy(),u(s)===p&&y(s,null)}});let c;he(()=>{const p=u(s);if(!p)return;const m=e.readOnly;c!==m&&(c=m,p.setEditable(!m))}),he(()=>{const p=u(s);if(p)return yC(m=>p.commands.updateUser({name:m}))}),he(()=>{const p=u(s);if(!p)return;const m=p.view.dom;m.querySelectorAll(".tandem-annotation-active").forEach(v=>{v.classList.remove("tandem-annotation-active")}),e.activeAnnotationId&&m.querySelectorAll(`[data-annotation-id="${CSS.escape(e.activeAnnotationId)}"]`).forEach(v=>{v.classList.add("tandem-annotation-active")})});async function d(p){const m=p.target.closest("a[href]");if(m){const _=m.getAttribute("href")??"";if(!_||_.startsWith("#"))return;if(p.preventDefault(),i(_)){window.open(_,"_blank","noopener,noreferrer");return}if(e.currentFilePath){const A=o(_,e.currentFilePath);if(A){const M=await us(A);M.ok||console.warn(`[tandem] Could not open linked file "${A}": ${M.error}`)}}return}const v={highlight:2,comment:1,note:0};let g=p.target.closest("[data-annotation-id]"),b=null,x=Number.NEGATIVE_INFINITY;for(;g;){const _=g.getAttribute("data-annotation-id");if(_){const M=g.getAttribute("data-annotation-type")??"",P=v[M]??-1;P>x&&(x=P,b=_)}const A=g.parentElement;g=A?A.closest("[data-annotation-id]"):null}b&&e.onAnnotationClick&&e.onAnnotationClick(b)}var f=SW();let h;pt(f,p=>a=p,()=>a),U(()=>h=Xr(f,1,"",null,h,{"tandem-paged":u(l)})),R("click",f,d),S(t,f),Le()}Ke(["click"]);var TW=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>'),EW=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-error-fg);" role="alert"> </div>'),AW=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-warning-fg); padding: 2px 0;" role="status"> </div>'),MW=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);">Searching…</div>'),OW=E('<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);">No matches in open tabs</div>'),DW=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>'),IW=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>'),RW=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>'),NW=E(`<div data-testid="find-replace-bar" role="dialog" tabindex="-1" aria-modal="false" aria-label="Find and replace" style="
|
|
193
|
+
position: absolute; bottom: 0; right: 0;
|
|
194
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
195
|
+
border-radius: var(--tandem-r-3) var(--tandem-r-3) 0 0;
|
|
196
|
+
padding: var(--tandem-space-3) var(--tandem-space-4);
|
|
197
|
+
box-shadow: var(--tandem-shadow-3);
|
|
198
|
+
z-index: var(--tandem-z-overlay, 200);
|
|
199
|
+
min-width: 320px; max-width: 480px;
|
|
200
|
+
display: flex; flex-direction: column; gap: var(--tandem-space-2);
|
|
201
|
+
"><!> <div style="display: flex; gap: var(--tandem-space-2); align-items: center;"><input data-testid="find-input" type="text" placeholder="Find…" aria-label="Find"/> <span data-testid="find-match-count" style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); white-space: nowrap; min-width: 48px; text-align: right;"><!></span> <button data-testid="find-prev-btn" title="Previous match (Shift+Enter)" aria-label="Previous match">↑</button> <button data-testid="find-next-btn" title="Next match (Enter)" aria-label="Next match">↓</button> <button data-testid="find-close-btn" title="Close (Esc)" aria-label="Close find bar" style="background: none; border: none; cursor: pointer; font-size: 16px; color: var(--tandem-fg-muted); padding: 0 2px; line-height: 1;">×</button></div> <!> <div style="display: flex; gap: var(--tandem-space-3); align-items: center;"><label style="display: flex; align-items: center; gap: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); cursor: pointer; user-select: none;"><input data-testid="find-case-toggle" type="checkbox"/> Aa</label> <label style="display: flex; align-items: center; gap: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); cursor: pointer; user-select: none;"><input data-testid="find-word-toggle" type="checkbox"/> \\b</label> <label style="display: flex; align-items: center; gap: 4px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); cursor: pointer; user-select: none;"><input data-testid="find-regex-toggle" type="checkbox"/> .*</label></div> <div style="display: flex; gap: var(--tandem-space-2); align-items: center;"><input data-testid="replace-input" type="text" placeholder="Replace with…" aria-label="Replace with" style="
|
|
202
|
+
flex: 1; padding: 4px 8px; font-size: var(--tandem-text-sm);
|
|
203
|
+
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
204
|
+
background: var(--tandem-surface); color: var(--tandem-fg); outline: none;
|
|
205
|
+
"/> <button data-testid="replace-btn">Replace</button> <button data-testid="replace-all-btn"><!></button></div> <!> <!></div>`);function PW(t,e){Pe(e,!0);let n=nt(e,"tabs",19,()=>[]),r=I("doc"),i=I(We([])),o=I(!1);he(()=>{n().length<=1&&u(r)==="tabs"&&(y(r,"doc"),y(i,[],!0),y(o,!1))});function s(W){const ee=W.getXmlFragment("default"),ie=[];function K(Y){if(Y instanceof Dn)ie.push(Y.toString());else{for(let O=0;O<Y.length;O++){const T=Y.get(O);(T instanceof Dn||T instanceof sn)&&K(T)}Y instanceof sn&&Y.nodeName!=="text"&&ie.push(" ")}}return K(ee),ie.join("")}function a(W,ee,ie){const K=s(W),Y=ie?ee:ee.toLowerCase(),O=ie?K:K.toLowerCase(),T=[];let C=0,Z=0;for(;(Z=O.indexOf(Y,Z))!==-1;){if(C++,T.length<3){const q=Math.max(0,Z-30),oe=Math.min(K.length,Z+Y.length+30),ge=K.slice(q,oe).replace(/\s+/g," ").trim();T.push((q>0?"…":"")+ge+(oe<K.length?"…":""))}Z+=Y.length}return{count:C,snippets:T}}let l;Qr(()=>clearTimeout(l));function c(W,ee){if(clearTimeout(l),!W){y(i,[],!0),y(o,!1);return}y(o,!0),l=setTimeout(()=>{const ie=[];for(const K of n()){if(!K.ydoc)continue;const{count:Y,snippets:O}=a(K.ydoc,W,ee);Y>0&&ie.push({tabId:K.id,fileName:K.fileName,count:Y,snippets:O})}y(i,ie,!0),y(o,!1)},300)}let d=I(""),f=I(""),h=I(!1),p=I(!1),m=I(!1),v=I(null),g=I(!1),b=I(null),x=I(null),_=I(0);const A=F(()=>(u(_),e.editor?Wa(e.editor.state):void 0)),M=F(()=>{var W;return((W=u(A))==null?void 0:W.matches.length)??0}),P=F(()=>{var W;return((W=u(A))==null?void 0:W.activeIndex)??-1});let D=I(null);he(()=>{var W;e.open&&((W=u(D))==null||W.focus())});let L=!1;he(()=>{const W=e.open&&!L;L=e.open,!(!W||!e.forceScope)&&(e.forceScope==="tabs"&&n().length>1?(y(r,"tabs"),c(u(d),u(h))):y(r,"doc"))}),he(()=>{const W=e.editor;if(!W||W.isDestroyed)return;const ee=()=>Tc(_);return W.on("update",ee),W.on("selectionUpdate",ee),()=>{W.isDestroyed||(W.off("update",ee),W.off("selectionUpdate",ee))}});function X(){if(u(r)==="tabs"){c(u(d),u(h));return}const W=e.editor;if(!W||!u(d)){y(v,null),W==null||W.commands.findClose();return}if(u(m))try{new RegExp(u(d)),y(v,null)}catch(ie){y(v,ie instanceof Error?ie.message:"Invalid regex",!0);return}else y(v,null);const ee={query:u(d),caseSensitive:u(h),wholeWord:u(p),regexMode:u(m)};W.commands.find(ee)}function z(W){var ee;y(r,W,!0),W==="tabs"?((ee=e.editor)==null||ee.commands.findClose(),c(u(d),u(h))):(y(i,[],!0),clearTimeout(l),X())}function re(W){var ee,ie;if(W.key==="Enter"){W.preventDefault(),W.shiftKey?(ee=e.editor)==null||ee.commands.findPrev():(ie=e.editor)==null||ie.commands.findNext();return}W.key==="Escape"&&Q()}function Q(){var W;(W=e.editor)==null||W.commands.findClose(),e.onClose()}async function N(){const W=e.editor;if(!W||!u(d)||u(g))return;const ee=u(M);if(ee>500&&!window.confirm(`Replace all ${ee} occurrences? This cannot be undone as a single action.`))return;y(g,!0),y(x,null),y(b,{replaced:0,total:ee},!0);const{replaced:ie,partial:K}=await iW(W.view,u(f),(Y,O)=>{y(b,{replaced:Y,total:O},!0)});y(b,null),y(g,!1),K&&y(x,`Replaced ${ie} of ${ee}; re-run to continue`)}var B=ft(),j=Se(B);{var H=W=>{var ee=NW(),ie=w(ee);{var K=ze=>{var _t=TW(),hn=w(_t),De=k(hn,2);U(()=>{G(hn,"aria-pressed",u(r)==="doc"),ve(hn,`
|
|
206
|
+
padding: 2px var(--tandem-space-2); font-size: var(--tandem-text-xs);
|
|
207
|
+
border: 1px solid ${u(r)==="doc"?"var(--tandem-accent-border)":"var(--tandem-border)"};
|
|
208
|
+
border-radius: var(--tandem-r-pill);
|
|
209
|
+
background: ${u(r)==="doc"?"var(--tandem-accent-bg)":"var(--tandem-surface)"};
|
|
210
|
+
color: ${u(r)==="doc"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};
|
|
211
|
+
cursor: pointer;
|
|
212
|
+
`),G(De,"aria-pressed",u(r)==="tabs"),ve(De,`
|
|
213
|
+
padding: 2px var(--tandem-space-2); font-size: var(--tandem-text-xs);
|
|
214
|
+
border: 1px solid ${u(r)==="tabs"?"var(--tandem-accent-border)":"var(--tandem-border)"};
|
|
215
|
+
border-radius: var(--tandem-r-pill);
|
|
216
|
+
background: ${u(r)==="tabs"?"var(--tandem-accent-bg)":"var(--tandem-surface)"};
|
|
217
|
+
color: ${u(r)==="tabs"?"var(--tandem-accent)":"var(--tandem-fg-muted)"};
|
|
218
|
+
cursor: pointer;
|
|
219
|
+
`)}),R("click",hn,()=>z("doc")),R("click",De,()=>z("tabs")),S(ze,_t)};J(ie,ze=>{n().length>1&&ze(K)})}var Y=k(ie,2),O=w(Y);pt(O,ze=>y(D,ze),()=>u(D));var T=k(O,2),C=w(T);{var Z=ze=>{var _t=hr();U(()=>te(_t,u(M)===0?"No matches":`${u(P)+1} / ${u(M)}`)),S(ze,_t)};J(C,ze=>{u(d)&&ze(Z)})}var q=k(T,2),oe=k(q,2),ge=k(oe,2),$=k(Y,2);{var le=ze=>{var _t=EW(),hn=w(_t);U(()=>te(hn,u(v))),S(ze,_t)};J($,ze=>{u(v)&&ze(le)})}var ce=k($,2),ue=w(ce),pe=w(ue),_e=k(ue,2),ae=w(_e),de=k(_e,2),ye=w(de),ke=k(ce,2),Ve=w(ke),qe=k(Ve,2),fe=k(qe,2),Ee=w(fe);{var Re=ze=>{var _t=hr();U(()=>te(_t,`${u(b).replaced??""}/${u(b).total??""}`)),S(ze,_t)},Ge=ze=>{var _t=hr("All");S(ze,_t)};J(Ee,ze=>{u(g)&&u(b)?ze(Re):ze(Ge,-1)})}var Te=k(ke,2);{var Me=ze=>{var _t=AW(),hn=w(_t);U(()=>te(hn,u(x))),S(ze,_t)};J(Te,ze=>{u(x)&&ze(Me)})}var dt=k(Te,2);{var Kt=ze=>{var _t=RW(),hn=w(_t);{var De=St=>{var jt=MW();S(St,jt)},it=St=>{var jt=OW();S(St,jt)},Vt=St=>{var jt=ft(),ir=Se(jt);Ye(ir,17,()=>u(i),Ac,(Pt,rn)=>{var At=IW(),cn=w(At),or=w(cn),sr=k(or),Lt=w(sr),Ht=k(cn,2);Ye(Ht,17,()=>u(rn).snippets,Ac,(tt,Ct)=>{var Ar=DW(),ti=w(Ar);U(()=>te(ti,u(Ct))),S(tt,Ar)}),U(()=>{te(or,`${u(rn).fileName??""} `),te(Lt,`(${u(rn).count??""} ${u(rn).count===1?"match":"matches"})`)}),S(Pt,At)}),S(St,jt)};J(hn,St=>{u(o)?St(De):u(d)&&u(i).length===0?St(it,1):St(Vt,-1)})}S(ze,_t)};J(dt,ze=>{u(r)==="tabs"&&ze(Kt)})}U(()=>{ve(O,`
|
|
220
|
+
flex: 1; padding: 4px 8px; font-size: var(--tandem-text-sm);
|
|
221
|
+
border: 1px solid ${u(v)?"var(--tandem-error)":"var(--tandem-border)"};
|
|
222
|
+
border-radius: var(--tandem-r-2); background: var(--tandem-surface);
|
|
223
|
+
color: var(--tandem-fg); outline: none;
|
|
224
|
+
`),q.disabled=u(M)===0,ve(q,`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: ${u(M)===0?.4:1};`),oe.disabled=u(M)===0,ve(oe,`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: ${u(M)===0?.4:1};`),qe.disabled=u(M)===0||u(g)||u(r)==="tabs",G(qe,"title",u(r)==="tabs"?"Replace is not available in Open tabs mode":void 0),ve(qe,`
|
|
225
|
+
padding: 4px 10px; font-size: var(--tandem-text-xs); cursor: pointer;
|
|
226
|
+
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
227
|
+
background: var(--tandem-surface); color: var(--tandem-fg-muted);
|
|
228
|
+
opacity: ${u(M)===0||u(g)||u(r)==="tabs"?.4:1};
|
|
229
|
+
`),fe.disabled=u(M)===0||u(g)||u(r)==="tabs",G(fe,"title",u(r)==="tabs"?"Replace All is not available in Open tabs mode":void 0),ve(fe,`
|
|
230
|
+
padding: 4px 10px; font-size: var(--tandem-text-xs); cursor: pointer;
|
|
231
|
+
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
232
|
+
background: var(--tandem-surface); color: var(--tandem-fg-muted);
|
|
233
|
+
opacity: ${u(M)===0||u(g)||u(r)==="tabs"?.4:1};
|
|
234
|
+
`)}),R("keydown",ee,re),R("input",O,X),Bn(O,()=>u(d),ze=>y(d,ze)),R("click",q,()=>{var ze;return(ze=e.editor)==null?void 0:ze.commands.findPrev()}),R("click",oe,()=>{var ze;return(ze=e.editor)==null?void 0:ze.commands.findNext()}),R("click",ge,Q),R("change",pe,X),Pu(pe,()=>u(h),ze=>y(h,ze)),R("change",ae,X),Pu(ae,()=>u(p),ze=>y(p,ze)),R("change",ye,X),Pu(ye,()=>u(m),ze=>y(m,ze)),Bn(Ve,()=>u(f),ze=>y(f,ze)),R("click",qe,()=>{e.editor&&(rW(e.editor.view,u(f)),Tc(_))}),R("click",fe,N),S(W,ee)};J(j,W=>{e.open&&W(H)})}S(t,B),Le()}Ke(["keydown","click","input","change"]);function bb(t,e,n,r={}){const{capture:i=!0}=r;function o(s){const a=t();a&&(s.target instanceof Node&&a.contains(s.target)||n(s))}for(const s of e)document.addEventListener(s,o,i);return()=>{for(const s of e)document.removeEventListener(s,o,i)}}function mE(t){var n;const e=(n=t.closest)==null?void 0:n.call(t,"[data-tauri-drag-region]");return!!e&&e.getAttribute("data-tauri-drag-region")!=="false"}function yr(t){return e=>{e.preventDefault(),t()}}function LW(t){const e=t.getAttributes("link").href;return e===void 0?"":typeof e=="string"?e:(console.warn("[tandem] getInitialLinkHref: non-string href attribute",{href:e}),"")}function zW(t,e){const n=e.trim();n?t.chain().focus().setLink({href:n}).run():t.isActive("link")&&t.chain().focus().unsetLink().run()}function gE(t,e,n){const r=t.getMap(xo);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=ug(),c={id:l,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:n};return Hs(t,()=>r.set(l,c)),"added"}if(o===n)return Hs(t,()=>r.delete(i)),"removed";const s=ug(),a={id:s,author:"user",type:"highlight",audience:"private",range:{from:e.from,to:e.to},content:"",status:"pending",timestamp:Date.now(),color:n};return Hs(t,()=>{r.delete(i),r.set(s,a)}),"recolored"}const _u=48,Su=8,$1=10,ex=4;function FW({start:t,end:e,toolbarHeight:n,toolbarWidth:r,viewportHeight:i,viewportWidth:o,previousPlacement:s}){const a=(t.left+e.right)/2,l=r/2,c=Su+l,d=Math.max(c,o-Su-l),f=Math.min(t.top,e.top),h=Math.max(t.bottom,e.bottom),p=f-$1-n,m=h+$1,v=m+n,g=_u+ex,b=_u-ex,_=p>=(s==="above"?b:g),A=v<=i-Su,M=Math.max(_u,i-n-Su);let P,D;return _?(P=p,D="above"):A?(P=m,D="below"):(P=M,D="below"),{left:Math.min(Math.max(a,c),d),top:Math.min(Math.max(P,_u),M),placement:D}}function BW(t,e){return t.on("selectionUpdate",e),()=>t.off("selectionUpdate",e)}var VW=E('<button type="button"><!></button>');function zn(t,e){const n=nt(e,"disabled",3,!1),r=nt(e,"active",3,!1),i=nt(e,"style",3,""),o=F(()=>{let v="1px solid transparent",g="transparent",b="var(--tandem-fg-muted)";return n()?(g="transparent",b="var(--tandem-fg-subtle)"):r()&&(g="var(--tandem-accent-bg)",v="1px solid var(--tandem-accent-border)",b="var(--tandem-accent-fg-strong)"),{border:v,background:g,color:b}}),s=F(()=>e.ariaLabel??(typeof e.label=="string"?e.label:void 0)),a=F(()=>u(s)??""),l=F(()=>n()&&e.disabledTitle?e.disabledTitle:e.shortcut?`${u(a)} (${e.shortcut})`:u(a)),c="height: 28px; padding: 0 8px; font-size: 12px; border-radius: var(--tandem-r-2); display: inline-flex; align-items: center; justify-content: center; gap: 5px;",d=F(()=>`${c} cursor: ${n()?"not-allowed":"pointer"}; ${i()}; border: ${u(o).border}; background: ${u(o).background}; color: ${u(o).color};`);var f=VW(),h=w(f);{var p=v=>{var g=ft(),b=Se(g);Cd(b,()=>e.children),S(v,g)},m=v=>{var g=hr();U(()=>te(g,e.label)),S(v,g)};J(h,v=>{e.children?v(p):v(m,-1)})}U(()=>{G(f,"data-testid",e.testId),f.disabled=n(),G(f,"title",u(l)),G(f,"aria-label",u(s)),ve(f,u(d))}),R("mousedown",f,function(...v){var g;(g=e.onMouseDown)==null||g.apply(this,v)}),R("click",f,function(...v){var g;(g=e.onClick)==null||g.apply(this,v)}),S(t,f)}Ke(["mousedown","click"]);var HW=E('<button type="button"></button>'),UW=E('<div style="display: flex; align-items: center; gap: 1px; padding: 4px;"><!> <!> <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 style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px;"></div> <button type="button" data-testid="popup-annotate-btn" aria-label="Annotate" style="height: 24px; padding: 0 12px; border: 1px solid var(--tandem-author-user); background: transparent; color: var(--tandem-author-user); border-radius: var(--tandem-r-pill); font-size: 12px; font-weight: 600; cursor: pointer;">Annotate</button></div>'),jW=E('<div style="display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; min-width: 260px; max-width: 360px;"><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 style="display: flex; justify-content: space-between; gap: 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>'),WW=E('<div role="toolbar" aria-label="Selection tools" class="tandem-floating-pill"><!></div>');function KW(t,e){Pe(e,!0);let n=nt(e,"selectionToolbar",3,!0),r=nt(e,"suppressSelectionToolbar",3,!1),i=nt(e,"requestCommentFocus",3,0),o=I(!1),s=I(null),a=I(null),l=I(""),c=I(null),d=I(null),f=I(!1),h=I(0),p=I(0),m=I(We(window.innerHeight)),v=I(We(window.innerWidth));const g=Object.keys(Ck),b=F(()=>!!e.editor&&!!e.ydoc&&u(o)),x=F(()=>n()&&!r()&&u(b)&&u(s)!==null),_=F(()=>u(l).trim());let A,M=0,P=0;const D=3;function L(C){const{from:Z,to:q}=C.state.selection,oe=Z!==q;if(y(o,oe),!oe){y(s,null),A=void 0,P=0;return}try{const ge=C.view.coordsAtPos(Z),$=C.view.coordsAtPos(q),le=FW({start:ge,end:$,toolbarHeight:u(h),toolbarWidth:u(p),viewportHeight:u(m),viewportWidth:u(v),previousPlacement:A});if(A=le.placement,P=0,u(s)&&u(s).left===le.left&&u(s).top===le.top)return;y(s,{left:le.left,top:le.top},!0)}catch{if(P>=D){P=0,y(s,null),A=void 0;return}P+=1,cancelAnimationFrame(M),M=requestAnimationFrame(()=>{C.isDestroyed||L(C)})}}he(()=>{if(!e.editor)return;const C=e.editor;function Z(){L(C)}const q=BW(C,Z);return Z(),()=>{cancelAnimationFrame(M),M=0,q()}}),he(()=>{if(!e.editor||!u(s))return;const C=e.editor;let Z=0;function q(){cancelAnimationFrame(Z),Z=requestAnimationFrame(()=>{y(m,window.innerHeight,!0),y(v,window.innerWidth,!0),L(C)})}window.addEventListener("resize",q);let oe=!1;requestAnimationFrame(()=>{oe=!0});const ge=bb(()=>u(a),["scroll"],()=>{oe&&document.activeElement!==u(d)&&H()});return()=>{cancelAnimationFrame(Z),window.removeEventListener("resize",q),ge()}}),he(()=>{const C=e.editor,Z=u(a);if(!C||!Z||!u(s))return;const q=()=>{if(document.activeElement===u(d))return;const ge=Z.getBoundingClientRect();y(h,ge.height,!0),y(p,ge.width,!0),L(C)};q();const oe=new ResizeObserver(q);return oe.observe(Z),()=>oe.disconnect()}),he(()=>{u(x)&&!u(c)&&re(),u(x)||(y(c,null),document.activeElement!==u(d)&&y(l,""))});let X=0;he(()=>{if(i()===X||(X=i(),i()===0||!e.editor))return;const{from:C,to:Z}=e.editor.state.selection;C!==Z&&(vt(()=>re()),y(f,!0),requestAnimationFrame(()=>{var q;return(q=u(d))==null?void 0:q.focus()}))}),he(()=>{if(!e.editor||!u(x))return;const C=e.editor,Z=()=>{document.activeElement!==u(d)&&re()};return C.on("selectionUpdate",Z),()=>{C.isDestroyed||C.off("selectionUpdate",Z)}}),he(()=>{if(!u(x))return;function C(Z){Z.key==="Escape"&&(Z.preventDefault(),H())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)});function z(C,Z,q){if(!e.editor||!e.ydoc)return;const oe=u(c)??e.editor.state.selection,{from:ge,to:$}=oe;if(ge===$)return;const le=Mi(e.editor.state.doc,Mn(ge)),ce=Mi(e.editor.state.doc,Mn($)),ue=ug(),_e={id:ue,author:"user",type:C,audience:C==="highlight"||C==="note"?"private":"outbound",range:{from:le,to:ce},content:Z,status:"pending",timestamp:Date.now()};Hs(e.ydoc,()=>e.ydoc.getMap(xo).set(ue,_e)),y(c,null)}function re(){if(!e.editor)return;const{from:C,to:Z}=e.editor.state.selection;y(c,{from:C,to:Z},!0)}function Q(C){if(!e.editor||!e.ydoc)return;const Z=u(c)??e.editor.state.selection,{from:q,to:oe}=Z;if(q===oe)return;const ge=Mi(e.editor.state.doc,Mn(q)),$=Mi(e.editor.state.doc,Mn(oe));gE(e.ydoc,{from:ge,to:$},C),y(c,null),e.editor.chain().setTextSelection(oe).run()}function N(C){return Z=>{Z.detail===0&&C(Z)}}const B=F(()=>yr(()=>{var C;return(C=e.editor)==null?void 0:C.chain().focus().toggleBold().run()})),j=F(()=>yr(()=>{var C;return(C=e.editor)==null?void 0:C.chain().focus().toggleItalic().run()}));function H(){var C;y(o,!1),y(s,null),y(c,null),y(l,""),y(f,!1),(C=e.editor)==null||C.chain().focus().run()}function W(){y(f,!0),requestAnimationFrame(()=>{var C;return(C=u(d))==null?void 0:C.focus()})}function ee(){u(_)&&(z("comment",u(_)),H())}function ie(){z("note",u(_)),H()}function K(C){C.key==="Enter"&&!C.shiftKey?(C.preventDefault(),ee()):C.key==="Escape"&&(C.preventDefault(),H())}var Y=ft(),O=Se(Y);{var T=C=>{var Z=WW(),q=w(Z);{var oe=$=>{var le=UW(),ce=w(le);{let de=F(()=>N(u(B)));zn(ce,{label:"B",ariaLabel:"Bold",style:"font-weight: 700; min-width: 28px;",get onMouseDown(){return u(B)},get onClick(){return u(de)}})}var ue=k(ce,2);{let de=F(()=>N(u(j)));zn(ue,{label:"I",ariaLabel:"Italic",style:"font-style: italic; min-width: 28px;",get onMouseDown(){return u(j)},get onClick(){return u(de)}})}var pe=k(ue,4);Ye(pe,21,()=>g,Ac,(de,ye)=>{var ke=HW(),Ve=F(()=>N(()=>{var qe;Q(u(ye)),(qe=e.editor)==null||qe.chain().focus().run()}));U(()=>{G(ke,"data-testid",`popup-highlight-${u(ye)}`),G(ke,"aria-label",`Highlight ${u(ye)}`),G(ke,"title",`Highlight ${u(ye)}`),ve(ke,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${Ic[u(ye)]}; cursor: pointer; padding: 0;`)}),R("mousedown",ke,qe=>{var fe;qe.preventDefault(),Q(u(ye)),(fe=e.editor)==null||fe.chain().focus().run()}),R("click",ke,function(...qe){var fe;(fe=u(Ve))==null||fe.apply(this,qe)}),S(de,ke)});var _e=k(pe,4),ae=F(()=>N(()=>W()));R("mousedown",_e,de=>{de.preventDefault(),W()}),R("click",_e,function(...de){var ye;(ye=u(ae))==null||ye.apply(this,de)}),S($,le)},ge=$=>{var le=jW(),ce=w(le);G(ce,"rows",1),pt(ce,ae=>y(d,ae),()=>u(d));var ue=k(ce,2),pe=w(ue),_e=k(pe,2);U(()=>_e.disabled=!u(_)),R("keydown",ce,K),Bn(ce,()=>u(l),ae=>y(l,ae)),R("click",pe,ie),R("click",_e,ee),S($,le)};J(q,$=>{u(f)?$(ge,-1):$(oe)})}pt(Z,$=>y(a,$),()=>u(a)),U(()=>ve(Z,`position: fixed; left: ${u(s).left}px; top: ${u(s).top}px; transform: translateX(-50%); display: flex; flex-direction: column; border-radius: var(--tandem-r-pill); z-index: var(--tandem-z-modal);`)),S(C,Z)};J(O,C=>{u(x)&&u(s)&&C(T)})}S(t,Y),Le()}Ke(["mousedown","click","keydown"]);function qW(t,e=document.documentElement){const n=Math.max(0,Math.min(360,Math.round(t)));return e.style.setProperty("--tandem-accent-h",`${n}deg`),()=>e.style.removeProperty("--tandem-accent-h")}function GW(t){he(()=>qW(t()))}function Cu(t){return[...t].sort((e,n)=>{const r=e.range.from-n.range.from;return r!==0?r:e.id<n.id?-1:e.id>n.id?1:0})}function vE(t,e){if(!e)return-1;for(let n=0;n<t.length;n++)if(t[n].id===e)return n;return-1}function tx(t,e){if(t.length===0)return null;const n=vE(t,e);return n===-1?t[0].id:t[(n+1)%t.length].id}function nx(t,e){if(t.length===0)return null;const n=vE(t,e);return n===-1?t[t.length-1].id:t[(n-1+t.length)%t.length].id}function JW(t,e=document.documentElement){return t?e.setAttribute("data-annotation-patterns","true"):e.removeAttribute("data-annotation-patterns"),()=>e.removeAttribute("data-annotation-patterns")}function YW(t){he(()=>JW(t()))}function ZW(t){let e=I(We(new Map));return he(()=>{const n=t.getYdoc();if(!n){u(e).size>0&&y(e,new Map,!0);return}const r=n.getMap(Dk),i=()=>{y(e,XW(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return u(e)}}}function XW(t){const e=new Map;t.forEach(n=>{const r=n;if(!r||typeof r!="object"||!r.annotationId)return;const i=e.get(r.annotationId)??[];i.push(r),e.set(r.annotationId,i)});for(const n of e.values())n.sort((r,i)=>r.timestamp-i.timestamp);return e}function QW(t){if(t.isComposing)return null;const e=t.ctrlKey||t.metaKey;if(t.key==="?")return{id:"toggle-help"};if(e){if(t.shiftKey&&t.code==="Comma")return{id:"settings-modal"};if(!t.shiftKey&&t.code==="Comma")return{id:"settings"};if(t.key==="/")return{id:"toggle-help"};if(!t.altKey&&!t.shiftKey&&t.code==="KeyA")return{id:"select-all"};if(t.shiftKey&&!t.altKey&&t.code==="KeyS")return{id:"save-as"};if(t.code==="KeyS")return{id:"save"};if(t.shiftKey&&t.code==="KeyP")return{id:"toggle-palette"};if(t.code==="KeyN")return{id:"new-scratchpad"};if(t.code==="KeyW")return{id:"close-tab"};if(t.code==="KeyO")return{id:"open-file"};if(/^Digit[1-9]$/.test(t.code))return{id:"pick-tab",context:{tabIndex:Number(t.code.slice(5))}};if(t.shiftKey&&!t.altKey&&t.code==="KeyM")return{id:"toggle-mode"};if(t.altKey&&t.code==="KeyT")return{id:"reopen-closed-tab"};if(t.code==="KeyF")return{id:"find",context:{shift:t.shiftKey}};if(t.code==="KeyG")return{id:"find-nav",context:{shift:t.shiftKey}};if(t.key==="Enter")return{id:"annotation-accept-or-dismiss",context:{shift:t.shiftKey}};if(t.altKey&&t.code==="KeyM")return{id:"comment-on-selection"};if(t.altKey&&t.code==="KeyA")return{id:"toggle-authorship"}}if(t.altKey&&!t.ctrlKey&&!t.metaKey){if(t.shiftKey){if(t.code==="ArrowLeft")return{id:"toggle-left-panel"};if(t.code==="ArrowRight")return{id:"toggle-right-panel"}}if(!t.shiftKey){if(t.code==="BracketRight")return{id:"annotation-next"};if(t.code==="BracketLeft")return{id:"annotation-prev"}}if(!t.shiftKey&&t.code==="KeyL")return{id:"select-block"}}return null}const $W=25;function e9(t=$W){const e=[];return{push(n){if(!(e.length&&e[e.length-1].filePath===n.filePath))for(e.push(n);e.length>t;)e.shift()},pop(){return e.pop()??null},peek(){return e.length?e[e.length-1]:null},size(){return e.length},clear(){e.length=0}}}function t9(t,e=()=>PM){let n=I(!1),r=I(!1);return he(()=>{const i=t();if(i==null){y(n,!1),y(r,!1);return}const o=Date.now()-i,s=e()-o;if(s<=0){y(n,!0);return}const a=setTimeout(()=>{y(n,!0)},s);return()=>clearTimeout(a)}),{get showBanner(){return u(n)&&!u(r)},dismiss(){y(r,!0)}}}function n9(t,e=document.documentElement){return e.setAttribute("data-density",t),()=>e.removeAttribute("data-density")}function r9(t){he(()=>n9(t()))}const Ka=200,ud=600,i9=300;function rx(t){const e=Ak[t];try{const n=localStorage.getItem(e);if(n){const r=parseInt(n,10);if(Number.isFinite(r))return Math.max(Ka,Math.min(ud,r));console.warn(`[tandem] ignoring non-numeric panel width for ${e}: ${n}`)}}catch(n){console.warn(`[tandem] localStorage unavailable reading ${e}:`,n)}return i9}function ix(t){const{side:e}=t,n=Ak[e];let r=I(We(t.initialWidth)),i=null;return he(()=>{!t.getVisible()&&i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),i=null,document.body.style.userSelect="",document.body.style.cursor="")}),he(()=>()=>{i&&(document.removeEventListener("mousemove",i.move),document.removeEventListener("mouseup",i.up),document.body.style.userSelect="",document.body.style.cursor="",i=null)}),{get width(){return u(r)},handleResizeStart:a=>{a.preventDefault();const l=a.clientX,c=u(r);let d=c;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const f=p=>{const m=p.clientX-l,v=e==="left"?c+m:c-m;d=Math.max(Ka,Math.min(ud,v)),y(r,d,!0)},h=()=>{if(document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",h),i=null,document.body.style.userSelect="",document.body.style.cursor="",t.getVisible())try{localStorage.setItem(n,String(d))}catch(p){console.warn(`[tandem] failed to persist ${n}:`,p)}};i={move:f,up:h},document.addEventListener("mousemove",f),document.addEventListener("mouseup",h)},handleResizeStep:a=>{const l=Math.max(Ka,Math.min(ud,u(r)+a));if(y(r,l,!0),t.getVisible())try{localStorage.setItem(n,String(l))}catch(c){console.warn(`[tandem] failed to persist ${n}:`,c)}}}}const o9={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 s9(t){const e=document.documentElement;return e.style.setProperty("--tandem-editor-font-family",o9[t]),()=>e.style.removeProperty("--tandem-editor-font-family")}function a9(t){he(()=>s9(t()))}function l9(){let t=I(!1);return{get fileDragOver(){return u(t)},handleEditorDragOver:i=>{var o;Nt()||(o=i.dataTransfer)!=null&&o.types.includes("Files")&&(i.preventDefault(),y(t,!0))},handleEditorDragLeave:i=>{Nt()||(i.currentTarget===i.target||!i.currentTarget.contains(i.relatedTarget))&&y(t,!1)},handleEditorDrop:async i=>{var a;if(Nt()||(y(t,!1),!((a=i.dataTransfer)!=null&&a.files.length)))return;i.preventDefault();const o=i.dataTransfer.files[0],s=await Fk(o);try{const l=await fetch(`${Nn}${kk}`,{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 Im(t){return!!(t!=null&&t.query)}function c9(){let t=I(null),e=I(null),n=I(null),r=I(!1),i=0;async function o(){const s=++i;try{const a=await fetch(HD,{credentials:"same-origin"});if(!a.ok){if(s!==i)return;y(t,!1),y(e,null),y(n,null),y(r,!0);return}const l=await a.json();if(s!==i)return;y(t,l.needed===!0),y(e,typeof l.serverVersion=="string"?l.serverVersion:null,!0),y(n,typeof l.confirmationNonce=="string"?l.confirmationNonce:null,!0),y(r,!0)}catch{if(s!==i)return;y(t,!1),y(e,null),y(n,null),y(r,!0)}}return o(),{get needed(){return u(t)},get serverVersion(){return u(e)},get confirmationNonce(){return u(n)},get settled(){return u(r)},refetch:o}}function d9(t,e=document.documentElement){return t?e.setAttribute("data-high-contrast","true"):e.removeAttribute("data-high-contrast"),()=>e.removeAttribute("data-high-contrast")}function u9(t){he(()=>d9(t()))}function f9(t,e,n,r){const i=new Map;let o=0,s=0;for(const a of t){const l=e(a);if(l){o++;try{const c=n(l.from);if(!Number.isFinite(c.top))continue;i.set(a.id,c.top-r)}catch{s++}}}return{positions:i,attempted:o,thrown:s}}function h9(t){let e=null;return{schedule(){e===null&&(e=requestAnimationFrame(()=>{e=null,t()}))},cancel(){e!==null&&(cancelAnimationFrame(e),e=null)}}}function p9(t){let e=I(We(new Map));function n(){if(!t.getEnabled()){u(e).size>0&&y(e,new Map,!0);return}const i=t.getEditor(),o=t.getLayerEl(),s=t.getYdoc();if(!i||!o||!s){u(e).size>0&&y(e,new Map,!0);return}const a=o.getBoundingClientRect().top,l=t.getAnnotations(),{positions:c,attempted:d,thrown:f}=f9(l,h=>Xc(h,i.state.doc,s),h=>i.view.coordsAtPos(h),a);d>0&&f===d&&console.warn(`[margin] coordsAtPos threw for all ${d} annotations — view may be detached`),!m9(u(e),c)&&y(e,c,!0)}const r=h9(n);return he(()=>{if(!t.getEnabled())return;const i=t.getEditor(),o=t.getLayerEl();if(!i||!o)return;const s=()=>r.schedule();i.on("transaction",s);const a=new ResizeObserver(()=>r.schedule());return a.observe(o),r.schedule(),()=>{i.off("transaction",s),a.disconnect(),r.cancel()}}),he(()=>{t.getAnnotations(),r.schedule()}),{get byId(){return u(e)}}}function m9(t,e){if(t.size!==e.size)return!1;for(const[n,r]of t){const i=e.get(n);if(i===void 0||Math.abs(i-r)>.5)return!1}return!0}function g9(){let t=I(We([]));const e=new Map,n=l=>{const c=e.get(l);c&&(clearTimeout(c),e.delete(l))},r=(l,c)=>{const d=e.get(l);d&&clearTimeout(d);const f=mw[c]??mw.info,h=setTimeout(()=>{y(t,u(t).filter(p=>p.id!==l),!0),e.delete(l)},f);e.set(l,h)},i=l=>{y(t,u(t).filter(c=>c.id!==l),!0),n(l)},o=`http://127.0.0.1:${Sl}${bM}`,s=new EventSource(o),a=l=>{if(l.dedupKey){const f=u(t).findIndex(h=>h.dedupKey===l.dedupKey);if(f!==-1){const h=u(t)[f];n(h.id);const p={...l,count:h.count+1},m=[...u(t)];m[f]=p,y(t,m,!0),r(p.id,p.severity);return}}const c={...l,count:1},d=[...u(t),c];for(;d.length>UM;){const f=d.shift();n(f.id)}y(t,d,!0),r(c.id,c.severity)};return s.onmessage=l=>{let c;try{c=JSON.parse(l.data)}catch{console.warn("[useNotifications] Malformed SSE data:",l.data);return}a(c)},s.onerror=()=>{s.readyState===EventSource.CLOSED&&console.warn("[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?")},Qr(()=>{s.close();for(const l of e.values())clearTimeout(l);e.clear()}),{get toasts(){return u(t)},dismiss:i,push:a}}function v9(t,e,n){if(t.length<2)return null;const o=(t.findIndex(s=>s.id===e)+(n?-1:1)+t.length)%t.length;return t[o].id}function y9(t,e,n){let r=null;Td(()=>{r=i=>{if(!i.ctrlKey&&!i.metaKey||i.key!=="Tab")return;const o=v9(t(),e(),i.shiftKey);o&&(i.preventDefault(),n(o))},window.addEventListener("keydown",r)}),Qr(()=>{r&&window.removeEventListener("keydown",r)})}function b9(t,e){if(t.length===0||e<1||e>9)return null;const n=Math.min(e-1,t.length-1);return t[n].id}function Dr(t){if(t.isComposing)return!0;const e=t.target;return e?e.tagName==="INPUT"||e.tagName==="TEXTAREA":!1}function ox(t,e){const n=new Set(e),r=t.filter(s=>n.has(s)),i=new Set(r),o=e.filter(s=>!i.has(s));return[...r,...o]}function w9(t,e,n,r,i="left"){const o=t.filter(f=>r.has(f)),s=o.indexOf(e),a=o.indexOf(n);if(s===-1||a===-1)return o;const l=[...o];l.splice(s,1);const c=l.indexOf(n),d=i==="right"?c+1:c;return l.splice(d,0,e),l}function x9(t){let e=I(We([]));he(()=>{const o=t().map(a=>a.id),s=ox(u(e),o);(u(e).length!==s.length||u(e).some((a,l)=>a!==s[l]))&&y(e,s,!0)});const n=F(()=>{const i=t(),o=new Map(i.map(l=>[l.id,l])),s=i.map(l=>l.id);return ox(u(e),s).map(l=>o.get(l)).filter(Boolean)});return{get orderedTabs(){return u(n)},reorder:(i,o,s="left")=>{if(i===o)return;const a=t(),l=new Set(a.map(c=>c.id));y(e,w9(u(e),i,o,l,s),!0)}}}function k9(t,e){let n=I(We((()=>{try{const r=localStorage.getItem($d),i=mM.safeParse(r);return i.success?i.data:cw}catch(r){return console.warn(`[tandem] localStorage unavailable reading ${$d}:`,r),cw}})()));return he(()=>{const r=u(n);try{localStorage.setItem($d,r)}catch(i){console.warn(`[tandem] failed to persist ${$d}:`,i)}}),he(()=>{const r=t(),i=u(n);if(r)try{r.getMap(fg).set(BM,i)}catch(o){console.warn("[tandem] failed to broadcast tandem mode to Y.Map:",o)}}),he(()=>{const r=t(),i=e();if(r)try{r.getMap(fg).set(VM,i)}catch(o){console.warn("[tandem] failed to broadcast dwell ms to Y.Map:",o)}}),{get tandemMode(){return u(n)},setTandemMode(r){y(n,r,!0)}}}let ef=I(!1),Rm=!1,yE=()=>{};const Nm={get fileDragOver(){return u(ef)}};function _9(t){const e=t.split(/[/\\]/).at(-1)??"",n=e.lastIndexOf(".");return n<=0?!1:Ih.has(e.slice(n).toLowerCase())}const S9=(()=>{const t=Array.from(Ih).sort();return t.length<=1?t[0]??"":t.length===2?`${t[0]} or ${t[1]}`:`${t.slice(0,-1).join(", ")}, or ${t.at(-1)}`})();function Tu(t,e,n){yE({id:`tauri-drop-${n}-${Date.now()}`,type:"general-error",severity:e,message:t,dedupKey:n,timestamp:Date.now()})}function C9(t){yE=t,!Rm&&Nt()&&(Rm=!0,Rn(()=>import("./webview-KiZyy_pC.js"),__vite__mapDeps([2,3,1,4])).then(async({getCurrentWebview:e})=>{await e().onDragDropEvent(n=>{try{const r=n.payload;switch(r.type){case"enter":y(ef,!0);return;case"drop":y(ef,!1);for(const i of r.paths)if(_9(i)){(async()=>{const o=await us(i);o.ok||Tu(`Couldn't open ${i}: ${o.error}`,"error","tauri-drop-open-failed")})();return}Tu(`Tandem can only open ${S9} files`,"warning","tauri-drop-unsupported");return;case"leave":y(ef,!1);return;default:console.warn("[useTauriFileDrop] unknown payload type:",r)}}catch(r){console.error("[useTauriFileDrop] callback threw:",r),Tu("Drag-and-drop encountered an error — try the Open File dialog","error","tauri-drop-callback-error")}})}).catch(e=>{Rm=!1,console.error("[useTauriFileDrop] Failed to attach onDragDropEvent:",e),Tu("Drag-and-drop unavailable — use the Open File dialog instead","warning","tauri-drop-unavailable")}))}var bd;class T9{constructor(){Ze(this,bd,I(We(Nt()?window.__TANDEM_INITIAL_THEME__??null:null)))}get current(){return u(ne(this,bd))}set current(e){y(ne(this,bd),e,!0)}}bd=new WeakMap;const mp=new T9;let sx=!1;function Pm(t){mp.current=t,typeof window<"u"&&(window.__TANDEM_INITIAL_THEME__=t)}function E9(){if(sx||!Nt())return;sx=!0;let t=null;Rn(async()=>{const{invoke:i}=await import("./core-DhEqZVGG.js");return{invoke:i}},[]).then(({invoke:i})=>{t=i,i("get_app_theme").then(o=>{Pm(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] get_app_theme failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri API import failed:",i)}),Rn(async()=>{const{getCurrentWindow:i}=await import("./window-DePn7tLG.js").then(o=>o.w);return{getCurrentWindow:i}},__vite__mapDeps([3,1,4])).then(({getCurrentWindow:i})=>{i().onThemeChanged(({payload:o})=>{Pm(o==="dark"?"dark":"light")}).catch(o=>{console.warn("[useTauriTheme] onThemeChanged subscribe failed:",o)})}).catch(i=>{console.warn("[useTauriTheme] Tauri window API import failed:",i)});let e=!1;const n=setInterval(()=>{!document.hasFocus()||!t||t("get_app_theme").then(i=>{const o=i==="dark"?"dark":"light";mp.current!==o&&(Pm(o),e=!1)}).catch(i=>{e||(console.warn("[useTauriTheme] theme poll failed (further errors suppressed):",i),e=!0)})},3e3),r=()=>clearInterval(n);window.addEventListener("pagehide",r,{once:!0})}function bE(){try{if(typeof window>"u")return"light";if(Nt()){const t=mp.current;if(t==="dark"||t==="light")return t;const e=window.__TANDEM_INITIAL_THEME__;if(e==="dark"||e==="light")return e}return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(t){return console.warn("[Tandem] Theme detection failed, defaulting to light:",t),"light"}}function A9(t){return t==="system"?bE():t}function ax(t){try{const e=document.querySelector('meta[name="theme-color"]');e&&(e.content=t==="dark"?"#1c1c24":t==="warm"?"#f1ead9":"#fafaf9")}catch{}}function M9(t){const e=document.documentElement,n=A9(t);if(e.setAttribute("data-theme",n),ax(n),t!=="system")return()=>e.removeAttribute("data-theme");if(Nt())return()=>e.removeAttribute("data-theme");const r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>{const o=bE();e.setAttribute("data-theme",o),ax(o)};return r.addEventListener("change",i),()=>{r.removeEventListener("change",i),e.removeAttribute("data-theme")}}function O9(t){E9(),he(()=>{const e=t();return mp.current,M9(e)})}function D9(){try{return localStorage.getItem(Pk)==="true"}catch{return!1}}function I9(t){return t.author==="user"&&!t.id.startsWith(Lk)}function lx(){try{localStorage.setItem(Pk,"true")}catch{}}function R9(t,e,n){let r=I(We(D9())),i=I(0),o=0;const s=S_(),a=F(()=>n()==="welcome.md"),l=F(()=>!u(r)&&u(a)),c=Nt(),d=E_(()=>c&&u(l)),f=F(()=>!c||d.status!==null||d.error!==null),h=F(()=>c&&__(d.status,s)),p=F(()=>u(f)?u(h)?4:3:1/0);return he(()=>{if(!u(l)||u(i)!==0)return;const b=t().filter(_=>_.id.startsWith(Lk));if(b.length===0)return;b.some(_=>_.status!=="pending")&&(o=Date.now(),y(i,1))}),he(()=>{if(!u(l)||u(i)!==1)return;t().some(I9)&&(o=Date.now(),y(i,2))}),he(()=>{if(!u(l)||u(i)!==2||!isFinite(u(p)))return;const g=e();if(!g)return;const b=()=>{Date.now()-o<2e3||g.isFocused&&(o=Date.now(),y(i,3))};return g.on("update",b),()=>{g.off("update",b)}}),he(()=>{if(!u(l)||!isFinite(u(p))||u(i)!==u(p))return;const g=setTimeout(()=>{lx(),y(r,!0)},3e3);return()=>clearTimeout(g)}),he(()=>{isFinite(u(p))&&u(i)>u(p)&&y(i,u(p),!0)}),{get tutorialActive(){return u(l)},get currentStep(){return u(i)},get coworkStatus(){return d.status},dismissTutorial:()=>{lx(),y(r,!0)},nextStep:()=>{o=Date.now(),y(i,Math.min(u(i)+1,u(p)),!0)}}}const N9="tandem://update-available",P9="tandem:updater-dismissed-v";function wE(t){return`${P9}${t}`}function xE(t){try{return window.localStorage.getItem(wE(t))==="1"}catch{return!1}}function L9(t){try{window.localStorage.setItem(wE(t),"1")}catch{}}let kE=I(null),wh=I(null),Ea=0,Lm=null,Eu=!1,zm=0;function cx(){return Ea}function As(){return u(kE)}function _E(){return u(wh)}function SE(t){t&&(L9(t),y(wh,t,!0))}function CE(){if(Ea+=1,Ea===1&&Nt()){Eu=!1;const e=++zm;(async()=>{try{const{listen:n}=await Rn(async()=>{const{listen:i}=await import("./event-CNdo2oXa.js");return{listen:i}},__vite__mapDeps([4,1]));if(Eu||e!==zm||cx()===0)return;const r=await n(N9,i=>{var s;const o=((s=i.payload)==null?void 0:s.version)??null;o&&(y(kE,o,!0),u(wh)!==o&&y(wh,null))});if(Eu||e!==zm||cx()===0){r();return}Lm=r}catch(n){console.warn("[useUpdaterChannel] listen() failed:",n)}})()}let t=!1;return()=>{if(!t&&(t=!0,Ea=Math.max(0,Ea-1),Ea===0)){Eu=!0;const e=Lm;if(Lm=null,e)try{e()}catch(n){console.warn("[useUpdaterChannel] unlisten threw:",n)}}}}function z9(){return he(()=>CE()),{get availableVersion(){return As()},get showDot(){const t=As();return!(!t||_E()===t||xE(t))},acknowledge(){SE(As())}}}const dx=3e4;function F9(){let t=I(!1),e=null;function n(){e!==null&&(clearTimeout(e),e=null)}he(()=>{const i=CE();return()=>{n(),i()}});async function r(){if(!(!As()||u(t))){y(t,!0),n(),e=setTimeout(()=>{e=null,y(t,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${dx}ms; re-arming CTA`)},dx);try{const{invoke:o}=await Rn(async()=>{const{invoke:s}=await import("./core-DhEqZVGG.js");return{invoke:s}},[]);await o("install_update"),n(),y(t,!1)}catch(o){console.warn("[useUpdaterBanner] install_update failed:",o),n(),y(t,!1)}}}return{get availableVersion(){return As()},get installing(){return u(t)},get showBanner(){const i=As();return!(!i||_E()===i||xE(i))},dismiss(){SE(As())},install:r}}function B9(){let t=I(We(window.innerWidth));return he(()=>{let e=null;const n=()=>{e===null&&(e=requestAnimationFrame(()=>{y(t,window.innerWidth,!0),e=null}))};return window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n),e!==null&&cancelAnimationFrame(e)}}),{get width(){return u(t)}}}function V9(){let t=null;Td(()=>{let e=!1,n;Rn(async()=>{const{getCurrentWebview:r}=await import("./webview-KiZyy_pC.js");return{getCurrentWebview:r}},__vite__mapDeps([2,3,1,4])).then(({getCurrentWebview:r})=>{if(e)return;const i=r();let o=Hl;try{const d=localStorage.getItem(gw);if(d!==null){const f=Number(d);Number.isFinite(f)?o=Math.max(vw,Math.min(yw,f)):console.warn(`[tandem] ignoring invalid stored zoom: ${d}`)}}catch{}o!==Hl&&i.setZoom(o).catch(d=>{console.warn("[tandem] failed to restore zoom level:",d)});function s(d){try{localStorage.setItem(gw,String(d))}catch{}}const a=d=>{!(d.metaKey||d.ctrlKey)||d.key!=="0"||(d.preventDefault(),d.stopPropagation(),o=Hl,i.setZoom(Hl).catch(h=>{console.warn("[tandem] failed to reset zoom:",h)}),s(Hl))},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(vw,Math.min(yw,Math.round(m*100)/100)),s(o)};window.addEventListener("keydown",a,{capture:!0}),window.addEventListener("keydown",c,{capture:!0}),n=()=>{window.removeEventListener("keydown",a,{capture:!0}),window.removeEventListener("keydown",c,{capture:!0})}}).catch(()=>{}),t=()=>{e=!0,n==null||n()}}),Qr(()=>{t==null||t()})}function H9(t){const{prev:e,serverActiveId:n,serverIds:r,removedCount:i,serverEpoch:o,lastAppliedEpoch:s}=t;return e===null||!r.has(e)?n:i>0&&n===e?e:o!==s?n:e}function U9(t,e,n){return t.filter(r=>!e.has(r.id)&&!n.has(r.id))}function j9(){let t=I(We([])),e=I(null),n=I(!1),r=I("connecting"),i=I(0),o=I(null),s=I(We([])),a=I(null),l=I(!1),c=I(null),d=I(!1),f=I(!1),h=I(!1),p=I(!1),m=I(null),v=null,g=!1,b=null,x=null;const _=new Set,A=new Map,M=new Map,P=new Map;let D=!1;const L=ee=>{const{ydoc:ie}=ee,K=ie.getMap(xo),Y=()=>{const ue=[];K.forEach(pe=>{ue.push(ta(pe,_e=>{console.warn("[sanitize]",_e)}))}),y(s,ue,!0)};K.observe(Y),Y();const O=ie.getMap(Ok);let T=null,C=!1,Z=null;const q=ue=>ue?`${ue.tool} ${ue.annotationId??""} ${ue.token??ue.startedAt}`:null,oe=()=>{const ue=O.get(hg),pe=(ue==null?void 0:ue.status)??null,_e=(ue==null?void 0:ue.active)??!1,ae=(ue==null?void 0:ue.working)??null;pe!==T&&(T=pe,y(a,pe,!0)),_e!==C&&(C=_e,y(l,_e,!0));const de=q(ae);de!==Z&&(Z=de,y(c,ae,!0))};O.observe(oe),oe();const ge=ie.getMap(zu);let $=!1;const le=ue=>{if(!ue.keysChanged.has(Dp))return;const pe=ge.get(Dp)===!0;pe!==$&&($=pe,y(d,pe))};ge.observe(le);const ce=ge.get(Dp)===!0;return ce!==$&&($=ce,y(d,ce)),()=>{K.unobserve(Y),O.unobserve(oe),ge.unobserve(le)}},X=(ee,ie,K)=>{var $,le;const Y=u(t),O=new Set(Y.map(ce=>ce.id)),T=new Set(ee.map(ce=>ce.id));for(const ce of Y)_.delete(ce.id),A.delete(ce.id);for(const[ce,ue]of A)T.has(ce)||(($=P.get(ce))==null||$(),P.delete(ce),ue.provider.destroy(),ue.ydoc.destroy(),A.delete(ce),_.delete(ce));const C=U9(ee,O,_),Z=[];for(const ce of C){_.add(ce.id);const ue=new zi,pe=new A0({url:`ws://127.0.0.1:${lw}`,name:ce.id,document:ue});A.set(ce.id,{ydoc:ue,provider:pe});const _e=ue.getMap(zu),ae=de=>{if(!de.keysChanged.has(Fl)&&!de.keysChanged.has(Bl)&&!de.keysChanged.has(Vl))return;const ye=_e.get(Fl),ke=_e.get(Bl),Ve=_e.get(Vl);ye&&X(ye,ke??null,Ve??null)};_e.observe(ae),P.set(ce.id,()=>_e.unobserve(ae)),Z.push({...ce,ydoc:ue,provider:pe})}const q=Y.filter(ce=>!T.has(ce.id));for(const ce of q){const ue=M.get(ce.id);ue&&(ue.cleanup(),M.delete(ce.id)),(le=P.get(ce.id))==null||le(),P.delete(ce.id),_.delete(ce.id),A.delete(ce.id),ce.provider.destroy(),ce.ydoc.destroy()}const oe=new Map(ee.map(ce=>[ce.id,ce])),ge=Y.filter(ce=>T.has(ce.id)).map(ce=>{const ue=oe.get(ce.id);return!ue||ue.fileName===ce.fileName&&ue.filePath===ce.filePath&&ue.format===ce.format&&ue.readOnly===ce.readOnly?ce:{...ce,fileName:ue.fileName,filePath:ue.filePath,format:ue.format,readOnly:ue.readOnly}});y(t,[...ge,...Z],!0),ie!==null&&(y(e,H9({prev:u(e),serverActiveId:ie,serverIds:T,removedCount:q.length,serverEpoch:K,lastAppliedEpoch:x}),!0),x=K)};let z=null,re=null;{const ee=new zi,ie=new A0({url:`ws://127.0.0.1:${lw}`,name:FM,document:ee});y(m,ee,!0),re=ie,ie.on("status",({status:q})=>{y(n,q==="connected"),y(r,["connected","connecting","disconnected"].includes(q)?q:"connecting",!0),q==="connected"?(g=!0,y(i,0),y(o,null)):q==="disconnected"?u(o)===null&&y(o,Date.now(),!0):q==="connecting"&&(g&&y(i,u(i)+1),u(o)===null&&y(o,Date.now(),!0))});const K=ee.getMap(zu),Y=q=>{if(q.keysChanged.has(Op)){const oe=K.get(Op);oe&&b&&oe!==b&&(console.warn("[Tandem] Server restarted — refreshing documents"),y(p,!0),x=null,v&&clearTimeout(v),v=setTimeout(()=>{y(p,!1)},5e3)),oe&&(b=oe)}if(q.keysChanged.has(Fl)||q.keysChanged.has(Bl)||q.keysChanged.has(Vl)){const oe=K.get(Fl),ge=K.get(Bl),$=K.get(Vl);oe&&X(oe,ge??null,$??null)}q.keysChanged.has(Ip)&&y(f,K.get(Ip)===!0)};K.observe(Y);const O=K.get(Op);O&&(b=O);const T=K.get(Fl),C=K.get(Bl),Z=K.get(Vl);T&&X(T,C??null,Z??null),y(f,K.get(Ip)===!0),z=()=>{K.unobserve(Y),v&&(clearTimeout(v),v=null),ie.destroy(),ee.destroy(),y(m,null),re=null},y(h,!0)}const Q=F(()=>u(t).find(ee=>ee.id===u(e))??null),N=F(()=>{var ee;return((ee=u(Q))==null?void 0:ee.ydoc)??null}),B=XA(()=>{he(()=>{u(N);const ee=u(Q);for(const ie of M.values())ie.cleanup();if(M.clear(),ee){const ie=L(ee);M.set(ee.id,{cleanup:ie})}else y(s,[],!0),y(a,null),y(l,!1),y(c,null),y(d,!1)})});return{get tabs(){return u(t)},get activeTabId(){return u(e)},setActiveTabId:ee=>{y(e,ee,!0)},handleTabClose:ee=>{if(u(e)===ee){const ie=u(t),K=ie.findIndex(O=>O.id===ee),Y=ie.filter(O=>O.id!==ee);Y.length===0?y(e,null):y(e,Y[Math.min(K,Y.length-1)].id,!0)}fetch(`http://127.0.0.1:${Sl}${xM}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({documentId:ee})}).then(ie=>{ie.ok||console.warn("[Tandem] Server rejected close:",ie.status)}).catch(ie=>{console.warn("[Tandem] Failed to close document on server:",ie)})},get connected(){return u(n)},get connectionStatus(){return u(r)},get reconnectAttempts(){return u(i)},get disconnectedSince(){return u(o)},get annotations(){return u(s)},get claudeStatus(){return u(a)},get claudeActive(){return u(l)},get claudeWorking(){return u(c)},get readOnly(){return u(d)},get storeReadOnly(){return u(f)},get bootstrapYdoc(){return u(m)},get ready(){return u(h)},get serverRestarted(){return u(p)},destroy:()=>{if(!D){D=!0,B();for(const ee of M.values())ee.cleanup();M.clear();for(const ee of P.values())ee();P.clear();for(const ee of A.values())ee.provider.destroy(),ee.ydoc.destroy();A.clear(),_.clear();for(const ee of u(t))ee.provider.destroy(),ee.ydoc.destroy();z==null||z(),y(t,[],!0),y(s,[],!0),y(e,null),y(h,!1)}},reconnect(){re==null||re.connect();for(const ee of u(t))ee.provider.connect()}}}function W9(t,e){const n=F(()=>t.settings.leftPanelVisible),r=F(()=>t.settings.rightPanelVisible&&!(e.tandemMode==="solo"&&t.settings.soloRailHidden));function i(){t.updateSettings({leftPanelVisible:!t.settings.leftPanelVisible})}function o(){if(u(r)){t.updateSettings({rightPanelVisible:!1});return}t.updateSettings({rightPanelVisible:!0,...e.tandemMode==="solo"?{soloRailHidden:!1}:{}})}return{get leftVisible(){return u(n)},get rightVisible(){return u(r)},toggleLeft:i,toggleRight:o}}const K9=6;function q9(t,e={}){const n=e.gap??K9,r=new Map;if(t.length===0)return r;const i=t.map((s,a)=>({...s,idx:a})).sort((s,a)=>s.top-a.top||s.idx-a.idx);let o=Number.NEGATIVE_INFINITY;for(const s of i){if(!Number.isFinite(s.top))continue;const a=Math.max(s.top,o);r.set(s.id,a),typeof s.height=="number"&&Number.isFinite(s.height)&&s.height>0&&(o=a+s.height+n)}return r}function G9(t,e){const n=[];for(const r of t.keys())e.has(r)||n.push(r);for(const r of n)t.delete(r);return n.length}var J9=Ui('<line stroke="currentColor" stroke-linecap="round" fill="none"></line>'),Y9=E('<div class="margin-bubble svelte-lzz9jv"><!></div>'),Z9=E('<svg aria-hidden="true"></svg> <div></div>',1);function ux(t,e){Pe(e,!0);const n=12,r=F(()=>e.side==="right"?"claude":"user"),i=F(()=>e.side==="right"?0:e.gap),o=F(()=>e.side==="right"?e.gap:0),s=F(()=>`position: absolute; top: 0; bottom: 0; ${e.side}: ${e.edgeInset+e.width}px; width: ${e.gap}px; pointer-events: none; color: var(--tandem-author-${u(r)});`),a=F(()=>e.annotations.filter(m=>e.positions.has(m.id)&&m.status==="pending"));let l=I(We(new Map));const c=F(()=>{const m=u(a).map(v=>({id:v.id,top:e.positions.get(v.id)??0,height:u(l).get(v.id)}));return q9(m)});he(()=>{const m=new Set(u(a).map(v=>v.id));vt(()=>{G9(u(l),m)>0&&y(l,new Map(u(l)),!0)})});function d(m,v){if(!Number.isFinite(v)||v<=0)return;const g=u(l).get(m);if(g!==void 0&&Math.abs(g-v)<.5)return;const b=new Map(u(l));b.set(m,v),y(l,b,!0)}var f=Z9(),h=Se(f);Ye(h,21,()=>u(a),m=>m.id,(m,v)=>{const g=F(()=>e.positions.get(u(v).id)),b=F(()=>u(c).get(u(v).id));var x=ft(),_=Se(x);{var A=M=>{const P=F(()=>u(v).id===e.activeAnnotationId);var D=J9();U(()=>{G(D,"data-annotation-id",u(v).id),G(D,"x1",u(i)),G(D,"y1",u(g)),G(D,"x2",u(o)),G(D,"y2",u(b)+n),G(D,"stroke-width",u(P)?1.75:1),G(D,"stroke-opacity",u(P)?.9:.4)}),S(M,D)};J(_,M=>{u(g)!==void 0&&u(b)!==void 0&&M(A)})}S(m,x)});var p=k(h,2);Ye(p,21,()=>u(a),m=>m.id,(m,v)=>{const g=F(()=>u(c).get(u(v).id)??e.positions.get(u(v).id)??0),b=F(()=>Xh(u(v),e.repliesById.get(u(v).id)));var x=Y9(),_=w(x);{let A=F(()=>u(v).id===e.activeAnnotationId),M=F(()=>u(v).author!=="user"?e.onAccept:void 0),P=F(()=>u(v).author!=="user"?e.onDismiss:void 0),D=F(()=>u(v).author==="user"?e.onRemove:void 0),L=F(()=>u(v).type==="note"?e.onSendToClaude:void 0);Hg(_,{get annotation(){return u(v)},get replies(){return u(b)},get isReviewTarget(){return u(A)},onClick:()=>e.onClick(u(v)),get onAccept(){return u(M)},get onDismiss(){return u(P)},get onRemove(){return u(D)},get onSendToClaude(){return u(L)},get onEdit(){return e.onEdit},get onReply(){return e.onReply}})}U(()=>{G(x,"data-testid",`margin-bubble-${u(v).id??""}`),G(x,"data-margin-bubble-reply-count",u(b).length),ve(x,`position: absolute; top: ${u(g)??""}px; ${e.side??""}: 0; width: ${e.width??""}px; pointer-events: auto;`)}),R2(x,"clientHeight",A=>d(u(v).id,A)),S(m,x)}),U(()=>{G(h,"data-testid",`margin-leaders-${e.side??""}`),ve(h,u(s)),G(p,"data-testid",`margin-column-${e.side??""}`),G(p,"aria-label",e.side==="left"?"Note bubbles":"Comment bubbles"),ve(p,`position: absolute; top: 0; ${e.side??""}: ${e.edgeInset??""}px; width: ${e.width??""}px; pointer-events: none;`)}),S(t,f),Le()}var X9=E('<button type="button" tabindex="-1" aria-expanded="false"><span class="peek-chevron svelte-1mwvi22" aria-hidden="true"> </span></button>');function fx(t,e){Pe(e,!0);function n(s){(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),e.onActivate())}var r=X9(),i=w(r),o=w(i);U(()=>{Xr(r,1,`peek-strip peek-strip-${e.side??""}`,"svelte-1mwvi22"),G(r,"data-testid",`peek-strip-${e.side}`),G(r,"aria-label",e.side==="left"?"Show left panel":"Show right panel"),te(o,e.side==="left"?"›":"‹")}),R("click",r,function(...s){var a;(a=e.onActivate)==null||a.apply(this,s)}),R("keydown",r,n),S(t,r),Le()}Ke(["click","keydown"]);const hx=t=>{console.warn("[sanitize]",t)};function Q9(t,e,n){if(t.suggestedText===void 0)return!1;const r=t.suggestedText,i=Xc(t,e.state.doc,n);if(!i)return console.warn("[SidePanel] Could not resolve range for suggestion",t.id),!1;try{e.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,r).run()}catch(o){return console.error("[SidePanel] Editor mutation failed for suggestion",t.id,o),!1}return!0}function $9({getYdoc:t,getEditor:e,getAnnotations:n,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:o}){let s=I(0),a=I(We(new Set));const l=new Map;Qr(()=>{for(const x of l.values())clearTimeout(x);l.clear()});function c(){return n().filter(ff)}function d(){const x=c();return x.length>0?x[u(s)]??null:null}function f(x,_){const A=t();if(!A)return;const M=A.getMap(xo),P=M.get(x);if(!P||P.status!=="pending")return;const D=ta(P,hx);if(M.set(x,{...D,status:_}),_==="accepted"&&D.suggestedText!==void 0){const L=e();if(L&&!Q9(D,L,A)){M.set(x,{...D,status:"pending"});return}}y(a,new Set(u(a)).add(x),!0)}function h(x){const _=l.get(x);_&&clearTimeout(_),l.set(x,setTimeout(()=>{l.delete(x);const A=new Set(u(a));A.delete(x),y(a,A,!0)},3e3))}function p(x){const _=l.get(x);_&&(clearTimeout(_),l.delete(x));const A=new Set(u(a));A.delete(x),y(a,A,!0)}function m(x){const _=t();if(!_)return!1;const A=_.getMap(xo),M=A.get(x);if(!M||M.status==="pending")return p(x),!1;const P=ta(M,hx),D=e();if(P.status==="accepted"&&P.suggestedText!==void 0&&D)try{const L=P.suggestedText,X=P.textSnapshot;if(typeof L=="string"&&typeof X=="string"){const z=Xc(P,D.state.doc,_);if(!z)return console.warn(`[undo] Cannot resolve range for annotation ${x}, skipping`),h(x),!1;if(D.state.doc.textBetween(z.from,z.to)!==L)return console.warn(`[undo] Text changed since accept for annotation ${x}, skipping`),h(x),!1;D.chain().focus().deleteRange({from:z.from,to:z.to}).insertContentAt(z.from,X).run()}}catch(L){return console.warn(`[undo] Failed to revert text for annotation ${x}:`,L),h(x),!1}return A.set(x,{...P,status:"pending"}),p(x),!0}function v(x){f(x,"accepted")}function g(x){f(x,"dismissed")}function b(x){const _=e();if(!_)return;const A=Xc(x,_.state.doc,t());if(!A)return;_.chain().focus().setTextSelection({from:A.from,to:A.to}).run();const M=_.view.domAtPos(A.from),P=M.node instanceof HTMLElement?M.node:M.node.parentElement;P==null||P.scrollIntoView({behavior:i(),block:"center"})}return he(()=>{var P;const _=((P=c()[u(s)])==null?void 0:P.id)??null,A=(o==null?void 0:o())??null;if(A===null){r(_);return}n().some(D=>D.id===A&&D.status==="pending")||r(_)}),he(()=>{const x=c();u(s)>=x.length&&y(s,Math.max(0,x.length-1),!0)}),{resolveAnnotation:f,undoResolveAnnotation:m,handleAccept:v,handleDismiss:g,scrollToAnnotation:b,getRecentlyResolved:()=>u(a),getReviewIndex:()=>u(s),getReviewTargets:c,getActiveReviewAnn:d}}function no(t,e){function n(r){t.contains(r.target)||e(r)}return document.addEventListener("mousedown",n),{destroy(){document.removeEventListener("mousedown",n)}}}var eK=Ui('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M4 7L1 4l3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M1 4h9a5 5 0 0 1 0 10H7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),tK=Ui('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M12 7l3-3-3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M15 4H6a5 5 0 0 0 0 10h3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),nK=E('<button type="button" role="menuitem"> </button>'),rK=E(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
235
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
236
|
+
border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
|
|
237
|
+
gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),iK=Ui('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="4" r="1.5" fill="currentColor"></circle><circle cx="2" cy="8" r="1.5" fill="currentColor"></circle><circle cx="2" cy="12" r="1.5" fill="currentColor"></circle><rect x="5" y="3" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="7" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="11" width="9" height="2" rx="1" fill="currentColor"></rect></svg>'),oK=Ui('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="5" y="3" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="7" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="11" width="9" height="2" rx="1" fill="currentColor"></rect><text x="0" y="5.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">1.</text><text x="0" y="9.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">2.</text><text x="0" y="13.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">3.</text></svg>'),sK=Ui('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="2" width="3" height="12" rx="1.5" fill="currentColor"></rect><rect x="5" y="4" width="9" height="2" rx="1" fill="currentColor" opacity="0.7"></rect><rect x="5" y="8" width="7" height="2" rx="1" fill="currentColor" opacity="0.7"></rect><rect x="5" y="12" width="8" height="2" rx="1" fill="currentColor" opacity="0.7"></rect></svg>'),aK=Ui('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 8.5a3.5 3.5 0 0 0 5 0l2-2a3.5 3.5 0 0 0-5-5l-1 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.5 7.5a3.5 3.5 0 0 0-5 0l-2 2a3.5 3.5 0 0 0 5 5l1-1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),lK=E(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
238
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
239
|
+
border-radius: var(--tandem-r-3); padding: 6px;
|
|
240
|
+
display: flex; align-items: center; gap: 4px;
|
|
241
|
+
z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1); min-width: 240px;"><input data-testid="toolbar-link-input" type="url" placeholder="https://" style="flex: 1; height: 26px; padding: 2px 6px; font-size: 12px;
|
|
242
|
+
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
243
|
+
background: var(--tandem-surface); color: var(--tandem-fg);
|
|
244
|
+
outline: none; font-family: inherit;"/> <button type="button" data-testid="toolbar-link-submit" style="height: 26px; padding: 0 8px; font-size: 12px; font-weight: 500;
|
|
245
|
+
border: 1px solid var(--tandem-accent-border); background: transparent;
|
|
246
|
+
color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
|
|
247
|
+
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;
|
|
248
|
+
border: 1px solid var(--tandem-border); background: transparent;
|
|
249
|
+
color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),cK=Ui('<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>'),dK=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 uK(t,e){Pe(e,!0);const n=nt(e,"disabled",3,!1),r=[1,2,3],i={1:700,2:600,3:500};let o=I(0),s=I(!1),a=I(!1),l=I(""),c=I(null);he(()=>{const K=e.editor;if(!K||K.isDestroyed)return;const Y=()=>{K.isDestroyed||Tc(o)};return K.on("transaction",Y),()=>{K.isDestroyed||K.off("transaction",Y)}}),he(()=>{var K,Y;u(a)&&((K=u(c))==null||K.focus(),(Y=u(c))==null||Y.select())});function d(K){for(const Y of r)if(K.isActive("heading",{level:Y}))return Y;return null}const f=F(()=>e.editor?e.editor.isEditable:!1),h=F(()=>!u(f)||!!n()),p=F(()=>(u(o),e.editor?Ii.getState(e.editor.state):null)),m=F(()=>{var K,Y;return!u(h)&&(((Y=(K=u(p))==null?void 0:K.undoManager)==null?void 0:Y.undoStack.length)??0)>0}),v=F(()=>{var K,Y;return!u(h)&&(((Y=(K=u(p))==null?void 0:K.undoManager)==null?void 0:Y.redoStack.length)??0)>0}),g=F(()=>(u(o),e.editor?d(e.editor):null)),b=F(()=>{var K;return u(o),!!((K=e.editor)!=null&&K.isActive("bold"))}),x=F(()=>{var K;return u(o),!!((K=e.editor)!=null&&K.isActive("italic"))}),_=F(()=>{var K;return u(o),!!((K=e.editor)!=null&&K.isActive("strike"))}),A=F(()=>{var K;return u(o),!!((K=e.editor)!=null&&K.isActive("code"))}),M=F(()=>{var K;return u(o),!!((K=e.editor)!=null&&K.isActive("bulletList"))}),P=F(()=>{var K;return u(o),!!((K=e.editor)!=null&&K.isActive("orderedList"))}),D=F(()=>{var K;return u(o),!!((K=e.editor)!=null&&K.isActive("blockquote"))}),L=F(()=>{var K;return u(o),!!((K=e.editor)!=null&&K.isActive("codeBlock"))}),X=F(()=>{var K;return u(o),!!((K=e.editor)!=null&&K.isActive("link"))}),z=F(()=>(u(o),e.editor?u(h)||!e.editor.isActive("link")&&e.editor.state.selection.from===e.editor.state.selection.to:!0)),re=F(()=>u(g)?`H${u(g)}`:"H");function Q(K){return Y=>{Y.preventDefault(),!(!e.editor||e.editor.isDestroyed)&&(e.editor.chain().focus().toggleHeading({level:K}).run(),y(s,!1))}}function N(K){K.preventDefault(),e.editor&&(y(l,LW(e.editor),!0),y(a,!0))}function B(){e.editor&&(zW(e.editor,u(l)),j())}function j(){y(a,!1),y(l,"")}function H(K){K.key==="Enter"?(K.preventDefault(),B()):K.key==="Escape"&&(K.preventDefault(),j())}var W=ft(),ee=Se(W);{var ie=K=>{var Y=dK(),O=w(Y);{const fe=Ge=>{var Te=eK();S(Ge,Te)};let Ee=F(()=>!u(m)),Re=F(()=>yr(()=>e.editor.commands.undo()));zn(O,{ariaLabel:"Undo",shortcut:"Ctrl+Z",get disabled(){return u(Ee)},get onMouseDown(){return u(Re)},style:"min-width: 30px; padding: 4px 6px;",children:fe,$$slots:{default:!0}})}var T=k(O,2);{const fe=Ge=>{var Te=tK();S(Ge,Te)};let Ee=F(()=>!u(v)),Re=F(()=>yr(()=>e.editor.commands.redo()));zn(T,{ariaLabel:"Redo",shortcut:"Ctrl+Shift+Z",get disabled(){return u(Ee)},get onMouseDown(){return u(Re)},style:"min-width: 30px; padding: 4px 6px;",children:fe,$$slots:{default:!0}})}var C=k(T,4);{let fe=F(()=>yr(()=>e.editor.chain().focus().toggleBold().run()));zn(C,{label:"B",shortcut:"Ctrl+B",get disabled(){return u(h)},get active(){return u(b)},get onMouseDown(){return u(fe)},style:"font-weight: 700; min-width: 30px;"})}var Z=k(C,2);{let fe=F(()=>yr(()=>e.editor.chain().focus().toggleItalic().run()));zn(Z,{label:"I",shortcut:"Ctrl+I",get disabled(){return u(h)},get active(){return u(x)},get onMouseDown(){return u(fe)},style:"font-style: italic; min-width: 30px;"})}var q=k(Z,2);{let fe=F(()=>yr(()=>e.editor.chain().focus().toggleStrike().run()));zn(q,{label:"S",shortcut:"Ctrl+Shift+X",get disabled(){return u(h)},get active(){return u(_)},get onMouseDown(){return u(fe)},style:"text-decoration: line-through; min-width: 30px;"})}var oe=k(q,2);{let fe=F(()=>yr(()=>e.editor.chain().focus().toggleCode().run()));zn(oe,{label:"<>",shortcut:"Ctrl+E",get disabled(){return u(h)},get active(){return u(A)},get onMouseDown(){return u(fe)},style:"font-family: monospace; min-width: 30px;"})}var ge=k(oe,2),$=w(ge);{let fe=F(()=>u(g)!==null);zn($,{get label(){return u(re)},get disabled(){return u(h)},get active(){return u(fe)},onMouseDown:Ee=>{Ee.preventDefault(),y(s,!u(s))},style:"min-width: 30px;"})}var le=k($,2);{var ce=fe=>{var Ee=rK();Ye(Ee,20,()=>r,Re=>Re,(Re,Ge)=>{var Te=nK(),Me=F(()=>Q(Ge)),dt=w(Te);U(()=>{ve(Te,`padding: 4px 12px; font-size: 13px; border: none;
|
|
250
|
+
border-radius: var(--tandem-r-2);
|
|
251
|
+
background: ${u(g)===Ge?"var(--tandem-accent-bg)":"transparent"};
|
|
252
|
+
color: ${u(g)===Ge?"var(--tandem-accent)":"var(--tandem-fg)"};
|
|
253
|
+
cursor: pointer; text-align: left;
|
|
254
|
+
font-weight: ${i[Ge]??""}; white-space: nowrap;`),te(dt,`Heading ${Ge??""}`)}),R("mousedown",Te,function(...Kt){var ze;(ze=u(Me))==null||ze.apply(this,Kt)}),S(Re,Te)}),S(fe,Ee)};J(le,fe=>{u(s)&&fe(ce)})}Tr(ge,(fe,Ee)=>no==null?void 0:no(fe,Ee),()=>()=>y(s,!1));var ue=k(ge,4);{const fe=Re=>{var Ge=iK();S(Re,Ge)};let Ee=F(()=>yr(()=>e.editor.chain().focus().toggleBulletList().run()));zn(ue,{ariaLabel:"Bullet list",shortcut:"Ctrl+Shift+8",get disabled(){return u(h)},get active(){return u(M)},get onMouseDown(){return u(Ee)},style:"min-width: 30px; padding: 4px 6px;",children:fe,$$slots:{default:!0}})}var pe=k(ue,2);{const fe=Re=>{var Ge=oK();S(Re,Ge)};let Ee=F(()=>yr(()=>e.editor.chain().focus().toggleOrderedList().run()));zn(pe,{ariaLabel:"Ordered list",shortcut:"Ctrl+Shift+7",get disabled(){return u(h)},get active(){return u(P)},get onMouseDown(){return u(Ee)},style:"min-width: 30px; padding: 4px 6px;",children:fe,$$slots:{default:!0}})}var _e=k(pe,2);{const fe=Re=>{var Ge=sK();S(Re,Ge)};let Ee=F(()=>yr(()=>e.editor.chain().focus().toggleBlockquote().run()));zn(_e,{ariaLabel:"Blockquote",shortcut:"Ctrl+Shift+B",get disabled(){return u(h)},get active(){return u(D)},get onMouseDown(){return u(Ee)},style:"min-width: 30px; padding: 4px 6px;",children:fe,$$slots:{default:!0}})}var ae=k(_e,4),de=w(ae);{const fe=Re=>{var Ge=aK();S(Re,Ge)};let Ee=F(()=>u(X)||u(a));zn(de,{ariaLabel:"Link",shortcut:"Ctrl+K",get disabled(){return u(z)},get active(){return u(Ee)},onMouseDown:N,style:"min-width: 30px; padding: 4px 6px;",children:fe,$$slots:{default:!0}})}var ye=k(de,2);{var ke=fe=>{var Ee=lK(),Re=w(Ee);pt(Re,Me=>y(c,Me),()=>u(c));var Ge=k(Re,2),Te=k(Ge,2);R("keydown",Re,H),Bn(Re,()=>u(l),Me=>y(l,Me)),R("mousedown",Ge,Me=>{Me.preventDefault(),B()}),R("mousedown",Te,Me=>{Me.preventDefault(),j()}),S(fe,Ee)};J(ye,fe=>{u(a)&&fe(ke)})}Tr(ae,(fe,Ee)=>no==null?void 0:no(fe,Ee),()=>j);var Ve=k(ae,2);{let fe=F(()=>yr(()=>e.editor.chain().focus().setHorizontalRule().run()));zn(Ve,{label:"—",ariaLabel:"Horizontal rule",get disabled(){return u(h)},get onMouseDown(){return u(fe)},style:"min-width: 30px;"})}var qe=k(Ve,2);{const fe=Re=>{var Ge=cK();S(Re,Ge)};let Ee=F(()=>yr(()=>e.editor.chain().focus().toggleCodeBlock().run()));zn(qe,{ariaLabel:"Code block",get disabled(){return u(h)},get active(){return u(L)},get onMouseDown(){return u(Ee)},style:"min-width: 30px; padding: 4px 6px;",children:fe,$$slots:{default:!0}})}R("keydown",ge,fe=>{fe.key==="Escape"&&y(s,!1)}),R("keydown",ae,fe=>{fe.key==="Escape"&&j()}),S(K,Y)};J(ee,K=>{e.editor&&K(ie)})}S(t,W),Le()}Ke(["keydown","mousedown"]);var fK=E("<button></button>"),hK=E(`<div style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
255
|
+
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
256
|
+
border-radius: var(--tandem-r-3); padding: 6px; display: flex; gap: 4px;
|
|
257
|
+
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);
|
|
258
|
+
border: 1px solid var(--tandem-border);
|
|
259
|
+
background: var(--tandem-surface-muted); cursor: pointer; padding: 0;
|
|
260
|
+
font-size: 13px; color: var(--tandem-fg-muted);
|
|
261
|
+
display: flex; align-items: center; justify-content: center;">✕</button></div>`),pK=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 mK(t,e){Pe(e,!0);const n=[{value:"yellow",label:"Yellow"},{value:"green",label:"Green"},{value:"blue",label:"Blue"},{value:"pink",label:"Pink"}],r=nt(e,"disabled",3,!1);let i=I("yellow"),o=I(!1),s=I(null);he(()=>{if(u(o))return bb(()=>u(s),["mousedown"],()=>{y(o,!1)},{capture:!1})});function a(g){g.preventDefault(),e.onHighlight(u(i))}function l(g){g.preventDefault(),y(o,!u(o))}function c(g){y(i,g,!0),y(o,!1)}var d=pK(),f=w(d);zn(f,{label:"Highlight",testId:"toolbar-highlight-btn",get disabled(){return r()},disabledTitle:"Select text first",onMouseDown:a,style:"border-radius: var(--tandem-r-2) 0 0 var(--tandem-r-2); border-right: none;"});var h=k(f,2),p=w(h),m=k(h,2);{var v=g=>{var b=hK(),x=w(b);Ye(x,17,()=>n,({value:A,label:M})=>A,(A,M)=>{let P=()=>u(M).value,D=()=>u(M).label;var L=fK();U(()=>{G(L,"data-testid",`toolbar-highlight-color-${P()}`),G(L,"title",D()),G(L,"aria-label",D()),ve(L,`width: 24px; height: 24px; border-radius: var(--tandem-r-2);
|
|
262
|
+
border: ${P()===u(i)?"2px solid var(--tandem-fg)":"1px solid var(--tandem-border)"};
|
|
263
|
+
background: ${Ic[P()]??""};
|
|
264
|
+
cursor: pointer; padding: 0;`)}),R("click",L,()=>c(P())),S(A,L)});var _=k(x,2);pt(b,A=>y(s,A),()=>u(s)),R("click",_,()=>y(o,!1)),S(g,b)};J(m,g=>{u(o)&&g(v)})}U(()=>{h.disabled=r(),ve(h,`padding: 4px 6px; font-size: 13px; border: 1px solid var(--tandem-border);
|
|
265
|
+
border-radius: 0 var(--tandem-r-2) var(--tandem-r-2) 0;
|
|
266
|
+
background: ${r()?"var(--tandem-surface-muted)":"var(--tandem-surface)"};
|
|
267
|
+
cursor: ${r()?"not-allowed":"pointer"};
|
|
268
|
+
display: flex; align-items: center;`),ve(p,`display: inline-block; width: 12px; height: 12px; border-radius: var(--tandem-r-1);
|
|
269
|
+
background: ${Ic[u(i)]??""};
|
|
270
|
+
border: 1px solid var(--tandem-border);`)}),R("mousedown",h,l),S(t,d),Le()}Ke(["mousedown","click"]);var gK=E('<div class="tandem-fmtbar-wrap" style="position: fixed; top: var(--tandem-fmtbar-top, 52px); left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; z-index: var(--tandem-z-sticky);"><div data-testid="formatting-bar" class="tandem-floating-pill" style="display: inline-flex; align-items: center; height: var(--tandem-h-fmtbar, 36px); padding: 0 var(--tandem-space-3); user-select: none; pointer-events: auto; -webkit-app-region: no-drag; max-width: calc(100% - var(--tandem-space-6));"><div style="display: flex; align-items: center; gap: 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></div>');function vK(t,e){Pe(e,!0);let n=I(0);he(()=>{const d=e.editor;if(!d||d.isDestroyed)return;const f=()=>{d.isDestroyed||Tc(n)};return d.on("selectionUpdate",f),d.on("transaction",f),()=>{d.off("selectionUpdate",f),d.off("transaction",f)}});const r=F(()=>(u(n),!e.editor||e.editor.isDestroyed||!e.ydoc?!1:!e.editor.state.selection.empty));function i(d){if(!e.editor||!e.ydoc||e.editor.isDestroyed)return;const{state:f}=e.editor,{from:h,to:p}=f.selection;if(h===p)return;const m=Mi(f.doc,Mn(h)),v=Mi(f.doc,Mn(p));if(m===null||v===null){console.warn("[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded",{from:h,to:p});return}gE(e.ydoc,{from:m,to:v},d)}var o=gK(),s=w(o),a=w(s),l=w(a);uK(l,{get editor(){return e.editor}});var c=k(l,4);{let d=F(()=>!u(r));mK(c,{get disabled(){return u(d)},onHighlight:i})}S(t,o),Le()}var yK=E('<div data-testid="mode-toggle" data-tauri-drag-region="false" class="mode-toggle svelte-14q5edy" role="group" aria-label="AI collaboration mode"><button data-testid="mode-solo-btn" title="Write undisturbed — your AI only responds when you message">Solo</button> <button data-testid="mode-tandem-btn" title="Full collaboration — your AI reacts to selections and document changes">Tandem</button></div>');function bK(t,e){Pe(e,!0);var n=yK(),r=w(n),i=k(r,2);U(()=>{Xr(r,1,ig(e.tandemMode==="solo"?"on":""),"svelte-14q5edy"),G(r,"aria-pressed",e.tandemMode==="solo"),Xr(i,1,ig(e.tandemMode==="tandem"?"on":""),"svelte-14q5edy"),G(i,"aria-pressed",e.tandemMode==="tandem")}),R("click",r,()=>e.onModeChange("solo")),R("click",i,()=>e.onModeChange("tandem")),S(t,n),Le()}Ke(["click"]);const wK=[{value:"system",label:"Match system"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"warm",label:"Warm"}];var xK=E('<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>'),kK=E('<button type="button" class="brand-menu-item svelte-12l7ydf" data-testid="brand-menu-settings" role="menuitem"><span>Settings…</span> <kbd class="brand-menu-kbd svelte-12l7ydf">Ctrl+,</kbd></button>'),_K=E('<button type="button" class="brand-menu-item svelte-12l7ydf" data-testid="brand-menu-shortcuts" role="menuitem"><span>Keyboard Shortcuts</span> <kbd class="brand-menu-kbd svelte-12l7ydf">?</kbd></button>'),SK=E('<button type="button" class="brand-menu-item svelte-12l7ydf" role="menuitemradio"><span class="brand-menu-check svelte-12l7ydf" aria-hidden="true"> </span> <span> </span></button>'),CK=E('<div class="brand-menu-divider svelte-12l7ydf" role="separator"></div> <div class="brand-menu-heading svelte-12l7ydf">Color scheme</div> <!>',1),TK=E('<div class="brand-menu tandem-floating-pill svelte-12l7ydf" data-testid="titlebar-brand-menu-popover" data-tauri-drag-region="false" role="menu" tabindex="-1" aria-label="Tandem menu"><!> <!> <!></div>'),EK=E('<div class="title-bar-center svelte-12l7ydf" data-tauri-drag-region="false"><!></div>'),AK=E('<span class="status-dot svelte-12l7ydf" data-tauri-drag-region="false" title="AI assistant is connected" aria-label="AI assistant is connected"></span>'),MK=E('<button type="button" data-testid="toolbar-authorship-toggle" data-tauri-drag-region="false"><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>'),OK=E('<button type="button" class="model-chip svelte-12l7ydf" data-testid="titlebar-default-model"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf"> </span></button>'),DK=Ui('<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>'),IK=Ui('<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>'),RK=E('<div class="title-bar-spacer-sm svelte-12l7ydf" data-tauri-drag-region=""></div> <div class="title-bar-controls svelte-12l7ydf" data-tauri-drag-region="false"><button type="button" class="title-bar-btn svelte-12l7ydf" aria-label="Minimize"><svg width="10" height="1" viewBox="0 0 10 1" aria-hidden="true" focusable="false"><rect width="10" height="1" fill="currentColor"></rect></svg></button> <button type="button" class="title-bar-btn svelte-12l7ydf"><!></button> <button type="button" class="title-bar-btn title-bar-close svelte-12l7ydf" aria-label="Close"><svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M1 0L0 1L4 5L0 9L1 10L5 6L9 10L10 9L6 5L10 1L9 0L5 4L1 0Z" fill="currentColor"></path></svg></button></div>',1),NK=E('<div class="title-bar svelte-12l7ydf" data-testid="title-bar" data-tauri-drag-region=""><div class="title-bar-left svelte-12l7ydf"><button type="button" class="brand-btn svelte-12l7ydf" data-testid="titlebar-brand-menu" data-tauri-drag-region="false" aria-label="Tandem menu" aria-haspopup="menu"><img class="brand-mark svelte-12l7ydf" src="/logo.png" alt="" width="32" height="32"/> <!></button> <!></div> <div class="title-bar-spacer title-bar-spacer-fixed svelte-12l7ydf" data-tauri-drag-region=""></div> <!> <div class="title-bar-spacer svelte-12l7ydf" data-tauri-drag-region=""></div> <div class="title-bar-actions svelte-12l7ydf"><!> <!> <!> <!></div> <!></div>');function PK(t,e){Pe(e,!0);let n=nt(e,"claudeActive",3,!1),r=nt(e,"theme",3,"system"),i=nt(e,"showAuthorship",3,!1),o=nt(e,"settingsBtn",15,null),s=nt(e,"updateAvailable",3,!1),a=nt(e,"defaultModelLabel",3,null),l=I(null),c=I(!1),d=[],f=!0;Td(async()=>{if(Nt())try{const[{invoke:$},{getCurrentWindow:le}]=await Promise.all([Rn(()=>import("./core-DhEqZVGG.js"),[]),Rn(()=>import("./window-DePn7tLG.js").then(_e=>_e.w),__vite__mapDeps([3,1,4]))]);if(!f||(await $("setup_overlay_titlebar").catch(_e=>{console.error("[TitleBar] setup_overlay_titlebar failed:",_e)}),!f))return;const ce=le();if(y(l,ce,!0),y(c,await ce.isMaximized(),!0),!f)return;const ue=await ce.onResized(async()=>{try{y(c,await ce.isMaximized(),!0)}catch(_e){console.warn("[TitleBar] isMaximized check failed on resize:",_e)}});if(!f){ue();return}d.push(ue);const pe=await ce.onMoved(async()=>{try{y(c,await ce.isMaximized(),!0)}catch(_e){console.warn("[TitleBar] isMaximized check failed on move:",_e)}});if(!f){pe();return}d.push(pe)}catch($){console.error("[TitleBar] Window API initialization failed:",$)}}),Qr(()=>{f=!1,d.forEach($=>$())});async function h(){var $;try{await(($=u(l))==null?void 0:$.minimize())}catch(le){console.error("[TitleBar] minimize failed:",le)}}async function p(){var $;try{await(($=u(l))==null?void 0:$.toggleMaximize())}catch(le){console.error("[TitleBar] toggleMaximize failed:",le)}}async function m(){var $;try{await(($=u(l))==null?void 0:$.close())}catch(le){console.error("[TitleBar] close failed:",le)}}let v=I(!1),g=I(null);he(()=>{if(u(v))return bb(()=>u(g)??o(),["mousedown"],()=>{y(v,!1)})});function b(){y(v,!u(v))}function x(){var $;y(v,!1),($=o())==null||$.focus()}function _($){$.key==="Escape"&&($.stopPropagation(),x())}function A($){var le;(le=e.onSetTheme)==null||le.call(e,$),x()}function M(){var $;($=e.onOpenSettings)==null||$.call(e),y(v,!1)}function P(){var $;($=e.onOpenHelp)==null||$.call(e),y(v,!1)}var D=NK(),L=w(D),X=w(L),z=k(w(X),2);{var re=$=>{var le=xK();S($,le)},Q=F(()=>Nt()&&s());J(z,$=>{u(Q)&&$(re)})}pt(X,$=>o($),()=>o());var N=k(X,2);{var B=$=>{var le=TK(),ce=w(le);{var ue=ye=>{var ke=kK();R("click",ke,M),S(ye,ke)};J(ce,ye=>{e.onOpenSettings&&ye(ue)})}var pe=k(ce,2);{var _e=ye=>{var ke=_K();R("click",ke,P),S(ye,ke)};J(pe,ye=>{e.onOpenHelp&&ye(_e)})}var ae=k(pe,2);{var de=ye=>{var ke=CK(),Ve=k(Se(ke),4);Ye(Ve,17,()=>wK,qe=>qe.value,(qe,fe)=>{var Ee=SK(),Re=w(Ee),Ge=w(Re),Te=k(Re,2),Me=w(Te);U(()=>{G(Ee,"data-testid",`brand-menu-theme-${u(fe).value??""}`),G(Ee,"aria-checked",r()===u(fe).value),te(Ge,r()===u(fe).value?"●":"○"),te(Me,u(fe).label)}),R("click",Ee,()=>A(u(fe).value)),S(qe,Ee)}),S(ye,ke)};J(ae,ye=>{e.onSetTheme&&ye(de)})}pt(le,ye=>y(g,ye),()=>u(g)),R("keydown",le,_),S($,le)};J(N,$=>{u(v)&&$(B)})}var j=k(L,4);{var H=$=>{var le=EK(),ce=w(le);Cd(ce,()=>e.center),S($,le)};J(j,$=>{e.center&&$(H)})}var W=k(j,4),ee=w(W);{var ie=$=>{bK($,{get tandemMode(){return e.tandemMode},get onModeChange(){return e.onModeChange}})};J(ee,$=>{e.tandemMode&&e.onModeChange&&$(ie)})}var K=k(ee,2);{var Y=$=>{var le=AK();S($,le)};J(K,$=>{n()&&$(Y)})}var O=k(K,2);{var T=$=>{var le=MK();let ce;U(()=>{ce=Xr(le,1,"icon-btn svelte-12l7ydf",null,ce,{active:i()}),G(le,"aria-label",i()?"Hide authorship colors":"Show authorship colors"),G(le,"aria-pressed",i()),G(le,"title",i()?"Hide authorship colors":"Show authorship colors")}),R("click",le,()=>e.onAuthorshipChange(!i())),S($,le)};J(O,$=>{e.onAuthorshipChange&&$(T)})}var C=k(O,2);{var Z=$=>{var le=OK(),ce=k(w(le),2),ue=w(ce);U(()=>{G(le,"aria-label",`Default model: ${a()}. Open Settings → Models.`),G(le,"title",`Default model: ${a()}`),te(ue,a())}),R("click",le,function(...pe){var _e;(_e=e.onOpenModelsSettings)==null||_e.apply(this,pe)}),S($,le)};J(C,$=>{a()&&e.onOpenModelsSettings&&$(Z)})}var q=k(W,2);{var oe=$=>{var le=RK(),ce=k(Se(le),2),ue=w(ce),pe=k(ue,2),_e=w(pe);{var ae=ke=>{var Ve=DK();S(ke,Ve)},de=ke=>{var Ve=IK();S(ke,Ve)};J(_e,ke=>{u(c)?ke(ae):ke(de,-1)})}var ye=k(pe,2);U(()=>{ue.disabled=u(l)===null,G(pe,"aria-label",u(c)?"Restore":"Maximize"),pe.disabled=u(l)===null,ye.disabled=u(l)===null}),R("click",ue,h),R("click",pe,p),R("click",ye,m),S($,le)},ge=F(()=>Nt());J(q,$=>{u(ge)&&$(oe)})}U(()=>G(X,"aria-expanded",u(v))),R("click",X,b),S(t,D),Le()}Ke(["click","keydown"]);const TE="tandem-status-count-mode",tf=["words","characters","sentences","paragraphs","pages"],LK={words:"words",characters:"chars",sentences:"sentences",paragraphs:"paragraphs",pages:"pages"},zK=250;function px(t){const e=t.trim();return e?e.split(/\s+/).length:0}function mx(t){const e=tf.indexOf(t);return tf[(e+1)%tf.length]??"words"}function Fm(t){return LK[t]}function FK(){try{const t=localStorage.getItem(TE);if(t&&tf.includes(t))return t}catch{}return"words"}function BK(t){try{localStorage.setItem(TE,t)}catch{}}function VK(t,e){if(!t||t.isDestroyed)return 0;const n=t.state.doc.textContent;switch(e){case"characters":return n.length;case"words":return px(n);case"sentences":{const r=n.match(/[^.!?]+[.!?]+(?:\s|$)/g);return(r==null?void 0:r.length)??(n.trim()?1:0)}case"paragraphs":{let r=0;return t.state.doc.forEach(i=>{i.type.name==="paragraph"&&i.textContent.trim()&&r++}),r}case"pages":return Math.ceil(px(n)/zK)}}var HK=E('<button type="button" data-testid="status-word-count" style="background: none; border: none; padding: 0; margin: 0; cursor: pointer; color: var(--tandem-fg-subtle); font: inherit; font-family: var(--tandem-font-mono);" class="svelte-1esxubl"> </button>'),UK=E('<span data-testid="save-indicator" style="color: var(--tandem-accent);" class="svelte-1esxubl">Saving...</span>'),jK=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);" class="svelte-1esxubl">Review Only</span>'),WK=E('<span data-testid="claude-working-indicator" class="claude-working-pill svelte-1esxubl" role="status" aria-live="polite"><span class="claude-working-dot svelte-1esxubl"></span> <span class="claude-working-dot svelte-1esxubl"></span> <span class="claude-working-dot svelte-1esxubl"></span> <span style="margin-left: 4px;" class="svelte-1esxubl"> </span></span>'),KK=E('<div class="tandem-floating-pill tandem-status-pill svelte-1esxubl" style="position: fixed; bottom: var(--tandem-space-3, 12px); left: var(--tandem-space-5, 22px); max-width: calc(100% - var(--tandem-space-7, 44px)); display: inline-flex; align-items: center; padding: 4px var(--tandem-space-3); height: var(--tandem-h-statusbar, 28px); font-family: var(--tandem-font-mono); font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); user-select: none; gap: var(--tandem-space-3); z-index: var(--tandem-z-sticky); overflow: hidden;"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-1esxubl"><span class="status-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </span> <!> <!></div> <div style="display: flex; align-items: center; gap: var(--tandem-space-1); font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);" class="svelte-1esxubl"><span class="svelte-1esxubl">You:</span> <input data-testid="user-name-input" type="text" aria-label="Display name" title="Your display name" style="background: transparent; border: none; border-bottom: 1px dashed transparent; color: var(--tandem-fg-muted); font: inherit; font-family: var(--tandem-font-sans); font-size: var(--tandem-text-xs); width: 80px; outline: none; padding: 0 2px;" class="svelte-1esxubl"/></div> <!> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-1esxubl"><span class="claude-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </span> <!></div></div>');function qK(t,e){Pe(e,!0);let n=nt(e,"claudeWorkingTool",3,null),r=nt(e,"saving",3,!1);function i(T){return{tandem_edit:"editing",tandem_comment:"commenting",tandem_reply:"replying",tandem_annotationReply:"replying"}[T]??T.replace(/^tandem_/,"")}const o=2e3,s=Py();let a=I(We(s.userName)),l=I(void 0);he(()=>{const T=s.userName;u(a)!==T&&document.activeElement!==u(l)&&y(a,T,!0)});let c=I(!1),d=I(0),f=vt(()=>e.connected);he(()=>{const T=f;if(f=e.connected,e.connected&&!T){y(c,!0);const C=setTimeout(()=>{y(c,!1)},o);return()=>clearTimeout(C)}}),he(()=>{if(e.disconnectedSince==null){y(d,0);return}y(d,Math.floor((Date.now()-e.disconnectedSince)/1e3),!0);const T=setInterval(()=>{y(d,Math.floor((Date.now()-(e.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(T)});const h=F(()=>e.connectionStatus==="connecting"),p=F(()=>e.connected?"var(--tandem-success)":u(h)?"var(--tandem-warning)":"var(--tandem-error)"),m=F(()=>u(c)?"Reconnected":e.connectionStatus==="connected"?"Connected":e.connectionStatus==="connecting"?(()=>{const T=["Reconnecting…"];if(e.reconnectAttempts>0||u(d)>0){const C=[];e.reconnectAttempts>0&&C.push(`attempt ${e.reconnectAttempts}`),u(d)>0&&C.push(`${u(d)}s`),T.push(`(${C.join(", ")})`)}return T.join(" ")})():"Disconnected — check that the server is running");function v(){s.setUserName(u(a))}let g=I(We(FK())),b=I(0);he(()=>{const T=e.editor;if(!T||T.isDestroyed)return;const C=()=>{T.isDestroyed||Tc(b)};return T.on("update",C),T.on("transaction",C),()=>{T.off("update",C),T.off("transaction",C)}});const x=F(()=>(u(b),VK(e.editor??null,u(g))));function _(){const T=mx(u(g));y(g,T,!0),BK(T)}var A=KK(),M=w(A),P=w(M),D=k(P,2),L=w(D),X=k(D,2);{var z=T=>{var C=HK(),Z=w(C);U((q,oe,ge,$)=>{G(C,"title",q),G(C,"aria-label",oe),te(Z,`${ge??""} ${$??""}`)},[()=>`Click to cycle: ${Fm(mx(u(g)))}`,()=>`${u(x)} ${Fm(u(g))} (click to change unit)`,()=>u(x).toLocaleString(),()=>Fm(u(g))]),R("click",C,_),S(T,C)};J(X,T=>{e.editor&&T(z)})}var re=k(X,2);{var Q=T=>{var C=UK();S(T,C)};J(re,T=>{r()&&T(Q)})}var N=k(M,2),B=k(w(N),2);pt(B,T=>y(l,T),()=>u(l));var j=k(N,2);{var H=T=>{var C=jK();S(T,C)};J(j,T=>{e.readOnly&&T(H)})}var W=k(j,2),ee=w(W),ie=k(ee,2),K=w(ie),Y=k(ie,2);{var O=T=>{var C=WK(),Z=k(w(C),6),q=w(Z);U(oe=>te(q,`Claude is ${oe??""}…`),[()=>i(n())]),S(T,C)};J(Y,T=>{n()&&T(O)})}U(()=>{ve(P,`width: 8px; height: 8px; border-radius: 50%; background: ${u(p)??""}; display: inline-block; animation: ${u(h)?"tandem-reconnect-pulse 1.2s ease-in-out infinite":"none"};`),te(L,u(m)),$n(B,u(a)),G(B,"maxlength",Rh),ve(ee,`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"};`),ve(ie,`transition: color 0.3s ease; color: ${e.claudeActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"};`),te(K,e.claudeStatus?`Claude · ${e.claudeStatus}`:"Claude · idle")}),R("input",B,T=>{y(a,T.target.value,!0)}),Tt("blur",B,v),R("keydown",B,T=>{T.key==="Enter"&&T.currentTarget.blur(),T.key==="Escape"&&(y(a,s.userName,!0),T.currentTarget.blur())}),S(t,A),Le()}Ke(["click","input","keydown"]);function Bm(t){return document.body.appendChild(t),{destroy(){t.remove()}}}var GK=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>'),JK=E('<div class="new-tab-menu-divider svelte-7c4il0"></div>'),YK=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 ZK(t,e){Pe(e,!0);function n(v){return v.replace(/[/\\]+$/,"").replace(/.*[/\\]/,"")}function r(v){var b;const g=((b=v.split(".").pop())==null?void 0:b.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,b;if(v.key==="Escape")v.preventDefault(),e.onClose();else if(v.key==="ArrowDown"){v.preventDefault();const x=o(),_=x.indexOf(document.activeElement);(g=x[(_+1)%x.length])==null||g.focus()}else if(v.key==="ArrowUp"){v.preventDefault();const x=o(),_=x.indexOf(document.activeElement);(b=x[(_-1+x.length)%x.length])==null||b.focus()}}function o(){var v;return Array.from(((v=u(s))==null?void 0:v.querySelectorAll("[role='menuitem']"))??[])}let s=I(null);function a(v){var b;const g=v.target;g&&((b=e.anchorEl)!=null&&b.contains(g)||mE(g)||e.onClose())}function l(){if(!u(s))return;if(!e.anchorEl){u(s).style.top="8px",u(s).style.left="8px",u(s).style.right="auto";return}const v=e.anchorEl.getBoundingClientRect(),g=u(s).offsetWidth,b=window.innerWidth,x=v.bottom+4,_=v.left;_+g>b-8?(u(s).style.right="8px",u(s).style.left="auto"):(u(s).style.left=`${_}px`,u(s).style.right="auto"),u(s).style.top=`${x}px`}he(()=>{var v;u(s)&&(l(),(v=o()[0])==null||v.focus())});var c=YK(),d=k(w(c),2);Ye(d,17,()=>e.recentFiles,Ac,(v,g)=>{var b=GK(),x=w(b),_=w(x),A=k(x,2),M=w(A);U((P,D)=>{G(b,"title",u(g)),te(_,P),te(M,D)},[()=>r(u(g)),()=>n(u(g))]),R("click",b,()=>e.onOpen(u(g))),S(v,b)});var f=k(d,2);{var h=v=>{var g=JK();S(v,g)};J(f,v=>{e.recentFiles.length>0&&v(h)})}var p=k(f,2),m=k(p,2);Tr(c,v=>Bm==null?void 0:Bm(v)),Tr(c,(v,g)=>no==null?void 0:no(v,g),()=>a),pt(c,v=>y(s,v),()=>u(s)),R("keydown",c,i),R("click",p,function(...v){var g;(g=e.onNewScratchpad)==null||g.apply(this,v)}),R("click",m,function(...v){var g;(g=e.onBrowse)==null||g.apply(this,v)}),S(t,c),Le()}Ke(["keydown","click"]);var XK=E('<span class="tab-ro-badge svelte-1btt0ja" aria-label="Read-only">RO</span>'),QK=E('<div role="tab"><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 $K(t,e){Pe(e,!0);let n=I(!1),r=null;he(()=>{const{ydoc:v,readOnly:g}=e.tab;if(g){y(n,!1);return}const b=v.getXmlFragment("default"),x=v.getMap(zu);let _=!1;const A=setTimeout(()=>{_=!0,r=x.get(uw)??0,y(n,!1)},500),M=()=>{_&&y(n,!0)};b.observeDeep(M);const P=()=>{if(!_)return;const D=x.get(uw);D!==void 0&&D!==r&&(r=D,y(n,!1))};return x.observe(P),()=>{clearTimeout(A),b.unobserveDeep(M),x.unobserve(P)}});const i=F(()=>["display: flex","align-items: center","gap: 6px","padding: 0 10px 0 12px","height: 26px","font-size: var(--tandem-text-sm)","cursor: pointer",`background: ${e.isActive?"var(--tandem-surface)":"transparent"}`,`color: ${e.isActive?"var(--tandem-fg)":"var(--tandem-fg-subtle)"}`,`border: 1px solid ${e.isActive?"var(--tandem-border)":"transparent"}`,`border-left: ${e.dropIndicator==="left"?"2px solid var(--tandem-accent)":e.isActive?"1px solid var(--tandem-border)":"2px solid transparent"}`,`border-right: ${e.dropIndicator==="right"?"2px solid var(--tandem-accent)":e.isActive?"1px solid var(--tandem-border)":"2px solid transparent"}`,"border-radius: var(--tandem-r-pill)",`box-shadow: ${e.isActive?"var(--tandem-shadow-1)":"0 1px 3px rgba(0, 0, 0, 0.08)"}`,"user-select: none","white-space: nowrap","transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s","flex-shrink: 0"].join("; "));let o=I(void 0);function s(){u(o)&&(u(o).style.color="var(--tandem-error)")}function a(){u(o)&&(u(o).style.color="var(--tandem-fg-muted)")}var l=QK();G(l,"tabindex",0);var c=w(l),d=k(c,2),f=w(d),h=k(d,2);{var p=v=>{var g=XK();S(v,g)};J(h,v=>{e.tab.readOnly&&v(p)})}var m=k(h,2);pt(m,v=>y(o,v),()=>u(o)),U(()=>{G(l,"data-testid",`tab-${e.tab.id}`),G(l,"data-active",e.isActive),G(l,"aria-selected",e.isActive),G(l,"aria-label",e.tab.fileName),G(l,"draggable",e.draggable),ve(l,u(i)),G(c,"data-testid",`unsaved-indicator-${e.tab.id}`),ve(c,`color: var(--tandem-warning); font-size: 10px; visibility: ${u(n)?"visible":"hidden"};`),G(c,"aria-hidden",!u(n)),G(d,"data-testid",`tab-name-${e.tab.id}`),G(d,"title",e.tab.filePath),ve(d,`font-weight: ${e.isActive?500:400}; min-width: 80px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),te(f,e.tab.fileName),G(m,"aria-label",`Close ${e.tab.fileName}`)}),R("click",l,()=>e.onswitch(e.tab.id)),Tt("dragstart",l,v=>e.ondragstart(v,e.tab.id)),Tt("dragover",l,v=>e.ondragover(v,e.tab.id)),Tt("drop",l,v=>e.ondrop(v,e.tab.id)),Tt("dragend",l,function(...v){var g;(g=e.ondragend)==null||g.apply(this,v)}),Tt("dragleave",l,function(...v){var g;(g=e.ondragleave)==null||g.apply(this,v)}),R("keydown",l,v=>e.onkeydown(v,e.tab.id)),R("click",m,v=>{v.stopPropagation(),e.onclose(e.tab.id)}),Tt("dragover",m,v=>{v.stopPropagation(),v.preventDefault()}),Tt("drop",m,v=>{v.stopPropagation(),v.preventDefault()}),Tt("mouseenter",m,s),Tt("mouseleave",m,a),S(t,l),Le()}Ke(["click","keydown"]);var e7=E('<div style="position: relative; display: flex; align-items: center; background: transparent; min-height: 32px; z-index: var(--tandem-z-base); width: 100%; min-width: 0;"><div data-testid="tab-scroll-container" role="tablist" aria-label="Open documents" style="display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 6px 8px;"></div> <button data-testid="open-file-btn" class="tandem-floating-pill tab-add-pill svelte-urrc8n" title="Open file" aria-label="Open file">+</button> <!></div>');function t7(t,e){Pe(e,!0);const n=nt(e,"reduceMotion",3,!1),r=F(()=>n()?"auto":"smooth");let i=I(!1),o=I(We([])),s=I(null),a=new Set;he(()=>{const Q=new Set(e.tabs.map(N=>N.id));for(const N of a)Q.has(N)||a.delete(N)});function l(Q){a.has(Q)||(a.add(Q),e.onTabClose(Q))}let c=I(void 0),d=I(!1),f=I(!1),h=I(null),p=I(null);function m(){y(h,null),y(p,null)}he(()=>{if(!u(h)&&!u(p))return;const Q=new Set(e.tabs.map(N=>N.id));u(h)&&!Q.has(u(h))&&y(h,null),u(p)&&!Q.has(u(p).id)&&y(p,null)});function v(){const Q=u(c);Q&&(y(d,Q.scrollLeft>0),y(f,Q.scrollLeft+Q.clientWidth<Q.scrollWidth-1))}he(()=>{const Q=u(c);if(!Q)return;v(),Q.addEventListener("scroll",v,{passive:!0});const N=new ResizeObserver(v);return N.observe(Q),()=>{Q.removeEventListener("scroll",v),N.disconnect()}}),he(()=>{e.tabs.length,v()}),he(()=>{if(!e.activeTabId||!u(c))return;const Q=u(c).querySelector(`[data-testid="tab-${e.activeTabId}"]`);Q&&Q.scrollIntoView({inline:"nearest",block:"nearest",behavior:u(r)})});function g(Q,N){y(h,N,!0),Q.dataTransfer&&(Q.dataTransfer.setData("text/plain",N),Q.dataTransfer.effectAllowed="move")}function b(Q,N){if(!u(h))return;if(Q.preventDefault(),u(h)===N){y(p,null);return}const B=Q.currentTarget.getBoundingClientRect(),j=B.left+B.width/2,H=Q.clientX<j?"left":"right";y(p,{id:N,side:H},!0)}function x(Q,N){var j;Q.preventDefault();const B=u(h)||((j=Q.dataTransfer)==null?void 0:j.getData("text/plain"))||"";if(B&&B!==N&&e.reorder){const H=Q.currentTarget.getBoundingClientRect(),W=H.left+H.width/2,ee=Q.clientX<W?"left":"right";e.reorder(B,N,ee)}m()}function _(){m()}function A(){y(p,null)}function M(Q,N){if(!Q.altKey||!e.reorder||Q.key!=="ArrowLeft"&&Q.key!=="ArrowRight")return;Q.preventDefault();const B=e.tabs.findIndex(j=>j.id===N);B!==-1&&(Q.key==="ArrowLeft"&&B>0?e.reorder(N,e.tabs[B-1].id):Q.key==="ArrowRight"&&B<e.tabs.length-1&&e.reorder(e.tabs[B+1].id,N))}const P=F(()=>e.tabs.length<=1);he(()=>{if(!u(i))return;function Q(N){var j,H;const B=N.target;B&&((j=u(s))!=null&&j.contains(B)||(H=B.closest)!=null&&H.call(B,".new-tab-menu")||mE(B)||y(i,!1))}return window.addEventListener("pointerdown",Q,!0),()=>window.removeEventListener("pointerdown",Q,!0)});var D=e7(),L=w(D);Ye(L,21,()=>e.tabs,Q=>Q.id,(Q,N)=>{{let B=F(()=>u(N).id===e.activeTabId),j=F(()=>!u(P)),H=F(()=>{var W;return((W=u(p))==null?void 0:W.id)===u(N).id?u(p).side:null});$K(Q,{get tab(){return u(N)},get isActive(){return u(B)},get onswitch(){return e.onTabSwitch},onclose:l,get draggable(){return u(j)},ondragstart:g,ondragover:b,ondrop:x,ondragend:_,ondragleave:A,get dropIndicator(){return u(H)},onkeydown:M})}}),pt(L,Q=>y(c,Q),()=>u(c));var X=k(L,2);pt(X,Q=>y(s,Q),()=>u(s));var z=k(X,2);{var re=Q=>{ZK(Q,{get recentFiles(){return u(o)},get anchorEl(){return u(s)},onOpen:async N=>{y(i,!1);const B=await us(N);B.ok?iy(ny(Bw(),N)):console.warn("[tandem] failed to open recent file:",B.error)},onNewScratchpad:()=>{y(i,!1),Yv()},onBrowse:()=>{var N;y(i,!1),(N=e.onRequestOpenDialog)==null||N.call(e)},onClose:()=>y(i,!1)})};J(z,Q=>{u(i)&&Q(re)})}U(()=>Xr(L,1,ig(["tab-scroll-hide","tab-scroll-mask",u(d)&&u(f)&&"has-overflow",u(d)&&!u(f)&&"overflow-left",!u(d)&&u(f)&&"overflow-right"]))),R("click",X,()=>{y(o,Bw(),!0),y(i,!u(i))}),S(t,D),Le()}Ke(["click"]);const gx=(t,e=ur,n=ur)=>{var r=r7();U(()=>{Xr(r,1,`panel-edge-collapse panel-edge-collapse-${e()}`,"svelte-y74n0s"),G(r,"data-testid",`panel-edge-collapse-${e()}`),G(r,"aria-label",e()==="left"?"Hide left panel":"Hide right panel")}),R("click",r,function(...i){var o;(o=n())==null||o.apply(this,i)}),S(t,r)};var n7=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>'),r7=E('<div role="button" tabindex="-1"></div>'),i7=E("<div><!></div>"),o7=E('<div class="editor-scroll tandem-scroll-fade-y" role="region" aria-label="Document editor"><!> <div><!> <!> <!></div> <!></div>'),s7=E('<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>'),a7=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>'),l7=E('<div data-testid="left-outline-rail"><!> <!></div> <!>',1),c7=E('<span class="rail-tab-badge svelte-y74n0s"> </span>'),d7=E('<!> <div><!> <div class="rail-tabs-row svelte-y74n0s"><div class="rail-tabs-track svelte-y74n0s"><button data-testid="annotations-tab">Annotations <!></button> <button data-testid="chat-tab">Chat</button></div></div> <!> <!></div>',1),u7=E('<!> <!> <!> <!> <!> <div style="position: relative; display: flex; flex: 1; overflow: hidden; background: var(--tandem-bg);"><!> <!> <!></div> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>',1),f7=E('<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>');function h7(t,e){Pe(e,!0);const n=V=>{t7(V,{get tabs(){return d.orderedTabs},get activeTabId(){return o.activeTabId},get onTabSwitch(){return o.setActiveTabId},onTabClose:l,get reorder(){return d.reorder},get reduceMotion(){return f.settings.reduceMotion},onRequestOpenDialog:()=>{y(ee,!0)}})},r=(V,se=ur,we=ur,Oe=ur,xt=ur)=>{var qt=n7();G(qt,"aria-valuemin",0),G(qt,"aria-valuemax",100),U(Wt=>{G(qt,"data-testid",Oe()??`${se()}-panel-resize-handle`),G(qt,"aria-label",se()==="left"?"Resize left panel":"Resize right panel"),G(qt,"aria-valuenow",Wt)},[()=>xt()!==void 0?Math.round((xt()-Ka)/(ud-Ka)*100):50]),R("mousedown",qt,function(...Wt){var qi;(qi=we())==null||qi.apply(this,Wt)}),R("keydown",qt,Wt=>{let ar=null;Wt.key==="ArrowRight"||Wt.key==="ArrowUp"?ar=16:Wt.key==="ArrowLeft"||Wt.key==="ArrowDown"?ar=-16:Wt.key==="PageUp"?ar=80:Wt.key==="PageDown"?ar=-80:Wt.key==="Home"?ar=Ka-(se()==="left"?Ee.width:Re.width):Wt.key==="End"&&(ar=ud-(se()==="left"?Ee.width:Re.width)),ar!==null&&(Wt.preventDefault(),Wt.stopPropagation(),se()==="left"?Ee.handleResizeStep(ar):Re.handleResizeStep(ar))}),R("keyup",qt,()=>{}),Tt("mouseenter",qt,Wt=>{Wt.currentTarget.style.background="var(--tandem-border-strong)"}),Tt("mouseleave",qt,Wt=>{Wt.currentTarget.style.background="transparent"}),S(V,qt)},i=V=>{var se=o7();{const ri=gt=>{CW(gt,{get ydoc(){return u(tt).ydoc},get provider(){return u(tt).provider},get readOnly(){return o.readOnly},get currentFilePath(){return u(tt).filePath},get format(){return u(tt).format},get activeAnnotationId(){return u(le)},onEditorReady:Mt=>y(pe,Mt,!0),onAnnotationClick:Mt=>{y(ge,"annotations"),y(le,Mt,!0)},onSlashCommandMenuChange:Mt=>y(ae,Mt,!0)})};var we=w(se);{let gt=F(()=>{var Mr,So;return((Mr=u(tt))==null?void 0:Mr.readOnly)===!0&&((So=u(tt))==null?void 0:So.format)==="docx"}),Mt=F(()=>{var Mr;return(Mr=u(tt))==null?void 0:Mr.id});xz(we,{get visible(){return u(gt)},get documentId(){return u(Mt)}})}var Oe=k(we,2),xt=w(Oe);{var qt=gt=>{var Mt=ft(),Mr=Se(Mt);sf(Mr,()=>u(tt).id,So=>{ri(So)}),S(gt,Mt)},Wt=gt=>{var Mt=i7(),Mr=w(Mt);{var So=Co=>{var Pl=ft(),jd=Se(Pl);sf(jd,()=>u(tt).id,Wd=>{ri(Wd)}),S(Co,Pl)},yp=Co=>{AD(Co,{get connected(){return o.connected},get claudeActive(){return o.claudeActive}})};J(Mr,Co=>{u(tt)?Co(So):Co(yp,-1)})}U(()=>ve(Mt,`max-width: ${u(sr)}; margin: 0 auto;`)),S(gt,Mt)};J(xt,gt=>{var Mt;((Mt=u(tt))==null?void 0:Mt.format)==="docx"?gt(qt):gt(Wt,-1)})}var qi=k(xt,2);{var Hd=gt=>{ux(gt,{side:"left",get annotations(){return u(Ar)},get positions(){return Ki.byId},width:_t,edgeInset:hn,gap:De,get activeAnnotationId(){return u(le)},get repliesById(){return Pn.byId},onClick:Mt=>{y(le,Mt.id,!0),Ct.scrollToAnnotation(Mt)},get onAccept(){return Ct.handleAccept},get onDismiss(){return Ct.handleDismiss},get onRemove(){return u(Jn).onRemove},get onEdit(){return u(Jn).onEdit},get onReply(){return u(Jn).onReply},get onSendToClaude(){return u(Jn).onSendToClaude}})};J(qi,gt=>{u(cn)&&u(tt)&>(Hd)})}var ar=k(qi,2);{var Ud=gt=>{ux(gt,{side:"right",get annotations(){return u(ti)},get positions(){return Ki.byId},width:_t,edgeInset:hn,gap:De,get activeAnnotationId(){return u(le)},get repliesById(){return Pn.byId},onClick:Mt=>{y(le,Mt.id,!0),Ct.scrollToAnnotation(Mt)},get onAccept(){return Ct.handleAccept},get onDismiss(){return Ct.handleDismiss},get onRemove(){return u(Jn).onRemove},get onEdit(){return u(Jn).onEdit},get onReply(){return u(Jn).onReply},get onSendToClaude(){return u(Jn).onSendToClaude}})};J(ar,gt=>{u(or)&&u(tt)&>(Ud)})}pt(Oe,gt=>y(_e,gt),()=>u(_e));var Nl=k(Oe,2);PW(Nl,{get editor(){return u(pe)},get open(){return u(de)},onClose:()=>y(de,!1),get tabs(){return o.tabs},get forceScope(){return u(ye)}}),Tr(se,(gt,Mt)=>Dt==null?void 0:Dt(gt,Mt),()=>"y"),U(()=>ve(Oe,u(At)?"position: relative;":"display: contents;"))}U(()=>ve(se,`position: relative; flex: 1; overflow: auto; padding: max(var(--tandem-space-7), 52px) var(--tandem-space-5) var(--tandem-space-7) var(--tandem-space-5); border: ${_.fileDragOver||Nm.fileDragOver?"2px dashed var(--tandem-accent)":"2px solid transparent"}; background: ${_.fileDragOver||Nm.fileDragOver?"var(--tandem-accent-bg)":"var(--tandem-bg)"}; transition: border-color 0.15s, background 0.15s; border-radius: ${_.fileDragOver||Nm.fileDragOver?"var(--tandem-r-5)":"0"};`)),Tt("dragover",se,function(...ri){var gt;(gt=_.handleEditorDragOver)==null||gt.apply(this,ri)}),Tt("dragleave",se,function(...ri){var gt;(gt=_.handleEditorDragLeave)==null||gt.apply(this,ri)}),Tt("drop",se,function(...ri){var gt;(gt=_.handleEditorDrop)==null||gt.apply(this,ri)}),S(V,se)},o=j9();Qr(()=>o.destroy());const s=e9(),a=new Set;function l(V){const se=o.tabs.find(we=>we.id===V);se&&!zl(se.filePath)&&s.push({filePath:se.filePath,closedAt:Date.now()}),o.handleTabClose(V)}async function c(){const V=s.pop();if(!V)return;const se=o.tabs.find(Oe=>Oe.filePath===V.filePath);if(se){o.setActiveTabId(se.id);return}if(a.has(V.filePath))return;a.add(V.filePath);const we=Oe=>{s.push(V);const xt=V.filePath.split(/[\\/]/).pop()||V.filePath;x.push({id:`reopen-failed-${Date.now()}`,type:"general-error",severity:"error",message:`Couldn't reopen ${xt}: ${Oe}`,dedupKey:`reopen-failed:${V.filePath}`,timestamp:Date.now()})};try{const Oe=await us(V.filePath);Oe.ok||we(Oe.error)}finally{a.delete(V.filePath)}}const d=x9(()=>o.tabs);y9(()=>d.orderedTabs,()=>o.activeTabId,V=>o.setActiveTabId(V)),he(()=>{const V=o.tabs;if(V.length!==0)try{const se=ry();let we=se;for(const Oe of V)zl(Oe.filePath)||(we=ny(we,Oe.filePath));(we.length!==se.length||we.some((Oe,xt)=>Oe!==se[xt]))&&iy(we)}catch(se){console.warn("[tandem] failed to sync recent files:",se)}});const f=oy(),h=k9(()=>o.bootstrapYdoc,()=>f.settings.selectionDwellMs),p=W9(f,h),m=F(()=>o.annotations),v=t9(()=>o.disconnectedSince,()=>f.settings.degradedBannerDelayMs),g=F9();V9();const b=F(()=>o.tabs.map(V=>({id:V.id,fileName:V.fileName}))),x=g9(),_=l9();if(C9(x.push),Nt()){let V=null,se=!1;Rn(async()=>{const{listen:we}=await import("./event-CNdo2oXa.js");return{listen:we}},__vite__mapDeps([4,1])).then(({listen:we})=>we("sidecar-restart-failed",()=>{x.push({id:`sidecar-restart-failed-${Date.now()}`,type:"general-error",severity:"error",message:"Sidecar failed to restart — see logs",dedupKey:"sidecar-restart-failed",timestamp:Date.now(),errorCode:"SIDECAR_RESTART_FAILED"})})).then(we=>{se?we():V=we}).catch(we=>{console.warn("[App] Failed to wire sidecar-restart-failed listener:",we)}),Qr(()=>{se=!0,V==null||V()})}let A=I(!1),M=I(!1);const P=c9(),D="tandem:wizard-dismissed";let L=I(We(z())),X=I(!1);function z(){try{return localStorage.getItem(D)}catch{return null}}const re=F(()=>P.needed===!0&&P.serverVersion!==null&&u(L)!==P.serverVersion),Q=F(()=>u(X)||u(re));let N=I(!1);const B=F(()=>u(re)&&f.settings.models.length===0&&!u(N));function j(){if(u(re)&&P.serverVersion!==null)try{localStorage.setItem(D,P.serverVersion),y(L,P.serverVersion,!0)}catch{}y(X,!1),y(N,!1)}he(()=>{const V=se=>{se.key===D&&y(L,se.newValue,!0)};return window.addEventListener("storage",V),()=>window.removeEventListener("storage",V)}),he(()=>{const V=()=>{y(X,!0),y(M,!1),P.refetch()};return window.addEventListener("tandem:open-integration-wizard",V),()=>window.removeEventListener("tandem:open-integration-wizard",V)});let H=I(null),W=I(!1),ee=I(!1);const ie=z9();function K(){u(A)||ie.acknowledge(),y(A,!u(A))}function Y(){ie.acknowledge(),y(M,!0)}const O=F(()=>{const V=f.settings.defaultModelId;if(V===null)return null;const se=f.settings.models.find(we=>we.id===V);return se?se.displayName:null});let T=I(null);function C(){u(M)||y(T,R4.models,!0),Y()}function Z(){ie.acknowledge(),y(A,!0)}GM({getActiveTabId:()=>o.activeTabId,getActiveDocumentPath:()=>{const V=o.tabs.find(se=>se.id===o.activeTabId);return V&&!zl(V.filePath)?V.filePath:null},notify:(V,se)=>{x.push({id:`launcher-${Date.now()}`,type:"launcher",severity:V,message:se,timestamp:Date.now()})},openSettings:Z,openSettingsModal:Y,toggleSoloMode:()=>h.setTandemMode(h.tandemMode==="solo"?"tandem":"solo"),openFindBar:()=>{y(ye,"doc"),y(de,!0)},openFindBarTabs:()=>{y(ye,"tabs"),y(de,!0)},findNext:()=>{const V=u(pe),se=V?Wa(V.state):void 0;V&&Im(se)?V.commands.findNext():(y(ye,"doc"),y(de,!0))},findPrev:()=>{const V=u(pe),se=V?Wa(V.state):void 0;V&&Im(se)?V.commands.findPrev():(y(ye,"doc"),y(de,!0))},closeActiveTab:()=>{const V=o.activeTabId;V&&l(V)},openFileDialog:()=>{y(ee,!0)},toggleLeftPanel:()=>dt(),toggleRightPanel:()=>Kt(),reopenClosedTab:()=>void c(),annotationNext:()=>{const V=Cu(u(m)),se=tx(V,u(le));if(se){y(le,se,!0);const we=V.find(Oe=>Oe.id===se);we&&Ct.scrollToAnnotation(we)}},annotationPrev:()=>{const V=Cu(u(m)),se=nx(V,u(le));if(se){y(le,se,!0);const we=V.find(Oe=>Oe.id===se);we&&Ct.scrollToAnnotation(we)}},annotationAccept:()=>{const V=u(m).find(se=>se.id===u(le));V&&V.author!=="user"&&Ct.handleAccept(V.id)},annotationDismiss:()=>{const V=u(m).find(se=>se.id===u(le));V&&V.author!=="user"&&Ct.handleDismiss(V.id)},selectBlock:()=>{var V;return(V=u(pe))==null?void 0:V.chain().focus().selectParentNode().run()},toggleAuthorship:()=>f.updateSettings({showAuthorship:!f.settings.showAuthorship}),saveAs:async()=>{const V=o.tabs.find(Oe=>Oe.id===o.activeTabId);if(!V||!zl(V.filePath)){x.push({id:Qd(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const se=Math.max(V.filePath.lastIndexOf("/"),V.filePath.lastIndexOf("\\")),we=V.filePath.slice(se+1);await bw({activeDocId:o.activeTabId,defaultName:we,sourceFormat:V.format,notify:(Oe,xt)=>x.push({id:Qd(),type:"launcher",severity:Oe,message:xt,timestamp:Date.now()})})}});let q=null;he(()=>{const V=u(pe);if(!V)return;const se=f.settings.showAuthorship;if(q===se)return;const we=q===null;q=se,!we&&vt(()=>{const Oe=V.state.tr.setMeta(Ta,{type:"toggle",visible:se});V.view.dispatch(Oe)})});let oe=null;he(()=>{const V=u(pe);if(!V)return;const se=f.settings.showAnnotationDecorations;if(oe===se)return;const we=oe===null;oe=se,!we&&vt(()=>{const Oe=V.state.tr.setMeta(tc,{type:"toggle-decorations",visible:se});V.view.dispatch(Oe)})}),he(()=>(document.body.classList.toggle("tandem-reduce-motion",f.settings.reduceMotion),()=>document.body.classList.remove("tandem-reduce-motion"))),O9(()=>f.settings.theme),GW(()=>f.settings.accentHue),a9(()=>f.settings.editorFont),r9(()=>f.settings.density),u9(()=>f.settings.highContrast),YW(()=>f.settings.annotationPatterns),he(()=>{const V=tI[f.settings.textSize];return document.documentElement.style.setProperty("--tandem-editor-font-size",`${V}px`),()=>document.documentElement.style.removeProperty("--tandem-editor-font-size")});let ge=I(We(f.settings.primaryTab==="chat"?"chat":"annotations"));const $=F(()=>u(ge)==="annotations"?0:u(m).filter(ff).length);let le=I(null),ce=I(!1),ue=I(null),pe=I(null),_e=I(null),ae=I(!1),de=I(!1),ye=I("doc"),ke=I(0),Ve=I(0);const qe=rx("left"),fe=rx("right"),Ee=ix({side:"left",initialWidth:qe,getVisible:()=>u(Ge)}),Re=ix({side:"right",initialWidth:fe,getVisible:()=>u(Te)}),Ge=F(()=>p.leftVisible),Te=F(()=>p.rightVisible);function Me(V,se){queueMicrotask(()=>{const we=se?`panel-edge-collapse-${V}`:`peek-strip-${V}`,Oe=document.querySelector(`[data-testid="${we}"]`);Oe?Oe.focus():console.warn(`[tandem] focusToggleTarget: ${we} not mounted; focus dropped to body`)})}const dt=()=>{const V=!p.leftVisible;p.toggleLeft(),Me("left",V)},Kt=()=>{const V=!p.rightVisible;p.toggleRight(),Me("right",V)};function ze(V,se){if(se.reduceMotion)return{duration:0,css:()=>""};const we=se.side==="left"?-1:1;return{duration:220,easing:H2,css:Oe=>`transform: translateX(${(1-Oe)*100*we}%);`}}const _t=240,hn=8,De=24,it=2*(_t+hn+De),Vt=480,St=32,jt=B9(),ir=F(()=>(u(Ge)?qe:0)+(u(Te)?fe:0)),Pt=F(()=>it+u(ir)+Vt);let rn=I(!1);he(()=>{const V=jt.width,se=u(Pt);V<se?y(rn,!0):V>se+St&&y(rn,!1)});const At=F(()=>f.settings.marginView&&!u(rn)),cn=F(()=>u(At)&&!u(Ge)),or=F(()=>u(At)&&!u(Te)),sr=F(()=>{const V=f.settings.editorWidthPercent,se=u(At)?it:0;return se>0?`max(0px, calc(${V}% - ${se}px))`:`${V}%`});function Lt(){if(u(ge)==="chat"||!u(pe))return;const{from:V,to:se}=u(pe).state.selection;if(V===se)return;const we=oC(u(pe).state.doc,{from:Mn(V),to:Mn(se)}),Oe=u(pe).state.doc.textBetween(V,se,`
|
|
271
|
+
`);y(ue,{...we,textSnapshot:Oe.length>200?Oe.slice(0,197)+"...":Oe},!0)}const Ht={"toggle-help":V=>{const se=V.target;se&&(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable)||(V.preventDefault(),y(ce,vt(()=>!u(ce)),!0))},"select-all":V=>{var we,Oe;const se=document.activeElement;se instanceof HTMLInputElement||se instanceof HTMLTextAreaElement||(we=se==null?void 0:se.closest)!=null&&we.call(se,".ProseMirror")||(V.preventDefault(),(Oe=u(pe))==null||Oe.commands.selectAll())},save:V=>{V.preventDefault(),Bk(o.activeTabId)},"save-as":V=>{const se=V.target;if(se&&(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable))return;V.preventDefault();const we=o.tabs.find(qt=>qt.id===o.activeTabId);if(!we||!zl(we.filePath)){x.push({id:Qd(),type:"launcher",severity:"info",message:"Save As is only available for scratchpads; this document is already on disk.",timestamp:Date.now()});return}const Oe=Math.max(we.filePath.lastIndexOf("/"),we.filePath.lastIndexOf("\\")),xt=we.filePath.slice(Oe+1);bw({activeDocId:o.activeTabId,defaultName:xt,sourceFormat:we.format,notify:(qt,Wt)=>x.push({id:Qd(),type:"launcher",severity:qt,message:Wt,timestamp:Date.now()})})},"settings-modal":V=>{V.preventDefault(),Y()},settings:V=>{V.preventDefault(),Z()},"toggle-palette":V=>{V.preventDefault(),y(W,!vt(()=>u(W)))},"new-scratchpad":V=>{const se=V.target;se&&(se.tagName==="INPUT"||se.tagName==="TEXTAREA")||(V.preventDefault(),Yv())},"close-tab":V=>{if(Dr(V))return;V.preventDefault();const se=o.activeTabId;se&&l(se)},"open-file":V=>{Dr(V)||(V.preventDefault(),y(ee,!0))},"pick-tab":(V,se)=>{if(Dr(V))return;const we=se==null?void 0:se.tabIndex;if(we===void 0)return;const Oe=b9(o.tabs,we);Oe&&(V.preventDefault(),o.setActiveTabId(Oe))},"toggle-mode":V=>{Dr(V)||(V.preventDefault(),h.setTandemMode(h.tandemMode==="solo"?"tandem":"solo"))},"reopen-closed-tab":V=>{Dr(V)||(V.preventDefault(),c())},find:(V,se)=>{if(V.preventDefault(),se!=null&&se.shift){y(ye,"tabs"),y(de,!0);return}u(Ge)?y(ke,u(ke)+1):(y(ye,"doc"),y(de,!0))},"find-nav":(V,se)=>{if(Dr(V))return;V.preventDefault();const we=u(pe),Oe=we?Wa(we.state):void 0;we&&Im(Oe)?se!=null&&se.shift?we.commands.findPrev():we.commands.findNext():(y(ye,"doc"),y(de,!0))},"annotation-accept-or-dismiss":(V,se)=>{if(Dr(V))return;V.preventDefault();const we=u(m).find(Oe=>Oe.id===u(le));we&&we.author!=="user"&&(se!=null&&se.shift?Ct.handleDismiss(we.id):Ct.handleAccept(we.id))},"comment-on-selection":V=>{var xt;V.preventDefault();const se=!!u(pe)&&u(pe).state.selection.from!==u(pe).state.selection.to,we=((xt=u(tt))==null?void 0:xt.readOnly)===!0;if(!(u(ae)||u(de)||u(W))){if(!se){x.push({id:`comment-shortcut-no-selection-${Date.now()}`,type:"general-error",severity:"info",message:"Select text to comment",dedupKey:"comment-shortcut-no-selection",timestamp:Date.now()});return}if(we){x.push({id:`comment-shortcut-readonly-${Date.now()}`,type:"general-error",severity:"info",message:"Document is read-only",dedupKey:"comment-shortcut-readonly",timestamp:Date.now()});return}if(!f.settings.selectionToolbar){x.push({id:`comment-shortcut-toolbar-off-${Date.now()}`,type:"general-error",severity:"info",message:"Enable selection toolbar in Settings to comment via keyboard",dedupKey:"comment-shortcut-toolbar-off",timestamp:Date.now()});return}y(Ve,u(Ve)+1)}},"toggle-authorship":V=>{V.preventDefault(),f.updateSettings({showAuthorship:!f.settings.showAuthorship})},"toggle-left-panel":V=>{Dr(V)||(V.preventDefault(),dt())},"toggle-right-panel":V=>{Dr(V)||(V.preventDefault(),Kt())},"annotation-next":V=>{if(Dr(V))return;V.preventDefault();const se=Cu(u(m)),we=tx(se,u(le));if(we){y(le,we,!0);const Oe=se.find(xt=>xt.id===we);Oe&&Ct.scrollToAnnotation(Oe)}},"annotation-prev":V=>{if(Dr(V))return;V.preventDefault();const se=Cu(u(m)),we=nx(se,u(le));if(we){y(le,we,!0);const Oe=se.find(xt=>xt.id===we);Oe&&Ct.scrollToAnnotation(Oe)}},"select-block":V=>{Dr(V)||(V.preventDefault(),u(pe)&&u(pe).chain().focus().selectParentNode().run())}};he(()=>{function V(se){var Oe;const we=QW(se);we&&((Oe=Ht[we.id])==null||Oe.call(Ht,se,we.context))}return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)});const tt=F(()=>o.tabs.find(V=>V.id===o.activeTabId)),Ct=$9({getYdoc:()=>{var V;return((V=u(tt))==null?void 0:V.ydoc)??null},getEditor:()=>u(pe),getAnnotations:()=>u(m),onActiveAnnotationChange:V=>{y(le,V,!0)},getScrollBehavior:()=>f.settings.reduceMotion?"auto":"smooth",getActiveAnnotationId:()=>u(le)}),Ar=F(()=>u(At)?u(m).filter(V=>V.type==="note"):[]),ti=F(()=>u(At)?u(m).filter(V=>V.author==="import"||V.type==="comment"):[]),Ki=p9({getEditor:()=>u(pe),getYdoc:()=>{var V;return((V=u(tt))==null?void 0:V.ydoc)??null},getAnnotations:()=>[...u(Ar),...u(ti)],getLayerEl:()=>u(_e),getEnabled:()=>u(At)}),Pn=ZW({getYdoc:()=>{var V;return((V=u(tt))==null?void 0:V.ydoc)??null}}),Jn=F(()=>{var we,Oe;const V=((we=u(tt))==null?void 0:we.ydoc)??null,se=(Oe=u(tt))==null?void 0:Oe.id;return{ydoc:V,docId:se,onEdit:(xt,qt)=>lC(V,xt,qt),onReply:(xt,qt)=>fC(xt,qt,se),onRemove:xt=>uC(xt,se),onSendToClaude:xt=>dC(V,xt)}}),ni=R9(()=>u(m),()=>u(pe),()=>{var V;return(V=u(tt))==null?void 0:V.fileName});var ps=f7(),ha=w(ps);PK(ha,{get tandemMode(){return h.tandemMode},get onModeChange(){return h.setTandemMode},get claudeActive(){return o.claudeActive},get theme(){return f.settings.theme},onSetTheme:V=>f.updateSettings({theme:V}),get showAuthorship(){return f.settings.showAuthorship},onAuthorshipChange:V=>f.updateSettings({showAuthorship:V}),onOpenHelp:()=>y(ce,!0),onOpenSettings:K,onOpenSettingsModal:Y,get updateAvailable(){return ie.showDot},get defaultModelLabel(){return u(O)},onOpenModelsSettings:C,get center(){return n},get settingsBtn(){return u(H)},set settingsBtn(V){y(H,V,!0)}});var gp=k(ha,2);{var Vd=V=>{var se=s7();S(V,se)},vp=V=>{var se=u7(),we=Se(se);{var Oe=He=>{var _n=a7();S(He,_n)};J(we,He=>{o.serverRestarted&&He(Oe)})}var xt=k(we,2);{var qt=He=>{lF(He,{get version(){return g.availableVersion},get installing(){return g.installing},onInstall:()=>{g.install()},get onDismiss(){return g.dismiss}})},Wt=F(()=>Nt()&&g.showBanner&&g.availableVersion);J(xt,He=>{u(Wt)&&He(qt)})}var qi=k(xt,2);{var Hd=He=>{fD(He,{get onDismiss(){return v.dismiss},onRetry:()=>{o.reconnect()}})};J(qi,He=>{v.showBanner&&He(Hd)})}var ar=k(qi,2);{let He=F(()=>{var vi;return((vi=u(tt))==null?void 0:vi.ydoc)??null}),_n=F(()=>u(ae)||u(de)||u(W));KW(ar,{get editor(){return u(pe)},get ydoc(){return u(He)},get selectionToolbar(){return f.settings.selectionToolbar},get suppressSelectionToolbar(){return u(_n)},get requestCommentFocus(){return u(Ve)}})}var Ud=k(ar,2);{let He=F(()=>{var _n;return((_n=u(tt))==null?void 0:_n.ydoc)??null});vK(Ud,{get editor(){return u(pe)},get ydoc(){return u(He)}})}var Nl=k(Ud,2),ri=w(Nl);{var gt=He=>{var _n=l7(),vi=Se(_n),pa=w(vi);om(pa,{kind:"outline",get focusTrigger(){return u(ke)},get editor(){return u(pe)},visible:!0});var Kd=k(pa,2);gx(Kd,()=>"left",()=>dt);var qd=k(vi,2);r(qd,()=>"left",()=>bp=>Ee.handleResizeStart(bp),()=>{},()=>Ee.width),U(()=>ve(vi,`position: relative; display: flex; flex-direction: column; width: ${Ee.width}px; background: var(--tandem-surface-muted); border-radius: 0 var(--tandem-rail-inner-radius, 14px) var(--tandem-rail-inner-radius, 14px) 0; margin-top: var(--tandem-rail-top-clearance, 0); margin-bottom: var(--tandem-status-clearance-total, 60px); overflow: hidden; box-shadow: var(--tandem-rail-shadow-left);`)),Hb(3,vi,()=>ze,()=>({side:"left",reduceMotion:f.settings.reduceMotion})),S(He,_n)},Mt=He=>{fx(He,{side:"left",onActivate:dt})};J(ri,He=>{u(Ge)?He(gt):He(Mt,-1)})}var Mr=k(ri,2);i(Mr);var So=k(Mr,2);{var yp=He=>{var _n=d7(),vi=Se(_n);r(vi,()=>"right",()=>Gi=>Re.handleResizeStart(Gi),()=>"panel-resize-handle",()=>Re.width);var pa=k(vi,2),Kd=w(pa);gx(Kd,()=>"right",()=>Kt);var qd=k(Kd,2),bp=w(qd),Gd=w(bp),NE=k(w(Gd));{var PE=Gi=>{var ma=c7(),xp=w(ma);U(()=>te(xp,u($)>9?"9+":u($))),S(Gi,ma)};J(NE,Gi=>{u(ge)!=="annotations"&&u($)>0&&Gi(PE)})}var wp=k(Gd,2),Tb=k(qd,2);{let Gi=F(()=>u(ge)==="chat");om(Tb,{kind:"chat",get ctrlYdoc(){return o.bootstrapYdoc},get editor(){return u(pe)},get activeDocId(){return o.activeTabId},get openDocs(){return u(b)},get claudeActive(){return o.claudeActive},get claudeStatus(){return o.claudeStatus},get capturedAnchor(){return u(ue)},onCapturedAnchorChange:ma=>y(ue,ma,!0),get reduceMotion(){return f.settings.reduceMotion},get visible(){return u(Gi)}})}var LE=k(Tb,2);{let Gi=F(()=>{var gr;return((gr=u(tt))==null?void 0:gr.ydoc)??null}),ma=F(()=>{var gr;return(gr=u(tt))==null?void 0:gr.format}),xp=F(()=>{var gr;return(gr=u(tt))==null?void 0:gr.id}),zE=F(()=>{var gr;return((gr=o.claudeWorking)==null?void 0:gr.annotationId)??null}),FE=F(()=>u(ge)==="annotations");om(LE,{kind:"side",get annotations(){return u(m)},get editor(){return u(pe)},get ydoc(){return u(Gi)},get activeDocFormat(){return u(ma)},get documentId(){return u(xp)},get activeAnnotationId(){return u(le)},onActiveAnnotationChange:gr=>y(le,gr,!0),get reduceMotion(){return f.settings.reduceMotion},get storeReadOnly(){return o.storeReadOnly},get claudeWorkingAnnotationId(){return u(zE)},get review(){return Ct},get visible(){return u(FE)}})}U(()=>{ve(pa,`position: relative; z-index: 1; display: flex; flex-direction: column; width: ${Re.width}px; background: var(--tandem-surface-muted); border-radius: var(--tandem-rail-inner-radius, 14px) 0 0 var(--tandem-rail-inner-radius, 14px); margin-top: var(--tandem-rail-top-clearance, 0); margin-bottom: var(--tandem-status-clearance-total, 60px); overflow: hidden; box-shadow: var(--tandem-rail-shadow-right);`),Xr(Gd,1,"rail-tab"+(u(ge)==="annotations"?" on":""),"svelte-y74n0s"),Xr(wp,1,"rail-tab"+(u(ge)==="chat"?" on":""),"svelte-y74n0s")}),R("click",Gd,()=>{y(ge,"annotations")}),R("mousedown",wp,Lt),R("click",wp,()=>{y(ge,"chat")}),Hb(3,pa,()=>ze,()=>({side:"right",reduceMotion:f.settings.reduceMotion})),S(He,_n)},Co=He=>{fx(He,{side:"right",onActivate:Kt})};J(So,He=>{u(Te)?He(yp):He(Co,-1)})}var Pl=k(Nl,2);{let He=F(()=>{var _n;return((_n=o.claudeWorking)==null?void 0:_n.tool)??null});qK(Pl,{get connected(){return o.connected},get connectionStatus(){return o.connectionStatus},get reconnectAttempts(){return o.reconnectAttempts},get disconnectedSince(){return o.disconnectedSince},get claudeStatus(){return o.claudeStatus},get claudeActive(){return o.claudeActive},get claudeWorkingTool(){return u(He)},get readOnly(){return o.readOnly},get saving(){return JM.saving},get editor(){return u(pe)}})}var jd=k(Pl,2);nF(jd,{get open(){return u(A)},onClose:()=>y(A,!1),get settings(){return f.settings},get onUpdate(){return f.updateSettings},get returnFocusEl(){return u(H)},get anchorEl(){return u(H)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts}});var Wd=k(jd,2);F4(Wd,{get open(){return u(M)},onClose:()=>{y(M,!1),y(T,null)},get settings(){return f.settings},get onUpdate(){return f.updateSettings},get returnFocusEl(){return u(H)},get triggerEl(){return u(H)},get connected(){return o.connected},get reconnectAttempts(){return o.reconnectAttempts},get initialTabId(){return u(T)},notify:(He,_n)=>x.push({id:`settings-${Date.now()}`,type:"launcher",severity:He,message:_n,timestamp:Date.now()})});var wb=k(Wd,2);vI(wb,{get open(){return u(ce)},onClose:()=>y(ce,!1)});var xb=k(wb,2);{var EE=He=>{fI(He,{onComplete:()=>y(N,!0)})},AE=He=>{UI(He,{open:!0,onClose:j})};J(xb,He=>{u(B)?He(EE):u(Q)&&He(AE,1)})}var kb=k(xb,2);{var ME=He=>{zD(He,{onClose:()=>y(ee,!1)})};J(kb,He=>{u(ee)&&He(ME)})}var _b=k(kb,2);dD(_b,{get open(){return u(W)},onClose:()=>y(W,!1),get editor(){return u(pe)},get annotations(){return u(m)},onFocusAnnotation:He=>{y(le,He,!0)}});var Sb=k(_b,2);sF(Sb,{get toasts(){return x.toasts},get onDismiss(){return x.dismiss}});var Cb=k(Sb,2);{var OE=He=>{_D(He,{})},DE=F(()=>Nt());J(Cb,He=>{u(DE)&&He(OE)})}var IE=k(Cb,2);{var RE=He=>{nR(He,{get currentStep(){return ni.currentStep},get onNext(){return ni.nextStep},get onDismiss(){return ni.dismissTutorial},get coworkStatus(){return ni.coworkStatus}})};J(IE,He=>{ni.tutorialActive&&He(RE)})}Tt("scroll",Nl,He=>{He.currentTarget.scrollLeft=0}),S(V,se)};J(gp,V=>{o.ready?V(vp,-1):V(Vd)})}U(()=>G(ps,"data-tandem-mode",h.tandemMode)),S(t,ps),Le()}Ke(["mousedown","keydown","keyup","click"]);const vx=3,p7="error-boundary-recover-btn",m7="error-boundary-reload-btn";function g7(t,e){Pe(e,!0),he(()=>{e.onSuccess()}),Le()}var v7=E('<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>'),y7=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>'),b7=E("<!> <!>",1);function w7(t,e){let n=I(0),r=I(0);var i=ft(),o=Se(i);Ux(o,{onerror:()=>{y(r,u(r)+1)},failed:(a,l=ur,c=ur)=>{var d=ft(),f=Se(d);sf(f,()=>u(r),h=>{var p=y7(),m=k(w(p),2),v=w(m),g=k(m,2),b=w(g),x=k(g,2);{var _=M=>{var P=v7();U(()=>G(P,"data-testid",p7)),R("click",P,()=>{y(n,u(n)+1),c()()}),S(M,P)};J(x,M=>{u(n)<vx&&M(_)})}var A=k(x,2);U(M=>{te(v,u(n)>=vx?"Recovery attempts exhausted. Reload the page to continue.":"The editor encountered an unexpected error."),te(b,M),G(A,"data-testid",m7)},[()=>l()instanceof Error?l().message:String(l())]),R("click",A,()=>window.location.reload()),S(h,p)}),S(a,d)}},a=>{var l=b7(),c=Se(l);Cd(c,()=>e.children);var d=k(c,2);g7(d,{onSuccess:()=>{y(n,0)}}),S(a,l)}),S(t,i)}Ke(["click"]);function x7(t){w7(t,{children:(e,n)=>{h7(e,{})}})}d2(x7,{target:document.getElementById("root")});export{Ye as A,O7 as B,S7 as C,A7 as D,Ke as E,R7 as F,M7 as G,_k as T,k as a,S as b,E_ as c,Le as d,I as e,E7 as f,u as g,w as h,J as i,G as j,Se as k,Vn as l,D7 as m,te as n,Qr as o,Pe as p,R as q,y as r,ve as s,U as t,F as u,E as v,ty as w,k_ as x,T_ as y,I7 as z};
|