tandem-editor 0.14.3 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +4 -4
- package/CHANGELOG.md +26 -0
- package/README.md +21 -1
- package/dist/cli/index.js +82 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/client/assets/CoworkSettings-BWtK14Nl.js +11 -0
- package/dist/client/assets/CoworkSettings-C0m1IhNy.css +1 -0
- package/dist/client/assets/{dist-dYgyssYq.js → dist-BIC2phzY.js} +1 -1
- package/dist/client/assets/index-BVcBJagd.css +1 -0
- package/dist/client/assets/index-DMmXYPP4.js +270 -0
- package/dist/client/assets/{prod-DeXsEx17.js → prod-Bv0q-mQu.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/index.js +277 -64
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/CoworkSettings-BevsTL0m.css +0 -1
- package/dist/client/assets/CoworkSettings-CAr7DoyA.js +0 -5
- package/dist/client/assets/index-BbxWZ4FI.css +0 -1
- package/dist/client/assets/index-wtM-9NgF.js +0 -262
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/path-49-uTKly.js","assets/core-SwWLTXZB.js","assets/dist-js-BWAGOggB.js","assets/event-wL_2RBc7.js","assets/CoworkSettings-CAr7DoyA.js","assets/CoworkSettings-BevsTL0m.css","assets/dist-dYgyssYq.js","assets/prod-DeXsEx17.js","assets/webview-C-97RVRf.js","assets/window-CR0qpD8C.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=Array.isArray,r=Array.prototype.indexOf,i=Array.prototype.includes,a=Array.from,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyDescriptors,l=Object.prototype,u=Array.prototype,d=Object.getPrototypeOf,f=Object.isExtensible;function p(e){return typeof e==`function`}var m=()=>{};function h(e){return typeof e?.then==`function`}function g(e){for(var t=0;t<e.length;t++)e[t]()}function _(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function v(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var y=1024,b=2048,x=4096,S=8192,C=16384,w=32768,ee=1<<25,T=65536,te=1<<19,ne=1<<20,E=1<<25,re=65536,ie=1<<21,ae=1<<22,oe=1<<23,se=Symbol(`$state`),ce=Symbol(`legacy props`),le=Symbol(``),ue=Symbol(`attributes`),de=Symbol(`class`),fe=Symbol(`style`),pe=Symbol(`text`),me=Symbol(`form reset`),he=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},ge=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function _e(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ve(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ye(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function be(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function xe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Se(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ce(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function we(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Te(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ee(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Oe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ke={},Ae=Symbol(),je=`http://www.w3.org/1999/xhtml`,Me=`http://www.w3.org/2000/svg`,Ne=`http://www.w3.org/1998/Math/MathML`;function Pe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Fe(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Ie(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Le(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var Re=!1;function ze(e){Re=e}var Be;function Ve(e){if(e===null)throw Fe(),ke;return Be=e}function He(){return Ve(bn(Be))}function D(e){if(Re){if(bn(Be)!==null)throw Fe(),ke;Be=e}}function O(e=1){if(Re){for(var t=e,n=Be;t--;)n=bn(n);Be=n}}function Ue(e=!0){for(var t=0,n=Be;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=bn(n);e&&n.remove(),n=i}}function We(e){if(!e||e.nodeType!==8)throw Fe(),ke;return e.data}function Ge(e){return e===this.v}function Ke(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function qe(e){return!Ke(e,this.v)}var Je=!1,Ye=!1;function Xe(){Ye=!0}var Ze=null;function Qe(e){Ze=e}function k(e,t=!1,n){Ze={p:Ze,i:!1,c:null,e:null,s:e,x:null,r:cr,l:Ye&&!t?{s:null,u:null,$:[]}:null}}function A(e){var t=Ze,n=t.e;if(n!==null){t.e=null;for(var r of n)In(r)}return e!==void 0&&(t.x=e),t.i=!0,Ze=t.p,e??{}}function $e(){return!Ye||Ze!==null&&Ze.l===null}var et=[];function tt(){var e=et;et=[],g(e)}function nt(e){if(et.length===0&&!bt){var t=et;queueMicrotask(()=>{t===et&&tt()})}et.push(e)}function rt(){for(;et.length>0;)tt()}function it(e){var t=cr;if(t===null)return ar.f|=oe,e;if(!(t.f&32768)&&!(t.f&4))throw e;at(e,t)}function at(e,t){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}var ot=~(b|x|y);function st(e,t){e.f=e.f&ot|t}function ct(e){e.f&512||e.deps===null?st(e,y):st(e,x)}function lt(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=re,lt(t.deps))}function ut(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),lt(e.deps),st(e,y)}var dt=!1,ft=!1;function pt(e){var t=ft;try{return ft=!1,[e(),ft]}finally{ft=t}}var mt=null,ht=null,gt=null,_t=null,vt=null,yt=null,bt=!1,xt=!1,St=null,Ct=null,wt=0,Tt=1,Et=class e{id=Tt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;unblocked=new Set;#r=new Set;#i=new Set;#a=new Set;#o=0;#s=new Map;#c=null;#l=[];#u=[];#d=new Set;#f=new Set;#p=new Map;#m=new Set;is_fork=!1;#h=!1;#g(){if(this.is_fork)return!0;for(let n of this.#s.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#p.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#p.has(e)||this.#p.set(e,{d:[],m:[]}),this.#m.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#p.get(e);if(n){this.#p.delete(e);for(var r of n.d)st(r,b),t(r);for(r of n.m)st(r,x),t(r)}this.#m.add(e)}#_(){if(this.#e=!0,wt++>1e3&&(this.#w(),Ot()),!this.#g()){for(let e of this.#d)this.#f.delete(e),st(e,b),this.schedule(e);for(let e of this.#f)st(e,x),this.schedule(e)}let t=this.#l;this.#l=[],this.apply();var n=St=[],r=[],i=Ct=[];for(let e of t)try{this.#v(e,n,r)}catch(t){throw Ft(e),t}if(gt=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(St=null,Ct=null,this.#g()){this.#x(r),this.#x(n);for(let[e,t]of this.#p)Pt(e,t);i.length>0&>.#_();return}let o=this.#y();if(o){o.#b(this);return}this.#d.clear(),this.#f.clear();for(let e of this.#r)e(this);this.#r.clear(),_t=this,At(r),At(n),_t=null,this.#c?.resolve();var s=gt;if(this.linked&&this.#o===0&&this.#w(),Je&&!this.linked&&(this.#S(),gt=s),this.#l.length>0){s===null&&(s=this,this.#C());let e=s;e.#l.push(...this.#l.filter(t=>!e.#l.includes(t)))}s!==null&&s.#_()}#v(e,t,n){e.f^=y;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#p.has(r))&&r.fn!==null){a?r.f^=y:i&4?t.push(r):Je&&i&16777224?n.push(r):xr(r)&&(i&16&&this.#f.add(r),Er(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve)}let t=e=>{var n=e.reactions;if(n!==null)for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#f.delete(i),st(i,b),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#w(),gt=this,this.#_()}#x(e){for(var t=0;t<e.length;t+=1)ut(e[t],this.#d,this.#f)}capture(e,t,n=!1){e.v!==Ae&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),vt?.set(e,t)),this.is_fork||(e.v=t)}activate(){gt=this}deactivate(){gt=null,vt=null}flush(){try{xt=!0,gt=this,this.#_()}finally{wt=0,yt=null,St=null,Ct=null,xt=!1,gt=null,vt=null,en.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear(),this.#a.clear(),this.#w()}register_created_effect(e){this.#u.push(e)}#S(){this.#w();for(let l=mt;l!==null;l=l.#n){var e=l.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(l.current.has(r)){var n=l.current.get(r)[0];if(e&&i!==n)l.current.set(r,[i,a]);else continue}t.push(r)}if(e)for(let[e,t]of this.async_deriveds){let n=l.async_deriveds.get(e);n&&t.promise.then(n.resolve)}if(l.#e){var r=[...l.current.keys()].filter(e=>!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#m)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#x([e])});l.activate();var i=new Set,a=new Map;for(var o of t)jt(o,r,i,a);a=new Map;var s=[...l.current.keys()].filter(e=>this.current.has(e)?this.current.get(e)[0]!==e.v:!0);if(s.length>0)for(let e of this.#u)!(e.f&155648)&&Mt(e,s,a)&&(e.f&4194320?(st(e,b),l.schedule(e)):l.#d.add(e));if(l.#l.length>0){l.apply();for(var c of l.#l)l.#v(c,[],[]);l.#l=[]}l.deactivate()}}}}increment(e,t){if(this.#o+=1,e){let e=this.#s.get(t)??0;this.#s.set(t,e+1)}}decrement(e,t){if(--this.#o,e){let e=this.#s.get(t)??0;e===1?this.#s.delete(t):this.#s.set(t,e-1)}this.#h||(this.#h=!0,nt(()=>{this.#h=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#d.add(t);for(let e of t)this.#f.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}on_fork_commit(e){this.#a.add(e)}run_fork_commit_callbacks(){for(let e of this.#a)e(this);this.#a.clear()}settled(){return(this.#c??=_()).promise}static ensure(){if(gt===null){let t=gt=new e;t.#C(),!xt&&!bt&&nt(()=>{t.#e||t.flush()})}return gt}apply(){if(!Je||!this.is_fork&&this.#t===null&&this.#n===null){vt=null;return}vt=new Map;for(let[e,[t]]of this.current)vt.set(e,t);for(let t=mt;t!==null;t=t.#n)if(!(t===this||t.is_fork)){var e=!1;if(t.id<this.id){for(let[n,[,r]]of t.current)if(!r&&this.current.has(n)){e=!0;break}}if(!e)for(let[e,n]of t.previous)vt.has(e)||vt.set(e,n)}}schedule(e){if(yt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(St!==null&&t===cr&&(Je||(ar===null||!(ar.f&2))&&!dt))return;if(n&96){if(!(n&1024))return;t.f^=y}}this.#l.push(t)}#C(){ht===null?mt=ht=this:(ht.#n=this,this.#t=ht),ht=this}#w(){var e=this.#t,t=this.#n;e===null?mt=t:e.#n=t,t===null?ht=e:t.#t=e,this.linked=!1}};function Dt(e){var t=bt;bt=!0;try{var n;for(e&&(gt!==null&&!gt.is_fork&>.flush(),n=e());;){if(rt(),gt===null)return n;gt.flush()}}finally{bt=t}}function Ot(){try{Ce()}catch(e){at(e,yt)}}var kt=null;function At(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&xr(r)&&(kt=new Set,Er(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Yn(r),kt?.size>0)){en.clear();for(let e of kt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)kt.has(n)&&(kt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Er(n)}}kt.clear()}}kt=null}}function jt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?jt(i,t,n,r):e&4194320&&!(e&2048)&&Mt(i,t,r)&&(st(i,b),Nt(i))}}function Mt(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(i.call(t,r))return!0;if(r.f&2&&Mt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function Nt(e){gt.schedule(e)}function Pt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),st(e,y);for(var n=e.first;n!==null;)Pt(n,t),n=n.next}}function Ft(e){st(e,y);for(var t=e.first;t!==null;)Ft(t),t=t.next}function It(e){let t=0,n=nn(0),r;return()=>{Pn()&&(z(n),Vn(()=>(t===0&&(r=Ar(()=>e(()=>cn(n)))),t+=1,()=>{nt(()=>{--t,t===0&&(r?.(),r=void 0,cn(n))})})))}}var Lt=T|te;function Rt(e,t,n,r){new zt(e,t,n,r)}var zt=class{parent;is_pending=!1;transform_error;#e;#t=Re?Be:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=It(()=>(this.#m=nn(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=cr;t.b=this,t.f|=128,n(e)},this.parent=cr.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Hn(()=>{if(Re){let e=this.#t;He();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},Lt),Re&&(this.#e=Be)}#g(){try{this.#a=Un(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Un(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Un(()=>e(this.#e)),nt(()=>{var e=this.#c=document.createDocumentFragment(),t=vn();e.append(t),this.#a=this.#x(()=>Un(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Xn(this.#o,()=>{this.#o=null}),this.#b(gt))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Un(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();er(this.#a,e);let t=this.#n.pending;this.#o=Un(()=>t(this.#e))}else this.#b(gt)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){ut(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=cr,n=ar,r=Ze;lr(this.#i),sr(this.#i),Qe(this.#i.ctx);try{return Et.ensure(),e()}catch(e){return it(e),null}finally{lr(t),sr(n),Qe(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&Xn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,nt(()=>{this.#d=!1,this.#m&&an(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),z(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;gt?.is_fork?(this.#a&>.skip_effect(this.#a),this.#o&>.skip_effect(this.#o),this.#s&>.skip_effect(this.#s),gt.on_fork_commit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(qn(this.#a),null),this.#o&&=(qn(this.#o),null),this.#s&&=(qn(this.#s),null),Re&&(Ve(this.#t),O(),Ve(Ue()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Le();return}r=!0,i&&Oe(),this.#s!==null&&Xn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){at(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Un(()=>{var t=cr;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return at(e,this.#i.parent),null}}))};nt(()=>{var t;try{t=this.transform_error(e)}catch(e){at(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>at(e,this.#i&&this.#i.parent)):o(t)})}};function Bt(e,t,n,r){let i=$e()?Wt:qt;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=cr,s=Vt(),c=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function l(e){if(!(o.f&16384)){s();try{r(e)}catch(e){at(e,o)}Ht()}}var u=Ut();if(n.length===0){c.then(()=>l(t.map(i))).finally(u);return}function d(){Promise.all(n.map(e=>Kt(e))).then(e=>l([...t.map(i),...e])).catch(e=>at(e,o)).finally(u)}c?c.then(()=>{s(),d(),Ht()}):d()}function Vt(){var e=cr,t=ar,n=Ze,r=gt;return function(i=!0){lr(e),sr(t),Qe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function Ht(e=!0){lr(null),sr(null),Qe(null),e&>?.deactivate()}function Ut(){var e=cr,t=e.b,n=gt,r=t.is_rendered();return t.update_pending_count(1,n),n.increment(r,e),()=>{t.update_pending_count(-1,n),n.decrement(r,e)}}function Wt(e){var t=2|b;return cr!==null&&(cr.f|=te),{ctx:Ze,deps:null,effects:null,equals:Ge,f:t,fn:e,reactions:null,rv:0,v:Ae,wv:0,parent:cr,ac:null}}var Gt=Symbol(`obsolete`);function Kt(e,t,n){let r=cr;r===null&&ve();var i=void 0,a=nn(Ae),o=!ar,s=new Set;return Bn(()=>{var t=cr,n=_();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==he&&n.reject(e)}).finally(Ht)}catch(e){n.reject(e),Ht()}var c=gt;if(o){if(t.f&32768)var l=Ut();if(r.b.is_rendered())c.async_deriveds.get(t)?.reject(Gt);else for(let e of s.values())e.reject(Gt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==Gt&&(c.activate(),t?(a.f|=oe,an(a,t)):(a.f&8388608&&(a.f^=oe),an(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),Fn(()=>{for(let e of s)e.reject(Gt)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function j(e){let t=Wt(e);return Je||dr(t),t}function qt(e){let t=Wt(e);return t.equals=qe,t}function Jt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)qn(t[n])}}function Yt(e){var t,n=cr,r=e.parent;if(!rr&&r!==null&&r.f&24576)return Pe(),e.v;lr(r);try{e.f&=~re,Jt(e),t=Cr(e)}finally{lr(n)}return t}function Xt(e){var t=Yt(e);if(!e.equals(t)&&(e.wv=br(),(!gt?.is_fork||e.deps===null)&&(gt===null?e.v=t:(gt.capture(e,t,!0),_t?.capture(e,t,!0)),e.deps===null))){st(e,y);return}rr||(vt===null?ct(e):(Pn()||gt?.is_fork)&&vt.set(e,t))}function Zt(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(he),t.teardown=m,t.ac=null,Tr(t,0),Gn(t))}function Qt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&Er(t)}var $t=new Set,en=new Map,tn=!1;function nn(e,t){return{f:0,v:e,reactions:null,equals:Ge,rv:0,wv:0}}function M(e,t){let n=nn(e,t);return dr(n),n}function rn(e,t=!1,n=!0){let r=nn(e);return t||(r.equals=qe),Ye&&n&&Ze!==null&&Ze.l!==null&&(Ze.l.s??=[]).push(r),r}function N(e,t,n=!1){return ar!==null&&(!or||ar.f&131072)&&$e()&&ar.f&4325394&&(ur===null||!i.call(ur,e))&&De(),an(e,n?un(t):t,Ct)}function an(e,t,n=null){if(!e.equals(t)){en.set(e,rr?t:e.v);var r=Et.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Yt(t),vt===null&&ct(t)}e.wv=br(),ln(e,b,n),$e()&&cr!==null&&cr.f&1024&&!(cr.f&96)&&(mr===null?hr([e]):mr.push(e)),!r.is_fork&&$t.size>0&&!tn&&on()}return t}function on(){tn=!1;for(let e of $t){e.f&1024&&st(e,x);let t;try{t=xr(e)}catch{t=!0}t&&Er(e)}$t.clear()}function sn(e,t=1){var n=z(e),r=t===1?n++:n--;return N(e,n),r}function cn(e){N(e,e.v+1)}function ln(e,t,n){var r=e.reactions;if(r!==null)for(var i=$e(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===cr)){var l=(c&b)===0;if(l&&st(s,t),c&131072)$t.add(s);else if(c&2){var u=s;vt?.delete(u),c&65536||(c&512&&(cr===null||!(cr.f&2097152))&&(s.f|=re),ln(u,x,n))}else if(l){var d=s;c&16&&kt!==null&&kt.add(d),n===null?Nt(d):n.push(d)}}}}function un(e){if(typeof e!=`object`||!e||se in e)return e;let t=d(e);if(t!==l&&t!==u)return e;var r=new Map,i=n(e),a=M(0),o=null,c=vr,f=e=>{if(vr===c)return e();var t=ar,n=vr;sr(null),yr(c);var r=e();return sr(t),yr(n),r};return i&&r.set(`length`,M(e.length,o)),new Proxy(e,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Te();var i=r.get(t);return i===void 0?f(()=>{var e=M(n.value,o);return r.set(t,e),e}):N(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>M(Ae,o));r.set(t,e),cn(a)}}else N(n,Ae),cn(a);return!0},get(t,n,i){if(n===se)return e;var a=r.get(n),c=n in t;if(a===void 0&&(!c||s(t,n)?.writable)&&(a=f(()=>M(un(c?t[n]:Ae),o)),r.set(n,a)),a!==void 0){var l=z(a);return l===Ae?void 0:l}return Reflect.get(t,n,i)},getOwnPropertyDescriptor(e,t){var n=Reflect.getOwnPropertyDescriptor(e,t);if(n&&`value`in n){var i=r.get(t);i&&(n.value=z(i))}else if(n===void 0){var a=r.get(t),o=a?.v;if(a!==void 0&&o!==Ae)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return n},has(e,t){if(t===se)return!0;var n=r.get(t),i=n!==void 0&&n.v!==Ae||Reflect.has(e,t);return(n!==void 0||cr!==null&&(!i||s(e,t)?.writable))&&(n===void 0&&(n=f(()=>M(i?un(e[t]):Ae,o)),r.set(t,n)),z(n)===Ae)?!1:i},set(e,t,n,c){var l=r.get(t),u=t in e;if(i&&t===`length`)for(var d=n;d<l.v;d+=1){var p=r.get(d+``);p===void 0?d in e&&(p=f(()=>M(Ae,o)),r.set(d+``,p)):N(p,Ae)}if(l===void 0)(!u||s(e,t)?.writable)&&(l=f(()=>M(void 0,o)),N(l,un(n)),r.set(t,l));else{u=l.v!==Ae;var m=f(()=>un(n));N(l,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(c,n),!u){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&N(g,_+1)}cn(a)}return!0},ownKeys(e){z(a);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==Ae});for(var[n,i]of r)i.v!==Ae&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Ee()}})}function dn(e){try{if(typeof e==`object`&&e&&se in e)return e[se]}catch{}return e}function fn(e,t){return Object.is(dn(e),dn(t))}new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);var pn,mn,hn,gn;function _n(){if(pn===void 0){pn=window,mn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;hn=s(t,`firstChild`).get,gn=s(t,`nextSibling`).get,f(e)&&(e[de]=void 0,e[ue]=null,e[fe]=void 0,e.__e=void 0),f(n)&&(n[pe]=void 0)}}function vn(e=``){return document.createTextNode(e)}function yn(e){return hn.call(e)}function bn(e){return gn.call(e)}function P(e,t){if(!Re)return yn(e);var n=yn(Be);if(n===null)n=Be.appendChild(vn());else if(t&&n.nodeType!==3){var r=vn();return n?.before(r),Ve(r),r}return t&&wn(n),Ve(n),n}function F(e,t=!1){if(!Re){var n=yn(e);return n instanceof Comment&&n.data===``?bn(n):n}if(t){if(Be?.nodeType!==3){var r=vn();return Be?.before(r),Ve(r),r}wn(Be)}return Be}function I(e,t=1,n=!1){let r=Re?Be:e;for(var i;t--;)i=r,r=bn(r);if(!Re)return r;if(n){if(r?.nodeType!==3){var a=vn();return r===null?i?.after(a):r.before(a),Ve(a),a}wn(r)}return Ve(r),r}function xn(e){e.textContent=``}function Sn(){return!Je||kt!==null?!1:(cr.f&w)!==0}function Cn(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}function wn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Tn(e,t){if(t){let t=document.body;e.autofocus=!0,nt(()=>{document.activeElement===t&&e.focus()})}}function En(e){Re&&yn(e)!==null&&xn(e)}var Dn=!1;function On(){Dn||(Dn=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[me]?.()})},{capture:!0}))}function kn(e){var t=ar,n=cr;sr(null),lr(null);try{return e()}finally{sr(t),lr(n)}}function An(e,t,n,r=n){e.addEventListener(t,()=>kn(n));let i=e[me];i?e[me]=()=>{i(),r(!0)}:e[me]=()=>r(!0),On()}function jn(e){cr===null&&(ar===null&&Se(e),xe()),rr&&be(e)}function Mn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Nn(e,t){var n=cr;n!==null&&n.f&8192&&(e|=S);var r={ctx:Ze,deps:null,nodes:null,f:e|b|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};gt?.register_created_effect(r);var i=r;if(e&4)St===null?Et.ensure().schedule(r):St.push(r);else if(t!==null){try{Er(r)}catch(e){throw qn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=T))}if(i!==null&&(i.parent=n,n!==null&&Mn(i,n),ar!==null&&ar.f&2&&!(e&64))){var a=ar;(a.effects??=[]).push(i)}return r}function Pn(){return ar!==null&&!or}function Fn(e){let t=Nn(8,null);return st(t,y),t.teardown=e,t}function L(e){jn(`$effect`);var t=cr.f;if(!ar&&t&32&&!(t&32768)){var n=Ze;(n.e??=[]).push(e)}else return In(e)}function In(e){return Nn(4|ne,e)}function Ln(e){Et.ensure();let t=Nn(64|te,e);return()=>{qn(t)}}function Rn(e){Et.ensure();let t=Nn(64|te,e);return(e={})=>new Promise(n=>{e.outro?Xn(t,()=>{qn(t),n(void 0)}):(qn(t),n(void 0))})}function zn(e){return Nn(4,e)}function Bn(e){return Nn(ae|te,e)}function Vn(e,t=0){return Nn(8|t,e)}function R(e,t=[],n=[],r=[]){Bt(r,t,n,t=>{Nn(8,()=>e(...t.map(z)))})}function Hn(e,t=0){return Nn(16|t,e)}function Un(e){return Nn(32|te,e)}function Wn(e){var t=e.teardown;if(t!==null){let e=rr,n=ar;ir(!0),sr(null);try{t.call(null)}finally{ir(e),sr(n)}}}function Gn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&kn(()=>{e.abort(he)});var r=n.next;n.f&64?n.parent=null:qn(n,t),n=r}}function Kn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||qn(t),t=n}}function qn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Jn(e.nodes.start,e.nodes.end),n=!0),st(e,ee),Gn(e,t&&!n),Tr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Wn(e),e.f^=ee,e.f|=C;var i=e.parent;i!==null&&i.first!==null&&Yn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Jn(e,t){for(;e!==null;){var n=e===t?null:bn(e);e.remove(),e=n}}function Yn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Xn(e,t,n=!0){var r=[];Zn(e,r,!0);var i=()=>{n&&qn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Zn(e,t,n){if(!(e.f&8192)){e.f^=S;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;Zn(i,t,o?n:!1)}i=a}}}function Qn(e){$n(e,!0)}function $n(e,t){if(e.f&8192){e.f^=S,e.f&1024||(st(e,b),Et.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;$n(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function er(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:bn(n);t.append(n),n=i}}var tr=null,nr=!1,rr=!1;function ir(e){rr=e}var ar=null,or=!1;function sr(e){ar=e}var cr=null;function lr(e){cr=e}var ur=null;function dr(e){ar!==null&&(!Je||ar.f&2)&&(ur===null?ur=[e]:ur.push(e))}var fr=null,pr=0,mr=null;function hr(e){mr=e}var gr=1,_r=0,vr=_r;function yr(e){vr=e}function br(){return++gr}function xr(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~re),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(xr(a)&&Xt(a),a.wv>e.wv)return!0}t&512&&vt===null&&st(e,y)}return!1}function Sr(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Je&&ur!==null&&i.call(ur,e)))for(var a=0;a<r.length;a++){var o=r[a];o.f&2?Sr(o,t,!1):t===o&&(n?st(o,b):o.f&1024&&st(o,x),Nt(o))}}function Cr(e){var t=fr,n=pr,r=mr,i=ar,a=ur,o=Ze,s=or,c=vr,l=e.f;fr=null,pr=0,mr=null,ar=l&96?null:e,ur=null,Qe(e.ctx),or=!1,vr=++_r,e.ac!==null&&(kn(()=>{e.ac.abort(he)}),e.ac=null);try{e.f|=ie;var u=e.fn,d=u();e.f|=w;var f=e.deps,p=gt?.is_fork;if(fr!==null){var m;if(p||Tr(e,pr),f!==null&&pr>0)for(f.length=pr+fr.length,m=0;m<fr.length;m++)f[pr+m]=fr[m];else e.deps=f=fr;if(Pn()&&e.f&512)for(m=pr;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&pr<f.length&&(Tr(e,pr),f.length=pr);if($e()&&mr!==null&&!or&&f!==null&&!(e.f&6146))for(m=0;m<mr.length;m++)Sr(mr[m],e);if(i!==null&&i!==e){if(_r++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=_r;if(t!==null)for(let e of t)e.rv=_r;mr!==null&&(r===null?r=mr:r.push(...mr))}return e.f&8388608&&(e.f^=oe),d}catch(e){return it(e)}finally{e.f^=ie,fr=t,pr=n,mr=r,ar=i,ur=a,Qe(o),or=s,vr=c}}function wr(e,t){let n=t.reactions;if(n!==null){var a=r.call(n,e);if(a!==-1){var o=n.length-1;o===0?n=t.reactions=null:(n[a]=n[o],n.pop())}}if(n===null&&t.f&2&&(fr===null||!i.call(fr,t))){var s=t;s.f&512&&(s.f^=512,s.f&=~re),s.v!==Ae&&ct(s),Zt(s),Tr(s,0)}}function Tr(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)wr(e,n[r])}function Er(e){var t=e.f;if(!(t&16384)){st(e,y);var n=cr,r=nr;cr=e,nr=!0;try{t&16777232?Kn(e):Gn(e),Wn(e);var i=Cr(e);e.teardown=typeof i==`function`?i:null,e.wv=gr}finally{nr=r,cr=n}}}async function Dr(){if(Je)return new Promise(e=>{requestAnimationFrame(()=>e()),setTimeout(()=>e())});await Promise.resolve(),Dt()}function z(e){var t=(e.f&2)!=0;if(tr?.add(e),ar!==null&&!or&&!(cr!==null&&cr.f&16384)&&(ur===null||!i.call(ur,e))){var n=ar.deps;if(ar.f&2097152)e.rv<_r&&(e.rv=_r,fr===null&&n!==null&&n[pr]===e?pr++:fr===null?fr=[e]:fr.push(e));else{(ar.deps??=[]).push(e);var r=e.reactions;r===null?e.reactions=[ar]:i.call(r,ar)||r.push(ar)}}if(rr&&en.has(e))return en.get(e);if(t){var a=e;if(rr){var o=a.v;return(!(a.f&1024)&&a.reactions!==null||kr(a))&&(o=Yt(a)),en.set(a,o),o}var s=(a.f&512)==0&&!or&&ar!==null&&(nr||(ar.f&512)!=0),c=(a.f&w)===0;xr(a)&&(s&&(a.f|=512),Xt(a)),s&&!c&&(Qt(a),Or(a))}if(vt?.has(e))return vt.get(e);if(e.f&8388608)throw e.v;return e.v}function Or(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(Qt(t),Or(t))}function kr(e){if(e.v===Ae)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(en.has(t)||t.f&2&&kr(t))return!0;return!1}function Ar(e){var t=or;try{return or=!0,e()}finally{or=t}}function jr(e){if(!(typeof e!=`object`||!e||e instanceof EventTarget)){if(se in e)Mr(e);else if(!Array.isArray(e))for(let t in e){let n=e[t];typeof n==`object`&&n&&se in n&&Mr(n)}}}function Mr(e,t=new Set){if(typeof e==`object`&&e&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let n in e)try{Mr(e[n],t)}catch{}let n=d(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){let t=c(n);for(let n in t){let r=t[n].get;if(r)try{r.call(e)}catch{}}}}}[...`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`)];var Nr=[`touchstart`,`touchmove`];function Pr(e){return Nr.includes(e)}var Fr=Symbol(`events`),Ir=new Set,Lr=new Set;function Rr(e,t,n,r={}){function i(e){if(r.capture||Hr.call(t,e),!e.cancelBubble)return kn(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?nt(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function zr(e,t,n,r,i){var a={capture:r,passive:i},o=Rr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Fn(()=>{t.removeEventListener(e,o,a)})}function B(e,t,n){(t[Fr]??={})[e]=n}function Br(e){for(var t=0;t<e.length;t++)Ir.add(e[t]);for(var n of Lr)n(e)}var Vr=null;function Hr(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;Vr=e;var s=0,c=Vr===e&&e[Fr];if(c){var l=i.indexOf(c);if(l!==-1&&(t===document||t===window)){e[Fr]=t;return}var u=i.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(a=i[s]||e.target,a!==t){o(e,`currentTarget`,{configurable:!0,get(){return a||n}});var d=ar,f=cr;sr(null),lr(null);try{for(var p,m=[];a!==null;){var h=a.assignedSlot||a.parentNode||a.host||null;try{var g=a[Fr]?.[r];g!=null&&(!a.disabled||e.target===a)&&g.call(a,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble||h===t||h===null)break;a=h}if(p){for(let e of m)queueMicrotask(()=>{throw e});throw p}}finally{e[Fr]=t,delete e.currentTarget,sr(d),lr(f)}}}var Ur=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Wr(e){return Ur?.createHTML(e)??e}function Gr(e){var t=Cn(`template`);return t.innerHTML=Wr(e.replaceAll(`<!>`,`<!---->`)),t.content}function Kr(e,t){var n=cr;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function V(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(Re)return Kr(Be,null),Be;i===void 0&&(i=Gr(a?e:`<!>`+e),n||(i=yn(i)));var t=r||mn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=yn(t),s=t.lastChild;Kr(o,s)}else Kr(t,t);return t}}function qr(e,t,n=`svg`){var r=!e.startsWith(`<!>`),i=(t&1)!=0,a=`<${n}>${r?e:`<!>`+e}</${n}>`,o;return()=>{if(Re)return Kr(Be,null),Be;if(!o){var e=yn(Gr(a));if(i)for(o=document.createDocumentFragment();yn(e);)o.appendChild(yn(e));else o=yn(e)}var t=o.cloneNode(!0);if(i){var n=yn(t),r=t.lastChild;Kr(n,r)}else Kr(t,t);return t}}function Jr(e,t){return qr(e,t,`svg`)}function Yr(e=``){if(!Re){var t=vn(e+``);return Kr(t,t),t}var n=Be;return n.nodeType===3?wn(n):(n.before(n=vn()),Ve(n)),Kr(n,n),n}function Xr(){if(Re)return Kr(Be,null),Be;var e=document.createDocumentFragment(),t=document.createComment(``),n=vn();return e.append(t,n),Kr(t,n),e}function H(e,t){if(Re){var n=cr;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=Be),He();return}e!==null&&e.before(t)}var Zr=!0;function U(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[pe]??=e.nodeValue)&&(e[pe]=n,e.nodeValue=`${n}`)}function Qr(e,t){return ei(e,t)}var $r=new Map;function ei(e,{target:t,anchor:n,props:r={},events:i,context:o,intro:s=!0,transformError:c}){_n();var l=void 0,u=Rn(()=>{var u=n??t.appendChild(vn());Rt(u,{pending:()=>{}},t=>{k({});var n=Ze;if(o&&(n.c=o),i&&(r.$$events=i),Re&&Kr(t,null),Zr=s,l=e(t,r)||{},Zr=!0,Re&&(cr.nodes.end=Be,Be===null||Be.nodeType!==8||Be.data!==`]`))throw Fe(),ke;A()},c);var d=new Set,f=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!d.has(r)){d.add(r);var i=Pr(r);for(let e of[t,document]){var a=$r.get(e);a===void 0&&(a=new Map,$r.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,Hr,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return f(a(Ir)),Lr.add(f),()=>{for(var e of d)for(let n of[t,document]){var r=$r.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Hr),r.delete(e),r.size===0&&$r.delete(n)):r.set(e,i)}Lr.delete(f),u!==n&&u.parentNode?.removeChild(u)}});return ti.set(l,u),l}var ti=new WeakMap,ni=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)Qn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(qn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();er(r,t),t.append(vn()),this.#n.set(e,{effect:r,fragment:t})}else qn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Xn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(qn(n.effect),this.#n.delete(e))};ensure(e,t){var n=gt,r=Sn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=vn();i.append(a),this.#n.set(e,{effect:Un(()=>t(a)),fragment:i})}else this.#t.set(e,Un(()=>t(this.anchor)));if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else Re&&(this.anchor=Be),this.#a(n)}},ri=0,ii=1,ai=2;function oi(e,t,n,r,i){Re&&He();var a=$e(),o=Ae,s=a?nn(o):rn(o,!1,!1),c=a?nn(o):rn(o,!1,!1),l=new ni(e);Hn(()=>{var a=gt;a.deactivate();var o=t();a.activate();var u=!1;let d=Re&&h(o)===(e.data===`[!`);if(d&&(Ve(Ue()),ze(!1)),h(o)){var f=Vt(),p=!1;let e=e=>{if(!u){p=!0,f(!1),Et.ensure(),Re&&ze(!1);try{e()}finally{Ht(!1),bt||Dt()}}};o.then(t=>{e(()=>{an(s,t),l.ensure(ii,r&&(e=>r(e,s)))})},t=>{e(()=>{if(an(c,t),l.ensure(ai,i&&(e=>i(e,c))),!i)throw c.v})}),Re?l.ensure(ri,n):nt(()=>{p||e(()=>{l.ensure(ri,n)})})}else an(s,o),l.ensure(ii,r&&(e=>r(e,s)));return d&&ze(!0),()=>{u=!0}})}function W(e,t,n=!1){var r;Re&&(r=Be,He());var i=new ni(e),a=n?T:0;function o(e,t){if(Re){var n=We(r);if(e!==parseInt(n.substring(1))){var a=Ue();Ve(a),i.anchor=a,ze(!1),i.ensure(e,t),ze(!0);return}}i.ensure(e,t)}Hn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var si=Symbol(`NaN`);function ci(e,t,n){Re&&He();var r=new ni(e),i=!$e();Hn(()=>{var e=t();e!==e&&(e=si),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function li(e,t){return t}function ui(e,t,n){for(var r=[],i=t.length,o,s=t.length,c=0;c<i;c++){let n=t[c];Xn(n,()=>{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;di(e,a(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else --s},!1)}if(s===0){var l=r.length===0&&n!==null;if(l){var u=n,d=u.parentNode;xn(d),d.append(u),e.items.clear()}di(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function di(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i<t.length;i++){var a=t[i];r?.has(a)?(a.f|=E,er(a,document.createDocumentFragment())):qn(t[i],n)}}var fi;function pi(e,t,r,i,o,s=null){var c=e,l=new Map;if(t&4){var u=e;c=Re?Ve(yn(u)):u.appendChild(vn())}Re&&He();var d=null,f=qt(()=>{var e=r();return n(e)?e:e==null?[]:a(e)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,hi(v,p,c,t,i),d!==null&&(p.length===0?d.f&33554432?(d.f^=E,_i(d,null,c)):Qn(d):Xn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Hn(()=>{p=z(f);var e=p.length;let n=!1;Re&&We(c)===`[!`!=(e===0)&&(c=Ue(),Ve(c),ze(!1),n=!0);for(var a=new Set,u=gt,v=Sn(),y=0;y<e;y+=1){Re&&Be.nodeType===8&&Be.data===`]`&&(c=Be,n=!0,ze(!1));var b=p[y],x=i(b,y),S=h?null:l.get(x);S?(S.v&&an(S.v,b),S.i&&an(S.i,y),v&&u.unskip_effect(S.e)):(S=gi(l,h?c:fi??=vn(),b,x,y,o,t,r),h||(S.e.f|=E),l.set(x,S)),a.add(x)}if(e===0&&s&&!d&&(h?d=Un(()=>s(c)):(d=Un(()=>s(fi??=vn())),d.f|=E)),e>a.size&&ye(``,``,``),Re&&e>0&&Ve(Ue()),!h)if(m.set(u,a),v){for(let[e,t]of l)a.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u);n&&ze(!0),z(f)}),flags:t,items:l,pending:m,outrogroups:null,fallback:d};h=!1,Re&&(c=Be)}function mi(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function hi(e,t,n,r,i){var o=(r&8)!=0,s=t.length,c=e.items,l=mi(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v<s;v+=1)h=t[v],g=i(h,v),_=c.get(g).e,_.f&33554432||(_.nodes?.a?.measure(),(f??=new Set).add(_));for(v=0;v<s;v+=1){if(h=t[v],g=i(h,v),_=c.get(g).e,e.outrogroups!==null)for(let t of e.outrogroups)t.pending.delete(_),t.done.delete(_);if(_.f&8192&&(Qn(_),o&&(_.nodes?.a?.unfix(),(f??=new Set).delete(_))),_.f&33554432)if(_.f^=E,_===l)_i(_,null,n);else{var y=d?d.next:l;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),vi(e,d,_),vi(e,_,y),_i(_,y,n),d=_,p=[],m=[],l=mi(d.next);continue}if(_!==l){if(u!==void 0&&u.has(_)){if(p.length<m.length){var b=m[0],x;d=b.prev;var S=p[0],C=p[p.length-1];for(x=0;x<p.length;x+=1)_i(p[x],b,n);for(x=0;x<m.length;x+=1)u.delete(m[x]);vi(e,S.prev,C.next),vi(e,d,S),vi(e,C,b),l=b,d=C,--v,p=[],m=[]}else u.delete(_),_i(_,l,n),vi(e,_.prev,_.next),vi(e,_,d===null?e.effect.first:d.next),vi(e,d,_),d=_;continue}for(p=[],m=[];l!==null&&l!==_;)(u??=new Set).add(l),m.push(l),l=mi(l.next);if(l===null)continue}_.f&33554432||p.push(_),d=_,l=mi(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(di(e,a(t.done)),e.outrogroups?.delete(t));e.outrogroups.size===0&&(e.outrogroups=null)}if(l!==null||u!==void 0){var w=[];if(u!==void 0)for(_ of u)_.f&8192||w.push(_);for(;l!==null;)!(l.f&8192)&&l!==e.fallback&&w.push(l),l=mi(l.next);var ee=w.length;if(ee>0){var T=r&4&&s===0?n:null;if(o){for(v=0;v<ee;v+=1)w[v].nodes?.a?.measure();for(v=0;v<ee;v+=1)w[v].nodes?.a?.fix()}ui(e,w,T)}}o&&nt(()=>{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function gi(e,t,n,r,i,a,o,s){var c=o&1?o&16?nn(n):rn(n,!1,!1):null,l=o&2?nn(i):null;return{v:c,i:l,e:Un(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function _i(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=bn(r);if(a.before(r),r===i)return;r=o}}function vi(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function yi(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;Re&&(o=Ve(yn(c)))}R(()=>{var e=cr;if(s===(s=t()??``)){Re&&He();return}if(n&&!Re){e.nodes=null,c.innerHTML=s,s!==``&&Kr(yn(c),c.lastChild);return}if(e.nodes!==null&&(Jn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(Re){for(var a=Be.data,l=He(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=bn(l);if(l===null)throw Fe(),ke;Kr(Be,u),o=Ve(l);return}var d=Cn(r?`svg`:i?`math`:`template`,r?Me:i?Ne:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Kr(yn(f),f.lastChild),r||i)for(;yn(f);)o.before(yn(f));else o.before(f)}})}function bi(e,t,...n){var r=new ni(e);Hn(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},T)}function xi(e,t,n){var r;Re&&(r=Be,He());var i=new ni(e);Hn(()=>{var e=t()??null;if(Re&&We(r)===`[`!=(e!==null)){var a=Ue();Ve(a),i.anchor=a,ze(!1),i.ensure(e,e&&(t=>n(t,e))),ze(!0);return}i.ensure(e,e&&(t=>n(t,e)))},T)}var Si=()=>performance.now(),Ci={tick:e=>requestAnimationFrame(e),now:()=>Si(),tasks:new Set};function wi(){let e=Ci.now();Ci.tasks.forEach(t=>{t.c(e)||(Ci.tasks.delete(t),t.f())}),Ci.tasks.size!==0&&Ci.tick(wi)}function Ti(e){let t;return Ci.tasks.size===0&&Ci.tick(wi),{promise:new Promise(n=>{Ci.tasks.add(t={c:e,f:n})}),abort(){Ci.tasks.delete(t)}}}function Ei(e,t){kn(()=>{e.dispatchEvent(new CustomEvent(t))})}function Di(e){if(e===`float`)return`cssFloat`;if(e===`offset`)return`cssOffset`;if(e.startsWith(`--`))return e;let t=e.split(`-`);return t.length===1?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function Oi(e){let t={},n=e.split(`;`);for(let e of n){let[n,r]=e.split(`:`);if(!n||r===void 0)break;let i=Di(n.trim());t[i]=r.trim()}return t}var ki=e=>e,Ai=null;function ji(e,t,n){var r=(Ai??cr).nodes,i,a,o,s=null;r.a??={element:e,measure(){i=this.element.getBoundingClientRect()},apply(){if(o?.abort(),a=this.element.getBoundingClientRect(),i.left!==a.left||i.right!==a.right||i.top!==a.top||i.bottom!==a.bottom){let e=t()(this.element,{from:i,to:a},n?.());o=Ni(this.element,e,void 0,1,()=>{},()=>{o?.abort(),o=void 0})}},fix(){if(!e.getAnimations().length){var{position:t,width:n,height:r}=getComputedStyle(e);if(t!==`absolute`&&t!==`fixed`){var a=e.style;s={position:a.position,width:a.width,height:a.height,transform:a.transform},a.position=`absolute`,a.width=n,a.height=r;var o=e.getBoundingClientRect();if(i.left!==o.left||i.top!==o.top){var c=`translate(${i.left-o.left}px, ${i.top-o.top}px)`;a.transform=a.transform?`${a.transform} ${c}`:c}}}},unfix(){if(s){var t=e.style;t.position=s.position,t.width=s.width,t.height=s.height,t.transform=s.transform}}},r.a.element=e}function Mi(e,t,n,r){var i=(e&1)!=0,a=(e&2)!=0,o=i&&a,s=(e&4)!=0,c=o?`both`:i?`in`:`out`,l,u=t.inert,d=t.style.overflow,f,p;function m(){return kn(()=>l??=n()(t,r?.()??{},{direction:c}))}var h={is_global:s,in(){if(t.inert=u,!i){p?.abort(),p?.reset?.();return}a||f?.abort(),f=Ni(t,m(),p,1,()=>{Ei(t,`introstart`)},()=>{Ei(t,`introend`),f?.abort(),f=l=void 0,t.style.overflow=d})},out(e){if(!a){e?.(),l=void 0;return}t.inert=!0,p=Ni(t,m(),f,0,()=>{Ei(t,`outrostart`)},()=>{Ei(t,`outroend`),e?.()})},stop:()=>{f?.abort(),p?.abort()}},g=cr;if((g.nodes.t??=[]).push(h),i&&Zr){var _=s;if(!_){for(var v=g.parent;v&&v.f&65536;)for(;(v=v.parent)&&!(v.f&16););_=!v||(v.f&32768)!=0}_&&zn(()=>{Ar(()=>h.in())})}}function Ni(e,t,n,r,i,a){var o=r===1;if(p(t)){var s,c=!1;return nt(()=>{c||(s=Ni(e,t({direction:o?`in`:`out`}),n,r,i,a))}),{abort:()=>{c=!0,s?.abort()},deactivate:()=>s.deactivate(),reset:()=>s.reset(),t:()=>s.t()}}if(n?.deactivate(),!t?.duration&&!t?.delay)return i(),a(),{abort:m,deactivate:m,reset:m,t:()=>r};let{delay:l=0,css:u,tick:d,easing:f=ki}=t;var h=[];if(o&&n===void 0&&(d&&d(0,1),u)){var g=Oi(u(0,1));h.push(g,g)}var _=()=>1-r,v=e.animate(h,{duration:l,fill:`forwards`});return v.onfinish=()=>{v.cancel(),i();var o=n?.t()??1-r;n?.abort();var s=r-o,c=t.duration*Math.abs(s),l=[];if(c>0){var p=!1;if(u)for(var m=Math.ceil(c/(1e3/60)),h=0;h<=m;h+=1){var g=o+s*f(h/m),y=Oi(u(g,1-g));l.push(y),p||=y.overflow===`hidden`}p&&(e.style.overflow=`hidden`),_=()=>{var e=v.currentTime;return o+s*f(e/c)},d&&Ti(()=>{if(v.playState!==`running`)return!1;var e=_();return d(e,1-e),!0})}v=e.animate(l,{duration:c,fill:`forwards`}),v.onfinish=()=>{_=()=>r,d?.(r,1-r),a()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=m)},deactivate:()=>{a=m},reset:()=>{r===0&&d?.(1,0)},t:()=>_()}}function Pi(e,t,n){zn(()=>{var r=Ar(()=>t(e,n?.())||{});if(n&&r?.update){var i=!1,a={};Vn(()=>{var e=n();jr(e),i&&Ke(a,e)&&(a=e,r.update(e))}),i=!0}if(r?.destroy)return()=>r.destroy()})}function Fi(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Fi(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Ii(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Fi(e))&&(r&&(r+=` `),r+=t);return r}function Li(e){return typeof e==`object`?Ii(e):e??``}var Ri=[...`
|
|
3
|
-
\r\f\xA0\v`];function zi(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||Ri.includes(r[o-1]))&&(s===r.length||Ri.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Bi(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function Vi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Hi(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(Vi)),i&&c.push(...Object.keys(i).map(Vi));var l=0,u=-1;let t=e.length;for(var d=0;d<t;d++){var f=e[d];if(s?f===`/`&&e[d-1]===`*`&&(s=!1):a?a===f&&(a=!1):f===`/`&&e[d+1]===`*`?s=!0:f===`"`||f===`'`?a=f:f===`(`?o++:f===`)`&&o--,!s&&a===!1&&o===0){if(f===`:`&&u===-1)u=d;else if(f===`;`||d===t-1){if(u!==-1){var p=Vi(e.substring(l,u).trim());if(!c.includes(p)){f!==`;`&&d++;var m=e.substring(l,d).trim();n+=` `+m+`;`}}l=d+1,u=-1}}}}return r&&(n+=Bi(r)),i&&(n+=Bi(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function Ui(e,t,n,r,i,a){var o=e[de];if(Re||o!==n||o===void 0){var s=zi(n,r,a);(!Re||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e[de]=n}else if(a&&i!==a)for(var c in a){var l=!!a[c];(i==null||l!==!!i[c])&&e.classList.toggle(c,l)}return a}function Wi(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,a,r))}}function G(e,t,n,r){var i=e[fe];if(Re||i!==t){var a=Hi(t,r);(!Re||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e[fe]=t}else r&&(Array.isArray(r)?(Wi(e,n?.[0],r[0]),Wi(e,n?.[1],r[1],`important`)):Wi(e,n,r));return r}function Gi(e,t,r=!1){if(e.multiple){if(t==null)return;if(!n(t))return Ie();for(var i of e.options)i.selected=t.includes(Ji(i));return}for(i of e.options)if(fn(Ji(i),t)){i.selected=!0;return}(!r||t!==void 0)&&(e.selectedIndex=-1)}function Ki(e){var t=new MutationObserver(()=>{Gi(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),Fn(()=>{t.disconnect()})}function qi(e,t,n=t){var r=new WeakSet,i=!0;An(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Ji);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Ji(o)}n(a),e.__value=a,gt!==null&&r.add(gt)}),zn(()=>{var a=t();if(e===document.activeElement){var o=Je?_t:gt;if(r.has(o))return}if(Gi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Ji(s),n(a))}e.__value=a,i=!1}),Ki(e)}function Ji(e){return`__value`in e?e.__value:e.value}var Yi=Symbol(`is custom element`),Xi=Symbol(`is html`),Zi=ge?`link`:`LINK`,Qi=ge?`progress`:`PROGRESS`;function $i(e){if(Re){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;K(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;K(e,`checked`,null),e.checked=r}}};e[me]=n,nt(n),On()}}function ea(e,t){var n=na(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==Qi)||(e.value=t??``)}function ta(e,t){var n=na(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function K(e,t,n,r){var i=na(e);Re&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Zi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[le]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&ia(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function na(e){return e[ue]??={[Yi]:e.nodeName.includes(`-`),[Xi]:e.namespaceURI===je}}var ra=new Map;function ia(e){var t=e.getAttribute(`is`)||e.nodeName,n=ra.get(t);if(n)return n;ra.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=c(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=d(i)}return n}function aa(e,t,n=t){var r=new WeakSet;An(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=sa(e)?ca(a):a,n(a),gt!==null&&r.add(gt),await Dr(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(Re&&e.defaultValue!==e.value||Ar(t)==null&&e.value)&&(n(sa(e)?ca(e.value):e.value),gt!==null&&r.add(gt)),Vn(()=>{var n=t();if(e===document.activeElement){var i=Je?_t:gt;if(r.has(i))return}sa(e)&&n===ca(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function oa(e,t,n=t){An(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(Re&&e.defaultChecked!==e.checked||Ar(t)==null)&&n(e.checked),Vn(()=>{e.checked=!!t()})}function sa(e){var t=e.type;return t===`number`||t===`range`}function ca(e){return e===``?null:+e}var la=new class e{#e=new WeakMap;#t;#n;static entries=new WeakMap;constructor(e){this.#n=e}observe(e,t){var n=this.#e.get(e)||new Set;return n.add(t),this.#e.set(e,n),this.#r().observe(e,this.#n),()=>{var n=this.#e.get(e);n.delete(t),n.size===0&&(this.#e.delete(e),this.#t.unobserve(e))}}#r(){return this.#t??=new ResizeObserver(t=>{for(var n of t){e.entries.set(n.target,n);for(var r of this.#e.get(n.target)||[])r(n)}})}}({box:`border-box`});function ua(e,t,n){var r=la.observe(e,()=>n(e[t]));zn(()=>(Ar(()=>n(e[t])),r))}function da(e,t){return e===t||e?.[se]===t}function fa(e={},t,n,r){var i=Ze.r,a=cr;return zn(()=>{var o,s;return Vn(()=>{o=s,s=r?.()||[],Ar(()=>{da(n(...s),e)||(t(e,...s),o&&da(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&da(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var pa={get(e,t){if(!e.exclude.includes(t))return e.props[t]},set(e,t){return!1},getOwnPropertyDescriptor(e,t){if(!e.exclude.includes(t)&&t in e.props)return{enumerable:!0,configurable:!0,value:e.props[t]}},has(e,t){return e.exclude.includes(t)?!1:t in e.props},ownKeys(e){return Reflect.ownKeys(e.props).filter(t=>!e.exclude.includes(t))}};function ma(e,t,n){return new Proxy({props:e,exclude:t},pa)}var ha={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(p(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];p(i)&&(i=i());let a=s(i,t);if(a&&a.set)return a.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(p(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=s(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===se||t===ce)return!1;for(let n of e.props)if(p(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(p(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function ga(...e){return new Proxy({props:e},ha)}function q(e,t,n,r){var i=!Ye||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,c=r,l=!0,u=void 0,d=()=>o&&i?(u??=Wt(r),z(u)):(l&&(l=!1,c=o?Ar(r):r),c);let f;if(a){var p=se in e||ce in e;f=s(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;a?[m,h]=pt(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&we(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?Wt:qt)(()=>(v=!1,g()));a&&z(y);var b=cr;return(function(e,t){if(arguments.length>0){let n=t?z(y):i&&a?un(e):e;return N(y,n),v=!0,c!==void 0&&(c=n),e}return rr&&v||b.f&16384?y.v:z(y)})}function _a(e){Ze===null&&_e(`onMount`),Ye&&Ze.l!==null?ya(Ze).m.push(e):L(()=>{let t=Ar(e);if(typeof t==`function`)return t})}function va(e){Ze===null&&_e(`onDestroy`),_a(()=>()=>Ar(e))}function ya(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`),Xe();var ba=3478,xa=3479,Sa=`https://github.com/bloknayrb/tandem`,Ca=`${Sa}/issues/new`,wa=new Set([`.md`,`.txt`,`.html`,`.htm`,`.docx`]),Ta=3e3,Ea=3e3,Da=3e4,Oa={yellow:`rgba(255, 235, 59, 0.3)`,green:`rgba(76, 175, 80, 0.3)`,blue:`rgba(33, 150, 243, 0.3)`,pink:`rgba(236, 72, 153, 0.3)`},ka={yellow:`var(--tandem-highlight-yellow)`,green:`var(--tandem-highlight-green)`,blue:`var(--tandem-highlight-blue)`,pink:`var(--tandem-highlight-pink)`};function Aa(e){return e&&e in Oa?e:`yellow`}var ja=`tandem`,Ma=`tandem:mode`,Na=`tandem:settings`,Pa={left:`tandem-left-panel-width`,right:`tandem-panel-width`},Fa=1e3,Ia=3e3,La=`__tandem_ctrl__`,Ra=`annotations`,za=`awareness`,Ba=`userAwareness`,Va=`mode`,Ha=`selectionDwellMs`,Ua=`chat`,Wa=`documentMeta`,Ga=`annotationReplies`,Ka=`savedAtVersion`,qa=`authorship`,Ja=`selection`,Ya=`activity`,Xa=`claude`,Za=`openDocuments`,Qa=`activeDocumentId`,$a=`activeDocumentEpoch`,eo=`storeReadOnly`,to=`fidelityReport`,no=`tandem:showAuthorship`,ro=`tandem:decorationVisibility`,io=`tandem:recentFiles`,ao=`tandem:userName`,oo=`tandem:user-name-changed`,so={error:8e3,warning:6e3,info:4e3},co=5*6e4,lo=`tandem:tutorialCompleted`,uo=`tutorial-`,fo=`tandem:coworkOnboardingSkipped`,po=3e4,mo=2e3,ho=`tandem:zoomLevel`,go=.5,_o=`upload://`,vo=`upload://scratchpad/`;function yo(e){return e.startsWith(_o)}function bo(e){return e.startsWith(vo)}function xo(e){if(!bo(e))return null;let t=e.slice(20).split(`/`)[0];return t.length>0?t:null}var So=e=>e,Co=e=>e,wo;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(wo||={});var To;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(To||={});var J=wo.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Eo=e=>{switch(typeof e){case`undefined`:return J.undefined;case`string`:return J.string;case`number`:return Number.isNaN(e)?J.nan:J.number;case`boolean`:return J.boolean;case`function`:return J.function;case`bigint`:return J.bigint;case`symbol`:return J.symbol;case`object`:return Array.isArray(e)?J.array:e===null?J.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?J.promise:typeof Map<`u`&&e instanceof Map?J.map:typeof Set<`u`&&e instanceof Set?J.set:typeof Date<`u`&&e instanceof Date?J.date:J.object;default:return J.unknown}},Y=wo.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),Do=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,wo.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Do.create=e=>new Do(e);var Oo=(e,t)=>{let n;switch(e.code){case Y.invalid_type:n=e.received===J.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,wo.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${wo.joinValues(e.keys,`, `)}`;break;case Y.invalid_union:n=`Invalid input`;break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${wo.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${wo.joinValues(e.options)}, received '${e.received}'`;break;case Y.invalid_arguments:n=`Invalid function arguments`;break;case Y.invalid_return_type:n=`Invalid function return type`;break;case Y.invalid_date:n=`Invalid date`;break;case Y.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:wo.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case Y.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case Y.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case Y.custom:n=`Invalid input`;break;case Y.invalid_intersection_types:n=`Intersection results could not be merged`;break;case Y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Y.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,wo.assertNever(e)}return{message:n}},ko=Oo;function Ao(){return ko}var jo=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function X(e,t){let n=Ao(),r=jo({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Oo?void 0:Oo].filter(e=>!!e)});e.common.issues.push(r)}var Mo=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return No;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return No;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},No=Object.freeze({status:`aborted`}),Po=e=>({status:`dirty`,value:e}),Fo=e=>({status:`valid`,value:e}),Io=e=>e.status===`aborted`,Lo=e=>e.status===`dirty`,Ro=e=>e.status===`valid`,zo=e=>typeof Promise<`u`&&e instanceof Promise,Bo;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Bo||={});var Vo=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ho=(e,t)=>{if(Ro(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Do(e.common.issues);return this._error=t,this._error}}};function Uo(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var Wo=class{get description(){return this._def.description}_getType(e){return Eo(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Eo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Mo,ctx:{common:e.parent.common,data:e.data,parsedType:Eo(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(zo(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Eo(e)};return Ho(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Eo(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ro(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Ro(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Eo(e)},r=this._parse({data:e,path:n.path,parent:n});return Ho(n,await(zo(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:Y.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Js({schema:this,typeName:rc.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Ys.create(this,this._def)}nullable(){return Xs.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ks.create(this)}promise(){return qs.create(this,this._def)}or(e){return Ms.create([this,e],this._def)}and(e){return Is.create(this,e,this._def)}transform(e){return new Js({...Uo(this._def),schema:this,typeName:rc.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Zs({...Uo(this._def),innerType:this,defaultValue:t,typeName:rc.ZodDefault})}brand(){return new ec({typeName:rc.ZodBranded,type:this,...Uo(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Qs({...Uo(this._def),innerType:this,catchValue:t,typeName:rc.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return tc.create(this,e)}readonly(){return nc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Go=/^c[^\s-]{8,}$/i,Ko=/^[0-9a-z]+$/,qo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Jo=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Yo=/^[a-z0-9_-]{21}$/i,Xo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Zo=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Qo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$o=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,es,ts=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ns=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,rs=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,is=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,as=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ss=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,cs=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,ls=RegExp(`^${cs}$`);function us(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function ds(e){return RegExp(`^${us(e)}$`)}function fs(e){let t=`${cs}T${us(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ps(e,t){return!!((t===`v4`||!t)&&ts.test(e)||(t===`v6`||!t)&&rs.test(e))}function ms(e,t){if(!Xo.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function hs(e,t){return!!((t===`v4`||!t)&&ns.test(e)||(t===`v6`||!t)&&is.test(e))}var gs=class e extends Wo{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.string,received:t.parsedType}),No}let t=new Mo,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?X(n,{code:Y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&X(n,{code:Y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Qo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`email`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)es||=new RegExp($o,`u`),es.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`emoji`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Jo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`uuid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Yo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`nanoid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Go.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`cuid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Ko.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`cuid2`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)qo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`ulid`,code:Y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),X(n,{validation:`url`,code:Y.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`regex`,code:Y.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?fs(r).test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?ls.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?ds(r).test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:Y.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Zo.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`duration`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?ps(e.data,r.version)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`ip`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?ms(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`jwt`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?hs(e.data,r.version)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`cidr`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?as.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`base64`,code:Y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?ss.test(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{validation:`base64url`,code:Y.invalid_string,message:r.message}),t.dirty()):wo.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:Y.invalid_string,...Bo.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Bo.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Bo.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Bo.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Bo.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Bo.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Bo.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Bo.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Bo.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Bo.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Bo.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Bo.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Bo.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Bo.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Bo.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...Bo.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Bo.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Bo.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Bo.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Bo.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Bo.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Bo.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Bo.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Bo.errToObj(t)})}nonempty(e){return this.min(1,Bo.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};gs.create=e=>new gs({checks:[],typeName:rc.ZodString,coerce:e?.coerce??!1,...Uo(e)});function _s(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var vs=class e extends Wo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==J.number){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.number,received:t.parsedType}),No}let t,n=new Mo;for(let r of this._def.checks)r.kind===`int`?wo.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),X(t,{code:Y.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?_s(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),X(t,{code:Y.not_finite,message:r.message}),n.dirty()):wo.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Bo.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Bo.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Bo.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Bo.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Bo.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Bo.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Bo.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Bo.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Bo.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Bo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Bo.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Bo.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Bo.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Bo.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&wo.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};vs.create=e=>new vs({checks:[],typeName:rc.ZodNumber,coerce:e?.coerce||!1,...Uo(e)});var ys=class e extends Wo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==J.bigint)return this._getInvalidInput(e);let t,n=new Mo;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),X(t,{code:Y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):wo.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.bigint,received:t.parsedType}),No}gte(e,t){return this.setLimit(`min`,e,!0,Bo.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Bo.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Bo.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Bo.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Bo.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:Bo.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Bo.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Bo.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Bo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Bo.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};ys.create=e=>new ys({checks:[],typeName:rc.ZodBigInt,coerce:e?.coerce??!1,...Uo(e)});var bs=class extends Wo{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.boolean,received:t.parsedType}),No}return Fo(e.data)}};bs.create=e=>new bs({typeName:rc.ZodBoolean,coerce:e?.coerce||!1,...Uo(e)});var xs=class e extends Wo{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.date,received:t.parsedType}),No}if(Number.isNaN(e.data.getTime()))return X(this._getOrReturnCtx(e),{code:Y.invalid_date}),No;let t=new Mo,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),X(n,{code:Y.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):wo.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:Bo.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Bo.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};xs.create=e=>new xs({checks:[],coerce:e?.coerce||!1,typeName:rc.ZodDate,...Uo(e)});var Ss=class extends Wo{_parse(e){if(this._getType(e)!==J.symbol){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.symbol,received:t.parsedType}),No}return Fo(e.data)}};Ss.create=e=>new Ss({typeName:rc.ZodSymbol,...Uo(e)});var Cs=class extends Wo{_parse(e){if(this._getType(e)!==J.undefined){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.undefined,received:t.parsedType}),No}return Fo(e.data)}};Cs.create=e=>new Cs({typeName:rc.ZodUndefined,...Uo(e)});var ws=class extends Wo{_parse(e){if(this._getType(e)!==J.null){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.null,received:t.parsedType}),No}return Fo(e.data)}};ws.create=e=>new ws({typeName:rc.ZodNull,...Uo(e)});var Ts=class extends Wo{constructor(){super(...arguments),this._any=!0}_parse(e){return Fo(e.data)}};Ts.create=e=>new Ts({typeName:rc.ZodAny,...Uo(e)});var Es=class extends Wo{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Fo(e.data)}};Es.create=e=>new Es({typeName:rc.ZodUnknown,...Uo(e)});var Ds=class extends Wo{_parse(e){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.never,received:t.parsedType}),No}};Ds.create=e=>new Ds({typeName:rc.ZodNever,...Uo(e)});var Os=class extends Wo{_parse(e){if(this._getType(e)!==J.undefined){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.void,received:t.parsedType}),No}return Fo(e.data)}};Os.create=e=>new Os({typeName:rc.ZodVoid,...Uo(e)});var ks=class e extends Wo{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==J.array)return X(t,{code:Y.invalid_type,expected:J.array,received:t.parsedType}),No;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(X(t,{code:e?Y.too_big:Y.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(X(t,{code:Y.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(X(t,{code:Y.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Vo(t,e,t.path,n)))).then(e=>Mo.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Vo(t,e,t.path,n)));return Mo.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Bo.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Bo.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Bo.toString(n)}})}nonempty(e){return this.min(1,e)}};ks.create=(e,t)=>new ks({type:e,minLength:null,maxLength:null,exactLength:null,typeName:rc.ZodArray,...Uo(t)});function As(e){if(e instanceof js){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Ys.create(As(r))}return new js({...e._def,shape:()=>t})}else if(e instanceof ks)return new ks({...e._def,type:As(e.element)});else if(e instanceof Ys)return Ys.create(As(e.unwrap()));else if(e instanceof Xs)return Xs.create(As(e.unwrap()));else if(e instanceof Ls)return Ls.create(e.items.map(e=>As(e)));else return e}var js=class e extends Wo{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=wo.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==J.object){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.object,received:t.parsedType}),No}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ds&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Vo(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Ds){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(X(n,{code:Y.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Vo(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>Mo.mergeObjectSync(t,e)):Mo.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Bo.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:Bo.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:rc.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of wo.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of wo.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return As(this)}partial(t){let n={};for(let e of wo.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of wo.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ys;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Ws(wo.objectKeys(this.shape))}};js.create=(e,t)=>new js({shape:()=>e,unknownKeys:`strip`,catchall:Ds.create(),typeName:rc.ZodObject,...Uo(t)}),js.strictCreate=(e,t)=>new js({shape:()=>e,unknownKeys:`strict`,catchall:Ds.create(),typeName:rc.ZodObject,...Uo(t)}),js.lazycreate=(e,t)=>new js({shape:e,unknownKeys:`strip`,catchall:Ds.create(),typeName:rc.ZodObject,...Uo(t)});var Ms=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Do(e.ctx.common.issues));return X(t,{code:Y.invalid_union,unionErrors:n}),No}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Do(e));return X(t,{code:Y.invalid_union,unionErrors:i}),No}}get options(){return this._def.options}};Ms.create=(e,t)=>new Ms({options:e,typeName:rc.ZodUnion,...Uo(t)});var Ns=e=>e instanceof Hs?Ns(e.schema):e instanceof Js?Ns(e.innerType()):e instanceof Us?[e.value]:e instanceof Gs?e.options:e instanceof Ks?wo.objectValues(e.enum):e instanceof Zs?Ns(e._def.innerType):e instanceof Cs?[void 0]:e instanceof ws?[null]:e instanceof Ys?[void 0,...Ns(e.unwrap())]:e instanceof Xs?[null,...Ns(e.unwrap())]:e instanceof ec||e instanceof nc?Ns(e.unwrap()):e instanceof Qs?Ns(e._def.innerType):[],Ps=class e extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return X(t,{code:Y.invalid_type,expected:J.object,received:t.parsedType}),No;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(X(t,{code:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),No)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ns(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:rc.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Uo(r)})}};function Fs(e,t){let n=Eo(e),r=Eo(t);if(e===t)return{valid:!0,data:e};if(n===J.object&&r===J.object){let n=wo.objectKeys(t),r=wo.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Fs(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===J.array&&r===J.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Fs(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===J.date&&r===J.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Is=class extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Io(e)||Io(r))return No;let i=Fs(e.value,r.value);return i.valid?((Lo(e)||Lo(r))&&t.dirty(),{status:t.value,value:i.data}):(X(n,{code:Y.invalid_intersection_types}),No)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Is.create=(e,t,n)=>new Is({left:e,right:t,typeName:rc.ZodIntersection,...Uo(n)});var Ls=class e extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return X(n,{code:Y.invalid_type,expected:J.array,received:n.parsedType}),No;if(n.data.length<this._def.items.length)return X(n,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),No;!this._def.rest&&n.data.length>this._def.items.length&&(X(n,{code:Y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Vo(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Mo.mergeArray(t,e)):Mo.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ls.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ls({items:e,typeName:rc.ZodTuple,rest:null,...Uo(t)})};var Rs=class e extends Wo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.object)return X(n,{code:Y.invalid_type,expected:J.object,received:n.parsedType}),No;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Vo(n,e,n.path,e)),value:a._parse(new Vo(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Mo.mergeObjectAsync(t,r):Mo.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Wo?new e({keyType:t,valueType:n,typeName:rc.ZodRecord,...Uo(r)}):new e({keyType:gs.create(),valueType:t,typeName:rc.ZodRecord,...Uo(n)})}},zs=class extends Wo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.map)return X(n,{code:Y.invalid_type,expected:J.map,received:n.parsedType}),No;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Vo(n,e,n.path,[a,`key`])),value:i._parse(new Vo(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return No;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return No;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};zs.create=(e,t,n)=>new zs({valueType:t,keyType:e,typeName:rc.ZodMap,...Uo(n)});var Bs=class e extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return X(n,{code:Y.invalid_type,expected:J.set,received:n.parsedType}),No;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(X(n,{code:Y.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(X(n,{code:Y.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return No;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Vo(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:Bo.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Bo.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Bs.create=(e,t)=>new Bs({valueType:e,minSize:null,maxSize:null,typeName:rc.ZodSet,...Uo(t)});var Vs=class e extends Wo{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return X(t,{code:Y.invalid_type,expected:J.function,received:t.parsedType}),No;function n(e,n){return jo({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ao(),Oo].filter(e=>!!e),issueData:{code:Y.invalid_arguments,argumentsError:n}})}function r(e,n){return jo({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ao(),Oo].filter(e=>!!e),issueData:{code:Y.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qs){let e=this;return Fo(async function(...t){let o=new Do([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return Fo(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Do([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Do([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ls.create(t).rest(Es.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ls.create([]).rest(Es.create()),returns:n||Es.create(),typeName:rc.ZodFunction,...Uo(r)})}},Hs=class extends Wo{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Hs.create=(e,t)=>new Hs({getter:e,typeName:rc.ZodLazy,...Uo(t)});var Us=class extends Wo{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return X(t,{received:t.data,code:Y.invalid_literal,expected:this._def.value}),No}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Us.create=(e,t)=>new Us({value:e,typeName:rc.ZodLiteral,...Uo(t)});function Ws(e,t){return new Gs({values:e,typeName:rc.ZodEnum,...Uo(t)})}var Gs=class e extends Wo{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{expected:wo.joinValues(n),received:t.parsedType,code:Y.invalid_type}),No}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{received:t.data,code:Y.invalid_enum_value,options:n}),No}return Fo(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Gs.create=Ws;var Ks=class extends Wo{_parse(e){let t=wo.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){let e=wo.objectValues(t);return X(n,{expected:wo.joinValues(e),received:n.parsedType,code:Y.invalid_type}),No}if(this._cache||=new Set(wo.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=wo.objectValues(t);return X(n,{received:n.data,code:Y.invalid_enum_value,options:e}),No}return Fo(e.data)}get enum(){return this._def.values}};Ks.create=(e,t)=>new Ks({values:e,typeName:rc.ZodNativeEnum,...Uo(t)});var qs=class extends Wo{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==J.promise&&t.common.async===!1?(X(t,{code:Y.invalid_type,expected:J.promise,received:t.parsedType}),No):Fo((t.parsedType===J.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qs.create=(e,t)=>new qs({type:e,typeName:rc.ZodPromise,...Uo(t)});var Js=class extends Wo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===rc.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{X(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return No;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?No:r.status===`dirty`||t.value===`dirty`?Po(r.value):r});{if(t.value===`aborted`)return No;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?No:r.status===`dirty`||t.value===`dirty`?Po(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?No:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?No:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ro(e))return No;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Ro(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):No);wo.assertNever(r)}};Js.create=(e,t,n)=>new Js({schema:e,typeName:rc.ZodEffects,effect:t,...Uo(n)}),Js.createWithPreprocess=(e,t,n)=>new Js({schema:t,effect:{type:`preprocess`,transform:e},typeName:rc.ZodEffects,...Uo(n)});var Ys=class extends Wo{_parse(e){return this._getType(e)===J.undefined?Fo(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ys.create=(e,t)=>new Ys({innerType:e,typeName:rc.ZodOptional,...Uo(t)});var Xs=class extends Wo{_parse(e){return this._getType(e)===J.null?Fo(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Xs.create=(e,t)=>new Xs({innerType:e,typeName:rc.ZodNullable,...Uo(t)});var Zs=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===J.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Zs.create=(e,t)=>new Zs({innerType:e,typeName:rc.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...Uo(t)});var Qs=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return zo(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Do(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Do(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Qs.create=(e,t)=>new Qs({innerType:e,typeName:rc.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...Uo(t)});var $s=class extends Wo{_parse(e){if(this._getType(e)!==J.nan){let t=this._getOrReturnCtx(e);return X(t,{code:Y.invalid_type,expected:J.nan,received:t.parsedType}),No}return{status:`valid`,value:e.data}}};$s.create=e=>new $s({typeName:rc.ZodNaN,...Uo(e)});var ec=class extends Wo{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},tc=class e extends Wo{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?No:e.status===`dirty`?(t.dirty(),Po(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?No:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:rc.ZodPipeline})}},nc=class extends Wo{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ro(e)&&(e.value=Object.freeze(e.value)),e);return zo(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};nc.create=(e,t)=>new nc({innerType:e,typeName:rc.ZodReadonly,...Uo(t)}),js.lazycreate;var rc;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(rc||={}),gs.create,vs.create,$s.create,ys.create,bs.create,xs.create,Ss.create,Cs.create,ws.create,Ts.create,Es.create,Ds.create,Os.create,ks.create,js.create,js.strictCreate,Ms.create,Ps.create,Is.create,Ls.create,Rs.create,zs.create,Bs.create,Vs.create,Hs.create,Us.create;var ic=Gs.create;Ks.create,qs.create,Js.create,Ys.create,Xs.create,Js.createWithPreprocess,tc.create,ic([`highlight`,`note`,`comment`]),ic([`pending`,`accepted`,`dismissed`]),ic([`yellow`,`green`,`blue`,`pink`]),ic([`info`,`warning`,`error`,`success`]);var ac=ic([`solo`,`tandem`]);ic([`user`,`claude`,`import`]),ic([`user`,`claude`,`import`]),ic([`accept`,`dismiss`]),ic([`markdown`,`json`]),ic([`md`,`txt`,`html`,`docx`]),ic([`RANGE_GONE`,`RANGE_MOVED`,`FILE_LOCKED`,`FILE_NOT_FOUND`,`NO_DOCUMENT`,`INVALID_RANGE`,`INVALID_ARGUMENT`,`NOT_FOUND`,`ANNOTATION_RESOLVED`,`FORMAT_ERROR`,`PERMISSION_DENIED`]),ic([`CHANNEL_CONNECT_FAILED`,`MONITOR_CONNECT_FAILED`]);function oc(e){return e.author!==`user`}function sc(e){return e.status===`pending`&&oc(e)}function cc(e){return`${e}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function lc(){return cc(`ann`)}function uc(){return cc(`msg`)}function dc(){return cc(`ntf`)}function fc(e){return cc(e)}var pc=`/api/notify-stream`,mc=`/api/info`,hc=`/api/diagnostics`,gc=`/health`,_c=`/api/open`,vc=`/api/close`,yc=`/api/save`,bc=`/api/rename`,xc=`/api/upload`,Sc=`/api/scratchpad`,Cc=`/api/convert`,wc=`/api/apply-changes`,Tc=`/api/document/raw`,Ec=`/api/document/reload`,Dc=`/api/backups`,Oc=`/api/backups/restore`,kc=`/api/docx-conflict/resolve`,Ac=`/api/annotation-reply`,jc=`/api/remove-annotation`,Mc=`/api/store/reclaim-lock`,Nc=`/api/chat`,Pc=`/api/sessions`,Fc=`/api/sessions/delete`,Ic=`/api/sessions/clear`,Lc=`/api/license/status`,Rc=`/api/license/activate`,zc=`/api/launcher/status`,Bc=`/api/launcher/nonce`,Vc=`/api/launcher/relaunch`,Hc=`/api/launcher/start-fresh`,Uc=`/api/launcher/working-directory`,Wc=[`save`,`save-as`,`settings`,`settings-modal`,`toggle-palette`,`new-scratchpad`,`close-tab`,`open-file`,`toggle-mode`,`reopen-closed-tab`,`comment-on-selection`,`toggle-authorship`,`toggle-left-panel`,`toggle-right-panel`,`annotation-next`,`annotation-prev`,`select-block`,`new-tab-menu`],Gc=new Set(Wc);function Kc(e){return Gc.has(e)}var qc={save:`Save document`,"save-as":`Save As…`,settings:`Open settings`,"settings-modal":`Open settings (new)`,"toggle-palette":`Toggle command palette`,"new-scratchpad":`New Scratchpad`,"close-tab":`Close active tab`,"open-file":`Open file…`,"toggle-mode":`Toggle Solo / Tandem mode`,"reopen-closed-tab":`Reopen closed tab`,"comment-on-selection":`Comment on selection`,"toggle-authorship":`Toggle authorship colors`,"toggle-left-panel":`Toggle left panel`,"toggle-right-panel":`Toggle right panel`,"annotation-next":`Next annotation`,"annotation-prev":`Previous annotation`,"select-block":`Select containing block`,"new-tab-menu":`New tab menu`},Jc={save:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyS`},"save-as":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyS`},settings:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`Comma`},"settings-modal":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`Comma`},"toggle-palette":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyP`},"new-scratchpad":{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyN`},"close-tab":{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyW`},"open-file":{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyO`},"toggle-mode":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyM`},"reopen-closed-tab":{ctrlOrMeta:!0,alt:!0,shift:!1,code:`KeyT`},"comment-on-selection":{ctrlOrMeta:!0,alt:!0,shift:!1,code:`KeyM`},"toggle-authorship":{ctrlOrMeta:!0,alt:!0,shift:!1,code:`KeyA`},"toggle-left-panel":{ctrlOrMeta:!1,alt:!0,shift:!0,code:`ArrowLeft`},"toggle-right-panel":{ctrlOrMeta:!1,alt:!0,shift:!0,code:`ArrowRight`},"annotation-next":{ctrlOrMeta:!1,alt:!0,shift:!1,code:`BracketRight`},"annotation-prev":{ctrlOrMeta:!1,alt:!0,shift:!1,code:`BracketLeft`},"select-block":{ctrlOrMeta:!1,alt:!0,shift:!1,code:`KeyL`},"new-tab-menu":{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyT`}},Yc=[{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`Tab`},label:`Next document tab`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:`Tab`},label:`Previous document tab`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`Digit0`},label:`Reset zoom`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`Equal`},label:`Zoom in`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:`Equal`},label:`Zoom in`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`Minus`},label:`Zoom out`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:`Minus`},label:`Zoom out`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyB`},label:`Bold`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyI`},label:`Italic`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyE`},label:`Inline code`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyX`},label:`Strikethrough`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyZ`},label:`Undo`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyY`},label:`Redo`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyZ`},label:`Redo`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyK`},label:`Add link`},{chord:{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyB`},label:`Blockquote`}],Xc={save:`save`,"save-as":`save-as`,settings:`settings`,"settings-modal":`settings-modal`,"new-scratchpad":`new-scratchpad`,"close-tab":`close-tab`,"open-file":`open-file`,"toggle-mode":`toggle-mode`,"reopen-closed-tab":`reopen-closed-tab`,"toggle-authorship":`toggle-authorship`,"toggle-left-panel":`toggle-left-panel`,"toggle-right-panel":`toggle-right-panel`,"annotation-next":`annotation-next`,"annotation-previous":`annotation-prev`,"select-block":`select-block`},Zc=/^(Control|Shift|Alt|Meta|OS)/,Qc=new Set([`Tab`,`Escape`,`Enter`,`NumpadEnter`,`NumLock`,`CapsLock`,`ContextMenu`,`Insert`]);function $c(e){return Zc.test(e.code)||e.code.startsWith(`Numpad`)||Qc.has(e.code)?!1:e.ctrlOrMeta||e.alt}function el(e){if(!e.code||e.key===`Dead`)return null;let t={ctrlOrMeta:e.ctrlKey||e.metaKey,alt:e.altKey,shift:e.shiftKey,code:e.code};return $c(t)?t:null}function tl(e,t){return e.ctrlOrMeta===(t.ctrlKey||t.metaKey)&&e.alt===t.altKey&&e.shift===t.shiftKey&&e.code===t.code}function nl(e,t){return e.ctrlOrMeta===t.ctrlOrMeta&&e.alt===t.alt&&e.shift===t.shift&&e.code===t.code}function rl(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.ctrlOrMeta==`boolean`&&typeof t.alt==`boolean`&&typeof t.shift==`boolean`&&typeof t.code==`string`&&t.code.length>0&&t.code.length<=32}function il(){try{if(typeof navigator>`u`)return!1;let e=navigator.userAgentData?.platform??navigator.platform;return/Mac|iPhone|iPad|iPod/i.test(e??``)}catch{return!1}}function al(e){return e.startsWith(`Key`)?e.slice(3):e.startsWith(`Digit`)?e.slice(5):{Comma:`,`,Period:`.`,Slash:`/`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,BracketLeft:`[`,BracketRight:`]`,Backquote:"`",Minus:`-`,Equal:`=`,Space:`Space`,Tab:`Tab`,Enter:`Enter`,ArrowLeft:`←`,ArrowRight:`→`,ArrowUp:`↑`,ArrowDown:`↓`}[e]??e}function ol(e){let t=il(),n=[];return e.ctrlOrMeta&&n.push(t?`⌘`:`Ctrl`),e.alt&&n.push(t?`⌥`:`Alt`),e.shift&&n.push(t?`⇧`:`Shift`),n.push(al(e.code)),t?n.join(``):n.join(`+`)}function sl(e,t){return t.get(e)??Jc[e]}function cl(e){let t=new Map;for(let n of Wc)t.set(n,ol(sl(n,e)));return t}function ll(e,t){return t?t.has(e):!1}function ul(e,t){if(e.isComposing)return null;if(t&&t.size>0)for(let n of Wc){let r=t.get(n);if(r&&tl(r,e))return{id:n}}let n=e.ctrlKey||e.metaKey;if(e.key===`?`)return{id:`toggle-help`};if(n){if(e.shiftKey&&e.code===`Comma`&&!ll(`settings-modal`,t))return{id:`settings-modal`};if(!e.shiftKey&&e.code===`Comma`&&!ll(`settings`,t))return{id:`settings`};if(e.key===`/`)return{id:`toggle-help`};if(!e.altKey&&!e.shiftKey&&e.code===`KeyA`)return{id:`select-all`};if(e.shiftKey&&!e.altKey&&e.code===`KeyS`&&!ll(`save-as`,t))return{id:`save-as`};if(e.code===`KeyS`&&!ll(`save`,t))return{id:`save`};if(e.shiftKey&&e.code===`KeyP`&&!ll(`toggle-palette`,t))return{id:`toggle-palette`};if(e.code===`KeyN`&&!ll(`new-scratchpad`,t))return{id:`new-scratchpad`};if(e.code===`KeyW`&&!ll(`close-tab`,t))return{id:`close-tab`};if(e.code===`KeyO`&&!ll(`open-file`,t))return{id:`open-file`};if(/^Digit[1-9]$/.test(e.code))return{id:`pick-tab`,context:{tabIndex:Number(e.code.slice(5))}};if(e.shiftKey&&!e.altKey&&e.code===`KeyM`&&!ll(`toggle-mode`,t))return{id:`toggle-mode`};if(e.altKey&&e.code===`KeyT`&&!ll(`reopen-closed-tab`,t))return{id:`reopen-closed-tab`};if(!e.altKey&&!e.shiftKey&&e.code===`KeyT`&&!ll(`new-tab-menu`,t))return{id:`new-tab-menu`};if(e.code===`KeyF`)return{id:`find`,context:{shift:e.shiftKey}};if(e.code===`KeyG`)return{id:`find-nav`,context:{shift:e.shiftKey}};if(e.key===`Enter`)return{id:`annotation-accept-or-dismiss`,context:{shift:e.shiftKey}};if(e.altKey&&e.code===`KeyM`&&!ll(`comment-on-selection`,t))return{id:`comment-on-selection`};if(e.altKey&&e.code===`KeyA`&&!ll(`toggle-authorship`,t))return{id:`toggle-authorship`}}if(e.altKey&&!e.ctrlKey&&!e.metaKey){if(e.shiftKey){if(e.code===`ArrowLeft`&&!ll(`toggle-left-panel`,t))return{id:`toggle-left-panel`};if(e.code===`ArrowRight`&&!ll(`toggle-right-panel`,t))return{id:`toggle-right-panel`}}if(!e.shiftKey){if(e.code===`BracketRight`&&!ll(`annotation-next`,t))return{id:`annotation-next`};if(e.code===`BracketLeft`&&!ll(`annotation-prev`,t))return{id:`annotation-prev`}}if(!e.shiftKey&&e.code===`KeyL`&&!ll(`select-block`,t))return{id:`select-block`}}return null}function dl(e){return e.code===`Slash`?e.shift?`?`:`/`:e.code===`Enter`||e.code===`NumpadEnter`?`Enter`:``}function fl(e){return{key:dl(e),code:e.code,ctrlKey:e.ctrlOrMeta,metaKey:!1,altKey:e.alt,shiftKey:e.shift,isComposing:!1}}function pl(e,t){switch(e){case`toggle-help`:return`Show keyboard shortcuts`;case`select-all`:return`Select all`;case`find`:return t?.shift?`Find in open tabs`:`Find / Replace`;case`find-nav`:return t?.shift?`Find previous`:`Find next`;case`annotation-accept-or-dismiss`:return t?.shift?`Dismiss annotation`:`Accept annotation`;case`pick-tab`:return t?.tabIndex?`Jump to tab ${t.tabIndex}`:`Jump to tab`;default:return``}}function ml(e){let t=ul(fl(e));return!t||Kc(t.id)?null:pl(t.id,t.context)||null}function hl(e,t,n){for(let r of Wc)if(r!==n&&nl(sl(r,t),e))return qc[r];let r=ml(e);if(r)return r;for(let t of Yc)if(nl(t.chord,e))return t.label;return null}function gl(e){return Yc.some(t=>nl(t.chord,e))}function _l(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Kc(n)&&rl(r)&&$c(r)&&(gl(r)||ml(r)||(t[n]=r));let n={},r=[];for(let e of Wc){let i=t[e];i&&(r.some(e=>nl(e,i))||(r.push(i),n[e]=i))}return n}function vl(e){let t=new Map;for(let[n,r]of Object.entries(_l(e)))t.set(n,r);return t}var yl=[`narrow`,`comfortable`,`wide`,`full`],bl={narrow:`58ch`,comfortable:`68ch`,wide:`82ch`,full:`100%`};function xl(e){return typeof e==`string`&&yl.includes(e)}var Sl=[`anthropic`,`openai`,`gemini`,`local-ollama`,`local-llamacpp`],Cl=50,wl={s:14,m:16,l:18};function Tl(){try{return typeof window>`u`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}var El={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:16,primaryTab:`annotations`,panelOrder:`chat-editor-annotations`,editorMeasure:`comfortable`,selectionDwellMs:Fa,showAuthorship:!0,reduceMotion:!1,textSize:`m`,theme:`system`,systemLightVariant:`light`,accentHue:275,editorFont:`sans`,fontByExtension:{},defaultSaveDirectory:null,density:`cozy`,defaultMode:`tandem`,highContrast:!1,annotationPatterns:!1,selectionToolbar:!0,formattingBarVisible:!0,railHoverReveal:!0,soloRailHidden:!0,degradedBannerDelayMs:3e4,sidecarRetryStrategy:`exponential`,marginView:!1,showComments:!0,showHighlights:!0,showNotes:!0,showRawMarkdown:!0,decorationsMuted:!1,models:[],defaultModelId:null,customShortcuts:{}},Dl=64,Ol=512;function kl(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(t.length>=Cl)break;if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.id!=`string`||e.id.length===0||e.id.length>64||typeof e.provider!=`string`||!Sl.includes(e.provider)||typeof e.displayName!=`string`||e.displayName.length>256||typeof e.modelId!=`string`||e.modelId.length===0||e.modelId.length>256||typeof e.enabled!=`boolean`)continue;let r={id:e.id,provider:e.provider,displayName:e.displayName,modelId:e.modelId,enabled:e.enabled};if(typeof e.apiKeyRef==`string`&&e.apiKeyRef.length>0&&e.apiKeyRef.length<=Dl&&/^[A-Za-z0-9_-]+$/.test(e.apiKeyRef)?r.apiKeyRef=e.apiKeyRef:typeof e.apiKey==`string`&&e.apiKey.length<=Ol&&(r._legacyApiKey=e.apiKey),typeof e.endpoint==`string`&&e.endpoint.length<=2048&&(r.endpoint=e.endpoint),e.params&&typeof e.params==`object`&&!Array.isArray(e.params)){let t={};for(let[n,r]of Object.entries(e.params))(typeof r==`number`||typeof r==`string`||typeof r==`boolean`)&&(t[n]=r);r.params=t}t.push(r)}return t}var Al=[`serif`,`sans`,`mono`];function jl(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))n===`__proto__`||n===`constructor`||n===`prototype`||typeof n!=`string`||n.length===0||n.length>32||typeof r==`string`&&Al.includes(r)&&(t[n]=r);return t}function Ml(e){return{leftPanelVisible:e.leftPanelVisible===!0,rightPanelVisible:e.rightPanelVisible!==!1,schemaVersion:16,primaryTab:e.primaryTab===`annotations`?`annotations`:`chat`,panelOrder:e.panelOrder===`annotations-editor-chat`?`annotations-editor-chat`:`chat-editor-annotations`,editorMeasure:xl(e.editorMeasure)?e.editorMeasure:El.editorMeasure,selectionDwellMs:Math.max(500,Math.min(Ia,Number(e.selectionDwellMs)||1e3)),showAuthorship:e.showAuthorship===!1?!1:El.showAuthorship,reduceMotion:typeof e.reduceMotion==`boolean`?e.reduceMotion:Tl(),textSize:e.textSize===`s`||e.textSize===`m`||e.textSize===`l`?e.textSize:El.textSize,theme:e.theme===`light`||e.theme===`dark`||e.theme===`warm`||e.theme===`system`?e.theme:El.theme,systemLightVariant:e.systemLightVariant===`warm`?`warm`:El.systemLightVariant,accentHue:typeof e.accentHue==`number`&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:El.accentHue,editorFont:e.editorFont===`serif`||e.editorFont===`sans`||e.editorFont===`mono`?e.editorFont:El.editorFont,fontByExtension:jl(e.fontByExtension),defaultSaveDirectory:typeof e.defaultSaveDirectory==`string`&&e.defaultSaveDirectory.trim()?e.defaultSaveDirectory.trim():null,density:e.density===`compact`||e.density===`cozy`||e.density===`spacious`?e.density:El.density,defaultMode:e.defaultMode===`solo`||e.defaultMode===`tandem`?e.defaultMode:El.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:El.selectionToolbar,formattingBarVisible:e.formattingBarVisible===!1?!1:El.formattingBarVisible,railHoverReveal:e.railHoverReveal===!1?!1:El.railHoverReveal,soloRailHidden:e.soloRailHidden===!1?!1:El.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs==`number`&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:El.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy===`exponential`||e.sidecarRetryStrategy===`constant-2s`?e.sidecarRetryStrategy:El.sidecarRetryStrategy,marginView:e.marginView===!0,showComments:e.showComments===!1?!1:El.showComments,showHighlights:e.showHighlights===!1?!1:El.showHighlights,showNotes:e.showNotes===!1?!1:El.showNotes,showRawMarkdown:e.showRawMarkdown===!1?!1:El.showRawMarkdown,decorationsMuted:e.decorationsMuted===!0,models:kl(e.models),defaultModelId:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null,customShortcuts:_l(e.customShortcuts)}}function Nl(){let e;try{e=localStorage.getItem(Na)}catch{e=null}if(e)try{let t=JSON.parse(e);if((!t||typeof t!=`object`||Array.isArray(t))&&(t={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:1}),(typeof t.schemaVersion==`number`?t.schemaVersion:1)===1){let e=t.panelHidden===!0,n=!1,r=!0;e?(n=!1,r=!1):t.layout===`three-panel`?(n=!0,r=!0):t.layout===`tabbed-left`&&(n=!0,r=!1),t={...t,leftPanelVisible:n,rightPanelVisible:r,schemaVersion:2},delete t.layout,delete t.panelHidden}if(t.schemaVersion===2&&(t={...t,models:[],schemaVersion:3}),t.schemaVersion===3&&(t={...t,schemaVersion:4}),t.schemaVersion===4){let e={...t,schemaVersion:5};delete e.leftRailTabs,delete e.rightRailTabs,t=e}if(t.schemaVersion===5){let e={...t,schemaVersion:6};delete e.showIntegrationWizard,t=e}if(t.schemaVersion===6){let e=(Array.isArray(t.models)?t.models:[]).find(e=>typeof e?.id==`string`&&e.enabled===!0);t={...t,schemaVersion:7,defaultModelId:e&&typeof e.id==`string`?e.id:null}}if(t.schemaVersion===7&&(t={...t,schemaVersion:8}),t.schemaVersion===8){let e=t.showAnnotationDecorations===!1,n={...t,showComments:!e,showHighlights:!e,showNotes:!e,decorationsMuted:!1,schemaVersion:9};delete n.showAnnotationDecorations,t=n}if(t.schemaVersion===9&&(t={...t,schemaVersion:10}),t.schemaVersion===10&&(t={...t,schemaVersion:11}),t.schemaVersion===11){let e={...t,schemaVersion:12};if(e.editorMeasure===void 0){let n=t.editorWidthPercent;e.editorMeasure=n===void 0||n===100?`full`:`comfortable`}delete e.editorWidthPercent,t=e}if(t.showAnnotationDecorations===!1&&t.showComments===void 0&&(t={...t,showComments:!1,showHighlights:!1,showNotes:!1}),t.schemaVersion===12&&(t={...t,schemaVersion:13}),t.schemaVersion===13&&(t={...t,schemaVersion:14}),t.schemaVersion===14&&(t={...t,schemaVersion:15}),t.schemaVersion===15){let e={...t,schemaVersion:16};delete e.holdAnnotationsWhileOffline,e.sidecarRetryStrategy===`manual`&&(e.sidecarRetryStrategy=`exponential`),t=e}if(typeof t.schemaVersion==`number`&&t.schemaVersion>16){console.warn(`[tandem] settings schemaVersion=${t.schemaVersion} is newer than v16; loading defensively without writing.`);let e=t.editorMeasure,n=Ml(t);typeof e==`string`&&e!==n.editorMeasure&&console.warn(`[tandem] editorMeasure=${JSON.stringify(e)} from newer client is unknown to v16; displaying as ${JSON.stringify(n.editorMeasure)} (your setting is preserved on-disk).`);let r=new Set(Object.keys(n)),i=new Set([`leftRailTabs`,`rightRailTabs`,`showIntegrationWizard`,`showAnnotationDecorations`,`editorWidthPercent`,`holdAnnotationsWhileOffline`]),a={};for(let[e,n]of Object.entries(t))!r.has(e)&&e!==`_readOnly`&&!i.has(e)&&(a[e]=n);return{...n,...a,_readOnly:!0}}return Ml(t)}catch(e){console.warn(`[tandem] settings JSON is corrupt, resetting to defaults:`,e)}return{...El,reduceMotion:Tl()}}function Pl(e,t){let n={...e,...t},r=kl(n.models);return{...n,customShortcuts:_l(n.customShortcuts),fontByExtension:jl(n.fontByExtension),defaultSaveDirectory:typeof n.defaultSaveDirectory==`string`&&n.defaultSaveDirectory.trim()?n.defaultSaveDirectory.trim():null,selectionDwellMs:Math.max(500,Math.min(Ia,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):El.accentHue,editorMeasure:xl(n.editorMeasure)?n.editorMeasure:El.editorMeasure,degradedBannerDelayMs:Math.max(5e3,Math.min(12e4,n.degradedBannerDelayMs)),models:r,defaultModelId:typeof n.defaultModelId==`string`&&r.some(e=>e.id===n.defaultModelId)?n.defaultModelId:null}}function Fl(e,t){if(t){let n=e.fontByExtension?.[t];if(n)return n}return e.editorFont}var Il=`http://127.0.0.1:${xa}`;function Ll(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function Rl(e){return e.toLowerCase().endsWith(`.docx`)}async function zl(e){return Rl(e.name)?Ll(await e.arrayBuffer()):e.text()}var Bl=`modulepreload`,Vl=function(e){return`/`+e},Hl={},Ul=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Vl(t,n),t in Hl)return;Hl[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Bl,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Wl(){try{return Nl().defaultSaveDirectory}catch{return null}}async function Gl(){let e=new AbortController,t=setTimeout(()=>e.abort(),250);try{let t=await fetch(`${Il}/api/integrations`,{signal:e.signal});if(!t.ok)return null;let n=(await t.json()).integrations?.find(e=>e.kind===`claude-code`)?.workingDirectory;return typeof n==`string`&&n.trim()?n.trim():null}catch{return null}finally{clearTimeout(t)}}async function Kl(){try{let{homeDir:e}=await Ul(async()=>{let{homeDir:e}=await import(`./path-49-uTKly.js`);return{homeDir:e}},__vite__mapDeps([0,1])),t=await e();return typeof t==`string`&&t.trim()?t:null}catch{return null}}async function ql(){return Wl()||await Gl()||await Kl()}function Jl(e,t,n=Date.now(),r=20){return[e.find(e=>e.path===t)??{path:t,openedAt:n},...e.filter(e=>e.path!==t)].slice(0,r)}function Yl(e){return e.map(e=>e.path)}function Xl(e,t=Date.now()){if(!e)return``;let n=t-e;if(n<6e4)return`just now`;let r=Math.floor(n/6e4);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Zl(){try{let e=localStorage.getItem(io);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.map(e=>{if(typeof e==`string`)return{path:e,openedAt:0};if(typeof e==`object`&&e&&typeof e.path==`string`){let t=e;return{path:t.path,openedAt:typeof t.openedAt==`number`?t.openedAt:0}}return null}).filter(e=>e!==null):[]}catch(e){return console.warn(`[tandem] failed to load recent files:`,e),[]}}function Ql(e){try{localStorage.setItem(io,JSON.stringify(e)),ru()}catch(e){console.warn(`[tandem] failed to save recent files:`,e)}}function $l(){try{localStorage.removeItem(io),ru()}catch(e){console.warn(`[tandem] failed to clear recent files:`,e)}}var eu=3e4,tu=null;function nu(){let e=Date.now();if(tu&&e-tu.ts<eu)return tu.files;let t=Zl();return tu={files:t,ts:e},t}function ru(){tu=null}var iu=[`editor`,`navigation`,`view`,`document`,`annotations`,`claude`],au=M(un(new Map));function ou(e,t={}){if(z(au).has(e.id)&&!t.replace){let t=`[actions] id collision: "${e.id}" — existing action silently replaced. Pass { replace: true } to suppress this warning.`;console.warn(t)}return N(au,new Map(z(au)).set(e.id,e),!0),!0}function su(){return z(au)}var cu=null;function lu(e){cu=e}function uu(e,t){if(!cu){console.warn(`[actions] "${e}" invoked before App mounted — deps not wired yet`);return}t(cu)}var du=M(!1),fu={get saving(){return z(du)}},pu=!1,mu=!1;function hu(e){return e.connected&&e.tabCount===0&&e.activeTabId===null}async function gu(){if(!mu){mu=!0;try{let e=await fetch(`${Il}${Sc}`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));console.warn(`[Tandem] New Scratchpad failed:`,t.message??e.statusText)}}catch(e){console.warn(`[Tandem] New Scratchpad request failed:`,e)}finally{mu=!1}}}function _u(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}var vu=!1;async function yu(e){let t=await ql();if(!t)return e;try{let{join:n}=await Ul(async()=>{let{join:e}=await import(`./path-49-uTKly.js`);return{join:e}},__vite__mapDeps([0,1]));return await n(t,e)}catch{return e}}function bu(e,t){let n=`.${t}`,r=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return e.slice(r+1).includes(`.`)?e.slice(e.lastIndexOf(`.`)).toLowerCase()===n?e:`${e.slice(0,e.lastIndexOf(`.`))}${n}`:`${e}${n}`}function xu(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(i),0)}async function Su(e){if(vu)return;let{activeDocId:t,notify:n,defaultName:r,sourceFormat:i}=e;if(!t){n(`warning`,`No active document to save.`);return}vu=!0;try{_u()?await Cu(t,n,r??`Scratchpad.md`):await wu(t,n,i)}finally{vu=!1}}async function Cu(e,t,n){let r;try{let{save:e}=await Ul(async()=>{let{save:e}=await import(`./dist-js-BWAGOggB.js`);return{save:e}},__vite__mapDeps([2,1]));r=await e({defaultPath:await yu(n),filters:[{name:`Markdown`,extensions:[`md`]},{name:`Plain Text`,extensions:[`txt`]}]})}catch(e){t(`error`,`Save As dialog unavailable: ${e instanceof Error?e.message:e}`);return}if(typeof r!=`string`||r.length===0)return;let i=r.toLowerCase().endsWith(`.txt`)?`txt`:`md`,a=bu(r,i);a!==r&&t(`info`,`Saving as ${i.toUpperCase()} — only .md and .txt are supported.`);try{let n=await fetch(`${Il}${yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,targetPath:a,format:i})});if(!n.ok){t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`);return}let r=await n.json().catch(()=>null),o=r?.data?.fileName??a,s=r?.data?.targetPath??a;Ql(Jl(Zl(),s)),t(`info`,`Saved to ${o}.`)}catch(e){t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`)}}async function wu(e,t,n){let r=n===`txt`?`txt`:`md`;try{let n=await fetch(`${Il}${yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,serialize:!0,format:r})});if(!n.ok){t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`);return}let i=await n.json().catch(()=>null),a=i?.data?.content,o=i?.data?.fileName??`Scratchpad.${r}`;if(typeof a!=`string`){t(`error`,`Save As returned no content.`);return}xu(a,o,r===`md`?`text/markdown`:`text/plain`),t(`info`,`Downloaded; scratchpad remains in-session.`)}catch(e){t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`)}}async function Tu(e){if(!(!e||pu)){pu=!0,N(du,!0);try{let t=await fetch(`${Il}${yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e})});if(t.ok){let e=await t.json().catch(()=>null);(e?.data?.integrityWarnings?.length??0)>0&&cu?.notify(`error`,`Saved, but some content may not have been preserved — your original is backed up. See the document notice, or run "Restore a backup of this document…" from the command palette.`);let n=e?.data?.fidelityWarnings?.length??0;n>0&&cu?.notify(`warning`,`Saved — ${n} Word feature${n===1?``:`s`} were simplified on export; see the document notice for details.`)}else{let e=await t.json().catch(()=>({}));console.warn(`[Tandem] Save failed:`,e.message??t.statusText)}}catch(e){console.warn(`[Tandem] Save request failed:`,e)}finally{pu=!1,N(du,!1)}}}var Eu=!1;async function Du(){let e;try{e=await fetch(`${Il}${zc}`)}catch(e){return{ok:!1,kind:`network`,detail:e instanceof Error?e.message:String(e)}}return e.status===404?{ok:!1,kind:`not-built`}:e.ok?{ok:!0,value:await e.json()}:{ok:!1,kind:`server-error`,detail:`HTTP ${e.status}`}}async function Ou(){let e;try{e=await fetch(`${Il}${Bc}`,{method:`GET`})}catch(e){return{ok:!1,kind:`network`,detail:e instanceof Error?e.message:String(e)}}if(e.status===404)return{ok:!1,kind:`not-built`};if(!e.ok)return{ok:!1,kind:`server-error`,detail:`HTTP ${e.status}`};let t=await e.json();return typeof t.nonce==`string`?{ok:!0,value:t.nonce}:{ok:!1,kind:`server-error`,detail:`malformed nonce response`}}function ku(e){if(!e||/^[a-z]+:\/\//.test(e))return null;let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>0?e.slice(0,t):null}async function Au(e,t,n,r){let i=await Ou();if(!i.ok){e.notify(`error`,`Failed to acquire launcher nonce: ${i.kind}${i.detail?` (${i.detail})`:``}.`);return}let a=i.value;try{let i=await fetch(`${Il}${t}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,nonce:a})});if(!i.ok){let t=await i.json().catch(()=>({}));e.notify(`error`,`${r.failPrefix}: ${t.message??i.statusText}`);return}e.notify(`info`,r.successMessage)}catch(t){e.notify(`error`,`${r.requestFailPrefix}: ${t instanceof Error?t.message:t}`)}}async function ju(e){if(Eu)return!1;let t=await Du();if(!t.ok)return t.kind===`not-built`?e.notify(`warning`,`Claude launcher not active in this Tandem build.`):t.kind===`network`?e.notify(`error`,`Cannot reach Tandem server${t.detail?`: ${t.detail}`:``}.`):e.notify(`error`,`Launcher status check failed${t.detail?`: ${t.detail}`:``}.`),!1;let n=t.value;return n.available?(`skillRefresh`in n&&n.skillRefresh&&e.notify(`warning`,`Bundled skill refresh failed: ${n.skillRefresh.message}. Run \`tandem setup\` to retry.`),!0):(e.notify(`warning`,`Claude launcher not active in this Tandem build.`),!1)}async function Mu(e){if(!await ju(e))return;let t=ku(e.getActiveDocumentPath());if(!t){e.notify(`warning`,`Active document isn't saved to a folder. Set a working directory in Settings → Claude Code.`);return}if(confirm(`Restart Claude in:\n${t}\n\nYour current task may be interrupted.`)){Eu=!0;try{await Au(e,Vc,{cwd:t},{failPrefix:`Relaunch failed`,requestFailPrefix:`Relaunch request failed`,successMessage:`Claude restarting in ${t}.`})}finally{Eu=!1}}}function Nu(){uu(`launcher-relaunch-here`,e=>void Mu(e))}async function Pu(e){if(await ju(e)&&confirm(`Drop Claude's saved conversation and restart fresh. This cannot be undone.`)){Eu=!0;try{await Au(e,Hc,{},{failPrefix:`Start fresh failed`,requestFailPrefix:`Start-fresh request failed`,successMessage:`Claude restarting with a fresh conversation.`})}finally{Eu=!1}}}var Fu=!1;function Iu(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}async function Lu(e){if(Fu)return;let t=e.getActiveTabId();if(!t){e.notify(`warning`,`No active document.`);return}Fu=!0;try{let n=await fetch(`${Il}${Dc}?documentId=${encodeURIComponent(t)}`);if(!n.ok){let t=await n.json().catch(()=>({}));e.notify(`error`,`Couldn't list backups: ${t.message??n.statusText}`);return}let r=(await n.json().catch(()=>null))?.data?.backups??[];if(r.length===0){e.notify(`info`,`No backups exist for this document yet. Tandem snapshots the on-disk file before its first overwrite each session.`);return}let i=r[0],a=r.map((e,t)=>` ${t+1}. ${Iu(e.timestamp)}`).join(`
|
|
4
|
-
`);if(!confirm(`Available backups (newest first):\n${a}\n\nRestore the most recent backup (${Iu(i.timestamp)})? The document reloads with the backup's content; annotations are preserved.
|
|
5
|
-
|
|
6
|
-
Older backups can be restored by asking Claude (tandem_restoreBackup).`))return;let o=await fetch(`${Il}${Oc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t,backup:i.name})});if(!o.ok){let t=await o.json().catch(()=>({}));e.notify(`error`,`Restore failed: ${t.message??o.statusText}`);return}e.notify(`info`,`Restored backup from ${Iu(i.timestamp)}.`)}catch(t){e.notify(`error`,`Restore request failed: ${t instanceof Error?t.message:t}`)}finally{Fu=!1}}async function Ru(e){let t=e.getActiveDocumentPath();if(!t){e.notify(`warning`,`This document isn't saved to a file yet.`);return}try{let{invoke:e}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);await e(`show_in_file_manager`,{path:t})}catch(t){e.notify(`error`,`Couldn't reveal in file manager: ${t instanceof Error?t.message:String(t)}`)}}var zu=[{id:`save`,label:`Save document`,group:`document`,shortcut:`Ctrl+S`,run(){uu(`save`,e=>void Tu(e.getActiveTabId()))}},{id:`settings`,label:`Open settings`,group:`view`,shortcut:`Ctrl+,`,run(){uu(`settings`,e=>e.openSettings())}},{id:`settings-modal`,label:`Open settings (new)`,group:`view`,shortcut:`Ctrl+Shift+,`,run(){uu(`settings-modal`,e=>e.openSettingsModal())}},{id:`toggle-mode`,label:`Toggle Solo / Tandem mode`,group:`document`,shortcut:`Ctrl+Shift+M`,run(){uu(`toggle-mode`,e=>e.toggleSoloMode())}},{id:`new-scratchpad`,label:`New Scratchpad`,group:`document`,shortcut:`Ctrl+N`,run(){gu()}},{id:`save-as`,label:`Save As…`,group:`document`,shortcut:`Ctrl+Shift+S`,run(){uu(`save-as`,e=>void e.saveAs())}},{id:`close-tab`,label:`Close active tab`,group:`document`,shortcut:`Ctrl+W`,run(){uu(`close-tab`,e=>e.closeActiveTab())}},{id:`open-file`,label:`Open file…`,group:`document`,shortcut:`Ctrl+O`,run(){uu(`open-file`,e=>e.openFileDialog())}},{id:`find`,label:`Find / Replace`,group:`navigation`,shortcut:`Ctrl+F`,run(){uu(`find`,e=>e.openFindBar())}},{id:`find-in-tabs`,label:`Find in open tabs`,group:`navigation`,shortcut:`Ctrl+Shift+F`,run(){uu(`find-in-tabs`,e=>e.openFindBarTabs())}},{id:`find-next`,label:`Find next match`,group:`navigation`,shortcut:`Ctrl+G`,run(){uu(`find-next`,e=>e.findNext())}},{id:`find-previous`,label:`Find previous match`,group:`navigation`,shortcut:`Ctrl+Shift+G`,run(){uu(`find-previous`,e=>e.findPrev())}},{id:`toggle-left-panel`,label:`Toggle left panel`,group:`view`,shortcut:`Alt+Shift+Left`,run(){uu(`toggle-left-panel`,e=>e.toggleLeftPanel())}},{id:`toggle-right-panel`,label:`Toggle right panel`,group:`view`,shortcut:`Alt+Shift+Right`,run(){uu(`toggle-right-panel`,e=>e.toggleRightPanel())}},{id:`reopen-closed-tab`,label:`Reopen closed tab (this session)`,group:`document`,shortcut:`Ctrl+Alt+T`,run(){uu(`reopen-closed-tab`,e=>e.reopenClosedTab())}},{id:`annotation-next`,label:`Next annotation`,group:`annotations`,shortcut:`Alt+]`,run(){uu(`annotation-next`,e=>e.annotationNext())}},{id:`annotation-previous`,label:`Previous annotation`,group:`annotations`,shortcut:`Alt+[`,run(){uu(`annotation-previous`,e=>e.annotationPrev())}},{id:`annotation-accept`,label:`Accept focused annotation`,group:`annotations`,shortcut:`Ctrl+Enter`,run(){uu(`annotation-accept`,e=>e.annotationAccept())}},{id:`annotation-dismiss`,label:`Dismiss focused annotation`,group:`annotations`,shortcut:`Ctrl+Shift+Enter`,run(){uu(`annotation-dismiss`,e=>e.annotationDismiss())}},{id:`select-block`,label:`Select containing block`,group:`editor`,shortcut:`Alt+L`,run(){uu(`select-block`,e=>e.selectBlock())}},{id:`toggle-authorship`,label:`Toggle authorship colors`,group:`view`,shortcut:`Ctrl+Alt+A`,run(){uu(`toggle-authorship`,e=>e.toggleAuthorship())}},{id:`toggle-formatting-bar`,label:`Toggle formatting bar`,group:`view`,run(){uu(`toggle-formatting-bar`,e=>e.toggleFormattingBar())}},{id:`toggle-source-view`,label:`Toggle markdown source view`,group:`view`,run(){uu(`toggle-source-view`,e=>e.toggleSourceView())}},{id:`restore-backup`,label:`Restore a backup of this document…`,group:`document`,run(){uu(`restore-backup`,e=>void Lu(e))}},{id:`launcher-relaunch-here`,label:`Relaunch Claude in this folder`,group:`claude`,run(){uu(`launcher-relaunch-here`,e=>void Mu(e))}},{id:`launcher-start-fresh`,label:`Start fresh Claude conversation`,group:`claude`,run(){uu(`launcher-start-fresh`,e=>void Pu(e))}},..._u()?[{id:`show-in-file-explorer`,label:`Show in file explorer`,group:`document`,run(){uu(`show-in-file-explorer`,e=>void Ru(e))}}]:[]];for(let e of zu)ou(e);function Bu(e,t=`y`){function n(){if(e.isConnected){if(t===`y`||t===`both`){let t=e.scrollTop>0,n=e.scrollTop+e.clientHeight<e.scrollHeight-1;r(`data-overflow-top`,t),r(`data-overflow-bottom`,n)}if(t===`x`||t===`both`){let t=e.scrollLeft>0,n=e.scrollLeft+e.clientWidth<e.scrollWidth-1;r(`data-overflow-left`,t),r(`data-overflow-right`,n)}}}function r(t,n){n?e.setAttribute(t,`true`):e.removeAttribute(t)}n(),e.addEventListener(`scroll`,n,{passive:!0});let i=null;try{i=new ResizeObserver(n),i.observe(e)}catch(e){console.warn(`[tandem:scrollFade] ResizeObserver init failed`,e)}return{destroy(){e.removeEventListener(`scroll`,n),i?.disconnect()}}}function Vu(e){return e.type===`save-error`&&e.documentId?{label:`Retry`,documentId:e.documentId}:null}var Hu={info:[`M12 3a9 9 0 100 18 9 9 0 000-18z`,`M12 11v6`,`M12 8h.01`],warning:[`M10.3 3.86 1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z`,`M12 9v4`,`M12 17h.01`],error:[`M12 3a9 9 0 100 18 9 9 0 000-18z`,`M15 9l-6 6`,`M9 9l6 6`]};function Uu(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}var Wu=V(`<button type="button" data-testid="activity-clear-all" class="svelte-bf7dij">Clear all</button>`),Gu=V(`<div class="tray-empty svelte-bf7dij" data-testid="activity-empty">Nothing to report. <div class="sub svelte-bf7dij">Saves, errors, and integration events appear here.</div></div>`),Ku=Jr(`<path class="svelte-bf7dij"></path>`),qu=V(`<span class="badge svelte-bf7dij"> </span>`),Ju=V(`<button type="button" class="action svelte-bf7dij"><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bf7dij"><path d="M21 12a9 9 0 1 1-3-7" class="svelte-bf7dij"></path><path d="M21 4v5h-5" class="svelte-bf7dij"></path></svg> </button>`),Yu=V(`<div><span class="glyph svelte-bf7dij"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bf7dij"></svg></span> <div class="body svelte-bf7dij"><div class="msg-row svelte-bf7dij"><span class="msg svelte-bf7dij"> </span> <!> <span class="ts svelte-bf7dij"> </span></div> <!></div> <button type="button" class="dismiss svelte-bf7dij" aria-label="Dismiss activity item"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bf7dij"><path d="M6 6l12 12" class="svelte-bf7dij"></path><path d="M6 18L18 6" class="svelte-bf7dij"></path></svg></button></div>`),Xu=V(`<div></div>`),Zu=V(`<div class="tray-inner svelte-bf7dij" id="activity-tray" role="region" aria-label="Activity" data-testid="activity-tray"><div class="tray-head svelte-bf7dij"><span class="label svelte-bf7dij">Activity</span> <span class="num svelte-bf7dij"> </span> <span class="spacer svelte-bf7dij"></span> <!></div> <!></div>`),Qu=V(`<span class="svelte-bf7dij">No activity</span>`),$u=V(`<span class="svelte-bf7dij">Activity</span> <span class="count svelte-bf7dij"> </span>`,1),ed=V(`<div class="activity-anchor svelte-bf7dij"><div><div class="tray-wrap svelte-bf7dij"><!></div> <button type="button" class="pill-row svelte-bf7dij" data-testid="activity-pill"><span class="led svelte-bf7dij"></span> <!> <span class="spacer svelte-bf7dij"></span> <span class="chev svelte-bf7dij"><svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bf7dij"><path d="M6 9l6 6 6-6" class="svelte-bf7dij"></path></svg></span></button></div></div>`);function td(e,t){k(t,!0);let n=j(()=>t.items.length),r=j(()=>t.items.some(e=>e.severity===`error`)?`has-error`:t.items.some(e=>e.severity===`warning`)?`has-warning`:t.items.some(e=>e.severity===`info`)?`has-info`:`idle`),i=M(un(Date.now())),a=setInterval(()=>{N(i,Date.now(),!0)},3e4),o=M(!1),s=!1,c;L(()=>{t.open&&!s?(N(o,!0),c&&clearTimeout(c),c=setTimeout(()=>{N(o,!1)},1800)):!t.open&&s&&(N(o,!1),c&&=(clearTimeout(c),void 0)),s=t.open}),va(()=>{clearInterval(a),c&&clearTimeout(c)});var l=ed(),u=P(l);let d;var f=P(u),p=P(f),m=e=>{var r=Zu(),a=P(r),s=I(P(a),2),c=P(s,!0);D(s);var l=I(s,4),u=e=>{var n=Wu();B(`click`,n,function(...e){t.onClear?.apply(this,e)}),H(e,n)};W(l,e=>{z(n)>0&&e(u)}),D(a);var d=I(a,2),f=e=>{H(e,Gu())},p=e=>{var n=Xu();let r;pi(n,21,()=>t.items,e=>e.id,(e,n)=>{let r=j(()=>Vu(z(n)));var a=Yu(),o=P(a),s=P(o);pi(s,20,()=>Hu[z(n).severity],e=>e,(e,t)=>{var n=Ku();R(()=>K(n,`d`,t)),H(e,n)}),D(s),D(o);var c=I(o,2),l=P(c),u=P(l),d=P(u,!0);D(u);var f=I(u,2),p=e=>{var t=qu(),r=P(t);D(t),R(()=>U(r,`×${z(n).count??``}`)),H(e,t)};W(f,e=>{z(n).count>1&&e(p)});var m=I(f,2),h=P(m,!0);D(m),D(l);var g=I(l,2),_=e=>{var i=Ju(),a=I(P(i));D(i),R(()=>{K(i,`data-testid`,`activity-action-${z(n).id}`),U(a,` ${z(r).label??``}`)}),B(`click`,i,()=>t.onAction(z(n))),H(e,i)};W(g,e=>{z(r)&&e(_)}),D(c);var v=I(c,2);D(a),R(e=>{Ui(a,1,`toast-row ${z(n).severity??``}`,`svelte-bf7dij`),K(a,`data-testid`,`activity-row-${z(n).id}`),U(d,z(n).message),U(h,e),K(v,`data-testid`,`activity-dismiss-${z(n).id}`)},[()=>Uu(z(n).timestamp,z(i))]),B(`click`,v,()=>t.onDismiss(z(n).id)),H(e,a)}),D(n),R(()=>r=Ui(n,1,`tray-list svelte-bf7dij`,null,r,{cascade:z(o)})),H(e,n)};W(d,e=>{z(n)===0?e(f):e(p,-1)}),D(r),R(()=>U(c,z(n)===0?`No events`:`${z(n)} event${z(n)===1?``:`s`}`)),H(e,r)};W(p,e=>{t.open&&e(m)}),D(f);var h=I(f,2),g=I(P(h),2),_=e=>{H(e,Qu())},v=e=>{var t=$u(),r=I(F(t),2),i=P(r,!0);D(r),R(()=>U(i,z(n))),H(e,t)};W(g,e=>{z(n)===0?e(_):e(v,-1)}),O(4),D(h),D(u),D(l),R(()=>{d=Ui(u,1,`activity-shell ${z(r)??``}`,`svelte-bf7dij`,d,{open:t.open}),K(h,`aria-expanded`,t.open),K(h,`aria-controls`,t.open?`activity-tray`:void 0)}),B(`click`,h,function(...e){t.onToggle?.apply(this,e)}),H(e,l),A()}Br([`click`]);function nd(e){this.content=e}nd.prototype={constructor:nd,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new nd(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new nd(n)},addToStart:function(e,t){return new nd([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new nd(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new nd(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=nd.from(e),e.size?new nd(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=nd.from(e),e.size?new nd(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=nd.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},nd.from=function(e){if(e instanceof nd)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new nd(t)};function rd(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=rd(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function id(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=id(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var Z=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return rd(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return id(this,e,t,n)}findIndex(e){if(e==0)return od(0,e);if(e==this.size)return od(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?od(t+1,i):od(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};Z.empty=new Z([],0);var ad={index:0,offset:0};function od(e,t){return ad.index=e,ad.offset=t,ad}function sd(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!sd(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!sd(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var cd=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&sd(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};cd.none=[];var ld=class extends Error{},Q=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=dd(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ud(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(Z.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};Q.empty=new Q(Z.empty,0,0);function ud(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ud(a.content,t-i-1,n-i-1)))}function dd(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=dd(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function fd(e,t,n){if(n.openStart>e.depth)throw new ld(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ld(`Inconsistent open depths`);return pd(e,t,n,0)}function pd(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=pd(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return vd(a,bd(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return vd(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=xd(n,e);return vd(a,yd(e,i,o,t,r))}}function md(e,t){if(!t.type.compatibleContent(e.type))throw new ld(`Cannot join `+t.type.name+` onto `+e.type.name)}function hd(e,t,n){let r=e.node(n);return md(r,t.node(n)),r}function gd(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function _d(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(gd(e.nodeAfter,r),a++));for(let e=a;e<o;e++)gd(i.child(e),r);t&&t.depth==n&&t.textOffset&&gd(t.nodeBefore,r)}function vd(e,t){return e.type.checkContent(t),e.copy(t)}function yd(e,t,n,r,i){let a=e.depth>i&&hd(e,t,i+1),o=r.depth>i&&hd(n,r,i+1),s=[];return _d(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(md(a,o),gd(vd(a,yd(e,t,n,r,i+1)),s)):(a&&gd(vd(a,bd(e,t,i+1)),s),_d(t,n,i,s),o&&gd(vd(o,bd(n,r,i+1)),s)),_d(r,null,i,s),new Z(s)}function bd(e,t,n){let r=[];return _d(null,e,n,r),e.depth>n&&gd(vd(hd(e,t,n+1),bd(e,t,n+1)),r),_d(t,null,n,r),new Z(r)}function xd(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(Z.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Sd=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return cd.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Ed(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Td.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Td.set(t,r=new Cd);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%wd,i}},Cd=class{constructor(){this.elts=[],this.i=0}},wd=12,Td=new WeakMap,Ed=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Dd=Object.create(null),Od=class e{constructor(e,t,n,r=cd.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Z.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&sd(this.attrs,t||e.defaultAttrs||Dd)&&cd.sameSet(this.marks,n||cd.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Q.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new Q(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return fd(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Sd.resolveCached(this,e)}resolveNoCache(e){return Sd.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Ad(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=Z.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=cd.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!cd.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=Z.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Od.prototype.text=void 0;var kd=class e extends Od{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ad(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Ad(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var jd=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Md(t,n);if(r.next==null)return e.empty;let i=Nd(r);r.next&&r.err(`Unexpected trailing text`);let a=Ud(Bd(i));return Wd(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return Z.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
7
|
-
`)}};jd.empty=new jd(!0);var Md=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Nd(e){let t=[];do t.push(Pd(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Pd(e){let t=[];do t.push(Fd(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Fd(e){let t=zd(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Ld(e,t);else break;return t}function Id(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Ld(e,t){let n=Id(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Id(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Rd(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function zd(e){if(e.eat(`(`)){let t=Nd(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Rd(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Bd(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Vd(e,t){return t-e}function Hd(e,t){let n=[];return r(t),n.sort(Vd);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function Ud(e){let t=Object.create(null);return n(Hd(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Hd(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new jd(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Vd);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Wd(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Gd(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Kd(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function qd(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Jd(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Zd(e,r,t[r]);return n}var Yd=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Jd(e,n.attrs),this.defaultAttrs=Gd(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==jd.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Kd(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Od(this,this.computeAttrs(e),Z.from(t),cd.setFrom(n))}createChecked(e=null,t,n){return t=Z.from(t),this.checkContent(t),new Od(this,this.computeAttrs(e),t,cd.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=Z.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(Z.empty,!0);return i?new Od(this,e,t.append(i),cd.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){qd(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:cd.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Xd(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Zd=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Xd(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Qd=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Jd(e,r.attrs),this.excluded=null;let i=Gd(this.attrs);this.instance=i?new cd(this,i):null}create(e=null){return!e&&this.instance?this.instance:new cd(this,Kd(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){qd(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},$d=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=nd.from(e.nodes),t.marks=nd.from(e.marks||{}),this.nodes=Yd.compile(this.spec.nodes,this),this.marks=Qd.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=jd.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?ef(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:ef(this,n.split(` `))}this.nodeFromJSON=e=>Od.fromJSON(this,e),this.markFromJSON=e=>cd.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Yd))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new kd(n,n.defaultAttrs,e,cd.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function ef(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function tf(e){return e.tag!=null}function nf(e){return e.style!=null}var rf=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(tf(e))this.tags.push(e);else if(nf(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new pf(this,t,!1);return n.addAll(e,cd.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new pf(this,t,!0);return n.addAll(e,cd.none,t.from,t.to),Q.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(hf(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=gf(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=gf(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},af={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},of={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},sf={ol:!0,ul:!0},cf=1,lf=2,uf=4;function df(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?cf:0)|(t===`full`?lf:0)}var ff=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=cd.none,this.match=i||(a&uf?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Z.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&cf)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=Z.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Z.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!af.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},pf=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=df(null,t.preserveWhitespace,0)|(n?uf:0);i=r?new ff(r.type,r.attrs,cd.none,!0,t.topMatch||r.type.contentMatch,a):n?new ff(null,null,cd.none,!0,null,a):new ff(e.schema.topNodeType,null,cd.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&lf?`full`:this.localPreserveWS||(r.options&cf)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
8
|
-
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;sf.hasOwnProperty(a)&&this.parser.normalizeLists&&mf(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:of.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(af.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
9
|
-
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=cd.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):_f(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=df(e,i,a.options);a.options&uf&&a.content.length==0&&(o|=uf);let s=cd.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):_f(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new ff(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=cf);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function mf(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&sf.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function hf(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function gf(e){let t={};for(let n in e)t[n]=e[n];return t}function _f(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var vf=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=bf(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=wf(bf(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&wf(bf(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return wf(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=yf(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return yf(e.marks)}};function yf(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function bf(e){return e.document||window.document}var xf=new WeakMap;function Sf(e){let t=xf.get(e);return t===void 0&&xf.set(e,t=Cf(e)),t}function Cf(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function wf(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Sf(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=wf(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Tf=65535,Ef=2**16;function Df(e,t){return e+t*Ef}function Of(e){return e&Tf}function kf(e){return(e-(e&Tf))/Ef}var Af=1,jf=2,Mf=4,Nf=8,Pf=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Nf)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Mf)>0}},Ff=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Of(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+kf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Df(o/3,e-s),f=e==s?jf:e==u?Af:Mf;return(t<0?e!=s:e!=u)&&(f|=Nf),new Pf(a,f,d)}r+=l-c}return n?e+r:new Pf(e+r,0,null)}touches(e,t){let n=0,r=Of(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};Ff.empty=new Ff([]);var If=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Pf(e,r,null)}},Lf=Object.create(null),Rf=class{getMap(){return Ff.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Lf[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Lf)throw RangeError(`Duplicate use of step JSON ID `+e);return Lf[e]=t,t.prototype.jsonID=e,t}},zf=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof ld)return e.fail(t.message);throw t}}};function Bf(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Bf(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return Z.fromArray(r)}var Vf=class e extends Rf{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Q(Bf(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return zf.fromReplace(e,this.from,this.to,i)}invert(){return new Hf(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Rf.jsonID(`addMark`,Vf);var Hf=class e extends Rf{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Q(Bf(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return zf.fromReplace(e,this.from,this.to,n)}invert(){return new Vf(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Rf.jsonID(`removeMark`,Hf);var Uf=class e extends Rf{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return zf.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return zf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Wf(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Rf.jsonID(`addNodeMark`,Uf);var Wf=class e extends Rf{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return zf.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return zf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Uf(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Rf.jsonID(`removeNodeMark`,Wf);var Gf=class e extends Rf{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&qf(e,this.from,this.to)?zf.fail(`Structure replace would overwrite content`):zf.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ff([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,Q.fromJSON(t,n.slice),!!n.structure)}};Rf.jsonID(`replace`,Gf);var Kf=class e extends Rf{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(qf(e,this.from,this.gapFrom)||qf(e,this.gapTo,this.to)))return zf.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return zf.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?zf.fromReplace(e,this.from,this.to,n):zf.fail(`Content does not fit in gap`)}getMap(){return new Ff([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,Q.fromJSON(t,n.slice),n.insert,!!n.structure)}};Rf.jsonID(`replaceAround`,Kf);function qf(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Jf(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Hf(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Vf(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Yf(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Qd){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Hf(t.from,t.to,t.style)))}function Xf(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Gf(s,l,Q.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Hf(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new Q(Z.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Gf(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(Z.empty,!0);e.replace(s,s,new Q(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Zf(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Qf(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Zf(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function $f(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=Z.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=Z.from(r.node(e).copy(u)),d++):c--;let f=Z.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=Z.from(i.node(e).copy(f)),p++):l++;e.step(new Kf(c,l,o,s,new Q(u.append(f),d,p),u.size-d,!0))}function ep(e,t,n=null,r=e){let i=np(e,t),a=i&&rp(r,t);return a?i.map(tp).concat({type:t,attrs:n}).concat(a.map(tp)):null}function tp(e){return{type:e,attrs:null}}function np(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function rp(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function ip(e,t,n){let r=Z.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=Z.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Kf(i,a,i,a,new Q(r,0,0),n.length,!0))}function ap(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&cp(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&sp(e,t,n,a),Xf(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Kf(c,l,c+1,l-1,new Q(Z.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&op(e,t,n,a),!1}})}function op(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function sp(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
10
|
-
`))}})}function cp(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function lp(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Kf(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new Q(Z.from(o),0,0),1,!0))}function up(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function dp(e,t,n=1,r){let i=e.doc.resolve(t),a=Z.empty,o=Z.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=Z.from(i.node(e).copy(a));let t=r&&r[s];o=Z.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Gf(t,t,new Q(a.append(o),n,n),!0))}function fp(e,t){let n=e.resolve(t),r=n.index();return mp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function pp(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function mp(e,t){return!!(e&&t&&!e.isLeaf&&pp(e,t))}function hp(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&mp(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function gp(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);sp(e,r.node(),r.before(),s)}o.inlineContent&&Xf(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Gf(l,c.map(t+n,-1),Q.empty,!0)),r===!0){let t=e.doc.resolve(l);op(e,t.node(),t.before(),e.steps.length)}return e}function _p(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function vp(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function yp(e,t,n=t,r=Q.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return bp(i,a,r)?new Gf(t,n,r):new xp(i,a,r).fit()}function bp(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var xp=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Z.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Z.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new Q(i,a,o);return e>-1?new Kf(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Gf(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=wp(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(Z.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=wp(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new Q(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=wp(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new Q(Sp(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new Q(Sp(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(Tp(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Cp(this.placed,t,Z.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?Q.empty:new Q(Sp(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new Q(Sp(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ep(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Ep(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Ep(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Cp(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Cp(this.placed,this.depth,Z.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Z.empty,!0);e.childCount&&(this.placed=Cp(this.placed,this.frontier.length,e))}};function Sp(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Sp(e.firstChild.content,t-1,n)))}function Cp(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Cp(e.lastChild.content,t-1,n)))}function wp(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Tp(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Tp(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(Z.empty,!0)))),e.copy(r)}function Ep(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Dp(n,a.content,o)?s:null}function Dp(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Op(e){return e.spec.defining||e.spec.definingForContent}function kp(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(bp(i,a,r))return e.step(new Gf(t,n,r));let o=Np(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Op(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new Q(Ap(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Ap(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Ap(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Z.empty,!0))}return e}function jp(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=_p(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new Q(Z.from(r),0,0))}function Mp(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),a=Np(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Np(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var Pp=class e extends Rf{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return zf.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return zf.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(r),0,+!t.isLeaf))}getMap(){return Ff.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};Rf.jsonID(`attr`,Pp);var Fp=class e extends Rf{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return zf.ok(n)}getMap(){return Ff.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};Rf.jsonID(`docAttr`,Fp);var Ip=class extends Error{};Ip=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Ip.prototype=Object.create(Error.prototype),Ip.prototype.constructor=Ip,Ip.prototype.name=`TransformError`;var Lp=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new If}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ip(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Q.empty){let r=yp(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Q(Z.from(n),0,0))}delete(e,t){return this.replace(e,t,Q.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return kp(this,e,t,n),this}replaceRangeWith(e,t,n){return jp(this,e,t,n),this}deleteRange(e,t){return Mp(this,e,t),this}lift(e,t){return $f(this,e,t),this}join(e,t=1){return gp(this,e,t),this}wrap(e,t){return ip(this,e,t),this}setBlockType(e,t=e,n,r=null){return ap(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return lp(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Pp(e,t,n)),this}setDocAttribute(e,t){return this.step(new Fp(e,t)),this}addNodeMark(e,t){return this.step(new Uf(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof cd)t.isInSet(n.marks)&&this.step(new Wf(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new Wf(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return dp(this,e,t,n),this}addMark(e,t,n){return Jf(this,e,t,n),this}removeMark(e,t,n){return Yf(this,e,t,n),this}clearIncompatible(e,t,n){return Xf(this,e,t,n),this}},Rp=Object.create(null),zp=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Bp(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Q.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?Q.empty:t),o==0&&Xp(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),Xp(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new Up(e):Yp(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?Yp(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Yp(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new qp(e.node(0))}static atStart(e){return Yp(e,e,0,0,1)||new qp(e)}static atEnd(e){return Yp(e,e,e.content.size,e.childCount,-1)||new qp(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=Rp[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Rp)throw RangeError(`Duplicate use of selection JSON ID `+e);return Rp[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Up.between(this.$anchor,this.$head).getBookmark()}};zp.prototype.visible=!0;var Bp=class{constructor(e,t){this.$from=e,this.$to=t}},Vp=!1;function Hp(e){!Vp&&!e.parent.inlineContent&&(Vp=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var Up=class e extends zp{constructor(e,t=e){Hp(e),Hp(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return zp.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=Q.empty){if(super.replace(e,t),t==Q.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Wp(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=zp.findFrom(n,r,!0)||zp.findFrom(n,-r,!0);if(e)n=e.$head;else return zp.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(zp.findFrom(t,-r,!0)||zp.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};zp.jsonID(`text`,Up);var Wp=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return Up.between(e.resolve(this.anchor),e.resolve(this.head))}},Gp=class e extends zp{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?zp.near(a):new e(a)}content(){return new Q(Z.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new Kp(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Gp.prototype.visible=!1,zp.jsonID(`node`,Gp);var Kp=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new Wp(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Gp.isSelectable(n)?new Gp(t):zp.near(t)}},qp=class e extends zp{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Q.empty){if(t==Q.empty){e.delete(0,e.doc.content.size);let t=zp.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return Jp}};zp.jsonID(`all`,qp);var Jp={map(){return this},resolve(e){return new qp(e)}};function Yp(e,t,n,r,i,a=!1){if(t.inlineContent)return Up.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Yp(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Gp.isSelectable(r))return Gp.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function Xp(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Gf||i instanceof Kf))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(zp.near(e.doc.resolve(o),n))}var Zp=1,Qp=2,$p=4,em=class extends Lp{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Zp)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Zp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Qp,this}ensureMarks(e){return cd.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Qp)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||cd.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(zp.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=$p,this}get scrolledIntoView(){return(this.updated&$p)>0}};function tm(e,t){return!t||!e?e:e.bind(t)}var nm=class{constructor(e,t,n){this.name=e,this.init=tm(t.init,n),this.apply=tm(t.apply,n)}},rm=[new nm(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new nm(`selection`,{init(e,t){return e.selection||zp.atStart(t.doc)},apply(e){return e.selection}}),new nm(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new nm(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],im=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=rm.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new nm(e.key,e.spec.state,e))})}},am=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new em(this)}static create(t){let n=new im(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new im(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new im(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=Od.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=zp.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function om(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=om(i,t,{})),n[r]=i}return n}var sm=class{constructor(e){this.spec=e,this.props={},e.props&&om(e.props,this,this.props),this.key=e.key?e.key.key:lm(`plugin`)}getState(e){return e[this.key]}},cm=Object.create(null);function lm(e){return e in cm?e+`$`+ ++cm[e]:(cm[e]=0,e+`$`)}var um=class{constructor(e=`key`){this.key=lm(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},dm=[{keys:`Ctrl+B`,description:`Bold`},{keys:`Ctrl+I`,description:`Italic`},{keys:`Ctrl+Z`,description:`Undo`},{keys:`Ctrl+Y`,description:`Redo`},{keys:`? or Ctrl+/`,description:`Show keyboard shortcuts`},{keys:`Ctrl+Tab`,description:`Next document tab`},{keys:`Ctrl+Shift+Tab`,description:`Previous document tab`},{keys:`Ctrl+1 – Ctrl+9`,description:`Jump to tab by number`},{keys:`Ctrl+Alt+1`,description:`Heading 1`},{keys:`Ctrl+Alt+2`,description:`Heading 2`},{keys:`Ctrl+Alt+3`,description:`Heading 3`},{keys:`Ctrl+Alt+4`,description:`Heading 4`},{keys:`Ctrl+Alt+5`,description:`Heading 5`},{keys:`Ctrl+Alt+6`,description:`Heading 6`}];function fm(e){let t=[];return e.state.doc.descendants((e,n)=>{e.type.name===`heading`&&e.attrs.level<=3&&t.push({text:e.textContent,level:e.attrs.level,pos:n})}),t}var pm=V(`<div style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);"><!> <!> <!> <!></div>`),mm=V(`<li data-testid="palette-empty" style="padding: var(--tandem-space-3) var(--tandem-space-4); font-size: var(--tandem-text-sm); color: var(--tandem-fg-faint); font-style: italic;"> </li>`),hm=V(`<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>`),gm=V(`<span style="font-size: var(--tandem-text-sm);"> </span> <!>`,1),_m=V(`<span style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="
|
|
11
|
-
font-size: var(--tandem-text-xs);
|
|
12
|
-
color: var(--tandem-fg-subtle);
|
|
13
|
-
font-family: var(--tandem-font-mono);
|
|
14
|
-
min-width: 20px;
|
|
15
|
-
"> </span> <span> </span></span>`),vm=V(`<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span>`),ym=V(`<span style="display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0;"><span style="font-size: var(--tandem-text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></span> <span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); flex-shrink: 0; margin-left: var(--tandem-space-2);"> </span>`,1),bm=V(`<span style="font-size: var(--tandem-text-sm);"> </span> <span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-family: var(--tandem-font-mono);"> </span>`,1),xm=V(`<li role="option"><!></li>`),Sm=V(`<div role="presentation" class="palette-scrim svelte-gunx66" style="
|
|
16
|
-
position: fixed; inset: 0;
|
|
17
|
-
background: rgba(0,0,0,0.4);
|
|
18
|
-
backdrop-filter: blur(2px);
|
|
19
|
-
z-index: var(--tandem-z-above-titlebar);
|
|
20
|
-
display: flex; align-items: flex-start; justify-content: center;
|
|
21
|
-
padding-top: 15vh;
|
|
22
|
-
"><div data-testid="command-palette" role="dialog" tabindex="-1" aria-modal="true" aria-label="Command palette" class="palette-modal svelte-gunx66" style="
|
|
23
|
-
width: 640px; max-width: 92vw;
|
|
24
|
-
background: var(--tandem-surface);
|
|
25
|
-
border: 1px solid var(--tandem-border);
|
|
26
|
-
border-radius: var(--tandem-r-5);
|
|
27
|
-
box-shadow: var(--tandem-shadow-4);
|
|
28
|
-
overflow: hidden;
|
|
29
|
-
display: flex; flex-direction: column;
|
|
30
|
-
"><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--tandem-fg-faint)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" style="flex-shrink: 0;"><circle cx="11" cy="11" r="7"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg> <input data-testid="palette-input" type="text" aria-label="Search commands" aria-controls="palette-results" style="
|
|
31
|
-
flex: 1; min-width: 0; padding: 6px 0;
|
|
32
|
-
font-size: var(--tandem-text-md); color: var(--tandem-fg);
|
|
33
|
-
background: transparent; border: none; outline: none;
|
|
34
|
-
"/> <span class="palette-kbd svelte-gunx66" aria-hidden="true">Esc</span></div> <!></div> <ul id="palette-results" role="listbox" aria-label="Results" class="tandem-scroll-fade-y" style="max-height: 400px; overflow-y: auto; padding: var(--tandem-space-1); list-style: none; margin: 0;"><!></ul> <div style="
|
|
35
|
-
padding: var(--tandem-space-2) var(--tandem-space-4);
|
|
36
|
-
border-top: 1px solid var(--tandem-border);
|
|
37
|
-
background: var(--tandem-surface-muted);
|
|
38
|
-
display: flex; align-items: center; gap: var(--tandem-space-3);
|
|
39
|
-
font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);
|
|
40
|
-
"><span><kbd class="palette-kbd svelte-gunx66">#</kbd> headings</span> <span><kbd class="palette-kbd svelte-gunx66">@</kbd> annotations</span> <span><kbd class="palette-kbd svelte-gunx66">?</kbd> shortcuts</span> <span><kbd class="palette-kbd svelte-gunx66">></kbd> commands</span></div></div></div>`);function Cm(e,t){k(t,!0);let n=q(t,`editor`,3,null),r=q(t,`annotations`,19,()=>[]),i=M(``),a=M(0),o=M(null),s=[`#`,`@`,`?`,`>`],c=j(()=>s.find(e=>z(i).startsWith(e))??null),l=j(()=>(z(c)?z(i).slice(1):z(i)).trim().toLowerCase()),u=j(()=>{if(z(c)!==null&&z(c)!==`>`)return[];let e=su(),t=z(l),n=[];for(let r of e.values())(!t||r.label.toLowerCase().includes(t)||r.group.toLowerCase().includes(t)||(r.shortcut?.toLowerCase().includes(t)??!1))&&n.push({kind:`action`,id:r.id,action:r});return n}),d=j(()=>{if(z(c)!==`#`)return[];let e=n();if(!e||e.isDestroyed)return[];let t=z(l);return fm(e).filter(e=>!t||e.text.toLowerCase().includes(t)).map((e,t)=>({kind:`heading`,id:`heading-${t}`,...e}))}),f=j(()=>{if(z(c)!==`@`)return[];let e=z(l);return r().filter(t=>e?t.content.toLowerCase().includes(e)||t.textSnapshot?.toLowerCase().includes(e):!0).slice(0,50).map(e=>({kind:`annotation`,id:`annotation-${e.id}`,label:e.content?e.content.slice(0,60):`(no content)`,snippet:e.textSnapshot??``,annotationType:e.type}))}),p=j(()=>{if(z(c)!==`?`)return[];let e=z(l),t=su(),n=[];for(let r of t.values())r.shortcut&&(!e||r.label.toLowerCase().includes(e)||r.shortcut.toLowerCase().includes(e))&&n.push({kind:`shortcut`,id:`shortcut-registry-${r.id}`,keys:r.shortcut,description:r.label,group:r.group});for(let t=0;t<dm.length;t++){let r=dm[t];(!e||r.description.toLowerCase().includes(e)||r.keys.toLowerCase().includes(e))&&n.push({kind:`shortcut`,id:`shortcut-static-${t}`,keys:r.keys,description:r.description,group:`other`})}return n}),m=j(()=>[...z(u),...z(d),...z(f),...z(p)]);L(()=>{z(m),N(a,0)}),L(()=>{t.open&&(N(i,``),N(a,0),Promise.resolve().then(()=>z(o)?.focus()))}),_a(()=>{let e=e=>{e.key!==`Escape`||!t.open||(e.preventDefault(),e.stopPropagation(),_())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});let h={"#":`Search headings…`,"@":`Search annotations…`,"?":`Search shortcuts…`,">":`Search commands…`},g=j(()=>z(c)?h[z(c)]:`Type a command, # headings, @ annotations, ? shortcuts…`);function _(){t.onClose()}function v(e){if(e.kind===`action`)_(),e.action.run();else if(e.kind===`heading`){_();let t=n();if(!t||t.isDestroyed)return;let r=e.pos;try{let e=t.state.doc.resolve(r+1),n=Up.near(e);t.view.dispatch(t.state.tr.setSelection(n).scrollIntoView()),t.view.focus()}catch{}}else e.kind===`annotation`&&(_(),t.onFocusAnnotation?.(e.id.replace(`annotation-`,``)))}function y(e){let t=z(m).length;if(e.key===`ArrowDown`)e.preventDefault(),N(a,(z(a)+1)%Math.max(1,t));else if(e.key===`ArrowUp`)e.preventDefault(),N(a,(z(a)-1+Math.max(1,t))%Math.max(1,t));else if(e.key===`Enter`){e.preventDefault();let t=z(m)[z(a)];t&&v(t)}else e.key===`Escape`&&(e.preventDefault(),_())}function b(e){e.target===e.currentTarget&&_()}var x=Xr(),S=F(x),C=e=>{var t=Sm(),n=P(t),r=P(n),s=P(r),l=I(P(s),2);$i(l),fa(l,e=>N(o,e),()=>z(o)),O(2),D(s);var u=I(s,2),d=e=>{var t=pm(),n=P(t),r=e=>{H(e,Yr(`Searching document headings`))};W(n,e=>{z(c)===`#`&&e(r)});var i=I(n,2),a=e=>{H(e,Yr(`Searching annotations`))};W(i,e=>{z(c)===`@`&&e(a)});var o=I(i,2),s=e=>{H(e,Yr(`Showing keyboard shortcuts`))};W(o,e=>{z(c)===`?`&&e(s)});var l=I(o,2),u=e=>{H(e,Yr(`Filtering commands`))};W(l,e=>{z(c)===`>`&&e(u)}),D(t),H(e,t)};W(u,e=>{z(c)&&e(d)}),D(r);var f=I(r,2),p=P(f),h=e=>{var t=mm(),n=P(t,!0);D(t),R(()=>U(n,z(c)===`#`?`No headings found`:z(c)===`@`?`No annotations found`:z(c)===`?`?`No shortcuts found`:`No commands match`)),H(e,t)},x=e=>{var t=Xr();pi(F(t),19,()=>z(m),e=>e.id,(e,t,n)=>{let r=j(()=>z(n)===z(a));var i=xm(),o=P(i),s=e=>{var n=gm(),r=F(n),i=P(r,!0);D(r);var a=I(r,2),o=e=>{var n=hm(),r=P(n,!0);D(n),R(()=>U(r,z(t).action.shortcut)),H(e,n)};W(a,e=>{z(t).action.shortcut&&e(o)}),R(()=>U(i,z(t).action.label)),H(e,n)},c=e=>{var n=_m(),r=P(n),i=P(r);D(r);var a=I(r,2),o=P(a,!0);D(a),D(n),R(()=>{U(i,`H${z(t).level??``}`),G(a,`font-size: var(--tandem-text-sm); padding-left: calc(${z(t).level-1} * var(--tandem-space-2));`),U(o,z(t).text)}),H(e,n)},l=e=>{var n=ym(),r=F(n),i=P(r),a=P(i,!0);D(i);var o=I(i,2),s=e=>{var n=vm(),r=P(n);D(n),R(()=>U(r,`"${z(t).snippet??``}"`)),H(e,n)};W(o,e=>{z(t).snippet&&e(s)}),D(r);var c=I(r,2),l=P(c,!0);D(c),R(e=>{U(a,z(t).label),U(l,e)},[()=>z(t).annotationType.charAt(0).toUpperCase()+z(t).annotationType.slice(1)]),H(e,n)},u=e=>{var n=bm(),r=F(n),i=P(r,!0);D(r);var a=I(r,2),o=P(a,!0);D(a),R(()=>{U(i,z(t).description),U(o,z(t).keys)}),H(e,n)};W(o,e=>{z(t).kind===`action`?e(s):z(t).kind===`heading`?e(c,1):z(t).kind===`annotation`?e(l,2):z(t).kind===`shortcut`&&e(u,3)}),D(i),R(()=>{K(i,`id`,`palette-item-${z(t).id}`),K(i,`data-testid`,`palette-item-${z(t).id}`),K(i,`aria-selected`,z(r)),G(i,`
|
|
41
|
-
display: flex; align-items: center; justify-content: space-between;
|
|
42
|
-
padding: 8px var(--tandem-space-3);
|
|
43
|
-
border-radius: var(--tandem-r-3);
|
|
44
|
-
transition: background 80ms;
|
|
45
|
-
cursor: ${z(t).kind===`shortcut`?`default`:`pointer`};
|
|
46
|
-
background: ${z(r)?`var(--tandem-accent-bg)`:`transparent`};
|
|
47
|
-
color: ${z(r)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg)`};
|
|
48
|
-
`)}),B(`click`,i,()=>v(z(t))),zr(`mouseenter`,i,()=>N(a,z(n),!0)),H(e,i)}),H(e,t)};W(p,e=>{z(m).length===0?e(h):e(x,-1)}),D(f),Pi(f,(e,t)=>Bu?.(e,t),()=>`y`),O(2),D(n),D(t),R(()=>{K(l,`placeholder`,z(g)),K(l,`aria-activedescendant`,z(m)[z(a)]?`palette-item-${z(m)[z(a)].id}`:void 0)}),B(`click`,t,b),B(`keydown`,t,e=>{e.key===`Escape`&&_()}),B(`keydown`,n,y),aa(l,()=>z(i),e=>N(i,e)),H(e,t)};W(S,e=>{t.open&&e(C)}),H(e,x),A()}Br([`click`,`keydown`]);var wm=V(`<div class="tandem-banner tandem-banner--error" role="status" aria-live="polite" data-testid="connection-banner"><span class="tandem-banner__icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 2l20 20"></path><path d="M5.16 5.26A6 6 0 008 17h11a4 4 0 00.74-7.93"></path><path d="M12 7a5 5 0 014.9 4"></path></svg></span> <span class="tandem-banner__message">We've lost the connection to the Tandem server. Please check that it's still running.</span> <button type="button" class="tandem-banner__cta" data-testid="connection-banner-retry">Retry now</button> <button type="button" class="tandem-banner__dismiss" aria-label="Dismiss connection banner"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>`);function Tm(e,t){var n=wm(),r=I(P(n),4),i=I(r,2);D(n),B(`click`,r,function(...e){t.onRetry?.apply(this,e)}),B(`click`,i,function(...e){t.onDismiss?.apply(this,e)}),H(e,n)}Br([`click`]);function Em(e){return e?e.osSupported?e.coworkDetected?`normal`:`undetected`:`unsupported`:`loading`}function Dm(e){return e.claudeDesktopDetected??!1?(e.workspacesBlocked??0)>0?`blocked`:`noWorkspacesYet`:`noClaude`}function Om(e){switch(e.kind){case`adminDeclined`:return`Tandem couldn't update Windows Firewall — that needs administrator rights, and Tandem doesn't run as admin. Nothing was changed, and your documents stay on this computer (the server is only reachable locally).`;case`netshNotFound`:return`Windows Firewall command (netsh) was not found on PATH. Confirm your Windows install is intact.`;case`netshFailure`:return`Windows Firewall command failed (exit ${e.exitCode}). Details: ${km(e.stderrTail)}`;case`subnetDetectionFailed`:return`Could not detect the Hyper-V / Cowork VM subnet. Is Claude Desktop Cowork actually set up on this machine?`;case`adapterEnumerationFailed`:return`Could not enumerate Hyper-V network adapters. Run Tandem as administrator or reboot to refresh the adapter list.`;default:return`Unexpected firewall error (${e.kind}). Please restart Tandem.`}}function km(e){let t=e.trim();return t.length===0?`(no output)`:t.length<=200?t:`${t.slice(0,197)}...`}function Am(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`kind`in t&&typeof t.kind==`string`)try{return Om(t)}catch(n){return console.error(`[cowork] firewallErrorHint failed for:`,t,n),e}return e}catch{return e}}function jm(e){switch(e){case`ok`:return`Installed`;case`alreadyPresent`:return`Already installed`;case`locked`:return`Locked (retrying)`;case`schemaDrift`:return`Schema drift`;case`insecureAcl`:return`Insecure ACL`;case`failed`:return`Failed`;case`notConfigured`:return`Not configured`}}function Mm(e){switch(e){case`ok`:case`alreadyPresent`:return`success`;case`locked`:return`warning`;case`schemaDrift`:case`insecureAcl`:case`failed`:return`error`;case`notConfigured`:return`neutral`}}function Nm(e){let t=[`failed`,`schemaDrift`,`insecureAcl`,`locked`,`notConfigured`,`alreadyPresent`,`ok`],n=[e.installedPlugins,e.knownMarketplaces,e.coworkSettings];for(let e of t)if(n.includes(e))return e;return`ok`}function Pm(e,t){return!(!e||t||!e.osSupported||!e.coworkDetected||e.enabled)}function Fm(){try{return localStorage.getItem(fo)===`true`}catch{return!1}}function Im(){try{localStorage.setItem(fo,`true`)}catch{}}function Lm(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}function Rm(e){let t=null;return{schedule(n){t!==null&&clearTimeout(t),t=setTimeout(()=>{t=null,n()},e)},cancel(){t!==null&&(clearTimeout(t),t=null)}}}var zm=`Tauri runtime not available`;async function Bm(){try{return(await Ul(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return Lm()&&console.error(`[cowork] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(zm)))}}function Vm(e){return e(`cowork_get_status`)}function Hm(e,t){return e(`cowork_toggle_integration`,{enabled:t})}function Um(e){return e(`cowork_rescan`)}function Wm(e,t){return e(`cowork_set_lan_ip_override`,{enabled:t})}function Gm(e){return e(`cowork_retry_admin_elevation`)}var Km=M(!1),qm=null;function Jm(){return z(Km)}function Ym(){N(Km,!0)}function Xm(e){e!==qm&&(qm=e,e!==null&&N(Km,!1))}function Zm(e){let t=M(null),n=M(!1),r=M(null),i=null,a=!1,o=!0,s=null;va(()=>{o=!1,s!==null&&(clearInterval(s),s=null)});let c=async()=>{if(a){o&&N(n,!1);return}let e=i;if(e)try{let n=await Vm(e);if(!o)return;N(t,n,!0),N(r,null)}catch(e){if(!o)return;let t=e instanceof Error?e.message:String(e);if(t===`Tauri runtime not available`){a=!0,s!==null&&(clearInterval(s),s=null),N(n,!1);return}N(r,t,!0)}finally{o&&N(n,!1)}};return L(()=>{if(!e()){N(n,!1);return}let t=!1;return Bm().then(e=>{if(!t)return i=e,N(n,!0),c()}).catch(e=>{t||(N(r,e instanceof Error?e.message:String(e),!0),N(n,!1))}),s=setInterval(()=>{t||a||c()},po),()=>{t=!0,s!==null&&(clearInterval(s),s=null)}}),{get status(){return z(t)},get loading(){return z(n)},get error(){return z(r)},refetch:c}}var Qm=V(`<div class="cad-toast svelte-cbdwov" data-testid="cowork-admin-declined-status-error" role="alert">Cowork status check failed: unable to determine if admin elevation was declined. Please
|
|
49
|
-
restart Tandem to restore normal operation.</div>`),$m=V(`<div class="cad-error svelte-cbdwov" data-testid="cowork-admin-declined-error" role="alert"> </div>`),eh=V(`<div class="cad-warning-banner svelte-cbdwov" data-testid="cowork-admin-declined-confirm-disable"><div class="cad-confirm-heading svelte-cbdwov">Disable Cowork integration?</div> <div class="cad-confirm-body svelte-cbdwov">Cowork will be turned off. Any firewall rule a past admin run added is left in
|
|
50
|
-
place (it's harmless — the server only listens on this computer). You can
|
|
51
|
-
re-enable Cowork later from Settings.</div> <div class="cad-actions svelte-cbdwov"><button class="cad-btn cad-btn--destructive svelte-cbdwov" data-testid="cowork-admin-declined-disable-confirm-btn" type="button">Disable</button> <button class="cad-btn cad-btn--ghost svelte-cbdwov" data-testid="cowork-admin-declined-disable-cancel-btn" type="button">Cancel</button></div></div>`),th=V(`<div class="cad-actions cad-actions--right svelte-cbdwov"><button class="cad-btn cad-btn--ghost cad-btn--lg svelte-cbdwov" data-testid="cowork-admin-declined-disable-btn" type="button">Disable Cowork</button> <button class="cad-btn cad-btn--primary cad-btn--lg svelte-cbdwov" data-testid="cowork-admin-declined-retry-btn" type="button">Retry with admin</button></div>`),nh=V(`<div class="cad-backdrop svelte-cbdwov" data-testid="cowork-admin-declined-backdrop" role="button" tabindex="-1" aria-label="Dismiss admin permission notice"><div class="cad-dialog svelte-cbdwov" data-testid="cowork-admin-declined-modal" role="dialog" aria-modal="true" aria-labelledby="cowork-admin-declined-heading"><h2 class="cad-heading svelte-cbdwov" id="cowork-admin-declined-heading">Admin permission required</h2> <div class="cad-description svelte-cbdwov">Cowork integration needs Windows admin permission to add the firewall rule that lets
|
|
52
|
-
Claude inside the Cowork VM reach Tandem. Without it, that rule wasn't added, so Cowork
|
|
53
|
-
can't connect. Nothing was exposed — Tandem's server only listens on this computer
|
|
54
|
-
(127.0.0.1). You can dismiss this for now, or turn Cowork off below.</div> <!> <!></div></div>`);function rh(e,t){k(t,!0);let n=Zm(()=>!0),r=j(()=>n.status?.uacDeclined===!0),i=j(()=>z(r)&&!Jm()),a=M(void 0),o=M(!1),s=M(!1),c=M(null);L(()=>{Xm(n.status?.uacDeclinedAt??null)}),L(()=>{if(!z(i))return;let e=typeof document<`u`?document.title:null;return typeof document<`u`&&!document.title.startsWith(`⚠`)&&(document.title=`⚠ ${document.title}`),()=>{typeof document<`u`&&e!==null&&(document.title=e)}}),L(()=>{if(!z(i))return;let e=e=>{if(e.key===`Escape`){if(z(s))return;Ym();return}if(e.key!==`Tab`||!z(a))return;let t=z(a).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;if(!z(a).contains(i)){e.preventDefault(),n.focus();return}e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),L(()=>{z(i)&&z(a)?.focus()});async function l(e,t){N(s,!0),N(c,null);try{await e(await Bm())}catch(e){N(c,`${t}: ${Am(e instanceof Error?e.message:String(e))}`)}finally{N(s,!1)}}async function u(){await l(async e=>{await Gm(e),await n.refetch()},`Retry failed`)}async function d(){await l(async e=>{await Hm(e,!1),await n.refetch()},`Failed to disable Cowork`),z(c)||N(o,!1)}var f=Xr(),p=F(f),m=e=>{H(e,Qm())},h=e=>{var t=nh(),n=P(t);K(n,`tabindex`,-1);var r=I(P(n),4),i=e=>{var t=$m(),n=P(t,!0);D(t),R(()=>U(n,z(c))),H(e,t)};W(r,e=>{z(c)&&e(i)});var l=I(r,2),f=e=>{var t=eh(),n=I(P(t),4),r=P(n),i=I(r,2);D(n),D(t),R(()=>{r.disabled=z(s),i.disabled=z(s)}),B(`click`,r,()=>void d()),B(`click`,i,()=>{N(o,!1)}),H(e,t)},p=e=>{var t=th(),n=P(t),r=I(n,2);D(t),R(()=>{n.disabled=z(s),r.disabled=z(s)}),B(`click`,n,()=>{N(o,!0)}),B(`click`,r,()=>void u()),H(e,t)};W(l,e=>{z(o)?e(f):e(p,-1)}),D(n),fa(n,e=>N(a,e),()=>z(a)),D(t),B(`click`,t,e=>{!z(s)&&e.target===e.currentTarget&&Ym()}),B(`keydown`,t,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),z(s)||Ym())}),H(e,t)};W(p,e=>{n.error&&!n.status?e(m):z(i)&&e(h,1)}),H(e,f),A()}Br([`click`,`keydown`]);var ih=V(`<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>`),ah=V(`<div class="tandem-banner tandem-banner--warning" role="status" aria-live="polite" data-testid="docx-conflict-banner"><span class="tandem-banner__message"> </span> <!> <button type="button" class="tandem-banner__cta" data-testid="docx-conflict-keep-btn"> </button> <button type="button" class="tandem-banner__cta" data-testid="docx-conflict-reload-btn"> </button></div>`);function oh(e,t){k(t,!0);let n=M(null),r=M(null),i=M(null);L(()=>{let e=t.ydoc.getMap(Wa),a=()=>{N(n,e.get(`externalConflict`)??null,!0)};a();let o=e=>{e.keysChanged.has(`externalConflict`)&&a()};return e.observe(o),()=>{e.unobserve(o),N(n,null),N(i,null),N(r,null)}});let a=j(()=>z(n)?z(n).kind===`external-edit`?`${t.fileName} changed on disk while you have unsaved edits. Keeping your edits means your next save overwrites the disk changes; reloading discards your unsaved edits.`:z(n).diskChanged?`Unsaved edits for ${t.fileName} were restored from your last session, but the file also changed on disk. Keep your restored edits, or reload the file from disk (discards them)?`:`Unsaved edits for ${t.fileName} were restored from your last session. Keep them, or reload fresh from the file on disk (discards them)?`:``);async function o(e){if(!z(r)){N(r,e,!0),N(i,null);try{let n=await fetch(`${Il}${kc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId,choice:e})});n.ok||N(i,(await n.json().catch(()=>null))?.message??`Request failed (HTTP ${n.status}).`,!0)}catch{N(i,`Could not reach the server.`)}finally{N(r,null)}}}var s=Xr(),c=F(s),l=e=>{var t=ah(),n=P(t),s=P(n,!0);D(n);var c=I(n,2),l=e=>{var t=ih(),n=P(t,!0);D(t),R(()=>U(n,z(i))),H(e,t)};W(c,e=>{z(i)&&e(l)});var u=I(c,2),d=P(u,!0);D(u);var f=I(u,2),p=P(f,!0);D(f),D(t),R(()=>{U(s,z(a)),u.disabled=z(r)!==null,U(d,z(r)===`keep`?`Keeping…`:`Keep my edits`),f.disabled=z(r)!==null,U(p,z(r)===`reload`?`Reloading…`:`Reload from file`)}),B(`click`,u,()=>o(`keep`)),B(`click`,f,()=>o(`reload`)),H(e,t)};W(c,e=>{z(n)&&e(l)}),H(e,s),A()}Br([`click`]);var sh=V(`<div class="empty-illus svelte-16uow3k" aria-hidden="true"><svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="13" cy="36" r="9" stroke="var(--tandem-fg-faint)" stroke-width="1.5" fill="var(--tandem-surface)"></circle><circle cx="13" cy="36" r="3.5" fill="var(--tandem-fg-faint)"></circle><circle cx="59" cy="36" r="9" stroke="var(--tandem-border-strong)" stroke-width="1.5" fill="var(--tandem-surface-muted)"></circle><circle cx="59" cy="36" r="3.5" fill="var(--tandem-border-strong)"></circle><line x1="22" y1="36" x2="30" y2="36" stroke="var(--tandem-fg-faint)" stroke-width="1.5" stroke-linecap="round"></line><line x1="42" y1="36" x2="50" y2="36" stroke="var(--tandem-border-strong)" stroke-width="1.5" stroke-linecap="round"></line><line x1="32" y1="31" x2="40" y2="41" stroke="var(--tandem-error)" stroke-width="1.8" stroke-linecap="round"></line><line x1="40" y1="31" x2="32" y2="41" stroke="var(--tandem-error)" stroke-width="1.8" stroke-linecap="round"></line></svg></div> <p class="empty-heading svelte-16uow3k">Server unavailable</p> <p class="empty-sub svelte-16uow3k">Tandem can't reach its sync server. Make sure it's running locally.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-retry">Retry</button> <button class="empty-link svelte-16uow3k" data-testid="empty-state-open-settings">Open settings</button></div>`,1),ch=V(`<p class="empty-sub empty-sub-secondary svelte-16uow3k">No AI is connected yet.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-connect-ai" data-ai-chip="connect">Connect AI</button></div>`,1),lh=V(`<p class="empty-sub empty-sub-secondary svelte-16uow3k">Claude Code has stopped.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-connect-ai" data-ai-chip="restart">Restart Claude Code</button></div>`,1),uh=V(`<p class="empty-sub empty-sub-secondary svelte-16uow3k">Tandem works alongside Claude (the default integration) or any MCP-capable AI client.</p>`),dh=V(`<div class="empty-illus svelte-16uow3k" aria-hidden="true"><svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="11" y="10" width="36" height="46" rx="3" stroke="var(--tandem-border-strong)" stroke-width="1.2" fill="var(--tandem-surface-muted)"></rect><rect x="20" y="17" width="36" height="46" rx="3" stroke="var(--tandem-fg-faint)" stroke-width="1.5" fill="var(--tandem-surface)"></rect><line x1="27" y1="27" x2="49" y2="27" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><line x1="27" y1="33" x2="46" y2="33" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><line x1="27" y1="39" x2="49" y2="39" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><line x1="27" y1="45" x2="44" y2="45" stroke="var(--tandem-border-strong)" stroke-width="1.1" stroke-linecap="round"></line><circle cx="56" cy="16" r="9" fill="var(--tandem-surface)" stroke="var(--tandem-fg-faint)" stroke-width="1.5"></circle><line x1="56" y1="11.5" x2="56" y2="20.5" stroke="var(--tandem-fg-faint)" stroke-width="1.5" stroke-linecap="round"></line><line x1="51.5" y1="16" x2="60.5" y2="16" stroke="var(--tandem-fg-faint)" stroke-width="1.5" stroke-linecap="round"></line></svg></div> <p class="empty-heading svelte-16uow3k">Nothing open yet</p> <p class="empty-sub svelte-16uow3k">Click + in the tab bar, or drop a Markdown file here.</p> <div class="empty-actions svelte-16uow3k"><button class="empty-cta svelte-16uow3k" data-testid="empty-state-open-file">Open file…</button></div> <!>`,1),fh=V(`<div class="empty-state svelte-16uow3k"><!></div>`);function ph(e,t){k(t,!0);let n=q(t,`aiChip`,3,null),r=M(!1);L(()=>{if(t.connected){N(r,!1);return}let e=setTimeout(()=>{N(r,!0)},Ea);return()=>clearTimeout(e)});var i=fh(),a=P(i),o=e=>{var n=sh(),r=I(F(n),6),i=P(r),a=I(i,2);D(r),B(`click`,i,function(...e){t.onRetry?.apply(this,e)}),B(`click`,a,function(...e){t.onOpenSettings?.apply(this,e)}),H(e,n)},s=e=>{var r=dh(),i=I(F(r),6),a=P(i);D(i);var o=I(i,2),s=e=>{var n=ch(),r=I(F(n),2),i=P(r);D(r),B(`click`,i,function(...e){t.onConnectAi?.apply(this,e)}),H(e,n)},c=e=>{var n=lh(),r=I(F(n),2),i=P(r);D(r),B(`click`,i,function(...e){t.onRestartClaude?.apply(this,e)}),H(e,n)},l=e=>{H(e,uh())};W(o,e=>{t.connected&&n()===`connect`?e(s):t.connected&&n()===`restart`?e(c,1):t.connected&&e(l,2)}),B(`click`,a,function(...e){t.onOpenFile?.apply(this,e)}),H(e,r)};W(a,e=>{z(r)?e(o):e(s,-1)}),D(i),H(e,i),A()}Br([`click`]);var mh=V(`<li> </li>`),hh=V(`<section data-testid="fidelity-report-integrity-warnings"><h4 class="svelte-coexzc">This save may not have preserved everything</h4> <ul class="svelte-coexzc"></ul> <p class="fidelity-report-restore-hint svelte-coexzc">To recover, run "Restore a backup of this document…" from the command palette.</p></section>`),gh=V(`<li> </li>`),_h=V(`<section data-testid="fidelity-report-import-losses"><h4 class="svelte-coexzc">Not imported — lost if you save over the original</h4> <ul class="svelte-coexzc"></ul></section>`),vh=V(`<li> </li>`),yh=V(`<section data-testid="fidelity-report-export-downgrades"><h4 class="svelte-coexzc">Simplified on the last save</h4> <ul class="svelte-coexzc"></ul></section>`),bh=V(`<div data-testid="fidelity-report-details"><!> <!> <!></div>`),xh=V(`<div data-testid="fidelity-report-banner"><span class="tandem-banner__message"><!></span> <button type="button" class="tandem-banner__cta" data-testid="fidelity-report-details-toggle"> </button></div> <!>`,1);function Sh(e,t){k(t,!0);let n=M(null),r=M(!1);L(()=>{let e=t.ydoc.getMap(Wa),i=()=>{let t=e.get(to);N(n,t?{importLosses:Array.isArray(t.importLosses)?t.importLosses:[],exportDowngrades:Array.isArray(t.exportDowngrades)?t.exportDowngrades:[],integrityWarnings:Array.isArray(t.integrityWarnings)?t.integrityWarnings:[],updatedAt:typeof t.updatedAt==`number`?t.updatedAt:0}:null,!0)};i();let a=e=>{e.keysChanged.has(`fidelityReport`)&&i()};return e.observe(a),()=>{e.unobserve(a),N(n,null),N(r,!1)}});let i=j(()=>z(n)?.integrityWarnings??[]),a=j(()=>z(i).length>0),o=j(()=>!!z(n)&&(z(n).importLosses.length>0||z(n).exportDowngrades.length>0||z(a)));var s=Xr(),c=F(s),l=e=>{var o=xh(),s=F(o),c=P(s),l=P(c),u=e=>{var n=Yr();R(()=>U(n,`This save of ${t.fileName??``} may have changed more than expected — your original is backed up and
|
|
55
|
-
can be restored.`)),H(e,n)},d=e=>{var n=Yr();R(()=>U(n,`Some Word features in ${t.fileName??``} aren't fully supported. Tandem imported the text and
|
|
56
|
-
structure, but the items below won't survive a save back to .docx.`)),H(e,n)};W(l,e=>{z(a)?e(u):e(d,-1)}),D(c);var f=I(c,2),p=P(f,!0);D(f),D(s);var m=I(s,2),h=e=>{var t=bh(),r=P(t),o=e=>{var t=hh(),n=I(P(t),2);pi(n,21,()=>z(i),li,(e,t)=>{var n=mh(),r=P(n,!0);D(n),R(()=>U(r,z(t))),H(e,n)}),D(n),O(2),D(t),H(e,t)};W(r,e=>{z(a)&&e(o)});var s=I(r,2),c=e=>{var t=_h(),r=I(P(t),2);pi(r,21,()=>z(n).importLosses,li,(e,t)=>{var n=gh(),r=P(n,!0);D(n),R(()=>U(r,z(t))),H(e,n)}),D(r),D(t),H(e,t)};W(s,e=>{z(n).importLosses.length>0&&e(c)});var l=I(s,2),u=e=>{var t=yh(),r=I(P(t),2);pi(r,21,()=>z(n).exportDowngrades,li,(e,t)=>{var n=vh(),r=P(n,!0);D(n),R(()=>U(r,z(t))),H(e,n)}),D(r),D(t),H(e,t)};W(l,e=>{z(n).exportDowngrades.length>0&&e(u)}),D(t),R(()=>Ui(t,1,`fidelity-report-details ${z(a)?`fidelity-report-details--warning`:``}`,`svelte-coexzc`)),H(e,t)};W(m,e=>{z(r)&&e(h)}),R(()=>{Ui(s,1,`tandem-banner ${z(a)?`tandem-banner--warning`:`tandem-banner--info`}`),K(s,`role`,z(a)?`alert`:`status`),K(s,`aria-live`,z(a)?`assertive`:`polite`),K(f,`aria-expanded`,z(r)),U(p,z(r)?`Hide details`:`Details`)}),B(`click`,f,()=>N(r,!z(r))),H(e,o)};W(c,e=>{z(o)&&z(n)&&e(l)}),H(e,s),A()}Br([`click`]);async function Ch(e,t={}){let{readOnly:n=!1,notFoundMessage:r=`File not found.`,failureMessage:i=`Failed to open file.`}=t;try{let t=await fetch(`${Il}${_c}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({filePath:e,readOnly:n})});if(!t.ok){let e=i;try{let n=await t.json();n.message&&(e=n.message)}catch{}return t.status===404&&(e=r),{ok:!1,error:e}}return{ok:!0}}catch(e){return console.warn(`[tandem] openServerPath failed:`,e),{ok:!1,error:`Server unavailable.`}}}var wh=Array.from(wa).sort().map(e=>e.replace(/^\./,``));async function Th(){let{open:e}=await Ul(async()=>{let{open:e}=await import(`./dist-js-BWAGOggB.js`);return{open:e}},__vite__mapDeps([2,1])),t=await e({multiple:!1,directory:!1,title:`Open file in Tandem`,defaultPath:await ql()??void 0,filters:[{name:`Documents`,extensions:wh}]});return typeof t==`string`?t:null}async function Eh(e={}){let t;try{t=await Th()}catch(t){console.error(`[tandem] native file picker unavailable:`,t),e.onError?.(`File picker unavailable: ${t instanceof Error?t.message:t}`);return}if(!t)return;let n=await Ch(t);if(!n.ok){e.onError?.(n.error);return}Ql(Jl(Zl(),t))}async function Dh(e){e.isTauri?await Eh({onError:e.onError}):e.openModal()}async function Oh(e,t){try{let n=await fetch(`${Il}${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));return n.ok?{ok:!0,data:r.data??{}}:{ok:!1,error:r.message??`Request failed.`}}catch(e){return console.warn(`[tandem] sessions request failed:`,e),{ok:!1,error:`Server unavailable.`}}}async function kh(){try{let e=await fetch(`${Il}${Pc}`),t=await e.json().catch(()=>({}));return e.ok?{ok:!0,data:t.data?.sessions??[]}:{ok:!1,error:t.message??`Failed to load sessions.`}}catch(e){return console.warn(`[tandem] fetchSessions failed:`,e),{ok:!1,error:`Server unavailable.`}}}async function Ah(e){return Oh(Fc,{filePath:e})}async function jh(){return Oh(Ic,{})}var Mh=V(`<input type="file" style="display: none;"/>`),Nh=V(`<p style="margin: 8px 0 0; font-size: 11px; color: var(--tandem-fg-subtle); text-align: center;">…or drop a file anywhere in the window</p>`),Ph=V(`<button type="button" style="background: none; border: none; padding: 6px 8px; border-radius: var(--tandem-r-2); cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 1px;"><span style="font-size: 13px; color: var(--tandem-fg);"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px;"> </span></button>`),Fh=V(`<div data-testid="recent-files-list" style="margin-top: 16px;"><div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;"><span style="font-size: 11px; color: var(--tandem-fg-subtle); text-transform: uppercase; letter-spacing: 0.05em;">Recent</span> <button data-testid="clear-recent-files" type="button" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline;">Clear all</button></div> <div class="tandem-scroll-fade-y" style="max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div></div>`),Ih=V(`<p data-testid="sessions-loading" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">Loading…</p>`),Lh=V(`<p data-testid="sessions-empty" style="margin: 8px 0 0; font-size: 12px; color: var(--tandem-fg-subtle);">No saved sessions.</p>`),Rh=V(`<div data-testid="session-row" style="display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: var(--tandem-r-2);"><button type="button" data-testid="session-reopen" style="flex: 1; min-width: 0; background: none; border: none; padding: 0; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 1px;"><span style="font-size: 13px; color: var(--tandem-fg);"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </span> <span style="font-size: 11px; color: var(--tandem-fg-subtle);"> </span></button> <button type="button" data-testid="session-delete" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 14px; cursor: pointer; padding: 4px; line-height: 1;">×</button></div>`),zh=V(`<div style="display: flex; justify-content: flex-end; margin: 6px 0;"><button data-testid="sessions-clear-all" type="button" style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline;">Clear all</button></div> <div class="tandem-scroll-fade-y" style="max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;"></div>`,1),Bh=V(`<div data-testid="sessions-error" style="margin-top: 8px; padding: 8px 10px; font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-error-border);"> </div>`),Vh=V(`<!> <!>`,1),Hh=V(`<div style="margin-top: 10px; padding: 8px 10px; font-size: 12px; color: var(--tandem-error-fg-strong); background: var(--tandem-error-bg); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-error-border);" data-testid="file-open-error"> </div>`),Uh=V(`<div role="dialog" aria-modal="true" aria-label="Open File" style="position: fixed; inset: 0; z-index: var(--tandem-z-above-titlebar); display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent);"><div style="background: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-5); box-shadow: var(--tandem-shadow-3); width: 440px; padding: 20px;" data-testid="file-open-dialog"><div style="display: flex; justify-content: space-between; margin-bottom: 16px;"><h3 style="margin: 0; font-size: 15px; font-weight: 600; color: var(--tandem-fg);">Open File</h3> <button class="modal-close svelte-ik1xhg" aria-label="Close">×</button></div> <button type="button" data-testid="file-open-browse"> </button> <!> <!> <!> <div data-testid="sessions-section" style="margin-top: 16px;"><button type="button" data-testid="sessions-toggle" style="width: 100%; background: none; border: none; padding: 0; cursor: pointer; display: flex; justify-content: space-between; align-items: center; color: var(--tandem-fg-subtle);"><span style="font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;">Saved sessions</span> <span style="font-size: 11px;"> </span></button> <!></div> <!></div></div>`);function Wh(e,t){k(t,!0);let n=M(null),r=M(!1),i=M(void 0),a=M(un(Yl(Zl()))),o=M(un([])),s=M(!1),c=M(!1),l=M(!1),u=M(null);async function d(){N(c,!0),N(u,null);let e=await kh();e.ok?(N(o,e.data,!0),N(l,!0)):N(u,e.error,!0),N(c,!1)}function f(){N(s,!z(s)),z(s)&&!z(l)&&!z(c)&&d()}async function p(e){N(u,null);let t=await Ah(e);t.ok?N(o,z(o).filter(t=>t.filePath!==e),!0):N(u,t.error,!0)}async function m(){N(u,null);let e=await jh();e.ok?N(o,[],!0):N(u,e.error,!0)}function h(e){if(!e)return`unknown`;let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}let g=Array.from(wa).sort().join(`,`);function _(e){let t=Jl(Zl(),e);Ql(t),N(a,Yl(t),!0)}function v(){$l(),N(a,[],!0)}async function y(e){if(!z(r)){N(n,null),N(r,!0);try{let r=await Ch(e);if(!r.ok){N(n,r.error,!0);return}_(e),t.onClose()}finally{N(r,!1)}}}async function b(){if(!z(r))try{let e=await Th();e&&await y(e)}catch(e){N(n,`File picker unavailable: ${e instanceof Error?e.message:e}`)}}async function x(e){if(!z(r)){N(n,null),N(r,!0);try{let r=await zl(e),i=await fetch(`${Il}${xc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileName:e.name,content:r})}),a=await i.json();if(!i.ok){N(n,a.message??`Failed to open file`,!0);return}t.onClose()}catch(e){console.error(`FileOpenDialog: upload failed`,e),e instanceof SyntaxError?N(n,`Server returned an unexpected response`):e instanceof TypeError?N(n,`Unexpected response format`):N(n,`Cannot reach server. Is it running?`)}finally{N(r,!1)}}}function S(e){let t=e.target.files?.[0];t&&x(t)}function C(){Lm()?b():z(i)?.click()}var w=Uh();K(w,`tabindex`,-1);var ee=P(w),T=P(ee),te=I(P(T),2);D(T);var ne=I(T,2);Tn(ne,!0);var E=P(ne,!0);D(ne);var re=I(ne,2),ie=e=>{var t=Mh();fa(t,e=>N(i,e),()=>z(i)),R(()=>K(t,`accept`,g)),B(`change`,t,S),H(e,t)},ae=j(()=>!Lm());W(re,e=>{z(ae)&&e(ie)});var oe=I(re,2),se=e=>{H(e,Nh())},ce=j(()=>Lm());W(oe,e=>{z(ce)&&e(se)});var le=I(oe,2),ue=e=>{var t=Fh(),n=P(t),r=I(P(n),2);D(n);var i=I(n,2);pi(i,22,()=>z(a),e=>e,(e,t,n)=>{let r=j(()=>t.split(/[/\\]/)),i=j(()=>z(r).at(-1)??t),a=j(()=>z(r).slice(0,-1).join(`/`)||`/`);var o=Ph(),s=P(o),c=P(s,!0);D(s);var l=I(s,2),u=P(l,!0);D(l),D(o),R(()=>{K(o,`data-testid`,`recent-file-${z(n)}`),U(c,z(i)),U(u,z(a))}),B(`click`,o,()=>y(t)),zr(`mouseenter`,o,e=>{e.currentTarget.style.background=`var(--tandem-surface-muted)`}),zr(`mouseleave`,o,e=>{e.currentTarget.style.background=`transparent`}),H(e,o)}),D(i),Pi(i,(e,t)=>Bu?.(e,t),()=>`y`),D(t),B(`click`,r,v),H(e,t)};W(le,e=>{z(a).length>0&&e(ue)});var de=I(le,2),fe=P(de),pe=I(P(fe),2),me=P(pe,!0);D(pe),D(fe);var he=I(fe,2),ge=e=>{var t=Vh(),n=F(t),r=e=>{H(e,Ih())},i=e=>{H(e,Lh())},a=e=>{var t=zh(),n=F(t),r=P(n);D(n);var i=I(n,2);pi(i,21,()=>z(o),e=>e.filePath,(e,t)=>{let n=j(()=>z(t).filePath.split(/[/\\]/)),r=j(()=>z(n).at(-1)??z(t).filePath),i=j(()=>z(n).slice(0,-1).join(`/`)||`/`);var a=Rh(),o=P(a),s=P(o),c=P(s,!0);D(s);var l=I(s,2),u=P(l,!0);D(l);var d=I(l,2),f=P(d);D(d),D(o);var m=I(o,2);D(a),R(e=>{K(o,`title`,z(t).filePath),U(c,z(r)),U(u,z(i)),U(f,`${e??``} · ${z(t).annotationCount??``} annotation${z(t).annotationCount===1?``:`s`}`),K(m,`aria-label`,`Delete session for ${z(r)}`)},[()=>h(z(t).lastAccessed)]),B(`click`,o,()=>y(z(t).filePath)),B(`click`,m,()=>p(z(t).filePath)),H(e,a)}),D(i),Pi(i,(e,t)=>Bu?.(e,t),()=>`y`),B(`click`,r,m),H(e,t)};W(n,e=>{z(c)?e(r):z(o).length===0?e(i,1):e(a,-1)});var s=I(n,2),l=e=>{var t=Bh(),n=P(t,!0);D(t),R(()=>U(n,z(u))),H(e,t)};W(s,e=>{z(u)&&e(l)}),H(e,t)};W(he,e=>{z(s)&&e(ge)}),D(de);var _e=I(de,2),ve=e=>{var t=Hh(),r=P(t,!0);D(t),R(()=>U(r,z(n))),H(e,t)};W(_e,e=>{z(n)&&e(ve)}),D(ee),D(w),R(()=>{ne.disabled=z(r),G(ne,`width: 100%; padding: 12px; font-size: 14px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: ${z(r)?`wait`:`pointer`}; background: ${z(r)?`var(--tandem-fg-subtle)`:`var(--tandem-accent)`}; color: var(--tandem-accent-fg);`),U(E,z(r)?`Opening…`:`Browse…`),K(fe,`aria-expanded`,z(s)),U(me,z(s)?`▾`:`▸`)}),B(`click`,w,e=>{e.target===e.currentTarget&&t.onClose()}),B(`keydown`,w,e=>{e.key===`Escape`&&t.onClose()}),B(`click`,te,function(...e){t.onClose?.apply(this,e)}),B(`click`,ne,C),B(`click`,fe,f),H(e,w),A()}Br([`click`,`keydown`,`change`]);var Gh=V(`<span style="font-size: 12px; font-family: ui-monospace, SFMono-Regular, monospace; white-space: nowrap;"><kbd style="display: inline-block; padding: 1px 6px; font-size: 12px; font-family: inherit; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom: 2px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); color: var(--tandem-fg); line-height: 1.5;"> </kbd></span> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),Kh=V(`<div style="margin-bottom: 18px;"><div style="font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tandem-fg-subtle); margin-bottom: 6px;"> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></div>`),qh=V(`<span style="font-size: 12px; font-family: ui-monospace, SFMono-Regular, monospace; white-space: nowrap;"><kbd style="display: inline-block; padding: 1px 6px; font-size: 12px; font-family: inherit; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom: 2px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); color: var(--tandem-fg); line-height: 1.5;"> </kbd></span> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),Jh=V(`<div role="presentation" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); display: flex; align-items: center; justify-content: center; z-index: var(--tandem-z-above-titlebar);" data-testid="help-modal"><div role="dialog" aria-modal="true" aria-label="Keyboard Shortcuts" tabindex="-1" class="tandem-scroll-fade-y" style="background-color: var(--tandem-surface); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-5); box-shadow: var(--tandem-shadow-3); padding: 24px 28px 20px; width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto; position: relative;"><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;"><h2 style="margin: 0; font-size: 16px; font-weight: 600; color: var(--tandem-fg);">Keyboard Shortcuts</h2> <button type="button" class="modal-close svelte-6zgoeu" aria-label="Close help" data-testid="help-modal-close">✕</button></div> <!> <div style="margin-bottom: 18px;"><div style="font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tandem-fg-subtle); margin-bottom: 6px;">Other</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></div> <div style="margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--tandem-border); font-size: 11px; color: var(--tandem-fg-subtle); text-align: center;">Press <kbd style="font-size: 11px; padding: 1px 4px; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); color: var(--tandem-fg-subtle);">?</kbd>, <kbd style="font-size: 11px; padding: 1px 4px; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); color: var(--tandem-fg-subtle);">Ctrl+/</kbd>,
|
|
57
|
-
or <kbd style="font-size: 11px; padding: 1px 4px; background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); color: var(--tandem-fg-subtle);">Esc</kbd> to close</div></div></div>`);function Yh(e,t){k(t,!0);let n=j(()=>{let e=su(),n=t.effectiveShortcutLabels,r=new Map;for(let t of e.values()){if(!t.shortcut)continue;let e=Xc[t.id],i=e&&n?.get(e)||t.shortcut,a=r.get(t.group)??[];a.push({keys:i,description:t.label}),r.set(t.group,a)}return iu.map(e=>({title:e.charAt(0).toUpperCase()+e.slice(1),rows:r.get(e)??[]})).filter(e=>e.rows.length>0)}),r=M(null),i=null;L(()=>{if(!t.open)return;let e=Ar(()=>z(r));if(!e)return;i=document.activeElement,e.focus();let n=t=>{e&&!e.contains(t.target)&&e.focus()};return document.addEventListener(`focusin`,n),()=>{document.removeEventListener(`focusin`,n),i instanceof HTMLElement&&document.contains(i)&&i.focus()}}),L(()=>{if(!t.open)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t.onClose())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});var a=Xr(),o=F(a),s=e=>{var i=Jh(),a=P(i),o=P(a),s=I(P(o),2);D(o);var c=I(o,2);pi(c,17,()=>z(n),e=>e.title,(e,t)=>{var n=Kh(),r=P(n),i=P(r,!0);D(r);var a=I(r,2);pi(a,21,()=>z(t).rows,e=>e.description,(e,t)=>{var n=Gh(),r=F(n),i=P(r),a=P(i,!0);D(i),D(r);var o=I(r,2),s=P(o,!0);D(o),R(()=>{U(a,z(t).keys),U(s,z(t).description)}),H(e,n)}),D(a),D(n),R(()=>U(i,z(t).title)),H(e,n)});var l=I(c,2),u=I(P(l),2);pi(u,21,()=>dm,e=>e.description,(e,t)=>{var n=qh(),r=F(n),i=P(r),a=P(i,!0);D(i),D(r);var o=I(r,2),s=P(o,!0);D(o),R(()=>{U(a,z(t).keys),U(s,z(t).description)}),H(e,n)}),D(u),D(l),O(2),D(a),fa(a,e=>N(r,e),()=>z(r)),Pi(a,(e,t)=>Bu?.(e,t),()=>`y`),D(i),B(`click`,i,function(...e){t.onClose?.apply(this,e)}),B(`click`,a,e=>e.stopPropagation()),B(`keydown`,a,e=>{if(e.key===`Escape`){t.onClose();return}if(e.stopPropagation(),e.key===`Tab`&&z(r)){let t=Array.from(z(r).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.closest(`[hidden]`));if(t.length===0){e.preventDefault();return}let n=t[0],i=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus())}}),B(`click`,s,function(...e){t.onClose?.apply(this,e)}),H(e,i)};W(o,e=>{t.open&&e(s)}),H(e,a),A()}Br([`click`,`keydown`]);var Xh=`/api/integrations/existing`,Zh=`/api/integrations`,Qh=`/api/integrations/apply`,$h=`/api/integrations/first-run-needed`;function eg(e){return`/api/integrations/secrets/${encodeURIComponent(e)}`}function tg(e){return`/api/models/secrets/${encodeURIComponent(e)}`}var ng=`/api/integrations/claude-cli-status`,rg=`/api/integrations/install-claude-code`;function ig(e,t=``,n=globalThis.fetch.bind(globalThis)){let r=M(null),i=M(!1),a=M(null),o=M(!1),s=M(null),c=!0;va(()=>{c=!1});let l=async e=>{try{let i=await n(`${t}${ng}`);if(!c||e())return;if(!i.ok){N(a,`Could not check for Claude (status ${i.status}).`);return}let o=await i.json();if(!c||e())return;N(r,o.presence,!0),N(a,null)}catch(t){if(!c||e())return;N(a,t instanceof Error?t.message:String(t),!0)}finally{c&&!e()&&N(i,!1)}};return L(()=>{if(!e()){N(i,!1);return}let t=!1;return N(i,!0),l(()=>t),()=>{t=!0}}),{get presence(){return z(r)},get loading(){return z(i)},get error(){return z(a)},get installing(){return z(o)},get installError(){return z(s)},install:async()=>{if(!c)return null;N(o,!0),N(s,null);try{let e=await n(`${t}${rg}`,{method:`POST`});if(!c)return null;if(!e.ok){let t=await e.json().catch(()=>null);return c&&N(s,ag(e.status,t),!0),null}let i=await e.json();return c?(N(r,i.presence,!0),i.presence===`NOT_INSTALLED`&&N(s,`The installer finished but Claude wasn't detected yet. Open a new terminal and click "Check again", or install Claude Code manually.`),i.presence):null}catch(e){return c&&N(s,e instanceof Error?e.message:String(e),!0),null}finally{c&&N(o,!1)}},refetch:async()=>{c&&(N(i,!0),N(s,null),await l(()=>!1))}}}function ag(e,t){let n=t??null;if(n?.code===`UNSUPPORTED_PLATFORM`)return`Automatic install isn't available on this operating system. Install Claude Code manually, then check again.`;if(n?.code===`INSTALL_IN_PROGRESS`)return`An install is already in progress.`;let r=n?.stderrTail?.trim();return r?`Install failed (exit ${typeof n?.exitCode==`number`?n.exitCode:`?`}). ${r}`:n?.message??`Install failed (status ${e}).`}var og=`Tauri runtime not available`;async function sg(){try{return(await Ul(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return Lm()&&console.error(`[keychain] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(og)))}}function cg(e,t,n){return e(`keychain_set`,{account:t,secret:n})}function lg(e,t){return e(`keychain_delete`,{account:t})}function ug(e={}){let t=e.fetchFn??((...e)=>globalThis.fetch(...e)),n=e.baseUrl??``,r=e.pathFor??eg;return{async set(e,i){try{let a=await t(`${n}${r(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({secret:i})});return a.status===503&&(await a.json().catch(()=>null))?.code===`KEYCHAIN_UNAVAILABLE`?{status:`unavailable`}:a.ok?{status:`ok`}:{status:`error`,message:`HTTP ${a.status}`}}catch(e){return{status:`error`,message:e instanceof Error?e.message:String(e)}}},async delete(e){await t(`${n}${r(e)}`,{method:`DELETE`}).catch(()=>{})}}}var dg=[`keychain-init`,`Platform secure storage failure`,`Couldn't access platform secure storage`];function fg(e){return dg.some(t=>e.includes(t))}function pg(e={}){let t=()=>e.invoke?Promise.resolve(e.invoke):sg();return{async set(e,n){try{return await cg(await t(),e,n),{status:`ok`}}catch(e){let t=e instanceof Error?e.message:String(e);return fg(t)?{status:`unavailable`}:{status:`error`,message:t}}},async delete(e){try{await lg(await t(),e)}catch{}}}}function mg(e={}){return e.force===`tauri`||e.force!==`http`&&Lm()?pg({invoke:e.invoke}):ug({fetchFn:e.fetchFn,baseUrl:e.baseUrl,pathFor:e.pathFor})}function hg(e){return e.tandemValidation!==void 0&&e.tandemValidation.status!==`valid`}function gg(e){return(e.status===`ok`||e.status===`missing`)&&!hg(e)}function _g(e){return`${e}-${crypto.randomUUID().replace(/-/g,``).slice(0,12)}`}function vg(e){return`${e}-${crypto.randomUUID().slice(0,8)}`}function yg(e){if(e.target.kind===`claude-code`){let t=e.tandemEntry?.url??`http://127.0.0.1:3479`,n=vg(`claude-code`);return{id:n,config:{kind:`claude-code`,id:n,label:e.target.label,configPath:e.target.configPath,transport:`http`,url:t},hasStoredSecret:!1,keychainUnavailable:!1}}if(e.target.kind===`claude-desktop`){let t=vg(`claude-desktop`);return{id:t,config:{kind:`claude-desktop`,id:t,label:e.target.label,configPath:e.target.configPath,transport:`stdio`},hasStoredSecret:!1,keychainUnavailable:!1}}return null}function bg(e={}){let t=e.fetchFn??globalThis.fetch.bind(globalThis),n=e.baseUrl??``,r=e.keychainBackend??mg({fetchFn:t,baseUrl:n}),i=M(`connect`),a=M(!0),o=M(un([])),s=M(un([])),c=M(null),l=M(un([])),u=M(!1),d=0,f=e=>{N(c,e,!0),N(i,`error`),N(a,!1)},p=async()=>{let e=++d;N(a,!0),N(i,`connect`),N(c,null);try{let r=await t(`${n}${Xh}`);if(e!==d)return;if(!r.ok){f(`Could not load existing entries (HTTP ${r.status}).`);return}let i=await r.json();if(e!==d)return;N(o,i.installs,!0),N(s,i.installs.filter(gg).map(yg).filter(e=>e!==null),!0)}catch(t){if(e!==d)return;if(t instanceof TypeError&&/fetch|load failed|network/i.test(t.message)){f(`Could not reach the Tandem server. Make sure Tandem is running, then try again.`);return}f(t instanceof Error?t.message:String(t))}finally{e===d&&N(a,!1)}},m=e=>{let t=z(s).filter(t=>t.config.tokenSecretRef&&!e.some(e=>e.id===t.id));N(s,e,!0);for(let e of t){let t=e.config.tokenSecretRef;t&&r.delete(t)}},h=async(e,t)=>{let n=_g(e.id),i=await r.set(n,t);if(i.status===`unavailable`){N(u,!0),N(s,z(s).map(t=>t.id===e.id?{...t,keychainUnavailable:!0}:t),!0);return}if(i.status===`error`){r.delete(n),f(`Could not store secret: ${i.message}`);return}N(s,z(s).map(t=>t.id===e.id?{...t,config:{...t.config,tokenSecretRef:n},hasStoredSecret:!0,keychainUnavailable:!1}:t),!0)},g=async()=>{let e=z(s).map(e=>e.config.tokenSecretRef).filter(e=>typeof e==`string`&&e.length>0);await Promise.all(e.map(e=>r.delete(e)))};return{get step(){return z(i)},get detecting(){return z(a)},get existing(){return z(o)},get picked(){return z(s)},get errorMessage(){return z(c)},get applyResults(){return z(l)},get keychainUnavailable(){return z(u)},begin:p,setPicked:m,submitSecret:h,save:async()=>{N(i,`applying`);let e={schemaVersion:3,integrations:z(s).map(e=>{if(e.config.kind===`other-mcp`)return{...e.config,apply:`skip`};let t=e.config.configPath,n=z(o).find(e=>e.target.configPath===t),r=n!==void 0&&hg(n);return{...e.config,apply:r?`skip`:`create`}})},r=!1;try{let a=await t(`${n}${Zh}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});if(!a.ok){let e=await a.json().catch(()=>null);await g(),f(e?.message??`Could not save (HTTP ${a.status}).`);return}r=!0;let o=await a.json(),s=await t(`${n}${Qh}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:o.ids,confirmationNonce:o.confirmationNonce})});if(!s.ok){f((await s.json().catch(()=>null))?.message??`Could not apply (HTTP ${s.status}).`);return}N(l,(await s.json()).results,!0),N(i,`done`)}catch(e){r||await g(),f(e instanceof Error?e.message:String(e))}},reset:()=>{N(i,`connect`),N(a,!1),N(o,[],!0),N(s,[],!0),N(c,null),N(l,[],!0),N(u,!1)},cleanupUnsavedSecrets:async()=>{z(i)===`connect`&&await g()}}}var xg=Jr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" class="svelte-q7klwd"><path d="M4 5h16a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z"></path><path d="M7 9l3 3-3 3"></path><path d="M13 15h4"></path></svg>`),Sg=Jr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" class="svelte-q7klwd"><path d="M3 5h18a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z"></path><path d="M2 9h20"></path></svg>`),Cg=Jr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-q7klwd"><path d="M5 13l4 4L19 7"></path></svg>`),wg=V(`<span class="itc-check-empty svelte-q7klwd"></span>`),Tg=V(`<label><input type="checkbox" class="itc-checkbox svelte-q7klwd"/> <span class="itc-icon svelte-q7klwd" aria-hidden="true"><!></span> <span class="itc-text svelte-q7klwd"><span class="itc-name svelte-q7klwd"> </span> <span> </span> <span class="itc-path svelte-q7klwd"> </span></span> <span class="itc-check svelte-q7klwd" aria-hidden="true"><!></span></label>`);function Eg(e,t){k(t,!0);let n=j(()=>gg(t.install)),r=j(()=>t.install.target.configPath.replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase()),i=j(()=>t.install.status===`error`?{text:t.install.errorMessage?`Couldn't check this one — ${t.install.errorMessage}`:`Couldn't check this one`,family:`error`}:t.install.status===`malformed`?{text:`Settings file couldn't be read — we'll leave it alone`,family:`warning`}:t.install.tandemEntry===void 0?t.install.status===`missing`?{text:`Ready to connect (settings file will be created)`,family:null}:{text:`Ready to connect`,family:null}:hg(t.install)?{text:`Has a custom setup — we won't touch it`,family:`warning`}:{text:`Already connected — we'll refresh it`,family:`success`});var a=Tg();let o;var s=P(a);$i(s);var c=I(s,2),l=P(c),u=e=>{H(e,xg())},d=e=>{H(e,Sg())};W(l,e=>{t.install.target.kind===`claude-code`?e(u):e(d,-1)}),D(c);var f=I(c,2),p=P(f),m=P(p,!0);D(p);var h=I(p,2),g=P(h,!0);D(h);var _=I(h,2),v=P(_,!0);D(_),D(f);var y=I(f,2),b=P(y),x=e=>{var n=Xr(),r=F(n),i=e=>{H(e,Cg())},a=e=>{H(e,wg())};W(r,e=>{t.selected?e(i):e(a,-1)}),H(e,n)};W(b,e=>{z(n)&&e(x)}),D(y),D(a),R(()=>{o=Ui(a,1,`itc-card svelte-q7klwd`,null,o,{"is-selected":t.selected,"is-locked":!z(n)}),K(a,`data-testid`,`integration-wizard-card-${z(r)??``}`),ta(s,t.selected),s.disabled=!z(n),K(s,`data-testid`,`integration-wizard-pick-${z(r)??``}`),U(m,t.install.target.label),Ui(h,1,`itc-status itc-status-${z(i).family??`neutral`??``}`,`svelte-q7klwd`),U(g,z(i).text),U(v,t.install.target.configPath)}),B(`change`,s,function(...e){t.onToggle?.apply(this,e)}),H(e,a),A()}Br([`change`]);var Dg=(e,t=m)=>{var n=jg();R(()=>Ui(n,0,Li(t()),`svelte-bt94ms`)),H(e,n)},Og=e=>{H(e,Mg())},kg=e=>{H(e,Ng())},Ag=(e,t=m)=>{var n=Pg(),r=I(P(n));D(n),R(()=>U(r,` ${t()??``}`)),H(e,n)},jg=Jr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3l9 16H3z" class="svelte-bt94ms"></path><path d="M12 9v4" class="svelte-bt94ms"></path><path d="M12 17h.01" class="svelte-bt94ms"></path></svg>`),Mg=Jr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bt94ms"><path d="M5 13l4 4L19 7" class="svelte-bt94ms"></path></svg>`),Ng=Jr(`<svg class="iw-chevron svelte-bt94ms" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6" class="svelte-bt94ms"></path></svg>`),Pg=V(`<div class="iw-loading svelte-bt94ms" aria-live="polite"><span class="iw-dots svelte-bt94ms" aria-hidden="true"><span class="iw-dot svelte-bt94ms"></span><span class="iw-dot svelte-bt94ms"></span><span class="iw-dot svelte-bt94ms"></span></span> </div>`),Fg=V(`<p class="iw-subtitle svelte-bt94ms">Connect your AI assistant.</p>`),Ig=V(`<p class="iw-subtitle svelte-bt94ms">Let a teammate's Claude join from the Cowork VM.</p>`),Lg=V(`<div class="iw-whats-next svelte-bt94ms"><!> <span class="svelte-bt94ms">Cowork is enabled. Manage workspaces in Settings → Network.</span></div>`),Rg=V(`<p class="iw-hint-text svelte-bt94ms" data-testid="cowork-vethernet-cidr">Detected Cowork environment: <code class="iw-code-inline svelte-bt94ms"> </code></p>`),zg=V(`<p class="iw-hint-text svelte-bt94ms">A previous attempt couldn't update Windows Firewall (that needs administrator
|
|
58
|
-
rights). Enabling writes the workspace plugin entries either way.</p>`),Bg=V(`<div class="iw-banner-warning svelte-bt94ms"><!> <span class="svelte-bt94ms">Tandem writes plugin entries to every detected Cowork workspace so Claude running
|
|
59
|
-
in Cowork can reach the documents you have open.</span></div> <!> <!>`,1),Vg=V(`<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-cowork-error"><!> <span class="svelte-bt94ms"> </span></div>`),Hg=V(`<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-cowork-step"><!> <!></section>`),Ug=V(`<div class="iw-banner-warning svelte-bt94ms" role="alert" data-testid="integration-wizard-install-error"><!> <span class="svelte-bt94ms"> </span></div>`),Wg=V(`<p class="iw-hint-text svelte-bt94ms">Don't have Claude Code yet? Install it now — a small, signed download
|
|
60
|
-
straight from Anthropic.</p> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-install-claude"> </button> <!>`,1),Gg=V(`<div class="iw-whats-next svelte-bt94ms" data-testid="integration-wizard-install-success"><!> <span class="svelte-bt94ms">Claude Code is installed. Open a new terminal and run <code class="svelte-bt94ms">claude</code> once, then choose “Check again”.</span></div>`),Kg=V(`<div class="iw-empty svelte-bt94ms" data-testid="integration-wizard-empty"><p class="iw-empty-title svelte-bt94ms">We couldn't find Claude on this computer.</p> <!> <p class="iw-hint-text svelte-bt94ms">If you use Claude Code or Claude Desktop, open it once, then check again. To
|
|
61
|
-
connect a different MCP-compatible app manually, point it at:</p> <code class="iw-code svelte-bt94ms"> </code></div>`),qg=V(`<div class="iw-banner-warning svelte-bt94ms" data-testid="integration-wizard-keychain-fallback"><!> <span class="svelte-bt94ms">Your operating system's secure storage isn't reachable from this Tandem
|
|
62
|
-
build, so tokens entered here can't be saved. Set the environment
|
|
63
|
-
variable <code class="iw-code-inline svelte-bt94ms">TANDEM_INTEGRATION_<id>_TOKEN</code> instead, or add the token in your AI client's own configuration.</span></div>`),Jg=V(`<span class="iw-secret-stored svelte-bt94ms"><!> Token saved</span>`),Yg=V(`<span class="iw-secret-skipped svelte-bt94ms">Skipped (secure storage unavailable)</span>`),Xg=V(`<div class="iw-secret-input svelte-bt94ms"><input type="password" placeholder="Paste access token" class="svelte-bt94ms"/> <button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Save token</button></div>`),Zg=V(`<div class="iw-secret-row svelte-bt94ms"><span class="iw-secret-label svelte-bt94ms"> </span> <!></div>`),Qg=V(`<details class="iw-advanced svelte-bt94ms" data-testid="integration-wizard-advanced"><summary class="svelte-bt94ms"><!> Advanced — set an access token</summary> <div class="iw-advanced-body svelte-bt94ms"><p class="iw-hint-text svelte-bt94ms">Only needed if you've changed Tandem to listen on your network instead of
|
|
64
|
-
just this computer. Most people can skip this. Tokens are stored in your
|
|
65
|
-
operating system's secure storage.</p> <!> <!></div></details>`),$g=V(`<p class="iw-intro svelte-bt94ms">We'll add a small entry to Claude's settings file so Claude can read and edit the
|
|
66
|
-
documents you have open in Tandem. Nothing else is touched, and you can undo this
|
|
67
|
-
any time.</p> <div class="iw-cards svelte-bt94ms"></div> <!>`,1),e_=V(`<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-step-detect"><!> <p class="iw-hint-text iw-reopen-hint svelte-bt94ms" data-testid="integration-wizard-reopen-hint">Not now? You can reopen this wizard anytime from Settings → AI Assistant.</p></section>`),t_=V(`<section class="iw-step iw-center svelte-bt94ms" data-testid="integration-wizard-step-applying"><!> <p class="iw-hint-text svelte-bt94ms">Updating Claude's settings file. This takes a second.</p></section>`),n_=V(`<span class="iw-result-detail svelte-bt94ms">Connected</span>`),r_=V(`<span class="iw-result-detail svelte-bt94ms">Left unchanged (already set up, or couldn't be safely edited)</span>`),i_=V(`<span class="iw-result-detail svelte-bt94ms"> </span>`),a_=V(`<div><span class="iw-result-mark svelte-bt94ms" aria-hidden="true"><!></span> <span class="iw-result-text svelte-bt94ms"><span class="iw-result-name svelte-bt94ms"> </span> <!></span></div>`),o_=V(`<div class="iw-results svelte-bt94ms"></div>`),s_=V(`<section class="iw-step svelte-bt94ms" data-testid="integration-wizard-step-done"><div class="iw-done-header svelte-bt94ms"><svg class="iw-done-check svelte-bt94ms" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path class="iw-check-path svelte-bt94ms" d="M4 13l5 5L20 7"></path></svg> <h3 class="iw-done-title svelte-bt94ms"> </h3></div> <!> <div class="iw-whats-next svelte-bt94ms"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-bt94ms"><circle cx="12" cy="12" r="9" class="svelte-bt94ms"></circle><path d="M12 11v5" class="svelte-bt94ms"></path><path d="M12 8h.01" class="svelte-bt94ms"></path></svg> <span class="svelte-bt94ms">Restart Claude Code, then type <code class="iw-code-inline svelte-bt94ms">/mcp</code> to verify —
|
|
68
|
-
or just ask Claude to open a document.</span></div></section>`),c_=V(`<p class="iw-hint-text svelte-bt94ms"> </p>`),l_=V(`<details class="iw-tech-details svelte-bt94ms"><summary class="svelte-bt94ms"><!> Technical details</summary> <pre class="iw-tech-text svelte-bt94ms"> </pre></details>`),u_=V(`<section class="iw-step iw-center svelte-bt94ms" data-testid="integration-wizard-step-error"><!> <h3 class="iw-error-title svelte-bt94ms">Something went wrong while connecting</h3> <!> <!></section>`),d_=V(`<span class="iw-more-badge svelte-bt94ms"><!> Enabled</span>`),f_=V(`<button type="button" class="iw-btn iw-btn-secondary iw-more-btn svelte-bt94ms" aria-label="Set up Cowork" data-testid="integration-wizard-cowork-setup">Set up</button>`),p_=V(`<div class="iw-more-row svelte-bt94ms"><div class="iw-more-row-text svelte-bt94ms"><span class="iw-more-row-name svelte-bt94ms">Cowork</span> <span class="iw-more-row-detail svelte-bt94ms"> </span></div> <!></div>`),m_=V(`<div class="iw-more-row iw-more-row-disabled svelte-bt94ms"><div class="iw-more-row-text svelte-bt94ms"><span class="iw-more-row-name svelte-bt94ms">AI models</span> <span class="iw-more-row-detail svelte-bt94ms">Bring your own model — coming soon</span></div></div>`),h_=V(`<section class="iw-more svelte-bt94ms" data-testid="integration-wizard-more"><div class="iw-more-label svelte-bt94ms">More integrations</div> <!> <!></section>`),g_=V(`<!> <!>`,1),__=V(`<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms">Done</button>`),v_=V(`<button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="cowork-enable-confirm-btn"> </button>`),y_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-cowork-back">Back</button> <!>`,1),b_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Cancel</button>`),x_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Close</button> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-check-again">Check again</button>`,1),S_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Not now</button> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-connect-btn"> </button>`,1),C_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" disabled="">Connecting…</button>`),w_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms" data-testid="integration-wizard-done-retry">Try again</button>`),T_=V(`<!> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-done-close">Done</button>`,1),E_=V(`<button type="button" class="iw-btn iw-btn-secondary svelte-bt94ms">Close</button> <button type="button" class="iw-btn iw-btn-primary svelte-bt94ms" data-testid="integration-wizard-error-retry">Try again</button>`,1),D_=V(`<div role="presentation" class="iw-scrim svelte-bt94ms" data-testid="integration-wizard"><div role="dialog" aria-modal="true" aria-label="Integration Setup Wizard" tabindex="-1" class="iw-dialog svelte-bt94ms"><header class="iw-header svelte-bt94ms"><div class="iw-header-text svelte-bt94ms"><h2 class="iw-title svelte-bt94ms"> </h2> <!></div> <button type="button" class="iw-close svelte-bt94ms" aria-label="Close wizard" data-testid="integration-wizard-close">×</button></header> <div class="iw-body svelte-bt94ms"><!></div> <footer class="iw-footer svelte-bt94ms"><!></footer></div></div>`);function O_(e,t){k(t,!0);let n=bg({baseUrl:`http://127.0.0.1:${xa}`}),r=Zm(()=>Lm()),i=j(()=>Em(r.status)),a=ig(()=>t.open&&n.step===`connect`,`http://127.0.0.1:${xa}`),o=j(()=>a.presence===`NOT_INSTALLED`),s=j(()=>a.presence===`INSTALLED_NOT_ON_PATH`),c=M(`main`),l=M(!1),u=M(null),d=M(null),f=null,p=M(un({}));L(()=>{if(!t.open)return;let e=Ar(()=>z(d));if(e)return f=document.activeElement,e.focus(),()=>{f instanceof HTMLElement&&document.contains(f)&&f.focus()}}),L(()=>{t.open&&(N(c,`main`),n.begin())});async function m(){N(l,!0),N(u,null);try{await Hm(await Bm(),!0),await r.refetch(),N(c,`main`)}catch(e){N(u,Am(e instanceof Error?e.message:String(e)),!0)}finally{N(l,!1)}}let h=j(()=>{if(z(i)===`loading`)return`Checking…`;if(z(i)===`unsupported`)return`Coming soon to macOS & Linux`;if(z(i)===`undetected`){let e=r.status,t=e?Dm(e):`noClaude`;return t===`blocked`?`Found in a network-redirected or synced location Tandem can't safely configure`:t===`noWorkspacesYet`?`Claude Desktop detected — run a Cowork session once, then set up here`:`Not detected on this computer`}let e=r.status;return e?.enabled?`Connected — token provisioned`:e?.uacDeclined?`Setup didn't complete last time — try again from here`:`Let a teammate's Claude join from the Cowork VM`});L(()=>{if(!t.open)return;let e=e=>{e.key===`Escape`&&g()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});function g(){n.cleanupUnsavedSecrets().catch(()=>{}),n.reset(),N(p,{},!0),t.onClose()}function _(){n.reset(),N(p,{},!0),n.begin(),a.refetch(),r.refetch()}async function v(){let e=await a.install();e&&e!==`NOT_INSTALLED`&&n.begin()}function y(e){if(e.key!==`Tab`||!z(d))return;let t=Array.from(z(d).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null);if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||i===z(d))?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())}function b(e){let t=n.picked.findIndex(t=>t.config.configPath===e.target.configPath);if(t>=0){n.setPicked(n.picked.filter((e,n)=>n!==t));return}let r=yg(e);r&&n.setPicked([...n.picked,r])}function x(e){return n.picked.some(t=>t.config.configPath===e.target.configPath)}async function S(e){let t=z(p)[e.id]??``;t.length!==0&&(await n.submitSecret(e,t),z(p)[e.id]=``)}let C=/HTTP 5\d\d/,w=/HTTP 4\d\d/,ee=/fetch|network|Failed to/i,T=j(()=>n.picked.length===1?`Connect ${n.picked[0].config.label}`:`Connect selected`);function te(e){return n.picked.find(t=>t.id===e.id)?.config.label??`Unknown`}function ne(e){switch(e.code){case`WRITE_FAILED`:return`Couldn't write the settings file — check it isn't open in another program, then try again.`;case`SECRET_MISSING`:return`The access token wasn't found — re-enter it under Advanced and try again.`;case`TARGET_NOT_DETECTED`:return`This assistant's settings file couldn't be found anymore — it may have moved.`;case`PATH_REJECTED`:return`The settings file is in an unexpected location, so Tandem left it alone for safety.`;case`OTHER_MCP_NOT_APPLICABLE`:return`Tandem can't auto-configure this app — connect it manually from that app's settings.`;default:return e.message??`Something went wrong applying this one.`}}let E=j(()=>{let e=n.errorMessage??``;return C.test(e)?`Tandem's helper isn't responding. Make sure Tandem is running, then try again.`:w.test(e)?`Tandem couldn't save the connection. Try again in a moment.`:ee.test(e)?`Couldn't reach Tandem — is it still running?`:null}),re=j(()=>n.applyResults.some(e=>e.status===`error`));var ie=Xr(),ae=F(ie),oe=e=>{var t=D_(),f=P(t),C=P(f),w=P(C),ee=P(w),ie=P(ee,!0);D(ee);var ae=I(ee,2),oe=e=>{H(e,Fg())},se=e=>{H(e,Ig())};W(ae,e=>{z(c)===`main`&&n.step===`connect`?e(oe):z(c)===`cowork`&&e(se,1)}),D(w);var ce=I(w,2);D(C);var le=I(C,2),ue=P(le),de=e=>{var t=Hg(),n=P(t),i=e=>{var t=Lg();Og(P(t)),O(2),D(t),H(e,t)},a=e=>{var t=Bg(),n=F(t);Dg(P(n)),O(2),D(n);var i=I(n,2),a=e=>{var t=Rg(),n=I(P(t)),i=P(n,!0);D(n),D(t),R(()=>U(i,r.status.vethernetCidr)),H(e,t)};W(i,e=>{r.status?.vethernetCidr&&e(a)});var o=I(i,2),s=e=>{H(e,zg())};W(o,e=>{r.status?.uacDeclined&&e(s)}),H(e,t)};W(n,e=>{r.status?.enabled?e(i):e(a,-1)});var o=I(n,2),s=e=>{var t=Vg(),n=P(t);Dg(n);var r=I(n,2),i=P(r,!0);D(r),D(t),R(()=>U(i,z(u))),H(e,t)};W(o,e=>{z(u)&&e(s)}),D(t),H(e,t)},fe=e=>{var t=g_(),d=F(t),f=e=>{var t=e_(),r=P(t),i=e=>{Ag(e,()=>`Looking for Claude on your computer…`)},c=e=>{var t=Kg(),n=I(P(t),2),r=e=>{var t=Wg(),n=I(F(t),2),r=P(n,!0);D(n);var i=I(n,2),o=e=>{var t=Ug(),n=P(t);Dg(n);var r=I(n,2),i=P(r,!0);D(r),D(t),R(()=>U(i,a.installError)),H(e,t)};W(i,e=>{a.installError&&e(o)}),R(()=>{n.disabled=a.installing,U(r,a.installing?`Installing…`:`Install Claude Code`)}),B(`click`,n,v),H(e,t)},i=e=>{var t=Gg();Og(P(t)),O(2),D(t),H(e,t)};W(n,e=>{z(o)?e(r):z(s)&&e(i,1)});var c=I(n,4),l=P(c);D(c),D(t),R(()=>U(l,`http://127.0.0.1:3479/mcp`)),H(e,t)},l=e=>{var t=$g(),r=I(F(t),2);pi(r,21,()=>n.existing,e=>e.target.configPath,(e,t)=>{{let n=j(()=>x(z(t)));Eg(e,{get install(){return z(t)},get selected(){return z(n)},onToggle:()=>b(z(t))})}}),D(r);var i=I(r,2),a=e=>{var t=Qg(),r=P(t);kg(P(r)),O(),D(r);var i=I(r,2),a=I(P(i),2),o=e=>{var t=qg();Dg(P(t)),O(2),D(t),H(e,t)};W(a,e=>{n.keychainUnavailable&&e(o)}),pi(I(a,2),17,()=>n.picked,e=>e.id,(e,t)=>{var n=Zg(),r=P(n),i=P(r,!0);D(r);var a=I(r,2),o=e=>{var t=Jg();Og(P(t)),O(),D(t),H(e,t)},s=e=>{H(e,Yg())},c=e=>{var n=Xg(),r=P(n);$i(r);var i=I(r,2);D(n),R(()=>{K(r,`data-testid`,`integration-wizard-secret-input-${z(t).id??``}`),i.disabled=!z(p)[z(t).id],K(i,`data-testid`,`integration-wizard-secret-submit-${z(t).id??``}`)}),aa(r,()=>z(p)[z(t).id],e=>z(p)[z(t).id]=e),B(`click`,i,()=>S(z(t))),H(e,n)};W(a,e=>{z(t).hasStoredSecret?e(o):z(t).keychainUnavailable?e(s,1):e(c,-1)}),D(n),R(()=>U(i,z(t).config.label)),H(e,n)}),D(i),D(t),H(e,t)};W(i,e=>{n.picked.length>0&&e(a)}),H(e,t)};W(r,e=>{n.detecting?e(i):n.existing.length===0?e(c,1):e(l,-1)}),O(2),D(t),H(e,t)},m=e=>{var t=t_();Ag(P(t),()=>`Connecting Claude…`),O(2),D(t),H(e,t)},g=e=>{var t=s_(),r=P(t),i=I(P(r),2),a=P(i,!0);D(i),D(r);var o=I(r,2),s=e=>{var t=o_();pi(t,21,()=>n.applyResults,e=>e.id,(e,t)=>{var n=a_(),r=P(n),i=P(r),a=e=>{Og(e)},o=e=>{H(e,Yr(`—`))},s=e=>{Dg(e)};W(i,e=>{z(t).status===`applied`?e(a):z(t).status===`skipped`?e(o,1):e(s,-1)}),D(r);var c=I(r,2),l=P(c),u=P(l,!0);D(l);var d=I(l,2),f=e=>{H(e,n_())},p=e=>{H(e,r_())},m=e=>{var n=i_(),r=P(n,!0);D(n),R(e=>U(r,e),[()=>ne(z(t))]),H(e,n)};W(d,e=>{z(t).status===`applied`?e(f):z(t).status===`skipped`?e(p,1):e(m,-1)}),D(c),D(n),R(e=>{Ui(n,1,`iw-result iw-result-${z(t).status??``}`,`svelte-bt94ms`),K(n,`data-testid`,`integration-wizard-apply-result-${z(t).id??``}`),U(u,e)},[()=>te(z(t))]),H(e,n)}),D(t),H(e,t)};W(o,e=>{n.applyResults.length>0&&e(s)}),O(2),D(t),R(()=>U(a,z(re)?`Partly connected`:`Claude is connected to Tandem`)),H(e,t)},_=e=>{var t=u_(),r=P(t);Dg(r,()=>`iw-error-icon`);var i=I(r,4),a=e=>{var t=c_(),n=P(t,!0);D(t),R(()=>U(n,z(E))),H(e,t)};W(i,e=>{z(E)&&e(a)});var o=I(i,2),s=e=>{var t=l_(),r=P(t);kg(P(r)),O(),D(r);var i=I(r,2),a=P(i,!0);D(i),D(t),R(()=>U(a,n.errorMessage)),H(e,t)};W(o,e=>{n.errorMessage&&e(s)}),D(t),H(e,t)};W(d,e=>{n.step===`connect`?e(f):n.step===`applying`?e(m,1):n.step===`done`?e(g,2):n.step===`error`&&e(_,3)});var y=I(d,2),C=e=>{var t=h_(),n=I(P(t),2),a=e=>{var t=p_(),n=P(t),a=I(P(n),2),o=P(a,!0);D(a),D(n);var s=I(n,2),d=e=>{var t=d_();Og(P(t)),O(),D(t),H(e,t)},f=e=>{var t=f_();B(`click`,t,()=>{N(u,null),N(l,!1),N(c,`cowork`)}),H(e,t)};W(s,e=>{r.status?.enabled?e(d):z(i)===`normal`&&e(f,1)}),D(t),R(()=>U(o,z(h))),H(e,t)},o=j(()=>Lm());W(n,e=>{z(o)&&e(a)});var s=I(n,2),d=e=>{H(e,m_())};W(s,e=>{e(d)}),D(t),H(e,t)};W(y,e=>{(n.step===`connect`||n.step===`done`)&&e(C)}),H(e,t)};W(ue,e=>{z(c)===`cowork`?e(de):e(fe,-1)}),D(le);var pe=I(le,2),me=P(pe),he=e=>{var t=y_(),n=F(t),i=I(n,2),a=e=>{var t=__();B(`click`,t,()=>N(c,`main`)),H(e,t)},o=e=>{var t=v_(),n=P(t,!0);D(t),R(()=>{t.disabled=z(l),U(n,z(l)?`Enabling…`:`Enable Cowork`)}),B(`click`,t,m),H(e,t)};W(i,e=>{r.status?.enabled?e(a):e(o,-1)}),R(()=>n.disabled=z(l)),B(`click`,n,()=>N(c,`main`)),H(e,t)},ge=e=>{var t=Xr(),r=F(t),i=e=>{var t=b_();B(`click`,t,g),H(e,t)},a=e=>{var t=x_(),n=F(t),r=I(n,2);B(`click`,n,g),B(`click`,r,_),H(e,t)},o=e=>{var t=S_(),r=F(t),i=I(r,2),a=P(i,!0);D(i),R(()=>{i.disabled=n.picked.length===0,U(a,z(T))}),B(`click`,r,g),B(`click`,i,()=>n.save()),H(e,t)};W(r,e=>{n.detecting?e(i):n.existing.length===0?e(a,1):e(o,-1)}),H(e,t)},_e=e=>{H(e,C_())},ve=e=>{var t=T_(),n=F(t),r=e=>{var t=w_();B(`click`,t,_),H(e,t)};W(n,e=>{z(re)&&e(r)}),B(`click`,I(n,2),g),H(e,t)},ye=e=>{var t=E_(),n=F(t),r=I(n,2);B(`click`,n,g),B(`click`,r,_),H(e,t)};W(me,e=>{z(c)===`cowork`?e(he):n.step===`connect`?e(ge,1):n.step===`applying`?e(_e,2):n.step===`done`?e(ve,3):n.step===`error`&&e(ye,4)}),D(pe),D(f),fa(f,e=>N(d,e),()=>z(d)),D(t),R(()=>U(ie,z(c)===`cowork`?`Set up Cowork`:`Connect Claude to Tandem`)),B(`click`,t,e=>{e.target===e.currentTarget&&g()}),B(`keydown`,f,e=>{if(e.key===`Escape`){e.stopPropagation(),g();return}if(e.key===`Tab`){y(e);return}e.stopPropagation()}),B(`click`,ce,g),H(e,t)};W(ae,e=>{t.open&&e(oe)}),H(e,ie),A()}Br([`click`,`keydown`]);function k_(e){return e.trial?.daysRemaining??e.daysRemaining??null}function A_(e){if(!e||!e.gateActive)return{editable:!0,showWall:!1,showTrialBanner:!1,trialDaysRemaining:null,statusLabel:``};if(e.status===`restricted`)return{editable:!1,showWall:!0,showTrialBanner:!1,trialDaysRemaining:null,statusLabel:`Trial ended`};if(e.status===`trial`){let t=k_(e);return{editable:!0,showWall:!1,showTrialBanner:!0,trialDaysRemaining:t,statusLabel:t==null?`Trial`:`Trial — ${t} day${t===1?``:`s`} left`}}return{editable:!0,showWall:!1,showTrialBanner:!1,trialDaysRemaining:null,statusLabel:e.license?.name?`Licensed to ${e.license.name}`:`Licensed`}}async function j_(e){let t=await fetch(`${Il}${Lc}`,{signal:e});if(!t.ok)throw Error(`${Lc} responded ${t.status} ${t.statusText}`);return await t.json()}async function M_(e){try{let t=await fetch(`${Il}${Rc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({license:e})}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,state:n}:{ok:!1,error:n.message??`Activation failed.`}}catch{return{ok:!1,error:`Server unavailable.`}}}var N_=6e4;function P_(){let e=M(null),t=j(()=>A_(z(e))),n=!1,r=null,i=null,a=null;function o(e){return e.gateActive&&e.status===`restricted`}function s(e){a!==null&&e!==a&&i?.(),a=e}function c(){r&&=(clearInterval(r),null),n=!1,i=null,a=null}async function l(){try{let t=await j_();N(e,t,!0),s(o(t)),t.gateActive||c()}catch{}}return{get status(){return z(e)},get ui(){return z(t)},start(e){n||(n=!0,i=e?.onTransition??null,l(),r=setInterval(()=>void l(),N_))},stop:c,refresh(){return l()},set(t){N(e,t,!0),s(o(t))}}}var F_=P_(),I_=V(`<strong data-testid="license-trial-days" class="svelte-ae26fd"> </strong> `,1),L_=V(`<div class="license-trial-banner svelte-ae26fd" role="status" aria-live="polite" data-testid="license-trial-banner"><span class="license-trial-banner__text svelte-ae26fd"><!> Activate a license in Settings → License to keep editing when it ends.</span></div>`);function R_(e,t){k(t,!0);let n=j(()=>F_.ui);var r=Xr(),i=F(r),a=e=>{var t=L_(),r=P(t),i=P(r),a=e=>{var t=I_(),r=F(t),i=P(r,!0);D(r);var a=I(r);R(()=>{U(i,z(n).trialDaysRemaining),U(a,` ${z(n).trialDaysRemaining===1?`day`:`days`} left in your Tandem trial.`)}),H(e,t)},o=e=>{H(e,Yr(`You're trying Tandem.`))};W(i,e=>{z(n).trialDaysRemaining==null?e(o,-1):e(a)}),O(),D(r),D(t),H(e,t)};W(i,e=>{z(n).showTrialBanner&&e(a)}),H(e,r),A()}var z_=V(`<div class="license-activate__error svelte-1yvc9ue" data-testid="license-activate-error" role="alert"> </div>`),B_=V(`<div class="license-activate svelte-1yvc9ue"><textarea data-testid="license-activate-input" class="license-activate__input svelte-1yvc9ue" placeholder="Paste your license key" spellcheck="false"></textarea> <!> <button type="button" class="license-activate__submit svelte-1yvc9ue" data-testid="license-activate-submit"> </button></div>`);function V_(e,t){k(t,!0);let n=M(``),r=M(null),i=M(!1);async function a(){let e=z(n).trim();if(!e){N(r,`Paste your license key first.`);return}N(i,!0),N(r,null);let a=await M_(e);N(i,!1),a.ok?(F_.set(a.state),N(n,``),t.onActivated?.()):N(r,a.error,!0)}var o=B_(),s=P(o);En(s),K(s,`rows`,4);var c=I(s,2),l=e=>{var t=z_(),n=P(t,!0);D(t),R(()=>U(n,z(r))),H(e,t)};W(c,e=>{z(r)&&e(l)});var u=I(c,2),d=P(u,!0);D(u),D(o),R(()=>{s.disabled=z(i),u.disabled=z(i),U(d,z(i)?`Activating…`:`Activate license`)}),aa(s,()=>z(n),e=>N(n,e)),B(`click`,u,()=>void a()),H(e,o),A()}Br([`click`]);var H_=V(`<div class="license-wall-backdrop svelte-1or3b6b" data-testid="license-wall" role="dialog" aria-modal="true" aria-labelledby="license-wall-heading"><div class="license-wall-dialog svelte-1or3b6b"><h2 class="license-wall-heading svelte-1or3b6b" id="license-wall-heading">Your trial has ended</h2> <p class="license-wall-body svelte-1or3b6b">Activate a license to keep editing. Your documents stay open — you can still read and
|
|
69
|
-
export them, and chat with Claude.</p> <!></div></div>`);function U_(e,t){k(t,!0);let n=j(()=>F_.ui);var r=Xr(),i=F(r),a=e=>{var t=H_(),n=P(t);V_(I(P(n),4),{}),D(n),D(t),H(e,t)};W(i,e=>{z(n).showWall&&e(a)}),H(e,r),A()}var W_=e=>e;function G_(e,{delay:t=0,duration:n=400,easing:r=W_}={}){let i=+getComputedStyle(e).opacity;return{delay:t,duration:n,easing:r,css:e=>`opacity: ${e*i}`}}var K_=null;function q_(e){let t=e.decorationsMuted;try{localStorage.setItem(no,String(!t&&e.showAuthorship)),localStorage.setItem(ro,JSON.stringify({comment:!t&&e.showComments,highlight:!t&&e.showHighlights,note:!t&&e.showNotes}))}catch{}}function J_(){if(K_)return K_;let e=Nl(),t=M(un(e));return q_(e),K_={get settings(){return z(t)},updateSettings:e=>{if(z(t)._readOnly)return;let n=Pl(z(t),e);try{localStorage.setItem(Na,JSON.stringify(n))}catch{}q_(n),N(t,n,!0)}},K_}function Y_(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i,p=e=>{let t=e;for(let n=0;n<8;n++){let n=u(t)-e;if(Math.abs(n)<1e-5)return t;let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;t=e;for(let i=0;i<20;i++){let i=u(t)-e;if(Math.abs(i)<1e-5)break;i>0?r=t:n=t,t=(n+r)/2}return t};return e=>e<=0?0:e>=1?1:d(p(e))}var X_=Y_(.2,.8,.2,1),Z_=Y_(.4,0,.2,1),Q_=260,$_=260,ev=280;function tv(e){return e?!0:typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function nv(e){return{h:e.offsetHeight,mb:Number.parseFloat(getComputedStyle(e).marginBottom)||0}}function rv(e,{enabled:t,reduceMotion:n}){if(!t||tv(n))return{duration:0};let{h:r,mb:i}=nv(e);return{duration:Q_,easing:X_,css:(e,t)=>`opacity:${e}; transform:translateY(${-6*t}px); height:${e*r}px; margin-bottom:${e*i}px; overflow:clip; box-sizing:border-box;`}}function iv(e,{enabled:t,reduceMotion:n,id:r,modes:i}){let a=i?.get(r);if(i?.delete(r),!t||tv(n))return{duration:0};let{h:o,mb:s}=nv(e),c=e=>a===`accept`?`translateY(${-8*e}px)`:a===`dismiss`?`translateX(${40*e}px) scale(${1-.04*e})`:`none`;return{duration:$_,easing:X_,css:(e,t)=>`opacity:${e}; height:${e*o}px; margin-bottom:${e*s}px; transform:${c(t)}; overflow:clip; box-sizing:border-box;`}}function av(e,{reduceMotion:t}){if(tv(t))return{duration:0};let{h:n,mb:r}=nv(e);return{duration:ev,easing:X_,css:(e,t)=>`opacity:${e}; transform:translateY(${-8*t}px); height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box;`}}function ov(e,{reduceMotion:t,exitMs:n=200}){if(tv(t))return{duration:0};let{h:r,mb:i}=nv(e);return{duration:n,easing:Z_,css:(e,t)=>`opacity:${e}; transform:translateY(${-8*t}px); height:${e*r}px; margin-bottom:${e*i}px; overflow:clip; box-sizing:border-box;`}}var sv=new Map,cv=480,lv=1e3;function uv(e,t){sv.set(e,t),setTimeout(()=>sv.delete(e),lv)}function dv(e,{id:t,reduceMotion:n}){let r=sv.get(t);if(sv.delete(t),!r||tv(n))return{duration:0};let i=e.getBoundingClientRect(),a=r.left-i.left,o=r.top-i.top;return{duration:cv,easing:X_,css:(e,t)=>`transform:translate(${a*t}px, ${o*t}px); opacity:${.2+.8*e};`}}var fv=200;function pv(e,{reduceMotion:t}){if(tv(t))return{duration:0};let n=e.offsetWidth;return{duration:fv,easing:X_,css:e=>`opacity:${e}; width:${e*n}px; min-width:0; overflow:clip; box-sizing:border-box; pointer-events:none;`}}var mv=220;function hv(e,{reduceMotion:t}){if(tv(t))return{duration:0};let n=e.offsetWidth;return{duration:mv,easing:X_,css:e=>`opacity:${e}; width:${e*n}px; min-width:0; overflow:clip; box-sizing:border-box;`}}function gv(e,{reduceMotion:t}){if(tv(t))return{duration:0};let n=e.offsetWidth,r=e.offsetHeight;return{duration:440,easing:X_,css:e=>`opacity:${e}; width:${e*n}px; height:${e*r}px; overflow:clip; box-sizing:border-box;`}}var _v=380;function vv(e,{reduceMotion:t}){if(tv(t))return{duration:0};let{h:n,mb:r}=nv(e);return{duration:_v,easing:X_,css:e=>`opacity:${e}; height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box;`}}var yv=V(`Detected VM subnet: <code> </code>.`,1),bv=V(`<div class="cos-error svelte-1h0desi" data-testid="cowork-onboarding-error" role="alert"> </div>`),xv=V(`<div class="cos-confirm-banner svelte-1h0desi" data-testid="cowork-onboarding-confirm"><div class="cos-confirm-heading svelte-1h0desi">Confirm: Enable Cowork</div> <div class="cos-confirm-body svelte-1h0desi">Tandem will write plugin entries to every detected Cowork workspace so Claude running in
|
|
70
|
-
Cowork can reach the documents you have open.</div> <div class="cos-actions svelte-1h0desi"><button data-testid="cowork-onboarding-enable-confirm-btn" class="cos-btn cos-btn--primary svelte-1h0desi" type="button">Enable</button> <button data-testid="cowork-onboarding-enable-cancel-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Cancel</button></div></div>`),Sv=V(`<button data-testid="cowork-onboarding-learn-more-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Learn more</button>`),Cv=V(`<a class="cos-learn-more-link svelte-1h0desi" data-testid="cowork-onboarding-learn-more-link" target="_blank" rel="noreferrer">Learn more</a>`),wv=V(`<div class="cos-actions svelte-1h0desi"><button data-testid="cowork-onboarding-enable-btn" class="cos-btn cos-btn--primary svelte-1h0desi" type="button">Enable</button> <button data-testid="cowork-onboarding-skip-btn" class="cos-btn cos-btn--ghost svelte-1h0desi" type="button">Skip</button> <!></div>`),Tv=V(`<div class="cos-root svelte-1h0desi" data-testid="cowork-onboarding-step"><div class="cos-title svelte-1h0desi">Claude Desktop Cowork detected</div> <div class="cos-description svelte-1h0desi">Enable Tandem inside Cowork workspaces? <!></div> <!> <!></div>`);function Ev(e,t){k(t,!0);let n=M(!1),r=M(!1),i=M(null);async function a(e,t){N(r,!0),N(i,null);try{return await e(await Bm()),!0}catch(e){return N(i,`${t}: ${Am(e instanceof Error?e.message:String(e))}`),!1}finally{N(r,!1)}}async function o(){await a(async e=>{await Hm(e,!0)},`Failed to enable Cowork`)&&t.onAdvance()}function s(){Im(),t.onAdvance()}var c=Tv(),l=I(P(c),2),u=I(P(l)),d=e=>{var n=yv(),r=I(F(n)),i=P(r,!0);D(r),O(),R(()=>U(i,t.status.vethernetCidr)),H(e,n)};W(u,e=>{t.status.vethernetCidr!==null&&e(d)}),D(l);var f=I(l,2),p=e=>{var t=bv(),n=P(t,!0);D(t),R(()=>U(n,z(i))),H(e,t)};W(f,e=>{z(i)&&e(p)});var m=I(f,2),h=e=>{var t=xv(),i=I(P(t),4),a=P(i),s=I(a,2);D(i),D(t),R(()=>{a.disabled=z(r),s.disabled=z(r)}),B(`click`,a,()=>void o()),B(`click`,s,()=>{N(n,!1)}),H(e,t)},g=e=>{var i=wv(),a=P(i),o=I(a,2),c=I(o,2),l=e=>{var n=Sv();R(()=>n.disabled=z(r)),B(`click`,n,function(...e){t.onLearnMore?.apply(this,e)}),H(e,n)},u=e=>{var t=Cv();R(()=>K(t,`href`,`${Sa}#cowork`)),H(e,t)};W(c,e=>{t.onLearnMore?e(l):e(u,-1)}),D(i),R(()=>{a.disabled=z(r),o.disabled=z(r)}),B(`click`,a,()=>{N(n,!0)}),B(`click`,o,s),H(e,i)};W(m,e=>{z(n)?e(h):e(g,-1)}),D(c),H(e,c),A()}Br([`click`]);var Dv=V(`<div></div>`),Ov=V(`<div style="display: flex; gap: var(--tandem-space-1); margin-bottom: var(--tandem-space-3);" class="svelte-1us4jmd"></div>`),kv=V(`<div style="font-size: var(--tandem-text-sm); font-weight: 600; color: var(--tandem-fg); margin-bottom: var(--tandem-space-1);" class="svelte-1us4jmd"> </div> <div class="svelte-1us4jmd"> </div>`,1),Av=V(`<div class="svelte-1us4jmd"><!></div>`),jv=V(`<div style="display: flex; justify-content: space-between; align-items: center;" class="svelte-1us4jmd"><span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle);" class="svelte-1us4jmd"> </span> <div style="display: flex; gap: 12px; align-items: center;" class="svelte-1us4jmd"><button data-testid="tutorial-dismiss-btn" style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); padding: 0; text-decoration: underline;" class="svelte-1us4jmd">Dismiss tutorial</button> <button data-testid="tutorial-next-btn" style="padding: var(--tandem-space-1) var(--tandem-space-3); font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-pill); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; font-weight: 500;" class="svelte-1us4jmd"> </button></div></div>`),Mv=V(`<div data-testid="onboarding-tutorial" style="position: fixed; bottom: 48px; left: 24px; z-index: var(--tandem-z-overlay); max-width: 340px; background: var(--tandem-surface); border-left: 4px solid var(--tandem-accent); border-radius: var(--tandem-r-4); box-shadow: var(--tandem-shadow-2); padding: var(--tandem-space-4) var(--tandem-space-5); font-family: inherit;" class="svelte-1us4jmd"><!> <!> <!></div>`);function Nv(e,t){k(t,!0);let n=J_(),r=j(()=>tv(n.settings.reduceMotion)?0:220),i=[{id:`review`,title:`Review an annotation`,text:`Open the side panel and accept or dismiss one of the highlighted annotations — or turn on the margin view to see them beside the text. Ctrl+Enter accepts the selected annotation; Ctrl+Shift+Enter dismisses it.`},{id:`question`,title:`Ask a question`,text:`Select text and click Annotate, then send it to your AI assistant — or keep it as a private note to yourself. You can also use the Chat panel.`},{id:`edit`,title:`Make an edit`,text:`Click in the document and type something. All changes sync in real-time. Open a tab or scratchpad with Ctrl+N, and jump anywhere with the command palette (Ctrl+Shift+P).`},{id:`cowork`,title:`Claude Desktop Cowork detected`,text:``},{id:`complete`,title:`You're ready!`,text:`You've learned the basics. Press ? anytime for keyboard shortcuts, or Ctrl+Shift+, to customize them.`}],a=Lm(),o=Fm(),s=j(()=>a&&Pm(t.coworkStatus,o)),c=j(()=>i.filter(e=>e.id!==`cowork`||z(s))),l=j(()=>z(c).length-1),u=j(()=>z(c)[t.currentStep]),d=j(()=>t.currentStep>=z(l)),f=j(()=>z(u)?.id===`cowork`);var p=Xr(),m=F(p),h=e=>{var n=Mv(),i=P(n),a=e=>{var n=Ov();pi(n,20,()=>Array.from({length:z(l)},(e,t)=>t),e=>e,(e,n)=>{var r=Dv();let i;R(()=>{i=Ui(r,1,`tut-dot svelte-1us4jmd`,null,i,{"is-current":n===t.currentStep}),G(r,`width: var(--tandem-space-2); height: var(--tandem-space-2); border-radius: var(--tandem-r-circle); background: ${n<=t.currentStep?`var(--tandem-accent)`:`var(--tandem-border)`}; transition: background 0.2s;`)}),H(e,r)}),D(n),H(e,n)};W(i,e=>{z(d)||e(a)});var o=I(i,2);ci(o,()=>z(u).id,e=>{var n=Av(),i=P(n),a=e=>{Ev(e,{get status(){return t.coworkStatus},get onAdvance(){return t.onNext}})},o=e=>{var t=kv(),n=F(t),r=P(n,!0);D(n);var i=I(n,2),a=P(i,!0);D(i),R(()=>{U(r,z(u).title),G(i,`font-size: var(--tandem-text-base); line-height: 1.5; color: var(--tandem-fg-muted); margin-bottom: ${z(d)?0:14}px;`),U(a,z(u).text)}),H(e,t)};W(i,e=>{z(f)&&t.coworkStatus!==null?e(a):e(o,-1)}),D(n),Mi(1,n,()=>G_,()=>({duration:z(r)})),H(e,n)});var s=I(o,2),c=e=>{var n=jv(),r=P(n),i=P(r);D(r);var a=I(r,2),o=P(a),s=I(o,2),c=P(s,!0);D(s),D(a),D(n),R(()=>{U(i,`Step ${t.currentStep+1} of ${z(l)??``}`),U(c,t.currentStep===z(l)-1?`Done`:`Next`)}),B(`click`,o,function(...e){t.onDismiss?.apply(this,e)}),B(`click`,s,function(...e){t.onNext?.apply(this,e)}),H(e,n)};W(s,e=>{!z(d)&&!z(f)&&e(c)}),D(n),H(e,n)};W(m,e=>{z(u)&&e(h)}),H(e,p),A()}Br([`click`]);var Pv=()=>new Map,Fv=e=>{let t=Pv();return e.forEach((e,n)=>{t.set(n,e)}),t},Iv=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Lv=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Rv=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},zv=()=>new Set,Bv=e=>e[e.length-1],Vv=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Hv=Array.from,Uv=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Wv=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Gv=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Kv=Array.isArray,qv=class{constructor(){this._observers=Pv()}on(e,t){return Iv(this._observers,e,zv).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Hv((this._observers.get(e)||Pv()).values()).forEach(e=>e(...t))}destroy(){this._observers=Pv()}},Jv=Math.floor,Yv=Math.abs,Xv=(e,t)=>e<t?e:t,Zv=(e,t)=>e>t?e:t;Number.isNaN;var Qv=e=>e===0?1/e<0:e<0,$v=1<<17,ey=1<<18,ty=1<<19,ny=1<<20,ry=1<<21,iy=1<<22,ay=1<<23,oy=1<<24,sy=1<<25,cy=1<<26,ly=1<<27,uy=1<<28,dy=1<<29;$v-1,ey-1,ty-1,ny-1,ry-1,iy-1,ay-1,oy-1,sy-1,cy-1,ly-1,uy-1,dy-1;var fy=2**53-1,py=-(2**53-1),my=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&Jv(e)===e);Number.isNaN,Number.parseInt;var hy=String.fromCharCode;String.fromCodePoint,hy(65535);var gy=e=>e.toLowerCase(),_y=/^\s*/g,vy=e=>e.replace(_y,``),yy=/([A-Z])/g,by=(e,t)=>vy(e.replace(yy,e=>`${t}${gy(e)}`)),xy=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Sy=typeof TextEncoder<`u`?new TextEncoder:null,Cy=Sy?e=>Sy.encode(e):xy,wy=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});wy&&wy.decode(new Uint8Array).length===1&&(wy=null);var Ty=(e,t)=>Gv(t,()=>e).join(``),Ey=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Dy=()=>new Ey,Oy=e=>{let t=Dy();return e(t),Ay(t)},ky=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Ay=e=>{let t=new Uint8Array(ky(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},jy=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Zv(n,t)*2),e.cpos=0)},My=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Ny=My,Py=(e,t)=>{for(;t>127;)My(e,128|127&t),t=Jv(t/128);My(e,127&t)},Fy=(e,t)=>{let n=Qv(t);for(n&&(t=-t),My(e,(t>63?128:0)|(n?64:0)|63&t),t=Jv(t/64);t>0;)My(e,(t>127?128:0)|127&t),t=Jv(t/128)},Iy=new Uint8Array(3e4),Ly=Iy.length/3,Ry=Sy&&Sy.encodeInto?(e,t)=>{if(t.length<Ly){let n=Sy.encodeInto(t,Iy).written||0;Py(e,n);for(let t=0;t<n;t++)My(e,Iy[t])}else By(e,Cy(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;Py(e,r);for(let t=0;t<r;t++)My(e,n.codePointAt(t))},zy=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Xv(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Zv(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},By=(e,t)=>{Py(e,t.byteLength),zy(e,t)},Vy=(e,t)=>{jy(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Hy=(e,t)=>Vy(e,4).setFloat32(0,t,!1),Uy=(e,t)=>Vy(e,8).setFloat64(0,t,!1),Wy=(e,t)=>Vy(e,8).setBigInt64(0,t,!1),Gy=new DataView(new ArrayBuffer(4)),Ky=e=>(Gy.setFloat32(0,e),Gy.getFloat32(0)===e),qy=(e,t)=>{switch(typeof t){case`string`:My(e,119),Ry(e,t);break;case`number`:my(t)&&Yv(t)<=2147483647?(My(e,125),Fy(e,t)):Ky(t)?(My(e,124),Hy(e,t)):(My(e,123),Uy(e,t));break;case`bigint`:My(e,122),Wy(e,t);break;case`object`:if(t===null)My(e,126);else if(Kv(t)){My(e,117),Py(e,t.length);for(let n=0;n<t.length;n++)qy(e,t[n])}else if(t instanceof Uint8Array)My(e,116),By(e,t);else{My(e,118);let n=Object.keys(t);Py(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];Ry(e,i),qy(e,t[i])}}break;case`boolean`:My(e,t?120:121);break;default:My(e,127)}},Jy=class extends Ey{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Py(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Yy=e=>{e.count>0&&(Fy(e.encoder,e.count===1?e.s:-e.s),e.count>1&&Py(e.encoder,e.count-2))},Xy=class{constructor(){this.encoder=new Ey,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Yy(this),this.count=1,this.s=e)}toUint8Array(){return Yy(this),Ay(this.encoder)}},Zy=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Fy(e.encoder,t),e.count>1&&Py(e.encoder,e.count-2)}},Qy=class{constructor(){this.encoder=new Ey,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Zy(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Zy(this),Ay(this.encoder)}},$y=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Xy}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new Ey;return this.sarr.push(this.s),this.s=``,Ry(e,this.sarr.join(``)),zy(e,this.lensE.toUint8Array()),Ay(e)}},eb=e=>Error(e),tb=()=>{throw eb(`Method unimplemented`)},nb=()=>{throw eb(`Unexpected case`)},rb=eb(`Unexpected end of array`),ib=eb(`Integer out of Range`),ab=class{constructor(e){this.arr=e,this.pos=0}},ob=e=>new ab(e),sb=e=>e.pos!==e.arr.length,cb=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},lb=e=>cb(e,db(e)),ub=e=>e.arr[e.pos++],db=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>fy)throw ib}throw rb},fb=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>fy)throw ib}throw rb},pb=wy?e=>wy.decode(lb(e)):e=>{let t=db(e);if(t===0)return``;{let n=String.fromCodePoint(ub(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(ub(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},mb=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},hb=[e=>void 0,e=>null,fb,e=>mb(e,4).getFloat32(0,!1),e=>mb(e,8).getFloat64(0,!1),e=>mb(e,8).getBigInt64(0,!1),e=>!1,e=>!0,pb,e=>{let t=db(e),n={};for(let r=0;r<t;r++){let t=pb(e);n[t]=gb(e)}return n},e=>{let t=db(e),n=[];for(let r=0;r<t;r++)n.push(gb(e));return n},lb],gb=e=>hb[127-ub(e)](e),_b=class extends ab{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),sb(this)?this.count=db(this)+1:this.count=-1),this.count--,this.s}},vb=class extends ab{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=fb(this);let e=Qv(this.s);this.count=1,e&&(this.s=-this.s,this.count=db(this)+2)}return this.count--,this.s}},yb=class extends ab{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=fb(this),t=e&1;this.diff=Jv(e/2),this.count=1,t&&(this.count=db(this)+2)}return this.s+=this.diff,this.count--,this.s}},bb=class{constructor(e){this.decoder=new vb(e),this.str=pb(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var xb=crypto.getRandomValues.bind(crypto),Sb=Math.random,Cb=()=>xb(new Uint32Array(1))[0],wb=e=>e[Jv(Sb()*e.length)],Tb=`10000000-1000-4000-8000-100000000000`,Eb=()=>Tb.replace(/[018]/g,e=>(e^Cb()&15>>e/4).toString(16)),Db=Date.now,Ob=e=>new Promise(e);Promise.all.bind(Promise);var kb=e=>e===void 0?null:e,Ab=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(Ab=localStorage)}catch{}var jb=Ab,Mb=Symbol(`Equality`),Nb=(e,t)=>e===t||!!e?.[Mb]?.(t)||!1,Pb=e=>typeof e==`object`,Fb=Object.assign,Ib=Object.keys,Lb=(e,t)=>{for(let n in e)t(e[n],n)},Rb=e=>Ib(e).length,zb=e=>{for(let t in e)return!1;return!0},Bb=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Vb=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Hb=(e,t)=>e===t||Rb(e)===Rb(t)&&Bb(e,(e,n)=>(e!==void 0||Vb(t,n))&&Nb(t[n],e)),Ub=Object.freeze,Wb=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Wb(e[t])}return Ub(e)},Gb=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Gb(e,t,n+1)}},Kb=e=>e,qb=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Mb]!=null)return e[Mb](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!qb(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Rb(e)!==Rb(t))return!1;for(let n in e)if(!Vb(e,n)||!qb(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!qb(e[n],t[n]))return!1;break;default:return!1}return!0},Jb=(e,t)=>t.includes(e),Yb=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,Xb=typeof window<`u`&&typeof document<`u`&&!Yb;typeof navigator<`u`&&/Mac/.test(navigator.platform);var Zb,Qb=[],$b=()=>{if(Zb===void 0)if(Yb){Zb=Pv();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&Zb.set(t,``),t=r):t===null?Qb.push(r):(Zb.set(t,r),t=null)}t!==null&&Zb.set(t,``)}else typeof location==`object`?(Zb=Pv(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);Zb.set(`--${by(t,`-`)}`,n),Zb.set(`-${by(t,`-`)}`,n)}})):Zb=Pv();return Zb},ex=e=>$b().has(e),tx=e=>kb(Yb?{}[e.toUpperCase().replaceAll(`-`,`_`)]:jb.getItem(e)),nx=e=>ex(`--`+e)||tx(e)!==null,rx=nx(`production`),ix=Yb&&Jb({}.FORCE_COLOR,[`true`,`1`,`2`])||!ex(`--no-colors`)&&!nx(`no-color`)&&(!Yb||process.stdout.isTTY)&&(!Yb||ex(`--color`)||tx(`COLORTERM`)!==null||(tx(`TERM`)||``).includes(`color`)),ax=e=>new Uint8Array(e),ox=Xb?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=hy(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),sx=e=>{let t=ax(e.byteLength);return t.set(e),t},cx=e=>Oy(t=>qy(t,e)),lx=class{constructor(e,t){this.left=e,this.right=t}},ux=(e,t)=>new lx(e,t),dx=e=>e.next()>=.5,fx=(e,t,n)=>Jv(e.next()*(n+1-t)+t),px=(e,t,n)=>Jv(e.next()*(n+1-t)+t),mx=(e,t,n)=>px(e,t,n),hx=e=>hy(mx(e,97,122)),gx=(e,t=0,n=20)=>{let r=mx(e,t,n),i=``;for(let t=0;t<r;t++)i+=hx(e);return i},_x=(e,t)=>t[mx(e,0,t.length-1)],vx=Symbol(`0schema`),yx=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(Ty(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
71
|
-
`)}},bx=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Mb]?Nb(e,t):Kv(e)?Uv(e,e=>Wv(t,t=>bx(e,t))):Pb(e)?Bb(e,(e,n)=>bx(e,t[n])):!1,xx=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),bx(t,n)}equals(e){return this.constructor===e.constructor&&qb(this.shape,e.shape)}[vx](){return!0}[Mb](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){tb()}get nullable(){return eS(this,hS)}get optional(){return new Mx(this)}cast(e){return yS(e,this),e}expect(e){return yS(e,this),e}},Sx=class extends xx{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},Cx=(e,t=null)=>new Sx(e,t);Cx(Sx);var wx=class extends xx{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Tx=e=>new wx(e);Cx(wx);var Ex=class extends xx{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},Dx=(...e)=>new Ex(e),Ox=Cx(Ex),kx=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Ax=e=>{if(uS.check(e))return[kx(e)];if(Ox.check(e))return e.shape.map(e=>e+``);if(lS.check(e))return[`[+-]?\\d+.?\\d*`];if(dS.check(e))return[`.*`];if(tS.check(e))return e.shape.map(Ax).flat(1);nb()};Cx(class extends xx{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Ax).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var jx=Symbol(`optional`),Mx=class extends xx{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[jx](){return!0}},Nx=Cx(Mx),Px=class extends xx{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Px,Cx(Px);var Fx=class e extends xx{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):Bb(this.shape,(n,r)=>{let i=this._isPartial&&!Vb(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Ix=e=>new Fx(e),Lx=Cx(Fx),Rx=Tx(e=>e!=null&&(e.constructor===Object||e.constructor==null)),zx=class extends xx{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Bb(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Bx=(e,t)=>new zx(e,t),Vx=Cx(zx),Hx=class extends xx{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Bb(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},Ux=(...e)=>new Hx(e);Cx(Hx);var Wx=class extends xx{constructor(e){super(),this.shape=e.length===1?e[0]:new $x(e)}check(e,t){let n=Kv(e)&&Uv(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},Gx=(...e)=>new Wx(e),Kx=Cx(Wx),qx=Tx(e=>Kv(e)),Jx=class extends xx{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},Yx=(e,t=null)=>new Jx(e,t);Cx(Jx);var Xx=Yx(xx),Zx=Cx(class extends xx{constructor(e){super(),this.len=e.length-1,this.args=Ux(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),Qx=Tx(e=>typeof e==`function`);Cx(class extends xx{constructor(e){super(),this.shape=e}check(e,t){let n=Uv(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var $x=class extends xx{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Wv(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},eS=(...e)=>e.findIndex(e=>tS.check(e))>=0?eS(...e.map(e=>vS(e)).map(e=>tS.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new $x(e),tS=Cx($x),nS=()=>!0,rS=Tx(nS),iS=Cx(wx,e=>e.shape===nS),aS=Tx(e=>typeof e==`bigint`),oS=Tx(e=>e===aS),sS=Tx(e=>typeof e==`symbol`);Tx(e=>e===sS);var cS=Tx(e=>typeof e==`number`),lS=Tx(e=>e===cS),uS=Tx(e=>typeof e==`string`),dS=Tx(e=>e===uS),fS=Tx(e=>typeof e==`boolean`),pS=Tx(e=>e===fS),mS=Dx(void 0);Cx(Ex,e=>e.shape.length===1&&e.shape[0]===void 0),Dx(void 0);var hS=Dx(null),gS=Cx(Ex,e=>e.shape.length===1&&e.shape[0]===null);Cx(Uint8Array),Cx(Sx,e=>e.shape===Uint8Array);var _S=eS(cS,uS,hS,mS,aS,fS,sS);(()=>{let e=Gx(rS),t=Bx(uS,rS),n=eS(cS,uS,hS,fS,e,t);return e.shape=n,t.shape.values=n,n})();var vS=e=>{if(Xx.check(e))return e;if(Rx.check(e)){let t={};for(let n in e)t[n]=vS(e[n]);return Ix(t)}else if(qx.check(e))return eS(...e.map(vS));else if(_S.check(e))return Dx(e);else if(Qx.check(e))return Cx(e);nb()},yS=rx?()=>{}:(e,t)=>{let n=new yx;if(!t.check(e,n))throw eb(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},bS=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:vS(e),h:t}),this}else(e){return this.if(rS,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw eb(`Unhandled pattern`)}}},xS=(e=>new bS(e))(rS).if(lS,(e,t)=>fx(t,py,fy)).if(dS,(e,t)=>gx(t)).if(pS,(e,t)=>dx(t)).if(oS,(e,t)=>BigInt(fx(t,py,fy))).if(tS,(e,t)=>SS(t,_x(t,e.shape))).if(Lx,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Nx.check(i)){if(dx(t))continue;i=i.shape}n[r]=xS(i,t)}return n}).if(Kx,(e,t)=>{let n=[],r=px(t,0,42);for(let i=0;i<r;i++)n.push(SS(t,e.shape));return n}).if(Ox,(e,t)=>_x(t,e.shape)).if(gS,(e,t)=>null).if(Zx,(e,t)=>{let n=SS(t,e.res);return()=>n}).if(iS,(e,t)=>SS(t,_x(t,[cS,uS,hS,mS,aS,fS,Gx(cS),Bx(eS(`a`,`b`,`c`),cS)]))).if(Vx,(e,t)=>{let n={},r=fx(t,0,3);for(let i=0;i<r;i++){let r=SS(t,e.shape.keys);n[r]=SS(t,e.shape.values)}return n}).done(),SS=(e,t)=>xS(vS(t),e),CS=typeof document<`u`?document:{};Tx(e=>e.nodeType===OS),typeof DOMParser<`u`&&new DOMParser,Tx(e=>e.nodeType===TS),Tx(e=>e.nodeType===ES);var wS=e=>Lv(e,(e,t)=>`${t}:${e};`).join(``),TS=CS.ELEMENT_NODE,ES=CS.TEXT_NODE;CS.CDATA_SECTION_NODE,CS.COMMENT_NODE;var DS=CS.DOCUMENT_NODE;CS.DOCUMENT_TYPE_NODE;var OS=CS.DOCUMENT_FRAGMENT_NODE;Tx(e=>e.nodeType===DS);var kS=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),AS=(e,t)=>new kS(setTimeout(t,e)),jS=Symbol,MS=jS(),NS=jS(),PS=jS(),FS=jS(),IS=jS(),LS=jS(),RS=jS(),zS=jS(),BS=jS(),VS=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};Db();var HS={[MS]:ux(`font-weight`,`bold`),[NS]:ux(`font-weight`,`normal`),[PS]:ux(`color`,`blue`),[IS]:ux(`color`,`green`),[FS]:ux(`color`,`grey`),[LS]:ux(`color`,`red`),[RS]:ux(`color`,`purple`),[zS]:ux(`color`,`orange`),[BS]:ux(`color`,`black`)},US=ix?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=Pv(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=HS[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=wS(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:VS,WS=(...e)=>{console.log(...US(e)),KS.forEach(t=>t.print(e))},GS=(...e)=>{console.warn(...US(e)),e.unshift(zS),KS.forEach(t=>t.print(e))},KS=zv(),qS=e=>({[Symbol.iterator](){return this},next:e}),JS=(e,t)=>qS(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),YS=(e,t)=>qS(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),XS=class{constructor(e,t){this.clock=e,this.len=t}},ZS=class{constructor(){this.clients=new Map}},QS=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])gw(e,i,o.clock,o.len,n)}}),$S=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=Jv((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},eC=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&$S(n,t.clock)!==null},tC=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new XS(r.clock,Zv(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},nC=e=>{let t=new ZS;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)Vv(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return tC(t),t},rC=(e,t,n,r)=>{Iv(e.clients,t,()=>[]).push(new XS(n,r))},iC=()=>new ZS,aC=e=>{let t=iC();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new XS(i,a))}}r.length>0&&t.clients.set(n,r)}),t},oC=(e,t)=>{Py(e.restEncoder,t.clients.size),Hv(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),Py(e.restEncoder,t);let r=n.length;Py(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},sC=e=>{let t=new ZS,n=db(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=db(e.restDecoder),r=db(e.restDecoder);if(r>0){let i=Iv(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new XS(e.readDsClock(),e.readDsLen()))}}return t},cC=(e,t,n)=>{let r=new ZS,i=db(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=db(e.restDecoder),a=db(e.restDecoder),o=n.clients.get(i)||[],s=cw(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&rC(r,i,s,a-s);let e=uw(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,NE(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,NE(t,c,a-c.id.clock)),c.delete(t))}else rC(r,i,n,a-n)}}if(r.clients.size>0){let e=new vC;return Py(e.restEncoder,0),oC(e,r),e.toUint8Array()}return null},lC=Cb,uC=class e extends qv{constructor({guid:e=Eb(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=lC(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new ow,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ob(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>Ob(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&ww(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Hv(this.subdocs).map(e=>e.guid))}transact(e,t=null){return ww(this,e,t)}get(e,t=eT){let n=Iv(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==eT&&r!==t)if(r===eT){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,xT)}getText(e=``){return this.get(e,HT)}getMap(e=``){return this.get(e,wT)}getXmlElement(e=``){return this.get(e,qT)}getXmlFragment(e=``){return this.get(e,GT)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,Hv(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,ww(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},dC=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return db(this.restDecoder)}readDsLen(){return db(this.restDecoder)}},fC=class extends dC{readLeftID(){return UC(db(this.restDecoder),db(this.restDecoder))}readRightID(){return UC(db(this.restDecoder),db(this.restDecoder))}readClient(){return db(this.restDecoder)}readInfo(){return ub(this.restDecoder)}readString(){return pb(this.restDecoder)}readParentInfo(){return db(this.restDecoder)===1}readTypeRef(){return db(this.restDecoder)}readLen(){return db(this.restDecoder)}readAny(){return gb(this.restDecoder)}readBuf(){return sx(lb(this.restDecoder))}readJSON(){return JSON.parse(pb(this.restDecoder))}readKey(){return pb(this.restDecoder)}},pC=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=db(this.restDecoder),this.dsCurrVal}readDsLen(){let e=db(this.restDecoder)+1;return this.dsCurrVal+=e,e}},mC=class extends pC{constructor(e){super(e),this.keys=[],db(e),this.keyClockDecoder=new yb(lb(e)),this.clientDecoder=new vb(lb(e)),this.leftClockDecoder=new yb(lb(e)),this.rightClockDecoder=new yb(lb(e)),this.infoDecoder=new _b(lb(e),ub),this.stringDecoder=new bb(lb(e)),this.parentInfoDecoder=new _b(lb(e),ub),this.typeRefDecoder=new vb(lb(e)),this.lenDecoder=new vb(lb(e))}readLeftID(){return new VC(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new VC(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 gb(this.restDecoder)}readBuf(){return lb(this.restDecoder)}readJSON(){return gb(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},hC=class{constructor(){this.restEncoder=Dy()}toUint8Array(){return Ay(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Py(this.restEncoder,e)}writeDsLen(e){Py(this.restEncoder,e)}},gC=class extends hC{writeLeftID(e){Py(this.restEncoder,e.client),Py(this.restEncoder,e.clock)}writeRightID(e){Py(this.restEncoder,e.client),Py(this.restEncoder,e.clock)}writeClient(e){Py(this.restEncoder,e)}writeInfo(e){Ny(this.restEncoder,e)}writeString(e){Ry(this.restEncoder,e)}writeParentInfo(e){Py(this.restEncoder,+!!e)}writeTypeRef(e){Py(this.restEncoder,e)}writeLen(e){Py(this.restEncoder,e)}writeAny(e){qy(this.restEncoder,e)}writeBuf(e){By(this.restEncoder,e)}writeJSON(e){Ry(this.restEncoder,JSON.stringify(e))}writeKey(e){Ry(this.restEncoder,e)}},_C=class{constructor(){this.restEncoder=Dy(),this.dsCurrVal=0}toUint8Array(){return Ay(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,Py(this.restEncoder,t)}writeDsLen(e){e===0&&nb(),Py(this.restEncoder,e-1),this.dsCurrVal+=e}},vC=class extends _C{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Qy,this.clientEncoder=new Xy,this.leftClockEncoder=new Qy,this.rightClockEncoder=new Qy,this.infoEncoder=new Jy(Ny),this.stringEncoder=new $y,this.parentInfoEncoder=new Jy(Ny),this.typeRefEncoder=new Xy,this.lenEncoder=new Xy}toUint8Array(){let e=Dy();return Py(e,0),By(e,this.keyClockEncoder.toUint8Array()),By(e,this.clientEncoder.toUint8Array()),By(e,this.leftClockEncoder.toUint8Array()),By(e,this.rightClockEncoder.toUint8Array()),By(e,Ay(this.infoEncoder)),By(e,this.stringEncoder.toUint8Array()),By(e,Ay(this.parentInfoEncoder)),By(e,this.typeRefEncoder.toUint8Array()),By(e,this.lenEncoder.toUint8Array()),zy(e,Ay(this.restEncoder)),Ay(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){qy(this.restEncoder,e)}writeBuf(e){By(this.restEncoder,e)}writeJSON(e){qy(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},yC=(e,t,n,r)=>{r=Zv(r,t[0].id.clock);let i=uw(t,r);Py(e.restEncoder,t.length-i),e.writeClient(n),Py(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},bC=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{cw(t,n)>e&&r.set(n,e)}),sw(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),Py(e.restEncoder,r.size),Hv(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{yC(e,t.clients.get(n),n,r)})},xC=(e,t)=>{let n=Pv(),r=db(e.restDecoder);for(let i=0;i<r;i++){let r=db(e.restDecoder),i=Array(r),a=e.readClient(),o=db(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new nE(UC(a,o),t),o+=t;break}case 10:{let t=db(e.restDecoder);i[n]=new BE(UC(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new IE(UC(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,LE(e,r));i[n]=c,o+=c.length}}}}return n},SC=(e,t,n)=>{let r=[],i=Hv(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new ow,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==BE){let i=Iv(d,u.id.client,()=>cw(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,cw(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new vC;return bC(e,s,new Map),Py(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},CC=(e,t)=>bC(e,t.doc.store,t.beforeState),wC=(e,t,n,r=new mC(e))=>ww(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=SC(e,i,xC(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<cw(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=Pw([o.update,a.update])}}else i.pendingStructs=a;let s=cC(r,e,i);if(i.pendingDs){let t=new mC(ob(i.pendingDs));db(t.restDecoder);let n=cC(t,e,i);s&&n?i.pendingDs=Pw([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,TC(e.doc,t)}},n,!1),TC=(e,t,n,r=mC)=>{let i=ob(t);wC(i,e,n,new r(i))},EC=(e,t,n)=>TC(e,t,n,fC),DC=(e,t,n=new Map)=>{bC(e,t.store,n),oC(e,aC(t.store))},OC=(e,t=new Uint8Array([0]),n=new vC)=>{DC(n,e,jC(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Fw(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===gC)return Mw(r.map((e,t)=>t===0?e:Bw(e)));if(n.constructor===vC)return Pw(r)}return r[0]},kC=(e,t)=>OC(e,t,new gC),AC=e=>{let t=new Map,n=db(e.restDecoder);for(let r=0;r<n;r++){let n=db(e.restDecoder),r=db(e.restDecoder);t.set(n,r)}return t},jC=e=>AC(new dC(ob(e))),MC=(e,t)=>(Py(e.restEncoder,t.size),Hv(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{Py(e.restEncoder,t),Py(e.restEncoder,n)}),e),NC=(e,t)=>MC(e,sw(t.store)),PC=(e,t=new _C)=>(e instanceof Map?MC(t,e):NC(t,e),t.toUint8Array()),FC=e=>PC(e,new hC),IC=class{constructor(){this.l=[]}},LC=()=>new IC,RC=(e,t)=>e.l.push(t),zC=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},BC=(e,t,n)=>Gb(e.l,[t,n]),VC=class{constructor(e,t){this.client=e,this.clock=t}},HC=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,UC=(e,t)=>new VC(e,t),WC=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw nb()},GC=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},KC=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},qC=e=>new KC(e.type==null?null:UC(e.type.client,e.type.clock),e.tname??null,e.item==null?null:UC(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),JC=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},YC=(e,t,n=0)=>new JC(e,t,n),XC=(e,t,n)=>{let r=null,i=null;return e._item===null?i=WC(e):r=UC(e._item.id.client,e._item.id.clock),new KC(r,i,t,n)},ZC=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return XC(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return XC(e,UC(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return XC(e,r.lastId,n);r=r.right}return XC(e,null,n)},QC=(e,t)=>{let n=dw(e,t);return{item:n,diff:t.clock-n.id.clock}},$C=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(cw(r,i.client)<=i.clock)return null;let e=n?jE(r,i):QC(r,i),t=e.item;if(!(t instanceof IE))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(cw(r,a.client)<=a.clock)return null;let{item:e}=n?jE(r,a):{item:dw(r,a)};if(e instanceof IE&&e.content instanceof kE)c=e.content.type;else return null}else throw nb();l=s>=0?c._length:0}return YC(c,l,e.assoc)},ew=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&HC(e.item,t.item)&&HC(e.type,t.type)&&e.assoc===t.assoc,tw=class{constructor(e,t){this.ds=e,this.sv=t}},nw=(e,t)=>new tw(e,t);nw(iC(),new Map);var rw=e=>nw(aC(e.store),sw(e.store)),iw=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!eC(t.ds,e.id),aw=(e,t)=>{let n=Iv(e.meta,aw,zv),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<cw(r,n)&&pw(e,UC(n,t))}),QS(e,t.ds,e=>{}),n.add(t))},ow=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},sw=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},cw=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},lw=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw nb()}n.push(t)},uw=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=Jv(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=Jv((n+r)/2)}throw nb()},dw=(e,t)=>{let n=e.clients.get(t.client);return n[uw(n,t.clock)]},fw=(e,t,n)=>{let r=uw(t,n),i=t[r];return i.id.clock<n&&i instanceof IE?(t.splice(r+1,0,NE(e,i,n-i.id.clock)),r+1):r},pw=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[fw(e,n,t.clock)]},mw=(e,t,n)=>{let r=t.clients.get(n.client),i=uw(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==nE&&r.splice(i+1,0,NE(e,a,n.clock-a.id.clock+1)),a},hw=(e,t,n)=>{let r=e.clients.get(t.id.client);r[uw(r,t.id.clock)]=n},gw=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=fw(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&fw(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},_w=class{constructor(e,t,n){this.doc=e,this.deleteSet=new ZS,this.beforeState=sw(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},vw=(e,t)=>t.deleteSet.clients.size===0&&!Rv(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(tC(t.deleteSet),CC(e,t),oC(e,t.deleteSet),!0),yw=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Iv(e.changed,t,zv).add(n)},bw=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof IE&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},xw=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=uw(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof IE&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Sw=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=Xv(r.length-1,1+uw(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+bw(r,e)}})},Cw=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{tC(a),n.afterState=sw(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{BC(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&zT(n)})}),Gb(e,[])}finally{r.gc&&xw(a,i,r.gcFilter),Sw(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=Zv(uw(e,r),1);for(let t=e.length-1;t>=n;)t-=1+bw(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=uw(r,n);a+1<r.length&&bw(r,a+1)>1||a>0&&bw(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(WS(zS,MS,`[yjs] `,NS,LS,`Changed the client-id because another client seems to be using it.`),r.clientID=lC()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new gC;vw(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new vC;vw(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Cw(e,t+1)}}},ww=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new _w(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Cw(i,0)}}return o},Tw=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},Ew=(e,t,n)=>{QS(e,n.deletions,n=>{n instanceof IE&&t.scope.some(t=>t===e.doc||GC(t,n))&&ME(n,!1)})},Dw=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;ww(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;QS(n,o.insertions,e=>{if(e instanceof IE){if(e.redone!==null){let{item:t,diff:i}=jE(r,e.id);i>0&&(t=pw(n,UC(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||GC(t,e))&&c.push(e)}}),QS(n,o.deletions,e=>{e instanceof IE&&a.some(t=>t===n.doc||GC(t,e))&&!eC(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=FE(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},Ow=class extends qv{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=Kv(e)?e[0].doc:e instanceof uC?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new ZS;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&rC(i,n,r,a)});let a=Db(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=nC([t.deletions,e.deleteSet]),t.insertions=nC([t.insertions,i])}else r.push(new Tw(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),QS(e,e.deleteSet,t=>{t instanceof IE&&this.scope.some(n=>n===e.doc||GC(n,t))&&ME(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=Kv(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof eT?e.doc!==this.doc:e!==this.doc)&&GS(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>Ew(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>Ew(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Dw(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Dw(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*kw(e){let t=db(e.restDecoder);for(let n=0;n<t;n++){let t=db(e.restDecoder),n=e.readClient(),r=db(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=db(e.restDecoder);yield new BE(UC(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new IE(UC(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,LE(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new nE(UC(n,r),t),r+=t}}}}var Aw=class{constructor(e,t){this.gen=kw(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===BE);return this.curr}},jw=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Mw=e=>Pw(e,fC,gC),Nw=(e,t)=>{if(e.constructor===nE){let{client:n,clock:r}=e.id;return new nE(UC(n,r+t),e.length-t)}else if(e.constructor===BE){let{client:n,clock:r}=e.id;return new BE(UC(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new IE(UC(r,i+t),null,UC(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Pw=(e,t=mC,n=vC)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(ob(e))),i=r.map(e=>new Aw(e,!0)),a=null,o=new n,s=new jw(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===BE?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)Lw(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===BE)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{Lw(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new BE(UC(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===BE?a.struct.length-=t:n=Nw(n,t)),a.struct.mergeWith(n)||(Lw(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==BE;n=e.next())Lw(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(Lw(s,a.struct,a.offset),a=null),Rw(s),oC(o,nC(r.map(e=>sC(e)))),o.toUint8Array()},Fw=(e,t,n=mC,r=vC)=>{let i=jC(t),a=new r,o=new jw(a),s=new n(ob(e)),c=new Aw(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===BE){c.next();continue}if(e.id.clock+e.length>n)for(Lw(o,e,Zv(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)Lw(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return Rw(o),oC(a,sC(s)),a.toUint8Array()},Iw=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:Ay(e.encoder.restEncoder)}),e.encoder.restEncoder=Dy(),e.written=0)},Lw=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Iw(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),Py(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Rw=e=>{Iw(e);let t=e.encoder.restEncoder;Py(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];Py(t,r.written),zy(t,r.restEncoder)}},zw=(e,t,n,r)=>{let i=new n(ob(e)),a=new Aw(i,!1),o=new r,s=new jw(o);for(let e=a.curr;e!==null;e=a.next())Lw(s,t(e),0);return Rw(s),oC(o,sC(i)),o.toUint8Array()},Bw=e=>zw(e,Kb,mC,gC),Vw=`You must not compute changes after the event-handler fired.`,Hw=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=Uw(this.currentTarget,this.target)}deletes(e){return eC(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw eb(Vw);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=Bv(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=Bv(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Bv(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw eb(Vw);let t=this.target,n=zv(),r=zv(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},Uw=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},Ww=()=>{GS(`Invalid access: Add Yjs type to a document before reading data.`)},Gw=80,Kw=0,qw=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Kw++}},Jw=e=>{e.timestamp=Kw++},Yw=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Kw++},Xw=(e,t,n)=>{if(e.length>=Gw){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Yw(r,t,n),r}else{let r=new qw(t,n);return e.push(r),r}},Zw=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>Yv(t-e.index)<Yv(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,Jw(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&Yv(n.index-i)<r.parent.length/Gw?(Yw(n,r,i),n):Xw(e._searchMarker,r,i)},Qw=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=Zv(t,i.index+n))}},$w=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Iv(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;BC(r._eH,n,t)},eT=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=LC(),this._dEH=LC(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw tb()}clone(){throw tb()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){RC(this._eH,e)}observeDeep(e){RC(this._dEH,e)}unobserve(e){zC(this._eH,e)}unobserveDeep(e){zC(this._dEH,e)}toJSON(){}},tT=(e,t,n)=>{e.doc??Ww(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},nT=e=>{e.doc??Ww();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},rT=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&iw(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},iT=(e,t)=>{let n=0,r=e._start;for(e.doc??Ww();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},aT=(e,t)=>{let n=[];return iT(e,(r,i)=>{n.push(t(r,i,e))}),n},oT=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},sT=(e,t)=>{e.doc??Ww();let n=Zw(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},cT=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new IE(UC(o,cw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new _E(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new IE(UC(o,cw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new rE(new Uint8Array(n))),i.integrate(e,0);break;case uC:i=new IE(UC(o,cw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new cE(n)),i.integrate(e,0);break;default:if(n instanceof eT)i=new IE(UC(o,cw(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new kE(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},lT=()=>eb(`Length exceeded!`),uT=(e,t,n,r)=>{if(n>t._length)throw lT();if(n===0)return t._searchMarker&&Qw(t._searchMarker,n,r.length),cT(e,t,null,r);let i=n,a=Zw(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&pw(e,UC(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Qw(t._searchMarker,i,r.length),cT(e,t,o,r)},dT=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return cT(e,t,r,n)},fT=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=Zw(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&pw(e,UC(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&pw(e,UC(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw lT();t._searchMarker&&Qw(t._searchMarker,i,-a+r)},pT=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},mT=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new _E([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new _E([r]);break;case Uint8Array:s=new rE(r);break;case uC:s=new cE(r);break;default:if(r instanceof eT)s=new kE(r);else throw Error(`Unexpected content type`)}new IE(UC(o,cw(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},hT=(e,t)=>{e.doc??Ww();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},gT=e=>{let t={};return e.doc??Ww(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},_T=(e,t)=>{e.doc??Ww();let n=e._map.get(t);return n!==void 0&&!n.deleted},vT=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&iw(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},yT=e=>(e.doc??Ww(),JS(e._map.entries(),e=>!e[1].deleted)),bT=class extends Hw{},xT=class e extends eT{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof eT?e.clone():e)),t}get length(){return this.doc??Ww(),this._length}_callObserver(e,t){super._callObserver(e,t),$w(this,e,new bT(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):ww(this.doc,n=>{uT(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):ww(this.doc,t=>{dT(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):ww(this.doc,n=>{fT(n,this,e,t)})}get(e){return sT(this,e)}toArray(){return nT(this)}slice(e=0,t=this.length){return tT(this,e,t)}toJSON(){return this.map(e=>e instanceof eT?e.toJSON():e)}map(e){return aT(this,e)}forEach(e){iT(this,e)}[Symbol.iterator](){return oT(this)}_write(e){e.writeTypeRef(SE)}},ST=e=>new xT,CT=class extends Hw{constructor(e,t,n){super(e,t),this.keysChanged=n}},wT=class e extends eT{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof eT?e.clone():e)}),t}_callObserver(e,t){$w(this,e,new CT(this,e,t))}toJSON(){this.doc??Ww();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof eT?r.toJSON():r}}),e}get size(){return[...yT(this)].length}keys(){return YS(yT(this),e=>e[0])}values(){return YS(yT(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return YS(yT(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Ww(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):ww(this.doc,t=>{pT(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):ww(this.doc,n=>{mT(n,this,e,t)}),t}get(e){return hT(this,e)}has(e){return _T(this,e)}clear(){this.doc===null?this._prelimContent.clear():ww(this.doc,e=>{this.forEach(function(t,n,r){pT(e,r,n)})})}_write(e){e.writeTypeRef(CE)}},TT=e=>new wT,ET=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Hb(e,t),DT=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&nb(),this.right.content.constructor){case fE:this.right.deleted||jT(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}},OT=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case fE:t.right.deleted||jT(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&pw(e,UC(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},kT=(e,t,n,r)=>{let i=new Map,a=r?Zw(t,n):null;return a?OT(e,new DT(a.p.left,a.p,a.index,i),n-a.index):OT(e,new DT(null,t._start,0,i),n)},AT=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===fE&&ET(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new IE(UC(a,cw(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new fE(o,r));l.integrate(e,0),n.right=l,n.forward()})},jT=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},MT=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===fE&&ET(t[e.right.content.key]??null,e.right.content.value));)e.forward()},NT=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!ET(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new IE(UC(a,cw(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new fE(s,c)),n.right.integrate(e,0),n.forward()}}return o},PT=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;MT(n,i);let s=NT(e,t,n,i),c=r.constructor===String?new yE(r):r instanceof eT?new kE(r):new uE(r),{left:l,right:u,index:d}=n;t._searchMarker&&Qw(t._searchMarker,n.index,c.getLength()),u=new IE(UC(o,cw(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),AT(e,t,n,s)},FT=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;MT(n,i);let s=NT(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===fE));){if(!n.right.deleted)switch(n.right.content.constructor){case fE:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(ET(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&pw(e,UC(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
72
|
-
`;n.right=new IE(UC(o,cw(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new yE(i)),n.right.integrate(e,0),n.forward()}AT(e,t,n,s)},IT=(e,t,n,r,i)=>{let a=t,o=Pv();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===fE){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case fE:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&jT(i,n);break}}}t=t.right}return s},LT=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===fE){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},RT=e=>{let t=0;return ww(e.doc,n=>{let r=e._start,i=e._start,a=Pv(),o=Fv(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case fE:jT(o,i.content);break;default:t+=IT(n,r,i,a,o),a=Fv(o),r=i;break}i=i.right}}),t},zT=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&gw(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===fE&&e.constructor!==nE&&t.add(e.parent)})}ww(n,n=>{QS(e,e.deleteSet,e=>{if(e instanceof nE||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===fE?t.add(r):LT(n,e)});for(let e of t)RT(e)})},BT=(e,t,n)=>{let r=n,i=Fv(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case kE:case uE:case yE:n<t.right.length&&pw(e,UC(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&IT(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&Qw(o._searchMarker,t.index,-r+n),t},VT=class extends Hw{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];ww(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},zb(o)||(e.attributes=Fb({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case kE:case uE:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case yE:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case fE:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(ET(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),ET(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;ET(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(ET(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),jT(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},HT=class e extends eT{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Ww(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new VT(this,e,t);$w(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Ww();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===yE&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):ww(this.doc,n=>{let r=new DT(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
73
|
-
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&PT(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&BT(n,r,a.delete):FT(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??Ww();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(iw(s,e)||t!==void 0&&iw(s,t))switch(s.content.constructor){case yE:{let r=i.get(`ychange`);e!==void 0&&!iw(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!iw(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case kE:case uE:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case fE:iw(s,e)&&(c(),jT(i,s.content));break}s=s.right}c()};return e||t?ww(a,n=>{e&&aw(n,e),t&&aw(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):ww(r,r=>{let i=kT(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),PT(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):ww(r,r=>{let i=kT(r,this,e,!n);PT(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):ww(n,n=>{BT(n,kT(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):ww(r,r=>{let i=kT(r,this,e,!1);i.right!==null&&FT(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):ww(this.doc,t=>{pT(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):ww(this.doc,n=>{mT(n,this,e,t)})}getAttribute(e){return hT(this,e)}getAttributes(){return gT(this)}_write(e){e.writeTypeRef(wE)}},UT=e=>new HT,WT=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Ww()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===qT||t.constructor===GT)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},GT=class e extends eT{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof eT?e.clone():e)),t}get length(){return this.doc??Ww(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new WT(this,e)}querySelector(e){e=e.toUpperCase();let t=new WT(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Hv(new WT(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){$w(this,e,new YT(this,t,e))}toString(){return aT(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),iT(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):ww(this.doc,n=>{uT(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)ww(this.doc,n=>{let r=e&&e instanceof eT?e._item:e;cT(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw eb(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):ww(this.doc,n=>{fT(n,this,e,t)})}toArray(){return nT(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return sT(this,e)}slice(e=0,t=this.length){return tT(this,e,t)}forEach(e){iT(this,e)}_write(e){e.writeTypeRef(EE)}},KT=e=>new GT,qT=class e extends GT{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Lb(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof eT?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):ww(this.doc,t=>{pT(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):ww(this.doc,n=>{mT(n,this,e,t)})}getAttribute(e){return hT(this,e)}hasAttribute(e){return _T(this,e)}getAttributes(e){return e?vT(this,e):gT(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return iT(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(TE),e.writeKey(this.nodeName)}},JT=e=>new qT(e.readKey()),YT=class extends Hw{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},XT=class e extends wT{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(DE),e.writeKey(this.hookName)}},ZT=e=>new XT(e.readKey()),QT=class e extends HT{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(OE)}},$T=e=>new QT,eE=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw tb()}mergeWith(e){return!1}write(e,t,n){throw tb()}integrate(e,t){throw tb()}},tE=0,nE=class extends eE{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),lw(e.doc.store,this)}write(e,t){e.writeInfo(tE),e.writeLen(this.length-t)}getMissing(e,t){return null}},rE=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw tb()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},iE=e=>new rE(e.readBuf()),aE=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){rC(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},oE=e=>new aE(e.readLen()),sE=(e,t)=>new uC({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),cE=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(sE(this.doc.guid,this.opts))}splice(e){throw tb()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},lE=e=>new cE(sE(e.readString(),e.readAny())),uE=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw tb()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},dE=e=>new uE(e.readJSON()),fE=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw tb()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},pE=e=>new fE(e.readKey(),e.readJSON()),mE=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},hE=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new mE(n)},gE=tx(`node_env`)===`development`,_E=class e{constructor(e){this.arr=e,gE&&Wb(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},vE=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new _E(n)},yE=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},bE=e=>new yE(e.readString()),xE=[ST,TT,UT,JT,KT,ZT,$T],SE=0,CE=1,wE=2,TE=3,EE=4,DE=5,OE=6,kE=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw tb()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},AE=e=>new kE(xE[e.readTypeRef()](e)),jE=(e,t)=>{let n=t,r=0,i;do r>0&&(n=UC(n.client,n.clock+r)),i=dw(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof IE);return{item:i,diff:r}},ME=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},NE=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new IE(UC(r,i+n),t,UC(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=UC(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},PE=(e,t)=>Wv(e,e=>eC(e.deletions,t)),FE=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return pw(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||FE(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=pw(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:pw(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:pw(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||eC(r,d.right.id)||PE(a.undoStack,d.right.id)||PE(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=pw(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;let m=UC(c,cw(s,c)),h=new IE(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,ME(h,!0),h.integrate(e,0),h},IE=class e extends eE{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=cw(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=cw(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===VC&&this.id.client!==this.parent.client&&this.parent.clock>=cw(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=mw(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=pw(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===nE||this.right&&this.right.constructor===nE)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===VC){let e=dw(n,this.parent);e.constructor===nE?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=mw(e,e.doc.store,UC(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),HC(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(HC(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(dw(e.doc.store,n.origin)))r.has(dw(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),lw(e.doc.store,this),this.content.integrate(e,this),yw(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new nE(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:UC(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&HC(e.origin,this.lastId)&&this.right===e&&HC(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),rC(e.deleteSet,this.id.client,this.id.clock,this.length),yw(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw nb();this.content.gc(e),t?hw(e,this,new nE(this.id,this.length)):this.content=new aE(this.length)}write(e,t){let n=t>0?UC(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=WC(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===VC?(e.writeParentInfo(!1),e.writeLeftID(t)):nb();i!==null&&e.writeString(i)}this.content.write(e,t)}},LE=(e,t)=>RE[t&31](e),RE=[()=>{nb()},oE,hE,iE,bE,dE,pE,AE,vE,lE,()=>{nb()}],zE=10,BE=class extends eE{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){nb()}write(e,t){e.writeInfo(zE),Py(e.restEncoder,this.length-t)}getMissing(e,t){return null}},VE=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},HE=`__ $YJS$ __`;VE[HE]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),VE[HE]=!0;var UE={anthropic:`Claude`,openai:`GPT`,gemini:`Gemini`,"local-ollama":`Local model`,"local-llamacpp":`Local model`},WE=`Assistant`;function GE(e){return(e.defaultModelId?e.models.find(t=>t.id===e.defaultModelId):void 0)||(e.models.length===1?e.models[0]:void 0)}function KE(e,t){let n=GE(e);if(!n)return WE;let r=UE[n.provider]||`Assistant`;return t===`family`?r:n.displayName||n.modelId||r}function qE(e){let t=j(()=>KE(e.settings,`family`)),n=j(()=>KE(e.settings,`model`));return{get family(){return z(t)},get specific(){return z(n)}}}function JE(e){return e?e+1:0}function YE(e){let t=0;return e.forEach(e=>{e.isText?t+=e.text.length:e.type.name===`hardBreak`&&(t+=1)}),t}function XE(e){if(e.isTextblock)return YE(e);let t=0;for(let n=0;n<e.childCount;n++)n>0&&(t+=1),t+=XE(e.child(n));return t}function ZE(e,t,n){if(e.isTextblock)return Co(n+Math.min(t,YE(e)));let r=0,i=n;for(let n=0;n<e.childCount;n++){let a=e.child(n),o=i+1;n>0&&(r+=1);let s=XE(a);if(r+s>t)return ZE(a,t-r,o);r+=s,i+=a.nodeSize}return Co(n+e.content.size)}function QE(e,t){let n=0,r=0,i=e.childCount;for(let a=0;a<i;a++){let o=e.child(a),s=r+1,c=o.type.name===`heading`?JE(o.attrs.level||1):0,l=c+XE(o);if(n+l>t){let e=t-n;return ZE(o,Math.max(0,e-c),s)}if(n+=l,r+=o.nodeSize,a<i-1&&(n+=1,n>t))return Co(s+o.content.size)}return Co(e.content.size)}function $E(e,t,n){if(e.isTextblock)return Math.min(t-n,YE(e));let r=0,i=n;for(let n=0;n<e.childCount;n++){let a=e.child(n),o=i+1;if(n>0&&(r+=1),t<i+a.nodeSize)return t<=o?r:r+$E(a,t,o);r+=XE(a),i+=a.nodeSize}return r}function eD(e,t){let n=0,r=0,i=e.childCount;for(let a=0;a<i;a++){let o=e.child(a),s=r+1,c=o.type.name===`heading`?JE(o.attrs.level||1):0,l=XE(o);if(t<r+o.nodeSize)return So(t<=s?n+c:n+c+$E(o,t,s));n+=c+l,r+=o.nodeSize,a<i-1&&(n+=1)}return So(n)}function tD(e,t,n,r){if(t.isTextblock){let i=0;for(let a=0;a<e.length;a++){let o=e.get(a);if(o instanceof QT){if(o===r.type)return Co(n+Math.min(i+r.index,YE(t)));i+=o.length}}return null}let i=n;e.length!==t.childCount&&console.warn(`[positions] Y.js/PM child count mismatch: yEl(${e.nodeName}).length=${e.length} vs pmNode(${t.type.name}).childCount=${t.childCount}`);let a=Math.min(e.length,t.childCount);for(let n=0;n<a;n++){let a=e.get(n),o=t.child(n),s=i+1;if(a instanceof qT){let e=tD(a,o,s,r);if(e!==null)return e}i+=o.nodeSize}return null}function nD(e,t,n){let r=0,i=Math.min(e.childCount,t.length);for(let a=0;a<i;a++){let i=t.get(a),o=e.child(a),s=r+1;if(i instanceof qT){let e=tD(i,o,s,n);if(e!==null)return e}r+=o.nodeSize}return null}function rD(e,t,n){let r,i;try{let t=qC(n.fromRel),a=qC(n.toRel);r=$C(t,e),i=$C(a,e)}catch(e){return console.warn(`[positions] relRangeToPmPositions: failed to resolve relRange:`,e),null}if(!r||!i)return null;let a=e.getXmlFragment(`default`),o=nD(t,a,r),s=nD(t,a,i);return o===null||s===null?null:{from:o,to:s}}function iD(e,t,n){if(e.relRange&&n){let r=rD(n,t,e.relRange);if(r&&r.from<=r.to)return{...r,method:`rel`};console.warn(r?`[positions] annotationToPmRange: inverted rel range for ${e.id}, falling back to flat`:`[positions] annotationToPmRange: relRange resolved to null for ${e.id}, falling back to flat`)}return e.range?{from:QE(t,e.range.from),to:QE(t,e.range.to),method:`flat`}:null}function aD(e,t){return{from:eD(e,t.from),to:eD(e,t.to)}}function oD(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function sD(e){let t=oD(e),n=[],r=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(e,t,r)=>{let i=n.length,a=t?` class="language-${t}"`:``;return n.push(`<pre><code${a}>${r.trimEnd()}</code></pre>`),`\x00BLOCK${i}\x00`});r=r.replace(/^### (.+)$/gm,`<h3>$1</h3>`).replace(/^## (.+)$/gm,`<h2>$1</h2>`).replace(/^# (.+)$/gm,`<h1>$1</h1>`).replace(/\*\*\*(.+?)\*\*\*/g,`<strong><em>$1</em></strong>`).replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`).replace(/\*(.+?)\*/g,`<em>$1</em>`).replace(/`([^`\n]+)`/g,`<code>$1</code>`).replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{let r=n.trim();return/^(https?:\/\/|mailto:|#)/i.test(r)?`<a href="${r}" target="_blank" rel="noopener noreferrer">${t}</a>`:t}).replace(/^[*-] (.+)$/gm,`<li>$1</li>`).replace(/\n\n/g,`</p><p>`).replace(/\n/g,`<br>`);for(let e=0;e<n.length;e++)r=r.replace(`\x00BLOCK${e}\x00`,n[e]);return r}var cD=V(`<span style="background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill); padding: 2px 8px; font-size: var(--tandem-text-xs);"> </span>`),lD=V(`<button title="Clear chat history" data-testid="clear-chat-btn" style="background: none; border: none; cursor: pointer; color: var(--tandem-fg-subtle); font-size: 13px; padding: 2px 4px; line-height: 1;">Clear</button>`),uD=V(`<div style="color: var(--tandem-fg-subtle); font-size: 13px; text-align: center; margin-top: 24px;">No messages yet. Select text and send a message to your AI.</div>`),dD=V(`<span style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-muted); background: var(--tandem-surface-muted); padding: 1px 6px; border-radius: var(--tandem-r-2);"> </span>`),fD=V(`<button type="button" class="chat-anchor-quote" title="Click to scroll to this text"> </button>`),pD=V(`<div class="chat-markdown svelte-15oag3v"></div>`),mD=V(`<div style="white-space: pre-wrap; word-break: break-word;"> </div>`),hD=V(`<div><div style="display: flex; gap: 6px; align-items: center; margin-bottom: 4px;"><span> </span> <!> <span style="font-size: 10px; color: var(--tandem-fg-subtle); margin-left: auto;"> </span></div> <!> <!></div>`),gD=V(`<span></span>`),_D=V(`<div style="padding: var(--tandem-space-2) var(--tandem-space-3); margin-bottom: var(--tandem-space-2); font-size: 12px; color: var(--tandem-author-claude); display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="display: inline-flex; gap: 3px;"></span> <span> </span></div>`),vD=V(`<div style="padding: var(--tandem-space-1) var(--tandem-space-3); background: var(--tandem-accent-bg); border-top: 1px solid var(--tandem-accent-border); font-size: 11px; color: var(--tandem-accent-fg-strong); display: flex; justify-content: space-between; align-items: center;"><span> </span> <button style="background: none; border: none; cursor: pointer; color: var(--tandem-fg-muted); font-size: 14px;">x</button></div>`),yD=V(`<div style="width: 100%; display: flex; flex-direction: column; background: var(--tandem-surface-muted); flex: 1; min-height: 0;"><div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); font-weight: 600; font-size: var(--tandem-text-md); display: flex; justify-content: space-between; align-items: center;">Chat <div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><!> <!></div></div> <div class="tandem-scroll-fade-y" style="flex: 1; overflow: auto; padding: var(--tandem-space-3); min-height: 0;"><!> <!> <!> <div></div></div> <!> <div class="chat-input-area svelte-15oag3v"><textarea placeholder="Message your AI…" class="chat-textarea svelte-15oag3v"></textarea> <button class="chat-send-btn svelte-15oag3v" aria-label="Send message" title="Send · Enter" data-testid="chat-send-btn"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" style="display:block" aria-hidden="true"><path d="M14 2L2 8l4 2 2 4 2-4 4-8z"></path></svg></button></div></div>`);function bD(e,t){k(t,!0);let n=[0,.2,.4],r=qE(J_()),i=q(t,`inputEl`,15,null),a=j(()=>t.reduceMotion?`auto`:`smooth`),o=M(un([])),s=M(``),c=M(void 0),l=M(void 0);L(()=>{i(z(l)??null)}),L(()=>{if(!t.ctrlYdoc)return;let e=t.ctrlYdoc.getMap(Ua),n=()=>{let t=[];e.forEach(e=>{t.push(e)}),t.sort((e,t)=>e.timestamp-t.timestamp||e.id.localeCompare(t.id)),N(o,t,!0)};return e.observe(n),n(),()=>e.unobserve(n)});let u=!1;L(()=>{z(o);let e=!!t.claudeActive,n=Ar(()=>z(a));if(!e&&u){u=!1;return}u=e,z(c)?.scrollIntoView({behavior:n})}),L(()=>{let e=t.visible,n=Ar(()=>z(a));e&&z(c)?.scrollIntoView({behavior:n})});let d=j(()=>z(o).filter(e=>e.author===`claude`&&!e.read).length);function f(){if(!t.ctrlYdoc||!z(s).trim())return;let e=t.ctrlYdoc.getMap(Ua),n={id:uc(),author:`user`,text:z(s).trim(),timestamp:Date.now(),...t.activeDocId?{documentId:t.activeDocId}:{},...t.capturedAnchor?{anchor:t.capturedAnchor}:{},read:!1};e.set(n.id,n),N(s,``),t.onCapturedAnchorChange(null),window.dispatchEvent(new CustomEvent(`tandem:addressed-ai`,{detail:{via:`chat`}}))}function p(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),f())}function m(e,n){if(!(!t.editor||n&&n!==t.activeDocId))try{let n=QE(t.editor.state.doc,e.from),r=QE(t.editor.state.doc,e.to);t.editor.chain().focus().setTextSelection({from:n,to:r}).scrollIntoView().run()}catch(e){console.warn(`[ChatPanel] Could not scroll to anchor:`,e instanceof Error?e.message:e)}}function h(e){return e?t.openDocs.find(t=>t.id===e)?.fileName??null:null}async function g(){try{await fetch(`http://127.0.0.1:${xa}${Nc}`,{method:`DELETE`})}catch(e){console.warn(`[ChatPanel] Failed to clear chat:`,e)}}let _=M(un(new Set));function v(e){let t=new Set(z(_));t.has(e)?t.delete(e):t.add(e),N(_,t,!0)}var y=yD(),b=P(y),x=I(P(b)),S=P(x),C=e=>{var t=cD(),n=P(t,!0);D(t),R(()=>U(n,z(d))),H(e,t)};W(S,e=>{z(d)>0&&e(C)});var w=I(S,2),ee=e=>{var t=lD();B(`click`,t,g),H(e,t)};W(w,e=>{z(o).length>0&&e(ee)}),D(x),D(b);var T=I(b,2),te=P(T),ne=e=>{H(e,uD())};W(te,e=>{z(o).length===0&&e(ne)});var E=I(te,2);pi(E,17,()=>z(o),e=>e.id,(e,t)=>{var n=hD(),i=P(n),a=P(i),o=P(a,!0);D(a);var s=I(a,2),c=e=>{var n=dD(),r=P(n,!0);D(n),R(e=>U(r,e),[()=>h(z(t).documentId)??z(t).documentId]),H(e,n)};W(s,e=>{z(t).documentId&&e(c)});var l=I(s,2),u=P(l,!0);D(l),D(i);var d=I(i,2),f=e=>{var n=fD(),r=P(n,!0);D(n),R(e=>{G(n,`background: var(--tandem-accent-bg); border: none; border-left: 3px solid var(--tandem-accent-border); padding: 4px 8px; margin-bottom: 6px; font: inherit; color: var(--tandem-accent-fg-strong); cursor: pointer; text-align: left; width: 100%; font-size: var(--tandem-text-sm); border-radius: 0 var(--tandem-r-2) var(--tandem-r-2) 0; max-height: ${e??``}; overflow: hidden; transition: max-height 0.3s ease;`),U(r,z(t).anchor.textSnapshot)},[()=>z(_).has(z(t).id)?`500px`:`60px`]),B(`click`,n,()=>m(z(t).anchor,z(t).documentId)),zr(`mouseenter`,n,()=>v(z(t).id)),zr(`mouseleave`,n,()=>v(z(t).id)),H(e,n)};W(d,e=>{z(t).anchor&&e(f)});var p=I(d,2),g=e=>{var n=pD();yi(n,()=>sD(z(t).text),!0),D(n),H(e,n)},y=e=>{var n=mD(),r=P(n,!0);D(n),R(()=>U(r,z(t).text)),H(e,n)};W(p,e=>{z(t).author===`claude`?e(g):e(y,-1)}),D(n),R(e=>{G(n,`margin-bottom: var(--tandem-space-3); padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-4); background: ${z(t).author===`user`?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; border: 1px solid ${z(t).author===`user`?`var(--tandem-accent-border)`:`var(--tandem-border)`}; font-size: var(--tandem-text-base); color: var(--tandem-fg); box-shadow: var(--tandem-shadow-1);`),G(a,`font-weight: 600; font-size: 11px; color: ${z(t).author===`claude`?`var(--tandem-accent)`:`var(--tandem-fg-muted)`}; text-transform: uppercase;`),U(o,z(t).author===`claude`?r.family:`You`),U(u,e)},[()=>new Date(z(t).timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]),H(e,n)});var re=I(E,2),ie=e=>{var r=_D(),i=P(r);pi(i,20,()=>n,e=>e,(e,t)=>{var n=gD();R(()=>G(n,`width: 5px; height: 5px; border-radius: 50%; background: var(--tandem-author-claude); animation: tandem-typing-bounce 1.2s ease-in-out ${t??``}s infinite;`)),H(e,n)}),D(i);var a=I(i,2),o=P(a,!0);D(a),D(r),R(()=>U(o,t.claudeStatus??`Your AI is thinking...`)),H(e,r)};W(re,e=>{t.claudeActive&&e(ie)}),fa(I(re,2),e=>N(c,e),()=>z(c)),D(T),Pi(T,(e,t)=>Bu?.(e,t),()=>`y`);var ae=I(T,2),oe=e=>{var n=vD(),r=P(n),i=P(r);D(r);var a=I(r,2);D(n),R(e=>U(i,`with selection: “${e??``}${t.capturedAnchor.textSnapshot.length>40?`...`:``}”`),[()=>t.capturedAnchor.textSnapshot.slice(0,40)]),B(`click`,a,()=>t.onCapturedAnchorChange(null)),H(e,n)};W(ae,e=>{t.capturedAnchor&&e(oe)});var se=I(ae,2),ce=P(se);En(ce),K(ce,`rows`,1),fa(ce,e=>N(l,e),()=>z(l));var le=I(ce,2);D(se),D(y),R(e=>{ea(ce,z(s)),le.disabled=e},[()=>!z(s).trim()]),B(`input`,ce,e=>N(s,e.target.value,!0)),B(`keydown`,ce,p),B(`click`,le,f),H(e,y),A()}Br([`click`,`input`,`keydown`]);var xD=V(`<button type="button" data-testid="apply-changes-btn"> </button>`);function SD(e,t){k(t,!0);let n=M(!1),r=j(()=>t.annotations.filter(e=>e.status===`accepted`)),i=j(()=>t.annotations.filter(e=>e.status===`pending`)),a=j(()=>z(r).length===0||z(n));async function o(){if(z(a)||!t.documentId)return;let e=`Apply ${z(r).length} change(s) as tracked revisions?\n\nThe changes will appear as tracked revisions in Word — you can Accept or Reject each one individually.\n\nYour original file will be backed up.`;if(z(i).length>0&&(e+=`\n\n⚠ ${z(i).length} annotation(s) are still pending review and will not be applied.`),confirm(e)){N(n,!0);try{let e=await fetch(`${Il}${wc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId})}),n=await e.json().catch(e=>(console.error(`[ApplyChanges] Failed to parse response JSON:`,e),null));if(!e.ok){alert(n?.message??`Apply failed (HTTP ${e.status}).`);return}let r=n?.data;if(r){let e=[`Applied ${r.applied??0} tracked change(s).`];r.rejected>0&&e.push(`${r.rejected} could not be applied.`),r.backupPath&&e.push(`\nBackup saved to:\n${r.backupPath}`),alert(e.join(` `))}else alert(`Changes applied successfully.`)}catch(e){console.error(`[ApplyChanges] Request failed:`,e),alert(e instanceof TypeError?`Could not reach the server.`:`Apply failed: ${e instanceof Error?e.message:String(e)}`)}finally{N(n,!1)}}}var s=Xr(),c=F(s),l=e=>{var t=xD();let i;var s=P(t,!0);D(t),R(()=>{i=Ui(t,1,`acb-btn svelte-hdlegv`,null,i,{"is-disabled":z(a),"is-applying":z(n)}),t.disabled=z(a),K(t,`title`,z(r).length===0?`No accepted suggestions to apply`:void 0),U(s,z(n)?`Applying…`:`Apply as Tracked Changes (${z(r).length})`)}),B(`click`,t,o),H(e,t)};W(c,e=>{t.activeDocFormat===`docx`&&e(l)}),H(e,s),A()}Br([`click`]);function CD(e,t){return e.id<t.id?-1:+(e.id>t.id)}function wD(e){return[...e].sort((e,t)=>{let n=Number.isFinite(e.range?.from)?e.range.from:1/0,r=Number.isFinite(t.range?.from)?t.range.from:1/0;return n===r?CD(e,t):n<r?-1:1})}function TD(e){return[...e].sort((e,t)=>{let n=(Number.isFinite(e.timestamp)?e.timestamp:0)-(Number.isFinite(t.timestamp)?t.timestamp:0);return n===0?CD(e,t):n})}function ED(e,t){return t===`chronological`?TD(e):wD(e)}function DD(e,t){if(!t)return-1;for(let n=0;n<e.length;n++)if(e[n].id===t)return n;return-1}function OD(e,t){if(e.length===0)return null;let n=DD(e,t);return n===-1?e[0].id:e[(n+1)%e.length].id}function kD(e,t){if(e.length===0)return null;let n=DD(e,t);return n===-1?e[e.length-1].id:e[(n-1+e.length)%e.length].id}var AD={background:`var(--tandem-warning-bg)`,border:`var(--tandem-warning-border)`,color:`var(--tandem-warning-fg-strong)`};function jD(e,t){return e.type===`highlight`?[]:t??[]}var MD=V(`<button class="aca-btn aca-btn--accept svelte-1u9ox5p">Accept</button>`),ND=V(`<button class="aca-btn aca-btn--reject svelte-1u9ox5p">Reject</button>`),PD=V(`<div class="aca-row svelte-1u9ox5p"><!> <!></div>`),FD=V(`<button class="aca-btn aca-btn--ghost svelte-1u9ox5p">Archive</button>`),ID=V(`<button class="aca-btn aca-btn--send svelte-1u9ox5p"> </button>`),LD=V(`<div class="aca-row svelte-1u9ox5p"><!> <!></div>`),RD=V(`<button class="aca-btn aca-btn--ghost aca-standalone svelte-1u9ox5p">Remove</button>`),zD=V(`<div class="aca-undo-error svelte-1u9ox5p">Can't undo — text has changed.</div>`),BD=V(`<div class="aca-undo-row svelte-1u9ox5p"><button data-testid="undo-btn" class="aca-undo svelte-1u9ox5p">Undo</button> <!></div>`);function VD(e,t){k(t,!0);let n=qE(J_()),r=M(!1),i=null;function a(){i&&=(clearTimeout(i),null)}function o(e){if(e.stopPropagation(),!t.onUndo)return;let n=t.onUndo(t.annotationId);if(n){a(),N(r,!1);return}n||(N(r,!0),a(),i=setTimeout(()=>{N(r,!1),i=null},3e3))}va(a);var s=Xr(),c=F(s),l=e=>{var n=PD(),r=P(n),i=e=>{var n=MD();R(()=>K(n,`data-testid`,`accept-btn-${t.annotationId??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onAccept(t.annotationId)}),H(e,n)};W(r,e=>{t.onAccept&&e(i)});var a=I(r,2),o=e=>{var n=ND();R(()=>K(n,`data-testid`,`dismiss-btn-${t.annotationId??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onDismiss(t.annotationId)}),H(e,n)};W(a,e=>{t.onDismiss&&e(o)}),D(n),H(e,n)},u=e=>{var r=LD(),i=P(r),a=e=>{var n=FD();R(()=>K(n,`data-testid`,`archive-btn-${t.annotationId??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onRemove(t.annotationId)}),H(e,n)};W(i,e=>{t.onRemove&&e(a)});var o=I(i,2),s=e=>{var r=ID(),i=P(r);D(r),R(()=>{K(r,`data-testid`,`send-to-claude-btn-${t.annotationId??``}`),U(i,`Send to ${n.family??``}`)}),B(`click`,r,e=>{e.stopPropagation(),t.onSendToClaude(t.annotationId)}),H(e,r)};W(o,e=>{t.onSendToClaude&&e(s)}),D(r),H(e,r)},d=e=>{var n=RD();R(()=>K(n,`data-testid`,`remove-btn-${t.annotationId??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onRemove(t.annotationId)}),H(e,n)},f=e=>{var t=BD(),n=P(t),i=I(n,2),a=e=>{H(e,zD())};W(i,e=>{z(r)&&e(a)}),D(t),B(`click`,n,o),H(e,t)};W(c,e=>{t.isPending&&!t.isEditing&&(t.onAccept||t.onDismiss)?e(l):t.isPending&&!t.isEditing&&t.annotationType===`note`?e(u,1):t.isPending&&!t.isEditing&&t.onRemove?e(d,2):!t.isPending&&t.undoable&&t.onUndo&&e(f,3)}),H(e,s),A()}Br([`click`]);var HD=`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);`,UD=V(`<label style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); display: block; margin-bottom: 2px;">Replacement text</label> <textarea></textarea> <label style="font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); display: block; margin-top: 4px; margin-bottom: 2px;">Reason</label> <textarea></textarea>`,1),WD=V(`<textarea></textarea>`),GD=V(`<div style="margin-top: 4px;"><!> <div style="display: flex; gap: 2px; margin-top: 4px;"><button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-success-bg); color: var(--tandem-success-fg-strong); cursor: pointer;">Save</button> <button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button></div></div>`);function KD(e,t){k(t,!0);let n=M(null);L(()=>{z(n)?.focus()});var r=GD(),i=P(r),a=e=>{var r=UD(),i=F(r),a=I(i,2);En(a),fa(a,e=>N(n,e),()=>z(n));var o=I(a,2),s=I(o,2);En(s),R(()=>{K(i,`for`,`edit-newtext-${t.annotationId??``}`),K(a,`id`,`edit-newtext-${t.annotationId??``}`),K(a,`data-testid`,`edit-newtext-${t.annotationId??``}`),ea(a,t.editNewText),G(a,HD),K(o,`for`,`edit-reason-${t.annotationId??``}`),K(s,`id`,`edit-reason-${t.annotationId??``}`),K(s,`data-testid`,`edit-reason-${t.annotationId??``}`),ea(s,t.editReason),G(s,HD)}),B(`input`,a,e=>t.onChangeEditNewText(e.target.value)),B(`keydown`,a,function(...e){t.onKeyDown?.apply(this,e)}),B(`input`,s,e=>t.onChangeEditReason(e.target.value)),B(`keydown`,s,function(...e){t.onKeyDown?.apply(this,e)}),H(e,r)},o=e=>{var r=WD();En(r),fa(r,e=>N(n,e),()=>z(n)),R(()=>{K(r,`data-testid`,`edit-text-${t.annotationId??``}`),ea(r,t.editText),G(r,HD)}),B(`input`,r,e=>t.onChangeEditText(e.target.value)),B(`keydown`,r,function(...e){t.onKeyDown?.apply(this,e)}),H(e,r)};W(i,e=>{t.hasSuggestedText?e(a):e(o,-1)});var s=I(i,2),c=P(s),l=I(c,2);D(s),D(r),R(()=>{K(c,`data-testid`,`edit-save-btn-${t.annotationId??``}`),K(l,`data-testid`,`edit-cancel-btn-${t.annotationId??``}`)}),B(`click`,r,e=>e.stopPropagation()),B(`keydown`,r,e=>e.stopPropagation()),B(`click`,c,e=>{e.stopPropagation(),t.onSave()}),B(`click`,l,e=>{e.stopPropagation(),t.onCancel()}),H(e,r),A()}Br([`click`,`keydown`,`input`]);function qD(e,t){return e===`claude`?t??`Assistant`:e===`import`?`Imported`:`You`}function JD(e){let t=Math.floor((Date.now()-e)/6e4);if(t<1)return`just now`;if(t<60)return`${t}m ago`;let n=Math.floor(t/60);return n<24?`${n}h ago`:new Date(e).toLocaleDateString()}function YD(e){return e.suggestedText===void 0?e.type:`replacement`}function XD(e,t){return e?e.length>t?e.slice(0,t-3)+`...`:e:``}function ZD(e){let t=YD(e),n=XD(e.content,60);return`${e.type===`note`?`private `:``}${t} annotation${n?`: `+n:``}, ${e.status}`}function QD(e){return e.type===`highlight`&&e.color?ka[Aa(e.color)]:`var(--tandem-author-user)`}var $D=V(`<span> </span>`),eO=V(`<button class="ach-edit-btn svelte-d1dbnh" title="Edit this annotation's content">✎ Edit</button>`),tO=V(`<span class="ach-edited svelte-d1dbnh">(edited)</span>`),nO=V(`<span class="ach-dot svelte-d1dbnh" aria-hidden="true"></span>`),rO=V(`<div class="ach-row svelte-d1dbnh"><span class="ach-type svelte-d1dbnh"><span class="ach-badge annotation-type-badge svelte-d1dbnh"> </span> <!> <!> <!></span> <span class="ach-author svelte-d1dbnh"><!> <!> <span class="ach-time svelte-d1dbnh"> </span></span></div>`);function iO(e,t){k(t,!0);let n=qE(J_()),r=j(()=>YD(t.annotation)),i=j(()=>qD(t.annotation.author,n.family)),a=j(()=>t.annotation.author===`claude`?`var(--tandem-author-claude)`:`var(--tandem-author-user)`);var o=rO(),s=P(o),c=P(s),l=P(c,!0);D(c);var u=I(c,2),d=e=>{var n=Xr();bi(F(n),()=>t.extraPill),H(e,n)};W(u,e=>{t.extraPill&&e(d)});var f=I(u,2),p=e=>{var n=$D();let r;var i=P(n,!0);D(n),R(()=>{r=Ui(n,1,`ach-status svelte-d1dbnh`,null,r,{"is-accepted":t.annotation.status===`accepted`,"is-rejected":t.annotation.status!==`accepted`}),U(i,t.annotation.status)}),H(e,n)};W(f,e=>{t.isPending||e(p)});var m=I(f,2),h=e=>{var n=eO();R(()=>K(n,`data-testid`,`edit-btn-${t.annotation.id??``}`)),B(`click`,n,e=>{e.stopPropagation(),t.onEnterEdit()}),H(e,n)};W(m,e=>{t.isPending&&t.canEdit&&!t.isReviewTarget&&!t.isEditing&&e(h)}),D(s);var g=I(s,2),_=P(g),v=e=>{H(e,tO())};W(_,e=>{t.annotation.editedAt&&e(v)});var y=I(_,2),b=e=>{var t=nO();R(()=>G(t,`background: ${z(a)??``};`)),H(e,t)};W(y,e=>{t.annotation.author!==`import`&&e(b)});var x=I(y),S=I(x),C=P(S,!0);D(S),D(g),D(o),R((e,n)=>{G(c,`background: ${t.badgeBg??``}; color: ${t.badgeFg??``};`),U(l,z(r)),U(x,` ${z(i)??``} `),K(S,`title`,e),U(C,n)},[()=>new Date(t.annotation.timestamp).toLocaleString(),()=>JD(t.annotation.timestamp)]),H(e,o),A()}Br([`click`]);var aO=V(`<div style="padding: 4px 8px; margin-bottom: 6px; border-left: 3px solid var(--tandem-border-strong); color: var(--tandem-fg-muted); font-size: 12px; font-style: italic; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-1);"> </div>`);function oO(e,t){k(t,!0);let n=j(()=>t.text?t.text.length>80?t.text.slice(0,77)+`...`:t.text:``);var r=Xr(),i=F(r),a=e=>{var r=aO(),i=P(r,!0);D(r),R(()=>{K(r,`data-testid`,`annotation-snippet-${t.annotationId??``}`),U(i,z(n))}),H(e,r)};W(i,e=>{t.text&&e(a)}),H(e,r),A()}var sO=V(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),cO=V(`<!> <!> <!>`,1);function lO(e,t){k(t,!0);var n=cO(),r=F(n);iO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-surface-sunk)`,badgeFg:`var(--tandem-fg-muted)`,get onEnterEdit(){return t.onEnterEdit}});var i=I(r,2);oO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=I(i,2),o=e=>{var n=sO(),r=P(n),i=P(r,!0);D(r),D(n),R(()=>U(i,t.annotation.content||`(no note)`)),H(e,n)};W(a,e=>{t.isEditing||e(o)}),H(e,n),A()}var uO=V(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),dO=V(`<!> <!> <!>`,1);function fO(e,t){k(t,!0);var n=dO(),r=F(n);iO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-surface-sunk)`,badgeFg:`var(--tandem-fg-muted)`,get onEnterEdit(){return t.onEnterEdit}});var i=I(r,2);oO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=I(i,2),o=e=>{var n=uO(),r=P(n),i=P(r,!0);D(r),D(n),R(()=>U(i,t.annotation.content||`(no note)`)),H(e,n)};W(a,e=>{t.isEditing||e(o)}),H(e,n),A()}var pO=V(`<input type="checkbox" style="margin-top: 4px; flex-shrink: 0; cursor: pointer;"/>`),mO=V(`<div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-bottom: 4px;">From: <span style="font-weight: 500;"> </span></div>`),hO=V(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),gO=V(`<div style="display: flex; align-items: flex-start; gap: var(--tandem-space-2);"><!> <div style="flex: 1; min-width: 0;"><!> <!> <!> <!></div></div>`);function _O(e,t){k(t,!0);let n=q(t,`selected`,3,!1);var r=gO(),i=P(r),a=e=>{var r=pO();$i(r),R(()=>{K(r,`data-testid`,`annotation-select-checkbox-${t.annotation.id??``}`),ta(r,n()),K(r,`aria-label`,`Select ${t.annotation.importSource?.author??`import`} comment for batch promote`)}),B(`click`,r,e=>e.stopPropagation()),B(`change`,r,()=>t.onToggleSelect?.(t.annotation.id)),H(e,r)};W(i,e=>{t.onToggleSelect&&e(a)});var o=I(i,2),s=P(o);iO(s,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-surface-sunk)`,badgeFg:`var(--tandem-fg-muted)`,get onEnterEdit(){return t.onEnterEdit}});var c=I(s,2),l=e=>{var n=mO(),r=I(P(n)),i=P(r,!0);D(r),D(n),R(()=>{K(n,`data-testid`,`annotation-import-byline-${t.annotation.id??``}`),U(i,t.annotation.importSource.author)}),H(e,n)};W(c,e=>{t.annotation.importSource?.author&&e(l)});var u=I(c,2);oO(u,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var d=I(u,2),f=e=>{var n=hO(),r=P(n),i=P(r,!0);D(r),D(n),R(()=>U(i,t.annotation.content||`(no note)`)),H(e,n)};W(d,e=>{t.isEditing||e(f)}),D(o),D(r),H(e,r),A()}Br([`click`,`change`]);var vO=V(`<span data-testid="annotation-private-pill" aria-hidden="true" title="Private note" style="padding: 1px 6px; font-size: var(--tandem-text-2xs); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--tandem-warning-fg); background: var(--tandem-warning); border-radius: var(--tandem-r-2); line-height: 1;">Private</span>`),yO=V(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><p style="margin: 0;"> </p></div>`),bO=V(`<!> <!> <!>`,1);function xO(e,t){k(t,!0);var n=bO(),r=F(n);iO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-warning-bg)`,badgeFg:`var(--tandem-warning-fg-strong)`,get onEnterEdit(){return t.onEnterEdit},extraPill:e=>{H(e,vO())},$$slots:{extraPill:!0}});var i=I(r,2);oO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=I(i,2),o=e=>{var n=yO(),r=P(n),i=P(r,!0);D(r),D(n),R(()=>U(i,t.annotation.content||`(no note)`)),H(e,n)};W(a,e=>{t.isEditing||e(o)}),H(e,n),A()}var SO=V(`<span class="ct-author-dot ct-author-dot--claude svelte-4l0b78" aria-hidden="true"></span> `,1),CO=V(`<span> </span>`),wO=V(`<span class="ct-author-dot ct-author-dot--user svelte-4l0b78" aria-hidden="true"></span> You`,1),TO=V(`<span class="ct-edited svelte-4l0b78">(edited)</span>`),EO=V(`<div class="ct-reply svelte-4l0b78"><div class="ct-reply-head svelte-4l0b78"><span><!></span> <span class="ct-time svelte-4l0b78"><!> </span></div> <p class="ct-body svelte-4l0b78"> </p></div>`),DO=V(`<div class="ct-root svelte-4l0b78" data-testid="comment-thread"></div>`);function OO(e,t){k(t,!0);let n=qE(J_());var r=Xr(),i=F(r),a=e=>{var r=DO();pi(r,21,()=>t.replies,e=>e.id,(e,t)=>{let r=j(()=>z(t).author===`claude`?`claude`:z(t).author===`import`?`import`:`user`);var i=EO(),a=P(i),o=P(a);let s;var c=P(o),l=e=>{var t=SO(),r=I(F(t));R(()=>U(r,` ${n.family??``}`)),H(e,t)},u=e=>{var n=CO(),r=P(n,!0);D(n),R(()=>{K(n,`data-testid`,`reply-import-byline-${z(t).id??``}`),U(r,z(t).importAuthor??`Imported`)}),H(e,n)},d=e=>{var t=wO();O(),H(e,t)};W(c,e=>{z(r)===`claude`?e(l):z(r)===`import`?e(u,1):e(d,-1)}),D(o);var f=I(o,2),p=P(f),m=e=>{H(e,TO())};W(p,e=>{z(t).editedAt&&e(m)});var h=I(p);D(f),D(a);var g=I(a,2),_=P(g,!0);D(g),D(i),R(e=>{K(i,`data-testid`,`reply-${z(t).id??``}`),s=Ui(o,1,`ct-author svelte-4l0b78`,null,s,{"is-claude":z(r)===`claude`,"is-import":z(r)===`import`,"is-user":z(r)===`user`}),U(h,` ${e??``}`),U(_,z(t).text)},[()=>JD(z(t).timestamp)]),H(e,i)}),D(r),H(e,r)};W(i,e=>{t.replies.length>0&&e(a)}),H(e,r),A()}var kO=V(`<div class="art-replies svelte-155xn9n"><!></div>`),AO=V(`<button type="button"><span class="art-arrow svelte-155xn9n" aria-hidden="true">›</span> </button> <!>`,1),jO=V(`<div><textarea placeholder="Write a reply..."></textarea> <div style="display: flex; gap: 2px; margin-top: 2px;"><button>Send</button> <button style="padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button></div></div>`),MO=V(`<button style="padding: 1px 4px; font-size: var(--tandem-text-xs); border: none; background: none; color: var(--tandem-fg-subtle); cursor: pointer;">Reply</button>`),NO=V(`<div style="margin-top: 6px;"><!></div>`),PO=V(`<div class="art-root svelte-155xn9n"><!> <!></div>`);function FO(e,t){k(t,!0);let n=q(t,`reduceMotion`,3,!1),r=q(t,`openNonce`,3,0),i=j(()=>jD(t.annotation,t.replies)),a=j(()=>t.annotation.id),o=M(!1),s=M(!1),c=M(``),l=M(!1),u=M(null),d=j(()=>!!z(c).trim());L(()=>{z(s)&&z(u)?.focus()});let f=Ar(()=>r());L(()=>{r()!==f&&(f=r(),N(s,!0))});function p(e){e.key===`Escape`&&(e.stopPropagation(),N(s,!1),N(c,``))}async function m(){let e=z(c).trim();if(!(!e||z(l))){N(l,!0);try{await t.onReply?.(z(a),e)!==!1&&(N(c,``),N(s,!1))}finally{N(l,!1)}}}var h=PO(),g=P(h),_=e=>{var t=AO(),r=F(t);let s;var c=I(P(r));D(r);var l=I(r,2),u=e=>{var t=kO();OO(P(t),{get replies(){return z(i)}}),D(t),Mi(3,t,()=>vv,()=>({reduceMotion:n()})),H(e,t)};W(l,e=>{z(o)&&e(u)}),R(()=>{K(r,`data-testid`,`reply-toggle-${z(a)??``}`),s=Ui(r,1,`art-toggle svelte-155xn9n`,null,s,{open:z(o)}),K(r,`aria-expanded`,z(o)),U(c,` ${z(i).length===1?`1 reply`:`${z(i).length} replies`}`)}),B(`click`,r,e=>{e.stopPropagation(),N(o,!z(o))}),H(e,t)};W(g,e=>{z(i).length>0&&e(_)});var v=I(g,2),y=e=>{var t=NO(),n=P(t),r=e=>{var t=jO(),n=P(t);En(n),fa(n,e=>N(u,e),()=>z(u));var r=I(n,2),i=P(r),o=I(i,2);D(r),D(t),R(()=>{K(n,`data-testid`,`reply-input-${z(a)??``}`),ea(n,z(c)),G(n,HD),K(i,`data-testid`,`reply-send-btn-${z(a)??``}`),i.disabled=!z(d)||z(l),G(i,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); background: ${z(d)?`var(--tandem-accent-bg)`:`var(--tandem-surface-muted)`}; color: ${z(d)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-subtle)`}; cursor: ${z(d)?`pointer`:`default`};`),K(o,`data-testid`,`reply-cancel-btn-${z(a)??``}`)}),B(`input`,n,e=>N(c,e.target.value,!0)),B(`keydown`,n,p),B(`click`,i,m),B(`click`,o,()=>{N(s,!1),N(c,``)}),H(e,t)},i=e=>{var t=MO();R(()=>K(t,`data-testid`,`reply-btn-${z(a)??``}`)),B(`click`,t,()=>N(s,!0)),H(e,t)};W(n,e=>{z(s)?e(r):e(i,-1)}),D(t),B(`click`,t,e=>e.stopPropagation()),B(`keydown`,t,e=>e.stopPropagation()),H(e,t)};W(v,e=>{t.isPending&&t.onReply&&!t.isEditing&&e(y)}),D(h),H(e,h),A()}Br([`click`,`keydown`,`input`]);var IO=V(`<span style="text-decoration: line-through; color: var(--tandem-error); background-color: var(--tandem-error-bg); padding: 0 2px; border-radius: var(--tandem-r-1);"> </span> `,1),LO=V(`<p style="margin: 0; font-size: 12px; color: var(--tandem-fg-muted);"> </p>`),RO=V(`<div class="aca-body" style="margin: 0; color: var(--tandem-fg); line-height: 1.45;"><div><!> <span style="color: var(--tandem-success-fg-strong); background-color: var(--tandem-success-bg); padding: 0 2px; border-radius: var(--tandem-r-1);"> </span></div> <!></div>`),zO=V(`<!> <!> <!>`,1);function BO(e,t){k(t,!0);var n=zO(),r=F(n);iO(r,{get annotation(){return t.annotation},get isPending(){return t.isPending},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return t.isEditing},get canEdit(){return t.canEdit},badgeBg:`var(--tandem-suggestion-bg)`,badgeFg:`var(--tandem-suggestion-fg-strong)`,get onEnterEdit(){return t.onEnterEdit}});var i=I(r,2);oO(i,{get annotationId(){return t.annotation.id},get text(){return t.annotation.textSnapshot}});var a=I(i,2),o=e=>{var n=RO(),r=P(n),i=P(r),a=e=>{var n=IO(),r=F(n),i=P(r,!0);D(r);var a=I(r);a.nodeValue=` → `,R(()=>U(i,t.annotation.textSnapshot)),H(e,n)};W(i,e=>{t.annotation.textSnapshot&&e(a)});var o=I(i,2),s=P(o,!0);D(o),D(r);var c=I(r,2),l=e=>{var n=LO(),r=P(n,!0);D(n),R(()=>U(r,t.annotation.content)),H(e,n)};W(c,e=>{t.annotation.content&&e(l)}),D(n),R(()=>{K(r,`data-testid`,`suggestion-diff-${t.annotation.id??``}`),G(r,`padding: 4px 8px; margin-bottom: ${t.annotation.content?`4px`:`0`}; background-color: var(--tandem-surface-muted); border-radius: var(--tandem-r-2); font-size: 12px; line-height: 1.5;`),U(s,t.annotation.suggestedText)}),H(e,n)};W(a,e=>{t.isEditing||e(o)}),H(e,n),A()}var VO=V(`<div class="tandem-claude-typing svelte-3ascys" role="status" aria-live="polite"><span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span> <span class="tandem-claude-typing-dot svelte-3ascys"></span></div>`),HO=V(`<div role="listitem"><!> <!> <!> <!> <!></div>`);function UO(e,t){k(t,!0);let n=q(t,`replies`,19,()=>[]),r=q(t,`claudeTyping`,3,!1),i=q(t,`selected`,3,!1),a=q(t,`density`,3,`full`),o=q(t,`lifecycleMotion`,3,!1),s=q(t,`reduceMotion`,3,!1),c=q(t,`openRequest`,3,null),l=qE(J_()),u=M(!1),d=M(``),f=M(``),p=M(``),m=j(()=>t.annotation.status===`pending`),h=j(()=>t.annotation.suggestedText!==void 0),g=j(()=>t.onEdit!==void 0),_=j(()=>ZD(t.annotation)),v=j(()=>jD(t.annotation,n())),y=j(()=>a()===`stub`?`stub`:z(u)?`full`:a()),b=-1,x=-1,S=M(0);L(()=>{let e=c();if(e)if(e.kind===`edit`){if(e.nonce===b)return;b=e.nonce,t.onEdit&&ee()}else{if(e.nonce===x)return;x=e.nonce,N(S,e.nonce,!0)}});let C=j(()=>t.annotation.author===`import`?`var(--tandem-surface-muted)`:t.annotation.type===`highlight`?`color-mix(in srgb, ${QD(t.annotation)} 18%, var(--tandem-surface))`:t.annotation.type===`note`?`var(--tandem-warning-bg)`:t.annotation.suggestedText===void 0?t.annotation.author===`claude`?`var(--tandem-author-claude-bg)`:`var(--tandem-author-user-bg)`:`var(--tandem-suggestion-bg)`),w=j(()=>t.isReviewTarget?`var(--tandem-accent-bg)`:z(C));function ee(){z(h)?(N(f,t.annotation.suggestedText??``,!0),N(p,t.annotation.content,!0)):N(d,t.annotation.content,!0),N(u,!0)}function T(){let e=z(h)?JSON.stringify({suggestedText:z(f),content:z(p)}):z(d);t.onEdit?.(t.annotation.id,e),N(u,!1)}function te(){N(u,!1)}function ne(e){e.key===`Escape`&&(e.stopPropagation(),te())}var E=HO();let re;var ie=P(E),ae=e=>{var n=VO();R(()=>{K(n,`data-testid`,`claude-typing-indicator-${t.annotation.id??``}`),K(n,`aria-label`,`${l.family??``} is working on this annotation`),K(n,`title`,`${l.family??``} is working on this annotation`)}),H(e,n)};W(ie,e=>{r()&&e(ae)});var oe=I(ie,2),se=e=>{_O(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:ee,get selected(){return i()},get onToggleSelect(){return t.onToggleSelect}})},ce=e=>{fO(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:ee})},le=e=>{xO(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:ee})},ue=e=>{BO(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:ee})},de=e=>{lO(e,{get annotation(){return t.annotation},get isPending(){return z(m)},get isReviewTarget(){return t.isReviewTarget},get isEditing(){return z(u)},get canEdit(){return z(g)},onEnterEdit:ee})};W(oe,e=>{t.annotation.author===`import`?e(se):t.annotation.type===`highlight`?e(ce,1):t.annotation.type===`note`?e(le,2):t.annotation.suggestedText===void 0?e(de,-1):e(ue,3)});var fe=I(oe,2),pe=e=>{KD(e,{get annotationId(){return t.annotation.id},get hasSuggestedText(){return z(h)},get editText(){return z(d)},get editNewText(){return z(f)},get editReason(){return z(p)},onChangeEditText:e=>N(d,e,!0),onChangeEditNewText:e=>N(f,e,!0),onChangeEditReason:e=>N(p,e,!0),onKeyDown:ne,onSave:T,onCancel:te})};W(fe,e=>{z(u)&&e(pe)});var me=I(fe,2);VD(me,{get annotationId(){return t.annotation.id},get annotationType(){return t.annotation.type},get isPending(){return z(m)},get isEditing(){return z(u)},get undoable(){return t.undoable},get onAccept(){return t.onAccept},get onDismiss(){return t.onDismiss},get onUndo(){return t.onUndo},get onRemove(){return t.onRemove},get onSendToClaude(){return t.onSendToClaude}}),FO(I(me,2),{get annotation(){return t.annotation},get replies(){return z(v)},get isPending(){return z(m)},get isEditing(){return z(u)},get onReply(){return t.onReply},get reduceMotion(){return s()},get openNonce(){return z(S)}}),D(E),R(()=>{re=Ui(E,1,`tandem-annotation-card svelte-3ascys`,null,re,{"is-review-target":t.isReviewTarget,"is-density-clamped":z(y)===`clamped`,"is-density-stub":z(y)===`stub`}),K(E,`data-testid`,`annotation-card-${t.annotation.id??``}`),K(E,`data-annotation-id`,t.annotation.id),K(E,`data-annotation-type`,t.annotation.type),K(E,`data-density`,z(y)),K(E,`data-claude-typing`,r()?`true`:void 0),K(E,`aria-label`,z(_)),K(E,`aria-current`,t.isReviewTarget?`true`:void 0),G(E,`background: ${z(w)??``}; opacity: ${z(m)?1:.6}; cursor: ${t.onClick?`pointer`:`default`};`)}),B(`click`,E,function(...e){t.onClick?.apply(this,e)}),Mi(1,E,()=>rv,()=>({enabled:o(),reduceMotion:s()})),Mi(2,E,()=>iv,()=>({enabled:o(),reduceMotion:s(),id:t.annotation.id,modes:t.exitModes})),H(e,E),A()}Br([`click`]);var WO=`browser`;function GO(e,t,n){let r,i=!1;if(e.transact(()=>{r=t(),i=!0},n),!i)throw Error(`origins: transact callback did not run (origin=${n})`);return r}function KO(e,t){return GO(e,t,WO)}function qO(e,t){let n=e,r=e=>{try{t(e)}catch(t){console.warn(`[sanitizeAnnotation] onLossy threw for ${e.kind}:`,t)}},i=n.audience===`private`||n.audience===`outbound`?n.audience:n.author===`import`||n.type===`highlight`||n.type===`note`||n.type===`flag`?`private`:`outbound`,a={id:n.id,author:n.author,range:n.range,content:n.content,status:n.status,timestamp:n.timestamp,...n.relRange===void 0?{}:{relRange:n.relRange},...n.textSnapshot===void 0?{}:{textSnapshot:n.textSnapshot},...n.editedAt===void 0?{}:{editedAt:n.editedAt},...typeof n.rev==`number`?{rev:n.rev}:{},audience:i,...n.promotedFrom===void 0?{}:{promotedFrom:n.promotedFrom},...n.importSource===void 0?{}:{importSource:n.importSource}};if(a.audience===`outbound`&&n.author===`user`&&(n.type===`note`||n.type===`highlight`||n.type===`flag`)&&(a.audience=`private`,r({kind:`audience-conflict-resolved`,id:n.id})),n.type===`suggestion`){let e,t;try{let r=JSON.parse(n.content);e=r.newText,t=r.reason??``}catch{r({kind:`malformed-suggestion-json`,id:n.id}),t=n.content}return{...a,type:`comment`,content:t,suggestedText:e}}return n.type===`question`?(r({kind:`question-to-comment`,id:n.id}),{...a,type:`comment`}):n.type===`highlight`?{...a,type:`highlight`,color:n.color}:n.type===`flag`||n.type===`note`?(n.type===`flag`&&r({kind:`flag-to-note`,id:n.id}),{...a,type:`note`}):n.type===`comment`?{...a,type:`comment`,...n.suggestedText===void 0?{}:{suggestedText:n.suggestedText}}:(r({kind:`unknown-type`,id:n.id,rawType:n.type}),{...a,type:`comment`})}var JO=e=>{console.warn(`[sanitize]`,e)};function YO(e,t,n){if(!e)return;let r=e.getMap(Ra),i=r.get(t);if(!i)return;let a=qO(i,JO);KO(e,()=>{if(a.suggestedText!==void 0){try{let e=JSON.parse(n);r.set(t,{...a,suggestedText:e.suggestedText,content:e.content,editedAt:Date.now(),rev:(a.rev??0)+1})}catch{console.warn(`[annotation-actions] Failed to parse edit payload for annotation ${t}`)}return}r.set(t,{...a,content:n,editedAt:Date.now(),rev:(a.rev??0)+1})})}function XO(e){let{color:t,suggestedText:n,...r}=e;return{...r,type:`comment`,author:e.author===`import`?`user`:e.author,audience:`outbound`,promotedFrom:`note`,rev:(e.rev??0)+1}}function ZO(e,t){if(!e)return;let n=e.getMap(Ra),r=n.get(t);if(!r)return;let i=qO(r,JO);i.type===`note`&&KO(e,()=>{n.set(t,XO(i))})}function QO(e,t){if(!e||t.length===0)return 0;let n=e.getMap(Ra),r=0;return KO(e,()=>{for(let e of t){let t=n.get(e);if(!t)continue;let i=qO(t,JO);i.type===`note`&&(n.set(e,XO(i)),r++)}}),r}async function $O(e,t){try{let n=await fetch(`${Il}${jc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({annotationId:e,documentId:t})});if(!n.ok){let e=await n.json().catch(()=>({message:`Unknown error`}));console.error(`[Tandem] Remove annotation failed:`,e)}}catch(e){console.error(`[Tandem] Remove annotation failed:`,e)}}async function ek(e,t,n){try{let r=await fetch(`${Il}${Ac}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({annotationId:e,text:t,documentId:n})});if(!r.ok){let e=await r.json().catch(()=>({}));return console.warn(`[annotation-actions] Reply failed (${r.status}): ${e.message??`unknown error`}`),!1}return!0}catch(e){return console.error(`[annotation-actions] Reply request failed:`,e),!1}}var tk=new Set([`ctx:annotation:accept`,`ctx:annotation:dismiss`,`ctx:annotation:reply`,`ctx:annotation:edit`,`ctx:annotation:sendToClaude`,`ctx:annotation:copy`,`ctx:annotation:remove`]);function nk(e){return typeof e==`string`&&tk.has(e)}var rk=e=>e.status===`pending`,ik=e=>e.author!==`user`&&rk(e),ak=e=>e.author!==`user`&&rk(e),ok=e=>(e.type===`note`||e.type===`comment`)&&rk(e),sk=e=>e.author===`user`&&rk(e),ck=e=>e.author===`user`&&e.type===`note`&&rk(e),lk=e=>e.author===`user`&&rk(e),uk=e=>!0;function dk(e){return{canAccept:ik(e),canDismiss:ak(e),canReply:ok(e),canEdit:sk(e),canSendToClaude:ck(e),canCopy:uk(e),canRemove:lk(e),isNote:e.type===`note`}}function fk(e){return e.content?.trim()?e.content:e.textSnapshot??``}var pk=null;function mk(e){pk=e}function hk(e,t,n){switch(e){case`ctx:annotation:accept`:ik(t)&&n.accept?.(t.id);return;case`ctx:annotation:dismiss`:ak(t)&&n.dismiss?.(t.id);return;case`ctx:annotation:sendToClaude`:ck(t)&&n.sendToClaude?.(t.id);return;case`ctx:annotation:remove`:lk(t)&&n.remove?.(t.id);return;case`ctx:annotation:edit`:sk(t)&&n.openEdit?.(t.id);return;case`ctx:annotation:reply`:ok(t)&&n.openReply?.(t.id);return;case`ctx:annotation:copy`:if(uk(t)){let e=fk(t);e&&navigator.clipboard.writeText(e).catch(()=>{})}return}}async function gk(e,t){mk({run:t});try{await(await Bm())(`show_annotation_context_menu`,{req:dk(e)})}catch{}}var _k=0,vk=null;function yk(){if(!Lm())return()=>{};_k++,_k===1&&(vk=Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`context-menu-action`,e=>{let t=e.payload?.id;nk(t)&&pk?.run(t)})),vk.catch(()=>{}));let e=!1;return()=>{if(!e&&(e=!0,_k--,_k===0)){let e=vk;vk=null,e?.then(e=>e()).catch(()=>{})}}}var bk=V(`<div data-testid="batch-promote-bar" role="region" aria-label="Batch promote imported notes" style="position: sticky; top: 0; z-index: var(--tandem-z-base); display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-4); background: var(--tandem-surface); border-bottom: 1px solid var(--tandem-border); box-shadow: var(--tandem-shadow-1);"><span data-testid="batch-promote-count" style="flex: 1; font-size: var(--tandem-text-2xs); font-weight: 500; color: var(--tandem-fg-subtle);"> </span> <button data-testid="batch-promote-clear" style="padding: 3px 10px; border: 1px solid transparent; background: none; color: var(--tandem-fg-subtle); border-radius: var(--tandem-r-pill); cursor: pointer; font-size: var(--tandem-text-xs);">Clear</button> <button data-testid="batch-promote-confirm" style="padding: 3px 12px; border: 1px solid var(--tandem-accent); background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill); cursor: pointer; font-size: var(--tandem-text-xs); font-weight: 500;"> </button></div>`);function xk(e,t){k(t,!0);let n=q(t,`reduceMotion`,3,!1),r=qE(J_());var i=Xr(),a=F(i),o=e=>{var i=bk(),a=P(i),o=P(a);D(a);var s=I(a,2),c=I(s,2),l=P(c);D(c),D(i),R(()=>{U(o,`${t.selectedCount??``} selected`),U(l,`Send ${t.selectedCount??``} to ${r.family??``}`)}),B(`click`,s,function(...e){t.onClear?.apply(this,e)}),B(`click`,c,function(...e){t.onPromote?.apply(this,e)}),Mi(1,i,()=>av,()=>({reduceMotion:n()})),Mi(2,i,()=>ov,()=>({reduceMotion:n(),exitMs:200})),H(e,i)};W(a,e=>{t.selectedCount>0&&e(o)}),H(e,i),A()}Br([`click`]);var Sk=V(`<span style="font-size: var(--tandem-text-xs); color: var(--tandem-fg);"> </span> <button data-testid="bulk-confirm-btn">Confirm</button> <button data-testid="bulk-cancel-btn">Cancel</button>`,1),Ck=V(`<button data-testid="bulk-accept-btn"> </button> <button data-testid="bulk-dismiss-btn">Reject All</button>`,1),wk=V(`<div style="padding: 6px var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border); display: flex; gap: 4px; align-items: center;"><!></div>`);function Tk(e,t){k(t,!0);let n=q(t,`confirmRef`,15,null),r=q(t,`reduceMotion`,3,!1),i=j(()=>t.bulkConfirm===`accept`),a=j(()=>t.pendingCount===t.allPendingCount?`${t.pendingCount} annotations?`:`${t.pendingCount} of ${t.allPendingCount} pending?`);var o=Xr(),s=F(o),c=e=>{var o=wk(),s=P(o),c=e=>{var r=Sk(),o=F(r),s=P(o);D(o);var c=I(o,2);fa(c,e=>n(e),()=>n());var l=I(c,2);G(l,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-surface); color: var(--tandem-fg-muted);`),R(()=>{U(s,`${z(i)?`Accept`:`Reject`}
|
|
74
|
-
${z(a)??``}`),G(c,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: ${z(i)?`var(--tandem-success-bg)`:`var(--tandem-error-bg)`}; color: ${z(i)?`var(--tandem-success-fg-strong)`:`var(--tandem-error-fg-strong)`}; font-weight: 600;`)}),B(`click`,c,function(...e){(z(i)?t.onConfirmAccept:t.onConfirmDismiss)?.apply(this,e)}),B(`click`,l,function(...e){t.onCancel?.apply(this,e)}),H(e,r)},l=e=>{var n=Ck(),r=F(n);G(r,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-success-bg); color: var(--tandem-success-fg-strong);`);var i=P(r);D(r);var a=I(r,2);G(a,`padding: 2px 8px; font-size: var(--tandem-text-xs); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-1); cursor: pointer; background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong);`),R(()=>U(i,`Accept All (${t.pendingCount??``})`)),B(`click`,r,function(...e){t.onRequestAccept?.apply(this,e)}),B(`click`,a,function(...e){t.onRequestDismiss?.apply(this,e)}),H(e,n)};W(s,e=>{t.bulkConfirm?e(c):e(l,-1)}),D(o),Mi(1,o,()=>av,()=>({reduceMotion:r()})),Mi(2,o,()=>ov,()=>({reduceMotion:r(),exitMs:180})),H(e,o)};W(s,e=>{t.pendingCount>1&&e(c)}),H(e,o),A()}Br([`click`]);function Ek(e,t,n,r){return{handleKeyDown:i=>{let{key:a}=i;if(a!==`ArrowLeft`&&a!==`ArrowRight`&&a!==`ArrowUp`&&a!==`ArrowDown`&&a!==`Home`&&a!==`End`)return;let o=r?t.filter(e=>!r(e)):t;if(o.length===0)return;i.preventDefault();let s=e(),c=o.indexOf(s),l=o.length-1,u;u=a===`Home`?0:a===`End`?l:a===`ArrowLeft`||a===`ArrowUp`?c<=0?l:c-1:c>=l?0:c+1;let d=o[u];n(d);let f=i.currentTarget?.querySelectorAll(`[role="radio"]`),p=t.indexOf(d);f?.[p]?.focus()},tabIndexFor:n=>{if(r?.(n))return-1;let i=e(),a=r?t.filter(e=>!r(e)):t;return n===(r?.(i)?a[0]:i)?0:-1}}}var Dk=(e,t=m)=>{var n=Xr(),r=F(n),i=e=>{H(e,Ok())},a=e=>{H(e,kk())},o=e=>{H(e,Ak())},s=e=>{H(e,jk())},c=e=>{H(e,Mk())},l=e=>{H(e,Nk())},u=e=>{H(e,Pk())};W(r,e=>{t()===`highlight`?e(i):t()===`comment`?e(a,1):t()===`lock`?e(o,2):t()===`sparkle`?e(s,3):t()===`pending`?e(c,4):t()===`check`?e(l,5):t()===`dismiss`&&e(u,6)}),H(e,n)},Ok=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="svelte-v4eg2o"><path d="M3 13h10"></path><path d="M5 11l3 1 5-5-2-2-5 5z"></path><path d="M9 4l2 2"></path></svg>`),kk=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="svelte-v4eg2o"><path d="M2.5 3h11v8h-7l-3 2.5V11H2.5z"></path></svg>`),Ak=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" class="svelte-v4eg2o"><rect x="3" y="7" width="10" height="6" rx="1"></rect><path d="M5 7V5a3 3 0 0 1 6 0v2"></path></svg>`),jk=Jr(`<svg class="g-suggestion svelte-v4eg2o" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v4"></path><path d="M8 10v4"></path><path d="M2 8h4"></path><path d="M10 8h4"></path><path d="M4 4l1.5 1.5"></path><path d="M10.5 10.5L12 12"></path><path d="M12 4l-1.5 1.5"></path><path d="M5.5 10.5L4 12"></path></svg>`),Mk=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" class="svelte-v4eg2o"><circle cx="8" cy="8" r="5"></circle></svg>`),Nk=Jr(`<svg class="g-success svelte-v4eg2o" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8l3 3 7-7"></path></svg>`),Pk=Jr(`<svg class="g-error svelte-v4eg2o" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4l8 8M12 4l-8 8"></path></svg>`),Fk=V(`<span class="chip-text"> </span>`),Ik=V(`<span></span>`),Lk=V(`<button type="button" role="radio"><!></button>`),Rk=V(`<div class="chip-bar svelte-v4eg2o" role="radiogroup" tabindex="-1"><span aria-hidden="true"></span> <!></div>`);function zk(e,t){k(t,!0);let n=q(t,`value`,3,``),r=q(t,`options`,19,()=>[]),i=q(t,`onSet`,3,()=>{}),a=q(t,`groupAriaLabel`,3,``),o=q(t,`groupTestId`,3,``),s=Ek(()=>n(),Ar(()=>r().map(e=>e.value)),e=>i()(e)),c=M(null),l=M(un({left:0,width:0,ready:!1}));function u(){if(!z(c))return;let e=z(c).querySelector(`[aria-checked="true"]`);if(!e)return;let t=e.offsetLeft,n=e.offsetWidth;z(l).ready?N(l,{left:t,width:n,ready:!0},!0):(N(l,{left:t,width:n,ready:!1},!0),requestAnimationFrame(()=>{N(l,{left:t,width:n,ready:!0},!0)}))}L(()=>{if(n(),!z(c))return;let e=!1;return Dr().then(()=>{e||requestAnimationFrame(()=>{e||u()})}),()=>{e=!0}}),L(()=>{if(!z(c))return;let e=new ResizeObserver(()=>u());return e.observe(z(c)),()=>e.disconnect()});var d=Rk(),f=P(d);let p;pi(I(f,2),17,r,e=>e.value,(e,t)=>{let r=j(()=>z(t).value===n());var a=Lk();let c;var l=P(a),u=e=>{var n=Fk(),r=P(n,!0);D(n),R(()=>U(r,z(t).label)),H(e,n)},d=e=>{var n=Ik();R(()=>Ui(n,1,`pip pip-${z(t).pip??``}`,`svelte-v4eg2o`)),H(e,n)},f=e=>{Dk(e,()=>z(t).icon)};W(l,e=>{z(t).kind===`text`?e(u):z(t).kind===`pip`?e(d,1):z(t).kind===`icon`&&e(f,2)}),D(a),R(e=>{c=Ui(a,1,`chip svelte-v4eg2o`,null,c,{"is-checked":z(r)}),K(a,`aria-checked`,z(r)),K(a,`aria-label`,z(t).label),K(a,`title`,z(t).label),K(a,`tabindex`,e),K(a,`data-testid`,`${o()??``}-${z(t).value??``}`)},[()=>s.tabIndexFor(z(t).value)]),B(`click`,a,()=>i()(z(t).value)),H(e,a)}),D(d),fa(d,e=>N(c,e),()=>z(c)),R(()=>{K(d,`aria-label`,a()),K(d,`data-testid`,o()),p=Ui(f,1,`chip-thumb svelte-v4eg2o`,null,p,{ready:z(l).ready}),G(f,`left: ${z(l).left??``}px; width: ${z(l).width??``}px;`)}),B(`keydown`,d,function(...e){s.handleKeyDown?.apply(this,e)}),H(e,d),A()}Br([`keydown`,`click`]);var Bk=V(`<button data-testid="clear-filters-btn" style="background: none; border: none; color: var(--tandem-accent); font-size: 11px; cursor: pointer; padding: 2px 4px;">Clear</button>`),Vk=V(`<div style="padding: 8px 16px; border-bottom: 1px solid var(--tandem-border); display: flex; gap: 8px; flex-wrap: wrap; align-items: center;"><!> <!> <!> <!> <button style="background: none; border: none; color: var(--tandem-fg-subtle); font-size: 10px; cursor: pointer; padding: 2px 4px; margin-left: auto;" aria-label="Collapse filters">▲</button></div>`);function Hk(e,t){k(t,!0);let n=qE(J_()),r=[{value:`all`,label:`All types`,kind:`text`},{value:`highlight`,label:`Highlights`,kind:`icon`,icon:`highlight`},{value:`comment`,label:`Comments`,kind:`icon`,icon:`comment`},{value:`note`,label:`Notes`,kind:`icon`,icon:`lock`},{value:`with-replacement`,label:`With replacement`,kind:`icon`,icon:`sparkle`}],i=j(()=>[{value:`all`,label:`Anyone`,kind:`text`},{value:`claude`,label:n.family,kind:`pip`,pip:`claude`},{value:`user`,label:`You`,kind:`pip`,pip:`user`},{value:`import`,label:`Imported`,kind:`pip`,pip:`import`}]),a=[{value:`all`,label:`Any status`,kind:`text`},{value:`pending`,label:`Pending`,kind:`icon`,icon:`pending`},{value:`accepted`,label:`Accepted`,kind:`icon`,icon:`check`},{value:`dismissed`,label:`Dismissed`,kind:`icon`,icon:`dismiss`}];var o=Xr(),s=F(o),c=e=>{var n=Vk(),o=P(n);zk(o,{groupTestId:`filter-type`,groupAriaLabel:`Filter by type`,get value(){return t.filterType},get options(){return r},onSet:e=>t.onSetFilterType(e)});var s=I(o,2);zk(s,{groupTestId:`filter-author`,groupAriaLabel:`Filter by author`,get value(){return t.filterAuthor},get options(){return z(i)},onSet:e=>t.onSetFilterAuthor(e)});var c=I(s,2);zk(c,{groupTestId:`filter-status`,groupAriaLabel:`Filter by status`,get value(){return t.filterStatus},get options(){return a},onSet:e=>t.onSetFilterStatus(e)});var l=I(c,2),u=e=>{var n=Bk();B(`click`,n,function(...e){t.onClearFilters?.apply(this,e)}),H(e,n)};W(l,e=>{t.hasFilters&&e(u)});var d=I(l,2);D(n),B(`click`,d,function(...e){t.onToggleOpen?.apply(this,e)}),H(e,n)};W(s,e=>{t.open&&e(c)}),H(e,o),A()}Br([`click`]);var Uk=V(`<div data-testid="store-readonly-reclaim-error" role="alert" style="font-size: var(--tandem-text-2xs); color: var(--tandem-error-fg);" class="svelte-l26r3u"> </div>`),Wk=V(`<div data-testid="store-readonly-banner" class="svelte-l26r3u"><div style="display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;" class="svelte-l26r3u"><span class="svelte-l26r3u">Annotation store is read-only — another Tandem instance holds the lock. Annotations
|
|
75
|
-
won't be saved. Close the other instance, or reclaim the lock if no other instance is
|
|
76
|
-
running.</span> <div style="display: flex; flex-shrink: 0; gap: var(--tandem-space-1);" class="svelte-l26r3u"><button data-testid="store-readonly-reclaim" class="svelte-l26r3u"> </button> <button data-testid="store-readonly-dismiss" class="svelte-l26r3u">Dismiss</button></div></div> <!></div>`),Gk=V(`<span style="margin-left: 8px; padding: 1px 6px; font-size: var(--tandem-text-xs); background: var(--tandem-accent); color: var(--tandem-accent-fg); border-radius: var(--tandem-r-pill);" class="svelte-l26r3u"> </span>`),Kk=V(`<div style="padding: var(--tandem-space-3); flex: 1;" aria-live="polite" class="svelte-l26r3u"><p style="font-size: var(--tandem-text-base); color: var(--tandem-fg-subtle); margin-top: 8px;" class="svelte-l26r3u"> </p></div>`),qk=V(`<details style="margin-top: 12px;" class="svelte-l26r3u"><summary style="font-size: 12px; color: var(--tandem-fg-subtle); cursor: pointer;" class="svelte-l26r3u"> </summary> <div role="list" aria-label="Resolved annotations" class="svelte-l26r3u"></div></details>`),Jk=V(`<div style="padding: var(--tandem-space-3); flex: 1;" role="list" aria-label="Annotations" class="svelte-l26r3u"><!> <!></div>`),Yk=V(`<div data-testid="annotation-list-scroll-container" class="tandem-scroll-fade-y svelte-l26r3u" style="width: 100%; background: var(--tandem-surface-muted); display: flex; flex-direction: column; overflow-y: auto;"><!> <div style="padding: var(--tandem-space-3) var(--tandem-space-4); border-bottom: 1px solid var(--tandem-border);" class="svelte-l26r3u"><div style="display: flex; justify-content: space-between; align-items: center;" class="svelte-l26r3u"><h3 style="font-size: 13px; font-weight: 600; margin: 0;" class="svelte-l26r3u">Annotations <!></h3> <span aria-live="polite" style="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);" class="svelte-l26r3u"> </span> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-l26r3u"><button data-testid="annotation-sort-toggle" style="display: flex; align-items: center; gap: 4px; background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-pill); padding: 3px 10px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); cursor: pointer; white-space: nowrap;" class="svelte-l26r3u"><span style="font-size: 9px; opacity: 0.7;" aria-hidden="true" class="svelte-l26r3u">⇅</span> <span class="svelte-l26r3u"> </span></button> <button data-testid="filter-bar-toggle" style="display: flex; align-items: center; gap: 4px; background: none; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-pill); padding: 3px 10px; font-size: var(--tandem-text-xs); color: var(--tandem-fg-subtle); cursor: pointer; white-space: nowrap;" class="svelte-l26r3u"><span class="svelte-l26r3u"> </span> <span style="font-size: 9px; opacity: 0.7;" class="svelte-l26r3u">▾</span> <span class="svelte-l26r3u">Filter</span></button></div></div></div> <!> <div style="padding: var(--tandem-space-1) var(--tandem-space-4) 0;" class="svelte-l26r3u"><!></div> <!> <!> <!></div>`);function Xk(e,t){k(t,!0);let n=q(t,`storeReadOnly`,3,!1),r=q(t,`claudeWorkingAnnotationId`,3,null),i=j(()=>t.reduceMotion?`auto`:`smooth`),a=`tandem:storeReadOnlyBannerDismissed`;function o(){try{return localStorage.getItem(a)===`true`}catch{return!1}}let s=M(un(o()));L(()=>{if(!n()){N(s,!1),N(m,null);try{localStorage.removeItem(a)}catch{}}});function c(){try{localStorage.setItem(a,`true`)}catch{}N(s,!0)}let l=`tandem:annotationSortMode`;function u(){try{return localStorage.getItem(l)===`chronological`?`chronological`:`position`}catch{return`position`}}let d=M(un(u()));function f(){N(d,z(d)===`position`?`chronological`:`position`,!0);try{localStorage.setItem(l,z(d))}catch{}}let p=M(!1),m=M(null);async function h(){if(!z(p)){N(p,!0),N(m,null);try{let e=await fetch(`${Il}${Mc}`,{method:`POST`});if(!e.ok){let t=`Could not reclaim the annotation store lock.`;try{let n=await e.json();typeof n?.message==`string`&&n.message&&(t=n.message)}catch{}N(m,t,!0)}}catch{N(m,`Could not reach the Tandem server.`)}finally{N(p,!1)}}}let g=M(`all`),_=M(`all`),v=M(`all`),y=M(!1),b=M(null),x=M(void 0),S=M(null);L(()=>{z(b)&&z(S)?.focus()}),L(()=>{z(g),z(_),z(v),N(b,null)}),L(()=>{t.onFilterChange?.(z(g),z(_),z(v))});let C=M(un(new Map));L(()=>{if(!t.ydoc){N(C,new Map,!0);return}let e=t.ydoc.getMap(Ga);function n(){let t=new Map;e.forEach(e=>{let n=e;if(n&&typeof n==`object`&&n.annotationId){let e=t.get(n.annotationId)??[];e.push(n),t.set(n.annotationId,e)}});for(let e of t.values())e.sort((e,t)=>e.timestamp-t.timestamp);N(C,t,!0)}return n(),e.observe(n),()=>e.unobserve(n)});let w=j(()=>{let e=[],n=[];for(let r of t.annotations){r.status===`pending`&&n.push(r);let t;t=z(g)===`all`?!0:z(g)===`with-replacement`?r.suggestedText!==void 0:r.type===z(g);let i=z(_)===`all`||r.author===z(_),a=z(v)===`all`||r.status===z(v);t&&i&&a&&e.push(r)}return{filtered:e,pending:ED(e.filter(e=>e.status===`pending`),z(d)),reviewPending:e.filter(sc),resolved:ED(e.filter(e=>e.status!==`pending`),z(d)),allPending:n,reviewAllPending:t.annotations.filter(sc)}}),ee=qE(J_()),T=j(()=>z(g)!==`all`||z(_)!==`all`||z(v)!==`all`),te=j(()=>{if(!z(T))return`All`;let e=[];if(z(g)!==`all`&&e.push({all:`All`,highlight:`Highlights`,comment:`Comments`,note:`Notes`,"with-replacement":`With replacement`}[z(g)]),z(_)!==`all`){let t={all:`Anyone`,claude:ee.family,user:`You`,import:`Imported`};e.push(t[z(_)])}return z(v)!==`all`&&e.push({all:`Any status`,pending:`Pending`,accepted:`Accepted`,dismissed:`Dismissed`}[z(v)]),e.join(` · `)||`All`}),ne=!1;L(()=>{if(z(g),z(_),z(v),!ne){ne=!0;return}Ar(()=>{if(t.activeAnnotationId){let e=document.querySelector(`[data-testid="annotation-card-${t.activeAnnotationId}"]`);if(e){e.scrollIntoView({block:`center`});return}console.warn(`[tandem] SidePanel: active annotation ${t.activeAnnotationId} not found on filter change; scrolling to top`)}z(x)?.scrollTo({top:0})})}),L(()=>{let e=t.activeAnnotationId;if(!e)return;let n=z(i),r=t.reduceMotion||typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,a=setTimeout(()=>{let t=document.querySelector(`[data-testid="annotation-card-${e}"]`);if(!t){console.warn(`[tandem] SidePanel: active annotation ${e} not found after 50ms delay; scroll-to-card skipped`);return}if(t.scrollIntoView({behavior:n,block:`nearest`}),r)return;t.classList.add(`tandem-annotation-flash`);let i=e=>{e.animationName.includes(`tandem-annotation-flash`)&&(t.classList.remove(`tandem-annotation-flash`),t.removeEventListener(`animationend`,i))};t.addEventListener(`animationend`,i)},50);return()=>clearTimeout(a)});let E=(e,n)=>YO(t.ydoc,e,n),re=e=>ZO(t.ydoc,e),ie=e=>$O(e,t.documentId),ae=(e,n)=>ek(e,n,t.documentId),oe=new Map;function se(e){oe.set(e,`accept`),t.review.handleAccept(e)}function ce(e){oe.set(e,`dismiss`),t.review.handleDismiss(e)}let le=M(void 0),ue=M(null),de=0;function fe(e){return t.annotations.find(t=>t.id===e)}function pe(e){return t=>{let n=fe(e);n&&hk(t,n,{accept:se,dismiss:ce,sendToClaude:re,remove:ie,openEdit:e=>N(ue,{id:e,kind:`edit`,nonce:++de},!0),openReply:e=>N(ue,{id:e,kind:`reply`,nonce:++de},!0)})}}async function me(e){if(!Lm())return;let t=(e.target?.closest(`[data-annotation-id]`))?.getAttribute(`data-annotation-id`);if(!t)return;let n=fe(t);n&&(e.preventDefault(),e.stopPropagation(),await gk(n,pe(t)))}L(()=>{let e=z(le);if(e)return e.addEventListener(`contextmenu`,me),()=>e.removeEventListener(`contextmenu`,me)}),L(()=>yk());function he(e){for(let n of z(w).reviewPending)t.review.resolveAnnotation(n.id,e);N(b,null)}let ge=M(un(new Set));L(()=>{let e=new Set(z(w).pending.filter(e=>e.author===`import`&&e.type===`note`).map(e=>e.id));Ar(()=>{let t=new Set([...z(ge)].filter(t=>e.has(t)));t.size!==z(ge).size&&N(ge,t,!0)})});function _e(e){let t=new Set(z(ge));t.has(e)?t.delete(e):t.add(e),N(ge,t,!0)}function ve(){let e=Array.from(z(ge));QO(t.ydoc,e),N(ge,new Set,!0)}function ye(){N(ge,new Set,!0)}function be(e){e.target===e.currentTarget&&t.onActiveAnnotationChange(null)}var xe=Yk(),Se=P(xe),Ce=e=>{var t=Wk(),n=P(t),r=I(P(n),2),i=P(r),a=P(i,!0);D(i);var o=I(i,2);D(r),D(n);var s=I(n,2),l=e=>{var t=Uk(),n=P(t,!0);D(t),R(()=>U(n,z(m))),H(e,t)};W(s,e=>{z(m)&&e(l)}),D(t),R(()=>{G(t,`padding: 10px 14px; margin: 10px 14px 0; background: ${AD.background??``}; border: 1px solid ${AD.border??``}; border-radius: var(--tandem-r-4); font-size: var(--tandem-text-xs); color: ${AD.color??``}; display: flex; flex-direction: column; gap: var(--tandem-space-2);`),i.disabled=z(p),G(i,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: 1px solid ${AD.border??``}; border-radius: var(--tandem-r-2); background: none; color: ${AD.color??``}; cursor: ${z(p)?`wait`:`pointer`}; font-weight: 500;`),U(a,z(p)?`Reclaiming…`:`Reclaim`),G(o,`flex-shrink: 0; font-size: var(--tandem-text-xs); padding: 2px 8px; border: none; border-radius: var(--tandem-r-2); background: none; color: ${AD.color??``}; cursor: pointer; font-weight: 500;`)}),B(`click`,i,h),B(`click`,o,c),H(e,t)};W(Se,e=>{n()&&!z(s)&&e(Ce)});var we=I(Se,2),Te=P(we),Ee=P(Te),De=I(P(Ee)),Oe=e=>{var t=Gk(),n=P(t,!0);D(t),R(()=>U(n,z(w).allPending.length)),H(e,t)};W(De,e=>{z(w).allPending.length>0&&e(Oe)}),D(Ee);var ke=I(Ee,2),Ae=P(ke);D(ke);var je=I(ke,2),Me=P(je),Ne=I(P(Me),2),Pe=P(Ne,!0);D(Ne),D(Me);var Fe=I(Me,2),Ie=P(Fe),Le=P(Ie);D(Ie),O(4),D(Fe),D(je),D(Te),D(we);var Re=I(we,2);Hk(Re,{get filterType(){return z(g)},get filterAuthor(){return z(_)},get filterStatus(){return z(v)},get hasFilters(){return z(T)},get open(){return z(y)},onToggleOpen:()=>N(y,!z(y)),onSetFilterType:e=>{N(g,e,!0)},onSetFilterAuthor:e=>{N(_,e,!0)},onSetFilterStatus:e=>{N(v,e,!0)},onClearFilters:()=>{N(g,`all`),N(_,`all`),N(v,`all`)}});var ze=I(Re,2);SD(P(ze),{get annotations(){return t.annotations},get activeDocFormat(){return t.activeDocFormat},get documentId(){return t.documentId}}),D(ze);var Be=I(ze,2);xk(Be,{get selectedCount(){return z(ge).size},onPromote:ve,onClear:ye,get reduceMotion(){return t.reduceMotion}});var Ve=I(Be,2);Tk(Ve,{get bulkConfirm(){return z(b)},get pendingCount(){return z(w).reviewPending.length},get allPendingCount(){return z(w).reviewAllPending.length},onConfirmAccept:()=>he(`accepted`),onConfirmDismiss:()=>he(`dismissed`),onCancel:()=>N(b,null),onRequestAccept:()=>N(b,`accept`),onRequestDismiss:()=>N(b,`dismiss`),get reduceMotion(){return t.reduceMotion},get confirmRef(){return z(S)},set confirmRef(e){N(S,e,!0)}});var He=I(Ve,2),Ue=e=>{var t=Kk(),n=P(t),r=P(n,!0);D(n),D(t),R(()=>U(r,z(T)?`No annotations match filters.`:`No annotations yet. Open a document to get started.`)),B(`click`,t,be),H(e,t)},We=e=>{var n=Jk(),i=P(n);pi(i,17,()=>z(w).pending,e=>e.id,(e,n)=>{let i=j(()=>t.activeAnnotationId===z(n).id);{let a=j(()=>z(C).get(z(n).id)??[]),o=j(()=>r()===z(n).id),s=j(()=>ik(z(n))?se:void 0),c=j(()=>ak(z(n))?ce:void 0),l=j(()=>lk(z(n))?ie:void 0),u=j(()=>ck(z(n))?re:void 0),d=j(()=>sk(z(n))?E:void 0),f=j(()=>ok(z(n))?ae:void 0),p=j(()=>z(ue)?.id===z(n).id?z(ue):null),m=j(()=>z(ge).has(z(n).id)),h=j(()=>z(n).author===`import`&&z(n).type===`note`?_e:void 0);UO(e,{get annotation(){return z(n)},get replies(){return z(a)},get isReviewTarget(){return z(i)},get claudeTyping(){return z(o)},lifecycleMotion:!0,get reduceMotion(){return t.reduceMotion},get exitModes(){return oe},get onAccept(){return z(s)},get onDismiss(){return z(c)},get onRemove(){return z(l)},get onSendToClaude(){return z(u)},get onEdit(){return z(d)},get onReply(){return z(f)},get openRequest(){return z(p)},onClick:()=>t.review.scrollToAnnotation(z(n)),get selected(){return z(m)},get onToggleSelect(){return z(h)}})}});var a=I(i,2),o=e=>{var n=qk(),r=P(n),i=P(r);D(r);var a=I(r,2);pi(a,21,()=>z(w).resolved,e=>e.id,(e,n)=>{{let r=j(()=>z(C).get(z(n).id)??[]),i=j(()=>t.review.getRecentlyResolved().has(z(n).id));UO(e,{get annotation(){return z(n)},get replies(){return z(r)},get reduceMotion(){return t.reduceMotion},get onUndo(){return t.review.undoResolveAnnotation},get undoable(){return z(i)},onClick:()=>t.review.scrollToAnnotation(z(n))})}}),D(a),D(n),R(()=>U(i,`${z(w).resolved.length??``} resolved`)),H(e,n)};W(a,e=>{z(w).resolved.length>0&&e(o)}),D(n),fa(n,e=>N(le,e),()=>z(le)),B(`click`,n,be),H(e,n)};W(He,e=>{z(w).filtered.length===0?e(Ue):e(We,-1)}),D(xe),fa(xe,e=>N(x,e),()=>z(x)),Pi(xe,(e,t)=>Bu?.(e,t),()=>`y`),R(()=>{U(Ae,`${z(w).allPending.length??``} pending annotation${z(w).allPending.length===1?``:`s`}`),K(Me,`title`,z(d)===`position`?`Sorted by position in document. Click to sort oldest first.`:`Sorted oldest first. Click to sort by position in document.`),K(Me,`aria-label`,z(d)===`position`?`Annotations sorted by position in document. Switch to oldest first.`:`Annotations sorted oldest first. Switch to position in document.`),U(Pe,z(d)===`position`?`Position`:`Oldest`),U(Le,`${z(te)??``} ${z(w).filtered.length??``}`)}),B(`click`,Me,f),B(`click`,Fe,()=>N(y,!z(y))),H(e,xe),A()}Br([`click`]);var Zk=V(`<div style="padding: var(--tandem-space-3) var(--tandem-space-4); font-size: var(--tandem-text-xs); color: var(--tandem-fg-faint); font-style: italic;">No headings</div>`),Qk=V(`<span style="
|
|
77
|
-
flex-shrink: 0;
|
|
78
|
-
font-family: var(--tandem-font-mono);
|
|
79
|
-
font-size: var(--tandem-text-2xs, 10px);
|
|
80
|
-
font-weight: 500;
|
|
81
|
-
color: var(--tandem-fg-subtle);
|
|
82
|
-
background: var(--tandem-surface-muted);
|
|
83
|
-
border-radius: var(--tandem-r-pill);
|
|
84
|
-
padding: 0 var(--tandem-space-1);
|
|
85
|
-
min-width: 16px;
|
|
86
|
-
text-align: center;
|
|
87
|
-
line-height: 16px;
|
|
88
|
-
"> </span>`),$k=V(`<li><button><span class="outline-tick svelte-or41wm" aria-hidden="true"></span> <span style="flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"> </span> <!></button></li>`),eA=V(`<ul style="list-style: none; margin: 0; padding: 0;"></ul>`),tA=V(`<nav data-testid="outline-panel" aria-label="Document outline" style="display: flex; flex-direction: column; flex: 1; overflow-y: auto;"><div class="outline-header-label tandem-ui svelte-or41wm">Outline</div> <div style="padding: var(--tandem-space-3) var(--tandem-space-3) var(--tandem-space-2);"><div class="outline-search-pill svelte-or41wm"><svg class="outline-search-icon svelte-or41wm" width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="7" cy="7" r="4.3" stroke="currentColor" stroke-width="1.4" fill="none"></circle><line x1="10.2" y1="10.2" x2="13.5" y2="13.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></line></svg> <input type="search" placeholder="Search in document…" data-testid="outline-search-input" aria-label="Search document" class="outline-search-input svelte-or41wm"/></div></div> <div class="tandem-scroll-fade-y" style="flex: 1; overflow-y: auto; padding: var(--tandem-space-3) var(--tandem-space-3);"><!></div></nav>`);function nA(e,t){k(t,!0);let n=q(t,`annotations`,19,()=>[]),r=q(t,`focusTrigger`,3,0),i=q(t,`activeFilterType`,3,`all`),a=q(t,`activeFilterAuthor`,3,`all`),o=q(t,`activeFilterStatus`,3,`all`),s=M(un([])),c=M(-1),l=M(un([])),u=M(``),d=M(null),f=M(-1);L(()=>{let e=t.editor;if(!e||e.isDestroyed){N(s,[],!0);return}N(s,fm(e),!0),Ar(()=>{N(l,z(l).slice(0,z(s).length),!0),z(c)>=z(s).length&&N(c,Math.max(0,z(s).length-1),!0)});let n=()=>{N(s,fm(e),!0),N(l,z(l).slice(0,z(s).length),!0),z(c)>=z(s).length&&N(c,Math.max(0,z(s).length-1),!0)};return e.on(`update`,n),()=>{e.isDestroyed||e.off(`update`,n),N(s,[],!0)}}),L(()=>{r()>0&&(z(d)?.focus(),z(d)?.select())}),L(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=e.view.dom.closest(`.editor-scroll`)??e.view.dom.parentElement;function r(){if(!e||e.isDestroyed||z(s).length===0){N(f,-1);return}let t=(n?.getBoundingClientRect().top??0)+48,r=-1;for(let n=0;n<z(s).length;n++)try{e.view.coordsAtPos(z(s)[n].pos+1).top<=t&&(r=n)}catch{}N(f,r,!0)}return r(),n?.addEventListener(`scroll`,r),()=>n?.removeEventListener(`scroll`,r)});function p(){let e=t.editor;!e||e.isDestroyed||(z(u)?e.commands.find({query:z(u),caseSensitive:!1,wholeWord:!1,regexMode:!1}):e.commands.findClose())}function m(e){e.key===`Enter`?(e.preventDefault(),e.shiftKey?t.editor?.commands.findPrev():t.editor?.commands.findNext()):e.key===`Escape`&&(e.preventDefault(),N(u,``),t.editor?.commands.findClose(),z(d)?.blur())}let h=j(()=>{let e=t.editor;if(!e||e.isDestroyed||z(s).length===0)return[];let r=e.state.doc.content.size,c=[];for(let t of n()){if(i()!==`all`){if(i()===`with-replacement`){if(!t.suggestedText)continue}else if(t.type!==i())continue}if(!(a()!==`all`&&t.author!==a())&&!(o()!==`all`&&t.status!==o()))try{c.push(QE(e.state.doc,t.range.from))}catch{}}return z(s).map((e,t)=>{let n=t+1<z(s).length?z(s)[t+1].pos:r;return c.filter(t=>t>=e.pos&&t<n).length})});function g(e,n){let r=t.editor;if(!r||r.isDestroyed)return;let{state:i}=r;try{let t=i.doc.resolve(e.pos+1),n=Up.near(t);r.view.dispatch(i.tr.setSelection(n)),r.view.focus();let{node:a}=r.view.domAtPos(e.pos+1),o=a instanceof Element?a:a.parentElement,s=r.view.dom.closest(`.editor-scroll`)??r.view.dom.parentElement;if(o&&s){let e=o.getBoundingClientRect().top,t=s.getBoundingClientRect().top;s.scrollTop+=e-t-s.clientHeight*.05}}catch{}N(c,n,!0)}function _(e){if(z(s).length!==0)if(e.key===`ArrowDown`){e.preventDefault();let t=(z(c)+1)%z(s).length;N(c,t),z(l)[t]?.focus()}else if(e.key===`ArrowUp`){e.preventDefault();let t=(z(c)-1+z(s).length)%z(s).length;N(c,t),z(l)[t]?.focus()}else e.key===`Home`?(e.preventDefault(),N(c,0),z(l)[0]?.focus()):e.key===`End`&&(e.preventDefault(),N(c,z(s).length-1),z(l)[z(s).length-1]?.focus())}var v=tA(),y=I(P(v),2),b=P(y),x=I(P(b),2);$i(x),fa(x,e=>N(d,e),()=>z(d)),D(b),D(y);var S=I(y,2),C=P(S),w=e=>{H(e,Zk())},ee=e=>{var t=eA();pi(t,21,()=>z(s),li,(e,t,n)=>{let r=j(()=>z(f)===n),i=j(()=>z(h)[n]??0);var a=$k(),o=P(a),s=P(o),u=I(s,2),d=P(u,!0);D(u);var p=I(u,2),m=e=>{var t=Qk(),n=P(t,!0);D(t),R(()=>{K(t,`title`,`${z(i)??``} annotation${z(i)===1?``:`s`}`),U(n,z(i))}),H(e,t)};W(p,e=>{z(i)>0&&e(m)}),D(o),fa(o,(e,t)=>z(l)[t]=e,e=>z(l)?.[e],()=>[n]),D(a),R(()=>{K(o,`data-testid`,`outline-heading-${z(t).level}-${n}`),K(o,`tabindex`,z(c)===n||z(c)===-1&&n===0?0:-1),G(o,`
|
|
89
|
-
display: flex; align-items: center; width: 100%; text-align: left;
|
|
90
|
-
padding: var(--tandem-space-1) var(--tandem-space-3);
|
|
91
|
-
padding-left: calc(var(--tandem-space-1) + ${(z(t).level-1)*12}px);
|
|
92
|
-
font-size: ${z(t).level===1?`var(--tandem-text-sm)`:`var(--tandem-text-xs)`};
|
|
93
|
-
font-weight: ${z(t).level===1?600:z(t).level===2?500:400};
|
|
94
|
-
color: ${z(r)?`var(--tandem-accent)`:z(t).level===1?`var(--tandem-fg)`:z(t).level===2?`var(--tandem-fg-subtle)`:`var(--tandem-fg-muted)`};
|
|
95
|
-
background: ${z(r)?`var(--tandem-accent-bg)`:`none`};
|
|
96
|
-
border: none; cursor: pointer; line-height: 1.5;
|
|
97
|
-
transition: color 0.1s, background 0.1s;
|
|
98
|
-
gap: var(--tandem-space-2);
|
|
99
|
-
`),K(o,`title`,z(t).text),G(s,z(r)?`background-color: var(--tandem-accent); opacity: 1;`:``),U(d,z(t).text||`(untitled)`)}),B(`click`,o,()=>g(z(t),n)),zr(`focus`,o,()=>N(c,n,!0)),zr(`mouseenter`,o,e=>{z(r)||(e.currentTarget.style.background=`var(--tandem-surface-hover, var(--tandem-surface-muted))`)}),zr(`mouseleave`,o,e=>{z(r)||(e.currentTarget.style.background=`none`)}),H(e,a)}),D(t),H(e,t)};W(C,e=>{z(s).length===0?e(w):e(ee,-1)}),D(S),Pi(S,(e,t)=>Bu?.(e,t),()=>`y`),D(v),B(`keydown`,v,_),B(`input`,x,p),B(`keydown`,x,m),aa(x,()=>z(u),e=>N(u,e)),H(e,v),A()}Br([`keydown`,`input`,`click`]);var rA=V(`<div><!></div>`);function iA(e,t){k(t,!0);let n=ma(t,[`$$slots`,`$$events`,`$$legacy`,`kind`,`visible`]),r=j(()=>t.visible===void 0?void 0:`display: ${t.visible?`flex`:`none`}; flex-direction: column; flex: 1; min-height: 0;${t.kind===`outline`?` padding-bottom: var(--tandem-status-clearance-total, 88px);`:``}`);var i=Xr(),a=F(i),o=e=>{var i=rA(),a=P(i),o=e=>{bD(e,ga(()=>n,{get visible(){return t.visible}}))},s=e=>{nA(e,{get editor(){return t.editor},get annotations(){return t.annotations},get focusTrigger(){return t.focusTrigger},get activeFilterType(){return t.activeFilterType},get activeFilterAuthor(){return t.activeFilterAuthor},get activeFilterStatus(){return t.activeFilterStatus}})},c=e=>{Xk(e,ga(()=>n))};W(a,e=>{t.kind===`chat`?e(o):t.kind===`outline`?e(s,1):e(c,-1)}),D(i),R(()=>G(i,z(r))),H(e,i)},s=e=>{bD(e,ga(()=>n))},c=e=>{nA(e,{get editor(){return t.editor},get annotations(){return t.annotations},get focusTrigger(){return t.focusTrigger},get activeFilterType(){return t.activeFilterType}})},l=e=>{Xk(e,ga(()=>n))};W(a,e=>{z(r)?e(o):t.kind===`chat`?e(s,1):t.kind===`outline`?e(c,2):e(l,-1)}),H(e,i),A()}var aA=V(`<span style="color: var(--tandem-error-fg-strong); font-size: var(--tandem-text-xs); max-width: 200px;"> </span>`),oA=V(`<button type="button" class="tandem-banner__cta" data-testid="convert-to-markdown-btn"> </button>`),sA=V(`<div class="tandem-banner tandem-banner--info" role="status" aria-live="polite" data-testid="review-only-banner"><span class="tandem-banner__message">This document is open in review-only mode. You can add annotations and review, but cannot
|
|
100
|
-
edit directly.</span> <!> <!> <button type="button" class="tandem-banner__dismiss" data-testid="review-only-dismiss" aria-label="Dismiss review-only banner"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>`);function cA(e,t){k(t,!0);let n=`tandem:reviewOnlyBannerDismissed`;function r(){try{return localStorage.getItem(n)===`true`}catch{return!1}}let i=M(un(r())),a=M(!1),o=M(null);async function s(){if(!(!t.documentId||z(a))){N(a,!0),N(o,null);try{let e=await fetch(`${Il}${Cc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId})});e.ok||N(o,(await e.json().catch(()=>null))?.message??`Conversion failed (HTTP ${e.status}).`,!0)}catch{N(o,`Could not reach the server.`)}finally{N(a,!1)}}}function c(){try{localStorage.setItem(n,`true`)}catch{}N(i,!0)}var l=Xr(),u=F(l),d=e=>{var n=sA(),r=I(P(n),2),i=e=>{var t=aA(),n=P(t,!0);D(t),R(()=>U(n,z(o))),H(e,t)};W(r,e=>{z(o)&&e(i)});var l=I(r,2),u=e=>{var t=oA(),n=P(t,!0);D(t),R(()=>{t.disabled=z(a),U(n,z(a)?`Converting…`:`Convert to Markdown`)}),B(`click`,t,s),H(e,t)};W(l,e=>{t.documentId&&e(u)});var d=I(l,2);D(n),B(`click`,d,c),H(e,n)};W(u,e=>{t.visible&&!z(i)&&e(d)}),H(e,l),A()}Br([`click`]);var lA=null;async function uA(e){if(lA!==null)return lA;let t=await fetch(`${Il}${mc}`,{signal:e});if(!t.ok)throw Error(`${mc} responded ${t.status} ${t.statusText}`);let n=await t.json();return lA=n,n}function dA(e){let t=M(null),n=M(!1);return L(()=>{if(!e())return;let r=!1,i=new AbortController,a=setTimeout(()=>i.abort(),3e3);return N(n,!0),uA(i.signal).then(e=>{r||N(t,e,!0)}).catch(e=>{e instanceof Error&&e.name!==`AbortError`&&console.warn(`[useAppInfo] failed to load /api/info:`,e)}).finally(()=>{clearTimeout(a),r||N(n,!1)}),()=>{r=!0,clearTimeout(a),i.abort()}}),{get info(){return z(t)},get loading(){return z(n)}}}var fA=V(`<div><div>Contrast</div> <label data-testid="high-contrast-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>High contrast</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Increases border and text contrast for improved readability.</div></div> <div><div>Annotation Patterns</div> <label data-testid="annotation-patterns-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Use pattern fills for annotations</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Adds visual patterns to annotation decorations (color-blind friendly).</div></div>`,1);function pA(e,t){k(t,!0);let n=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`;var r=fA(),i=F(r),a=P(i);G(a,n);var o=I(a,2),s=P(o);$i(s),O(2),D(o),O(2),D(i);var c=I(i,2),l=P(c);G(l,n);var u=I(l,2),d=P(u);$i(d),O(2),D(u),O(2),D(c),R(()=>{ta(s,t.settings.highContrast),ta(d,t.settings.annotationPatterns)}),B(`change`,s,e=>t.onUpdate({highContrast:e.target.checked})),B(`change`,d,e=>t.onUpdate({annotationPatterns:e.target.checked})),H(e,r),A()}Br([`change`]);var mA=V(`<button role="radio"> </button>`),hA=V(`<label data-testid="appearance-system-light-warm" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5); margin-top: var(--tandem-space-2);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Use Warm when system is light</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">When your OS reports a light appearance, use the paper-tone Warm theme instead of
|
|
101
|
-
neutral Light. A dark OS appearance still resolves to Dark.</div>`,1),gA=V(`<button role="radio"> </button>`),_A=V(`<button role="radio"> </button>`),vA=V(`<button role="radio"> </button>`),yA=V(`<div style="display: flex; align-items: center; gap: var(--tandem-space-2);"><span style="flex: 0 0 7rem; font-size: 11px; color: var(--tandem-fg-muted);"> </span> <div role="radiogroup" tabindex="0" style="display: flex; gap: var(--tandem-space-2); flex: 1;"></div></div>`),bA=V(`<button role="radio"> </button>`),xA=V(`<label style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span> </span></label>`),SA=V(`<div><div id="settings-theme-label">Theme</div> <div role="radiogroup" aria-labelledby="settings-theme-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div> <!></div> <div><div id="settings-default-tab-label">Default Tab</div> <div role="radiogroup" aria-labelledby="settings-default-tab-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"><button data-testid="default-tab-chat-btn" role="radio">Chat</button> <button data-testid="default-tab-annotations-btn" role="radio">Annotations</button></div></div> <div><div id="settings-text-size-label">Text Size</div> <div role="radiogroup" aria-labelledby="settings-text-size-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Reading density only — use browser zoom (Ctrl + =/−) to scale the whole UI.</div></div> <div><div id="settings-accent-color-label">Accent Color</div> <div style="display: flex; align-items: center; gap: 8px;"><span aria-hidden="true" style="display: inline-block; width: 16px; height: 16px; background: var(--tandem-accent); border-radius: var(--tandem-r-1); flex-shrink: 0; border: 1px solid var(--tandem-border-strong);"></span> <input data-testid="accent-hue-slider" type="range" min="0" max="360" step="1" aria-labelledby="settings-accent-color-label" style="flex: 1; accent-color: var(--tandem-accent);"/></div></div> <div><div id="settings-editor-font-label">Editor Font</div> <div role="radiogroup" aria-labelledby="settings-editor-font-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div></div> <div data-testid="font-by-extension-section"><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;"><div id="settings-font-by-ext-label">Default font by file type</div> <button data-testid="font-by-extension-reset" type="button">Reset to defaults</button></div> <div style="display: flex; flex-direction: column; gap: var(--tandem-space-2);"></div> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Each file type uses this font; files with no specific choice fall back to the Editor Font above.</div></div> <div><div id="settings-density-label">Spacing Density</div> <div role="radiogroup" aria-labelledby="settings-density-label" tabindex="0" style="display: flex; gap: var(--tandem-space-2);"></div></div> <div><div>Decorations</div> <!> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Turn a type off to hide its inline marks in the editor. Annotation cards in the
|
|
102
|
-
side panel stay visible. Display-only — hiding Notes never affects what Claude reads.</div></div> <div><label data-testid="reduce-motion-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Reduce motion</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Disables smooth autoscroll and the annotation flash animation.</div></div> <div><label data-testid="appearance-formatting-bar" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show formatting bar</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">The persistent toolbar above the document. When hidden, formatting stays available
|
|
103
|
-
in the selection popup, and Ctrl+Z / Ctrl+Y still undo and redo.</div></div> <div><label data-testid="appearance-show-raw-markdown" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show raw markdown</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Footnotes, reference-style links, and inline HTML that Tandem keeps as raw source.
|
|
104
|
-
When hidden they stay in the file and always save — only the on-screen markers are
|
|
105
|
-
hidden.</div></div> <div><label data-testid="appearance-rail-hover-reveal" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: var(--tandem-text-sm); color: var(--tandem-fg); min-height: var(--tandem-space-5);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Reveal rails on hover</span></label> <div style="font-size: var(--tandem-text-2xs); color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Hover a closed outline or annotations rail to float it over the document without
|
|
106
|
-
resizing it; click its edge to pin it open. When off, rails reveal only on click.</div></div>`,1);function CA(e,t){k(t,!0);let n=[{format:`md`,label:`Markdown (.md)`},{format:`docx`,label:`Word (.docx)`},{format:`html`,label:`HTML (.html)`},{format:`txt`,label:`Plain text (.txt)`}],r=[[`sans`,`Sans`],[`serif`,`Serif`],[`mono`,`Mono`]];function i(e){return t.settings.fontByExtension?.[e]??t.settings.editorFont}function a(e,n){t.onUpdate({fontByExtension:{...t.settings.fontByExtension,[e]:n}})}function o(){t.onUpdate({fontByExtension:{}})}let s=j(()=>Object.keys(t.settings.fontByExtension??{}).length>0),c=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,l=[[`showAuthorship`,`appearance-show-authorship`,`Authorship colors`],[`showComments`,`appearance-show-comments`,`Comments`],[`showHighlights`,`appearance-show-highlights`,`Highlights`],[`showNotes`,`appearance-show-notes`,`Notes (private)`]];function u(e,t){return[`flex: 1;`,`padding: var(--tandem-space-2);`,`min-height: 24px;`,`border: 2px solid ${e?`var(--tandem-accent)`:`var(--tandem-border)`};`,`border-radius: var(--tandem-r-3);`,`background: ${t?`var(--tandem-surface-muted)`:e?`var(--tandem-accent-bg)`:`var(--tandem-surface)`};`,`cursor: ${t?`not-allowed`:`pointer`};`,`text-align: center;`,`font-size: 11px;`,`color: ${t?`var(--tandem-fg-subtle)`:e?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-muted)`};`,`font-weight: ${e?600:400};`,`opacity: ${t?.6:1};`,`transition: border-color 0.15s, background 0.15s;`].join(` `)}let d=Ek(()=>t.settings.theme,[`light`,`warm`,`dark`,`system`],e=>t.onUpdate({theme:e})),f=Ek(()=>t.settings.primaryTab,[`chat`,`annotations`],e=>t.onUpdate({primaryTab:e})),p=Ek(()=>t.settings.textSize,[`s`,`m`,`l`],e=>t.onUpdate({textSize:e})),m=Ek(()=>t.settings.editorFont,[`sans`,`serif`,`mono`],e=>t.onUpdate({editorFont:e})),h=Ek(()=>t.settings.density,[`compact`,`cozy`,`spacious`],e=>t.onUpdate({density:e})),g={};for(let e of n)g[e.format]=Ek(()=>i(e.format),[`sans`,`serif`,`mono`],t=>a(e.format,t));var _=SA(),y=F(_),b=P(y);G(b,c);var x=I(b,2);pi(x,20,()=>[`light`,`warm`,`dark`,`system`],e=>e,(e,n)=>{var r=mA(),i=P(r,!0);D(r),R((e,a)=>{K(r,`data-testid`,`theme-${n}-btn`),K(r,`aria-checked`,t.settings.theme===n),K(r,`tabindex`,e),G(r,a),U(i,n===`light`?`Light`:n===`warm`?`Warm`:n===`dark`?`Dark`:`System`)},[()=>d.tabIndexFor(n),()=>u(t.settings.theme===n)]),B(`click`,r,()=>t.onUpdate({theme:n})),H(e,r)}),D(x);var S=I(x,2),C=e=>{var n=hA(),r=F(n),i=P(r);$i(i),O(2),D(r),O(2),R(()=>ta(i,t.settings.systemLightVariant===`warm`)),B(`change`,i,e=>t.onUpdate({systemLightVariant:e.target.checked?`warm`:`light`})),H(e,n)};W(S,e=>{t.settings.theme===`system`&&e(C)}),D(y);var w=I(y,2),ee=P(w);G(ee,c);var T=I(ee,2),te=P(T),ne=I(te,2);D(T),D(w);var E=I(w,2),re=P(E);G(re,c);var ie=I(re,2);pi(ie,20,()=>[`s`,`m`,`l`],e=>e,(e,n)=>{var r=gA(),i=P(r,!0);D(r),R((e,a)=>{K(r,`data-testid`,`text-size-${n}-btn`),K(r,`aria-checked`,t.settings.textSize===n),K(r,`tabindex`,e),G(r,a),U(i,n===`s`?`Small`:n===`m`?`Medium`:`Large`)},[()=>p.tabIndexFor(n),()=>u(t.settings.textSize===n)]),B(`click`,r,()=>t.onUpdate({textSize:n})),H(e,r)}),D(ie),O(2),D(E);var ae=I(E,2),oe=P(ae);G(oe,c);var se=I(oe,2),ce=I(P(se),2);$i(ce),D(se),D(ae);var le=I(ae,2),ue=P(le);G(ue,c);var de=I(ue,2);pi(de,20,()=>[[`sans`,`Sans-serif`],[`serif`,`Serif (Source Serif 4)`],[`mono`,`Monospace`]],([e,t])=>e,(e,n)=>{var r=j(()=>v(n,2));let i=()=>z(r)[0],a=()=>z(r)[1];var o=_A(),s=P(o,!0);D(o),R((e,n)=>{K(o,`data-testid`,`editor-font-${i()}-btn`),K(o,`aria-checked`,t.settings.editorFont===i()),K(o,`tabindex`,e),G(o,n),U(s,a())},[()=>m.tabIndexFor(i()),()=>u(t.settings.editorFont===i())]),B(`click`,o,()=>t.onUpdate({editorFont:i()})),H(e,o)}),D(de),D(le);var fe=I(le,2),pe=P(fe),me=P(pe);G(me,`${c} margin-bottom: 0;`);var he=I(me,2);D(pe);var ge=I(pe,2);pi(ge,21,()=>n,e=>e.format,(e,t)=>{var n=yA(),o=P(n),s=P(o,!0);D(o);var c=I(o,2);pi(c,21,()=>r,([e,t])=>e,(e,n)=>{var r=j(()=>v(z(n),2));let o=()=>z(r)[0],s=()=>z(r)[1];var c=vA(),l=P(c,!0);D(c),R((e,n,r)=>{K(c,`data-testid`,`font-by-extension-${z(t).format}-${o()}`),K(c,`aria-checked`,e),K(c,`tabindex`,n),G(c,r),U(l,s())},[()=>i(z(t).format)===o(),()=>g[z(t).format].tabIndexFor(o()),()=>u(i(z(t).format)===o())]),B(`click`,c,()=>a(z(t).format,o())),H(e,c)}),D(c),D(n),R(()=>{K(n,`data-testid`,`font-by-extension-row-${z(t).format}`),U(s,z(t).label),K(c,`aria-label`,`Default font for ${z(t).label}`)}),B(`keydown`,c,function(...e){g[z(t).format].handleKeyDown?.apply(this,e)}),H(e,n)}),D(ge),O(2),D(fe);var _e=I(fe,2),ve=P(_e);G(ve,c);var ye=I(ve,2);pi(ye,20,()=>[[`compact`,`Compact`],[`cozy`,`Cozy`],[`spacious`,`Spacious`]],([e,t])=>e,(e,n)=>{var r=j(()=>v(n,2));let i=()=>z(r)[0],a=()=>z(r)[1];var o=bA(),s=P(o,!0);D(o),R((e,n)=>{K(o,`data-testid`,`density-${i()}-btn`),K(o,`aria-checked`,t.settings.density===i()),K(o,`tabindex`,e),G(o,n),U(s,a())},[()=>h.tabIndexFor(i()),()=>u(t.settings.density===i())]),B(`click`,o,()=>t.onUpdate({density:i()})),H(e,o)}),D(ye),D(_e);var be=I(_e,2),xe=P(be);G(xe,c),pi(I(xe,2),17,()=>l,([e,t,n])=>e,(e,n)=>{var r=j(()=>v(z(n),3));let i=()=>z(r)[0],a=()=>z(r)[1],o=()=>z(r)[2];var s=xA(),c=P(s);$i(c);var l=I(c,2),u=P(l,!0);D(l),D(s),R(()=>{K(s,`data-testid`,a()),ta(c,t.settings[i()]),U(u,o())}),B(`change`,c,e=>t.onUpdate({[i()]:e.target.checked,...t.settings.decorationsMuted?{decorationsMuted:!1}:{}})),H(e,s)}),O(2),D(be);var Se=I(be,2),Ce=P(Se),we=P(Ce);$i(we),O(2),D(Ce),O(2),D(Se);var Te=I(Se,2),Ee=P(Te),De=P(Ee);$i(De),O(2),D(Ee),O(2),D(Te);var Oe=I(Te,2),ke=P(Oe),Ae=P(ke);$i(Ae),O(2),D(ke),O(2),D(Oe);var je=I(Oe,2),Me=P(je),Ne=P(Me);$i(Ne),O(2),D(Me),O(2),D(je),R((e,n,r,i)=>{K(te,`aria-checked`,t.settings.primaryTab===`chat`),K(te,`tabindex`,e),G(te,n),K(ne,`aria-checked`,t.settings.primaryTab===`annotations`),K(ne,`tabindex`,r),G(ne,i),ea(ce,t.settings.accentHue),he.disabled=!z(s),G(he,`background: none; border: none; padding: 0; font-size: var(--tandem-text-2xs); color: ${z(s)?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-subtle)`}; cursor: ${z(s)?`pointer`:`default`}; text-decoration: ${z(s)?`underline`:`none`};`),ta(we,t.settings.reduceMotion),ta(De,t.settings.formattingBarVisible),ta(Ae,t.settings.showRawMarkdown),ta(Ne,t.settings.railHoverReveal)},[()=>f.tabIndexFor(`chat`),()=>u(t.settings.primaryTab===`chat`),()=>f.tabIndexFor(`annotations`),()=>u(t.settings.primaryTab===`annotations`)]),B(`keydown`,x,function(...e){d.handleKeyDown?.apply(this,e)}),B(`keydown`,T,function(...e){f.handleKeyDown?.apply(this,e)}),B(`click`,te,()=>t.onUpdate({primaryTab:`chat`})),B(`click`,ne,()=>t.onUpdate({primaryTab:`annotations`})),B(`keydown`,ie,function(...e){p.handleKeyDown?.apply(this,e)}),B(`input`,ce,e=>t.onUpdate({accentHue:Number(e.target.value)})),B(`keydown`,de,function(...e){m.handleKeyDown?.apply(this,e)}),B(`click`,he,o),B(`keydown`,ye,function(...e){h.handleKeyDown?.apply(this,e)}),B(`change`,we,e=>t.onUpdate({reduceMotion:e.target.checked})),B(`change`,De,e=>t.onUpdate({formattingBarVisible:e.target.checked})),B(`change`,Ae,e=>t.onUpdate({showRawMarkdown:e.target.checked})),B(`change`,Ne,e=>t.onUpdate({railHoverReveal:e.target.checked})),H(e,_),A()}Br([`keydown`,`click`,`change`,`input`]);var wA=V(`<button type="button" role="radio"> </button>`),TA=V(`<button type="button" data-testid="settings-default-save-folder-pick" style="padding: 6px 10px; font-size: 11px; white-space: nowrap; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer;">Choose…</button>`),EA=V(`<div><div id="settings-measure-label">Reading Measure</div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 8px;">The line length of the editor text. A stable measure keeps lines readable
|
|
107
|
-
regardless of panel state.</div> <div role="radiogroup" aria-labelledby="settings-measure-label" tabindex="0" style="display: flex; gap: var(--tandem-space-1); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2); padding: 2px;"></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: 6px;"> </div> <div data-testid="settings-default-save-folder" style="margin-top: var(--tandem-space-5);"><div>Default Save Folder</div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 8px;">Where new files go when you use <strong>Save As</strong> in the desktop app.
|
|
108
|
-
Leave empty to fall back to your AI's working directory, then your home
|
|
109
|
-
folder.</div> <form style="display: flex; gap: var(--tandem-space-1); align-items: center;"><input type="text" name="default-save-dir" data-testid="settings-default-save-folder-input" placeholder="(default: AI working directory, then home)" aria-label="Default save folder path" style="flex: 1; min-width: 0; padding: 6px 8px; font-size: 11px; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); background: var(--tandem-surface); color: var(--tandem-fg);"/> <!> <button type="button" data-testid="settings-default-save-folder-reset">Reset</button></form></div></div>`);function DA(e,t){k(t,!0);let n=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,r=Lm();function i(e){let n=e?.trim();t.onUpdate({defaultSaveDirectory:n||null})}function a(e){e.preventDefault(),i(e.target.elements.namedItem(`default-save-dir`)?.value??null)}async function o(){let e;try{({open:e}=await Ul(()=>import(`./dist-js-BWAGOggB.js`),__vite__mapDeps([2,1])))}catch(e){console.warn(`[Settings] Folder picker import failed:`,e),t.notify(`error`,`Folder picker plugin unavailable`);return}try{let t=await e({directory:!0,multiple:!1,title:`Choose default save folder`});typeof t==`string`&&i(t)}catch(e){console.warn(`[Settings] Folder picker open() failed:`,e),t.notify(`error`,`Folder picker permission denied or IPC error`)}}let s=[{value:`narrow`,label:`Narrow`,hint:`58 characters`},{value:`comfortable`,label:`Comfortable`,hint:`68 characters`},{value:`wide`,label:`Wide`,hint:`82 characters`},{value:`full`,label:`Full`,hint:`Fills the editor`}],c=Ek(()=>t.settings.editorMeasure,s.map(e=>e.value),e=>t.onUpdate({editorMeasure:e})),l=j(()=>s.find(e=>e.value===t.settings.editorMeasure)?.hint??``);var u=EA(),d=P(u);G(d,n);var f=I(d,4);pi(f,21,()=>s,e=>e.value,(e,n)=>{let r=j(()=>t.settings.editorMeasure===z(n).value);var i=wA(),a=P(i,!0);D(i),R(e=>{K(i,`aria-checked`,z(r)),K(i,`tabindex`,e),K(i,`data-testid`,`editor-measure-${z(n).value}`),G(i,`flex: 1; padding: 6px 4px; border: none; border-radius: var(--tandem-r-1); cursor: pointer; font-size: 11px; font-weight: ${z(r)?600:400}; background: ${z(r)?`var(--tandem-accent)`:`transparent`}; color: ${z(r)?`var(--tandem-accent-fg)`:`var(--tandem-fg)`};`),U(a,z(n).label)},[()=>c.tabIndexFor(z(n).value)]),B(`click`,i,()=>t.onUpdate({editorMeasure:z(n).value})),H(e,i)}),D(f);var p=I(f,2),m=P(p,!0);D(p);var h=I(p,2),g=P(h);G(g,n);var _=I(g,4),v=P(_);$i(v);var y=I(v,2),b=e=>{var t=TA();B(`click`,t,o),H(e,t)};W(y,e=>{r&&e(b)});var x=I(y,2);D(_),D(h),D(u),R(()=>{U(m,z(l)),ea(v,t.settings.defaultSaveDirectory??``),x.disabled=!t.settings.defaultSaveDirectory,G(x,`padding: 6px 10px; font-size: 11px; white-space: nowrap; border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-1); background: transparent; color: var(--tandem-fg-muted); cursor: ${t.settings.defaultSaveDirectory?`pointer`:`default`}; opacity: ${t.settings.defaultSaveDirectory?1:.5};`)}),B(`keydown`,f,function(...e){c.handleKeyDown?.apply(this,e)}),zr(`submit`,_,a),zr(`blur`,v,e=>i(e.currentTarget.value)),B(`click`,x,()=>i(null)),H(e,u),A()}Br([`keydown`,`click`]);var OA=V(`<details class="cs-details svelte-x76129"><summary class="cs-summary svelte-x76129"><span class="cs-chevron svelte-x76129" aria-hidden="true">›</span> </summary> <div class="cs-body svelte-x76129"><!></div></details>`);function kA(e,t){let n=q(t,`defaultOpen`,3,!1);var r=OA(),i=P(r),a=I(P(i));D(i);var o=I(i,2);bi(P(o),()=>t.children),D(o),D(r),R(()=>{K(r,`data-testid`,t.testid),r.open=n(),K(i,`data-testid`,t.testid?`${t.testid}-toggle`:void 0),U(a,` ${t.label??``}`)}),H(e,r)}var AA=V(`<span style="color: var(--tandem-fg-subtle);"> </span>`),jA=V(`<button type="button" data-testid="network-restart-sidecar"> </button>`),MA=V(`<span style="font-size: 10px; color: var(--tandem-fg-subtle);">Run <code>tandem stop && tandem start</code> to restart</span>`),NA=V(`<div style="font-size: 10px; color: var(--tandem-error-fg); margin-top: var(--tandem-space-1);"> </div>`),PA=V(`<span><strong>Host:</strong> </span>`),FA=V(`<div><div>Loopback Port</div> <div style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface-muted); font-size: 13px; color: var(--tandem-fg-subtle); display: inline-block;"> </div> <div>Port used when transport is HTTP. To change, run <code>tandem start --port <N></code>.</div></div>`),IA=V(`<option> </option>`),LA=V(`<div><div>Token Rotation</div> <div style="font-size: 12px; color: var(--tandem-fg);"> </div> <div>To rotate: run <code>tandem rotate-token</code> in the CLI.</div></div>`),RA=V(`<!> <div><div>Show degraded banner after: <span style="font-weight: 400; text-transform: none;"> </span></div> <input data-testid="network-degraded-delay-slider" type="range" min="5000" max="120000" step="5000" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Degraded banner delay"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span>5s</span> <span>120s</span></div></div> <div><div>Reconnect Strategy</div> <select data-testid="network-retry-strategy" style="width: 100%; padding: 6px 8px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: pointer;" aria-label="Reconnect retry strategy"></select></div> <!>`,1),zA=V(`<div><div>Connection Status</div> <div style="display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface);"><span aria-hidden="true"></span> <span style="font-size: 12px; color: var(--tandem-fg); flex: 1;"> <!></span> <!></div> <!></div> <div><div>Transport</div> <div style="display: flex; gap: var(--tandem-space-4); padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface); font-size: 12px; color: var(--tandem-fg);"><span><strong>Mode:</strong> </span> <!></div></div> <!>`,1);function BA(e,t){k(t,!0);let n=dA(()=>t.open),r=Lm(),i=M(null),a=M(!1);async function o(){if(r){N(a,!0),N(i,null);try{let{invoke:e}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);await e(`restart_sidecar`)}catch(e){N(i,e instanceof Error?e.message:String(e),!0)}finally{N(a,!1)}}}let s=[{value:`exponential`,label:`Exponential backoff`},{value:`constant-2s`,label:`Constant (2s)`}],c=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,l=`font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);`,u=j(()=>n.info?.transport),d=j(()=>n.info?.bindHost),f=j(()=>n.info?.bindPort),p=j(()=>z(u)===`http`),m=j(()=>n.info?.tokenRotatedAt);var h=zA(),g=F(h),_=P(g);G(_,c);var v=I(_,2),y=P(v),b=I(y,2),x=P(b),S=I(x),C=e=>{var n=AA(),r=P(n);D(n),R(()=>U(r,`· ${t.reconnectAttempts??``} retry attempt${t.reconnectAttempts===1?``:`s`}`)),H(e,n)};W(S,e=>{t.reconnectAttempts>0&&e(C)}),D(b);var w=I(b,2),ee=e=>{var t=jA(),n=P(t,!0);D(t),R(()=>{t.disabled=z(a),G(t,`padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer; opacity: ${z(a)?.5:1};`),U(n,z(a)?`Restarting…`:`Restart sidecar`)}),B(`click`,t,o),H(e,t)},T=e=>{H(e,MA())};W(w,e=>{r?e(ee):e(T,-1)}),D(v);var te=I(v,2),ne=e=>{var t=NA(),n=P(t,!0);D(t),R(()=>U(n,z(i))),H(e,t)};W(te,e=>{z(i)&&e(ne)}),D(g);var E=I(g,2),re=P(E);G(re,c);var ie=I(re,2),ae=P(ie),oe=I(P(ae));D(ae);var se=I(ae,2),ce=e=>{var t=PA(),n=I(P(t));D(t),R(()=>U(n,` ${z(d)??``}`)),H(e,t)};W(se,e=>{z(d)&&e(ce)}),D(ie),D(E),kA(I(E,2),{label:`Advanced`,testid:`network-advanced`,children:(e,n)=>{var r=RA(),i=F(r),a=e=>{var t=FA(),n=P(t);G(n,c);var r=I(n,2),i=P(r,!0);D(r),G(I(r,2),l),D(t),R(()=>U(i,z(f)??`—`)),H(e,t)};W(i,e=>{z(p)&&e(a)});var o=I(i,2),u=P(o);G(u,c);var d=I(P(u)),h=P(d);D(d),D(u);var g=I(u,2);$i(g),O(2),D(o);var _=I(o,2),v=P(_);G(v,c);var y=I(v,2);pi(y,21,()=>s,e=>e.value,(e,t)=>{var n=IA(),r=P(n,!0);D(n);var i={};R(()=>{U(r,z(t).label),i!==(i=z(t).value)&&(n.value=(n.__value=z(t).value)??``)}),H(e,n)}),D(y);var b;Ki(y),D(_);var x=I(_,2),S=e=>{var t=LA(),n=P(t);G(n,c);var r=I(n,2),i=P(r,!0);D(r),G(I(r,2),l),D(t),R(e=>U(i,e),[()=>z(m)===null?`Auth token not yet created`:`Last rotated: ${new Date(z(m)).toLocaleString()}`]),H(e,t)};W(x,e=>{z(m)!==void 0&&e(S)}),R(()=>{U(h,`${t.settings.degradedBannerDelayMs/1e3}s`),ea(g,t.settings.degradedBannerDelayMs),b!==(b=t.settings.sidecarRetryStrategy)&&(y.value=(y.__value=t.settings.sidecarRetryStrategy)??``,Gi(y,t.settings.sidecarRetryStrategy))}),B(`input`,g,e=>t.onUpdate({degradedBannerDelayMs:Number(e.target.value)})),B(`change`,y,e=>t.onUpdate({sidecarRetryStrategy:e.target.value})),H(e,r)},$$slots:{default:!0}}),R(e=>{G(y,`width: 8px; height: 8px; border-radius: var(--tandem-r-circle); background: ${t.connected?`var(--tandem-success)`:`var(--tandem-error)`}; flex-shrink: 0;`),U(x,`${t.connected?`Connected to Tandem server`:`Disconnected`} `),U(oe,` ${e??``}`)},[()=>z(u)?z(u).toUpperCase():`—`]),H(e,h),A()}Br([`click`,`input`,`change`]);var VA=`INVALID_BODY`,HA=`PATH_REJECTED`,UA=`LAUNCHER_IN_PROGRESS`,WA=`LAUNCHER_NOT_AVAILABLE`,GA=`NO_CLAUDE_INTEGRATION`,KA=V(`<div data-testid="settings-modal-connect-ai-callout" style="display: flex; flex-direction: column; align-items: flex-start; gap: var(--tandem-space-2); padding: var(--tandem-space-3); background: var(--tandem-info-bg); border: 1px solid var(--tandem-info-border); border-radius: var(--tandem-r-3); margin-bottom: var(--tandem-space-3);"><div style="font-size: 13px; font-weight: 600; color: var(--tandem-info-fg-strong);">No AI connected yet</div> <div style="font-size: 12px; line-height: 1.5; color: var(--tandem-info-fg);">Tandem's AI works through Claude Code or Claude Desktop using your existing Claude
|
|
110
|
-
sign-in — no API key needed. The setup wizard connects it in one step.</div> <button type="button" data-testid="settings-modal-connect-ai-btn" style="font-size: 12px; font-weight: 500; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-accent); background: var(--tandem-accent); color: var(--tandem-accent-fg); cursor: pointer;">Connect AI…</button></div>`),qA=V(`<div role="alert" data-testid="settings-modal-working-directory-load-error" style="font-size: 11px; color: var(--tandem-error-fg); background: var(--tandem-error-bg); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); padding: var(--tandem-space-2);"> </div>`),JA=V(`<button type="button" data-testid="settings-modal-working-directory-pick" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: pointer;">Choose folder…</button>`),YA=V(`<div role="alert" style="font-size: 11px; color: var(--tandem-error-fg);"> </div>`),XA=V(`<div data-testid="settings-modal-working-directory" style="display: flex; flex-direction: column; gap: var(--tandem-space-2);"><div class="settings-section-label">Claude working directory</div> <div class="settings-hint">Folder where Claude launches. Defaults to your home directory if empty.</div> <form style="display: flex; gap: var(--tandem-space-2);"><input type="text" name="wd" data-testid="settings-modal-working-directory-input" style="flex: 1; font-size: 12px; padding: var(--tandem-space-2); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface); color: var(--tandem-fg); font-family: var(--tandem-font-mono);"/> <button type="submit" data-testid="settings-modal-working-directory-save" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: pointer;">Save</button></form> <div style="display: flex; gap: var(--tandem-space-2);"><!> <button type="button" data-testid="settings-modal-working-directory-reset" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: transparent; color: var(--tandem-fg-muted); cursor: pointer;">Reset to default</button></div> <!></div>`),ZA=V(`<div data-testid="settings-modal-cowork-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>`),QA=V(`<!> <p style="font-size: 12px; line-height: 1.5; color: var(--tandem-fg-muted); margin: 0 0 var(--tandem-space-3);">Tandem connects to any MCP-capable AI client over its MCP endpoint. Claude (Claude Code and
|
|
111
|
-
Claude Desktop) is the default integration — auto-configured, tested, and the only client whose
|
|
112
|
-
channel-push, cowork, and auto-launch extras are validated today. Other clients can connect
|
|
113
|
-
manually using the MCP endpoint on the Network tab.</p> <div><div class="settings-section-label">Selection Sensitivity: <span style="font-weight: 400; text-transform: none;"> </span></div> <div class="settings-hint" style="margin-bottom: 6px;">How long you must hold a selection before your AI notices it</div> <input data-testid="settings-modal-dwell-time-slider" type="range" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Selection dwell time"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span> </span> <span> </span></div></div> <label data-testid="settings-modal-selection-toolbar-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show floating selection toolbar</span></label> <label data-testid="settings-modal-margin-view-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Margin annotation view (Word-style)</span></label> <div data-testid="settings-modal-margin-view-hint" style="font-size: 10px; color: var(--tandem-fg-subtle);">Margin columns appear where rails are collapsed — open rails hide that side.</div> <!> <!> <button type="button" data-testid="settings-modal-open-integration-wizard" style="font-size: 12px; padding: var(--tandem-space-2) var(--tandem-space-3); border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: pointer; align-self: flex-start;"> </button> <!>`,1);function $A(e,t){k(t,!0);function n(e){switch(e){case HA:return`Working directory must be a folder inside your home directory.`;case VA:return`Working directory path is invalid.`;case UA:return`Another working-directory update is in progress. Try again.`;case GA:return`No Claude Code integration is configured.`;case WA: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=M(null),a=M(!1),o=M(null),s=M(!1),c=M(!1),l=M(null),u=j(()=>z(s)&&!z(c)&&!z(l)),d=!0;va(()=>{d=!1});async function f(){try{let e=await fetch(`${Il}/api/integrations`);if(!d)return;if(!e.ok){N(l,`Failed to load integrations (HTTP ${e.status}).`);return}let t=await e.json();if(!d)return;let n=t.integrations?.find(e=>e.kind===`claude-code`);n&&(N(c,!0),N(i,n.workingDirectory??null,!0))}catch(e){if(!d)return;console.warn(`[Settings] Failed to load workingDirectory:`,e),N(l,`Couldn't load Claude working directory.`)}finally{d&&N(s,!0)}}f();async function p(e){N(a,!0),N(o,null);try{let r=await fetch(`${Il}${Uc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workingDirectory:e})});if(!d)return;if(!r.ok){let e=await r.json().catch(()=>({}));if(!d)return;N(o,n(e.code),!0);return}let a=await r.json();if(!d)return;N(i,a.workingDirectory??null,!0),t.notify(`info`,`Working directory saved.`)}catch(e){if(!d)return;console.warn(`[Settings] Failed to save workingDirectory:`,e),N(o,`Couldn't save working directory.`)}finally{d&&N(a,!1)}}async function m(){let e;try{({open:e}=await Ul(()=>import(`./dist-js-BWAGOggB.js`),__vite__mapDeps([2,1])))}catch(e){console.warn(`[Settings] Folder picker import failed:`,e),t.notify(`error`,`Folder picker plugin unavailable`);return}try{let t=await e({directory:!0,multiple:!1,title:`Choose Claude working directory`});typeof t==`string`&&p(t)}catch(e){console.warn(`[Settings] Folder picker open() failed:`,e),t.notify(`error`,`Folder picker permission denied or IPC error`)}}function h(e){e.preventDefault();let t=e.target.elements.namedItem(`wd`)?.value.trim();p(t||null)}function g(){p(null)}var _=QA(),v=F(_),y=e=>{var t=KA(),n=I(P(t),4);D(t),B(`click`,n,r),H(e,t)};W(v,e=>{z(u)&&e(y)});var b=I(v,4),x=P(b),S=I(P(x)),C=P(S);D(S),D(x);var w=I(x,4);$i(w),K(w,`step`,100);var ee=I(w,2),T=P(ee),te=P(T);D(T);var ne=I(T,2),E=P(ne);D(ne),D(ee),D(b);var re=I(b,2),ie=P(re);$i(ie),O(2),D(re);var ae=I(re,2),oe=P(ae);$i(oe),O(2),D(ae);var se=I(ae,4),ce=e=>{var t=qA(),n=P(t,!0);D(t),R(()=>U(n,z(l))),H(e,t)};W(se,e=>{z(s)&&!z(c)&&z(l)&&e(ce)});var le=I(se,2),ue=e=>{var t=XA(),n=I(P(t),4),r=P(n);$i(r),K(r,`placeholder`,`(default: home)`);var s=I(r,2);D(n);var c=I(n,2),l=P(c),u=e=>{var t=JA();R(()=>t.disabled=z(a)),B(`click`,t,m),H(e,t)},d=j(()=>Lm());W(l,e=>{z(d)&&e(u)});var f=I(l,2);D(c);var p=I(c,2),_=e=>{var t=YA(),n=P(t,!0);D(t),R(()=>U(n,z(o))),H(e,t)};W(p,e=>{z(o)&&e(_)}),D(t),R(()=>{ea(r,z(i)??``),r.disabled=z(a),s.disabled=z(a),f.disabled=z(a)||z(i)===null}),zr(`submit`,n,h),B(`click`,f,g),H(e,t)};W(le,e=>{z(s)&&z(c)&&e(ue)});var de=I(le,2),fe=P(de,!0);D(de);var pe=I(de,2),me=e=>{var t=Xr();oi(F(t),()=>Ul(()=>import(`./CoworkSettings-CAr7DoyA.js`),__vite__mapDeps([4,5])),e=>{H(e,ZA())},(e,t)=>{let n=j(()=>z(t).default);var r=Xr();xi(F(r),()=>z(n),(e,t)=>{t(e,{})}),H(e,r)}),H(e,t)},he=j(()=>Lm());W(pe,e=>{z(he)&&e(me)}),R((e,n,r)=>{U(C,`${e??``}s`),K(w,`min`,500),K(w,`max`,Ia),ea(w,t.settings.selectionDwellMs),U(te,`${n??``}s`),U(E,`${r??``}s`),ta(ie,t.settings.selectionToolbar),ta(oe,t.settings.marginView),U(fe,z(u)?`Open integration wizard…`:`Reopen integration wizard…`)},[()=>(t.settings.selectionDwellMs/1e3).toFixed(1),()=>(500/1e3).toFixed(1),()=>(Ia/1e3).toFixed(1)]),B(`input`,w,e=>t.onUpdate({selectionDwellMs:Number(e.target.value)})),B(`change`,ie,e=>t.onUpdate({selectionToolbar:e.target.checked})),B(`change`,oe,e=>t.onUpdate({marginView:e.target.checked})),B(`click`,de,r),H(e,_),A()}Br([`click`,`input`,`change`]);function ej(e){let t=e?.trim();return t?t.slice(0,40):`You`}function tj(){try{return ej(localStorage.getItem(ao))}catch{return`You`}}function nj(e){let t=ej(e);try{localStorage.setItem(ao,t)}catch{}return typeof window<`u`&&window.dispatchEvent(new Event(oo)),t}function rj(e){let t=()=>e(tj()),n=t=>{t.key===`tandem:userName`&&e(ej(t.newValue))};return window.addEventListener(oo,t),window.addEventListener(`storage`,n),()=>{window.removeEventListener(oo,t),window.removeEventListener(`storage`,n)}}function ij(){let e=M(un(tj()));return va(rj(t=>{N(e,t,!0)})),{get userName(){return z(e)},setUserName:t=>{N(e,nj(t),!0)}}}var aj=V(`<div><label for="settings-modal-display-name" class="settings-section-label">Display Name</label> <input id="settings-modal-display-name" data-testid="settings-modal-display-name" type="text" style="width: 100%; padding: 8px 10px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); outline: none;"/></div> <div><div id="settings-modal-default-mode-label" class="settings-section-label">Default Mode</div> <div role="radiogroup" aria-labelledby="settings-modal-default-mode-label" class="settings-mode-btns"><button type="button" data-testid="settings-modal-default-mode-tandem-btn" role="radio" class="settings-mode-btn">Tandem</button> <button type="button" data-testid="settings-modal-default-mode-solo-btn" role="radio" class="settings-mode-btn">Solo</button></div> <div class="settings-hint" style="margin-top: var(--tandem-space-1);">Sets the preferred starting mode for new sessions.</div></div> <label data-testid="settings-modal-solo-rail-hidden-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Hide side panel in Solo mode</span></label> <div class="settings-hint" style="margin-top: var(--tandem-space-1);">When enabled, the annotation panel hides automatically when you enter Solo mode and
|
|
114
|
-
restores when you return to Tandem.</div>`,1);function oj(e,t){k(t,!0);let n=ij(),r=M(un(n.userName)),i=M(void 0);L(()=>{let e=n.userName;z(r)!==e&&document.activeElement!==z(i)&&N(r,e,!0)});var a=aj(),o=F(a),s=I(P(o),2);$i(s),fa(s,e=>N(i,e),()=>z(i)),D(o);var c=I(o,2),l=I(P(c),2),u=P(l),d=I(u,2);D(l),O(2),D(c);var f=I(c,2),p=P(f);$i(p),O(2),D(f),O(2),R(()=>{ea(s,z(r)),K(s,`maxlength`,40),K(u,`aria-checked`,t.settings.defaultMode===`tandem`),K(d,`aria-checked`,t.settings.defaultMode===`solo`),ta(p,t.settings.soloRailHidden)}),B(`input`,s,e=>{N(r,e.target.value,!0)}),zr(`blur`,s,()=>n.setUserName(z(r))),B(`keydown`,s,e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(N(r,n.userName,!0),e.currentTarget.blur())}),B(`click`,u,()=>t.onUpdate({defaultMode:`tandem`})),B(`click`,d,()=>t.onUpdate({defaultMode:`solo`})),B(`change`,p,e=>t.onUpdate({soloRailHidden:e.target.checked})),H(e,a),A()}Br([`input`,`keydown`,`click`,`change`]);var sj=mg({baseUrl:`http://127.0.0.1:${xa}`,pathFor:tg});function cj(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function lj(){return crypto.randomUUID()}function uj(e){if(e.provider!==void 0&&!Sl.includes(e.provider))throw Error(`Invalid model provider: ${String(e.provider)}`)}async function dj(e,t){let n=await sj.set(e,t);if(n.status===`ok`)return;let r=n.status===`unavailable`?`KEYCHAIN_UNAVAILABLE`:`STORE_FAILED`;throw Error(`Failed to store model key (${r})`)}function fj(e){return{get models(){return e.settings.models},get defaultModelId(){return e.settings.defaultModelId},get hasLegacyKeys(){return e.settings.models.some(e=>typeof e._legacyApiKey==`string`)},async addModel(t,n){uj(t);let r=lj(),i;n&&n.length>0&&(i=cj(),await dj(i,n));let a={...t,id:r,...i?{apiKeyRef:i}:{}};return e.updateSettings({models:[...e.settings.models,a]}),r},async updateModel(t,n,r){uj(n);let i=e.settings.models.find(e=>e.id===t);if(!i)return;let a;r!==void 0&&r.length>0&&(a=cj(),await Promise.all([dj(a,r),i.apiKeyRef?sj.delete(i.apiKeyRef):Promise.resolve()])),e.updateSettings({models:e.settings.models.map(e=>e.id===t?{...e,...n,...a?{apiKeyRef:a}:{}}:e)})},async deleteModel(t){let n=e.settings.models.find(e=>e.id===t);n?.apiKeyRef&&await sj.delete(n.apiKeyRef),e.updateSettings({models:e.settings.models.filter(e=>e.id!==t),defaultModelId:e.settings.defaultModelId===t?null:e.settings.defaultModelId})},toggleEnabled(t){e.updateSettings({models:e.settings.models.map(e=>e.id===t?{...e,enabled:!e.enabled}:e)})},setDefault(t){e.updateSettings({defaultModelId:t})},async migrateLegacyKeys(){let t=e.settings.models,n=t.map((e,t)=>typeof e._legacyApiKey==`string`?t:-1).filter(e=>e>=0);if(n.length===0)return{migrated:0,failed:0};let r=n.map(()=>cj()),i=await Promise.allSettled(n.map((e,n)=>dj(r[n],t[e]._legacyApiKey))),a=t.slice(),o=0,s=0;return i.forEach((e,i)=>{let c=n[i];if(e.status===`fulfilled`){let e={...t[c],apiKeyRef:r[i]};delete e._legacyApiKey,a[c]=e,o++}else s++}),o>0&&e.updateSettings({models:a}),{migrated:o,failed:s}}}}var pj=V(`<option> </option>`),mj=V(`<div class="mem-key-row svelte-1pwv6ag"><span class="mem-key-preview svelte-1pwv6ag" aria-label="Existing API key (masked)"> </span> <button type="button" class="mem-key-replace-btn svelte-1pwv6ag" data-testid="model-edit-apikey-replace-btn">Replace key</button></div>`),hj=V(`<input data-testid="model-edit-apikey" class="mem-input mem-input--mono svelte-1pwv6ag" type="password" autocomplete="off"/>`),gj=V(`<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">API key</span> <!></label>`),_j=V(`<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Endpoint</span> <input data-testid="model-edit-endpoint" class="mem-input mem-input--mono svelte-1pwv6ag" type="text" autocomplete="off" placeholder="http://localhost:11434"/></label>`),vj=V(`<p class="mem-advanced-help svelte-1pwv6ag">Per-model parameter overrides (temperature, max tokens, etc.) are not editable in
|
|
115
|
-
this preview. The data model accepts a \`params\` map for forward-compat with
|
|
116
|
-
Wave 6 surfaces.</p>`),yj=V(`<div role="dialog" aria-modal="true" data-testid="model-edit-modal" class="mem-scrim svelte-1pwv6ag"><form class="mem-dialog svelte-1pwv6ag"><div class="mem-header svelte-1pwv6ag"><h3 class="mem-title svelte-1pwv6ag"> </h3> <button type="button" class="mem-close svelte-1pwv6ag" data-testid="model-edit-cancel" aria-label="Close">×</button></div> <label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Provider</span> <select data-testid="model-edit-provider" class="mem-input svelte-1pwv6ag"></select></label> <label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Display name</span> <input data-testid="model-edit-displayname" class="mem-input svelte-1pwv6ag" type="text" autocomplete="off" placeholder="My Anthropic key"/></label> <label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">Model ID</span> <input data-testid="model-edit-modelid" class="mem-input mem-input--mono svelte-1pwv6ag" type="text" autocomplete="off" placeholder="e.g. claude-opus-4-7"/></label> <!> <!> <label class="mem-enabled-row svelte-1pwv6ag"><input type="checkbox" class="mem-enabled-cbx svelte-1pwv6ag"/> <span>Enabled</span></label> <!> <div class="mem-actions svelte-1pwv6ag"><button type="button" class="mem-btn mem-btn--ghost svelte-1pwv6ag">Cancel</button> <button type="submit" class="mem-btn mem-btn--primary svelte-1pwv6ag" data-testid="model-edit-save"> </button></div></form></div>`);function bj(e,t){k(t,!0);let n=[{value:`anthropic`,label:`Anthropic`},{value:`openai`,label:`OpenAI`},{value:`gemini`,label:`Gemini`},{value:`local-ollama`,label:`Ollama (local)`},{value:`local-llamacpp`,label:`llama.cpp (local)`}],r=Ar(()=>t.entry),i=M(un(r?.provider??`anthropic`)),a=M(un(r?.displayName??``)),o=M(un(r?.modelId??``)),s=M(un(r?.endpoint??``)),c=M(un(r?.enabled??!0)),l=M(``),u=r!==void 0&&!!r.apiKeyRef,d=M(un(r===void 0||!u)),f=r!==void 0,p=j(()=>z(i)===`anthropic`||z(i)===`openai`||z(i)===`gemini`),m=j(()=>z(i).startsWith(`local-`)),h=r?.apiKeyRef?r.apiKeyRef.slice(-4):``,g=j(()=>z(a).trim().length>0&&z(o).trim().length>0&&(!z(p)||!z(d)||z(l).trim().length>0));function _(e){if(e.preventDefault(),!z(g))return;let n={provider:z(i),displayName:z(a).trim(),modelId:z(o).trim(),enabled:z(c)};z(p)&&z(d)&&z(l).trim()&&(n.plaintextApiKey=z(l).trim()),z(m)&&z(s).trim()&&(n.endpoint=z(s).trim()),t.onSave(n)}function v(){N(d,!0),N(l,``)}var y=yj();K(y,`tabindex`,-1);var b=P(y),x=P(b),S=P(x),C=P(S,!0);D(S);var w=I(S,2);D(x);var ee=I(x,2),T=I(P(ee),2);pi(T,21,()=>n,e=>e.value,(e,t)=>{var n=pj(),r=P(n,!0);D(n);var i={};R(()=>{U(r,z(t).label),i!==(i=z(t).value)&&(n.value=(n.__value=z(t).value)??``)}),H(e,n)}),D(T),D(ee);var te=I(ee,2),ne=I(P(te),2);$i(ne),D(te);var E=I(te,2),re=I(P(E),2);$i(re),D(E);var ie=I(E,2),ae=e=>{var t=gj(),n=I(P(t),2),i=e=>{var t=mj(),n=P(t),r=P(n);D(n);var i=I(n,2);D(t),R(()=>U(r,`••••••••${h??``}`)),B(`click`,i,v),H(e,t)},a=e=>{var t=hj();$i(t),R(()=>K(t,`placeholder`,f?`Enter new key`:`Paste your API key`)),aa(t,()=>z(l),e=>N(l,e)),H(e,t)};W(n,e=>{f&&r?.apiKeyRef&&!z(d)?e(i):e(a,-1)}),D(t),H(e,t)};W(ie,e=>{z(p)&&e(ae)});var oe=I(ie,2),se=e=>{var t=_j(),n=I(P(t),2);$i(n),D(t),aa(n,()=>z(s),e=>N(s,e)),H(e,t)};W(oe,e=>{z(m)&&e(se)});var ce=I(oe,2),le=P(ce);$i(le),O(2),D(ce);var ue=I(ce,2);kA(ue,{label:`Advanced parameters`,testid:`model-edit-advanced`,children:(e,t)=>{H(e,vj())},$$slots:{default:!0}});var de=I(ue,2),fe=P(de),pe=I(fe,2),me=P(pe,!0);D(pe),D(de),D(b),D(y),R(()=>{K(y,`aria-label`,f?`Edit model`:`Add model`),U(C,f?`Edit model`:`Add model`),pe.disabled=!z(g),U(me,f?`Save changes`:`Add model`)}),B(`click`,y,e=>{e.target===e.currentTarget&&t.onCancel()}),B(`keydown`,y,e=>{e.key===`Escape`&&t.onCancel()}),zr(`submit`,b,_),B(`click`,w,function(...e){t.onCancel?.apply(this,e)}),qi(T,()=>z(i),e=>N(i,e)),aa(ne,()=>z(a),e=>N(a,e)),aa(re,()=>z(o),e=>N(o,e)),oa(le,()=>z(c),e=>N(c,e)),B(`click`,fe,function(...e){t.onCancel?.apply(this,e)}),H(e,y),A()}Br([`click`,`keydown`]);var xj=V(`<span data-testid="models-legacy-migration-status"> </span>`),Sj=V(`<div data-testid="models-legacy-migration-banner" role="note" style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-3); background: var(--tandem-warning-bg); color: var(--tandem-warning-fg-strong); font-size: 12px; line-height: 1.5; display: flex; flex-direction: column; gap: var(--tandem-space-2);"><div><strong style="font-weight: 600;">Move API keys to OS keychain.</strong> Existing keys were stored unencrypted in browser storage. Move them now to
|
|
117
|
-
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>`),Cj=V(`<div data-testid="models-empty-state" style="padding: var(--tandem-space-5) var(--tandem-space-3); text-align: center; border: 1px dashed var(--tandem-border-strong); border-radius: var(--tandem-r-3); color: var(--tandem-fg-muted); font-size: 13px;"><p style="margin: 0 0 var(--tandem-space-3) 0;">No models configured.</p> <button type="button" data-testid="model-add-btn" style="padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: none; border-radius: var(--tandem-r-2); cursor: pointer; background: var(--tandem-accent); color: var(--tandem-accent-fg);">Add your first model</button></div>`),wj=V(`<button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-2); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); cursor: pointer;">Confirm</button> <button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: pointer;">Cancel</button>`,1),Tj=V(`<button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-error-fg); cursor: pointer;">Delete</button>`),Ej=V(`<div style="display: flex; align-items: center; gap: var(--tandem-space-2); padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-3); background: var(--tandem-surface);"><div style="flex: 1; min-width: 0;"><div style="font-size: 13px; color: var(--tandem-fg); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </div> <div style="font-size: 11px; color: var(--tandem-fg-subtle); font-family: var(--tandem-font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> </div></div> <label style="display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tandem-fg-muted);" title="Use as the default model"><input type="radio" name="default-model" style="accent-color: var(--tandem-accent);"/> <span>Default</span></label> <label style="display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tandem-fg-muted);"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span> </span></label> <button type="button" style="padding: 2px var(--tandem-space-2); font-size: 11px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg); cursor: pointer;">Edit</button> <!></div>`),Dj=V(`<div><div class="settings-section-label"> </div> <div style="display: flex; flex-direction: column; gap: 4px;"></div></div>`),Oj=V(`<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"></div> <button type="button" data-testid="model-add-btn" style="align-self: flex-start; padding: 6px var(--tandem-space-3); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-accent-border); border-radius: var(--tandem-r-2); cursor: pointer; background: var(--tandem-surface); color: var(--tandem-accent);">+ Add model</button>`,1),kj=V(`<div role="alert" data-testid="models-save-error" style="padding: var(--tandem-space-2) var(--tandem-space-3); border: 1px solid var(--tandem-error-border); border-radius: var(--tandem-r-3); background: var(--tandem-error-bg); color: var(--tandem-error-fg-strong); font-size: 12px;"> </div>`),Aj=V(`<div style="display: flex; flex-direction: column; gap: var(--tandem-space-3);"><!> <!></div> <!> <!>`,1);function jj(e,t){k(t,!0);let n=fj(J_()),r={anthropic:`Anthropic`,openai:`OpenAI`,gemini:`Gemini`,"local-ollama":`Ollama (local)`,"local-llamacpp":`llama.cpp (local)`},i=[`anthropic`,`openai`,`gemini`,`local-ollama`,`local-llamacpp`],a=j(()=>{let e=new Map;for(let t of i)e.set(t,[]);for(let t of n.models){let n=e.get(t.provider);n&&n.push(t)}return e}),o=M(void 0),s=M(!1),c=M(null),l=M(null),u=M(!1),d=M(null);function f(){N(o,void 0),N(l,null),N(s,!0)}function p(e){N(o,e,!0),N(l,null),N(s,!0)}async function m(e){let{plaintextApiKey:t,...r}=e;try{z(o)?await n.updateModel(z(o).id,r,t):await n.addModel(r,t),N(s,!1),N(o,void 0),N(l,null)}catch(e){N(l,e instanceof Error?e.message:`Failed to save`,!0)}}async function h(e){await n.deleteModel(e),N(c,null)}async function g(){N(u,!0),N(d,null);try{let e=await n.migrateLegacyKeys();e.failed>0?N(d,`Migrated ${e.migrated}; ${e.failed} failed. Retry?`):e.migrated>0&&N(d,`Migrated ${e.migrated} ${e.migrated===1?`key`:`keys`} to OS keychain.`)}finally{N(u,!1)}}var _=Aj(),v=F(_),y=P(v),b=e=>{var t=Sj(),n=I(P(t),2),r=P(n),i=P(r,!0);D(r);var a=I(r,2),o=e=>{var t=xj(),n=P(t,!0);D(t),R(()=>U(n,z(d))),H(e,t)};W(a,e=>{z(d)&&e(o)}),D(n),D(t),R(()=>{r.disabled=z(u),G(r,`padding: 4px var(--tandem-space-3); font-size: 12px; font-weight: 500; border: 1px solid var(--tandem-warning-border); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-warning-fg-strong); cursor: ${z(u)?`wait`:`pointer`};`),U(i,z(u)?`Migrating…`:`Migrate keys`)}),B(`click`,r,g),H(e,t)};W(y,e=>{n.hasLegacyKeys&&e(b)});var x=I(y,2),S=e=>{var t=Cj(),n=I(P(t),2);D(t),B(`click`,n,f),H(e,t)},C=e=>{var t=Oj(),o=F(t);pi(o,20,()=>i,e=>e,(e,t)=>{let i=j(()=>z(a).get(t)??[]);var o=Xr(),s=F(o),l=e=>{var a=Dj(),o=P(a),s=P(o,!0);D(o);var l=I(o,2);pi(l,21,()=>z(i),e=>e.id,(e,t)=>{var r=Ej(),i=P(r),a=P(i),o=P(a,!0);D(a);var s=I(a,2),l=P(s,!0);D(s),D(i);var u=I(i,2),d=P(u);$i(d),O(2),D(u);var f=I(u,2),m=P(f);$i(m);var g=I(m,2),_=P(g,!0);D(g),D(f);var v=I(f,2),y=I(v,2),b=e=>{var n=wj(),r=F(n),i=I(r,2);R(()=>K(r,`data-testid`,`model-delete-confirm-${z(t).id}`)),B(`click`,r,()=>h(z(t).id)),B(`click`,i,()=>N(c,null)),H(e,n)},x=e=>{var n=Tj();R(()=>K(n,`data-testid`,`model-delete-btn-${z(t).id}`)),B(`click`,n,()=>N(c,z(t).id,!0)),H(e,n)};W(y,e=>{z(c)===z(t).id?e(b):e(x,-1)}),D(r),R(()=>{K(r,`data-testid`,`model-row-${z(t).id}`),U(o,z(t).displayName),U(l,z(t).modelId),K(d,`data-testid`,`model-default-${z(t).id}`),ta(d,n.defaultModelId===z(t).id),K(m,`data-testid`,`model-toggle-${z(t).id}`),ta(m,z(t).enabled),U(_,z(t).enabled?`On`:`Off`),K(v,`data-testid`,`model-edit-btn-${z(t).id}`)}),B(`change`,d,()=>n.setDefault(z(t).id)),B(`change`,m,()=>n.toggleEnabled(z(t).id)),B(`click`,v,()=>p(z(t))),H(e,r)}),D(l),D(a),R(()=>U(s,r[t])),H(e,a)};W(s,e=>{z(i).length>0&&e(l)}),H(e,o)}),D(o),B(`click`,I(o,2),f),H(e,t)};W(x,e=>{n.models.length===0?e(S):e(C,-1)}),D(v);var w=I(v,2),ee=e=>{var t=kj(),n=P(t,!0);D(t),R(()=>U(n,z(l))),H(e,t)};W(w,e=>{z(l)&&e(ee)});var T=I(w,2),te=e=>{bj(e,{get entry(){return z(o)},onCancel:()=>{N(s,!1),N(o,void 0),N(l,null)},onSave:m})};W(T,e=>{z(s)&&e(te)}),H(e,_),A()}Br([`click`,`change`]);var Mj=V(`<div data-testid="store-readonly-banner" style="font-size: 11px; color: var(--tandem-warning-fg); margin-bottom: 8px;">Settings are read-only (a newer client wrote them). Shortcut changes are disabled.</div>`),Nj=V(`<span style="justify-self: start; font-size: 11px; color: var(--tandem-accent-fg-strong); font-style: italic;">Press keys… (Esc to cancel)</span>`),Pj=V(`<kbd> </kbd>`),Fj=V(`<button type="button">Reset</button>`),Ij=V(`<div style="grid-column: 1 / -1; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),Lj=V(`<div style="display: grid; grid-template-columns: 1fr max-content auto; gap: 10px; align-items: center; padding: 3px 0;"><span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span> <!> <div style="display: flex; gap: 6px; justify-self: end;"><button type="button"> </button> <!></div> <!></div>`),Rj=V(`<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),zj=V(`<section><div class="settings-section-label"> </div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section>`),Bj=V(`<kbd> </kbd> <span style="font-size: 13px; color: var(--tandem-fg-muted);"> </span>`,1),Vj=V(`<div style="display: flex; flex-direction: column; gap: var(--tandem-space-4);"><section><div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;"><div class="settings-section-label">Customizable</div> <button type="button" data-testid="shortcuts-reset-all">Reset all</button></div> <!> <div style="display: flex; flex-direction: column; gap: 4px;"></div></section> <!> <section><div class="settings-section-label">Other (fixed)</div> <div style="display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; align-items: center;"></div></section></div>`);function Hj(e,t){k(t,!0);let n=q(t,`notify`,3,()=>{}),r=M(null),i=M(null),a=j(()=>t.settings._readOnly===!0),o=j(()=>vl(t.settings.customShortcuts));L(()=>{if(z(r)===null)return;let e=z(r),a=a=>{if(a.preventDefault(),a.stopPropagation(),a.key===`Escape`){N(r,null),N(i,null);return}let s=el(a);if(!s)return;let c=hl(s,z(o),e);if(c){N(i,{id:e,message:`Already used by ${c}`},!0);return}N(r,null),N(i,null),t.onUpdate({customShortcuts:{...t.settings.customShortcuts,[e]:s}}),n()(`info`,`${qc[e]} set to ${ol(s)}`)};return window.addEventListener(`keydown`,a,{capture:!0}),()=>window.removeEventListener(`keydown`,a,{capture:!0})});function s(e){z(a)||(N(i,null),N(r,e,!0))}function c(e){if(z(a))return;let{[e]:n,...o}=t.settings.customShortcuts;t.onUpdate({customShortcuts:o}),z(r)===e&&N(r,null),z(i)?.id===e&&N(i,null)}function l(){z(a)||(t.onUpdate({customShortcuts:{}}),N(r,null),N(i,null))}let u=j(()=>Wc.some(e=>z(o).has(e))),d=j(()=>{let e=su(),t=new Map;for(let n of e.values()){if(!n.shortcut||Xc[n.id])continue;let e=t.get(n.group)??[];e.push({keys:n.shortcut,description:n.label}),t.set(n.group,e)}return iu.map(e=>({title:e.charAt(0).toUpperCase()+e.slice(1),rows:t.get(e)??[]})).filter(e=>e.rows.length>0)}),f=`justify-self: start; padding: 1px 6px; font-family: var(--tandem-font-mono); font-size: 11px; color: var(--tandem-fg); background: var(--tandem-surface-muted); border: 1px solid var(--tandem-border-strong); border-bottom-width: 2px; border-radius: var(--tandem-r-2);`;var p=Vj(),m=P(p),h=P(m),g=I(P(h),2);D(h);var _=I(h,2),v=e=>{H(e,Mj())};W(_,e=>{z(a)&&e(v)});var y=I(_,2);pi(y,20,()=>Wc,e=>e,(e,t)=>{let n=j(()=>z(r)===t),l=j(()=>z(o).has(t)),u=j(()=>ol(sl(t,z(o))));var d=Lj(),p=P(d),m=P(p,!0);D(p);var h=I(p,2),g=e=>{var n=Nj();R(()=>K(n,`data-testid`,`shortcut-recording-${t}`)),H(e,n)},_=e=>{var t=Pj();G(t,f);var n=P(t,!0);D(t),R(()=>U(n,z(u))),H(e,t)};W(h,e=>{z(n)?e(g):e(_,-1)});var v=I(h,2),y=P(v),b=P(y,!0);D(y);var x=I(y,2),S=e=>{var n=Fj();R(()=>{K(n,`data-testid`,`shortcut-reset-${t}`),n.disabled=z(a),G(n,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: ${z(a)?`not-allowed`:`pointer`}; opacity: ${z(a)?.5:1};`)}),B(`click`,n,()=>c(t)),H(e,n)};W(x,e=>{z(l)&&e(S)}),D(v);var C=I(v,2),w=e=>{var n=Ij(),r=P(n,!0);D(n),R(()=>{K(n,`data-testid`,`shortcut-conflict-${t}`),U(r,z(i).message)}),H(e,n)};W(C,e=>{z(i)&&z(i).id===t&&e(w)}),D(d),R(()=>{K(d,`data-testid`,`shortcut-row-${t}`),U(m,qc[t]),K(y,`data-testid`,`shortcut-edit-${t}`),y.disabled=z(a),G(y,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: ${z(n)?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; color: var(--tandem-fg); cursor: ${z(a)?`not-allowed`:`pointer`}; opacity: ${z(a)?.5:1};`),U(b,z(n)?`Recording…`:`Change`)}),B(`click`,y,()=>s(t)),H(e,d)}),D(y),D(m);var b=I(m,2);pi(b,17,()=>z(d),e=>e.title,(e,t)=>{var n=zj(),r=P(n),i=P(r);D(r);var a=I(r,2);pi(a,21,()=>z(t).rows,e=>e.keys+e.description,(e,t)=>{var n=Rj(),r=F(n);G(r,f);var i=P(r,!0);D(r);var a=I(r,2),o=P(a,!0);D(a),R(()=>{U(i,z(t).keys),U(o,z(t).description)}),H(e,n)}),D(a),D(n),R(()=>U(i,`${z(t).title??``} (fixed)`)),H(e,n)});var x=I(b,2),S=I(P(x),2);pi(S,21,()=>dm,e=>e.keys+e.description,(e,t)=>{var n=Bj(),r=F(n);G(r,f);var i=P(r,!0);D(r);var a=I(r,2),o=P(a,!0);D(a),R(()=>{U(i,z(t).keys),U(o,z(t).description)}),H(e,n)}),D(S),D(x),D(p),R(()=>{g.disabled=z(a)||!z(u),G(g,`font-size: 11px; padding: 2px 8px; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface); color: var(--tandem-fg-muted); cursor: ${z(a)||!z(u)?`not-allowed`:`pointer`}; opacity: ${z(a)||!z(u)?.5:1};`)}),B(`click`,g,l),H(e,p),A()}Br([`click`]);var Uj=V(`<div data-testid="settings-modal-shortcuts-list"><!></div>`);function Wj(e,t){var n=Uj();Hj(P(n),{get settings(){return t.settings},get onUpdate(){return t.onUpdate},get notify(){return t.notify}}),D(n),H(e,n)}var Gj=V(`<div data-testid="license-settings-section"><div class="settings-section-label">License status</div> <div class="license-pill svelte-ezrf0s" data-testid="license-status-pill"> </div> <div class="settings-section-label" style="margin-top: var(--tandem-space-4);">Activate a license</div> <!> <div class="settings-hint" style="margin-top: var(--tandem-space-1);">Paste a license key you received by email, or run <code>tandem activate <file></code> from
|
|
118
|
-
the command line. A valid license unlocks editing and runs forever.</div></div>`);function Kj(e,t){k(t,!0);let n=j(()=>F_.ui),r=j(()=>z(n).statusLabel||`No license required`);function i(){t.notify(`info`,`License activated.`)}var a=Gj(),o=I(P(a),2),s=P(o,!0);D(o),V_(I(o,4),{onActivated:i}),O(2),D(a),R(()=>U(s,z(r))),H(e,a),A()}var qj=null;function Jj(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function Yj(e){return e.replace(/sk-ant-[A-Za-z0-9_-]{8,}/g,`sk-ant-[redacted]`).replace(/sk-[A-Za-z0-9_-]{16,}/g,`sk-[redacted]`).replace(/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,`Bearer [redacted]`)}function Xj(e){return e.replace(/(\/Users\/)[^/\\]+/g,`$1[user]`).replace(/(\/home\/)[^/\\]+/g,`$1[user]`).replace(/([A-Za-z]:\\Users\\)[^\\]+/g,`$1[user]`)}function Zj(e){return Xj(Yj(e))}async function Qj(){if(Jj())try{let{invoke:e}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);if(!await e(`sentry_enabled`).catch(()=>!1))return;let t=await Ul(()=>import(`./prod-DeXsEx17.js`),[]),{defaultOptions:n}=await Ul(async()=>{let{defaultOptions:e}=await import(`./dist-dYgyssYq.js`);return{defaultOptions:e}},__vite__mapDeps([6,7]));t.init({...n,sendDefaultPii:!1,beforeSend:e=>{e.message&&=Zj(e.message);for(let t of e.exception?.values??[])t.value&&=Zj(t.value);return e.request&&(e.request.data=void 0,e.request.url&&(e.request.url=Zj(e.request.url))),e},beforeBreadcrumb:e=>(e.message&&=Zj(e.message),(e.category===`fetch`||e.category===`xhr`)&&(e.data=void 0),e)}),qj=t,window.addEventListener(`error`,e=>{eM(e.error??e.message,{source:`window.onerror`})}),window.addEventListener(`unhandledrejection`,e=>{eM(e.reason,{source:`unhandledrejection`})}),console.info(`[sentry] client crash reporting initialised`)}catch(e){console.warn(`[sentry] client init failed (non-fatal):`,e)}}function $j(){return qj!==null}function eM(e,t){if(qj)try{qj.captureException(e,t?{extra:t}:void 0)}catch{}}var tM={pass:`[ok] `,warn:`[warn]`,fail:`[fail]`};function nM(e){return e.replace(/[\x00-\x08\x0b-\x1f\x7f]/g,``)}function rM(e){let t=[`Tandem v${e.version} (${e.transport}${e.tauriSidecar?`, desktop`:``})`,`${e.platform}/${e.arch}, Node ${e.nodeVersion}`,``];for(let n of e.report.results)t.push(`${tM[n.status]} ${n.check} — ${nM(n.message)}`),n.status!==`pass`&&n.fix&&t.push(` fix: ${nM(n.fix)}`);return t.push(``,nM(e.report.summary)),t.join(`
|
|
119
|
-
`)}var iM=V(`<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),aM=V(`<button type="button" data-testid="settings-modal-open-log-folder-btn">Open Log Folder</button>`),oM=V(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>`),sM=V(`<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere; font-family: var(--tandem-font-mono);"> </dd>`,1),cM=V(`<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 11px;"></dl>`),lM=V(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>`),uM=V(`<div><button type="button" data-testid="settings-modal-view-documentation-btn"> </button> <!></div> <div style="display: flex; gap: var(--tandem-space-2);"><button type="button" data-testid="settings-modal-copy-diagnostics-btn"> </button> <!></div> <div data-testid="settings-modal-app-info-footer" style="border-top: 1px solid var(--tandem-border); padding-top: 10px;"><div class="settings-section-label">About</div> <!></div>`,1);function dM(e,t){k(t,!0);let n=dA(()=>t.open),r=M(!1),i=M(null),a=M(!1);async function o(){N(a,!0);let e;try{let n;try{n=await fetch(`${Il}${hc}`)}catch{t.notify(`error`,`Couldn't reach the server — is it running?`);return}if(!n.ok){t.notify(`error`,"Diagnostics failed on the server — try `tandem doctor` in a terminal");return}e=rM(await n.json())}catch{t.notify(`error`,"Diagnostics failed on the server — try `tandem doctor` in a terminal");return}finally{N(a,!1)}try{await navigator.clipboard.writeText(e),t.notify(`info`,`Diagnostics copied to clipboard`)}catch{t.notify(`error`,"Couldn't access the clipboard — run `tandem doctor` in a terminal instead")}}async function s(){try{let[{appLogDir:e},t]=await Promise.all([Ul(()=>import(`./path-49-uTKly.js`),__vite__mapDeps([0,1])),Bm()]);await t(`show_in_file_manager`,{path:await e()})}catch{t.notify(`error`,`Couldn't open the log folder`)}}async function c(){let e=n.info?.workflowsPath;if(!e){N(i,`Documentation file not found.`);return}N(r,!0),N(i,null);let t=await Ch(e,{readOnly:!0,notFoundMessage:`Documentation file not found.`,failureMessage:`Failed to open documentation.`});N(r,!1),t.ok||N(i,t.error,!0)}let l=j(()=>{let e=n.info;if(!e)return[];let t=[{label:`Version`,value:`Tandem v${e.version}`},{label:`Tools`,value:e.toolCount===null?`Tool count unavailable`:`${e.toolCount} tools available`},{label:`MCP SDK`,value:`MCP SDK ${e.mcpSdkVersion}`},{label:`Transport`,value:e.transport?.toUpperCase()??`—`}];return e.storagePath&&t.push({label:`Storage`,value:e.storagePath}),e.tokenRotatedAt!==void 0&&t.push({label:`Token`,value:e.tokenRotatedAt===null?`Token not created`:`Token rotated ${new Date(e.tokenRotatedAt).toLocaleString()}`}),e.changelogPath&&t.push({label:`Changelog`,value:e.changelogPath}),t.push({label:`Crash reports`,value:$j()?`On (TANDEM_SENTRY_DSN set)`:`Off — opt in with TANDEM_SENTRY_DSN`}),t});var u=uM(),d=F(u),f=P(d),p=P(f,!0);D(f);var m=I(f,2),h=e=>{var t=iM(),n=P(t,!0);D(t),R(()=>U(n,z(i))),H(e,t)};W(m,e=>{z(i)&&e(h)}),D(d);var g=I(d,2),_=P(g),v=P(_,!0);D(_);var y=I(_,2),b=e=>{var t=aM();G(t,`flex: 1; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: pointer;`),B(`click`,t,()=>void s()),H(e,t)},x=j(()=>Lm());W(y,e=>{z(x)&&e(b)}),D(g);var S=I(g,2),C=I(P(S),2),w=e=>{H(e,oM())},ee=e=>{var t=cM();pi(t,21,()=>z(l),e=>e.label,(e,t)=>{var n=sM(),r=F(n),i=P(r,!0);D(r);var a=I(r,2),o=P(a,!0);D(a),R(()=>{U(i,z(t).label),U(o,z(t).value)}),H(e,n)}),D(t),H(e,t)},T=e=>{H(e,lM())};W(C,e=>{n.loading?e(w):n.info?e(ee,1):e(T,-1)}),D(S),R(()=>{f.disabled=z(r)||n.loading,G(f,`width: 100%; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: ${z(r)||n.loading?`not-allowed`:`pointer`}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${z(r)||n.loading?.6:1};`),U(p,z(r)?`Opening…`:`View Documentation`),_.disabled=z(a),G(_,`flex: 1; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); background: var(--tandem-surface-muted); color: var(--tandem-fg); cursor: ${z(a)?`not-allowed`:`pointer`}; opacity: ${z(a)?.6:1};`),U(v,z(a)?`Collecting…`:`Copy Diagnostics`)}),B(`click`,f,()=>void c()),B(`click`,_,()=>void o()),H(e,u),A()}Br([`click`]);var fM={appearance:`appearance`,editor:`editor`,network:`network`,accessibility:`accessibility`,collaboration:`collaboration`,claudeCode:`claude-code`,models:`models`,shortcuts:`shortcuts`,license:`license`,about:`about`},pM=V(`<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>`),mM=V(`<button type="button" class="settings-modal-nav-btn svelte-bbu5nk"><svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path></path></svg> <span> </span></button>`),hM=V(`<div role="alert" data-testid="settings-modal-changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>`),gM=V(`<div role="button" tabindex="-1" aria-label="Close settings" data-testid="settings-modal-scrim" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); z-index: var(--tandem-z-above-titlebar);"></div> <div data-testid="settings-modal" role="dialog" aria-modal="true" class="settings-modal svelte-bbu5nk"><aside class="settings-modal-sidebar tandem-scroll-fade-y svelte-bbu5nk"><div class="settings-modal-sidebar-head svelte-bbu5nk"><div class="settings-modal-sidebar-title svelte-bbu5nk">Settings</div> <!></div> <nav aria-label="Settings sections" class="settings-modal-sidebar-nav svelte-bbu5nk"></nav> <div class="settings-modal-sidebar-foot svelte-bbu5nk" data-testid="settings-modal-sidebar-footer"><button type="button" data-testid="settings-modal-view-changelog-btn" class="settings-modal-sidebar-link svelte-bbu5nk"> </button> <!> <a target="_blank" rel="noreferrer" data-testid="settings-modal-report-bug-link" class="settings-modal-sidebar-link svelte-bbu5nk">Report a bug</a> <div class="settings-modal-sidebar-status svelte-bbu5nk" data-testid="settings-modal-mcp-status" aria-live="polite"><span class="settings-modal-status-dot svelte-bbu5nk"></span> <span class="settings-modal-status-label svelte-bbu5nk"><!></span></div></div></aside> <section class="settings-modal-content svelte-bbu5nk" data-testid="settings-modal-content"><header class="settings-modal-content-head svelte-bbu5nk"><button type="button" class="settings-modal-narrow-hamburger svelte-bbu5nk" data-testid="settings-modal-narrow-hamburger"><svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="4" y1="7" x2="20" y2="7"></line><line x1="4" y1="12" x2="20" y2="12"></line><line x1="4" y1="17" x2="20" y2="17"></line></svg></button> <h2 class="settings-modal-content-title svelte-bbu5nk"> </h2> <button type="button" data-testid="settings-modal-close-btn" class="settings-modal-close svelte-bbu5nk" aria-label="Close settings">×</button></header> <div class="settings-modal-content-body tandem-scroll-fade-y svelte-bbu5nk"><div class="settings-modal-content-inner svelte-bbu5nk"><!></div></div></section></div>`,1);function _M(e,t){k(t,!0);let n=`tandem-settings-modal-heading`,r=[{id:`appearance`,label:`Appearance`,icon:`M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z`,component:CA},{id:`editor`,label:`Editor`,icon:`M4 4h11M4 9h16M4 14h11M4 19h16`,component:DA},{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:BA},{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:pA},{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:oj},{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:$A},{id:`models`,label:`Models`,icon:`M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z`,component:jj},{id:`shortcuts`,label:`Shortcuts`,icon:`M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z`,component:Wj},{id:`license`,label:`License`,icon:`M6 10h12v10H6V10Zm2 0V7a4 4 0 0 1 8 0v3`,component:Kj},{id:`about`,label:`About`,icon:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01`,component:dM}].filter(e=>e.id!==fM.models||!1),i=q(t,`returnFocusEl`,3,null),a=q(t,`triggerEl`,3,null),o=q(t,`connected`,3,!1),s=q(t,`reconnectAttempts`,3,0),c=q(t,`tabs`,3,r),l=q(t,`initialTabId`,3,null),u=q(t,`notify`,3,()=>{}),d=M(void 0),f=dA(()=>t.open),p=M(!1),m=M(null),h=M(!1);L(()=>{t.open&&N(h,!1)});let g=!1;L(()=>{if(t.open&&!g&&l()){let e=z(v).find(e=>e.id===l());e&&N(y,e.id,!0)}g=t.open});let _=M(!1);L(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(max-width: 860px)`);N(_,e.matches,!0);let t=e=>{N(_,e.matches,!0)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)});let v=j(()=>c().length>0?c():r),y=M(un(r[0].id)),b=j(()=>z(v).find(e=>e.id===z(y))??z(v)[0]),x=j(()=>z(b).label),S=j(()=>({open:t.open,settings:t.settings,onUpdate:t.onUpdate,connected:o(),reconnectAttempts:s(),notify:u()}));L(()=>{z(b)&&z(b).id!==z(y)&&N(y,z(b).id,!0)}),L(()=>{if(t.open)return Ar(()=>z(d)?.focus()),()=>{i()?.focus()}}),L(()=>{if(!t.open)return;let e=e=>{let n=e.target;n&&(a()?.contains(n)||z(d)&&!z(d).contains(n)&&t.onClose())},n=setTimeout(()=>document.addEventListener(`pointerdown`,e),0);return()=>{clearTimeout(n),document.removeEventListener(`pointerdown`,e)}}),_a(()=>{let e=e=>{if(e.key!==`Escape`||!t.open)return;let n=e.target;if(!(!z(d)||!n||!z(d).contains(n))){if(e.stopPropagation(),z(_)&&z(h)){N(h,!1);return}t.onClose()}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),L(()=>{if(!t.open)return;let e=e=>{if(e.key!==`Tab`||!z(d))return;let t=z(d).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(t.length===0)return;let n=t[0],r=t[t.length-1],i=document.activeElement;if(!z(d).contains(i)){e.preventDefault(),n.focus();return}e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),L(()=>{z(y),N(m,null)});async function C(){let e=f.info?.changelogPath;if(!e){N(m,`Changelog file not found.`);return}N(p,!0),N(m,null);let n=await Ch(e,{readOnly:!0,notFoundMessage:`Changelog file not found.`,failureMessage:`Failed to open changelog.`});N(p,!1),n.ok?t.onClose():N(m,n.error,!0)}var w={DEFAULT_SETTINGS_TABS:r},ee=Xr(),T=F(ee),te=e=>{var r=gM(),i=F(r),a=I(i,2);K(a,`aria-labelledby`,n),K(a,`tabindex`,-1);var c=P(a),l=P(c),u=P(l);K(u,`id`,n);var g=I(u,2),w=e=>{var t=pM(),n=P(t);D(t),R(()=>U(n,`v${f.info.version??``}`)),H(e,t)};W(g,e=>{f.info&&e(w)}),D(l);var ee=I(l,2);pi(ee,21,()=>z(v),e=>e.id,(e,t)=>{var n=mM(),r=P(n),i=P(r);D(r);var a=I(r,2),o=P(a,!0);D(a),D(n),R(()=>{K(n,`aria-current`,z(y)===z(t).id?`page`:void 0),K(n,`data-active`,z(y)===z(t).id?`true`:`false`),K(n,`data-testid`,`settings-modal-tab-${z(t).id}`),K(i,`d`,z(t).icon),U(o,z(t).label)}),B(`click`,n,()=>{N(y,z(t).id,!0),N(h,!1)}),H(e,n)}),D(ee);var T=I(ee,2),te=P(T),ne=P(te,!0);D(te);var E=I(te,2),re=e=>{var t=hM(),n=P(t,!0);D(t),R(()=>U(n,z(m))),H(e,t)};W(E,e=>{z(m)&&e(re)});var ie=I(E,2),ae=I(ie,2),oe=P(ae),se=I(oe,2),ce=P(se),le=e=>{H(e,Yr(`MCP connected`))},ue=e=>{H(e,Yr(`Reconnecting…`))},de=e=>{H(e,Yr(`MCP offline`))};W(ce,e=>{o()?e(le):s()>0?e(ue,1):e(de,-1)}),D(se),D(ae),D(T),D(c),Pi(c,(e,t)=>Bu?.(e,t),()=>`y`);var fe=I(c,2),pe=P(fe),me=P(pe),he=I(me,2),ge=P(he,!0);D(he);var _e=I(he,2);D(pe);var ve=I(pe,2),ye=P(ve);ci(P(ye),()=>z(b).id,e=>{var t=Xr();xi(F(t),()=>z(b).component,(e,t)=>{t(e,ga(()=>z(S)))}),H(e,t)}),D(ye),D(ve),Pi(ve,(e,t)=>Bu?.(e,t),()=>`y`),D(fe),D(a),fa(a,e=>N(d,e),()=>z(d)),R(()=>{K(a,`data-narrow-sidebar-open`,z(h)?`true`:`false`),c.inert=z(_)&&!z(h),te.disabled=z(p)||f.loading,U(ne,z(p)?`Opening…`:`Changelog`),K(ie,`href`,Ca),K(oe,`data-state`,o()?`connected`:s()>0?`reconnecting`:`disconnected`),K(me,`aria-label`,z(h)?`Hide sections`:`Show sections`),K(me,`aria-expanded`,z(h)),U(ge,z(x))}),B(`click`,i,function(...e){t.onClose?.apply(this,e)}),B(`keydown`,i,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t.onClose())}),B(`click`,te,()=>void C()),B(`click`,me,()=>{N(h,!z(h))}),B(`click`,_e,function(...e){t.onClose?.apply(this,e)}),H(e,r)};return W(T,e=>{t.open&&e(te)}),H(e,ee),A(w)}Br([`click`,`keydown`]);var vM=V(`<span class="settings-version-chip svelte-fsutp8" data-testid="settings-sidebar-version"> </span>`),yM=V(`<button type="button" class="settings-nav-btn svelte-fsutp8"><svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path></path></svg> <span> </span></button>`),bM=V(`<div role="alert" data-testid="changelog-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>`),xM=V(`<div><label for="settings-display-name">Display Name</label> <input id="settings-display-name" data-testid="settings-display-name" type="text" style="width: 100%; padding: 8px 10px; font-size: 13px; color: var(--tandem-fg); background: var(--tandem-surface); border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); outline: none;"/></div> <div><div id="settings-default-mode-label">Default Mode</div> <div role="radiogroup" aria-labelledby="settings-default-mode-label" style="display: flex; gap: var(--tandem-space-2);"><button type="button" data-testid="default-mode-tandem-btn" role="radio">Tandem</button> <button type="button" data-testid="default-mode-solo-btn" role="radio">Solo</button></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">Sets the preferred starting mode for new sessions.</div></div> <label data-testid="solo-rail-hidden-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Hide side panel in Solo mode</span></label> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-top: var(--tandem-space-1);">When enabled, the annotation panel hides automatically when you enter Solo mode and
|
|
120
|
-
restores when you return to Tandem.</div>`,1),SM=V(`<div data-testid="cowork-settings-suspense-fallback" style="font-size: 12px; color: var(--tandem-fg-subtle);">Loading Cowork integration...</div>`),CM=V(`<div><div>Selection Sensitivity: <span style="font-weight: 400; text-transform: none;"> </span></div> <div style="font-size: 10px; color: var(--tandem-fg-subtle); margin-bottom: 6px;">How long you must hold a selection before your AI notices it</div> <input data-testid="dwell-time-slider" type="range" style="width: 100%; accent-color: var(--tandem-accent);" aria-label="Selection dwell time"/> <div style="display: flex; justify-content: space-between; font-size: 10px; color: var(--tandem-fg-subtle);"><span> </span> <span> </span></div></div> <label data-testid="selection-toolbar-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Show floating selection toolbar</span></label> <label data-testid="margin-view-toggle" style="display: flex; align-items: center; gap: var(--tandem-space-2); cursor: pointer; font-size: 12px; color: var(--tandem-fg); min-height: 24px;"><input type="checkbox" style="accent-color: var(--tandem-accent);"/> <span>Margin annotation view (Word-style)</span></label> <div data-testid="margin-view-hint" style="font-size: 10px; color: var(--tandem-fg-subtle);">Margin columns appear where rails are collapsed — open rails hide that side.</div> <!>`,1),wM=V(`<div data-testid="settings-shortcuts-list"><!></div>`),TM=V(`<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),EM=V(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>`),DM=V(`<dt style="color: var(--tandem-fg-subtle);"> </dt> <dd style="margin: 0; color: var(--tandem-fg-muted); overflow-wrap: anywhere;"> </dd>`,1),OM=V(`<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 11px;"></dl>`),kM=V(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>`),AM=V(`<div><button data-testid="view-documentation-btn"> </button> <!></div> <div data-testid="app-info-footer" style="border-top: 1px solid var(--tandem-border); padding-top: 10px;"><div>About</div> <!></div>`,1),jM=V(`<div aria-hidden="true" style="position: fixed; inset: 0; background: color-mix(in srgb, var(--tandem-bg) 70%, transparent); z-index: var(--tandem-z-above-titlebar);"></div> <div data-testid="settings-popover" role="dialog" aria-modal="true" class="settings-dialog svelte-fsutp8"><aside class="settings-sidebar svelte-fsutp8"><div class="settings-sidebar-head svelte-fsutp8"><div class="settings-sidebar-title svelte-fsutp8">Settings</div> <!></div> <nav aria-label="Settings sections" class="settings-sidebar-nav svelte-fsutp8"></nav> <div class="settings-sidebar-foot svelte-fsutp8" data-testid="settings-sidebar-footer"><button type="button" data-testid="view-changelog-btn" class="settings-sidebar-link svelte-fsutp8"> </button> <!> <a target="_blank" rel="noreferrer" data-testid="report-bug-link" class="settings-sidebar-link svelte-fsutp8">Report a bug</a> <div class="settings-sidebar-status svelte-fsutp8" data-testid="settings-mcp-status" aria-live="polite"><span class="settings-status-dot svelte-fsutp8"></span> <span class="settings-status-label svelte-fsutp8"><!></span></div></div></aside> <section class="settings-content svelte-fsutp8" data-testid="settings-content"><header style="display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 var(--tandem-space-5); border-bottom: 1px solid var(--tandem-border); background: var(--tandem-surface);"><h2 style="font-size: 16px; font-weight: 700; color: var(--tandem-fg); margin: 0;"> </h2> <button class="settings-close-btn svelte-fsutp8" aria-label="Close settings">×</button></header> <div style="flex: 1; overflow-y: auto; padding: var(--tandem-space-5);"><div style="display: flex; flex-direction: column; gap: var(--tandem-space-5); max-width: 620px;"><!></div></div></section></div>`,1);function MM(e,t){k(t,!0);let n=`tandem-settings-heading`,r=[{id:`appearance`,label:`Appearance`,icon:`M12 3v2M12 19v2M5 12H3M21 12h-2M6.3 6.3 4.9 4.9M19.1 19.1l-1.4-1.4M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z`},{id:`editor`,label:`Editor`,icon:`M4 4h11M4 9h16M4 14h11M4 19h16`},{id:`network`,label:`Network`,icon:`M3 12h18M3 12a9 9 0 0 1 18 0M3 12a9 9 0 0 0 18 0M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18`},{id:`accessibility`,label:`Accessibility`,icon:`M12 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4ZM4 9h16M9 9v5l-2 7M15 9v5l2 7M9 14h6`},{id:`collaboration`,label:`Collaboration`,icon:`M17 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM21 21v-2a4 4 0 0 0-3-3.87M16 3.13A4 4 0 0 1 16 11`},{id:`claude-code`,label:`AI Assistant`,icon:`M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z`},{id:`shortcuts`,label:`Shortcuts`,icon:`M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z`},{id:`about`,label:`About`,icon:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01`}],i=q(t,`connected`,3,!1),a=q(t,`reconnectAttempts`,3,0),o=M(void 0),s=M(void 0),c=ij(),l=M(un(c.userName)),u=dA(()=>t.open),d=M(!1),f=M(null),p=M(!1),m=M(null),h=M(`appearance`);L(()=>{z(h),N(f,null),N(m,null)}),L(()=>{let e=c.userName;z(l)!==e&&document.activeElement!==z(s)&&N(l,e,!0)}),L(()=>{if(t.open)return z(o)?.focus(),()=>{t.returnFocusEl?.focus()}}),L(()=>{if(!t.open)return;let e=e=>{let n=e.target;t.anchorEl?.contains(n)||z(o)&&!z(o).contains(n)&&t.onClose()},n=setTimeout(()=>document.addEventListener(`pointerdown`,e),0);return()=>{clearTimeout(n),document.removeEventListener(`pointerdown`,e)}}),L(()=>{if(!t.open)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),t.onClose();return}if(e.key!==`Tab`||!z(o))return;let n=z(o).querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement;if(!z(o).contains(a)){e.preventDefault(),r.focus();return}e.shiftKey&&a===r?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});async function g(e,n,r,i){if(!e){r(i.notFound);return}n(!0),r(null);try{let n=await Ch(e,{readOnly:!0,notFoundMessage:i.notFound,failureMessage:i.failed});if(!n.ok){r(n.error);return}t.onClose()}finally{n(!1)}}function _(){return g(u.info?.workflowsPath,e=>N(p,e,!0),e=>N(m,e,!0),{notFound:`Documentation file not found.`,failed:`Failed to open documentation.`})}function v(){return g(u.info?.changelogPath,e=>N(d,e,!0),e=>N(f,e,!0),{notFound:`Changelog file not found.`,failed:`Failed to open changelog.`})}let y=`font-size: 11px; font-weight: 600; color: var(--tandem-fg); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;`,b=()=>{};function x(e){return r.find(t=>t.id===e)?.label??`Settings`}function S(){let e=u.info;if(!e)return[];let t=[{label:`Version`,value:`Tandem v${e.version}`},{label:`Tools`,value:e.toolCount===null?`Tool count unavailable`:`${e.toolCount} tools available`},{label:`MCP SDK`,value:`MCP SDK ${e.mcpSdkVersion}`},{label:`Transport`,value:e.transport?.toUpperCase()??`—`}];return e.storagePath&&t.push({label:`Storage`,value:e.storagePath}),e.tokenRotatedAt!==void 0&&t.push({label:`Token`,value:e.tokenRotatedAt===null?`Token not created`:`Token rotated ${new Date(e.tokenRotatedAt).toLocaleString()}`}),e.changelogPath&&t.push({label:`Changelog`,value:e.changelogPath}),t}var C=Xr(),w=F(C),ee=e=>{var g=jM(),C=F(g),w=I(C,2);K(w,`aria-labelledby`,n),K(w,`tabindex`,-1);var ee=P(w),T=P(ee),te=P(T);K(te,`id`,n);var ne=I(te,2),E=e=>{var t=vM(),n=P(t);D(t),R(()=>U(n,`v${u.info.version??``}`)),H(e,t)};W(ne,e=>{u.info&&e(E)}),D(T);var re=I(T,2);pi(re,21,()=>r,e=>e.id,(e,t)=>{var n=yM(),r=P(n),i=P(r);D(r);var a=I(r,2),o=P(a,!0);D(a),D(n),R(()=>{K(n,`aria-current`,z(h)===z(t).id?`page`:void 0),K(n,`data-active`,z(h)===z(t).id?`true`:`false`),K(i,`d`,z(t).icon),U(o,z(t).label)}),B(`click`,n,()=>N(h,z(t).id,!0)),H(e,n)}),D(re);var ie=I(re,2),ae=P(ie),oe=P(ae,!0);D(ae);var se=I(ae,2),ce=e=>{var t=bM(),n=P(t,!0);D(t),R(()=>U(n,z(f))),H(e,t)};W(se,e=>{z(f)&&e(ce)});var le=I(se,2),ue=I(le,2),de=P(ue),fe=I(de,2),pe=P(fe),me=e=>{H(e,Yr(`MCP connected`))},he=e=>{H(e,Yr(`Reconnecting…`))},ge=e=>{H(e,Yr(`MCP offline`))};W(pe,e=>{i()?e(me):a()>0?e(he,1):e(ge,-1)}),D(fe),D(ue),D(ie),D(ee);var _e=I(ee,2),ve=P(_e),ye=P(ve),be=P(ye,!0);D(ye);var xe=I(ye,2);D(ve);var Se=I(ve,2),Ce=P(Se),we=P(Ce),Te=e=>{var n=xM(),r=F(n),i=P(r);G(i,y);var a=I(i,2);$i(a),fa(a,e=>N(s,e),()=>z(s)),D(r);var o=I(r,2),u=P(o);G(u,y);var d=I(u,2),f=P(d),p=I(f,2);D(d),O(2),D(o);var m=I(o,2),h=P(m);$i(h),O(2),D(m),O(2),R(()=>{ea(a,z(l)),K(a,`maxlength`,40),K(f,`aria-checked`,t.settings.defaultMode===`tandem`),G(f,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${t.settings.defaultMode===`tandem`?`var(--tandem-accent)`:`var(--tandem-border)`}; border-radius: var(--tandem-r-3); background: ${t.settings.defaultMode===`tandem`?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; color: ${t.settings.defaultMode===`tandem`?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-muted)`}; font-size: 12px; font-weight: ${t.settings.defaultMode===`tandem`?600:400}; cursor: pointer;`),K(p,`aria-checked`,t.settings.defaultMode===`solo`),G(p,`flex: 1; padding: var(--tandem-space-2); min-height: 30px; border: 2px solid ${t.settings.defaultMode===`solo`?`var(--tandem-accent)`:`var(--tandem-border)`}; border-radius: var(--tandem-r-3); background: ${t.settings.defaultMode===`solo`?`var(--tandem-accent-bg)`:`var(--tandem-surface)`}; color: ${t.settings.defaultMode===`solo`?`var(--tandem-accent-fg-strong)`:`var(--tandem-fg-muted)`}; font-size: 12px; font-weight: ${t.settings.defaultMode===`solo`?600:400}; cursor: pointer;`),ta(h,t.settings.soloRailHidden)}),B(`input`,a,e=>{N(l,e.target.value,!0)}),zr(`blur`,a,()=>c.setUserName(z(l))),B(`keydown`,a,e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(N(l,c.userName,!0),e.currentTarget.blur())}),B(`click`,f,()=>t.onUpdate({defaultMode:`tandem`})),B(`click`,p,()=>t.onUpdate({defaultMode:`solo`})),B(`change`,h,e=>t.onUpdate({soloRailHidden:e.target.checked})),H(e,n)},Ee=e=>{CA(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},De=e=>{DA(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},Oe=e=>{BA(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},ke=e=>{pA(e,{get open(){return t.open},get settings(){return t.settings},get onUpdate(){return t.onUpdate},get connected(){return i()},get reconnectAttempts(){return a()},notify:b})},Ae=e=>{var n=CM(),r=F(n),i=P(r);G(i,y);var a=I(P(i)),o=P(a);D(a),D(i);var s=I(i,4);$i(s),K(s,`step`,100);var c=I(s,2),l=P(c),u=P(l);D(l);var d=I(l,2),f=P(d);D(d),D(c),D(r);var p=I(r,2),m=P(p);$i(m),O(2),D(p);var h=I(p,2),g=P(h);$i(g),O(2),D(h);var _=I(h,4),v=e=>{var t=Xr();oi(F(t),()=>Ul(()=>import(`./CoworkSettings-CAr7DoyA.js`),__vite__mapDeps([4,5])),e=>{H(e,SM())},(e,t)=>{let n=j(()=>z(t).default);var r=Xr();xi(F(r),()=>z(n),(e,t)=>{t(e,{})}),H(e,r)}),H(e,t)},b=j(()=>Lm());W(_,e=>{z(b)&&e(v)}),R((e,n,r)=>{U(o,`${e??``}s`),K(s,`min`,500),K(s,`max`,Ia),ea(s,t.settings.selectionDwellMs),U(u,`${n??``}s`),U(f,`${r??``}s`),ta(m,t.settings.selectionToolbar),ta(g,t.settings.marginView)},[()=>(t.settings.selectionDwellMs/1e3).toFixed(1),()=>(500/1e3).toFixed(1),()=>(Ia/1e3).toFixed(1)]),B(`input`,s,e=>t.onUpdate({selectionDwellMs:Number(e.target.value)})),B(`change`,m,e=>t.onUpdate({selectionToolbar:e.target.checked})),B(`change`,g,e=>t.onUpdate({marginView:e.target.checked})),H(e,n)},je=e=>{var n=wM();Hj(P(n),{get settings(){return t.settings},get onUpdate(){return t.onUpdate},notify:b}),D(n),H(e,n)},Me=e=>{var t=AM(),n=F(t),r=P(n),i=P(r,!0);D(r);var a=I(r,2),o=e=>{var t=TM(),n=P(t,!0);D(t),R(()=>U(n,z(m))),H(e,t)};W(a,e=>{z(m)&&e(o)}),D(n);var s=I(n,2),c=P(s);G(c,y);var l=I(c,2),d=e=>{H(e,EM())},f=e=>{var t=OM();pi(t,21,S,e=>e.label,(e,t)=>{var n=DM(),r=F(n),i=P(r,!0);D(r);var a=I(r,2),o=P(a,!0);D(a),R(()=>{U(i,z(t).label),U(o,z(t).value)}),H(e,n)}),D(t),H(e,t)},h=e=>{H(e,kM())};W(l,e=>{u.loading?e(d):u.info?e(f,1):e(h,-1)}),D(s),R(()=>{r.disabled=z(p)||u.loading,G(r,`width: 100%; padding: var(--tandem-space-2); font-size: 13px; font-weight: 500; border: 1px solid var(--tandem-border-strong); border-radius: var(--tandem-r-2); cursor: ${z(p)||u.loading?`not-allowed`:`pointer`}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${z(p)||u.loading?.6:1};`),U(i,z(p)?`Opening…`:`View Documentation`)}),B(`click`,r,()=>void _()),H(e,t)};W(we,e=>{z(h)===`collaboration`?e(Te):z(h)===`appearance`?e(Ee,1):z(h)===`editor`?e(De,2):z(h)===`network`?e(Oe,3):z(h)===`accessibility`?e(ke,4):z(h)===`claude-code`?e(Ae,5):z(h)===`shortcuts`?e(je,6):e(Me,-1)}),D(Ce),D(Se),D(_e),D(w),fa(w,e=>N(o,e),()=>z(o)),R(e=>{ae.disabled=z(d)||u.loading,U(oe,z(d)?`Opening…`:`Changelog`),K(le,`href`,Ca),K(de,`data-state`,i()?`connected`:a()>0?`reconnecting`:`disconnected`),U(be,e)},[()=>x(z(h))]),B(`click`,C,function(...e){t.onClose?.apply(this,e)}),B(`click`,ae,()=>void v()),B(`click`,xe,function(...e){t.onClose?.apply(this,e)}),H(e,g)};W(w,e=>{t.open&&e(ee)}),H(e,C),A()}Br([`click`,`input`,`keydown`,`change`]);var NM=Jr(`<path></path>`),PM=V(`<span class="badge svelte-nsu1aw"> </span>`),FM=V(`<button type="button" class="action svelte-nsu1aw"> </button>`),IM=V(`<div><span class="glyph svelte-nsu1aw"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg></span> <div class="body svelte-nsu1aw"><span class="msg svelte-nsu1aw"> </span> <!> <!></div> <button type="button" class="dismiss svelte-nsu1aw" aria-label="Dismiss notification"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12"></path><path d="M6 18L18 6"></path></svg></button></div>`),LM=V(`<div data-testid="toast-container" class="toast-stack svelte-nsu1aw"></div>`);function RM(e,t){k(t,!0);var n=Xr(),r=F(n),i=e=>{var n=LM();pi(n,21,()=>t.toasts,e=>e.id,(e,n)=>{var r=IM(),i=P(r),a=P(i);pi(a,20,()=>Hu[z(n).severity],e=>e,(e,t)=>{var n=NM();R(()=>K(n,`d`,t)),H(e,n)}),D(a),D(i);var o=I(i,2),s=P(o),c=P(s,!0);D(s);var l=I(s,2),u=e=>{var t=PM(),r=P(t);D(t),R(()=>{K(t,`data-testid`,`toast-count-${z(n).id}`),U(r,`×${z(n).count??``}`)}),H(e,t)};W(l,e=>{z(n).count>1&&e(u)});var d=I(l,2),f=e=>{var r=FM(),i=P(r,!0);D(r),R(()=>{K(r,`data-testid`,`toast-action-${z(n).id}`),U(i,z(n).action.label)}),B(`click`,r,()=>{z(n).action?.onClick(),t.onDismiss(z(n).id)}),H(e,r)};W(d,e=>{z(n).action&&e(f)}),D(o);var p=I(o,2);D(r),R(()=>{K(r,`role`,z(n).severity===`info`?`status`:`alert`),K(r,`data-testid`,`toast-${z(n).id}`),Ui(r,1,`toast-card ${z(n).severity??``}`,`svelte-nsu1aw`),U(c,z(n).message),K(p,`data-testid`,`toast-dismiss-${z(n).id}`)}),B(`click`,p,()=>t.onDismiss(z(n).id)),H(e,r)}),D(n),H(e,n)};W(r,e=>{t.toasts.length>0&&e(i)}),H(e,n),A()}Br([`click`]);var zM=V(`<div class="tandem-banner tandem-banner--info" role="status" aria-live="polite" data-testid="updater-banner"><span class="tandem-banner__icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25"></path><path d="M12 12v8"></path><path d="M8 16l4 4 4-4"></path></svg></span> <span class="tandem-banner__message"> </span> <button type="button" class="tandem-banner__cta" data-testid="updater-banner-install"> </button> <button type="button" class="tandem-banner__dismiss" data-testid="updater-banner-dismiss" aria-label="Dismiss update notification"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button></div>`);function BM(e,t){let n=j(()=>t.installing?`Installing…`:`Restart to install`);var r=zM(),i=I(P(r),2),a=P(i);D(i);var o=I(i,2),s=P(o,!0);D(o);var c=I(o,2);D(r),R(()=>{U(a,`Tandem v${t.version??``} is available.`),o.disabled=t.installing,U(s,z(n))}),B(`click`,o,function(...e){t.onInstall?.apply(this,e)}),B(`click`,c,function(...e){t.onDismiss?.apply(this,e)}),H(e,r)}Br([`click`]);var VM=Math.floor,HM=(e,t)=>e<t?e:t,UM=(e,t)=>e>t?e:t,WM=128,GM=127,KM=2**53-1,qM=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},JM=typeof TextEncoder<`u`?new TextEncoder:null,YM=JM?e=>JM.encode(e):qM,XM=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});XM&&XM.decode(new Uint8Array).length===1&&(XM=null);var ZM=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},QM=(e,t)=>{for(;t>GM;)ZM(e,WM|GM&t),t=VM(t/128);ZM(e,GM&t)},$M=new Uint8Array(3e4),eN=$M.length/3,tN=JM&&JM.encodeInto?(e,t)=>{if(t.length<eN){let n=JM.encodeInto(t,$M).written||0;QM(e,n);for(let t=0;t<n;t++)ZM(e,$M[t])}else rN(e,YM(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;QM(e,r);for(let t=0;t<r;t++)ZM(e,n.codePointAt(t))},nN=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=HM(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(UM(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},rN=(e,t)=>{QM(e,t.byteLength),nN(e,t)},iN=e=>Error(e),aN=iN(`Unexpected end of array`),oN=iN(`Integer out of Range`),sN=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},cN=e=>sN(e,uN(e)),lN=e=>e.arr[e.pos++],uN=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&GM)*n,n*=128,r<WM)return t;if(t>KM)throw oN}throw aN},dN=XM?e=>XM.decode(cN(e)):e=>{let t=uN(e);if(t===0)return``;{let n=String.fromCodePoint(lN(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(lN(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},fN;(function(e){e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`})(fN||={});var pN=(e,t)=>{QM(e,fN.Token),tN(e,t)},mN=(e,t,n,r)=>{switch(uN(e)){case fN.Token:t();break;case fN.PermissionDenied:n(dN(e));break;case fN.Authenticated:r(dN(e));break}},hN=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),gN;(function(e){e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`})(gN||={});function _N(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function vN(e){return new Promise(t=>setTimeout(t,e))}function yN(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function bN(e,t){let n=_N(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||yN;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await vN(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await vN(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await vN(e)}return a()}var xN=Math.floor,SN=(e,t)=>e<t?e:t,CN=(e,t)=>e>t?e:t,wN=64,TN=128,EN=63,DN=127,ON=2**53-1,kN=()=>new Set,AN=Array.from,jN=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},MN=typeof TextEncoder<`u`?new TextEncoder:null,NN=MN?e=>MN.encode(e):jN,PN=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});PN&&PN.decode(new Uint8Array).length===1&&(PN=null);var FN=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},IN=()=>new FN,LN=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},RN=e=>{let t=new Uint8Array(LN(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},zN=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},BN=(e,t)=>{for(;t>DN;)zN(e,TN|DN&t),t=xN(t/128);zN(e,DN&t)},VN=new Uint8Array(3e4),HN=VN.length/3,UN=MN&&MN.encodeInto?(e,t)=>{if(t.length<HN){let n=MN.encodeInto(t,VN).written||0;BN(e,n);for(let t=0;t<n;t++)zN(e,VN[t])}else GN(e,NN(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;BN(e,r);for(let t=0;t<r;t++)zN(e,n.codePointAt(t))},WN=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=SN(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(CN(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},GN=(e,t)=>{BN(e,t.byteLength),WN(e,t)},KN=e=>Error(e),qN=KN(`Unexpected end of array`),JN=KN(`Integer out of Range`),YN=class{constructor(e){this.arr=e,this.pos=0}},XN=e=>new YN(e),ZN=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},QN=e=>ZN(e,eP(e)),$N=e=>e.arr[e.pos++],eP=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&DN)*n,n*=128,r<TN)return t;if(t>ON)throw JN}throw qN},tP=e=>{let t=e.arr[e.pos++],n=t&EN,r=64,i=(t&wN)>0?-1:1;if((t&TN)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&DN)*r,r*=128,t<TN)return i*n;if(n>ON)throw JN}throw qN},nP=PN?e=>PN.decode(QN(e)):e=>{let t=eP(e);if(t===0)return``;{let n=String.fromCodePoint($N(e));if(--t<100)for(;t--;)n+=String.fromCodePoint($N(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},rP=e=>{let t=e.pos,n=nP(e);return e.pos=t,n},iP=Date.now,aP=()=>new Map,oP=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},sP=class{constructor(){this._observers=aP()}on(e,t){oP(this._observers,e,kN).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return AN((this._observers.get(e)||aP()).values()).forEach(e=>e(...t))}destroy(){this._observers=aP()}},cP=Object.keys,lP=e=>cP(e).length,uP=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),dP=(e,t)=>e===t,fP=(e,t)=>{if(e==null||t==null)return dP(e,t);if(e.constructor!==t.constructor)return!1;if(e===t)return!0;switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!fP(e.get(n),t.get(n)))return!1;break;case Object:if(lP(e)!==lP(t))return!1;for(let n in e)if(!uP(e,n)||!fP(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!fP(e[n],t[n]))return!1;break;default:return!1}return!0},pP=3e4,mP=class extends sP{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=iP();this.getLocalState()!==null&&pP/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&pP<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&hP(this,t,`timeout`)},xN(pP/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:iP()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),fP(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},hP=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:iP()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},gP=(e,t,n=e.states)=>{let r=t.length,i=IN();BN(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;BN(i,r),BN(i,s),UN(i,JSON.stringify(o))}return RN(i)},_P=(e,t,n)=>{let r=XN(t),i=iP(),a=[],o=[],s=[],c=[],l=eP(r);for(let t=0;t<l;t++){let t=eP(r),n=eP(r),l=JSON.parse(nP(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(fP(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},vP=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},yP=class{constructor(e){this.data=e,this.encoder=IN(),this.decoder=XN(new Uint8Array(this.data))}peekVarString(){return rP(this.decoder)}readVarUint(){return eP(this.decoder)}readVarString(){return nP(this.decoder)}readVarUint8Array(){return QN(this.decoder)}writeVarUint(e){return BN(this.encoder,e)}writeVarString(e){return UN(this.encoder,e)}writeVarUint8Array(e){return GN(this.encoder,e)}length(){return LN(this.encoder)}},bP;(function(e){e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`})(bP||={});var xP;(function(e){e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`})(xP||={});var SP=class{constructor(){this.encoder=IN()}get(e){return e.encoder}toUint8Array(){return RN(this.encoder)}},CP=class extends SP{constructor(){super(...arguments),this.type=bP.CLOSE,this.description=`Ask the server to close the connection`}get(e){return UN(this.encoder,e.documentName),BN(this.encoder,this.type),this.encoder}},wP=class extends vP{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=xP.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=xP.Connected,this.emit(`status`,{status:xP.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===xP.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===xP.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(CP,{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===xP.Connected)return;this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:bN(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{var r;(r=this.webSocket)==null||r.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=xP.Connecting,this.emit(`status`,{status:xP.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){var t;this.resolveConnectionAttempt(),this.lastMessageReceived=iP();let n=new yP(e.data).peekVarString();(t=this.configuration.providerMap.get(n))==null||t.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=xP.Connected,this.emit(`status`,{status:xP.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){var e;(e=this.connectionAttempt)==null||e.reject(),this.connectionAttempt=null}checkConnection(){var e;this.status===xP.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=iP()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:`forced`}}),this.closeTries=0):((e=this.webSocket)==null||e.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}send(e){this.webSocket?.readyState===gN.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=xP.Disconnected,this.emit(`status`,{status:xP.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()}},TP=0,EP=1,DP=2,OP=(e,t)=>{BN(e,TP),GN(e,FC(t))},kP=(e,t,n)=>{BN(e,EP),GN(e,kC(t,n))},AP=(e,t,n)=>kP(t,n,QN(e)),jP=(e,t,n)=>{try{EC(t,QN(e),n)}catch(e){console.error(`Caught error while handling a Yjs update`,e)}},MP=(e,t)=>{BN(e,DP),GN(e,t)},NP=jP,PP=(e,t,n,r)=>{let i=eP(e);switch(i){case TP:AP(e,t,n);break;case EP:jP(e,n,r);break;case DP:NP(e,n,r);break;default:throw Error(`Unknown message type`)}return i},FP=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case bP.Sync:this.applySyncMessage(e,t);break;case bP.Awareness:this.applyAwarenessMessage(e);break;case bP.Auth:this.applyAuthMessage(e);break;case bP.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case bP.Stateless:e.receiveStateless(nP(n.decoder));break;case bP.SyncStatus:this.applySyncStatusMessage(e,tP(n.decoder)===1);break;case bP.CLOSE:let i={code:1e3,reason:nP(n.decoder),target:e.configuration.websocketProvider.webSocket,type:`close`};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:throw Error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(SP,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(bP.Sync);let r=PP(n.decoder,n.encoder,e.document,e);t&&r===EP&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;_P(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;mN(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(bP.Awareness),t.writeVarUint8Array(gP(e.awareness,Array.from(e.awareness.getStates().keys())))}},IP=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return RN(this.encoder)}send(e){e?.send(this.create())}},LP=class extends SP{constructor(){super(...arguments),this.type=bP.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return UN(this.encoder,e.documentName),BN(this.encoder,this.type),pN(this.encoder,e.token),this.encoder}},RP=class extends SP{constructor(){super(...arguments),this.type=bP.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);UN(this.encoder,e.documentName),BN(this.encoder,this.type);let t;return t=e.states===void 0?gP(e.awareness,e.clients):gP(e.awareness,e.clients,e.states),GN(this.encoder,t),this.encoder}},zP=class extends SP{constructor(){super(...arguments),this.type=bP.Stateless,this.description=`A stateless message`}get(e){return UN(this.encoder,e.documentName),BN(this.encoder,this.type),UN(this.encoder,e.payload??``),this.encoder}},BP=class extends SP{constructor(){super(...arguments),this.type=bP.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return UN(this.encoder,e.documentName),BN(this.encoder,this.type),OP(this.encoder,e.document),this.encoder}},VP=class extends SP{constructor(){super(...arguments),this.type=bP.Sync,this.description=`A document update`}get(e){return UN(this.encoder,e.documentName),BN(this.encoder,this.type),MP(this.encoder,e.update),this.encoder}},HP=class extends Error{constructor(){super(...arguments),this.code=1001}},UP=class extends vP{constructor(e){var t,n,r;super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new uC,this.configuration.awareness=e.awareness===void 0?new mP(this.document):e.awareness,this.on(`open`,this.configuration.onOpen),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`synced`,this.configuration.onSynced),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`stateless`,this.configuration.onStateless),this.on(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),(t=this.awareness)==null||t.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:hN(this.awareness.getStates())})}),(n=this.awareness)==null||n.on(`change`,()=>{this.emit(`awarenessChange`,{states:hN(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),(r=this.awareness)==null||r.on(`update`,this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval==`number`&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new wP(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(BP,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&hP(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(zP,{documentName:this.configuration.name,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(LP,{token:e??``,documentName:this.configuration.name})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(VP,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(RP,{awareness:this.awareness,clients:i,documentName:this.configuration.name})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(BP,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(RP,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t){if(!this._isAttached)return;let n=new IP(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new yP(e.data),n=t.readVarString();t.writeVarString(n),this.emit(`message`,{event:e,message:new yP(e.data)}),new FP(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&hP(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&&(hP(this.awareness,[this.document.clientID],`provider destroy`),this.awareness.off(`update`,this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off(`update`,this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),this.configuration.websocketProvider.off(`close`,this.boundOnClose),this.configuration.websocketProvider.off(`close`,this.configuration.onClose),this.configuration.websocketProvider.off(`close`,this.forwardClose),this.configuration.websocketProvider.off(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.off(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.off(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.off(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),this.configuration.websocketProvider.on(`close`,this.boundOnClose),this.configuration.websocketProvider.on(`close`,this.configuration.onClose),this.configuration.websocketProvider.on(`close`,this.forwardClose),this.configuration.websocketProvider.on(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.on(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.on(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.on(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new HP(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},WP=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},GP=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},KP=null,qP=function(e,t,n){let r=KP||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},JP=function(){KP=null},YP=function(e,t,n,r){return n&&(ZP(e,t,n,r,-1)||ZP(e,t,n,r,1))},XP=/^(img|br|input|textarea|hr)$/i;function ZP(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:QP(e))){let n=e.parentNode;if(!n||n.nodeType!=1||nF(e)||XP.test(e.nodeName)||e.contentEditable==`false`)return!1;t=WP(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?QP(e):0}else return!1}}function QP(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function $P(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=QP(e)}else if(e.parentNode&&!nF(e))t=WP(e),e=e.parentNode;else return null}}function eF(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!nF(e))t=WP(e)+1,e=e.parentNode;else return null}}function tF(e,t,n){for(let r=t==0,i=t==QP(e);r||i;){if(e==n)return!0;let t=WP(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==QP(e)}}function nF(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var rF=function(e){return e.focusNode&&YP(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function iF(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function aF(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function oF(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(QP(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(QP(r.startContainer),r.startOffset)}}}var sF=typeof navigator<`u`?navigator:null,cF=typeof document<`u`?document:null,lF=sF&&sF.userAgent||``,uF=/Edge\/(\d+)/.exec(lF),dF=/MSIE \d/.exec(lF),fF=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(lF),pF=!!(dF||fF||uF),mF=dF?document.documentMode:fF?+fF[1]:uF?+uF[1]:0,hF=!pF&&/gecko\/(\d+)/i.test(lF);hF&&+(/Firefox\/(\d+)/.exec(lF)||[0,0])[1];var gF=!pF&&/Chrome\/(\d+)/.exec(lF),_F=!!gF,vF=gF?+gF[1]:0,yF=!pF&&!!sF&&/Apple Computer/.test(sF.vendor),bF=yF&&(/Mobile\/\w+/.test(lF)||!!sF&&sF.maxTouchPoints>2),xF=bF||(sF?/Mac/.test(sF.platform):!1),SF=sF?/Win/.test(sF.platform):!1,CF=/Android \d/.test(lF),wF=!!cF&&`webkitFontSmoothing`in cF.documentElement.style,TF=wF?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function EF(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function DF(e,t){return typeof e==`number`?e:e[t]}function OF(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function kF(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=GP(o);continue}let e=o,n=e==a.body,s=n?EF(a):OF(e),c=0,l=0;if(t.top<s.top+DF(r,`top`)?l=-(s.top-t.top+DF(i,`top`)):t.bottom>s.bottom-DF(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+DF(i,`top`)-s.top:t.bottom-s.bottom+DF(i,`bottom`)),t.left<s.left+DF(r,`left`)?c=-(s.left-t.left+DF(i,`left`)):t.right>s.right-DF(r,`right`)&&(c=t.right-s.right+DF(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:GP(o)}}function AF(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:jF(e.dom)}}function jF(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=GP(r));return t}function MF({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;NF(n,r==0?0:r-t)}function NF(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var PF=null;function FF(e){if(e.setActive)return e.setActive();if(PF)return e.focus(PF);let t=jF(e);e.focus(PF==null?{get preventScroll(){return PF={preventScroll:!0},!0}}:void 0),PF||(PF=!1,NF(t,0))}function IF(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=qP(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?LF(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:IF(n,i)}function LF(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=GF(r,1);if(n.top!=n.bottom&&RF(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function RF(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function zF(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function BF(e,t,n){let{node:r,offset:i}=IF(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function VF(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function HF(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(RF(t,i))return HF(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function UF(e,t){let n=e.dom.ownerDocument,r,i=0,a=oF(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!RF(t,n)||(o=HF(e.dom,t,n),!o))return null}if(yF)for(let e=o;r&&e;e=GP(e))e.draggable&&(r=void 0);if(o=zF(o,t),r){if(hF&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;wF&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=VF(e,r,i,t))}s??=BF(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function WF(e){return e.top<e.bottom||e.left<e.right}function GF(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(WF(e))return e}return Array.prototype.find.call(n,WF)||e.getBoundingClientRect()}var KF=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function qF(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=wF||hF;if(r.nodeType==3)if(o&&(KF.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=GF(qP(r,i,i),n);if(hF&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=GF(qP(r,i-1,i-1),-1);if(t.top==e.top){let n=GF(qP(r,i,i+1),-1);if(n.top!=e.top)return JF(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,JF(GF(qP(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==QP(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return YF(e.getBoundingClientRect(),!1)}if(a==null&&i<QP(r)){let e=r.childNodes[i];if(e.nodeType==1)return YF(e.getBoundingClientRect(),!0)}return YF(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==QP(r))){let e=r.childNodes[i-1],t=e.nodeType==3?qP(e,QP(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return JF(GF(t,1),!1)}if(a==null&&i<QP(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?qP(e,0,+!o):e.nodeType==1?e:null:null;if(t)return JF(GF(t,-1),!0)}return JF(GF(r.nodeType==3?qP(r):r,-n),n>=0)}function JF(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function YF(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function XF(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function ZF(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return XF(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=qF(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=qP(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var QF=/[\u0590-\u08ac]/;function $F(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!QF.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:XF(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var eI=null,tI=null,nI=!1;function rI(e,t,n){return eI==t&&tI==n?nI:(eI=t,tI=n,nI=n==`up`||n==`down`?ZF(e,t,n):$F(e,t,n))}var iI=0,aI=1,oI=2,sI=3,cI=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=iI,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>WP(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof hI){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof lI&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?WP(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?WP(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=WP(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=WP(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((hF||yF)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
|
|
121
|
-
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:WP(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(hF&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&yF)&&YP(o.node,o.offset,l.anchorNode,l.anchorOffset)&&YP(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&hF)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?oI:aI,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=sI:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?oI:sI}n=a}this.dirty=oI}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?oI:aI;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},lI=class extends cI{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==iI&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},uI=class extends cI{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},dI=class e extends cI{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=vf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&sI||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=sI&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=iI){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=iI}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=MI(a,n,o,r)),t>0&&(a=MI(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},fI=class e extends cI{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=vf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=CI(u,r,n),l?c=new gI(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new mI(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Z.empty)}return e}matchesNode(e,t,n){return this.dirty==iI&&e.eq(this.node)&&wI(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new EI(this,a&&a.node,e);kI(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?cd.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==oI)&&(a&&this.protectLocalComposition(e,a),_I(this.contentDOM,this.children,e),bF&&AI(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Up)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=jI(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new uI(this,i,t,r);e.input.compositionNodes.push(a),this.children=MI(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==sI||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=iI}updateOuterDeco(e){if(wI(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=xI(this.dom,this.nodeDOM,bI(this.outerDeco,this.node,t),bI(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function pI(e,t,n,r,i){CI(r,t,e);let a=new fI(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var mI=class e extends fI{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==sI||this.dirty!=iI&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=iI||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=iI,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=sI)}get domAtom(){return!1}isText(e){return this.node.text==e}},hI=class extends cI{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==iI&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},gI=class extends fI{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==sI)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function _I(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=TI(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof dI){let t=r?r.previousSibling:e.lastChild;_I(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=TI(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var vI=function(e){e&&(this.nodeName=e)};vI.prototype=Object.create(null);var yI=[new vI];function bI(e,t,n){if(e.length==0)return yI;let r=n?yI[0]:new vI,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new vI(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new vI(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function xI(e,t,n,r){if(n==yI&&r==yI)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=yI[0],i=t)}SI(i,o||yI[0],a)}return i}function SI(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function CI(e,t,n){return xI(e,e,yI,bI(t,n,e.nodeType!=1))}function wI(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function TI(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var EI=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=DI(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=iI,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=dI.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==sI&&a.dom==a.contentDOM&&(a.dirty=oI),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof fI){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=sI&&wI(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=oI,u.updateChildren(r,a+1),u.dirty=iI),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!wI(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=fI.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=fI.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new lI(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof dI;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof mI)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((yF||_F)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new hI(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function DI(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof dI)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function OI(e,t){return e.type.side-t.type.side}function kI(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(OI);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function AI(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function jI(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function MI(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function NI(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(rF(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Gp.isSelectable(e)&&i.parent&&!(e.isInline&&tF(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Gp(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=WI(e,u,s,n)}return l}function PI(e){return e.editable?e.hasFocus():KI(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function FI(e,t=!1){let n=e.state.selection;if(HI(e,n),PI(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&_F){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&YP(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)VI(e);else{let{anchor:r,head:i}=n,a,o;II&&!(n instanceof Up)&&(n.$from.parent.inlineContent||(a=LI(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=LI(e,n.to))),e.docView.setSelection(r,i,e,t),II&&(a&&zI(a),o&&zI(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&BI(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var II=yF||_F&&vF<63;function LI(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(yF&&i&&i.contentEditable==`false`)return RI(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return RI(i);if(a)return RI(a)}}function RI(e){return e.contentEditable=`true`,yF&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function zI(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function BI(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!PI(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function VI(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,WP(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&pF&&mF<=11&&(n.disabled=!0,n.disabled=!1)}function HI(e,t){if(t instanceof Gp){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(UI(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else UI(e)}function UI(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function WI(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||Up.between(t,n,r)}function GI(e){return e.editable&&!e.hasFocus()?!1:KI(e)}function KI(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function qI(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return YP(t.node,t.offset,n.anchorNode,n.anchorOffset)}function JI(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&zp.findFrom(a,t)}function YI(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function XI(e,t,n){let r=e.state.selection;if(r instanceof Up){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return YI(e,new Up(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=JI(e.state,t);return n&&n instanceof Gp?YI(e,n):!1}else if(!(xF&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?Gp.isSelectable(i)?YI(e,new Gp(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):wF?YI(e,new Up(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof Gp&&r.node.isInline)return YI(e,new Up(t>0?r.$to:r.$from));else{let n=JI(e.state,t);return n?YI(e,n):!1}}function ZI(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function QI(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function $I(e,t){return t<0?eL(e):tL(e)}function eL(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(hF&&n.nodeType==1&&r<ZI(n)&&QI(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(QI(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(nL(n))break;else{let t=n.previousSibling;for(;t&&QI(t,-1);)i=n.parentNode,a=WP(t),t=t.previousSibling;if(t)n=t,r=ZI(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?aL(e,n,r):i&&aL(e,i,a)}function tL(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=ZI(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(QI(e,1))a=n,o=++r;else break}else if(nL(n))break;else{let t=n.nextSibling;for(;t&&QI(t,1);)a=t.parentNode,o=WP(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=ZI(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&aL(e,a,o)}function nL(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function rL(e,t){for(;e&&t==e.childNodes.length&&!nF(e);)t=WP(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function iL(e,t){for(;e&&!t&&!nF(e);)t=WP(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function aL(e,t,n){if(t.nodeType!=3){let e,r;(r=rL(t,n))?(t=r,n=0):(e=iL(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(rF(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&FI(e)},50)}function oL(e,t){let n=e.state.doc.resolve(t);if(!(_F||SF)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function sL(e,t,n){let r=e.state.selection;if(r instanceof Up&&!r.empty||n.indexOf(`s`)>-1||xF&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=JI(e.state,t);if(n&&n instanceof Gp)return YI(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof qp?zp.near(n,t):zp.findFrom(n,t);return o?YI(e,o):!1}return!1}function cL(e,t){if(!(e.state.selection instanceof Up))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function lL(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function uL(e){if(!yF||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;lL(e,n,`true`),setTimeout(()=>lL(e,n,`false`),20)}return!1}function dL(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function fL(e,t){let n=t.keyCode,r=dL(t);if(n==8||xF&&n==72&&r==`c`)return cL(e,-1)||$I(e,-1);if(n==46&&!t.shiftKey||xF&&n==68&&r==`c`)return cL(e,1)||$I(e,1);if(n==13||n==27)return!0;if(n==37||xF&&n==66&&r==`c`){let t=n==37?oL(e,e.state.selection.from)==`ltr`?-1:1:-1;return XI(e,t,r)||$I(e,t)}else if(n==39||xF&&n==70&&r==`c`){let t=n==39?oL(e,e.state.selection.from)==`ltr`?1:-1:1;return XI(e,t,r)||$I(e,t)}else if(n==38||xF&&n==80&&r==`c`)return sL(e,-1,r)||$I(e,-1);else if(n==40||xF&&n==78&&r==`c`)return uL(e)||sL(e,1,r)||$I(e,1);else if(r==(xF?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function pL(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||vf.fromSchema(e.state.schema),s=wL(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=SL[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
|
|
122
|
-
|
|
123
|
-
`),slice:t}}function mL(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new Q(Z.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
124
|
-
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=vf.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=DL(n),wF&&OL(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||rf.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!hL.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=kL(xL(s,+u[1],+u[2]),u[4]);else if(s=Q.maxOpen(gL(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=xL(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var hL=/^(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 gL(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&vL(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=yL(a[a.length-1],i.length));let n=_L(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return Z.from(a)}return e}function _L(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,Z.from(e));return e}function vL(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=vL(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(Z.from(_L(n,e,i+1))))}}function yL(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,yL(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(Z.empty,!0);return e.copy(n.append(r))}function bL(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=bL(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(Z.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function xL(e,t,n){return t<e.openStart&&(e=new Q(bL(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Q(bL(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var SL={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},CL=null;function wL(){return CL||=document.implementation.createHTMLDocument(`title`)}var TL=null;function EL(e){let t=window.trustedTypes;return t?(TL||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),TL.createHTML(e)):e}function DL(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=wL().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&SL[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=EL(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function OL(e){let t=e.querySelectorAll(_F?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function kL(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=Z.from(t.create(r[e+1],i)),a++,o++}return new Q(i,a,o)}var AL={},jL={},ML={touchstart:!0,touchmove:!0},NL=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function PL(e){for(let t in AL){let n=AL[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{zL(e,t)&&!RL(e,t)&&(e.editable||!(t.type in jL))&&n(e,t)},ML[t]?{passive:!0}:void 0)}yF&&e.dom.addEventListener(`input`,()=>null),LL(e)}function FL(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function IL(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function LL(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>RL(e,t))})}function RL(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function zL(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function BL(e,t){!RL(e,t)&&AL[t.type]&&(e.editable||!(t.type in jL))&&AL[t.type](e,t)}jL.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!eR(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(CF&&_F&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),bF&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,iF(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||fL(e,n)?n.preventDefault():FL(e,`key`)},jL.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},jL.keypress=(e,t)=>{let n=t;if(eR(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||xF&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof Up)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function VL(e){return{left:e.clientX,top:e.clientY}}function HL(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function UL(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function WL(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function GL(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Gp.isSelectable(r)?(WL(e,new Gp(n),`pointer`),!0):!1}function KL(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof Gp&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(Gp.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(WL(e,Gp.create(e.state.doc,i),`pointer`),!0)}function qL(e,t,n,r,i){return UL(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?KL(e,n):GL(e,n))}function JL(e,t,n,r){return UL(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function YL(e,t,n,r){return UL(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||XL(e,n,r)}function XL(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(WL(e,Up.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)WL(e,Up.create(r,a+1,a+1+n.content.size),`pointer`);else if(Gp.isSelectable(n))WL(e,Gp.create(r,a),`pointer`);else continue;return!0}}function ZL(e){return sR(e)}var QL=xF?`metaKey`:`ctrlKey`;AL.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=ZL(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&HL(n,e.input.lastClick)&&!n[QL]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(VL(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new $L(e,o,n,!!r)):(a==`doubleClick`?JL:YL)(e,o.pos,o.inside,n)?n.preventDefault():FL(e,`pointer`))};var $L=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[QL],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Gp&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&hF&&!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)),FL(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(()=>FI(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(VL(e))),this.updateAllowDefault(e),this.allowDefault||!t?FL(this.view,`pointer`):qL(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||yF&&this.mightDrag&&!this.mightDrag.node.isAtom||_F&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(WL(this.view,zp.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):FL(this.view,`pointer`)}move(e){this.updateAllowDefault(e),FL(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)}};AL.touchstart=e=>{e.input.lastTouch=Date.now(),ZL(e),FL(e,`pointer`)},AL.touchmove=e=>{e.input.lastTouch=Date.now(),FL(e,`pointer`)},AL.contextmenu=e=>ZL(e);function eR(e,t){return e.composing?!0:yF&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var tR=CF?5e3:-1;jL.compositionstart=jL.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Up&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||_F&&SF&&nR(e)))e.markCursor=e.state.storedMarks||n.marks(),sR(e,!0),e.markCursor=null;else if(sR(e,!t.selection.empty),hF&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}rR(e,tR)};function nR(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}jL.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,rR(e,20))};function rR(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>sR(e),t))}function iR(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=oR());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function aR(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=$P(t.focusNode,t.focusOffset),r=eF(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function oR(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function sR(e,t=!1){if(!(CF&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),iR(e),t||e.docView&&e.docView.dirty){let n=NI(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function cR(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var lR=pF&&mF<15||bF&&TF<604;AL.copy=jL.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=lR?null:n.clipboardData,{dom:o,text:s}=pL(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):cR(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function uR(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function dR(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?fR(e,r.value,null,i,t):fR(e,r.textContent,r.innerHTML,i,t)},50)}function fR(e,t,n,r,i){let a=mL(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||Q.empty)))return!0;if(!a)return!1;let o=uR(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function pR(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}jL.paste=(e,t)=>{let n=t;if(e.composing&&!CF)return;let r=lR?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&fR(e,pR(r),r.getData(`text/html`),i,n)?n.preventDefault():dR(e,n)};var mR=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},hR=xF?`altKey`:`ctrlKey`;function gR(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[hR]}AL.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(VL(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Gp?i.to-1:i.to))){if(r&&r.mightDrag)o=Gp.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Gp.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=pL(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!_F||vF>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(lR?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,lR||n.dataTransfer.setData(`text/plain`,c),e.dragging=new mR(l,gR(e,n),o)},AL.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},jL.dragover=jL.dragenter=(e,t)=>t.preventDefault(),jL.drop=(e,t)=>{try{_R(e,t,e.dragging)}finally{e.dragging=null}};function _R(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(VL(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=mL(e,pR(t.dataTransfer),lR?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&gR(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||Q.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?vp(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&Gp.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Gp(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(WI(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}AL.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&FI(e)},20))},AL.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},AL.beforeinput=(e,t)=>{if(_F&&CF&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,iF(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in jL)AL[e]=jL[e];function vR(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var yR=class e{constructor(e,t){this.toDOM=e,this.spec=t||wR,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new SR(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&vR(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},bR=class e{constructor(e,t){this.attrs=e,this.spec=t||wR}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new SR(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&vR(this.attrs,t.attrs)&&vR(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},xR=class e{constructor(e,t){this.attrs=e,this.spec=t||wR}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new SR(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&vR(this.attrs,t.attrs)&&vR(this.spec,t.spec)}destroy(){}},SR=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new yR(n,r))}static inline(t,n,r,i){return new e(t,n,new bR(r,i))}static node(t,n,r,i){return new e(t,n,new xR(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof bR}get widget(){return this.type instanceof yR}},CR=[],wR={},TR=class e{constructor(e,t){this.local=e.length?e:CR,this.children=t.length?t:CR}static create(e,t){return t.length?NR(t,e,0,wR):ER}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==ER||e.maps.length==0?this:this.mapInner(e,t,0,0,n||wR)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?OR(this.children,o||[],t,n,r,i,a):o?new e(o.sort(PR),CR):ER}add(t,n){return n.length?this==ER?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=jR(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,NR(s,e,o+1,wR)),a+=3}});let o=kR(a?MR(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(PR):this.local,i||this.children)}remove(e){return e.length==0||this==ER?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==ER?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):ER}forChild(t,n){if(this==ER)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof bR){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(PR),CR);return r?new DR([t,r]):t}return r||ER}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return FR(this.localsInner(e))}localsInner(e){if(this==ER)return CR;if(e.inlineContent||!this.local.some(bR.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof bR||t.push(this.local[e]);return t}forEachSet(e){e(this)}};TR.empty=new TR([],[]),TR.removeOverlap=FR;var ER=TR.empty,DR=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,wR));return e.from(r)}forChild(t,n){if(n.isLeaf)return TR.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=ER&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?FR(n?t:t.sort(PR)):CR}static from(t){switch(t.length){case 0:return ER;case 1:return t[0];default:return new e(t.every(e=>e instanceof TR)?t:t.reduce((e,t)=>e.concat(t instanceof TR?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function OR(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==ER?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=NR(AR(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new TR(t.sort(PR),s)}function kR(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new SR(i.from+t,i.to+t,i.type))}return n}function AR(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function jR(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function MR(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function NR(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=jR(e,t,o+n);if(s){a=!0;let e=NR(s,t,n+o+1,r);e!=ER&&i.push(o,o+t.nodeSize,e)}});let o=kR(a?MR(e):e,-n).sort(PR);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new TR(o,i):ER}function PR(e,t){return e.from-t.from||e.to-t.to}function FR(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),IR(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),IR(t,i,r.copy(a.from,r.to)));break}}}return t}function IR(e,t,n){for(;t<e.length&&PR(n,e[t])>0;)t++;e.splice(t,0,n)}function LR(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=ER&&t.push(r)}),e.cursorWrapper&&t.push(TR.create(e.state.doc,[e.cursorWrapper.deco])),DR.from(t)}var RR={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},zR=pF&&mF<=11,BR=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},VR=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new BR,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);pF&&mF<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():yF&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),zR&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,RR)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(GI(this.view)){if(this.suppressingSelectionUpdates)return FI(this.view);if(pF&&mF<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&YP(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=GP(n))t.add(n);for(let r=e.anchorNode;r;r=GP(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&GI(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(hF&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||qR(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&rF(n)&&(c=NI(e))&&c.eq(zp.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,FI(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),WR(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,JR(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||FI(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(pF&&mF<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?WP(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?WP(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},HR=new WeakMap,UR=!1;function WR(e){if(!HR.has(e)&&(HR.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=hF,UR)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.`),UR=!0}}function GR(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return YP(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function KR(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return GR(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?GR(e,n):null}function qR(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function JR(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function YR(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],rF(c)||l.push({node:c.focusNode,offset:c.focusOffset})),_F&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||rf.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:XR,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function XR(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(yF&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||yF&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var ZR=/^(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 QR(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=NI(e,t);if(n&&!e.state.selection.eq(n)){if(_F&&CF&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,iF(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=YR(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=rz(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(bF&&e.input.lastIOSEnter>Date.now()-225||CF)&&i.some(e=>e.nodeType==1&&!ZR.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,iF(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof Up&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=$R(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof Up&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),pF&&mF<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((bF&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,iF(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&tz(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,iF(8,`Backspace`)))){CF&&_F&&e.domObserver.suppressSelectionUpdates();return}_F&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),CF&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,iF(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=$R(e,n.doc,l.sel);t&&!(_F&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||pF&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){pF&&mF<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>FI(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=ez(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function $R(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:WI(e,t.resolve(n.anchor),t.resolve(n.head))}function ez(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(Z.from(l).eq(e))return{mark:s,type:o}}function tz(e,t,n,r,i){if(n-t<=i.pos-r.pos||nz(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(nz(a,!0,!0));return!o.parent.isTextblock||o.pos>n||nz(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function nz(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function rz(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&iz(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&iz(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function iz(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var az=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new NL,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(fz),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=cz(this),sz(this),this.nodeViews=uz(this),this.docView=pI(this.state.doc,oz(this),LR(this),this.dom,this),this.domObserver=new VR(this,(e,t,n,r)=>QR(this,e,t,n,r)),this.domObserver.start(),PL(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&LL(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(fz),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(iR(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=uz(this);dz(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&LL(this),this.editable=cz(this),sz(this);let o=LR(this),s=oz(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&AF(this);if(i){this.domObserver.stop();let t=l&&(pF||_F)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&lz(n.selection,e.selection);if(l){let n=_F?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=aR(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=pI(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&qI(this))?FI(this,t):(HI(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&MF(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof Gp){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&kF(this,t.getBoundingClientRect(),e)}else kF(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new mR(e.slice,e.move,r<0?void 0:Gp.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(pF){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&&FF(this.dom),FI(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return UF(this,e)}coordsAtPos(e,t=1){return qF(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return rI(this,t||this.state,e)}pasteHTML(e,t){return fR(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return fR(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return pL(this,e)}destroy(){this.docView&&(IL(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],LR(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,JP())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return BL(this,e)}domSelectionRange(){let e=this.domSelection();return e?yF&&this.root.nodeType===11&&aF(this.dom.ownerDocument)==this.dom&&KR(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};az.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function oz(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[SR.node(0,e.state.doc.content.size,t)]}function sz(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:SR.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function cz(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function lz(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function uz(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function dz(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function fz(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var pz={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:`'`},mz={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},hz=typeof navigator<`u`&&/Mac/.test(navigator.platform),gz=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),_z=0;_z<10;_z++)pz[48+_z]=pz[96+_z]=String(_z);for(var _z=1;_z<=24;_z++)pz[_z+111]=`F`+_z;for(var _z=65;_z<=90;_z++)pz[_z]=String.fromCharCode(_z+32),mz[_z]=String.fromCharCode(_z);for(var vz in pz)mz.hasOwnProperty(vz)||(mz[vz]=pz[vz]);function yz(e){var t=!(hz&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||gz&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?mz:pz)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var bz=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),xz=typeof navigator<`u`&&/Win/.test(navigator.platform);function Sz(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))bz?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function Cz(e){let t=Object.create(null);for(let n in e)t[Sz(n)]=e[n];return t}function wz(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function Tz(e){return new sm({props:{handleKeyDown:Ez(e)}})}function Ez(e){let t=Cz(e);return function(e,n){let r=yz(n),i,a=t[wz(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[wz(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(xz&&n.ctrlKey&&n.altKey)&&(i=pz[n.keyCode])&&i!=r){let r=t[wz(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Dz=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Oz(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var kz=(e,t,n)=>{let r=Oz(e,n);if(!r)return!1;let i=Fz(r);if(!i){let n=r.blockRange(),i=n&&Qf(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if($z(e,i,t,-1))return!0;if(r.parent.content.size==0&&(Nz(a,`end`)||Gp.isSelectable(a)))for(let n=r.depth;;n--){let o=yp(e.doc,r.before(n),r.after(n),Q.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(Nz(a,`end`)?zp.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):Gp.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},Az=(e,t,n)=>{let r=Oz(e,n);if(!r)return!1;let i=Fz(r);return i?Mz(e,i,t):!1},jz=(e,t,n)=>{let r=Iz(e,n);if(!r)return!1;let i=zz(r);return i?Mz(e,i,t):!1};function Mz(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=yp(e.doc,i,o,Q.empty);if(!s||s.from!=i||s instanceof Gf&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(Up.create(t.doc,i)),n(t.scrollIntoView())}return!0}function Nz(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Pz=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=Fz(r)}let o=a&&a.nodeBefore;return!o||!Gp.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Gp.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function Fz(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Iz(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var Lz=(e,t,n)=>{let r=Iz(e,n);if(!r)return!1;let i=zz(r);if(!i)return!1;let a=i.nodeAfter;if($z(e,i,t,1))return!0;if(r.parent.content.size==0&&(Nz(a,`start`)||Gp.isSelectable(a))){let n=yp(e.doc,r.before(),r.after(),Q.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Nz(a,`start`)?zp.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Gp.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},Rz=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=zz(r)}let o=a&&a.nodeAfter;return!o||!Gp.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Gp.create(e.doc,a.pos)).scrollIntoView()),!0)};function zz(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var Bz=(e,t)=>{let n=e.selection,r=n instanceof Gp,i;if(r){if(n.node.isTextblock||!fp(e.doc,n.from))return!1;i=n.from}else if(i=hp(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(Gp.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},Vz=(e,t)=>{let n=e.selection,r;if(n instanceof Gp){if(n.node.isTextblock||!fp(e.doc,n.to))return!1;r=n.to}else if(r=hp(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},Hz=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&Qf(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},Uz=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
125
|
-
`).scrollIntoView()),!0)};function Wz(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Gz=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=Wz(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(zp.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},Kz=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof qp||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=Wz(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(Up.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},qz=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(up(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Qf(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function Jz(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof Gp&&t.selection.node.isBlock)return!r.parentOffset||!up(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=Wz(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof Up||t.selection instanceof qp)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=up(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,up(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var Yz=Jz(),Xz=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(Gp.create(e.doc,i))),!0)},Zz=(e,t)=>(t&&t(e.tr.setSelection(new qp(e.doc))),!0);function Qz(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||fp(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function $z(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&Qz(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=Z.empty;for(let e=o.length-1;e>=0;e--)s=Z.from(o[e].create(null,s));s=Z.from(i.copy(s));let c=e.tr.step(new Kf(t.pos-1,r,t.pos,r,new Q(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&fp(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:zp.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Qf(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&Nz(a,`start`,!0)&&Nz(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=Z.empty;for(let e=o.length-1;e>=0;e--)r=Z.from(o[e].copy(r));n(e.tr.step(new Kf(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new Q(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function eB(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(Up.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var tB=eB(-1),nB=eB(1);function rB(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&ep(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function iB(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function aB(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var oB=aB(Dz,kz,Pz),sB=aB(Dz,Lz,Rz),cB={Enter:aB(Uz,Kz,qz,Yz),"Mod-Enter":Gz,Backspace:oB,"Mod-Backspace":oB,"Shift-Backspace":oB,Delete:sB,"Mod-Delete":sB,"Mod-a":Zz},lB={"Ctrl-h":cB.Backspace,"Alt-Backspace":cB[`Mod-Backspace`],"Ctrl-d":cB.Delete,"Ctrl-Alt-Backspace":cB[`Mod-Delete`],"Alt-Delete":cB[`Mod-Delete`],"Alt-d":cB[`Mod-Delete`],"Ctrl-a":tB,"Ctrl-e":nB};for(let e in cB)lB[e]=cB[e];typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform();function uB(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return dB(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function dB(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new Ed(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new Ed(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=ep(a,n,r,t);return s?(e&&fB(e,t,s,i,n),!0):!1}function fB(e,t,n,r,i){let a=Z.empty;for(let e=n.length-1;e>=0;e--)a=Z.from(n[e].type.create(n[e].attrs,a));e.step(new Kf(t.start-(r?2:0),t.end,t.start,t.end,new Q(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&up(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function pB(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?mB(t,n,e,a):hB(t,n,a):!0:!1}}function mB(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Kf(a-1,o,a,o,new Q(Z.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Ed(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=Qf(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return fp(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function hB(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?Z.empty:Z.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new Kf(d-+!!s,f+ +!!c,d+1,f-1,new Q((s?Z.empty:Z.from(i.copy(Z.empty))).append(c?Z.empty:Z.from(i.copy(Z.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function gB(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=Z.from(r?e.create():null),o=new Q(Z.from(e.create(null,Z.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new Kf(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}function _B(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var vB=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:_B({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},yB=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}};function bB(e,t,n){return e.config[t]===void 0&&e.parent?bB(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?bB(e.parent,t,n):null}):e.config[t]}function xB(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function SB(e){let t=[],{nodeExtensions:n,markExtensions:r}=xB(e),i=[...n,...r],a={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{let n=bB(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=bB(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function CB(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function wB(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=t?t.split(`;`).map(e=>e.trim()).filter(Boolean):[],i=n[e]?n[e].split(`;`).map(e=>e.trim()).filter(Boolean):[],a=new Map;i.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),r.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),n[e]=Array.from(a.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function TB(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>wB(e,t),{})}function EB(e){return typeof e==`function`}function DB(e,t=void 0,...n){return EB(e)?t?e.bind(t)(...n):e(...n):e}function OB(e={}){return Object.keys(e).length===0&&e.constructor===Object}function kB(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function AB(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):kB(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function jB(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&OB(t)?!1:t!=null))}function MB(e,t){let n=SB(e),{nodeExtensions:r,markExtensions:i}=xB(e);return new $d({topNode:r.find(e=>bB(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=jB({...e.reduce((e,t)=>{let n=bB(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:DB(bB(r,`content`,a)),marks:DB(bB(r,`marks`,a)),group:DB(bB(r,`group`,a)),inline:DB(bB(r,`inline`,a)),atom:DB(bB(r,`atom`,a)),selectable:DB(bB(r,`selectable`,a)),draggable:DB(bB(r,`draggable`,a)),code:DB(bB(r,`code`,a)),whitespace:DB(bB(r,`whitespace`,a)),linebreakReplacement:DB(bB(r,`linebreakReplacement`,a)),defining:DB(bB(r,`defining`,a)),isolating:DB(bB(r,`isolating`,a)),attrs:Object.fromEntries(i.map(e=>[e.name,{default:e?.attribute?.default}]))}),s=DB(bB(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>AB(e,i)));let c=bB(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:TB(e,i)}));let l=bB(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=jB({...e.reduce((e,t)=>{let n=bB(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:DB(bB(r,`inclusive`,a)),excludes:DB(bB(r,`excludes`,a)),group:DB(bB(r,`group`,a)),spanning:DB(bB(r,`spanning`,a)),code:DB(bB(r,`code`,a)),attrs:Object.fromEntries(i.map(e=>[e.name,{default:e?.attribute?.default}]))}),s=DB(bB(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>AB(e,i)));let c=bB(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:TB(e,i)})),[r.name,o]}))})}function NB(e,t){return t.nodes[e]||t.marks[e]||null}function PB(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function FB(e,t){let n=vf.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}var IB=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function LB(e){return Object.prototype.toString.call(e)===`[object RegExp]`}var RB=class{constructor(e){this.find=e.find,this.handler=e.handler}},zB=(e,t)=>{if(LB(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function BB(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=IB(c)+i;return a.forEach(e=>{if(l)return;let a=zB(u,e.find);if(!a)return;let c=s.state.tr,d=_B({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new vB({editor:t,state:d});e.handler({state:d,range:f,match:a,commands:p,chain:m,can:h})===null||!c.steps.length||(c.setMeta(o,{transform:c,from:n,to:r,text:i}),s.dispatch(c),l=!0)}),l}function VB(e){let{editor:t,rules:n}=e,r=new sm({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:FB(Z.from(e),a.schema);let{from:i}=s;BB({editor:t,from:i,to:i+e.length,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return BB({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&BB({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?BB({editor:t,from:a.pos,to:a.pos,text:`
|
|
126
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function HB(e){return Object.prototype.toString.call(e).slice(8,-1)}function UB(e){return HB(e)===`Object`?e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype:!1}function WB(e,t){let n={...e};return UB(e)&&UB(t)&&Object.keys(t).forEach(r=>{UB(t[r])&&UB(e[r])?n[r]=WB(e[r],t[r]):n[r]=t[r]}),n}var GB=class e{constructor(e={}){this.type=`mark`,this.name=`mark`,this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=DB(bB(this,`addOptions`,{name:this.name}))),this.storage=DB(bB(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>WB(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(t={}){let n=new e(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=DB(bB(n,`addOptions`,{name:n.name})),n.storage=DB(bB(n,`addStorage`,{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}};function KB(e){return typeof e==`number`}var qB=class{constructor(e){this.find=e.find,this.handler=e.handler}},JB=(e,t,n)=>{if(LB(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function YB(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new vB({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{if(!e.isTextblock||e.type.spec.code)return;let f=Math.max(r,t),p=Math.min(i,t+e.content.size);JB(e.textBetween(f-t,p-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=f+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},p=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(p)})}),d.every(e=>e!==null)}var XB=null,ZB=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function QB(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr;if(!(!YB({editor:t,state:_B({state:e,transaction:c}),from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})||!c.steps.length)){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return n.map(e=>new sm({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(XB=t)},i=()=>{XB&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=XB;e?.isEditable&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:FB(Z.from(t),r.schema);let{from:n}=d,i=n+t.length,a=ZB(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(!(!KB(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}function $B(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}var eV=class e{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=e.resolve(t),this.schema=MB(this.extensions,n),this.setupExtensions()}static resolve(t){let n=e.sort(e.flatten(t)),r=$B(n.map(e=>e.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),n}static flatten(e){return e.map(e=>{let t=bB(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...this.flatten(t())]:e}).flat(10)}static sort(e){return e.sort((e,t)=>{let n=bB(e,`priority`)||100,r=bB(t,`priority`)||100;return n>r?-1:+(n<r)})}get commands(){return this.extensions.reduce((e,t)=>{let n=bB(t,`addCommands`,{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:NB(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:t}=this,n=e.sort([...this.extensions].reverse()),r=[],i=[],a=n.map(e=>{let n={name:e.name,options:e.options,storage:e.storage,editor:t,type:NB(e.name,this.schema)},a=[],o=bB(e,`addKeyboardShortcuts`,n),s={};if(e.type===`mark`&&bB(e,`exitable`,n)&&(s.ArrowRight=()=>GB.handleExit({editor:t,mark:e})),o){let e=Object.fromEntries(Object.entries(o()).map(([e,n])=>[e,()=>n({editor:t})]));s={...s,...e}}let c=Tz(s);a.push(c);let l=bB(e,`addInputRules`,n);PB(e,t.options.enableInputRules)&&l&&r.push(...l());let u=bB(e,`addPasteRules`,n);PB(e,t.options.enablePasteRules)&&u&&i.push(...u());let d=bB(e,`addProseMirrorPlugins`,n);if(d){let e=d();a.push(...e)}return a}).flat();return[VB({editor:t,rules:r}),...QB({editor:t,rules:i}),...a]}get attributes(){return SB(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=xB(this.extensions);return Object.fromEntries(t.filter(e=>!!bB(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=bB(t,`addNodeView`,{name:t.name,options:t.options,storage:t.storage,editor:e,type:CB(t.name,this.schema)});return r?[t.name,(i,a,o,s,c)=>{let l=TB(i,n);return r()({node:i,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}setupExtensions(){this.extensions.forEach(e=>{this.editor.extensionStorage[e.name]=e.storage;let t={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:NB(e.name,this.schema)};e.type===`mark`&&(DB(bB(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name);let n=bB(e,`onBeforeCreate`,t),r=bB(e,`onCreate`,t),i=bB(e,`onUpdate`,t),a=bB(e,`onSelectionUpdate`,t),o=bB(e,`onTransaction`,t),s=bB(e,`onFocus`,t),c=bB(e,`onBlur`,t),l=bB(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}},tV=class e{constructor(e={}){this.type=`extension`,this.name=`extension`,this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=DB(bB(this,`addOptions`,{name:this.name}))),this.storage=DB(bB(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>WB(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(t={}){let n=new e({...this.config,...t});return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=DB(bB(n,`addOptions`,{name:n.name})),n.storage=DB(bB(n,`addStorage`,{name:n.name,options:n.options})),n}};function nV(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=`
|
|
127
|
-
|
|
128
|
-
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;e.isText&&(s+=(e?.text)?.slice(Math.max(r,n)-n,i-n))}),s}function rV(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}var iV=tV.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new sm({key:new um(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:a}=i,o=Math.min(...a.map(e=>e.$from.pos)),s=Math.max(...a.map(e=>e.$to.pos)),c=rV(n);return nV(r,{from:o,to:s},{...this.options.blockSeparator===void 0?{}:{blockSeparator:this.options.blockSeparator},textSerializers:c})}}})]}}),aV=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),oV=(e=!1)=>({commands:t})=>t.setContent(``,e),sV=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=Qf(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},cV=e=>t=>e(t),lV=()=>({state:e,dispatch:t})=>Kz(e,t),uV=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new Up(r.doc.resolve(Math.max(o-1,0)))),!0},dV=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1},fV=e=>({tr:t,state:n,dispatch:r})=>{let i=CB(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},pV=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},mV=()=>({state:e,dispatch:t})=>Dz(e,t),hV=()=>({commands:e})=>e.keyboardShortcut(`Enter`),gV=()=>({state:e,dispatch:t})=>Gz(e,t);function _V(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:LB(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function vV(e,t,n={}){return e.find(e=>e.type===t&&_V(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function yV(e,t,n={}){return!!vV(e,t,n)}function bV(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t)||(n||=r.node.marks[0]?.attrs,!vV([...r.node.marks],t,n)))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&yV([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&yV([...e.parent.child(o).marks],t,n);)s+=e.parent.child(o).nodeSize,o+=1;return{from:a,to:s}}function xV(e,t){if(typeof e==`string`){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var SV=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=xV(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=bV(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=Up.create(o,e.from,e.to);n.setSelection(t)}}return!0},CV=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function wV(e){return e instanceof Up}function TV(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function EV(e,t=null){if(!t)return null;let n=zp.atStart(e),r=zp.atEnd(e);if(t===`start`||t===!0)return n;if(t===`end`)return r;let i=n.from,a=r.to;return t===`all`?Up.create(e,TV(0,i,a),TV(e.content.size,i,a)):Up.create(e,TV(t,i,a),TV(t,i,a))}function DV(){return navigator.platform===`Android`||/android/i.test(navigator.userAgent)}function OV(){return[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document}function kV(){return typeof navigator<`u`?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var AV=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(OV()||DV())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),kV()&&!OV()&&!DV()&&r.dom.focus({preventScroll:!0}))})};if(r.hasFocus()&&e===null||e===!1)return!0;if(a&&e===null&&!wV(n.state.selection))return o(),!0;let s=EV(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},jV=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),MV=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),NV=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&NV(r)}return e};function PV(e){let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return NV(n)}function FV(e,t,n){if(e instanceof Od||e instanceof Z)return e;n={slice:!0,parseOptions:{},...n};let r=typeof e==`object`&&!!e,i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return Z.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),FV(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new $d({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?rf.fromSchema(a).parseSlice(PV(e),n.parseOptions):rf.fromSchema(a).parse(PV(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=rf.fromSchema(t);return n.slice?r.parseSlice(PV(e),n.parseOptions).content:r.parse(PV(e),n.parseOptions)}return FV(``,t,n)}function IV(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Gf||i instanceof Kf))return;let a=e.mapping.maps[r],o=0;a.forEach((e,t,n,r)=>{o===0&&(o=r)}),e.setSelection(zp.near(e.doc.resolve(o),n))}var LV=e=>!(`type`in e),RV=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{FV(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=FV(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((LV(i)?i:[i]).forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let f;if(u){if(Array.isArray(t))f=t.map(e=>e.text||``).join(``);else if(t instanceof Z){let e=``;t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f=typeof t==`object`&&t&&t.text?t.text:t;r.insertText(f,c,l)}else f=i,r.replaceWith(c,l,f);n.updateSelection&&IV(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:f}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:f})}return!0},zV=()=>({state:e,dispatch:t})=>Bz(e,t),BV=()=>({state:e,dispatch:t})=>Vz(e,t),VV=()=>({state:e,dispatch:t})=>kz(e,t),HV=()=>({state:e,dispatch:t})=>Lz(e,t),UV=()=>({state:e,dispatch:t,tr:n})=>{try{let r=hp(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},WV=()=>({state:e,dispatch:t,tr:n})=>{try{let r=hp(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},GV=()=>({state:e,dispatch:t})=>Az(e,t),KV=()=>({state:e,dispatch:t})=>jz(e,t);function qV(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function JV(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e+=1){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))OV()||qV()?o=!0:i=!0;else throw Error(`Unrecognized modifier name: ${n}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var YV=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let a=JV(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function XV(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?CB(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>o?o.name===e.node.type.name:!0).filter(e=>_V(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var ZV=(e,t={})=>({state:n,dispatch:r})=>XV(n,CB(e,n.schema),t)?Hz(n,r):!1,QV=()=>({state:e,dispatch:t})=>qz(e,t),$V=e=>({state:t,dispatch:n})=>pB(CB(e,t.schema))(t,n),eH=()=>({state:e,dispatch:t})=>Uz(e,t);function tH(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function nH(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var rH=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=tH(typeof e==`string`?e:e.name,r.schema);return s?(s===`node`&&(a=CB(e,r.schema)),s===`mark`&&(o=xV(e,r.schema)),i&&n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&n.setNodeMarkup(r,void 0,nH(e.attrs,t)),o&&e.marks.length&&e.marks.forEach(i=>{o===i.type&&n.addMark(r,r+e.nodeSize,o.create(nH(i.attrs,t)))})})}),!0):!1},iH=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),aH=()=>({tr:e,dispatch:t})=>{if(t){let t=new qp(e.doc);e.setSelection(t)}return!0},oH=()=>({state:e,dispatch:t})=>Pz(e,t),sH=()=>({state:e,dispatch:t})=>Rz(e,t),cH=()=>({state:e,dispatch:t})=>Xz(e,t),lH=()=>({state:e,dispatch:t})=>nB(e,t),uH=()=>({state:e,dispatch:t})=>tB(e,t);function dH(e,t,n={},r={}){return FV(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var fH=(e,t=!1,n={},r={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(n.preserveWhitespace!==`full`){let s=dH(e,i.schema,n,{errorOnInvalidContent:r.errorOnInvalidContent??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,s).setMeta(`preventUpdate`,!t),!0}return o&&a.setMeta(`preventUpdate`,!t),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent??i.options.enableContentCheck})};function pH(e,t){let n=xV(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function mH(e,t){let n=new Lp(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function hH(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function gH(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function _H(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function vH(e){return t=>_H(t.$from,e)}function yH(e,t){return nV(e,{from:0,to:e.content.size},t)}function bH(e,t){let n=CB(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function xH(e,t){let n=tH(typeof t==`string`?t:t.name,e.schema);return n===`node`?bH(e,t):n===`mark`?pH(e,t):{}}function SH(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function CH(e){let t=SH(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function wH(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),CH(r)}function TH(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=bV(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}function EH(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}function DH(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?xV(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>_V(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize),c=a-n;o+=c,s.push(...e.marks.map(e=>({mark:e,from:n,to:a})))})}),o===0)return!1;let c=s.filter(e=>a?a.name===e.mark.type.name:!0).filter(e=>_V(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>a?e.mark.type!==a&&e.mark.type.excludes(a):!0).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function OH(e,t,n={}){if(!t)return XV(e,null,n)||DH(e,null,n);let r=tH(t,e.schema);return r===`node`?XV(e,t,n):r===`mark`?DH(e,t,n):!1}function kH(e,t){let{nodeExtensions:n}=xB(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=DB(bB(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function AH(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return/^\s*$/m.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(AH(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function jH(e){return e instanceof Gp}function MH(e,t,n){let{selection:r}=t,i=null;if(wV(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return!!n.isInSet(t)||!t.some(e=>e.type.excludes(n))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var NH=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=xV(e,r.schema);if(i)if(o){let e=pH(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return MH(r,n,c)},PH=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),FH=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=CB(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>iB(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>iB(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},IH=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=TV(e,0,n.content.size),i=Gp.create(n,r);t.setSelection(i)}return!0},LH=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=Up.atStart(n).from,o=Up.atEnd(n).to,s=TV(r,a,o),c=TV(i,a,o),l=Up.create(n,s,c);t.setSelection(l)}return!0},RH=e=>({state:t,dispatch:n})=>gB(CB(e,t.schema))(t,n);function zH(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var BH=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=EH(l,s.node().type.name,s.node().attrs);if(a instanceof Gp&&a.node.isBlock)return!s.parentOffset||!up(o,s.pos)?!1:(r&&(e&&zH(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:hH(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=up(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&up(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof Up&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&zH(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},VH=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=CB(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=Z.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=Z.from(s.node(t).copy(e));let i=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,a={...EH(d,s.node().type.name,s.node().attrs),...t},c=o.contentMatch.defaultType?.createAndFill(a)||void 0;e=e.append(Z.from(o.createAndFill(null,c)||void 0));let l=s.before(s.depth-(r-1));n.replace(l,s.after(-i),new Q(e,4-r,0));let u=-1;n.doc.nodesBetween(l,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(Up.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...EH(d,u.type.name,u.attrs),...t},m={...EH(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!up(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0},HH=(e,t)=>{let n=vH(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&fp(e.doc,n.pos)&&e.join(n.pos),!0},UH=(e,t)=>{let n=vH(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&fp(e.doc,r)&&e.join(r),!0},WH=Object.freeze({__proto__:null,blur:aV,clearContent:oV,clearNodes:sV,command:cV,createParagraphNear:lV,cut:uV,deleteCurrentNode:dV,deleteNode:fV,deleteRange:pV,deleteSelection:mV,enter:hV,exitCode:gV,extendMarkRange:SV,first:CV,focus:AV,forEach:jV,insertContent:MV,insertContentAt:RV,joinBackward:VV,joinDown:BV,joinForward:HV,joinItemBackward:UV,joinItemForward:WV,joinTextblockBackward:GV,joinTextblockForward:KV,joinUp:zV,keyboardShortcut:YV,lift:ZV,liftEmptyBlock:QV,liftListItem:$V,newlineInCode:eH,resetAttributes:rH,scrollIntoView:iH,selectAll:aH,selectNodeBackward:oH,selectNodeForward:sH,selectParentNode:cH,selectTextblockEnd:lH,selectTextblockStart:uH,setContent:fH,setMark:NH,setMeta:PH,setNode:FH,setNodeSelection:IH,setTextSelection:LH,sinkListItem:RH,splitBlock:BH,splitListItem:VH,toggleList:(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=CB(e,o.schema),m=CB(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=vH(e=>kH(e.type.name,d))(h);if(y.depth>=1&&x&&y.depth-x.depth<=1){if(x.node.type===p)return l.liftListItem(m);if(kH(x.node.type.name,d)&&p.validContent(x.node.content)&&s)return c().command(()=>(a.setNodeMarkup(x.pos,p),!0)).command(()=>HH(a,p)).command(()=>UH(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>HH(a,p)).command(()=>UH(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>HH(a,p)).command(()=>UH(a,p)).run()},toggleMark:(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=xV(e,r.schema);return DH(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},toggleNode:(e,t,n={})=>({state:r,commands:i})=>{let a=CB(e,r.schema),o=CB(t,r.schema),s=XV(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},toggleWrap:(e,t={})=>({state:n,commands:r})=>{let i=CB(e,n.schema);return XV(n,i,t)?r.lift(i):r.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let t=e.tr,n=a.transform;for(let e=n.steps.length-1;e>=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},unsetMark:(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=xV(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=bV(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},updateAttributes:(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=tH(typeof e==`string`?e:e.name,r.schema);return s?(s===`node`&&(a=CB(e,r.schema)),s===`mark`&&(o=xV(e,r.schema)),i&&n.selection.ranges.forEach(e=>{let i=e.$from.pos,s=e.$to.pos,c,l,u,d;n.selection.empty?r.doc.nodesBetween(i,s,(e,t)=>{a&&a===e.type&&(u=Math.max(t,i),d=Math.min(t+e.nodeSize,s),c=t,l=e)}):r.doc.nodesBetween(i,s,(e,r)=>{r<i&&a&&a===e.type&&(u=Math.max(r,i),d=Math.min(r+e.nodeSize,s),c=r,l=e),r>=i&&r<=s&&(a&&a===e.type&&n.setNodeMarkup(r,void 0,{...e.attrs,...t}),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type){let c=Math.max(r,i),l=Math.min(r+e.nodeSize,s);n.addMark(c,l,o.create({...a.attrs,...t}))}}))}),l&&(c!==void 0&&n.setNodeMarkup(c,void 0,{...l.attrs,...t}),o&&l.marks.length&&l.marks.forEach(e=>{o===e.type&&n.addMark(u,d,o.create({...e.attrs,...t}))}))}),!0):!1},wrapIn:(e,t={})=>({state:n,dispatch:r})=>rB(CB(e,n.schema),t)(n,r),wrapInList:(e,t={})=>({state:n,dispatch:r})=>uB(CB(e,n.schema),t)(n,r)}),GH=tV.create({name:`commands`,addCommands(){return{...WH}}}),KH=tV.create({name:`drop`,addProseMirrorPlugins(){return[new sm({key:new um(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),qH=tV.create({name:`editable`,addProseMirrorPlugins(){return[new sm({key:new um(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),JH=new um(`focusEvents`),YH=tV.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new sm({key:JH,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),XH=tV.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:zp.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return OV()||qV()?i:r},addProseMirrorPlugins(){return[new sm({key:new um(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=zp.atStart(t.doc).from,l=zp.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!AH(n.doc))return;let u=n.tr,d=_B({state:n,transaction:u}),{commands:f}=new vB({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),ZH=tV.create({name:`paste`,addProseMirrorPlugins(){return[new sm({key:new um(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),QH=tV.create({name:`tabindex`,addProseMirrorPlugins(){return[new sm({key:new um(`tabindex`),props:{attributes:()=>this.editor.isEditable?{tabindex:`0`}:{}}})]}}),$H=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=this.pos+r+ +!a;if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;let s=this.resolvedPos.doc.resolve(o);if(!i&&s.depth<=this.depth)return;let c=new e(s,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),t.push(new e(s,this.editor,i,i?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==t[i])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||this.children.length===0)return r;let i=Object.keys(t);return this.children.forEach(a=>{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),!(n&&r.length>0)&&(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},eU=`.ProseMirror {
|
|
129
|
-
position: relative;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.ProseMirror {
|
|
133
|
-
word-wrap: break-word;
|
|
134
|
-
white-space: pre-wrap;
|
|
135
|
-
white-space: break-spaces;
|
|
136
|
-
-webkit-font-variant-ligatures: none;
|
|
137
|
-
font-variant-ligatures: none;
|
|
138
|
-
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.ProseMirror [contenteditable="false"] {
|
|
142
|
-
white-space: normal;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
146
|
-
white-space: pre-wrap;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.ProseMirror pre {
|
|
150
|
-
white-space: pre-wrap;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
img.ProseMirror-separator {
|
|
154
|
-
display: inline !important;
|
|
155
|
-
border: none !important;
|
|
156
|
-
margin: 0 !important;
|
|
157
|
-
width: 0 !important;
|
|
158
|
-
height: 0 !important;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.ProseMirror-gapcursor {
|
|
162
|
-
display: none;
|
|
163
|
-
pointer-events: none;
|
|
164
|
-
position: absolute;
|
|
165
|
-
margin: 0;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.ProseMirror-gapcursor:after {
|
|
169
|
-
content: "";
|
|
170
|
-
display: block;
|
|
171
|
-
position: absolute;
|
|
172
|
-
top: -2px;
|
|
173
|
-
width: 20px;
|
|
174
|
-
border-top: 1px solid black;
|
|
175
|
-
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@keyframes ProseMirror-cursor-blink {
|
|
179
|
-
to {
|
|
180
|
-
visibility: hidden;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.ProseMirror-hideselection *::selection {
|
|
185
|
-
background: transparent;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.ProseMirror-hideselection *::-moz-selection {
|
|
189
|
-
background: transparent;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.ProseMirror-hideselection * {
|
|
193
|
-
caret-color: transparent;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
197
|
-
display: block;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
201
|
-
opacity: 0
|
|
202
|
-
}`;function tU(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}var nU=class extends yB{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement(`div`),content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`contentError`,this.options.onContentError),this.createView(),this.injectCSS(),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=tU(eU,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){let n=EB(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){let e=[...this.options.enableCoreExtensions?[qH,iV.configure({blockSeparator:this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator}),GH,YH,XH,QH,KH,ZH].filter(e=>typeof this.options.enableCoreExtensions==`object`?this.options.enableCoreExtensions[e.name]!==!1:!0):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new eV(e,this)}createCommandManager(){this.commandManager=new vB({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let e;try{e=dH(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(t.message))throw t;this.emit(`contentError`,{editor:this,error:t,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),e=dH(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let t=EV(e,this.options.autofocus);this.view=new az(this.options.element,{...this.options.editorProps,attributes:{role:`textbox`,...this.options.editorProps?.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:am.create({doc:e,selection:t||void 0})});let n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.prependClass();let r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e}),n&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let r=e.getMeta(`focus`),i=e.getMeta(`blur`);r&&this.emit(`focus`,{editor:this,event:r.event,transaction:e}),i&&this.emit(`blur`,{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta(`preventUpdate`))&&this.emit(`update`,{editor:this,transaction:e})}getAttributes(e){return xH(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return OH(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return FB(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
|
|
203
|
-
|
|
204
|
-
`,textSerializers:n={}}=e||{};return yH(this.state.doc,{blockSeparator:t,textSerializers:{...rV(this.schema),...n}})}get isEmpty(){return AH(this.state.doc)}getCharacterCount(){return console.warn(`[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.`),this.state.doc.content.size-2}destroy(){if(this.emit(`destroy`),this.view){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){return!this.view?.docView}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){return new $H(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}};function rU(e){return new RB({find:e.find,handler:({state:t,range:n,match:r})=>{let i=DB(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(TH(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}}})}function iU(e){return new RB({find:e.find,handler:({state:t,range:n,match:r})=>{let i=DB(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()}})}function aU(e){return new RB({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=DB(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)}})}function oU(e){return new RB({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=DB(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&ep(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&fp(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)}})}var sU=class e{constructor(e={}){this.type=`node`,this.name=`node`,this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=DB(bB(this,`addOptions`,{name:this.name}))),this.storage=DB(bB(this,`addStorage`,{name:this.name,options:this.options}))||{}}static create(t={}){return new e(t)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>WB(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(t={}){let n=new e(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=DB(bB(n,`addOptions`,{name:n.name})),n.storage=DB(bB(n,`addStorage`,{name:n.name,options:n.options})),n}};function cU(e){return new qB({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=DB(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let r=c.search(/\S/),i=n.from+c.indexOf(s),u=i+s.length;if(TH(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>i).length)return null;u<n.to&&o.delete(u,n.to),i>n.from&&o.delete(n.from+r,i),l=n.from+r+s.length,o.addMark(n.from+r,l,e.type.create(a||{})),o.removeStoredMark(e.type)}}})}function lU(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof Gp){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}var uU=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},dU=/[\uD800-\uDBFF]/,fU=/[\uDC00-\uDFFF]/,pU=(e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&dU.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&fU.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},mU=new um(`y-sync`),hU=new um(`y-undo`),gU=new um(`yjs-cursor`),_U=(e,t)=>e>>>t|e<<32-t,vU=e=>_U(e,2)^_U(e,13)^_U(e,22),yU=e=>_U(e,6)^_U(e,11)^_U(e,25),bU=e=>_U(e,7)^_U(e,18)^e>>>3,xU=e=>_U(e,17)^_U(e,19)^e>>>10,SU=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]),CU=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),wU=class{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(CU),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=xU(t[e-2])+t[e-7]+bU(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7];for(let e=0,u,d;e<64;e++)u=l+yU(o)+(o&s^~o&c)+SU[e]+t[e]>>>0,d=vU(n)+(n&r^n&i^r&i)>>>0,l=c,c=s,s=o,o=a+u>>>0,a=i,i=r,r=n,n=u+d>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=o,e[5]+=s,e[6]+=c,e[7]+=l}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<n*8;n||(this._W[r-(t%4==0?0:1)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/dy,this._W[15]=e.byteLength*8,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[e*4+t]=this._H[e]>>>(3-t)*8;return i}},TU=e=>new wU().digest(e),EU=e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)},DU=e=>ox(EU(TU(cx(e)))),OU=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!eC(t.ds,e.id),kU=[{light:`#ecd44433`,dark:`#ecd444`}],AU=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let n=zv();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,wb(t))}return e.get(n)},jU=(e,{colors:t=kU,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let o=!1,s=new PU(e,a),c=new sm({props:{editable:e=>{let t=mU.getState(e);return t.snapshot==null&&t.prevSnapshot==null}},key:mU,state:{init:(i,a)=>({type:e,doc:e.doc,binding:s,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(mU);if(n!==void 0){t=Object.assign({},t);for(let e in n)t[e]=n[e]}return t.addToHistory=e.getMeta(`addToHistory`)!==!1,t.isChangeOrigin=n!==void 0&&!!n.isChangeOrigin,t.isUndoRedoOperation=n!==void 0&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,s.prosemirrorView!==null&&n!==void 0&&(n.snapshot!=null||n.prevSnapshot!=null)&&AS(0,()=>{s.prosemirrorView!=null&&(n.restore==null?s._renderSnapshot(n.snapshot,n.prevSnapshot,t):(s._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,s.mux(()=>{s._prosemirrorChanged(s.prosemirrorView.state.doc)})))}),t}},view:e=>(s.initView(e),a??s._forceRerender(),i(),{update:()=>{let t=c.getState(e.state);if(t.snapshot==null&&t.prevSnapshot==null&&(o||e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content)!==null)){if(o=!0,t.addToHistory===!1&&!t.isChangeOrigin){let t=hU.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}s.mux(()=>{t.doc.transact(n=>{n.meta.set(`addToHistory`,t.addToHistory),s._prosemirrorChanged(e.state.doc)},mU)})}},destroy:()=>{s.destroy()}})});return c},MU=(e,t,n)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type===`all`)e.setSelection(new qp(e.doc));else if(t.type===`node`){let r=sW(n.doc,n.type,t.anchor,n.mapping);e.setSelection(Gp.create(e.doc,r))}else{let r=sW(n.doc,n.type,t.anchor,n.mapping),i=sW(n.doc,n.type,t.head,n.mapping);if(r!==null&&i!==null){let t=Up.between(e.doc.resolve(r),e.doc.resolve(i));e.setSelection(t)}}},NU=(e,t)=>({type:t.selection.jsonID,anchor:aW(t.selection.anchor,e.type,e.mapping),head:aW(t.selection.head,e.type,e.mapping)}),PU=class{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=uU(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=NU(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()?(Xb&&this._domSelectionInView===null&&(AS(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=CS.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||=nw(iC(),new Map),this.prosemirrorView.dispatch(this._tr.setMeta(mU,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>IU(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(e),0,0));t.setMeta(mU,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=this.beforeTransactionSelection===null?this.prosemirrorView.state.selection:null,t=this.type.toArray().map(e=>IU(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(t),0,0));if(e){let t=Xv(Zv(e.anchor,0),n.doc.content.size),r=Xv(Zv(e.head,0),n.doc.content.size);n.setSelection(Up.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(mU,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||=rw(this.doc),e instanceof Uint8Array||t instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&nb(),r=new uC({gc:!1}),TC(r,t),t=rw(r),TC(r,e),e=rw(r),i._item===null){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[];i=e[uw(e,i._item.id.clock)].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;a&&a.dss.forEach(e=>{QS(r,e,e=>{})});let o=(e,t)=>{let r=e===`added`?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:AU(n.colorMapping,n.colors,r)}},s=rT(i,new tw(t.ds,e.sv)).map(n=>!n._item.deleted||OU(n._item,e)||OU(n._item,t)?IU(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,o):null).filter(e=>e!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(s),0,0));this.prosemirrorView.dispatch(c.setMeta(mU,{isChangeOrigin:!0}))},mU)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;let n=mU.getState(this.prosemirrorView.state);if(e.length===0||n.snapshot!=null||n.prevSnapshot!=null){this.renderSnapshot(n.snapshot,n.prevSnapshot);return}this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);QS(t,t.deleteSet,e=>{if(e.constructor===IE){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e);let n=this.type.toArray().map(e=>FU(e,this.prosemirrorView.state.schema,this)).filter(e=>e!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(Z.from(n),0,0));MU(r,this.beforeTransactionSelection,this),r=r.setMeta(mU,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof Ow}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&r.scrollIntoView(),this.prosemirrorView.dispatch(r)})}_prosemirrorChanged(e){this.doc.transact(()=>{eW(this.doc,this.type,e,this),this.beforeTransactionSelection=NU(this,this.prosemirrorView.state)},mU)}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))}},FU=(e,t,n,r,i,a)=>{let o=n.mapping.get(e);if(o===void 0){if(e instanceof qT)return IU(e,t,n,r,i,a);throw tb()}return o},IU=(e,t,n,r,i,a)=>{let o=[],s=e=>{if(e instanceof qT){let s=FU(e,t,n,r,i,a);s!==null&&o.push(s)}else{let s=e._item.right?.content?.type;s instanceof HT&&!s._item.deleted&&s._item.id.client===s.doc.clientID&&(e.applyDelta([{retain:e.length},...s.toDelta()]),s.doc.transact(e=>{s._item.delete(e)}));let c=LU(e,t,n,r,i,a);c!==null&&c.forEach(e=>{e!==null&&o.push(e)})}};r===void 0||i===void 0?e.toArray().forEach(s):rT(e,new tw(i.ds,r.sv)).forEach(s);try{let s=e.getAttributes(r);r!==void 0&&(OU(e._item,r)?OU(e._item,i)||(s.ychange=a?a(`added`,e._item.id):{type:`added`}):s.ychange=a?a(`removed`,e._item.id):{type:`removed`});let c=t.node(e.nodeName,s,o);return n.mapping.set(e,c),c}catch{return e.doc.transact(t=>{e._item.delete(t)},mU),n.mapping.delete(e),null}},LU=(e,t,n,r,i,a)=>{let o=[],s=e.toDelta(r,i,a);try{for(let e=0;e<s.length;e++){let n=s[e];o.push(t.text(n.insert,QU(n.attributes,t)))}}catch{return e.doc.transact(t=>{e._item.delete(t)},mU),null}return o},RU=(e,t)=>{let n=new QT,r=e.map(e=>({insert:e.text,attributes:$U(e.marks,t)}));return n.applyDelta(r),t.mapping.set(n,e),n},zU=(e,t)=>{let n=new qT(e.type.name);for(let t in e.attrs){let r=e.attrs[t];r!==null&&t!==`ychange`&&n.setAttribute(t,r)}return n.insert(0,UU(e).map(e=>BU(e,t))),t.mapping.set(n,e),n},BU=(e,t)=>e instanceof Array?RU(e,t):zU(e,t),VU=e=>typeof e==`object`&&!!e,HU=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]!==null),r=n.length===(t==null?0:Object.keys(t).filter(e=>t[e]!==null).length);for(let i=0;i<n.length&&r;i++){let a=n[i],o=e[a],s=t[a];r=a===`ychange`||o===s||VU(o)&&VU(s)&&HU(o,s)}return r},UU=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},WU=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&Ib(e.attributes||{}).length===t[n].marks.length&&Bb(e.attributes,(e,r)=>{let i=ZU(r),a=t[n].marks;return HU(e,a.find(e=>e.type.name===i)?.attrs)}))},GU=(e,t)=>{if(e instanceof qT&&!(t instanceof Array)&&tW(e,t)){let n=UU(t);return e._length===n.length&&HU(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>GU(e,n[t]))}return e instanceof QT&&t instanceof Array&&WU(e,t)},KU=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),qU=(e,t,n)=>{let r=e.toArray(),i=UU(t),a=i.length,o=r.length,s=Xv(o,a),c=0,l=0,u=!1;for(;c<s;c++){let e=r[c],t=i[c];if(KU(n.mapping.get(e),t))u=!0;else if(!GU(e,t))break}for(;c+l<s;l++){let e=r[o-l-1],t=i[a-l-1];if(KU(n.mapping.get(e),t))u=!0;else if(!GU(e,t))break}return{equalityFactor:c+l,foundMappedChild:u}},JU=e=>{let t=``,n=e._start,r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof yE?t+=n.content.str:n.content instanceof fE&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}},YU=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=JU(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,$U(e.marks,n))})),{insert:o,remove:s,index:c}=pU(i,a.map(e=>e.insert).join(``));e.delete(c,s),e.insert(c,o),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},XU=/(.*)(--[a-zA-Z0-9+/=]{8})$/,ZU=e=>XU.exec(e)?.[1]??e,QU=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(ZU(r),e[r]));return n},$U=(e,t)=>{let n={};return e.forEach(e=>{if(e.type.name!==`ychange`){let r=Iv(t.isOMark,e.type,()=>!e.type.excludes(e.type));n[r?`${e.type.name}--${DU(e.toJSON())}`:e.type.name]=e.attrs}}),n},eW=(e,t,n,r)=>{if(t instanceof qT&&t.nodeName!==n.type.name)throw Error(`node name mismatch!`);if(r.mapping.set(t,n),t instanceof qT){let e=t.getAttributes(),r=n.attrs;for(let n in r)r[n]===null?t.removeAttribute(n):e[n]!==r[n]&&n!==`ychange`&&t.setAttribute(n,r[n]);for(let n in e)r[n]===void 0&&t.removeAttribute(n)}let i=UU(n),a=i.length,o=t.toArray(),s=o.length,c=Xv(a,s),l=0,u=0;for(;l<c;l++){let e=o[l],t=i[l];if(!KU(r.mapping.get(e),t))if(GU(e,t))r.mapping.set(e,t);else break}for(;u+l<c;u++){let e=o[s-u-1],t=i[a-u-1];if(!KU(r.mapping.get(e),t))if(GU(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;s-l-u>0&&a-l-u>0;){let n=o[l],c=i[l],d=o[s-u-1],f=i[a-u-1];if(n instanceof QT&&c instanceof Array)WU(n,c)||YU(n,c,r),l+=1;else{let i=n instanceof qT&&tW(n,c),a=d instanceof qT&&tW(d,f);if(i&&a){let e=qU(n,c,r),t=qU(d,f,r);e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(eW(e,n,c,r),l+=1):a?(eW(e,d,f,r),u+=1):(r.mapping.delete(t.get(l)),t.delete(l,1),t.insert(l,[BU(c,r)]),l+=1)}}let n=s-l-u;if(s===1&&a===0&&o[0]instanceof QT?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):n>0&&(t.slice(l,l+n).forEach(e=>r.mapping.delete(e)),t.delete(l,n)),l+u<a){let e=[];for(let t=l;t<a-u;t++)e.push(BU(i[t],r));t.insert(l,e)}},mU)},tW=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,nW=null,rW=()=>{let e=nW;nW=null,e.forEach((e,t)=>{let n=t.state.tr,r=mU.getState(t.state);r&&r.binding&&!r.binding.isDestroyed&&(e.forEach((e,t)=>{n.setMeta(t,e)}),t.dispatch(n))})},iW=(e,t,n)=>{nW||(nW=new Map,AS(0,rW)),Iv(nW,e,Pv).set(t,n)},aW=(e,t,n)=>{if(e===0)return ZC(t,0,t.length===0?-1:0);let r=t._first===null?null:t._first.content.type;for(;r!==null&&t!==r;){if(r instanceof QT){if(r._length>=e)return ZC(r,e,t.length===0?-1:0);if(e-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==t&&(r=r._item===null?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&e<i)r=r._first.content.type,e--;else{if(e===1&&r._length===0&&i>1)return new KC(r._item===null?null:r._item.id,r._item===null?WC(r):null,null);if(e-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(e===0)return r=r._item===null?r:r._item.parent,new KC(r._item===null?null:r._item.id,r._item===null?WC(r):null,null);do r=r._item.parent,e--;while(r!==t&&r._item.next===null);r!==t&&(r=r._item.next.content.type)}}}if(r===null)throw nb();if(e===0&&r.constructor!==QT&&r!==t)return oW(r._item.parent,r._item)}return ZC(t,t._length,t.length===0?-1:0)},oW=(e,t)=>{let n=null,r=null;return e._item===null?r=WC(e):n=UC(e._item.id.client,e._item.id.clock),new KC(n,r,t.id)},sW=(e,t,n,r)=>{let i=$C(n,e);if(i===null||i.type!==t&&!GC(t,i.type._item))return null;let a=i.type,o=0;if(a.constructor===QT)o=i.index;else if(a._item===null||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&e!==null;){if(!e.deleted){let n=e.content.type;t++,n instanceof QT?o+=n._length:o+=r.get(n).nodeSize}e=e.right}o+=1}for(;a!==t&&a._item!==null;){let e=a._item.parent;if(e._item===null||!e._item.deleted){o+=1;let t=e._first;for(;t!==null;){let e=t.content.type;if(e===a)break;t.deleted||(e instanceof QT?o+=e._length:o+=r.get(e).nodeSize),t=t.right}}a=e}return o-1};function cW(e){let t=e.toArray(),n=e=>{let t;if(e instanceof QT)t=e.toDelta().map(e=>{let t={type:`text`,text:e.insert};return e.attributes&&(t.marks=Object.keys(e.attributes).map(t=>{let n=e.attributes[t],r={type:ZU(t)};return Object.keys(n)&&(r.attrs=n),r})),t});else if(e instanceof qT){t={type:e.nodeName};let r=e.getAttributes();Object.keys(r).length&&(t.attrs=r);let i=e.toArray();i.length&&(t.content=i.map(n).flat())}else nb();return t};return{type:`doc`,content:t.map(n)}}var lW=(e,t,n)=>e!==t,uW=e=>{let t=document.createElement(`span`);t.classList.add(`ProseMirror-yjs-cursor`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(``),i=document.createTextNode(``);return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},dW=e=>({style:`background-color: ${e.color}70`,class:`ProseMirror-yjs-selection`}),fW=/^#[0-9a-fA-F]{6}$/,pW=(e,t,n,r,i)=>{let a=mU.getState(e),o=a.doc,s=[];return a.snapshot!=null||a.prevSnapshot!=null||a.binding.mapping.size===0?TR.create(e.doc,[]):(t.getStates().forEach((t,c)=>{if(n(o.clientID,c,t)&&t.cursor!=null){let n=t.user||{};n.color==null?n.color=`#ffa500`:fW.test(n.color)||console.warn(`A user uses an unsupported color format`,n),n.name??=`User: ${c}`;let l=sW(o,a.type,qC(t.cursor.anchor),a.binding.mapping),u=sW(o,a.type,qC(t.cursor.head),a.binding.mapping);if(l!==null&&u!==null){let t=Zv(e.doc.content.size-1,0);l=Xv(l,t),u=Xv(u,t),s.push(SR.widget(u,()=>r(n,c),{key:c+``,side:10}));let a=Xv(l,u),o=Zv(l,u);s.push(SR.inline(a,o,i(n,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),TR.create(e.doc,s))},mW=(e,{awarenessStateFilter:t=lW,cursorBuilder:n=uW,selectionBuilder:r=dW,getSelection:i=e=>e.selection}={},a=`cursor`)=>new sm({key:gU,state:{init(i,a){return pW(a,e,t,n,r)},apply(i,a,o,s){let c=mU.getState(s),l=i.getMeta(gU);return c&&c.isChangeOrigin||l&&l.awarenessUpdated?pW(s,e,t,n,r):a.map(i.mapping,i.doc)}},props:{decorations:e=>gU.getState(e)},view:t=>{let n=()=>{t.docView&&iW(t,gU,{awarenessUpdated:!0})},r=()=>{let n=mU.getState(t.state),r=e.getLocalState()||{};if(t.hasFocus()){let o=i(t.state),s=aW(o.anchor,n.type,n.binding.mapping),c=aW(o.head,n.type,n.binding.mapping);(r.cursor==null||!ew(qC(r.cursor.anchor),s)||!ew(qC(r.cursor.head),c))&&e.setLocalStateField(a,{anchor:s,head:c})}else r.cursor!=null&&sW(n.doc,n.type,qC(r.cursor.anchor),n.binding.mapping)!==null&&e.setLocalStateField(a,null)};return e.on(`change`,n),t.dom.addEventListener(`focusin`,r),t.dom.addEventListener(`focusout`,r),{update:r,destroy:()=>{t.dom.removeEventListener(`focusin`,r),t.dom.removeEventListener(`focusout`,r),e.off(`change`,n),e.setLocalStateField(a,null)}}}}),hW=e=>hU.getState(e)?.undoManager?.undo()!=null,gW=e=>hU.getState(e)?.undoManager?.redo()!=null,_W=new Set([`paragraph`]),vW=(e,t)=>!(e instanceof IE)||!(e.content instanceof kE)||!(e.content.type instanceof HT||e.content.type instanceof qT&&t.has(e.content.type.nodeName))||e.content.type._length===0,yW=({protectedNodes:e=_W,trackedOrigins:t=[],undoManager:n=null}={})=>new sm({key:hU,state:{init:(r,i)=>{let a=mU.getState(i),o=n||new Ow(a.type,{trackedOrigins:new Set([mU].concat(t)),deleteFilter:t=>vW(t,e),captureTransaction:e=>e.meta.get(`addToHistory`)!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(e,t,n,r)=>{let i=mU.getState(r).binding,a=t.undoManager,o=a.undoStack.length>0,s=a.redoStack.length>0;return i?{undoManager:a,prevSel:NU(i,n),hasUndoOps:o,hasRedoOps:s}:o!==t.hasUndoOps||s!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=mU.getState(e.state),n=hU.getState(e.state).undoManager;return n.on(`stack-item-added`,({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,hU.getState(e.state).prevSel)}),n.on(`stack-item-popped`,({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy()}}}}),bW=tV.create({name:`collaboration`,priority:1e3,addOptions(){return{document:null,field:`default`,fragment:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name===`history`)&&console.warn(`[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".`)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),hU.getState(t).undoManager.undoStack.length===0?!1:n?hW(t):!0),redo:()=>({tr:e,state:t,dispatch:n})=>(e.setMeta(`preventDispatch`,!0),hU.getState(t).undoManager.redoStack.length===0?!1:n?gW(t):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var e;let t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=yW(this.options.yUndoOptions),r=n.spec.view;n.spec.view=e=>{let{undoManager:t}=hU.getState(e.state);t.restore&&=(t.restore(),()=>{});let n=r?r(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),r=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on(`afterTransaction`,t.afterTransactionHandler),t._observers=r},n?.destroy&&n.destroy()}}};let i=jU(t,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender});return this.editor.options.enableContentCheck&&((e=t.doc)==null||e.on(`beforeTransaction`,()=>{try{let e=cW(t);if(e.content.length===0)return;this.editor.schema.nodeFromJSON(e).check()}catch(e){return this.editor.emit(`contentError`,{error:e,editor:this.editor,disableCollaboration:()=>{var e;(e=t.doc)==null||e.destroy(),this.storage.isDisabled=!0}}),!1}})),[i,n,this.editor.options.enableContentCheck&&new sm({key:new um(`filterInvalidContent`),filterTransaction:()=>{var e;return this.storage.isDisabled&&((e=t.doc)==null||e.destroy()),!0}})].filter(Boolean)}}),xW=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t.user})),SW=()=>null,CW=tV.create({name:`collaborationCursor`,priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:e=>{let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.setAttribute(`style`,`border-color: ${e.color}`);let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.setAttribute(`style`,`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null),t.insertBefore(n,null),t},selectionRender:dW,onUpdate:SW}},onCreate(){if(this.options.onUpdate!==SW&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),!this.options.provider)throw Error(`The "provider" option is required for the CollaborationCursor extension`)},addStorage(){return{users:[]}},addCommands(){return{updateUser:e=>()=>(this.options.user=e,this.options.provider.awareness.setLocalStateField(`user`,this.options.user),!0),user:e=>({editor:t})=>(console.warn(`[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor`),t.commands.updateUser(e))}},addProseMirrorPlugins(){return[mW((this.options.provider.awareness.setLocalStateField(`user`,this.options.user),this.storage.users=xW(this.options.provider.awareness.states),this.options.provider.awareness.on(`update`,()=>{this.storage.users=xW(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}});function wW(e){let{targetEl:t,platform:n,hasSelection:r,isEditable:i}=e,a=t.closest(`a[href]`)!=null,o=t.closest(`td, th`)!=null,s={hasSelection:r,isEditable:i,overLink:a,canMergeCells:!1,canSplitCell:!1};return a?{kind:`link`,...s}:o?{kind:`tableCell`,...s}:n===`macos`?null:{kind:`editorText`,...s}}function TW(e){let t=e.toLowerCase();return t.includes(`mac`)||t===`darwin`?`macos`:t.includes(`win`)?`windows`:`linux`}function EW(e,t,n){let r=e.split(/(?:\r\n?|\n)+/).map(e=>t.nodes.paragraph.create(null,e?t.text(e,n):void 0));return Q.maxOpen(Z.fromArray(r))}var DW=[`http://`,`https://`,`mailto:`,`ftp://`,`//`];function OW(e){let t=e.toLowerCase();return DW.some(e=>t.startsWith(e))}function kW(e){if(!e)return null;let t=e.trim();if(!t)return null;if(OW(t)||t.startsWith(`#`))return t;let n=t.indexOf(`:`);if(n===-1)return t;let r=Math.min(...[`/`,`#`,`?`].map(e=>t.indexOf(e)).filter(e=>e!==-1));return Number.isFinite(r)&&r<n?t:null}function AW(e){return e.chain().focus()}async function jW(e,t){let{editor:n}=t;switch(e){case`ctx:undo`:AW(n).undo().run();return;case`ctx:redo`:AW(n).redo().run();return;case`ctx:pastePlain`:{let e=await t.readClipboardText();if(!e)return;let{state:r,view:i}=n,a=EW(e,r.schema,r.selection.$from.marks());i.dispatch(r.tr.replaceSelection(a).scrollIntoView()),i.focus();return}case`ctx:table:insertRowAbove`:AW(n).addRowBefore().run();return;case`ctx:table:insertRowBelow`:AW(n).addRowAfter().run();return;case`ctx:table:insertColLeft`:AW(n).addColumnBefore().run();return;case`ctx:table:insertColRight`:AW(n).addColumnAfter().run();return;case`ctx:table:deleteRow`:AW(n).deleteRow().run();return;case`ctx:table:deleteCol`:AW(n).deleteColumn().run();return;case`ctx:table:mergeCells`:AW(n).mergeCells().run();return;case`ctx:table:splitCell`:AW(n).splitCell().run();return;case`ctx:table:deleteTable`:AW(n).deleteTable().run();return;case`ctx:link:open`:{let e=t.getLinkHref();e&&t.openHref(e);return}case`ctx:link:copy`:{let e=t.getLinkHref();if(!e)return;let n=kW(e);n&&await t.writeClipboardText(n);return}case`ctx:link:remove`:AW(n).extendMarkRange(`link`).unsetLink().run();return;default:return}}var MW=new Set([`ctx:undo`,`ctx:redo`,`ctx:pastePlain`,`ctx:table:insertRowAbove`,`ctx:table:insertRowBelow`,`ctx:table:insertColLeft`,`ctx:table:insertColRight`,`ctx:table:deleteRow`,`ctx:table:deleteCol`,`ctx:table:mergeCells`,`ctx:table:splitCell`,`ctx:table:deleteTable`,`ctx:link:open`,`ctx:link:copy`,`ctx:link:remove`]);function NW(e){return typeof e==`string`&&MW.has(e)}async function PW(){try{return await navigator.clipboard.readText()}catch{return null}}async function FW(e){try{await navigator.clipboard.writeText(e)}catch{}}function IW(e,t){if(!Lm())return()=>{};let n=e.view.dom,r=t.platform??TW(typeof navigator<`u`?navigator.platform||navigator.userAgent:``),i=null,a=async t=>{let n=t.target;if(!n)return;let a=wW({targetEl:n,platform:r,hasSelection:!1,isEditable:e.isEditable});if(!a)return;t.preventDefault();let o=e.view.posAtCoords({left:t.clientX,top:t.clientY});if(o){let{from:t,to:n}=e.state.selection;(o.pos<t||o.pos>n)&&e.commands.setTextSelection(o.pos)}if(a.hasSelection=!e.state.selection.empty,i=n.closest(`a[href]`)?.getAttribute(`href`)??null,a.kind===`tableCell`){let t=e.can();a.canMergeCells=t.mergeCells(),a.canSplitCell=t.splitCell()}e.view.focus();try{await(await Bm())(`show_context_menu`,{req:a})}catch{}};n.addEventListener(`contextmenu`,a);let o=Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:n})=>n(`context-menu-action`,n=>{let r=n.payload?.id;NW(r)&&jW(r,{editor:e,openHref:t.openHref,getLinkHref:()=>i,readClipboardText:PW,writeClipboardText:FW})}));return o.catch(()=>{}),()=>{n.removeEventListener(`contextmenu`,a),o.then(e=>e()).catch(()=>{})}}var LW=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,RW=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,zW=GB.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){return[`mark`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[rU({find:LW,type:this.type})]},addPasteRules(){return[cU({find:RW,type:this.type})]}}),BW=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,VW=sU.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,wB(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[iU({find:BW,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),HW=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,UW=`ελ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`,WW=`numeric`,GW=`ascii`,KW=`alpha`,qW=`asciinumeric`,JW=`alphanumeric`,YW=`domain`,XW=`emoji`,ZW=`scheme`,QW=`slashscheme`,$W=`whitespace`;function eG(e,t){return e in t||(t[e]=[]),t[e]}function tG(e,t,n){t[WW]&&(t[qW]=!0,t[JW]=!0),t[GW]&&(t[qW]=!0,t[KW]=!0),t[qW]&&(t[JW]=!0),t[KW]&&(t[JW]=!0),t[JW]&&(t[YW]=!0),t[XW]&&(t[YW]=!0);for(let r in t){let t=eG(r,n);t.indexOf(e)<0&&t.push(e)}}function nG(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function rG(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}rG.groups={},rG.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=rG.groups;let i;return t&&t.j?i=t:(i=new rG(t),n&&r&&tG(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=rG.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new rG,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new rG,a&&(r&&(o.t&&typeof o.t==`string`?tG(a,Object.assign(nG(o.t,r),n),r):n&&tG(a,n,r)),o.t=a),i.j[e]=o,o}};var iG=(e,t,n,r,i)=>e.ta(t,n,r,i),aG=(e,t,n,r,i)=>e.tr(t,n,r,i),oG=(e,t,n,r,i)=>e.ts(t,n,r,i),$=(e,t,n,r,i)=>e.tt(t,n,r,i),sG=`WORD`,cG=`UWORD`,lG=`ASCIINUMERICAL`,uG=`ALPHANUMERICAL`,dG=`LOCALHOST`,fG=`TLD`,pG=`UTLD`,mG=`SCHEME`,hG=`SLASH_SCHEME`,gG=`NUM`,_G=`WS`,vG=`NL`,yG=`OPENBRACE`,bG=`CLOSEBRACE`,xG=`OPENBRACKET`,SG=`CLOSEBRACKET`,CG=`OPENPAREN`,wG=`CLOSEPAREN`,TG=`OPENANGLEBRACKET`,EG=`CLOSEANGLEBRACKET`,DG=`FULLWIDTHLEFTPAREN`,OG=`FULLWIDTHRIGHTPAREN`,kG=`LEFTCORNERBRACKET`,AG=`RIGHTCORNERBRACKET`,jG=`LEFTWHITECORNERBRACKET`,MG=`RIGHTWHITECORNERBRACKET`,NG=`FULLWIDTHLESSTHAN`,PG=`FULLWIDTHGREATERTHAN`,FG=`AMPERSAND`,IG=`APOSTROPHE`,LG=`ASTERISK`,RG=`AT`,zG=`BACKSLASH`,BG=`BACKTICK`,VG=`CARET`,HG=`COLON`,UG=`COMMA`,WG=`DOLLAR`,GG=`DOT`,KG=`EQUALS`,qG=`EXCLAMATION`,JG=`HYPHEN`,YG=`PERCENT`,XG=`PIPE`,ZG=`PLUS`,QG=`POUND`,$G=`QUERY`,eK=`QUOTE`,tK=`FULLWIDTHMIDDLEDOT`,nK=`SEMI`,rK=`SLASH`,iK=`TILDE`,aK=`UNDERSCORE`,oK=`EMOJI`,sK=`SYM`,cK=Object.freeze({__proto__:null,ALPHANUMERICAL:uG,AMPERSAND:FG,APOSTROPHE:IG,ASCIINUMERICAL:lG,ASTERISK:LG,AT:RG,BACKSLASH:zG,BACKTICK:BG,CARET:VG,CLOSEANGLEBRACKET:EG,CLOSEBRACE:bG,CLOSEBRACKET:SG,CLOSEPAREN:wG,COLON:HG,COMMA:UG,DOLLAR:WG,DOT:GG,EMOJI:oK,EQUALS:KG,EXCLAMATION:qG,FULLWIDTHGREATERTHAN:PG,FULLWIDTHLEFTPAREN:DG,FULLWIDTHLESSTHAN:NG,FULLWIDTHMIDDLEDOT:tK,FULLWIDTHRIGHTPAREN:OG,HYPHEN:JG,LEFTCORNERBRACKET:kG,LEFTWHITECORNERBRACKET:jG,LOCALHOST:dG,NL:vG,NUM:gG,OPENANGLEBRACKET:TG,OPENBRACE:yG,OPENBRACKET:xG,OPENPAREN:CG,PERCENT:YG,PIPE:XG,PLUS:ZG,POUND:QG,QUERY:$G,QUOTE:eK,RIGHTCORNERBRACKET:AG,RIGHTWHITECORNERBRACKET:MG,SCHEME:mG,SEMI:nK,SLASH:rK,SLASH_SCHEME:hG,SYM:sK,TILDE:iK,TLD:fG,UNDERSCORE:aK,UTLD:pG,UWORD:cG,WORD:sG,WS:_G}),lK=/[a-z]/,uK=/\p{L}/u,dK=/\p{Emoji}/u,fK=/\d/,pK=/\s/,mK=`\r`,hK=`
|
|
205
|
-
`,gK=`️`,_K=``,vK=``,yK=null,bK=null;function xK(e=[]){let t={};rG.groups=t;let n=new rG;yK??=TK(HW),bK??=TK(UW),$(n,`'`,IG),$(n,`{`,yG),$(n,`}`,bG),$(n,`[`,xG),$(n,`]`,SG),$(n,`(`,CG),$(n,`)`,wG),$(n,`<`,TG),$(n,`>`,EG),$(n,`(`,DG),$(n,`)`,OG),$(n,`「`,kG),$(n,`」`,AG),$(n,`『`,jG),$(n,`』`,MG),$(n,`<`,NG),$(n,`>`,PG),$(n,`&`,FG),$(n,`*`,LG),$(n,`@`,RG),$(n,"`",BG),$(n,`^`,VG),$(n,`:`,HG),$(n,`,`,UG),$(n,`$`,WG),$(n,`.`,GG),$(n,`=`,KG),$(n,`!`,qG),$(n,`-`,JG),$(n,`%`,YG),$(n,`|`,XG),$(n,`+`,ZG),$(n,`#`,QG),$(n,`?`,$G),$(n,`"`,eK),$(n,`/`,rK),$(n,`;`,nK),$(n,`~`,iK),$(n,`_`,aK),$(n,`\\`,zG),$(n,`・`,tK);let r=aG(n,fK,gG,{[WW]:!0});aG(r,fK,r);let i=aG(r,lK,lG,{[qW]:!0}),a=aG(r,uK,uG,{[JW]:!0}),o=aG(n,lK,sG,{[GW]:!0});aG(o,fK,i),aG(o,lK,o),aG(i,fK,i),aG(i,lK,i);let s=aG(n,uK,cG,{[KW]:!0});aG(s,lK),aG(s,fK,a),aG(s,uK,s),aG(a,fK,a),aG(a,lK),aG(a,uK,a);let c=$(n,hK,vG,{[$W]:!0}),l=$(n,mK,_G,{[$W]:!0}),u=aG(n,pK,_G,{[$W]:!0});$(n,vK,u),$(l,hK,c),$(l,vK,u),aG(l,pK,u),$(u,mK),$(u,hK),aG(u,pK,u),$(u,vK,u);let d=aG(n,dK,oK,{[XW]:!0});$(d,`#`),aG(d,dK,d),$(d,gK,d);let f=$(d,_K);$(f,`#`),aG(f,dK,d);let p=[[lK,o],[fK,i]],m=[[lK,null],[uK,s],[fK,a]];for(let e=0;e<yK.length;e++)wK(n,yK[e],fG,sG,p);for(let e=0;e<bK.length;e++)wK(n,bK[e],pG,cG,m);tG(fG,{tld:!0,ascii:!0},t),tG(pG,{utld:!0,alpha:!0},t),wK(n,`file`,mG,sG,p),wK(n,`mailto`,mG,sG,p),wK(n,`http`,hG,sG,p),wK(n,`https`,hG,sG,p),wK(n,`ftp`,hG,sG,p),wK(n,`ftps`,hG,sG,p),tG(mG,{scheme:!0,ascii:!0},t),tG(hG,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[ZW]:!0}:{[QW]:!0};r.indexOf(`-`)>=0?i[YW]=!0:lK.test(r)?fK.test(r)?i[qW]=!0:i[GW]=!0:i[WW]=!0,oG(n,r,r,i)}return oG(n,`localhost`,dG,{ascii:!0}),n.jd=new rG(sK),{start:n,tokens:Object.assign({groups:t},cK)}}function SK(e,t){let n=CK(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function CK(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function wK(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new rG(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new rG(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function TK(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var EK={defaultProtocol:`http`,events:null,format:OK,formatHref:OK,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function DK(e,t=null){let n=Object.assign({},EK);e&&(n=Object.assign(n,e instanceof DK?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}DK.prototype={o:EK,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:EK[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function OK(e){return e}function kK(e,t){this.t=`token`,this.v=e,this.tk=t}kK.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=EK.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function AK(e,t){class n extends kK{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var jK=AK(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),MK=AK(`text`),NK=AK(`nl`),PK=AK(`url`,{isLink:!0,toHref(e=EK.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==dG&&e[1].t===HG}}),FK=e=>new rG(e);function IK({groups:e}){let t=e.domain.concat([FG,LG,RG,zG,BG,VG,WG,KG,JG,gG,YG,XG,ZG,QG,rK,sK,iK,aK]),n=[IG,HG,UG,GG,qG,YG,$G,eK,nK,TG,EG,yG,bG,SG,xG,CG,wG,DG,OG,kG,AG,jG,MG,NG,PG],r=[FG,IG,LG,zG,BG,VG,WG,KG,JG,yG,bG,YG,XG,ZG,QG,$G,rK,sK,iK,aK],i=FK(),a=$(i,iK);iG(a,r,a),iG(a,e.domain,a);let o=FK(),s=FK(),c=FK();iG(i,e.domain,o),iG(i,e.scheme,s),iG(i,e.slashscheme,c),iG(o,r,a),iG(o,e.domain,o);let l=$(o,RG);$(a,RG,l),$(s,RG,l),$(c,RG,l);let u=$(a,GG);iG(u,r,a),iG(u,e.domain,a);let d=FK();iG(l,e.domain,d),iG(d,e.domain,d);let f=$(d,GG);iG(f,e.domain,d);let p=FK(jK);iG(f,e.tld,p),iG(f,e.utld,p),$(l,dG,p);let m=$(d,JG);$(m,JG,m),iG(m,e.domain,d),iG(p,e.domain,d),$(p,GG,f),$(p,JG,m),iG($(p,HG),e.numeric,jK);let h=$(o,JG),g=$(o,GG);$(h,JG,h),iG(h,e.domain,o),iG(g,r,a),iG(g,e.domain,o);let _=FK(PK);iG(g,e.tld,_),iG(g,e.utld,_),iG(_,e.domain,o),iG(_,r,a),$(_,GG,g),$(_,JG,h),$(_,RG,l);let v=$(_,HG),y=FK(PK);iG(v,e.numeric,y);let b=FK(PK),x=FK();iG(b,t,b),iG(b,n,x),iG(x,t,b),iG(x,n,x),$(_,rK,b),$(y,rK,b);let S=$(s,HG),C=$($($(c,HG),rK),rK);iG(s,e.domain,o),$(s,GG,g),$(s,JG,h),iG(c,e.domain,o),$(c,GG,g),$(c,JG,h),iG(S,e.domain,b),$(S,rK,b),$(S,$G,b),iG(C,e.domain,b),iG(C,t,b),$(C,rK,b);let w=[[yG,bG],[xG,SG],[CG,wG],[TG,EG],[DG,OG],[kG,AG],[jG,MG],[NG,PG]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=$(b,r);$(x,r,a),$(a,i,b);let o=FK(PK);iG(a,t,o);let s=FK();iG(a,n),iG(o,t,o),iG(o,n,s),iG(s,t,o),iG(s,n,s),$(o,i,b),$(s,i,b)}return $(i,dG,_),$(i,vG,NK),{start:i,tokens:cK}}function LK(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(RK(MK,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(RK(e,t,r))}}return o.length>0&&a.push(RK(MK,t,o)),a}function RK(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var zK=typeof console<`u`&&console&&console.warn||(()=>{}),BK=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,VK={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function HK(){return rG.groups={},VK.scanner=null,VK.parser=null,VK.tokenQueue=[],VK.pluginQueue=[],VK.customSchemes=[],VK.initialized=!1,VK}function UK(e,t=!1){if(VK.initialized&&zK(`linkifyjs: already initialized - will not register custom scheme "${e}" ${BK}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
206
|
-
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
207
|
-
2. Cannot start or end with "-"
|
|
208
|
-
3. "-" cannot repeat`);VK.customSchemes.push([e,t])}function WK(){VK.scanner=xK(VK.customSchemes);for(let e=0;e<VK.tokenQueue.length;e++)VK.tokenQueue[e][1]({scanner:VK.scanner});VK.parser=IK(VK.scanner.tokens);for(let e=0;e<VK.pluginQueue.length;e++)VK.pluginQueue[e][1]({scanner:VK.scanner,parser:VK.parser});return VK.initialized=!0,VK}function GK(e){return VK.initialized||WK(),LK(VK.parser.start,e,SK(VK.scanner.start,e))}GK.scan=SK;function KK(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new DK(n),i=GK(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var qK=`[\0- \xA0 -\u2029 ]`,JK=new RegExp(qK),YK=RegExp(`${qK}$`),XK=new RegExp(qK,`g`);function ZK(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function QK(e){return new sm({key:new um(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(wH(mH(n.doc,[...t])).forEach(({newRange:t})=>{let n=gH(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!YK.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(JK).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=GK(n).map(t=>t.toObject(e.defaultProtocol));if(!ZK(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>r.schema.marks.code?!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code):!0).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{TH(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function $K(e){return new sm({key:new um(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=r.target,a=[];for(;i.nodeName!==`DIV`;)a.push(i),i=i.parentNode;if(!a.find(e=>e.nodeName===`A`))return!1;let o=xH(t.state,e.type.name),s=r.target,c=s?.href??o.href,l=s?.target??o.target;return s&&c?(window.open(c,l),!0):!1}}})}function eq(e){return new sm({key:new um(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{state:i}=t,{selection:a}=i,{empty:o}=a;if(o)return!1;let s=``;r.content.forEach(e=>{s+=e.textContent});let c=KK(s,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===s);return!s||!c?!1:e.editor.commands.setMark(e.type,{href:c.href})}}})}function tq(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(XK,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))`,`i`))}var nq=GB.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){UK(e);return}UK(e.scheme,e.optionalSlashes)})},onDestroy(){HK()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!tq(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!tq(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!tq(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,wB(this.options.HTMLAttributes,e),0]:[`a`,wB(this.options.HTMLAttributes,{...e,href:``}),0]},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!tq(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!tq(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run():!1},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addPasteRules(){return[cU({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=KK(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!tq(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>t.push({text:e.value,data:{href:e.href},index:e.start}))}return t},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(QK({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!tq(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&e.push($K({type:this.type})),this.options.linkOnPaste&&e.push(eq({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),rq=tV.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new sm({key:new um(`placeholder`),props:{decorations:({doc:e,selection:t})=>{let n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,i=[];if(!n)return null;let a=this.editor.isEmpty;return e.descendants((e,t)=>{let n=r>=t&&r<=t+e.nodeSize,o=!e.isLeaf&&AH(e);if((n||!this.options.showOnlyCurrent)&&o){let r=[this.options.emptyNodeClass];a&&r.push(this.options.emptyEditorClass);let o=SR.node(t,t+e.nodeSize,{class:r.join(` `),"data-placeholder":typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:e,pos:t,hasAnchor:n}):this.options.placeholder});i.push(o)}return this.options.includeChildren}),TR.create(e,i)}}})]}}),iq=GB.create({name:`subscript`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`sub`},{style:`vertical-align`,getAttrs(e){return e===`sub`?null:!1}}]},renderHTML({HTMLAttributes:e}){return[`sub`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),aq=GB.create({name:`superscript`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`sup`},{style:`vertical-align`,getAttrs(e){return e===`super`?null:!1}}]},renderHTML({HTMLAttributes:e}){return[`sup`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),oq,sq;if(typeof WeakMap<`u`){let e=new WeakMap;oq=t=>e.get(t),sq=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;oq=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},sq=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var cq=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return oq(e)||sq(e,lq(e))}};function lq(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=uq(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new cq(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&dq(s,o,e),s}function uq(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function dq(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=fq(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function fq(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function pq(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var mq=new um(`selectingCells`);function hq(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function gq(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function _q(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function vq(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=hq(t.$head)||yq(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function yq(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function bq(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function xq(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Sq(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Cq(e,t,n){let r=e.node(-1),i=cq.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function wq(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Tq(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function Eq(e,t,n){let r=pq(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var Dq=class e extends zp{constructor(e,t=e){let n=e.node(-1),r=cq.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Bp(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(bq(r)&&bq(i)&&Sq(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return Up.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=cq.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=wq(e,0,l)),u>0&&(e=wq(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(Z.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new Q(Z.from(o),1,1)}replace(e,t=Q.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?Q.empty:t)}let i=zp.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new Q(Z.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=cq.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=cq.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=cq.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=cq.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new Oq(this.$anchorCell.pos,this.$headCell.pos)}};Dq.prototype.visible=!1,zp.jsonID(`cell`,Dq);var Oq=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Sq(t,n)?new Dq(t,n):zp.near(n,1)}};function kq(e){if(!(e.selection instanceof Dq))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(SR.node(n,n+e.nodeSize,{class:`selectedCell`}))}),TR.create(e.doc,t)}function Aq({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function jq({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function Mq(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof Gp&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=Dq.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=Dq.rowSelection(e,e)}else if(!n){let e=cq.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=Dq.create(i,t+1,n)}}else r instanceof Up&&Aq(r)?a=Up.create(i,r.from):r instanceof Up&&jq(r)&&(a=Up.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Nq=new um(`fix-tables`);function Pq(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?Pq(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Fq(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=Iq(e,t,r,n))};return t?t.doc!=e.doc&&Pq(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Iq(e,t,n,r){let i=cq.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,wq(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=pq(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(Nq,{fixTables:!0})}function Lq(e){let t=e.selection,n=vq(e),r=n.node(-1),i=n.start(-1),a=cq.get(r);return{...t instanceof Dq?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function Rq(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;Eq(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Tq(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?pq(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function zq(e,t){if(!_q(e))return!1;if(t){let n=Lq(e);t(Rq(e.tr,n,n.left))}return!0}function Bq(e,t){if(!_q(e))return!1;if(t){let n=Lq(e);t(Rq(e.tr,n,n.right))}return!0}function Vq(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,wq(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function Hq(e,t){if(!_q(e))return!1;if(t){let n=Lq(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;Vq(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=cq.get(e)}t(r)}return!0}function Uq(e,t,n){let r=pq(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function Wq(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;Uq(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?pq(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,pq(r.type.schema).row.create(null,o)),e}function Gq(e,t){if(!_q(e))return!1;if(t){let n=Lq(e);t(Wq(e.tr,n,n.top))}return!0}function Kq(e,t){if(!_q(e))return!1;if(t){let n=Lq(e);t(Wq(e.tr,n,n.bottom))}return!0}function qq(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function Jq(e,t){if(!_q(e))return!1;if(t){let n=Lq(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;qq(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=cq.get(n.table)}t(r)}return!0}function Yq(e){let t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function Xq({width:e,height:t,map:n},r){let i=r.top*e+r.left,a=i,o=(r.bottom-1)*e+r.left,s=i+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[a]==n[a-1]||r.right<e&&n[s]==n[s+1])return!0;a+=e,s+=e}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-e]||r.bottom<t&&n[o]==n[o+e])return!0;i++,o++}return!1}function Zq(e,t){let n=e.selection;if(!(n instanceof Dq)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Lq(e),{map:i}=r;if(Xq(i,r))return!1;if(t){let n=e.tr,a={},o=Z.empty,s,c;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){let l=i.map[e*i.width+t],u=r.table.nodeAt(l);if(!(a[l]||!u))if(a[l]=!0,s==null)s=l,c=u;else{Yq(u)||(o=o.append(u.content));let e=n.mapping.map(l+r.tableStart);n.delete(e,e+u.nodeSize)}}if(s==null||c==null)return!0;if(n.setNodeMarkup(s+r.tableStart,null,{...Tq(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),o.size>0){let e=s+1+c.content.size,t=Yq(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new Dq(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function Qq(e,t){let n=pq(e.schema);return $q(({node:e})=>n[e.type.spec.tableRole])(e,t)}function $q(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof Dq){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=gq(r.$from),!i)return!1;a=hq(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=Lq(t),u=t.tr;for(let e=0;e<l.right-l.left;e++)s.push(c?{...o,colwidth:c&&c[e]?[c[e]]:null}:o);let d;for(let t=l.top;t<l.bottom;t++){let n=l.map.positionAt(t,l.left,l.table);t==l.top&&(n+=i.nodeSize);for(let r=l.left,a=0;r<l.right;r++,a++)r==l.left&&t==l.top||u.insert(d=u.mapping.map(n+l.tableStart,1),e({node:i,row:t,col:r}).createAndFill(s[a]))}u.setNodeMarkup(a,e({node:i,row:l.top,col:l.left}),s[0]),r instanceof Dq&&u.setSelection(new Dq(u.doc.resolve(r.$anchorCell.pos),d?u.doc.resolve(d):void 0)),n(u)}return!0}}function eJ(e,t){return function(n,r){if(!_q(n))return!1;let i=vq(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof Dq?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function tJ(e){return function(t,n){if(!_q(t))return!1;if(n){let r=pq(t.schema),i=Lq(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function nJ(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function rJ(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?tJ(e):function(t,n){if(!_q(t))return!1;if(n){let r=pq(t.schema),i=Lq(t),a=t.tr,o=nJ(`row`,i,r),s=nJ(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}rJ(`row`,{useDeprecatedLogic:!0}),rJ(`column`,{useDeprecatedLogic:!0});var iJ=rJ(`cell`,{useDeprecatedLogic:!0});function aJ(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function oJ(e){return function(t,n){if(!_q(t))return!1;let r=aJ(vq(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(Up.between(e,xq(e))).scrollIntoView())}return!0}}function sJ(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function cJ(e,t){let n=e.selection;if(!(n instanceof Dq))return!1;if(t){let r=e.tr,i=pq(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new Q(i,0,0))}),r.docChanged&&t(r)}return!0}function lJ(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=dJ(pq(o).row,new Q(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?dJ(pq(o).row,new Q(t,n,r)).content:t);else return null;return uJ(o,s)}function uJ(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(Z.empty),n[i]<r){let a=pq(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(Z.from(o))}return{height:t.length,width:r,rows:t}}function dJ(e,t){let n=e.createAndFill();return new Lp(n).replace(0,n.content.size,t).doc}function fJ({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(wq(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(Z.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(Z.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function pJ(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=pq(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,Z.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function mJ(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function hJ(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,wq(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(wq(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function gJ(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=cq.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=cq.get(a),f=d.mapping.maps.length}pJ(d,o,a,n,l,u,f)&&p(),mJ(d,o,a,n,c,l,s,f)&&p(),mJ(d,o,a,n,c,l,u,f)&&p(),hJ(d,o,a,n,s,u,c,f)&&p(),hJ(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new Q(i.rows[e-s],0,0))}p(),d.setSelection(new Dq(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var _J=Ez({ArrowLeft:yJ(`horiz`,-1),ArrowRight:yJ(`horiz`,1),ArrowUp:yJ(`vert`,-1),ArrowDown:yJ(`vert`,1),"Shift-ArrowLeft":bJ(`horiz`,-1),"Shift-ArrowRight":bJ(`horiz`,1),"Shift-ArrowUp":bJ(`vert`,-1),"Shift-ArrowDown":bJ(`vert`,1),Backspace:cJ,"Mod-Backspace":cJ,Delete:cJ,"Mod-Delete":cJ});function vJ(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function yJ(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof Dq)return vJ(n,r,zp.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=wJ(i,e,t);if(o==null)return!1;if(e==`horiz`)return vJ(n,r,zp.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Cq(i,e,t),s;return s=a?zp.near(a,1):t<0?zp.near(n.doc.resolve(i.before(-1)),-1):zp.near(n.doc.resolve(i.after(-1)),1),vJ(n,r,s)}}}function bJ(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof Dq)o=a;else{let r=wJ(i,e,t);if(r==null)return!1;o=new Dq(n.doc.resolve(r))}let s=Cq(o.$headCell,e,t);return s?vJ(n,r,new Dq(o.$anchorCell,s)):!1}}function xJ(e,t){let n=e.state.doc,r=hq(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new Dq(r))),!0):!1}function SJ(e,t,n){if(!_q(e.state))return!1;let r=lJ(n),i=e.state.selection;if(i instanceof Dq){r||={width:1,height:1,rows:[Z.from(dJ(pq(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=cq.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=fJ(r,o.right-o.left,o.bottom-o.top),gJ(e.state,e.dispatch,a,o,r),!0}else if(r){let t=vq(e.state),n=t.start(-1);return gJ(e.state,e.dispatch,n,cq.get(t.node(-1)).findCell(t.pos-n),r),!0}else return!1}function CJ(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=TJ(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof Dq)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=hq(e.state.selection.$anchor))!=null&&EJ(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=EJ(e,n),i=mq.getState(e.state)==null;if(!r||!Sq(t,r))if(i)r=t;else return;let a=new Dq(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(mq,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),mq.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(mq,-1))}function o(r){let o=r,s=mq.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(TJ(e,o.target)!=n&&(c=EJ(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function wJ(e,t,n){if(!(e.state.selection instanceof Up))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function TJ(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function EJ(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&hq(e.state.doc.resolve(r))||hq(e.state.doc.resolve(i))}var DJ=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),OJ(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,OJ(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function OJ(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var kJ=new um(`tableColumnResizing`);function AJ({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=DJ,lastColumnResizable:i=!0}={}){let a=new sm({key:kJ,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=pq(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new jJ(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=kJ.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{MJ(t,n,e,i)},mouseleave:e=>{NJ(e)},mousedown:(e,r)=>{PJ(e,r,t,n)}},decorations:e=>{let t=kJ.getState(e);if(t&&t.activeHandle>-1)return UJ(e,t.activeHandle)},nodeViews:{}}});return a}var jJ=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(kJ);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return bq(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function MJ(e,t,n,r){if(!e.editable)return;let i=kJ.getState(e.state);if(i&&!i.dragging){let a=IJ(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=LJ(e,t,`left`,n):i-t.clientX<=n&&(o=LJ(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=cq.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}zJ(e,o)}}}function NJ(e){if(!e.editable)return;let t=kJ.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&zJ(e,-1)}function PJ(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=kJ.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=FJ(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(kJ,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=kJ.getState(e.state);r?.dragging&&(BJ(e,r.activeHandle,RJ(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(kJ,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=kJ.getState(e.state);if(i&&i.dragging){let a=RJ(i.dragging,t,n);VJ(e,i.activeHandle,a,r)}}return VJ(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function FJ(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function IJ(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function LJ(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=hq(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=cq.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function RJ(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function zJ(e,t){e.dispatch(e.state.tr.setMeta(kJ,{setHandle:t}))}function BJ(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=cq.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():HJ(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function VJ(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=cq.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&OJ(a,c.firstChild,c,r,s,n)}function HJ(e){return Array(e).fill(0)}function UJ(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return TR.empty;let a=cq.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,kJ.getState(e)?.dragging&&n.push(SR.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(SR.widget(s,c))}}return TR.create(e.doc,n)}function WJ({allowTableNodeSelection:e=!1}={}){return new sm({key:mq,state:{init(){return null},apply(e,t){let n=e.getMeta(mq);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:kq,handleDOMEvents:{mousedown:CJ},createSelectionBetween(e){return mq.getState(e.state)==null?null:e.state.selection},handleTripleClick:xJ,handleKeyDown:_J,handlePaste:SJ},appendTransaction(t,n,r){return Mq(r,Fq(r,n),e)}})}function GJ(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function KJ(e,t,n,r,i,a){var o;let s=0,c=!0,l=t.firstChild,u=e.firstChild;if(u!==null)for(let e=0,n=0;e<u.childCount;e+=1){let{colspan:o,colwidth:d}=u.child(e).attrs;for(let e=0;e<o;e+=1,n+=1){let o=i===n?a:d&&d[e],u=o?`${o}px`:``;if(s+=o||r,o||(c=!1),l){if(l.style.width!==u){let[e,t]=GJ(r,o);l.style.setProperty(e,t)}l=l.nextSibling}else{let e=document.createElement(`col`),[n,i]=GJ(r,o);e.style.setProperty(n,i),t.appendChild(e)}}}for(;l;){let e=l.nextSibling;(o=l.parentNode)==null||o.removeChild(l),l=e}c?(n.style.width=`${s}px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=`${s}px`)}var qJ=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),KJ(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type===this.node.type?(this.node=e,KJ(e,this.colgroup,this.table,this.cellMinWidth),!0):!1}ignoreMutation(e){return e.type===`attributes`&&(e.target===this.table||this.colgroup.contains(e.target))}};function JJ(e,t,n,r){let i=0,a=!0,o=[],s=e.firstChild;if(!s)return{};for(let e=0,c=0;e<s.childCount;e+=1){let{colspan:l,colwidth:u}=s.child(e).attrs;for(let e=0;e<l;e+=1,c+=1){let s=n===c?r:u&&u[e];i+=s||t,s||(a=!1);let[l,d]=GJ(t,s);o.push([`col`,{style:`${l}: ${d}`}])}}let c=a?`${i}px`:``,l=a?``:`${i}px`;return{colgroup:[`colgroup`,{},...o],tableWidth:c,tableMinWidth:l}}function YJ(e,t){return t?e.createChecked(null,t):e.createAndFill()}function XJ(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function ZJ(e,t,n,r,i){let a=XJ(e),o=[],s=[];for(let e=0;e<n;e+=1){let e=YJ(a.cell,i);if(e&&s.push(e),r){let e=YJ(a.header_cell,i);e&&o.push(e)}}let c=[];for(let e=0;e<t;e+=1)c.push(a.row.createChecked(null,r&&e===0?o:s));return a.table.createChecked(null,c)}function QJ(e){return e instanceof Dq}var $J=({editor:e})=>{let{selection:t}=e.state;if(!QJ(t))return!1;let n=0;return _H(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},eY=sU.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:qJ,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=JJ(e,this.options.cellMinWidth),a=[`table`,wB(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${i}`}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},a]:a},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=ZJ(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(Up.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>zq(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>Bq(e,t),deleteColumn:()=>({state:e,dispatch:t})=>Hq(e,t),addRowBefore:()=>({state:e,dispatch:t})=>Gq(e,t),addRowAfter:()=>({state:e,dispatch:t})=>Kq(e,t),deleteRow:()=>({state:e,dispatch:t})=>Jq(e,t),deleteTable:()=>({state:e,dispatch:t})=>sJ(e,t),mergeCells:()=>({state:e,dispatch:t})=>Zq(e,t),splitCell:()=>({state:e,dispatch:t})=>Qq(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>rJ(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>rJ(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>iJ(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>Zq(e,t)?!0:Qq(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>eJ(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>oJ(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>oJ(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&Fq(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=Dq.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:$J,"Mod-Backspace":$J,Delete:$J,"Mod-Delete":$J}},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})]:[],WJ({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){return{tableRole:DB(bB(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),tY=sU.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):null}}}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`}]},renderHTML({HTMLAttributes:e}){return[`td`,wB(this.options.HTMLAttributes,e),0]}}),nY=sU.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):null}}}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`}]},renderHTML({HTMLAttributes:e}){return[`th`,wB(this.options.HTMLAttributes,e),0]}}),rY=sU.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,wB(this.options.HTMLAttributes,e),0]}}),iY=GB.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),aY=/^\s*>\s$/,oY=sU.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return[`blockquote`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[oU({find:aY,type:this.type})]}}),sY=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,cY=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,lY=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,uY=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,dY=GB.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return[`strong`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[rU({find:sY,type:this.type}),rU({find:lY,type:this.type})]},addPasteRules(){return[cU({find:cY,type:this.type}),cU({find:uY,type:this.type})]}}),fY=`listItem`,pY=`textStyle`,mY=/^\s*([-+*])\s$/,hY=sU.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(fY,this.editor.getAttributes(pY)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=oU({find:mY,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=oU({find:mY,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(pY),editor:this.editor})),[e]}}),gY=/(^|[^`])`([^`]+)`(?!`)/,_Y=/(^|[^`])`([^`]+)`(?!`)/g,vY=GB.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[rU({find:gY,type:this.type})]},addPasteRules(){return[cU({find:_Y,type:this.type})]}}),yY=/^```([a-z]+)?[\s\n]$/,bY=/^~~~([a-z]+)?[\s\n]$/,xY=sU.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,wB(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
209
|
-
|
|
210
|
-
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(zp.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[aU({find:yY,type:this.type,getAttributes:e=>({language:e[1]})}),aU({find:bY,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new sm({key:new um(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
|
|
211
|
-
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(Up.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),SY=sU.create({name:`doc`,topNode:!0,content:`block+`});function CY(e={}){return new sm({view(t){return new wY(t,e)}})}var wY=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=vp(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},TY=tV.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[CY(this.options)]}}),EY=class e extends zp{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):zp.near(r)}content(){return Q.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new DY(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!kY(e)||!AY(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Gp.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};EY.prototype.visible=!1,EY.findFrom=EY.findGapCursorFrom,zp.jsonID(`gapcursor`,EY);var DY=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return EY.valid(t)?new EY(t):zp.near(t)}};function OY(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function kY(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||OY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function AY(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||OY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function jY(){return new sm({props:{decorations:IY,createSelectionBetween(e,t,n){return t.pos==n.pos&&EY.valid(n)?new EY(n):null},handleClick:PY,handleKeyDown:MY,handleDOMEvents:{beforeinput:FY}}})}var MY=Ez({ArrowLeft:NY(`horiz`,-1),ArrowRight:NY(`horiz`,1),ArrowUp:NY(`vert`,-1),ArrowDown:NY(`vert`,1)});function NY(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof Up){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=EY.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new EY(c))),!0):!1}}function PY(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!EY.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Gp.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new EY(r))),!0)}function FY(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof EY))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=Z.empty;for(let e=r.length-1;e>=0;e--)i=Z.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Q(i,0,0));return a.setSelection(Up.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function IY(e){if(!(e.selection instanceof EY))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,TR.create(e.doc,[SR.widget(e.selection.head,t,{key:`gapcursor`})])}var LY=tV.create({name:`gapCursor`,addProseMirrorPlugins(){return[jY()]},extendNodeSchema(e){return{allowGapCursor:DB(bB(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),RY=sU.create({name:`hardBreak`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,wB(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
212
|
-
`},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),zY=sU.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,wB(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>aU({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),BY=200,VY=function(){};VY.prototype.append=function(e){return e.length?(e=VY.from(e),!this.length&&e||e.length<BY&&this.leafAppend(e)||this.length<BY&&e.leafPrepend(this)||this.appendInner(e)):this},VY.prototype.prepend=function(e){return e.length?VY.from(e).append(this):this},VY.prototype.appendInner=function(e){return new UY(this,e)},VY.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?VY.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},VY.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},VY.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},VY.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},VY.from=function(e){return e instanceof VY?e:e&&e.length?new HY(e):VY.empty};var HY=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=BY)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=BY)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(VY);VY.empty=new HY([]);var UY=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(VY),WY=500,GY=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new qY(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new qY(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new qY(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>YY&&(s=KY(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new If;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new qY(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new qY(i,o,l))}else r.push(new qY(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new qY(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>WY&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new qY(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(VY.from(i.reverse()),a)}};GY.empty=new GY(VY.empty,0);function KY(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var qY=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},JY=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},YY=20;function XY(e,t,n,r){let i=n.getMeta(iX),a;if(i)return i.historyState;n.getMeta(aX)&&(e=new JY(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(iX))return o.getMeta(iX).redo?new JY(e.done.addTransform(n,void 0,r,rX(t)),e.undone,QY(n.mapping.maps),e.prevTime,e.prevComposition):new JY(e.done,e.undone.addTransform(n,void 0,r,rX(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!ZY(n,e.prevRanges)),s=o?$Y(e.prevRanges,n.mapping):QY(n.mapping.maps);return new JY(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,rX(t)),GY.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new JY(e.done.rebased(n,a),e.undone.rebased(n,a),$Y(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new JY(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),$Y(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function ZY(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function QY(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function $Y(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function eX(e,t,n){let r=rX(t),i=iX.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new JY(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(iX,{redo:n,historyState:c})}var tX=!1,nX=null;function rX(e){let t=e.plugins;if(nX!=t){tX=!1,nX=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){tX=!0;break}}return tX}var iX=new um(`history`),aX=new um(`closeHistory`);function oX(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new sm({key:iX,state:{init(){return new JY(GY.empty,GY.empty,null,0,-1)},apply(t,n,r){return XY(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?cX:n==`historyRedo`?lX:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function sX(e,t){return(n,r)=>{let i=iX.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=eX(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var cX=sX(!1,!0),lX=sX(!0,!0),uX=tV.create({name:`history`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>cX(e,t),redo:()=>({state:e,dispatch:t})=>lX(e,t)}},addProseMirrorPlugins(){return[oX(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()}}}),dX=sU.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{}}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,wB(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!lU(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$from:r,$to:i}=n,a=e();return r.parentOffset===0?a.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):jH(n)?a.insertContentAt(i.pos,{type:this.name}):a.insertContent({type:this.name}),a.command(({tr:e,dispatch:t})=>{if(t){let{$to:t}=e.selection,n=t.end();if(t.nodeAfter)t.nodeAfter.isTextblock?e.setSelection(Up.create(e.doc,t.pos+1)):t.nodeAfter.isBlock?e.setSelection(Gp.create(e.doc,t.pos)):e.setSelection(Up.create(e.doc,t.pos));else{let r=t.parent.type.contentMatch.defaultType?.create();r&&(e.insert(n,r),e.setSelection(Up.create(e.doc,n+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[iU({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),fX=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,pX=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,mX=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,hX=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,gX=GB.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[rU({find:fX,type:this.type}),rU({find:mX,type:this.type})]},addPasteRules(){return[cU({find:pX,type:this.type}),cU({find:hX,type:this.type})]}}),_X=sU.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,wB(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),vX=`listItem`,yX=`textStyle`,bX=/^(\d+)\.\s$/,xX=sU.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>e.getAttribute(`type`)}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return t===1?[`ol`,wB(this.options.HTMLAttributes,n),0]:[`ol`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(vX,this.editor.getAttributes(yX)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=oU({find:bX,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=oU({find:bX,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(yX)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),SX=sU.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),CX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,wX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,TX=GB.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,wB(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[rU({find:CX,type:this.type})]},addPasteRules(){return[cU({find:wX,type:this.type})]}}),EX=sU.create({name:`text`,group:`inline`}),DX=tV.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(dY.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(oY.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(hY.configure(this.options.bulletList)),this.options.code!==!1&&e.push(vY.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(xY.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(SY.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(TY.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(LY.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(RY.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(zY.configure(this.options.heading)),this.options.history!==!1&&e.push(uX.configure(this.options.history)),this.options.horizontalRule!==!1&&e.push(dX.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(gX.configure(this.options.italic)),this.options.listItem!==!1&&e.push(_X.configure(this.options.listItem)),this.options.orderedList!==!1&&e.push(xX.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(SX.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(TX.configure(this.options.strike)),this.options.text!==!1&&e.push(EX.configure(this.options.text)),e}}),OX=GB.create({name:`footnote-ref`,inclusive:!1,addAttributes(){return{id:{default:null,parseHTML:()=>null,renderHTML:e=>e.id==null?{}:{"data-footnote-id":String(e.id)}},kind:{default:`footnote`,parseHTML:()=>null,renderHTML:()=>({})}}},parseHTML(){return[]},renderHTML({HTMLAttributes:e}){return[`sup`,wB({class:`tandem-footnote-ref`},e),0]}}),kX=new um(`listItemCheckbox`),AX=/^\[([ xX])\]\s$/,jX=_X.extend({addAttributes(){return{...this.parent?.(),checked:{default:null,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===`true`?!0:t===`false`?!1:null},renderHTML:e=>e.checked===null||e.checked===void 0?{}:{"data-checked":String(e.checked)}}}},addInputRules(){let e=this.type;return[new RB({find:AX,handler:({state:t,range:n,match:r})=>{let i=r[1]!==` `,a=t.doc.resolve(n.from),o=-1,s={};for(let t=a.depth;t>0;t--){let n=a.node(t);if(n.type===e){o=a.before(t),s=n.attrs;break}}if(o<0)return null;let c=t.tr;c.delete(n.from,n.to),c.setNodeMarkup(o,void 0,{...s,checked:i})}})]},addProseMirrorPlugins(){let e=this.type;return[...this.parent?.()??[],new sm({key:kX,props:{decorations:t=>{let n=[];return t.doc.descendants((t,r)=>{if(t.type!==e||t.attrs.checked===null||t.attrs.checked===void 0)return;let i=t.attrs.checked===!0;n.push(SR.widget(r+1,(t,n)=>MX(t,n,i,e),{side:-1,key:`tandem-checkbox-${r}:${i}`,stopEvent:()=>!0,ignoreSelection:!0}))}),TR.create(t.doc,n)}}})]}});function MX(e,t,n,r){let i=document.createElement(`label`);i.className=`tandem-list-checkbox`,i.contentEditable=`false`;let a=document.createElement(`input`);return a.type=`checkbox`,a.checked=n,a.setAttribute(`aria-label`,n?`Checked task`:`Unchecked task`),a.addEventListener(`mousedown`,e=>e.preventDefault()),a.addEventListener(`change`,()=>{if(!e.editable){a.checked=n;return}let i=t();if(i==null)return;let o=i-1,s=e.state.doc.resolve(o).nodeAfter;!s||s.type!==r||e.dispatch(e.state.tr.setNodeMarkup(o,void 0,{...s.attrs,checked:!s.attrs.checked}))}),i.appendChild(a),i}var NX=tV.create({name:`markdownHtml`,addGlobalAttributes(){return[{types:[`paragraph`],attributes:{markdownHtml:{default:null,parseHTML:()=>null,renderHTML:()=>({})},markdownRaw:{default:null,parseHTML:()=>null,renderHTML:e=>e.markdownRaw?{"data-markdown-raw":``}:{}}}}]}}),PX=GB.create({name:`rawMarkdown`,parseHTML(){return[]},renderHTML(){return[`span`,{class:`tandem-raw-md`},0]}}),FX=nq.extend({renderHTML(e){let t=this.parent?.(e)??[`a`,wB(this.options.HTMLAttributes,e.HTMLAttributes),0];if(Array.isArray(t)&&t.length>=2&&t[1]&&typeof t[1]==`object`){let e=t[1],n=e.href;typeof n==`string`&&n.length>0&&e.title==null&&(t[1]={...e,title:n})}return t}});function IX(){return[DX.configure({history:!1,listItem:!1}),jX,iY,aq,iq,OX,zW.configure({multicolor:!0}),FX.configure({openOnClick:!1,HTMLAttributes:{rel:`noopener noreferrer`,target:`_blank`}}),VW.configure({allowBase64:!0}),rq.configure({placeholder:`Start typing…`}),eY.configure({resizable:!0}),rY,tY,nY,NX,PX]}var LX=new um(`tandemAnnotations`),RX={comment:!0,highlight:!0,note:!0};function zX(){try{let e=localStorage.getItem(ro);if(!e)return{...RX};let t=JSON.parse(e);return{comment:t.comment!==!1,highlight:t.highlight!==!1,note:t.note!==!1}}catch(e){return console.warn(`[annotation] localStorage unavailable`,e),{...RX}}}function BX(){return KE(Nl(),`family`)}function VX(e){return e===`highlight`?`highlight`:e===`note`||e===`flag`?`note`:`comment`}function HX(e,t,n,r,i){let a=[],o=e.content.size;return t.forEach(t=>{let s=qO(t,e=>{console.warn(`[sanitize]`,e)});if(s.status!==`pending`||!r[s.type]||!s.range&&!s.relRange)return;let c=iD(s,e,n);if(!c)return;s.relRange&&c.method===`flat`&&console.warn(`[annotation] relRange-equipped annotation %s fell back to flat offsets`,s.id);let{from:l,to:u}=c;if(l>=u||l<0||u>o)return;let d={};switch(s.type){case`highlight`:{let e=Aa(s.color),t=ka[e];d={class:`tandem-highlight tandem-highlight--${e}`,style:`background: ${t}; border-radius: var(--tandem-r-1); padding: 1px 0;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Highlight annotation (${e})`};break}case`comment`:d=s.suggestedText===void 0?s.author===`claude`?{class:`tandem-comment tandem-comment--claude`,style:`border-bottom: 2px solid var(--tandem-author-claude); padding-bottom: 1px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`${i} comment annotation`}:{class:`tandem-comment`,style:`border-bottom: 2px dashed var(--tandem-author-user); padding-bottom: 1px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Comment annotation`}:{class:`tandem-suggestion`,style:`background: var(--tandem-suggestion-bg); text-decoration: underline wavy var(--tandem-suggestion); text-underline-offset: 3px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Replacement annotation`};break;case`note`:d={class:`tandem-note`,style:`border-bottom: 2px dotted var(--tandem-fg-muted); padding-bottom: 1px;`,"data-annotation-id":s.id,"data-annotation-type":s.type,"data-annotation-author":s.author,"aria-label":`Note annotation`};break;default:console.warn(`[annotation] Unhandled annotation type in buildDecorations, skipping`);return}try{a.push(SR.inline(l,u,d))}catch(e){if(!(e instanceof RangeError))throw e;console.debug(`[annotation] RangeError for %s (from=%d, to=%d), skipping`,s.id,l,u)}}),TR.create(e,a)}var UX=tV.create({name:`tandemAnnotations`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Ra),n=zX(),r=BX();function i(){for(let e of t.values()){let t=e;if(t&&t.status===`pending`&&n[VX(t.type)])return!0}return!1}let a=i(),o=!1;return[new sm({key:LX,state:{init(i,o){return a?HX(o.doc,t,e,n,r):TR.empty},apply(s,c,l,u){let d=s.getMeta(LX);if(d&&typeof d==`object`&&d.type===`toggle-decorations`&&(n=d.visible,a=i(),o=!1),d)return r=BX(),a?HX(u.doc,t,e,n,r):TR.empty;if(!a)return TR.empty;if(s.docChanged){if(!o&&c===TR.empty&&a){let i=HX(u.doc,t,e,n,r);return i!==TR.empty&&(o=!0),i}return c.map(s.mapping,s.doc)}return c}},props:{decorations(e){return LX.getState(e)}},view(e){let n=null,r=!1;function s(){n===null&&(n=requestAnimationFrame(()=>{n=null,r=!0;let t=e.state.tr.setMeta(LX,!0);e.dispatch(t)}))}let c=()=>{a=i(),o=!1,s()};t.observe(c);let l=setTimeout(()=>{!r&&n===null&&t.size>0&&c()},500);return{destroy(){clearTimeout(l),n!==null&&cancelAnimationFrame(n),t.unobserve(c)}}}})]}}),WX=new um(`tandemAnnotationPing`),GX=700,KX=500,qX=`tandem-annotation-ping`;function JX(e,t){return!(!t.isLive||t.alreadySeen||!e||e.status!==`pending`||!t.visible[VX(e.type)])}function YX(){try{if(Nl().reduceMotion)return!0}catch{}return typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var XX=tV.create({name:`tandemAnnotationPing`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(Ra),n=new Set,r=!1;return[new sm({key:WX,state:{init:()=>TR.empty,apply(e,t){let n=t.map(e.mapping,e.doc),r=e.getMeta(WX);if(r?.type===`add`)n=n.add(e.doc,[r.deco]);else if(r?.type===`remove`){let e=n.find(void 0,void 0,e=>e.pingId===r.id);e.length&&(n=n.remove(e))}return n}},props:{decorations(e){return WX.getState(e)}},view(i){let a=new Map,o=!1;function s(t,n){if(YX())return;let r=iD(n,i.state.doc,e);if(r)try{let e=i.state.doc.resolve(r.from),n=e.depth;if(n<1)return;let s=e.before(n),c=e.after(n),l=SR.node(s,c,{class:qX},{pingId:t});i.dispatch(i.state.tr.setMeta(WX,{type:`add`,deco:l}));let u=setTimeout(()=>{a.delete(t),!o&&i.dispatch(i.state.tr.setMeta(WX,{type:`remove`,id:t}))},GX);a.set(t,u)}catch(e){if(!(e instanceof RangeError))throw e}}let c,l=()=>{for(let e of t.keys())n.add(e);r=!0},u=()=>{clearTimeout(c),c=setTimeout(l,KX)},d=e=>{r||u();let i=zX();for(let a of e.keysChanged){let e=t.get(a),o=JX(e,{isLive:r,alreadySeen:n.has(a),visible:i});n.add(a),o&&e&&s(a,e)}};return t.observe(d),u(),{destroy(){o=!0,clearTimeout(c);for(let e of a.values())clearTimeout(e);a.clear(),t.unobserve(d)}}}})]}}),ZX=new um(`tandemAuthorship`),QX=new Set([`paragraph`,`heading`]);function $X(e,t,n){if(e.relRange){let r=rD(n,t,e.relRange);if(r&&r.from<r.to)return r}if(e.range){console.warn(`[authorship] Falling back to flat offsets for range`,e.id);let n=QE(t,e.range.from),r=QE(t,e.range.to);if(n<r)return{from:n,to:r}}return null}function eZ(e,t,n,r){if(!r)return TR.empty;let i=[],a=e.content.size,o=[];return t.forEach(t=>{let r=t;if(!r.author||!r.range||r.author!==`user`&&r.author!==`claude`)return;let s=$X(r,e,n);if(!s)return;let{from:c,to:l}=s;if(!(c>=l||c<0||l>a)){try{i.push(SR.inline(c,l,{"data-tandem-author":r.author}))}catch(e){if(!(e instanceof RangeError))throw e;console.warn(`[authorship] Decoration RangeError for entry`,r.id,e)}o.push({author:r.author,from:c,to:l})}}),e.descendants((e,t)=>{if(!QX.has(e.type.name))return;let n=t,r=t+e.nodeSize,a=0,s=0;for(let e of o){let t=Math.max(e.from,n),i=Math.min(e.to,r);if(i<=t)continue;let o=i-t;e.author===`user`?a+=o:s+=o}if(a===0&&s===0||e.content.size===0)return;let c=a>=s?`user`:`claude`;try{i.push(SR.node(n,r,{"data-tandem-author-block":c}))}catch(e){if(!(e instanceof RangeError))throw e;console.warn(`[authorship] node Decoration RangeError at offset`,t,e)}}),TR.create(e,i)}var tZ=tV.create({name:`tandemAuthorship`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(qa),n=!1;try{n=localStorage.getItem(no)===`true`}catch(e){console.warn(`[authorship] localStorage unavailable`,e)}return[new sm({key:ZX,state:{init(r,i){return{visible:n,decorations:eZ(i.doc,t,e,n)}},apply(n,r,i,a){let o=n.getMeta(ZX);if(o?.type===`toggle`){let n=o.visible;return{visible:n,decorations:eZ(a.doc,t,e,n)}}return o?.type===`rebuild`?{visible:r.visible,decorations:eZ(a.doc,t,e,r.visible)}:n.docChanged&&r.visible?{visible:r.visible,decorations:r.decorations.map(n.mapping,n.doc)}:r}},props:{decorations(e){return ZX.getState(e)?.decorations??TR.empty}},view(e){let n=()=>{let t=e.state.tr.setMeta(ZX,{type:`rebuild`});e.dispatch(t)};t.observe(n);let r=setTimeout(()=>{t.size>0&&n()},500);return{destroy(){clearTimeout(r),t.unobserve(n)}}}})]},onTransaction({transaction:e}){let t=this.options.ydoc;if(!t||e.getMeta(`y-sync$`)||e.getMeta(ZX)||!e.docChanged)return;let n=t.getMap(qa),r=e.doc;e.steps.forEach(e=>{e.getMap().forEach((e,t,i,a)=>{if(a-i-(t-e)>0)try{let e=eD(r,Co(i)),t=eD(r,Co(a));if(t<=e)return;let o=fc(`user`),s={id:o,author:`user`,range:{from:e,to:t},timestamp:Date.now()};n.set(o,s)}catch(e){console.warn(`[authorship] Position conversion failed during user attribution`,e)}})})}}),nZ=new um(`tandemAwareness`);function rZ(e,t){if(!t)return TR.empty;let n=[],{focusParagraph:r,focusOffset:i,active:a}=t;if(r!==null&&r>=0){let t=0;e.forEach((e,i)=>{t===r&&n.push(SR.node(i,i+e.nodeSize,{class:`tandem-claude-focus`,style:`background: var(--tandem-claude-focus-bg); border-left: 3px solid var(--tandem-claude-focus-border); padding-left: 8px; transition: background 0.3s ease, border-color 0.3s ease;`})),t++})}if(i!==null&&i>=0)try{let t=QE(e,So(i)),r=a===!1?` tandem-claude-cursor-idle`:``;n.push(SR.widget(t,()=>{let e=document.createElement(`span`);e.className=`tandem-claude-cursor${r}`,e.setAttribute(`aria-hidden`,`true`);let t=document.createElement(`span`);return t.className=`tandem-claude-cursor-label`,t.textContent=`AI`,e.appendChild(t),e}))}catch(e){console.warn(`[awareness] cursor decoration failed, falling back to gutter-only:`,e)}return n.length===0?TR.empty:TR.create(e,n)}var iZ=tV.create({name:`tandemAwareness`,addOptions(){return{ydoc:null}},addProseMirrorPlugins(){let e=this.options.ydoc;if(!e)return[];let t=e.getMap(za),n=e.getMap(Ba);return[new sm({key:nZ,state:{init(e,n){let r=t.get(Xa);return rZ(n.doc,r??null)},apply(e,n,r,i){if(e.getMeta(nZ)){let e=t.get(Xa);return rZ(i.doc,e??null)}return e.docChanged?n.map(e.mapping,e.doc):n}},props:{decorations(e){return nZ.getState(e)}},view(e){let n=()=>{let t=e.state.tr.setMeta(nZ,!0);e.dispatch(t)};return t.observe(n),{destroy(){t.unobserve(n)}}}}),new sm({key:new um(`tandemUserAwareness`),view(){let e=null,t=null,r=null,i=!1,a=-1;return{update(o,s){let{state:c}=o;if(!c.selection.eq(s.selection)){let e=aD(c.doc,{from:Co(c.selection.from),to:Co(c.selection.to)});if(c.selection.from===c.selection.to)r&&=(clearTimeout(r),null),n.set(Ja,{...e,timestamp:Date.now()});else{let t=c.doc.textBetween(c.selection.from,c.selection.to,`
|
|
213
|
-
`),i=t.length>200?t.slice(0,197)+`...`:t;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n.set(Ja,{...e,selectedText:i,timestamp:Date.now()})},150)}}c.doc!==s.doc&&(a=c.selection.from,i=!0,t||=setTimeout(()=>{t=null,i&&n.set(Ya,{isTyping:!0,cursor:a,lastEdit:Date.now()})},200),e&&clearTimeout(e),e=setTimeout(()=>{i=!1,n.set(Ya,{isTyping:!1,cursor:o.state.selection.from,lastEdit:Date.now()})},Ta))},destroy(){e&&clearTimeout(e),t&&clearTimeout(t),r&&clearTimeout(r)}}}})]}}),aZ=new um(`tandemFindReplace`),oZ={query:``,caseSensitive:!1,wholeWord:!1,regexMode:!1,matches:[],activeIndex:-1,decoSet:TR.empty};function sZ(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function cZ(e){if(!e.query)return null;try{let t=e.regexMode?e.query:sZ(e.query),n=e.caseSensitive?`g`:`gi`,r=e.wholeWord?`\\b${t}\\b`:t;return new RegExp(r,n)}catch{return null}}function lZ(e,t){let n=cZ(t);if(!n)return[];let r=[];return e.descendants((e,t)=>{if(!e.isTextblock)return;let i=e.textContent;for(let e of i.matchAll(n)){let n=e.index??0;r.push({from:t+1+n,to:t+1+n+e[0].length})}}),r}function uZ(e,t,n){if(t.length===0)return TR.empty;let r=[];for(let e=0;e<t.length;e++){let{from:i,to:a}=t[e];try{r.push(SR.inline(i,a,{class:e===n?`tandem-find-active`:`tandem-find-match`}))}catch{}}return TR.create(e,r)}function dZ(e,t){if(e.length===0)return-1;for(let n=0;n<e.length;n++)if(e[n].from<=t&&t<=e[n].to)return n;for(let n=0;n<e.length;n++)if(e[n].from>t)return n;return 0}function fZ(e,t,n){if(e.type===`close`)return oZ;if(e.type===`find`){let t=e.opts,r=lZ(n.doc,t),i=n.selection.from,a=dZ(r,i);return{...t,matches:r,activeIndex:a,decoSet:uZ(n.doc,r,a)}}if(e.type===`next`){let e=t.matches.length===0?-1:(t.activeIndex+1)%t.matches.length;return{...t,activeIndex:e,decoSet:uZ(n.doc,t.matches,e)}}if(e.type===`prev`){let e=t.matches.length===0?-1:(t.activeIndex-1+t.matches.length)%t.matches.length;return{...t,activeIndex:e,decoSet:uZ(n.doc,t.matches,e)}}return e}var pZ=tV.create({name:`tandemFindReplace`,addProseMirrorPlugins(){return[new sm({key:aZ,state:{init:()=>oZ,apply(e,t,n,r){let i=e.getMeta(aZ);if(i)return fZ(i,t,r);if(!t.query)return t;if(e.docChanged){let e=lZ(r.doc,t),n=r.selection.from,i=dZ(e,n);return{...t,matches:e,activeIndex:i,decoSet:uZ(r.doc,e,i)}}let a=r.selection.from,o=dZ(t.matches,a);return o===t.activeIndex?t:{...t,activeIndex:o,decoSet:uZ(r.doc,t.matches,o)}}},props:{decorations(e){return aZ.getState(e)?.decoSet??TR.empty}}})]},addCommands(){return{find:e=>({dispatch:t,tr:n})=>(t&&t(n.setMeta(aZ,{type:`find`,opts:e})),!0),findNext:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(aZ,{type:`next`})),!0),findPrev:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(aZ,{type:`prev`})),!0),findClose:()=>({dispatch:e,tr:t})=>(e&&e(t.setMeta(aZ,{type:`close`})),!0)}},addKeyboardShortcuts(){return{Escape:({editor:e})=>aZ.getState(e.state)?.query?(e.commands.findClose(),!0):!1}}});function mZ(e){return aZ.getState(e)}function hZ(e,t){let n=mZ(e.state);if(!n||n.activeIndex<0||n.matches.length===0)return!1;let{from:r,to:i}=n.matches[n.activeIndex],a=e.state.tr.insertText(t,r,i).setMeta(aZ,{type:`next`});return e.dispatch(a),!0}async function gZ(e,t,n){let r=0,i=!1;for(let a=0;a<50;a++){let o=mZ(e.state);if(!o?.query||o.matches.length===0)break;let s=o.matches.slice(0,100);try{let i=e.state.tr;for(let e=s.length-1;e>=0;e--){let{from:n,to:r}=s[e];i=i.insertText(t,n,r)}e.dispatch(i),r+=s.length,n?.(r,r+(o.matches.length-s.length))}catch(e){i=!0,console.warn(`[find-replace] replaceAll chunk failed at pass`,a,e);break}if(s.length<100)break;await new Promise(e=>setTimeout(e,0))}return{replaced:r,partial:i}}var _Z=new um(`tandemHeadingCollapse`),vZ=`tandem:headingCollapse:`;function yZ(e){return!e||e.startsWith(`upload://`)?null:vZ+e}function bZ(e){let t=yZ(e);if(!t)return new Set;try{let e=window.localStorage.getItem(t);if(!e)return new Set;let n=JSON.parse(e);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function xZ(e,t){let n=yZ(e);if(n)try{t.size===0?window.localStorage.removeItem(n):window.localStorage.setItem(n,JSON.stringify(Array.from(t)))}catch{}}function SZ(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function CZ(e){let t=[],n=new Map;return e.descendants((r,i,a)=>{if(r.type.name!==`heading`)return!0;if(a!==e)return!1;let o=r.attrs.level??1,s=`${o}::${SZ(r.textContent)}`,c=n.get(s)??0;n.set(s,c+1);let l=`${s}::${c}`;return t.push({pos:i,level:o,hash:l}),!1}),t}function wZ(e,t,n,r){if(n.size===0)return n;let i=new Set(t.map(e=>e.hash));if(e.length===t.length){let i=[];for(let n=0;n<e.length;n++)e[n].hash!==t[n].hash&&i.push(n);if(i.length!==1)return n;let a=i[0],o=e[a].hash,s=t[a].hash;if(!n.has(o))return n;let c=new Set(n);return c.delete(o),c.add(s),xZ(r,c),c}if(t.length>e.length||t.length===0)return n;let a=!1,o=new Set;for(let e of n)i.has(e)?o.add(e):a=!0;return a?(xZ(r,o),o):n}function TZ(e,t,n){return SR.widget(e+1,e=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`tandem-heading-chevron`,r.dataset.testid=`heading-chevron`,r.dataset.headingHash=t,r.dataset.collapsed=String(n),r.setAttribute(`aria-label`,n?`Expand section`:`Collapse section`),r.setAttribute(`aria-expanded`,String(!n)),r.contentEditable=`false`,r.textContent=n?`▶`:`▼`,r.addEventListener(`mousedown`,e=>{e.preventDefault()}),r.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault();let r=e.state.tr.setMeta(_Z,{type:`toggle`,hash:t});e.dispatch(r)}),r},{side:-1,ignoreSelection:!0,stopEvent:()=>!0,key:`chevron:${t}:${n?`c`:`e`}`})}function EZ(e,t,n){let r=t[n],i=e.content.size;for(let e=n+1;e<t.length;e++)if(t[e].level<=r.level){i=t[e].pos;break}let a=[];return e.forEach((e,t)=>{if(t>r.pos&&t<i){let n=t,r=t+e.nodeSize;a.push(SR.node(n,r,{class:`tandem-heading-collapsed-hidden`,style:`display: none;`}))}}),a}function DZ(e,t,n){let r=[];for(let i=0;i<t.length;i++){let a=t[i],o=n.has(a.hash);try{r.push(TZ(a.pos,a.hash,o)),o&&r.push(...EZ(e,t,i))}catch{}}return r.length===0?TR.empty:TR.create(e,r)}var OZ=tV.create({name:`tandemHeadingCollapse`,addOptions(){return{filePath:null}},addProseMirrorPlugins(){let e=this.options.filePath;return[new sm({key:_Z,state:{init(t,n){let r=bZ(e),i=CZ(n.doc);return{collapsed:r,headings:i,decoSet:DZ(n.doc,i,r),hasSeenContent:i.length>0}},apply(t,n,r,i){let a=t.getMeta(_Z);if(a?.type===`toggle`){let t=new Set(n.collapsed);return t.has(a.hash)?t.delete(a.hash):t.add(a.hash),xZ(e,t),{collapsed:t,headings:n.headings,decoSet:DZ(i.doc,n.headings,t),hasSeenContent:n.hasSeenContent}}if(a?.type===`rehydrate`){let t=CZ(i.doc),n=bZ(e),r=new Set(t.map(e=>e.hash)),a=new Set;for(let e of n)r.has(e)&&a.add(e);return a.size!==n.size&&xZ(e,a),{collapsed:a,headings:t,decoSet:DZ(i.doc,t,a),hasSeenContent:!0}}if(!t.docChanged)return n;let o=CZ(i.doc),s=n.hasSeenContent||o.length>0,c=n.collapsed;return n.hasSeenContent&&(c=wZ(n.headings,o,n.collapsed,e)),{collapsed:c,headings:o,decoSet:DZ(i.doc,o,c),hasSeenContent:s}}},view(e){let t=!1,n=null;function r(){t||n!==null||(n=requestAnimationFrame(()=>{if(n=null,t)return;let r=_Z.getState(e.state);if(!r||r.headings.length===0)return;t=!0;let i=e.state.tr.setMeta(_Z,{type:`rehydrate`}).setMeta(`addToHistory`,!1);e.dispatch(i)}))}return r(),{update(e){if(t)return;let n=_Z.getState(e.state);!n||n.headings.length===0||r()},destroy(){n!==null&&cancelAnimationFrame(n)}}},props:{decorations(e){return _Z.getState(e)?.decoSet??TR.empty}}})]}}),kZ=new um(`tandemSelectionDecoration`),AZ=tV.create({name:`tandemSelectionDecoration`,addProseMirrorPlugins(){return[new sm({key:kZ,props:{decorations(e){let{selection:t}=e;if(!(t instanceof Up))return TR.empty;let{from:n,to:r}=t;return n===r?TR.empty:TR.create(e.doc,[SR.inline(n,r,{class:`tandem-selection-blurred`})])}}})]}});function jZ(e){return e.chain().focus()}var MZ={tag:`path`,attrs:{d:`M6 4.5h7M6 8h7M6 11.5h7`}},NZ=[{id:`heading-1`,label:`Heading 1`,keywords:[`h1`,`heading`,`title`],hint:`h1`,icon:{kind:`glyph`,glyph:`H¹`},run:e=>jZ(e).toggleHeading({level:1}).run()},{id:`heading-2`,label:`Heading 2`,keywords:[`h2`,`heading`,`subtitle`],hint:`h2`,icon:{kind:`glyph`,glyph:`H²`},run:e=>jZ(e).toggleHeading({level:2}).run()},{id:`heading-3`,label:`Heading 3`,keywords:[`h3`,`heading`,`subheading`],hint:`h3`,icon:{kind:`glyph`,glyph:`H³`},run:e=>jZ(e).toggleHeading({level:3}).run()},{id:`bullet-list`,label:`Bullet list`,keywords:[`bullet`,`ul`,`list`],hint:`ul`,icon:{kind:`svg`,els:[{tag:`circle`,attrs:{cx:`3`,cy:`4.5`,r:`0.7`,fill:`currentColor`,stroke:`none`}},{tag:`circle`,attrs:{cx:`3`,cy:`8`,r:`0.7`,fill:`currentColor`,stroke:`none`}},{tag:`circle`,attrs:{cx:`3`,cy:`11.5`,r:`0.7`,fill:`currentColor`,stroke:`none`}},MZ]},run:e=>jZ(e).toggleBulletList().run()},{id:`numbered-list`,label:`Numbered list`,keywords:[`numbered`,`ordered`,`ol`,`list`],hint:`ol`,icon:{kind:`svg`,els:[{tag:`path`,attrs:{d:`M2 3.5h1V6M2 6h2M2 9.5c0-.5.5-1 1-1s1 .5 1 1c0 1-2 1.3-2 2.5h2`}},MZ]},run:e=>jZ(e).toggleOrderedList().run()},{id:`task-list`,label:`Task list`,keywords:[`task`,`todo`,`checkbox`,`check`,`checklist`],hint:`todo`,icon:{kind:`svg`,els:[{tag:`path`,attrs:{d:`M3 3h10v10H3z`}},{tag:`path`,attrs:{d:`M5.5 8l2 2 3.5-4`}}]},run:e=>jZ(e).toggleBulletList().updateAttributes(`listItem`,{checked:!1}).run()},{id:`quote`,label:`Quote`,keywords:[`blockquote`,`quote`],hint:`q`,icon:{kind:`svg`,els:[{tag:`path`,attrs:{d:`M3 6c0-1.5 1-2.5 2-2.5`}},{tag:`path`,attrs:{d:`M3 6v3h3V6z`}},{tag:`path`,attrs:{d:`M9 6c0-1.5 1-2.5 2-2.5`}},{tag:`path`,attrs:{d:`M9 6v3h3V6z`}}]},run:e=>jZ(e).toggleBlockquote().run()},{id:`code-block`,label:`Code block`,keywords:[`code`,`pre`,`snippet`],hint:`code`,icon:{kind:`svg`,els:[{tag:`path`,attrs:{d:`M5 4l-3 4 3 4`}},{tag:`path`,attrs:{d:`M11 4l3 4-3 4`}}]},run:e=>jZ(e).toggleCodeBlock().run()},{id:`horizontal-rule`,label:`Horizontal rule`,keywords:[`hr`,`divider`,`rule`,`separator`],hint:`hr`,icon:{kind:`glyph`,glyph:`—`},run:e=>jZ(e).setHorizontalRule().run()}];function PZ(e){let t=/(?:^|\s)\/([A-Za-z0-9 -]*)$/.exec(e);if(!t)return null;let n=t[1]??``;return{fromOffset:e.length-n.length-1,query:n}}function FZ(e){let t=e.trim().toLowerCase();return t?NZ.filter(e=>[e.label,...e.keywords].join(` `).toLowerCase().includes(t)):NZ}var IZ=[`popup-annotation-input`,`popup-note-submit`,`popup-comment-submit`,`popup-highlight-yellow`,`popup-highlight-green`,`popup-highlight-blue`,`popup-highlight-pink`];function LZ(e){let t=document.querySelector(`[data-testid="${e}"]`);return t?document.activeElement===t:!1}function RZ(e){for(let t of e)if(document.querySelector(`[data-testid="${t}"]`))return!0;return!1}function zZ(){return typeof document>`u`?!1:!!(LZ(`find-input`)||document.querySelector(`[data-testid="command-palette"]`)||RZ(IZ))}var BZ=`http://www.w3.org/2000/svg`,VZ=new um(`tandemSlashCommand`);function HZ(e){return`${e.from}:${e.to}:${e.query}`}function UZ(e){if(!e.docChanged||e.getMeta(`y-sync$`))return!1;let t=e.getMeta(`uiEvent`);if(t===`paste`||t===`drop`||e.getMeta(`paste`))return!1;let n=e.selection.from,r=!1;return e.mapping.maps.forEach((t,i)=>{t.forEach((t,a,o,s)=>{s<=o||e.mapping.slice(i+1).map(s,-1)===n&&(r=!0)})}),r}function WZ(e,t=0){if(zZ())return null;let{selection:n}=e;if(!n.empty)return null;let r=n.$from,i=PZ(r.parent.textBetween(0,r.parentOffset,`
|
|
214
|
-
`,`
|
|
215
|
-
`));if(!i)return null;let a=r.start()+i.fromOffset,o=r.pos,s=FZ(i.query);return s.length===0?null:{from:a,to:o,query:i.query,selectedIndex:Math.min(t,s.length-1)}}function GZ(e,t){let n=e.getMeta(VZ);return n?n.type===`close`?{active:null,dismissedKey:t.active?HZ(t.active):t.dismissedKey}:n.type===`select`&&t.active?{...t,active:{...t.active,selectedIndex:n.selectedIndex??t.active.selectedIndex}}:t:null}function KZ(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function qZ(){let e=document.createElement(`div`);e.className=`tandem-slash-menu__hint`;for(let[t,n]of[[`↑↓`,`navigate`],[`↵`,`insert`],[`esc`,`close`]]){let r=document.createElement(`span`),i=document.createElement(`kbd`);i.textContent=t,r.appendChild(i),r.appendChild(document.createTextNode(` ${n}`)),e.appendChild(r)}return e}function JZ(e){let t=document.createElement(`span`);if(t.className=`tandem-slash-menu__icon`,t.setAttribute(`aria-hidden`,`true`),e.kind===`glyph`)return t.textContent=e.glyph,t;let n=document.createElementNS(BZ,`svg`);n.setAttribute(`viewBox`,`0 0 16 16`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`1.6`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`);for(let t of e.els){let e=document.createElementNS(BZ,t.tag);for(let[n,r]of Object.entries(t.attrs))e.setAttribute(n,r);n.appendChild(e)}return t.appendChild(n),t}function YZ(e,t,n,r,i){let a=FZ(t.query);KZ(e),e.className=`tandem-floating-pill tandem-slash-menu`;let o=document.createElement(`div`);o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,`Slash commands`),a.forEach((e,n)=>{let a=document.createElement(`button`);a.type=`button`,a.role=`option`,a.id=`slash-command-${e.id}`,a.className=`tandem-slash-menu__item`,a.setAttribute(`aria-selected`,String(n===t.selectedIndex)),a.setAttribute(`aria-label`,e.label),a.dataset.commandId=e.id,a.appendChild(JZ(e.icon));let s=document.createElement(`span`);s.className=`tandem-slash-menu__label`,s.textContent=e.label,a.appendChild(s);let c=document.createElement(`span`);c.className=`tandem-slash-menu__shortcut`,c.setAttribute(`aria-hidden`,`true`),c.textContent=e.hint,a.appendChild(c),a.addEventListener(`mouseenter`,()=>r(n)),a.addEventListener(`mousedown`,t=>{t.preventDefault(),i(e)}),o.appendChild(a)}),e.appendChild(o),e.appendChild(qZ());let s=n.view.coordsAtPos(t.from);e.style.display=`block`,e.style.position=`fixed`,e.style.left=`${Math.max(8,s.left)}px`,e.style.top=`${s.bottom+8}px`}function XZ(e,t){let n=FZ(t.query)[t.selectedIndex];return n?(e.chain().focus().deleteRange({from:t.from,to:t.to}).run(),n.run(e),!0):!1}var ZZ=tV.create({name:`slashCommand`,addOptions(){return{onOpenChange:void 0}},addProseMirrorPlugins(){let e=this.editor,t=this.options.onOpenChange;return[new sm({key:VZ,state:{init:()=>({active:null,dismissedKey:null}),apply(e,t,n,r){let i=GZ(e,t);if(i)return i;let a=WZ(r,t.active?.selectedIndex??0);return a&&!t.active&&!UZ(e)||a&&HZ(a)===t.dismissedKey?{active:null,dismissedKey:t.dismissedKey}:{active:a,dismissedKey:a?null:t.dismissedKey}}},props:{handleKeyDown(t,n){let r=VZ.getState(t.state)?.active;if(!r)return!1;let i=FZ(r.query);if(n.key===`ArrowDown`){n.preventDefault();let e=(r.selectedIndex+1)%i.length;return t.dispatch(t.state.tr.setMeta(VZ,{type:`select`,selectedIndex:e})),!0}if(n.key===`ArrowUp`){n.preventDefault();let e=(r.selectedIndex-1+i.length)%i.length;return t.dispatch(t.state.tr.setMeta(VZ,{type:`select`,selectedIndex:e})),!0}return n.key===`Enter`?(n.preventDefault(),XZ(e,r)):n.key===`Escape`?(n.preventDefault(),t.dispatch(t.state.tr.setMeta(VZ,{type:`close`})),!0):!1}},view(n){let r=document.createElement(`div`);r.dataset.testid=`slash-command-menu`,r.style.display=`none`,document.body.appendChild(r);let i=!1,a=e=>{e!==i&&(i=e,t?.(e))},o=()=>{r.style.display=`none`,KZ(r),a(!1)},s=()=>{let t=VZ.getState(n.state)?.active;if(!t){o();return}YZ(r,t,e,e=>{n.dispatch(n.state.tr.setMeta(VZ,{type:`select`,selectedIndex:e}))},r=>{e.chain().focus().deleteRange({from:t.from,to:t.to}).run(),r.run(e),o(),n.dispatch(n.state.tr.setMeta(VZ,{type:`close`}))}),a(!0)};return s(),{update:s,destroy(){a(!1),r.remove()}}}})]}}),QZ={};function $Z(e){let t=QZ[e];if(t)return t;t=QZ[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);t.push(n)}for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[r]=`%`+(`0`+r.toString(16).toUpperCase()).slice(-2)}return t}function eQ(e,t){typeof t!=`string`&&(t=eQ.defaultChars);let n=$Z(t);return e.replace(/(%[a-f0-9]{2})+/gi,function(e){let t=``;for(let r=0,i=e.length;r<i;r+=3){let a=parseInt(e.slice(r+1,r+3),16);if(a<128){t+=n[a];continue}if((a&224)==192&&r+3<i){let n=parseInt(e.slice(r+4,r+6),16);if((n&192)==128){let e=a<<6&1984|n&63;e<128?t+=`��`:t+=String.fromCharCode(e),r+=3;continue}}if((a&240)==224&&r+6<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16);if((n&192)==128&&(i&192)==128){let e=a<<12&61440|n<<6&4032|i&63;e<2048||e>=55296&&e<=57343?t+=`���`:t+=String.fromCharCode(e),r+=6;continue}}if((a&248)==240&&r+9<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16),o=parseInt(e.slice(r+10,r+12),16);if((n&192)==128&&(i&192)==128&&(o&192)==128){let e=a<<18&1835008|n<<12&258048|i<<6&4032|o&63;e<65536||e>1114111?t+=`����`:(e-=65536,t+=String.fromCharCode(55296+(e>>10),56320+(e&1023))),r+=9;continue}}t+=`�`}return t})}eQ.defaultChars=`;/?:@&=+$,#`,eQ.componentChars=``;var tQ={};function nQ(e){let t=tQ[e];if(t)return t;t=tQ[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);/^[0-9a-z]$/i.test(n)?t.push(n):t.push(`%`+(`0`+e.toString(16).toUpperCase()).slice(-2))}for(let n=0;n<e.length;n++)t[e.charCodeAt(n)]=e[n];return t}function rQ(e,t,n){typeof t!=`string`&&(n=t,t=rQ.defaultChars),n===void 0&&(n=!0);let r=nQ(t),i=``;for(let t=0,a=e.length;t<a;t++){let o=e.charCodeAt(t);if(n&&o===37&&t+2<a&&/^[0-9a-f]{2}$/i.test(e.slice(t+1,t+3))){i+=e.slice(t,t+3),t+=2;continue}if(o<128){i+=r[o];continue}if(o>=55296&&o<=57343){if(o>=55296&&o<=56319&&t+1<a){let n=e.charCodeAt(t+1);if(n>=56320&&n<=57343){i+=encodeURIComponent(e[t]+e[t+1]),t++;continue}}i+=`%EF%BF%BD`;continue}i+=encodeURIComponent(e[t])}return i}rQ.defaultChars=`;/?:@&=+$,-_.!~*'()#`,rQ.componentChars=`-_.!~*'()`;function iQ(e){let t=``;return t+=e.protocol||``,t+=e.slashes?`//`:``,t+=e.auth?e.auth+`@`:``,e.hostname&&e.hostname.indexOf(`:`)!==-1?t+=`[`+e.hostname+`]`:t+=e.hostname||``,t+=e.port?`:`+e.port:``,t+=e.pathname||``,t+=e.search||``,t+=e.hash||``,t}function aQ(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var oQ=/^([a-z0-9.+-]+:)/i,sQ=/:[0-9]*$/,cQ=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,lQ=[`%`,`/`,`?`,`;`,`#`,`'`,`{`,`}`,`|`,`\\`,`^`,"`",`<`,`>`,`"`,"`",` `,`\r`,`
|
|
216
|
-
`,` `],uQ=[`/`,`?`,`#`],dQ=255,fQ=/^[+a-z0-9A-Z_-]{0,63}$/,pQ=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,mQ={javascript:!0,"javascript:":!0},hQ={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function gQ(e,t){if(e&&e instanceof aQ)return e;let n=new aQ;return n.parse(e,t),n}aQ.prototype.parse=function(e,t){let n,r,i,a=e;if(a=a.trim(),!t&&e.split(`#`).length===1){let e=cQ.exec(a);if(e)return this.pathname=e[1],e[2]&&(this.search=e[2]),this}let o=oQ.exec(a);if(o&&(o=o[0],n=o.toLowerCase(),this.protocol=o,a=a.substr(o.length)),(t||o||a.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i=a.substr(0,2)===`//`,i&&!(o&&mQ[o])&&(a=a.substr(2),this.slashes=!0)),!mQ[o]&&(i||o&&!hQ[o])){let e=-1;for(let t=0;t<uQ.length;t++)r=a.indexOf(uQ[t]),r!==-1&&(e===-1||r<e)&&(e=r);let t,n;n=e===-1?a.lastIndexOf(`@`):a.lastIndexOf(`@`,e),n!==-1&&(t=a.slice(0,n),a=a.slice(n+1),this.auth=t),e=-1;for(let t=0;t<lQ.length;t++)r=a.indexOf(lQ[t]),r!==-1&&(e===-1||r<e)&&(e=r);e===-1&&(e=a.length),a[e-1]===`:`&&e--;let i=a.slice(0,e);a=a.slice(e),this.parseHost(i),this.hostname=this.hostname||``;let o=this.hostname[0]===`[`&&this.hostname[this.hostname.length-1]===`]`;if(!o){let e=this.hostname.split(/\./);for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n&&!n.match(fQ)){let r=``;for(let e=0,t=n.length;e<t;e++)n.charCodeAt(e)>127?r+=`x`:r+=n[e];if(!r.match(fQ)){let r=e.slice(0,t),i=e.slice(t+1),o=n.match(pQ);o&&(r.push(o[1]),i.unshift(o[2])),i.length&&(a=i.join(`.`)+a),this.hostname=r.join(`.`);break}}}}this.hostname.length>dQ&&(this.hostname=``),o&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}let s=a.indexOf(`#`);s!==-1&&(this.hash=a.substr(s),a=a.slice(0,s));let c=a.indexOf(`?`);return c!==-1&&(this.search=a.substr(c),a=a.slice(0,c)),a&&(this.pathname=a),hQ[n]&&this.hostname&&!this.pathname&&(this.pathname=``),this},aQ.prototype.parseHost=function(e){let t=sQ.exec(e);t&&(t=t[0],t!==`:`&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};var _Q=t({decode:()=>eQ,encode:()=>rQ,format:()=>iQ,parse:()=>gQ}),vQ=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,yQ=/[\0-\x1F\x7F-\x9F]/,bQ=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,xQ=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,SQ=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,CQ=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,wQ=t({Any:()=>vQ,Cc:()=>yQ,Cf:()=>bQ,P:()=>xQ,S:()=>SQ,Z:()=>CQ}),TQ=new Uint16Array(`ᵁ<Õıʊҝջאٵ۞ޢߖࠏઑඡ༉༦ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲϏϢϸontourIntegraìȹoɴ\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲy;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱còJTabcdfgorstרׯؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ߂ߐĀiyޱrc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣসে্ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४ĀnrࢃgleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpwਖਛgȀLRlr৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼અઋp;椅y;䐜Ādl੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑඞcy;䐊cute;䅃ƀaeyહાron;䅇dil;䅅;䐝ƀgswે૰ativeƀMTV૨ediumSpace;怋hiĀcn૦ëeryThiîtedĀGLଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷreak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪௫ఄ಄ದൡඅ櫬Āoungruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater;EFGLSTஶஷ扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨setĀ;Eೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂෛ෧ขภยา฿ไlig;䅒cute耻Ó䃓Āiyීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲcr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬืde耻Õ䃕es;樷ml耻Ö䃖erĀBP๋Āar๐๓r;怾acĀek๚;揞et;掴arenthesis;揜ҀacfhilorsງຊຏຒດຝະrtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ檻cedesȀ;EST່້扺qual;檯lantEqual;扼ilde;找me;怳Ādpuct;戏ortionĀ;aȥl;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL憒ar;懥eftArrow;懄eiling;按oǵ\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄቕቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHcቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗ĀeiቻDzኀ\0ኇefore;戴a;䎘ĀcnኘkSpace;쀀 Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtèa;䎖r;愨pf;愤cr;쀀𝒵ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒;Eaeiopᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;eᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;eᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰᝃᝈ០៦ᠹᡐᜍ᥈ᥰot;櫭ĀcrᛶkȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;tbrk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯᝳ;䎲;愶een;扬r;쀀𝔟gcostuvwឍឝឳេ៕៛ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀakoᠦᠵĀcn៲ᠣkƀlst֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ;敛;敘;攘;攔;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģbar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;elƀ;bhᥨᥩᥫ䁜;槅sub;柈ŬᥴlĀ;e怢t»pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭒\0᯽\0ᰌƀcprᦲute;䄇̀;abcdsᦿᧀᧄ᧕᧙戩nd;橄rcup;橉Āau᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r;Ecefms᩠ᩢᩫ᪤᪪旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ\0\0aĀ;t䀬;䁀ƀ;fl戁îᅠeĀmxent»eóɍǧ\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯delprvw᭠᭬᭷ᮂᮬᯔarrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;pᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰻᰿ᱝᱩᱵᲞᲬᲷᴍᵻᶑᶫᶻ᷆᷍ròar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂᳖᳜᳠mƀ;oș᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄĀDoḆᴴoôĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»ṺƀaeiἒἚls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧\0耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₥₰₴⃰℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽ƀ;qsؾٌlanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqrⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0proør;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼ròòΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonóquigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roøurĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻\xA0ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨íistĀ;sடr;쀀𝔫ȀEest⩦⩹⩼ƀ;qs⩭ƀ;qs⩴lanôií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast⭕⭚⭟lleìl;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖchimpqu⮽⯍⯙⬄⯤⯯Ȁ;cerല⯆ഷ⯉uå;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭ååഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñĀ;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;cⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācrir;榿;쀀𝔬ͯ\0\0\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕⶥⶨrò᪀Āirⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔǒr;榷rp;榹;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ\0\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ脀¶;l䂶leìЃɩ\0\0m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳ᤈ⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t⾴ïrel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⋢⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔ABHabcdefhilmnoprstuxけさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstwガクシスゼゾダッデナp;極Ā;fゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ìâヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘rrowĀ;tㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowóarpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓ròaòՑ;怏oustĀ;a㈞掱che»mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì耻䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;qኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫwar;椪lig耻ß䃟㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rëƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproøim»ኬsðኞĀas㚺㚮ðrn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈadempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xôheadĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roðtré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜtré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌`.split(``).map(e=>e.charCodeAt(0))),EQ=new Uint16Array(`Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢`.split(``).map(e=>e.charCodeAt(0))),DQ=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),OQ=String.fromCodePoint??function(e){let t=``;return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t};function kQ(e){return e>=55296&&e<=57343||e>1114111?65533:DQ.get(e)??e}var AQ;(function(e){e[e.NUM=35]=`NUM`,e[e.SEMI=59]=`SEMI`,e[e.EQUALS=61]=`EQUALS`,e[e.ZERO=48]=`ZERO`,e[e.NINE=57]=`NINE`,e[e.LOWER_A=97]=`LOWER_A`,e[e.LOWER_F=102]=`LOWER_F`,e[e.LOWER_X=120]=`LOWER_X`,e[e.LOWER_Z=122]=`LOWER_Z`,e[e.UPPER_A=65]=`UPPER_A`,e[e.UPPER_F=70]=`UPPER_F`,e[e.UPPER_Z=90]=`UPPER_Z`})(AQ||={});var jQ=32,MQ;(function(e){e[e.VALUE_LENGTH=49152]=`VALUE_LENGTH`,e[e.BRANCH_LENGTH=16256]=`BRANCH_LENGTH`,e[e.JUMP_TABLE=127]=`JUMP_TABLE`})(MQ||={});function NQ(e){return e>=AQ.ZERO&&e<=AQ.NINE}function PQ(e){return e>=AQ.UPPER_A&&e<=AQ.UPPER_F||e>=AQ.LOWER_A&&e<=AQ.LOWER_F}function FQ(e){return e>=AQ.UPPER_A&&e<=AQ.UPPER_Z||e>=AQ.LOWER_A&&e<=AQ.LOWER_Z||NQ(e)}function IQ(e){return e===AQ.EQUALS||FQ(e)}var LQ;(function(e){e[e.EntityStart=0]=`EntityStart`,e[e.NumericStart=1]=`NumericStart`,e[e.NumericDecimal=2]=`NumericDecimal`,e[e.NumericHex=3]=`NumericHex`,e[e.NamedEntity=4]=`NamedEntity`})(LQ||={});var RQ;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Strict=1]=`Strict`,e[e.Attribute=2]=`Attribute`})(RQ||={});var zQ=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=LQ.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=RQ.Strict}startEntity(e){this.decodeMode=e,this.state=LQ.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case LQ.EntityStart:return e.charCodeAt(t)===AQ.NUM?(this.state=LQ.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=LQ.NamedEntity,this.stateNamedEntity(e,t));case LQ.NumericStart:return this.stateNumericStart(e,t);case LQ.NumericDecimal:return this.stateNumericDecimal(e,t);case LQ.NumericHex:return this.stateNumericHex(e,t);case LQ.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|jQ)===AQ.LOWER_X?(this.state=LQ.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=LQ.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,n,r){if(t!==n){let i=n-t;this.result=this.result*r**+i+parseInt(e.substr(t,i),r),this.consumed+=i}}stateNumericHex(e,t){let n=t;for(;t<e.length;){let r=e.charCodeAt(t);if(NQ(r)||PQ(r))t+=1;else return this.addToNumericResult(e,n,t,16),this.emitNumericEntity(r,3)}return this.addToNumericResult(e,n,t,16),-1}stateNumericDecimal(e,t){let n=t;for(;t<e.length;){let r=e.charCodeAt(t);if(NQ(r))t+=1;else return this.addToNumericResult(e,n,t,10),this.emitNumericEntity(r,2)}return this.addToNumericResult(e,n,t,10),-1}emitNumericEntity(e,t){var n;if(this.consumed<=t)return(n=this.errors)==null||n.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===AQ.SEMI)this.consumed+=1;else if(this.decodeMode===RQ.Strict)return 0;return this.emitCodePoint(kQ(this.result),this.consumed),this.errors&&(e!==AQ.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){let{decodeTree:n}=this,r=n[this.treeIndex],i=(r&MQ.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){let a=e.charCodeAt(t);if(this.treeIndex=VQ(n,r,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===RQ.Attribute&&(i===0||IQ(a))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],i=(r&MQ.VALUE_LENGTH)>>14,i!==0){if(a===AQ.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==RQ.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;let{result:t,decodeTree:n}=this,r=(n[t]&MQ.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,r,this.consumed),(e=this.errors)==null||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){let{decodeTree:r}=this;return this.emitCodePoint(t===1?r[e]&~MQ.VALUE_LENGTH:r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case LQ.NamedEntity:return this.result!==0&&(this.decodeMode!==RQ.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case LQ.NumericDecimal:return this.emitNumericEntity(0,2);case LQ.NumericHex:return this.emitNumericEntity(0,3);case LQ.NumericStart:return(e=this.errors)==null||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case LQ.EntityStart:return 0}}};function BQ(e){let t=``,n=new zQ(e,e=>t+=OQ(e));return function(e,r){let i=0,a=0;for(;(a=e.indexOf(`&`,a))>=0;){t+=e.slice(i,a),n.startEntity(r);let o=n.write(e,a+1);if(o<0){i=a+n.end();break}i=a+o,a=o===0?i+1:i}let o=t+e.slice(i);return t=``,o}}function VQ(e,t,n,r){let i=(t&MQ.BRANCH_LENGTH)>>7,a=t&MQ.JUMP_TABLE;if(i===0)return a!==0&&r===a?n:-1;if(a){let t=r-a;return t<0||t>=i?-1:e[n+t]-1}let o=n,s=o+i-1;for(;o<=s;){let t=o+s>>>1,n=e[t];if(n<r)o=t+1;else if(n>r)s=t-1;else return e[t+i]}return-1}var HQ=BQ(TQ);BQ(EQ);function UQ(e,t=RQ.Legacy){return HQ(e,t)}function WQ(e){return HQ(e,RQ.Strict)}var GQ=t({arrayReplaceAt:()=>ZQ,asciiTrim:()=>b$,assign:()=>XQ,escapeHtml:()=>u$,escapeRE:()=>f$,fromCodePoint:()=>$Q,has:()=>YQ,isMdAsciiPunct:()=>_$,isPunctChar:()=>h$,isPunctCharCode:()=>g$,isSpace:()=>p$,isString:()=>qQ,isValidEntityCode:()=>QQ,isWhiteSpace:()=>m$,lib:()=>x$,normalizeReference:()=>v$,unescapeAll:()=>a$,unescapeMd:()=>i$});function KQ(e){return Object.prototype.toString.call(e)}function qQ(e){return KQ(e)===`[object String]`}var JQ=Object.prototype.hasOwnProperty;function YQ(e,t){return JQ.call(e,t)}function XQ(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){if(t){if(typeof t!=`object`)throw TypeError(t+`must be object`);Object.keys(t).forEach(function(n){e[n]=t[n]})}}),e}function ZQ(e,t,n){return[].concat(e.slice(0,t),n,e.slice(t+1))}function QQ(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534||e>=0&&e<=8||e===11||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function $Q(e){if(e>65535){e-=65536;let t=55296+(e>>10),n=56320+(e&1023);return String.fromCharCode(t,n)}return String.fromCharCode(e)}var e$=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,t$=RegExp(e$.source+`|&([a-z#][a-z0-9]{1,31});`,`gi`),n$=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function r$(e,t){if(t.charCodeAt(0)===35&&n$.test(t)){let n=t[1].toLowerCase()===`x`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return QQ(n)?$Q(n):e}let n=UQ(e);return n===e?e:n}function i$(e){return e.indexOf(`\\`)<0?e:e.replace(e$,`$1`)}function a$(e){return e.indexOf(`\\`)<0&&e.indexOf(`&`)<0?e:e.replace(t$,function(e,t,n){return t||r$(e,n)})}var o$=/[&<>"]/,s$=/[&<>"]/g,c$={"&":`&`,"<":`<`,">":`>`,'"':`"`};function l$(e){return c$[e]}function u$(e){return o$.test(e)?e.replace(s$,l$):e}var d$=/[.?*+^$[\]\\(){}|-]/g;function f$(e){return e.replace(d$,`\\$&`)}function p$(e){switch(e){case 9:case 32:return!0}return!1}function m$(e){if(e>=8192&&e<=8202)return!0;switch(e){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function h$(e){return xQ.test(e)||SQ.test(e)}function g$(e){return h$($Q(e))}function _$(e){switch(e){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function v$(e){return e=e.trim().replace(/\s+/g,` `),e.toLowerCase().toUpperCase()}function y$(e){return e===32||e===9||e===10||e===13}function b$(e){let t=0;for(;t<e.length&&y$(e.charCodeAt(t));t++);let n=e.length-1;for(;n>=t&&y$(e.charCodeAt(n));n--);return e.slice(t,n+1)}var x$={mdurl:_Q,ucmicro:wQ};function S$(e,t,n){let r,i,a,o,s=e.posMax,c=e.pos;for(e.pos=t+1,r=1;e.pos<s;){if(a=e.src.charCodeAt(e.pos),a===93&&(r--,r===0)){i=!0;break}if(o=e.pos,e.md.inline.skipToken(e),a===91){if(o===e.pos-1)r++;else if(n)return e.pos=c,-1}}let l=-1;return i&&(l=e.pos),e.pos=c,l}function C$(e,t,n){let r,i=t,a={ok:!1,pos:0,str:``};if(e.charCodeAt(i)===60){for(i++;i<n;){if(r=e.charCodeAt(i),r===10||r===60)return a;if(r===62)return a.pos=i+1,a.str=a$(e.slice(t+1,i)),a.ok=!0,a;if(r===92&&i+1<n){i+=2;continue}i++}return a}let o=0;for(;i<n&&(r=e.charCodeAt(i),!(r===32||r<32||r===127));){if(r===92&&i+1<n){if(e.charCodeAt(i+1)===32)break;i+=2;continue}if(r===40&&(o++,o>32))return a;if(r===41){if(o===0)break;o--}i++}return t===i||o!==0?a:(a.str=a$(e.slice(t,i)),a.pos=i,a.ok=!0,a)}function w$(e,t,n,r){let i,a=t,o={ok:!1,can_continue:!1,pos:0,str:``,marker:0};if(r)o.str=r.str,o.marker=r.marker;else{if(a>=n)return o;let r=e.charCodeAt(a);if(r!==34&&r!==39&&r!==40)return o;t++,a++,r===40&&(r=41),o.marker=r}for(;a<n;){if(i=e.charCodeAt(a),i===o.marker)return o.pos=a+1,o.str+=a$(e.slice(t,a)),o.ok=!0,o;if(i===40&&o.marker===41)return o;i===92&&a+1<n&&a++,a++}return o.can_continue=!0,o.str+=a$(e.slice(t,a)),o}var T$=t({parseLinkDestination:()=>C$,parseLinkLabel:()=>S$,parseLinkTitle:()=>w$}),E$={};E$.code_inline=function(e,t,n,r,i){let a=e[t];return`<code`+i.renderAttrs(a)+`>`+u$(a.content)+`</code>`},E$.code_block=function(e,t,n,r,i){let a=e[t];return`<pre`+i.renderAttrs(a)+`><code>`+u$(e[t].content)+`</code></pre>
|
|
217
|
-
`},E$.fence=function(e,t,n,r,i){let a=e[t],o=a.info?a$(a.info).trim():``,s=``,c=``;if(o){let e=o.split(/(\s+)/g);s=e[0],c=e.slice(2).join(``)}let l;if(l=n.highlight&&n.highlight(a.content,s,c)||u$(a.content),l.indexOf(`<pre`)===0)return l+`
|
|
218
|
-
`;if(o){let e=a.attrIndex(`class`),t=a.attrs?a.attrs.slice():[];e<0?t.push([`class`,n.langPrefix+s]):(t[e]=t[e].slice(),t[e][1]+=` `+n.langPrefix+s);let r={attrs:t};return`<pre><code${i.renderAttrs(r)}>${l}</code></pre>\n`}return`<pre><code${i.renderAttrs(a)}>${l}</code></pre>\n`},E$.image=function(e,t,n,r,i){let a=e[t];return a.attrs[a.attrIndex(`alt`)][1]=i.renderInlineAsText(a.children,n,r),i.renderToken(e,t,n)},E$.hardbreak=function(e,t,n){return n.xhtmlOut?`<br />
|
|
219
|
-
`:`<br>
|
|
220
|
-
`},E$.softbreak=function(e,t,n){return n.breaks?n.xhtmlOut?`<br />
|
|
221
|
-
`:`<br>
|
|
222
|
-
`:`
|
|
223
|
-
`},E$.text=function(e,t){return u$(e[t].content)},E$.html_block=function(e,t){return e[t].content},E$.html_inline=function(e,t){return e[t].content};function D$(){this.rules=XQ({},E$)}D$.prototype.renderAttrs=function(e){let t,n,r;if(!e.attrs)return``;for(r=``,t=0,n=e.attrs.length;t<n;t++)r+=` `+u$(e.attrs[t][0])+`="`+u$(e.attrs[t][1])+`"`;return r},D$.prototype.renderToken=function(e,t,n){let r=e[t],i=``;if(r.hidden)return``;r.block&&r.nesting!==-1&&t&&e[t-1].hidden&&(i+=`
|
|
224
|
-
`),i+=(r.nesting===-1?`</`:`<`)+r.tag,i+=this.renderAttrs(r),r.nesting===0&&n.xhtmlOut&&(i+=` /`);let a=!1;if(r.block&&(a=!0,r.nesting===1&&t+1<e.length)){let n=e[t+1];(n.type===`inline`||n.hidden||n.nesting===-1&&n.tag===r.tag)&&(a=!1)}return i+=a?`>
|
|
225
|
-
`:`>`,i},D$.prototype.renderInline=function(e,t,n){let r=``,i=this.rules;for(let a=0,o=e.length;a<o;a++){let o=e[a].type;i[o]===void 0?r+=this.renderToken(e,a,t):r+=i[o](e,a,t,n,this)}return r},D$.prototype.renderInlineAsText=function(e,t,n){let r=``;for(let i=0,a=e.length;i<a;i++)switch(e[i].type){case`text`:r+=e[i].content;break;case`image`:r+=this.renderInlineAsText(e[i].children,t,n);break;case`html_inline`:case`html_block`:r+=e[i].content;break;case`softbreak`:case`hardbreak`:r+=`
|
|
226
|
-
`;break;default:}return r},D$.prototype.render=function(e,t,n){let r=``,i=this.rules;for(let a=0,o=e.length;a<o;a++){let o=e[a].type;o===`inline`?r+=this.renderInline(e[a].children,t,n):i[o]===void 0?r+=this.renderToken(e,a,t,n):r+=i[o](e,a,t,n,this)}return r};function O$(){this.__rules__=[],this.__cache__=null}O$.prototype.__find__=function(e){for(let t=0;t<this.__rules__.length;t++)if(this.__rules__[t].name===e)return t;return-1},O$.prototype.__compile__=function(){let e=this,t=[``];e.__rules__.forEach(function(e){e.enabled&&e.alt.forEach(function(e){t.indexOf(e)<0&&t.push(e)})}),e.__cache__={},t.forEach(function(t){e.__cache__[t]=[],e.__rules__.forEach(function(n){n.enabled&&(t&&n.alt.indexOf(t)<0||e.__cache__[t].push(n.fn))})})},O$.prototype.at=function(e,t,n){let r=this.__find__(e),i=n||{};if(r===-1)throw Error(`Parser rule not found: `+e);this.__rules__[r].fn=t,this.__rules__[r].alt=i.alt||[],this.__cache__=null},O$.prototype.before=function(e,t,n,r){let i=this.__find__(e),a=r||{};if(i===-1)throw Error(`Parser rule not found: `+e);this.__rules__.splice(i,0,{name:t,enabled:!0,fn:n,alt:a.alt||[]}),this.__cache__=null},O$.prototype.after=function(e,t,n,r){let i=this.__find__(e),a=r||{};if(i===-1)throw Error(`Parser rule not found: `+e);this.__rules__.splice(i+1,0,{name:t,enabled:!0,fn:n,alt:a.alt||[]}),this.__cache__=null},O$.prototype.push=function(e,t,n){let r=n||{};this.__rules__.push({name:e,enabled:!0,fn:t,alt:r.alt||[]}),this.__cache__=null},O$.prototype.enable=function(e,t){Array.isArray(e)||(e=[e]);let n=[];return e.forEach(function(e){let r=this.__find__(e);if(r<0){if(t)return;throw Error(`Rules manager: invalid rule name `+e)}this.__rules__[r].enabled=!0,n.push(e)},this),this.__cache__=null,n},O$.prototype.enableOnly=function(e,t){Array.isArray(e)||(e=[e]),this.__rules__.forEach(function(e){e.enabled=!1}),this.enable(e,t)},O$.prototype.disable=function(e,t){Array.isArray(e)||(e=[e]);let n=[];return e.forEach(function(e){let r=this.__find__(e);if(r<0){if(t)return;throw Error(`Rules manager: invalid rule name `+e)}this.__rules__[r].enabled=!1,n.push(e)},this),this.__cache__=null,n},O$.prototype.getRules=function(e){return this.__cache__===null&&this.__compile__(),this.__cache__[e]||[]};function k$(e,t,n){this.type=e,this.tag=t,this.attrs=null,this.map=null,this.nesting=n,this.level=0,this.children=null,this.content=``,this.markup=``,this.info=``,this.meta=null,this.block=!1,this.hidden=!1}k$.prototype.attrIndex=function(e){if(!this.attrs)return-1;let t=this.attrs;for(let n=0,r=t.length;n<r;n++)if(t[n][0]===e)return n;return-1},k$.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]},k$.prototype.attrSet=function(e,t){let n=this.attrIndex(e),r=[e,t];n<0?this.attrPush(r):this.attrs[n]=r},k$.prototype.attrGet=function(e){let t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n},k$.prototype.attrJoin=function(e,t){let n=this.attrIndex(e);n<0?this.attrPush([e,t]):this.attrs[n][1]=this.attrs[n][1]+` `+t};function A$(e,t,n){this.src=e,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=t}A$.prototype.Token=k$;var j$=/\r\n?|\n/g,M$=/\0/g;function N$(e){let t;t=e.src.replace(j$,`
|
|
227
|
-
`),t=t.replace(M$,`�`),e.src=t}function P$(e){let t;e.inlineMode?(t=new e.Token(`inline`,``,0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}function F$(e){let t=e.tokens;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.type===`inline`&&e.md.inline.parse(r.content,e.md,e.env,r.children)}}function I$(e){return/^<a[>\s]/i.test(e)}function L$(e){return/^<\/a\s*>/i.test(e)}function R$(e){let t=e.tokens;if(e.md.options.linkify)for(let n=0,r=t.length;n<r;n++){if(t[n].type!==`inline`||!e.md.linkify.pretest(t[n].content))continue;let r=t[n].children,i=0;for(let a=r.length-1;a>=0;a--){let o=r[a];if(o.type===`link_close`){for(a--;r[a].level!==o.level&&r[a].type!==`link_open`;)a--;continue}if(o.type===`html_inline`&&(I$(o.content)&&i>0&&i--,L$(o.content)&&i++),!(i>0)&&o.type===`text`&&e.md.linkify.test(o.content)){let i=o.content,s=e.md.linkify.match(i),c=[],l=o.level,u=0;s.length>0&&s[0].index===0&&a>0&&r[a-1].type===`text_special`&&(s=s.slice(1));for(let t=0;t<s.length;t++){let n=s[t].url,r=e.md.normalizeLink(n);if(!e.md.validateLink(r))continue;let a=s[t].text;a=s[t].schema?s[t].schema===`mailto:`&&!/^mailto:/i.test(a)?e.md.normalizeLinkText(`mailto:`+a).replace(/^mailto:/,``):e.md.normalizeLinkText(a):e.md.normalizeLinkText(`http://`+a).replace(/^http:\/\//,``);let o=s[t].index;if(o>u){let t=new e.Token(`text`,``,0);t.content=i.slice(u,o),t.level=l,c.push(t)}let d=new e.Token(`link_open`,`a`,1);d.attrs=[[`href`,r]],d.level=l++,d.markup=`linkify`,d.info=`auto`,c.push(d);let f=new e.Token(`text`,``,0);f.content=a,f.level=l,c.push(f);let p=new e.Token(`link_close`,`a`,-1);p.level=--l,p.markup=`linkify`,p.info=`auto`,c.push(p),u=s[t].lastIndex}if(u<i.length){let t=new e.Token(`text`,``,0);t.content=i.slice(u),t.level=l,c.push(t)}t[n].children=r=ZQ(r,a,c)}}}}var z$=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,B$=/\((c|tm|r)\)/i,V$=/\((c|tm|r)\)/gi,H$={c:`©`,r:`®`,tm:`™`};function U$(e,t){return H$[t.toLowerCase()]}function W$(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&(r.content=r.content.replace(V$,U$)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function G$(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&z$.test(r.content)&&(r.content=r.content.replace(/\+-/g,`±`).replace(/\.{2,}/g,`…`).replace(/([?!])…/g,`$1..`).replace(/([?!]){4,}/g,`$1$1$1`).replace(/,{2,}/g,`,`).replace(/(^|[^-])---(?=[^-]|$)/gm,`$1—`).replace(/(^|\s)--(?=\s|$)/gm,`$1–`).replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,`$1–`)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function K$(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type===`inline`&&(B$.test(e.tokens[t].content)&&W$(e.tokens[t].children),z$.test(e.tokens[t].content)&&G$(e.tokens[t].children))}var q$=/['"]/,J$=/['"]/g,Y$=`’`;function X$(e,t,n,r){e[t]||(e[t]=[]),e[t].push({pos:n,ch:r})}function Z$(e,t){let n=``,r=0;t.sort((e,t)=>e.pos-t.pos);for(let i=0;i<t.length;i++){let a=t[i];n+=e.slice(r,a.pos)+a.ch,r=a.pos+1}return n+e.slice(r)}function Q$(e,t){let n,r=[],i={};for(let a=0;a<e.length;a++){let o=e[a],s=e[a].level;for(n=r.length-1;n>=0&&!(r[n].level<=s);n--);if(r.length=n+1,o.type!==`text`)continue;let c=o.content,l=0,u=c.length;OUTER:for(;l<u;){J$.lastIndex=l;let o=J$.exec(c);if(!o)break;let d=!0,f=!0;l=o.index+1;let p=o[0]===`'`,m=32;if(o.index-1>=0)m=c.charCodeAt(o.index-1);else for(n=a-1;n>=0&&!(e[n].type===`softbreak`||e[n].type===`hardbreak`);n--)if(e[n].content){m=e[n].content.charCodeAt(e[n].content.length-1);break}let h=32;if(l<u)h=c.charCodeAt(l);else for(n=a+1;n<e.length&&!(e[n].type===`softbreak`||e[n].type===`hardbreak`);n++)if(e[n].content){h=e[n].content.charCodeAt(0);break}let g=_$(m)||g$(m),_=_$(h)||g$(h),v=m$(m),y=m$(h);if(y?d=!1:_&&(v||g||(d=!1)),v?f=!1:g&&(y||_||(f=!1)),h===34&&o[0]===`"`&&m>=48&&m<=57&&(f=d=!1),d&&f&&(d=g,f=_),!d&&!f){p&&X$(i,a,o.index,Y$);continue}if(f)for(n=r.length-1;n>=0;n--){let e=r[n];if(r[n].level<s)break;if(e.single===p&&r[n].level===s){e=r[n];let s,c;p?(s=t.md.options.quotes[2],c=t.md.options.quotes[3]):(s=t.md.options.quotes[0],c=t.md.options.quotes[1]),X$(i,a,o.index,c),X$(i,e.token,e.pos,s),r.length=n;continue OUTER}}d?r.push({token:a,pos:o.index,single:p,level:s}):f&&p&&X$(i,a,o.index,Y$)}}Object.keys(i).forEach(function(t){e[t].content=Z$(e[t].content,i[t])})}function $$(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!==`inline`||!q$.test(e.tokens[t].content)||Q$(e.tokens[t].children,e)}function e1(e){let t,n,r=e.tokens,i=r.length;for(let e=0;e<i;e++){if(r[e].type!==`inline`)continue;let i=r[e].children,a=i.length;for(t=0;t<a;t++)i[t].type===`text_special`&&(i[t].type=`text`);for(t=n=0;t<a;t++)i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}}var t1=[[`normalize`,N$],[`block`,P$],[`inline`,F$],[`linkify`,R$],[`replacements`,K$],[`smartquotes`,$$],[`text_join`,e1]];function n1(){this.ruler=new O$;for(let e=0;e<t1.length;e++)this.ruler.push(t1[e][0],t1[e][1])}n1.prototype.process=function(e){let t=this.ruler.getRules(``);for(let n=0,r=t.length;n<r;n++)t[n](e)},n1.prototype.State=A$;function r1(e,t,n,r){this.src=e,this.md=t,this.env=n,this.tokens=r,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType=`root`,this.level=0;let i=this.src;for(let e=0,t=0,n=0,r=0,a=i.length,o=!1;t<a;t++){let s=i.charCodeAt(t);if(!o)if(p$(s)){n++,s===9?r+=4-r%4:r++;continue}else o=!0;(s===10||t===a-1)&&(s!==10&&t++,this.bMarks.push(e),this.eMarks.push(t),this.tShift.push(n),this.sCount.push(r),this.bsCount.push(0),o=!1,n=0,r=0,e=t+1)}this.bMarks.push(i.length),this.eMarks.push(i.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}r1.prototype.push=function(e,t,n){let r=new k$(e,t,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r},r1.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]},r1.prototype.skipEmptyLines=function(e){for(let t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e},r1.prototype.skipSpaces=function(e){for(let t=this.src.length;e<t&&p$(this.src.charCodeAt(e));e++);return e},r1.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!p$(this.src.charCodeAt(--e)))return e+1;return e},r1.prototype.skipChars=function(e,t){for(let n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e},r1.prototype.skipCharsBack=function(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e},r1.prototype.getLines=function(e,t,n,r){if(e>=t)return``;let i=Array(t-e);for(let a=0,o=e;o<t;o++,a++){let e=0,s=this.bMarks[o],c=s,l;for(l=o+1<t||r?this.eMarks[o]+1:this.eMarks[o];c<l&&e<n;){let t=this.src.charCodeAt(c);if(p$(t))t===9?e+=4-(e+this.bsCount[o])%4:e++;else if(c-s<this.tShift[o])e++;else break;c++}e>n?i[a]=Array(e-n+1).join(` `)+this.src.slice(c,l):i[a]=this.src.slice(c,l)}return i.join(``)},r1.prototype.Token=k$;var i1=65536;function a1(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(n,r)}function o1(e){let t=[],n=e.length,r=0,i=e.charCodeAt(r),a=!1,o=0,s=``;for(;r<n;)i===124&&(a?(s+=e.substring(o,r-1),o=r):(t.push(s+e.substring(o,r)),s=``,o=r+1)),a=i===92,r++,i=e.charCodeAt(r);return t.push(s+e.substring(o)),t}function s1(e,t,n,r){if(t+2>n)return!1;let i=t+1;if(e.sCount[i]<e.blkIndent||e.sCount[i]-e.blkIndent>=4)return!1;let a=e.bMarks[i]+e.tShift[i];if(a>=e.eMarks[i])return!1;let o=e.src.charCodeAt(a++);if(o!==124&&o!==45&&o!==58||a>=e.eMarks[i])return!1;let s=e.src.charCodeAt(a++);if(s!==124&&s!==45&&s!==58&&!p$(s)||o===45&&p$(s))return!1;for(;a<e.eMarks[i];){let t=e.src.charCodeAt(a);if(t!==124&&t!==45&&t!==58&&!p$(t))return!1;a++}let c=a1(e,t+1),l=c.split(`|`),u=[];for(let e=0;e<l.length;e++){let t=l[e].trim();if(!t){if(e===0||e===l.length-1)continue;return!1}if(!/^:?-+:?$/.test(t))return!1;t.charCodeAt(t.length-1)===58?u.push(t.charCodeAt(0)===58?`center`:`right`):t.charCodeAt(0)===58?u.push(`left`):u.push(``)}if(c=a1(e,t).trim(),c.indexOf(`|`)===-1||e.sCount[t]-e.blkIndent>=4)return!1;l=o1(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop();let d=l.length;if(d===0||d!==u.length)return!1;if(r)return!0;let f=e.parentType;e.parentType=`table`;let p=e.md.block.ruler.getRules(`blockquote`),m=e.push(`table_open`,`table`,1),h=[t,0];m.map=h;let g=e.push(`thead_open`,`thead`,1);g.map=[t,t+1];let _=e.push(`tr_open`,`tr`,1);_.map=[t,t+1];for(let t=0;t<l.length;t++){let n=e.push(`th_open`,`th`,1);u[t]&&(n.attrs=[[`style`,`text-align:`+u[t]]]);let r=e.push(`inline`,``,0);r.content=l[t].trim(),r.children=[],e.push(`th_close`,`th`,-1)}e.push(`tr_close`,`tr`,-1),e.push(`thead_close`,`thead`,-1);let v,y=0;for(i=t+2;i<n&&!(e.sCount[i]<e.blkIndent);i++){let r=!1;for(let t=0,a=p.length;t<a;t++)if(p[t](e,i,n,!0)){r=!0;break}if(r||(c=a1(e,i).trim(),!c)||e.sCount[i]-e.blkIndent>=4||(l=o1(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop(),y+=d-l.length,y>i1))break;if(i===t+2){let n=e.push(`tbody_open`,`tbody`,1);n.map=v=[t+2,0]}let a=e.push(`tr_open`,`tr`,1);a.map=[i,i+1];for(let t=0;t<d;t++){let n=e.push(`td_open`,`td`,1);u[t]&&(n.attrs=[[`style`,`text-align:`+u[t]]]);let r=e.push(`inline`,``,0);r.content=l[t]?l[t].trim():``,r.children=[],e.push(`td_close`,`td`,-1)}e.push(`tr_close`,`tr`,-1)}return v&&(e.push(`tbody_close`,`tbody`,-1),v[1]=i),e.push(`table_close`,`table`,-1),h[1]=i,e.parentType=f,e.line=i,!0}function c1(e,t,n){if(e.sCount[t]-e.blkIndent<4)return!1;let r=t+1,i=r;for(;r<n;){if(e.isEmpty(r)){r++;continue}if(e.sCount[r]-e.blkIndent>=4){r++,i=r;continue}break}e.line=i;let a=e.push(`code_block`,`code`,0);return a.content=e.getLines(t,i,4+e.blkIndent,!1)+`
|
|
228
|
-
`,a.map=[t,e.line],!0}function l1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||i+3>a)return!1;let o=e.src.charCodeAt(i);if(o!==126&&o!==96)return!1;let s=i;i=e.skipChars(i,o);let c=i-s;if(c<3)return!1;let l=e.src.slice(s,i),u=e.src.slice(i,a);if(o===96&&u.indexOf(String.fromCharCode(o))>=0)return!1;if(r)return!0;let d=t,f=!1;for(;d++,!(d>=n||(i=s=e.bMarks[d]+e.tShift[d],a=e.eMarks[d],i<a&&e.sCount[d]<e.blkIndent));)if(e.src.charCodeAt(i)===o&&!(e.sCount[d]-e.blkIndent>=4)&&(i=e.skipChars(i,o),!(i-s<c)&&(i=e.skipSpaces(i),!(i<a)))){f=!0;break}c=e.sCount[t],e.line=d+ +!!f;let p=e.push(`fence`,`code`,0);return p.info=u,p.content=e.getLines(t+1,d,c,!0),p.markup=l,p.map=[t,e.line],!0}function u1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o=e.lineMax;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==62)return!1;if(r)return!0;let s=[],c=[],l=[],u=[],d=e.md.block.ruler.getRules(`blockquote`),f=e.parentType;e.parentType=`blockquote`;let p=!1,m;for(m=t;m<n;m++){let t=e.sCount[m]<e.blkIndent;if(i=e.bMarks[m]+e.tShift[m],a=e.eMarks[m],i>=a)break;if(e.src.charCodeAt(i++)===62&&!t){let t=e.sCount[m]+1,n,r;e.src.charCodeAt(i)===32?(i++,t++,r=!1,n=!0):e.src.charCodeAt(i)===9?(n=!0,(e.bsCount[m]+t)%4==3?(i++,t++,r=!1):r=!0):n=!1;let o=t;for(s.push(e.bMarks[m]),e.bMarks[m]=i;i<a;){let t=e.src.charCodeAt(i);if(p$(t))t===9?o+=4-(o+e.bsCount[m]+ +!!r)%4:o++;else break;i++}p=i>=a,c.push(e.bsCount[m]),e.bsCount[m]=e.sCount[m]+1+ +!!n,l.push(e.sCount[m]),e.sCount[m]=o-t,u.push(e.tShift[m]),e.tShift[m]=i-e.bMarks[m];continue}if(p)break;let r=!1;for(let t=0,i=d.length;t<i;t++)if(d[t](e,m,n,!0)){r=!0;break}if(r){e.lineMax=m,e.blkIndent!==0&&(s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]-=e.blkIndent);break}s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]=-1}let h=e.blkIndent;e.blkIndent=0;let g=e.push(`blockquote_open`,`blockquote`,1);g.markup=`>`;let _=[t,0];g.map=_,e.md.block.tokenize(e,t,m);let v=e.push(`blockquote_close`,`blockquote`,-1);v.markup=`>`,e.lineMax=o,e.parentType=f,_[1]=e.line;for(let n=0;n<u.length;n++)e.bMarks[n+t]=s[n],e.tShift[n+t]=u[n],e.sCount[n+t]=l[n],e.bsCount[n+t]=c[n];return e.blkIndent=h,!0}function d1(e,t,n,r){let i=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let a=e.bMarks[t]+e.tShift[t],o=e.src.charCodeAt(a++);if(o!==42&&o!==45&&o!==95)return!1;let s=1;for(;a<i;){let t=e.src.charCodeAt(a++);if(t!==o&&!p$(t))return!1;t===o&&s++}if(s<3)return!1;if(r)return!0;e.line=t+1;let c=e.push(`hr`,`hr`,0);return c.map=[t,e.line],c.markup=Array(s+1).join(String.fromCharCode(o)),!0}function f1(e,t){let n=e.eMarks[t],r=e.bMarks[t]+e.tShift[t],i=e.src.charCodeAt(r++);return i!==42&&i!==45&&i!==43||r<n&&!p$(e.src.charCodeAt(r))?-1:r}function p1(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t],i=n;if(i+1>=r)return-1;let a=e.src.charCodeAt(i++);if(a<48||a>57)return-1;for(;;){if(i>=r)return-1;if(a=e.src.charCodeAt(i++),a>=48&&a<=57){if(i-n>=10)return-1;continue}if(a===41||a===46)break;return-1}return i<r&&(a=e.src.charCodeAt(i),!p$(a))?-1:i}function m1(e,t){let n=e.level+2;for(let r=t+2,i=e.tokens.length-2;r<i;r++)e.tokens[r].level===n&&e.tokens[r].type===`paragraph_open`&&(e.tokens[r+2].hidden=!0,e.tokens[r].hidden=!0,r+=2)}function h1(e,t,n,r){let i,a,o,s,c=t,l=!0;if(e.sCount[c]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[c]-e.listIndent>=4&&e.sCount[c]<e.blkIndent)return!1;let u=!1;r&&e.parentType===`paragraph`&&e.sCount[c]>=e.blkIndent&&(u=!0);let d,f,p;if((p=p1(e,c))>=0){if(d=!0,o=e.bMarks[c]+e.tShift[c],f=Number(e.src.slice(o,p-1)),u&&f!==1)return!1}else if((p=f1(e,c))>=0)d=!1;else return!1;if(u&&e.skipSpaces(p)>=e.eMarks[c])return!1;if(r)return!0;let m=e.src.charCodeAt(p-1),h=e.tokens.length;d?(s=e.push(`ordered_list_open`,`ol`,1),f!==1&&(s.attrs=[[`start`,f]])):s=e.push(`bullet_list_open`,`ul`,1);let g=[c,0];s.map=g,s.markup=String.fromCharCode(m);let _=!1,v=e.md.block.ruler.getRules(`list`),y=e.parentType;for(e.parentType=`list`;c<n;){a=p,i=e.eMarks[c];let t=e.sCount[c]+p-(e.bMarks[c]+e.tShift[c]),r=t;for(;a<i;){let t=e.src.charCodeAt(a);if(t===9)r+=4-(r+e.bsCount[c])%4;else if(t===32)r++;else break;a++}let u=a,f;f=u>=i?1:r-t,f>4&&(f=1);let h=t+f;s=e.push(`list_item_open`,`li`,1),s.markup=String.fromCharCode(m);let g=[c,0];s.map=g,d&&(s.info=e.src.slice(o,p-1));let y=e.tight,b=e.tShift[c],x=e.sCount[c],S=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=h,e.tight=!0,e.tShift[c]=u-e.bMarks[c],e.sCount[c]=r,u>=i&&e.isEmpty(c+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,c,n,!0),(!e.tight||_)&&(l=!1),_=e.line-c>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=S,e.tShift[c]=b,e.sCount[c]=x,e.tight=y,s=e.push(`list_item_close`,`li`,-1),s.markup=String.fromCharCode(m),c=e.line,g[1]=c,c>=n||e.sCount[c]<e.blkIndent||e.sCount[c]-e.blkIndent>=4)break;let C=!1;for(let t=0,r=v.length;t<r;t++)if(v[t](e,c,n,!0)){C=!0;break}if(C)break;if(d){if(p=p1(e,c),p<0)break;o=e.bMarks[c]+e.tShift[c]}else if(p=f1(e,c),p<0)break;if(m!==e.src.charCodeAt(p-1))break}return s=d?e.push(`ordered_list_close`,`ol`,-1):e.push(`bullet_list_close`,`ul`,-1),s.markup=String.fromCharCode(m),g[1]=c,e.line=c,e.parentType=y,l&&m1(e,h),!0}function g1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==91)return!1;function s(t){let n=e.lineMax;if(t>=n||e.isEmpty(t))return null;let r=!1;if(e.sCount[t]-e.blkIndent>3&&(r=!0),e.sCount[t]<0&&(r=!0),!r){let r=e.md.block.ruler.getRules(`reference`),i=e.parentType;e.parentType=`reference`;let a=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,t,n,!0)){a=!0;break}if(e.parentType=i,a)return null}let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];return e.src.slice(i,a+1)}let c=e.src.slice(i,a+1);a=c.length;let l=-1;for(i=1;i<a;i++){let e=c.charCodeAt(i);if(e===91)return!1;if(e===93){l=i;break}else if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(e===92&&(i++,i<a&&c.charCodeAt(i)===10)){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}}if(l<0||c.charCodeAt(l+1)!==58)return!1;for(i=l+2;i<a;i++){let e=c.charCodeAt(i);if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(!p$(e))break}let u=e.md.helpers.parseLinkDestination(c,i,a);if(!u.ok)return!1;let d=e.md.normalizeLink(u.str);if(!e.md.validateLink(d))return!1;i=u.pos;let f=i,p=o,m=i;for(;i<a;i++){let e=c.charCodeAt(i);if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(!p$(e))break}let h=e.md.helpers.parseLinkTitle(c,i,a);for(;h.can_continue;){let t=s(o);if(t===null)break;c+=t,i=a,a=c.length,o++,h=e.md.helpers.parseLinkTitle(c,i,a,h)}let g;for(i<a&&m!==i&&h.ok?(g=h.str,i=h.pos):(g=``,i=f,o=p);i<a&&p$(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10&&g)for(g=``,i=f,o=p;i<a&&p$(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10)return!1;let _=v$(c.slice(1,l));return _?r?!0:(e.env.references===void 0&&(e.env.references={}),e.env.references[_]===void 0&&(e.env.references[_]={title:g,href:d}),e.line=o,!0):!1}var _1=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),v1=RegExp(`^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)`),y1=RegExp(`^(?:<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>|<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>)`),b1=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[RegExp(`^</?(`+_1.join(`|`)+`)(?=(\\s|/?>|$))`,`i`),/^$/,!0],[RegExp(y1.source+`\\s*$`),/^$/,!1]];function x1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(i)!==60)return!1;let o=e.src.slice(i,a),s=0;for(;s<b1.length&&!b1[s][0].test(o);s++);if(s===b1.length)return!1;if(r)return b1[s][2];let c=t+1,l=b1[s][1].test(``);if(!b1[s][1].test(o)){for(;c<n&&!(e.sCount[c]<e.blkIndent&&(l||!e.isEmpty(c)));c++)if(i=e.bMarks[c]+e.tShift[c],a=e.eMarks[c],o=e.src.slice(i,a),b1[s][1].test(o)){o.length!==0&&c++;break}}e.line=c;let u=e.push(`html_block`,``,0);return u.map=[t,c],u.content=e.getLines(t,c,e.blkIndent,!0),!0}function S1(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let o=e.src.charCodeAt(i);if(o!==35||i>=a)return!1;let s=1;for(o=e.src.charCodeAt(++i);o===35&&i<a&&s<=6;)s++,o=e.src.charCodeAt(++i);if(s>6||i<a&&!p$(o))return!1;if(r)return!0;a=e.skipSpacesBack(a,i);let c=e.skipCharsBack(a,35,i);c>i&&p$(e.src.charCodeAt(c-1))&&(a=c),e.line=t+1;let l=e.push(`heading_open`,`h`+String(s),1);l.markup=`########`.slice(0,s),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=b$(e.src.slice(i,a)),u.map=[t,e.line],u.children=[];let d=e.push(`heading_close`,`h`+String(s),-1);return d.markup=`########`.slice(0,s),!0}function C1(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`);if(e.sCount[t]-e.blkIndent>=4)return!1;let i=e.parentType;e.parentType=`paragraph`;let a=0,o,s=t+1;for(;s<n&&!e.isEmpty(s);s++){if(e.sCount[s]-e.blkIndent>3)continue;if(e.sCount[s]>=e.blkIndent){let t=e.bMarks[s]+e.tShift[s],n=e.eMarks[s];if(t<n&&(o=e.src.charCodeAt(t),(o===45||o===61)&&(t=e.skipChars(t,o),t=e.skipSpaces(t),t>=n))){a=o===61?1:2;break}}if(e.sCount[s]<0)continue;let t=!1;for(let i=0,a=r.length;i<a;i++)if(r[i](e,s,n,!0)){t=!0;break}if(t)break}if(!a)return e.parentType=i,!1;let c=b$(e.getLines(t,s,e.blkIndent,!1));e.line=s+1;let l=e.push(`heading_open`,`h`+String(a),1);l.markup=String.fromCharCode(o),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=c,u.map=[t,e.line-1],u.children=[];let d=e.push(`heading_close`,`h`+String(a),-1);return d.markup=String.fromCharCode(o),e.parentType=i,!0}function w1(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`),i=e.parentType,a=t+1;for(e.parentType=`paragraph`;a<n&&!e.isEmpty(a);a++){if(e.sCount[a]-e.blkIndent>3||e.sCount[a]<0)continue;let t=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,a,n,!0)){t=!0;break}if(t)break}let o=b$(e.getLines(t,a,e.blkIndent,!1));e.line=a;let s=e.push(`paragraph_open`,`p`,1);s.map=[t,e.line];let c=e.push(`inline`,``,0);return c.content=o,c.map=[t,e.line],c.children=[],e.push(`paragraph_close`,`p`,-1),e.parentType=i,!0}var T1=[[`table`,s1,[`paragraph`,`reference`]],[`code`,c1],[`fence`,l1,[`paragraph`,`reference`,`blockquote`,`list`]],[`blockquote`,u1,[`paragraph`,`reference`,`blockquote`,`list`]],[`hr`,d1,[`paragraph`,`reference`,`blockquote`,`list`]],[`list`,h1,[`paragraph`,`reference`,`blockquote`]],[`reference`,g1],[`html_block`,x1,[`paragraph`,`reference`,`blockquote`]],[`heading`,S1,[`paragraph`,`reference`,`blockquote`]],[`lheading`,C1],[`paragraph`,w1]];function E1(){this.ruler=new O$;for(let e=0;e<T1.length;e++)this.ruler.push(T1[e][0],T1[e][1],{alt:(T1[e][2]||[]).slice()})}E1.prototype.tokenize=function(e,t,n){let r=this.ruler.getRules(``),i=r.length,a=e.md.options.maxNesting,o=t,s=!1;for(;o<n&&(e.line=o=e.skipEmptyLines(o),!(o>=n||e.sCount[o]<e.blkIndent));){if(e.level>=a){e.line=n;break}let t=e.line,c=!1;for(let a=0;a<i;a++)if(c=r[a](e,o,n,!1),c){if(t>=e.line)throw Error(`block rule didn't increment state.line`);break}if(!c)throw Error(`none of the block rules matched`);e.tight=!s,e.isEmpty(e.line-1)&&(s=!0),o=e.line,o<n&&e.isEmpty(o)&&(s=!0,o++,e.line=o)}},E1.prototype.parse=function(e,t,n,r){if(!e)return;let i=new this.State(e,t,n,r);this.tokenize(i,i.line,i.lineMax)},E1.prototype.State=r1;function D1(e,t,n,r){this.src=e,this.env=n,this.md=t,this.tokens=r,this.tokens_meta=Array(r.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending=``,this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}D1.prototype.pushPending=function(){let e=new k$(`text`,``,0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending=``,e},D1.prototype.push=function(e,t,n){this.pending&&this.pushPending();let r=new k$(e,t,n),i=null;return n<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),r.level=this.level,n>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(i),r},D1.prototype.scanDelims=function(e,t){let n=this.posMax,r=this.src.charCodeAt(e),i;if(e===0)i=32;else if(e===1)i=this.src.charCodeAt(0),(i&63488)==55296&&(i=65533);else if(i=this.src.charCodeAt(e-1),(i&64512)==56320){let t=this.src.charCodeAt(e-2);i=(t&64512)==55296?65536+(t-55296<<10)+(i-56320):65533}else (i&64512)==55296&&(i=65533);let a=e;for(;a<n&&this.src.charCodeAt(a)===r;)a++;let o=a-e,s=a<n?this.src.charCodeAt(a):32;if((s&64512)==55296){let e=this.src.charCodeAt(a+1);s=(e&64512)==56320?65536+(s-55296<<10)+(e-56320):65533}else (s&64512)==56320&&(s=65533);let c=_$(i)||g$(i),l=_$(s)||g$(s),u=m$(i),d=m$(s),f=!d&&(!l||u||c),p=!u&&(!c||d||l);return{can_open:f&&(t||!p||c),can_close:p&&(t||!f||l),length:o}},D1.prototype.Token=k$;function O1(e){switch(e){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}function k1(e,t){let n=e.pos;for(;n<e.posMax&&!O1(e.src.charCodeAt(n));)n++;return n===e.pos?!1:(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}var A1=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function j1(e,t){if(!e.md.options.linkify||e.linkLevel>0)return!1;let n=e.pos,r=e.posMax;if(n+3>r||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47)return!1;let i=e.pending.match(A1);if(!i)return!1;let a=i[1],o=e.md.linkify.matchAtStart(e.src.slice(n-a.length));if(!o)return!1;let s=o.url;if(s.length<=a.length)return!1;let c=s.length;for(;c>0&&s.charCodeAt(c-1)===42;)c--;c!==s.length&&(s=s.slice(0,c));let l=e.md.normalizeLink(s);if(!e.md.validateLink(l))return!1;if(!t){e.pending=e.pending.slice(0,-a.length);let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,l]],t.markup=`linkify`,t.info=`auto`;let n=e.push(`text`,``,0);n.content=e.md.normalizeLinkText(s);let r=e.push(`link_close`,`a`,-1);r.markup=`linkify`,r.info=`auto`}return e.pos+=s.length-a.length,!0}function M1(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==10)return!1;let r=e.pending.length-1,i=e.posMax;if(!t)if(r>=0&&e.pending.charCodeAt(r)===32)if(r>=1&&e.pending.charCodeAt(r-1)===32){let t=r-1;for(;t>=1&&e.pending.charCodeAt(t-1)===32;)t--;e.pending=e.pending.slice(0,t),e.push(`hardbreak`,`br`,0)}else e.pending=e.pending.slice(0,-1),e.push(`softbreak`,`br`,0);else e.push(`softbreak`,`br`,0);for(n++;n<i&&p$(e.src.charCodeAt(n));)n++;return e.pos=n,!0}var N1=[];for(let e=0;e<256;e++)N1.push(0);`\\!"#$%&'()*+,./:;<=>?@[]^_\`{|}~-`.split(``).forEach(function(e){N1[e.charCodeAt(0)]=1});function P1(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=e.src.charCodeAt(n);if(i===10){for(t||e.push(`hardbreak`,`br`,0),n++;n<r&&(i=e.src.charCodeAt(n),p$(i));)n++;return e.pos=n,!0}let a=e.src[n];if(i>=55296&&i<=56319&&n+1<r){let t=e.src.charCodeAt(n+1);t>=56320&&t<=57343&&(a+=e.src[n+1],n++)}let o=`\\`+a;if(!t){let t=e.push(`text_special`,``,0);i<256&&N1[i]!==0?t.content=a:t.content=o,t.markup=o,t.info=`escape`}return e.pos=n+1,!0}function F1(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==96)return!1;let r=n;n++;let i=e.posMax;for(;n<i&&e.src.charCodeAt(n)===96;)n++;let a=e.src.slice(r,n),o=a.length;if(e.backticksScanned&&(e.backticks[o]||0)<=r)return t||(e.pending+=a),e.pos+=o,!0;let s=n,c;for(;(c=e.src.indexOf("`",s))!==-1;){for(s=c+1;s<i&&e.src.charCodeAt(s)===96;)s++;let r=s-c;if(r===o){if(!t){let t=e.push(`code_inline`,`code`,0);t.markup=a,t.content=e.src.slice(n,c).replace(/\n/g,` `).replace(/^ (.+) $/,`$1`)}return e.pos=s,!0}e.backticks[r]=c}return e.backticksScanned=!0,t||(e.pending+=a),e.pos+=o,!0}function I1(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==126)return!1;let i=e.scanDelims(e.pos,!0),a=i.length,o=String.fromCharCode(r);if(a<2)return!1;let s;a%2&&(s=e.push(`text`,``,0),s.content=o,a--);for(let t=0;t<a;t+=2)s=e.push(`text`,``,0),s.content=o+o,e.delimiters.push({marker:r,length:0,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0}function L1(e,t){let n,r=[],i=t.length;for(let a=0;a<i;a++){let i=t[a];if(i.marker!==126||i.end===-1)continue;let o=t[i.end];n=e.tokens[i.token],n.type=`s_open`,n.tag=`s`,n.nesting=1,n.markup=`~~`,n.content=``,n=e.tokens[o.token],n.type=`s_close`,n.tag=`s`,n.nesting=-1,n.markup=`~~`,n.content=``,e.tokens[o.token-1].type===`text`&&e.tokens[o.token-1].content===`~`&&r.push(o.token-1)}for(;r.length;){let t=r.pop(),i=t+1;for(;i<e.tokens.length&&e.tokens[i].type===`s_close`;)i++;i--,t!==i&&(n=e.tokens[i],e.tokens[i]=e.tokens[t],e.tokens[t]=n)}}function R1(e){let t=e.tokens_meta,n=e.tokens_meta.length;L1(e,e.delimiters);for(let r=0;r<n;r++)t[r]&&t[r].delimiters&&L1(e,t[r].delimiters)}var z1={tokenize:I1,postProcess:R1};function B1(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==95&&r!==42)return!1;let i=e.scanDelims(e.pos,r===42);for(let t=0;t<i.length;t++){let t=e.push(`text`,``,0);t.content=String.fromCharCode(r),e.delimiters.push({marker:r,length:i.length,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return e.pos+=i.length,!0}function V1(e,t){let n=t.length;for(let r=n-1;r>=0;r--){let n=t[r];if(n.marker!==95&&n.marker!==42||n.end===-1)continue;let i=t[n.end],a=r>0&&t[r-1].end===n.end+1&&t[r-1].marker===n.marker&&t[r-1].token===n.token-1&&t[n.end+1].token===i.token+1,o=String.fromCharCode(n.marker),s=e.tokens[n.token];s.type=a?`strong_open`:`em_open`,s.tag=a?`strong`:`em`,s.nesting=1,s.markup=a?o+o:o,s.content=``;let c=e.tokens[i.token];c.type=a?`strong_close`:`em_close`,c.tag=a?`strong`:`em`,c.nesting=-1,c.markup=a?o+o:o,c.content=``,a&&(e.tokens[t[r-1].token].content=``,e.tokens[t[n.end+1].token].content=``,r--)}}function H1(e){let t=e.tokens_meta,n=e.tokens_meta.length;V1(e,e.delimiters);for(let r=0;r<n;r++)t[r]&&t[r].delimiters&&V1(e,t[r].delimiters)}var U1={tokenize:B1,postProcess:H1};function W1(e,t){let n,r,i,a,o=``,s=``,c=e.pos,l=!0;if(e.src.charCodeAt(e.pos)!==91)return!1;let u=e.pos,d=e.posMax,f=e.pos+1,p=e.md.helpers.parseLinkLabel(e,e.pos,!0);if(p<0)return!1;let m=p+1;if(m<d&&e.src.charCodeAt(m)===40){for(l=!1,m++;m<d&&(n=e.src.charCodeAt(m),!(!p$(n)&&n!==10));m++);if(m>=d)return!1;if(c=m,i=e.md.helpers.parseLinkDestination(e.src,m,e.posMax),i.ok){for(o=e.md.normalizeLink(i.str),e.md.validateLink(o)?m=i.pos:o=``,c=m;m<d&&(n=e.src.charCodeAt(m),!(!p$(n)&&n!==10));m++);if(i=e.md.helpers.parseLinkTitle(e.src,m,e.posMax),m<d&&c!==m&&i.ok)for(s=i.str,m=i.pos;m<d&&(n=e.src.charCodeAt(m),!(!p$(n)&&n!==10));m++);}(m>=d||e.src.charCodeAt(m)!==41)&&(l=!0),m++}if(l){if(e.env.references===void 0)return!1;if(m<d&&e.src.charCodeAt(m)===91?(c=m+1,m=e.md.helpers.parseLinkLabel(e,m),m>=0?r=e.src.slice(c,m++):m=p+1):m=p+1,r||=e.src.slice(f,p),a=e.env.references[v$(r)],!a)return e.pos=u,!1;o=a.href,s=a.title}if(!t){e.pos=f,e.posMax=p;let t=e.push(`link_open`,`a`,1),n=[[`href`,o]];t.attrs=n,s&&n.push([`title`,s]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push(`link_close`,`a`,-1)}return e.pos=m,e.posMax=d,!0}function G1(e,t){let n,r,i,a,o,s,c,l,u=``,d=e.pos,f=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91)return!1;let p=e.pos+2,m=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(m<0)return!1;if(a=m+1,a<f&&e.src.charCodeAt(a)===40){for(a++;a<f&&(n=e.src.charCodeAt(a),!(!p$(n)&&n!==10));a++);if(a>=f)return!1;for(l=a,s=e.md.helpers.parseLinkDestination(e.src,a,e.posMax),s.ok&&(u=e.md.normalizeLink(s.str),e.md.validateLink(u)?a=s.pos:u=``),l=a;a<f&&(n=e.src.charCodeAt(a),!(!p$(n)&&n!==10));a++);if(s=e.md.helpers.parseLinkTitle(e.src,a,e.posMax),a<f&&l!==a&&s.ok)for(c=s.str,a=s.pos;a<f&&(n=e.src.charCodeAt(a),!(!p$(n)&&n!==10));a++);else c=``;if(a>=f||e.src.charCodeAt(a)!==41)return e.pos=d,!1;a++}else{if(e.env.references===void 0)return!1;if(a<f&&e.src.charCodeAt(a)===91?(l=a+1,a=e.md.helpers.parseLinkLabel(e,a),a>=0?i=e.src.slice(l,a++):a=m+1):a=m+1,i||=e.src.slice(p,m),o=e.env.references[v$(i)],!o)return e.pos=d,!1;u=o.href,c=o.title}if(!t){r=e.src.slice(p,m);let t=[];e.md.inline.parse(r,e.md,e.env,t);let n=e.push(`image`,`img`,0),i=[[`src`,u],[`alt`,``]];n.attrs=i,n.children=t,n.content=r,c&&i.push([`title`,c])}return e.pos=a,e.posMax=f,!0}var K1=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,q1=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function J1(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==60)return!1;let r=e.pos,i=e.posMax;for(;;){if(++n>=i)return!1;let t=e.src.charCodeAt(n);if(t===60)return!1;if(t===62)break}let a=e.src.slice(r+1,n);if(q1.test(a)){let n=e.md.normalizeLink(a);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}if(K1.test(a)){let n=e.md.normalizeLink(`mailto:`+a);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}return!1}function Y1(e){return/^<a[>\s]/i.test(e)}function X1(e){return/^<\/a\s*>/i.test(e)}function Z1(e){let t=e|32;return t>=97&&t<=122}function Q1(e,t){if(!e.md.options.html)return!1;let n=e.posMax,r=e.pos;if(e.src.charCodeAt(r)!==60||r+2>=n)return!1;let i=e.src.charCodeAt(r+1);if(i!==33&&i!==63&&i!==47&&!Z1(i))return!1;let a=e.src.slice(r).match(v1);if(!a)return!1;if(!t){let t=e.push(`html_inline`,``,0);t.content=a[0],Y1(t.content)&&e.linkLevel++,X1(t.content)&&e.linkLevel--}return e.pos+=a[0].length,!0}var $1=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,e0=/^&([a-z][a-z0-9]{1,31});/i;function t0(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==38||n+1>=r)return!1;if(e.src.charCodeAt(n+1)===35){let r=e.src.slice(n).match($1);if(r){if(!t){let t=r[1][0].toLowerCase()===`x`?parseInt(r[1].slice(1),16):parseInt(r[1],10),n=e.push(`text_special`,``,0);n.content=QQ(t)?$Q(t):$Q(65533),n.markup=r[0],n.info=`entity`}return e.pos+=r[0].length,!0}}else{let r=e.src.slice(n).match(e0);if(r){let n=WQ(r[0]);if(n!==r[0]){if(!t){let t=e.push(`text_special`,``,0);t.content=n,t.markup=r[0],t.info=`entity`}return e.pos+=r[0].length,!0}}}return!1}function n0(e){let t={},n=e.length;if(!n)return;let r=0,i=-2,a=[];for(let o=0;o<n;o++){let n=e[o];if(a.push(0),(e[r].marker!==n.marker||i!==n.token-1)&&(r=o),i=n.token,n.length=n.length||0,!n.close)continue;t.hasOwnProperty(n.marker)||(t[n.marker]=[-1,-1,-1,-1,-1,-1]);let s=t[n.marker][(n.open?3:0)+n.length%3],c=r-a[r]-1,l=c;for(;c>s;c-=a[c]+1){let t=e[c];if(t.marker===n.marker&&t.open&&t.end<0){let r=!1;if((t.close||n.open)&&(t.length+n.length)%3==0&&(t.length%3!=0||n.length%3!=0)&&(r=!0),!r){let r=c>0&&!e[c-1].open?a[c-1]+1:0;a[o]=o-c+r,a[c]=r,n.open=!1,t.end=o,t.close=!1,l=-1,i=-2;break}}}l!==-1&&(t[n.marker][(n.open?3:0)+(n.length||0)%3]=l)}}function r0(e){let t=e.tokens_meta,n=e.tokens_meta.length;n0(e.delimiters);for(let e=0;e<n;e++)t[e]&&t[e].delimiters&&n0(t[e].delimiters)}function i0(e){let t,n,r=0,i=e.tokens,a=e.tokens.length;for(t=n=0;t<a;t++)i[t].nesting<0&&r--,i[t].level=r,i[t].nesting>0&&r++,i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}var a0=[[`text`,k1],[`linkify`,j1],[`newline`,M1],[`escape`,P1],[`backticks`,F1],[`strikethrough`,z1.tokenize],[`emphasis`,U1.tokenize],[`link`,W1],[`image`,G1],[`autolink`,J1],[`html_inline`,Q1],[`entity`,t0]],o0=[[`balance_pairs`,r0],[`strikethrough`,z1.postProcess],[`emphasis`,U1.postProcess],[`fragments_join`,i0]];function s0(){this.ruler=new O$;for(let e=0;e<a0.length;e++)this.ruler.push(a0[e][0],a0[e][1]);this.ruler2=new O$;for(let e=0;e<o0.length;e++)this.ruler2.push(o0[e][0],o0[e][1])}s0.prototype.skipToken=function(e){let t=e.pos,n=this.ruler.getRules(``),r=n.length,i=e.md.options.maxNesting,a=e.cache;if(a[t]!==void 0){e.pos=a[t];return}let o=!1;if(e.level<i){for(let i=0;i<r;i++)if(e.level++,o=n[i](e,!0),e.level--,o){if(t>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}else e.pos=e.posMax;o||e.pos++,a[t]=e.pos},s0.prototype.tokenize=function(e){let t=this.ruler.getRules(``),n=t.length,r=e.posMax,i=e.md.options.maxNesting;for(;e.pos<r;){let a=e.pos,o=!1;if(e.level<i){for(let r=0;r<n;r++)if(o=t[r](e,!1),o){if(a>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}if(o){if(e.pos>=r)break;continue}e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()},s0.prototype.parse=function(e,t,n,r){let i=new this.State(e,t,n,r);this.tokenize(i);let a=this.ruler2.getRules(``),o=a.length;for(let e=0;e<o;e++)a[e](i)},s0.prototype.State=D1;function c0(e){let t={};return e||={},t.src_Any=vQ.source,t.src_Cc=yQ.source,t.src_Z=CQ.source,t.src_P=xQ.source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join(`|`),t.src_ZCc=[t.src_Z,t.src_Cc].join(`|`),t.src_pseudo_letter=`(?:(?![><|]|`+t.src_ZPCc+`)`+t.src_Any+`)`,t.src_ip4=`(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)`,t.src_auth=`(?:(?:(?!`+t.src_ZCc+`|[@/\\[\\]()]).)+@)?`,t.src_port=`(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?`,t.src_host_terminator=`(?=$|[><|]|`+t.src_ZPCc+`)(?!`+(e[`---`]?`-(?!--)|`:`-|`)+`_|:\\d|\\.-|\\.(?!$|`+t.src_ZPCc+`))`,t.src_path=`(?:[/?#](?:(?!`+t.src_ZCc+`|[><|]|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!`+t.src_ZCc+`|\\]).)*\\]|\\((?:(?!`+t.src_ZCc+`|[)]).)*\\)|\\{(?:(?!`+t.src_ZCc+`|[}]).)*\\}|\\"(?:(?!`+t.src_ZCc+`|["]).)+\\"|\\'(?:(?!`+t.src_ZCc+`|[']).)+\\'|\\'(?=`+t.src_pseudo_letter+`|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!`+t.src_ZCc+`|[.]|$)|`+(e[`---`]?`\\-(?!--(?:[^-]|$))(?:-*)|`:`\\-+|`)+`,(?!`+t.src_ZCc+`|$)|;(?!`+t.src_ZCc+`|$)|\\!+(?!`+t.src_ZCc+`|[!]|$)|\\?(?!`+t.src_ZCc+`|[?]|$))+|\\/)?`,t.src_email_name=`[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*`,t.src_xn=`xn--[a-z0-9\\-]{1,59}`,t.src_domain_root=`(?:`+t.src_xn+`|`+t.src_pseudo_letter+`{1,63})`,t.src_domain=`(?:`+t.src_xn+`|(?:`+t.src_pseudo_letter+`)|(?:`+t.src_pseudo_letter+`(?:-|`+t.src_pseudo_letter+`){0,61}`+t.src_pseudo_letter+`))`,t.src_host=`(?:(?:(?:(?:`+t.src_domain+`)\\.)*`+t.src_domain+`))`,t.tpl_host_fuzzy=`(?:`+t.src_ip4+`|(?:(?:(?:`+t.src_domain+`)\\.)+(?:%TLDS%)))`,t.tpl_host_no_ip_fuzzy=`(?:(?:(?:`+t.src_domain+`)\\.)+(?:%TLDS%))`,t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:`+t.src_ZPCc+`|>|$))`,t.tpl_email_fuzzy=`(^|[><|]|"|\\(|`+t.src_ZCc+`)(`+t.src_email_name+`@`+t.tpl_host_fuzzy_strict+`)`,t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+`)`,t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+`)`,t}function l0(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}function u0(e){return Object.prototype.toString.call(e)}function d0(e){return u0(e)===`[object String]`}function f0(e){return u0(e)===`[object Object]`}function p0(e){return u0(e)===`[object RegExp]`}function m0(e){return u0(e)===`[object Function]`}function h0(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,`\\$&`)}var g0={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function _0(e){return Object.keys(e||{}).reduce(function(e,t){return e||g0.hasOwnProperty(t)},!1)}var v0={"http:":{validate:function(e,t,n){let r=e.slice(t);return n.re.http||(n.re.http=RegExp(`^\\/\\/`+n.re.src_auth+n.re.src_host_port_strict+n.re.src_path,`i`)),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":`http:`,"ftp:":`http:`,"//":{validate:function(e,t,n){let r=e.slice(t);return n.re.no_http||(n.re.no_http=RegExp(`^`+n.re.src_auth+`(?:localhost|(?:(?:`+n.re.src_domain+`)\\.)+`+n.re.src_domain_root+`)`+n.re.src_port+n.re.src_host_terminator+n.re.src_path,`i`)),n.re.no_http.test(r)?t>=3&&e[t-3]===`:`||t>=3&&e[t-3]===`/`?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){let r=e.slice(t);return n.re.mailto||(n.re.mailto=RegExp(`^`+n.re.src_email_name+`@`+n.re.src_host_strict,`i`)),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},y0=`a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]`,b0=`biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф`.split(`|`);function x0(e){return function(t,n){let r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function S0(){return function(e,t){t.normalize(e)}}function C0(e){let t=e.re=c0(e.__opts__),n=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||n.push(y0),n.push(t.src_xn),t.src_tlds=n.join(`|`);function r(e){return e.replace(`%TLDS%`,t.src_tlds)}t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),`i`),t.email_fuzzy_global=RegExp(r(t.tpl_email_fuzzy),`ig`),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),`i`),t.link_fuzzy_global=RegExp(r(t.tpl_link_fuzzy),`ig`),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),`i`),t.link_no_ip_fuzzy_global=RegExp(r(t.tpl_link_no_ip_fuzzy),`ig`),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),`i`);let i=[];e.__compiled__={};function a(e,t){throw Error(`(LinkifyIt) Invalid schema "`+e+`": `+t)}Object.keys(e.__schemas__).forEach(function(t){let n=e.__schemas__[t];if(n===null)return;let r={validate:null,link:null};if(e.__compiled__[t]=r,f0(n)){p0(n.validate)?r.validate=x0(n.validate):m0(n.validate)?r.validate=n.validate:a(t,n),m0(n.normalize)?r.normalize=n.normalize:n.normalize?a(t,n):r.normalize=S0();return}if(d0(n)){i.push(t);return}a(t,n)}),i.forEach(function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)}),e.__compiled__[``]={validate:null,normalize:S0()};let o=Object.keys(e.__compiled__).filter(function(t){return t.length>0&&e.__compiled__[t]}).map(h0).join(`|`);e.re.schema_test=RegExp(`(^|(?!_)(?:[><|]|`+t.src_ZPCc+`))(`+o+`)`,`i`),e.re.schema_search=RegExp(`(^|(?!_)(?:[><|]|`+t.src_ZPCc+`))(`+o+`)`,`ig`),e.re.schema_at_start=RegExp(`^`+e.re.schema_search.source,`i`),e.re.pretest=RegExp(`(`+e.re.schema_test.source+`)|(`+e.re.host_fuzzy_test.source+`)|@`,`i`)}function w0(e,t,n,r){let i=e.slice(n,r);this.schema=t.toLowerCase(),this.index=n,this.lastIndex=r,this.raw=i,this.text=i,this.url=i}function T0(e,t){if(!(this instanceof T0))return new T0(e,t);t||_0(e)&&(t=e,e={}),this.__opts__=l0({},g0,t),this.__schemas__=l0({},v0,e),this.__compiled__={},this.__tlds__=b0,this.__tlds_replaced__=!1,this.re={},C0(this)}T0.prototype.add=function(e,t){return this.__schemas__[e]=t,C0(this),this},T0.prototype.set=function(e){return this.__opts__=l0(this.__opts__,e),this},T0.prototype.test=function(e){if(!e.length)return!1;let t,n;if(this.re.schema_test.test(e)){for(n=this.re.schema_search,n.lastIndex=0;(t=n.exec(e))!==null;)if(this.testSchemaAt(e,t[2],n.lastIndex))return!0}return!!(this.__opts__.fuzzyLink&&this.__compiled__[`http:`]&&e.search(this.re.host_fuzzy_test)>=0&&e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy)!==null||this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`]&&e.indexOf(`@`)>=0&&e.match(this.re.email_fuzzy)!==null)},T0.prototype.pretest=function(e){return this.re.pretest.test(e)},T0.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},T0.prototype.match=function(e){let t=[],n=[],r=[],i=[],a,o,s;function c(e,t){return e?t?e.index===t.index?e.lastIndex>=t.lastIndex?e:t:e.index<t.index?e:t:e:t}if(!e.length)return null;if(this.re.schema_test.test(e))for(s=this.re.schema_search,s.lastIndex=0;(a=s.exec(e))!==null;)o=this.testSchemaAt(e,a[2],s.lastIndex),o&&n.push({schema:a[2],index:a.index+a[1].length,lastIndex:a.index+a[0].length+o});if(this.__opts__.fuzzyLink&&this.__compiled__[`http:`])for(s=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)r.push({schema:``,index:a.index+a[1].length,lastIndex:a.index+a[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__[`mailto:`])for(s=this.re.email_fuzzy_global,s.lastIndex=0;(a=s.exec(e))!==null;)i.push({schema:`mailto:`,index:a.index+a[1].length,lastIndex:a.index+a[0].length});let l=[0,0,0],u=0;for(;;){let a=[n[l[0]],i[l[1]],r[l[2]]],o=c(c(a[0],a[1]),a[2]);if(!o)break;if(o===a[0]?l[0]++:o===a[1]?l[1]++:l[2]++,o.index<u)continue;let s=new w0(e,o.schema,o.index,o.lastIndex);this.__compiled__[s.schema].normalize(s,this),t.push(s),u=o.lastIndex}return t.length?t:null},T0.prototype.matchAtStart=function(e){if(!e.length)return null;let t=this.re.schema_at_start.exec(e);if(!t)return null;let n=this.testSchemaAt(e,t[2],t[0].length);if(!n)return null;let r=new w0(e,t[2],t.index+t[1].length,t.index+t[0].length+n);return this.__compiled__[r.schema].normalize(r,this),r},T0.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(e,t,n){return e!==n[t-1]}).reverse(),C0(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,C0(this),this)},T0.prototype.normalize=function(e){e.schema||(e.url=`http://`+e.url),e.schema===`mailto:`&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:`+e.url)},T0.prototype.onCompile=function(){};var E0=2147483647,D0=36,O0=1,k0=26,A0=38,j0=700,M0=72,N0=128,P0=`-`,F0=/^xn--/,I0=/[^\0-\x7F]/,L0=/[\x2E\u3002\uFF0E\uFF61]/g,R0={overflow:`Overflow: input needs wider integers to process`,"not-basic":`Illegal input >= 0x80 (not a basic code point)`,"invalid-input":`Invalid input`},z0=D0-O0,B0=Math.floor,V0=String.fromCharCode;function H0(e){throw RangeError(R0[e])}function U0(e,t){let n=[],r=e.length;for(;r--;)n[r]=t(e[r]);return n}function W0(e,t){let n=e.split(`@`),r=``;n.length>1&&(r=n[0]+`@`,e=n[1]),e=e.replace(L0,`.`);let i=U0(e.split(`.`),t).join(`.`);return r+i}function G0(e){let t=[],n=0,r=e.length;for(;n<r;){let i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){let r=e.charCodeAt(n++);(r&64512)==56320?t.push(((i&1023)<<10)+(r&1023)+65536):(t.push(i),n--)}else t.push(i)}return t}var K0=e=>String.fromCodePoint(...e),q0=function(e){return e>=48&&e<58?26+(e-48):e>=65&&e<91?e-65:e>=97&&e<123?e-97:D0},J0=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},Y0=function(e,t,n){let r=0;for(e=n?B0(e/j0):e>>1,e+=B0(e/t);e>455;r+=D0)e=B0(e/z0);return B0(r+36*e/(e+A0))},X0=function(e){let t=[],n=e.length,r=0,i=N0,a=M0,o=e.lastIndexOf(P0);o<0&&(o=0);for(let n=0;n<o;++n)e.charCodeAt(n)>=128&&H0(`not-basic`),t.push(e.charCodeAt(n));for(let s=o>0?o+1:0;s<n;){let o=r;for(let t=1,i=D0;;i+=D0){s>=n&&H0(`invalid-input`);let o=q0(e.charCodeAt(s++));o>=D0&&H0(`invalid-input`),o>B0((E0-r)/t)&&H0(`overflow`),r+=o*t;let c=i<=a?O0:i>=a+k0?k0:i-a;if(o<c)break;let l=D0-c;t>B0(E0/l)&&H0(`overflow`),t*=l}let c=t.length+1;a=Y0(r-o,c,o==0),B0(r/c)>E0-i&&H0(`overflow`),i+=B0(r/c),r%=c,t.splice(r++,0,i)}return String.fromCodePoint(...t)},Z0=function(e){let t=[];e=G0(e);let n=e.length,r=N0,i=0,a=M0;for(let n of e)n<128&&t.push(V0(n));let o=t.length,s=o;for(o&&t.push(P0);s<n;){let n=E0;for(let t of e)t>=r&&t<n&&(n=t);let c=s+1;n-r>B0((E0-i)/c)&&H0(`overflow`),i+=(n-r)*c,r=n;for(let n of e)if(n<r&&++i>E0&&H0(`overflow`),n===r){let e=i;for(let n=D0;;n+=D0){let r=n<=a?O0:n>=a+k0?k0:n-a;if(e<r)break;let i=e-r,o=D0-r;t.push(V0(J0(r+i%o,0))),e=B0(i/o)}t.push(V0(J0(e,0))),a=Y0(i,c,s===o),i=0,++s}++i,++r}return t.join(``)},Q0={version:`2.3.1`,ucs2:{decode:G0,encode:K0},decode:X0,encode:Z0,toASCII:function(e){return W0(e,function(e){return I0.test(e)?`xn--`+Z0(e):e})},toUnicode:function(e){return W0(e,function(e){return F0.test(e)?X0(e.slice(4).toLowerCase()):e})}},$0={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:20},components:{core:{rules:[`normalize`,`block`,`inline`,`text_join`]},block:{rules:[`paragraph`]},inline:{rules:[`text`],rules2:[`balance_pairs`,`fragments_join`]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:20},components:{core:{rules:[`normalize`,`block`,`inline`,`text_join`]},block:{rules:[`blockquote`,`code`,`fence`,`heading`,`hr`,`html_block`,`lheading`,`list`,`reference`,`paragraph`]},inline:{rules:[`autolink`,`backticks`,`emphasis`,`entity`,`escape`,`html_inline`,`image`,`link`,`newline`,`text`],rules2:[`balance_pairs`,`emphasis`,`fragments_join`]}}}},e2=/^(vbscript|javascript|file|data):/,t2=/^data:image\/(gif|png|jpeg|webp);/;function n2(e){let t=e.trim().toLowerCase();return e2.test(t)?t2.test(t):!0}var r2=[`http:`,`https:`,`mailto:`];function i2(e){let t=gQ(e,!0);if(t.hostname&&(!t.protocol||r2.indexOf(t.protocol)>=0))try{t.hostname=Q0.toASCII(t.hostname)}catch{}return rQ(iQ(t))}function a2(e){let t=gQ(e,!0);if(t.hostname&&(!t.protocol||r2.indexOf(t.protocol)>=0))try{t.hostname=Q0.toUnicode(t.hostname)}catch{}return eQ(iQ(t),eQ.defaultChars+`%`)}function o2(e,t){if(!(this instanceof o2))return new o2(e,t);t||qQ(e)||(t=e||{},e=`default`),this.inline=new s0,this.block=new E1,this.core=new n1,this.renderer=new D$,this.linkify=new T0,this.validateLink=n2,this.normalizeLink=i2,this.normalizeLinkText=a2,this.utils=GQ,this.helpers=XQ({},T$),this.options={},this.configure(e),t&&this.set(t)}o2.prototype.set=function(e){return XQ(this.options,e),this},o2.prototype.configure=function(e){let t=this;if(qQ(e)){let t=e;if(e=$0[t],!e)throw Error('Wrong `markdown-it` preset "'+t+`", check name`)}if(!e)throw Error("Wrong `markdown-it` preset, can't be empty");return e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach(function(n){e.components[n].rules&&t[n].ruler.enableOnly(e.components[n].rules),e.components[n].rules2&&t[n].ruler2.enableOnly(e.components[n].rules2)}),this},o2.prototype.enable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(function(t){n=n.concat(this[t].ruler.enable(e,!0))},this),n=n.concat(this.inline.ruler2.enable(e,!0));let r=e.filter(function(e){return n.indexOf(e)<0});if(r.length&&!t)throw Error(`MarkdownIt. Failed to enable unknown rule(s): `+r);return this},o2.prototype.disable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(function(t){n=n.concat(this[t].ruler.disable(e,!0))},this),n=n.concat(this.inline.ruler2.disable(e,!0));let r=e.filter(function(e){return n.indexOf(e)<0});if(r.length&&!t)throw Error(`MarkdownIt. Failed to disable unknown rule(s): `+r);return this},o2.prototype.use=function(e){let t=[this].concat(Array.prototype.slice.call(arguments,1));return e.apply(e,t),this},o2.prototype.parse=function(e,t){if(typeof e!=`string`)throw Error(`Input data should be a String`);let n=new this.core.State(e,this,t);return this.core.process(n),n.tokens},o2.prototype.render=function(e,t){return t||={},this.renderer.render(this.parse(e,t),this.options,t)},o2.prototype.parseInline=function(e,t){let n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens},o2.prototype.renderInline=function(e,t){return t||={},this.renderer.render(this.parseInline(e,t),this.options,t)};var s2=new $d({nodes:{doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}},blockquote:{content:`block+`,group:`block`,parseDOM:[{tag:`blockquote`}],toDOM(){return[`blockquote`,0]}},horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM(){return[`div`,[`hr`]]}},heading:{attrs:{level:{default:1}},content:`(text | image)*`,group:`block`,defining:!0,parseDOM:[{tag:`h1`,attrs:{level:1}},{tag:`h2`,attrs:{level:2}},{tag:`h3`,attrs:{level:3}},{tag:`h4`,attrs:{level:4}},{tag:`h5`,attrs:{level:5}},{tag:`h6`,attrs:{level:6}}],toDOM(e){return[`h`+e.attrs.level,0]}},code_block:{content:`text*`,group:`block`,code:!0,defining:!0,marks:``,attrs:{params:{default:``}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>({params:e.getAttribute(`data-params`)||``})}],toDOM(e){return[`pre`,e.attrs.params?{"data-params":e.attrs.params}:{},[`code`,0]]}},ordered_list:{content:`list_item+`,group:`block`,attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:`ol`,getAttrs(e){return{order:e.hasAttribute(`start`)?+e.getAttribute(`start`):1,tight:e.hasAttribute(`data-tight`)}}}],toDOM(e){return[`ol`,{start:e.attrs.order==1?null:e.attrs.order,"data-tight":e.attrs.tight?`true`:null},0]}},bullet_list:{content:`list_item+`,group:`block`,attrs:{tight:{default:!1}},parseDOM:[{tag:`ul`,getAttrs:e=>({tight:e.hasAttribute(`data-tight`)})}],toDOM(e){return[`ul`,{"data-tight":e.attrs.tight?`true`:null},0]}},list_item:{content:`block+`,defining:!0,parseDOM:[{tag:`li`}],toDOM(){return[`li`,0]}},text:{group:`inline`},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[src]`,getAttrs(e){return{src:e.getAttribute(`src`),title:e.getAttribute(`title`),alt:e.getAttribute(`alt`)}}}],toDOM(e){return[`img`,e.attrs]}},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}}},marks:{em:{parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`},{style:`font-style=normal`,clearMark:e=>e.type.name==`em`}],toDOM(){return[`em`]}},strong:{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return[`strong`]}},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM(e){return[`a`,e.attrs]}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return[`code`]}}}});function c2(e,t){if(e.isText&&t.isText&&cd.sameSet(e.marks,t.marks))return e.withText(e.text+t.text)}var l2=class{constructor(e,t){this.schema=e,this.tokenHandlers=t,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:cd.none}]}top(){return this.stack[this.stack.length-1]}push(e){this.stack.length&&this.top().content.push(e)}addText(e){if(!e)return;let t=this.top(),n=t.content,r=n[n.length-1],i=this.schema.text(e,t.marks),a;r&&(a=c2(r,i))?n[n.length-1]=a:n.push(i)}openMark(e){let t=this.top();t.marks=e.addToSet(t.marks)}closeMark(e){let t=this.top();t.marks=e.removeFromSet(t.marks)}parseTokens(e){for(let t=0;t<e.length;t++){let n=e[t],r=this.tokenHandlers[n.type];if(!r)throw Error("Token type `"+n.type+"` not supported by Markdown parser");r(this,n,e,t)}}addNode(e,t,n){let r=this.top(),i=e.createAndFill(t,n,r?r.marks:[]);return i?(this.push(i),i):null}openNode(e,t){this.stack.push({type:e,attrs:t,content:[],marks:cd.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}};function u2(e,t,n,r){return e.getAttrs?e.getAttrs(t,n,r):e.attrs instanceof Function?e.attrs(t):e.attrs}function d2(e,t){return e.noCloseToken||t==`code_inline`||t==`code_block`||t==`fence`}function f2(e){return e[e.length-1]==`
|
|
229
|
-
`?e.slice(0,e.length-1):e}function p2(){}function m2(e,t){let n=Object.create(null);for(let r in t){let i=t[r];if(i.block){let t=e.nodeType(i.block);d2(i,r)?n[r]=(e,n,r,a)=>{e.openNode(t,u2(i,n,r,a)),e.addText(f2(n.content)),e.closeNode()}:(n[r+`_open`]=(e,n,r,a)=>e.openNode(t,u2(i,n,r,a)),n[r+`_close`]=e=>e.closeNode())}else if(i.node){let t=e.nodeType(i.node);n[r]=(e,n,r,a)=>e.addNode(t,u2(i,n,r,a))}else if(i.mark){let t=e.marks[i.mark];d2(i,r)?n[r]=(e,n,r,a)=>{e.openMark(t.create(u2(i,n,r,a))),e.addText(f2(n.content)),e.closeMark(t)}:(n[r+`_open`]=(e,n,r,a)=>e.openMark(t.create(u2(i,n,r,a))),n[r+`_close`]=e=>e.closeMark(t))}else if(i.ignore)d2(i,r)?n[r]=p2:(n[r+`_open`]=p2,n[r+`_close`]=p2);else throw RangeError(`Unrecognized parsing spec `+JSON.stringify(i))}return n.text=(e,t)=>e.addText(t.content),n.inline=(e,t)=>e.parseTokens(t.children),n.softbreak=n.softbreak||(e=>e.addText(` `)),n}var h2=class{constructor(e,t,n){this.schema=e,this.tokenizer=t,this.tokens=n,this.tokenHandlers=m2(e,n)}parse(e,t={}){let n=new l2(this.schema,this.tokenHandlers),r;n.parseTokens(this.tokenizer.parse(e,t));do r=n.closeNode();while(n.stack.length);return r||this.schema.topNodeType.createAndFill()}};function g2(e,t){for(;++t<e.length;)if(e[t].type!=`list_item_open`)return e[t].hidden;return!1}new h2(s2,o2(`commonmark`,{html:!1}),{blockquote:{block:`blockquote`},paragraph:{block:`paragraph`},list_item:{block:`list_item`},bullet_list:{block:`bullet_list`,getAttrs:(e,t,n)=>({tight:g2(t,n)})},ordered_list:{block:`ordered_list`,getAttrs:(e,t,n)=>({order:+e.attrGet(`start`)||1,tight:g2(t,n)})},heading:{block:`heading`,getAttrs:e=>({level:+e.tag.slice(1)})},code_block:{block:`code_block`,noCloseToken:!0},fence:{block:`code_block`,getAttrs:e=>({params:e.info||``}),noCloseToken:!0},hr:{node:`horizontal_rule`},image:{node:`image`,getAttrs:e=>({src:e.attrGet(`src`),title:e.attrGet(`title`)||null,alt:e.children[0]&&e.children[0].content||null})},hardbreak:{node:`hard_break`},em:{mark:`em`},strong:{mark:`strong`},link:{mark:`link`,getAttrs:e=>({href:e.attrGet(`href`),title:e.attrGet(`title`)||null})},code_inline:{mark:`code`,noCloseToken:!0}});var _2={open:``,close:``,mixable:!0};new class{constructor(e,t,n={}){this.nodes=e,this.marks=t,this.options=n}serialize(e,t={}){t=Object.assign({},this.options,t);let n=new b2(this.nodes,this.marks,t);return n.renderContent(e),n.out}}({blockquote(e,t){e.wrapBlock(`> `,null,t,()=>e.renderContent(t))},code_block(e,t){let n=t.textContent.match(/`{3,}/gm),r=n?n.sort().slice(-1)[0]+"`":"```";e.write(r+(t.attrs.params||``)+`
|
|
230
|
-
`),e.text(t.textContent,!1),e.write(`
|
|
231
|
-
`),e.write(r),e.closeBlock(t)},heading(e,t){e.write(e.repeat(`#`,t.attrs.level)+` `),e.renderInline(t,!1),e.closeBlock(t)},horizontal_rule(e,t){e.write(t.attrs.markup||`---`),e.closeBlock(t)},bullet_list(e,t){e.renderList(t,` `,()=>(t.attrs.bullet||`*`)+` `)},ordered_list(e,t){let n=t.attrs.order||1,r=String(n+t.childCount-1).length,i=e.repeat(` `,r+2);e.renderList(t,i,t=>{let i=String(n+t);return e.repeat(` `,r-i.length)+i+`. `})},list_item(e,t){e.renderContent(t)},paragraph(e,t){e.renderInline(t),e.closeBlock(t)},image(e,t){e.write(`]/g,`\\$&`)+(t.attrs.title?` "`+t.attrs.title.replace(/"/g,`\\"`)+`"`:``)+`)`)},hard_break(e,t,n,r){for(let i=r+1;i<n.childCount;i++)if(n.child(i).type!=t.type){e.write(`\\
|
|
232
|
-
`);return}},text(e,t){e.text(t.text,!e.inAutolink)}},{em:{open:`*`,close:`*`,mixable:!0,expelEnclosingWhitespace:!0},strong:{open:`**`,close:`**`,mixable:!0,expelEnclosingWhitespace:!0},link:{open(e,t,n,r){return e.inAutolink=y2(t,n,r),e.inAutolink?`<`:`[`},close(e,t,n,r){let{inAutolink:i}=e;return e.inAutolink=void 0,i?`>`:`](`+t.attrs.href.replace(/[\(\)"]/g,`\\$&`)+(t.attrs.title?` "${t.attrs.title.replace(/"/g,`\\"`)}"`:``)+`)`},mixable:!0},code:{open(e,t,n,r){return v2(n.child(r),-1)},close(e,t,n,r){return v2(n.child(r-1),1)},escape:!1}});function v2(e,t){let n=/`+/g,r,i=0;if(e.isText)for(;r=n.exec(e.text);)i=Math.max(i,r[0].length);let a=i>0&&t>0?" `":"`";for(let e=0;e<i;e++)a+="`";return i>0&&t<0&&(a+=` `),a}function y2(e,t,n){if(e.attrs.title||!/^\w+:/.test(e.attrs.href))return!1;let r=t.child(n);return!r.isText||r.text!=e.attrs.href||r.marks[r.marks.length-1]!=e?!1:n==t.childCount-1||!e.isInSet(t.child(n+1).marks)}var b2=class{constructor(e,t,n){this.nodes=e,this.marks=t,this.options=n,this.delim=``,this.out=``,this.closed=null,this.inAutolink=void 0,this.atBlockStart=!1,this.inTightList=!1,this.options.tightLists===void 0&&(this.options.tightLists=!1),this.options.hardBreakNodeName===void 0&&(this.options.hardBreakNodeName=`hard_break`)}flushClose(e=2){if(this.closed){if(this.atBlank()||(this.out+=`
|
|
233
|
-
`),e>1){let t=this.delim,n=/\s+$/.exec(t);n&&(t=t.slice(0,t.length-n[0].length));for(let n=1;n<e;n++)this.out+=t+`
|
|
234
|
-
`}this.closed=null}}getMark(e){let t=this.marks[e];if(!t){if(this.options.strict!==!1)throw Error(`Mark type \`${e}\` not supported by Markdown renderer`);t=_2}return t}wrapBlock(e,t,n,r){let i=this.delim;this.write(t??e),this.delim+=e,r(),this.delim=i,this.closeBlock(n)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){this.atBlank()||(this.out+=`
|
|
235
|
-
`)}write(e){this.flushClose(),this.delim&&this.atBlank()&&(this.out+=this.delim),e&&(this.out+=e)}closeBlock(e){this.closed=e}text(e,t=!0){let n=e.split(`
|
|
236
|
-
`);for(let e=0;e<n.length;e++)this.write(),!t&&n[e][0]==`[`&&/(^|[^\\])\!$/.test(this.out)&&(this.out=this.out.slice(0,this.out.length-1)+`\\!`),this.out+=t?this.esc(n[e],this.atBlockStart):n[e],e!=n.length-1&&(this.out+=`
|
|
237
|
-
`)}render(e,t,n){if(this.nodes[e.type.name])this.nodes[e.type.name](this,e,t,n);else if(this.options.strict!==!1)throw Error("Token type `"+e.type.name+"` not supported by Markdown renderer");else e.type.isLeaf||(e.type.inlineContent?this.renderInline(e):this.renderContent(e),e.isBlock&&this.closeBlock(e))}renderContent(e){e.forEach((t,n,r)=>this.render(t,e,r))}renderInline(e,t=!0){this.atBlockStart=t;let n=[],r=``,i=(t,i,a)=>{let o=t?t.marks:[];t&&t.type.name===this.options.hardBreakNodeName&&(o=o.filter(t=>{if(a+1==e.childCount)return!1;let n=e.child(a+1);return t.isInSet(n.marks)&&(!n.isText||/\S/.test(n.text))}));let s=r;if(r=``,t&&t.isText&&o.some(e=>{let t=this.getMark(e.type.name);return t&&t.expelEnclosingWhitespace&&!e.isInSet(n)})){let[e,r,i]=/^(\s*)(.*)$/m.exec(t.text);r&&(s+=r,t=i?t.withText(i):null,t||(o=n))}if(t&&t.isText&&o.some(t=>{let n=this.getMark(t.type.name);return n&&n.expelEnclosingWhitespace&&!this.isMarkAhead(e,a+1,t)})){let[e,i,a]=/^(.*?)(\s*)$/m.exec(t.text);a&&(r=a,t=i?t.withText(i):null,t||(o=n))}let c=o.length?o[o.length-1]:null,l=c&&this.getMark(c.type.name).escape===!1,u=o.length-+!!l;outer:for(let e=0;e<u;e++){let t=o[e];if(!this.getMark(t.type.name).mixable)break;for(let r=0;r<n.length;r++){let i=n[r];if(!this.getMark(i.type.name).mixable)break;if(t.eq(i)){e>r?o=o.slice(0,r).concat(t).concat(o.slice(r,e)).concat(o.slice(e+1,u)):r>e&&(o=o.slice(0,e).concat(o.slice(e+1,r)).concat(t).concat(o.slice(r,u)));continue outer}}}let d=0;for(;d<Math.min(n.length,u)&&o[d].eq(n[d]);)++d;for(;d<n.length;)this.text(this.markString(n.pop(),!1,e,a),!1);if(s&&this.text(s),t){for(;n.length<u;){let t=o[n.length];n.push(t),this.text(this.markString(t,!0,e,a),!1),this.atBlockStart=!1}l&&t.isText?this.text(this.markString(c,!0,e,a)+t.text+this.markString(c,!1,e,a+1),!1):this.render(t,e,a),this.atBlockStart=!1}t?.isText&&t.nodeSize>0&&(this.atBlockStart=!1)};e.forEach(i),i(null,0,e.childCount),this.atBlockStart=!1}renderList(e,t,n){this.closed&&this.closed.type==e.type?this.flushClose(3):this.inTightList&&this.flushClose(1);let r=e.attrs.tight===void 0?this.options.tightLists:e.attrs.tight,i=this.inTightList;this.inTightList=r,e.forEach((i,a,o)=>{o&&r&&this.flushClose(1),this.wrapBlock(t,n(o),e,()=>this.render(i,e,o))}),this.inTightList=i}esc(e,t=!1){return e=e.replace(/[`*\\~\[\]_]/g,(t,n)=>t==`_`&&n>0&&n+1<e.length&&e[n-1].match(/\w/)&&e[n+1].match(/\w/)?t:`\\`+t),t&&(e=e.replace(/^(\+[ ]|[\-*>])/,`\\$&`).replace(/^(\s*)(#{1,6})(\s|$)/,`$1\\$2$3`).replace(/^(\s*\d+)\.\s/,`$1\\. `)),this.options.escapeExtraCharacters&&(e=e.replace(this.options.escapeExtraCharacters,`\\$&`)),e}quote(e){let t=e.indexOf(`"`)==-1?`""`:e.indexOf(`'`)==-1?`''`:`()`;return t[0]+e+t[1]}repeat(e,t){let n=``;for(let r=0;r<t;r++)n+=e;return n}markString(e,t,n,r){let i=this.getMark(e.type.name),a=t?i.open:i.close;return typeof a==`string`?a:a(this,e,n,r)}getEnclosingWhitespace(e){return{leading:(e.match(/^(\s+)/)||[void 0])[0],trailing:(e.match(/(\s+)$/)||[void 0])[0]}}isMarkAhead(e,t,n){for(;;t++){if(t>=e.childCount)return!1;let r=e.child(t);if(r.type.name!=this.options.hardBreakNodeName)return n.isInSet(r.marks);t++}}};function x2(e){let t={blockquote:{block:`blockquote`},paragraph:{block:`paragraph`},list_item:{block:`listItem`},bullet_list:{block:`bulletList`},ordered_list:{block:`orderedList`,getAttrs:e=>({start:+(e.attrGet(`start`)??1)||1})},heading:{block:`heading`,getAttrs:e=>({level:+e.tag.slice(1)})},code_block:{block:`codeBlock`,noCloseToken:!0,getAttrs:e=>({language:e.info?.trim()||null})},fence:{block:`codeBlock`,noCloseToken:!0,getAttrs:e=>({language:e.info?.trim()||null})},hr:{node:`horizontalRule`},hardbreak:{node:`hardBreak`},softbreak:{ignore:!0,noCloseToken:!0},html_block:{ignore:!0,noCloseToken:!0},html_inline:{ignore:!0,noCloseToken:!0},image:{ignore:!0,noCloseToken:!0},em:{mark:`italic`},strong:{mark:`bold`},s:{mark:`strike`},code_inline:{mark:`code`,noCloseToken:!0},link:{mark:`link`,getAttrs:e=>({href:kW(e.attrGet(`href`)),title:e.attrGet(`title`)||null})}},n={};for(let[r,i]of Object.entries(t))i.node&&!e.nodes[i.node]||i.block&&!e.nodes[i.block]||i.mark&&!e.marks[i.mark]||(n[r]=i);return n}function S2(e){return new h2(e,o2(`commonmark`,{html:!1}).enable([`strikethrough`,`linkify`]),x2(e))}function C2(e){return e?!!(/^\s{0,3}(#{1,6}\s|[-*+]\s|\d+[.)]\s|>\s|```|~~~|-{3,}\s*$|\*{3,}\s*$|_{3,}\s*$)/m.test(e)||/(\*\*\S(?:[^*\n]*\S)?\*\*|__\S(?:[^_\n]*\S)?__|\*\S(?:[^*\n]*\S)?\*|`[^`\n]+`|~~\S(?:[^~\n]*\S)?~~|\[[^\]\n]+\]\([^)\n]+\))/.test(e)):!1}function w2(e,t){if(!C2(e))return null;let n;try{let r=S2(t).parse(e);if(!r)return null;n=r}catch{return null}return n.childCount===0?null:Q.maxOpen(n.content)}var T2=V(`<div role="presentation" data-testid="editor-root"></div>`);function E2(e,t){k(t,!0);let n=new Set([...wa].filter(e=>e!==`.docx`));function r(e,t){let r=t.includes(`\\`)?`\\`:`/`,i=e.indexOf(`#`),a=i>=0?e.slice(0,i):e;if(!a)return null;let o=a.match(/\.[^./\\]+$/),s=o?o[0].toLowerCase():``;if(!n.has(s))return null;let c=t.split(r);c.pop();let l=a.replace(/\//g,r).split(r),u=[...c];for(let e of l)e===`..`?u.length>0&&u.pop():e!==`.`&&u.push(e);return u.join(r)}let i=M(null),a=null,o=j(()=>t.format===`docx`);L(()=>{if(t.ydoc,t.provider,!a)return;let e=new nU({element:a,extensions:[...IX(),bW.configure({document:t.ydoc}),CW.configure({provider:t.provider,user:{name:tj(),color:`var(--tandem-warning)`}}),UX.configure({ydoc:t.ydoc}),XX.configure({ydoc:t.ydoc}),OZ.configure({filePath:Ar(()=>t.currentFilePath??null)}),tZ.configure({ydoc:t.ydoc}),iZ.configure({ydoc:t.ydoc}),ZZ.configure({onOpenChange:t.onSlashCommandMenuChange}),pZ,AZ],editorProps:{attributes:{class:`tandem-editor`,style:`outline: none; font-size: var(--tandem-editor-font-size, 16px); line-height: 1.6;`},clipboardTextParser:(e,t,n,r)=>{if(!n){let t=w2(e,r.state.schema);if(t)return t}return EW(e,r.state.schema,t.marks())}},editable:Ar(()=>!t.readOnly),autofocus:Ar(()=>!t.readOnly)});N(i,e,!0),Ar(()=>t.onEditorReady?.(e));let n=IW(e,{openHref:e=>{c(e)}});return()=>{Ar(()=>t.onEditorReady?.(null)),n(),e.destroy(),z(i)===e&&N(i,null)}});let s;L(()=>{let e=z(i);if(!e)return;let n=t.readOnly;s!==n&&(s=n,e.setEditable(!n))}),L(()=>{let e=z(i);if(e)return rj(t=>e.commands.updateUser({name:t}))}),L(()=>{let e=z(i);if(!e)return;let n=e.view.dom;n.querySelectorAll(`.tandem-annotation-active`).forEach(e=>{e.classList.remove(`tandem-annotation-active`)}),t.activeAnnotationId&&n.querySelectorAll(`[data-annotation-id="${CSS.escape(t.activeAnnotationId)}"]`).forEach(e=>{e.classList.add(`tandem-annotation-active`)})});async function c(e){if(!(!e||e.startsWith(`#`))){if(OW(e)){window.open(e,`_blank`,`noopener,noreferrer`);return}if(t.currentFilePath){let n=r(e,t.currentFilePath);if(n){let e=await Ch(n);e.ok||console.warn(`[tandem] Could not open linked file "${n}": ${e.error}`)}}}}async function l(e){let n=e.target.closest(`a[href]`);if(n){let t=n.getAttribute(`href`)??``;if(!t||t.startsWith(`#`))return;e.preventDefault(),await c(t);return}let r={highlight:2,comment:1,note:0},i=e.target.closest(`[data-annotation-id]`),a=null,o=-1/0;for(;i;){let e=i.getAttribute(`data-annotation-id`);if(e){let t=r[i.getAttribute(`data-annotation-type`)??``]??-1;t>o&&(o=t,a=e)}let t=i.parentElement;i=t?t.closest(`[data-annotation-id]`):null}a&&t.onAnnotationClick?t.onAnnotationClick(a):a||t.onClearAnnotation?.()}var u=T2();let d;fa(u,e=>a=e,()=>a),R(()=>d=Ui(u,1,``,null,d,{"tandem-paged":z(o)})),B(`click`,u,l),H(e,u),A()}Br([`click`]);var D2=V(`<div data-testid="find-scope-pills" class="fr-scope-row svelte-1q9bff2"><button data-testid="find-scope-doc">This document</button> <button data-testid="find-scope-tabs">Open tabs</button></div>`),O2=V(`<div class="fr-error svelte-1q9bff2" role="alert"> </div>`),k2=V(`<div class="fr-warning svelte-1q9bff2" role="status"> </div>`),A2=V(`<div class="fr-xdoc-status svelte-1q9bff2">Searching…</div>`),j2=V(`<div class="fr-xdoc-status svelte-1q9bff2">No matches in open tabs</div>`),M2=V(`<div class="fr-xdoc-snip svelte-1q9bff2"> </div>`),N2=V(`<div class="fr-xdoc-row svelte-1q9bff2"><div class="fr-xdoc-name svelte-1q9bff2"> <span class="fr-xdoc-count svelte-1q9bff2"> </span></div> <!></div>`),P2=V(`<div data-testid="find-cross-doc-results" class="fr-xdoc svelte-1q9bff2"><!></div>`),F2=V(`<div data-testid="find-replace-bar" role="dialog" tabindex="-1" aria-modal="false" aria-label="Find and replace" class="fr-bar svelte-1q9bff2"><!> <div class="fr-row svelte-1q9bff2"><input data-testid="find-input" type="text" placeholder="Find…" aria-label="Find"/> <span data-testid="find-match-count" class="fr-count svelte-1q9bff2"><!></span> <button data-testid="find-prev-btn" class="fr-nav svelte-1q9bff2" title="Previous match (Shift+Enter)" aria-label="Previous match">↑</button> <button data-testid="find-next-btn" class="fr-nav svelte-1q9bff2" title="Next match (Enter)" aria-label="Next match">↓</button> <button data-testid="find-close-btn" class="fr-close svelte-1q9bff2" title="Close (Esc)" aria-label="Close find bar">×</button></div> <!> <div class="fr-options svelte-1q9bff2"><label class="fr-toggle svelte-1q9bff2"><input data-testid="find-case-toggle" type="checkbox"/> Aa</label> <label class="fr-toggle svelte-1q9bff2"><input data-testid="find-word-toggle" type="checkbox"/> \\b</label> <label class="fr-toggle svelte-1q9bff2"><input data-testid="find-regex-toggle" type="checkbox"/> .*</label></div> <div class="fr-row svelte-1q9bff2"><input data-testid="replace-input" type="text" placeholder="Replace with…" aria-label="Replace with" class="fr-input svelte-1q9bff2"/> <button data-testid="replace-btn" class="fr-replace-btn svelte-1q9bff2">Replace</button> <button data-testid="replace-all-btn" class="fr-replace-btn svelte-1q9bff2"><!></button></div> <!> <!></div>`);function I2(e,t){k(t,!0);let n=q(t,`tabs`,19,()=>[]),r=M(`doc`),i=M(un([])),a=M(!1);L(()=>{n().length<=1&&z(r)===`tabs`&&(N(r,`doc`),N(i,[],!0),N(a,!1))});function o(e){let t=e.getXmlFragment(`default`),n=[];function r(e){if(e instanceof QT)n.push(e.toString());else{for(let t=0;t<e.length;t++){let n=e.get(t);(n instanceof QT||n instanceof qT)&&r(n)}e instanceof qT&&e.nodeName!==`text`&&n.push(` `)}}return r(t),n.join(``)}function s(e,t,n){let r=o(e),i=n?t:t.toLowerCase(),a=n?r:r.toLowerCase(),s=[],c=0,l=0;for(;(l=a.indexOf(i,l))!==-1;){if(c++,s.length<3){let e=Math.max(0,l-30),t=Math.min(r.length,l+i.length+30),n=r.slice(e,t).replace(/\s+/g,` `).trim();s.push((e>0?`…`:``)+n+(t<r.length?`…`:``))}l+=i.length}return{count:c,snippets:s}}let c;va(()=>clearTimeout(c));function l(e,t){if(clearTimeout(c),!e){N(i,[],!0),N(a,!1);return}N(a,!0),c=setTimeout(()=>{let r=[];for(let i of n()){if(!i.ydoc)continue;let{count:n,snippets:a}=s(i.ydoc,e,t);n>0&&r.push({tabId:i.id,fileName:i.fileName,count:n,snippets:a})}N(i,r,!0),N(a,!1)},300)}let u=M(``),d=M(``),f=M(!1),p=M(!1),m=M(!1),h=M(null),g=M(!1),_=M(null),v=M(null),y=M(0),b=j(()=>(z(y),t.editor?mZ(t.editor.state):void 0)),x=j(()=>z(b)?.matches.length??0),S=j(()=>z(b)?.activeIndex??-1),C=M(null);L(()=>{t.open&&z(C)?.focus()});let w=!1;L(()=>{let e=t.open&&!w;w=t.open,!(!e||!t.forceScope)&&(t.forceScope===`tabs`&&n().length>1?(N(r,`tabs`),l(z(u),z(f))):N(r,`doc`))}),L(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>sn(y);return e.on(`update`,n),e.on(`selectionUpdate`,n),()=>{e.isDestroyed||(e.off(`update`,n),e.off(`selectionUpdate`,n))}});function ee(){if(z(r)===`tabs`){l(z(u),z(f));return}let e=t.editor;if(!e||!z(u)){N(h,null),e?.commands.findClose();return}if(z(m))try{new RegExp(z(u)),N(h,null)}catch(e){N(h,e instanceof Error?e.message:`Invalid regex`,!0);return}else N(h,null);let n={query:z(u),caseSensitive:z(f),wholeWord:z(p),regexMode:z(m)};e.commands.find(n)}function T(e){N(r,e,!0),e===`tabs`?(t.editor?.commands.findClose(),l(z(u),z(f))):(N(i,[],!0),clearTimeout(c),ee())}function te(e){if(e.key===`Enter`){e.preventDefault(),e.shiftKey?t.editor?.commands.findPrev():t.editor?.commands.findNext();return}e.key===`Escape`&&ne()}function ne(){t.editor?.commands.findClose(),t.onClose()}async function E(){let e=t.editor;if(!e||!z(u)||z(g))return;let n=z(x);if(n>500&&!window.confirm(`Replace all ${n} occurrences? This cannot be undone as a single action.`))return;N(g,!0),N(v,null),N(_,{replaced:0,total:n},!0);let{replaced:r,partial:i}=await gZ(e.view,z(d),(e,t)=>{N(_,{replaced:e,total:t},!0)});N(_,null),N(g,!1),i&&N(v,`Replaced ${r} of ${n}; re-run to continue`)}var re=Xr(),ie=F(re),ae=e=>{var o=F2(),s=P(o),c=e=>{var t=D2(),n=P(t);let i;var a=I(n,2);let o;D(t),R(()=>{i=Ui(n,1,`fr-scope-pill svelte-1q9bff2`,null,i,{on:z(r)===`doc`}),K(n,`aria-pressed`,z(r)===`doc`),o=Ui(a,1,`fr-scope-pill svelte-1q9bff2`,null,o,{on:z(r)===`tabs`}),K(a,`aria-pressed`,z(r)===`tabs`)}),B(`click`,n,()=>T(`doc`)),B(`click`,a,()=>T(`tabs`)),H(e,t)};W(s,e=>{n().length>1&&e(c)});var l=I(s,2),b=P(l);$i(b);let w;fa(b,e=>N(C,e),()=>z(C));var re=I(b,2),ie=P(re),ae=e=>{var t=Yr();R(()=>U(t,z(x)===0?`No matches`:`${z(S)+1} / ${z(x)}`)),H(e,t)};W(ie,e=>{z(u)&&e(ae)}),D(re);var oe=I(re,2),se=I(oe,2),ce=I(se,2);D(l);var le=I(l,2),ue=e=>{var t=O2(),n=P(t,!0);D(t),R(()=>U(n,z(h))),H(e,t)};W(le,e=>{z(h)&&e(ue)});var de=I(le,2),fe=P(de),pe=P(fe);$i(pe),O(),D(fe);var me=I(fe,2),he=P(me);$i(he),O(),D(me);var ge=I(me,2),_e=P(ge);$i(_e),O(),D(ge),D(de);var ve=I(de,2),ye=P(ve);$i(ye);var be=I(ye,2),xe=I(be,2),Se=P(xe),Ce=e=>{var t=Yr();R(()=>U(t,`${z(_).replaced??``}/${z(_).total??``}`)),H(e,t)},we=e=>{H(e,Yr(`All`))};W(Se,e=>{z(g)&&z(_)?e(Ce):e(we,-1)}),D(xe),D(ve);var Te=I(ve,2),Ee=e=>{var t=k2(),n=P(t,!0);D(t),R(()=>U(n,z(v))),H(e,t)};W(Te,e=>{z(v)&&e(Ee)});var De=I(Te,2),Oe=e=>{var t=P2(),n=P(t),r=e=>{H(e,A2())},o=e=>{H(e,j2())},s=e=>{var t=Xr();pi(F(t),17,()=>z(i),li,(e,t)=>{var n=N2(),r=P(n),i=P(r),a=I(i),o=P(a);D(a),D(r),pi(I(r,2),17,()=>z(t).snippets,li,(e,t)=>{var n=M2(),r=P(n,!0);D(n),R(()=>U(r,z(t))),H(e,n)}),D(n),R(()=>{U(i,`${z(t).fileName??``} `),U(o,`(${z(t).count??``} ${z(t).count===1?`match`:`matches`})`)}),H(e,n)}),H(e,t)};W(n,e=>{z(a)?e(r):z(u)&&z(i).length===0?e(o,1):e(s,-1)}),D(t),H(e,t)};W(De,e=>{z(r)===`tabs`&&e(Oe)}),D(o),R(()=>{w=Ui(b,1,`fr-input svelte-1q9bff2`,null,w,{"has-error":!!z(h)}),oe.disabled=z(x)===0,se.disabled=z(x)===0,be.disabled=z(x)===0||z(g)||z(r)===`tabs`,K(be,`title`,z(r)===`tabs`?`Replace is not available in Open tabs mode`:void 0),xe.disabled=z(x)===0||z(g)||z(r)===`tabs`,K(xe,`title`,z(r)===`tabs`?`Replace All is not available in Open tabs mode`:void 0)}),B(`keydown`,o,te),B(`input`,b,ee),aa(b,()=>z(u),e=>N(u,e)),B(`click`,oe,()=>t.editor?.commands.findPrev()),B(`click`,se,()=>t.editor?.commands.findNext()),B(`click`,ce,ne),B(`change`,pe,ee),oa(pe,()=>z(f),e=>N(f,e)),B(`change`,he,ee),oa(he,()=>z(p),e=>N(p,e)),B(`change`,_e,ee),oa(_e,()=>z(m),e=>N(m,e)),aa(ye,()=>z(d),e=>N(d,e)),B(`click`,be,()=>{t.editor&&(hZ(t.editor.view,z(d)),sn(y))}),B(`click`,xe,E),H(e,o)};W(ie,e=>{t.open&&e(ae)}),H(e,re),A()}Br([`keydown`,`click`,`input`,`change`]);var L2=V(`<div class="source-view-warning svelte-fwjuih" data-testid="source-view-annotation-warning" role="status"> </div>`),R2=V(`<div class="source-view-error svelte-fwjuih" data-testid="source-view-error" role="alert"> </div>`),z2=V(`<div class="source-view-loading svelte-fwjuih">Loading source…</div>`),B2=V(`<textarea class="source-view-textarea svelte-fwjuih" data-testid="source-view-textarea" spellcheck="false" autocomplete="off" autocapitalize="off" aria-label="Markdown source"></textarea>`),V2=V(`<div class="source-view svelte-fwjuih" data-testid="source-view-container"><div class="source-view-toolbar svelte-fwjuih"><button type="button" class="source-view-btn source-view-exit svelte-fwjuih" data-testid="source-view-exit-btn">← WYSIWYG</button> <span class="source-view-title svelte-fwjuih">Markdown source</span> <button type="button" class="source-view-btn svelte-fwjuih" data-testid="source-view-copy-btn">Copy</button></div> <!> <!> <!></div>`);function H2(e,t){k(t,!0);let n=Ar(()=>t.initialDraft),r=M(``),i=M(``),a=M(!0),o=M(!1),s=M(null),c=j(()=>!z(a)&&z(i)!==z(r)),l=M(0);L(()=>{let e=t.ydoc.getMap(Ra),n=()=>{N(l,e.size,!0)};return n(),e.observe(n),()=>e.unobserve(n)}),L(()=>{let e=t.documentId,o=!1;return N(a,!0),N(s,null),(async()=>{try{let t=await fetch(`${Il}${Tc}?documentId=${encodeURIComponent(e)}`);if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}let a=await t.json();if(o)return;N(r,a.markdown??``,!0),N(i,n??z(r),!0)}catch(e){if(o)return;N(s,e instanceof Error?e.message:`Failed to load markdown source.`,!0)}finally{o||N(a,!1)}})(),()=>{o=!0}});async function u(){N(o,!0),N(s,null);try{let e=await fetch(`${Il}${Ec}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:t.documentId,markdown:z(i)})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.message??e.statusText)}return N(r,z(i),!0),t.onDraftChange(z(i),!1),!0}catch(e){return N(s,e instanceof Error?e.message:`Failed to apply markdown changes.`,!0),!1}finally{N(o,!1)}}function d(e){let n=e.target.value;t.onDraftChange(n,n!==z(r))}async function f(){z(c)&&!await u()||t.onExit()}async function p(e){(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),e.stopPropagation(),z(c)&&!z(o)&&await u())}async function m(){try{await navigator.clipboard.writeText(z(i))}catch{}}var h=V2(),g=P(h),_=P(g),v=I(_,4);D(g);var y=I(g,2),b=e=>{var t=L2(),n=P(t);D(t),R(()=>U(n,`Editing the source clears this document's ${z(l)??``} annotation${z(l)===1?``:`s`} when you return to the editor.`)),H(e,t)};W(y,e=>{z(l)>0&&e(b)});var x=I(y,2),S=e=>{var t=R2(),n=P(t,!0);D(t),R(()=>U(n,z(s))),H(e,t)};W(x,e=>{z(s)&&e(S)});var C=I(x,2),w=e=>{H(e,z2())},ee=e=>{var t=B2();En(t),B(`input`,t,d),B(`keydown`,t,p),aa(t,()=>z(i),e=>N(i,e)),H(e,t)};W(C,e=>{z(a)?e(w):e(ee,-1)}),D(h),R(()=>{_.disabled=z(o),v.disabled=z(a)}),B(`click`,_,f),B(`click`,v,m),H(e,h),A()}Br([`click`,`input`,`keydown`]);function U2(e,t){function n(n){e.contains(n.target)||t(n)}return document.addEventListener(`mousedown`,n),{destroy(){document.removeEventListener(`mousedown`,n)}}}var W2=V(`<div class="menu-div svelte-94a7fq" role="separator"></div> <button type="button" class="mi link svelte-94a7fq" data-testid="decorations-settings-link" role="menuitem"><span>Appearance settings…</span> <kbd class="svelte-94a7fq">Ctrl+,</kbd></button>`,1),G2=V(`<div class="menu svelte-94a7fq" role="menu" aria-label="Decorations"><div class="menu-head svelte-94a7fq">Decorations</div> <p class="menu-help svelte-94a7fq">Inline editor overlays — author colors, comment, highlight, and note
|
|
238
|
-
marks. Toggle a type to hide its marks in the document; side-panel cards
|
|
239
|
-
stay.</p> <button type="button" data-testid="decorations-row-authorship" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" aria-hidden="true" class="svelte-94a7fq"><circle cx="9.5" cy="12" r="5" fill="var(--tandem-author-user)"></circle><circle cx="14.5" cy="12" r="5" fill="var(--tandem-author-claude)"></circle></svg></span> <span class="mi-label svelte-94a7fq">Authorship colors</span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <button type="button" data-testid="decorations-row-comments" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="M21 11.5a8.5 8.5 0 0 1-12.5 7.5L3 21l1.6-5A8.5 8.5 0 1 1 21 11.5z"></path></svg></span> <span class="mi-label svelte-94a7fq">Comments</span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <button type="button" data-testid="decorations-row-highlights" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><rect x="3" y="9" width="18" height="6" rx="2" fill="currentColor" opacity="0.25" stroke="none"></rect><path d="M4 6h16M4 18h11"></path></svg></span> <span class="mi-label svelte-94a7fq">Highlights</span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <button type="button" data-testid="decorations-row-notes" role="menuitemcheckbox"><span class="mi-ic svelte-94a7fq"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8z"></path><path d="M14 3v5h5"></path><path d="M8 13h7M8 17h4"></path></svg></span> <span class="mi-label svelte-94a7fq">Notes <span class="mi-tag svelte-94a7fq">· private</span></span> <span class="chk svelte-94a7fq" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="svelte-94a7fq"><path d="M20 6 9 17l-5-5"></path></svg></span></button> <!></div>`),K2=V(`<div data-testid="decorations-menu" data-tauri-drag-region="false"><button type="button" data-testid="decorations-mute-toggle"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"></path><circle cx="12" cy="12" r="3"></circle></svg></button> <span class="split-div svelte-94a7fq" aria-hidden="true"></span> <button type="button" class="ib half-caret svelte-94a7fq" data-testid="decorations-menu-caret" aria-haspopup="menu" title="Decoration options" aria-label="Decoration options"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-94a7fq"><path d="m6 9 6 6 6-6"></path></svg></button> <!></div>`);function q2(e,t){k(t,!0);let n=M(!1),r=M(null);function i(){t.onUpdate({decorationsMuted:!t.decorationsMuted})}function a(e,n){t.onUpdate({[e]:!n,...t.decorationsMuted?{decorationsMuted:!1}:{}})}function o(){N(n,!1),z(r)?.focus()}function s(e){e.key===`Escape`&&z(n)&&(e.stopPropagation(),o())}function c(){t.onOpenSettings?.(),N(n,!1)}var l=K2();let u;var d=P(l);let f;var p=I(d,4);fa(p,e=>N(r,e),()=>z(r));var m=I(p,2),h=e=>{var n=G2(),r=I(P(n),4);let i;var o=I(r,2);let s;var l=I(o,2);let u;var d=I(l,2);let f;var p=I(d,2),m=e=>{var t=W2();B(`click`,I(F(t),2),c),H(e,t)};W(p,e=>{t.onOpenSettings&&e(m)}),D(n),R(()=>{i=Ui(r,1,`mi svelte-94a7fq`,null,i,{on:t.showAuthorship}),K(r,`aria-checked`,t.showAuthorship),s=Ui(o,1,`mi svelte-94a7fq`,null,s,{on:t.showComments}),K(o,`aria-checked`,t.showComments),u=Ui(l,1,`mi svelte-94a7fq`,null,u,{on:t.showHighlights}),K(l,`aria-checked`,t.showHighlights),f=Ui(d,1,`mi svelte-94a7fq`,null,f,{on:t.showNotes}),K(d,`aria-checked`,t.showNotes)}),B(`click`,r,()=>a(`showAuthorship`,t.showAuthorship)),B(`click`,o,()=>a(`showComments`,t.showComments)),B(`click`,l,()=>a(`showHighlights`,t.showHighlights)),B(`click`,d,()=>a(`showNotes`,t.showNotes)),H(e,n)};W(m,e=>{z(n)&&e(h)}),D(l),Pi(l,(e,t)=>U2?.(e,t),()=>()=>N(n,!1)),R(()=>{u=Ui(l,1,`split menu-wrap svelte-94a7fq`,null,u,{open:z(n)}),f=Ui(d,1,`ib half-main svelte-94a7fq`,null,f,{on:!t.decorationsMuted}),K(d,`aria-pressed`,!t.decorationsMuted),K(d,`title`,t.decorationsMuted?`Restore decorations`:`Mute decorations`),K(d,`aria-label`,t.decorationsMuted?`Restore decorations`:`Mute decorations`),K(p,`aria-expanded`,z(n))}),B(`keydown`,l,s),B(`click`,d,i),B(`click`,p,()=>N(n,!z(n))),H(e,l),A()}Br([`keydown`,`click`]);function J2(e,t,n,r={}){let{capture:i=!0}=r;function a(t){let r=e();r&&(t.target instanceof Node&&r.contains(t.target)||n(t))}for(let e of t)document.addEventListener(e,a,i);return()=>{for(let e of t)document.removeEventListener(e,a,i)}}function Y2(e){let t=e.closest?.(`[data-tauri-drag-region]`);return!!t&&t.getAttribute(`data-tauri-drag-region`)!==`false`}function X2(e){return t=>{t.preventDefault(),e()}}function Z2(e){let t=e.getAttributes(`link`).href;return t===void 0?``:typeof t==`string`?t:(console.warn(`[tandem] getInitialLinkHref: non-string href attribute`,{href:t}),``)}function Q2(e,t){let n=t.trim();n?e.chain().focus().setLink({href:n}).run():e.isActive(`link`)&&e.chain().focus().unsetLink().run()}var $2=V(`<button type="button"><!></button>`);function e4(e,t){let n=q(t,`disabled`,3,!1),r=q(t,`active`,3,!1),i=q(t,`style`,3,``),a=j(()=>t.ariaLabel??(typeof t.label==`string`?t.label:void 0)),o=j(()=>z(a)??``),s=j(()=>n()&&t.disabledTitle?t.disabledTitle:t.shortcut?`${z(o)} (${t.shortcut})`:z(o));var c=$2();let l;var u=P(c),d=e=>{var n=Xr();bi(F(n),()=>t.children),H(e,n)},f=e=>{var n=Yr();R(()=>U(n,t.label)),H(e,n)};W(u,e=>{t.children?e(d):e(f,-1)}),D(c),R(()=>{l=Ui(c,1,`toolbar-btn svelte-xw5pw0`,null,l,{"is-active":r()}),K(c,`data-testid`,t.testId),c.disabled=n(),K(c,`title`,z(s)),K(c,`aria-label`,z(a)),K(c,`aria-pressed`,t.ariaPressed),K(c,`aria-haspopup`,t.ariaHasPopup),K(c,`aria-expanded`,t.ariaExpanded),G(c,i())}),B(`mousedown`,c,function(...e){t.onMouseDown?.apply(this,e)}),B(`click`,c,function(...e){t.onClick?.apply(this,e)}),H(e,c)}Br([`mousedown`,`click`]);var t4=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M4 7L1 4l3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M1 4h9a5 5 0 0 1 0 10H7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>`),n4=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M12 7l3-3-3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M15 4H6a5 5 0 0 0 0 10h3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>`),r4=V(`<!> <!> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div>`,1),i4=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 8.5a3.5 3.5 0 0 0 5 0l2-2a3.5 3.5 0 0 0-5-5l-1 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.5 7.5a3.5 3.5 0 0 0-5 0l-2 2a3.5 3.5 0 0 0 5 5l1-1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>`),a4=V(`<div role="dialog" aria-label="Insert link" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
240
|
-
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
241
|
-
border-radius: var(--tandem-r-3); padding: 6px;
|
|
242
|
-
display: flex; align-items: center; gap: 4px;
|
|
243
|
-
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;
|
|
244
|
-
border: 1px solid var(--tandem-border); border-radius: var(--tandem-r-2);
|
|
245
|
-
background: var(--tandem-surface); color: var(--tandem-fg);
|
|
246
|
-
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;
|
|
247
|
-
border: 1px solid var(--tandem-accent-border); background: transparent;
|
|
248
|
-
color: var(--tandem-accent); border-radius: var(--tandem-r-2); cursor: pointer;
|
|
249
|
-
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;
|
|
250
|
-
border: 1px solid var(--tandem-border); background: transparent;
|
|
251
|
-
color: var(--tandem-fg-muted); border-radius: var(--tandem-r-2); cursor: pointer;">Cancel</button></div>`),o4=V(`<span style="font-family: var(--tandem-font-serif); font-weight: 600; font-size: 13.5px; line-height: 1;"> </span> <span aria-hidden="true" style="color: var(--tandem-fg-faint); font-size: 10px; line-height: 1;">▾</span>`,1),s4=V(`<button type="button" role="menuitemradio"> </button>`),c4=V(`<div role="menu" aria-label="Heading level" style="position: absolute; top: 100%; left: 0; margin-top: 4px;
|
|
252
|
-
background: var(--tandem-surface); border: 1px solid var(--tandem-border);
|
|
253
|
-
border-radius: var(--tandem-r-3); padding: 4px; display: flex; flex-direction: column;
|
|
254
|
-
gap: 2px; z-index: var(--tandem-z-dropdown); box-shadow: var(--tandem-shadow-1);"></div>`),l4=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="4" r="1.5" fill="currentColor"></circle><circle cx="2" cy="8" r="1.5" fill="currentColor"></circle><circle cx="2" cy="12" r="1.5" fill="currentColor"></circle><rect x="5" y="3" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="7" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="11" width="9" height="2" rx="1" fill="currentColor"></rect></svg>`),u4=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="5" y="3" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="7" width="9" height="2" rx="1" fill="currentColor"></rect><rect x="5" y="11" width="9" height="2" rx="1" fill="currentColor"></rect><text x="0" y="5.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">1.</text><text x="0" y="9.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">2.</text><text x="0" y="13.5" font-size="4.5" fill="currentColor" font-family="monospace" font-weight="bold">3.</text></svg>`),d4=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="2" width="3" height="12" rx="1.5" fill="currentColor"></rect><rect x="5" y="4" width="9" height="2" rx="1" fill="currentColor" opacity="0.7"></rect><rect x="5" y="8" width="7" height="2" rx="1" fill="currentColor" opacity="0.7"></rect><rect x="5" y="12" width="8" height="2" rx="1" fill="currentColor" opacity="0.7"></rect></svg>`),f4=Jr(`<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="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>`),p4=V(`<div style="display: flex; align-items: center; gap: 1px;"><!> <!> <!> <!> <!> <div style="position: relative;" role="presentation"><!> <!></div> <div style="width: 1px; height: 16px; background: var(--tandem-border); margin: 0 2px;"></div> <div style="position: relative;" role="presentation"><!> <!></div> <!> <!> <!> <!> <!></div>`);function m4(e,t){k(t,!0);let n=q(t,`disabled`,3,!1),r=q(t,`variant`,3,`bar`),i=j(()=>r()===`bar`),a=j(()=>r()===`bar`),o=[1,2,3],s={1:700,2:600,3:500},c=M(0),l=M(!1),u=M(!1),d=M(``),f=M(null);L(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>{e.isDestroyed||sn(c)};return e.on(`transaction`,n),()=>{e.isDestroyed||e.off(`transaction`,n)}}),L(()=>{z(u)&&(z(f)?.focus(),z(f)?.select())});function p(e){for(let t of o)if(e.isActive(`heading`,{level:t}))return t;return null}let m=j(()=>t.editor?t.editor.isEditable:!1),h=j(()=>!z(m)||!!n()),g=j(()=>(z(c),t.editor?hU.getState(t.editor.state):null)),_=j(()=>!z(h)&&(z(g)?.undoManager?.undoStack.length??0)>0),v=j(()=>!z(h)&&(z(g)?.undoManager?.redoStack.length??0)>0),y=j(()=>(z(c),t.editor?p(t.editor):null)),b=j(()=>(z(c),!!t.editor?.isActive(`bold`))),x=j(()=>(z(c),!!t.editor?.isActive(`italic`))),S=j(()=>(z(c),!!t.editor?.isActive(`strike`))),C=j(()=>(z(c),!!t.editor?.isActive(`code`))),w=j(()=>(z(c),!!t.editor?.isActive(`bulletList`))),ee=j(()=>(z(c),!!t.editor?.isActive(`orderedList`))),T=j(()=>(z(c),!!t.editor?.isActive(`blockquote`))),te=j(()=>(z(c),!!t.editor?.isActive(`codeBlock`))),ne=j(()=>(z(c),!!t.editor?.isActive(`link`))),E=j(()=>(z(c),t.editor?z(h)||!t.editor.isActive(`link`)&&t.editor.state.selection.from===t.editor.state.selection.to:!0)),re=j(()=>z(y)?`H${z(y)}`:`H`),ie=j(()=>X2(()=>t.editor?.commands.undo())),ae=j(()=>X2(()=>t.editor?.commands.redo())),oe=j(()=>X2(()=>t.editor?.chain().focus().toggleBold().run())),se=j(()=>X2(()=>t.editor?.chain().focus().toggleItalic().run())),ce=j(()=>X2(()=>t.editor?.chain().focus().toggleStrike().run())),le=j(()=>X2(()=>t.editor?.chain().focus().toggleCode().run())),ue=j(()=>X2(()=>t.editor?.chain().focus().toggleBulletList().run())),de=j(()=>X2(()=>t.editor?.chain().focus().toggleOrderedList().run())),fe=j(()=>X2(()=>t.editor?.chain().focus().toggleBlockquote().run())),pe=j(()=>X2(()=>t.editor?.chain().focus().setHorizontalRule().run())),me=j(()=>X2(()=>t.editor?.chain().focus().toggleCodeBlock().run()));function he(e){return t=>{t.detail===0&&e(t)}}function ge(e){return n=>{n.preventDefault(),!(!t.editor||t.editor.isDestroyed)&&(t.editor.chain().focus().toggleHeading({level:e}).run(),N(l,!1))}}function _e(e){e.preventDefault(),t.editor&&(N(d,Z2(t.editor),!0),N(u,!0))}function ve(){t.editor&&(Q2(t.editor,z(d)),ye())}function ye(){N(u,!1),N(d,``)}function be(e){e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),ve()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ye())}var xe=Xr(),Se=F(xe),Ce=e=>{var t=p4(),n=P(t),r=e=>{var t=r4(),n=F(t);{let e=e=>{H(e,t4())},t=j(()=>!z(_)),r=j(()=>he(z(ie)));e4(n,{ariaLabel:`Undo`,shortcut:`Ctrl+Z`,get disabled(){return z(t)},get onMouseDown(){return z(ie)},get onClick(){return z(r)},children:e,$$slots:{default:!0}})}var r=I(n,2);{let e=e=>{H(e,n4())},t=j(()=>!z(v)),n=j(()=>he(z(ae)));e4(r,{ariaLabel:`Redo`,shortcut:`Ctrl+Shift+Z`,get disabled(){return z(t)},get onMouseDown(){return z(ae)},get onClick(){return z(n)},children:e,$$slots:{default:!0}})}O(2),H(e,t)};W(n,e=>{z(i)&&e(r)});var c=I(n,2);{let e=j(()=>he(z(oe)));e4(c,{label:`B`,shortcut:`Ctrl+B`,get disabled(){return z(h)},get active(){return z(b)},get onMouseDown(){return z(oe)},get onClick(){return z(e)},style:`font-weight: 700;`})}var p=I(c,2);{let e=j(()=>he(z(se)));e4(p,{label:`I`,shortcut:`Ctrl+I`,get disabled(){return z(h)},get active(){return z(x)},get onMouseDown(){return z(se)},get onClick(){return z(e)},style:`font-style: italic;`})}var m=I(p,2);{let e=j(()=>he(z(ce)));e4(m,{label:`S`,shortcut:`Ctrl+Shift+X`,get disabled(){return z(h)},get active(){return z(S)},get onMouseDown(){return z(ce)},get onClick(){return z(e)},style:`text-decoration: line-through;`})}var g=I(m,2);{let e=j(()=>he(z(le)));e4(g,{label:`<>`,shortcut:`Ctrl+E`,get disabled(){return z(h)},get active(){return z(C)},get onMouseDown(){return z(le)},get onClick(){return z(e)},style:`font-family: monospace;`})}var xe=I(g,2),Se=P(xe);{let e=e=>{H(e,i4())},t=j(()=>z(ne)||z(u)),n=j(()=>he(_e));e4(Se,{ariaLabel:`Link`,shortcut:`Ctrl+K`,get disabled(){return z(E)},get active(){return z(t)},ariaHasPopup:`dialog`,get ariaExpanded(){return z(u)},onMouseDown:_e,get onClick(){return z(n)},children:e,$$slots:{default:!0}})}var Ce=I(Se,2),we=e=>{var t=a4(),n=P(t);$i(n),fa(n,e=>N(f,e),()=>z(f));var r=I(n,2),i=j(()=>he(e=>{e.preventDefault(),ve()})),a=I(r,2),o=j(()=>he(e=>{e.preventDefault(),ye()}));D(t),B(`keydown`,n,be),aa(n,()=>z(d),e=>N(d,e)),B(`mousedown`,r,e=>{e.preventDefault(),ve()}),B(`click`,r,function(...e){z(i)?.apply(this,e)}),B(`mousedown`,a,e=>{e.preventDefault(),ye()}),B(`click`,a,function(...e){z(o)?.apply(this,e)}),H(e,t)};W(Ce,e=>{z(u)&&e(we)}),D(xe),Pi(xe,(e,t)=>U2?.(e,t),()=>ye);var Te=I(xe,4),Ee=P(Te);{let e=e=>{var t=o4(),n=F(t),r=P(n,!0);D(n),O(2),R(()=>U(r,z(re))),H(e,t)},t=j(()=>z(y)?`Heading ${z(y)}`:`Heading`),n=j(()=>z(y)!==null),r=j(()=>he(e=>{e.preventDefault(),N(l,!z(l))}));e4(Ee,{get ariaLabel(){return z(t)},get disabled(){return z(h)},get active(){return z(n)},ariaHasPopup:`menu`,get ariaExpanded(){return z(l)},style:`gap: 2px; padding-right: 4px;`,onMouseDown:e=>{e.preventDefault(),N(l,!z(l))},get onClick(){return z(r)},children:e,$$slots:{default:!0}})}var De=I(Ee,2),Oe=e=>{var t=c4();pi(t,20,()=>o,e=>e,(e,t)=>{let n=j(()=>ge(t));var r=s4(),i=j(()=>he(z(n))),a=P(r);D(r),R(()=>{K(r,`aria-checked`,z(y)===t),G(r,`padding: 4px 12px; font-size: 13px; border: none;
|
|
255
|
-
border-radius: var(--tandem-r-2);
|
|
256
|
-
background: ${z(y)===t?`var(--tandem-accent-bg)`:`transparent`};
|
|
257
|
-
color: ${z(y)===t?`var(--tandem-accent)`:`var(--tandem-fg)`};
|
|
258
|
-
cursor: pointer; text-align: left;
|
|
259
|
-
font-weight: ${s[t]??``}; white-space: nowrap;`),U(a,`Heading ${t??``}`)}),B(`mousedown`,r,function(...e){z(n)?.apply(this,e)}),B(`click`,r,function(...e){z(i)?.apply(this,e)}),H(e,r)}),D(t),H(e,t)};W(De,e=>{z(l)&&e(Oe)}),D(Te),Pi(Te,(e,t)=>U2?.(e,t),()=>()=>N(l,!1));var ke=I(Te,2);{let e=e=>{H(e,l4())},t=j(()=>he(z(ue)));e4(ke,{ariaLabel:`Bullet list`,shortcut:`Ctrl+Shift+8`,get disabled(){return z(h)},get active(){return z(w)},get onMouseDown(){return z(ue)},get onClick(){return z(t)},children:e,$$slots:{default:!0}})}var Ae=I(ke,2);{let e=e=>{H(e,u4())},t=j(()=>he(z(de)));e4(Ae,{ariaLabel:`Ordered list`,shortcut:`Ctrl+Shift+7`,get disabled(){return z(h)},get active(){return z(ee)},get onMouseDown(){return z(de)},get onClick(){return z(t)},children:e,$$slots:{default:!0}})}var je=I(Ae,2);{let e=e=>{H(e,d4())},t=j(()=>he(z(fe)));e4(je,{ariaLabel:`Blockquote`,shortcut:`Ctrl+Shift+B`,get disabled(){return z(h)},get active(){return z(T)},get onMouseDown(){return z(fe)},get onClick(){return z(t)},children:e,$$slots:{default:!0}})}var Me=I(je,2),Ne=e=>{{let t=j(()=>he(z(pe)));e4(e,{label:`—`,ariaLabel:`Horizontal rule`,get disabled(){return z(h)},get onMouseDown(){return z(pe)},get onClick(){return z(t)}})}};W(Me,e=>{z(a)&&e(Ne)});var Pe=I(Me,2);{let e=e=>{H(e,f4())},t=j(()=>he(z(me)));e4(Pe,{ariaLabel:`Code block`,get disabled(){return z(h)},get active(){return z(te)},get onMouseDown(){return z(me)},get onClick(){return z(t)},children:e,$$slots:{default:!0}})}D(t),B(`keydown`,xe,e=>{e.key===`Escape`&&ye()}),B(`keydown`,Te,e=>{e.key===`Escape`&&N(l,!1)}),H(e,t)};W(Se,e=>{t.editor&&e(Ce)}),H(e,xe),A()}Br([`keydown`,`mousedown`,`click`]);function h4(e,t,n){let r=e.getMap(Ra),i=null,a;for(let[e,n]of r.entries())if(n.type===`highlight`&&n.range.from===t.from&&n.range.to===t.to&&n.author===`user`&&n.status===`pending`&&n.content===``){i=e,a=n.color;break}if(i===null){let i=lc(),a={id:i,author:`user`,type:`highlight`,audience:`private`,range:{from:t.from,to:t.to},content:``,status:`pending`,timestamp:Date.now(),color:n};return KO(e,()=>r.set(i,a)),`added`}if(a===n)return KO(e,()=>r.delete(i)),`removed`;let o=lc(),s={id:o,author:`user`,type:`highlight`,audience:`private`,range:{from:t.from,to:t.to},content:``,status:`pending`,timestamp:Date.now(),color:n};return KO(e,()=>{r.delete(i),r.set(o,s)}),`recolored`}function g4(e,t){let n=e.getMap(Ra),r=[];for(let[e,i]of n.entries())i.type===`highlight`&&i.range.from===t.from&&i.range.to===t.to&&i.author===`user`&&i.status===`pending`&&i.content===``&&r.push(e);return r.length===0?`noop`:(KO(e,()=>{for(let e of r)n.delete(e)}),`removed`)}function _4({anchorX:e,anchorY:t,toolbarHeight:n,toolbarWidth:r,viewportHeight:i,viewportWidth:a,previousPlacement:o}){let s=Math.max(8,a-8-r),c=t+6,l=c+n,u=t-6-n,d=i-8,f=l<=(o===`below`?d+4:d-4),p=u>=48,m=Math.max(48,i-n-8),h,g;f?(h=c,g=`below`):p?(h=u,g=`above`):(h=m,g=`below`);let _=i-(t-6);return{left:Math.min(Math.max(e,8),s),top:Math.min(Math.max(h,48),m),bottom:_,placement:g}}function v4(e,t){return e.on(`selectionUpdate`,t),()=>e.off(`selectionUpdate`,t)}var y4=V(`<div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px; flex-shrink: 0;"></div> <div style="display: inline-flex; align-items: center;" role="presentation"><!></div>`,1),b4=V(`<div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px; flex-shrink: 0;"></div> <button type="button" data-testid="popup-show-formatbar-btn" style="height: 26px; min-width: 26px; padding: 0 6px; border: 1px solid transparent; background: transparent; color: var(--tandem-fg-muted); border-radius: var(--tandem-r-pill); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path></path></svg></button>`,1),x4=V(`<button type="button"></button>`),S4=V(`<div role="toolbar" aria-label="Selection tools"><div><div class="morph-block-inner svelte-1tvmluw"><div class="popup-format-col svelte-1tvmluw" role="presentation"><div class="pill-row tandem-floating-pill svelte-1tvmluw" data-testid="popup-format-row"><!> <!> <!></div> <div class="pill-row tandem-floating-pill svelte-1tvmluw" data-testid="popup-annotate-row"><div style="display: inline-flex; gap: 3px; padding: 0 4px;" aria-label="Highlight colors"><button type="button" data-testid="popup-highlight-none" aria-label="No highlight" title="No highlight" style="width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: var(--tandem-surface); cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center;"><svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><line x1="3.5" y1="12.5" x2="12.5" y2="3.5" stroke="var(--tandem-fg-muted)" stroke-width="1.5" stroke-linecap="round"></line></svg></button> <!></div> <div style="width: 1px; height: 18px; background: var(--tandem-border); margin: 0 3px;"></div> <button type="button" data-testid="popup-annotate-btn" aria-label="Annotate" style="height: 24px; padding: 0 12px; border: 1px solid var(--tandem-author-user); background: transparent; color: var(--tandem-author-user); border-radius: var(--tandem-r-pill); font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;"><svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"></path></svg> Annotate</button></div></div></div></div> <div><div class="morph-block-inner svelte-1tvmluw"><div class="composer-card svelte-1tvmluw"><textarea data-testid="popup-annotation-input" aria-label="Annotation text" placeholder="Write a note or instruction..." class="composer-input svelte-1tvmluw"></textarea> <div class="composer-actions svelte-1tvmluw"><button type="button" class="composer-btn composer-btn-note svelte-1tvmluw" data-testid="popup-note-submit" aria-label="Note to self (Alt+Enter)">Note to self <kbd class="composer-kbd svelte-1tvmluw"> </kbd></button> <button type="button" class="composer-btn composer-btn-send svelte-1tvmluw" data-testid="popup-comment-submit"> <kbd class="composer-kbd svelte-1tvmluw"> </kbd></button></div></div></div></div></div>`);function C4(e,t){k(t,!0);let n=q(t,`selectionToolbar`,3,!0),r=q(t,`suppressSelectionToolbar`,3,!1),i=q(t,`requestCommentFocus`,3,0),a=q(t,`showAuthorship`,3,!0),o=q(t,`showComments`,3,!0),s=q(t,`showHighlights`,3,!0),c=q(t,`showNotes`,3,!0),l=q(t,`decorationsMuted`,3,!1),u=q(t,`formattingBarVisible`,3,!0),d=q(t,`reduceMotion`,3,!1),f=qE(J_()),p=M(!1),m=M(null),h=M(null),g=M(``),_=M(null),v=M(null),y=M(!1),b=M(!1),x=M(!1),S,C,w=-1,ee=-1,T=!1,te=0,ne=0,E=0,re=0,ie=null,ae=null,oe=!1;function se(){ie=T?te:E,ae=T?ne:re,!tv(d())&&(N(x,!0),clearTimeout(C),C=setTimeout(()=>{N(x,!1)},440))}function ce(){clearTimeout(S),clearTimeout(C),N(b,!1),N(x,!1),w=-1,ee=-1,ie=null,ae=null,T=!1}function le(e,t,n){w=e,ee=t,T=n,clearTimeout(S),S=setTimeout(()=>{se(),N(b,!0)},100)}let ue=il(),de=ue?`⌥⏎`:`Alt+⏎`,fe=ue?`⌘⏎`:`Ctrl+⏎`,pe=j(()=>{let e=z(m);if(!e)return``;let t=e.placement===`above`?`bottom: ${e.bottom}px; top: auto;`:`top: ${e.top}px; bottom: auto;`;return`left: ${e.left}px; ${t}`}),me=M(0),he=M(un(window.innerHeight)),ge=M(un(window.innerWidth)),_e=Object.keys(Oa),ve=j(()=>!!t.editor&&!!t.ydoc&&z(p)),ye=j(()=>n()&&!r()&&z(ve)&&z(m)!==null&&z(b)),be=j(()=>z(g).trim()),xe,Se=0,Ce=0;function we(e){let{from:t,to:n}=e.state.selection,r=t!==n;if(N(p,r),!r){N(m,null),xe=void 0,Ce=0,ce(),document.activeElement!==z(v)&&N(y,!1);return}!z(b)&&!oe&&(t!==w||n!==ee)&&le(t,n,!1);try{let t=e.view.coordsAtPos(e.state.selection.head);E=t.left,re=t.bottom;let n=_4({anchorX:ie??E,anchorY:ae??re,toolbarHeight:200,toolbarWidth:z(me),viewportHeight:z(he),viewportWidth:z(ge),previousPlacement:xe});if(xe=n.placement,Ce=0,z(m)&&z(m).left===n.left&&z(m).top===n.top&&z(m).bottom===n.bottom&&z(m).placement===n.placement)return;N(m,{left:n.left,top:n.top,bottom:n.bottom,placement:n.placement},!0)}catch{if(Ce>=3){Ce=0,N(m,null),xe=void 0;return}Ce+=1,cancelAnimationFrame(Se),Se=requestAnimationFrame(()=>{e.isDestroyed||we(e)})}}L(()=>{if(!t.editor)return;let e=t.editor;function n(){we(e)}let r=e.view.dom,i=r.ownerDocument;function a(e){e.button!==0||!e.isPrimary||(oe=!0)}function o(t){if(!oe)return;oe=!1,te=t.clientX,ne=t.clientY;let{from:n,to:r}=e.state.selection;n!==r&&!z(b)&&le(n,r,!0)}function s(){oe=!1}r.addEventListener(`pointerdown`,a),i.addEventListener(`pointerup`,o),i.addEventListener(`pointercancel`,s);let c=v4(e,n);return n(),()=>{r.removeEventListener(`pointerdown`,a),i.removeEventListener(`pointerup`,o),i.removeEventListener(`pointercancel`,s),cancelAnimationFrame(Se),Se=0,clearTimeout(S),clearTimeout(C),c()}}),L(()=>{if(!t.editor||!z(m))return;let e=t.editor,n=0;function r(){cancelAnimationFrame(n),n=requestAnimationFrame(()=>{N(he,window.innerHeight,!0),N(ge,window.innerWidth,!0),we(e)})}window.addEventListener(`resize`,r);let i=!1;requestAnimationFrame(()=>{i=!0});let a=J2(()=>z(h),[`scroll`],()=>{i&&document.activeElement!==z(v)&&je()});return()=>{cancelAnimationFrame(n),window.removeEventListener(`resize`,r),a()}}),L(()=>{let e=t.editor,n=z(h);if(!e||!n||!z(m))return;let r=z(x),i=()=>{if(document.activeElement!==z(v)){if(z(x)){z(me)===0&&(N(me,n.scrollWidth,!0),we(e));return}N(me,n.getBoundingClientRect().width,!0),we(e)}};r||i();let a=new ResizeObserver(i);return a.observe(n),()=>a.disconnect()}),L(()=>{z(ye)&&!z(_)&&De(),z(ye)||(N(_,null),document.activeElement!==z(v)&&N(g,``))});let Te=0;L(()=>{if(i()===Te||(Te=i(),i()===0||!t.editor))return;let{from:e,to:n}=t.editor.state.selection;e!==n&&(Ar(()=>De()),N(y,!0),N(b,!0),se(),requestAnimationFrame(()=>z(v)?.focus()))}),L(()=>{if(!t.editor||!z(ye))return;let e=t.editor,n=()=>{document.activeElement!==z(v)&&De()};return e.on(`selectionUpdate`,n),()=>{e.isDestroyed||e.off(`selectionUpdate`,n)}}),L(()=>{if(!z(ye))return;function e(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),je())}return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})});function Ee(e,n,r){if(!t.editor||!t.ydoc||e!==`highlight`&&!n.trim())return;let{from:i,to:a}=z(_)??t.editor.state.selection;if(i===a)return;let o=eD(t.editor.state.doc,Co(i)),s=eD(t.editor.state.doc,Co(a)),c=lc(),l={id:c,author:`user`,type:e,audience:e===`highlight`||e===`note`?`private`:`outbound`,range:{from:o,to:s},content:n,status:`pending`,timestamp:Date.now(),...r?.color?{color:r.color}:{}};return KO(t.ydoc,()=>t.ydoc.getMap(Ra).set(c,l)),N(_,null),c}function De(){if(!t.editor)return;let{from:e,to:n}=t.editor.state.selection;N(_,{from:e,to:n},!0)}function Oe(e){if(!t.editor||!t.ydoc)return;let{from:n,to:r}=z(_)??t.editor.state.selection;if(n===r)return;let i=eD(t.editor.state.doc,Co(n)),a=eD(t.editor.state.doc,Co(r));h4(t.ydoc,{from:i,to:a},e),N(_,null),t.editor.chain().setTextSelection(r).run()}function ke(){if(!t.editor||!t.ydoc)return;let{from:e,to:n}=z(_)??t.editor.state.selection;if(e===n)return;let r=eD(t.editor.state.doc,Co(e)),i=eD(t.editor.state.doc,Co(n));g4(t.ydoc,{from:r,to:i}),N(_,null),t.editor.chain().setTextSelection(n).run()}function Ae(e){return t=>{t.detail===0&&e(t)}}function je(){N(p,!1),N(m,null),N(_,null),N(g,``),N(y,!1),ce(),t.editor?.chain().focus().run()}function Me(){N(y,!0),requestAnimationFrame(()=>z(v)?.focus())}function Ne(){if(!z(be))return;let e=z(h)?.getBoundingClientRect(),t=Ee(`comment`,z(be));t&&e&&uv(t,e),window.dispatchEvent(new CustomEvent(`tandem:addressed-ai`,{detail:{via:`comment`}})),je()}function Pe(){if(!z(be))return;let e=z(h)?.getBoundingClientRect(),t=Ee(`note`,z(be));t&&e&&uv(t,e),je()}function Fe(e){e.key===`Enter`&&e.altKey?(e.preventDefault(),Pe()):e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),Ne()):e.key===`Escape`&&(e.preventDefault(),je())}var Ie=Xr(),Le=F(Ie),Re=e=>{var n=S4();let r;var i=P(n);let p;var _=P(i),b=P(_),x=P(b),S=P(x);m4(S,{get editor(){return t.editor},variant:`popup`});var C=I(S,2),w=e=>{var n=y4(),r=I(F(n),2);q2(P(r),{get showAuthorship(){return a()},get showComments(){return o()},get showHighlights(){return s()},get showNotes(){return c()},get decorationsMuted(){return l()},get onUpdate(){return t.onUpdateDecorations},get onOpenSettings(){return t.onOpenSettings}}),D(r),B(`mousedown`,r,e=>e.preventDefault()),H(e,n)};W(C,e=>{t.onUpdateDecorations&&e(w)});var ee=I(C,2),T=e=>{var n=b4(),r=I(F(n),2),i=j(()=>Ae(()=>t.onToggleFormattingBar?.())),a=P(r),o=P(a);D(a),D(r),R(()=>{K(r,`aria-label`,u()?`Hide formatting bar`:`Show formatting bar`),K(r,`title`,u()?`Hide formatting bar`:`Show formatting bar`),K(o,`d`,u()?`m18 15-6-6-6 6`:`m6 9 6 6 6-6`)}),B(`mousedown`,r,e=>{e.preventDefault(),t.onToggleFormattingBar?.()}),B(`click`,r,function(...e){z(i)?.apply(this,e)}),H(e,n)};W(ee,e=>{t.onToggleFormattingBar&&e(T)}),D(x);var te=I(x,2),ne=P(te),E=P(ne),re=j(()=>Ae(()=>{ke(),t.editor?.chain().focus().run()}));pi(I(E,2),17,()=>_e,li,(e,n)=>{var r=x4(),i=j(()=>Ae(()=>{Oe(z(n)),t.editor?.chain().focus().run()}));R(()=>{K(r,`data-testid`,`popup-highlight-${z(n)}`),K(r,`aria-label`,`Highlight ${z(n)}`),K(r,`title`,`Highlight ${z(n)}`),G(r,`width: 16px; height: 16px; border-radius: var(--tandem-r-2); border: 1px solid var(--tandem-border); background: ${ka[z(n)]}; cursor: pointer; padding: 0;`)}),B(`mousedown`,r,e=>{e.preventDefault(),Oe(z(n)),t.editor?.chain().focus().run()}),B(`click`,r,function(...e){z(i)?.apply(this,e)}),H(e,r)}),D(ne);var ie=I(ne,4),ae=j(()=>Ae(()=>Me()));D(te),D(b),D(_),D(i);var oe=I(i,2);let se;var ce=P(oe),le=P(ce),ue=P(le);En(ue),K(ue,`rows`,1),fa(ue,e=>N(v,e),()=>z(v));var me=I(ue,2),he=P(me),ge=I(P(he)),ve=P(ge,!0);D(ge),D(he);var ye=I(he,2),xe=P(ye),Se=I(xe),Ce=P(Se,!0);D(Se),D(ye),D(me),D(le),D(ce),D(oe),D(n),fa(n,e=>N(h,e),()=>z(h)),R(()=>{r=Ui(n,1,`tandem-floating-pill selection-popup svelte-1tvmluw`,null,r,{"is-annotate":z(y),"is-below":z(m).placement===`below`}),G(n,z(pe)),p=Ui(i,1,`morph-block morph-format svelte-1tvmluw`,null,p,{"is-active":!z(y)}),i.inert=z(y),se=Ui(oe,1,`morph-block morph-annotate svelte-1tvmluw`,null,se,{"is-active":z(y)}),oe.inert=!z(y),K(he,`title`,`Note to self — private, not sent to ${f.family??``} (Alt+Enter)`),he.disabled=!z(be),U(ve,de),K(ye,`aria-label`,`Send to ${f.family??``} (Ctrl+Enter)`),K(ye,`title`,`Send to ${f.family??``} — outbound comment (Ctrl/Cmd+Enter)`),ye.disabled=!z(be),U(xe,`Send to ${f.family??``} `),U(Ce,fe)}),B(`mousedown`,b,e=>e.preventDefault()),B(`mousedown`,E,e=>{e.preventDefault(),ke(),t.editor?.chain().focus().run()}),B(`click`,E,function(...e){z(re)?.apply(this,e)}),B(`mousedown`,ie,e=>{e.preventDefault(),Me()}),B(`click`,ie,function(...e){z(ae)?.apply(this,e)}),B(`keydown`,ue,Fe),aa(ue,()=>z(g),e=>N(g,e)),B(`click`,he,Pe),B(`click`,ye,Ne),Mi(1,n,()=>gv,()=>({reduceMotion:d()})),H(e,n)};W(Le,e=>{z(ye)&&z(m)&&e(Re)}),H(e,Ie),A()}Br([`mousedown`,`click`,`keydown`]);function w4(e,t=document.documentElement){let n=Math.max(0,Math.min(360,Math.round(e)));return t.style.setProperty(`--tandem-accent-h`,`${n}deg`),()=>t.style.removeProperty(`--tandem-accent-h`)}function T4(e){L(()=>w4(e()))}var E4=8e3;function D4(e){let t=M(null),n=M(!1),r=M(!1),i=0,a=0,o=!1;async function s(e){let n;try{n=await fetch(`${Il}${zc}`)}catch{return}if(e===i&&n.ok)try{N(t,await n.json(),!0),N(r,!0)}catch{}}async function c(){let e;try{e=await fetch(`${Il}${gc}`)}catch{return null}if(!e.ok)return null;try{let t=await e.json();return typeof t.hasSession==`boolean`?t.hasSession:null}catch{return null}}async function l(){let e=++a,t=await c();return t!==null&&e===a&&!o&&N(n,t,!0),t}async function u(){return await l()??z(n)}function d(){s(++i),l()}d();let f=setInterval(()=>d(),E4);va(()=>{i++,o=!0,clearInterval(f)});let p=j(()=>!e.firstRunSettled()||!e.connected()||!z(r)||z(t)===null?`booting`:z(n)?`ready`:z(t).available===!1?`unconfigured`:z(t).running===!0?`ready`:`stopped`),m=j(()=>e.soloMode()?null:z(p)===`unconfigured`?`connect`:z(p)===`stopped`?`restart`:null);return{get state(){return z(p)},get chip(){return z(m)},refresh:()=>d(),probeSession:u}}function O4(e,t=document.documentElement){return e?t.setAttribute(`data-annotation-patterns`,`true`):t.removeAttribute(`data-annotation-patterns`),()=>t.removeAttribute(`data-annotation-patterns`)}function k4(e){L(()=>O4(e()))}function A4(e){let t=M(un(new Map));return L(()=>{let n=e.getYdoc();if(!n){z(t).size>0&&N(t,new Map,!0);return}let r=n.getMap(Ga),i=()=>{N(t,j4(r),!0)};return i(),r.observe(i),()=>r.unobserve(i)}),{get byId(){return z(t)}}}function j4(e){let t=new Map;e.forEach(e=>{let n=e;if(!n||typeof n!=`object`||!n.annotationId)return;let r=t.get(n.annotationId)??[];r.push(n),t.set(n.annotationId,r)});for(let e of t.values())e.sort((e,t)=>e.timestamp-t.timestamp);return t}var M4=25;function N4(e=M4){let t=un([]);return{push(n){if(!(t.length&&t[t.length-1].filePath===n.filePath))for(t.push(n);t.length>e;)t.shift()},pop(){return t.pop()??null},peek(){return t.length?t[t.length-1]:null},get top(){return t.length?t[t.length-1]:null},size(){return t.length},clear(){t.length=0}}}function P4(e,t=()=>Da){let n=M(!1),r=M(!1);return L(()=>{let i=e();if(i==null){N(n,!1),N(r,!1);return}let a=Date.now()-i,o=t()-a;if(o<=0){N(n,!0);return}let s=setTimeout(()=>{N(n,!0)},o);return()=>clearTimeout(s)}),{get showBanner(){return z(n)&&!z(r)},dismiss(){N(r,!0)}}}function F4(e,t=document.documentElement){return t.setAttribute(`data-density`,e),()=>t.removeAttribute(`data-density`)}function I4(e){L(()=>F4(e()))}function L4(e){let t=Pa[e];try{let e=localStorage.getItem(t);if(e){let n=parseInt(e,10);if(Number.isFinite(n))return Math.max(200,Math.min(600,n));console.warn(`[tandem] ignoring non-numeric panel width for ${t}: ${e}`)}}catch(e){console.warn(`[tandem] localStorage unavailable reading ${t}:`,e)}return 300}function R4(e){let{side:t}=e,n=Pa[t],r=M(un(e.initialWidth)),i=null;return L(()=>{!e.getVisible()&&i&&(document.removeEventListener(`mousemove`,i.move),document.removeEventListener(`mouseup`,i.up),i=null,document.body.style.userSelect=``,document.body.style.cursor=``)}),L(()=>()=>{i&&=(document.removeEventListener(`mousemove`,i.move),document.removeEventListener(`mouseup`,i.up),document.body.style.userSelect=``,document.body.style.cursor=``,null)}),{get width(){return z(r)},handleResizeStart:a=>{a.preventDefault();let o=a.clientX,s=z(r),c=s;document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`;let l=e=>{let n=e.clientX-o,i=t===`left`?s+n:s-n;c=Math.max(200,Math.min(600,i)),N(r,c,!0)},u=()=>{if(document.removeEventListener(`mousemove`,l),document.removeEventListener(`mouseup`,u),i=null,document.body.style.userSelect=``,document.body.style.cursor=``,e.getVisible())try{localStorage.setItem(n,String(c))}catch(e){console.warn(`[tandem] failed to persist ${n}:`,e)}};i={move:l,up:u},document.addEventListener(`mousemove`,l),document.addEventListener(`mouseup`,u)},handleResizeStep:t=>{let i=Math.max(200,Math.min(600,z(r)+t));if(N(r,i,!0),e.getVisible())try{localStorage.setItem(n,String(i))}catch(e){console.warn(`[tandem] failed to persist ${n}:`,e)}}}}var z4={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 B4(e){let t=document.documentElement;return t.style.setProperty(`--tandem-editor-font-family`,z4[e]),()=>t.style.removeProperty(`--tandem-editor-font-family`)}function V4(e){L(()=>B4(e()))}function H4(){let e=M(!1);return{get fileDragOver(){return z(e)},handleEditorDragOver:t=>{Lm()||t.dataTransfer?.types.includes(`Files`)&&(t.preventDefault(),N(e,!0))},handleEditorDragLeave:t=>{Lm()||(t.currentTarget===t.target||!t.currentTarget.contains(t.relatedTarget))&&N(e,!1)},handleEditorDrop:async t=>{if(Lm()||(N(e,!1),!t.dataTransfer?.files.length))return;t.preventDefault();let n=t.dataTransfer.files[0],r=await zl(n);try{let e=await fetch(`${Il}${xc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileName:n.name,content:r})});if(!e.ok){let t=await e.json().catch(()=>({message:`Upload failed`}));console.error(`[useFileDrop] Upload failed:`,e.status,t.message??t.error)}}catch{console.error(`[useFileDrop] Server unreachable — file drop ignored`)}}}}function U4(e){return!!e?.query}function W4(){let e=M(null),t=M(null),n=M(null),r=M(!1),i=0;async function a(){let a=++i;try{let o=await fetch($h,{credentials:`same-origin`});if(!o.ok){if(a!==i)return;N(e,!1),N(t,null),N(n,null),N(r,!0);return}let s=await o.json();if(a!==i)return;N(e,s.needed===!0),N(t,typeof s.serverVersion==`string`?s.serverVersion:null,!0),N(n,typeof s.confirmationNonce==`string`?s.confirmationNonce:null,!0),N(r,!0)}catch{if(a!==i)return;N(e,!1),N(t,null),N(n,null),N(r,!0)}}return a(),{get needed(){return z(e)},get serverVersion(){return z(t)},get confirmationNonce(){return z(n)},get settled(){return z(r)},refetch:a}}function G4(e,t=document.documentElement){return e?t.setAttribute(`data-high-contrast`,`true`):t.removeAttribute(`data-high-contrast`),()=>t.removeAttribute(`data-high-contrast`)}function K4(e){L(()=>G4(e()))}function q4(e,t,n,r){let i=new Map,a=0,o=0;for(let s of e){let e=t(s);if(e){a++;try{let t=n(e.from);if(!Number.isFinite(t.top))continue;i.set(s.id,t.top-r())}catch{o++}}}return{positions:i,attempted:a,thrown:o}}function J4(e){let t=null;return{schedule(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel(){t!==null&&(cancelAnimationFrame(t),t=null)}}}function Y4(e){let t=M(un(new Map));function n(){if(!e.getEnabled()){z(t).size>0&&N(t,new Map,!0);return}let n=e.getEditor(),r=e.getLayerEl(),i=e.getYdoc();if(!n||!r||!i){z(t).size>0&&N(t,new Map,!0);return}let{positions:a,attempted:o,thrown:s}=q4(e.getAnnotations(),e=>iD(e,n.state.doc,i),e=>n.view.coordsAtPos(e),()=>r.getBoundingClientRect().top);o>0&&s===o&&console.warn(`[margin] coordsAtPos threw for all ${o} annotations — view may be detached`),!X4(z(t),a)&&N(t,a,!0)}let r=J4(n);return L(()=>{if(!e.getEnabled())return;let t=e.getEditor(),n=e.getLayerEl();if(!t||!n)return;let i=()=>r.schedule();t.on(`transaction`,i);let a=new ResizeObserver(()=>r.schedule());return a.observe(n),r.schedule(),()=>{t.off(`transaction`,i),a.disconnect(),r.cancel()}}),L(()=>{e.getAnnotations(),r.schedule()}),{get byId(){return z(t)}}}function X4(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(e===void 0||Math.abs(e-r)>.5)return!1}return!0}var Z4=co,Q4=250;function $4(e,t){return e.severity===`info`&&t-e.timestamp>=Z4}function e3(e){try{let t=localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);if(!Array.isArray(n))return[];let r=Date.now();return n.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.message==`string`&&typeof e.timestamp==`number`&&[`info`,`warning`,`error`].includes(e.severity)).filter(e=>!$4(e,r)).slice(-50)}catch(e){return console.warn(`[useNotifications] failed to load activity history:`,e),[]}}function t3(e={}){let t=e.persist??!0,n=e.storageKey??`tandem:activityHistory`,r=M(un([])),i=M(un(t?e3(n):[])),a=new Map,o=new Map,s=null,c=()=>{if(t){s=null;try{localStorage.setItem(n,JSON.stringify(z(i)))}catch{}}},l=()=>{t&&(s&&clearTimeout(s),s=setTimeout(c,Q4))},u=e=>{let t=a.get(e);t&&(clearTimeout(t),a.delete(e))},d=(e,t)=>{u(e);let n=so[t]??so.info;a.set(e,setTimeout(()=>{N(r,z(r).filter(t=>t.id!==e),!0),a.delete(e)},n))},f=(e,t)=>{if(e.dedupKey){let n=z(r).findIndex(t=>t.dedupKey===e.dedupKey);if(n!==-1){let i=z(r)[n];u(i.id);let a={...e,count:i.count+1,action:t},o=[...z(r)];o[n]=a,N(r,o,!0),d(a.id,a.severity);return}}let n={...e,count:1,action:t},i=[...z(r),n];for(;i.length>5;)u(i.shift().id);N(r,i,!0),d(n.id,n.severity)},p=e=>{let t=o.get(e);t&&(clearTimeout(t),o.delete(e))},m=(e,t)=>{p(e);let n=Math.max(0,Z4-(Date.now()-t));o.set(e,setTimeout(()=>{o.delete(e),z(i).some(t=>t.id===e)&&(N(i,z(i).filter(t=>t.id!==e),!0),N(r,z(r).filter(t=>t.id!==e),!0),l())},n))},h=e=>{if(e.dedupKey){let t=z(i).findIndex(t=>t.dedupKey===e.dedupKey);if(t!==-1){let n=z(i)[t],r={...e,id:n.id,count:n.count+1},a=[...z(i)];a[t]=r,N(i,a,!0),r.severity===`info`?m(r.id,r.timestamp):p(r.id),l();return}}let t={...e,count:1},n=[...z(i),t];for(;n.length>50;)n.shift();N(i,n,!0),t.severity===`info`&&m(t.id,t.timestamp),l()},g=(e,t,n)=>{h(e),(e.severity!==`info`||t)&&f(e,n)},_=e=>{N(r,z(r).filter(t=>t.id!==e),!0),u(e)},v=e=>{N(i,z(i).filter(t=>t.id!==e),!0),p(e),l()},y=()=>{N(i,[],!0);for(let e of o.values())clearTimeout(e);o.clear(),l()};for(let e of z(i))e.severity===`info`&&m(e.id,e.timestamp);let b=(e,t)=>g(e,!0,t),x=`http://127.0.0.1:${xa}${pc}`,S=new EventSource(x);return S.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{console.warn(`[useNotifications] Malformed SSE data:`,e.data);return}g(t,!1)},S.onerror=()=>{S.readyState===EventSource.CLOSED&&console.warn(`[useNotifications] EventSource permanently closed. Notifications will not be delivered. Is the server running?`)},va(()=>{S.close();for(let e of a.values())clearTimeout(e);a.clear();for(let e of o.values())clearTimeout(e);o.clear(),s&&(clearTimeout(s),c())}),{get toasts(){return z(r)},get activity(){return z(i)},get total(){return z(i).length},dismiss:_,dismissActivity:v,clearActivity:y,push:b}}function n3(e,t){let n=null,r=null,i=(...i)=>{r=i,n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null;let t=r;r=null,t&&e(...t)},t)};return i.cancel=()=>{n!==null&&(clearTimeout(n),n=null),r=null},i.flush=()=>{n!==null&&(clearTimeout(n),n=null);let t=r;r=null,t&&e(...t)},i}function r3(e){return`tandem:scratchpad:${e}`}var i3=`tandem:scratchpad:latest`,a3=500;function o3(e){let t=[],n=e=>{if(e instanceof QT)return e.toString();if(e instanceof qT){let t=``;for(let r=0;r<e.length;r++)t+=n(e.get(r));return t}return``};for(let r=0;r<e.length;r++){let i=e.get(r);(i instanceof qT||i instanceof QT)&&t.push(n(i))}return t.join(`
|
|
260
|
-
`).replace(/\n+$/,``)}function s3(e){try{return localStorage.getItem(e)}catch{return null}}function c3(e,t){try{localStorage.setItem(e,t)}catch{}}function l3(e){try{localStorage.removeItem(e)}catch{}}function u3(e){let t=new Map,n=un({}),r=()=>Object.values(n).some(Boolean),i=e=>{let t=o3(e.ydoc.getXmlFragment(`default`)),r=r3(e.uuid);if(t.length===0){l3(r),s3(i3)===e.uuid&&l3(i3),n[e.uuid]=!1;return}c3(r,t),c3(i3,e.uuid),n[e.uuid]=!0},a=(e,n,r)=>{if(t.has(e))return;let a={uuid:e,ydoc:n,provider:r,updateHandler:()=>{},syncedHandler:null,persist:n3(()=>{},a3)};if(a.persist=n3(()=>i(a),a3),a.updateHandler=()=>a.persist(),n.on(`update`,a.updateHandler),t.set(e,a),r.synced)o(a);else{let n=()=>{a.syncedHandler=null,r.off(`synced`,n),t.get(e)===a&&o(a)};a.syncedHandler=n,r.on(`synced`,n)}},o=e=>{let r=e.ydoc.getXmlFragment(`default`);if(o3(r).length>0)return;let i=e.uuid,a=s3(r3(i));if(a===null&&t.size===1){let t=s3(i3);t&&t!==e.uuid&&(a=s3(r3(t)),i=t)}if(a===null||a.length===0)return;let o=a.split(`
|
|
261
|
-
`).map(e=>{let t=new qT(`paragraph`);return e.length>0&&t.insert(0,[new QT(e)]),t});KO(e.ydoc,()=>{r.length>0&&r.delete(0,r.length),r.insert(0,o)}),c3(r3(e.uuid),a),c3(i3,e.uuid),i!==e.uuid&&l3(r3(i)),n[e.uuid]=!0},s=e=>{let n=t.get(e);n&&(n.persist.flush(),n.ydoc.off(`update`,n.updateHandler),n.syncedHandler&&n.provider.off(`synced`,n.syncedHandler),t.delete(e))},c=e=>{l3(r3(e)),s3(i3)===e&&l3(i3),t.get(e)?.persist.cancel(),n[e]=!1},l=Ln(()=>{L(()=>{let n=e(),r=new Set;for(let e of n){if(!bo(e.filePath))continue;let t=xo(e.filePath);t&&(r.add(t),a(t,e.ydoc,e.provider))}for(let e of[...t.keys()])r.has(e)||s(e)}),L(()=>{let e=e=>{if(r()){for(let e of t.values())e.persist.flush();return e.preventDefault(),e.returnValue=`You have unsaved scratchpad content.`,`You have unsaved scratchpad content.`}};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)})});return{hasUnsavedContent:e=>n[e]===!0,clearUnsaved:c,destroy:()=>{l();for(let e of[...t.keys()])s(e)}}}function d3(e,t,n){return e.length<2?null:e[(e.findIndex(e=>e.id===t)+(n?-1:1)+e.length)%e.length].id}function f3(e,t,n){let r=null;_a(()=>{r=r=>{if(!r.ctrlKey&&!r.metaKey||r.key!==`Tab`)return;let i=d3(e(),t(),r.shiftKey);i&&(r.preventDefault(),n(i))},window.addEventListener(`keydown`,r)}),va(()=>{r&&window.removeEventListener(`keydown`,r)})}function p3(e,t){return e.length===0||t<1||t>9?null:e[Math.min(t-1,e.length-1)].id}function m3(e){if(e.isComposing)return!0;let t=e.target;return t?t.tagName===`INPUT`||t.tagName===`TEXTAREA`:!1}function h3(e,t){let n=new Set(t),r=e.filter(e=>n.has(e)),i=new Set(r),a=t.filter(e=>!i.has(e));return[...r,...a]}function g3(e,t,n,r,i=`left`){let a=e.filter(e=>r.has(e)),o=a.indexOf(t),s=a.indexOf(n);if(o===-1||s===-1)return a;let c=[...a];c.splice(o,1);let l=c.indexOf(n),u=i===`right`?l+1:l;return c.splice(u,0,t),c}function _3(e){let t=M(un([]));L(()=>{let n=e().map(e=>e.id),r=h3(z(t),n);(z(t).length!==r.length||z(t).some((e,t)=>e!==r[t]))&&N(t,r,!0)});let n=j(()=>{let n=e(),r=new Map(n.map(e=>[e.id,e])),i=n.map(e=>e.id);return h3(z(t),i).map(e=>r.get(e)).filter(Boolean)});return{get orderedTabs(){return z(n)},reorder:(n,r,i=`left`)=>{if(n===r)return;let a=e(),o=new Set(a.map(e=>e.id));N(t,g3(z(t),n,r,o,i),!0)}}}function v3(e,t){let n=M(un((()=>{try{let e=localStorage.getItem(Ma),t=ac.safeParse(e);return t.success?t.data:ja}catch(e){return console.warn(`[tandem] localStorage unavailable reading ${Ma}:`,e),ja}})()));return L(()=>{let e=z(n);try{localStorage.setItem(Ma,e)}catch(e){console.warn(`[tandem] failed to persist ${Ma}:`,e)}}),L(()=>{let t=e(),r=z(n);if(t)try{t.getMap(Ba).set(Va,r)}catch(e){console.warn(`[tandem] failed to broadcast tandem mode to Y.Map:`,e)}}),L(()=>{let n=e(),r=t();if(n)try{n.getMap(Ba).set(Ha,r)}catch(e){console.warn(`[tandem] failed to broadcast dwell ms to Y.Map:`,e)}}),{get tandemMode(){return z(n)},setTandemMode(e){N(n,e,!0)}}}var y3=M(!1),b3=!1,x3=()=>{},S3={get fileDragOver(){return z(y3)}};function C3(e){let t=e.split(/[/\\]/).at(-1)??``,n=t.lastIndexOf(`.`);return n<=0?!1:wa.has(t.slice(n).toLowerCase())}var w3=(()=>{let e=Array.from(wa).sort();return e.length<=1?e[0]??``:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(`, `)}, or ${e.at(-1)}`})();function T3(e,t,n){x3({id:`tauri-drop-${n}-${Date.now()}`,type:`general-error`,severity:t,message:e,dedupKey:n,timestamp:Date.now()})}function E3(e){x3=e,!b3&&Lm()&&(b3=!0,Ul(async()=>{let{getCurrentWebview:e}=await import(`./webview-C-97RVRf.js`);return{getCurrentWebview:e}},__vite__mapDeps([8,1,9,3])).then(async({getCurrentWebview:e})=>{await e().onDragDropEvent(e=>{try{let t=e.payload;switch(t.type){case`enter`:N(y3,!0);return;case`drop`:N(y3,!1);for(let e of t.paths)if(C3(e)){(async()=>{let t=await Ch(e);t.ok||T3(`Couldn't open ${e}: ${t.error}`,`error`,`tauri-drop-open-failed`)})();return}T3(`Tandem can only open ${w3} files`,`warning`,`tauri-drop-unsupported`);return;case`leave`:N(y3,!1);return;default:console.warn(`[useTauriFileDrop] unknown payload type:`,t)}}catch(e){console.error(`[useTauriFileDrop] callback threw:`,e),T3(`Drag-and-drop encountered an error — try the Open File dialog`,`error`,`tauri-drop-callback-error`)}})}).catch(e=>{b3=!1,console.error(`[useTauriFileDrop] Failed to attach onDragDropEvent:`,e),T3(`Drag-and-drop unavailable — use the Open File dialog instead`,`warning`,`tauri-drop-unavailable`)}))}var D3=new class{#e=M(un(Lm()?window.__TANDEM_INITIAL_THEME__??null:null));get current(){return z(this.#e)}set current(e){N(this.#e,e,!0)}},O3=!1;function k3(e){D3.current=e,typeof window<`u`&&(window.__TANDEM_INITIAL_THEME__=e)}function A3(){if(O3||!Lm())return;O3=!0;let e=null;Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]).then(({invoke:t})=>{e=t,t(`get_app_theme`).then(e=>{k3(e===`dark`?`dark`:`light`)}).catch(e=>{console.warn(`[useTauriTheme] get_app_theme failed:`,e)})}).catch(e=>{console.warn(`[useTauriTheme] Tauri API import failed:`,e)}),Ul(async()=>{let{getCurrentWindow:e}=await import(`./window-CR0qpD8C.js`);return{getCurrentWindow:e}},__vite__mapDeps([9,1,3])).then(({getCurrentWindow:e})=>{e().onThemeChanged(({payload:e})=>{k3(e===`dark`?`dark`:`light`)}).catch(e=>{console.warn(`[useTauriTheme] onThemeChanged subscribe failed:`,e)})}).catch(e=>{console.warn(`[useTauriTheme] Tauri window API import failed:`,e)});let t=!1,n=setInterval(()=>{!document.hasFocus()||!e||e(`get_app_theme`).then(e=>{let n=e===`dark`?`dark`:`light`;D3.current!==n&&(k3(n),t=!1)}).catch(e=>{t||=(console.warn(`[useTauriTheme] theme poll failed (further errors suppressed):`,e),!0)})},3e3);window.addEventListener(`pagehide`,()=>clearInterval(n),{once:!0})}function j3(e=`light`){let t=e===`warm`?`warm`:`light`;try{if(typeof window>`u`)return t;if(Lm()){let e=D3.current;if(e===`dark`)return`dark`;if(e===`light`)return t;let n=window.__TANDEM_INITIAL_THEME__;if(n===`dark`)return`dark`;if(n===`light`)return t}return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:t}catch(e){return console.warn(`[Tandem] Theme detection failed, defaulting to light:`,e),t}}function M3(e,t=`light`){return e===`system`?j3(t):e}function N3(e){try{let t=document.querySelector(`meta[name="theme-color"]`);t&&(t.content=e===`dark`?`#1c1c24`:e===`warm`?`#f1ead9`:`#fafaf9`)}catch{}}function P3(e,t=`light`){let n=document.documentElement,r=M3(e,t);if(n.setAttribute(`data-theme`,r),N3(r),e!==`system`||Lm())return()=>n.removeAttribute(`data-theme`);let i=window.matchMedia(`(prefers-color-scheme: dark)`),a=()=>{let e=j3(t);n.setAttribute(`data-theme`,e),N3(e)};return i.addEventListener(`change`,a),()=>{i.removeEventListener(`change`,a),n.removeAttribute(`data-theme`)}}function F3(e,t=()=>`light`){A3(),L(()=>{let n=e(),r=t();return D3.current,P3(n,r)})}function I3(){try{return localStorage.getItem(lo)===`true`}catch{return!1}}function L3(e){return e.author===`user`&&!e.id.startsWith(`tutorial-`)}function R3(){try{localStorage.setItem(lo,`true`)}catch{}}function z3(e,t,n){let r=M(un(I3())),i=M(0),a=0,o=Fm(),s=j(()=>n()===`welcome.md`),c=j(()=>!z(r)&&z(s)),l=Lm(),u=Zm(()=>l&&z(c)),d=j(()=>!l||u.status!==null||u.error!==null),f=j(()=>l&&Pm(u.status,o)),p=j(()=>z(d)?z(f)?4:3:1/0);return L(()=>{if(!z(c)||z(i)!==0)return;let t=e().filter(e=>e.id.startsWith(uo));t.length!==0&&t.some(e=>e.status!==`pending`)&&(a=Date.now(),N(i,1))}),L(()=>{!z(c)||z(i)!==1||e().some(L3)&&(a=Date.now(),N(i,2))}),L(()=>{if(!z(c)||z(i)!==2||!isFinite(z(p)))return;let e=t();if(!e)return;let n=()=>{Date.now()-a<2e3||e.isFocused&&(a=Date.now(),N(i,3))};return e.on(`update`,n),()=>{e.off(`update`,n)}}),L(()=>{if(!z(c)||!isFinite(z(p))||z(i)!==z(p))return;let e=setTimeout(()=>{R3(),N(r,!0)},3e3);return()=>clearTimeout(e)}),L(()=>{isFinite(z(p))&&z(i)>z(p)&&N(i,z(p),!0)}),{get tutorialActive(){return z(c)},get currentStep(){return z(i)},get coworkStatus(){return u.status},dismissTutorial:()=>{R3(),N(r,!0)},nextStep:()=>{a=Date.now(),N(i,Math.min(z(i)+1,z(p)),!0)}}}var B3=`tandem://update-available`,V3=`tandem:updater-dismissed-v`;function H3(e){return`${V3}${e}`}function U3(e){try{return window.localStorage.getItem(H3(e))===`1`}catch{return!1}}function W3(e){try{window.localStorage.setItem(H3(e),`1`)}catch{}}var G3=M(null),K3=M(null),q3=0,J3=null,Y3=!1,X3=0;function Z3(){return q3}function Q3(){return z(G3)}function $3(){return z(K3)}function e6(e){e&&(W3(e),N(K3,e,!0))}function t6(){if(q3+=1,q3===1&&Lm()){Y3=!1;let e=++X3;(async()=>{try{let{listen:t}=await Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1]));if(Y3||e!==X3||Z3()===0)return;let n=await t(B3,e=>{let t=e.payload?.version??null;t&&(N(G3,t,!0),z(K3)!==t&&N(K3,null))});if(Y3||e!==X3||Z3()===0){n();return}J3=n}catch(e){console.warn(`[useUpdaterChannel] listen() failed:`,e)}})()}let e=!1;return()=>{if(!e&&(e=!0,q3=Math.max(0,q3-1),q3===0)){Y3=!0;let e=J3;if(J3=null,e)try{e()}catch(e){console.warn(`[useUpdaterChannel] unlisten threw:`,e)}}}}function n6(){return L(()=>t6()),{get availableVersion(){return Q3()},get showDot(){let e=Q3();return!(!e||$3()===e||U3(e))},acknowledge(){e6(Q3())}}}var r6=3e4;function i6(){let e=M(!1),t=null;function n(){t!==null&&(clearTimeout(t),t=null)}L(()=>{let e=t6();return()=>{n(),e()}});async function r(){if(!(!Q3()||z(e))){N(e,!0),n(),t=setTimeout(()=>{t=null,N(e,!1),console.warn(`[useUpdaterBanner] install_update did not tear down WebView within ${r6}ms; re-arming CTA`)},r6);try{let{invoke:t}=await Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);await t(`install_update`),n(),N(e,!1)}catch(t){console.warn(`[useUpdaterBanner] install_update failed:`,t),n(),N(e,!1)}}}return{get availableVersion(){return Q3()},get installing(){return z(e)},get showBanner(){let e=Q3();return!(!e||$3()===e||U3(e))},dismiss(){e6(Q3())},install:r}}function a6(){let e=M(un(window.innerWidth));return L(()=>{let t=null,n=()=>{t===null&&(t=requestAnimationFrame(()=>{N(e,window.innerWidth,!0),t=null}))};return window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),t!==null&&cancelAnimationFrame(t)}}),{get width(){return z(e)}}}function o6(){let e=null;_a(()=>{let t=!1,n;Ul(async()=>{let{getCurrentWebview:e}=await import(`./webview-C-97RVRf.js`);return{getCurrentWebview:e}},__vite__mapDeps([8,1,9,3])).then(({getCurrentWebview:e})=>{if(t)return;let r=e(),i=1;try{let e=localStorage.getItem(ho);if(e!==null){let t=Number(e);Number.isFinite(t)?i=Math.max(go,Math.min(2,t)):console.warn(`[tandem] ignoring invalid stored zoom: ${e}`)}}catch{}i!==1&&r.setZoom(i).catch(e=>{console.warn(`[tandem] failed to restore zoom level:`,e)});function a(e){try{localStorage.setItem(ho,String(e))}catch{}}let o=e=>{!(e.metaKey||e.ctrlKey)||e.key!==`0`||(e.preventDefault(),e.stopPropagation(),i=1,r.setZoom(1).catch(e=>{console.warn(`[tandem] failed to reset zoom:`,e)}),a(1))},s=.1,c=e=>{if(!(e.metaKey||e.ctrlKey))return;let t=e.key===`+`||e.key===`=`,n=e.key===`-`||e.key===`_`;if(!t&&!n)return;let r=t?i+s:i-s;i=Math.max(go,Math.min(2,Math.round(r*100)/100)),a(i)};window.addEventListener(`keydown`,o,{capture:!0}),window.addEventListener(`keydown`,c,{capture:!0}),n=()=>{window.removeEventListener(`keydown`,o,{capture:!0}),window.removeEventListener(`keydown`,c,{capture:!0})}}).catch(()=>{}),e=()=>{t=!0,n?.()}}),va(()=>{e?.()})}var s6=1e3;function c6(e){let t=!1;return function(){e.isDestroyed()||t||(t=!0,queueMicrotask(async()=>{try{for(;!e.isDestroyed();){let t=await e.fetchGenerationId();if(e.isDestroyed())return;if(t&&t===e.getPinnedGeneration()){e.onGenerationUnchanged();return}if(t){e.rebuild(t);return}await e.sleep(s6)}}finally{t=!1}}))}}function l6(e){let{prev:t,serverActiveId:n,serverIds:r,removedCount:i,serverEpoch:a,lastAppliedEpoch:o}=e;return t===null||!r.has(t)?n:i>0&&n===t||a===o?t:n}function u6(e,t,n){return e.filter(e=>!t.has(e.id)&&!n.has(e.id))}function d6(e){return e===`constant-2s`?{delay:2e3,factor:1,maxAttempts:0,minDelay:2e3,maxDelay:2e3,jitter:!1}:{delay:1e3,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0}}function f6(e){let t=t=>({...t,...d6(e?.getRetryStrategy?.()??`exponential`)}),n=M(un([])),r=M(null),i=M(!1),a=M(`connecting`),o=M(0),s=M(null),c=M(un([])),l=M(null),u=M(!1),d=M(null),f=M(!1),p=M(!1),m=M(!1),h=M(null),g=null,_=!1,v=null,y=null,b=new Set,x=new Map,S=new Map,C=new Map,w=!1,ee=e=>{let{ydoc:t}=e,n=t.getMap(Ra),r=()=>{let e=[];n.forEach(t=>{e.push(qO(t,e=>{console.warn(`[sanitize]`,e)}))}),N(c,e,!0)};n.observe(r),r();let i=t.getMap(za),a=null,o=!1,s=null,f=e=>e?`${e.tool} ${e.annotationId??``} ${e.token??e.startedAt}`:null,p=()=>{let e=i.get(Xa),t=e?.status??null,n=e?.active??!1,r=e?.working??null;t!==a&&(a=t,N(l,t,!0)),n!==o&&(o=n,N(u,n,!0));let c=f(r);c!==s&&(s=c,N(d,r,!0))};return i.observe(p),p(),()=>{n.unobserve(r),i.unobserve(p)}},T=e=>new Promise(t=>setTimeout(t,e)),te=async()=>{try{let e=await fetch(`http://127.0.0.1:${xa}${mc}`,{signal:AbortSignal.timeout(5e3)});return e.ok?(await e.json()).generationId??null:null}catch{return null}},ne=()=>{for(let e of S.values())e.cleanup();S.clear();for(let e of C.values())e();C.clear();for(let e of x.values())e.provider.destroy(),e.ydoc.destroy();x.clear(),b.clear();for(let e of z(n))e.provider.destroy(),e.ydoc.destroy();N(n,[],!0)},E=c6({isDestroyed:()=>w,fetchGenerationId:te,getPinnedGeneration:()=>v,onGenerationUnchanged:()=>{console.warn(`[Tandem] Provider auth failed without a generation change`)},rebuild:e=>{console.warn(`[Tandem] Server restarted — resyncing documents`),ne(),ie?.(),N(m,!0),y=null,g=setTimeout(()=>{N(m,!1)},5e3),oe(e)},sleep:T}),re=(e,i,a)=>{let o=z(n),s=new Set(o.map(e=>e.id)),c=new Set(e.map(e=>e.id));for(let e of o)b.delete(e.id),x.delete(e.id);for(let[e,t]of x)c.has(e)||(C.get(e)?.(),C.delete(e),t.provider.destroy(),t.ydoc.destroy(),x.delete(e),b.delete(e));let l=u6(e,s,b),u=[];for(let e of l){b.add(e.id);let n=new uC,r=new UP(t({url:`ws://127.0.0.1:${ba}`,name:e.id,document:n,token:v}));r.on(`authenticationFailed`,E),x.set(e.id,{ydoc:n,provider:r});let i=n.getMap(Wa),a=e=>{if(!e.keysChanged.has(`openDocuments`)&&!e.keysChanged.has(`activeDocumentId`)&&!e.keysChanged.has(`activeDocumentEpoch`))return;let t=i.get(Za),n=i.get(Qa),r=i.get($a);t&&re(t,n??null,r??null)};i.observe(a),C.set(e.id,()=>i.unobserve(a)),u.push({...e,ydoc:n,provider:r})}let d=o.filter(e=>!c.has(e.id));for(let e of d){let t=S.get(e.id);t&&(t.cleanup(),S.delete(e.id)),C.get(e.id)?.(),C.delete(e.id),b.delete(e.id),x.delete(e.id),e.provider.destroy(),e.ydoc.destroy()}let f=new Map(e.map(e=>[e.id,e]));N(n,[...o.filter(e=>c.has(e.id)).map(e=>{let t=f.get(e.id);return!t||t.fileName===e.fileName&&t.filePath===e.filePath&&t.format===e.format&&t.readOnly===e.readOnly&&t.source===e.source?e:{...e,fileName:t.fileName,filePath:t.filePath,format:t.format,readOnly:t.readOnly,source:t.source}}),...u],!0),i!==null&&(N(r,l6({prev:z(r),serverActiveId:i,serverIds:c,removedCount:d.length,serverEpoch:a,lastAppliedEpoch:y}),!0),y=a)},ie=null,ae=null;function oe(e){v=e;let n=new uC,r=new UP(t({url:`ws://127.0.0.1:${ba}`,name:La,document:n,token:e}));N(h,n,!0),ae=r,r.on(`authenticationFailed`,E),r.on(`status`,({status:e})=>{N(i,e===`connected`),N(a,[`connected`,`connecting`,`disconnected`].includes(e)?e:`connecting`,!0),e===`connected`?(_=!0,N(o,0),N(s,null)):e===`disconnected`?z(s)===null&&N(s,Date.now(),!0):e===`connecting`&&(_&&N(o,z(o)+1),z(s)===null&&N(s,Date.now(),!0))});let c=n.getMap(Wa),l=e=>{if(e.keysChanged.has(`openDocuments`)||e.keysChanged.has(`activeDocumentId`)||e.keysChanged.has(`activeDocumentEpoch`)){let e=c.get(Za),t=c.get(Qa),n=c.get($a);e&&re(e,t??null,n??null)}e.keysChanged.has(`storeReadOnly`)&&N(f,c.get(eo)===!0)};c.observe(l);let u=c.get(Za),d=c.get(Qa),m=c.get($a);u&&re(u,d??null,m??null),N(f,c.get(eo)===!0),ie=()=>{c.unobserve(l),g&&=(clearTimeout(g),null),r.destroy(),n.destroy(),N(h,null),ae=null,ie=null},N(p,!0)}(async()=>{for(;!w;){let e=await te();if(w)return;if(e){oe(e);return}N(p,!0),N(a,`disconnected`),N(i,!1),z(s)===null&&N(s,Date.now(),!0),await T(1e3)}})();let se=j(()=>z(n).find(e=>e.id===z(r))??null),ce=j(()=>z(se)?.ydoc??null),le=Ln(()=>{L(()=>{z(ce);let e=z(se);for(let e of S.values())e.cleanup();if(S.clear(),e){let t=ee(e);S.set(e.id,{cleanup:t})}else N(c,[],!0),N(l,null),N(u,!1),N(d,null)})});return{get tabs(){return z(n)},get activeTabId(){return z(r)},setActiveTabId:e=>{N(r,e,!0)},handleTabClose:e=>{if(z(r)===e){let t=z(n),i=t.findIndex(t=>t.id===e),a=t.filter(t=>t.id!==e);a.length===0?N(r,null):N(r,a[Math.min(i,a.length-1)].id,!0)}fetch(`http://127.0.0.1:${xa}${vc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e})}).then(e=>{e.ok||console.warn(`[Tandem] Server rejected close:`,e.status)}).catch(e=>{console.warn(`[Tandem] Failed to close document on server:`,e)})},handleTabRename:(e,t,r)=>{let i=z(n).find(t=>t.id===e);if(!i)return;let a=i.fileName,o=t=>z(n).map(n=>n.id===e?{...n,fileName:t}:n);N(n,o(t),!0);let s=e=>{N(n,o(a),!0),r?.(e)};fetch(`http://127.0.0.1:${xa}${bc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,newName:t})}).then(async e=>{if(e.ok)return;let t=`Rename failed (${e.status}).`;try{let n=await e.json();n?.message&&(t=n.message)}catch{}console.warn(`[Tandem] Server rejected rename:`,e.status,t),s(t)}).catch(e=>{console.warn(`[Tandem] Failed to rename document on server:`,e),s(`Rename failed: could not reach the server.`)})},get connected(){return z(i)},get connectionStatus(){return z(a)},get reconnectAttempts(){return z(o)},get disconnectedSince(){return z(s)},get annotations(){return z(c)},get claudeStatus(){return z(l)},get claudeActive(){return z(u)},get claudeWorking(){return z(d)},get storeReadOnly(){return z(f)},get bootstrapYdoc(){return z(h)},get ready(){return z(p)},get serverRestarted(){return z(m)},destroy:()=>{w||(w=!0,le(),ne(),ie?.(),N(c,[],!0),N(r,null),N(p,!1))},reconnect(){ae?.connect();for(let e of z(n))e.provider.connect()},rebuildForLicenseChange(){if(w)return;let e=v;e!==null&&(ne(),ie?.(),y=null,oe(e))}}}var p6={full:{column:240,inset:8,gap:24},narrow:{column:160,inset:8,gap:24},stub:{column:28,inset:8,gap:24},off:{column:0,inset:0,gap:0}};function m6(e){return e.column+e.inset+e.gap}p6.full.column;var h6=m6(p6.full);function g6(e){return 2*h6+e+480}function _6(e){let t=e+480;return{t1:g6(e),t2:2*m6(p6.narrow)+t,t3:2*m6(p6.stub)+t}}var v6={off:0,stub:1,narrow:2,full:3};function y6(e,t,n,r){let{t1:i,t2:a,t3:o}=n,s=t,c=r,l=s<o?`off`:s<a?`stub`:s<i?`narrow`:`full`,u=s>i+c?`full`:s>a+c?`narrow`:s>o+c?`stub`:`off`;return v6[e]>v6[l]?l:v6[e]<v6[u]?u:e}function b6(e,t,n){return e?t&&n===`full`?`full`:`off`:t?n:`off`}function x6(e,t,n){return!t&&!n?`off`:e}function S6(e){return e.isDocx?e.effectivelyOn?`position: relative;`:`display: contents;`:`--editor-measure: ${e.measure}; --margin-left-track: ${e.leftReservePx}px; --margin-right-track: ${e.rightReservePx}px; display: grid; align-items: stretch; grid-template-columns: minmax(0, 1fr) var(--margin-left-track) minmax(0, var(--editor-measure)) var(--margin-right-track) minmax(0, 1fr);`}function C6(e){let t=j(()=>(e.getLeftRailVisible()?e.leftRailWidthPx:0)+(e.getRightRailVisible()?e.rightRailWidthPx:0)),n=j(()=>_6(z(t))),r=M(`full`);L(()=>{let t=e.getViewportWidth(),i=z(n),a=Ar(()=>z(r)),o=y6(a,t,i,32);o!==a&&N(r,o,!0)});let i=j(()=>e.getFormat()===`docx`),a=j(()=>b6(z(i),e.getMarginView(),z(r))),o=j(()=>x6(z(a),z(i),e.getLeftHasPending())),s=j(()=>x6(z(a),z(i),e.getRightHasPending())),c=j(()=>z(o)!==`off`),l=j(()=>z(s)!==`off`),u=j(()=>z(c)||z(l)),d=j(()=>p6[z(o)]),f=j(()=>p6[z(s)]),p=new Set,m=j(()=>S6({isDocx:z(i),effectivelyOn:z(u),leftReservePx:m6(z(d)),rightReservePx:m6(z(f)),measure:(()=>{let t=e.getEditorMeasure(),n=bl[t];return n===void 0&&!p.has(t)&&(p.add(t),console.warn(`[tandem] editorMeasure=${JSON.stringify(t)} not in EDITOR_MEASURE_CH; falling back to comfortable. Both useTandemSettings validators should have coerced this upstream — a TS-violating cast slipped past them.`)),n??bl.comfortable})()}));return{get effectivelyOn(){return z(u)},get leftVisible(){return z(c)},get rightVisible(){return z(l)},get leftMode(){return z(o)},get rightMode(){return z(s)},get leftGeometry(){return z(d)},get rightGeometry(){return z(f)},get layerStyle(){return z(m)}}}function w6(e,t){let n=j(()=>e.settings.leftPanelVisible),r=j(()=>e.settings.rightPanelVisible&&!(t.tandemMode===`solo`&&e.settings.soloRailHidden));function i(){e.updateSettings({leftPanelVisible:!e.settings.leftPanelVisible})}function a(){if(z(r)){e.updateSettings({rightPanelVisible:!1});return}e.updateSettings({rightPanelVisible:!0,...t.tandemMode===`solo`?{soloRailHidden:!1}:{}})}return{get leftVisible(){return z(n)},get rightVisible(){return z(r)},toggleLeft:i,toggleRight:a}}function T6(e){return e.mode===`stub`?`stub`:e.isEditing||e.isActive?`full`:e.mode===`narrow`?`clamped`:`full`}var E6=6;function D6(e,t={}){let n=t.gap??E6,r=new Map;if(e.length===0)return r;let i=e.map((e,t)=>({...e,idx:t})).sort((e,t)=>e.top-t.top||e.idx-t.idx),a=-1/0;for(let e of i){if(!Number.isFinite(e.top))continue;let t=Math.max(e.top,a);r.set(e.id,t),typeof e.height==`number`&&Number.isFinite(e.height)&&e.height>0&&(a=t+e.height+n)}return r}function O6(e,t){let n=[];for(let r of e.keys())t.has(r)||n.push(r);for(let t of n)e.delete(t);return n.length}var k6=.62;function A6(e){let t=e.endX-e.startX,n=e.startX+t*k6,r=e.endX-t*k6;return`M ${e.startX.toFixed(1)},${e.startY.toFixed(1)} C ${n.toFixed(1)},${e.startY.toFixed(1)} ${r.toFixed(1)},${e.endY.toFixed(1)} ${e.endX.toFixed(1)},${e.endY.toFixed(1)}`}function j6(e){throw Error(`unhandled annotation author: ${String(e)}`)}function M6(e){switch(e){case`claude`:return`var(--tandem-author-claude)`;case`user`:return`var(--tandem-author-user)`;case`import`:return`var(--tandem-fg-subtle)`;default:return j6(e)}}var N6=Jr(`<path stroke-linecap="round" fill="none"></path><circle data-testid="margin-anchor-dot"></circle>`,1),P6=V(`<div class="margin-bubble svelte-lzz9jv"><!></div>`),F6=V(`<svg aria-hidden="true"></svg> <div></div>`,1);function I6(e,t){k(t,!0);let n=q(t,`reduceMotion`,3,!1),r=j(()=>t.side===`right`?0:t.gap),i=j(()=>t.side===`right`?t.gap:0),a=j(()=>`position: absolute; top: 0; bottom: 0; ${t.side}: ${t.edgeInset+t.width}px; width: ${t.gap}px; pointer-events: none;`),o=j(()=>t.annotations.filter(e=>t.positions.has(e.id)&&e.status===`pending`)),s=M(un(new Map)),c=j(()=>new Map(z(o).map(e=>[e.id,T6({mode:t.mode,isActive:e.id===t.activeAnnotationId,isEditing:!1})]))),l=j(()=>D6(z(o).map(e=>({id:e.id,top:t.positions.get(e.id)??0,height:z(c).get(e.id)===`stub`?void 0:z(s).get(e.id)}))));L(()=>{let e=new Set(z(o).map(e=>e.id));Ar(()=>{O6(z(s),e)>0&&N(s,new Map(z(s)),!0)})});function u(e,t){if(!Number.isFinite(t)||t<=0)return;let n=z(s).get(e);if(n!==void 0&&Math.abs(n-t)<.5)return;let r=new Map(z(s));r.set(e,t),N(s,r,!0)}let d=M(void 0),f=M(null),p=0;function m(e){return t.annotations.find(t=>t.id===e)}function h(e){return n=>{let r=m(e);r&&hk(n,r,{accept:t.onAccept,dismiss:t.onDismiss,sendToClaude:t.onSendToClaude,remove:t.onRemove,openEdit:e=>N(f,{id:e,kind:`edit`,nonce:++p},!0),openReply:e=>N(f,{id:e,kind:`reply`,nonce:++p},!0)})}}async function g(e){if(!Lm())return;let t=(e.target?.closest(`[data-annotation-id]`))?.getAttribute(`data-annotation-id`);if(!t)return;let n=m(t);n&&(e.preventDefault(),e.stopPropagation(),await gk(n,h(t)))}L(()=>{let e=z(d);if(e)return e.addEventListener(`contextmenu`,g),()=>e.removeEventListener(`contextmenu`,g)}),L(()=>yk());var _=F6(),v=F(_);pi(v,21,()=>z(o),e=>e.id,(e,n)=>{let a=j(()=>t.positions.get(z(n).id)),o=j(()=>z(l).get(z(n).id));var s=Xr(),c=F(s),u=e=>{let s=j(()=>z(n).id===t.activeAnnotationId),c=j(()=>z(o)??z(a)),l=j(()=>z(c)+12),u=j(()=>M6(z(n).author)),d=j(()=>A6({startX:z(r),startY:z(a),endX:z(i),endY:z(l)}));var f=N6(),p=F(f),m=I(p);R(()=>{K(p,`data-annotation-id`,z(n).id),K(p,`data-tandem-author`,z(n).author),K(p,`d`,z(d)),K(p,`stroke`,z(u)),K(p,`stroke-width`,z(s)?1.8:1.1),K(p,`stroke-opacity`,z(s)?.82:.38),K(m,`data-annotation-id`,z(n).id),K(m,`data-tandem-author`,z(n).author),K(m,`cx`,z(r)),K(m,`cy`,z(a)),K(m,`r`,z(s)?3:2),K(m,`fill`,z(u)),K(m,`fill-opacity`,z(s)?.72:.42)}),H(e,f)};W(c,e=>{z(a)!==void 0&&e(u)}),H(e,s)}),D(v);var y=I(v,2);pi(y,21,()=>z(o),e=>e.id,(e,r)=>{let i=j(()=>z(l).get(z(r).id)??t.positions.get(z(r).id)??0),a=j(()=>jD(z(r),t.repliesById.get(z(r).id))),o=j(()=>z(c).get(z(r).id)??`full`);var s=P6(),d=P(s);{let e=j(()=>z(r).id===t.activeAnnotationId),i=j(()=>ik(z(r))?t.onAccept:void 0),s=j(()=>ak(z(r))?t.onDismiss:void 0),c=j(()=>lk(z(r))?t.onRemove:void 0),l=j(()=>ck(z(r))?t.onSendToClaude:void 0),u=j(()=>sk(z(r))?t.onEdit:void 0),p=j(()=>ok(z(r))?t.onReply:void 0),m=j(()=>z(f)?.id===z(r).id?z(f):null);UO(d,{get annotation(){return z(r)},get replies(){return z(a)},get isReviewTarget(){return z(e)},get density(){return z(o)},get reduceMotion(){return n()},onClick:()=>t.onClick(z(r)),get onAccept(){return z(i)},get onDismiss(){return z(s)},get onRemove(){return z(c)},get onSendToClaude(){return z(l)},get onEdit(){return z(u)},get onReply(){return z(p)},get openRequest(){return z(m)}})}D(s),R(()=>{K(s,`data-testid`,`margin-bubble-${z(r).id??``}`),K(s,`data-margin-bubble-reply-count`,z(a).length),G(s,`position: absolute; top: ${z(i)??``}px; ${t.side??``}: 0; width: ${t.width??``}px; pointer-events: auto;`)}),Mi(1,s,()=>dv,()=>({id:z(r).id,reduceMotion:n()})),ua(s,`clientHeight`,e=>u(z(r).id,e)),H(e,s)}),D(y),fa(y,e=>N(d,e),()=>z(d)),R(()=>{K(v,`data-testid`,`margin-leaders-${t.side??``}`),G(v,z(a)),K(y,`data-testid`,`margin-column-${t.side??``}`),K(y,`aria-label`,t.side===`left`?`Note bubbles`:`Comment bubbles`),G(y,`position: absolute; top: 0; ${t.side??``}: ${t.edgeInset??``}px; width: ${t.width??``}px; pointer-events: none;`)}),H(e,_),A()}function L6(e){return e.type===`note`}function R6(e){return e.author===`import`||e.type===`comment`}var z6=V(`<span class="peek-tick h1 svelte-1mwvi22"></span> <span class="peek-tick h2 svelte-1mwvi22"></span> <span class="peek-tick h2 svelte-1mwvi22"></span> <span class="peek-tick h3 svelte-1mwvi22"></span> <span class="peek-tick h2 svelte-1mwvi22"></span>`,1),B6=V(`<span></span>`),V6=V(`<button type="button" tabindex="-1"><span class="peek-chevron svelte-1mwvi22" aria-hidden="true"> </span> <div class="peek-content svelte-1mwvi22" aria-hidden="true"><!></div> <span class="peek-label svelte-1mwvi22" aria-hidden="true"> </span></button>`);function H6(e,t){k(t,!0);let n=q(t,`annotations`,19,()=>[]),r=j(()=>t.side===`left`?`Outline`:`Annotations`);function i(e){return e.type===`highlight`?`hl`:e.type===`comment`&&e.suggestedText!=null?`suggest`:e.author===`claude`?`claude`:e.author===`import`?`import`:`user`}function a(e){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t.onActivate())}var o=V6(),s=P(o),c=P(s,!0);D(s);var l=I(s,2),u=P(l),d=e=>{var t=z6();O(8),H(e,t)},f=e=>{var t=Xr();pi(F(t),17,n,e=>e.id,(e,t)=>{var n=B6();R(e=>Ui(n,1,`peek-dot ${e??``}`,`svelte-1mwvi22`),[()=>i(z(t))]),H(e,n)}),H(e,t)};W(u,e=>{t.kind===`outline`?e(d):e(f,-1)}),D(l);var p=I(l,2),m=P(p,!0);D(p),D(o),R(()=>{Ui(o,1,`peek-strip peek-strip-${t.side??``}`,`svelte-1mwvi22`),K(o,`data-testid`,`peek-strip-${t.side}`),K(o,`aria-label`,t.side===`left`?`Show left panel`:`Show right panel`),K(o,`aria-expanded`,!t.collapsed),G(o,t.collapsed?``:`display: none;`),U(c,t.side===`left`?`›`:`‹`),U(m,z(r))}),B(`click`,o,function(...e){t.onActivate?.apply(this,e)}),B(`keydown`,o,a),H(e,o),A()}Br([`click`,`keydown`]);var U6=e=>{console.warn(`[sanitize]`,e)};function W6(e,t,n){if(e.suggestedText===void 0)return!1;let r=e.suggestedText,i=iD(e,t.state.doc,n);if(!i)return console.warn(`[SidePanel] Could not resolve range for suggestion`,e.id),!1;try{t.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,r).run()}catch(t){return console.error(`[SidePanel] Editor mutation failed for suggestion`,e.id,t),!1}return!0}function G6({getYdoc:e,getEditor:t,getAnnotations:n,onActiveAnnotationChange:r,getScrollBehavior:i,getActiveAnnotationId:a}){let o=M(0),s=M(un(new Set)),c=new Map,l=null;va(()=>{for(let e of c.values())clearTimeout(e);c.clear()});function u(){return n().filter(sc)}function d(n,r){let i=e();if(!i)return;let a=i.getMap(Ra),o=a.get(n);if(!o||o.status!==`pending`)return;let c=qO(o,U6);if(a.set(n,{...c,status:r}),r===`accepted`&&c.suggestedText!==void 0){let e=t();if(e&&!W6(c,e,i)){a.set(n,{...c,status:`pending`});return}}l=n,N(s,new Set(z(s)).add(n),!0)}function f(e){let t=c.get(e);t&&clearTimeout(t),c.set(e,setTimeout(()=>{c.delete(e);let t=new Set(z(s));t.delete(e),N(s,t,!0)},3e3))}function p(e){let t=c.get(e);t&&(clearTimeout(t),c.delete(e));let n=new Set(z(s));n.delete(e),N(s,n,!0)}function m(n){let r=e();if(!r)return!1;let i=r.getMap(Ra),a=i.get(n);if(!a||a.status===`pending`)return p(n),!1;let o=qO(a,U6),s=t();if(o.status===`accepted`&&o.suggestedText!==void 0&&s)try{let e=o.suggestedText,t=o.textSnapshot;if(typeof e==`string`&&typeof t==`string`){let i=iD(o,s.state.doc,r);if(!i)return console.warn(`[undo] Cannot resolve range for annotation ${n}, skipping`),f(n),!1;if(s.state.doc.textBetween(i.from,i.to)!==e)return console.warn(`[undo] Text changed since accept for annotation ${n}, skipping`),f(n),!1;s.chain().focus().deleteRange({from:i.from,to:i.to}).insertContentAt(i.from,t).run()}}catch(e){return console.warn(`[undo] Failed to revert text for annotation ${n}:`,e),f(n),!1}return i.set(n,{...o,status:`pending`}),p(n),l===n&&(l=null),!0}function h(e){d(e,`accepted`)}function g(e){d(e,`dismissed`)}function _(n){let r=t();if(!r)return;let a=iD(n,r.state.doc,e());if(!a)return;r.chain().focus().setTextSelection({from:a.from,to:a.to}).run();let o=r.view.domAtPos(a.from);(o.node instanceof HTMLElement?o.node:o.node.parentElement)?.scrollIntoView({behavior:i(),block:`center`})}return L(()=>{let e=a?.()??null;e!==null&&(n().some(t=>t.id===e&&t.status===`pending`)||r(u()[z(o)]?.id??null))}),L(()=>{let e=u();z(o)>=e.length&&N(o,Math.max(0,e.length-1),!0)}),{resolveAnnotation:d,undoResolveAnnotation:m,handleAccept:h,handleDismiss:g,scrollToAnnotation:_,getRecentlyResolved:()=>z(s),getReviewIndex:()=>z(o),getReviewTargets:u}}var K6=V(`<button type="button"><span class="highlight-picker-swatch-inner svelte-1d240y8"></span> <svg class="highlight-picker-swatch-check svelte-1d240y8" width="10" height="10" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 11l3 3 7-9"></path></svg></button>`),q6=V(`<div class="highlight-picker-popover svelte-1d240y8"><!> <button type="button" data-testid="color-picker-close" title="Close" aria-label="Close color picker" class="highlight-picker-close svelte-1d240y8">✕</button></div>`),J6=V(`<div class="highlight-picker-wrap svelte-1d240y8"><!> <button type="button" class="highlight-swatch-toggle svelte-1d240y8" data-testid="toolbar-highlight-color-toggle" title="Choose highlight color"><span class="highlight-swatch-preview svelte-1d240y8"></span></button> <!></div>`);function Y6(e,t){k(t,!0);let n=[{value:`yellow`,label:`Yellow`},{value:`green`,label:`Green`},{value:`blue`,label:`Blue`},{value:`pink`,label:`Pink`}],r=q(t,`disabled`,3,!1),i=M(`yellow`),a=M(!1),o=M(null);L(()=>{t.onOpenChange?.(z(a))}),L(()=>{if(z(a))return J2(()=>z(o),[`mousedown`],()=>{N(a,!1)},{capture:!1})});function s(e){e.preventDefault(),t.onHighlight(z(i))}function c(e){e.preventDefault(),N(a,!z(a))}function l(e){N(i,e,!0),N(a,!1)}var u=J6(),d=P(u);e4(d,{label:`Highlight`,testId:`toolbar-highlight-btn`,get disabled(){return r()},disabledTitle:`Select text first`,onMouseDown:s});var f=I(d,2),p=P(f);D(f);var m=I(f,2),h=e=>{var t=q6(),r=P(t);pi(r,17,()=>n,({value:e,label:t})=>e,(e,t)=>{let n=()=>z(t).value,r=()=>z(t).label;var a=K6();let o;var s=P(a);O(2),D(a),R(()=>{K(a,`data-testid`,`toolbar-highlight-color-${n()}`),K(a,`title`,r()),K(a,`aria-label`,r()),o=Ui(a,1,`highlight-picker-swatch svelte-1d240y8`,null,o,{"is-selected":n()===z(i)}),G(s,`background: ${ka[n()]??``};`)}),B(`click`,a,()=>l(n())),H(e,a)});var s=I(r,2);D(t),fa(t,e=>N(o,e),()=>z(o)),B(`click`,s,()=>N(a,!1)),H(e,t)};W(m,e=>{z(a)&&e(h)}),D(u),R(()=>{f.disabled=r(),G(p,`background: ${ka[z(i)]??``};`)}),B(`mousedown`,f,c),H(e,u),A()}Br([`mousedown`,`click`]);var X6=V(`<div class="fmtbar-divider svelte-1lcxsnm"></div> <!>`,1),Z6=V(`<div class="fmtbar-divider svelte-1lcxsnm"></div> <button type="button" class="fmtbar-hide svelte-1lcxsnm" data-testid="formatbar-hide-btn" title="Hide formatting bar" aria-label="Hide formatting bar"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="svelte-1lcxsnm"><path d="m18 15-6-6-6 6"></path></svg></button>`,1),Q6=V(`<div class="tandem-fmtbar-wrap"><div data-testid="formatting-bar" class="tandem-floating-pill" style="display: inline-flex; align-items: center; padding: var(--tandem-space-1); user-select: none; pointer-events: auto; -webkit-app-region: no-drag; max-width: calc(100% - var(--tandem-space-6));"><div style="display: flex; align-items: center; gap: 1px; overflow: hidden; min-width: 0;"><!> <div class="fmtbar-divider svelte-1lcxsnm"></div> <!></div> <!> <!></div></div>`);function $6(e,t){k(t,!0);let n=q(t,`showAuthorship`,3,!0),r=q(t,`showComments`,3,!0),i=q(t,`showHighlights`,3,!0),a=q(t,`showNotes`,3,!0),o=q(t,`decorationsMuted`,3,!1),s=M(0);L(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>{e.isDestroyed||sn(s)};return e.on(`selectionUpdate`,n),e.on(`transaction`,n),()=>{e.off(`selectionUpdate`,n),e.off(`transaction`,n)}});let c=j(()=>(z(s),!t.editor||t.editor.isDestroyed||!t.ydoc?!1:!t.editor.state.selection.empty)),l=M(!1);function u(e){if(!t.editor||!t.ydoc||t.editor.isDestroyed)return;let{state:n}=t.editor,{from:r,to:i}=n.selection;if(r===i)return;let a=eD(n.doc,Co(r)),o=eD(n.doc,Co(i));if(a===null||o===null){console.warn(`[FormattingBar] pmPosToFlatOffset returned null — CRDT position may be degraded`,{from:r,to:i});return}h4(t.ydoc,{from:a,to:o},e)}var d=Q6(),f=P(d),p=P(f),m=P(p);m4(m,{get editor(){return t.editor}});var h=I(m,4);{let e=j(()=>!z(c));Y6(h,{get disabled(){return z(e)},onHighlight:u,onOpenChange:e=>N(l,e,!0)})}D(p);var g=I(p,2),_=e=>{var s=X6();q2(I(F(s),2),{get showAuthorship(){return n()},get showComments(){return r()},get showHighlights(){return i()},get showNotes(){return a()},get decorationsMuted(){return o()},get onUpdate(){return t.onUpdateDecorations},get onOpenSettings(){return t.onOpenSettings}}),H(e,s)};W(g,e=>{t.onUpdateDecorations&&e(_)});var v=I(g,2),y=e=>{var n=Z6();B(`click`,I(F(n),2),function(...e){t.onHide?.apply(this,e)}),H(e,n)};W(v,e=>{t.onHide&&e(y)}),D(f),D(d),R(()=>G(d,`position: fixed; top: var(--tandem-fmtbar-top, 52px); left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; z-index: ${z(l)?`var(--tandem-z-toast)`:`var(--tandem-z-sticky)`};`)),H(e,d),A()}Br([`click`]);var e8=V(`<div data-testid="mode-toggle" data-tauri-drag-region="false" class="mode-toggle svelte-14q5edy" role="group" aria-label="AI collaboration mode"><span aria-hidden="true"></span> <button data-testid="mode-solo-btn" title="Write undisturbed — your AI only responds when you message">Solo</button> <button data-testid="mode-tandem-btn" title="Full collaboration — your AI reacts to selections and document changes">Tandem</button></div>`);function t8(e,t){k(t,!0);var n=e8(),r=P(n);let i;var a=I(r,2),o=I(a,2);D(n),R(()=>{i=Ui(r,1,`thumb svelte-14q5edy`,null,i,{tandem:t.tandemMode===`tandem`}),Ui(a,1,Li(t.tandemMode===`solo`?`on`:``),`svelte-14q5edy`),K(a,`aria-pressed`,t.tandemMode===`solo`),Ui(o,1,Li(t.tandemMode===`tandem`?`on`:``),`svelte-14q5edy`),K(o,`aria-pressed`,t.tandemMode===`tandem`)}),B(`click`,a,()=>t.onModeChange(`solo`)),B(`click`,o,()=>t.onModeChange(`tandem`)),H(e,n),A()}Br([`click`]);var n8=[{value:`system`,label:`Match system`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`warm`,label:`Warm`}],r8=V(`<span class="titlebar-settings-dot svelte-12l7ydf" data-testid="titlebar-update-available-dot" aria-hidden="true"></span>`),i8=V(`<button type="button" role="menuitemradio"><span class="brand-theme-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="brand-theme-label svelte-12l7ydf"> </span></button>`),a8=V(`<div class="brand-menu-divider svelte-12l7ydf" role="separator"></div>`),o8=V(`<div class="brand-menu-heading svelte-12l7ydf">Color scheme</div> <div class="brand-theme-grid svelte-12l7ydf" role="group" aria-label="Color scheme"></div> <!>`,1),s8=V(`<button type="button" class="brand-menu-item svelte-12l7ydf" data-testid="brand-menu-settings" role="menuitem"><span>Settings…</span> <kbd class="brand-menu-kbd svelte-12l7ydf">Ctrl+,</kbd></button>`),c8=V(`<button type="button" class="brand-menu-item svelte-12l7ydf" data-testid="brand-menu-shortcuts" role="menuitem"><span>Keyboard Shortcuts</span> <kbd class="brand-menu-kbd svelte-12l7ydf">?</kbd></button>`),l8=V(`<div class="brand-menu tandem-floating-pill svelte-12l7ydf" data-testid="titlebar-brand-menu-popover" data-tauri-drag-region="false" role="menu" tabindex="-1" aria-label="Tandem menu"><!> <!> <!></div>`),u8=V(`<div class="title-bar-center svelte-12l7ydf" data-tauri-drag-region="false"><!></div>`),d8=V(`<button type="button" data-testid="titlebar-source-toggle" data-tauri-drag-region="false"><span aria-hidden="true"></></span></button>`),f8=V(`<span class="status-dot svelte-12l7ydf" data-tauri-drag-region="false" title="AI assistant is connected" aria-label="AI assistant is connected"></span>`),p8=V(`<button type="button" class="model-chip ai-chip ai-chip-connect svelte-12l7ydf" data-testid="titlebar-connect-ai" data-ai-chip="connect" aria-label="AI isn't set up. Connect Claude Code." title="AI isn't set up — click to connect Claude Code"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf">Connect AI</span></button>`),m8=V(`<button type="button" class="model-chip ai-chip ai-chip-restart svelte-12l7ydf" data-testid="titlebar-connect-ai" data-ai-chip="restart" aria-label="Claude Code has stopped. Restart it." title="Claude Code stopped — click to restart"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf">Restart Claude Code</span></button>`),h8=V(`<button type="button" class="model-chip svelte-12l7ydf" data-testid="titlebar-default-model"><span class="model-chip-dot svelte-12l7ydf" aria-hidden="true"></span> <span class="model-chip-label svelte-12l7ydf"> </span></button>`),g8=Jr(`<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M3 0H10V7H7V10H0V3H3V0ZM3 3H1V9H6V7H3V3ZM4 1V6H9V1H4Z" fill="currentColor"></path></svg>`),_8=Jr(`<svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M0 0H10V10H0V0ZM1 2V9H9V2H1Z" fill="currentColor"></path></svg>`),v8=V(`<div class="title-bar-spacer-sm svelte-12l7ydf" data-tauri-drag-region=""></div> <div class="title-bar-controls svelte-12l7ydf" data-tauri-drag-region="false"><button type="button" class="title-bar-btn svelte-12l7ydf" aria-label="Minimize"><svg width="10" height="1" viewBox="0 0 10 1" aria-hidden="true" focusable="false"><rect width="10" height="1" fill="currentColor"></rect></svg></button> <button type="button" class="title-bar-btn svelte-12l7ydf"><!></button> <button type="button" class="title-bar-btn title-bar-close svelte-12l7ydf" aria-label="Close"><svg width="10" height="10" viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M1 0L0 1L4 5L0 9L1 10L5 6L9 10L10 9L6 5L10 1L9 0L5 4L1 0Z" fill="currentColor"></path></svg></button></div>`,1),y8=V(`<div class="title-bar svelte-12l7ydf" data-testid="title-bar" data-tauri-drag-region=""><div class="title-bar-left svelte-12l7ydf"><button type="button" class="brand-btn svelte-12l7ydf" data-testid="titlebar-brand-menu" data-tauri-drag-region="false" aria-label="Tandem menu" aria-haspopup="menu"><img class="brand-mark svelte-12l7ydf" src="/logo.png" alt="" width="32" height="32"/> <!></button> <!></div> <div class="title-bar-spacer title-bar-spacer-fixed svelte-12l7ydf" data-tauri-drag-region=""></div> <!> <div class="title-bar-spacer svelte-12l7ydf" data-tauri-drag-region=""></div> <div class="title-bar-actions svelte-12l7ydf"><!> <!> <!> <!></div> <!></div>`);function b8(e,t){k(t,!0);let n=q(t,`claudeActive`,3,!1),r=q(t,`theme`,3,`system`),i=q(t,`settingsBtn`,15,null),a=q(t,`updateAvailable`,3,!1),o=q(t,`defaultModelLabel`,3,null),s=q(t,`aiChip`,3,null),c=q(t,`sourceViewActive`,3,!1),l=q(t,`onToggleSourceView`,3,null),u=M(null),d=M(!1),f=[],p=!0;_a(async()=>{if(Lm())try{let[{invoke:e},{getCurrentWindow:t}]=await Promise.all([Ul(()=>import(`./core-SwWLTXZB.js`),[]),Ul(()=>import(`./window-CR0qpD8C.js`),__vite__mapDeps([9,1,3]))]);if(!p||(await e(`setup_overlay_titlebar`).catch(e=>{console.error(`[TitleBar] setup_overlay_titlebar failed:`,e)}),!p))return;let n=t();if(N(u,n,!0),N(d,await n.isMaximized(),!0),!p)return;let r=await n.onResized(async()=>{try{N(d,await n.isMaximized(),!0)}catch(e){console.warn(`[TitleBar] isMaximized check failed on resize:`,e)}});if(!p){r();return}f.push(r);let i=await n.onMoved(async()=>{try{N(d,await n.isMaximized(),!0)}catch(e){console.warn(`[TitleBar] isMaximized check failed on move:`,e)}});if(!p){i();return}f.push(i)}catch(e){console.error(`[TitleBar] Window API initialization failed:`,e)}}),va(()=>{p=!1,f.forEach(e=>e())});async function m(){try{await z(u)?.minimize()}catch(e){console.error(`[TitleBar] minimize failed:`,e)}}async function h(){try{await z(u)?.toggleMaximize()}catch(e){console.error(`[TitleBar] toggleMaximize failed:`,e)}}async function g(){try{await z(u)?.close()}catch(e){console.error(`[TitleBar] close failed:`,e)}}let _=M(!1),v=M(null);L(()=>{if(z(_))return J2(()=>z(v)??i(),[`mousedown`],()=>{N(_,!1)})});function y(){N(_,!z(_))}function b(){N(_,!1),i()?.focus()}function x(e){e.key===`Escape`&&(e.stopPropagation(),b())}function S(e){t.onSetTheme?.(e),b()}function C(){t.onOpenSettings?.(),N(_,!1)}function w(){t.onOpenHelp?.(),N(_,!1)}var ee=y8(),T=P(ee),te=P(T),ne=I(P(te),2),E=e=>{H(e,r8())},re=j(()=>Lm()&&a());W(ne,e=>{z(re)&&e(E)}),D(te),fa(te,e=>i(e),()=>i());var ie=I(te,2),ae=e=>{var n=l8(),i=P(n),a=e=>{var n=o8(),i=I(F(n),2);pi(i,21,()=>n8,e=>e.value,(e,t)=>{var n=i8();let i;var a=I(P(n),2),o=P(a,!0);D(a),D(n),R(()=>{i=Ui(n,1,`brand-theme-sw svelte-12l7ydf`,null,i,{on:r()===z(t).value}),K(n,`data-testid`,`brand-menu-theme-${z(t).value??``}`),K(n,`data-theme-swatch`,z(t).value),K(n,`aria-checked`,r()===z(t).value),U(o,z(t).label)}),B(`click`,n,()=>S(z(t).value)),H(e,n)}),D(i);var a=I(i,2),o=e=>{H(e,a8())};W(a,e=>{(t.onOpenSettings||t.onOpenHelp)&&e(o)}),H(e,n)};W(i,e=>{t.onSetTheme&&e(a)});var o=I(i,2),s=e=>{var t=s8();B(`click`,t,C),H(e,t)};W(o,e=>{t.onOpenSettings&&e(s)});var c=I(o,2),l=e=>{var t=c8();B(`click`,t,w),H(e,t)};W(c,e=>{t.onOpenHelp&&e(l)}),D(n),fa(n,e=>N(v,e),()=>z(v)),B(`keydown`,n,x),H(e,n)};W(ie,e=>{z(_)&&e(ae)}),D(T);var oe=I(T,4),se=e=>{var n=u8();bi(P(n),()=>t.center),D(n),H(e,n)};W(oe,e=>{t.center&&e(se)});var ce=I(oe,4),le=P(ce),ue=e=>{var t=d8();let n;R(()=>{n=Ui(t,1,`source-toggle-btn svelte-12l7ydf`,null,n,{on:c()}),K(t,`aria-label`,c()?`Switch to formatted editor`:`View markdown source`),K(t,`aria-pressed`,c()),K(t,`title`,c()?`Switch to formatted editor`:`View markdown source`)}),B(`click`,t,function(...e){l()?.apply(this,e)}),H(e,t)};W(le,e=>{l()&&e(ue)});var de=I(le,2),fe=e=>{t8(e,{get tandemMode(){return t.tandemMode},get onModeChange(){return t.onModeChange}})};W(de,e=>{t.tandemMode&&t.onModeChange&&e(fe)});var pe=I(de,2),me=e=>{H(e,f8())};W(pe,e=>{n()&&e(me)});var he=I(pe,2),ge=e=>{var n=p8();B(`click`,n,function(...e){t.onConnectAi?.apply(this,e)}),H(e,n)},_e=e=>{var n=m8();B(`click`,n,function(...e){t.onRestartClaude?.apply(this,e)}),H(e,n)},ve=e=>{var n=h8(),r=I(P(n),2),i=P(r,!0);D(r),D(n),R(()=>{K(n,`aria-label`,`Default model: ${o()}. Open Settings → Models.`),K(n,`title`,`Default model: ${o()}`),U(i,o())}),B(`click`,n,function(...e){t.onOpenModelsSettings?.apply(this,e)}),H(e,n)};W(he,e=>{s()===`connect`?e(ge):s()===`restart`?e(_e,1):o()&&t.onOpenModelsSettings&&e(ve,2)}),D(ce);var ye=I(ce,2),be=e=>{var t=v8(),n=I(F(t),2),r=P(n),i=I(r,2),a=P(i),o=e=>{H(e,g8())},s=e=>{H(e,_8())};W(a,e=>{z(d)?e(o):e(s,-1)}),D(i);var c=I(i,2);D(n),R(()=>{r.disabled=z(u)===null,K(i,`aria-label`,z(d)?`Restore`:`Maximize`),i.disabled=z(u)===null,c.disabled=z(u)===null}),B(`click`,r,m),B(`click`,i,h),B(`click`,c,g),H(e,t)},xe=j(()=>Lm());W(ye,e=>{z(xe)&&e(be)}),D(ee),R(()=>K(te,`aria-expanded`,z(_))),B(`click`,te,y),H(e,ee),A()}Br([`click`,`keydown`]);var x8=`tandem-status-count-mode`,S8=[`words`,`characters`,`sentences`,`paragraphs`,`pages`],C8={words:`words`,characters:`chars`,sentences:`sentences`,paragraphs:`paragraphs`,pages:`pages`},w8=250;function T8(e){let t=e.trim();return t?t.split(/\s+/).length:0}function E8(e){return S8[(S8.indexOf(e)+1)%S8.length]??`words`}function D8(e){return C8[e]}function O8(){try{let e=localStorage.getItem(x8);if(e&&S8.includes(e))return e}catch{}return`words`}function k8(e){try{localStorage.setItem(x8,e)}catch{}}function A8(e,t){if(!e||e.isDestroyed)return 0;let n=e.state.doc.textContent;switch(t){case`characters`:return n.length;case`words`:return T8(n);case`sentences`:return n.match(/[^.!?]+[.!?]+(?:\s|$)/g)?.length??+!!n.trim();case`paragraphs`:{let t=0;return e.state.doc.forEach(e=>{e.type.name===`paragraph`&&e.textContent.trim()&&t++}),t}case`pages`:return Math.ceil(T8(n)/w8)}}var j8=V(`<button type="button" data-testid="status-word-count" style="background: none; border: none; padding: 0; margin: 0; cursor: pointer; color: var(--tandem-fg-subtle); font: inherit; font-family: var(--tandem-font-mono);" class="svelte-1esxubl"> </button>`),M8=V(`<span data-testid="save-indicator" style="color: var(--tandem-accent);" class="svelte-1esxubl">Saving...</span>`),N8=V(`<span style="padding: 1px 8px; font-size: var(--tandem-text-2xs); font-weight: 600; color: var(--tandem-warning-fg-strong); background: var(--tandem-warning-bg); border-radius: var(--tandem-r-pill); border: 1px solid var(--tandem-warning-border);" class="svelte-1esxubl">Review Only</span>`),P8=V(`<span data-testid="claude-working-indicator" class="claude-working-pill svelte-1esxubl" role="status" aria-live="polite"><span class="claude-working-dot svelte-1esxubl"></span> <span class="claude-working-dot svelte-1esxubl"></span> <span class="claude-working-dot svelte-1esxubl"></span> <span style="margin-left: 4px;" class="svelte-1esxubl"> </span></span>`),F8=V(`<div class="tandem-floating-pill tandem-status-pill svelte-1esxubl" style="position: fixed; bottom: var(--tandem-space-3, 12px); left: var(--tandem-space-5, 22px); max-width: calc(100% - var(--tandem-space-7, 44px)); display: inline-flex; align-items: center; padding: 6px var(--tandem-space-3); font-family: var(--tandem-font-mono); font-size: var(--tandem-text-xs); color: var(--tandem-fg-muted); user-select: none; gap: var(--tandem-space-3); z-index: var(--tandem-z-sticky); overflow: hidden;"><div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-1esxubl"><span class="status-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </span> <!> <!></div> <!> <div style="display: flex; align-items: center; gap: var(--tandem-space-2);" class="svelte-1esxubl"><span class="claude-dot svelte-1esxubl"></span> <span class="svelte-1esxubl"> </span> <!></div></div>`);function I8(e,t){k(t,!0);let n=q(t,`claudeWorkingTool`,3,null),r=q(t,`saving`,3,!1);function i(e){return{tandem_edit:`editing`,tandem_comment:`commenting`,tandem_reply:`replying`,tandem_annotationReply:`replying`}[e]??e.replace(/^tandem_/,``)}let a=qE(J_()),o=M(!1),s=M(0),c=Ar(()=>t.connected);L(()=>{let e=c;if(c=t.connected,t.connected&&!e){N(o,!0);let e=setTimeout(()=>{N(o,!1)},2e3);return()=>clearTimeout(e)}}),L(()=>{if(t.disconnectedSince==null){N(s,0);return}N(s,Math.floor((Date.now()-t.disconnectedSince)/1e3),!0);let e=setInterval(()=>{N(s,Math.floor((Date.now()-(t.disconnectedSince??0))/1e3),!0)},1e3);return()=>clearInterval(e)});let l=j(()=>t.connectionStatus===`connecting`),u=j(()=>t.connected?`var(--tandem-success)`:z(l)?`var(--tandem-warning)`:`var(--tandem-error)`),d=j(()=>z(o)?`Reconnected`:t.connectionStatus===`connected`?`Synced`:t.connectionStatus===`connecting`?(()=>{let e=[`Reconnecting…`];if(t.reconnectAttempts>0||z(s)>0){let n=[];t.reconnectAttempts>0&&n.push(`attempt ${t.reconnectAttempts}`),z(s)>0&&n.push(`${z(s)}s`),e.push(`(${n.join(`, `)})`)}return e.join(` `)})():`Disconnected — check that the server is running`),f=j(()=>z(o)?`var(--tandem-success-fg-strong)`:t.connectionStatus===`connected`?`var(--tandem-fg-muted)`:t.connectionStatus===`connecting`?`var(--tandem-warning-fg-strong)`:`var(--tandem-error-fg-strong)`),p=M(un(O8())),m=M(0);L(()=>{let e=t.editor;if(!e||e.isDestroyed)return;let n=()=>{e.isDestroyed||sn(m)};return e.on(`update`,n),e.on(`transaction`,n),()=>{e.off(`update`,n),e.off(`transaction`,n)}});let h=j(()=>(z(m),A8(t.editor??null,z(p))));function g(){let e=E8(z(p));N(p,e,!0),k8(e)}var _=F8(),v=P(_),y=P(v),b=I(y,2),x=P(b,!0);D(b);var S=I(b,2),C=e=>{var t=j8(),n=P(t);D(t),R((e,r,i,a)=>{K(t,`title`,e),K(t,`aria-label`,r),U(n,`${i??``} ${a??``}`)},[()=>`Click to cycle: ${D8(E8(z(p)))}`,()=>`${z(h)} ${D8(z(p))} (click to change unit)`,()=>z(h).toLocaleString(),()=>D8(z(p))]),B(`click`,t,g),H(e,t)};W(S,e=>{t.editor&&e(C)});var w=I(S,2),ee=e=>{H(e,M8())};W(w,e=>{r()&&e(ee)}),D(v);var T=I(v,2),te=e=>{H(e,N8())};W(T,e=>{t.readOnly&&e(te)});var ne=I(T,2),E=P(ne),re=I(E,2),ie=P(re,!0);D(re);var ae=I(re,2),oe=e=>{var t=P8(),r=I(P(t),6),o=P(r);D(r),D(t),R(e=>U(o,`${a.specific??``} is ${e??``}…`),[()=>i(n())]),H(e,t)};W(ae,e=>{n()&&e(oe)}),D(ne),D(_),R(()=>{G(y,`width: 7px; height: 7px; border-radius: 50%; background: ${z(u)??``}; display: inline-block; animation: ${t.connected&&z(o)?`tandem-conn-bloom 500ms var(--tandem-ease-out)`:z(l)?`tandem-conn-pulse 900ms ease-in-out infinite`:`none`};`),G(b,`color: ${z(f)??``}; transition: color 0.3s ease;`),U(x,z(d)),G(E,`width: 7px; height: 7px; border-radius: 50%; background: var(--tandem-author-claude); opacity: ${t.claudeActive?1:.4}; display: inline-block; transition: opacity 0.3s ease; animation: ${t.claudeActive?`tandem-status-pulse 1.5s ease-in-out infinite`:`none`};`),G(re,`transition: color 0.3s ease; color: ${t.claudeActive?`var(--tandem-fg)`:`var(--tandem-fg-subtle)`};`),U(ie,t.claudeStatus?`${a.specific} · ${t.claudeStatus}`:`${a.specific} · idle`)}),H(e,_),A()}Br([`click`]);function L8(e){let t=e-1;return t*t*t+1}function R8(e,{from:t,to:n},r={}){var{delay:i=0,duration:a=e=>Math.sqrt(e)*120,easing:o=L8}=r,s=getComputedStyle(e),c=s.transform===`none`?``:s.transform,[l,u]=s.transformOrigin.split(` `).map(parseFloat);l/=e.clientWidth,u/=e.clientHeight;var d=z8(e),f=e.clientWidth/n.width/d,p=e.clientHeight/n.height/d,m=t.left+t.width*l,h=t.top+t.height*u,g=n.left+n.width*l,_=n.top+n.height*u,v=(m-g)*f,y=(h-_)*p,b=t.width/n.width,x=t.height/n.height;return{delay:i,duration:typeof a==`function`?a(Math.sqrt(v*v+y*y)):a,easing:o,css:(e,t)=>`transform: ${c} translate(${t*v}px, ${t*y}px) scale(${e+t*b}, ${e+t*x});`}}function z8(e){if(`currentCSSZoom`in e)return e.currentCSSZoom;for(var t=e,n=1;t!==null;)n*=+getComputedStyle(t).zoom,t=t.parentElement;return n}function B8(e){return e.source===`file`&&!e.readOnly}var V8={md:`md`,markdown:`md`,docx:`docx`,doc:`docx`,txt:`txt`,text:`txt`,html:`html`,htm:`html`};function H8(e){let t=e.lastIndexOf(`.`);return t<=0||t===e.length-1?`other`:V8[e.slice(t+1).toLowerCase()]??`other`}function U8(e){let t=e.split(/[/\\]/);return{name:t.at(-1)??e,dir:t.slice(0,-1).join(`/`)}}function W8(e,t=Date.now()){let{dir:n,name:r}=U8(e.path);return{path:e.path,name:r,dir:n,when:Xl(e.openedAt,t),pip:H8(r)}}function G8(e,t){let n=t.trim().toLowerCase();return n?e.name.toLowerCase().includes(n)||e.dir.toLowerCase().includes(n):!0}function K8(e,t){let n=t.trim();if(!n)return[{text:e,match:!1}];let r=e.toLowerCase(),i=n.toLowerCase(),a=[],o=0;for(;o<e.length;){let t=r.indexOf(i,o);if(t===-1){a.push({text:e.slice(o),match:!1});break}t>o&&a.push({text:e.slice(o,t),match:!1}),a.push({text:e.slice(t,t+i.length),match:!0}),o=t+i.length}return a}var q8=Jr(`<path></path>`),J8=Jr(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"></svg>`),Y8=V(`<button class="ntl-search-clr svelte-7c4il0" type="button" aria-label="Clear search"><svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M6 18L18 6"></path></svg></button>`),X8=V(`<span class="ntl-count svelte-7c4il0" aria-hidden="true"> </span>`),Z8=V(`<div class="ntl-empty svelte-7c4il0" data-testid="new-tab-empty"><div class="ntl-empty-ic svelte-7c4il0"><!></div> No recent files yet. <div class="ntl-sub svelte-7c4il0">Open something and it'll appear here.</div></div>`),Q8=V(`<div class="ntl-no-match svelte-7c4il0" data-testid="new-tab-no-match"> <div class="ntl-sub svelte-7c4il0">Try a different name, or create a scratchpad.</div></div>`),$8=V(`<mark class="svelte-7c4il0"> </mark>`),e5=V(`<span class="ntl-path svelte-7c4il0"> </span>`),t5=V(`<span class="ntl-when svelte-7c4il0"> </span>`),n5=V(`<button type="button" data-nav-item="" class="ntl-recent svelte-7c4il0"><span></span> <span class="ntl-body svelte-7c4il0"><span class="ntl-name svelte-7c4il0"></span> <!></span> <!></button>`),r5=V(`<div class="ntl-recents svelte-7c4il0"></div>`),i5=V(`<button type="button" data-nav-item="" class="ntl-action svelte-7c4il0" data-testid="new-tab-reopen-closed"><span class="ntl-glyph svelte-7c4il0"><!></span> <span class="ntl-lbl svelte-7c4il0">Reopen last closed</span> <span class="ntl-kbd svelte-7c4il0" aria-hidden="true">Ctrl+Alt+T</span></button>`),a5=V(`<div role="dialog" aria-label="New tab" tabindex="-1" class="new-tab-menu svelte-7c4il0"><div class="ntl-search svelte-7c4il0"><span class="ntl-search-ic svelte-7c4il0"><!></span> <input type="text" placeholder="Search recent files…" aria-label="Search recent files" data-testid="new-tab-search" class="svelte-7c4il0"/> <!> <!> <span class="ntl-esc svelte-7c4il0" aria-hidden="true">Esc</span></div> <div class="ntl-cols svelte-7c4il0"><div class="ntl-col ntl-left svelte-7c4il0"><!></div> <div class="ntl-col ntl-right svelte-7c4il0"><div class="ntl-colhead svelte-7c4il0"><span class="ntl-colhead-label svelte-7c4il0">Create</span></div> <button type="button" data-nav-item="" class="ntl-action ntl-action-primary svelte-7c4il0" data-testid="palette-item-new-scratchpad"><span class="ntl-glyph svelte-7c4il0"><!></span> <span class="ntl-lbl svelte-7c4il0">New scratchpad</span> <span class="ntl-kbd svelte-7c4il0" aria-hidden="true">Ctrl+N</span></button> <div class="ntl-colhead svelte-7c4il0"><span class="ntl-colhead-label svelte-7c4il0">Open</span></div> <button type="button" data-nav-item="" class="ntl-action svelte-7c4il0" data-testid="new-tab-browse"><span class="ntl-glyph svelte-7c4il0"><!></span> <span class="ntl-lbl svelte-7c4il0">Browse files…</span> <span class="ntl-kbd svelte-7c4il0" aria-hidden="true">Ctrl+O</span></button> <!></div></div> <div class="ntl-footer svelte-7c4il0"><span class="ntl-kgrp svelte-7c4il0"><span class="ntl-key svelte-7c4il0" aria-hidden="true">↑</span><span class="ntl-key svelte-7c4il0" aria-hidden="true">↓</span>navigate</span> <span class="ntl-kgrp svelte-7c4il0"><span class="ntl-key svelte-7c4il0" aria-hidden="true">↵</span>open</span> <span class="ntl-spacer svelte-7c4il0"></span> <span class="ntl-kgrp svelte-7c4il0">type to filter</span></div></div>`);function o5(e,t){k(t,!0);let n=(e,t=m,n=m,r=m)=>{var i=J8();pi(i,21,()=>u[t()]??[],li,(e,t)=>{var n=q8();R(()=>K(n,`d`,z(t))),H(e,n)}),D(i),R(()=>{K(i,`width`,n()),K(i,`height`,n()),K(i,`stroke-width`,r())}),H(e,i)},r=M(``),i=M(null),a=M(null),o=j(()=>t.recentFiles.map(e=>W8(e))),s=j(()=>z(o).filter(e=>G8(e,z(r)))),c=j(()=>z(o).length>0),l=j(()=>z(r).trim().length>0),u={plus:[`M12 5v14`,`M5 12h14`],folder:[`M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`,`M14 3v6h6`],undo:[`M3 7v6h6`,`M3 13a9 9 0 1 0 3-7`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14z`,`m20 20-3.5-3.5`],inbox:[`M3 7l9 6 9-6`,`M3 7v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-9-4-9 4z`]};function d(){return Array.from(z(i)?.querySelectorAll(`[data-nav-item]`)??[])}function f(e){let t=d();if(t.length===0)return;let n=t.indexOf(document.activeElement);if(n===-1){(e>0?t[0]:t[t.length-1])?.focus();return}t[(n+e+t.length)%t.length]?.focus()}function p(e){e.key===`Escape`?(e.preventDefault(),t.onClose()):e.key===`ArrowDown`?(e.preventDefault(),f(1)):e.key===`ArrowUp`&&(e.preventDefault(),f(-1))}L(()=>{z(i)&&z(a)?.focus({preventScroll:!0})});var h=a5(),g=P(h),_=P(g);n(P(_),()=>`search`,()=>13,()=>1.7),D(_);var v=I(_,2);$i(v),fa(v,e=>N(a,e),()=>z(a));var y=I(v,2),b=e=>{var t=Y8();B(`click`,t,()=>N(r,``)),H(e,t)};W(y,e=>{z(l)&&e(b)});var x=I(y,2),S=e=>{var t=X8(),n=P(t);D(t),R(()=>U(n,`${z(s).length??``} of ${z(o).length??``}`)),H(e,t)};W(x,e=>{z(c)&&e(S)}),O(2),D(g);var C=I(g,2),w=P(C),ee=P(w),T=e=>{var t=Z8(),r=P(t);n(P(r),()=>`inbox`,()=>16,()=>1.6),D(r),O(2),D(t),H(e,t)},te=e=>{var t=Q8(),n=P(t);O(),D(t),R(e=>U(n,`No matches for “${e??``}”. `),[()=>z(r).trim()]),H(e,t)},ne=e=>{var n=r5();pi(n,23,()=>z(s),e=>e.path,(e,n,i)=>{var a=n5(),o=P(a),s=I(o,2),c=P(s);pi(c,21,()=>K8(z(n).name,z(r)),li,(e,t)=>{var n=Xr(),r=F(n),i=e=>{var n=$8(),r=P(n,!0);D(n),R(()=>U(r,z(t).text)),H(e,n)},a=e=>{var n=Yr();R(()=>U(n,z(t).text)),H(e,n)};W(r,e=>{z(t).match?e(i):e(a,-1)}),H(e,n)}),D(c);var l=I(c,2),u=e=>{var t=e5(),r=P(t,!0);D(t),R(()=>U(r,z(n).dir)),H(e,t)};W(l,e=>{z(n).dir&&e(u)}),D(s);var d=I(s,2),f=e=>{var t=t5(),r=P(t,!0);D(t),R(()=>U(r,z(n).when)),H(e,t)};W(d,e=>{z(n).when&&e(f)}),D(a),R(()=>{K(a,`data-testid`,`new-tab-recent-${z(i)}`),K(a,`title`,z(n).path),Ui(o,1,`ntl-pip ntl-pip-${z(n).pip??``}`,`svelte-7c4il0`)}),B(`click`,a,()=>t.onOpen(z(n).path)),H(e,a)}),D(n),H(e,n)};W(ee,e=>{z(c)?z(s).length===0?e(te,1):e(ne,-1):e(T)}),D(w);var E=I(w,2),re=I(P(E),2),ie=P(re);n(P(ie),()=>`plus`,()=>14,()=>1.9),D(ie),O(4),D(re);var ae=I(re,4),oe=P(ae);n(P(oe),()=>`folder`,()=>13,()=>1.7),D(oe),O(4),D(ae);var se=I(ae,2),ce=e=>{var r=i5(),i=P(r);n(P(i),()=>`undo`,()=>13,()=>1.7),D(i),O(4),D(r),R(()=>K(r,`title`,t.closedTabTop.filePath)),B(`click`,r,function(...e){t.onReopenClosed?.apply(this,e)}),H(e,r)};W(se,e=>{t.closedTabTop&&e(ce)}),D(E),D(C),O(2),D(h),fa(h,e=>N(i,e),()=>z(i)),B(`keydown`,h,p),aa(v,()=>z(r),e=>N(r,e)),B(`click`,re,function(...e){t.onNewScratchpad?.apply(this,e)}),B(`click`,ae,function(...e){t.onBrowse?.apply(this,e)}),H(e,h),A()}Br([`keydown`,`click`]);var s5=V(`<input type="text" spellcheck="false" autocomplete="off" aria-label="Rename file" style="min-width: 80px; max-width: 160px; font-size: var(--tandem-text-sm); padding: 0 4px; height: 20px; border: 1px solid var(--tandem-accent); border-radius: var(--tandem-r-1); background: var(--tandem-bg); color: var(--tandem-fg); outline: none;"/>`);function c5(e,t){k(t,!0);let n=M(un(Ar(()=>t.initial))),r=!1;function i(e){if(r)return;r=!0;let i=z(n).trim();e&&i.length>0&&i!==t.initial?t.oncommit(i):t.oncancel()}function a(e){e.focus();let n=t.initial.lastIndexOf(`.`);e.setSelectionRange(0,n>0?n:t.initial.length)}function o(e){e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),i(!0)):e.key===`Escape`&&(e.preventDefault(),i(!1))}var s=s5();$i(s),zn(()=>aa(s,()=>z(n),e=>N(n,e))),Pi(s,e=>a?.(e)),R(()=>K(s,`data-testid`,t.testId)),B(`keydown`,s,o),zr(`blur`,s,()=>i(!1)),B(`pointerdown`,s,e=>e.stopPropagation()),B(`click`,s,e=>e.stopPropagation()),B(`dblclick`,s,e=>e.stopPropagation()),H(e,s),A()}Br([`keydown`,`pointerdown`,`click`,`dblclick`]);var l5=V(`<span class="dot svelte-1btt0ja" aria-hidden="true">●</span>`),u5=V(`<span class="saved-check svelte-1btt0ja" aria-hidden="true">✓</span>`),d5=V(`<span class="svelte-1btt0ja"> </span>`),f5=V(`<span class="tab-ro-badge svelte-1btt0ja" aria-label="Read-only">RO</span>`),p5=V(`<div role="tab" class="svelte-1btt0ja"><span class="save-indicator svelte-1btt0ja"><!></span> <!> <!> <button style="background: none; border: none; cursor: pointer; font-size: var(--tandem-text-md); line-height: 1; color: var(--tandem-fg-muted); padding: 0 2px; border-radius: var(--tandem-r-1);" title="Close document" class="svelte-1btt0ja">×</button></div>`);function m5(e,t){k(t,!0);let n=q(t,`reduceMotion`,3,!1),r=q(t,`isRenaming`,3,!1),i=j(()=>B8(t.tab)),a=M(!1),o=0,s=null;L(()=>{let{ydoc:e,readOnly:n}=t.tab;if(n){N(a,!1);return}let r=e.getXmlFragment(`default`),i=e.getMap(Wa),c=!1,l=setTimeout(()=>{c=!0,s=i.get(`savedAtVersion`)??0,o=0,N(a,!1)},500),u=()=>{c&&(o++,N(a,!0))};r.observeDeep(u);let d=()=>{if(!c)return;let e=i.get(Ka);e!==void 0&&e!==s&&(s=e,o=0,N(a,!1))};return i.observe(d),()=>{clearTimeout(l),r.unobserveDeep(u),i.unobserve(d)}});let c=M(!1),l=!1;L(()=>{let e=l;if(l=z(a),!z(a)&&e){N(c,!0);let e=setTimeout(()=>{N(c,!1)},600);return()=>clearTimeout(e)}N(c,!1)});let u=j(()=>[`display: flex`,`align-items: center`,`gap: 6px`,`padding: 0 10px 0 12px`,`height: 26px`,`font-size: var(--tandem-text-sm)`,`cursor: pointer`,`background: ${t.isActive?`var(--tandem-surface)`:`transparent`}`,`color: ${t.isActive?`var(--tandem-fg)`:`var(--tandem-fg-subtle)`}`,`border: 1px solid ${t.isActive?`var(--tandem-border)`:`transparent`}`,`border-left: ${t.dropIndicator===`left`?`2px solid var(--tandem-accent)`:t.isActive?`1px solid var(--tandem-border)`:`2px solid transparent`}`,`border-right: ${t.dropIndicator===`right`?`2px solid var(--tandem-accent)`:t.isActive?`1px solid var(--tandem-border)`:`2px solid transparent`}`,`border-radius: var(--tandem-r-pill)`,`box-shadow: ${t.isActive?`var(--tandem-shadow-1)`:`0 1px 3px rgba(0, 0, 0, 0.08)`}`,`user-select: none`,`touch-action: none`,`white-space: nowrap`,`transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s`,`flex-shrink: 0`].join(`; `)),d=M(void 0);function f(){z(d)&&(z(d).style.color=`var(--tandem-error)`)}function p(){z(d)&&(z(d).style.color=`var(--tandem-fg-muted)`)}var m=p5();K(m,`tabindex`,0);var h=P(m),g=P(h),_=e=>{H(e,l5())},v=e=>{H(e,u5())};W(g,e=>{z(a)?e(_):z(c)&&e(v,1)}),D(h);var y=I(h,2),b=e=>{{let n=j(()=>`tab-rename-input-${t.tab.id}`);c5(e,{get initial(){return t.tab.fileName},get testId(){return z(n)},oncommit:e=>t.onrename?.(t.tab.id,e),oncancel:()=>t.onrenamecancel?.()})}},x=e=>{var n=d5(),r=P(n,!0);D(n),R(()=>{K(n,`data-testid`,`tab-name-${t.tab.id}`),K(n,`title`,z(i)?`${t.tab.filePath} — double-click or F2 to rename`:t.tab.filePath),G(n,`font-weight: ${t.isActive?500:400}; min-width: 80px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;`),U(r,t.tab.fileName)}),B(`dblclick`,n,e=>{z(i)&&(e.stopPropagation(),t.onstartrename?.(t.tab.id))}),H(e,n)};W(y,e=>{r()?e(b):e(x,-1)});var S=I(y,2),C=e=>{H(e,f5())};W(S,e=>{t.tab.readOnly&&e(C)});var w=I(S,2);fa(w,e=>N(d,e),()=>z(d)),D(m),R(()=>{K(m,`data-testid`,`tab-${t.tab.id}`),K(m,`data-active`,t.isActive),K(m,`aria-selected`,t.isActive),K(m,`aria-label`,t.tab.fileName),G(m,z(u)),K(h,`data-testid`,`unsaved-indicator-${t.tab.id}`),K(h,`aria-hidden`,!z(a)),K(w,`aria-label`,`Close ${t.tab.fileName}`)}),B(`click`,m,()=>t.onswitch(t.tab.id)),B(`pointerdown`,m,e=>t.onpointerdown(e,t.tab.id)),B(`keydown`,m,e=>t.onkeydown(e,t.tab.id)),B(`click`,w,e=>{e.stopPropagation(),t.onclose(t.tab.id)}),B(`pointerdown`,w,e=>e.stopPropagation()),zr(`mouseenter`,w,f),zr(`mouseleave`,w,p),Mi(1,m,()=>hv,()=>({reduceMotion:n()})),Mi(2,m,()=>pv,()=>({reduceMotion:n()})),H(e,m),A()}Br([`click`,`pointerdown`,`keydown`,`dblclick`]);var h5=new Set([`ctx:tab:close`,`ctx:tab:closeOthers`,`ctx:tab:closeRight`,`ctx:tab:copyPath`,`ctx:tab:reveal`]);function g5(e){return typeof e==`string`&&h5.has(e)}function _5(e){return!bo(e)&&!yo(e)}function v5(e,t){let n=e.findIndex(e=>e.id===t),r=n>=0?e[n]:void 0;return{canCloseOthers:e.length>1,canCloseRight:n>=0&&n<e.length-1,hasPath:!!r&&_5(r.filePath)}}function y5(e,t){return e.some(e=>e.id===t)?e.filter(e=>e.id!==t).map(e=>e.id):[]}function b5(e,t){let n=e.findIndex(e=>e.id===t);return n<0?[]:e.slice(n+1).map(e=>e.id)}var x5=V(`<div class="tab-flip svelte-urrc8n" role="presentation"><!></div>`),S5=V(`<div style="position: relative; display: flex; align-items: center; background: transparent; min-height: 32px; z-index: var(--tandem-z-base); width: 100%; min-width: 0;"><div data-testid="tab-scroll-container" role="tablist" aria-label="Open documents" style="display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; padding: 6px 8px;"></div> <div class="nt-wrap svelte-urrc8n"><div><button data-testid="open-file-btn" class="tandem-floating-pill tab-add-pill svelte-urrc8n" title="Open file" aria-label="Open file" aria-haspopup="dialog">+</button> <div class="nt-grid svelte-urrc8n"><div class="nt-cell svelte-urrc8n"><!></div></div></div></div></div>`);function C5(e,t){k(t,!0);let n=q(t,`reduceMotion`,3,!1),r=q(t,`openMenuTrigger`,3,0),i=q(t,`renameTrigger`,3,0),a=q(t,`closedTabTop`,3,null),o=M(null);function s(e){N(o,e,!0)}function c(e,n){N(o,null),t.onTabRename?.(e,n)}function l(){N(o,null)}let u=j(()=>n()?`auto`:`smooth`),d=M(!1),f=M(un([])),p=M(null),m=M(!1),h=M(!1),g=M(null),_=new Set;L(()=>{let e=new Set(t.tabs.map(e=>e.id));for(let t of _)e.has(t)||_.delete(t)});function v(e){_.has(e)||(_.add(e),t.onTabClose(e))}let y=null,b=null;async function x(e){if(!Lm())return;let n=e.target?.closest(`[data-testid^="tab-"][role="tab"]`),r=me(n);if(!r)return;let i=t.tabs.find(e=>e.id===r);if(i){y=r,b=i.filePath,e.preventDefault();try{await(await Bm())(`show_tab_context_menu`,{req:v5(t.tabs,r)})}catch{}}}async function S(e){let n=y,r=b;if(n)switch(e){case`ctx:tab:close`:v(n);return;case`ctx:tab:closeOthers`:t.onCloseOthers?.(n);return;case`ctx:tab:closeRight`:t.onCloseToRight?.(n);return;case`ctx:tab:copyPath`:if(r&&_5(r))try{await navigator.clipboard.writeText(r)}catch{}return;case`ctx:tab:reveal`:if(r&&_5(r))try{await(await Bm())(`show_in_file_manager`,{path:r})}catch{}return}}let C=M(void 0),w=M(!1),ee=M(!1),T=M(null),te=M(null),ne=null,E=0,re=0,ie=!1,ae=null;function oe(e){he(e)}function se(e){ge(e)}function ce(e){ne!==null&&e.pointerId===ne&&ue()}function le(e){e.key===`Escape`&&ue()}function ue(){if(ae&&ne!==null)try{ae.releasePointerCapture(ne)}catch{}window.removeEventListener(`pointermove`,oe),window.removeEventListener(`pointerup`,se),window.removeEventListener(`pointercancel`,ce),window.removeEventListener(`keydown`,le),N(T,null),N(te,null),ne=null,ie=!1,ae=null}va(ue),L(()=>{if(!z(T)&&!z(te))return;let e=new Set(t.tabs.map(e=>e.id));z(T)&&!e.has(z(T))&&N(T,null),z(te)&&!e.has(z(te).id)&&N(te,null)});function de(){let e=z(C);e&&(N(w,e.scrollLeft>0),N(ee,e.scrollLeft+e.clientWidth<e.scrollWidth-1))}L(()=>{let e=z(C);if(!e)return;de(),e.addEventListener(`scroll`,de,{passive:!0});let t=new ResizeObserver(de);return t.observe(e),()=>{e.removeEventListener(`scroll`,de),t.disconnect()}}),L(()=>{let e=z(C);if(e)return e.addEventListener(`contextmenu`,x),()=>e.removeEventListener(`contextmenu`,x)}),L(()=>{if(!Lm())return;let e=Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`context-menu-action`,e=>{let t=e.payload?.id;g5(t)&&S(t)}));return e.catch(()=>{}),()=>{e.then(e=>e()).catch(()=>{})}}),L(()=>{t.tabs.length,de()}),L(()=>{if(!t.activeTabId||!z(C))return;let e=z(C).querySelector(`[data-testid="tab-${t.activeTabId}"]`);e&&e.scrollIntoView({inline:`nearest`,block:`nearest`,behavior:z(u)})});function fe(e,t){if(!(e.button!==0||z(ve))){ne=e.pointerId,E=e.clientX,re=e.clientY,ie=!1,N(T,t,!0),ae=e.currentTarget;try{ae.setPointerCapture(e.pointerId)}catch{}window.addEventListener(`pointermove`,oe),window.addEventListener(`pointerup`,se),window.addEventListener(`pointercancel`,ce),window.addEventListener(`keydown`,le)}}function pe(e,t){return document.elementFromPoint(e,t)?.closest(`[data-testid^="tab-"][role="tab"]`)??null}function me(e){return e?.getAttribute(`data-testid`)?.slice(4)??null}function he(e){if(ne===null||e.pointerId!==ne||!z(T))return;if(!ie){let t=e.clientX-E,n=e.clientY-re;if(Math.hypot(t,n)<5)return;ie=!0}e.preventDefault();let t=pe(e.clientX,e.clientY),n=me(t);if(!t||!n||n===z(T)){N(te,null);return}let r=t.getBoundingClientRect(),i=r.left+r.width/2;N(te,{id:n,side:e.clientX<i?`left`:`right`},!0)}function ge(e){if(ne===null||e.pointerId!==ne)return;let n=ie,r=z(te);if(n&&z(T)&&r&&r.id!==z(T)&&t.reorder&&t.tabs.some(e=>e.id===z(T))&&t.tabs.some(e=>e.id===r.id)&&t.reorder(z(T),r.id,r.side),n){let e,t=n=>{n.stopPropagation(),n.preventDefault(),window.removeEventListener(`click`,t,!0),clearTimeout(e)};window.addEventListener(`click`,t,!0),e=setTimeout(()=>window.removeEventListener(`click`,t,!0),0)}ue()}function _e(e,n){if(!e.altKey||!t.reorder||e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let r=t.tabs.findIndex(e=>e.id===n);r!==-1&&(e.key===`ArrowLeft`&&r>0?t.reorder(n,t.tabs[r-1].id):e.key===`ArrowRight`&&r<t.tabs.length-1&&t.reorder(t.tabs[r+1].id,n))}let ve=j(()=>t.tabs.length<=1);function ye(){let e=!z(d);if(e)N(f,nu(),!0),Ee=document.activeElement,N(m,xe(),!0);else{be();return}N(d,e)}function be(){let e=document.activeElement;e&&z(g)?.contains(e)&&e.blur(),N(d,!1)}function xe(){if(!z(p))return!1;let e=z(p).getBoundingClientRect(),t=window.innerWidth,n=Math.min(460,t-16);return e.right-n>=8?!1:e.left+n<=t-8?!0:t-e.left>e.right}let Se=null;function Ce(e){if(!z(g))return NaN;let t=getComputedStyle(z(g)).getPropertyValue(e).trim();return t.endsWith(`ms`)?parseFloat(t):t.endsWith(`s`)?parseFloat(t)*1e3:parseFloat(t)}function we(){if(!z(g))return 0;let e=Ce(`--morph-p1`)+Ce(`--morph-p2`);return Number.isFinite(e)&&e>0?e+40:0}L(()=>{if(z(d)){Se&&=(clearTimeout(Se),null),N(h,!0);return}if(!Ar(()=>z(h)))return;Se&&clearTimeout(Se);let e=we();if(e<=0){N(h,!1);return}Se=setTimeout(()=>{N(h,!1),Se=null},e)}),va(()=>{Se&&clearTimeout(Se)});let Te=!1,Ee=null;L(()=>{if(!z(d))return;function e(e){let t=e.target;t&&(z(p)?.contains(t)||t.closest?.(`.new-tab-menu`)||Y2(t)||(Te=!0,be()))}return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)});let De=!1;L(()=>{if(z(d)){De=!0;return}if(!De)return;De=!1;let e=Ee;if(Ee=null,Te){Te=!1;return}e&&e.isConnected&&e!==z(p)&&!z(g)?.contains(e)&&e.focus({preventScroll:!0})}),L(()=>{r()>0&&Ar(ye)}),L(()=>{i()>0&&Ar(()=>{let e=t.tabs.find(e=>e.id===t.activeTabId);e&&B8(e)&&N(o,e.id,!0)})});var Oe=S5(),ke=P(Oe);pi(ke,29,()=>t.tabs,e=>e.id,(e,r)=>{var i=x5(),a=P(i);{let e=j(()=>z(r).id===t.activeTabId),i=j(()=>z(te)?.id===z(r).id?z(te).side:null),u=j(()=>z(o)===z(r).id);m5(a,{get tab(){return z(r)},get isActive(){return z(e)},get onswitch(){return t.onTabSwitch},onclose:v,onpointerdown:fe,get dropIndicator(){return z(i)},onkeydown:_e,get reduceMotion(){return n()},get isRenaming(){return z(u)},onstartrename:s,onrename:c,onrenamecancel:l})}D(i),ji(i,()=>R8,()=>({duration:tv(n())?0:200})),H(e,i)}),D(ke),fa(ke,e=>N(C,e),()=>z(C));var Ae=I(ke,2),je=P(Ae);let Me;var Ne=P(je);fa(Ne,e=>N(p,e),()=>z(p));var Pe=I(Ne,2),Fe=P(Pe),Ie=P(Fe),Le=e=>{o5(e,{get recentFiles(){return z(f)},get closedTabTop(){return a()},onOpen:async e=>{be();let t=await Ch(e);t.ok?Ql(Jl(nu(),e)):console.warn(`[tandem] failed to open recent file:`,t.error)},onNewScratchpad:()=>{be(),gu()},onBrowse:()=>{be(),t.onRequestOpenDialog?.()},onReopenClosed:()=>{be(),t.onReopenClosed?.()},onClose:be})};W(Ie,e=>{z(h)&&e(Le)}),D(Fe),D(Pe),D(je),fa(je,e=>N(g,e),()=>z(g)),D(Ae),D(Oe),R(()=>{Ui(ke,1,Li([`tab-scroll-hide`,`tab-scroll-mask`,z(w)&&z(ee)&&`has-overflow`,z(w)&&!z(ee)&&`overflow-left`,!z(w)&&z(ee)&&`overflow-right`])),Me=Ui(je,1,`nt-morph svelte-urrc8n`,null,Me,{open:z(d),filled:z(d)||z(h),"grow-right":z(m)}),K(Ne,`aria-expanded`,z(d)),Fe.inert=!z(d)}),B(`click`,Ne,ye),H(e,Oe),A()}Br([`click`]);var w5=(e,t=m,n=m)=>{var r=E5();R(()=>{Ui(r,1,`panel-edge-collapse panel-edge-collapse-${t()}`,`svelte-y74n0s`),K(r,`data-testid`,`panel-edge-collapse-${t()}`),K(r,`aria-label`,t()===`left`?`Hide left panel`:`Hide right panel`)}),B(`click`,r,function(...e){n()?.apply(this,e)}),H(e,r)},T5=V(`<div role="slider" aria-orientation="horizontal" tabindex="0" style="width: 4px; cursor: col-resize; background: transparent; flex-shrink: 0; transition: background 0.15s; position: relative; z-index: var(--tandem-z-base);"></div>`),E5=V(`<div role="button" tabindex="-1"></div>`),D5=V(`<!> <!>`,1),O5=V(`<!> <!> <!>`,1),k5=V(`<div class="margin-track svelte-y74n0s" style="grid-column: 2; grid-row: 1;"><!></div>`),A5=V(`<div class="margin-track svelte-y74n0s" style="grid-column: 4; grid-row: 1;"><!></div>`),j5=V(`<div class="editor-content-track svelte-y74n0s" style="grid-column: 3; grid-row: 1;"><!></div> <!> <!>`,1),M5=V(`<div class="editor-end-marker svelte-y74n0s" aria-hidden="true"><span class="editor-end-pill svelte-y74n0s">End of document</span></div>`),N5=V(`<div data-testid="editor-stage"><!></div> <!>`,1),P5=V(`<div data-testid="editor-scroll-container" role="region" aria-label="Document editor"><!> <!> <!> <!></div>`),F5=V(`<div style="display: flex; flex: 1; align-items: center; justify-content: center; color: var(--tandem-fg-subtle);">Connecting...</div>`),I5=V(`<div style="padding: var(--tandem-space-2) var(--tandem-space-4); background: var(--tandem-warning-bg); border-bottom: 1px solid var(--tandem-warning-border); font-size: 13px; color: var(--tandem-warning-fg-strong); text-align: center;">Server restarted — refreshing documents</div>`),L5=V(`<div class="rail-float-shadow rail-float-shadow-left svelte-y74n0s" aria-hidden="true"></div>`),R5=V(`<div class="rail-float-shadow rail-float-shadow-right svelte-y74n0s" aria-hidden="true"></div>`),z5=V(`<span class="rail-tab-badge svelte-y74n0s"> </span>`),B5=V(`<!> <!> <!> <!> <!> <!> <div style="position: relative; display: flex; flex: 1; overflow: hidden; background: var(--tandem-bg);"><div><!> <div data-testid="left-outline-rail" class="rail-full rail-full-left svelte-y74n0s"><!> <!></div> <!></div> <!> <!> <!> <div><!> <div class="rail-full rail-full-right svelte-y74n0s"><!> <div class="rail-tabs-row svelte-y74n0s"><div class="rail-tabs-track svelte-y74n0s"><button data-testid="annotations-tab">Annotations <!></button> <button data-testid="chat-tab">Chat</button></div></div> <!> <!></div> <!></div></div> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>`,1),V5=V(`<div style="display: flex; flex-direction: column; height: 100vh; background: var(--tandem-bg); color: var(--tandem-fg);"><!> <!></div>`);function H5(e,t){k(t,!0);let n=e=>{C5(e,{get tabs(){return p.orderedTabs},get activeTabId(){return a.activeTabId},get onTabSwitch(){return a.setActiveTabId},onTabClose:l,onCloseOthers:u,onCloseToRight:d,get reorder(){return p.reorder},get reduceMotion(){return h.settings.reduceMotion},onRequestOpenDialog:()=>void ge(),get openMenuTrigger(){return z(O)},onTabRename:(e,t)=>a.handleTabRename(e,t,e=>w.push({id:dc(),type:`launcher`,severity:`error`,message:e,timestamp:Date.now()})),get renameTrigger(){return z(Ue)},get closedTabTop(){return s.top},onReopenClosed:f})},r=(e,t=m,n=m,r=m,i=m)=>{var a=T5();K(a,`aria-valuemin`,0),K(a,`aria-valuemax`,100),R(e=>{K(a,`data-testid`,r()??`${t()}-panel-resize-handle`),K(a,`aria-label`,t()===`left`?`Resize left panel`:`Resize right panel`),K(a,`aria-valuenow`,e)},[()=>i()===void 0?50:Math.round((i()-200)/400*100)]),B(`mousedown`,a,function(...e){n()?.apply(this,e)}),B(`keydown`,a,e=>{let n=null;e.key===`ArrowRight`||e.key===`ArrowUp`?n=16:e.key===`ArrowLeft`||e.key===`ArrowDown`?n=-16:e.key===`PageUp`?n=80:e.key===`PageDown`?n=-80:e.key===`Home`?n=200-(t()===`left`?Ke.width:qe.width):e.key===`End`&&(n=600-(t()===`left`?Ke.width:qe.width)),n!==null&&(e.preventDefault(),e.stopPropagation(),t()===`left`?Ke.handleResizeStep(n):qe.handleResizeStep(n))}),B(`keyup`,a,()=>{}),zr(`mouseenter`,a,e=>{e.currentTarget.style.background=`var(--tandem-border-strong)`}),zr(`mouseleave`,a,e=>{e.currentTarget.style.background=`transparent`}),H(e,a)},i=e=>{var t=P5();let n;{let e=e=>{E2(e,{get ydoc(){return z(St).ydoc},get provider(){return z(St).provider},get readOnly(){return z(Dt)},get currentFilePath(){return z(St).filePath},get format(){return z(St).format},get activeAnnotationId(){return z(Oe)},onEditorReady:e=>N(je,e,!0),onAnnotationClick:e=>{N(Ee,`annotations`),N(Oe,e,!0)},onClearAnnotation:()=>{N(Oe,null)},onSlashCommandMenuChange:e=>N(Ne,e,!0)})},n=(e,t=m,n=m)=>{let r=j(()=>t()===`left`?yt.leftGeometry:yt.rightGeometry),i=j(()=>t()===`left`?yt.leftMode:yt.rightMode);I6(e,{get side(){return t()},get annotations(){return n()},get positions(){return It.byId},get width(){return z(r).column},get edgeInset(){return z(r).inset},get gap(){return z(r).gap},get mode(){return z(i)},get activeAnnotationId(){return z(Oe)},get repliesById(){return Lt.byId},get reduceMotion(){return h.settings.reduceMotion},onClick:e=>{N(Oe,e.id,!0),Mt.scrollToAnnotation(e)},get onAccept(){return Mt.handleAccept},get onDismiss(){return Mt.handleDismiss},get onRemove(){return z(Rt).onRemove},get onEdit(){return z(Rt).onEdit},get onReply(){return z(Rt).onReply},get onSendToClaude(){return z(Rt).onSendToClaude}})};var r=P(t);{let e=j(()=>z(Et)&&z(St)?.format===`docx`),t=j(()=>z(St)?.id);cA(r,{get visible(){return z(e)},get documentId(){return z(t)}})}var i=I(r,2),o=e=>{var t=D5(),n=F(t);oh(n,{get ydoc(){return z(St).ydoc},get documentId(){return z(St).id},get fileName(){return z(St).fileName}}),Sh(I(n,2),{get ydoc(){return z(St).ydoc},get documentId(){return z(St).id},get fileName(){return z(St).fileName}}),H(e,t)};W(i,e=>{z(St)&&z(St).format===`docx`&&e(o)});var s=I(i,2),c=e=>{var t=Xr();ci(F(t),()=>z(St).id,e=>{{let t=j(()=>z(Le).get(z(St).id));H2(e,{get documentId(){return z(St).id},get ydoc(){return z(St).ydoc},get initialDraft(){return z(t)},onDraftChange:(e,t)=>ze(z(St).id,e,t),onExit:()=>jt(z(St).id)})}}),H(e,t)},l=t=>{var r=N5(),i=F(r),o=P(i),s=t=>{var r=O5(),i=F(r);ci(i,()=>z(St).id,t=>{e(t)});var a=I(i,2),o=e=>{n(e,()=>`left`,()=>z(Pt))};W(a,e=>{yt.leftVisible&&z(St)&&e(o)});var s=I(a,2),c=e=>{n(e,()=>`right`,()=>z(Ft))};W(s,e=>{yt.rightVisible&&z(St)&&e(c)}),H(t,r)},c=t=>{var r=j5(),i=F(r),o=P(i),s=t=>{var n=Xr();ci(F(n),()=>z(St).id,t=>{e(t)}),H(t,n)},c=e=>{ph(e,{get connected(){return a.connected},get aiChip(){return re.chip},onOpenFile:()=>N(he,!0),onRetry:()=>a.reconnect(),onOpenSettings:ye,onConnectAi:ie,onRestartClaude:ae})};W(o,e=>{z(St)?e(s):e(c,-1)}),D(i);var l=I(i,2),u=e=>{var t=k5();n(P(t),()=>`left`,()=>z(Pt)),D(t),H(e,t)};W(l,e=>{yt.leftVisible&&z(St)&&e(u)});var d=I(l,2),f=e=>{var t=A5();n(P(t),()=>`right`,()=>z(Ft)),D(t),H(e,t)};W(d,e=>{yt.rightVisible&&z(St)&&e(f)}),H(t,r)};W(o,e=>{z(St)?.format===`docx`?e(s):e(c,-1)}),D(i),fa(i,e=>N(Me,e),()=>z(Me));var l=I(i,2),u=e=>{H(e,M5())};W(l,e=>{z(St)&&e(u)}),R(()=>G(i,yt.layerStyle)),H(t,r)};W(s,e=>{z(kt)&&z(St)?e(c):e(l,-1)}),I2(I(s,2),{get editor(){return z(je)},get open(){return z(Pe)},onClose:()=>N(Pe,!1),get tabs(){return a.tabs},get forceScope(){return z(Fe)}}),D(t),fa(t,e=>N(Ct,e),()=>z(Ct)),Pi(t,(e,t)=>Bu?.(e,t),()=>`y`)}R(()=>{n=Ui(t,1,`editor-scroll tandem-scroll-fade-y`,null,n,{"hide-raw-md":!h.settings.showRawMarkdown}),G(t,`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: ${T.fileDragOver||S3.fileDragOver?`2px dashed var(--tandem-accent)`:`2px solid transparent`}; background: ${T.fileDragOver||S3.fileDragOver?`var(--tandem-accent-bg)`:`var(--tandem-bg)`}; transition: border-color 0.15s, background 0.15s; border-radius: ${T.fileDragOver||S3.fileDragOver?`var(--tandem-r-5)`:`0`};`)}),zr(`dragover`,t,function(...e){T.handleEditorDragOver?.apply(this,e)}),zr(`dragleave`,t,function(...e){T.handleEditorDragLeave?.apply(this,e)}),zr(`drop`,t,function(...e){T.handleEditorDrop?.apply(this,e)}),H(e,t)},a=f6({getRetryStrategy:()=>h.settings.sidecarRetryStrategy});va(()=>a.destroy());let o=u3(()=>a.tabs);va(()=>o.destroy()),F_.start({onTransition:()=>a.rebuildForLicenseChange()}),va(()=>F_.stop());let s=N4(),c=new Set;function l(e){let t=a.tabs.find(t=>t.id===e);if(t&&bo(t.filePath)){let e=xo(t.filePath);if(e&&o.hasUnsavedContent(e)){if(!window.confirm(`This scratchpad has unsaved content that will be lost. Close it anyway?`))return;o.clearUnsaved(e)}}if(!(z(Re).has(e)&&!window.confirm(`This document has unsaved markdown-source edits that will be lost. Close it anyway?`))){if(t&&!yo(t.filePath)&&s.push({filePath:t.filePath,closedAt:Date.now()}),z(Ie).has(e)){let t=new Set(z(Ie));t.delete(e),N(Ie,t,!0)}Be(e),wt.delete(e),a.handleTabClose(e)}}function u(e){for(let t of y5(p.orderedTabs,e))l(t)}function d(e){for(let t of b5(p.orderedTabs,e))l(t)}async function f(){let e=s.pop();if(!e)return;let t=a.tabs.find(t=>t.filePath===e.filePath);if(t){a.setActiveTabId(t.id);return}if(c.has(e.filePath))return;c.add(e.filePath);let n=t=>{s.push(e);let n=e.filePath.split(/[\\/]/).pop()||e.filePath;w.push({id:`reopen-failed-${Date.now()}`,type:`general-error`,severity:`error`,message:`Couldn't reopen ${n}: ${t}`,dedupKey:`reopen-failed:${e.filePath}`,timestamp:Date.now()})};try{let t=await Ch(e.filePath);t.ok||n(t.error)}finally{c.delete(e.filePath)}}let p=_3(()=>a.tabs);f3(()=>p.orderedTabs,()=>a.activeTabId,e=>a.setActiveTabId(e)),L(()=>{let e=a.tabs;if(e.length!==0)try{let t=Zl(),n=t;for(let t of e)yo(t.filePath)||(n=Jl(n,t.filePath));(n.length!==t.length||n.some((e,n)=>e!==t[n]))&&Ql(n)}catch(e){console.warn(`[tandem] failed to sync recent files:`,e)}});let h=J_(),g=v3(()=>a.bootstrapYdoc,()=>h.settings.selectionDwellMs),_=w6(h,g),v=j(()=>vl(h.settings.customShortcuts)),y=j(()=>cl(z(v))),b=j(()=>a.annotations),x=P4(()=>a.disconnectedSince,()=>h.settings.degradedBannerDelayMs),S=i6();o6();let C=j(()=>a.tabs.map(e=>({id:e.id,fileName:e.fileName}))),w=t3(),ee=M(!1),T=H4();if(E3(w.push),Lm()){let e=null,t=!1;Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`sidecar-restart-failed`,()=>{w.push({id:`sidecar-restart-failed-${Date.now()}`,type:`general-error`,severity:`error`,message:`Sidecar failed to restart — see logs`,dedupKey:`sidecar-restart-failed`,timestamp:Date.now(),errorCode:`SIDECAR_RESTART_FAILED`})})).then(n=>{t?n():e=n}).catch(e=>{console.warn(`[App] Failed to wire sidecar-restart-failed listener:`,e)}),va(()=>{t=!0,e?.()})}if(Lm()){let e=null,t=!1;Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`open-integration-wizard`,()=>{window.dispatchEvent(new CustomEvent(`tandem:open-integration-wizard`))})).then(n=>{t?n():e=n}).catch(e=>{console.warn(`[App] Failed to wire open-integration-wizard listener:`,e),w.push({id:`open-wizard-listener-failed-${Date.now()}`,type:`launcher`,severity:`warning`,message:`Couldn't enable the Setup shortcut. Open Settings → Reopen wizard to configure integrations.`,dedupKey:`open-wizard-listener-failed`,timestamp:Date.now()})}),va(()=>{t=!0,e?.()})}if(Lm()){let e=e=>{switch(e){case`unsupported-extension`:return`That file type can't be opened in Tandem.`;case`not-a-file`:case`non-file-url`:return`That file couldn't be opened — it may have moved or been deleted.`;case`suspicious-path`:return`That file path was rejected for safety reasons.`;default:return`That file couldn't be opened in Tandem.`}},t=t=>{w.push({id:`startup-file-rejected-${Date.now()}`,type:`general-error`,severity:`warning`,message:e(t),dedupKey:`startup-file-rejected`,timestamp:Date.now(),errorCode:`STARTUP_FILE_REJECTED`})},n=null,r=!1;Ul(async()=>{let{listen:e}=await import(`./event-wL_2RBc7.js`);return{listen:e}},__vite__mapDeps([3,1])).then(({listen:e})=>e(`startup-file-rejected`,e=>{t(typeof e.payload==`string`?e.payload:``)})).then(e=>{r?e():n=e}).catch(e=>{console.warn(`[App] Failed to wire startup-file-rejected listener:`,e)}),Ul(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]).then(({invoke:e})=>e(`get_startup_rejection`)).then(e=>{e&&t(e)}).catch(e=>{console.warn(`[App] Failed to poll buffered startup rejection:`,e)}),va(()=>{r=!0,n?.()})}let te=M(!1),ne=M(!1),E=W4(),re=D4({connected:()=>a.connected,firstRunSettled:()=>E.settled,soloMode:()=>g.tandemMode===`solo`});function ie(){window.dispatchEvent(new CustomEvent(`tandem:open-integration-wizard`))}function ae(){Nu(),setTimeout(()=>re.refresh(),2e3),setTimeout(()=>re.refresh(),5e3)}L(()=>{let e=async e=>{let t=e.detail?.via;if(re.chip===null||await re.probeSession())return;let n=re.chip;if(n===null)return;let r=t===`comment`?`Comment`:`Message`;w.push({id:`ai-not-ready-${t??`chat`}-${Date.now()}`,type:`launcher`,severity:`warning`,message:`${r} saved — no AI is connected yet. It'll be seen when AI connects.`,dedupKey:`ai-not-ready-${t??`chat`}`,timestamp:Date.now()},{label:n===`connect`?`Connect AI`:`Restart Claude Code`,onClick:n===`connect`?ie:ae})};return window.addEventListener(`tandem:addressed-ai`,e),()=>window.removeEventListener(`tandem:addressed-ai`,e)});let oe=`tandem:wizard-dismissed`,se=M(un(le())),ce=M(!1);function le(){try{return localStorage.getItem(oe)}catch{return null}}let ue=j(()=>E.needed===!0&&E.serverVersion!==null&&z(se)!==E.serverVersion),de=j(()=>z(ce)||z(ue));function fe(){if(z(ue)&&E.serverVersion!==null)try{localStorage.setItem(oe,E.serverVersion),N(se,E.serverVersion,!0)}catch{}N(ce,!1)}L(()=>{let e=e=>{e.key===oe&&N(se,e.newValue,!0)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)}),L(()=>{let e=()=>{N(ce,!0),N(ne,!1),E.refetch()};return window.addEventListener(`tandem:open-integration-wizard`,e),()=>window.removeEventListener(`tandem:open-integration-wizard`,e)});let pe=M(null),me=M(!1),he=M(!1);function ge(){return Dh({isTauri:Lm(),openModal:()=>{N(he,!0)},onError:e=>w.push({id:dc(),type:`general-error`,severity:`error`,message:e,timestamp:Date.now()})})}let _e=n6();function ve(){z(te)||_e.acknowledge(),N(te,!z(te))}function ye(){_e.acknowledge(),N(ne,!0)}let be=M(null);function xe(){z(ne)||N(be,fM.models,!0),ye()}function Se(){_e.acknowledge(),N(te,!0)}lu({getActiveTabId:()=>a.activeTabId,getActiveDocumentPath:()=>{let e=a.tabs.find(e=>e.id===a.activeTabId);return e&&!yo(e.filePath)?e.filePath:null},notify:(e,t)=>{w.push({id:`launcher-${Date.now()}`,type:`launcher`,severity:e,message:t,timestamp:Date.now()})},openSettings:Se,openSettingsModal:ye,toggleSoloMode:()=>g.setTandemMode(g.tandemMode===`solo`?`tandem`:`solo`),openFindBar:()=>{N(Fe,`doc`),N(Pe,!0)},openFindBarTabs:()=>{N(Fe,`tabs`),N(Pe,!0)},findNext:()=>{let e=z(je),t=e?mZ(e.state):void 0;e&&U4(t)?e.commands.findNext():(N(Fe,`doc`),N(Pe,!0))},findPrev:()=>{let e=z(je),t=e?mZ(e.state):void 0;e&&U4(t)?e.commands.findPrev():(N(Fe,`doc`),N(Pe,!0))},closeActiveTab:()=>{let e=a.activeTabId;e&&l(e)},openFileDialog:()=>void ge(),toggleLeftPanel:()=>Ze(),toggleRightPanel:()=>Qe(),reopenClosedTab:()=>void f(),annotationNext:()=>{let e=wD(z(b)),t=OD(e,z(Oe));if(t){N(Oe,t,!0);let n=e.find(e=>e.id===t);n&&Mt.scrollToAnnotation(n)}},annotationPrev:()=>{let e=wD(z(b)),t=kD(e,z(Oe));if(t){N(Oe,t,!0);let n=e.find(e=>e.id===t);n&&Mt.scrollToAnnotation(n)}},annotationAccept:()=>{let e=Nt();e&&e.author!==`user`&&Mt.handleAccept(e.id)},annotationDismiss:()=>{let e=Nt();e&&e.author!==`user`&&Mt.handleDismiss(e.id)},selectBlock:()=>z(je)?.chain().focus().selectParentNode().run(),toggleAuthorship:()=>Ce(!h.settings.showAuthorship),toggleFormattingBar:()=>h.updateSettings({formattingBarVisible:!h.settings.formattingBarVisible}),toggleSourceView:()=>At(),saveAs:async()=>{let e=a.tabs.find(e=>e.id===a.activeTabId);if(!e||!yo(e.filePath)){w.push({id:dc(),type:`launcher`,severity:`info`,message:`Save As is only available for scratchpads; this document is already on disk.`,timestamp:Date.now()});return}let t=Math.max(e.filePath.lastIndexOf(`/`),e.filePath.lastIndexOf(`\\`)),n=e.filePath.slice(t+1);await Su({activeDocId:a.activeTabId,defaultName:n,sourceFormat:e.format,notify:(e,t)=>w.push({id:dc(),type:`launcher`,severity:e,message:t,timestamp:Date.now()})})}});function Ce(e){h.updateSettings({showAuthorship:e,...h.settings.decorationsMuted?{decorationsMuted:!1}:{}})}let we=null;L(()=>{let e=z(je);if(!e)return;let t=h.settings,n=!t.decorationsMuted&&t.showAuthorship;if(we===n)return;let r=we===null;we=n,!r&&Ar(()=>{let t=e.state.tr.setMeta(ZX,{type:`toggle`,visible:n});e.view.dispatch(t)})});let Te=null;L(()=>{let e=z(je);if(!e)return;let t=h.settings,n=t.decorationsMuted,r={comment:!n&&t.showComments,highlight:!n&&t.showHighlights,note:!n&&t.showNotes},i=`${+!!r.comment}${+!!r.highlight}${+!!r.note}`;if(Te===i)return;let a=Te===null;Te=i,!a&&Ar(()=>{let t=e.state.tr.setMeta(LX,{type:`toggle-decorations`,visible:r});e.view.dispatch(t)})}),L(()=>(document.body.classList.toggle(`tandem-reduce-motion`,h.settings.reduceMotion),()=>document.body.classList.remove(`tandem-reduce-motion`))),L(()=>(document.body.classList.toggle(`tandem-rail-hover-reveal`,h.settings.railHoverReveal),()=>document.body.classList.remove(`tandem-rail-hover-reveal`))),F3(()=>h.settings.theme,()=>h.settings.systemLightVariant),T4(()=>h.settings.accentHue),V4(()=>Fl(h.settings,z(St)?.format)),I4(()=>h.settings.density),K4(()=>h.settings.highContrast),k4(()=>h.settings.annotationPatterns),L(()=>{let e=wl[h.settings.textSize];return document.documentElement.style.setProperty(`--tandem-editor-font-size`,`${e}px`),()=>document.documentElement.style.removeProperty(`--tandem-editor-font-size`)});let Ee=M(un(h.settings.primaryTab===`chat`?`chat`:`annotations`)),De=j(()=>z(Ee)===`annotations`?0:z(b).filter(sc).length),Oe=M(null),ke=M(!1),Ae=M(null),je=M(null),Me=M(null),Ne=M(!1),Pe=M(!1),Fe=M(`doc`),Ie=M(un(new Set)),Le=M(un(new Map)),Re=M(un(new Set));function ze(e,t,n){let r=new Map(z(Le)),i=new Set(z(Re));n?(r.set(e,t),i.add(e)):(r.delete(e),i.delete(e)),N(Le,r,!0),N(Re,i,!0)}function Be(e){if(!z(Le).has(e)&&!z(Re).has(e))return;let t=new Map(z(Le)),n=new Set(z(Re));t.delete(e),n.delete(e),N(Le,t,!0),N(Re,n,!0)}let Ve=M(0),He=M(0),O=M(0),Ue=M(0),We=L4(`left`),Ge=L4(`right`),Ke=R4({side:`left`,initialWidth:We,getVisible:()=>z(Je)}),qe=R4({side:`right`,initialWidth:Ge,getVisible:()=>z(Ye)}),Je=j(()=>_.leftVisible),Ye=j(()=>_.rightVisible);function Xe(e,t){queueMicrotask(()=>{let n=t?`panel-edge-collapse-${e}`:`peek-strip-${e}`,r=document.querySelector(`[data-testid="${n}"]`);r?r.focus():console.warn(`[tandem] focusToggleTarget: ${n} not mounted; focus dropped to body`)})}let Ze=()=>{$e(`left`),tt.left=!1;let e=!_.leftVisible;_.toggleLeft(),Xe(`left`,e)},Qe=()=>{$e(`right`),tt.right=!1;let e=!_.rightVisible;_.toggleRight(),Xe(`right`,e)};function $e(e){tt[e]&&(nt[e]=!0,requestAnimationFrame(()=>{nt[e]=!1}))}let et=un({left:!1,right:!1}),tt=un({left:!1,right:!1}),nt=un({left:!1,right:!1}),rt=un({left:!1,right:!1}),it={left:void 0,right:void 0},at={left:void 0,right:void 0},ot={left:void 0,right:void 0},st={left:!1,right:!1},ct={left:!1,right:!1},lt=e=>z(e===`left`?Je:Ye);function ut(e){if(st[e]=!0,!(lt(e)||!h.settings.railHoverReveal)){if(clearTimeout(it[e]),rt[e]){clearTimeout(at[e]),rt[e]=!1,tt[e]=!0;return}it[e]=setTimeout(()=>{tt[e]=!0},120)}}function dt(e){if(!(st[e]||ct[e])&&tt[e]){if(tt[e]=!1,lt(e)||tv(h.settings.reduceMotion)){rt[e]=!1;return}rt[e]=!0,clearTimeout(at[e]),at[e]=setTimeout(()=>{rt[e]=!1},300)}}function ft(e){st[e]=!1,clearTimeout(it[e]),it[e]=setTimeout(()=>dt(e),180)}function pt(e){ct[e]=!0}function mt(e,t){let n=t.currentTarget,r=t.relatedTarget;r&&n.contains(r)||(ct[e]=!1,dt(e))}function ht(e,t){t.propertyName!==`width`||t.target!==t.currentTarget||(et[e]=!1,clearTimeout(ot[e]))}let gt=Ar(()=>({left:z(Je),right:z(Ye)}));L(()=>{let e=z(Je),t=z(Ye);Ar(()=>{_t(`left`,e),_t(`right`,t)})});function _t(e,t){if(t===gt[e])return;let n=gt[e]&&!t;gt[e]=t,!(!n||h.settings.reduceMotion)&&(et[e]=!0,clearTimeout(ot[e]),ot[e]=setTimeout(()=>{et[e]=!1},400))}L(()=>()=>{clearTimeout(it.left),clearTimeout(it.right),clearTimeout(ot.left),clearTimeout(ot.right),clearTimeout(at.left),clearTimeout(at.right)});let vt=a6(),yt=C6({getFormat:()=>z(St)?.format,getMarginView:()=>h.settings.marginView,getEditorMeasure:()=>h.settings.editorMeasure,getLeftRailVisible:()=>z(Je),getRightRailVisible:()=>z(Ye),getViewportWidth:()=>vt.width,getLeftHasPending:()=>z(b).some(e=>e.status===`pending`&&L6(e)),getRightHasPending:()=>z(b).some(e=>e.status===`pending`&&R6(e)),leftRailWidthPx:We,rightRailWidthPx:Ge});function bt(){if(z(Ee)===`chat`||!z(je))return;let{from:e,to:t}=z(je).state.selection;if(e===t)return;let n=aD(z(je).state.doc,{from:Co(e),to:Co(t)}),r=z(je).state.doc.textBetween(e,t,`
|
|
262
|
-
`);N(Ae,{...n,textSnapshot:r.length>200?r.slice(0,197)+`...`:r},!0)}let xt={"toggle-help":e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||(e.preventDefault(),N(ke,Ar(()=>!z(ke)),!0))},"select-all":e=>{let t=document.activeElement;t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t?.closest?.(`.ProseMirror`)||(e.preventDefault(),z(je)?.commands.selectAll())},save:e=>{e.preventDefault(),!z(kt)&&Tu(a.activeTabId)},"save-as":e=>{let t=e.target;if(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable))return;e.preventDefault();let n=a.tabs.find(e=>e.id===a.activeTabId);if(!n||!yo(n.filePath)){w.push({id:dc(),type:`launcher`,severity:`info`,message:`Save As is only available for scratchpads; this document is already on disk.`,timestamp:Date.now()});return}let r=Math.max(n.filePath.lastIndexOf(`/`),n.filePath.lastIndexOf(`\\`)),i=n.filePath.slice(r+1);Su({activeDocId:a.activeTabId,defaultName:i,sourceFormat:n.format,notify:(e,t)=>w.push({id:dc(),type:`launcher`,severity:e,message:t,timestamp:Date.now()})})},"settings-modal":e=>{e.preventDefault(),ye()},settings:e=>{e.preventDefault(),Se()},"toggle-palette":e=>{e.preventDefault(),N(me,!Ar(()=>z(me)))},"new-scratchpad":e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`)||(e.preventDefault(),gu())},"close-tab":e=>{if(m3(e))return;e.preventDefault();let t=a.activeTabId;t&&l(t)},"open-file":e=>{m3(e)||(e.preventDefault(),ge())},"pick-tab":(e,t)=>{if(m3(e))return;let n=t?.tabIndex;if(n===void 0)return;let r=p3(a.tabs,n);r&&(e.preventDefault(),a.setActiveTabId(r))},"toggle-mode":e=>{m3(e)||(e.preventDefault(),g.setTandemMode(g.tandemMode===`solo`?`tandem`:`solo`))},"reopen-closed-tab":e=>{m3(e)||(e.preventDefault(),f())},"new-tab-menu":e=>{m3(e)||(e.preventDefault(),N(O,z(O)+1))},find:(e,t)=>{if(e.preventDefault(),t?.shift){N(Fe,`tabs`),N(Pe,!0);return}z(Je)?N(Ve,z(Ve)+1):(N(Fe,`doc`),N(Pe,!0))},"find-nav":(e,t)=>{if(m3(e))return;e.preventDefault();let n=z(je),r=n?mZ(n.state):void 0;n&&U4(r)?t?.shift?n.commands.findPrev():n.commands.findNext():(N(Fe,`doc`),N(Pe,!0))},"annotation-accept-or-dismiss":(e,t)=>{if(m3(e))return;e.preventDefault();let n=Nt();n&&n.author!==`user`&&(t?.shift?Mt.handleDismiss(n.id):Mt.handleAccept(n.id))},"comment-on-selection":e=>{e.preventDefault();let t=!!z(je)&&z(je).state.selection.from!==z(je).state.selection.to,n=z(Et);if(!(z(Ne)||z(Pe)||z(me))){if(!t){w.push({id:`comment-shortcut-no-selection-${Date.now()}`,type:`general-error`,severity:`info`,message:`Select text to comment`,dedupKey:`comment-shortcut-no-selection`,timestamp:Date.now()});return}if(n){w.push({id:`comment-shortcut-readonly-${Date.now()}`,type:`general-error`,severity:`info`,message:`Document is read-only`,dedupKey:`comment-shortcut-readonly`,timestamp:Date.now()});return}if(!h.settings.selectionToolbar){w.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}N(He,z(He)+1)}},"toggle-authorship":e=>{e.preventDefault(),Ce(!h.settings.showAuthorship)},"toggle-left-panel":e=>{m3(e)||(e.preventDefault(),Ze())},"toggle-right-panel":e=>{m3(e)||(e.preventDefault(),Qe())},"annotation-next":e=>{if(m3(e))return;e.preventDefault();let t=wD(z(b)),n=OD(t,z(Oe));if(n){N(Oe,n,!0);let e=t.find(e=>e.id===n);e&&Mt.scrollToAnnotation(e)}},"annotation-prev":e=>{if(m3(e))return;e.preventDefault();let t=wD(z(b)),n=kD(t,z(Oe));if(n){N(Oe,n,!0);let e=t.find(e=>e.id===n);e&&Mt.scrollToAnnotation(e)}},"select-block":e=>{m3(e)||(e.preventDefault(),z(je)&&z(je).chain().focus().selectParentNode().run())}};L(()=>{function e(e){if(e.key===`F2`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){if(m3(e))return;let t=a.tabs.find(e=>e.id===a.activeTabId);t&&B8(t)&&(e.preventDefault(),N(Ue,z(Ue)+1));return}let t=ul(e,Ar(()=>z(v)));t&&xt[t.id]?.(e,t.context)}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),L(()=>{function e(e){if(e.key!==`Escape`||e.defaultPrevented||z(Oe)===null||z(Pe))return;let t=document.activeElement;t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||(!t||t===document.body||t.closest(`.ProseMirror, [data-testid="editor-root"], [data-testid="annotation-list-scroll-container"]`))&&(e.preventDefault(),N(Oe,null))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let St=j(()=>a.tabs.find(e=>e.id===a.activeTabId)),Ct=M(null),wt=new Map,Tt;L(()=>{let e=z(Ct);if(!e)return;let t=()=>{Tt!==void 0&&wt.set(Tt,e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)}),L(()=>{let e=z(Ct),t=z(St)?.id;if(!e||t===Tt||(Tt=t,t===void 0))return;let n=wt.get(t)??0,r=0,i=!1,a=()=>{i||Tt!==t||(e.scrollTop=n,e.scrollTop<n&&r<30&&(r+=1,requestAnimationFrame(a)))};return requestAnimationFrame(a),()=>{i=!0}});let Et=j(()=>z(St)?.readOnly===!0),Dt=j(()=>z(Et)||F_.ui.showWall),Ot=j(()=>!!z(St)&&z(St).format===`md`&&!z(Et)),kt=j(()=>!!z(St)&&z(Ie).has(z(St).id));function At(){if(!z(St))return;let e=z(St).id,t=new Set(z(Ie));if(t.has(e))t.delete(e);else{if(!z(Ot))return;t.add(e),N(Pe,!1),N(Ne,!1),N(me,!1)}N(Ie,t,!0)}function jt(e){if(!z(Ie).has(e))return;let t=new Set(z(Ie));t.delete(e),N(Ie,t,!0),Be(e)}L(()=>{let e=e=>{z(Re).size!==0&&(e.preventDefault(),e.returnValue=`You have unsaved markdown-source edits.`)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)}),L(()=>{if(!hu({connected:a.connected,tabCount:a.tabs.length,activeTabId:a.activeTabId}))return;let e=setTimeout(()=>{gu()},400);return()=>clearTimeout(e)});let Mt=G6({getYdoc:()=>z(St)?.ydoc??null,getEditor:()=>z(je),getAnnotations:()=>z(b),onActiveAnnotationChange:e=>{N(Oe,e,!0)},getScrollBehavior:()=>h.settings.reduceMotion?`auto`:`smooth`,getActiveAnnotationId:()=>z(Oe)});function Nt(){return z(Oe)?z(b).find(e=>e.id===z(Oe)):Mt.getReviewTargets()[0]}let Pt=j(()=>yt.effectivelyOn?z(b).filter(L6):[]),Ft=j(()=>yt.effectivelyOn?z(b).filter(R6):[]),It=Y4({getEditor:()=>z(je),getYdoc:()=>z(St)?.ydoc??null,getAnnotations:()=>[...z(Pt),...z(Ft)],getLayerEl:()=>z(Me),getEnabled:()=>yt.effectivelyOn}),Lt=A4({getYdoc:()=>z(St)?.ydoc??null}),Rt=j(()=>{let e=z(St)?.ydoc??null,t=z(St)?.id;return{ydoc:e,docId:t,onEdit:(t,n)=>YO(e,t,n),onReply:(e,n)=>ek(e,n,t),onRemove:e=>$O(e,t),onSendToClaude:t=>ZO(e,t)}}),zt=z3(()=>z(b),()=>z(je),()=>z(St)?.fileName);var Bt=V5(),Vt=P(Bt);{let e=j(()=>null),t=j(()=>z(Ot)||z(kt)?At:null);b8(Vt,{get tandemMode(){return g.tandemMode},get onModeChange(){return g.setTandemMode},get claudeActive(){return a.claudeActive},get theme(){return h.settings.theme},onSetTheme:e=>h.updateSettings({theme:e}),onOpenHelp:()=>N(ke,!0),onOpenSettings:ve,onOpenSettingsModal:ye,get updateAvailable(){return _e.showDot},get defaultModelLabel(){return z(e)},onOpenModelsSettings:xe,get aiChip(){return re.chip},onConnectAi:ie,onRestartClaude:ae,get sourceViewActive(){return z(kt)},get onToggleSourceView(){return z(t)},get center(){return n},get settingsBtn(){return z(pe)},set settingsBtn(e){N(pe,e,!0)}})}var Ht=I(Vt,2),Ut=e=>{H(e,F5())},Wt=e=>{var t=B5(),n=F(t),o=e=>{H(e,I5())};W(n,e=>{a.serverRestarted&&e(o)});var s=I(n,2),c=e=>{BM(e,{get version(){return S.availableVersion},get installing(){return S.installing},onInstall:()=>{S.install()},get onDismiss(){return S.dismiss}})},l=j(()=>Lm()&&S.showBanner&&S.availableVersion);W(s,e=>{z(l)&&e(c)});var u=I(s,2),d=e=>{Tm(e,{get onDismiss(){return x.dismiss},onRetry:()=>{a.reconnect()}})};W(u,e=>{x.showBanner&&e(d)});var f=I(u,2);R_(f,{});var p=I(f,2);{let e=j(()=>z(St)?.ydoc??null),t=j(()=>z(Ne)||z(Pe)||z(me));C4(p,{get editor(){return z(je)},get ydoc(){return z(e)},get selectionToolbar(){return h.settings.selectionToolbar},get suppressSelectionToolbar(){return z(t)},get requestCommentFocus(){return z(He)},get showAuthorship(){return h.settings.showAuthorship},get showComments(){return h.settings.showComments},get showHighlights(){return h.settings.showHighlights},get showNotes(){return h.settings.showNotes},get decorationsMuted(){return h.settings.decorationsMuted},onUpdateDecorations:e=>h.updateSettings(e),onOpenSettings:ve,get formattingBarVisible(){return h.settings.formattingBarVisible},onToggleFormattingBar:()=>h.updateSettings({formattingBarVisible:!h.settings.formattingBarVisible}),get reduceMotion(){return h.settings.reduceMotion}})}var m=I(p,2),g=e=>{{let t=j(()=>z(St)?.ydoc??null);$6(e,{get editor(){return z(je)},get ydoc(){return z(t)},get showAuthorship(){return h.settings.showAuthorship},get showComments(){return h.settings.showComments},get showHighlights(){return h.settings.showHighlights},get showNotes(){return h.settings.showNotes},get decorationsMuted(){return h.settings.decorationsMuted},onUpdateDecorations:e=>h.updateSettings(e),onOpenSettings:ve,onHide:()=>h.updateSettings({formattingBarVisible:!1})})}};W(m,e=>{h.settings.formattingBarVisible&&e(g)});var _=I(m,2),v=P(_);let T;var E=P(v),re=e=>{var t=L5();R(()=>G(t,`width: ${Ke.width}px;`)),H(e,t)};W(E,e=>{(tt.left||rt.left)&&e(re)});var ie=I(E,2),ae=P(ie);iA(ae,{kind:`outline`,get focusTrigger(){return z(Ve)},get editor(){return z(je)},visible:!0}),w5(I(ae,2),()=>`left`,()=>Ze),D(ie);var oe=I(ie,2);{let e=j(()=>!z(Je));H6(oe,{side:`left`,get collapsed(){return z(e)},kind:`outline`,onActivate:Ze})}D(v);var se=I(v,2),ce=e=>{r(e,()=>`left`,()=>e=>Ke.handleResizeStart(e),()=>void 0,()=>Ke.width)};W(se,e=>{z(Je)&&e(ce)});var le=I(se,2);i(le);var ue=I(le,2),ge=e=>{r(e,()=>`right`,()=>e=>qe.handleResizeStart(e),()=>`panel-resize-handle`,()=>qe.width)};W(ue,e=>{z(Ye)&&e(ge)});var _e=I(ue,2);let ye;var xe=P(_e),Se=e=>{var t=R5();R(()=>G(t,`width: ${qe.width}px;`)),H(e,t)};W(xe,e=>{(tt.right||rt.right)&&e(Se)});var Ce=I(xe,2),we=P(Ce);w5(we,()=>`right`,()=>Qe);var Te=I(we,2),Me=P(Te),Fe=P(Me),Ie=I(P(Fe)),Le=e=>{var t=z5(),n=P(t,!0);D(t),R(()=>U(n,z(De)>9?`9+`:z(De))),H(e,t)};W(Ie,e=>{z(Ee)!==`annotations`&&z(De)>0&&e(Le)}),D(Fe);var Re=I(Fe,2);D(Me),D(Te);var ze=I(Te,2);{let e=j(()=>z(Ee)===`chat`);iA(ze,{kind:`chat`,get ctrlYdoc(){return a.bootstrapYdoc},get editor(){return z(je)},get activeDocId(){return a.activeTabId},get openDocs(){return z(C)},get claudeActive(){return a.claudeActive},get claudeStatus(){return a.claudeStatus},get capturedAnchor(){return z(Ae)},onCapturedAnchorChange:e=>N(Ae,e,!0),get reduceMotion(){return h.settings.reduceMotion},get visible(){return z(e)}})}var Be=I(ze,2);{let e=j(()=>z(St)?.ydoc??null),t=j(()=>z(St)?.format),n=j(()=>z(St)?.id),r=j(()=>a.claudeWorking?.annotationId??null),i=j(()=>z(Ee)===`annotations`);iA(Be,{kind:`side`,get annotations(){return z(b)},get editor(){return z(je)},get ydoc(){return z(e)},get activeDocFormat(){return z(t)},get documentId(){return z(n)},get activeAnnotationId(){return z(Oe)},onActiveAnnotationChange:e=>N(Oe,e,!0),get reduceMotion(){return h.settings.reduceMotion},get storeReadOnly(){return a.storeReadOnly},get claudeWorkingAnnotationId(){return z(r)},get review(){return Mt},get visible(){return z(i)}})}D(Ce);var O=I(Ce,2);{let e=j(()=>!z(Ye));H6(O,{side:`right`,get collapsed(){return z(e)},kind:`annotations`,get annotations(){return z(b)},onActivate:Qe})}D(_e),D(_);var Ue=I(_,2);{let e=j(()=>a.claudeWorking?.tool??null);I8(Ue,{get connected(){return a.connected},get connectionStatus(){return a.connectionStatus},get reconnectAttempts(){return a.reconnectAttempts},get disconnectedSince(){return a.disconnectedSince},get claudeStatus(){return a.claudeStatus},get claudeActive(){return a.claudeActive},get claudeWorkingTool(){return z(e)},get readOnly(){return z(Et)},get saving(){return fu.saving},get editor(){return z(je)}})}var We=I(Ue,2);MM(We,{get open(){return z(te)},onClose:()=>N(te,!1),get settings(){return h.settings},get onUpdate(){return h.updateSettings},get returnFocusEl(){return z(pe)},get anchorEl(){return z(pe)},get connected(){return a.connected},get reconnectAttempts(){return a.reconnectAttempts}});var Ge=I(We,2);_M(Ge,{get open(){return z(ne)},onClose:()=>{N(ne,!1),N(be,null)},get settings(){return h.settings},get onUpdate(){return h.updateSettings},get returnFocusEl(){return z(pe)},get triggerEl(){return z(pe)},get connected(){return a.connected},get reconnectAttempts(){return a.reconnectAttempts},get initialTabId(){return z(be)},notify:(e,t)=>w.push({id:`settings-${Date.now()}`,type:`launcher`,severity:e,message:t,timestamp:Date.now()})});var Xe=I(Ge,2);U_(Xe,{});var k=I(Xe,2);Yh(k,{get open(){return z(ke)},onClose:()=>N(ke,!1),get effectiveShortcutLabels(){return z(y)}});var A=I(k,2),$e=e=>{O_(e,{open:!0,onClose:fe})};W(A,e=>{z(de)&&e($e)});var it=I(A,2),at=e=>{Wh(e,{onClose:()=>N(he,!1)})};W(it,e=>{z(he)&&e(at)});var ot=I(it,2);Cm(ot,{get open(){return z(me)},onClose:()=>N(me,!1),get editor(){return z(je)},get annotations(){return z(b)},onFocusAnnotation:e=>{N(Oe,e,!0)}});var st=I(ot,2);RM(st,{get toasts(){return w.toasts},get onDismiss(){return w.dismiss}});var ct=I(st,2);td(ct,{get items(){return w.activity},get open(){return z(ee)},onToggle:()=>N(ee,!z(ee)),get onDismiss(){return w.dismissActivity},get onClear(){return w.clearActivity},onAction:e=>{let t=Vu(e);t&&(a.tabs.some(e=>e.id===t.documentId)?Tu(t.documentId):w.push({id:`retry-unavailable-${t.documentId}`,type:`general-error`,severity:`warning`,message:`Reopen the document to retry the save.`,dedupKey:`retry-unavailable:${t.documentId}`,timestamp:Date.now()}))}});var lt=I(ct,2),dt=e=>{rh(e,{})},gt=j(()=>Lm()&&!z(de));W(lt,e=>{z(gt)&&e(dt)});var _t=I(lt,2),vt=e=>{Nv(e,{get currentStep(){return zt.currentStep},get onNext(){return zt.nextStep},get onDismiss(){return zt.dismissTutorial},get coworkStatus(){return zt.coworkStatus}})};W(_t,e=>{zt.tutorialActive&&e(vt)}),R(()=>{T=Ui(v,1,`rail-shell rail-shell-left svelte-y74n0s`,null,T,{collapsed:!z(Je),animating:et.left,"rail-floating-chrome":tt.left||rt.left,floating:tt.left,"float-closing":rt.left,"pin-snap":nt.left}),K(v,`data-testid`,tt.left?`rail-float-left`:void 0),G(v,z(Je)?`width: ${Ke.width}px;`:``),G(ie,`width: ${Ke.width}px;`),ye=Ui(_e,1,`rail-shell rail-shell-right svelte-y74n0s`,null,ye,{collapsed:!z(Ye),animating:et.right,"rail-floating-chrome":tt.right||rt.right,floating:tt.right,"float-closing":rt.right,"pin-snap":nt.right}),K(_e,`data-testid`,tt.right?`rail-float-right`:void 0),G(_e,z(Ye)?`width: ${qe.width}px;`:``),G(Ce,`width: ${qe.width}px;`),Ui(Fe,1,`rail-tab`+(z(Ee)===`annotations`?` on`:``),`svelte-y74n0s`),Ui(Re,1,`rail-tab`+(z(Ee)===`chat`?` on`:``),`svelte-y74n0s`)}),zr(`scroll`,_,e=>{e.currentTarget.scrollLeft=0}),zr(`mouseenter`,v,()=>ut(`left`)),zr(`mouseleave`,v,()=>ft(`left`)),B(`focusin`,v,()=>pt(`left`)),B(`focusout`,v,e=>mt(`left`,e)),zr(`transitionend`,v,e=>ht(`left`,e)),zr(`mouseenter`,_e,()=>ut(`right`)),zr(`mouseleave`,_e,()=>ft(`right`)),B(`focusin`,_e,()=>pt(`right`)),B(`focusout`,_e,e=>mt(`right`,e)),zr(`transitionend`,_e,e=>ht(`right`,e)),B(`click`,Fe,()=>{N(Ee,`annotations`)}),B(`mousedown`,Re,bt),B(`click`,Re,()=>{N(Ee,`chat`)}),H(e,t)};W(Ht,e=>{a.ready?e(Wt,-1):e(Ut)}),D(Bt),R(()=>K(Bt,`data-tandem-mode`,g.tandemMode)),H(e,Bt),A()}Br([`mousedown`,`keydown`,`keyup`,`click`,`focusin`,`focusout`]);var U5=`error-boundary-recover-btn`,W5=`error-boundary-reload-btn`;function G5(e,t){k(t,!0),L(()=>{t.onSuccess()}),A()}var K5=V(`<button class="btn btn-primary svelte-1bcl6yi">Try to recover</button>`),q5=V(`<div role="alert" class="error-boundary svelte-1bcl6yi"><h2 class="svelte-1bcl6yi">Something didn't go as planned</h2> <p class="message svelte-1bcl6yi"> </p> <pre class="detail svelte-1bcl6yi"> </pre> <!> <button class="btn btn-secondary svelte-1bcl6yi">Reload</button></div>`),J5=V(`<!> <!>`,1);function Y5(e,t){k(t,!0);let n=M(0),r=M(0);var i=Xr();Rt(F(i),{onerror:e=>{eM(e,{source:`ErrorBoundary`}),N(r,z(r)+1)},failed:(e,t=m,i=m)=>{var a=Xr();ci(F(a),()=>z(r),e=>{var r=q5(),a=I(P(r),2),o=P(a,!0);D(a);var s=I(a,2),c=P(s,!0);D(s);var l=I(s,2),u=e=>{var t=K5();R(()=>K(t,`data-testid`,U5)),B(`click`,t,()=>{N(n,z(n)+1),i()()}),H(e,t)};W(l,e=>{z(n)<3&&e(u)});var d=I(l,2);D(r),R(e=>{U(o,z(n)>=3?`We weren't able to recover this time — reloading the page should get you going again.`:`The editor ran into an unexpected hiccup.`),U(c,e),K(d,`data-testid`,W5)},[()=>t()instanceof Error?t().message:String(t())]),B(`click`,d,()=>window.location.reload()),H(e,r)}),H(e,a)}},e=>{var r=J5(),i=F(r);bi(i,()=>t.children),G5(I(i,2),{onSuccess:()=>{N(n,0)}}),H(e,r)}),H(e,i),A()}Br([`click`]);function X5(e){Y5(e,{children:(e,t)=>{H5(e,{})},$$slots:{default:!0}})}Qj(),Qr(X5,{target:document.getElementById(`root`)});export{R as A,D as B,U as C,Br as D,Yr as E,M as F,j as I,A as L,F as M,I as N,B as O,N as P,k as R,W as S,V as T,t as V,K as _,Bm as a,Ui as b,Am as c,Mm as d,jm as f,$i as g,va as h,Hm as i,P as j,z as k,Rm as l,Sa as m,Um as n,Nm as o,mo as p,Wm as r,Em as s,Zm as t,Dm as u,ta as v,H as w,pi as x,G as y,O as z};
|