tandem-editor 0.20.0 → 0.20.1
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 +12 -0
- package/dist/cli/index.js +3 -3
- package/dist/client/assets/{CoworkSettings-DGehNZBr.js → CoworkSettings-CIN50SzA.js} +1 -1
- package/dist/client/assets/{dist-C8MTGBX1.js → dist-Bq041SL2.js} +1 -1
- package/dist/client/assets/{index-DpPw5n4m.js → index-9gBq7QKg.js} +5 -5
- package/dist/client/assets/{prod-DDHRjaXr.js → prod-CXXJO_PR.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/index.js +4 -4
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
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-
|
|
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-CIN50SzA.js","assets/CoworkSettings-C0m1IhNy.css","assets/dist-Bq041SL2.js","assets/prod-CXXJO_PR.js","assets/webview-C-97RVRf.js","assets/window-CR0qpD8C.js"])))=>i.map(i=>d[i]);
|
|
2
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){return e()}function _(e){for(var t=0;t<e.length;t++)e[t]()}function v(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function y(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 b=1024,x=2048,S=4096,C=8192,w=16384,T=32768,ee=1<<25,te=65536,ne=1<<19,E=1<<20,D=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(yn(Be))}function O(e){if(Re){if(yn(Be)!==null)throw Fe(),ke;Be=e}}function k(e=1){if(Re){for(var t=e,n=Be;t--;)n=yn(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=yn(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 A(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 j(e){var t=Ze,n=t.e;if(n!==null){t.e=null;for(var r of n)Fn(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=[],_(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=~(x|S|b);function st(e,t){e.f=e.f&ot|t}function ct(e){e.f&512||e.deps===null?st(e,b):st(e,S)}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,b)}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,x),t(r);for(r of n.m)st(r,S),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,x),this.schedule(e);for(let e of this.#f)st(e,S),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^=b;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^=b: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,x),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,x),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??=v()).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^=b}}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,x),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,b);for(var n=e.first;n!==null;)Pt(n,t),n=n.next}}function Ft(e){st(e,b);for(var t=e.first;t!==null;)Ft(t),t=t.next}function It(e){let t=0,n=nn(0),r;return()=>{Nn()&&(V(n),Vn(()=>(t===0&&(r=Ar(()=>e(()=>cn(n)))),t+=1,()=>{nt(()=>{--t,t===0&&(r?.(),r=void 0,cn(n))})})))}}var Lt=te|ne;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=_n();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(),V(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),k(),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|x;return cr!==null&&(cr.f|=ne),{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=v();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`))}),Pn(()=>{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 M(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,b);return}rr||(vt===null?ct(e):(Nn()||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 N(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 P(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?F(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,x,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,S);let t;try{t=xr(e)}catch{t=!0}t&&Er(e)}$t.clear()}function sn(e,t=1){var n=V(e),r=t===1?n++:n--;return P(e,n),r}function cn(e){P(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&x)===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,S,n))}else if(l){var d=s;c&16&&kt!==null&&kt.add(d),n===null?Nt(d):n.push(d)}}}}function F(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=N(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`,N(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=N(n.value,o);return r.set(t,e),e}):P(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>N(Ae,o));r.set(t,e),cn(a)}}else P(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(()=>N(F(c?t[n]:Ae),o)),r.set(n,a)),a!==void 0){var l=V(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=V(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(()=>N(i?F(e[t]):Ae,o)),r.set(t,n)),V(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(()=>N(Ae,o)),r.set(d+``,p)):P(p,Ae)}if(l===void 0)(!u||s(e,t)?.writable)&&(l=f(()=>N(void 0,o)),P(l,F(n)),r.set(t,l));else{u=l.v!==Ae;var m=f(()=>F(n));P(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&&P(g,_+1)}cn(a)}return!0},ownKeys(e){V(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 un(e){try{if(typeof e==`object`&&e&&se in e)return e[se]}catch{}return e}function dn(e,t){return Object.is(un(e),un(t))}new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);var fn,pn,mn,hn;function gn(){if(fn===void 0){fn=window,pn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;mn=s(t,`firstChild`).get,hn=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 _n(e=``){return document.createTextNode(e)}function vn(e){return mn.call(e)}function yn(e){return hn.call(e)}function I(e,t){if(!Re)return vn(e);var n=vn(Be);if(n===null)n=Be.appendChild(_n());else if(t&&n.nodeType!==3){var r=_n();return n?.before(r),Ve(r),r}return t&&Cn(n),Ve(n),n}function L(e,t=!1){if(!Re){var n=vn(e);return n instanceof Comment&&n.data===``?yn(n):n}if(t){if(Be?.nodeType!==3){var r=_n();return Be?.before(r),Ve(r),r}Cn(Be)}return Be}function R(e,t=1,n=!1){let r=Re?Be:e;for(var i;t--;)i=r,r=yn(r);if(!Re)return r;if(n){if(r?.nodeType!==3){var a=_n();return r===null?i?.after(a):r.before(a),Ve(a),a}Cn(r)}return Ve(r),r}function bn(e){e.textContent=``}function xn(){return!Je||kt!==null?!1:(cr.f&T)!==0}function Sn(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}function Cn(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 wn(e,t){if(t){let t=document.body;e.autofocus=!0,nt(()=>{document.activeElement===t&&e.focus()})}}function Tn(e){Re&&vn(e)!==null&&bn(e)}var En=!1;function Dn(){En||(En=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[me]?.()})},{capture:!0}))}function On(e){var t=ar,n=cr;sr(null),lr(null);try{return e()}finally{sr(t),lr(n)}}function kn(e,t,n,r=n){e.addEventListener(t,()=>On(n));let i=e[me];i?e[me]=()=>{i(),r(!0)}:e[me]=()=>r(!0),Dn()}function An(e){cr===null&&(ar===null&&Se(e),xe()),rr&&be(e)}function jn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Mn(e,t){var n=cr;n!==null&&n.f&8192&&(e|=C);var r={ctx:Ze,deps:null,nodes:null,f:e|x|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|=te))}if(i!==null&&(i.parent=n,n!==null&&jn(i,n),ar!==null&&ar.f&2&&!(e&64))){var a=ar;(a.effects??=[]).push(i)}return r}function Nn(){return ar!==null&&!or}function Pn(e){let t=Mn(8,null);return st(t,b),t.teardown=e,t}function z(e){An(`$effect`);var t=cr.f;if(!ar&&t&32&&!(t&32768)){var n=Ze;(n.e??=[]).push(e)}else return Fn(e)}function Fn(e){return Mn(4|E,e)}function In(e){return An(`$effect.pre`),Mn(8|E,e)}function Ln(e){Et.ensure();let t=Mn(64|ne,e);return()=>{qn(t)}}function Rn(e){Et.ensure();let t=Mn(64|ne,e);return(e={})=>new Promise(n=>{e.outro?Xn(t,()=>{qn(t),n(void 0)}):(qn(t),n(void 0))})}function zn(e){return Mn(4,e)}function Bn(e){return Mn(ae|ne,e)}function Vn(e,t=0){return Mn(8|t,e)}function B(e,t=[],n=[],r=[]){Bt(r,t,n,t=>{Mn(8,()=>e(...t.map(V)))})}function Hn(e,t=0){return Mn(16|t,e)}function Un(e){return Mn(32|ne,e)}function Wn(e){var t=e.teardown;if(t!==null){let e=rr,n=ar;ir(!0),sr(null);try{t.call(null)}finally{ir(e),sr(n)}}}function Gn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&On(()=>{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|=w;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:yn(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^=C;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^=C,e.f&1024||(st(e,x),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:yn(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,b)}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,x):o.f&1024&&st(o,S),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&&(On(()=>{e.ac.abort(he)}),e.ac=null);try{e.f|=ie;var u=e.fn,d=u();e.f|=T;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(Nn()&&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,b);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 V(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&T)===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 On(()=>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)&&Pn(()=>{t.removeEventListener(e,o,a)})}function H(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=Sn(`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 U(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=vn(i)));var t=r||pn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=vn(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=vn(Gr(a));if(i)for(o=document.createDocumentFragment();vn(e);)o.appendChild(vn(e));else o=vn(e)}var t=o.cloneNode(!0);if(i){var n=vn(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=_n(e+``);return Kr(t,t),t}var n=Be;return n.nodeType===3?Cn(n):(n.before(n=_n()),Ve(n)),Kr(n,n),n}function Xr(){if(Re)return Kr(Be,null),Be;var e=document.createDocumentFragment(),t=document.createComment(``),n=_n();return e.append(t,n),Kr(t,n),e}function W(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 G(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}){gn();var l=void 0,u=Rn(()=>{var u=n??t.appendChild(_n());Rt(u,{pending:()=>{}},t=>{A({});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;j()},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(_n()),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=xn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=_n();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 K(e,t,n=!1){var r;Re&&(r=Be,He());var i=new ni(e),a=n?te: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;bn(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|=D,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(vn(u)):u.appendChild(_n())}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^=D,_i(d,null,c)):Qn(d):Xn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Hn(()=>{p=V(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=xn(),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??=_n(),b,x,y,o,t,r),h||(S.e.f|=D),l.set(x,S)),a.add(x)}if(e===0&&s&&!d&&(h?d=Un(()=>s(c)):(d=Un(()=>s(fi??=_n())),d.f|=D)),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),V(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^=D,_===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 T=w.length;if(T>0){var ee=r&4&&s===0?n:null;if(o){for(v=0;v<T;v+=1)w[v].nodes?.a?.measure();for(v=0;v<T;v+=1)w[v].nodes?.a?.fix()}ui(e,w,ee)}}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=yn(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(vn(c)))}B(()=>{var e=cr;if(s===(s=t()??``)){Re&&He();return}if(n&&!Re){e.nodes=null,c.innerHTML=s,s!==``&&Kr(vn(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=yn(l);if(l===null)throw Fe(),ke;Kr(Be,u),o=Ve(l);return}var d=Sn(r?`svg`:i?`math`:`template`,r?Me:i?Ne:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Kr(vn(f),f.lastChild),r||i)for(;vn(f);)o.before(vn(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)))},te)}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)))},te)}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){On(()=>{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 On(()=>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 q(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(dn(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`]}),Pn(()=>{t.disconnect()})}function qi(e,t,n=t){var r=new WeakSet,i=!0;kn(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;J(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;J(e,`checked`,null),e.checked=r}}};e[me]=n,nt(n),Dn()}}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 J(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;kn(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){kn(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}function pa(e=!1){let t=Ze,n=t.l.u;if(!n)return;let r=()=>jr(t.s);if(e){let e=0,n={},i=Wt(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>V(i)}n.b.length&&In(()=>{ma(t,r),_(n.b)}),z(()=>{let e=Ar(()=>n.m.map(g));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&z(()=>{ma(t,r),_(n.a)})}function ma(e,t){if(e.l.s)for(let t of e.l.s)V(t);t()}var ha={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 ga(e,t,n){return new Proxy({props:e,exclude:t},ha)}var _a={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 va(...e){return new Proxy({props:e},_a)}function Y(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),V(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&&V(y);var b=cr;return(function(e,t){if(arguments.length>0){let n=t?V(y):i&&a?F(e):e;return P(y,n),v=!0,c!==void 0&&(c=n),e}return rr&&v||b.f&16384?y.v:V(y)})}function ya(e){Ze===null&&_e(`onMount`),Ye&&Ze.l!==null?xa(Ze).m.push(e):z(()=>{let t=Ar(e);if(typeof t==`function`)return t})}function ba(e){Ze===null&&_e(`onDestroy`),ya(()=>()=>Ar(e))}function xa(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}var Sa=3478,Ca=3479,wa=`https://github.com/bloknayrb/tandem`,Ta=`${wa}/issues/new`,Ea=`https://tandem.ink`,Da=`support@tandem.ink`,Oa=new Set([`.md`,`.txt`,`.html`,`.htm`,`.docx`]),ka=3e3,Aa=3e3,ja=3e4,Ma={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)`},Na={yellow:`var(--tandem-highlight-yellow)`,green:`var(--tandem-highlight-green)`,blue:`var(--tandem-highlight-blue)`,pink:`var(--tandem-highlight-pink)`};function Pa(e){return e&&e in Ma?e:`yellow`}var Fa=`tandem`,Ia=`tandem:mode`,La=`tandem:settings`,Ra={left:`tandem-left-panel-width`,right:`tandem-panel-width`},za=1e3,Ba=3e3,Va=`__tandem_ctrl__`,Ha=`annotations`,Ua=`awareness`,Wa=`userAwareness`,Ga=`mode`,Ka=`selectionDwellMs`,qa=`chat`,Ja=`chatSeen`,Ya=`initialized`,Xa=`chatDocumentNames`,Za=`documentMeta`,Qa=`annotationReplies`,$a=`savedAtVersion`,eo=`authorship`,to=`selection`,no=`activity`,ro=`claude`,io=`openDocuments`,ao=`activeDocumentId`,oo=`activeDocumentEpoch`,so=`storeReadOnly`,co=`fidelityReport`,lo=`tandem:showAuthorship`,uo=`tandem:decorationVisibility`,fo=`tandem:recentFiles`,po=`tandem:userName`,mo=`tandem:user-name-changed`,ho={error:8e3,warning:6e3,info:4e3},go=5*6e4,_o=`tandem:tutorialCompleted`,vo=`tutorial-`,yo=`tandem:coworkOnboardingSkipped`,bo=3e4,xo=2e3,So=`tandem:zoomLevel`,Co=.5,wo=new Set([`md`,`txt`]),To=new Set([`docx`]),Eo=new Set([...wo,...To]),Do=`/api/integrations/existing`,Oo=`/api/integrations`,ko=`/api/integrations/apply`,Ao=`/api/integrations/first-run-needed`;function jo(e){return`/api/integrations/secrets/${encodeURIComponent(e)}`}function Mo(e){return`/api/models/secrets/${encodeURIComponent(e)}`}var No=`/api/integrations/claude-cli-status`,Po=`/api/integrations/install-claude-code`,Fo=`/api/models`,Io=[`anthropic`,`openai`,`gemini`,`local-ollama`,`local-llamacpp`],Lo=[`local-ollama`,`local-llamacpp`];function Ro(e){return Lo.includes(e)}var zo=[`save`,`save-as`,`focus-chat`,`toggle-source-view`,`settings`,`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`],Bo=new Set(zo);function Vo(e){return Bo.has(e)}var Ho={save:`Save document`,"save-as":`Save As…`,"focus-chat":`Focus Chat`,"toggle-source-view":`View / exit Markdown source`,settings:`Open settings`,"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`},Uo={save:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyS`},"save-as":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyS`},"focus-chat":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyJ`},"toggle-source-view":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyE`},settings:{ctrlOrMeta:!0,alt:!1,shift:!1,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`}},Wo=[{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`}],Go={save:`save`,"save-as":`save-as`,"focus-chat":`focus-chat`,"toggle-source-view":`toggle-source-view`,settings:`settings`,"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`},Ko=/^(Control|Shift|Alt|Meta|OS)/,qo=new Set([`Tab`,`Escape`,`Enter`,`NumpadEnter`,`NumLock`,`CapsLock`,`ContextMenu`,`Insert`]);function Jo(e){return Ko.test(e.code)||e.code.startsWith(`Numpad`)||qo.has(e.code)?!1:e.ctrlOrMeta||e.alt}function Yo(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 Jo(t)?t:null}function Xo(e,t){return e.ctrlOrMeta===(t.ctrlKey||t.metaKey)&&e.alt===t.altKey&&e.shift===t.shiftKey&&e.code===t.code}function Zo(e,t){return e.ctrlOrMeta===t.ctrlOrMeta&&e.alt===t.alt&&e.shift===t.shift&&e.code===t.code}function Qo(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 $o(){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 es(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 ts(e){let t=$o(),n=[];return e.ctrlOrMeta&&n.push(t?`⌘`:`Ctrl`),e.alt&&n.push(t?`⌥`:`Alt`),e.shift&&n.push(t?`⇧`:`Shift`),n.push(es(e.code)),t?n.join(``):n.join(`+`)}function ns(e,t){return t.get(e)??Uo[e]}function rs(e){let t=new Map;for(let n of zo)t.set(n,ts(ns(n,e)));return t}function is(e,t){return t?t.has(e):!1}function as(e,t){if(e.isComposing)return null;if(t&&t.size>0)for(let n of zo){let r=t.get(n);if(r&&Xo(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`&&!is(`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`&&!is(`save-as`,t))return{id:`save-as`};if(e.code===`KeyS`&&!is(`save`,t))return{id:`save`};if(e.shiftKey&&!e.altKey&&e.code===`KeyJ`&&!is(`focus-chat`,t))return{id:`focus-chat`};if(e.shiftKey&&!e.altKey&&e.code===`KeyE`&&!is(`toggle-source-view`,t))return{id:`toggle-source-view`};if(e.shiftKey&&e.code===`KeyP`&&!is(`toggle-palette`,t))return{id:`toggle-palette`};if(e.code===`KeyN`&&!is(`new-scratchpad`,t))return{id:`new-scratchpad`};if(e.code===`KeyW`&&!is(`close-tab`,t))return{id:`close-tab`};if(e.code===`KeyO`&&!is(`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`&&!is(`toggle-mode`,t))return{id:`toggle-mode`};if(e.altKey&&e.code===`KeyT`&&!is(`reopen-closed-tab`,t))return{id:`reopen-closed-tab`};if(!e.altKey&&!e.shiftKey&&e.code===`KeyT`&&!is(`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`&&!is(`comment-on-selection`,t))return{id:`comment-on-selection`};if(e.altKey&&e.code===`KeyA`&&!is(`toggle-authorship`,t))return{id:`toggle-authorship`}}if(e.altKey&&!e.ctrlKey&&!e.metaKey){if(e.shiftKey){if(e.code===`ArrowLeft`&&!is(`toggle-left-panel`,t))return{id:`toggle-left-panel`};if(e.code===`ArrowRight`&&!is(`toggle-right-panel`,t))return{id:`toggle-right-panel`}}if(!e.shiftKey){if(e.code===`BracketRight`&&!is(`annotation-next`,t))return{id:`annotation-next`};if(e.code===`BracketLeft`&&!is(`annotation-prev`,t))return{id:`annotation-prev`}}if(!e.shiftKey&&e.code===`KeyL`&&!is(`select-block`,t))return{id:`select-block`}}return null}function ss(e){return e.code===`Slash`?e.shift?`?`:`/`:e.code===`Enter`||e.code===`NumpadEnter`?`Enter`:``}function cs(e){return{key:ss(e),code:e.code,ctrlKey:e.ctrlOrMeta,metaKey:!1,altKey:e.alt,shiftKey:e.shift,isComposing:!1}}function ls(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 us(e){let t=as(cs(e));return!t||Vo(t.id)?null:ls(t.id,t.context)||null}function ds(e,t,n){for(let r of zo)if(r!==n&&Zo(ns(r,t),e))return Ho[r];let r=us(e);if(r)return r;for(let t of Wo)if(Zo(t.chord,e))return t.label;return null}function fs(e){return Wo.some(t=>Zo(t.chord,e))}function ps(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Vo(n)&&Qo(r)&&Jo(r)&&(fs(r)||us(r)||(t[n]=r));let n={},r=[];for(let e of zo){let i=t[e];i&&(r.some(e=>Zo(e,i))||(r.push(i),n[e]=i))}return n}function ms(e){let t=new Map;for(let[n,r]of Object.entries(ps(e)))t.set(n,r);return t}var hs=[`narrow`,`comfortable`,`wide`,`full`],gs={narrow:`58ch`,comfortable:`68ch`,wide:`82ch`,full:`100%`};function _s(e){return typeof e==`string`&&hs.includes(e)}var vs=50,ys={s:14,m:16,l:18};function bs(){try{return typeof window>`u`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}var xs={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:18,primaryTab:`annotations`,panelOrder:`chat-editor-annotations`,editorMeasure:`comfortable`,selectionDwellMs:za,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:{},smartTypography:!1,spellcheck:!0,uniformTabWidth:!0},Ss=64,Cs=512;function ws(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(t.length>=vs)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`||!Io.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<=Ss&&/^[A-Za-z0-9_-]+$/.test(e.apiKeyRef)?r.apiKeyRef=e.apiKeyRef:typeof e.apiKey==`string`&&e.apiKey.length<=Cs&&(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 Ts=[`serif`,`sans`,`mono`];function Es(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`&&Ts.includes(r)&&(t[n]=r);return t}function Ds(e){return{leftPanelVisible:e.leftPanelVisible===!0,rightPanelVisible:e.rightPanelVisible!==!1,schemaVersion:18,primaryTab:e.primaryTab===`annotations`?`annotations`:`chat`,panelOrder:e.panelOrder===`annotations-editor-chat`?`annotations-editor-chat`:`chat-editor-annotations`,editorMeasure:_s(e.editorMeasure)?e.editorMeasure:xs.editorMeasure,selectionDwellMs:Math.max(500,Math.min(Ba,Number(e.selectionDwellMs)||1e3)),showAuthorship:e.showAuthorship===!1?!1:xs.showAuthorship,reduceMotion:typeof e.reduceMotion==`boolean`?e.reduceMotion:bs(),textSize:e.textSize===`s`||e.textSize===`m`||e.textSize===`l`?e.textSize:xs.textSize,theme:e.theme===`light`||e.theme===`dark`||e.theme===`warm`||e.theme===`system`?e.theme:xs.theme,systemLightVariant:e.systemLightVariant===`warm`?`warm`:xs.systemLightVariant,accentHue:typeof e.accentHue==`number`&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:xs.accentHue,editorFont:e.editorFont===`serif`||e.editorFont===`sans`||e.editorFont===`mono`?e.editorFont:xs.editorFont,fontByExtension:Es(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:xs.density,defaultMode:e.defaultMode===`solo`||e.defaultMode===`tandem`?e.defaultMode:xs.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:xs.selectionToolbar,formattingBarVisible:e.formattingBarVisible===!1?!1:xs.formattingBarVisible,railHoverReveal:e.railHoverReveal===!1?!1:xs.railHoverReveal,soloRailHidden:e.soloRailHidden===!1?!1:xs.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs==`number`&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:xs.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy===`exponential`||e.sidecarRetryStrategy===`constant-2s`?e.sidecarRetryStrategy:xs.sidecarRetryStrategy,marginView:e.marginView===!0,showComments:e.showComments===!1?!1:xs.showComments,showHighlights:e.showHighlights===!1?!1:xs.showHighlights,showNotes:e.showNotes===!1?!1:xs.showNotes,showRawMarkdown:e.showRawMarkdown===!1?!1:xs.showRawMarkdown,decorationsMuted:e.decorationsMuted===!0,models:ws(e.models),defaultModelId:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null,customShortcuts:ps(e.customShortcuts),smartTypography:e.smartTypography===!0,spellcheck:e.spellcheck===!1?!1:xs.spellcheck,uniformTabWidth:e.uniformTabWidth===!1?!1:xs.uniformTabWidth}}function Os(){let e;try{e=localStorage.getItem(La)}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(t.schemaVersion===16&&(t={...t,schemaVersion:17}),t.schemaVersion===17&&(t={...t,schemaVersion:18}),typeof t.schemaVersion==`number`&&t.schemaVersion>18){console.warn(`[tandem] settings schemaVersion=${t.schemaVersion} is newer than v18; loading defensively without writing.`);let e=t.editorMeasure,n=Ds(t);typeof e==`string`&&e!==n.editorMeasure&&console.warn(`[tandem] editorMeasure=${JSON.stringify(e)} from newer client is unknown to v18; 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 Ds(t)}catch(e){console.warn(`[tandem] settings JSON is corrupt, resetting to defaults:`,e)}return{...xs,reduceMotion:bs()}}function ks(e,t){let n={...e,...t},r=ws(n.models);return{...n,customShortcuts:ps(n.customShortcuts),fontByExtension:Es(n.fontByExtension),defaultSaveDirectory:typeof n.defaultSaveDirectory==`string`&&n.defaultSaveDirectory.trim()?n.defaultSaveDirectory.trim():null,selectionDwellMs:Math.max(500,Math.min(Ba,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):xs.accentHue,editorMeasure:_s(n.editorMeasure)?n.editorMeasure:xs.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 As(e,t){if(t){let n=e.fontByExtension?.[t];if(n)return n}return e.editorFont}function js(e){let t={id:e.id,provider:e.provider,displayName:e.displayName,modelId:e.modelId,enabled:e.enabled};return e.apiKeyRef!==void 0&&(t.apiKeyRef=e.apiKeyRef),e.endpoint!==void 0&&(t.endpoint=e.endpoint),e.params!==void 0&&(t.params=e.params),t}function Ms(e,t){return{schemaVersion:1,models:e.map(js),defaultModelId:t}}var Ns=`http://127.0.0.1:${Ca}`;function Ps(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function Fs(e){return e.toLowerCase().endsWith(`.docx`)}async function Is(e){return Fs(e.name)?Ps(await e.arrayBuffer()):e.text()}var Ls=`tandem:models-reconciled-to-server-v2`,Rs=!1,zs=`skipped`;async function eee(){if(Rs)return zs;Rs=!0;try{if(localStorage.getItem(`tandem:models-reconciled-to-server-v2`)===`1`)return zs=`skipped`;let e=Os();if(e._readOnly)return zs=`skipped`;let t=e.models??[];if(t.length===0)return zs=`skipped`;let n=await fetch(`${Ns}${Fo}`,{method:`GET`});if(!n.ok)throw Error(`GET ${Fo} → ${n.status}`);let{etag:r}=await n.json(),i={file:Ms(t,e.defaultModelId??null),ifMatch:r},a=await fetch(`${Ns}${Fo}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(a.ok||a.status===409)return localStorage.setItem(Ls,`1`),zs=`reconciled`;let o=await a.json().then(e=>e?.code).catch(()=>void 0);return console.warn(`[tandem] model-registry reconcile POST failed (status ${a.status}${o?`, ${o}`:``}); will retry next boot.`),zs=`failed`}catch(e){return console.warn(`[tandem] model-registry reconcile errored; will retry next boot.`,e),zs=`failed`}}function Bs(e){return e?e.osSupported?e.coworkDetected?`normal`:`undetected`:`unsupported`:`loading`}function Vs(e){return e.claudeDesktopDetected??!1?(e.workspacesBlocked??0)>0?`blocked`:`noWorkspacesYet`:`noClaude`}function Hs(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: ${Us(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 Us(e){let t=e.trim();return t.length===0?`(no output)`:t.length<=200?t:`${t.slice(0,197)}...`}function Ws(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`kind`in t&&typeof t.kind==`string`)try{return Hs(t)}catch(n){return console.error(`[cowork] firewallErrorHint failed for:`,t,n),e}return e}catch{return e}}function Gs(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 Ks(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 qs(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 Js(e){let t=e=>e===`ok`||e===`alreadyPresent`;return t(e.installedPlugins)&&t(e.knownMarketplaces)&&t(e.coworkSettings)}function Ys(e){if(!e||!e.enabled)return`not-applicable`;let t=e.workspaces??[];return t.some(Js)?`reachable`:t.some(e=>Ks(qs(e))===`error`)?`unreachable`:`pending`}function Xs(e){switch(e){case`reachable`:return{title:`Tandem is reachable from Cowork`,detail:`At least one Cowork workspace has the Tandem plugin installed — a Cowork session can find and load it.`,family:`success`};case`unreachable`:return{title:`Tandem isn't reachable yet`,detail:`Cowork is enabled, but a workspace install didn't complete. Re-scan workspaces, or restart Claude Desktop and re-enable.`,family:`error`};case`pending`:return{title:`Waiting for a Cowork session`,detail:`Cowork is enabled. The Tandem plugin installs into a workspace the first time you open a Cowork session.`,family:`warning`};case`not-applicable`:return{title:``,detail:``,family:`neutral`}}}function Zs(e,t){return!(!e||t||!e.osSupported||!e.coworkDetected||e.enabled)}function Qs(){try{return localStorage.getItem(yo)===`true`}catch{return!1}}function $s(){try{localStorage.setItem(yo,`true`)}catch{}}function ec(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}function tc(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 nc=`modulepreload`,rc=function(e){return`/`+e},ic={},ac=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=rc(t,n),t in ic)return;ic[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`:nc,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)})},oc=`Tauri runtime not available`;async function sc(){try{return(await ac(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return ec()&&console.error(`[keychain] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(oc)))}}function cc(e,t,n){return e(`keychain_set`,{account:t,secret:n})}function lc(e,t){return e(`keychain_delete`,{account:t})}function uc(e={}){let t=e.fetchFn??((...e)=>globalThis.fetch(...e)),n=e.baseUrl??``,r=e.pathFor??jo;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 dc=[`keychain-init`,`Platform secure storage failure`,`Couldn't access platform secure storage`];function fc(e){return dc.some(t=>e.includes(t))}function pc(e={}){let t=()=>e.invoke?Promise.resolve(e.invoke):sc();return{async set(e,n){try{return await cc(await t(),e,n),{status:`ok`}}catch(e){let t=e instanceof Error?e.message:String(e);return fc(t)?{status:`unavailable`}:{status:`error`,message:t}}},async delete(e){try{await lc(await t(),e)}catch{}}}}function mc(e={}){return e.force===`tauri`||e.force!==`http`&&ec()?pc({invoke:e.invoke}):uc({fetchFn:e.fetchFn,baseUrl:e.baseUrl,pathFor:e.pathFor})}var hc=N(F([])),gc=N(null),_c=null,vc=N(null),yc=N(!1),bc=N(!1),xc=null,Sc=new Promise(e=>{xc=e});function Cc(){xc?.()}var wc=mc({baseUrl:`http://127.0.0.1:${Ca}`,pathFor:Mo});function Tc(){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 Ec(){return crypto.randomUUID()}function Dc(e){if(e.provider!==void 0&&!Io.includes(e.provider))throw Error(`Invalid model provider: ${String(e.provider)}`)}async function Oc(e,t){let n=await wc.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})`)}var kc=3,Ac=25;function jc(e){return new Promise(t=>setTimeout(t,e))}async function Mc(){let e={file:Ms(V(hc),V(gc)),ifMatch:_c??``},t=await fetch(`${Ns}${Fo}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(t.ok)return{ok:!0,etag:(await t.json()).etag};let n=await t.json().catch(()=>({}));return t.status===409&&n.code===`MODELS_STALE`?{ok:!1,kind:`stale`}:t.status===429&&n.code===`MODELS_BUSY`?{ok:!1,kind:`busy`}:{ok:!1,kind:`failed`}}async function Nc(){let e=await Mc();for(let t=1;t<kc&&!e.ok&&e.kind===`busy`;t++)await jc(Ac),e=await Mc();return e}var Pc=Promise.resolve();async function Fc(e){let t=Pc.then(async()=>{let t=e=>(_c=e,P(vc,null),`committed`),n={models:V(hc),defaultModelId:V(gc),etag:_c},r=e=>(P(hc,n.models,!0),P(gc,n.defaultModelId,!0),_c=n.etag,P(vc,e,!0),`rolledback`);e(),await Sc;try{let n=await Nc();if(n.ok)return t(n.etag);if(n.kind===`stale`){await Ic(),e();let n=await Nc();return n.ok?t(n.etag):(await Ic(),P(vc,`Model registry changed elsewhere; reloaded.`),`reconciled`)}return r(n.kind===`busy`?`Model registry is busy; please try again.`:`Failed to save model changes.`)}catch(e){return console.warn(`[models] write-through failed`,e),r(`Failed to save model changes.`)}});return Pc=t.then(()=>void 0,()=>void 0),t}async function Ic(){let e=await fetch(`${Ns}${Fo}`,{method:`GET`});if(!e.ok)throw Error(`GET ${Fo} → ${e.status}`);let{file:t,etag:n}=await e.json();P(hc,t.models,!0),P(gc,t.defaultModelId,!0),_c=n}function Lc(){return Promise.resolve()}function Rc(){return Lc()}async function zc(){try{await eee()}finally{Cc()}await Lc()}function Bc(){{let e=Os();return{models:e.models,defaultModelId:e.defaultModelId}}return{models:V(hc),defaultModelId:V(gc)}}function Vc(){return{get models(){return V(hc)},get defaultModelId(){return V(gc)},get saveError(){return V(vc)},get loading(){return V(yc)},get loadFailed(){return V(bc)},async addModel(e,t){Dc(e);let n=Ec(),r;t&&t.length>0&&(r=Tc(),await Oc(r,t));let i={...e,id:n,...r?{apiKeyRef:r}:{}},a=await Fc(()=>{P(hc,[...V(hc),i],!0)});return r&&a!==`committed`&&await wc.delete(r),a===`committed`?n:null},async updateModel(e,t,n){Dc(t);let r=V(hc).find(t=>t.id===e);if(!r)return!1;let i;n!==void 0&&n.length>0&&(i=Tc(),await Oc(i,n));let a=await Fc(()=>{P(hc,V(hc).map(n=>n.id===e?{...n,...t,...i?{apiKeyRef:i}:{}}:n),!0)});return i&&(a===`committed`&&V(hc).some(t=>t.id===e&&t.apiKeyRef===i)?r.apiKeyRef&&await wc.delete(r.apiKeyRef):await wc.delete(i)),a===`committed`},async deleteModel(e){let t=V(hc).find(t=>t.id===e)?.apiKeyRef,n=await Fc(()=>{P(hc,V(hc).filter(t=>t.id!==e),!0),V(gc)===e&&P(gc,null)});t&&n===`committed`&&await wc.delete(t)},async toggleEnabled(e){let t=!V(hc).find(t=>t.id===e)?.enabled;await Fc(()=>{P(hc,V(hc).map(n=>n.id===e?{...n,enabled:t}:n),!0)})},async setDefault(e){return await Fc(()=>{P(gc,e,!0)})===`committed`},reload:Rc,clearError(){P(vc,null)}}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`),Xe();var Hc=`/api/notify-stream`,Uc=`/api/mode/release`,Wc=`/api/info`,Gc=`/api/diagnostics`,Kc=`/health`,qc=`/api/open`,Jc=`/api/close`,Yc=`/api/save`,Xc=`/api/rename`,Zc=`/api/upload`,Qc=`/api/scratchpad`,$c=`/api/convert`,el=`/api/apply-changes`,tl=`/api/document/raw`,nl=`/api/document/reload`,rl=`/api/backups`,il=`/api/backups/restore`,al=`/api/external-conflict/resolve`,ol=`/api/annotation-reply`,sl=`/api/remove-annotation`,cl=`/api/store/reclaim-lock`,ll=`/api/chat`,ul=`/api/sessions`,dl=`/api/sessions/delete`,fl=`/api/sessions/clear`,pl=`/api/license/status`,ml=`/api/license/activate`,hl=`/api/launcher/status`,gl=`/api/launcher/nonce`,_l=`/api/launcher/relaunch`,vl=`/api/launcher/start-fresh`,yl=`/api/launcher/working-directory`,bl=`upload://`,xl=`upload://scratchpad/`;function Sl(e){return e.startsWith(bl)}function Cl(e){return e.startsWith(xl)}function wl(e){if(!Cl(e))return null;let t=e.slice(20).split(`/`)[0];return t.length>0?t:null}var Tl=e=>e,El=e=>e,Dl;(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})(Dl||={});var Ol;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Ol||={});var kl=Dl.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Al=e=>{switch(typeof e){case`undefined`:return kl.undefined;case`string`:return kl.string;case`number`:return Number.isNaN(e)?kl.nan:kl.number;case`boolean`:return kl.boolean;case`function`:return kl.function;case`bigint`:return kl.bigint;case`symbol`:return kl.symbol;case`object`:return Array.isArray(e)?kl.array:e===null?kl.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?kl.promise:typeof Map<`u`&&e instanceof Map?kl.map:typeof Set<`u`&&e instanceof Set?kl.set:typeof Date<`u`&&e instanceof Date?kl.date:kl.object;default:return kl.unknown}},X=Dl.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`]),jl=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,Dl.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()}};jl.create=e=>new jl(e);var Ml=(e,t)=>{let n;switch(e.code){case X.invalid_type:n=e.received===kl.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case X.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Dl.jsonStringifyReplacer)}`;break;case X.unrecognized_keys:n=`Unrecognized key(s) in object: ${Dl.joinValues(e.keys,`, `)}`;break;case X.invalid_union:n=`Invalid input`;break;case X.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Dl.joinValues(e.options)}`;break;case X.invalid_enum_value:n=`Invalid enum value. Expected ${Dl.joinValues(e.options)}, received '${e.received}'`;break;case X.invalid_arguments:n=`Invalid function arguments`;break;case X.invalid_return_type:n=`Invalid function return type`;break;case X.invalid_date:n=`Invalid date`;break;case X.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}"`:Dl.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case X.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 X.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 X.custom:n=`Invalid input`;break;case X.invalid_intersection_types:n=`Intersection results could not be merged`;break;case X.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case X.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,Dl.assertNever(e)}return{message:n}},Nl=Ml;function Pl(){return Nl}var Fl=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 Il(e,t){let n=Pl(),r=Fl({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ml?void 0:Ml].filter(e=>!!e)});e.common.issues.push(r)}var Ll=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 Rl;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 Rl;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}}},Rl=Object.freeze({status:`aborted`}),zl=e=>({status:`dirty`,value:e}),Bl=e=>({status:`valid`,value:e}),Vl=e=>e.status===`aborted`,Hl=e=>e.status===`dirty`,Ul=e=>e.status===`valid`,Wl=e=>typeof Promise<`u`&&e instanceof Promise,Gl;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Gl||={});var Kl=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}},ql=(e,t)=>{if(Ul(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 jl(e.common.issues);return this._error=t,this._error}}};function Jl(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 Yl=class{get description(){return this._def.description}_getType(e){return Al(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Al(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ll,ctx:{common:e.parent.common,data:e.data,parsedType:Al(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Wl(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:Al(e)};return ql(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:Al(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ul(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=>Ul(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:Al(e)},r=this._parse({data:e,path:n.path,parent:n});return ql(n,await(Wl(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:X.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 Qu({schema:this,typeName:sd.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 $u.create(this,this._def)}nullable(){return ed.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Nu.create(this)}promise(){return Zu.create(this,this._def)}or(e){return Iu.create([this,e],this._def)}and(e){return Bu.create(this,e,this._def)}transform(e){return new Qu({...Jl(this._def),schema:this,typeName:sd.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new td({...Jl(this._def),innerType:this,defaultValue:t,typeName:sd.ZodDefault})}brand(){return new id({typeName:sd.ZodBranded,type:this,...Jl(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new nd({...Jl(this._def),innerType:this,catchValue:t,typeName:sd.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ad.create(this,e)}readonly(){return od.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Xl=/^c[^\s-]{8,}$/i,Zl=/^[0-9a-z]+$/,Ql=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$l=/^[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,eu=/^[a-z0-9_-]{21}$/i,tu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,nu=/^[-+]?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)?)??$/,ru=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,iu=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,au,ou=/^(?:(?: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])$/,su=/^(?:(?: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])$/,cu=/^(([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]))$/,lu=/^(([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])$/,uu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,du=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,fu=`((\\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])))`,pu=RegExp(`^${fu}$`);function mu(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 hu(e){return RegExp(`^${mu(e)}$`)}function gu(e){let t=`${fu}T${mu(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function _u(e,t){return!!((t===`v4`||!t)&&ou.test(e)||(t===`v6`||!t)&&cu.test(e))}function vu(e,t){if(!tu.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 yu(e,t){return!!((t===`v4`||!t)&&su.test(e)||(t===`v6`||!t)&&lu.test(e))}var bu=class e extends Yl{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==kl.string){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.string,received:t.parsedType}),Rl}let t=new Ll,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),Il(n,{code:X.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),Il(n,{code:X.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?Il(n,{code:X.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&Il(n,{code:X.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)ru.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`email`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)au||=new RegExp(iu,`u`),au.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`emoji`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)$l.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`uuid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)eu.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`nanoid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Xl.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`cuid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Zl.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`cuid2`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Ql.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`ulid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),Il(n,{validation:`url`,code:X.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),Il(n,{validation:`regex`,code:X.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),Il(n,{code:X.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),Il(n,{code:X.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),Il(n,{code:X.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?gu(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{code:X.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?pu.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{code:X.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?hu(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{code:X.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?nu.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`duration`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?_u(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`ip`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?vu(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`jwt`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?yu(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`cidr`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?uu.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`base64`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?du.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`base64url`,code:X.invalid_string,message:r.message}),t.dirty()):Dl.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:X.invalid_string,...Gl.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Gl.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Gl.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Gl.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Gl.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Gl.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Gl.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Gl.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Gl.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Gl.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Gl.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Gl.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Gl.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Gl.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,...Gl.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,...Gl.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Gl.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Gl.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Gl.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Gl.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Gl.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Gl.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Gl.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Gl.errToObj(t)})}nonempty(e){return this.min(1,Gl.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}};bu.create=e=>new bu({checks:[],typeName:sd.ZodString,coerce:e?.coerce??!1,...Jl(e)});function xu(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 Su=class e extends Yl{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)!==kl.number){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.number,received:t.parsedType}),Rl}let t,n=new Ll;for(let r of this._def.checks)r.kind===`int`?Dl.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Il(t,{code:X.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),Il(t,{code:X.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),Il(t,{code:X.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?xu(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),Il(t,{code:X.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Il(t,{code:X.not_finite,message:r.message}),n.dirty()):Dl.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Gl.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Gl.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Gl.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Gl.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Gl.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Gl.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Gl.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Gl.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Gl.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Gl.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Gl.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Gl.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Gl.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Gl.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`&&Dl.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)}};Su.create=e=>new Su({checks:[],typeName:sd.ZodNumber,coerce:e?.coerce||!1,...Jl(e)});var Cu=class e extends Yl{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)!==kl.bigint)return this._getInvalidInput(e);let t,n=new Ll;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),Il(t,{code:X.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),Il(t,{code:X.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),Il(t,{code:X.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Dl.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.bigint,received:t.parsedType}),Rl}gte(e,t){return this.setLimit(`min`,e,!0,Gl.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Gl.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Gl.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Gl.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Gl.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:Gl.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Gl.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Gl.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Gl.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Gl.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}};Cu.create=e=>new Cu({checks:[],typeName:sd.ZodBigInt,coerce:e?.coerce??!1,...Jl(e)});var wu=class extends Yl{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==kl.boolean){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.boolean,received:t.parsedType}),Rl}return Bl(e.data)}};wu.create=e=>new wu({typeName:sd.ZodBoolean,coerce:e?.coerce||!1,...Jl(e)});var Tu=class e extends Yl{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==kl.date){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.date,received:t.parsedType}),Rl}if(Number.isNaN(e.data.getTime()))return Il(this._getOrReturnCtx(e),{code:X.invalid_date}),Rl;let t=new Ll,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),Il(n,{code:X.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),Il(n,{code:X.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):Dl.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:Gl.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Gl.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)}};Tu.create=e=>new Tu({checks:[],coerce:e?.coerce||!1,typeName:sd.ZodDate,...Jl(e)});var Eu=class extends Yl{_parse(e){if(this._getType(e)!==kl.symbol){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.symbol,received:t.parsedType}),Rl}return Bl(e.data)}};Eu.create=e=>new Eu({typeName:sd.ZodSymbol,...Jl(e)});var Du=class extends Yl{_parse(e){if(this._getType(e)!==kl.undefined){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.undefined,received:t.parsedType}),Rl}return Bl(e.data)}};Du.create=e=>new Du({typeName:sd.ZodUndefined,...Jl(e)});var Ou=class extends Yl{_parse(e){if(this._getType(e)!==kl.null){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.null,received:t.parsedType}),Rl}return Bl(e.data)}};Ou.create=e=>new Ou({typeName:sd.ZodNull,...Jl(e)});var ku=class extends Yl{constructor(){super(...arguments),this._any=!0}_parse(e){return Bl(e.data)}};ku.create=e=>new ku({typeName:sd.ZodAny,...Jl(e)});var Au=class extends Yl{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Bl(e.data)}};Au.create=e=>new Au({typeName:sd.ZodUnknown,...Jl(e)});var ju=class extends Yl{_parse(e){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.never,received:t.parsedType}),Rl}};ju.create=e=>new ju({typeName:sd.ZodNever,...Jl(e)});var Mu=class extends Yl{_parse(e){if(this._getType(e)!==kl.undefined){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.void,received:t.parsedType}),Rl}return Bl(e.data)}};Mu.create=e=>new Mu({typeName:sd.ZodVoid,...Jl(e)});var Nu=class e extends Yl{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==kl.array)return Il(t,{code:X.invalid_type,expected:kl.array,received:t.parsedType}),Rl;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(Il(t,{code:e?X.too_big:X.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&&(Il(t,{code:X.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&&(Il(t,{code:X.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 Kl(t,e,t.path,n)))).then(e=>Ll.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Kl(t,e,t.path,n)));return Ll.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Gl.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Gl.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Gl.toString(n)}})}nonempty(e){return this.min(1,e)}};Nu.create=(e,t)=>new Nu({type:e,minLength:null,maxLength:null,exactLength:null,typeName:sd.ZodArray,...Jl(t)});function Pu(e){if(e instanceof Fu){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=$u.create(Pu(r))}return new Fu({...e._def,shape:()=>t})}else if(e instanceof Nu)return new Nu({...e._def,type:Pu(e.element)});else if(e instanceof $u)return $u.create(Pu(e.unwrap()));else if(e instanceof ed)return ed.create(Pu(e.unwrap()));else if(e instanceof Vu)return Vu.create(e.items.map(e=>Pu(e)));else return e}var Fu=class e extends Yl{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=Dl.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==kl.object){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.object,received:t.parsedType}),Rl}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ju&&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 Kl(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ju){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&&(Il(n,{code:X.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 Kl(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=>Ll.mergeObjectSync(t,e)):Ll.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Gl.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:Gl.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:sd.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 Dl.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 Dl.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Pu(this)}partial(t){let n={};for(let e of Dl.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 Dl.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof $u;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Ju(Dl.objectKeys(this.shape))}};Fu.create=(e,t)=>new Fu({shape:()=>e,unknownKeys:`strip`,catchall:ju.create(),typeName:sd.ZodObject,...Jl(t)}),Fu.strictCreate=(e,t)=>new Fu({shape:()=>e,unknownKeys:`strict`,catchall:ju.create(),typeName:sd.ZodObject,...Jl(t)}),Fu.lazycreate=(e,t)=>new Fu({shape:e,unknownKeys:`strip`,catchall:ju.create(),typeName:sd.ZodObject,...Jl(t)});var Iu=class extends Yl{_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 jl(e.ctx.common.issues));return Il(t,{code:X.invalid_union,unionErrors:n}),Rl}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 jl(e));return Il(t,{code:X.invalid_union,unionErrors:i}),Rl}}get options(){return this._def.options}};Iu.create=(e,t)=>new Iu({options:e,typeName:sd.ZodUnion,...Jl(t)});var Lu=e=>e instanceof Ku?Lu(e.schema):e instanceof Qu?Lu(e.innerType()):e instanceof qu?[e.value]:e instanceof Yu?e.options:e instanceof Xu?Dl.objectValues(e.enum):e instanceof td?Lu(e._def.innerType):e instanceof Du?[void 0]:e instanceof Ou?[null]:e instanceof $u?[void 0,...Lu(e.unwrap())]:e instanceof ed?[null,...Lu(e.unwrap())]:e instanceof id||e instanceof od?Lu(e.unwrap()):e instanceof nd?Lu(e._def.innerType):[],Ru=class e extends Yl{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==kl.object)return Il(t,{code:X.invalid_type,expected:kl.object,received:t.parsedType}),Rl;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}):(Il(t,{code:X.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Rl)}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=Lu(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:sd.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Jl(r)})}};function zu(e,t){let n=Al(e),r=Al(t);if(e===t)return{valid:!0,data:e};if(n===kl.object&&r===kl.object){let n=Dl.objectKeys(t),r=Dl.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=zu(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===kl.array&&r===kl.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=zu(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===kl.date&&r===kl.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Bu=class extends Yl{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Vl(e)||Vl(r))return Rl;let i=zu(e.value,r.value);return i.valid?((Hl(e)||Hl(r))&&t.dirty(),{status:t.value,value:i.data}):(Il(n,{code:X.invalid_intersection_types}),Rl)};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}))}};Bu.create=(e,t,n)=>new Bu({left:e,right:t,typeName:sd.ZodIntersection,...Jl(n)});var Vu=class e extends Yl{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==kl.array)return Il(n,{code:X.invalid_type,expected:kl.array,received:n.parsedType}),Rl;if(n.data.length<this._def.items.length)return Il(n,{code:X.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),Rl;!this._def.rest&&n.data.length>this._def.items.length&&(Il(n,{code:X.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 Kl(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Ll.mergeArray(t,e)):Ll.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Vu.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Vu({items:e,typeName:sd.ZodTuple,rest:null,...Jl(t)})};var Hu=class e extends Yl{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!==kl.object)return Il(n,{code:X.invalid_type,expected:kl.object,received:n.parsedType}),Rl;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Kl(n,e,n.path,e)),value:a._parse(new Kl(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Ll.mergeObjectAsync(t,r):Ll.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Yl?new e({keyType:t,valueType:n,typeName:sd.ZodRecord,...Jl(r)}):new e({keyType:bu.create(),valueType:t,typeName:sd.ZodRecord,...Jl(n)})}},Uu=class extends Yl{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!==kl.map)return Il(n,{code:X.invalid_type,expected:kl.map,received:n.parsedType}),Rl;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Kl(n,e,n.path,[a,`key`])),value:i._parse(new Kl(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 Rl;(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 Rl;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Uu.create=(e,t,n)=>new Uu({valueType:t,keyType:e,typeName:sd.ZodMap,...Jl(n)});var Wu=class e extends Yl{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==kl.set)return Il(n,{code:X.invalid_type,expected:kl.set,received:n.parsedType}),Rl;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(Il(n,{code:X.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&&(Il(n,{code:X.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 Rl;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 Kl(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:Gl.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Gl.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Wu.create=(e,t)=>new Wu({valueType:e,minSize:null,maxSize:null,typeName:sd.ZodSet,...Jl(t)});var Gu=class e extends Yl{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==kl.function)return Il(t,{code:X.invalid_type,expected:kl.function,received:t.parsedType}),Rl;function n(e,n){return Fl({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pl(),Ml].filter(e=>!!e),issueData:{code:X.invalid_arguments,argumentsError:n}})}function r(e,n){return Fl({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pl(),Ml].filter(e=>!!e),issueData:{code:X.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Zu){let e=this;return Bl(async function(...t){let o=new jl([]),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 Bl(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new jl([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new jl([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:Vu.create(t).rest(Au.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||Vu.create([]).rest(Au.create()),returns:n||Au.create(),typeName:sd.ZodFunction,...Jl(r)})}},Ku=class extends Yl{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})}};Ku.create=(e,t)=>new Ku({getter:e,typeName:sd.ZodLazy,...Jl(t)});var qu=class extends Yl{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return Il(t,{received:t.data,code:X.invalid_literal,expected:this._def.value}),Rl}return{status:`valid`,value:e.data}}get value(){return this._def.value}};qu.create=(e,t)=>new qu({value:e,typeName:sd.ZodLiteral,...Jl(t)});function Ju(e,t){return new Yu({values:e,typeName:sd.ZodEnum,...Jl(t)})}var Yu=class e extends Yl{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return Il(t,{expected:Dl.joinValues(n),received:t.parsedType,code:X.invalid_type}),Rl}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return Il(t,{received:t.data,code:X.invalid_enum_value,options:n}),Rl}return Bl(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})}};Yu.create=Ju;var Xu=class extends Yl{_parse(e){let t=Dl.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==kl.string&&n.parsedType!==kl.number){let e=Dl.objectValues(t);return Il(n,{expected:Dl.joinValues(e),received:n.parsedType,code:X.invalid_type}),Rl}if(this._cache||=new Set(Dl.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=Dl.objectValues(t);return Il(n,{received:n.data,code:X.invalid_enum_value,options:e}),Rl}return Bl(e.data)}get enum(){return this._def.values}};Xu.create=(e,t)=>new Xu({values:e,typeName:sd.ZodNativeEnum,...Jl(t)});var Zu=class extends Yl{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==kl.promise&&t.common.async===!1?(Il(t,{code:X.invalid_type,expected:kl.promise,received:t.parsedType}),Rl):Bl((t.parsedType===kl.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Zu.create=(e,t)=>new Zu({type:e,typeName:sd.ZodPromise,...Jl(t)});var Qu=class extends Yl{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===sd.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=>{Il(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 Rl;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?Rl:r.status===`dirty`||t.value===`dirty`?zl(r.value):r});{if(t.value===`aborted`)return Rl;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?Rl:r.status===`dirty`||t.value===`dirty`?zl(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`?Rl:(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`?Rl:(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(!Ul(e))return Rl;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=>Ul(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):Rl);Dl.assertNever(r)}};Qu.create=(e,t,n)=>new Qu({schema:e,typeName:sd.ZodEffects,effect:t,...Jl(n)}),Qu.createWithPreprocess=(e,t,n)=>new Qu({schema:t,effect:{type:`preprocess`,transform:e},typeName:sd.ZodEffects,...Jl(n)});var $u=class extends Yl{_parse(e){return this._getType(e)===kl.undefined?Bl(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$u.create=(e,t)=>new $u({innerType:e,typeName:sd.ZodOptional,...Jl(t)});var ed=class extends Yl{_parse(e){return this._getType(e)===kl.null?Bl(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ed.create=(e,t)=>new ed({innerType:e,typeName:sd.ZodNullable,...Jl(t)});var td=class extends Yl{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===kl.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};td.create=(e,t)=>new td({innerType:e,typeName:sd.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...Jl(t)});var nd=class extends Yl{_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 Wl(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new jl(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new jl(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};nd.create=(e,t)=>new nd({innerType:e,typeName:sd.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...Jl(t)});var rd=class extends Yl{_parse(e){if(this._getType(e)!==kl.nan){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.nan,received:t.parsedType}),Rl}return{status:`valid`,value:e.data}}};rd.create=e=>new rd({typeName:sd.ZodNaN,...Jl(e)});var id=class extends Yl{_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}},ad=class e extends Yl{_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`?Rl:e.status===`dirty`?(t.dirty(),zl(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`?Rl: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:sd.ZodPipeline})}},od=class extends Yl{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ul(e)&&(e.value=Object.freeze(e.value)),e);return Wl(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};od.create=(e,t)=>new od({innerType:e,typeName:sd.ZodReadonly,...Jl(t)}),Fu.lazycreate;var sd;(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`})(sd||={});var cd=bu.create;Su.create,rd.create,Cu.create,wu.create,Tu.create,Eu.create,Du.create,Ou.create,ku.create,Au.create,ju.create,Mu.create,Nu.create;var ld=Fu.create;Fu.strictCreate,Iu.create,Ru.create,Bu.create,Vu.create,Hu.create,Uu.create,Wu.create,Gu.create,Ku.create,qu.create;var ud=Yu.create;Xu.create,Zu.create,Qu.create,$u.create,ed.create,Qu.createWithPreprocess,ad.create,ud([`highlight`,`note`,`comment`]),ud([`pending`,`accepted`,`dismissed`]),ud([`yellow`,`green`,`blue`,`pink`]),ud([`info`,`warning`,`error`,`success`]);var dd=ud([`solo`,`tandem`]);ud([`user`,`claude`,`import`]),ud([`user`,`claude`,`import`]),ld({provider:ud(Io),displayName:cd().max(120)}),ud([`accept`,`dismiss`]),ud([`markdown`,`json`]),ud([`md`,`txt`,`html`,`docx`]),ud([`RANGE_GONE`,`RANGE_MOVED`,`FILE_LOCKED`,`FILE_NOT_FOUND`,`NO_DOCUMENT`,`INVALID_RANGE`,`INVALID_ARGUMENT`,`NOT_FOUND`,`ANNOTATION_RESOLVED`,`FORMAT_ERROR`,`PERMISSION_DENIED`]),ud([`CHANNEL_CONNECT_FAILED`,`MONITOR_CONNECT_FAILED`]);function fd(e){return e.author!==`user`}function pd(e){return e.status===`pending`&&fd(e)}function md(e){return`${e}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function hd(){return md(`ann`)}function gd(){return md(`msg`)}function _d(){return md(`ntf`)}function vd(e){return md(e)}function yd(e){return e===`deferred-autostart`}var bd=`INVALID_BODY`,xd=`PATH_REJECTED`,Sd=`LAUNCHER_IN_PROGRESS`,Cd=`LAUNCHER_NOT_AVAILABLE`,wd=`NO_CLAUDE_INTEGRATION`;function Td(){try{return Os().defaultSaveDirectory}catch{return null}}async function Ed(){let e=new AbortController,t=setTimeout(()=>e.abort(),250);try{let t=await fetch(`${Ns}/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 Dd(){try{let{homeDir:e}=await ac(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 Od(){return Td()||await Ed()||await Dd()}function kd(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 Ad(e){return e.map(e=>e.path)}function jd(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 Md(){try{let e=localStorage.getItem(fo);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 Nd(e){try{localStorage.setItem(fo,JSON.stringify(e)),Rd()}catch(e){console.warn(`[tandem] failed to save recent files:`,e)}}function Pd(){try{localStorage.removeItem(fo),Rd()}catch(e){console.warn(`[tandem] failed to clear recent files:`,e)}}var Fd=3e4,Id=null;function Ld(){let e=Date.now();if(Id&&e-Id.ts<Fd)return Id.files;let t=Md();return Id={files:t,ts:e},t}function Rd(){Id=null}var zd=[`editor`,`navigation`,`view`,`document`,`annotations`,`claude`],Bd=N(F(new Map));function Vd(e,t={}){if(V(Bd).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 P(Bd,new Map(V(Bd)).set(e.id,e),!0),!0}function Hd(){return V(Bd)}var Ud=null;function Wd(e){Ud=e}function Gd(e,t){if(!Ud){console.warn(`[actions] "${e}" invoked before App mounted — deps not wired yet`);return}t(Ud)}var Kd=N(!1),qd=N(!1),Jd={get saving(){return V(Kd)},get lastSaveOk(){return V(qd)}},Yd=!1,Xd=!1;function Zd(e){return e.connected&&e.tabCount===0&&e.activeTabId===null}async function Qd(){if(!Xd){Xd=!0;try{let e=await fetch(`${Ns}${Qc}`,{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{Xd=!1}}}function $d(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}var ef=!1;async function tf(e){let t=await Od();if(!t)return e;try{let{join:n}=await ac(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 nf(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 rf(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 af(e){if(ef)return!1;let{activeDocId:t,notify:n,defaultName:r,sourceFormat:i}=e;if(!t)return n(`warning`,`No active document to save.`),!1;ef=!0;try{return $d()?await of(t,n,r??`Scratchpad.md`):await sf(t,n,i)}finally{ef=!1}}async function of(e,t,n){let r;try{let{save:e}=await ac(async()=>{let{save:e}=await import(`./dist-js-BWAGOggB.js`);return{save:e}},__vite__mapDeps([2,1]));r=await e({defaultPath:await tf(n),filters:[{name:`Markdown`,extensions:[`md`]},{name:`Plain Text`,extensions:[`txt`]}]})}catch(e){return t(`error`,`Save As dialog unavailable: ${e instanceof Error?e.message:e}`),!1}if(typeof r!=`string`||r.length===0)return!1;let i=r.toLowerCase().endsWith(`.txt`)?`txt`:`md`,a=nf(r,i);a!==r&&t(`info`,`Saving as ${i.toUpperCase()} — only .md and .txt are supported.`);try{let n=await fetch(`${Ns}${Yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,targetPath:a,format:i})});if(!n.ok)return t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`),!1;let r=await n.json().catch(()=>null);if(r?.data?.status!==`saved`)return t(`error`,`Save As failed: ${r?.data?.reason??`the server returned an invalid result.`}`),!1;let o=r?.data?.fileName??a,s=r?.data?.targetPath??a;return Nd(kd(Md(),s)),t(`info`,`Saved to ${o}.`),!0}catch(e){return t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`),!1}}async function sf(e,t,n){let r=n===`txt`?`txt`:`md`;try{let n=await fetch(`${Ns}${Yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,serialize:!0,format:r})});if(!n.ok)return t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`),!1;let i=await n.json().catch(()=>null),a=i?.data?.content,o=i?.data?.fileName??`Scratchpad.${r}`;return typeof a==`string`?(rf(a,o,r===`md`?`text/markdown`:`text/plain`),t(`info`,`Downloaded; scratchpad remains in-session.`),!0):(t(`error`,`Save As returned no content.`),!1)}catch(e){return t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`),!1}}async function cf(e){if(!e||Yd)return!1;Yd=!0,P(Kd,!0);let t=!1;try{let n=await fetch(`${Ns}${Yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e})});if(n.ok){let e=await n.json().catch(()=>null),r=e?.data;if(r?.status===`skipped`)return Ud?.notify(`warning`,lf(r.skipCode,r.reason)),!1;if(r?.status===`error`)return Ud?.notify(`error`,`Save failed: ${r.reason??`The document could not be saved.`}`),!1;if(r?.status!==`saved`)return Ud?.notify(`error`,`Save failed: the server returned an invalid result.`),!1;t=!0,(e?.data?.integrityWarnings?.length??0)>0&&Ud?.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 i=e?.data?.fidelityWarnings?.length??0,a=e?.data?.unpreservedImports??0;i>0&&a>0?Ud?.notify(`warning`,`Saved — ${i} Word feature${i===1?` was`:`s were`} simplified on export, and the backed-up original has features this file doesn't. See the document notice for details.`):i>0?Ud?.notify(`warning`,`Saved — ${i} Word feature${i===1?` was`:`s were`} simplified on export; see the document notice for details.`):a>0&&Ud?.notify(`warning`,`Saved — the backed-up original has Word features this file doesn't. Your original can still be restored; see the document notice for details.`)}else{let e=(await n.json().catch(()=>({}))).message??n.statusText;console.warn(`[Tandem] Save failed:`,e),Ud?.notify(`error`,`Save failed: ${e}`)}}catch(e){console.warn(`[Tandem] Save request failed:`,e),Ud?.notify(`error`,`Save failed — check your connection and try again.`)}finally{Yd=!1,P(qd,t,!0),P(Kd,!1)}return t}function lf(e,t){switch(e){case`EXTERNAL_CONFLICT`:case`FILE_MODIFIED`:return`Not saved — this file changed on disk. Choose Keep or Reload before saving.`;case`PROMOTION_REQUIRED`:return`Not saved — choose Save As to turn this upload or scratchpad into a file.`;case`READ_ONLY`:return`Not saved — this document is read-only.`;case`UNSUPPORTED_FORMAT`:case`ADAPTER_UNAVAILABLE`:return`Not saved — this document format cannot be written to disk.`;case`SAVE_IN_PROGRESS`:return`Not saved — another save is already in progress. Try again in a moment.`;case`SOURCE_MISSING`:return`Not saved — the original file no longer exists. Reopen it or use Save As.`;case`FILE_STATE_UNAVAILABLE`:return`Not saved — Tandem could not verify the file state. Check access and try again.`;case`NOT_OPEN`:return`Not saved — the document is no longer open.`;case`EXPLICIT_ONLY`:return`Not saved automatically — use Save to write this document format.`;default:return`Not saved${t?` — ${t}.`:`.`}`}}var uf=!1;async function df(){let e;try{e=await fetch(`${Ns}${hl}`)}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 ff(){let e;try{e=await fetch(`${Ns}${gl}`,{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 pf(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 mf(e,t,n,r){let i=await ff();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(`${Ns}${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}if(typeof r.successMessage==`string`)e.notify(`info`,r.successMessage);else{let t=await i.json().catch(()=>({}));e.notify(`info`,r.successMessage(t))}}catch(t){e.notify(`error`,`${r.requestFailPrefix}: ${t instanceof Error?t.message:t}`)}}async function hf(e){if(uf)return e.notify(`info`,`Already restarting Claude — hang on.`),!1;let t=await df();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):yd(n.reason)?(e.notify(`info`,`Claude is starting up — try again in a moment.`),!1):(e.notify(`warning`,`Claude launcher not active in this Tandem build.`),!1)}async function gf(e,{cwdRequired:t}){if(!await hf(e))return;let n=pf(e.getActiveDocumentPath());if(!n&&t){e.notify(`warning`,`Active document isn't saved to a folder. Set a working directory in Settings → Claude Code.`);return}let r=n?`Restart Claude in:\n${n}\n\nYour current task may be interrupted.`:`Restart Claude in its configured working directory.
|
|
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 q(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(dn(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`]}),Pn(()=>{t.disconnect()})}function qi(e,t,n=t){var r=new WeakSet,i=!0;kn(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;J(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;J(e,`checked`,null),e.checked=r}}};e[me]=n,nt(n),Dn()}}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 J(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;kn(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){kn(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}function pa(e=!1){let t=Ze,n=t.l.u;if(!n)return;let r=()=>jr(t.s);if(e){let e=0,n={},i=Wt(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>V(i)}n.b.length&&In(()=>{ma(t,r),_(n.b)}),z(()=>{let e=Ar(()=>n.m.map(g));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&z(()=>{ma(t,r),_(n.a)})}function ma(e,t){if(e.l.s)for(let t of e.l.s)V(t);t()}var ha={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 ga(e,t,n){return new Proxy({props:e,exclude:t},ha)}var _a={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 va(...e){return new Proxy({props:e},_a)}function Y(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),V(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&&V(y);var b=cr;return(function(e,t){if(arguments.length>0){let n=t?V(y):i&&a?F(e):e;return P(y,n),v=!0,c!==void 0&&(c=n),e}return rr&&v||b.f&16384?y.v:V(y)})}function ya(e){Ze===null&&_e(`onMount`),Ye&&Ze.l!==null?xa(Ze).m.push(e):z(()=>{let t=Ar(e);if(typeof t==`function`)return t})}function ba(e){Ze===null&&_e(`onDestroy`),ya(()=>()=>Ar(e))}function xa(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}var Sa=3478,Ca=3479,wa=`https://github.com/bloknayrb/tandem`,Ta=`${wa}/issues/new`,Ea=`https://tandem.ink`,Da=`support@tandem.ink`,Oa=new Set([`.md`,`.txt`,`.html`,`.htm`,`.docx`]),ka=3e3,Aa=3e3,ja=3e4,Ma={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)`},Na={yellow:`var(--tandem-highlight-yellow)`,green:`var(--tandem-highlight-green)`,blue:`var(--tandem-highlight-blue)`,pink:`var(--tandem-highlight-pink)`};function Pa(e){return e&&e in Ma?e:`yellow`}var Fa=`tandem`,Ia=`tandem:mode`,La=`tandem:settings`,Ra={left:`tandem-left-panel-width`,right:`tandem-panel-width`},za=1e3,Ba=3e3,Va=`__tandem_ctrl__`,Ha=`annotations`,Ua=`awareness`,Wa=`userAwareness`,Ga=`mode`,Ka=`selectionDwellMs`,qa=`chat`,Ja=`chatSeen`,Ya=`initialized`,Xa=`chatDocumentNames`,Za=`documentMeta`,Qa=`annotationReplies`,$a=`savedAtVersion`,eo=`authorship`,to=`selection`,no=`activity`,ro=`claude`,io=`openDocuments`,ao=`activeDocumentId`,oo=`activeDocumentEpoch`,so=`storeReadOnly`,co=`fidelityReport`,lo=`tandem:showAuthorship`,uo=`tandem:decorationVisibility`,fo=`tandem:recentFiles`,po=`tandem:userName`,mo=`tandem:user-name-changed`,ho={error:8e3,warning:6e3,info:4e3},go=5*6e4,_o=`tandem:tutorialCompleted`,vo=`tutorial-`,yo=`tandem:coworkOnboardingSkipped`,bo=3e4,xo=2e3,So=`tandem:zoomLevel`,Co=.5,wo=new Set([`md`,`txt`]),To=new Set([`docx`]),Eo=new Set([...wo,...To]),Do=`/api/integrations/existing`,Oo=`/api/integrations`,ko=`/api/integrations/apply`,Ao=`/api/integrations/first-run-needed`;function jo(e){return`/api/integrations/secrets/${encodeURIComponent(e)}`}function Mo(e){return`/api/models/secrets/${encodeURIComponent(e)}`}var No=`/api/integrations/claude-cli-status`,Po=`/api/integrations/install-claude-code`,Fo=`/api/models`,Io=[`anthropic`,`openai`,`gemini`,`local-ollama`,`local-llamacpp`],Lo=[`local-ollama`,`local-llamacpp`];function Ro(e){return Lo.includes(e)}var zo=[`save`,`save-as`,`focus-chat`,`toggle-source-view`,`settings`,`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`],Bo=new Set(zo);function Vo(e){return Bo.has(e)}var Ho={save:`Save document`,"save-as":`Save As…`,"focus-chat":`Focus Chat`,"toggle-source-view":`View / exit Markdown source`,settings:`Open settings`,"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`},Uo={save:{ctrlOrMeta:!0,alt:!1,shift:!1,code:`KeyS`},"save-as":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyS`},"focus-chat":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyJ`},"toggle-source-view":{ctrlOrMeta:!0,alt:!1,shift:!0,code:`KeyE`},settings:{ctrlOrMeta:!0,alt:!1,shift:!1,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`}},Wo=[{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`}],Go={save:`save`,"save-as":`save-as`,"focus-chat":`focus-chat`,"toggle-source-view":`toggle-source-view`,settings:`settings`,"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`},Ko=/^(Control|Shift|Alt|Meta|OS)/,qo=new Set([`Tab`,`Escape`,`Enter`,`NumpadEnter`,`NumLock`,`CapsLock`,`ContextMenu`,`Insert`]);function Jo(e){return Ko.test(e.code)||e.code.startsWith(`Numpad`)||qo.has(e.code)?!1:e.ctrlOrMeta||e.alt}function Yo(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 Jo(t)?t:null}function Xo(e,t){return e.ctrlOrMeta===(t.ctrlKey||t.metaKey)&&e.alt===t.altKey&&e.shift===t.shiftKey&&e.code===t.code}function Zo(e,t){return e.ctrlOrMeta===t.ctrlOrMeta&&e.alt===t.alt&&e.shift===t.shift&&e.code===t.code}function Qo(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 $o(){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 es(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 ts(e){let t=$o(),n=[];return e.ctrlOrMeta&&n.push(t?`⌘`:`Ctrl`),e.alt&&n.push(t?`⌥`:`Alt`),e.shift&&n.push(t?`⇧`:`Shift`),n.push(es(e.code)),t?n.join(``):n.join(`+`)}function ns(e,t){return t.get(e)??Uo[e]}function rs(e){let t=new Map;for(let n of zo)t.set(n,ts(ns(n,e)));return t}function is(e,t){return t?t.has(e):!1}function as(e,t){if(e.isComposing)return null;if(t&&t.size>0)for(let n of zo){let r=t.get(n);if(r&&Xo(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`&&!is(`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`&&!is(`save-as`,t))return{id:`save-as`};if(e.code===`KeyS`&&!is(`save`,t))return{id:`save`};if(e.shiftKey&&!e.altKey&&e.code===`KeyJ`&&!is(`focus-chat`,t))return{id:`focus-chat`};if(e.shiftKey&&!e.altKey&&e.code===`KeyE`&&!is(`toggle-source-view`,t))return{id:`toggle-source-view`};if(e.shiftKey&&e.code===`KeyP`&&!is(`toggle-palette`,t))return{id:`toggle-palette`};if(e.code===`KeyN`&&!is(`new-scratchpad`,t))return{id:`new-scratchpad`};if(e.code===`KeyW`&&!is(`close-tab`,t))return{id:`close-tab`};if(e.code===`KeyO`&&!is(`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`&&!is(`toggle-mode`,t))return{id:`toggle-mode`};if(e.altKey&&e.code===`KeyT`&&!is(`reopen-closed-tab`,t))return{id:`reopen-closed-tab`};if(!e.altKey&&!e.shiftKey&&e.code===`KeyT`&&!is(`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`&&!is(`comment-on-selection`,t))return{id:`comment-on-selection`};if(e.altKey&&e.code===`KeyA`&&!is(`toggle-authorship`,t))return{id:`toggle-authorship`}}if(e.altKey&&!e.ctrlKey&&!e.metaKey){if(e.shiftKey){if(e.code===`ArrowLeft`&&!is(`toggle-left-panel`,t))return{id:`toggle-left-panel`};if(e.code===`ArrowRight`&&!is(`toggle-right-panel`,t))return{id:`toggle-right-panel`}}if(!e.shiftKey){if(e.code===`BracketRight`&&!is(`annotation-next`,t))return{id:`annotation-next`};if(e.code===`BracketLeft`&&!is(`annotation-prev`,t))return{id:`annotation-prev`}}if(!e.shiftKey&&e.code===`KeyL`&&!is(`select-block`,t))return{id:`select-block`}}return null}function ss(e){return e.code===`Slash`?e.shift?`?`:`/`:e.code===`Enter`||e.code===`NumpadEnter`?`Enter`:``}function cs(e){return{key:ss(e),code:e.code,ctrlKey:e.ctrlOrMeta,metaKey:!1,altKey:e.alt,shiftKey:e.shift,isComposing:!1}}function ls(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 us(e){let t=as(cs(e));return!t||Vo(t.id)?null:ls(t.id,t.context)||null}function ds(e,t,n){for(let r of zo)if(r!==n&&Zo(ns(r,t),e))return Ho[r];let r=us(e);if(r)return r;for(let t of Wo)if(Zo(t.chord,e))return t.label;return null}function fs(e){return Wo.some(t=>Zo(t.chord,e))}function ps(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Vo(n)&&Qo(r)&&Jo(r)&&(fs(r)||us(r)||(t[n]=r));let n={},r=[];for(let e of zo){let i=t[e];i&&(r.some(e=>Zo(e,i))||(r.push(i),n[e]=i))}return n}function ms(e){let t=new Map;for(let[n,r]of Object.entries(ps(e)))t.set(n,r);return t}var hs=[`narrow`,`comfortable`,`wide`,`full`],gs={narrow:`58ch`,comfortable:`68ch`,wide:`82ch`,full:`100%`};function _s(e){return typeof e==`string`&&hs.includes(e)}var vs=50,ys={s:14,m:16,l:18};function bs(){try{return typeof window>`u`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}catch{return!1}}var xs={leftPanelVisible:!1,rightPanelVisible:!0,schemaVersion:18,primaryTab:`annotations`,panelOrder:`chat-editor-annotations`,editorMeasure:`comfortable`,selectionDwellMs:za,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:{},smartTypography:!1,spellcheck:!0,uniformTabWidth:!0},Ss=64,Cs=512;function ws(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(t.length>=vs)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`||!Io.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<=Ss&&/^[A-Za-z0-9_-]+$/.test(e.apiKeyRef)?r.apiKeyRef=e.apiKeyRef:typeof e.apiKey==`string`&&e.apiKey.length<=Cs&&(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 Ts=[`serif`,`sans`,`mono`];function Es(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`&&Ts.includes(r)&&(t[n]=r);return t}function Ds(e){return{leftPanelVisible:e.leftPanelVisible===!0,rightPanelVisible:e.rightPanelVisible!==!1,schemaVersion:18,primaryTab:e.primaryTab===`annotations`?`annotations`:`chat`,panelOrder:e.panelOrder===`annotations-editor-chat`?`annotations-editor-chat`:`chat-editor-annotations`,editorMeasure:_s(e.editorMeasure)?e.editorMeasure:xs.editorMeasure,selectionDwellMs:Math.max(500,Math.min(Ba,Number(e.selectionDwellMs)||1e3)),showAuthorship:e.showAuthorship===!1?!1:xs.showAuthorship,reduceMotion:typeof e.reduceMotion==`boolean`?e.reduceMotion:bs(),textSize:e.textSize===`s`||e.textSize===`m`||e.textSize===`l`?e.textSize:xs.textSize,theme:e.theme===`light`||e.theme===`dark`||e.theme===`warm`||e.theme===`system`?e.theme:xs.theme,systemLightVariant:e.systemLightVariant===`warm`?`warm`:xs.systemLightVariant,accentHue:typeof e.accentHue==`number`&&e.accentHue>=0&&e.accentHue<=360?e.accentHue:xs.accentHue,editorFont:e.editorFont===`serif`||e.editorFont===`sans`||e.editorFont===`mono`?e.editorFont:xs.editorFont,fontByExtension:Es(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:xs.density,defaultMode:e.defaultMode===`solo`||e.defaultMode===`tandem`?e.defaultMode:xs.defaultMode,highContrast:e.highContrast===!0,annotationPatterns:e.annotationPatterns===!0,selectionToolbar:e.selectionToolbar===!1?!1:xs.selectionToolbar,formattingBarVisible:e.formattingBarVisible===!1?!1:xs.formattingBarVisible,railHoverReveal:e.railHoverReveal===!1?!1:xs.railHoverReveal,soloRailHidden:e.soloRailHidden===!1?!1:xs.soloRailHidden,degradedBannerDelayMs:typeof e.degradedBannerDelayMs==`number`&&e.degradedBannerDelayMs>=5e3&&e.degradedBannerDelayMs<=12e4?e.degradedBannerDelayMs:xs.degradedBannerDelayMs,sidecarRetryStrategy:e.sidecarRetryStrategy===`exponential`||e.sidecarRetryStrategy===`constant-2s`?e.sidecarRetryStrategy:xs.sidecarRetryStrategy,marginView:e.marginView===!0,showComments:e.showComments===!1?!1:xs.showComments,showHighlights:e.showHighlights===!1?!1:xs.showHighlights,showNotes:e.showNotes===!1?!1:xs.showNotes,showRawMarkdown:e.showRawMarkdown===!1?!1:xs.showRawMarkdown,decorationsMuted:e.decorationsMuted===!0,models:ws(e.models),defaultModelId:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null,customShortcuts:ps(e.customShortcuts),smartTypography:e.smartTypography===!0,spellcheck:e.spellcheck===!1?!1:xs.spellcheck,uniformTabWidth:e.uniformTabWidth===!1?!1:xs.uniformTabWidth}}function Os(){let e;try{e=localStorage.getItem(La)}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(t.schemaVersion===16&&(t={...t,schemaVersion:17}),t.schemaVersion===17&&(t={...t,schemaVersion:18}),typeof t.schemaVersion==`number`&&t.schemaVersion>18){console.warn(`[tandem] settings schemaVersion=${t.schemaVersion} is newer than v18; loading defensively without writing.`);let e=t.editorMeasure,n=Ds(t);typeof e==`string`&&e!==n.editorMeasure&&console.warn(`[tandem] editorMeasure=${JSON.stringify(e)} from newer client is unknown to v18; 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 Ds(t)}catch(e){console.warn(`[tandem] settings JSON is corrupt, resetting to defaults:`,e)}return{...xs,reduceMotion:bs()}}function ks(e,t){let n={...e,...t},r=ws(n.models);return{...n,customShortcuts:ps(n.customShortcuts),fontByExtension:Es(n.fontByExtension),defaultSaveDirectory:typeof n.defaultSaveDirectory==`string`&&n.defaultSaveDirectory.trim()?n.defaultSaveDirectory.trim():null,selectionDwellMs:Math.max(500,Math.min(Ba,n.selectionDwellMs)),accentHue:Number.isFinite(n.accentHue)?Math.max(0,Math.min(360,n.accentHue)):xs.accentHue,editorMeasure:_s(n.editorMeasure)?n.editorMeasure:xs.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 As(e,t){if(t){let n=e.fontByExtension?.[t];if(n)return n}return e.editorFont}function js(e){let t={id:e.id,provider:e.provider,displayName:e.displayName,modelId:e.modelId,enabled:e.enabled};return e.apiKeyRef!==void 0&&(t.apiKeyRef=e.apiKeyRef),e.endpoint!==void 0&&(t.endpoint=e.endpoint),e.params!==void 0&&(t.params=e.params),t}function Ms(e,t){return{schemaVersion:1,models:e.map(js),defaultModelId:t}}var Ns=`http://127.0.0.1:${Ca}`;function Ps(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}function Fs(e){return e.toLowerCase().endsWith(`.docx`)}async function Is(e){return Fs(e.name)?Ps(await e.arrayBuffer()):e.text()}var Ls=`tandem:models-reconciled-to-server-v2`,Rs=!1,zs=`skipped`;async function eee(){if(Rs)return zs;Rs=!0;try{if(localStorage.getItem(`tandem:models-reconciled-to-server-v2`)===`1`)return zs=`skipped`;let e=Os();if(e._readOnly)return zs=`skipped`;let t=e.models??[];if(t.length===0)return zs=`skipped`;let n=await fetch(`${Ns}${Fo}`,{method:`GET`});if(!n.ok)throw Error(`GET ${Fo} → ${n.status}`);let{etag:r}=await n.json(),i={file:Ms(t,e.defaultModelId??null),ifMatch:r},a=await fetch(`${Ns}${Fo}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(a.ok||a.status===409)return localStorage.setItem(Ls,`1`),zs=`reconciled`;let o=await a.json().then(e=>e?.code).catch(()=>void 0);return console.warn(`[tandem] model-registry reconcile POST failed (status ${a.status}${o?`, ${o}`:``}); will retry next boot.`),zs=`failed`}catch(e){return console.warn(`[tandem] model-registry reconcile errored; will retry next boot.`,e),zs=`failed`}}function Bs(e){return e?e.osSupported?e.coworkDetected?`normal`:`undetected`:`unsupported`:`loading`}function Vs(e){return e.claudeDesktopDetected??!1?(e.workspacesBlocked??0)>0?`blocked`:`noWorkspacesYet`:`noClaude`}function Hs(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: ${Us(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 Us(e){let t=e.trim();return t.length===0?`(no output)`:t.length<=200?t:`${t.slice(0,197)}...`}function Ws(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`kind`in t&&typeof t.kind==`string`)try{return Hs(t)}catch(n){return console.error(`[cowork] firewallErrorHint failed for:`,t,n),e}return e}catch{return e}}function Gs(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 Ks(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 qs(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 Js(e){let t=e=>e===`ok`||e===`alreadyPresent`;return t(e.installedPlugins)&&t(e.knownMarketplaces)&&t(e.coworkSettings)}function Ys(e){if(!e||!e.enabled)return`not-applicable`;let t=e.workspaces??[];return t.some(Js)?`reachable`:t.some(e=>Ks(qs(e))===`error`)?`unreachable`:`pending`}function Xs(e){switch(e){case`reachable`:return{title:`Tandem is reachable from Cowork`,detail:`At least one Cowork workspace has the Tandem plugin installed — a Cowork session can find and load it.`,family:`success`};case`unreachable`:return{title:`Tandem isn't reachable yet`,detail:`Cowork is enabled, but a workspace install didn't complete. Re-scan workspaces, or restart Claude Desktop and re-enable.`,family:`error`};case`pending`:return{title:`Waiting for a Cowork session`,detail:`Cowork is enabled. The Tandem plugin installs into a workspace the first time you open a Cowork session.`,family:`warning`};case`not-applicable`:return{title:``,detail:``,family:`neutral`}}}function Zs(e,t){return!(!e||t||!e.osSupported||!e.coworkDetected||e.enabled)}function Qs(){try{return localStorage.getItem(yo)===`true`}catch{return!1}}function $s(){try{localStorage.setItem(yo,`true`)}catch{}}function ec(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}function tc(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 nc=`modulepreload`,rc=function(e){return`/`+e},ic={},ac=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=rc(t,n),t in ic)return;ic[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`:nc,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)})},oc=`Tauri runtime not available`;async function sc(){try{return(await ac(()=>import(`./core-SwWLTXZB.js`),[])).invoke}catch(e){return ec()&&console.error(`[keychain] Failed to load @tauri-apps/api/core:`,e),(()=>Promise.reject(Error(oc)))}}function cc(e,t,n){return e(`keychain_set`,{account:t,secret:n})}function lc(e,t){return e(`keychain_delete`,{account:t})}function uc(e={}){let t=e.fetchFn??((...e)=>globalThis.fetch(...e)),n=e.baseUrl??``,r=e.pathFor??jo;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 dc=[`keychain-init`,`Platform secure storage failure`,`Couldn't access platform secure storage`];function fc(e){return dc.some(t=>e.includes(t))}function pc(e={}){let t=()=>e.invoke?Promise.resolve(e.invoke):sc();return{async set(e,n){try{return await cc(await t(),e,n),{status:`ok`}}catch(e){let t=e instanceof Error?e.message:String(e);return fc(t)?{status:`unavailable`}:{status:`error`,message:t}}},async delete(e){try{await lc(await t(),e)}catch{}}}}function mc(e={}){return e.force===`tauri`||e.force!==`http`&&ec()?pc({invoke:e.invoke}):uc({fetchFn:e.fetchFn,baseUrl:e.baseUrl,pathFor:e.pathFor})}var hc=N(F([])),gc=N(null),_c=null,vc=N(null),yc=N(!1),bc=N(!1),xc=null,Sc=new Promise(e=>{xc=e});function Cc(){xc?.()}var wc=mc({baseUrl:`http://127.0.0.1:${Ca}`,pathFor:Mo});function Tc(){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 Ec(){return crypto.randomUUID()}function Dc(e){if(e.provider!==void 0&&!Io.includes(e.provider))throw Error(`Invalid model provider: ${String(e.provider)}`)}async function Oc(e,t){let n=await wc.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})`)}var kc=3,Ac=25;function jc(e){return new Promise(t=>setTimeout(t,e))}async function Mc(){let e={file:Ms(V(hc),V(gc)),ifMatch:_c??``},t=await fetch(`${Ns}${Fo}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(t.ok)return{ok:!0,etag:(await t.json()).etag};let n=await t.json().catch(()=>({}));return t.status===409&&n.code===`MODELS_STALE`?{ok:!1,kind:`stale`}:t.status===429&&n.code===`MODELS_BUSY`?{ok:!1,kind:`busy`}:{ok:!1,kind:`failed`}}async function Nc(){let e=await Mc();for(let t=1;t<kc&&!e.ok&&e.kind===`busy`;t++)await jc(Ac),e=await Mc();return e}var Pc=Promise.resolve();async function Fc(e){let t=Pc.then(async()=>{let t=e=>(_c=e,P(vc,null),`committed`),n={models:V(hc),defaultModelId:V(gc),etag:_c},r=e=>(P(hc,n.models,!0),P(gc,n.defaultModelId,!0),_c=n.etag,P(vc,e,!0),`rolledback`);e(),await Sc;try{let n=await Nc();if(n.ok)return t(n.etag);if(n.kind===`stale`){await Ic(),e();let n=await Nc();return n.ok?t(n.etag):(await Ic(),P(vc,`Model registry changed elsewhere; reloaded.`),`reconciled`)}return r(n.kind===`busy`?`Model registry is busy; please try again.`:`Failed to save model changes.`)}catch(e){return console.warn(`[models] write-through failed`,e),r(`Failed to save model changes.`)}});return Pc=t.then(()=>void 0,()=>void 0),t}async function Ic(){let e=await fetch(`${Ns}${Fo}`,{method:`GET`});if(!e.ok)throw Error(`GET ${Fo} → ${e.status}`);let{file:t,etag:n}=await e.json();P(hc,t.models,!0),P(gc,t.defaultModelId,!0),_c=n}function Lc(){return Promise.resolve()}function Rc(){return Lc()}async function zc(){try{await eee()}finally{Cc()}await Lc()}function Bc(){{let e=Os();return{models:e.models,defaultModelId:e.defaultModelId}}return{models:V(hc),defaultModelId:V(gc)}}function Vc(){return{get models(){return V(hc)},get defaultModelId(){return V(gc)},get saveError(){return V(vc)},get loading(){return V(yc)},get loadFailed(){return V(bc)},async addModel(e,t){Dc(e);let n=Ec(),r;t&&t.length>0&&(r=Tc(),await Oc(r,t));let i={...e,id:n,...r?{apiKeyRef:r}:{}},a=await Fc(()=>{P(hc,[...V(hc),i],!0)});return r&&a!==`committed`&&await wc.delete(r),a===`committed`?n:null},async updateModel(e,t,n){Dc(t);let r=V(hc).find(t=>t.id===e);if(!r)return!1;let i;n!==void 0&&n.length>0&&(i=Tc(),await Oc(i,n));let a=await Fc(()=>{P(hc,V(hc).map(n=>n.id===e?{...n,...t,...i?{apiKeyRef:i}:{}}:n),!0)});return i&&(a===`committed`&&V(hc).some(t=>t.id===e&&t.apiKeyRef===i)?r.apiKeyRef&&await wc.delete(r.apiKeyRef):await wc.delete(i)),a===`committed`},async deleteModel(e){let t=V(hc).find(t=>t.id===e)?.apiKeyRef,n=await Fc(()=>{P(hc,V(hc).filter(t=>t.id!==e),!0),V(gc)===e&&P(gc,null)});t&&n===`committed`&&await wc.delete(t)},async toggleEnabled(e){let t=!V(hc).find(t=>t.id===e)?.enabled;await Fc(()=>{P(hc,V(hc).map(n=>n.id===e?{...n,enabled:t}:n),!0)})},async setDefault(e){return await Fc(()=>{P(gc,e,!0)})===`committed`},reload:Rc,clearError(){P(vc,null)}}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`),Xe();var Hc=`/api/notify-stream`,Uc=`/api/mode/release`,Wc=`/api/info`,Gc=`/api/diagnostics`,Kc=`/health`,qc=`/api/open`,Jc=`/api/close`,Yc=`/api/save`,Xc=`/api/rename`,Zc=`/api/upload`,Qc=`/api/scratchpad`,$c=`/api/convert`,el=`/api/apply-changes`,tl=`/api/document/raw`,nl=`/api/document/reload`,rl=`/api/backups`,il=`/api/backups/restore`,al=`/api/external-conflict/resolve`,ol=`/api/annotation-reply`,sl=`/api/remove-annotation`,cl=`/api/store/reclaim-lock`,ll=`/api/chat`,ul=`/api/sessions`,dl=`/api/sessions/delete`,fl=`/api/sessions/clear`,pl=`/api/license/status`,ml=`/api/license/activate`,hl=`/api/launcher/status`,gl=`/api/launcher/nonce`,_l=`/api/launcher/relaunch`,vl=`/api/launcher/start-fresh`,yl=`/api/launcher/working-directory`,bl=`upload://`,xl=`upload://scratchpad/`;function Sl(e){return e.startsWith(bl)}function Cl(e){return e.startsWith(xl)}function wl(e){if(!Cl(e))return null;let t=e.slice(20).split(`/`)[0];return t.length>0?t:null}var Tl=e=>e,El=e=>e,Dl;(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})(Dl||={});var Ol;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Ol||={});var kl=Dl.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Al=e=>{switch(typeof e){case`undefined`:return kl.undefined;case`string`:return kl.string;case`number`:return Number.isNaN(e)?kl.nan:kl.number;case`boolean`:return kl.boolean;case`function`:return kl.function;case`bigint`:return kl.bigint;case`symbol`:return kl.symbol;case`object`:return Array.isArray(e)?kl.array:e===null?kl.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?kl.promise:typeof Map<`u`&&e instanceof Map?kl.map:typeof Set<`u`&&e instanceof Set?kl.set:typeof Date<`u`&&e instanceof Date?kl.date:kl.object;default:return kl.unknown}},X=Dl.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`]),jl=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,Dl.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()}};jl.create=e=>new jl(e);var Ml=(e,t)=>{let n;switch(e.code){case X.invalid_type:n=e.received===kl.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case X.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Dl.jsonStringifyReplacer)}`;break;case X.unrecognized_keys:n=`Unrecognized key(s) in object: ${Dl.joinValues(e.keys,`, `)}`;break;case X.invalid_union:n=`Invalid input`;break;case X.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Dl.joinValues(e.options)}`;break;case X.invalid_enum_value:n=`Invalid enum value. Expected ${Dl.joinValues(e.options)}, received '${e.received}'`;break;case X.invalid_arguments:n=`Invalid function arguments`;break;case X.invalid_return_type:n=`Invalid function return type`;break;case X.invalid_date:n=`Invalid date`;break;case X.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}"`:Dl.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case X.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 X.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 X.custom:n=`Invalid input`;break;case X.invalid_intersection_types:n=`Intersection results could not be merged`;break;case X.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case X.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,Dl.assertNever(e)}return{message:n}},Nl=Ml;function Pl(){return Nl}var Fl=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 Il(e,t){let n=Pl(),r=Fl({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ml?void 0:Ml].filter(e=>!!e)});e.common.issues.push(r)}var Ll=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 Rl;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 Rl;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}}},Rl=Object.freeze({status:`aborted`}),zl=e=>({status:`dirty`,value:e}),Bl=e=>({status:`valid`,value:e}),Vl=e=>e.status===`aborted`,Hl=e=>e.status===`dirty`,Ul=e=>e.status===`valid`,Wl=e=>typeof Promise<`u`&&e instanceof Promise,Gl;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Gl||={});var Kl=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}},ql=(e,t)=>{if(Ul(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 jl(e.common.issues);return this._error=t,this._error}}};function Jl(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 Yl=class{get description(){return this._def.description}_getType(e){return Al(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Al(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ll,ctx:{common:e.parent.common,data:e.data,parsedType:Al(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Wl(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:Al(e)};return ql(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:Al(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ul(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=>Ul(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:Al(e)},r=this._parse({data:e,path:n.path,parent:n});return ql(n,await(Wl(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:X.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 Qu({schema:this,typeName:sd.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 $u.create(this,this._def)}nullable(){return ed.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Nu.create(this)}promise(){return Zu.create(this,this._def)}or(e){return Iu.create([this,e],this._def)}and(e){return Bu.create(this,e,this._def)}transform(e){return new Qu({...Jl(this._def),schema:this,typeName:sd.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new td({...Jl(this._def),innerType:this,defaultValue:t,typeName:sd.ZodDefault})}brand(){return new id({typeName:sd.ZodBranded,type:this,...Jl(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new nd({...Jl(this._def),innerType:this,catchValue:t,typeName:sd.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ad.create(this,e)}readonly(){return od.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Xl=/^c[^\s-]{8,}$/i,Zl=/^[0-9a-z]+$/,Ql=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$l=/^[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,eu=/^[a-z0-9_-]{21}$/i,tu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,nu=/^[-+]?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)?)??$/,ru=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,iu=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,au,ou=/^(?:(?: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])$/,su=/^(?:(?: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])$/,cu=/^(([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]))$/,lu=/^(([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])$/,uu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,du=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,fu=`((\\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])))`,pu=RegExp(`^${fu}$`);function mu(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 hu(e){return RegExp(`^${mu(e)}$`)}function gu(e){let t=`${fu}T${mu(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function _u(e,t){return!!((t===`v4`||!t)&&ou.test(e)||(t===`v6`||!t)&&cu.test(e))}function vu(e,t){if(!tu.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 yu(e,t){return!!((t===`v4`||!t)&&su.test(e)||(t===`v6`||!t)&&lu.test(e))}var bu=class e extends Yl{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==kl.string){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.string,received:t.parsedType}),Rl}let t=new Ll,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),Il(n,{code:X.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),Il(n,{code:X.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?Il(n,{code:X.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&Il(n,{code:X.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)ru.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`email`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)au||=new RegExp(iu,`u`),au.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`emoji`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)$l.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`uuid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)eu.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`nanoid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Xl.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`cuid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Zl.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`cuid2`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Ql.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`ulid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),Il(n,{validation:`url`,code:X.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),Il(n,{validation:`regex`,code:X.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),Il(n,{code:X.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),Il(n,{code:X.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),Il(n,{code:X.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?gu(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{code:X.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?pu.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{code:X.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?hu(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{code:X.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?nu.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`duration`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?_u(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`ip`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?vu(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`jwt`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?yu(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`cidr`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?uu.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`base64`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?du.test(e.data)||(n=this._getOrReturnCtx(e,n),Il(n,{validation:`base64url`,code:X.invalid_string,message:r.message}),t.dirty()):Dl.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:X.invalid_string,...Gl.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Gl.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Gl.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Gl.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Gl.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Gl.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Gl.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Gl.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Gl.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Gl.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Gl.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Gl.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Gl.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Gl.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,...Gl.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,...Gl.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Gl.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Gl.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Gl.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Gl.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Gl.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Gl.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Gl.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Gl.errToObj(t)})}nonempty(e){return this.min(1,Gl.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}};bu.create=e=>new bu({checks:[],typeName:sd.ZodString,coerce:e?.coerce??!1,...Jl(e)});function xu(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 Su=class e extends Yl{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)!==kl.number){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.number,received:t.parsedType}),Rl}let t,n=new Ll;for(let r of this._def.checks)r.kind===`int`?Dl.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Il(t,{code:X.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),Il(t,{code:X.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),Il(t,{code:X.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?xu(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),Il(t,{code:X.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Il(t,{code:X.not_finite,message:r.message}),n.dirty()):Dl.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Gl.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Gl.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Gl.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Gl.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Gl.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Gl.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Gl.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Gl.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Gl.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Gl.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Gl.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Gl.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Gl.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Gl.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`&&Dl.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)}};Su.create=e=>new Su({checks:[],typeName:sd.ZodNumber,coerce:e?.coerce||!1,...Jl(e)});var Cu=class e extends Yl{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)!==kl.bigint)return this._getInvalidInput(e);let t,n=new Ll;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),Il(t,{code:X.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),Il(t,{code:X.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),Il(t,{code:X.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Dl.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.bigint,received:t.parsedType}),Rl}gte(e,t){return this.setLimit(`min`,e,!0,Gl.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Gl.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Gl.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Gl.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Gl.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:Gl.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Gl.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Gl.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Gl.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Gl.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}};Cu.create=e=>new Cu({checks:[],typeName:sd.ZodBigInt,coerce:e?.coerce??!1,...Jl(e)});var wu=class extends Yl{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==kl.boolean){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.boolean,received:t.parsedType}),Rl}return Bl(e.data)}};wu.create=e=>new wu({typeName:sd.ZodBoolean,coerce:e?.coerce||!1,...Jl(e)});var Tu=class e extends Yl{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==kl.date){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.date,received:t.parsedType}),Rl}if(Number.isNaN(e.data.getTime()))return Il(this._getOrReturnCtx(e),{code:X.invalid_date}),Rl;let t=new Ll,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),Il(n,{code:X.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),Il(n,{code:X.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):Dl.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:Gl.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Gl.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)}};Tu.create=e=>new Tu({checks:[],coerce:e?.coerce||!1,typeName:sd.ZodDate,...Jl(e)});var Eu=class extends Yl{_parse(e){if(this._getType(e)!==kl.symbol){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.symbol,received:t.parsedType}),Rl}return Bl(e.data)}};Eu.create=e=>new Eu({typeName:sd.ZodSymbol,...Jl(e)});var Du=class extends Yl{_parse(e){if(this._getType(e)!==kl.undefined){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.undefined,received:t.parsedType}),Rl}return Bl(e.data)}};Du.create=e=>new Du({typeName:sd.ZodUndefined,...Jl(e)});var Ou=class extends Yl{_parse(e){if(this._getType(e)!==kl.null){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.null,received:t.parsedType}),Rl}return Bl(e.data)}};Ou.create=e=>new Ou({typeName:sd.ZodNull,...Jl(e)});var ku=class extends Yl{constructor(){super(...arguments),this._any=!0}_parse(e){return Bl(e.data)}};ku.create=e=>new ku({typeName:sd.ZodAny,...Jl(e)});var Au=class extends Yl{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Bl(e.data)}};Au.create=e=>new Au({typeName:sd.ZodUnknown,...Jl(e)});var ju=class extends Yl{_parse(e){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.never,received:t.parsedType}),Rl}};ju.create=e=>new ju({typeName:sd.ZodNever,...Jl(e)});var Mu=class extends Yl{_parse(e){if(this._getType(e)!==kl.undefined){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.void,received:t.parsedType}),Rl}return Bl(e.data)}};Mu.create=e=>new Mu({typeName:sd.ZodVoid,...Jl(e)});var Nu=class e extends Yl{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==kl.array)return Il(t,{code:X.invalid_type,expected:kl.array,received:t.parsedType}),Rl;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(Il(t,{code:e?X.too_big:X.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&&(Il(t,{code:X.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&&(Il(t,{code:X.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 Kl(t,e,t.path,n)))).then(e=>Ll.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Kl(t,e,t.path,n)));return Ll.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Gl.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Gl.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Gl.toString(n)}})}nonempty(e){return this.min(1,e)}};Nu.create=(e,t)=>new Nu({type:e,minLength:null,maxLength:null,exactLength:null,typeName:sd.ZodArray,...Jl(t)});function Pu(e){if(e instanceof Fu){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=$u.create(Pu(r))}return new Fu({...e._def,shape:()=>t})}else if(e instanceof Nu)return new Nu({...e._def,type:Pu(e.element)});else if(e instanceof $u)return $u.create(Pu(e.unwrap()));else if(e instanceof ed)return ed.create(Pu(e.unwrap()));else if(e instanceof Vu)return Vu.create(e.items.map(e=>Pu(e)));else return e}var Fu=class e extends Yl{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=Dl.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==kl.object){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.object,received:t.parsedType}),Rl}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ju&&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 Kl(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ju){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&&(Il(n,{code:X.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 Kl(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=>Ll.mergeObjectSync(t,e)):Ll.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Gl.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:Gl.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:sd.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 Dl.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 Dl.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Pu(this)}partial(t){let n={};for(let e of Dl.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 Dl.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof $u;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Ju(Dl.objectKeys(this.shape))}};Fu.create=(e,t)=>new Fu({shape:()=>e,unknownKeys:`strip`,catchall:ju.create(),typeName:sd.ZodObject,...Jl(t)}),Fu.strictCreate=(e,t)=>new Fu({shape:()=>e,unknownKeys:`strict`,catchall:ju.create(),typeName:sd.ZodObject,...Jl(t)}),Fu.lazycreate=(e,t)=>new Fu({shape:e,unknownKeys:`strip`,catchall:ju.create(),typeName:sd.ZodObject,...Jl(t)});var Iu=class extends Yl{_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 jl(e.ctx.common.issues));return Il(t,{code:X.invalid_union,unionErrors:n}),Rl}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 jl(e));return Il(t,{code:X.invalid_union,unionErrors:i}),Rl}}get options(){return this._def.options}};Iu.create=(e,t)=>new Iu({options:e,typeName:sd.ZodUnion,...Jl(t)});var Lu=e=>e instanceof Ku?Lu(e.schema):e instanceof Qu?Lu(e.innerType()):e instanceof qu?[e.value]:e instanceof Yu?e.options:e instanceof Xu?Dl.objectValues(e.enum):e instanceof td?Lu(e._def.innerType):e instanceof Du?[void 0]:e instanceof Ou?[null]:e instanceof $u?[void 0,...Lu(e.unwrap())]:e instanceof ed?[null,...Lu(e.unwrap())]:e instanceof id||e instanceof od?Lu(e.unwrap()):e instanceof nd?Lu(e._def.innerType):[],Ru=class e extends Yl{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==kl.object)return Il(t,{code:X.invalid_type,expected:kl.object,received:t.parsedType}),Rl;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}):(Il(t,{code:X.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Rl)}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=Lu(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:sd.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Jl(r)})}};function zu(e,t){let n=Al(e),r=Al(t);if(e===t)return{valid:!0,data:e};if(n===kl.object&&r===kl.object){let n=Dl.objectKeys(t),r=Dl.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=zu(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===kl.array&&r===kl.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=zu(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===kl.date&&r===kl.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Bu=class extends Yl{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Vl(e)||Vl(r))return Rl;let i=zu(e.value,r.value);return i.valid?((Hl(e)||Hl(r))&&t.dirty(),{status:t.value,value:i.data}):(Il(n,{code:X.invalid_intersection_types}),Rl)};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}))}};Bu.create=(e,t,n)=>new Bu({left:e,right:t,typeName:sd.ZodIntersection,...Jl(n)});var Vu=class e extends Yl{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==kl.array)return Il(n,{code:X.invalid_type,expected:kl.array,received:n.parsedType}),Rl;if(n.data.length<this._def.items.length)return Il(n,{code:X.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),Rl;!this._def.rest&&n.data.length>this._def.items.length&&(Il(n,{code:X.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 Kl(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Ll.mergeArray(t,e)):Ll.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Vu.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Vu({items:e,typeName:sd.ZodTuple,rest:null,...Jl(t)})};var Hu=class e extends Yl{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!==kl.object)return Il(n,{code:X.invalid_type,expected:kl.object,received:n.parsedType}),Rl;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Kl(n,e,n.path,e)),value:a._parse(new Kl(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Ll.mergeObjectAsync(t,r):Ll.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Yl?new e({keyType:t,valueType:n,typeName:sd.ZodRecord,...Jl(r)}):new e({keyType:bu.create(),valueType:t,typeName:sd.ZodRecord,...Jl(n)})}},Uu=class extends Yl{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!==kl.map)return Il(n,{code:X.invalid_type,expected:kl.map,received:n.parsedType}),Rl;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Kl(n,e,n.path,[a,`key`])),value:i._parse(new Kl(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 Rl;(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 Rl;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Uu.create=(e,t,n)=>new Uu({valueType:t,keyType:e,typeName:sd.ZodMap,...Jl(n)});var Wu=class e extends Yl{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==kl.set)return Il(n,{code:X.invalid_type,expected:kl.set,received:n.parsedType}),Rl;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(Il(n,{code:X.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&&(Il(n,{code:X.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 Rl;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 Kl(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:Gl.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Gl.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Wu.create=(e,t)=>new Wu({valueType:e,minSize:null,maxSize:null,typeName:sd.ZodSet,...Jl(t)});var Gu=class e extends Yl{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==kl.function)return Il(t,{code:X.invalid_type,expected:kl.function,received:t.parsedType}),Rl;function n(e,n){return Fl({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pl(),Ml].filter(e=>!!e),issueData:{code:X.invalid_arguments,argumentsError:n}})}function r(e,n){return Fl({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pl(),Ml].filter(e=>!!e),issueData:{code:X.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Zu){let e=this;return Bl(async function(...t){let o=new jl([]),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 Bl(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new jl([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new jl([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:Vu.create(t).rest(Au.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||Vu.create([]).rest(Au.create()),returns:n||Au.create(),typeName:sd.ZodFunction,...Jl(r)})}},Ku=class extends Yl{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})}};Ku.create=(e,t)=>new Ku({getter:e,typeName:sd.ZodLazy,...Jl(t)});var qu=class extends Yl{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return Il(t,{received:t.data,code:X.invalid_literal,expected:this._def.value}),Rl}return{status:`valid`,value:e.data}}get value(){return this._def.value}};qu.create=(e,t)=>new qu({value:e,typeName:sd.ZodLiteral,...Jl(t)});function Ju(e,t){return new Yu({values:e,typeName:sd.ZodEnum,...Jl(t)})}var Yu=class e extends Yl{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return Il(t,{expected:Dl.joinValues(n),received:t.parsedType,code:X.invalid_type}),Rl}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return Il(t,{received:t.data,code:X.invalid_enum_value,options:n}),Rl}return Bl(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})}};Yu.create=Ju;var Xu=class extends Yl{_parse(e){let t=Dl.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==kl.string&&n.parsedType!==kl.number){let e=Dl.objectValues(t);return Il(n,{expected:Dl.joinValues(e),received:n.parsedType,code:X.invalid_type}),Rl}if(this._cache||=new Set(Dl.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=Dl.objectValues(t);return Il(n,{received:n.data,code:X.invalid_enum_value,options:e}),Rl}return Bl(e.data)}get enum(){return this._def.values}};Xu.create=(e,t)=>new Xu({values:e,typeName:sd.ZodNativeEnum,...Jl(t)});var Zu=class extends Yl{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==kl.promise&&t.common.async===!1?(Il(t,{code:X.invalid_type,expected:kl.promise,received:t.parsedType}),Rl):Bl((t.parsedType===kl.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Zu.create=(e,t)=>new Zu({type:e,typeName:sd.ZodPromise,...Jl(t)});var Qu=class extends Yl{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===sd.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=>{Il(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 Rl;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?Rl:r.status===`dirty`||t.value===`dirty`?zl(r.value):r});{if(t.value===`aborted`)return Rl;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?Rl:r.status===`dirty`||t.value===`dirty`?zl(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`?Rl:(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`?Rl:(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(!Ul(e))return Rl;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=>Ul(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):Rl);Dl.assertNever(r)}};Qu.create=(e,t,n)=>new Qu({schema:e,typeName:sd.ZodEffects,effect:t,...Jl(n)}),Qu.createWithPreprocess=(e,t,n)=>new Qu({schema:t,effect:{type:`preprocess`,transform:e},typeName:sd.ZodEffects,...Jl(n)});var $u=class extends Yl{_parse(e){return this._getType(e)===kl.undefined?Bl(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$u.create=(e,t)=>new $u({innerType:e,typeName:sd.ZodOptional,...Jl(t)});var ed=class extends Yl{_parse(e){return this._getType(e)===kl.null?Bl(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ed.create=(e,t)=>new ed({innerType:e,typeName:sd.ZodNullable,...Jl(t)});var td=class extends Yl{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===kl.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};td.create=(e,t)=>new td({innerType:e,typeName:sd.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...Jl(t)});var nd=class extends Yl{_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 Wl(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new jl(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new jl(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};nd.create=(e,t)=>new nd({innerType:e,typeName:sd.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...Jl(t)});var rd=class extends Yl{_parse(e){if(this._getType(e)!==kl.nan){let t=this._getOrReturnCtx(e);return Il(t,{code:X.invalid_type,expected:kl.nan,received:t.parsedType}),Rl}return{status:`valid`,value:e.data}}};rd.create=e=>new rd({typeName:sd.ZodNaN,...Jl(e)});var id=class extends Yl{_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}},ad=class e extends Yl{_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`?Rl:e.status===`dirty`?(t.dirty(),zl(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`?Rl: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:sd.ZodPipeline})}},od=class extends Yl{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Ul(e)&&(e.value=Object.freeze(e.value)),e);return Wl(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};od.create=(e,t)=>new od({innerType:e,typeName:sd.ZodReadonly,...Jl(t)}),Fu.lazycreate;var sd;(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`})(sd||={});var cd=bu.create;Su.create,rd.create,Cu.create,wu.create,Tu.create,Eu.create,Du.create,Ou.create,ku.create,Au.create,ju.create,Mu.create,Nu.create;var ld=Fu.create;Fu.strictCreate,Iu.create,Ru.create,Bu.create,Vu.create,Hu.create,Uu.create,Wu.create,Gu.create,Ku.create,qu.create;var ud=Yu.create;Xu.create,Zu.create,Qu.create,$u.create,ed.create,Qu.createWithPreprocess,ad.create,ud([`highlight`,`note`,`comment`]),ud([`pending`,`accepted`,`dismissed`]),ud([`yellow`,`green`,`blue`,`pink`]),ud([`info`,`warning`,`error`,`success`]);var dd=ud([`solo`,`tandem`]);ud([`user`,`claude`,`import`]),ud([`user`,`claude`,`import`]),ld({provider:ud(Io),displayName:cd().max(120)}),ud([`accept`,`dismiss`]),ud([`markdown`,`json`]),ud([`md`,`txt`,`html`,`docx`]),ud([`RANGE_GONE`,`RANGE_MOVED`,`FILE_LOCKED`,`FILE_NOT_FOUND`,`NO_DOCUMENT`,`INVALID_RANGE`,`INVALID_ARGUMENT`,`NOT_FOUND`,`ANNOTATION_RESOLVED`,`FORMAT_ERROR`,`PERMISSION_DENIED`]),ud([`CHANNEL_CONNECT_FAILED`,`MONITOR_CONNECT_FAILED`]);function fd(e){return e.author!==`user`}function pd(e){return e.status===`pending`&&fd(e)}function md(e){return`${e}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function hd(){return md(`ann`)}function gd(){return md(`msg`)}function _d(){return md(`ntf`)}function vd(e){return md(e)}function yd(e){return e===`deferred-autostart`}var bd=`INVALID_BODY`,xd=`PATH_REJECTED`,Sd=`LAUNCHER_IN_PROGRESS`,Cd=`LAUNCHER_NOT_AVAILABLE`,wd=`NO_CLAUDE_INTEGRATION`;function Td(){try{return Os().defaultSaveDirectory}catch{return null}}async function Ed(){let e=new AbortController,t=setTimeout(()=>e.abort(),250);try{let t=await fetch(`${Ns}/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 Dd(){try{let{homeDir:e}=await ac(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 Od(){return Td()||await Ed()||await Dd()}function kd(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 Ad(e){return e.map(e=>e.path)}function jd(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 Md(){try{let e=localStorage.getItem(fo);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 Nd(e){try{localStorage.setItem(fo,JSON.stringify(e)),Rd()}catch(e){console.warn(`[tandem] failed to save recent files:`,e)}}function Pd(){try{localStorage.removeItem(fo),Rd()}catch(e){console.warn(`[tandem] failed to clear recent files:`,e)}}var Fd=3e4,Id=null;function Ld(){let e=Date.now();if(Id&&e-Id.ts<Fd)return Id.files;let t=Md();return Id={files:t,ts:e},t}function Rd(){Id=null}var zd=[`editor`,`navigation`,`view`,`document`,`annotations`,`claude`],Bd=N(F(new Map));function Vd(e,t={}){if(V(Bd).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 P(Bd,new Map(V(Bd)).set(e.id,e),!0),!0}function Hd(){return V(Bd)}var Ud=null;function Wd(e){Ud=e}function Gd(e,t){if(!Ud){console.warn(`[actions] "${e}" invoked before App mounted — deps not wired yet`);return}t(Ud)}var Kd=N(!1),qd=N(!1),Jd={get saving(){return V(Kd)},get lastSaveOk(){return V(qd)}},Yd=!1,Xd=!1;function Zd(e){return e.connected&&e.tabCount===0&&e.activeTabId===null}async function Qd(){if(!Xd){Xd=!0;try{let e=await fetch(`${Ns}${Qc}`,{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{Xd=!1}}}function $d(){try{return typeof window<`u`&&`__TAURI_INTERNALS__`in window}catch{return!1}}var ef=!1;async function tf(e){let t=await Od();if(!t)return e;try{let{join:n}=await ac(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 nf(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 rf(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 af(e){if(ef)return!1;let{activeDocId:t,notify:n,defaultName:r,sourceFormat:i}=e;if(!t)return n(`warning`,`No active document to save.`),!1;ef=!0;try{return $d()?await of(t,n,r??`Scratchpad.md`):await sf(t,n,i)}finally{ef=!1}}async function of(e,t,n){let r;try{let{save:e}=await ac(async()=>{let{save:e}=await import(`./dist-js-BWAGOggB.js`);return{save:e}},__vite__mapDeps([2,1]));r=await e({defaultPath:await tf(n),filters:[{name:`Markdown`,extensions:[`md`]},{name:`Plain Text`,extensions:[`txt`]}]})}catch(e){return t(`error`,`Save As dialog unavailable: ${e instanceof Error?e.message:e}`),!1}if(typeof r!=`string`||r.length===0)return!1;let i=r.toLowerCase().endsWith(`.txt`)?`txt`:`md`,a=nf(r,i);a!==r&&t(`info`,`Saving as ${i.toUpperCase()} — only .md and .txt are supported.`);try{let n=await fetch(`${Ns}${Yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,targetPath:a,format:i})});if(!n.ok)return t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`),!1;let r=await n.json().catch(()=>null);if(r?.data?.status!==`saved`)return t(`error`,`Save As failed: ${r?.data?.reason??`the server returned an invalid result.`}`),!1;let o=r?.data?.fileName??a,s=r?.data?.targetPath??a;return Nd(kd(Md(),s)),t(`info`,`Saved to ${o}.`),!0}catch(e){return t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`),!1}}async function sf(e,t,n){let r=n===`txt`?`txt`:`md`;try{let n=await fetch(`${Ns}${Yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e,serialize:!0,format:r})});if(!n.ok)return t(`error`,`Save As failed: ${(await n.json().catch(()=>({}))).message??n.statusText}`),!1;let i=await n.json().catch(()=>null),a=i?.data?.content,o=i?.data?.fileName??`Scratchpad.${r}`;return typeof a==`string`?(rf(a,o,r===`md`?`text/markdown`:`text/plain`),t(`info`,`Downloaded; scratchpad remains in-session.`),!0):(t(`error`,`Save As returned no content.`),!1)}catch(e){return t(`error`,`Save As request failed: ${e instanceof Error?e.message:e}`),!1}}async function cf(e){if(!e||Yd)return!1;Yd=!0,P(Kd,!0);let t=!1;try{let n=await fetch(`${Ns}${Yc}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({documentId:e})});if(n.ok){let e=await n.json().catch(()=>null),r=e?.data;if(r?.status===`skipped`)return Ud?.notify(`warning`,lf(r.skipCode,r.reason)),!1;if(r?.status===`error`)return Ud?.notify(`error`,`Save failed: ${r.reason??`The document could not be saved.`}`),!1;if(r?.status!==`saved`)return Ud?.notify(`error`,`Save failed: the server returned an invalid result.`),!1;t=!0,(e?.data?.integrityWarnings?.length??0)>0&&Ud?.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 i=e?.data?.fidelityWarnings?.length??0,a=e?.data?.unpreservedImports??0;i>0&&a>0?Ud?.notify(`warning`,`Saved — ${i} Word feature${i===1?` was`:`s were`} simplified on export, and the backed-up original has features this file doesn't. See the document notice for details.`):i>0?Ud?.notify(`warning`,`Saved — ${i} Word feature${i===1?` was`:`s were`} simplified on export; see the document notice for details.`):a>0&&Ud?.notify(`warning`,`Saved — the backed-up original has Word features this file doesn't. Your original can still be restored; see the document notice for details.`)}else{let e=(await n.json().catch(()=>({}))).message??n.statusText;console.warn(`[Tandem] Save failed:`,e),Ud?.notify(`error`,`Save failed: ${e}`)}}catch(e){console.warn(`[Tandem] Save request failed:`,e),Ud?.notify(`error`,`Save failed — check your connection and try again.`)}finally{Yd=!1,P(qd,t,!0),P(Kd,!1)}return t}function lf(e,t){switch(e){case`EXTERNAL_CONFLICT`:case`FILE_MODIFIED`:return`Not saved — this file changed on disk. Choose Keep or Reload before saving.`;case`PROMOTION_REQUIRED`:return`Not saved — choose Save As to turn this upload or scratchpad into a file.`;case`READ_ONLY`:return`Not saved — this document is read-only.`;case`UNSUPPORTED_FORMAT`:case`ADAPTER_UNAVAILABLE`:return`Not saved — this document format cannot be written to disk.`;case`SAVE_IN_PROGRESS`:return`Not saved — another save is already in progress. Try again in a moment.`;case`SOURCE_MISSING`:return`Not saved — the original file no longer exists. Reopen it or use Save As.`;case`FILE_STATE_UNAVAILABLE`:return`Not saved — Tandem could not verify the file state. Check access and try again.`;case`NOT_OPEN`:return`Not saved — the document is no longer open.`;case`EXPLICIT_ONLY`:return`Not saved automatically — use Save to write this document format.`;default:return`Not saved${t?` — ${t}.`:`.`}`}}var uf=!1;async function df(){let e;try{e=await fetch(`${Ns}${hl}`)}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 ff(){let e;try{e=await fetch(`${Ns}${gl}`,{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 pf(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 mf(e,t,n,r,i={}){let a=await ff();if(!a.ok)return e.notify(`error`,`Failed to acquire launcher nonce: ${a.kind}${a.detail?` (${a.detail})`:``}.`),null;let o=a.value;try{let a=await fetch(`${Ns}${t}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,nonce:o})});if(!a.ok){let t=await a.json().catch(()=>({}));return i.retryOnCode!==void 0&&t.code===i.retryOnCode?t.code:(e.notify(`error`,`${r.failPrefix}: ${t.message??a.statusText}`),null)}if(typeof r.successMessage==`string`)e.notify(`info`,r.successMessage);else{let t=await a.json().catch(()=>({}));e.notify(`info`,r.successMessage(t))}}catch(t){e.notify(`error`,`${r.requestFailPrefix}: ${t instanceof Error?t.message:t}`)}return null}async function hf(e){if(uf)return e.notify(`info`,`Already restarting Claude — hang on.`),!1;let t=await df();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):yd(n.reason)?(e.notify(`info`,`Claude is starting up — try again in a moment.`),!1):(e.notify(`warning`,`Claude launcher not active in this Tandem build.`),!1)}async function gf(e,{cwdRequired:t}){if(!await hf(e))return;let n=pf(e.getActiveDocumentPath());if(!n&&t){e.notify(`warning`,`Active document isn't saved to a folder. Set a working directory in Settings → Claude Code.`);return}let r=n?t?`Restart Claude in:\n${n}\n\nYour current task may be interrupted.`:`Restart Claude in:\n${n}\n\nIf that folder isn't usable, Claude restarts in its configured directory instead.\n\nYour current task may be interrupted.`:`Restart Claude in its configured working directory.
|
|
4
4
|
|
|
5
|
-
Your current task may be interrupted.`;if(confirm(r))
|
|
5
|
+
Your current task may be interrupted.`;if(!confirm(r))return;let i={failPrefix:`Relaunch failed`,requestFailPrefix:`Relaunch request failed`,successMessage:e=>typeof e?.cwd==`string`?`Claude restarting in ${e.cwd}.`:`Claude restarting.`};uf=!0;try{(n&&!t?await mf(e,`/api/launcher/relaunch`,{cwd:n},i,{retryOnCode:`PATH_REJECTED`}):await mf(e,`/api/launcher/relaunch`,n?{cwd:n}:{},i))!==null&&await mf(e,_l,{},i)}finally{uf=!1}}function _f(){Gd(`launcher-relaunch-here`,e=>void gf(e,{cwdRequired:!1}))}function vf(){Gd(`launcher-start-fresh`,e=>void yf(e))}async function yf(e){if(await hf(e)&&confirm(`Drop Claude's saved conversation and restart fresh. This cannot be undone.`)){uf=!0;try{await mf(e,vl,{},{failPrefix:`Start fresh failed`,requestFailPrefix:`Start-fresh request failed`,successMessage:`Claude restarting with a fresh conversation.`})}finally{uf=!1}}}var bf=!1;function xf(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}async function Sf(e){if(bf)return;let t=e.getActiveTabId();if(!t){e.notify(`warning`,`No active document.`);return}bf=!0;try{let n=await fetch(`${Ns}${rl}?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}. ${xf(e.timestamp)}`).join(`
|
|
6
6
|
`);if(!confirm(`Available backups (newest first):\n${a}\n\nRestore the most recent backup (${xf(i.timestamp)})? The document reloads with the backup's content; annotations are preserved.
|
|
7
7
|
|
|
8
8
|
Older backups can be restored by asking Claude (tandem_restoreBackup).`))return;let o=await fetch(`${Ns}${il}`,{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 ${xf(i.timestamp)}.`)}catch(t){e.notify(`error`,`Restore request failed: ${t instanceof Error?t.message:t}`)}finally{bf=!1}}async function Cf(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 ac(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 wf=[{id:`save`,label:`Save document`,group:`document`,shortcut:`Ctrl+S`,run(){Gd(`save`,e=>void e.save())}},{id:`settings`,label:`Open settings`,group:`view`,shortcut:`Ctrl+,`,run(){Gd(`settings`,e=>e.openSettings())}},{id:`toggle-mode`,label:`Toggle Solo / Tandem mode`,group:`document`,shortcut:`Ctrl+Shift+M`,run(){Gd(`toggle-mode`,e=>e.toggleSoloMode())}},{id:`new-scratchpad`,label:`New Scratchpad`,group:`document`,shortcut:`Ctrl+N`,run(){Qd()}},{id:`save-as`,label:`Save As…`,group:`document`,shortcut:`Ctrl+Shift+S`,run(){Gd(`save-as`,e=>void e.saveAs())}},{id:`focus-chat`,label:`Focus Chat`,group:`view`,shortcut:`Ctrl+Shift+J`,run(){Gd(`focus-chat`,e=>e.focusChat())}},{id:`close-tab`,label:`Close active tab`,group:`document`,shortcut:`Ctrl+W`,run(){Gd(`close-tab`,e=>e.closeActiveTab())}},{id:`open-file`,label:`Open file…`,group:`document`,shortcut:`Ctrl+O`,run(){Gd(`open-file`,e=>e.openFileDialog())}},{id:`find`,label:`Find / Replace`,group:`navigation`,shortcut:`Ctrl+F`,run(){Gd(`find`,e=>e.openFindBar())}},{id:`find-in-tabs`,label:`Find in open tabs`,group:`navigation`,shortcut:`Ctrl+Shift+F`,run(){Gd(`find-in-tabs`,e=>e.openFindBarTabs())}},{id:`find-next`,label:`Find next match`,group:`navigation`,shortcut:`Ctrl+G`,run(){Gd(`find-next`,e=>e.findNext())}},{id:`find-previous`,label:`Find previous match`,group:`navigation`,shortcut:`Ctrl+Shift+G`,run(){Gd(`find-previous`,e=>e.findPrev())}},{id:`toggle-left-panel`,label:`Toggle left panel`,group:`view`,shortcut:`Alt+Shift+Left`,run(){Gd(`toggle-left-panel`,e=>e.toggleLeftPanel())}},{id:`toggle-right-panel`,label:`Toggle right panel`,group:`view`,shortcut:`Alt+Shift+Right`,run(){Gd(`toggle-right-panel`,e=>e.toggleRightPanel())}},{id:`reopen-closed-tab`,label:`Reopen closed tab (this session)`,group:`document`,shortcut:`Ctrl+Alt+T`,run(){Gd(`reopen-closed-tab`,e=>e.reopenClosedTab())}},{id:`annotation-next`,label:`Next annotation`,group:`annotations`,shortcut:`Alt+]`,run(){Gd(`annotation-next`,e=>e.annotationNext())}},{id:`annotation-previous`,label:`Previous annotation`,group:`annotations`,shortcut:`Alt+[`,run(){Gd(`annotation-previous`,e=>e.annotationPrev())}},{id:`annotation-accept`,label:`Accept focused annotation`,group:`annotations`,shortcut:`Ctrl+Enter`,run(){Gd(`annotation-accept`,e=>e.annotationAccept())}},{id:`annotation-dismiss`,label:`Dismiss focused annotation`,group:`annotations`,shortcut:`Ctrl+Shift+Enter`,run(){Gd(`annotation-dismiss`,e=>e.annotationDismiss())}},{id:`select-block`,label:`Select containing block`,group:`editor`,shortcut:`Alt+L`,run(){Gd(`select-block`,e=>e.selectBlock())}},{id:`toggle-authorship`,label:`Toggle authorship colors`,group:`view`,shortcut:`Ctrl+Alt+A`,run(){Gd(`toggle-authorship`,e=>e.toggleAuthorship())}},{id:`toggle-formatting-bar`,label:`Toggle formatting bar`,group:`view`,run(){Gd(`toggle-formatting-bar`,e=>e.toggleFormattingBar())}},{id:`toggle-source-view`,label:`View / exit Markdown source`,group:`view`,shortcut:`Ctrl+Shift+E`,run(){Gd(`toggle-source-view`,e=>e.toggleSourceView())}},{id:`restore-backup`,label:`Restore a backup of this document…`,group:`document`,run(){Gd(`restore-backup`,e=>void Sf(e))}},{id:`launcher-relaunch-here`,label:`Relaunch Claude in this folder`,group:`claude`,run(){Gd(`launcher-relaunch-here`,e=>void gf(e,{cwdRequired:!0}))}},{id:`launcher-start-fresh`,label:`Start fresh Claude conversation`,group:`claude`,run(){Gd(`launcher-start-fresh`,e=>void yf(e))}},...$d()?[{id:`show-in-file-explorer`,label:`Show in file explorer`,group:`document`,run(){Gd(`show-in-file-explorer`,e=>void Cf(e))}}]:[]];for(let e of wf)Vd(e);function Tf(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 Ef(e){let t=e.querySelector(`[role="tab"]`),n=e.querySelector(`[data-testid^="tab-name-"]`);if(!t||!n)return 142;let r=getComputedStyle(t),i=Array.from(t.children).filter(e=>e instanceof HTMLElement),a=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)+parseFloat(r.borderLeftWidth)+parseFloat(r.borderRightWidth)+Math.max(0,i.length-1)*(parseFloat(r.columnGap)||0);for(let e of i)e!==n&&(a+=e.getBoundingClientRect().width);let o=parseFloat(getComputedStyle(n).maxWidth)||1/0,s=Math.min(n.scrollWidth+1,o),c=Math.min(a+s,142);return Number.isFinite(c)?c:142}function Df(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 Of=Df(.2,.8,.2,1),kf=Df(.4,0,.2,1),Af=Df(.4,0,1,1),jf=260,Mf=260,Nf=280;function Pf(e){return e?!0:typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ff(e){return{h:e.offsetHeight,mb:Number.parseFloat(getComputedStyle(e).marginBottom)||0}}function If(e,{enabled:t,reduceMotion:n}){if(!t||Pf(n))return{duration:0};let{h:r,mb:i}=Ff(e);return{duration:jf,easing:Of,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 Lf(e,{enabled:t,reduceMotion:n,id:r,modes:i}){let a=i?.get(r);if(i?.delete(r),!t||Pf(n))return{duration:0};let{h:o,mb:s}=Ff(e),c=e=>a===`accept`?`translateY(${-8*e}px)`:a===`dismiss`?`translateX(${40*e}px) scale(${1-.04*e})`:`none`;return{duration:Mf,easing:Of,css:(e,t)=>`opacity:${e}; height:${e*o}px; margin-bottom:${e*s}px; transform:${c(t)}; overflow:clip; box-sizing:border-box;`}}function Rf(e,{reduceMotion:t}){if(Pf(t))return{duration:0};let{h:n,mb:r}=Ff(e);return{duration:Nf,easing:Of,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 zf(e,{reduceMotion:t,exitMs:n=200}){if(Pf(t))return{duration:0};let{h:r,mb:i}=Ff(e);return{duration:n,easing:kf,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 Bf=new Map,Vf=480,Hf=1e3;function Uf(e,t){Bf.set(e,t),setTimeout(()=>Bf.delete(e),Hf)}function Wf(e,{id:t,reduceMotion:n}){let r=Bf.get(t);if(Bf.delete(t),!r||Pf(n))return{duration:0};let i=e.getBoundingClientRect(),a=r.left-i.left,o=r.top-i.top;return{duration:Vf,easing:Of,css:(e,t)=>`transform:translate(${a*t}px, ${o*t}px); opacity:${.2+.8*e};`}}var Gf=200;function Kf(e,{reduceMotion:t}){if(Pf(t))return{duration:0};let n=e.offsetWidth;return{duration:Gf,easing:Of,css:e=>`opacity:${e}; width:${e*n}px; min-width:0; overflow:clip; box-sizing:border-box; pointer-events:none;`}}var qf=220;function Jf(e,{reduceMotion:t,uniformTabWidth:n}){if(Pf(t))return{duration:0};let r=n?e.offsetWidth:Ef(e);return{duration:qf,easing:Of,css:e=>`opacity:${e}; width:${e*r}px; min-width:0; overflow:clip; box-sizing:border-box;`}}function Yf(e,{reduceMotion:t}){if(Pf(t))return{duration:0};let n=e.offsetWidth,r=e.offsetHeight;return{duration:440,easing:Of,css:e=>`opacity:${e}; width:${e*n}px; height:${e*r}px; overflow:clip; box-sizing:border-box;`}}var Xf=380;function Zf(e,{reduceMotion:t}){if(Pf(t))return{duration:0};let{h:n,mb:r}=Ff(e);return{duration:Xf,easing:Of,css:e=>`opacity:${e}; height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box;`}}var Qf=240,$f=200;function ep(e,{reduceMotion:t}){if(Pf(t))return{duration:0};let{h:n,mb:r}=Ff(e);return{duration:Qf,easing:Of,css:(e,t)=>`opacity:${e}; transform:translateY(${10*t}px); height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box;`}}function tp(e,{reduceMotion:t}){if(Pf(t))return{duration:0};let{h:n,mb:r}=Ff(e);return{duration:$f,easing:Af,css:(e,t)=>`opacity:${e}; transform:translateX(${8*t}px); height:${e*n}px; margin-bottom:${e*r}px; overflow:clip; box-sizing:border-box; pointer-events:none;`}}var np=220,rp=$f;function ip(e,{reduceMotion:t}){if(Pf(t))return{duration:0};let{h:n}=Ff(e);return{duration:np,delay:rp,easing:Of,css:e=>`opacity:${e}; height:${e*n}px; overflow:clip; box-sizing:border-box;`}}function ap(e){return e.type===`save-error`&&e.documentId?{label:`Retry`,documentId:e.documentId}:null}var op={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 sp(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 cp=U(`<button type="button" data-testid="activity-clear-all" class="svelte-bf7dij">Clear all</button>`),lp=Jr(`<path class="svelte-bf7dij"></path>`),up=U(`<span> </span>`),dp=U(`<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>`),fp=U(`<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>`),pp=U(`<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>`),mp=U(`<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 class="tray-list svelte-bf7dij"></div> <!></div>`),hp=U(`<span class="svelte-bf7dij">No activity</span>`),gp=U(`<span class="svelte-bf7dij">Activity</span> <span class="count svelte-bf7dij"> </span>`,1),_p=U(`<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 vp(e,t){A(t,!0);let n=N(null),r=N(null);z(()=>{if(!t.open)return;let e=e=>{let r=e.target;!(r instanceof Node)||V(n)?.contains(r)||t.onToggle()},i=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t.onToggle(),queueMicrotask(()=>V(r)?.focus()))};return document.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,i,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,i,!0)}});let i=M(()=>t.items.length),a=M(()=>[...t.items].reverse()),o=M(()=>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`),s=N(F(Date.now())),c=setInterval(()=>{P(s,Date.now(),!0)},3e4),l=[240,160,84,16,8,6],u=[540,650,760,870,980,1090],d=e=>Math.min(e,l.length-1),f=N(F([])),p=!1,m,h=new Map;function g(e,t){return h.get(e)===t?!1:(h.set(e,t),!0)}In(()=>{t.open&&!p?(P(f,Ar(()=>V(a).map(e=>e.id)),!0),m&&clearTimeout(m),m=setTimeout(()=>{P(f,[],!0)},1800)):!t.open&&p&&(P(f,[],!0),m&&=(clearTimeout(m),void 0)),p=t.open}),z(()=>{let e=new Set(t.items.map(e=>e.id));for(let t of h.keys())e.has(t)||h.delete(t)}),ba(()=>{clearInterval(c),m&&clearTimeout(m)});var _=_p(),v=I(_);let y;var b=I(v),x=I(b),S=e=>{var n=mp(),r=I(n),o=R(I(r),2),c=I(o,!0);O(o);var p=R(o,4),m=e=>{var n=cp();H(`click`,n,function(...e){t.onClear?.apply(this,e)}),W(e,n)};K(p,e=>{V(i)>0&&e(m)}),O(r);var h=R(r,2);pi(h,21,()=>V(a),e=>e.id,(e,n)=>{let r=M(()=>ap(V(n))),i=M(()=>V(f).indexOf(V(n).id));var a=fp();let o,c;var p=I(a),m=I(p);pi(m,20,()=>op[V(n).severity],e=>e,(e,t)=>{var n=lp();B(()=>J(n,`d`,t)),W(e,n)}),O(m),O(p);var h=R(p,2),_=I(h),v=I(_),y=I(v,!0);O(v);var b=R(v,2),x=e=>{var t=Xr();ci(L(t),()=>V(n).count,e=>{let t=M(()=>g(V(n).id,V(n).count));var r=up();let i;var a=I(r);O(r),B(()=>{i=Ui(r,1,`badge svelte-bf7dij`,null,i,{pop:V(t)}),G(a,`×${V(n).count??``}`)}),W(e,r)}),W(e,t)};K(b,e=>{V(n).count>1&&e(x)});var S=R(b,2),C=I(S,!0);O(S),O(_);var w=R(_,2),T=e=>{var i=dp(),a=R(I(i));O(i),B(()=>{J(i,`data-testid`,`activity-action-${V(n).id}`),G(a,` ${V(r).label??``}`)}),H(`click`,i,()=>t.onAction(V(n))),W(e,i)};K(w,e=>{V(r)&&e(T)}),O(h);var ee=R(h,2);O(a),B((e,t)=>{o=Ui(a,1,`toast-row ${V(n).severity??``}`,`svelte-bf7dij`,o,{"cascade-row":V(i)>=0}),J(a,`data-testid`,`activity-row-${V(n).id}`),c=q(a,``,c,e),G(y,V(n).message),G(C,t),J(ee,`data-testid`,`activity-dismiss-${V(n).id}`)},[()=>({"--slide-y":V(i)>=0?`${l[d(V(i))]}px`:null,"animation-delay":V(i)>=0?`${u[d(V(i))]}ms`:null}),()=>sp(V(n).timestamp,V(s))]),H(`click`,ee,()=>t.onDismiss(V(n).id)),Mi(1,a,()=>ep,()=>({reduceMotion:t.reduceMotion})),Mi(2,a,()=>tp,()=>({reduceMotion:t.reduceMotion})),W(e,a)}),O(h);var _=R(h,2),v=e=>{var n=pp();Mi(1,n,()=>ip,()=>({reduceMotion:t.reduceMotion})),W(e,n)};K(_,e=>{V(i)===0&&e(v)}),O(n),B(()=>G(c,V(i)===0?`No events`:`${V(i)} event${V(i)===1?``:`s`}`)),W(e,n)};K(x,e=>{t.open&&e(S)}),O(b);var C=R(b,2),w=R(I(C),2),T=e=>{W(e,hp())},ee=e=>{var t=gp(),n=R(L(t),2),r=I(n,!0);O(n),B(()=>G(r,V(i))),W(e,t)};K(w,e=>{V(i)===0?e(T):e(ee,-1)}),k(4),O(C),fa(C,e=>P(r,e),()=>V(r)),O(v),fa(v,e=>P(n,e),()=>V(n)),O(_),B(()=>{y=Ui(v,1,`activity-shell ${V(o)??``}`,`svelte-bf7dij`,y,{open:t.open}),J(C,`aria-expanded`,t.open),J(C,`aria-label`,t.open?`Close activity tray`:`Open activity tray`),J(C,`aria-controls`,t.open?`activity-tray`:void 0)}),H(`click`,C,function(...e){t.onToggle?.apply(this,e)}),W(e,_),j()}Br([`click`]);function yp(e){this.content=e}yp.prototype={constructor:yp,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 yp(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 yp(n)},addToStart:function(e,t){return new yp([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new yp(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 yp(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=yp.from(e),e.size?new yp(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=yp.from(e),e.size?new yp(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=yp.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}},yp.from=function(e){if(e instanceof yp)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new yp(t)};function bp(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=bp(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function xp(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=xp(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 bp(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return xp(this,e,t,n)}findIndex(e){if(e==0)return Cp(0,e);if(e==this.size)return Cp(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?Cp(t+1,i):Cp(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 Sp={index:0,offset:0};function Cp(e,t){return Sp.index=e,Sp.offset=t,Sp}function wp(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(!wp(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!wp(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var Tp=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&&wp(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}};Tp.none=[];var Ep=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=Op(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Dp(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 Dp(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(Dp(a.content,t-i-1,n-i-1)))}function Op(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=Op(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function kp(e,t,n){if(n.openStart>e.depth)throw new Ep(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ep(`Inconsistent open depths`);return Ap(e,t,n,0)}function Ap(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=Ap(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return Fp(a,Lp(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Fp(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Rp(n,e);return Fp(a,Ip(e,i,o,t,r))}}function jp(e,t){if(!t.type.compatibleContent(e.type))throw new Ep(`Cannot join `+t.type.name+` onto `+e.type.name)}function Mp(e,t,n){let r=e.node(n);return jp(r,t.node(n)),r}function Np(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 Pp(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&&(Np(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Np(i.child(e),r);t&&t.depth==n&&t.textOffset&&Np(t.nodeBefore,r)}function Fp(e,t){return e.type.checkContent(t),e.copy(t)}function Ip(e,t,n,r,i){let a=e.depth>i&&Mp(e,t,i+1),o=r.depth>i&&Mp(n,r,i+1),s=[];return Pp(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(jp(a,o),Np(Fp(a,Ip(e,t,n,r,i+1)),s)):(a&&Np(Fp(a,Lp(e,t,i+1)),s),Pp(t,n,i,s),o&&Np(Fp(o,Lp(n,r,i+1)),s)),Pp(r,null,i,s),new Z(s)}function Lp(e,t,n){let r=[];return Pp(null,e,n,r),e.depth>n&&Np(Fp(Mp(e,t,n+1),Lp(e,t,n+1)),r),Pp(t,null,n,r),new Z(r)}function Rp(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 zp=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 Tp.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 Up(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=Hp.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 Hp.set(t,r=new Bp);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Vp,i}},Bp=class{constructor(){this.elts=[],this.i=0}},Vp=12,Hp=new WeakMap,Up=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)}},Wp=Object.create(null),Gp=class e{constructor(e,t,n,r=Tp.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&&wp(this.attrs,t||e.defaultAttrs||Wp)&&Tp.sameSet(this.marks,n||Tp.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 kp(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 zp.resolveCached(this,e)}resolveNoCache(e){return zp.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()+`)`),qp(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=Tp.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(!Tp.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}};Gp.prototype.text=void 0;var Kp=class e extends Gp{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):qp(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 qp(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Jp=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Yp(t,n);if(r.next==null)return e.empty;let i=Xp(r);r.next&&r.err(`Unexpected trailing text`);let a=om(rm(i));return sm(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(`
|
|
@@ -138,7 +138,7 @@ Older backups can be restored by asking Claude (tandem_restoreBackup).`))return;
|
|
|
138
138
|
Claude Desktop) is the default integration — auto-configured, tested, and the only client whose
|
|
139
139
|
channel-push, cowork, and auto-launch extras are validated today. Other clients can connect
|
|
140
140
|
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" 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"/> <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"/> <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);">Cards sit beside the text they reference. They shrink when space is tight —
|
|
141
|
-
click one, or its chevron, to expand it.</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 CN(e,t){A(t,!0);function n(e){switch(e){case xd:return`Working directory must be a folder inside your home directory.`;case bd:return`Working directory path is invalid.`;case Sd:return`Another working-directory update is in progress. Try again.`;case wd:return`No Claude Code integration is configured.`;case Cd: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=N(null),a=N(!1),o=N(null),s=N(!1),c=N(!1),l=N(null),u=M(()=>V(s)&&!V(c)&&!V(l)),d=!0;ba(()=>{d=!1});async function f(){try{let e=await fetch(`${Ns}/api/integrations`);if(!d)return;if(!e.ok){P(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&&(P(c,!0),P(i,n.workingDirectory??null,!0))}catch(e){if(!d)return;console.warn(`[Settings] Failed to load workingDirectory:`,e),P(l,`Couldn't load Claude working directory.`)}finally{d&&P(s,!0)}}f();async function p(e){P(a,!0),P(o,null);try{let r=await fetch(`${Ns}${yl}`,{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;P(o,n(e.code),!0);return}let a=await r.json();if(!d)return;P(i,a.workingDirectory??null,!0),t.notify(`info`,`Working directory saved.`)}catch(e){if(!d)return;console.warn(`[Settings] Failed to save workingDirectory:`,e),P(o,`Couldn't save working directory.`)}finally{d&&P(a,!1)}}async function m(){let e;try{({open:e}=await ac(()=>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 _=SN(),v=L(_),y=e=>{var t=gN(),n=R(I(t),4);O(t),H(`click`,n,r),W(e,t)};K(v,e=>{V(u)&&e(y)});var b=R(v,4),x=I(b),S=R(I(x)),C=I(S);O(S),O(x);var w=R(x,4);$i(w),J(w,`step`,100);var T=R(w,2),ee=I(T),te=I(ee);O(ee);var ne=R(ee,2),E=I(ne);O(ne),O(T),O(b);var D=R(b,2),re=I(D);$i(re),k(2),O(D);var ie=R(D,2),ae=I(ie);$i(ae),k(2),O(ie);var oe=R(ie,4),se=e=>{var t=_N(),n=I(t,!0);O(t),B(()=>G(n,V(l))),W(e,t)};K(oe,e=>{V(s)&&!V(c)&&V(l)&&e(se)});var ce=R(oe,2),le=e=>{var t=bN(),n=R(I(t),4),r=I(n);$i(r),J(r,`placeholder`,`(default: home)`);var s=R(r,2);O(n);var c=R(n,2),l=I(c),u=e=>{var t=vN();B(()=>t.disabled=V(a)),H(`click`,t,m),W(e,t)},d=M(()=>ec());K(l,e=>{V(d)&&e(u)});var f=R(l,2);O(c);var p=R(c,2),_=e=>{var t=yN(),n=I(t,!0);O(t),B(()=>G(n,V(o))),W(e,t)};K(p,e=>{V(o)&&e(_)}),O(t),B(()=>{ea(r,V(i)??``),r.disabled=V(a),s.disabled=V(a),f.disabled=V(a)||V(i)===null}),zr(`submit`,n,h),H(`click`,f,g),W(e,t)};K(ce,e=>{V(s)&&V(c)&&e(le)});var ue=R(ce,2),de=I(ue,!0);O(ue);var fe=R(ue,2),pe=e=>{var t=Xr();oi(L(t),()=>ac(()=>import(`./CoworkSettings-
|
|
141
|
+
click one, or its chevron, to expand it.</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 CN(e,t){A(t,!0);function n(e){switch(e){case xd:return`Working directory must be a folder inside your home directory.`;case bd:return`Working directory path is invalid.`;case Sd:return`Another working-directory update is in progress. Try again.`;case wd:return`No Claude Code integration is configured.`;case Cd: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=N(null),a=N(!1),o=N(null),s=N(!1),c=N(!1),l=N(null),u=M(()=>V(s)&&!V(c)&&!V(l)),d=!0;ba(()=>{d=!1});async function f(){try{let e=await fetch(`${Ns}/api/integrations`);if(!d)return;if(!e.ok){P(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&&(P(c,!0),P(i,n.workingDirectory??null,!0))}catch(e){if(!d)return;console.warn(`[Settings] Failed to load workingDirectory:`,e),P(l,`Couldn't load Claude working directory.`)}finally{d&&P(s,!0)}}f();async function p(e){P(a,!0),P(o,null);try{let r=await fetch(`${Ns}${yl}`,{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;P(o,n(e.code),!0);return}let a=await r.json();if(!d)return;P(i,a.workingDirectory??null,!0),t.notify(`info`,`Working directory saved.`)}catch(e){if(!d)return;console.warn(`[Settings] Failed to save workingDirectory:`,e),P(o,`Couldn't save working directory.`)}finally{d&&P(a,!1)}}async function m(){let e;try{({open:e}=await ac(()=>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 _=SN(),v=L(_),y=e=>{var t=gN(),n=R(I(t),4);O(t),H(`click`,n,r),W(e,t)};K(v,e=>{V(u)&&e(y)});var b=R(v,4),x=I(b),S=R(I(x)),C=I(S);O(S),O(x);var w=R(x,4);$i(w),J(w,`step`,100);var T=R(w,2),ee=I(T),te=I(ee);O(ee);var ne=R(ee,2),E=I(ne);O(ne),O(T),O(b);var D=R(b,2),re=I(D);$i(re),k(2),O(D);var ie=R(D,2),ae=I(ie);$i(ae),k(2),O(ie);var oe=R(ie,4),se=e=>{var t=_N(),n=I(t,!0);O(t),B(()=>G(n,V(l))),W(e,t)};K(oe,e=>{V(s)&&!V(c)&&V(l)&&e(se)});var ce=R(oe,2),le=e=>{var t=bN(),n=R(I(t),4),r=I(n);$i(r),J(r,`placeholder`,`(default: home)`);var s=R(r,2);O(n);var c=R(n,2),l=I(c),u=e=>{var t=vN();B(()=>t.disabled=V(a)),H(`click`,t,m),W(e,t)},d=M(()=>ec());K(l,e=>{V(d)&&e(u)});var f=R(l,2);O(c);var p=R(c,2),_=e=>{var t=yN(),n=I(t,!0);O(t),B(()=>G(n,V(o))),W(e,t)};K(p,e=>{V(o)&&e(_)}),O(t),B(()=>{ea(r,V(i)??``),r.disabled=V(a),s.disabled=V(a),f.disabled=V(a)||V(i)===null}),zr(`submit`,n,h),H(`click`,f,g),W(e,t)};K(ce,e=>{V(s)&&V(c)&&e(le)});var ue=R(ce,2),de=I(ue,!0);O(ue);var fe=R(ue,2),pe=e=>{var t=Xr();oi(L(t),()=>ac(()=>import(`./CoworkSettings-CIN50SzA.js`),__vite__mapDeps([4,5])),e=>{W(e,xN())},(e,t)=>{let n=M(()=>V(t).default);var r=Xr();xi(L(r),()=>V(n),(e,t)=>{t(e,{})}),W(e,r)}),W(e,t)},me=M(()=>ec());K(fe,e=>{V(me)&&e(pe)}),B((e,n,r,i,a,o)=>{G(C,`${e??``}s`),J(w,`min`,500),J(w,`max`,Ba),ea(w,t.settings.selectionDwellMs),w.disabled=t.readOnly,q(w,`width: 100%; accent-color: var(--tandem-accent); ${n??``}`),G(te,`${r??``}s`),G(E,`${i??``}s`),ta(re,t.settings.selectionToolbar),re.disabled=t.readOnly,q(re,`accent-color: var(--tandem-accent); ${a??``}`),ta(ae,t.settings.marginView),ae.disabled=t.readOnly,q(ae,`accent-color: var(--tandem-accent); ${o??``}`),G(de,V(u)?`Open integration wizard…`:`Reopen integration wizard…`)},[()=>(t.settings.selectionDwellMs/1e3).toFixed(1),()=>Yk(t.readOnly,`auto`),()=>(500/1e3).toFixed(1),()=>(Ba/1e3).toFixed(1),()=>Yk(t.readOnly),()=>Yk(t.readOnly)]),H(`input`,w,e=>t.onUpdate({selectionDwellMs:Number(e.target.value)})),H(`change`,re,e=>t.onUpdate({selectionToolbar:e.target.checked})),H(`change`,ae,e=>t.onUpdate({marginView:e.target.checked})),H(`click`,ue,r),W(e,_),j()}Br([`click`,`input`,`change`]);function wN(e){let t=e?.trim();return t?t.slice(0,40):`You`}function TN(){try{return wN(localStorage.getItem(po))}catch{return`You`}}function EN(e){let t=wN(e);try{localStorage.setItem(po,t)}catch{}return typeof window<`u`&&window.dispatchEvent(new Event(mo)),t}function DN(e){let t=()=>e(TN()),n=t=>{t.key===`tandem:userName`&&e(wN(t.newValue))};return window.addEventListener(mo,t),window.addEventListener(`storage`,n),()=>{window.removeEventListener(mo,t),window.removeEventListener(`storage`,n)}}function ON(){let e=N(F(TN()));return ba(DN(t=>{P(e,t,!0)})),{get userName(){return V(e)},setUserName:t=>{P(e,EN(t),!0)}}}var kN=U(`<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"/> <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
|
|
142
142
|
restores when you return to Tandem.</div>`,1);function AN(e,t){A(t,!0);let n=ON(),r=N(F(n.userName)),i=N(void 0);z(()=>{let e=n.userName;V(r)!==e&&document.activeElement!==V(i)&&P(r,e,!0)});var a=kN(),o=L(a),s=R(I(o),2);$i(s),fa(s,e=>P(i,e),()=>V(i)),O(o);var c=R(o,2),l=R(I(c),2),u=I(l),d=R(u,2);O(l),k(2),O(c);var f=R(c,2),p=I(f);$i(p),k(2),O(f),k(2),B(e=>{ea(s,V(r)),J(s,`maxlength`,40),J(u,`aria-checked`,t.settings.defaultMode===`tandem`),u.disabled=t.readOnly,J(d,`aria-checked`,t.settings.defaultMode===`solo`),d.disabled=t.readOnly,ta(p,t.settings.soloRailHidden),p.disabled=t.readOnly,q(p,`accent-color: var(--tandem-accent); ${e??``}`)},[()=>Yk(t.readOnly)]),H(`input`,s,e=>{P(r,e.target.value,!0)}),zr(`blur`,s,()=>n.setUserName(V(r))),H(`keydown`,s,e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(P(r,n.userName,!0),e.currentTarget.blur())}),H(`click`,u,()=>t.onUpdate({defaultMode:`tandem`})),H(`click`,d,()=>t.onUpdate({defaultMode:`solo`})),H(`change`,p,e=>t.onUpdate({soloRailHidden:e.target.checked})),W(e,a),j()}Br([`input`,`keydown`,`click`,`change`]);var jN=U(`<option> </option>`),MN=U(`<span class="mem-provider-note svelte-1pwv6ag" data-testid="model-edit-provider-note">Cloud providers are coming in a future release. For now, choose a local
|
|
143
143
|
provider (Ollama or llama.cpp).</span>`),NN=U(`<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>`),PN=U(`<input data-testid="model-edit-apikey" class="mem-input mem-input--mono svelte-1pwv6ag" type="password" autocomplete="off"/>`),FN=U(`<label class="mem-field svelte-1pwv6ag"><span class="mem-label svelte-1pwv6ag">API key</span> <!></label>`),IN=U(`<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>`),LN=U(`<p class="mem-advanced-help svelte-1pwv6ag">Per-model parameter overrides (temperature, max tokens, etc.) are not editable in
|
|
144
144
|
this preview. The data model accepts a \`params\` map for forward-compat with
|
|
@@ -148,7 +148,7 @@ Older backups can be restored by asking Claude (tandem_restoreBackup).`))return;
|
|
|
148
148
|
releases are no longer offered on this device. Renew to receive updates again.</div>`),mP=U(`<div class="license-warning svelte-ezrf0s" data-testid="license-unverifiable-warning" role="alert"> </div>`),hP=U(`<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
|
|
149
149
|
the command line. A valid license unlocks editing and runs forever; the update window is
|
|
150
150
|
separate and is shown above once activated.</div> <div class="settings-hint" style="margin-top: var(--tandem-space-2);">Don't have one yet? <a data-testid="license-buy-link" target="_blank" rel="noopener noreferrer">Buy a license</a>. Trouble activating? Email <a> </a> — please don't post your
|
|
151
|
-
license key publicly, it contains your name and email address.</div></div>`);function gP(e,t){A(t,!0);let n=M(()=>ob.ui),r=M(()=>ob.status),i=M(()=>V(r)!=null&&!V(r).gateActive),a=M(()=>V(i)&&V(r)?.licenseInstalled===!0),o=M(()=>V(n).statusLabel||(V(a)?V(r)?.licenseeName?`License installed for ${V(r).licenseeName} — takes effect at v1.0`:`License installed — takes effect at v1.0`:`Not enforced in this version`));function s(){t.notify(`info`,`License activated.`)}var c=hP(),l=R(I(c),2),u=I(l,!0);O(l);var d=R(l,2),f=e=>{W(e,dP())},p=e=>{W(e,fP())};K(d,e=>{V(i)&&!V(a)?e(f):V(a)&&e(p,1)});var m=R(d,2),h=e=>{W(e,pP())};K(m,e=>{V(r)?.gateActive&&V(r).status===`licensed`&&!V(r).updateWindowCurrent&&e(h)});var g=R(m,2),_=e=>{var t=mP(),n=I(t,!0);O(t),B(e=>G(n,e),[()=>ub(V(r).licenseUnverifiable)]),W(e,t)};K(g,e=>{V(r)?.licenseUnverifiable&&e(_)});var v=R(g,4);gb(v,{onActivated:s});var y=R(v,4),b=R(I(y)),x=R(b,2),S=I(x,!0);O(x),k(),O(y),O(c),B(()=>{G(u,V(o)),J(b,`href`,Ea),J(x,`href`,`mailto:support@tandem.ink`),G(S,Da)}),W(e,c),j()}var _P=null;function vP(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function yP(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 bP(e){return e.replace(/(\/Users\/)[^/\\]+/g,`$1[user]`).replace(/(\/home\/)[^/\\]+/g,`$1[user]`).replace(/([A-Za-z]:\\Users\\)[^\\]+/g,`$1[user]`)}function xP(e){return bP(yP(e))}async function SP(){if(vP())try{let{invoke:e}=await ac(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);if(!await e(`sentry_enabled`).catch(()=>!1))return;let t=await ac(()=>import(`./prod-
|
|
151
|
+
license key publicly, it contains your name and email address.</div></div>`);function gP(e,t){A(t,!0);let n=M(()=>ob.ui),r=M(()=>ob.status),i=M(()=>V(r)!=null&&!V(r).gateActive),a=M(()=>V(i)&&V(r)?.licenseInstalled===!0),o=M(()=>V(n).statusLabel||(V(a)?V(r)?.licenseeName?`License installed for ${V(r).licenseeName} — takes effect at v1.0`:`License installed — takes effect at v1.0`:`Not enforced in this version`));function s(){t.notify(`info`,`License activated.`)}var c=hP(),l=R(I(c),2),u=I(l,!0);O(l);var d=R(l,2),f=e=>{W(e,dP())},p=e=>{W(e,fP())};K(d,e=>{V(i)&&!V(a)?e(f):V(a)&&e(p,1)});var m=R(d,2),h=e=>{W(e,pP())};K(m,e=>{V(r)?.gateActive&&V(r).status===`licensed`&&!V(r).updateWindowCurrent&&e(h)});var g=R(m,2),_=e=>{var t=mP(),n=I(t,!0);O(t),B(e=>G(n,e),[()=>ub(V(r).licenseUnverifiable)]),W(e,t)};K(g,e=>{V(r)?.licenseUnverifiable&&e(_)});var v=R(g,4);gb(v,{onActivated:s});var y=R(v,4),b=R(I(y)),x=R(b,2),S=I(x,!0);O(x),k(),O(y),O(c),B(()=>{G(u,V(o)),J(b,`href`,Ea),J(x,`href`,`mailto:support@tandem.ink`),G(S,Da)}),W(e,c),j()}var _P=null;function vP(){return typeof window<`u`&&`__TAURI_INTERNALS__`in window}function yP(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 bP(e){return e.replace(/(\/Users\/)[^/\\]+/g,`$1[user]`).replace(/(\/home\/)[^/\\]+/g,`$1[user]`).replace(/([A-Za-z]:\\Users\\)[^\\]+/g,`$1[user]`)}function xP(e){return bP(yP(e))}async function SP(){if(vP())try{let{invoke:e}=await ac(async()=>{let{invoke:e}=await import(`./core-SwWLTXZB.js`);return{invoke:e}},[]);if(!await e(`sentry_enabled`).catch(()=>!1))return;let t=await ac(()=>import(`./prod-CXXJO_PR.js`),[]),{defaultOptions:n}=await ac(async()=>{let{defaultOptions:e}=await import(`./dist-Bq041SL2.js`);return{defaultOptions:e}},__vite__mapDeps([6,7]));t.init({...n,sendDefaultPii:!1,beforeSend:e=>{e.message&&=xP(e.message);for(let t of e.exception?.values??[])t.value&&=xP(t.value);return e.request&&(e.request.data=void 0,e.request.url&&(e.request.url=xP(e.request.url))),e},beforeBreadcrumb:e=>(e.message&&=xP(e.message),(e.category===`fetch`||e.category===`xhr`)&&(e.data=void 0),e)}),_P=t,window.addEventListener(`error`,e=>{wP(e.error??e.message,{source:`window.onerror`})}),window.addEventListener(`unhandledrejection`,e=>{wP(e.reason,{source:`unhandledrejection`})}),console.info(`[sentry] client crash reporting initialised`)}catch(e){console.warn(`[sentry] client init failed (non-fatal):`,e)}}function CP(){return _P!==null}function wP(e,t){if(_P)try{_P.captureException(e,t?{extra:t}:void 0)}catch{}}var TP={pass:`[ok] `,warn:`[warn]`,fail:`[fail]`};function EP(e){return e.replace(/[\x00-\x08\x0b-\x1f\x7f]/g,``)}function DP(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(`${TP[n.status]} ${n.check} — ${EP(n.message)}`),n.status!==`pass`&&n.fix&&t.push(` fix: ${EP(n.fix)}`);return t.push(``,EP(e.report.summary)),t.join(`
|
|
152
152
|
`)}var OP=U(`<div style="margin-top: 6px; font-size: 11px; color: var(--tandem-error-fg);"> </div>`),kP=U(`<button type="button" data-testid="settings-modal-open-log-folder-btn">Open Log Folder</button>`),AP=U(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">Loading...</div>`),jP=U(`<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),MP=U(`<dl style="display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 11px;"></dl>`),NP=U(`<div style="font-size: 11px; color: var(--tandem-fg-subtle);">App info unavailable.</div>`),PP=U(`<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 FP(e,t){A(t,!0);let n=MM(()=>t.open),r=N(!1),i=N(null),a=N(!1);async function o(){P(a,!0);let e;try{let n;try{n=await fetch(`${Ns}${Gc}`)}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=DP(await n.json())}catch{t.notify(`error`,"Diagnostics failed on the server — try `tandem doctor` in a terminal");return}finally{P(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([ac(()=>import(`./path-49-uTKly.js`),__vite__mapDeps([0,1])),a_()]);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){P(i,`Documentation file not found.`);return}P(r,!0),P(i,null);let t=await W_(e,{readOnly:!0,notFoundMessage:`Documentation file not found.`,failureMessage:`Failed to open documentation.`});P(r,!1),t.ok||P(i,t.error,!0)}let l=M(()=>{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:CP()?`On (TANDEM_SENTRY_DSN set)`:`Off — opt in with TANDEM_SENTRY_DSN`}),t});var u=PP(),d=L(u),f=I(d),p=I(f,!0);O(f);var m=R(f,2),h=e=>{var t=OP(),n=I(t,!0);O(t),B(()=>G(n,V(i))),W(e,t)};K(m,e=>{V(i)&&e(h)}),O(d);var g=R(d,2),_=I(g),v=I(_,!0);O(_);var y=R(_,2),b=e=>{var t=kP();q(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;`),H(`click`,t,()=>void s()),W(e,t)},x=M(()=>ec());K(y,e=>{V(x)&&e(b)}),O(g);var S=R(g,2),C=R(I(S),2),w=e=>{W(e,AP())},T=e=>{var t=MP();pi(t,21,()=>V(l),e=>e.label,(e,t)=>{var n=jP(),r=L(n),i=I(r,!0);O(r);var a=R(r,2),o=I(a,!0);O(a),B(()=>{G(i,V(t).label),G(o,V(t).value)}),W(e,n)}),O(t),W(e,t)},ee=e=>{W(e,NP())};K(C,e=>{n.loading?e(w):n.info?e(T,1):e(ee,-1)}),O(S),B(()=>{f.disabled=V(r)||n.loading,q(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: ${V(r)||n.loading?`not-allowed`:`pointer`}; background: var(--tandem-surface-muted); color: var(--tandem-fg); opacity: ${V(r)||n.loading?.6:1};`),G(p,V(r)?`Opening…`:`View Documentation`),_.disabled=V(a),q(_,`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: ${V(a)?`not-allowed`:`pointer`}; opacity: ${V(a)?.6:1};`),G(v,V(a)?`Collecting…`:`Copy Diagnostics`)}),H(`click`,f,()=>void c()),H(`click`,_,()=>void o()),W(e,u),j()}Br([`click`]);var IP={appearance:`appearance`,editor:`editor`,network:`network`,accessibility:`accessibility`,collaboration:`collaboration`,claudeCode:`claude-code`,models:`models`,shortcuts:`shortcuts`,license:`license`,about:`about`},LP=U(`<span class="settings-modal-version-chip svelte-bbu5nk" data-testid="settings-modal-sidebar-version"> </span>`),RP=U(`<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>`),zP=U(`<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>`),BP=U(`<div role="alert" data-testid="settings-modal-replay-error" style="font-size: 11px; color: var(--tandem-error-fg); padding: 0 var(--tandem-space-2);"> </div>`),VP=U(`<button type="button" data-testid="settings-modal-replay-tutorial-btn" class="settings-modal-sidebar-link svelte-bbu5nk"> </button> <!>`,1),HP=U(`<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 UP(e,t){A(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:KM},{id:`editor`,label:`Editor`,icon:`M4 4h11M4 9h16M4 14h11M4 19h16`,component:XM},{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:hN},{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:IM},{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:AN},{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:CN},{id:`models`,label:`Models`,icon:`M4 4h16v16H4V4Zm5-3v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3M8 8h8v8H8V8Z`,component:QN},{id:`shortcuts`,label:`Shortcuts`,icon:`M3 7h2v2H3V7Zm0 4h2v2H3v-2Zm0 4h2v2H3v-2Zm4-8h2v2H7V7Zm0 4h2v2H7v-2Zm0 4h10v2H7v-2Zm4-8h10v2H11V7Zm0 4h6v2h-6v-2Zm8 0h2v2h-2v-2Z`,component:uP},{id:`license`,label:`License`,icon:`M6 10h12v10H6V10Zm2 0V7a4 4 0 0 1 8 0v3`,component:gP},{id:`about`,label:`About`,icon:`M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm0 4v6m0 4h.01`,component:FP}].filter(e=>e.id!==IP.models||!1),i=Y(t,`returnFocusEl`,3,null),a=Y(t,`triggerEl`,3,null),o=Y(t,`connected`,3,!1),s=Y(t,`reconnectAttempts`,3,0),c=Y(t,`tabs`,3,r),l=Y(t,`initialTabId`,3,null),u=Y(t,`notify`,3,()=>{}),d=N(void 0),f=N(void 0),p=MM(()=>t.open),m=N(!1),h=N(null),g=N(!1),_=N(null),v=N(!1);z(()=>{t.open&&P(v,!1)});let y=!1;z(()=>{if(t.open&&!y&&l()){let e=V(w).find(e=>e.id===l());e&&P(T,e.id,!0)}y=t.open});let b=N(!1);z(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(max-width: 860px)`);P(b,e.matches,!0);let t=e=>{P(b,e.matches,!0)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)});let x=null;z(()=>{if(!t.open)return;x=null;let e=e=>{let t=e.target;x=t instanceof HTMLElement&&V(d)?.contains(t)?t:null};return document.addEventListener(`focusin`,e),()=>document.removeEventListener(`focusin`,e)});function S(){if(!t.open||!V(d))return;let e=x;if(!e||e===V(d)||e.isConnected&&!V(d).contains(e))return;let n=fb(V(d));if(n.includes(e))return;let r=document.activeElement;if(r instanceof Node&&r!==e&&V(d).contains(r))return;let i=V(b)?V(f):V(d).querySelector(`.settings-modal-nav-btn[aria-current="page"]`);(i&&n.includes(i)?i:n[0]??V(d)).focus()}let C=null;z(()=>{if(!t.open)return;let e=e=>{e.relatedTarget||x&&C===null&&(C=requestAnimationFrame(()=>{C=null,S()}))};return document.addEventListener(`focusout`,e),()=>{document.removeEventListener(`focusout`,e),C!==null&&(cancelAnimationFrame(C),C=null)}});let w=M(()=>c().length>0?c():r),T=N(F(r[0].id)),ee=M(()=>V(w).find(e=>e.id===V(T))??V(w)[0]),te=M(()=>V(ee).label),ne=M(()=>t.settings._readOnly===!0),E=M(()=>({open:t.open,settings:t.settings,onUpdate:t.onUpdate,connected:o(),reconnectAttempts:s(),readOnly:V(ne),notify:u()}));z(()=>{V(ee)&&V(ee).id!==V(T)&&P(T,V(ee).id,!0)}),z(()=>{if(t.open)return Ar(()=>V(d)?.focus()),()=>{i()?.focus()}}),z(()=>{if(!t.open)return;let e=e=>{let n=e.target;n&&(a()?.contains(n)||V(d)&&!V(d).contains(n)&&t.onClose())},n=setTimeout(()=>document.addEventListener(`pointerdown`,e),0);return()=>{clearTimeout(n),document.removeEventListener(`pointerdown`,e)}}),ya(()=>{let e=e=>{if(e.key!==`Escape`||!t.open)return;let n=e.target;if(!(!V(d)||!n||!V(d).contains(n))){if(e.stopPropagation(),V(b)&&V(v)){P(v,!1);return}t.onClose()}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),z(()=>{if(!t.open)return;let e=e=>pb(e,V(d)??null);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),z(()=>{V(T),P(h,null),P(_,null)});async function D(){let e=p.info?.changelogPath;if(!e){P(h,`Changelog file not found.`);return}P(m,!0),P(h,null);let n=await W_(e,{readOnly:!0,notFoundMessage:`Changelog file not found.`,failureMessage:`Failed to open changelog.`});P(m,!1),n.ok?t.onClose():P(h,n.error,!0)}async function re(){let e=p.info?.welcomePath;if(!e){P(_,`Welcome document not found.`);return}P(g,!0),P(_,null);let n=await W_(e,{force:!0,notFoundMessage:`Welcome document not found.`,failureMessage:`Couldn't reopen the welcome tutorial.`});P(g,!1),n.ok?(t.onReplayTutorial?.(),t.onClose()):P(_,n.error,!0)}var ie={DEFAULT_SETTINGS_TABS:r},ae=Xr(),oe=L(ae),se=e=>{var r=HP(),i=L(r),a=M(()=>__(t.onClose)),c=R(i,2);J(c,`aria-labelledby`,n),J(c,`tabindex`,-1);var l=I(c),u=I(l),y=I(u);J(y,`id`,n);var x=R(y,2),S=e=>{var t=LP(),n=I(t);O(t),B(()=>G(n,`v${p.info.version??``}`)),W(e,t)};K(x,e=>{p.info&&e(S)}),O(u);var C=R(u,2);pi(C,21,()=>V(w),e=>e.id,(e,t)=>{var n=RP(),r=I(n),i=I(r);O(r);var a=R(r,2),o=I(a,!0);O(a),O(n),B(()=>{J(n,`aria-current`,V(T)===V(t).id?`page`:void 0),J(n,`data-active`,V(T)===V(t).id?`true`:`false`),J(n,`data-testid`,`settings-modal-tab-${V(t).id}`),J(i,`d`,V(t).icon),G(o,V(t).label)}),H(`click`,n,()=>{P(T,V(t).id,!0),P(v,!1)}),W(e,n)}),O(C);var ie=R(C,2),ae=I(ie),oe=I(ae,!0);O(ae);var se=R(ae,2),ce=e=>{var t=zP(),n=I(t,!0);O(t),B(()=>G(n,V(h))),W(e,t)};K(se,e=>{V(h)&&e(ce)});var le=R(se,2),ue=e=>{var t=VP(),n=L(t),r=I(n,!0);O(n);var i=R(n,2),a=e=>{var t=BP(),n=I(t,!0);O(t),B(()=>G(n,V(_))),W(e,t)};K(i,e=>{V(_)&&e(a)}),B(()=>{n.disabled=V(g)||p.loading,G(r,V(g)?`Reopening…`:`Replay tutorial`)}),H(`click`,n,()=>void re()),W(e,t)};K(le,e=>{p.info?.welcomePath&&t.onReplayTutorial&&e(ue)});var de=R(le,2),fe=R(de,2),pe=I(fe),me=R(pe,2),he=I(me),ge=e=>{W(e,Yr(`MCP connected`))},_e=e=>{W(e,Yr(`Reconnecting…`))},ve=e=>{W(e,Yr(`MCP offline`))};K(he,e=>{o()?e(ge):s()>0?e(_e,1):e(ve,-1)}),O(me),O(fe),O(ie),O(l),Pi(l,(e,t)=>Tf?.(e,t),()=>`y`);var ye=R(l,2),be=I(ye),xe=I(be);fa(xe,e=>P(f,e),()=>V(f));var Se=R(xe,2),Ce=I(Se,!0);O(Se);var we=R(Se,2);O(be);var Te=R(be,2),Ee=e=>{PM(e,{})};K(Te,e=>{V(ne)&&e(Ee)});var De=R(Te,2),Oe=I(De);ci(I(Oe),()=>V(ee).id,e=>{var t=Xr();xi(L(t),()=>V(ee).component,(e,t)=>{t(e,va(()=>V(E)))}),W(e,t)}),O(Oe),O(De),Pi(De,(e,t)=>Tf?.(e,t),()=>`y`),O(ye),O(c),fa(c,e=>P(d,e),()=>V(d)),B(()=>{J(c,`data-narrow-sidebar-open`,V(v)?`true`:`false`),l.inert=V(b)&&!V(v),ae.disabled=V(m)||p.loading,G(oe,V(m)?`Opening…`:`Changelog`),J(de,`href`,Ta),J(pe,`data-state`,o()?`connected`:s()>0?`reconnecting`:`disconnected`),J(xe,`aria-label`,V(v)?`Hide sections`:`Show sections`),J(xe,`aria-expanded`,V(v)),G(Ce,V(te))}),H(`click`,i,function(...e){t.onClose?.apply(this,e)}),H(`keydown`,i,function(...e){V(a)?.apply(this,e)}),H(`click`,ae,()=>void D()),H(`click`,xe,()=>{P(v,!V(v))}),H(`click`,we,function(...e){t.onClose?.apply(this,e)}),W(e,r)};return K(oe,e=>{t.open&&e(se)}),W(e,ae),j(ie)}Br([`click`,`keydown`]);var WP=Jr(`<path></path>`),GP=U(`<span class="badge svelte-nsu1aw"> </span>`),KP=U(`<button type="button" class="action svelte-nsu1aw"> </button>`),qP=U(`<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>`),JP=U(`<div data-testid="toast-container" class="toast-stack svelte-nsu1aw"></div>`);function YP(e,t){A(t,!0);var n=Xr(),r=L(n),i=e=>{var n=JP();pi(n,21,()=>t.toasts,e=>e.id,(e,n)=>{var r=qP(),i=I(r),a=I(i);pi(a,20,()=>op[V(n).severity],e=>e,(e,t)=>{var n=WP();B(()=>J(n,`d`,t)),W(e,n)}),O(a),O(i);var o=R(i,2),s=I(o),c=I(s,!0);O(s);var l=R(s,2),u=e=>{var t=GP(),r=I(t);O(t),B(()=>{J(t,`data-testid`,`toast-count-${V(n).id}`),G(r,`×${V(n).count??``}`)}),W(e,t)};K(l,e=>{V(n).count>1&&e(u)});var d=R(l,2),f=e=>{var r=KP(),i=I(r,!0);O(r),B(()=>{J(r,`data-testid`,`toast-action-${V(n).id}`),G(i,V(n).action.label)}),H(`click`,r,()=>{V(n).action?.onClick(),t.onDismiss(V(n).id)}),W(e,r)};K(d,e=>{V(n).action&&e(f)}),O(o);var p=R(o,2);O(r),B(()=>{J(r,`role`,V(n).severity===`info`?`status`:`alert`),J(r,`data-testid`,`toast-${V(n).id}`),Ui(r,1,`toast-card ${V(n).severity??``}`,`svelte-nsu1aw`),G(c,V(n).message),J(p,`data-testid`,`toast-dismiss-${V(n).id}`)}),H(`click`,p,()=>t.onDismiss(V(n).id)),W(e,r)}),O(n),W(e,n)};K(r,e=>{t.toasts.length>0&&e(i)}),W(e,n),j()}Br([`click`]);var XP=U(`<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 ZP(e,t){let n=M(()=>t.installing?`Installing…`:`Restart to install`);var r=XP(),i=R(I(r),2),a=I(i);O(i);var o=R(i,2),s=I(o,!0);O(o);var c=R(o,2);O(r),B(()=>{G(a,`Tandem v${t.version??``} is available.`),o.disabled=t.installing,G(s,V(n))}),H(`click`,o,function(...e){t.onInstall?.apply(this,e)}),H(`click`,c,function(...e){t.onDismiss?.apply(this,e)}),W(e,r)}Br([`click`]);var QP=Math.floor,$P=(e,t)=>e<t?e:t,eF=(e,t)=>e>t?e:t,tF=128,nF=127,rF=2**53-1,iF=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},aF=typeof TextEncoder<`u`?new TextEncoder:null,oF=aF?e=>aF.encode(e):iF,sF=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});sF&&sF.decode(new Uint8Array).length===1&&(sF=null);var cF=(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},lF=(e,t)=>{for(;t>nF;)cF(e,tF|nF&t),t=QP(t/128);cF(e,nF&t)},uF=new Uint8Array(3e4),dF=uF.length/3,fF=aF&&aF.encodeInto?(e,t)=>{if(t.length<dF){let n=aF.encodeInto(t,uF).written||0;lF(e,n);for(let t=0;t<n;t++)cF(e,uF[t])}else mF(e,oF(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;lF(e,r);for(let t=0;t<r;t++)cF(e,n.codePointAt(t))},pF=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=$P(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(eF(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},mF=(e,t)=>{lF(e,t.byteLength),pF(e,t)},hF=e=>Error(e),gF=hF(`Unexpected end of array`),_F=hF(`Integer out of Range`),vF=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},yF=e=>vF(e,xF(e)),bF=e=>e.arr[e.pos++],xF=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&nF)*n,n*=128,r<tF)return t;if(t>rF)throw _F}throw gF},SF=sF?e=>sF.decode(yF(e)):e=>{let t=xF(e);if(t===0)return``;{let n=String.fromCodePoint(bF(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(bF(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))}},CF;(function(e){e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`})(CF||={});var wF=(e,t)=>{lF(e,CF.Token),fF(e,t)},TF=(e,t,n,r)=>{switch(xF(e)){case CF.Token:t();break;case CF.PermissionDenied:n(SF(e));break;case CF.Authenticated:r(SF(e));break}},EF=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),DF;(function(e){e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`})(DF||={});function OF(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 kF(e){return new Promise(t=>setTimeout(t,e))}function AF(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 jF(e,t){let n=OF(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||AF;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 kF(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 kF(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await kF(e)}return a()}var MF=Math.floor,NF=(e,t)=>e<t?e:t,PF=(e,t)=>e>t?e:t,FF=64,IF=128,LF=63,RF=127,zF=2**53-1,BF=()=>new Set,VF=Array.from,HF=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},UF=typeof TextEncoder<`u`?new TextEncoder:null,WF=UF?e=>UF.encode(e):HF,GF=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});GF&&GF.decode(new Uint8Array).length===1&&(GF=null);var KF=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},qF=()=>new KF,JF=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},YF=e=>{let t=new Uint8Array(JF(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},XF=(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},ZF=(e,t)=>{for(;t>RF;)XF(e,IF|RF&t),t=MF(t/128);XF(e,RF&t)},QF=new Uint8Array(3e4),$F=QF.length/3,eI=UF&&UF.encodeInto?(e,t)=>{if(t.length<$F){let n=UF.encodeInto(t,QF).written||0;ZF(e,n);for(let t=0;t<n;t++)XF(e,QF[t])}else nI(e,WF(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;ZF(e,r);for(let t=0;t<r;t++)XF(e,n.codePointAt(t))},tI=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=NF(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(PF(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},nI=(e,t)=>{ZF(e,t.byteLength),tI(e,t)},rI=e=>Error(e),iI=rI(`Unexpected end of array`),aI=rI(`Integer out of Range`),oI=class{constructor(e){this.arr=e,this.pos=0}},sI=e=>new oI(e),cI=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},lI=e=>cI(e,dI(e)),uI=e=>e.arr[e.pos++],dI=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&RF)*n,n*=128,r<IF)return t;if(t>zF)throw aI}throw iI},fI=e=>{let t=e.arr[e.pos++],n=t&LF,r=64,i=(t&FF)>0?-1:1;if((t&IF)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&RF)*r,r*=128,t<IF)return i*n;if(n>zF)throw aI}throw iI},pI=GF?e=>GF.decode(lI(e)):e=>{let t=dI(e);if(t===0)return``;{let n=String.fromCodePoint(uI(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(uI(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))}},mI=e=>{let t=e.pos,n=pI(e);return e.pos=t,n},hI=Date.now,gI=()=>new Map,_I=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},vI=class{constructor(){this._observers=gI()}on(e,t){_I(this._observers,e,BF).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 VF((this._observers.get(e)||gI()).values()).forEach(e=>e(...t))}destroy(){this._observers=gI()}},yI=Object.keys,bI=e=>yI(e).length,xI=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),SI=(e,t)=>e===t,CI=(e,t)=>{if(e==null||t==null)return SI(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)||!CI(e.get(n),t.get(n)))return!1;break;case Object:if(bI(e)!==bI(t))return!1;for(let n in e)if(!xI(e,n)||!CI(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(!CI(e[n],t[n]))return!1;break;default:return!1}return!0},wI=3e4,TI=class extends vI{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=hI();this.getLocalState()!==null&&wI/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&wI<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&EI(this,t,`timeout`)},MF(wI/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:hI()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),CI(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}},EI=(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:hI()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},DI=(e,t,n=e.states)=>{let r=t.length,i=qF();ZF(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;ZF(i,r),ZF(i,s),eI(i,JSON.stringify(o))}return YF(i)},OI=(e,t,n)=>{let r=sI(t),i=hI(),a=[],o=[],s=[],c=[],l=dI(r);for(let t=0;t<l;t++){let t=dI(r),n=dI(r),l=JSON.parse(pI(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&&(CI(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])},kI=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={}}},AI=class{constructor(e){this.data=e,this.encoder=qF(),this.decoder=sI(new Uint8Array(this.data))}peekVarString(){return mI(this.decoder)}readVarUint(){return dI(this.decoder)}readVarString(){return pI(this.decoder)}readVarUint8Array(){return lI(this.decoder)}writeVarUint(e){return ZF(this.encoder,e)}writeVarString(e){return eI(this.encoder,e)}writeVarUint8Array(e){return nI(this.encoder,e)}length(){return JF(this.encoder)}},jI;(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`})(jI||={});var MI;(function(e){e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`})(MI||={});var NI=class{constructor(){this.encoder=qF()}get(e){return e.encoder}toUint8Array(){return YF(this.encoder)}},PI=class extends NI{constructor(){super(...arguments),this.type=jI.CLOSE,this.description=`Ask the server to close the connection`}get(e){return eI(this.encoder,e.documentName),ZF(this.encoder,this.type),this.encoder}},FI=class extends kI{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=MI.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=MI.Connected,this.emit(`status`,{status:MI.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){this.configuration.providerMap.set(e.configuration.name,e),this.status===MI.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===MI.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){this.configuration.providerMap.has(e.configuration.name)&&(e.send(PI,{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===MI.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:jF(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=MI.Connecting,this.emit(`status`,{status:MI.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){var t;this.resolveConnectionAttempt(),this.lastMessageReceived=hI();let n=new AI(e.data).peekVarString();(t=this.configuration.providerMap.get(n))==null||t.onMessage(e)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=MI.Connected,this.emit(`status`,{status:MI.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===MI.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=hI()-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===DF.Open?this.webSocket.send(e):this.messageQueue.push(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=MI.Disconnected,this.emit(`status`,{status:MI.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()}},II=0,LI=1,RI=2,zI=(e,t)=>{ZF(e,II),nI(e,qT(t))},BI=(e,t,n)=>{ZF(e,LI),nI(e,VT(t,n))},VI=(e,t,n)=>BI(t,n,lI(e)),HI=(e,t,n)=>{try{RT(t,lI(e),n)}catch(e){console.error(`Caught error while handling a Yjs update`,e)}},UI=(e,t)=>{ZF(e,RI),nI(e,t)},WI=HI,GI=(e,t,n,r)=>{let i=dI(e);switch(i){case II:VI(e,t,n);break;case LI:HI(e,n,r);break;case RI:WI(e,n,r);break;default:throw Error(`Unknown message type`)}return i},KI=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case jI.Sync:this.applySyncMessage(e,t);break;case jI.Awareness:this.applyAwarenessMessage(e);break;case jI.Auth:this.applyAuthMessage(e);break;case jI.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case jI.Stateless:e.receiveStateless(pI(n.decoder));break;case jI.SyncStatus:this.applySyncStatusMessage(e,fI(n.decoder)===1);break;case jI.CLOSE:let i={code:1e3,reason:pI(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(NI,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(jI.Sync);let r=GI(n.decoder,n.encoder,e.document,e);t&&r===LI&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;OI(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;TF(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(jI.Awareness),t.writeVarUint8Array(DI(e.awareness,Array.from(e.awareness.getStates().keys())))}},qI=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return YF(this.encoder)}send(e){e?.send(this.create())}},JI=class extends NI{constructor(){super(...arguments),this.type=jI.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return eI(this.encoder,e.documentName),ZF(this.encoder,this.type),wF(this.encoder,e.token),this.encoder}},YI=class extends NI{constructor(){super(...arguments),this.type=jI.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`);eI(this.encoder,e.documentName),ZF(this.encoder,this.type);let t;return t=e.states===void 0?DI(e.awareness,e.clients):DI(e.awareness,e.clients,e.states),nI(this.encoder,t),this.encoder}},XI=class extends NI{constructor(){super(...arguments),this.type=jI.Stateless,this.description=`A stateless message`}get(e){return eI(this.encoder,e.documentName),ZF(this.encoder,this.type),eI(this.encoder,e.payload??``),this.encoder}},ZI=class extends NI{constructor(){super(...arguments),this.type=jI.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 eI(this.encoder,e.documentName),ZF(this.encoder,this.type),zI(this.encoder,e.document),this.encoder}},QI=class extends NI{constructor(){super(...arguments),this.type=jI.Sync,this.description=`A document update`}get(e){return eI(this.encoder,e.documentName),ZF(this.encoder,this.type),UI(this.encoder,e.update),this.encoder}},$I=class extends Error{constructor(){super(...arguments),this.code=1001}},eL=class extends kI{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 ST,this.configuration.awareness=e.awareness===void 0?new TI(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:EF(this.awareness.getStates())})}),(n=this.awareness)==null||n.on(`change`,()=>{this.emit(`awarenessChange`,{states:EF(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 FI(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(ZI,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&EI(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(XI,{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(JI,{token:e??``,documentName:this.configuration.name})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send(QI,{update:e,documentName:this.configuration.name}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(YI,{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(ZI,{document:this.document,documentName:this.configuration.name}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(YI,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(e,t){if(!this._isAttached)return;let n=new qI(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new AI(e.data),n=t.readVarString();t.writeVarString(n),this.emit(`message`,{event:e,message:new AI(e.data)}),new KI(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&EI(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&&(EI(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 $I(`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)}},tL=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},nL=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},rL=null,iL=function(e,t,n){let r=rL||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},aL=function(){rL=null},oL=function(e,t,n,r){return n&&(cL(e,t,n,r,-1)||cL(e,t,n,r,1))},sL=/^(img|br|input|textarea|hr)$/i;function cL(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:lL(e))){let n=e.parentNode;if(!n||n.nodeType!=1||pL(e)||sL.test(e.nodeName)||e.contentEditable==`false`)return!1;t=tL(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?lL(e):0}else return!1}}function lL(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function uL(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=lL(e)}else if(e.parentNode&&!pL(e))t=tL(e),e=e.parentNode;else return null}}function dL(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&&!pL(e))t=tL(e)+1,e=e.parentNode;else return null}}function fL(e,t,n){for(let r=t==0,i=t==lL(e);r||i;){if(e==n)return!0;let t=tL(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==lL(e)}}function pL(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 mL=function(e){return e.focusNode&&oL(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function hL(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function gL(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function _L(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(lL(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(lL(r.startContainer),r.startOffset)}}}var vL=typeof navigator<`u`?navigator:null,yL=typeof document<`u`?document:null,bL=vL&&vL.userAgent||``,xL=/Edge\/(\d+)/.exec(bL),SL=/MSIE \d/.exec(bL),CL=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bL),wL=!!(SL||CL||xL),TL=SL?document.documentMode:CL?+CL[1]:xL?+xL[1]:0,EL=!wL&&/gecko\/(\d+)/i.test(bL);EL&&+(/Firefox\/(\d+)/.exec(bL)||[0,0])[1];var DL=!wL&&/Chrome\/(\d+)/.exec(bL),OL=!!DL,kL=DL?+DL[1]:0,AL=!wL&&!!vL&&/Apple Computer/.test(vL.vendor),jL=AL&&(/Mobile\/\w+/.test(bL)||!!vL&&vL.maxTouchPoints>2),ML=jL||(vL?/Mac/.test(vL.platform):!1),NL=vL?/Win/.test(vL.platform):!1,PL=/Android \d/.test(bL),FL=!!yL&&`webkitFontSmoothing`in yL.documentElement.style,IL=FL?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function LL(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 RL(e,t){return typeof e==`number`?e:e[t]}function zL(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 BL(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=nL(o);continue}let e=o,n=e==a.body,s=n?LL(a):zL(e),c=0,l=0;if(t.top<s.top+RL(r,`top`)?l=-(s.top-t.top+RL(i,`top`)):t.bottom>s.bottom-RL(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+RL(i,`top`)-s.top:t.bottom-s.bottom+RL(i,`bottom`)),t.left<s.left+RL(r,`left`)?c=-(s.left-t.left+RL(i,`left`)):t.right>s.right-RL(r,`right`)&&(c=t.right-s.right+RL(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:nL(o)}}function VL(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:HL(e.dom)}}function HL(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=nL(r));return t}function UL({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;WL(n,r==0?0:r-t)}function WL(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 GL=null;function KL(e){if(e.setActive)return e.setActive();if(GL)return e.focus(GL);let t=HL(e);e.focus(GL==null?{get preventScroll(){return GL={preventScroll:!0},!0}}:void 0),GL||(GL=!1,WL(t,0))}function qL(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=iL(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?JL(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:qL(n,i)}function JL(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=nR(r,1);if(n.top!=n.bottom&&YL(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function YL(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function XL(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function ZL(e,t,n){let{node:r,offset:i}=qL(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 QL(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 $L(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(YL(t,i))return $L(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function eR(e,t){let n=e.dom.ownerDocument,r,i=0,a=_L(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(!YL(t,n)||(o=$L(e.dom,t,n),!o))return null}if(AL)for(let e=o;r&&e;e=nL(e))e.draggable&&(r=void 0);if(o=XL(o,t),r){if(EL&&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;FL&&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=QL(e,r,i,t))}s??=ZL(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function tR(e){return e.top<e.bottom||e.left<e.right}function nR(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(tR(e))return e}return Array.prototype.find.call(n,tR)||e.getBoundingClientRect()}var rR=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function iR(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=FL||EL;if(r.nodeType==3)if(o&&(rR.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=nR(iL(r,i,i),n);if(EL&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=nR(iL(r,i-1,i-1),-1);if(t.top==e.top){let n=nR(iL(r,i,i+1),-1);if(n.top!=e.top)return aR(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++,aR(nR(iL(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==lL(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return oR(e.getBoundingClientRect(),!1)}if(a==null&&i<lL(r)){let e=r.childNodes[i];if(e.nodeType==1)return oR(e.getBoundingClientRect(),!0)}return oR(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==lL(r))){let e=r.childNodes[i-1],t=e.nodeType==3?iL(e,lL(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return aR(nR(t,1),!1)}if(a==null&&i<lL(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?iL(e,0,+!o):e.nodeType==1?e:null:null;if(t)return aR(nR(t,-1),!0)}return aR(nR(r.nodeType==3?iL(r):r,-n),n>=0)}function aR(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 oR(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 sR(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 cR(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return sR(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=iR(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=iL(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 lR=/[\u0590-\u08ac]/;function uR(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?!lR.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:sR(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 dR=null,fR=null,pR=!1;function mR(e,t,n){return dR==t&&fR==n?pR:(dR=t,fR=n,pR=n==`up`||n==`down`?cR(e,t,n):uR(e,t,n))}var hR=0,gR=1,_R=2,vR=3,yR=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=hR,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>tL(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 ER){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 bR&&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?tL(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?tL(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=tL(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=tL(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((EL||AL)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
|
|
153
153
|
`),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:tL(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(EL&&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&&AL)&&oL(o.node,o.offset,l.anchorNode,l.anchorOffset)&&oL(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&EL)){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?_R:gR,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=vR:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?_R:vR}n=a}this.dirty=_R}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?_R:gR;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},bR=class extends yR{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==hR&&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}},xR=class extends yR{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}},SR=class e extends yR{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=Pm.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&vR||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=vR&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=hR){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=hR}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=UR(a,n,o,r)),t>0&&(a=UR(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()}},CR=class e extends yR{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=Pm.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=PR(u,r,n),l?c=new DR(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new TR(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==hR&&e.eq(this.node)&&FR(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 LR(this,a&&a.node,e);BR(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?Tp.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==_R)&&(a&&this.protectLocalComposition(e,a),OR(this.contentDOM,this.children,e),jL&&VR(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof ag)||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=HR(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 xR(this,i,t,r);e.input.compositionNodes.push(a),this.children=UR(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==vR||!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=hR}updateOuterDeco(e){if(FR(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=MR(this.dom,this.nodeDOM,jR(this.outerDeco,this.node,t),jR(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 wR(e,t,n,r,i){PR(r,t,e);let a=new CR(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var TR=class e extends CR{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==vR||this.dirty!=hR&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=hR||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=hR,!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=vR)}get domAtom(){return!1}isText(e){return this.node.text==e}},ER=class extends yR{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==hR&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},DR=class extends CR{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==vR)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 OR(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=IR(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof SR){let t=r?r.previousSibling:e.lastChild;OR(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=IR(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var kR=function(e){e&&(this.nodeName=e)};kR.prototype=Object.create(null);var AR=[new kR];function jR(e,t,n){if(e.length==0)return AR;let r=n?AR[0]:new kR,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new kR(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new kR(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 MR(e,t,n,r){if(n==AR&&r==AR)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=AR[0],i=t)}NR(i,o||AR[0],a)}return i}function NR(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 PR(e,t,n){return MR(e,e,AR,jR(t,n,e.nodeType!=1))}function FR(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 IR(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var LR=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=RR(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=hR,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=SR.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==vR&&a.dom==a.contentDOM&&(a.dirty=_R),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 CR){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!=vR&&FR(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=_R,u.updateChildren(r,a+1),u.dirty=hR),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)||!FR(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=CR.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=CR.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 bR(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 SR;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof TR)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((AL||OL)&&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 ER(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 RR(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 SR)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 zR(e,t){return e.type.side-t.type.side}function BR(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(zR);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 VR(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 HR(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 UR(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 WR(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(mL(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&sg.isSelectable(e)&&i.parent&&!(e.isInline&&fL(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new sg(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=tz(e,u,s,n)}return l}function GR(e){return e.editable?e.hasFocus():rz(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function KR(e,t=!1){let n=e.state.selection;if($R(e,n),GR(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&OL){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&oL(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)QR(e);else{let{anchor:r,head:i}=n,a,o;qR&&!(n instanceof ag)&&(n.$from.parent.inlineContent||(a=JR(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=JR(e,n.to))),e.docView.setSelection(r,i,e,t),qR&&(a&&XR(a),o&&XR(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&ZR(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var qR=AL||OL&&kL<63;function JR(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(AL&&i&&i.contentEditable==`false`)return YR(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return YR(i);if(a)return YR(a)}}function YR(e){return e.contentEditable=`true`,AL&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function XR(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function ZR(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(()=>{(!GR(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function QR(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,tL(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&wL&&TL<=11&&(n.disabled=!0,n.disabled=!1)}function $R(e,t){if(t instanceof sg){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ez(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ez(e)}function ez(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function tz(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||ag.between(t,n,r)}function nz(e){return e.editable&&!e.hasFocus()?!1:rz(e)}function rz(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 iz(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return oL(t.node,t.offset,n.anchorNode,n.anchorOffset)}function az(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&&tg.findFrom(a,t)}function oz(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function sz(e,t,n){let r=e.state.selection;if(r instanceof ag){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 oz(e,new ag(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=az(e.state,t);return n&&n instanceof sg?oz(e,n):!1}else if(!(ML&&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?sg.isSelectable(i)?oz(e,new sg(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):FL?oz(e,new ag(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof sg&&r.node.isInline)return oz(e,new ag(t>0?r.$to:r.$from));else{let n=az(e.state,t);return n?oz(e,n):!1}}function cz(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function lz(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function uz(e,t){return t<0?dz(e):fz(e)}function dz(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(EL&&n.nodeType==1&&r<cz(n)&&lz(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(lz(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(pz(n))break;else{let t=n.previousSibling;for(;t&&lz(t,-1);)i=n.parentNode,a=tL(t),t=t.previousSibling;if(t)n=t,r=cz(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?gz(e,n,r):i&&gz(e,i,a)}function fz(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=cz(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(lz(e,1))a=n,o=++r;else break}else if(pz(n))break;else{let t=n.nextSibling;for(;t&&lz(t,1);)a=t.parentNode,o=tL(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=cz(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&gz(e,a,o)}function pz(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function mz(e,t){for(;e&&t==e.childNodes.length&&!pL(e);)t=tL(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 hz(e,t){for(;e&&!t&&!pL(e);)t=tL(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 gz(e,t,n){if(t.nodeType!=3){let e,r;(r=mz(t,n))?(t=r,n=0):(e=hz(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(mL(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&&KR(e)},50)}function _z(e,t){let n=e.state.doc.resolve(t);if(!(OL||NL)&&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 vz(e,t,n){let r=e.state.selection;if(r instanceof ag&&!r.empty||n.indexOf(`s`)>-1||ML&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=az(e.state,t);if(n&&n instanceof sg)return oz(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof lg?tg.near(n,t):tg.findFrom(n,t);return o?oz(e,o):!1}return!1}function yz(e,t){if(!(e.state.selection instanceof ag))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 bz(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function xz(e){if(!AL||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;bz(e,n,`true`),setTimeout(()=>bz(e,n,`false`),20)}return!1}function Sz(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Cz(e,t){let n=t.keyCode,r=Sz(t);if(n==8||ML&&n==72&&r==`c`)return yz(e,-1)||uz(e,-1);if(n==46&&!t.shiftKey||ML&&n==68&&r==`c`)return yz(e,1)||uz(e,1);if(n==13||n==27)return!0;if(n==37||ML&&n==66&&r==`c`){let t=n==37?_z(e,e.state.selection.from)==`ltr`?-1:1:-1;return sz(e,t,r)||uz(e,t)}else if(n==39||ML&&n==70&&r==`c`){let t=n==39?_z(e,e.state.selection.from)==`ltr`?1:-1:1;return sz(e,t,r)||uz(e,t)}else if(n==38||ML&&n==80&&r==`c`)return vz(e,-1,r)||uz(e,-1);else if(n==40||ML&&n==78&&r==`c`)return xz(e)||vz(e,1,r)||uz(e,1);else if(r==(ML?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function wz(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`)||Pm.fromSchema(e.state.schema),s=Fz(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=Nz[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,`
|
|
154
154
|
|