gestalt-mobile 0.44.4 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/client/assets/index-Copi3ec4.css +1 -0
- package/dist/client/assets/index-UqpTKH1P.js +109 -0
- package/dist/client/index.html +2 -2
- package/dist/server/server/app.js +3 -0
- package/dist/server/server/composition.contracts.js +79 -0
- package/dist/server/server/composition.js +110 -0
- package/dist/server/server/features/control-plane-trace/export-trace.js +63 -2
- package/dist/server/server/features/self-debug/create-session.js +34 -0
- package/dist/server/server/features/self-debug/endpoint.js +81 -0
- package/dist/server/server/features/sessions/model/relay-session.js +1 -0
- package/dist/server/server/platform/persistence/migrate.js +2 -0
- package/dist/server/server/platform/persistence/sqlite-session-repository.js +5 -2
- package/dist/server/server/platform/self-debug/workspace.js +166 -0
- package/dist/server/shared/contracts/self-debug.js +33 -0
- package/package.json +1 -1
- package/dist/client/assets/index-DEVCzFB9.css +0 -1
- package/dist/client/assets/index-DYZT_mLU.js +0 -108
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(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 l=Array.isArray,u=Array.prototype.indexOf,d=Array.prototype.includes,f=Array.from,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyDescriptors,g=Object.prototype,_=Array.prototype,v=Object.getPrototypeOf,y=Object.isExtensible,b=()=>{};function x(e){for(var t=0;t<e.length;t++)e[t]()}function S(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function C(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 w=1<<24,T=1024,E=2048,D=4096,ee=8192,O=16384,te=32768,ne=1<<25,re=65536,ie=1<<18,k=1<<19,ae=1<<20,oe=1<<25,se=65536,ce=1<<21,le=1<<22,A=1<<23,ue=Symbol(`$state`),de=Symbol(`legacy props`),fe=Symbol(``),j=Symbol(`attributes`),M=Symbol(`class`),pe=Symbol(`style`),me=Symbol(`text`),he=Symbol(`form reset`),ge=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},_e=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ve(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function ye(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function be(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function xe(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Se(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Ce(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function we(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Te(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Ee(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function De(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Oe(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function ke(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Ae={},je=Symbol(`uninitialized`),Me=`http://www.w3.org/1999/xhtml`,Ne=`http://www.w3.org/2000/svg`,Pe=`http://www.w3.org/1998/Math/MathML`;function Fe(){console.warn(`https://svelte.dev/e/derived_inert`)}function Ie(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function Le(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function Re(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var N=!1;function ze(e){N=e}var P;function Be(e){if(e===null)throw Ie(),Ae;return P=e}function Ve(){return Be(_n(P))}function F(e){if(N){if(_n(P)!==null)throw Ie(),Ae;P=e}}function He(e=1){if(N){for(var t=e,n=P;t--;)n=_n(n);P=n}}function Ue(e=!0){for(var t=0,n=P;;){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=_n(n);e&&n.remove(),n=i}}function We(e){if(!e||e.nodeType!==8)throw Ie(),Ae;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;function Ye(){Je=!0}var Xe=null;function Ze(e){Xe=e}function Qe(e,t=!1,n){Xe={p:Xe,i:!1,c:null,e:null,s:e,x:null,r:or,l:Je&&!t?{s:null,u:null,$:[]}:null}}function $e(e){var t=Xe,n=t.e;if(n!==null){t.e=null;for(var r of n)Nn(r)}return e!==void 0&&(t.x=e),t.i=!0,Xe=t.p,e??{}}function et(){return!Je||Xe!==null&&Xe.l===null}var tt=[];function nt(){var e=tt;tt=[],x(e)}function rt(e){if(tt.length===0&&!Pt){var t=tt;queueMicrotask(()=>{t===tt&&nt()})}tt.push(e)}function it(){for(;tt.length>0;)nt()}function at(e){var t=or;if(t===null)return rr.f|=A,e;if(!(t.f&32768)&&!(t.f&4))throw e;ot(e,t)}function ot(e,t){if(!(t!==null&&t.f&16384)){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 st=~(E|D|T);function I(e,t){e.f=e.f&st|t}function ct(e){e.f&512||e.deps===null?I(e,T):I(e,D)}function lt(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=se,lt(t.deps))}function ut(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),lt(e.deps),I(e,T)}var dt=!1;function ft(e){var t=dt;try{return dt=!1,[e(),dt]}finally{dt=t}}function pt(e){let t=0,n=$t(0),r;return()=>{An()&&(G(n),Ln(()=>(t===0&&(r=Or(()=>e(()=>rn(n)))),t+=1,()=>{rt(()=>{--t,t===0&&(r?.(),r=void 0,rn(n))})})))}}var mt=re|k;function ht(e,t,n,r){new gt(e,t,n,r)}var gt=class{parent;is_pending=!1;transform_error;#e;#t=N?P: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=pt(()=>(this.#m=$t(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=or;t.b=this,t.f|=128,n(e)},this.parent=or.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=zn(()=>{if(N){let e=this.#t;Ve();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()},mt),N&&(this.#e=P)}#g(){try{this.#a=Vn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=Vn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Vn(()=>e(this.#e)),rt(()=>{var e=this.#c=document.createDocumentFragment(),t=hn();e.append(t),this.#a=this.#x(()=>Vn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,Jn(this.#o,()=>{this.#o=null}),this.#b(R))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Vn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Qn(this.#a,e);let t=this.#n.pending;this.#o=Vn(()=>t(this.#e))}else this.#b(R)}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=or,n=rr,r=Xe;sr(this.#i),ar(this.#i),Ze(this.#i.ctx);try{return Bt.ensure(),e()}catch(e){return at(e),null}finally{sr(t),ar(n),Ze(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&&Jn(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,rt(()=>{this.#d=!1,this.#m&&tn(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),G(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;R?.is_fork?(this.#a&&R.skip_effect(this.#a),this.#o&&R.skip_effect(this.#o),this.#s&&R.skip_effect(this.#s),R.oncommit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(Gn(this.#a),null),this.#o&&=(Gn(this.#o),null),this.#s&&=(Gn(this.#s),null),N&&(Be(this.#t),He(),Be(Ue()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){Re();return}r=!0,i&&ke(),this.#s!==null&&Jn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){ot(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return Vn(()=>{var t=or;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return ot(e,this.#i.parent),null}}))};rt(()=>{var t;try{t=this.transform_error(e)}catch(e){ot(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>ot(e,this.#i&&this.#i.parent)):o(t)})}};function _t(e,t,n,r){let i=et()?xt:wt;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=or,c=vt(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){ot(e,s)}yt()}}var d=bt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>Ct(e))).then(u).catch(e=>ot(e,s)).finally(d)}l?l.then(()=>{c(),f(),yt()}):f()}function vt(){var e=or,t=rr,n=Xe,r=R;return function(i=!0){sr(e),ar(t),Ze(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function yt(e=!0){sr(null),ar(null),Ze(null),e&&R?.deactivate()}function bt(){var e=or,t=e.b,n=R,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 xt(e){var t=2|E;return or!==null&&(or.f|=k),{ctx:Xe,deps:null,effects:null,equals:Ge,f:t,fn:e,reactions:null,rv:0,v:je,wv:0,parent:or,ac:null}}var St=Symbol(`obsolete`);function Ct(e,t,n){let r=or;r===null&&ye();var i=void 0,a=$t(je),o=!rr,s=new Set;return In(()=>{var t=or,n=S();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==ge&&n.reject(e)}).finally(yt)}catch(e){n.reject(e),yt()}var c=R;if(o){if(t.f&32768)var l=bt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(St);else for(let e of s.values())e.reject(St);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==St&&(c.activate(),t?(a.f|=A,tn(a,t)):(a.f&8388608&&(a.f^=A),tn(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),jn(()=>{for(let e of s)e.reject(St)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function L(e){let t=xt(e);return lr(t),t}function wt(e){let t=xt(e);return t.equals=qe,t}function Tt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)Gn(t[n])}}function Et(e){var t,n=or,r=e.parent;if(!tr&&r!==null&&e.v!==je&&r.f&24576)return Fe(),e.v;sr(r);try{e.f&=~se,Tt(e),t=xr(e)}finally{sr(n)}return t}function Dt(e){var t=Et(e);if(!e.equals(t)&&(e.wv=vr(),(!R?.is_fork||e.deps===null)&&(R===null?e.v=t:(R.capture(e,t,!0),jt?.capture(e,t,!0)),e.deps===null))){I(e,T);return}tr||(Mt===null?ct(e):(An()||R?.is_fork)&&Mt.set(e,t))}function Ot(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(ge),t.fn!==null&&(t.teardown=b),t.ac=null,Cr(t,0),Un(t))}function kt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&wr(t)}var At=null,R=null,jt=null,Mt=null,Nt=null,Pt=!1,Ft=!1,It=null,Lt=null,Rt=0,zt=1,Bt=class e{id=zt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){At===null?At=this:(At.#n=this,this.#t=At),At=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)I(r,E),t(r);for(r of n.m)I(r,D),t(r)}this.#p.add(e)}#g(){this.#e=!0,Rt++>1e3&&(this.#x(),Ht());for(let e of this.#u)this.#d.delete(e),I(e,E),this.schedule(e);for(let e of this.#d)I(e,D),this.schedule(e);let t=this.#c;this.#c=[],this.apply();var n=It=[],r=[],i=Lt=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw Yt(e),this.#h()||this.discard(),t}if(R=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(It=null,Lt=null,this.#h()){this.#b(r),this.#b(n);for(let[e,t]of this.#f)Jt(e,t);i.length>0&&R.#g();return}let o=this.#v();if(o){this.#b(r),this.#b(n),o.#y(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),jt=this,Wt(r),Wt(n),jt=null,this.#s?.resolve();var s=R;if(this.#a===0&&(this.#c.length===0||s!==null)&&this.#x(),this.#c.length>0)if(s!==null){let e=s;e.#c.push(...this.#c.filter(t=>!e.#c.includes(t)))}else s=this;s!==null&&s.#g()}#_(e,t,n){e.f^=T;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=T:i&4?t.push(r):yr(r)&&(i&16&&this.#d.add(r),wr(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}}}#v(){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}#y(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).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);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.#d.delete(i),I(i,E),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#x(),R=this,this.#g()}#b(e){for(var t=0;t<e.length;t+=1)ut(e[t],this.#u,this.#d)}capture(e,t,n=!1){e.v!==je&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),Mt?.set(e,t)),this.is_fork||(e.v=t)}activate(){R=this}deactivate(){R=null,Mt=null}flush(){try{Ft=!0,R=this,this.#g()}finally{Rt=0,Nt=null,It=null,Lt=null,Ft=!1,R=null,Mt=null,Zt.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear();for(let e of this.async_deriveds.values())e.reject(St);this.#x(),this.#s?.resolve()}register_created_effect(e){this.#l.push(e)}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,rt(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=S()).promise}static ensure(){if(R===null){let t=R=new e;!Ft&&!Pt&&rt(()=>{t.#e||t.flush()})}return R}apply(){Mt=null}schedule(e){if(Nt=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(It!==null&&t===or&&(rr===null||!(rr.f&2)))return;if(n&96){if(!(n&1024))return;t.f^=T}}this.#c.push(t)}#x(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?At=e:t.#t=e,this.linked=!1}}};function Vt(e){var t=Pt;Pt=!0;try{var n;for(e&&(R!==null&&!R.is_fork&&R.flush(),n=e());;){if(it(),R===null)return n;R.flush()}}finally{Pt=t}}function Ht(){try{we()}catch(e){ot(e,Nt)}}var Ut=null;function Wt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&yr(r)&&(Ut=new Set,wr(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&qn(r),Ut?.size>0)){Zt.clear();for(let e of Ut){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Ut.has(n)&&(Ut.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||wr(n)}}Ut.clear()}}Ut=null}}function Gt(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?Gt(i,t,n,r):e&4194320&&!(e&2048)&&Kt(i,t,r)&&(I(i,E),qt(i))}}function Kt(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(d.call(t,r))return!0;if(r.f&2&&Kt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function qt(e){R.schedule(e)}function Jt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),I(e,T);for(var n=e.first;n!==null;)Jt(n,t),n=n.next}}function Yt(e){I(e,T);for(var t=e.first;t!==null;)Yt(t),t=t.next}var Xt=new Set,Zt=new Map,Qt=!1;function $t(e,t){return{f:0,v:e,reactions:null,equals:Ge,rv:0,wv:0}}function z(e,t){let n=$t(e,t);return lr(n),n}function en(e,t=!1,n=!0){let r=$t(e);return t||(r.equals=qe),Je&&n&&Xe!==null&&Xe.l!==null&&(Xe.l.s??=[]).push(r),r}function B(e,t,n=!1){return rr!==null&&(!ir||rr.f&131072)&&et()&&rr.f&4325394&&(cr===null||!cr.has(e))&&Oe(),tn(e,n?on(t):t,Lt)}function tn(e,t,n=null){if(!e.equals(t)){Zt.set(e,tr?t:e.v);var r=Bt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&Et(t),Mt===null&&ct(t)}e.wv=vr(),an(e,E,n),et()&&or!==null&&or.f&1024&&!(or.f&96)&&(fr===null?pr([e]):fr.push(e)),!r.is_fork&&Xt.size>0&&!Qt&&nn()}return t}function nn(){Qt=!1;for(let e of Xt){e.f&1024&&I(e,D);let t;try{t=yr(e)}catch{t=!0}t&&wr(e)}Xt.clear()}function rn(e){B(e,e.v+1)}function an(e,t,n){var r=e.reactions;if(r!==null)for(var i=et(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===or)){var l=(c&E)===0;if(l&&I(s,t),c&131072)Xt.add(s);else if(c&2){var u=s;Mt?.delete(u),c&65536||(c&512&&(or===null||!(or.f&2097152))&&(s.f|=se),an(u,D,n))}else if(l){var d=s;c&16&&Ut!==null&&Ut.add(d),n===null?qt(d):n.push(d)}}}}function on(e){if(typeof e!=`object`||!e||ue in e)return e;let t=v(e);if(t!==g&&t!==_)return e;var n=new Map,r=l(e),i=z(0),a=null,o=gr,s=e=>{if(gr===o)return e();var t=rr,n=gr;ar(null),_r(o);var r=e();return ar(t),_r(n),r};return r&&n.set(`length`,z(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&Ee();var i=n.get(t);return i===void 0?s(()=>{var e=z(r.value,a);return n.set(t,e),e}):B(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>z(je,a));n.set(t,e),rn(i)}}else B(r,je),rn(i);return!0},get(t,r,i){if(r===ue)return e;var o=n.get(r),c=r in t;if(o===void 0&&(!c||m(t,r)?.writable)&&(o=s(()=>z(on(c?t[r]:je),a)),n.set(r,o)),o!==void 0){var l=G(o);return l===je?void 0:l}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=G(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==je)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===ue)return!0;var r=n.get(t),i=r!==void 0&&r.v!==je||Reflect.has(e,t);return(r!==void 0||or!==null&&(!i||m(e,t)?.writable))&&(r===void 0&&(r=s(()=>z(i?on(e[t]):je,a)),n.set(t,r)),G(r)===je)?!1:i},set(e,t,o,c){var l=n.get(t),u=t in e;if(r&&t===`length`)for(var d=o;d<l.v;d+=1){var f=n.get(d+``);f===void 0?d in e&&(f=s(()=>z(je,a)),n.set(d+``,f)):B(f,je)}if(l===void 0)(!u||m(e,t)?.writable)&&(l=s(()=>z(void 0,a)),B(l,on(o)),n.set(t,l));else{u=l.v!==je;var p=s(()=>on(o));B(l,p)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(c,o),!u){if(r&&typeof t==`string`){var g=n.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&B(g,_+1)}rn(i)}return!0},ownKeys(e){G(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==je});for(var[r,a]of n)a.v!==je&&!(r in e)&&t.push(r);return t},setPrototypeOf(){De()}})}function sn(e){try{if(typeof e==`object`&&e&&ue in e)return e[ue]}catch{}return e}function cn(e,t){return Object.is(sn(e),sn(t))}var ln,un,dn,fn,pn;function mn(){if(ln===void 0){ln=window,un=document,dn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;fn=m(t,`firstChild`).get,pn=m(t,`nextSibling`).get,y(e)&&(e[M]=void 0,e[j]=null,e[pe]=void 0,e.__e=void 0),y(n)&&(n[me]=void 0)}}function hn(e=``){return document.createTextNode(e)}function gn(e){return fn.call(e)}function _n(e){return pn.call(e)}function V(e,t){if(!N)return gn(e);var n=gn(P);if(n===null)n=P.appendChild(hn());else if(t&&n.nodeType!==3){var r=hn();return n?.before(r),Be(r),r}return t&&xn(n),Be(n),n}function H(e,t=!1){if(!N){var n=gn(e);return n instanceof Comment&&n.data===``?_n(n):n}if(t){if(P?.nodeType!==3){var r=hn();return P?.before(r),Be(r),r}xn(P)}return P}function U(e,t=1,n=!1){let r=N?P:e;for(var i;t--;)i=r,r=_n(r);if(!N)return r;if(n){if(r?.nodeType!==3){var a=hn();return r===null?i?.after(a):r.before(a),Be(a),a}xn(r)}return Be(r),r}function vn(e){e.textContent=``}function yn(){return!1}function bn(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function xn(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 Sn(e){N&&gn(e)!==null&&vn(e)}var Cn=!1;function wn(){Cn||(Cn=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[he]?.()})},{capture:!0}))}function Tn(e){var t=rr,n=or;ar(null),sr(null);try{return e()}finally{ar(t),sr(n)}}function En(e,t,n,r=n){e.addEventListener(t,()=>Tn(n));let i=e[he];i?e[he]=()=>{i(),r(!0)}:e[he]=()=>r(!0),wn()}function Dn(e){or===null&&(rr===null&&Ce(e),Se()),tr&&xe(e)}function On(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function kn(e,t){var n=or;n!==null&&n.f&8192&&(e|=ee);var r={ctx:Xe,deps:null,nodes:null,f:e|E|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};R?.register_created_effect(r);var i=r;if(e&4)It===null?Bt.ensure().schedule(r):It.push(r);else if(t!==null){try{wr(r)}catch(e){throw Gn(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|=re))}if(i!==null&&(i.parent=n,n!==null&&On(i,n),rr!==null&&rr.f&2&&!(e&64))){var a=rr;(a.effects??=[]).push(i)}return r}function An(){return rr!==null&&!ir}function jn(e){let t=kn(8,null);return I(t,T),t.teardown=e,t}function Mn(e){Dn(`$effect`);var t=or.f;if(!rr&&t&32&&Xe!==null&&!Xe.i){var n=Xe;(n.e??=[]).push(e)}else return Nn(e)}function Nn(e){return kn(4|ae,e)}function Pn(e){Bt.ensure();let t=kn(64|k,e);return(e={})=>new Promise(n=>{e.outro?Jn(t,()=>{Gn(t),n(void 0)}):(Gn(t),n(void 0))})}function Fn(e){return kn(4,e)}function In(e){return kn(le|k,e)}function Ln(e,t=0){return kn(8|t,e)}function W(e,t=[],n=[],r=[]){_t(r,t,n,t=>{kn(8,()=>{e(...t.map(G))})})}function Rn(e,t=[],n=[],r=[]){_t(r,t,n,t=>{kn(4,()=>e(...t.map(G)))})}function zn(e,t=0){return kn(16|t,e)}function Bn(e,t=0){return kn(w|t,e)}function Vn(e){return kn(32|k,e)}function Hn(e){var t=e.teardown;if(t!==null){let e=tr,n=rr;nr(!0),ar(null);try{t.call(null)}finally{nr(e),ar(n)}}}function Un(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&Tn(()=>{e.abort(ge)});var r=n.next;n.f&64?n.parent=null:Gn(n,t),n=r}}function Wn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Gn(t),t=n}}function Gn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Kn(e.nodes.start,e.nodes.end),n=!0),e.f|=ne,Un(e,t&&!n),Cr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Hn(e),e.f^=ne,e.f|=O;var i=e.parent;i!==null&&i.first!==null&&qn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Kn(e,t){for(;e!==null;){var n=e===t?null:_n(e);e.remove(),e=n}}function qn(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 Jn(e,t,n=!0){var r=[];Yn(e,r,!0);var i=()=>{n&&Gn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Yn(e,t,n){if(!(e.f&8192)){e.f^=ee;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;Yn(i,t,o?n:!1)}i=a}}}function Xn(e){Zn(e,!0)}function Zn(e,t){if(e.f&8192){e.f^=ee,e.f&1024||(I(e,E),Bt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;Zn(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 Qn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:_n(n);t.append(n),n=i}}var $n=null,er=!1,tr=!1;function nr(e){tr=e}var rr=null,ir=!1;function ar(e){rr=e}var or=null;function sr(e){or=e}var cr=null;function lr(e){rr!==null&&(cr??=new Set).add(e)}var ur=null,dr=0,fr=null;function pr(e){fr=e}var mr=1,hr=0,gr=hr;function _r(e){gr=e}function vr(){return++mr}function yr(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~se),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(yr(a)&&Dt(a),a.wv>e.wv)return!0}t&512&&Mt===null&&I(e,T)}return!1}function br(e,t,n=!0){var r=e.reactions;if(r!==null&&!(cr!==null&&cr.has(e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?br(a,t,!1):t===a&&(n?I(a,E):a.f&1024&&I(a,D),qt(a))}}function xr(e){var t=ur,n=dr,r=fr,i=rr,a=cr,o=Xe,s=ir,c=gr,l=e.f;ur=null,dr=0,fr=null,rr=l&96?null:e,cr=null,Ze(e.ctx),ir=!1,gr=++hr,e.ac!==null&&(Tn(()=>{e.ac.abort(ge)}),e.ac=null);try{e.f|=ce;var u=e.fn,d=u();e.f|=te;var f=e.deps,p=R?.is_fork;if(ur!==null){var m;if(p||Cr(e,dr),f!==null&&dr>0)for(f.length=dr+ur.length,m=0;m<ur.length;m++)f[dr+m]=ur[m];else e.deps=f=ur;if(An()&&e.f&512)for(m=dr;m<f.length;m++)(f[m].reactions??=[]).push(e)}else!p&&f!==null&&dr<f.length&&(Cr(e,dr),f.length=dr);if(et()&&fr!==null&&!ir&&f!==null&&!(e.f&6146))for(m=0;m<fr.length;m++)br(fr[m],e);if(i!==null&&i!==e){if(hr++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=hr;if(t!==null)for(let e of t)e.rv=hr;fr!==null&&(r===null?r=fr:r.push(...fr))}return e.f&8388608&&(e.f^=A),d}catch(e){return at(e)}finally{e.f^=ce,ur=t,dr=n,fr=r,rr=i,cr=a,Ze(o),ir=s,gr=c}}function Sr(e,t){let n=t.reactions;if(n!==null){var r=u.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&t.f&2&&(ur===null||!d.call(ur,t))){var a=t;a.f&512&&(a.f^=512,a.f&=~se),a.v!==je&&ct(a),Ot(a),Cr(a,0)}}function Cr(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Sr(e,n[r])}function wr(e){var t=e.f;if(!(t&16384)){I(e,T);var n=or,r=er;or=e,er=!0;try{t&16777232?Wn(e):Un(e),Hn(e);var i=xr(e);e.teardown=typeof i==`function`?i:null,e.wv=mr}finally{er=r,or=n}}}async function Tr(){await Promise.resolve(),Vt()}function G(e){var t=(e.f&2)!=0;if($n?.add(e),rr!==null&&!ir&&!(or!==null&&or.f&16384)&&(cr===null||!cr.has(e))){var n=rr.deps;if(rr.f&2097152)e.rv<hr&&(e.rv=hr,ur===null&&n!==null&&n[dr]===e?dr++:ur===null?ur=[e]:ur.push(e));else{rr.deps??=[],d.call(rr.deps,e)||rr.deps.push(e);var r=e.reactions;r===null?e.reactions=[rr]:d.call(r,rr)||r.push(rr)}}if(tr&&Zt.has(e))return Zt.get(e);if(t){var i=e;if(tr){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||Dr(i))&&(a=Et(i)),Zt.set(i,a),a}var o=(i.f&512)==0&&!ir&&rr!==null&&(er||(rr.f&512)!=0),s=(i.f&te)===0;yr(i)&&(o&&(i.f|=512),Dt(i)),o&&!s&&(kt(i),Er(i))}if(Mt?.has(e))return Mt.get(e);if(e.f&8388608)throw e.v;return e.v}function Er(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(kt(t),Er(t))}function Dr(e){if(e.v===je)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(Zt.has(t)||t.f&2&&Dr(t))return!0;return!1}function Or(e){var t=ir;try{return ir=!0,e()}finally{ir=t}}function kr(e){if(!(typeof e!=`object`||!e||e instanceof EventTarget)){if(ue in e)Ar(e);else if(!Array.isArray(e))for(let t in e){let n=e[t];typeof n==`object`&&n&&ue in n&&Ar(n)}}}function Ar(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{Ar(e[n],t)}catch{}let n=v(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){let t=h(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 jr=[`touchstart`,`touchmove`];function Mr(e){return jr.includes(e)}var Nr=Symbol(`events`),Pr=new Set,Fr=new Set;function Ir(e,t,n,r={}){function i(e){if(r.capture||Br.call(t,e),!e.cancelBubble)return Tn(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?rt(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Lr(e,t,n,r,i){var a={capture:r,passive:i},o=Ir(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&jn(()=>{t.removeEventListener(e,o,a)})}function K(e,t,n){(t[Nr]??={})[e]=n}function Rr(e){for(var t=0;t<e.length;t++)Pr.add(e[t]);for(var n of Fr)n(e)}var zr=null;function Br(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;zr=e;var o=0,s=zr===e&&e[Nr];if(s){var c=i.indexOf(s);if(c!==-1&&(t===document||t===window)){e[Nr]=t;return}var l=i.indexOf(t);if(l===-1)return;c<=l&&(o=c)}if(a=i[o]||e.target,a!==t){p(e,`currentTarget`,{configurable:!0,get(){return a||n}});var u=rr,d=or;ar(null),sr(null);try{for(var f,m=[];a!==null&&a!==t;){try{var h=a[Nr]?.[r];h!=null&&(!a.disabled||e.target===a)&&h.call(a,e)}catch(e){f?m.push(e):f=e}if(e.cancelBubble)break;o++,a=o<i.length?i[o]:null}if(f){for(let e of m)queueMicrotask(()=>{throw e});throw f}}finally{e[Nr]=t,delete e.currentTarget,ar(u),sr(d)}}}var Vr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Hr(e){return Vr?.createHTML(e)??e}function Ur(e){var t=bn(`template`);return t.innerHTML=Hr(e.replaceAll(`<!>`,`<!---->`)),t.content}function Wr(e,t){var n=or;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function q(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(N)return Wr(P,null),P;i===void 0&&(i=Ur(a?e:`<!>`+e),n||(i=gn(i)));var t=r||dn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=gn(t),s=t.lastChild;Wr(o,s)}else Wr(t,t);return t}}function Gr(e=``){if(!N){var t=hn(e+``);return Wr(t,t),t}var n=P;return n.nodeType===3?xn(n):(n.before(n=hn()),Be(n)),Wr(n,n),n}function Kr(){if(N)return Wr(P,null),P;var e=document.createDocumentFragment(),t=document.createComment(``),n=hn();return e.append(t,n),Wr(t,n),e}function J(e,t){if(N){var n=or;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=P),Ve();return}e!==null&&e.before(t)}function Y(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[me]??=e.nodeValue)&&(e[me]=n,e.nodeValue=`${n}`)}function qr(e,t){return Yr(e,t)}var Jr=new Map;function Yr(e,{target:t,anchor:n,props:r={},events:i,context:a,intro:o=!0,transformError:s}){mn();var c=void 0,l=Pn(()=>{var o=n??t.appendChild(hn());ht(o,{pending:()=>{}},t=>{Qe({});var n=Xe;if(a&&(n.c=a),i&&(r.$$events=i),N&&Wr(t,null),c=e(t,r)||{},N&&(or.nodes.end=P,P===null||P.nodeType!==8||P.data!==`]`))throw Ie(),Ae;$e()},s);var l=new Set,u=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!l.has(r)){l.add(r);var i=Mr(r);for(let e of[t,document]){var a=Jr.get(e);a===void 0&&(a=new Map,Jr.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,Br,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return u(f(Pr)),Fr.add(u),()=>{for(var e of l)for(let n of[t,document]){var r=Jr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Br),r.delete(e),r.size===0&&Jr.delete(n)):r.set(e,i)}Fr.delete(u),o!==n&&o.parentNode?.removeChild(o)}});return Xr.set(c,l),c}var Xr=new WeakMap,Zr=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)Xn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Xn(r.effect),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&&(Gn(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();Qn(r,t),t.append(hn()),this.#n.set(e,{effect:r,fragment:t})}else Gn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Jn(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)||(Gn(n.effect),this.#n.delete(e))};ensure(e,t){var n=R,r=yn();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=hn();i.append(a),this.#n.set(e,{effect:Vn(()=>t(a)),fragment:i})}else this.#t.set(e,Vn(()=>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 N&&(this.anchor=P),this.#a(n)}};function X(e,t,n=!1){var r;N&&(r=P,Ve());var i=new Zr(e),a=n?re:0;function o(e,t){if(N){var n=We(r);if(e!==parseInt(n.substring(1))){var a=Ue();Be(a),i.anchor=a,ze(!1),i.ensure(e,t),ze(!0);return}}i.ensure(e,t)}zn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Qr=Symbol(`NaN`);function $r(e,t,n){N&&Ve();var r=new Zr(e),i=!et();zn(()=>{var e=t();e!==e&&(e=Qr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function ei(e,t){return t}function ti(e,t,n){for(var r=[],i=t.length,a,o=t.length,s=0;s<i;s++){let n=t[s];Jn(n,()=>{if(a){if(a.pending.delete(n),a.done.add(n),a.pending.size===0){var t=e.outrogroups;ni(e,f(a.done)),t.delete(a),t.size===0&&(e.outrogroups=null)}}else--o},!1)}if(o===0){var c=r.length===0&&n!==null;if(c){var l=n,u=l.parentNode;vn(u),u.append(l),e.items.clear()}ni(e,t,!c)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function ni(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|=oe,Qn(a,document.createDocumentFragment())):Gn(t[i],n)}}var ri;function Z(e,t,n,r,i,a=null){var o=e,s=new Map;if(t&4){var c=e;o=N?Be(gn(c)):c.appendChild(hn())}N&&Ve();var u=null,d=wt(()=>{var e=n();return l(e)?e:e==null?[]:f(e)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=u,ai(v,p,o,t,r),u!==null&&(p.length===0?u.f&33554432?(u.f^=oe,si(u,null,o)):Xn(u):Jn(u,()=>{u=null})))}function _(e){v.pending.delete(e)}var v={effect:zn(()=>{p=G(d);var e=p.length;let c=!1;N&&We(o)===`[!`!=(e===0)&&(o=Ue(),Be(o),ze(!1),c=!0);for(var l=new Set,f=R,v=yn(),y=0;y<e;y+=1){N&&P.nodeType===8&&P.data===`]`&&(o=P,c=!0,ze(!1));var b=p[y],x=r(b,y),S=h?null:s.get(x);S?(S.v&&tn(S.v,b),S.i&&tn(S.i,y),v&&f.unskip_effect(S.e)):(S=oi(s,h?o:ri??=hn(),b,x,y,i,t,n),h||(S.e.f|=oe),s.set(x,S)),l.add(x)}if(e===0&&a&&!u&&(h?u=Vn(()=>a(o)):(u=Vn(()=>a(ri??=hn())),u.f|=oe)),e>l.size&&be(``,``,``),N&&e>0&&Be(Ue()),!h)if(m.set(f,l),v){for(let[e,t]of s)l.has(e)||f.skip_effect(t.e);f.oncommit(g),f.ondiscard(_)}else g(f);c&&ze(!0),G(d)}),flags:t,items:s,pending:m,outrogroups:null,fallback:u};h=!1,N&&(o=P)}function ii(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function ai(e,t,n,r,i){var a=(r&8)!=0,o=t.length,s=e.items,c=ii(e.effect.first),l,u=null,d,p=[],m=[],h,g,_,v;if(a)for(v=0;v<o;v+=1)h=t[v],g=i(h,v),_=s.get(g).e,_.f&33554432||(_.nodes?.a?.measure(),(d??=new Set).add(_));for(v=0;v<o;v+=1){if(h=t[v],g=i(h,v),_=s.get(g).e,e.outrogroups!==null)for(let t of e.outrogroups)t.pending.delete(_),t.done.delete(_);if(_.f&8192&&(Xn(_),a&&(_.nodes?.a?.unfix(),(d??=new Set).delete(_))),_.f&33554432)if(_.f^=oe,_===c)si(_,null,n);else{var y=u?u.next:c;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),ci(e,u,_),ci(e,_,y),si(_,y,n),u=_,p=[],m=[],c=ii(u.next);continue}if(_!==c){if(l!==void 0&&l.has(_)){if(p.length<m.length){var b=m[0],x;u=b.prev;var S=p[0],C=p[p.length-1];for(x=0;x<p.length;x+=1)si(p[x],b,n);for(x=0;x<m.length;x+=1)l.delete(m[x]);ci(e,S.prev,C.next),ci(e,u,S),ci(e,C,b),c=b,u=C,--v,p=[],m=[]}else l.delete(_),si(_,c,n),ci(e,_.prev,_.next),ci(e,_,u===null?e.effect.first:u.next),ci(e,u,_),u=_;continue}for(p=[],m=[];c!==null&&c!==_;)(l??=new Set).add(c),m.push(c),c=ii(c.next);if(c===null)continue}_.f&33554432||p.push(_),u=_,c=ii(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(ni(e,f(t.done)),e.outrogroups?.delete(t));e.outrogroups.size===0&&(e.outrogroups=null)}if(c!==null||l!==void 0){var w=[];if(l!==void 0)for(_ of l)_.f&8192||w.push(_);for(;c!==null;)!(c.f&8192)&&c!==e.fallback&&w.push(c),c=ii(c.next);var T=w.length;if(T>0){var E=r&4&&o===0?n:null;if(a){for(v=0;v<T;v+=1)w[v].nodes?.a?.measure();for(v=0;v<T;v+=1)w[v].nodes?.a?.fix()}ti(e,w,E)}}a&&rt(()=>{if(d!==void 0)for(_ of d)_.nodes?.a?.apply()})}function oi(e,t,n,r,i,a,o,s){var c=o&1?o&16?$t(n):en(n,!1,!1):null,l=o&2?$t(i):null;return{v:c,i:l,e:Vn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function si(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=_n(r);if(a.before(r),r===i)return;r=o}}function ci(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function li(e,t,n=!1,r=!1,i=!1,a=!1){var o=e,s=``;if(n){var c=e;N&&(o=Be(gn(c)))}W(()=>{var e=or;if(s===(s=t()??``)){N&&Ve();return}if(n&&!N){e.nodes=null,c.innerHTML=s,s!==``&&Wr(gn(c),c.lastChild);return}if(e.nodes!==null&&(Kn(e.nodes.start,e.nodes.end),e.nodes=null),s!==``){if(N){for(var a=P.data,l=Ve(),u=l;l!==null&&(l.nodeType!==8||l.data!==``);)u=l,l=_n(l);if(l===null)throw Ie(),Ae;Wr(P,u),o=Be(l);return}var d=bn(r?`svg`:i?`math`:`template`,r?Ne:i?Pe:void 0);d.innerHTML=s;var f=r||i?d:d.content;if(Wr(gn(f),f.lastChild),r||i)for(;gn(f);)o.before(gn(f));else o.before(f)}})}function ui(e,t,...n){var r=new Zr(e);zn(()=>{let e=t()??null;r.ensure(e,e&&(t=>e(t,...n)))},re)}function di(e,t){let n=null,r=N;var i;if(N){n=P;for(var a=gn(document.head);a!==null&&(a.nodeType!==8||a.data!==e);)a=_n(a);if(a===null)ze(!1);else{var o=_n(a);a.remove(),Be(o)}}N||(i=document.head.appendChild(hn()));try{zn(()=>{var e=Vn(()=>t(i));e.f|=ie})}finally{r&&(ze(!0),Be(n))}}function fi(e,t,n){Fn(()=>{var r=Or(()=>t(e,n?.())||{});if(n&&r?.update){var i=!1,a={};Ln(()=>{var e=n();kr(e),i&&Ke(a,e)&&(a=e,r.update(e))}),i=!0}if(r?.destroy)return()=>r.destroy()})}function pi(e,t){var n=void 0,r;Bn(()=>{n!==(n=t())&&(r&&=(Gn(r),null),n&&(r=Vn(()=>{Fn(()=>n(e))})))})}function mi(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=mi(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function hi(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=mi(e))&&(r&&(r+=` `),r+=t);return r}function gi(e){return typeof e==`object`?hi(e):e??``}var _i=[...`
|
|
2
|
+
\r\f\xA0\v`];function vi(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||_i.includes(r[o-1]))&&(s===r.length||_i.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function yi(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 bi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function xi(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(bi)),i&&c.push(...Object.keys(i).map(bi));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=bi(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+=yi(r)),i&&(n+=yi(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function Si(e,t,n,r,i,a){var o=e[M];if(N||o!==n||o===void 0){var s=vi(n,r,a);(!N||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e[M]=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 Ci(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 wi(e,t,n,r){var i=e[pe];if(N||i!==t){var a=xi(t,r);(!N||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e[pe]=t}else r&&(Array.isArray(r)?(Ci(e,n?.[0],r[0]),Ci(e,n?.[1],r[1],`important`)):Ci(e,n,r));return r}function Ti(e,t,n=!1){if(e.multiple){if(t==null)return;if(!l(t))return Le();for(var r of e.options)r.selected=t.includes(Oi(r));return}for(r of e.options)if(cn(Oi(r),t)){r.selected=!0;return}(!n||t!==void 0)&&(e.selectedIndex=-1)}function Ei(e){var t=new MutationObserver(()=>{Ti(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),jn(()=>{t.disconnect()})}function Di(e,t,n=t){var r=new WeakSet,i=!0;En(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),Oi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&Oi(o)}n(a),e.__value=a,R!==null&&r.add(R)}),Fn(()=>{var a=t();if(e===document.activeElement){var o=R;if(r.has(o))return}if(Ti(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=Oi(s),n(a))}e.__value=a,i=!1}),Ei(e)}function Oi(e){return`__value`in e?e.__value:e.value}var ki=Symbol(`is custom element`),Ai=Symbol(`is html`),ji=_e?`link`:`LINK`,Mi=_e?`progress`:`PROGRESS`;function Ni(e){if(N){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Q(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Q(e,`checked`,null),e.checked=r}}};e[he]=n,rt(n),wn()}}function Pi(e,t){var n=Ii(e);n.value===(n.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==Mi)||(e.value=t??``)}function Fi(e,t){var n=Ii(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function Q(e,t,n,r){var i=Ii(e);N&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===ji)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[fe]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Ri(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function Ii(e){return e[j]??={[ki]:e.nodeName.includes(`-`),[Ai]:e.namespaceURI===Me}}var Li=new Map;function Ri(e){var t=e.getAttribute(`is`)||e.nodeName,n=Li.get(t);if(n)return n;Li.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=h(i),r)r[o].set&&o!==`innerHTML`&&o!==`textContent`&&o!==`innerText`&&n.push(o);i=v(i)}return n}function zi(e,t,n=t){var r=new WeakSet;En(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=Bi(e)?Vi(a):a,n(a),R!==null&&r.add(R),await Tr(),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))}}}),(N&&e.defaultValue!==e.value||Or(t)==null&&e.value)&&(n(Bi(e)?Vi(e.value):e.value),R!==null&&r.add(R)),Ln(()=>{var n=t();if(e===document.activeElement){var i=R;if(r.has(i))return}Bi(e)&&n===Vi(e.value)||e.type===`date`&&!n&&!e.value||n!==e.value&&(e.value=n??``)})}function Bi(e){var t=e.type;return t===`number`||t===`range`}function Vi(e){return e===``?null:+e}function Hi(e,t){return e===t||e?.[ue]===t}function Ui(e={},t,n,r){var i=Xe.r,a=or;return Fn(()=>{var o,s;return Ln(()=>{o=s,s=r?.()||[],Or(()=>{Hi(n(...s),e)||(t(e,...s),o&&Hi(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&&Hi(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Wi(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?Ln(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&jn(()=>{n.removeEventListener(t,a)})}function $(e,t,n,r){var i=!Je||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,s=r,c=!0,l=void 0,u=()=>o&&i?(l??=xt(r),G(l)):(c&&(c=!1,s=o?Or(r):r),s);let d;if(a){var f=ue in e||de in e;d=m(e,t)?.set??(f&&t in e?n=>e[t]=n:void 0)}var p,h=!1;a?[p,h]=ft(()=>e[t]):p=e[t],p===void 0&&r!==void 0&&(p=u(),d&&(i&&Te(t),d(p)));var g=i?()=>{var n=e[t];return n===void 0?u():(c=!0,n)}:()=>{var n=e[t];return n!==void 0&&(s=void 0),n===void 0?s:n};if(i&&!(n&4))return g;if(d){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&d(t?g():e),e):g()})}var v=!1,y=(n&1?xt:wt)(()=>(v=!1,g()));a&&G(y);var b=or;return(function(e,t){if(arguments.length>0){let n=t?G(y):i&&a?on(e):e;return B(y,n),v=!0,s!==void 0&&(s=n),e}return tr&&v||b.f&16384?y.v:G(y)})}function Gi(e){Xe===null&&ve(`onMount`),Je&&Xe.l!==null?qi(Xe).m.push(e):Mn(()=>{let t=Or(e);if(typeof t==`function`)return t})}function Ki(e){Xe===null&&ve(`onDestroy`),Gi(()=>()=>Or(e))}function qi(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var Ji=`gestalt-mobile.theme`,Yi=`dyne-org`,Xi=[{id:`dyne-org`,label:`Dyne.org`,colorScheme:`light`,logoTone:`dark`},{id:`minimal-light`,label:`Minimal light`,colorScheme:`light`,logoTone:`dark`},{id:`minimal-dark`,label:`Minimal dark`,colorScheme:`dark`,logoTone:`light`}];function Zi(e){return typeof e==`string`&&Xi.some(t=>t.id===e)}function Qi(e){return e===`light`?`minimal-light`:e===`dark`?`minimal-dark`:Zi(e)?e:Yi}function $i(e){return Xi.find(t=>t.id===e)||ea(e)}function ea(e){throw Error(`Unknown theme ID: ${e}`)}function ta(e){try{return e?.getItem(`gestalt-mobile.theme`)??null}catch{return null}}function na(e){if(`storage`in e)return e.storage??null;try{return window.localStorage}catch{return null}}function ra(e){return`meta`in e?e.meta??null:document.querySelector(`meta[name="color-scheme"]`)}function ia(e,t={}){let n=t.root??document.documentElement,r=ra(t),i=$i(e);return n.dataset.theme=i.id,n.dataset.logoTone=i.logoTone,n.style.colorScheme=i.colorScheme,r&&(r.content=i.colorScheme),i.id}function aa(e={}){return ia(Qi(ta(na(e))),e)}function oa(e,t={}){let n=ia(e,t);try{na(t)?.setItem(Ji,n)}catch{}return n}var sa=q(`<img class="brand-icon brand-icon-custom" alt=""/>`),ca=q(`<img class="brand-icon light-asset" src="/branding/p_glogo_grey.svg" alt=""/> <img class="brand-icon dark-asset" src="/branding/p_glogo_white.svg" alt=""/>`,1),la=q(`<span class="session-model svelte-t9laac"><small> </small></span>`),ua=q(`<p class="session-path svelte-t9laac"> <!></p>`),da=q(`<span class="weekly-quota" aria-label="Weekly quota remaining"> </span>`),fa=q(`<button class="detach-chat svelte-t9laac" type="button" aria-label="Open Chat in a separate window" title="Open Chat in a separate window"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-t9laac"><path d="M14 5h5v5M19 5l-8 8"></path><path d="M18 13v5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"></path></svg></button>`),pa=q(`<option> </option>`),ma=q(`<button type="button" popovertarget="configuration-panel" popovertargetaction="hide"> </button>`),ha=q(`<button type="button" popovertarget="configuration-panel" popovertargetaction="hide">Copy session to CLI</button>`),ga=q(`<button type="button" popovertarget="configuration-panel" popovertargetaction="hide">Authorized devices</button> <button type="button" class="lock-relay" popovertarget="configuration-panel" popovertargetaction="hide">Lock Gestalt Mobile</button>`,1),_a=q(`<div class="svelte-t9laac"><dt class="svelte-t9laac"> </dt> <dd class="svelte-t9laac"> </dd></div>`),va=q(`<section class="component-versions svelte-t9laac" aria-labelledby="component-versions-title"><h2 id="component-versions-title" class="svelte-t9laac">Versions</h2> <dl class="svelte-t9laac"></dl></section>`),ya=q(`<header class="app-header"><a class="brand" href="/" aria-label="Gestalt Mobile"><!> <img class="brand-logotype light-asset" src="/branding/t_glogo_grey.svg" alt=""/> <img class="brand-logotype dark-asset" src="/branding/t_glogo_white.svg" alt=""/></a> <!> <div class="header-actions"><!> <!> <button class="menu-trigger" type="button" popovertarget="configuration-panel" aria-label="Open configuration"><span class="menu-lines" aria-hidden="true"><span></span><span></span><span></span></span></button></div></header> <div id="configuration-panel" class="configuration-panel" popover="auto"><div class="configuration-brand" aria-label="Dyne"><img class="configuration-logo light-asset" src="/branding/dyne-logotype-black.svg" alt=""/> <img class="configuration-logo dark-asset" src="/branding/dyne-logotype-white.svg" alt=""/></div> <label class="appearance-control" for="appearance"><span aria-hidden="true">aA</span> <select id="appearance" aria-label="Appearance"></select></label> <!> <button type="button" popovertarget="configuration-panel" popovertargetaction="hide">Notifications</button> <button type="button" popovertarget="configuration-panel" popovertargetaction="hide">Scratchpad</button> <!> <!> <!> <div class="maintenance-actions svelte-t9laac"><button type="button" popovertarget="configuration-panel" popovertargetaction="hide" class="quit-relay svelte-t9laac">Quit</button></div></div> <dialog aria-labelledby="quit-title" aria-describedby="quit-description" class="svelte-t9laac"><h2 id="quit-title" class="svelte-t9laac">Quit Gestalt Mobile?</h2> <p id="quit-description" class="svelte-t9laac">This stops Gestalt Mobile and every session process it started, including work that is currently
|
|
3
|
+
running. Saved sessions remain available the next time Gestalt Mobile starts.</p> <div class="dialog-actions svelte-t9laac"><button type="button" class="svelte-t9laac">Cancel</button> <button class="confirm-quit svelte-t9laac" type="button"> </button></div></dialog>`,1);function ba(e,t){Qe(t,!0);let n=$(t,`sessionPath`,3,null),r=$(t,`sessionModel`,3,null),i=$(t,`weeklyQuotaRemaining`,3,null),a=$(t,`brandIconUrl`,3,null),o=$(t,`passkeyAuthEnabled`,3,!0),s=$(t,`componentVersions`,19,()=>[]),c=$(t,`contextualActions`,19,()=>[]),l=$(t,`onlock`,3,()=>{}),u=$(t,`ondevices`,3,()=>{}),d=$(t,`onnotifications`,3,()=>{}),f=$(t,`onscratchpad`,3,()=>{}),p=$(t,`onquit`,3,async()=>{}),m=$(t,`copyToCliAvailable`,3,!0),h=z(null),g=z(null),_=z(null),v=z(!1);function y(){G(g)?.showModal(),queueMicrotask(()=>G(_)?.focus())}async function b(){B(v,!0);try{await p()()}catch{B(v,!1)}}function x(){G(v)||G(g)?.close()}function S(){G(v)||queueMicrotask(()=>G(h)?.focus())}var C=ya(),w=H(C),T=V(w),E=V(T),D=e=>{var t=sa();W(()=>Q(t,`src`,a())),J(e,t)},ee=e=>{var t=ca();He(2),J(e,t)};X(E,e=>{a()?e(D):e(ee,-1)}),He(4),F(T);var O=U(T,2),te=e=>{var t=ua(),i=V(t,!0),a=U(i),o=e=>{var t=la(),n=V(t),i=V(n);F(n),F(t),W(()=>Y(i,`· ${r()??``}`)),J(e,t)};X(a,e=>{r()&&e(o)}),F(t),W(()=>{Q(t,`title`,n()),Y(i,n())}),J(e,t)};X(O,e=>{n()&&e(te)});var ne=U(O,2),re=V(ne),ie=e=>{var t=da(),n=V(t);F(t),W(()=>Y(n,`${i()??``}% left`)),J(e,t)};X(re,e=>{i()!==null&&e(ie)});var k=U(re,2),ae=e=>{var n=fa();K(`click`,n,function(...e){t.ondetach?.apply(this,e)}),J(e,n)};X(k,e=>{t.ondetach&&e(ae)}),Ui(U(k,2),e=>B(h,e),()=>G(h)),F(ne),F(w);var oe=U(w,2),se=U(V(oe),2),ce=U(V(se),2);Z(ce,21,()=>Xi,e=>e.id,(e,t)=>{var n=pa(),r=V(n,!0);F(n);var i={};W(()=>{Y(r,G(t).label),i!==(i=G(t).id)&&(n.value=(n.__value=G(t).id)??``)}),J(e,n)}),F(ce);var le;Ei(ce),F(se);var A=U(se,2);Z(A,17,c,e=>e.id,(e,t)=>{var n=ma(),r=V(n,!0);F(n),W(()=>Y(r,G(t).label)),K(`click`,n,function(...e){G(t).run?.apply(this,e)}),J(e,n)});var ue=U(A,2),de=U(ue,2),fe=U(de,2),j=e=>{var n=ha();W(()=>n.disabled=!m()),K(`click`,n,function(...e){t.oncopytocli?.apply(this,e)}),J(e,n)};X(fe,e=>{t.oncopytocli&&e(j)});var M=U(fe,2),pe=e=>{var t=ga(),n=H(t),r=U(n,2);K(`click`,n,e=>u()(e.currentTarget)),K(`click`,r,function(...e){l()?.apply(this,e)}),J(e,t)};X(M,e=>{o()&&e(pe)});var me=U(M,2),he=e=>{var t=va(),n=U(V(t),2);Z(n,21,s,e=>e.id,(e,t)=>{var n=_a(),r=V(n),i=V(r,!0);F(r);var a=U(r,2),o=V(a,!0);F(a),F(n),W(()=>{Y(i,G(t).label),Q(a,`title`,G(t).version??`Version unavailable`),Y(o,G(t).version??`Unavailable`)}),J(e,n)}),F(n),F(t),J(e,t)};X(me,e=>{s().length&&e(he)});var ge=U(me,2),_e=V(ge);F(ge),F(oe);var ve=U(oe,2),ye=U(V(ve),4),be=V(ye);Ui(be,e=>B(_,e),()=>G(_));var xe=U(be,2),Se=V(xe,!0);F(xe),F(ye),F(ve),Ui(ve,e=>B(g,e),()=>G(g)),W(()=>{le!==(le=t.theme)&&(ce.value=(ce.__value=t.theme)??``,Ti(ce,t.theme)),Q(ve,`aria-busy`,G(v)),be.disabled=G(v),xe.disabled=G(v),Y(Se,G(v)?`Quitting…`:`Quit`)}),K(`change`,ce,e=>t.onthemechange(e.currentTarget.value)),K(`click`,ue,function(...e){d()?.apply(this,e)}),K(`click`,de,function(...e){f()?.apply(this,e)}),K(`click`,_e,y),Lr(`cancel`,ve,e=>G(v)?e.preventDefault():S()),Lr(`close`,ve,S),K(`click`,be,x),K(`click`,xe,()=>void b()),J(e,C),$e()}Rr([`click`,`change`]);function xa(e){return[[`Handoff trace`,e.handoffTrace??`Unavailable`],[`Control`,e.control??`Unavailable`],[`Mobile session`,e.mobileSession],[`Codex thread`,e.codexThread??`Unavailable`],...e.provider===`kimi`?[[`Kimi thread`,e.sourceThread??`Unavailable`]]:[]]}var Sa=q(`<div class="svelte-vx755z"><dt class="svelte-vx755z"> </dt> <dd class="svelte-vx755z"> </dd></div>`),Ca=q(`<div class="debug-identifiers svelte-vx755z"><h3 class="svelte-vx755z">Debug identifiers</h3> <dl class="svelte-vx755z"></dl> <h3 class="svelte-vx755z">Versions</h3> <dl class="svelte-vx755z"></dl></div>`);function wa(e,t){Qe(t,!0);var n=Ca(),r=U(V(n),2);Z(r,21,()=>xa(t.context),([e,t])=>e,(e,t)=>{var n=L(()=>C(G(t),2));let r=()=>G(n)[0],i=()=>G(n)[1];var a=Sa(),o=V(a),s=V(o,!0);F(o);var c=U(o,2),l=V(c,!0);F(c),F(a),W(()=>{Y(s,r()),Y(l,i())}),J(e,a)}),F(r);var i=U(r,4);Z(i,21,()=>t.context.versions,e=>e.id,(e,t)=>{var n=Sa(),r=V(n),i=V(r,!0);F(r);var a=U(r,2),o=V(a,!0);F(a),F(n),W(()=>{Y(i,G(t).label),Y(o,G(t).version??`Unavailable`)}),J(e,n)}),F(i),F(n),J(e,n),$e()}var Ta=q(`<dialog aria-labelledby="debug-title" aria-describedby="debug-description" class="svelte-f06alb"><h2 id="debug-title" class="svelte-f06alb">Confirm spawning a new Gestalt DEBUG session?</h2> <p id="debug-description" class="svelte-f06alb">Capture a redacted diagnostic trace and start an independent agent in ~/.gestalt/self-debug to
|
|
4
|
+
investigate and fix the error.</p> <!> <div class="dialog-actions svelte-f06alb"><button type="button" class="svelte-f06alb">Cancel</button> <button type="button" class="svelte-f06alb"> </button></div></dialog>`);function Ea(e,t){Qe(t,!0);let n,r,i=z(!1);Gi(()=>{n.showModal(),r.focus()});async function a(){if(!G(i)){B(i,!0);try{await t.onconfirm()}catch{}finally{B(i,!1)}}}var o=Ta(),s=U(V(o),4);wa(s,{get context(){return t.confirmation.context}});var c=U(s,2),l=V(c);Ui(l,e=>r=e,()=>r);var u=U(l,2),d=V(u,!0);F(u),F(c),F(o),Ui(o,e=>n=e,()=>n),W(()=>{Q(o,`aria-busy`,G(i)),l.disabled=G(i),u.disabled=G(i),Y(d,G(i)?`Preparing Self DEBUG…`:`Start Self DEBUG`)}),Lr(`cancel`,o,e=>{G(i)&&e.preventDefault()}),Lr(`close`,o,function(...e){t.onclose?.apply(this,e)}),K(`click`,l,()=>n.close()),K(`click`,u,()=>void a()),J(e,o),$e()}Rr([`click`]);function Da(e,t,n){return n?e.filter(e=>e.tab===t&&e.available(n)):[]}function Oa(e){return e.reduce((e,t)=>{let n=ka(t);return n?.kind===`Command`?(n.status===`completed`&&(e.successful+=1),n.status===`failed`&&(e.failed+=1),e):e},{successful:0,failed:0})}function ka(e){if(Aa(e))return null;let[t,n]=e.label.split(` · `,2);return{kind:t,...n?{status:n}:{},content:ja(t,e.detail)}}function Aa(e){return e.label.startsWith(`Tool`)&&(e.detail.includes(`context_mode`)||/(^|[_:])ctx_[a-z]/i.test(e.detail))}function ja(e,t){return e===`Command`?Ma(t):e===`File change`||e===`fileChange`?t.split(`
|
|
5
|
+
`).filter(Boolean).join(`, `):t}function Ma(e){let t=e.match(/^\/bin\/bash -lc "([\s\S]*)"$/);return t?t[1].replace(/\\"/g,`"`).replace(/\\\\/g,`\\`):e}var Na=q(`<dl class="command-counts svelte-thyolt"><div data-command-outcome="successful" class="svelte-thyolt"><dt class="svelte-thyolt">Successful commands</dt> <dd class="svelte-thyolt"> </dd></div> <div data-command-outcome="failed" class="svelte-thyolt"><dt class="svelte-thyolt">Failed commands</dt> <dd class="svelte-thyolt"> </dd></div></dl>`),Pa=q(`<li class="activity-row svelte-thyolt"><small class="activity-type svelte-thyolt"> </small> <span class="activity-content svelte-thyolt"> </span></li>`),Fa=q(`<ul class="activity-list svelte-thyolt"></ul>`),Ia=q(`<details class="chat-activity svelte-thyolt"><summary class="svelte-thyolt">activity</summary> <!> <!></details>`),La=q(`<section class="live-activity svelte-thyolt" aria-label="Current activity"><strong class="svelte-thyolt">activity</strong> <!> <!></section>`);function Ra(e,t){Qe(t,!0);let n=e=>{var t=Na(),n=V(t),r=U(V(n),2),i=V(r,!0);F(r),F(n);var a=U(n,2),o=U(V(a),2),c=V(o,!0);F(o),F(a),F(t),W(()=>{Y(i,G(s).successful),Y(c,G(s).failed)}),J(e,t)},r=e=>{var t=Kr(),n=H(t),r=e=>{var t=Fa();Z(t,21,()=>G(c),e=>e.id,(e,t)=>{var n=Pa(),r=V(n),i=V(r);F(r);var a=U(r,2),o=V(a,!0);F(a),F(n),W(e=>{Q(n,`data-activity-kind`,e),Q(n,`data-activity-status`,G(t).status),Y(i,`${G(t).kind??``}${G(t).status?` · ${G(t).status}`:``}`),Y(o,G(t).content)},[()=>G(t).kind.toLowerCase().replaceAll(` `,`-`)]),J(e,n)}),F(t),J(e,t)};X(n,e=>{G(c).length&&e(r)}),J(e,t)},i=$(t,`variant`,3,`summary`),a=L(()=>t.activities.flatMap(e=>{let t=ka(e);return t&&t.kind.toLowerCase().replaceAll(` `,``)!==`filechange`?[{id:e.id,...t}]:[]})),o=L(()=>G(a).some(e=>e.kind===`Command`)),s=L(()=>Oa(t.activities)),c=L(()=>G(a).filter(e=>e.kind!==`Command`));var l=Kr(),u=H(l),d=e=>{var t=Kr(),a=H(t),s=e=>{var t=Ia(),i=U(V(t),2),a=e=>{n(e)};X(i,e=>{G(o)&&e(a)});var s=U(i,2);r(s),F(t),J(e,t)},c=e=>{var t=La(),i=U(V(t),2),a=e=>{n(e)};X(i,e=>{G(o)&&e(a)});var s=U(i,2);r(s),F(t),J(e,t)};X(a,e=>{i()===`summary`?e(s):e(c,-1)}),J(e,t)};X(u,e=>{(G(o)||G(c).length)&&e(d)}),J(e,l),$e()}var za=q(`<summary><!></summary>`),Ba=q(`<button><!></button>`);function Va(e,t){let n=$(t,`element`,3,`button`),r=$(t,`type`,3,`button`),i=$(t,`disabled`,3,!1),a=$(t,`compact`,3,!1),o=$(t,`full`,3,!1),s=$(t,`primary`,3,!1),c=$(t,`accentPressed`,3,!1);var l=Kr(),u=H(l),d=e=>{var n=za();ui(V(n),()=>t.children),F(n),W(()=>{Q(n,`id`,t.id),Si(n,1,gi([`app-control`,t.class,{compact:a(),full:o(),primary:s(),accentPressed:c()}]),`svelte-6ey372`),Q(n,`data-state`,t.state)}),J(e,n)},f=e=>{var n=Ba();ui(V(n),()=>t.children),F(n),W(()=>{Q(n,`id`,t.id),Q(n,`type`,r()),n.disabled=i(),Si(n,1,gi([`app-control`,t.class,{compact:a(),full:o(),primary:s(),accentPressed:c()}]),`svelte-6ey372`),Q(n,`aria-label`,t.label),Q(n,`aria-current`,t.current),Q(n,`aria-pressed`,t.pressed),Q(n,`aria-describedby`,t.describedby),Q(n,`aria-disabled`,t.ariaDisabled)}),K(`click`,n,function(...e){t.onclick?.apply(this,e)}),J(e,n)};X(u,e=>{n()===`summary`?e(d):e(f,-1)}),J(e,l)}Rr([`click`]);var Ha=e=>({working:`working`,idle:`idle`,awaitingAgent:`waiting for child`,awaitingHuman:`needs you`,blocked:`blocked`,disconnected:`disconnected`})[e];function Ua(e,t){if(!t)return{polite:``,critical:``};let n=!e||e.root.state!==t.root.state||e.aggregateSubagents!==t.aggregateSubagents,r=t.root.state===`blocked`||t.root.state===`awaitingHuman`;return{polite:n?`l0 ${Ha(t.root.state)}; subagents ${Ha(t.aggregateSubagents)}.`:``,critical:r&&(!e||e.root.state!==t.root.state)?`l0 ${Ha(t.root.state)}.`:``}}function Wa(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`recently`;let r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`<1m`;let i=Math.floor(r/60);if(i<60)return`${i}m`;let a=Math.floor(i/60);if(a<24)return`${a}h`;let o=Math.floor(a/24);if(o<7)return`${o}d`;let s=Math.floor(o/7);if(s<5)return`${s}w`;let c=Math.floor(o/30);return c<12?`${c}mo`:`${Math.floor(o/365)}y`}var Ga=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j"> </strong> <span class="agent-metadata svelte-d9jh4j"> </span> <time class="svelte-d9jh4j"> </time></li>`),Ka=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j">l0</strong> <span class="agent-metadata svelte-d9jh4j"> </span> <span class="unavailable svelte-d9jh4j" role="status">activity unavailable</span></li>`),qa=q(`<details class="agents svelte-d9jh4j"><!> <ul class="svelte-d9jh4j"><!></ul></details>`),Ja=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j"> </strong> <small class="svelte-d9jh4j"> </small></li>`),Ya=q(`<div class="chips svelte-d9jh4j"><span class="chip svelte-d9jh4j"><span aria-hidden="true" class="svelte-d9jh4j">●</span> </span> <details class="children svelte-d9jh4j"><summary class="chip svelte-d9jh4j"><span aria-hidden="true" class="svelte-d9jh4j">◆</span> </summary> <ul class="svelte-d9jh4j"></ul></details> <span class="freshness svelte-d9jh4j"> </span></div>`),Xa=q(`<p class="visually-hidden svelte-d9jh4j" role="alert"> </p>`),Za=q(`<p class="visually-hidden svelte-d9jh4j" aria-live="polite" aria-atomic="true"> </p> <!>`,1),Qa=q(`<section aria-label="Agent activity"><!> <!></section>`);function $a(e,t){Qe(t,!0);let n=$(t,`compact`,3,!1),r=$(t,`popupAlign`,3,`end`),i=$(t,`onopen`,3,()=>{}),a={working:`working`,idle:`idle`,awaitingAgent:`waiting for child`,awaitingHuman:`needs you`,blocked:`blocked`,disconnected:`disconnected`},o={working:0,awaitingAgent:1,awaitingHuman:1,blocked:1,idle:2,disconnected:3},s=z(``),c=z(``),l=null,u=z(on(Date.now())),d=L(()=>t.activity?`${t.activity.sessionId}:${t.activity.root.state}:${t.activity.aggregateSubagents}`:``),f=L(()=>t.activity?[`blocked`,`awaitingHuman`,`disconnected`].includes(t.activity.root.state)?t.activity.root.state:t.activity.aggregateSubagents:`unavailable`);function p(e){return e.canonicalTaskName??e.canonicalPosition?.toLowerCase()??e.nickname??e.role??e.id}function m(){return`l0`}function h(e){return e===void 0?`(ctx: —)`:`(ctx: ${e}%)`}function g(e){let t=/^L([1-9]\d*)(?:\.([1-9]\d*))?$/.exec(e??``);return t?Number(t[1])*1e3+Number(t[2]??0):2**53-1}function _(e,t){return g(e.canonicalPosition)-g(t.canonicalPosition)||(e.continuationGeneration??1)-(t.continuationGeneration??1)||o[e.state]-o[t.state]||p(e).localeCompare(p(t))}let v=L(()=>t.activity?[{key:`root`,name:m(),planOrder:-1,generation:0,contextUsedPercent:t.activity.root.contextUsedPercent,role:`supervisor`,...t.rootModel?{model:t.rootModel}:{},state:t.activity.root.state,lastActivityAt:t.activity.root.lastActivityAt},...t.activity.subagents.map(e=>({key:`child:${e.id}`,name:p(e),planOrder:g(e.canonicalPosition),generation:e.continuationGeneration??1,contextUsedPercent:e.contextUsedPercent,...e.role?{role:e.role}:{},...e.model?{model:e.model}:{},state:e.state,lastActivityAt:e.lastActivityAt}))].sort((e,t)=>e.planOrder-t.planOrder||e.generation-t.generation||o[e.state]-o[t.state]||e.name.localeCompare(t.name)):[]),y=L(()=>t.activity?[...t.activity.subagents].sort(_):[]);Gi(()=>{let e=window.setInterval(()=>B(u,Date.now(),!0),6e4);return()=>window.clearInterval(e)});function b(e,t){let n=Wa(t,G(u));return e===`idle`||e===`disconnected`?`${a[e]} since ${n}`:`${a[e]} · active ${n} ago`}Mn(()=>{if(!G(d))return;let e=Or(()=>t.activity),n=Or(()=>l);if(!e)return;let r=Ua(n?.sessionId===e.sessionId?n:null,e);r.polite&&B(s,r.polite,!0),r.critical?B(c,r.critical,!0):e.root.state!==`blocked`&&e.root.state!==`awaitingHuman`&&B(c,``),l=e});var x=Qa();let S;var C=V(x),w=e=>{var n=qa(),r=V(n);Va(r,{element:`summary`,compact:!0,full:!0,get state(){return G(f)},children:(e,n)=>{He();var r=Gr();W(()=>Y(r,`Agents (${(t.activity?.subagents.length??0)+1})`)),J(e,r)},$$slots:{default:!0}});var a=U(r,2),o=V(a),s=e=>{var t=Kr();Z(H(t),17,()=>G(v),e=>e.key,(e,t)=>{var n=Ga(),r=V(n),i=V(r,!0);F(r);var a=U(r,2),o=V(a,!0);F(a);var s=U(a,2),c=V(s,!0);F(s),F(n),W((e,n)=>{Y(i,G(t).name),Y(o,e),Q(s,`datetime`,G(t).lastActivityAt),Y(c,n)},[()=>[h(G(t).contextUsedPercent),G(t).role,G(t).model?`Model: ${G(t).model}`:`Model unavailable`].filter(Boolean).join(` · `),()=>b(G(t).state,G(t).lastActivityAt)]),J(e,n)}),J(e,t)},c=e=>{var n=Ka(),r=U(V(n),2),i=V(r,!0);F(r),He(2),F(n),W(e=>Y(i,e),[()=>[`(ctx: —)`,`supervisor`,t.rootModel?`Model: ${t.rootModel}`:`Model unavailable`].filter(Boolean).join(` · `)]),J(e,n)};X(o,e=>{t.activity?e(s):e(c,-1)}),F(a),F(n),Lr(`toggle`,n,e=>e.currentTarget.open&&i()()),J(e,n)},T=e=>{var n=Ya(),r=V(n),i=U(V(r));F(r);var o=U(r,2),s=V(o),c=U(V(s));F(s);var l=U(s,2);Z(l,21,()=>G(y),e=>e.id,(e,t)=>{var n=Ja(),r=V(n),i=V(r,!0);F(r);var o=U(r),s=U(o),c=V(s,!0);F(s),F(n),W((e,n)=>{Y(i,e),Y(o,` · ${n??``}${G(t).role?` · ${G(t).role}`:``}${G(t).model?` · Model: ${G(t).model}`:``} —
|
|
6
|
+
${a[G(t).state]??``} `),Y(c,G(t).lastActivityAt)},[()=>p(G(t)),()=>h(G(t).contextUsedPercent)]),J(e,n)}),F(l),F(o);var u=U(o,2),d=V(u,!0);F(u),F(n),W(e=>{Q(r,`data-state`,t.activity.root.state),Y(i,` l0: ${a[t.activity.root.state]??``}
|
|
7
|
+
${e??``}`),Q(s,`data-state`,t.activity.aggregateSubagents),Y(c,` Subagents: ${a[t.activity.aggregateSubagents]??``} (${t.activity.subagents.length??``})`),Y(d,t.activity.confidence===`fresh`?`Current`:t.activity.confidence===`reconciling`?`Checking updates`:`May be stale`)},[()=>h(t.activity.root.contextUsedPercent)]),J(e,n)};X(C,e=>{n()?e(w):t.activity&&e(T,1)});var E=U(C,2),D=e=>{var t=Za(),n=H(t),r=V(n,!0);F(n);var i=U(n,2),a=e=>{var t=Xa(),n=V(t,!0);F(t),W(()=>Y(n,G(c))),J(e,t)};X(i,e=>{G(c)&&e(a)}),W(()=>Y(r,G(s))),J(e,t)};X(E,e=>{t.activity&&e(D)}),F(x),W(()=>S=Si(x,1,`agent-activity svelte-d9jh4j`,null,S,{compact:n(),"align-start":r()===`start`})),J(e,x),$e()}Ye();var eo=q(`<main class="svelte-iw6wrs"><h1 class="svelte-iw6wrs">Activity evidence</h1> <!><!></main>`);function to(e){let t={sessionId:`evidence`,confidence:`reconciling`,aggregateSubagents:`working`,root:{state:`awaitingAgent`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`},subagents:[{id:`α-worker`,nickname:`α worker`,role:`research`,state:`working`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`}]},n=[`working`,`awaitingAgent`,`awaitingHuman`,`blocked`,`idle`,`disconnected`];var r=eo(),i=U(V(r),2);$a(i,{get activity(){return t}}),Z(U(i),1,()=>n,e=>e,(e,n)=>{{let r=wt(()=>({...t,sessionId:G(n),confidence:G(n)===`blocked`?`stale`:`fresh`,root:{...t.root,state:G(n)},aggregateSubagents:G(n)}));$a(e,{get activity(){return G(r)}})}}),F(r),J(e,r)}function no(e,t){if(!e||typeof e!=`object`)return!1;let n=e,r=new Set([`working`,`idle`,`awaitingAgent`,`awaitingHuman`,`blocked`,`disconnected`]),i=(e,t=256)=>typeof e==`string`&&e.length<=t,a=e=>Array.isArray(e)&&e.length<=64&&e.every(e=>{let t=e;return t&&typeof t==`object`&&[`running`,`detached-active`,`exited-awaiting-result`,`result-consumed`,`terminated-for-budget`].includes(t.state)&&[`executor`,`supervisor`].includes(t.ownership)&&i(t.observedAt,64)&&!Number.isNaN(Date.parse(t.observedAt))}),o=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return i(t.state,32)&&r.has(t.state)&&i(t.observedAt,64)&&i(t.lastActivityAt,64)&&!Number.isNaN(Date.parse(t.observedAt))&&!Number.isNaN(Date.parse(t.lastActivityAt))&&(t.reason===void 0||i(t.reason,64))&&(t.contextUsedPercent===void 0||Number.isInteger(t.contextUsedPercent)&&t.contextUsedPercent>=0&&t.contextUsedPercent<=100)};return i(n.sessionId)&&(!t||n.sessionId===t)&&o(n.root)&&Array.isArray(n.subagents)&&n.subagents.length<=64&&n.subagents.every(e=>o(e)&&i(e.id)&&(e.nickname===void 0||i(e.nickname))&&(e.role===void 0||i(e.role))&&(e.model===void 0||i(e.model))&&(e.canonicalTaskName===void 0||i(e.canonicalTaskName))&&(e.canonicalPosition===void 0||i(e.canonicalPosition,32))&&(e.continuationGeneration===void 0||Number.isInteger(e.continuationGeneration)&&e.continuationGeneration>0)&&(e.outcome===void 0||[`partial`,`cancelled`,`failed`].includes(e.outcome))&&(e.ownedProcesses===void 0||a(e.ownedProcesses)))&&i(n.aggregateSubagents,32)&&r.has(n.aggregateSubagents)&&(n.confidence===`fresh`||n.confidence===`stale`||n.confidence===`reconciling`)}var ro=class{#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=null;#l=!1;#u;constructor(e){this.#u={...e,websocket:e.websocket??(e=>new WebSocket(e)),location:e.location??location,setTimeout:e.setTimeout??setTimeout,clearTimeout:e.clearTimeout??clearTimeout}}get(e){return e?this.#e.get(e)??null:null}bootstrap(e,t){for(let t of e)!this.#e.has(t.id)&&no(t.agentActivity,t.id)&&this.#p(t.id,this.#t.get(t.id)??0,t.agentActivity);this.sync(e.map(e=>e.id),t)}sync(e,t){if(!this.#l){this.#c=t,this.#n=new Set(e);for(let e of this.#n)this.#i.has(e)||this.#i.set(e,0);for(let e of[...this.#i.keys()])this.#n.has(e)||this.remove(e);for(let[e,n]of this.#r)(e===t||!this.#n.has(e))&&(n.close(),this.#r.delete(e));for(let e of this.#n)this.hydrate(e),e!==t&&!this.#r.has(e)&&this.#f(e)}}select(e){this.sync([...this.#n],e)}remove(e){this.#n.delete(e),this.#i.set(e,(this.#i.get(e)??0)+1),this.#r.get(e)?.close(),this.#r.delete(e);let t=this.#a.get(e);t&&this.#u.clearTimeout(t),this.#a.delete(e),this.#o.delete(e),this.#s.delete(e),this.#e.delete(e),this.#t.delete(e),this.#u.publish(this.#e)}observe(e,t){if(this.#l||!this.#n.has(e)||!Number.isInteger(t.sequence))return;let n=this.#t.get(e)??0;t.sequence<=n||(t.sequence>n+1&&(this.#t.set(e,t.sequence-1),this.resync(e)),this.#t.set(e,t.sequence),this.#u.onEvent?.(e,t),t.type===`agent.activity.updated`&&no(t.payload,e)&&this.#p(e,t.sequence,t.payload))}async hydrate(e){let t=this.#i.get(e)??0,n=this.#t.get(e)??0;try{let r=await this.#u.relay.getSession(e);if(!this.#d(e,t))return;let i=this.#t.get(e)??0,a=r.currentSequence;if(Number.isInteger(a)){if(a<i)return;this.#t.set(e,a),no(r.agentActivity,e)&&this.#p(e,a,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r)}else i===n&&no(r.agentActivity,e)&&(this.#p(e,i,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r))}catch{this.#m(e)}}async resync(e){let t=this.#o.get(e);if(t)return t;let n=this.#i.get(e)??0;this.#m(e);let r;return r=(async()=>{try{await this.#u.relay.refreshActivity(e),this.#d(e,n)&&await this.hydrate(e)}catch{}finally{this.#o.get(e)===r&&this.#o.delete(e)}})(),this.#o.set(e,r),r}dispose(){this.#l=!0;for(let e of[...this.#n])this.remove(e)}#d(e,t){return!this.#l&&this.#n.has(e)&&this.#i.get(e)===t}#f(e){let t=this.#i.get(e)??0,n=this.#u.location.protocol===`https:`?`wss:`:`ws:`,r=this.#u.websocket(`${n}//${this.#u.location.host}/api/sessions/${encodeURIComponent(e)}/events?after=${this.#t.get(e)??0}`);this.#r.set(e,r),r.onmessage=n=>{if(!(!this.#d(e,t)||this.#r.get(e)!==r))try{this.#s.delete(e);let t=JSON.parse(String(n.data));t.type===`relay.resyncRequired`?this.resync(e):t.type===`relay.event`&&t.event&&this.observe(e,t.event)}catch{}},r.onclose=()=>{if(!this.#d(e,t)||this.#c===e)return;this.#r.delete(e),this.#m(e);let n=this.#s.get(e)??0,r=(this.#u.reconnectDelaysMs??[250,1e3,5e3])[n];r!==void 0&&(this.#s.set(e,n+1),this.#a.set(e,this.#u.setTimeout(()=>{this.#a.delete(e),this.#d(e,t)&&e!==this.#c&&this.#f(e)},r)))}}#p(e,t,n){let r=this.#e.get(e);this.#t.set(e,Math.max(t,this.#t.get(e)??0)),JSON.stringify(r)!==JSON.stringify(n)&&(this.#e.set(e,n),this.#u.publish(this.#e))}#m(e){let t=this.#e.get(e);t&&t.confidence===`fresh`&&(this.#e.set(e,{...t,confidence:`stale`}),this.#u.publish(this.#e))}};function io(e=globalThis.crypto,t=Date.now,n=Math.random){return typeof e?.randomUUID==`function`?e.randomUUID():`k-${t().toString(36)}-${Math.floor(n()*4294967296).toString(36)}`}function ao(e){if(typeof e!=`string`||!e.trim())return;let t=e.trim();return t.length<=4e3?t:`${t.slice(0,3999)}…`}var oo=`Checkpoint handoff failed. Autopilot is reconnecting this session automatically. If it cannot recover, restore or reopen the session.`,so=(e,t=600)=>typeof e==`string`&&e.length<=t,co=e=>so(e,64)&&!Number.isNaN(Date.parse(e));function lo(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.enabled==`boolean`&&typeof t.state==`string`&&[`disabled`,`monitoring`,`backoff`,`attentionRequired`,`completed`,`safetyPaused`].includes(t.state)&&!!t.retry&&typeof t.retry==`object`&&Number.isInteger(t.retry.position)&&Number.isInteger(t.retry.limit)&&so(t.updatedAt,64)&&(t.reason===void 0||so(t.reason,80))&&(t.nextEvaluationAt===void 0||so(t.nextEvaluationAt,64))&&(t.health===void 0||uo(t.health))}function uo(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!t.wait||typeof t.wait!=`object`)return!1;let n=t.wait;return typeof t.healthy==`boolean`&&typeof t.phase==`string`&&[`off`,`rootWorking`,`continuationScheduled`,`waitingForAgentEvent`,`checkingState`,`needsYou`,`safetyPaused`,`complete`,`checkpointRecovery`,`degraded`].includes(t.phase)&&[`active`,`probeRequired`,`parked`,`retrying`,`attentionRequired`,`safetyPaused`,`none`].includes(t.supervision)&&typeof n.present==`boolean`&&Array.isArray(n.wakeCategories)&&n.wakeCategories.length<=9&&new Set(n.wakeCategories).size===n.wakeCategories.length&&n.wakeCategories.every(e=>[`planChanged`,`reviewChanged`,`checkpointChanged`,`interactionChanged`,`executorChanged`,`processExited`,`processResultAvailable`,`processLimitBreached`,`agentActivityChanged`].includes(e))&&(n.resumeAt===void 0||co(n.resumeAt))&&co(t.observedAt)&&co(t.lastTransitionAt)&&so(t.nextExpectedAction)&&(t.degradationReason===void 0||[`missingContinuation`,`invalidWaitLease`,`controllerUnavailable`,`staleTransition`,`planMismatch`].includes(t.degradationReason))}function fo(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.attention;if(!n||typeof n!=`object`)return!1;let r=n;return so(t.requestId,256)&&(t.turnId===null||so(t.turnId,256))&&(t.requestedAt===null||so(t.requestedAt,64))&&(t.supervisorReport===void 0||so(t.supervisorReport,4e3))&&so(r.reason,64)&&so(r.summary)&&so(r.requestedAction)&&so(r.resumeCondition,64)&&(r.executorReplacement===void 0||po(r.executorReplacement))}function po(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return Object.keys(t).length===1&&typeof t.canonicalTaskName==`string`&&/^l[1-9][0-9]*$/.test(t.canonicalTaskName)}function mo(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`orgPlanAttention`&&fo({requestId:t.requestId,turnId:t.turnId??null,requestedAt:t.requestedAt??null,attention:t.payload,supervisorReport:t.supervisorReport})}function ho(e){return{requestId:e.requestId,turnId:e.turnId,requestedAt:e.requestedAt,attention:e.payload,...e.supervisorReport?{supervisorReport:e.supervisorReport}:{}}}var go=e=>{let t=e&&typeof e==`object`?e.code:void 0;return t===`AUTOPILOT_PLAN_REQUIRED`?`An incomplete supervised plan is required before Autopilot can start.`:t===`AUTOPILOT_PLAN_COMPLETE`?`This plan is complete, so Autopilot is unavailable.`:t===`AUTOPILOT_SESSION_UNAVAILABLE`?`This session is unavailable for Autopilot.`:e instanceof Error?e.message:`Could not update Autopilot.`},_o=class{relay;publish;createKey;#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=new Map;#d=new Map;#f=new Set;#p=!1;constructor(e,t,n=io){this.relay=e,this.publish=t,this.createKey=n}bootstrap(e){if(this.#p)return;let t=new Set(e.map(e=>e.id));for(let e of this.#f)t.has(e)||this.remove(e);this.#f=t;for(let t of e){this.#a.has(t.id)||this.#a.set(t.id,0),this.#o.has(t.id)||this.#o.set(t.id,0);let e=this.#d.get(t.id)??0,n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#l.get(t.id);!this.#n.has(t.id)&&(r===void 0||n!==null&&n>r)&&(n!==null&&n>e||!this.#e.has(t.id)&&e===0)&&(n!==null&&(this.#d.set(t.id,n),r!==void 0&&n>r&&this.#l.delete(t.id)),this.#_(t.id,t))}this.#v()}observe(e,t){if(this.#p||!this.#f.has(e)||!Number.isInteger(t.sequence))return;let n=this.#d.get(e)??0;if(!(t.sequence<=n)){if(this.#d.set(e,t.sequence),this.#o.set(e,(this.#o.get(e)??0)+1),t.type===`autopilot.updated`&&this.#h(e,t.payload),t.type===`org-plan.attention-required`&&this.#g(e,t.payload),t.type===`agentMessageCompleted`&&t.payload&&typeof t.payload==`object`){let n=t.payload,r=this.#t.get(e),i=ao(n.text);r?.turnId&&r.turnId===n.turnId&&n.phase===`final_answer`&&i&&this.#t.set(e,{...r,supervisorReport:i})}t.type===`org-plan.attention-resolved`&&(t.payload&&typeof t.payload==`object`&&t.payload.outcome,this.#t.delete(e)),this.#v()}}async hydrate(e,t){let n=this.#a.get(e)??0,r=(this.#u.get(e)??0)+1;this.#u.set(e,r);let i=t??this.#d.get(e)??0,a=this.#s.get(e),o=this.#c.get(e)??0;try{let t=await this.relay.getSession(e);if(!this.#m(e,n)||this.#u.get(e)!==r||(this.#c.get(e)??0)!==o||this.#s.has(e)&&this.#s.get(e)!==a)return;let s=this.#d.get(e)??0,c=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null;c!==null&&c>s?(this.#d.set(e,c),this.#_(e,t)):c===null&&s===i&&this.#_(e,t),this.#v()}catch{}}async toggle(e,t){if(this.#p||!this.#f.has(e)||this.#n.has(e))return;let n=this.#a.get(e)??0,r=this.#o.get(e)??0;this.#s.set(e,(this.#s.get(e)??0)+1),this.#c.set(e,(this.#c.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#i.delete(e),this.#v();try{let i=await this.relay.setAutopilot(e,t,this.createKey());this.#m(e,n)&&this.#o.get(e)===r&&(this.#h(e,i.autopilot),this.#o.set(e,r+1),this.#l.set(e,this.#d.get(e)??0),lo(i.autopilot)&&!i.autopilot.enabled&&this.#t.delete(e))}catch(t){this.#m(e,n)&&this.#o.get(e)===r&&this.#r.set(e,go(t))}finally{this.#m(e,n)&&(this.#n.delete(e),this.#c.set(e,(this.#c.get(e)??0)+1)),this.#v()}}async resolve(e,t,n){let r=this.#t.get(e);if(!r||this.#n.has(e)||this.#p)return;let i=n?.trim();if(i&&i.length>600){this.#r.set(e,`Guidance must be 600 characters or fewer.`),this.#v();return}let a=this.#a.get(e)??0,o=this.#o.get(e)??0;this.#c.set(e,(this.#c.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#v();try{await this.relay.resolveAttention(e,r.requestId,{operationKey:this.createKey(),action:t,...i?{guidance:i}:{}}),this.#m(e,a)&&this.#o.get(e)===o&&await this.hydrate(e)}catch(t){this.#m(e,a)&&this.#o.get(e)===o&&this.#r.set(e,t instanceof Error?t.message:`Could not resolve attention.`)}finally{this.#m(e,a)&&(this.#n.delete(e),this.#c.set(e,(this.#c.get(e)??0)+1)),this.#v()}}remove(e){this.#a.set(e,(this.#a.get(e)??0)+1),this.#f.delete(e),this.#e.delete(e),this.#t.delete(e),this.#n.delete(e),this.#r.delete(e),this.#d.delete(e),this.#o.delete(e),this.#s.delete(e),this.#c.delete(e),this.#l.delete(e),this.#u.delete(e),this.#v()}dispose(){this.#p=!0,this.#f.clear(),this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#i.clear(),this.#u.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear(),this.#l.clear(),this.#v()}#m(e,t){return!this.#p&&this.#f.has(e)&&this.#a.get(e)===t}#h(e,t){lo(t)&&(this.#e.set(e,t),t.health?.phase===`checkpointRecovery`?this.#i.set(e,oo):this.#i.delete(e))}#g(e,t){if(fo(t))this.#t.set(e,t);else if(mo(t))this.#t.set(e,ho(t));else if(Array.isArray(t)){let n=t.find(mo);n?this.#t.set(e,ho(n)):this.#t.delete(e)}}applyAuthoritative(e,t){if(this.#p||!this.#f.has(e)||this.#n.has(e))return;let n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#d.get(e)??0,i=this.#l.get(e);i!==void 0&&(n===null||n<=i)||n!==null&&n<r||(n!==null&&(this.#d.set(e,n),i!==void 0&&n>i&&this.#l.delete(e)),this.#_(e,t),this.#v())}#_(e,t){this.#o.set(e,(this.#o.get(e)??0)+1),this.#h(e,t.autopilot),this.#g(e,t.pendingInteractions)}#v(){this.publish({snapshots:new Map(this.#e),attention:new Map(this.#t),pending:new Set(this.#n),errors:new Map([...this.#r,...this.#i])})}},vo=q(`<span aria-hidden="true" class="svelte-1qf1ppf"> </span> `,1),yo=q(`<div class="control-row svelte-1qf1ppf"><span class="status svelte-1qf1ppf"><span aria-hidden="true" class="svelte-1qf1ppf"> </span> </span> <!></div>`),bo=q(`<section aria-label="Autopilot"><p class="visually-hidden svelte-1qf1ppf" data-testid="autopilot-live-status" aria-live="polite" aria-atomic="true"> </p> <!> <p> </p></section>`);function xo(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-control`),r=$(t,`compact`,3,!1),i=$(t,`indicatorOnly`,3,!1),a=$(t,`pending`,3,!1),o=$(t,`ontoggle`,3,()=>{}),s={disabled:`Off`,monitoring:`Monitoring`,backoff:`Waiting to continue`,attentionRequired:`Paused for attention`,completed:`Complete`,safetyPaused:`Safety paused`},c={off:`Off`,rootWorking:`On · root working`,continuationScheduled:`On · continuation scheduled`,waitingForAgentEvent:`On · waiting for agent event`,checkingState:`On · checking state`,needsYou:`Paused · needs you`,safetyPaused:`Safety paused`,complete:`Complete`,checkpointRecovery:`Recovering checkpoint handoff`,degraded:`On · continuation unavailable`},l={planRequired:`An incomplete supervised plan is required before Autopilot can start.`,planComplete:`This plan is complete, so Autopilot is unavailable.`,sessionUnavailable:`This session is unavailable for Autopilot.`,attentionRequired:`Autopilot is paused because an agent is waiting for human input.`,noPlanProgress:`Autopilot paused because the plan did not make durable progress.`,reconcileFailed:`Autopilot paused because it could not safely confirm session state.`,startUnavailable:`Automatic continuation could not start because the session runtime is unavailable. Restore or reopen the session, then retry Autopilot.`,actionRateExceeded:`Autopilot paused after too many automatic actions in ten minutes. Wait for the safety window to clear, or continue manually.`,planRemoved:`The retained plan was removed.`,planReplaced:`The retained plan changed. Enable Autopilot again after reviewing it.`,sessionEnded:`This session ended.`,manualDisabled:`Autopilot is off.`,safetyPaused:`Autopilot paused after a repeated or invalid automatic continuation. Resume manually when ready.`,checkpointHandoffFailed:oo},u=L(()=>t.autopilot?t.autopilot.health?c[t.autopilot.health.phase]:s[t.autopilot.state]:`Unavailable`),d=L(()=>t.autopilot?.state===`backoff`&&t.autopilot.retry.position>0&&t.autopilot.retry.limit>0?`Retry ${t.autopilot.retry.position} of ${t.autopilot.retry.limit}.`:null),f=L(()=>(t.autopilot?.reason?l[t.autopilot.reason]:null)??G(d)??t.autopilot?.health?.nextExpectedAction??(t.autopilot?.state===`monitoring`?`Autopilot is monitoring this supervised plan.`:t.autopilot?.state===`attentionRequired`?`Autopilot is paused because human attention is required.`:`Autopilot state is loading from the relay.`)),p=L(()=>`Autopilot status: ${G(u)}. ${G(f)}`),m=L(()=>t.autopilot?.enabled??!1),h=L(()=>t.autopilot?.state===`safetyPaused`||t.autopilot?.health?.phase===`degraded`);var g=bo();let _;var v=V(g),y=V(v,!0);F(v);var b=U(v,2),x=e=>{{let t=L(()=>`${n()}-button`),r=L(()=>i()?`Autopilot: ${a()?`Updating`:G(u)}`:void 0),s=L(()=>`${n()}-help`);Va(e,{get id(){return G(t)},compact:!0,full:!0,get pressed(){return G(m)},get accentPressed(){return i()},get label(){return G(r)},get describedby(){return G(s)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{var n=Kr(),r=H(n),o=e=>{J(e,Gr(`Autopilot`))},s=e=>{var t=vo(),n=H(t),r=V(n,!0);F(n);var i=U(n);W(()=>{Y(r,G(m)?`●`:`○`),Y(i,` Autopilot: ${(a()?`Updating…`:G(u))??``}`)}),J(e,t)};X(r,e=>{i()?e(o):e(s,-1)}),J(e,n)},$$slots:{default:!0}})}},S=e=>{var r=yo(),i=V(r),s=V(i),c=V(s,!0);F(s);var l=U(s);F(i);var d=U(i,2);{let e=L(()=>`${n()}-button`),t=L(()=>`${n()}-help`);Va(d,{get id(){return G(e)},get pressed(){return G(m)},get describedby(){return G(t)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{He();var n=Gr();W(()=>Y(n,a()?`Updating…`:G(m)?`Pause`:`Enable`)),J(e,n)},$$slots:{default:!0}})}F(r),W(()=>{Q(i,`data-state`,t.autopilot?.state??`unavailable`),Y(c,G(m)?`●`:`○`),Y(l,` Autopilot: ${G(u)??``}`)}),J(e,r)};X(b,e=>{r()?e(x):e(S,-1)});var C=U(b,2);let w;var T=V(C,!0);F(C),F(g),W(()=>{_=Si(g,1,`autopilot-control svelte-1qf1ppf`,null,_,{compact:r(),"has-error":i()&&G(h)}),Y(y,G(p)),Q(C,`id`,`${n()}-help`),w=Si(C,1,`svelte-1qf1ppf`,null,w,{"visually-hidden":r()}),Y(T,G(f))}),J(e,g),$e()}var So=q(`<div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Supervisor explanation</dt> <dd class="supervisor-report svelte-1hnxk0w"> </dd></div>`),Co=q(`<div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Supervisor explanation</dt> <dd class="svelte-1hnxk0w">The supervisor has not supplied an explanation yet. You can ask for details in the
|
|
8
|
+
guidance below.</dd></div>`),wo=q(`<section class="attention svelte-1hnxk0w" role="alert"><h3 class="svelte-1hnxk0w">Autopilot needs your attention</h3> <dl class="svelte-1hnxk0w"><div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Reason</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">What happened</dt> <dd class="svelte-1hnxk0w"> </dd></div> <!> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Requested action</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Resume when</dt> <dd class="svelte-1hnxk0w"> </dd></div></dl> <label>Optional guidance for the resumed work</label> <textarea maxlength="600" class="svelte-1hnxk0w"></textarea> <p class="guidance-help svelte-1hnxk0w"> </p> <div class="actions svelte-1hnxk0w"><button type="button" class="svelte-1hnxk0w"> </button> <button type="button" class="svelte-1hnxk0w">Disable Autopilot</button></div></section>`);function To(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-attention`),r=$(t,`pending`,3,!1),i=$(t,`onresolve`,3,()=>{}),a=z(``),o={planChange:`Plan change needs approval`,hardBlock:`Work is blocked`,missingDependency:`A required capability is missing`,permissionRequired:`Permission is needed`,externalState:`An external condition changed`,materialAmbiguity:`A decision is needed`},s={userGuidance:`You have provided the decision or guidance below.`,planRevision:`You have approved or revised the plan.`,dependencyInstalled:`The required capability is available.`,permissionGranted:`The required permission has been granted.`,externalStateChanged:`The blocker has been resolved, or you have provided a way forward below.`},c=L(()=>t.attention?.attention.summary.startsWith(`Supervised execution requires human attention (`)),l=L(()=>G(a).trim().length>600?`Guidance must be 600 characters or fewer.`:``);var u=Kr(),d=H(u),f=e=>{var u=wo(),d=V(u),f=U(d,2),p=V(f),m=U(V(p),2),h=V(m,!0);F(m),F(p);var g=U(p,2),_=U(V(g),2),v=V(_,!0);F(_),F(g);var y=U(g,2),b=e=>{var n=So(),r=U(V(n),2),i=V(r,!0);F(r),F(n),W(()=>Y(i,t.attention.supervisorReport)),J(e,n)},x=e=>{J(e,Co())};X(y,e=>{t.attention.supervisorReport?e(b):G(c)&&e(x,1)});var S=U(y,2),C=U(V(S),2),w=V(C,!0);F(C),F(S);var T=U(S,2),E=U(V(T),2),D=V(E,!0);F(E),F(T),F(f);var ee=U(f,2),O=U(ee,2);Sn(O);var te=U(O,2),ne=V(te,!0);F(te);var re=U(te,2),ie=V(re),k=V(ie,!0);F(ie);var ae=U(ie,2);F(re),F(u),W((e,i)=>{Q(u,`aria-labelledby`,`${n()}-title`),Q(d,`id`,`${n()}-title`),Y(h,o[t.attention.attention.reason]??`Supervised work needs attention`),Y(v,G(c)?`The supervisor has paused work and needs your help to continue.`:t.attention.attention.summary),Y(w,G(c)?`Resolve the blocker or describe a way forward below, then choose Resume. You can also disable Autopilot.`:t.attention.attention.requestedAction),Y(D,s[t.attention.attention.resumeCondition]??`You are ready for the supervisor to continue.`),Q(ee,`for`,`${n()}-guidance`),Q(O,`id`,`${n()}-guidance`),Q(O,`aria-describedby`,`${n()}-guidance-help`),Q(O,`aria-invalid`,e),Q(te,`id`,`${n()}-guidance-help`),Y(ne,G(l)||`Up to 600 characters. Do not include secrets.`),ie.disabled=i,Y(k,r()?`Updating…`:t.attention.attention.executorReplacement?`Authorize replacement`:`Resume`),ae.disabled=r()},[()=>!!G(l),()=>r()||!!G(l)]),zi(O,()=>G(a),e=>B(a,e)),K(`click`,ie,()=>G(a).trim()?i()(`resume`,G(a)):i()(`resume`)),K(`click`,ae,()=>i()(`disableAutopilot`)),J(e,u)};X(d,e=>{t.attention&&e(f)}),J(e,u),$e()}Rr([`click`]);var Eo=q(`<section class="safety-stop svelte-yp6bgs" role="alert"><h3 class="svelte-yp6bgs">Autopilot safety stop</h3> <p class="svelte-yp6bgs"> </p> <p class="svelte-yp6bgs"> </p> <div class="actions svelte-yp6bgs"><button type="button" class="svelte-yp6bgs"> </button> <button type="button" class="svelte-yp6bgs">Disable Autopilot</button></div></section>`);function Do(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-safety-stop`),r=$(t,`pending`,3,!1),i=$(t,`onrecover`,3,()=>{}),a=$(t,`ondisable`,3,()=>{}),o={attentionRequired:`The coordinator stopped because it needs a human safety decision, but no actionable agent request is available.`,noPlanProgress:`The coordinator stopped because recent automatic turns made no durable plan progress.`,reconcileFailed:`The coordinator stopped because it could not safely confirm the session state.`,startUnavailable:`The coordinator stopped because the session runtime was unavailable when it tried to start an automatic turn.`,actionRateExceeded:`The coordinator stopped because it reached the automatic-action safety limit.`},s=L(()=>t.autopilot?.reason&&!t.attention?o[t.autopilot.reason]??null:null),c=L(()=>t.autopilot?.reason===`startUnavailable`?`There is no pending agent attention request to answer. Restore or reopen this session, then retry Autopilot.`:t.autopilot?.reason===`actionRateExceeded`?`There is no pending agent attention request to answer. Wait for the ten-minute safety window to clear, or continue manually.`:`There is no pending agent attention request to answer. Retry the supported Autopilot coordinator after addressing the cause, or disable it.`);var l=Kr(),u=H(l),d=e=>{var t=Eo(),o=V(t),l=U(o,2),u=V(l,!0);F(l);var d=U(l,2),f=V(d,!0);F(d);var p=U(d,2),m=V(p),h=V(m,!0);F(m);var g=U(m,2);F(p),F(t),W(()=>{Q(t,`aria-labelledby`,`${n()}-title`),Q(o,`id`,`${n()}-title`),Y(u,G(s)),Y(f,G(c)),m.disabled=r(),Y(h,r()?`Updating…`:`Retry Autopilot`),g.disabled=r()}),K(`click`,m,function(...e){i()?.apply(this,e)}),K(`click`,g,function(...e){a()?.apply(this,e)}),J(e,t)};X(u,e=>{t.autopilot?.state===`attentionRequired`&&G(s)&&e(d)}),J(e,l),$e()}Rr([`click`]);function Oo(e,t=`gestalt-mobile.autopilot-attention-toasts.v1`,n=100){let r=ko(e,t,n);return{claim(i){if(r.has(i))return!1;r=new Set([...r,i].slice(-n));try{e?.setItem(t,JSON.stringify([...r]))}catch{}return!0}}}function ko(e,t,n){try{let r=JSON.parse(e?.getItem(t)??`[]`);return new Set(Array.isArray(r)?r.filter(e=>typeof e==`string`).slice(-n):[])}catch{return new Set}}var Ao=[{name:`model`,description:`Choose the model for the next turn`,argumentPicker:`models`},{name:`reasoning`,description:`Choose reasoning effort for the next turn`,argumentPicker:`reasoning`}];function jo(e){let t=e.match(/^\/([^\s]*)$/);return t?t[1].toLowerCase():null}function Mo(e){let t=jo(e);return t===null?[]:Ao.filter(e=>e.name.startsWith(t))}function No(e){let t=e.match(/^\/([^\s]+)\s*$/)?.[1]?.toLowerCase();return Ao.find(e=>e.name===t)?.argumentPicker}function Po(e){return[...e].sort((e,t)=>Fo(t,e)||t.localeCompare(e))}function Fo(e,t){let n=e.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[],r=t.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[];for(let e=0;e<Math.max(n.length,r.length);e+=1){let t=(n[e]??0)-(r[e]??0);if(t)return t}return 0}var Io=q(`Ready <span class="block-cursor svelte-1264sfg" aria-hidden="true"></span>`,1),Lo=q(`<p id="writer-hint" class="writer-hint svelte-1264sfg"> </p>`),Ro=q(`<button type="button" class="svelte-1264sfg">Retry send</button>`),zo=q(`<div class="writer-feedback svelte-1264sfg" role="alert" aria-atomic="true"><p class="svelte-1264sfg"> </p> <!></div>`),Bo=q(`<li><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code> <small class="svelte-1264sfg"> </small></button></li>`),Vo=q(`<ul id="chat-command-completion" class="command-menu svelte-1264sfg" aria-label="Chat commands"></ul>`),Ho=q(`<li class="svelte-1264sfg"><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code></button></li>`),Uo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Available models"></ul>`),Wo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Reasoning efforts"></ul>`),Go=q(`<div id="prompt-action-panel" class="action-panel svelte-1264sfg" aria-label="Prompt actions"><button type="button" class="svelte-1264sfg">Queue message</button> <button type="button" class="svelte-1264sfg">Interrupt and send</button></div>`),Ko=q(`<div class="prompt-action svelte-1264sfg"><button type="button" aria-label="Choose prompt action" aria-controls="prompt-action-panel" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><circle cx="6" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="12" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="18" cy="12" r="1.5" class="svelte-1264sfg"></circle></svg></button> <!></div>`),qo=q(`<button type="button" aria-label="Interrupt" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="m7 7 10 10M17 7 7 17" class="svelte-1264sfg"></path></svg></button>`),Jo=q(`<button type="button" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="M9 10 5 14l4 4M5 14h8a6 6 0 0 0 6-6V6" class="svelte-1264sfg"></path></svg></button>`),Yo=q(`<form class="svelte-1264sfg"><p role="status" aria-live="polite" aria-atomic="true" class="svelte-1264sfg"><!></p> <!> <!> <!> <!> <!> <div class="prompt-row svelte-1264sfg"><textarea id="message" aria-label="Prompt" placeholder="Prompt" rows="1" required="" class="svelte-1264sfg"></textarea> <!></div></form>`);function Xo(e,t){Qe(t,!0);let n=$(t,`detached`,3,!1),r=$(t,`retryMessage`,3,null),i=$(t,`retryable`,3,!1),a=$(t,`models`,19,()=>[]),o=$(t,`provider`,3,`codex`),s=$(t,`onscrollbottom`,3,()=>{}),c=$(t,`onmodelselect`,3,()=>{}),l=$(t,`onqueue`,3,()=>{}),u=$(t,`oninterruptsend`,3,()=>{}),d=$(t,`onretry`,3,()=>{}),f=z(0),p=z(null),m=z(!1),h=L(()=>Mo(t.message)),g=L(()=>jo(t.message)),_=L(()=>G(g)!==null&&G(g)!==G(p)&&G(h).length>0),v=L(()=>No(t.message)),y=L(()=>G(v)===`models`),b=L(()=>Po(a())),x=L(()=>G(v)===`reasoning`),S=L(()=>!t.activeTurnId&&!t.starting&&!!t.message.trim()),C=L(()=>!!t.message.trim()),w=L(()=>i()&&!r());function T(e){B(m,!1),e===`queue`?l()():u()()}function E(e,n=!1){B(p,null),B(f,0),t.onchange(e),n&&s()()}function D(e=G(f)){let t=G(h)[e];t&&E(`/${t.name} `,!0)}function ee(e){if(e.key===`Enter`&&e.ctrlKey&&!e.isComposing){if(t.activeTurnId&&!t.starting&&G(C)){e.preventDefault(),T(`queue`);return}if(G(S)){e.preventDefault(),t.onsend();return}}if(G(_)){if(e.key===`ArrowDown`){e.preventDefault(),B(f,(G(f)+1)%G(h).length);return}if(e.key===`ArrowUp`){e.preventDefault(),B(f,(G(f)-1+G(h).length)%G(h).length);return}if(e.key===`Escape`){e.preventDefault(),B(p,G(g),!0);return}if(e.key===`Tab`){e.preventDefault(),D();return}}}var O=Yo(),te=V(O),ne=V(te),re=e=>{var t=Io();He(),J(e,t)},ie=e=>{var n=Gr();W(()=>Y(n,t.status)),J(e,n)};X(ne,e=>{t.status===`Ready.`?e(re):e(ie,-1)}),F(te);var k=U(te,2),ae=e=>{var t=Lo(),n=V(t);F(t),W(()=>Y(n,`You can read this conversation. Sending will connect to ${o()===`kimi`?`Kimi`:`Codex`}.`)),J(e,t)};X(k,e=>{n()&&e(ae)});var oe=U(k,2),se=e=>{var n=zo(),a=V(n),o=V(a,!0);F(a);var s=U(a,2),c=e=>{var n=Ro();W(()=>n.disabled=t.starting),K(`click`,n,function(...e){d()?.apply(this,e)}),J(e,n)};X(s,e=>{i()&&e(c)}),F(n),W(()=>Y(o,r())),J(e,n)};X(oe,e=>{r()&&e(se)});var ce=U(oe,2),le=e=>{var t=Vo();Z(t,23,()=>G(h),e=>e.name,(e,t,n)=>{var r=Bo(),i=V(r),a=V(i),o=V(a);F(a);var s=U(a,2),c=V(s,!0);F(s),F(i),F(r),W(()=>{Si(r,1,gi(G(n)===G(f)?`command-selected`:void 0),`svelte-1264sfg`),Y(o,`/${G(t).name??``}`),Y(c,G(t).description)}),K(`click`,i,()=>D(G(n))),J(e,r)}),F(t),J(e,t)};X(ce,e=>{G(_)&&e(le)});var A=U(ce,2),ue=e=>{var t=Uo();Z(t,20,()=>G(b),e=>e,(e,t)=>{var n=Ho(),r=V(n),i=V(r),a=V(i,!0);F(i),F(r),F(n),W(()=>Y(a,t)),K(`click`,r,()=>{c()(t),s()()}),J(e,n)}),F(t),J(e,t)};X(A,e=>{G(y)&&e(ue)});var de=U(A,2),fe=e=>{var t=Wo();Z(t,20,()=>[`low`,`medium`,`high`],e=>e,(e,t)=>{var n=Ho(),r=V(n),i=V(r),a=V(i,!0);F(i),F(r),F(n),W(()=>Y(a,t)),K(`click`,r,()=>E(`/reasoning ${t} `,!0)),J(e,n)}),F(t),J(e,t)};X(de,e=>{G(x)&&e(fe)});var j=U(de,2),M=V(j);Sn(M);var pe=U(M,2),me=e=>{var t=Ko(),n=V(t),r=U(n,2),i=e=>{var t=Go(),n=V(t),r=U(n,2);F(t),K(`click`,n,()=>T(`queue`)),K(`click`,r,()=>T(`interrupt-send`)),J(e,t)};X(r,e=>{G(m)&&e(i)}),F(t),W(()=>Q(n,`aria-expanded`,G(m))),K(`click`,n,()=>B(m,!G(m))),J(e,t)},he=e=>{var n=qo();W(()=>n.disabled=t.starting),K(`click`,n,function(...e){t.oninterrupt?.apply(this,e)}),J(e,n)},ge=e=>{var n=Jo();W(()=>{Q(n,`aria-label`,G(w)?`Retry send`:`Send prompt`),n.disabled=!G(S)}),K(`click`,n,function(...e){(G(w)?d():t.onsend)?.apply(this,e)}),J(e,n)};X(pe,e=>{t.activeTurnId&&G(C)?e(me):t.activeTurnId?e(he,1):e(ge,-1)}),F(j),F(O),W(()=>{Q(O,`aria-busy`,t.starting),Q(te,`aria-label`,t.status),Pi(M,t.message),Q(M,`aria-describedby`,n()?`writer-hint`:void 0)}),K(`input`,M,e=>E(e.currentTarget.value)),K(`keydown`,M,ee),J(e,O),$e()}Rr([`click`,`input`,`keydown`]);function Zo(e){let t=new Map;for(let n of e){if(!n.label.toLowerCase().replaceAll(` `,``).startsWith(`filechange`))continue;let e=n.changes?.length?n.changes:n.detail.split(`
|
|
9
|
+
`).filter(Boolean).map(e=>({path:e,additions:null,deletions:null}));for(let r of e){let e=t.get(r.path),i=typeof r.additions==`number`&&typeof r.deletions==`number`;t.set(r.path,{path:r.path,additions:i&&e?.additions!==null?(e?.additions??0)+r.additions:null,deletions:i&&e?.deletions!==null?(e?.deletions??0)+r.deletions:null,...n.occurredAt===void 0?e?.touchedAt===void 0?{}:{touchedAt:e.touchedAt}:{touchedAt:Math.max(e?.touchedAt??0,n.occurredAt)}})}}return[...t.values()]}function Qo(e){return{files:e.length,additions:e.every(e=>e.additions!==null)?e.reduce((e,t)=>e+t.additions,0):null,deletions:e.every(e=>e.deletions!==null)?e.reduce((e,t)=>e+t.deletions,0):null}}function $o(e,t){if(e===void 0||t===void 0||!Number.isFinite(e)||!Number.isFinite(t))return null;let n=Math.floor(Math.max(0,t-e)/6e4);if(n<1)return`moments later`;if(n<60)return`${n} minute${n===1?``:`s`} later`;let r=Math.floor(n/60);if(r<24)return`${r} hour${r===1?``:`s`} later`;let i=Math.floor(r/24);return`${i} day${i===1?``:`s`} later`}function es(e){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`}).format(e)}function ts(e,t){let n=Math.floor(Math.max(0,t-e)/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}var ns=q(`<dl class="command-counts svelte-11ye6aj"><div class="svelte-11ye6aj"><dt class="svelte-11ye6aj">Successful commands</dt> <dd class="svelte-11ye6aj"> </dd></div> <div class="svelte-11ye6aj"><dt class="svelte-11ye6aj">Failed commands</dt> <dd class="svelte-11ye6aj"> </dd></div></dl>`),rs=q(`<li data-status="failed" class="svelte-11ye6aj"><code class="svelte-11ye6aj"> </code></li>`),is=q(`<section aria-label="Failed commands"><strong>Failed commands</strong> <ul class="activity-list svelte-11ye6aj"></ul></section>`),as=q(`<li class="svelte-11ye6aj"><small class="svelte-11ye6aj"> </small> <span class="svelte-11ye6aj"> </span></li>`),os=q(`<ul class="activity-list svelte-11ye6aj" aria-label="Work activity"></ul>`),ss=q(`<time class="svelte-11ye6aj"> </time>`),cs=q(`<span class="svelte-11ye6aj">time unknown</span>`),ls=q(`<li class="svelte-11ye6aj"><code class="svelte-11ye6aj"> </code> <span class="file-counts svelte-11ye6aj" aria-label="Line changes"><span class="svelte-11ye6aj"> </span><span class="svelte-11ye6aj"> </span></span> <!></li>`),us=q(`<section aria-label="Files changed"><strong>Files changed</strong> <ul class="file-list svelte-11ye6aj"></ul></section>`),ds=q(`<details class="work-details svelte-11ye6aj"><summary class="svelte-11ye6aj"> </summary> <div class="work-details-content svelte-11ye6aj"><!> <!> <!> <!></div></details>`);function fs(e,t){Qe(t,!0);let n=$(t,`now`,19,()=>Date.now()),r=L(()=>Oa(t.activities)),i=L(()=>t.activities.flatMap(e=>{let t=ka(e);return t?.kind===`Command`&&t.status===`failed`?[{id:e.id,command:t.content}]:[]})),a=L(()=>Zo(t.activities)),o=L(()=>Qo(G(a))),s=L(()=>t.activities.flatMap(e=>{let t=ka(e);return t&&t.kind!==`Command`&&t.kind!==`File change`?[{id:e.id,...t}]:[]})),c=L(()=>t.activities.length),l=L(()=>G(a).length?`${G(o).files} ${G(o).files===1?`file`:`files`} changed · +${G(o).additions??`?`} −${G(o).deletions??`?`}`:`Work details · ${G(c)} ${G(c)===1?`activity`:`activities`}`);var u=Kr(),d=H(u),f=e=>{var t=ds(),o=V(t),c=V(o,!0);F(o);var u=U(o,2),d=V(u),f=e=>{var t=ns(),n=V(t),i=U(V(n),2),a=V(i,!0);F(i),F(n);var o=U(n,2),s=U(V(o),2),c=V(s,!0);F(s),F(o),F(t),W(()=>{Y(a,G(r).successful),Y(c,G(r).failed)}),J(e,t)};X(d,e=>{(G(r).successful||G(r).failed)&&e(f)});var p=U(d,2),m=e=>{var t=is(),n=U(V(t),2);Z(n,21,()=>G(i),e=>e.id,(e,t)=>{var n=rs(),r=V(n),i=V(r,!0);F(r),F(n),W(()=>Y(i,G(t).command)),J(e,n)}),F(n),F(t),J(e,t)};X(p,e=>{G(i).length&&e(m)});var h=U(p,2),g=e=>{var t=os();Z(t,21,()=>G(s),e=>e.id,(e,t)=>{var n=as(),r=V(n),i=V(r);F(r);var a=U(r,2),o=V(a,!0);F(a),F(n),W(()=>{Q(n,`data-status`,G(t).status),Y(i,`${G(t).kind??``}${G(t).status?` · ${G(t).status}`:``}`),Y(o,G(t).content)}),J(e,n)}),F(t),J(e,t)};X(h,e=>{G(s).length&&e(g)});var _=U(h,2),v=e=>{var t=us(),r=U(V(t),2);Z(r,21,()=>G(a),e=>e.path,(e,t)=>{var r=ls(),i=V(r),a=V(i,!0);F(i);var o=U(i,2),s=V(o),c=V(s);F(s);var l=U(s),u=V(l);F(l),F(o);var d=U(o,2),f=e=>{var r=ss(),i=V(r,!0);F(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,t)},[()=>new Date(G(t).touchedAt).toISOString(),()=>ts(G(t).touchedAt,n())]),J(e,r)},p=e=>{J(e,cs())};X(d,e=>{G(t).touchedAt===void 0?e(p,-1):e(f)}),F(r),W(()=>{Y(a,G(t).path),Y(c,`+${G(t).additions??`?`??``}`),Y(u,`-${G(t).deletions??`?`??``}`)}),J(e,r)}),F(r),F(t),J(e,t)};X(_,e=>{G(a).length&&e(v)}),F(u),F(t),W(()=>Y(c,G(l))),J(e,t)};X(d,e=>{G(c)&&e(f)}),J(e,u),$e()}function ps(e){if(!e||typeof e!=`object`)return null;let t=e.command;return typeof t==`string`&&t.trim()?t:null}function ms(e){if(!hs(e))return null;let t=e.changes;if(!Array.isArray(t))return null;let n=t.map(e=>hs(e)&&typeof e.path==`string`&&e.path.trim()?e.path:null).filter(e=>e!==null);return n.length===t.length&&n.length>0?n:null}function hs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var gs=q(`<div class="choice svelte-77f3gb"><input type="radio" class="svelte-77f3gb"/> <label class="svelte-77f3gb"><strong> </strong><span class="svelte-77f3gb"> </span></label></div>`),_s=q(`<label class="custom svelte-77f3gb">Your custom answer <input required="" class="svelte-77f3gb"/></label>`),vs=q(`<div class="choice svelte-77f3gb"><input type="radio" class="svelte-77f3gb"/> <label class="svelte-77f3gb"><strong>Custom answer</strong><span class="svelte-77f3gb">Provide your own response.</span></label></div> <!>`,1),ys=q(`<fieldset class="svelte-77f3gb"><legend class="svelte-77f3gb"><strong> </strong><span class="svelte-77f3gb"> </span></legend> <div class="choices svelte-77f3gb"><!> <!></div></fieldset>`),bs=q(`<form class="quiz-form svelte-77f3gb"><fieldset class="questions svelte-77f3gb"></fieldset> <button type="submit">Send answers</button></form>`);function xs(e,t){Qe(t,!0);let n=$(t,`disabled`,3,!1),r=on({}),i=on({}),a=L(()=>t.quiz.questions.every(e=>!!t.answers[e.id]?.trim()));async function o(e){i[e]=!0,t.onanswer(e,t.answers[e]??``),await Tr(),r[e]?.focus()}var s=bs(),c=V(s);Z(c,21,()=>t.quiz.questions,e=>e.id,(e,n)=>{let a=L(()=>`${t.requestId}-${G(n).id}-custom`),s=L(()=>G(n).choices.some(e=>e.label===t.answers[G(n).id]));var c=ys(),l=V(c),u=V(l),d=V(u,!0);F(u);var f=U(u),p=V(f,!0);F(f),F(l);var m=U(l,2),h=V(m);Z(h,17,()=>G(n).choices,e=>`${G(n).id}-${e.label}`,(e,r)=>{let a=L(()=>`${t.requestId}-${G(n).id}-${G(r).label}`);var o=gs(),s=V(o);Ni(s);var c=U(s,2),l=V(c),u=V(l,!0);F(l);var d=U(l),f=V(d,!0);F(d),F(c),F(o),W(()=>{Q(s,`id`,G(a)),Q(s,`name`,`${t.requestId}-${G(n).id}`),Fi(s,t.answers[G(n).id]===G(r).label),Q(c,`for`,G(a)),Y(u,G(r).label),Y(f,G(r).description)}),K(`change`,s,()=>{i[G(n).id]=!1,t.onanswer(G(n).id,G(r).label)}),J(e,o)});var g=U(h,2),_=e=>{var c=vs(),l=H(c),u=V(l);Ni(u);var d=U(u,2);F(l);var f=U(l,2),p=e=>{var i=_s(),o=U(V(i));Ni(o),Ui(o,(e,t)=>r[t.id]=e,e=>r?.[e.id],()=>[G(n)]),F(i),W(()=>{Q(i,`for`,`${G(a)}-text`),Q(o,`id`,`${G(a)}-text`),Q(o,`type`,G(n).isSecret?`password`:`text`),Pi(o,t.answers[G(n).id])}),K(`input`,o,e=>t.onanswer(G(n).id,e.currentTarget.value)),J(e,i)},m=L(()=>i[G(n).id]||!!t.answers[G(n).id]&&!G(s));X(f,e=>{G(m)&&e(p)}),W(e=>{Q(u,`id`,G(a)),Q(u,`name`,`${t.requestId}-${G(n).id}`),Fi(u,e),Q(d,`for`,G(a))},[()=>i[G(n).id]||!!t.answers[G(n).id]&&!G(s)]),K(`change`,u,()=>o(G(n).id)),K(`click`,u,()=>{i[G(n).id]&&o(G(n).id)}),J(e,c)};X(g,e=>{G(n).allowCustom&&e(_)}),F(m),F(c),W(()=>{Y(d,G(n).header),Y(p,G(n).question)}),J(e,c)}),F(c);var l=U(c,2);F(s),W(()=>{c.disabled=n(),l.disabled=n()||!G(a)}),Lr(`submit`,s,e=>{e.preventDefault(),G(a)&&t.onsubmit()}),J(e,s),$e()}Rr([`change`,`click`,`input`]);function Ss(e,t=2){if(!ks(e)||!Array.isArray(e.questions)||e.questions.length<1||e.questions.length>8)return null;let n=e.questions.map(e=>Ts(e,t));if(n.some(e=>e===null))return null;let r=n;return new Set(r.map(e=>e.id)).size===r.length?{questions:r}:null}function Cs(e){return!ks(e)||!Array.isArray(e.questions)||e.questions.length>3?null:Ss({questions:e.questions.map(e=>ks(e)?{id:e.id,header:e.header,question:e.question,choices:e.options,allowCustom:e.isOther===!0,isSecret:e.isSecret===!0}:e)},1)}function ws(e){return{contentItems:[{type:`inputText`,text:JSON.stringify({answers:Object.fromEntries(e.filter(e=>e.answer.trim()).map(e=>[e.id,e.answer]))})}],success:!0}}function Ts(e,t){if(!ks(e)||!Array.isArray(e.choices)||e.choices.length<t||e.choices.length>5||!Ds(e.id)||!Os(e.header,120)||!Os(e.question,600)||typeof e.allowCustom!=`boolean`)return null;let n=e.choices.map(Es);return n.some(e=>e===null)?null:{id:e.id,header:e.header,question:e.question,choices:n,allowCustom:e.allowCustom,isSecret:e.isSecret===!0}}function Es(e){return!ks(e)||!Os(e.label,160)||!Os(e.description,600)?null:{label:e.label,description:e.description}}function Ds(e){return typeof e==`string`&&/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(e)}function Os(e,t){return typeof e==`string`&&e.trim().length>0&&e.length<=t}function ks(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var As=q(`<p class="interaction-result svelte-ajsqcq" data-interaction-state="resolved" tabindex="-1"> </p>`),js=q(`<p class="interaction-submitting svelte-ajsqcq" data-interaction-state="submitting">Submitting…</p>`),Ms=q(`<p>Codex sent an invalid quiz request.</p>`),Ns=q(`<p>Grant the requested permissions for this turn only.</p> <button type="button">Approve</button>`,1),Ps=q(`<pre class="command-approval-command svelte-ajsqcq"><code> </code></pre>`),Fs=q(`<p class="command-approval-missing svelte-ajsqcq">Command details were not provided.</p>`),Is=q(`<p>Approve this command?</p> <!> <div class="approval-actions svelte-ajsqcq"><button type="button">Approve</button> <button type="button">Deny</button></div>`,1),Ls=q(`<li><code> </code></li>`),Rs=q(`<ul class="file-change-approval-targets svelte-ajsqcq" aria-label="Files to change"></ul>`),zs=q(`<p class="file-change-approval-missing svelte-ajsqcq">File details were not provided.</p>`),Bs=q(`<p>Approve changes to these files?</p> <!> <div class="approval-actions svelte-ajsqcq"><button type="button">Approve</button> <button type="button">Deny</button></div>`,1),Vs=q(`<button type="button">Approve</button><button type="button">Deny</button>`,1),Hs=q(`<p class="interaction-failed svelte-ajsqcq" data-interaction-state="failed">Could not send. Try again.</p> <button type="button">Retry</button>`,1),Us=q(`<!> <!> <!>`,1),Ws=q(`<li class="svelte-ajsqcq"><span class="submitted-question svelte-ajsqcq"><strong> </strong> </span> <span class="submitted-answer svelte-ajsqcq"> </span></li>`),Gs=q(`<section class="submitted-answers svelte-ajsqcq" aria-label="Submitted answers" aria-live="polite"><p class="svelte-ajsqcq"><strong>Submitted answers</strong></p> <ol class="svelte-ajsqcq"></ol> <p class="submitted-note svelte-ajsqcq">Recorded in this chat view before delivery.</p></section>`),Ks=q(`<article><p class="interaction-kind svelte-ajsqcq"> </p> <!> <!></article>`);function qs(e,t){Qe(t,!0);let n=$(t,`submittedAnswers`,19,()=>({})),r=$(t,`onretry`,3,()=>{}),i=z(null),a=on({}),o=e=>Object.fromEntries(Object.entries(t.answers).filter(([t])=>t.startsWith(`${e}:`)).map(([t,n])=>[t.slice(e.length+1),n]));function s(e,t){B(i,e.requestId,!0),t()}Mn(()=>{let e=t.interactions.find(e=>e.requestId===G(i));e?.state===`resolved`&&(Tr().then(()=>a[e.requestId]?.focus()),B(i,null))});var c=Kr();Z(H(c),17,()=>t.interactions,e=>e.key??e.requestId,(e,i)=>{let c=L(()=>G(i).state===`submitting`);var l=Ks();let u;var d=V(l),f=V(d,!0);F(d);var p=U(d,2),m=e=>{var t=As(),n=V(t,!0);F(t),Ui(t,(e,t)=>a[t.requestId]=e,e=>a?.[e.requestId],()=>[G(i)]),W(()=>Y(n,G(i).attemptedOutcome===`denied`?`Denied`:G(i).attemptedOutcome===`dismissed`?`No longer awaiting a response`:G(i).attemptedOutcome===`answered`?`Answers sent`:`Approved`)),J(e,t)},h=e=>{var n=Us(),a=H(n),l=e=>{J(e,js())};X(a,e=>{G(c)&&e(l)});var u=U(a,2),d=e=>{let n=L(()=>G(i).kind===`quiz`?Ss(G(i).payload):Cs(G(i).payload));var r=Kr(),a=H(r),l=e=>{{let r=L(()=>o(G(i).requestId));xs(e,{get requestId(){return G(i).requestId},get quiz(){return G(n)},get answers(){return G(r)},get disabled(){return G(c)},onanswer:(e,n)=>t.onanswer(G(i).requestId,e,n),onsubmit:()=>s(G(i),()=>t.onquiz(G(i)))})}},u=e=>{J(e,Ms())};X(a,e=>{G(n)?e(l):e(u,-1)}),J(e,r)},f=e=>{var n=Ns(),r=U(H(n),2);W(()=>r.disabled=G(c)),K(`click`,r,()=>s(G(i),()=>t.onpermission(G(i)))),J(e,n)},p=e=>{let n=L(()=>ps(G(i).payload));var r=Is(),a=U(H(r),2),o=e=>{var t=Ps(),r=V(t),i=V(r,!0);F(r),F(t),W(()=>Y(i,G(n))),J(e,t)},l=e=>{J(e,Fs())};X(a,e=>{G(n)?e(o):e(l,-1)});var u=U(a,2),d=V(u),f=U(d,2);F(u),W(()=>{d.disabled=G(c),f.disabled=G(c)}),K(`click`,d,()=>s(G(i),()=>t.ondecision(G(i).requestId,`accept`))),K(`click`,f,()=>s(G(i),()=>t.ondecision(G(i).requestId,`decline`))),J(e,r)},m=e=>{let n=L(()=>ms(G(i).payload));var r=Bs(),a=U(H(r),2),o=e=>{var t=Rs();Z(t,20,()=>G(n),e=>e,(e,t)=>{var n=Ls(),r=V(n),i=V(r,!0);F(r),F(n),W(()=>Y(i,t)),J(e,n)}),F(t),J(e,t)},l=e=>{J(e,zs())};X(a,e=>{G(n)?e(o):e(l,-1)});var u=U(a,2),d=V(u),f=U(d,2);F(u),W(()=>{d.disabled=G(c),f.disabled=G(c)}),K(`click`,d,()=>s(G(i),()=>t.ondecision(G(i).requestId,`accept`))),K(`click`,f,()=>s(G(i),()=>t.ondecision(G(i).requestId,`decline`))),J(e,r)},h=e=>{var n=Vs(),r=H(n),a=U(r);W(()=>{r.disabled=G(c),a.disabled=G(c)}),K(`click`,r,()=>s(G(i),()=>t.ondecision(G(i).requestId,`accept`))),K(`click`,a,()=>s(G(i),()=>t.ondecision(G(i).requestId,`decline`))),J(e,n)};X(u,e=>{G(i).kind===`userInput`||G(i).kind===`quiz`?e(d):G(i).kind===`permissionsApproval`?e(f,1):G(i).kind===`commandApproval`?e(p,2):G(i).kind===`fileChangeApproval`?e(m,3):e(h,-1)});var g=U(u,2),_=e=>{var t=Hs();K(`click`,U(H(t),2),()=>r()(G(i))),J(e,t)};X(g,e=>{G(i).state===`failed`&&e(_)}),J(e,n)};X(p,e=>{G(i).state===`resolved`?e(m):e(h,-1)});var g=U(p,2),_=e=>{var t=Gs(),r=U(V(t),2);Z(r,21,()=>n()[G(i).requestId],e=>e.id,(e,t)=>{var n=Ws(),r=V(n),i=V(r),a=V(i,!0);F(i);var o=U(i);F(r);var s=U(r,2),c=V(s,!0);F(s),F(n),W(()=>{Y(a,G(t).header),Y(o,` — ${G(t).question??``}`),Y(c,G(t).answer)}),J(e,n)}),F(r),He(2),F(t),J(e,t)};X(g,e=>{n()[G(i).requestId]?.length&&e(_)}),F(l),W(()=>{u=Si(l,1,`svelte-ajsqcq`,null,u,{resolved:G(i).state===`resolved`}),Y(f,G(i).kind)}),J(e,l)}),J(e,c),$e()}Rr([`click`]);function Js(e){let t=[],n=[],r=()=>{n.length&&(t.push({id:n.at(-1).id,kind:`assistant`,commentary:n.map(e=>e.text).join(`
|
|
10
|
+
|
|
11
|
+
`),answer:null,...n.at(-1)?.turnId?{turnId:n.at(-1).turnId}:{},...n.at(-1)?.occurredAt===void 0?{}:{occurredAt:n.at(-1).occurredAt}}),n=[])};for(let i of e){if(i.role===`audit`){r(),t.push({id:i.id,kind:`audit`,text:i.text,...i.controlId?{controlId:i.controlId}:{},...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt},count:1,timestamps:i.occurredAt===void 0?[]:[i.occurredAt]});continue}if(i.role===`user`){r(),t.push({id:i.id,kind:`user`,text:i.text,...i.turnId?{turnId:i.turnId}:{},...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt}});continue}if(i.phase===`commentary`){n.push(i);continue}t.push({id:i.id,kind:`assistant`,commentary:n.length?n.map(e=>e.text).join(`
|
|
12
|
+
|
|
13
|
+
`):null,answer:i.text,...i.turnId?{turnId:i.turnId}:{},...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt}}),n=[]}return r(),t}function Ys(e){let t=[],n=/```[^\n]*\n([\s\S]*?)```/g,r=0;for(let i of e.matchAll(n)){let n=e.slice(r,i.index);n&&t.push(...Xs(n)),t.push({kind:`code`,text:i[1]??``}),r=(i.index??0)+i[0].length}let i=e.slice(r);return(i||!t.length)&&t.push(...Xs(i)),t}function Xs(e){let t=[],n=e.split(`
|
|
14
|
+
`),r=0,i=e=>{let i=n.slice(r,e).join(`
|
|
15
|
+
`);i&&t.push({kind:`text`,parts:ec(i)})};for(let e=0;e<n.length;e+=1){let a=Zs(n[e]??``);if(a){i(e),t.push({kind:`heading`,level:a.level,parts:ec(a.text)}),r=e+1;continue}if(e===n.length-1)continue;let o=Qs(n[e]??``),s=Qs(n[e+1]??``);if(!o||!s||o.length!==s.length||!s.every($s))continue;i(e),e+=2;let c=[];for(;e<n.length;){let t=Qs(n[e]??``);if(!t||t.length!==o.length)break;c.push(t),e+=1}t.push({kind:`table`,headers:o.map(ec),rows:c.map(e=>e.map(ec))}),r=e,--e}return i(n.length),t.length?t:[{kind:`text`,parts:ec(e)}]}function Zs(e){let t=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*#*[ \t]*$/.exec(e);return t?{level:t[1].length,text:t[2]??``}:null}function Qs(e){let t=e.trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(Boolean)?n:null}function $s(e){return/^:?-{3,}:?$/.test(e)}function ec(e){let t=[],n=/\[([^\]]+)\]\((https?:\/\/[^\s)]+|codex:\/\/[^\s)]+|\/[^\s)]+)\)|`([^`]+)`|\*\*([^*\n]+)\*\*/g,r=0;for(let i of e.matchAll(n)){let n=e.slice(r,i.index);n&&t.push({kind:`text`,text:n}),t.push(i[3]?{kind:`code`,text:i[3]}:i[4]?{kind:`strong`,parts:ec(i[4])}:{kind:`link`,text:i[1]??``,href:i[2]??``}),r=(i.index??0)+i[0].length}let i=e.slice(r);return i&&t.push({kind:`text`,text:i}),t}var tc=/^(.*\.org)(?::\d+(?::\d+)?)?(?:#L\d+(?:C\d+)?)?$/;function nc(e){try{return decodeURIComponent(e)}catch{return null}}function rc(e){if(!e.startsWith(`/`)||e.includes(`\0`))return null;let t=[];for(let n of e.split(`/`))if(!(!n||n===`.`)){if(n===`..`){if(t.length===0)return null;t.pop();continue}t.push(n)}return t}function ic(e,t){let n=nc(e),r=nc(t),i=n?tc.exec(n):null;if(!i||!r)return null;let a=rc(i[1]??``),o=rc(r);if(!a||!o||a.length<=o.length||o.some((e,t)=>a[t]!==e))return null;let s=a.slice(o.length).join(`/`);return s.endsWith(`.org`)&&s!==`.org`?s:null}function ac(e){let t=nc(e);if(!t)return!1;let n=tc.exec(t);return!!(n&&rc(n[1]??``))}async function oc(e,t=globalThis.navigator?.clipboard,n=cc){if(!t)return sc(e,n);try{return await t.writeText(e),!0}catch{return sc(e,n)}}function sc(e,t){try{return t(e)}catch{return!1}}function cc(e){if(typeof document>`u`||!document.body)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.cssText=`position:fixed;opacity:0`,document.body.append(t),t.select();let n=document.execCommand(`copy`);return t.remove(),n}var lc=q(`<a class="svelte-1im954t"> </a>`),uc=q(`<a target="_blank" rel="noreferrer" class="svelte-1im954t"> </a>`),dc=q(`<code class="svelte-1im954t"> </code>`),fc=q(`<strong class="svelte-1im954t"><!></strong>`),pc=q(`<time class="svelte-1im954t"> </time>`),mc=q(`<span class="touch-unknown svelte-1im954t">time unknown</span>`),hc=q(`<li class="svelte-1im954t"><code class="file-path svelte-1im954t"> </code> <span class="file-counts svelte-1im954t" aria-label="Line changes"><span class="additions svelte-1im954t"> </span> <span class="deletions svelte-1im954t"> </span></span> <!></li>`),gc=q(`<details class="file-changes svelte-1im954t"><summary class="svelte-1im954t"> <span class="additions svelte-1im954t"> </span> <span class="deletions svelte-1im954t"> </span></summary> <section aria-label="Files changed"><ul class="svelte-1im954t"></ul></section></details>`),_c=q(`<div class="code-block svelte-1im954t"><button class="code-copy svelte-1im954t" type="button" title="Copy code"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1im954t"><rect x="9" y="9" width="10" height="10" rx="2"></rect><path d="M15 9V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2"></path></svg></button> <pre class="svelte-1im954t"><code class="svelte-1im954t"> </code></pre></div>`),vc=q(`<th scope="col" class="svelte-1im954t"><!></th>`),yc=q(`<td class="svelte-1im954t"><!></td>`),bc=q(`<tr></tr>`),xc=q(`<div class="table-scroll svelte-1im954t"><table class="svelte-1im954t"><thead><tr></tr></thead><tbody></tbody></table></div>`),Sc=q(`<h1 class="svelte-1im954t"><!></h1>`),Cc=q(`<h2 class="svelte-1im954t"><!></h2>`),wc=q(`<h3 class="svelte-1im954t"><!></h3>`),Tc=q(`<h4 class="svelte-1im954t"><!></h4>`),Ec=q(`<h5 class="svelte-1im954t"><!></h5>`),Dc=q(`<h6 class="svelte-1im954t"><!></h6>`),Oc=q(`<div class="svelte-1im954t"><!></div>`),kc=q(`<li class="audit-incomplete svelte-1im954t" role="status">Earlier Autopilot audit entries are not shown; this timeline contains the retained recent
|
|
16
|
+
audit.</li>`),Ac=q(`<li class="svelte-1im954t"><time class="svelte-1im954t"> </time></li>`),jc=q(`<details><summary class="svelte-1im954t"> </summary> <ul></ul></details>`),Mc=q(`<aside class="autopilot-audit svelte-1im954t" aria-label="Autopilot audit entry"><strong>Autopilot</strong> <!> <!></aside>`),Nc=q(`<time class="svelte-1im954t"> <!></time>`),Pc=q(`<div class="entry-heading svelte-1im954t"><strong>working</strong></div> <!> <!>`,1),Fc=q(`<section><!></section>`),Ic=q(`<div class="entry-heading svelte-1im954t"><strong>prompt</strong> <!></div> <div class="entry-content svelte-1im954t"><!></div> <!> <!>`,1),Lc=q(`<div class="commentary-content live-commentary svelte-1im954t"><!></div>`),Rc=q(`<!> <!>`,1),zc=q(`<button class="commentary-toggle svelte-1im954t" type="button"><span aria-hidden="true"> </span> commentary</button>`),Bc=q(`<div class="answer-history svelte-1im954t"><!></div>`),Vc=q(`<div class="commentary-content svelte-1im954t"><!></div>`),Hc=q(`<section class="answer-turn svelte-1im954t"><div class="entry-heading svelte-1im954t"><strong> </strong> <!></div> <!> <!> <div class="entry-content svelte-1im954t"><!></div> <!></section>`),Uc=q(`<div class="entry-content svelte-1im954t"><!></div>`),Wc=q(`<details><summary>commentary</summary> <!></details> <!>`,1),Gc=q(`<section><div class="entry-heading svelte-1im954t"><strong> </strong> <!></div> <!> <!></section>`),Kc=q(`<li><!></li>`),qc=q(`<li class="interaction-only svelte-1im954t"><!></li>`),Jc=q(`<li class="progress-item svelte-1im954t"><section><!></section></li>`),Yc=q(`<ol aria-label="Chat messages" class="svelte-1im954t"><!> <!> <!> <!></ol>`);function Xc(e,t){Qe(t,!0);let n=(e,r=b)=>{var i=Kr();Z(H(i),17,r,ei,(e,r)=>{var i=Kr(),a=H(i),o=e=>{var n=Kr(),i=H(n),a=e=>{var t=lc(),n=V(t,!0);F(t),W(()=>{Q(t,`href`,G(r).href),Y(n,G(r).text)}),K(`click`,t,e=>se(e,G(r).href)),J(e,t)},o=L(()=>t.onopenorg&&ac(G(r).href)),s=e=>{var t=uc(),n=V(t,!0);F(t),W(()=>{Q(t,`href`,G(r).href),Y(n,G(r).text)}),J(e,t)};X(i,e=>{G(o)?e(a):e(s,-1)}),J(e,n)},s=e=>{var t=dc(),n=V(t,!0);F(t),W(()=>Y(n,G(r).text)),J(e,t)},c=e=>{var t=fc(),i=V(t);n(i,()=>G(r).parts),F(t),J(e,t)},l=e=>{var t=Gr();W(()=>Y(t,G(r).text)),J(e,t)};X(a,e=>{G(r).kind===`link`?e(o):G(r).kind===`code`?e(s,1):G(r).kind===`strong`?e(c,2):e(l,-1)}),J(e,i)}),J(e,i)},r=(e,t=b)=>{let n=L(()=>Zo(t())),r=L(()=>Qo(G(n)));var i=Kr(),a=H(i),o=e=>{var t=gc(),i=V(t),a=V(i),o=U(a),s=V(o);F(o);var c=U(o,2),l=V(c);F(c),F(i);var u=U(i,2),d=V(u);Z(d,21,()=>G(n),e=>e.path,(e,t)=>{var n=hc(),r=V(n),i=V(r,!0);F(r);var a=U(r,2),o=V(a),s=V(o);F(o);var c=U(o,2),l=V(c);F(c),F(a);var u=U(a,2),d=e=>{var n=pc(),r=V(n,!0);F(n),W((e,t)=>{Q(n,`datetime`,e),Y(r,t)},[()=>new Date(G(t).touchedAt).toISOString(),()=>ts(G(t).touchedAt,G(y))]),J(e,n)},f=e=>{J(e,mc())};X(u,e=>{G(t).touchedAt===void 0?e(f,-1):e(d)}),F(n),W(()=>{Y(i,G(t).path),Y(s,`+${G(t).additions??`?`??``}`),Y(l,`−${G(t).deletions??`?`??``}`)}),J(e,n)}),F(d),F(u),F(t),W(()=>{Y(a,`${G(r).files??``}
|
|
17
|
+
${G(r).files===1?`file`:`files`} changed · `),Y(s,`+${G(r).additions??`?`??``}`),Y(l,`−${G(r).deletions??`?`??``}`)}),J(e,t)};X(a,e=>{G(n).length&&e(o)}),J(e,i)},i=(e,t=b)=>{var r=Kr();Z(H(r),17,()=>Ys(t()),ei,(e,t)=>{var r=Kr(),i=H(r),a=e=>{var n=_c(),r=V(n),i=U(r,2),a=V(i),o=V(a,!0);F(a),F(i),F(n),W(e=>{Q(r,`aria-label`,e),Y(o,G(t).text)},[()=>ce(G(t).text)]),K(`click`,r,()=>void le(G(t).text)),J(e,n)},o=e=>{var r=xc(),i=V(r),a=V(i),o=V(a);Z(o,21,()=>G(t).headers,ei,(e,t)=>{var r=vc(),i=V(r);n(i,()=>G(t)),F(r),J(e,r)}),F(o),F(a);var s=U(a);Z(s,21,()=>G(t).rows,ei,(e,t)=>{var r=bc();Z(r,21,()=>G(t),ei,(e,t)=>{var r=yc(),i=V(r);n(i,()=>G(t)),F(r),J(e,r)}),F(r),J(e,r)}),F(s),F(i),F(r),J(e,r)},s=e=>{var r=Kr(),i=H(r),a=e=>{var r=Sc(),i=V(r);n(i,()=>G(t).parts),F(r),J(e,r)},o=e=>{var r=Cc(),i=V(r);n(i,()=>G(t).parts),F(r),J(e,r)},s=e=>{var r=wc(),i=V(r);n(i,()=>G(t).parts),F(r),J(e,r)},c=e=>{var r=Tc(),i=V(r);n(i,()=>G(t).parts),F(r),J(e,r)},l=e=>{var r=Ec(),i=V(r);n(i,()=>G(t).parts),F(r),J(e,r)},u=e=>{var r=Dc(),i=V(r);n(i,()=>G(t).parts),F(r),J(e,r)};X(i,e=>{G(t).level===1?e(a):G(t).level===2?e(o,1):G(t).level===3?e(s,2):G(t).level===4?e(c,3):G(t).level===5?e(l,4):e(u,-1)}),J(e,r)},c=e=>{var r=Oc(),i=V(r);n(i,()=>G(t).parts),F(r),J(e,r)};X(i,e=>{G(t).kind===`code`?e(a):G(t).kind===`table`?e(o,1):G(t).kind===`heading`?e(s,2):e(c,-1)}),J(e,r)}),J(e,r)},a=$(t,`activeTurnId`,3,null),o=$(t,`autopilotAuditTruncated`,3,!1),s=$(t,`interactions`,19,()=>[]),c=$(t,`answers`,19,()=>({})),l=$(t,`submittedAnswers`,19,()=>({})),u=$(t,`clipboard`,19,()=>globalThis.navigator?.clipboard),d=$(t,`onanswer`,3,()=>{}),f=$(t,`onquiz`,3,()=>{}),p=$(t,`onpermission`,3,()=>{}),m=$(t,`ondecision`,3,()=>{}),h=$(t,`onretry`,3,()=>{}),g=$(t,`oncopyresult`,3,()=>{}),_=L(()=>Js(t.messages)),v=on({}),y=z(on(Date.now()));Gi(()=>{let e=globalThis.setInterval(()=>B(y,Date.now(),!0),1e3);return()=>globalThis.clearInterval(e)});let x=L(()=>G(_).filter(e=>e.kind===`user`)),S=L(()=>G(_).filter(e=>e.kind===`assistant`)),C=L(()=>G(S).at(-1)?.id),w=L(()=>s().filter(e=>!e.turnId||!G(x).some(t=>t.turnId===e.turnId)));function T(e){let t=G(x).findLast(t=>t.turnId&&t.turnId===e.turnId);if(t)return t.id;let n=e.occurredAt;if(n!==void 0){let e=G(x).findLast(e=>e.occurredAt!==void 0&&e.occurredAt<=n);if(e)return e.id}return G(x).at(-1)?.id??null}function E(e){return e.kind===`user`?s().filter(t=>T(t)===e.id):[]}function D(e){if(e.turnId){let t=G(S).findLast(t=>t.turnId===e.turnId);if(t)return t.id}return e.occurredAt===void 0?G(C)??null:G(S).find(t=>t.answer!==null&&t.occurredAt!==void 0&&t.occurredAt>=e.occurredAt)?.id??null}function ee(e){return e.kind===`assistant`?t.activities.filter(t=>D(t)===e.id):[]}function O(e){if(D(e))return null;if(e.turnId){let t=G(x).findLast(t=>t.turnId===e.turnId);if(t)return t.id}return e.occurredAt===void 0?null:G(x).findLast(t=>t.occurredAt!==void 0&&t.occurredAt<=e.occurredAt)?.id??null}function te(e){return e.kind===`user`?t.activities.filter(t=>O(t)===e.id):[]}function ne(){return t.activities.filter(e=>!D(e)&&!O(e))}let re=L(ne);function ie(e){return e.filter(e=>!e.label.toLowerCase().replaceAll(` `,``).startsWith(`filechange`))}function k(e){return!!(e.kind===`assistant`&&a()&&(e.turnId===a()||!e.turnId&&e.id===G(C)))}function ae(e){return!!(e.kind===`user`&&a()&&(e.turnId===a()||!e.turnId))}function oe(e,t){return $o(G(_)[e-1]?.occurredAt,t)}function se(e,n){!t.onopenorg||!ac(n)||(e.preventDefault(),t.onopenorg(n))}function ce(e){return`Copy code block: ${(e.trim().split(`
|
|
18
|
+
`)[0]?.trim()||`empty block`).slice(0,48)}`}async function le(e){g()(await oc(e,u()))}var A=Yc(),ue=V(A),de=e=>{J(e,kc())};X(ue,e=>{o()&&e(de)});var fe=U(ue,2);Z(fe,19,()=>G(_),e=>e.id,(e,t,n)=>{var a=Kc(),o=V(a),s=e=>{var n=Mc(),r=U(V(n)),i=U(r),a=e=>{var n=pc(),r=V(n,!0);F(n),W((e,t)=>{Q(n,`datetime`,e),Y(r,t)},[()=>new Date(G(t).occurredAt).toISOString(),()=>es(G(t).occurredAt)]),J(e,n)};X(i,e=>{G(t).occurredAt&&e(a)});var o=U(i,2),s=e=>{var n=jc(),r=V(n),i=V(r);F(r);var a=U(r,2);Z(a,21,()=>G(t).timestamps,e=>`${G(t).id}:${e}`,(e,t)=>{var n=Ac(),r=V(n),i=V(r,!0);F(r),F(n),W((e,t)=>{Q(r,`datetime`,e),Y(i,t)},[()=>new Date(G(t)).toISOString(),()=>es(G(t))]),J(e,n)}),F(a),F(n),W(()=>Y(i,`Show ${G(t).count??``} timestamps`)),J(e,n)};X(o,e=>{G(t).count>1&&e(s)}),F(n),W(()=>Y(r,` ${G(t).text??``}${G(t).count>1?` · ${G(t).count} times`:``} `)),J(e,n)},u=e=>{let a=L(()=>te(G(t)));var o=Ic(),s=H(o),u=U(V(s),2),g=e=>{var r=Nc(),i=V(r),a=U(i),o=e=>{var r=Gr();W(e=>Y(r,`· ${e??``}`),[()=>oe(G(n),G(t).occurredAt)]),J(e,r)},s=L(()=>oe(G(n),G(t).occurredAt));X(a,e=>{G(s)&&e(o)}),F(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,`${t??``} `)},[()=>new Date(G(t).occurredAt).toISOString(),()=>es(G(t).occurredAt)]),J(e,r)};X(u,e=>{G(t).occurredAt&&e(g)}),F(s);var _=U(s,2),v=V(_);i(v,()=>G(t).text),F(_);var b=U(_,2);{let e=L(()=>E(G(t)));qs(b,{get interactions(){return G(e)},get answers(){return c()},get submittedAnswers(){return l()},get onanswer(){return d()},get onquiz(){return f()},get onpermission(){return p()},get ondecision(){return m()},get onretry(){return h()}})}var x=U(b,2),S=e=>{var n=Fc(),i=V(n),o=e=>{var t=Pc(),n=U(H(t),2);{let e=L(()=>ie(G(a)));Ra(n,{get activities(){return G(e)},variant:`live`})}var i=U(n,2);r(i,()=>G(a)),J(e,t)},s=L(()=>ae(G(t))),c=e=>{fs(e,{get activities(){return G(a)},get now(){return G(y)}})};X(i,e=>{G(s)?e(o):e(c,-1)}),F(n),W(e=>Si(n,1,e,`svelte-1im954t`),[()=>gi(ae(G(t))?`progress-turn`:`orphan-activity-turn`)]),J(e,n)};X(x,e=>{G(a).length&&e(S)}),J(e,o)},g=e=>{let r=L(()=>ee(G(t)));var a=Hc(),o=V(a),s=V(o),c=V(s,!0);F(s);var l=U(s,2),u=e=>{var r=Nc(),i=V(r),a=U(i),o=e=>{var r=Gr();W(e=>Y(r,`· ${e??``}`),[()=>oe(G(n),G(t).occurredAt)]),J(e,r)},s=L(()=>oe(G(n),G(t).occurredAt));X(a,e=>{G(s)&&e(o)}),F(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,`${t??``} `)},[()=>new Date(G(t).occurredAt).toISOString(),()=>es(G(t).occurredAt)]),J(e,r)};X(l,e=>{G(t).occurredAt&&e(u)}),F(o);var d=U(o,2),f=e=>{var n=Rc(),a=H(n),o=e=>{var n=Lc(),r=V(n);i(r,()=>G(t).commentary),F(n),J(e,n)};X(a,e=>{G(t).commentary&&e(o)});var s=U(a,2);{let e=L(()=>ie(G(r)));Ra(s,{get activities(){return G(e)},variant:`live`})}J(e,n)},p=L(()=>k(G(t))),m=e=>{var n=Bc(),r=V(n),i=e=>{var n=zc(),r=V(n),i=V(r,!0);F(r),He(),F(n),W(e=>{Q(n,`aria-expanded`,e),Q(n,`aria-controls`,`commentary-${G(t).id}`),Y(i,v[G(t).id]?`⌄`:`›`)},[()=>!!v[G(t).id]]),K(`click`,n,()=>v[G(t).id]=!v[G(t).id]),J(e,n)};X(r,e=>{G(t).commentary&&e(i)}),F(n),J(e,n)},h=L(()=>G(t).commentary||ie(G(r)).length);X(d,e=>{G(p)?e(f):G(h)&&e(m,1)});var g=U(d,2),_=e=>{var n=Vc(),r=V(n);i(r,()=>G(t).commentary),F(n),W(()=>Q(n,`id`,`commentary-${G(t).id}`)),J(e,n)},b=L(()=>!k(G(t))&&G(t).commentary&&v[G(t).id]);X(g,e=>{G(b)&&e(_)});var x=U(g,2),S=V(x);i(S,()=>G(t).answer),F(x),fs(U(x,2),{get activities(){return G(r)},get now(){return G(y)}}),F(a),W(e=>Y(c,e),[()=>k(G(t))?`working`:`answer`]),J(e,a)},_=e=>{let a=L(()=>ee(G(t)));var o=Gc(),s=V(o),c=V(s),l=V(c,!0);F(c);var u=U(c,2),d=e=>{var r=Nc(),i=V(r),a=U(i),o=e=>{var r=Gr();W(e=>Y(r,`· ${e??``}`),[()=>oe(G(n),G(t).occurredAt)]),J(e,r)},s=L(()=>oe(G(n),G(t).occurredAt));X(a,e=>{G(s)&&e(o)}),F(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,`${t??``} `)},[()=>new Date(G(t).occurredAt).toISOString(),()=>es(G(t).occurredAt)]),J(e,r)};X(u,e=>{G(t).occurredAt&&e(d)}),F(s);var f=U(s,2),p=e=>{var n=Rc(),r=H(n),o=e=>{var n=Uc(),r=V(n);i(r,()=>G(t).commentary),F(n),J(e,n)};X(r,e=>{G(t).commentary&&e(o)});var s=U(r,2);{let e=L(()=>ie(G(a)));Ra(s,{get activities(){return G(e)},variant:`live`})}J(e,n)},m=L(()=>k(G(t))),h=e=>{var n=Wc(),r=H(n),o=U(V(r),2);i(o,()=>G(t).commentary),F(r),fs(U(r,2),{get activities(){return G(a)},get now(){return G(y)}}),J(e,n)};X(f,e=>{G(m)?e(p):e(h,-1)});var g=U(f,2),_=e=>{r(e,()=>G(a))},v=L(()=>k(G(t)));X(g,e=>{G(v)&&e(_)}),F(o),W((e,t)=>{Si(o,1,e,`svelte-1im954t`),Y(l,t)},[()=>gi(k(G(t))?`progress-turn`:`commentary-turn`),()=>k(G(t))?`working`:`commentary`]),J(e,o)};X(o,e=>{G(t).kind===`audit`?e(s):G(t).kind===`user`?e(u,1):G(t).answer===null?G(t).commentary!==null&&e(_,3):e(g,2)}),F(a),W(()=>Si(a,1,gi(G(t).kind===`user`?`prompt-turn`:G(t).kind===`audit`?`audit-item`:`answer-item`),`svelte-1im954t`)),J(e,a)});var j=U(fe,2),M=e=>{var t=qc();qs(V(t),{get interactions(){return G(w)},get answers(){return c()},get submittedAnswers(){return l()},get onanswer(){return d()},get onquiz(){return f()},get onpermission(){return p()},get ondecision(){return m()},get onretry(){return h()}}),F(t),J(e,t)};X(j,e=>{G(x).length===0&&G(w).length&&e(M)});var pe=U(j,2),me=e=>{var t=Jc(),n=V(t),i=V(n),o=e=>{var t=Pc(),n=U(H(t),2);{let e=L(()=>ie(G(re)));Ra(n,{get activities(){return G(e)},variant:`live`})}var i=U(n,2);r(i,()=>G(re)),J(e,t)},s=e=>{fs(e,{get activities(){return G(re)},get now(){return G(y)}})};X(i,e=>{a()?e(o):e(s,-1)}),F(n),F(t),W(()=>Si(n,1,gi(a()?`progress-turn`:`orphan-activity-turn`),`svelte-1im954t`)),J(e,t)};X(pe,e=>{G(re).length&&e(me)}),F(A),J(e,A),$e()}Rr([`click`]);var Zc=[150,300,600];function Qc(e){return new Promise(t=>setTimeout(t,e))}function $c(e){return e.status===502||e.status===503||e.status===504}async function el(e=fetch){for(let t=0;t<=Zc.length;t+=1){let n;try{n=await e(`/api/bootstrap`)}catch(e){if(e instanceof Error&&e.name===`AbortError`)throw e;if(t===Zc.length)throw Error(`BOOTSTRAP_FAILED`);await Qc(Zc[t]);continue}if(n.ok)return n.json();if(!$c(n)||t===Zc.length)throw Error(`BOOTSTRAP_FAILED`);await Qc(Zc[t])}throw Error(`BOOTSTRAP_FAILED`)}var tl=`gestalt-mobile`,nl=2,rl=[`settings`,`drafts`,`cursors`,`messages`];function il(e){return new Promise((t,n)=>{let r=e.open(tl,nl);r.onupgradeneeded=()=>{for(let e of rl)r.result.objectStoreNames.contains(e)||r.result.createObjectStore(e)},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})}function al(e,t,n){return cl(e.transaction(t,`readonly`).objectStore(t).get(n))}function ol(e,t,n,r){return cl(e.transaction(t,`readwrite`).objectStore(t).put(r,n))}function sl(e,t,n){return cl(e.transaction(t,`readwrite`).objectStore(t).delete(n))}function cl(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}var ll=`chat-projections`,ul=e=>({version:1,cursor:e.cursor,lifecycle:e.lifecycle,activeTurnId:e.activeTurnId,messages:e.messages.filter(e=>e.role===`user`).slice(-200),activities:[],prompts:e.prompts.slice(-200),interactions:e.interactions.map(({requestId:e,key:t,kind:n,turnId:r,state:i,operationId:a,attemptedOutcome:o})=>({requestId:e,key:t,kind:n,...r?{turnId:r}:{},state:i,...a?{operationId:a}:{},...i===`resolved`&&(o===`approved`||o===`denied`||o===`answered`||o===`dismissed`)?{attemptedOutcome:o}:{},...typeof o==`object`&&o&&(o.decision===`accept`||o.decision===`decline`)?{attemptedOutcome:{decision:o.decision}}:{}})).slice(-200),buffered:[]});function dl(e=globalThis.indexedDB){if(!e)return{read:async()=>null,write:async()=>{}};let t=il(e);return{read:async e=>{try{return await al(await t,ll,e)}catch{return null}},write:async(e,n)=>{try{await ol(await t,ll,e,ul(n))}catch{}}}}var fl=`chat-session`;function pl(e){return new URLSearchParams(e).get(`chat-session`)?.trim()||null}function ml(e,t){let n=new URL(e);return n.search=``,n.hash=``,n.searchParams.set(fl,t),n.toString()}function hl(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return`gestalt-chat-${(t>>>0).toString(36)}`}function gl(e,t){if(e===`autopilot.turn-started`)return`Continued execution automatically`;if(e===`autopilot.final-rejected`)return`Kept incomplete supervised work active`;if(e===`autopilot.executor-resumed`)return`Resumed the assigned executor`;if(e===`autopilot.process-monitoring`)return`Monitoring executor background work`;if(e===`autopilot.process-result-consumed`)return`Consumed background work result`;if(e===`autopilot.process-terminated`)return _l(t,`reason`)===`resourceBudget`?`Stopped background work at its resource limit`:`Stopped executor background work`;if(e===`autopilot.turn-failed`)return _l(t,`code`)===`START_UNAVAILABLE`?`Automatic continuation could not start: session runtime unavailable`:`Automatic continuation failed`;if(e===`org-plan.attention-required`)return`Needs attention`;if(e===`org-plan.attention-resolved`)return _l(t,`outcome`)===`failed`?`Attention resolution failed`:`Attention resolved`;if(e!==`autopilot.updated`)return null;let n=_l(t,`state`),r=_l(t,`reason`);return n===`completed`?`Completed the supervised plan`:n===`attentionRequired`&&r===`noPlanProgress`?`Automatic continuation stopped: no agent progress`:n===`attentionRequired`&&r===`reconcileFailed`?`Automatic continuation stopped: agent status unavailable`:n===`attentionRequired`&&r===`actionRateExceeded`?`Automatic continuation stopped: too many automatic actions`:null}function _l(e,t){return e&&typeof e==`object`?e[t]:void 0}function vl(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0?[{path:t.path,additions:t.additions,deletions:t.deletions}]:[]}):[]}function yl(e){if(typeof e.id!=`string`)return null;let t={...typeof e.turnId==`string`?{turnId:e.turnId}:{},...typeof e.actorTurnId==`string`?{actorTurnId:e.actorTurnId}:{},...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{}};if(e.kind===`reasoning`&&Array.isArray(e.summary)){let n=e.summary.filter(e=>typeof e==`string`).join(`
|
|
19
|
+
`);return n?{id:e.id,label:`Reasoning summary`,detail:n,...t}:null}if(e.kind===`plan`&&typeof e.text==`string`)return{id:e.id,label:`Plan`,detail:e.text,...t};if(e.kind===`command`&&typeof e.command==`string`)return{id:e.id,label:`Command · ${String(e.status??`unknown`)}`,detail:e.command,...t};if(e.kind===`fileChange`&&Array.isArray(e.paths)){let n=vl(e.changes);return{id:e.id,label:`File change · ${String(e.status??`unknown`)}`,detail:e.paths.join(`
|
|
20
|
+
`),...n.length?{changes:n}:{},...t}}return e.kind===`tool`&&typeof e.name==`string`?{id:e.id,label:`Tool · ${String(e.status??`unknown`)}`,detail:e.name,...t}:null}var bl=()=>({sessionId:null,cursor:0,snapshotting:!1,lifecycle:`finished`,activeTurnId:null,messages:[],activities:[],prompts:[],interactions:[],autopilotAuditTruncated:!1,buffered:new Map}),xl=(e=null)=>({...bl(),sessionId:e});function Sl(e){return e.kind===`autopilot`?{id:`item:${e.id}`,role:`audit`,text:`Continued execution automatically`,...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{},...typeof e.controlId==`string`?{controlId:e.controlId}:{},complete:!0}:e.kind!==`user`&&e.kind!==`agent`||typeof e.text!=`string`?null:{id:`item:${e.id}`,role:e.kind===`user`?`user`:`assistant`,text:e.text,...e.phase===`commentary`||e.phase===`final_answer`?{phase:e.phase}:{},...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{},...typeof e.turnId==`string`?{turnId:e.turnId}:{},complete:!0}}function Cl(e){return{id:e.id,role:`audit`,text:e.label,occurredAt:e.occurredAt,...e.controlId?{controlId:e.controlId}:{},complete:!0}}function wl(e){let t=Tl(e.occurredAt),n=gl(e.type,e.payload),r=e.payload&&typeof e.payload==`object`&&typeof e.payload.controlId==`string`?e.payload.controlId:void 0;return n&&t!==void 0?Cl({id:`audit:${e.sequence}`,label:n,occurredAt:t,...r?{controlId:r}:{}}):null}function Tl(e){if(typeof e!=`string`)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function El(e){let t=Tl(e.requestedAt);return{requestId:e.requestId,key:`interaction:${e.requestId}`,kind:e.kind,turnId:e.turnId,payload:`payload`in e?e.payload:null,state:e.resolvedAt?e.outcome===`failed`?`failed`:`resolved`:`pending`,...e.resolvedAt?{attemptedOutcome:e.outcome}:{},...t===void 0?{}:{occurredAt:t}}}function Dl(e,t){return t===`approved`||t===`denied`||t===`answered`||t===`dismissed`||t===`failed`?t:e?.kind===`quiz`||e?.kind===`userInput`?`answered`:typeof t==`object`&&t&&t.decision===`decline`?`denied`:e?`approved`:void 0}function Ol(e,t){return e?t===`finished`||t===`interrupted`?t:`working`:t===`working`||t===`starting`||t===`recoverable`?`finished`:t}function kl(e){return[...new Map(e.map(e=>[e.key??e.id??``,e])).values()]}function Al(e,t){return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?{...t,...t.occurredAt===void 0&&e.occurredAt!==void 0?{occurredAt:e.occurredAt}:{}}:e):[...e,t]}function jl(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=new Map(n.map((e,t)=>[e.id,t])),a=new Set(t.filter(e=>e.state!==`canonical`).map(e=>e.operationId)),o=new Set,s=e.flatMap(e=>{let i=Sl(e);if(!i)return[];if(e.kind===`user`){let n=t.find(t=>typeof e.operationId==`string`&&e.operationId===t.operationId||typeof e.turnId==`string`&&e.turnId===t.turnId),s=!n&&t.filter(t=>t.state!==`canonical`&&t.text===e.text).length===1?t.find(t=>t.state!==`canonical`&&t.text===e.text):void 0,c=n??s;if(c){a.delete(c.operationId);let e=r.get(c.key),t={...i,id:c.key,turnId:c.turnId??i.turnId,...i.occurredAt===void 0&&e?.occurredAt!==void 0?{occurredAt:e.occurredAt}:{}};return o.add(t.id),[e&&e.text===t.text&&e.turnId===t.turnId&&e.complete===t.complete&&e.occurredAt===t.occurredAt?e:t]}}if(e.kind===`agent`&&typeof e.turnId==`string`){let t=r.get(`assistant:${e.id}`)??n.find(t=>t.role===`assistant`&&t.turnId===e.turnId&&t.text===i.text&&(t.phase===i.phase||!t.complete));if(t){o.add(t.id);let e={...i,id:t.id,turnId:i.turnId??t.turnId,...i.occurredAt===void 0&&t.occurredAt!==void 0?{occurredAt:t.occurredAt}:{}};return[t.text===e.text&&t.phase===e.phase&&t.occurredAt===e.occurredAt?t:e]}}return o.add(i.id),[i]}),c=t.filter(e=>a.has(e.operationId)).map(e=>r.get(e.key)??{id:e.key,role:`user`,text:e.text,complete:e.state===`failed`,...e.turnId?{turnId:e.turnId}:{}}),l=n.filter(e=>e.role===`assistant`&&e.id.startsWith(`assistant:`)&&!o.has(e.id)),u=kl([...c,...l]),d=new Map(s.map((e,t)=>[e.id,t])),f=new Map;for(let e of u){let t=null;if(e.turnId){for(let n=s.length-1;n>=0;--n)if(s[n]?.turnId===e.turnId){t=n;break}}if(t===null){let r=i.get(e.id);if(r!==void 0){for(let e=r-1;e>=0;--e){let r=d.get(n[e].id);if(r!==void 0){t=r;break}}if(t===null)for(let e=r+1;e<n.length;e+=1){let r=d.get(n[e].id);if(r!==void 0){t=r-1;break}}}}let r=t??s.length-1;f.set(r,[...f.get(r)??[],e])}return kl([...f.get(-1)??[],...s.flatMap((e,t)=>[e,...f.get(t)??[]])])}function Ml(e,t){if(!t||typeof t!=`object`)return xl(e);let n=t;if(!Number.isInteger(n.cursor)||n.cursor<0||!Array.isArray(n.messages)||!Array.isArray(n.prompts)||!Array.isArray(n.interactions))return xl(e);let r=[`submitting`,`accepted`,`failed`,`canonical`],i=[`pending`,`submitting`,`resolved`,`failed`],a=[`starting`,`working`,`finished`,`interrupted`,`recoverable`];return{...xl(e),sessionId:e,cursor:n.cursor,lifecycle:a.includes(n.lifecycle)?n.lifecycle:`finished`,activeTurnId:typeof n.activeTurnId==`string`||n.activeTurnId===null?n.activeTurnId:null,snapshotting:!1,buffered:new Map,messages:n.messages.filter(e=>!!(e&&typeof e.id==`string`&&(e.role===`user`||e.role===`assistant`||e.role===`audit`)&&typeof e.text==`string`&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200),activities:Array.isArray(n.activities)?n.activities.filter(e=>!!(e&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.detail==`string`&&(e.changes===void 0||Array.isArray(e.changes)&&e.changes.every(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0}))&&(e.turnId===void 0||typeof e.turnId==`string`))).slice(-200):[],prompts:n.prompts.filter(e=>!!(e&&typeof e.operationId==`string`&&typeof e.key==`string`&&typeof e.text==`string`&&r.includes(e.state)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200),interactions:n.interactions.filter(e=>!!(e&&typeof e.requestId==`string`&&typeof e.key==`string`&&typeof e.kind==`string`&&(e.turnId===void 0||e.turnId===null||typeof e.turnId==`string`)&&i.includes(e.state)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200)}}function Nl(e,t){if(!Number.isInteger(t.baseSequence)||t.baseSequence<0)return e;if(t.baseSequence<e.cursor)return Gl({...e,snapshotting:!1});let n=t.items.filter(e=>e.kind===`user`),r=e.prompts.map(t=>{let r=n.some(e=>typeof e.turnId==`string`&&e.turnId===t.turnId||typeof e.operationId==`string`&&e.operationId===t.operationId),i=n.filter(e=>e.text===t.text),a=!t.turnId&&i.length===1&&e.prompts.filter(e=>e.state!==`canonical`&&e.text===t.text).length===1;return r||a?{...t,state:`canonical`}:t}),i=t.interactions.map(El),a=new Map(e.interactions.map(e=>[e.requestId,e])),o=kl(i.map(e=>{let t=a.get(e.requestId);return t?.state===`resolved`?t:{...e,...e.occurredAt===void 0&&t?.occurredAt!==void 0?{occurredAt:t.occurredAt}:{}}})),s=kl(t.items.flatMap(e=>{let t=yl(e);return t?[{...t,key:`activity:${t.id}`}]:[]}).concat((t.activities??[]).map(e=>({...e,key:`activity:${e.id}`})))).map(e=>({id:e.id,label:e.label,detail:e.detail,...e.turnId?{turnId:e.turnId}:{},...e.actorTurnId?{actorTurnId:e.actorTurnId}:{},...e.occurredAt===void 0?{}:{occurredAt:e.occurredAt},...e.changes?{changes:e.changes}:{}})).reduce(Al,[...e.activities]),c=new Map(t.turns.map(e=>[e.id,e])),l=t.items.map(e=>{if(typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt))return e;let t=typeof e.turnId==`string`?c.get(e.turnId):void 0,n=e.kind===`agent`?t?.completedAt??t?.startedAt:t?.startedAt??t?.completedAt;return typeof n==`number`&&Number.isFinite(n)?{...e,occurredAt:n}:e}),u=(t.autopilotAudit??[]).filter(e=>typeof e?.id==`string`&&typeof e.label==`string`&&typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)),d={...e,cursor:Math.max(e.cursor,t.baseSequence),snapshotting:!1,activeTurnId:t.activeTurnId,lifecycle:Ol(t.activeTurnId,e.cursor===0&&e.lifecycle===`finished`?`working`:e.lifecycle),prompts:r,messages:kl(jl(l,r,e.messages).concat(u.map(Cl))).sort((e,t)=>(e.occurredAt??2**53-1)-(t.occurredAt??2**53-1)),activities:s,interactions:o,autopilotAuditTruncated:t.autopilotAuditTruncated===!0,buffered:new Map([...e.buffered].filter(([e])=>e>t.baseSequence))};return Gl({...d,messages:Pl(d.messages)})}function Pl(e){let t=new Set;return e.filter(e=>e.role!==`audit`||!e.controlId?!0:t.has(e.controlId)?!1:(t.add(e.controlId),!0))}function Fl(e){return{...e,snapshotting:!0}}function Il(e,t,n,r){if(!n.trim()||e.prompts.some(e=>e.operationId===t))return e;let i={operationId:t,key:`prompt:${t}`,text:n,state:`submitting`,turnId:null,...typeof r==`number`&&Number.isFinite(r)?{occurredAt:r}:{}};return{...e,lifecycle:`starting`,prompts:[...e.prompts,i],messages:[...e.messages,{id:i.key,role:`user`,text:n,...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt},complete:!1}]}}function Ll(e,t,n,r){let i=Il(e,t,n,r);return i===e?e:{...i,lifecycle:`working`}}function Rl(e,t,n){return{...e,activeTurnId:n??e.activeTurnId,lifecycle:n?`working`:e.lifecycle,prompts:e.prompts.map(e=>e.operationId===t?{...e,state:`accepted`,turnId:n}:e),messages:e.messages.map(e=>e.id===`prompt:${t}`?{...e,complete:!0,...n?{turnId:n}:{}}:e)}}function zl(e,t){return{...e,lifecycle:`recoverable`,prompts:e.prompts.map(e=>e.operationId===t?{...e,state:`failed`}:e),messages:e.messages.map(e=>e.id===`prompt:${t}`?{...e,complete:!0}:e)}}function Bl(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t&&(e.state===`pending`||e.state===`failed`)?{...e,state:`submitting`,...n?{operationId:n}:{}}:e)}}function Vl(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t&&e.state!==`resolved`?{...e,state:`failed`,attemptedOutcome:n}:e)}}function Hl(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t?{...e,state:`resolved`,...Dl(e,n)?{attemptedOutcome:Dl(e,n)}:{}}:e)}}function Ul(e,t){if(!Number.isInteger(t.sequence)||t.sequence<=e.cursor)return e;if(e.snapshotting||t.sequence>e.cursor+1){let n=new Map(e.buffered);return n.set(t.sequence,t),{...e,snapshotting:!0,buffered:n}}let n={...e,cursor:t.sequence},r=t.payload,i=Tl(t.occurredAt);if(t.type===`agentMessageDelta`&&typeof r?.text==`string`){let e=typeof r.turnId==`string`?r.turnId:n.activeTurnId??void 0,t=`assistant:${typeof r.itemId==`string`?r.itemId:e??`live`}`,a=n.messages.find(e=>e.id===t);n={...n,lifecycle:n.activeTurnId?`working`:n.lifecycle,messages:a?n.messages.map(e=>e.id===t?{...e,text:e.text+r.text,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:{},complete:r.phase===`final_answer`||e.complete,...e.occurredAt===void 0&&i!==void 0?{occurredAt:i}:{}}:e):[...n.messages,{id:t,role:`assistant`,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:{},text:r.text,...e?{turnId:e}:{},...i===void 0?{}:{occurredAt:i},complete:r.phase===`final_answer`}]}}else if((t.type===`agentMessageStarted`||t.type===`agentMessageCompleted`)&&typeof r.text==`string`){let e=`assistant:${typeof r.itemId==`string`?r.itemId:n.activeTurnId??`live`}`,a=n.messages.find(t=>t.id===e),o=t.type===`agentMessageCompleted`,s={id:e,role:`assistant`,text:o&&r.text?r.text:a?.text??r.text,complete:o,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:a?.phase?{phase:a.phase}:{},...typeof r.turnId==`string`?{turnId:r.turnId}:a?.turnId?{turnId:a.turnId}:n.activeTurnId?{turnId:n.activeTurnId}:{},...a?.occurredAt===void 0?i===void 0?{}:{occurredAt:i}:{occurredAt:a.occurredAt}};n={...n,lifecycle:n.activeTurnId?`working`:n.lifecycle,messages:a?n.messages.map(t=>t.id===e?s:t):[...n.messages,s]}}else if(t.type===`turnCompleted`||t.type===`turnInterrupted`)n={...n,activeTurnId:null,lifecycle:t.type===`turnCompleted`||n.lifecycle===`finished`?`finished`:`interrupted`,messages:n.messages.map(e=>e.role===`assistant`?{...e,complete:!0}:e)};else if(t.type===`interaction.requested`&&typeof r?.requestId==`string`&&typeof r.kind==`string`){let e=n.interactions.find(e=>e.requestId===r.requestId);if(!e||e.state===`resolved`){let t={requestId:r.requestId,key:`interaction:${r.requestId}`,kind:r.kind,turnId:typeof r.turnId==`string`?r.turnId:n.activeTurnId,payload:r.payload,state:`pending`,...i===void 0?{}:{occurredAt:i}};n={...n,interactions:e?n.interactions.map(e=>e.requestId===r.requestId?t:e):[...n.interactions,t]}}}else if(t.type===`interaction.resolved`&&typeof r?.requestId==`string`)n=Hl(n,r.requestId,r.outcome);else if(t.type===`activity.updated`&&typeof r?.id==`string`&&typeof r.label==`string`&&typeof r.detail==`string`){let e=Wl(r.changes);n={...n,activities:Al(n.activities,{id:r.id,label:r.label,detail:r.detail,...i===void 0?{}:{occurredAt:i},...e.length?{changes:e}:{},...typeof r.turnId==`string`?{turnId:r.turnId}:n.activeTurnId?{turnId:n.activeTurnId}:{},...typeof r.actorTurnId==`string`?{actorTurnId:r.actorTurnId}:{}})}}else if(t.type===`session.updated`&&r?.activeTurnId!==void 0){let e=typeof r.activeTurnId==`string`?r.activeTurnId:null;n={...n,activeTurnId:e,lifecycle:e?`working`:Ol(e,n.lifecycle)}}let a=wl(t);return a&&!n.messages.some(e=>e.id===a.id)&&(n={...n,messages:Pl([...n.messages,a])}),n}function Wl(e){return!Array.isArray(e)||e.length>1e3?[]:e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0?[{path:t.path,additions:t.additions,deletions:t.deletions}]:[]})}function Gl(e){let t=new Map(e.buffered),n={...e,snapshotting:!1,buffered:t};for(;;){let e=t.get(n.cursor+1);if(!e)return{...n,buffered:t,snapshotting:t.size>0};t.delete(e.sequence),n=Ul({...n,buffered:t},e),t=new Map(n.buffered)}}function Kl(e){return e.sessionId?e.snapshotting||e.lifecycle===`recoverable`?`Connection interrupted. Reconnecting…`:e.lifecycle===`starting`?`Starting Codex turn…`:e.lifecycle===`working`?`Codex is working…`:e.lifecycle===`interrupted`?`Codex turn interrupted.`:`Ready.`:`Choose a workspace and start a session.`}var ql={read:async()=>null,write:async()=>{}},Jl=[250,750,1500],Yl=e=>!!e&&typeof e==`object`,Xl=e=>Yl(e)&&typeof e.path==`string`&&Number.isInteger(e.additions)&&e.additions>=0&&Number.isInteger(e.deletions)&&e.deletions>=0,Zl=e=>Yl(e)&&typeof e.id==`string`&&typeof e.kind==`string`,Ql=e=>Yl(e)&&typeof e.id==`string`&&Array.isArray(e.items)&&e.items.every(Zl)&&(e.startedAt===null||typeof e.startedAt==`number`)&&(e.completedAt===null||typeof e.completedAt==`number`),$l=e=>!Yl(e)||typeof e.requestId!=`string`||typeof e.kind!=`string`||!(e.turnId===null||typeof e.turnId==`string`)||!(e.requestedAt===null||typeof e.requestedAt==`string`)?!1:e.resolvedAt===null?Object.hasOwn(e,`payload`):typeof e.resolvedAt==`string`&&(e.outcome===`approved`||e.outcome===`denied`||e.outcome===`answered`||e.outcome===`dismissed`||e.outcome===`failed`)&&!Object.hasOwn(e,`payload`),eu=e=>Yl(e)&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)&&(e.controlId===void 0||typeof e.controlId==`string`),tu=e=>Yl(e)&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.detail==`string`&&(e.changes===void 0||Array.isArray(e.changes)&&e.changes.every(Xl))&&(e.turnId===void 0||typeof e.turnId==`string`)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)),nu=e=>!Yl(e)||!Number.isInteger(e.baseSequence)||e.baseSequence<0||!(e.activeTurnId===null||typeof e.activeTurnId==`string`)||!Array.isArray(e.items)||!Array.isArray(e.turns)||!Array.isArray(e.interactions)||!e.items.every(Zl)||!e.turns.every(Ql)||!e.interactions.every($l)||e.activities!==void 0&&(!Array.isArray(e.activities)||!e.activities.every(tu))||e.autopilotAudit!==void 0&&(!Array.isArray(e.autopilotAudit)||!e.autopilotAudit.every(eu))||e.autopilotAuditTruncated!==void 0&&typeof e.autopilotAuditTruncated!=`boolean`||e.currentSequence!==void 0&&(!Number.isInteger(e.currentSequence)||e.currentSequence<0)?null:e,ru=class{#e=xl();#t=null;#n=0;#r=-1;#i=null;#a=null;#o=null;#s=0;#c=!1;#l=!1;#u=null;#d=0;#f=!1;#p=new Set;#m=new Set;#h;constructor(e){this.#h={...e,websocket:e.websocket??(e=>new WebSocket(e)),cache:e.cache??ql,location:e.location??location,document:e.document??document,window:e.window??window,setTimeout:e.setTimeout??((e,t)=>setTimeout(e,t)),clearTimeout:e.clearTimeout??(e=>clearTimeout(e)),createKey:e.createKey??io,now:e.now??Date.now},this.#h.document.addEventListener(`visibilitychange`,this.#g),this.#h.window.addEventListener(`focus`,this.#g)}get view(){return Object.freeze({...this.#e,status:Kl(this.#e),starting:this.#e.lifecycle===`starting`})}canSubmit(e){return this.#t?e===`send`?!this.#e.activeTurnId:!!(this.#e.activeTurnId&&(e!==`queue`||this.#h.relay.queueTurnInput)):!1}select(e,t={}){if(this.#f||this.#t===e)return;this.#k(),this.#t=e,this.#l=e!==null&&t.history===`empty`;let n=++this.#n;this.#e=xl(e),this.#T(),e&&this.#_(e,n)}async send(e,t=this.#h.createKey()){let n=this.#t,r=this.#n,i=`${n}:${r}:${t}`;if(!(!n||!e.trim()||this.#e.activeTurnId||this.#p.has(i))){this.#p.add(i),this.#w(Il(this.#e,t,e.trim(),this.#h.now()));try{let i=await this.#h.relay.startTurn(n,e.trim(),t);this.#E(n,r)&&(this.#l=!1,this.#w(Rl(this.#e,t,i.activeTurnId??null))),this.#h.onSendAccepted?.(n,t)}catch(e){this.#E(n,r)&&(this.#w(zl(this.#e,t)),this.#h.onSendError?.(e,t))}finally{this.#p.delete(i)}}}async retryPrompt(e){let t=this.#e.prompts.find(t=>t.operationId===e);t?.state===`failed`&&await this.send(t.text,e)}async queue(e,t=this.#h.createKey()){let n=this.#t,r=this.#e.activeTurnId,i=this.#h.relay.queueTurnInput,a=this.#n,o=`${n}:${a}:${t}`;if(!(!n||!r||!i||!e.trim()||this.#p.has(o))){this.#p.add(o),this.#w(Ll(this.#e,t,e.trim(),this.#h.now()));try{let o=await i(n,r,e.trim(),t);this.#E(n,a)&&this.#w(Rl(this.#e,t,o.activeTurnId)),this.#h.onSendAccepted?.(n,t)}catch(e){this.#E(n,a)&&(this.#w(zl(this.#e,t)),this.#h.onSendError?.(e,t))}finally{this.#p.delete(o)}}}async interruptAndSend(e,t=this.#h.createKey()){let n=this.#t,r=this.#e.activeTurnId,i=this.#n,a=`${n}:${i}:${t}`;if(!(!n||!r||!e.trim()||this.#p.has(a))){this.#p.add(a),this.#w(Il(this.#e,t,e.trim(),this.#h.now()));try{await this.#h.relay.interruptTurn(n,r).catch(()=>void 0);let a=await this.#D(n,i,e.trim(),t);this.#E(n,i)&&this.#w(Rl(this.#e,t,a.activeTurnId??null)),this.#h.onSendAccepted?.(n,t)}catch(e){this.#E(n,i)&&(this.#w(zl(this.#e,t)),this.#h.onSendError?.(e,t))}finally{this.#p.delete(a)}}}async interrupt(){let e=this.#t,t=this.#e.activeTurnId;if(!(!e||!t))try{await this.#h.relay.interruptTurn(e,t)}catch{}}async respond(e,t,n=this.#h.createKey()){let r=this.#t,i=this.#n,a=this.#e.interactions.find(t=>t.requestId===e),o=a?.operationId??n,s=`${r}:${i}:${o}`;if(!(!r||!a||a.state===`resolved`||a.state===`submitting`||this.#m.has(s))){this.#m.add(s),this.#w(Bl(this.#e,e,o));try{let n=await this.#h.relay.respondInteraction(r,e,t,o),a=n&&(n.outcome===`approved`||n.outcome===`denied`||n.outcome===`answered`||n.outcome===`dismissed`||n.outcome===`failed`)?n.outcome:t;this.#E(r,i)&&this.#w(Hl(this.#e,e,a))}catch{this.#E(r,i)&&this.#w(Vl(this.#e,e,t))}finally{this.#m.delete(s)}}}async retryInteraction(e,t){let n=this.#e.interactions.find(t=>t.requestId===e);if(n?.state!==`failed`||!n.operationId)return;let r=t??n.attemptedOutcome,i=r===`approved`?{decision:`accept`}:r===`denied`?{decision:`decline`}:r;i!==void 0&&await this.respond(e,i,n.operationId)}refresh(){this.#t&&!this.#l&&this.#x(this.#t,this.#n)}dispose(){this.#f||(this.#f=!0,this.#k(),this.#h.document.removeEventListener(`visibilitychange`,this.#g),this.#h.window.removeEventListener(`focus`,this.#g))}#g=()=>{this.#h.document.visibilityState===`visible`&&this.refresh()};async#_(e,t){let n=this.#l;if(n||this.#x(e,t),this.#v(e,t),n)return;let r=await this.#h.cache.read(e).catch(()=>null);!this.#E(e,t)||this.#r===t||!r||(this.#e=Ml(e,r),this.#T())}#v(e,t){if(!this.#E(e,t)||this.#i)return;let n=this.#h.location.protocol===`https:`?`wss:`:`ws:`,r;try{r=this.#h.websocket(`${n}//${this.#h.location.host}/api/sessions/${encodeURIComponent(e)}/events?after=${this.#e.cursor}`)}catch{this.#e={...this.#e,lifecycle:`recoverable`},this.#T(),this.#u=this.#h.setTimeout(()=>this.#v(e,t),Math.min(1e3*2**this.#d++,1e4));return}this.#i=r,r.onopen=()=>{this.#E(e,t)&&this.#i===r&&(this.#d=0,this.#l||this.#x(e,t))},r.onmessage=n=>this.#y(e,t,String(n.data)),r.onclose=()=>{!this.#E(e,t)||this.#i!==r||(this.#i=null,this.#u=this.#h.setTimeout(()=>this.#v(e,t),Math.min(1e3*2**this.#d++,1e4)))}}#y(e,t,n){if(!this.#E(e,t))return;let r;try{r=JSON.parse(n)}catch{return}if(r.type===`relay.resyncRequired`){this.#l=!1,this.#x(e,t);return}if(r.type!==`relay.event`||!r.event||typeof r.event!=`object`)return;let i=r.event;if(!Number.isInteger(i.sequence)||typeof i.type!=`string`||!this.#b(i))return;this.#l=!1;let a=Ul(this.#e,i);this.#w(a),this.#h.onRelayEvent?.(i),(i.type===`session.updated`||i.type===`plan.updated`||i.type===`plan.closed`||i.type===`agent.activity.updated`||i.type===`session.status.updated`||i.type===`autopilot.updated`||i.type===`org-plan.attention-required`||i.type===`org-plan.attention-resolved`)&&this.#h.onSessionEvent?.(i),a.snapshotting&&this.#x(e,t)}#b(e){let t=e.payload;if(!t||typeof t!=`object`)return e.type===`turnCompleted`||e.type===`turnInterrupted`||e.type===`plan.closed`;let n=t;return e.type===`agentMessageDelta`||e.type===`agentMessageStarted`||e.type===`agentMessageCompleted`?typeof n.text==`string`:e.type===`interaction.requested`?typeof n.requestId==`string`&&typeof n.kind==`string`:e.type===`interaction.resolved`?typeof n.requestId==`string`:e.type===`session.updated`?n.activeTurnId===null||typeof n.activeTurnId==`string`:e.type===`activity.updated`?typeof n.id==`string`&&typeof n.label==`string`&&typeof n.detail==`string`:e.type===`agent.activity.updated`?typeof n.sessionId==`string`&&!!n.root&&Array.isArray(n.subagents):e.type===`session.status.updated`?typeof n.state==`string`&&typeof n.reason==`string`:e.type===`autopilot.updated`||e.type===`org-plan.attention-required`||e.type===`org-plan.attention-resolved`||[`autopilot.continuation-scheduled`,`autopilot.control-issued`,`autopilot.turn-started`,`autopilot.turn-failed`].includes(e.type)?!0:e.type===`plan.updated`||e.type===`plan.closed`}#x(e,t){if(this.#a?.id===e&&this.#a.generation===t)return this.#a.promise;if(!this.#E(e,t))return Promise.resolve();let n=this.#e.snapshotting&&this.#e.buffered.size>0;this.#e=Fl(this.#e),this.#T();let r=this.#h.relay.getHistory(e).then(r=>{let i=nu(r);if(this.#E(e,t)){if(!i){this.#w({...this.#e,snapshotting:!1,lifecycle:`recoverable`});return}this.#s=0,this.#c=!1,this.#o&&this.#h.clearTimeout(this.#o),this.#o=null,this.#r=t,this.#w(Nl(this.#e,i));for(let t of i.items)t.kind===`user`&&typeof t.operationId==`string`&&this.#h.onHistoryPromptAccepted?.(e,t.operationId);n&&this.#C(e,t)}}).catch(n=>{if(this.#E(e,t)){this.#w({...this.#e,snapshotting:!1,lifecycle:`recoverable`});let r=Jl[this.#s++];r===void 0?this.#c||(this.#c=!0,this.#h.onHistoryError?.(n)):this.#S(e,t,r)}}).finally(()=>{this.#a?.promise===r&&(this.#a=null,this.#E(e,t)&&this.#e.snapshotting&&this.#x(e,t))});return this.#a={id:e,generation:t,promise:r},r}#S(e,t,n){this.#o&&this.#h.clearTimeout(this.#o);let r=this.#h.setTimeout(()=>{this.#o===r&&(this.#o=null,this.#E(e,t)&&this.#x(e,t))},n);this.#o=r}#C(e,t){let n=this.#i;this.#i=null,n?.close(),this.#u&&this.#h.clearTimeout(this.#u),this.#u=null,this.#v(e,t)}#w(e){this.#e=e,this.#T(),this.#t&&this.#h.cache.write(this.#t,this.#e).catch(()=>{})}#T(){this.#h.publish(this.view)}#E(e,t){return!this.#f&&this.#t===e&&this.#n===t}async#D(e,t,n,r){let i;for(let a of[0,50,150,300]){if(!this.#E(e,t))throw Error(`SESSION_CHANGED`);a&&await this.#O(a);try{return await this.#h.relay.startTurn(e,n,r)}catch(e){if(!iu(e,`SESSION_TURN_ACTIVE`))throw e;i=e}}throw i}#O(e){return new Promise(t=>this.#h.setTimeout(t,e))}#k(){this.#u&&this.#h.clearTimeout(this.#u),this.#u=null,this.#o&&this.#h.clearTimeout(this.#o),this.#o=null,this.#s=0,this.#c=!1,this.#l=!1;let e=this.#i;this.#i=null,e?.close()}};function iu(e,t){return Yl(e)&&e.code===t}var au=class{#e=!0;#t=null;#n;constructor(e){this.#n=e}get following(){return this.#e}observeTail(e){this.#e=e}reset(){this.cancel(),this.#e=!0}request(e){e!==`content`&&(this.#e=!0),!(e===`content`&&!this.#e)&&this.#t===null&&(this.#t=this.#n.requestFrame(()=>{this.#t=null,this.#n.scrollTail(e===`initial`||this.#n.reducedMotion()?`auto`:`smooth`)}))}cancel(){this.#t!==null&&this.#n.cancelFrame(this.#t),this.#t=null}},ou=class{afterCommit;request;#e=0;constructor(e,t){this.afterCommit=e,this.request=t}schedule(e){let t=this.#e;this.afterCommit(()=>{t===this.#e&&this.request(e)})}invalidate(){this.#e+=1}};function su(e){if(!e||typeof e!=`object`)return!1;let t=e;return(t.state===`working`||t.state===`idle`)&&[`needsYou`,`complete`,`rootTurn`,`agent`,`process`,`autopilot`,`incompleteWithoutContinuation`,`stopped`,`disconnected`,`unknown`].includes(t.reason)&&[`fresh`,`stale`,`reconciling`].includes(t.confidence)&&typeof t.observedAt==`string`&&!Number.isNaN(Date.parse(t.observedAt))&&typeof t.nextExpectedAction==`string`&&t.nextExpectedAction.length>0&&t.nextExpectedAction.length<=240}var cu={FILE_PREVIEW_NOT_FOUND:`This file or folder no longer exists. Check the path and try again.`,FILE_PREVIEW_UNREADABLE:`This path could not be read. It must be inside the workspace and accessible without symbolic links.`,FILE_PREVIEW_UNSUPPORTED:`Preview supports UTF-8 text files and folders. This item cannot be displayed.`,FILE_PREVIEW_TOO_LARGE:`This file exceeds the 1 MiB preview limit. Open it locally to view its contents.`,INVALID_FILE_PREVIEW:`This file reference is invalid. Check its path and try again.`,RELAY_UNAVAILABLE:`The relay is unavailable. Check the connection and try again.`,SESSION_HISTORY_UNAVAILABLE:`Session history is unavailable. Check the relay connection and try opening the session again.`,SESSION_HISTORY_READ_FAILED:`Session history could not be read. The conversation remains saved; try again shortly.`,SESSION_WRITER_BUSY:`This thread is active in another Codex client. Release it there, then retry sending here.`,SESSION_WORKSPACE_UNAVAILABLE:`This session workspace is unavailable. Your message remains in the conversation for copying; restore workspace access before sending again.`,SESSION_RUNTIME_DEPENDENCY_FAILED:`A required Codex runtime dependency is unavailable. Check Codex, then retry.`,CODEX_PROTOCOL_INCOMPATIBLE:`The installed Codex runtime is incompatible with this relay. Update Codex before retrying.`,SESSION_ROLLOUT_MISSING:`This stored thread is no longer available.`,SESSION_RUNTIME_UNAVAILABLE:`The Codex runtime is unavailable. Retry shortly.`,SESSION_START_FAILED:`The session could not be started. Try again.`,ORG_EXECUTOR_PROFILE_UNAVAILABLE:`The Org-plan executor profile could not be read. Restore the installed Gestalt agent profile and try again.`,ORG_EXECUTOR_PROFILE_INVALID:`The Org-plan executor profile has invalid model settings. Repair the installed profile and try again.`,SESSION_CLOSE_FAILED:`The session could not be closed. Try again.`,SESSION_COPY_FAILED:`The CLI resume command could not be copied. Check clipboard access and try again.`,SESSION_DEFAULTS_READ_FAILED:`Saved session defaults could not be loaded. Using built-in defaults; check the configuration file and reload.`,SESSION_DEFAULTS_SAVE_FAILED:`Session defaults could not be saved. Try again.`,SESSION_MODELS_READ_FAILED:`Models could not be loaded for this provider. Select another provider and try again.`,SESSION_REFRESH_FAILED:`Sessions could not be refreshed. Try again.`,MESSAGE_SEND_FAILED:`The message was not sent. Your draft is preserved.`,GIT_SUMMARY_FAILED:`Repository status could not be loaded. Select it again to retry.`,GIT_PULL_FAILED:`The branch could not be refreshed. Resolve any Git conflicts and try again.`,GIT_CHECKOUT_FAILED:`The branch could not be selected. Refresh Git status and try again.`,GIT_PUSH_FAILED:`The push failed. Refresh Git status and resolve remote divergence first.`,GIT_CLONE_FAILED:`Clone failed.`,WORKSPACE_FILES_READ_FAILED:`Files could not be read. Try again.`,QUIT_FAILED:`Gestalt Mobile could not quit cleanly. Try again or stop it from the terminal.`,DEBUG_CONTEXT_FAILED:`Session diagnostics could not be read. Reopen DEBUG to try again.`,DEBUG_START_FAILED:`Self DEBUG could not start. Check Sessions for a saved debug session before trying again.`,DEBUG_TRACE_FAILED:`The diagnostic trace could not be opened. Check that the saved JSON file is still available.`,DEBUG_CONFIRMATION_EXPIRED:`The debug confirmation expired. Reopen DEBUG to confirm current session details.`,DEBUG_SOURCE_CHANGED:`The source session changed. Reopen DEBUG to confirm current session details.`};function lu(e,t){let n=e instanceof Error?e.message:``,r=typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:``,i=Object.hasOwn(cu,r)?r:Object.hasOwn(cu,n)?n:t,a=typeof e==`object`&&e&&`retryable`in e?e.retryable===!0:!0;return{code:i,message:cu[i],retryable:a}}var uu=q(`<small class="svelte-1izxxv2"> </small>`),du=q(`<li class="svelte-1izxxv2"><div class="notification-meta svelte-1izxxv2"><strong class="svelte-1izxxv2"> </strong> <time class="svelte-1izxxv2"> </time></div> <p class="svelte-1izxxv2"> </p> <!></li>`),fu=q(`<ol aria-label="Recent notifications" class="svelte-1izxxv2"></ol>`),pu=q(`<p class="empty svelte-1izxxv2" role="status">No recent notifications.</p>`),mu=q(`<main class="notification-history svelte-1izxxv2" aria-labelledby="notification-history-title"><header class="svelte-1izxxv2"><button type="button" class="svelte-1izxxv2">Back</button> <div><h1 id="notification-history-title" tabindex="-1" class="svelte-1izxxv2">Recent notifications</h1> <p class="svelte-1izxxv2">The latest notifications saved in this browser.</p></div></header> <!></main>`);function hu(e,t){Qe(t,!0);let n=z([]),r=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});Gi(()=>t.queue.subscribeHistory(e=>B(n,e)));function i(e){Tr().then(()=>e.focus())}var a=mu(),o=V(a),s=V(o),c=U(s,2);pi(V(c),()=>i),He(2),F(c),F(o);var l=U(o,2),u=e=>{var t=fu();Z(t,21,()=>G(n),e=>e.id,(e,t)=>{var n=du(),i=V(n),a=V(i),o=V(a,!0);F(a);var s=U(a,2),c=V(s,!0);F(s),F(i);var l=U(i,2),u=V(l,!0);F(l);var d=U(l,2),f=e=>{var n=uu(),r=V(n);F(n),W(()=>Y(r,`Repeated ${G(t).occurrences??``} times.`)),J(e,n)};X(d,e=>{G(t).occurrences>1&&e(f)}),F(n),W((e,r)=>{Q(n,`data-kind`,G(t).kind),Y(o,G(t).kind),Q(s,`datetime`,e),Y(c,r),Y(u,G(t).message)},[()=>new Date(G(t).updatedAt).toISOString(),()=>r.format(G(t).updatedAt)]),J(e,n)}),F(t),J(e,t)},d=e=>{J(e,pu())};X(l,e=>{G(n).length?e(u):e(d,-1)}),F(a),K(`click`,s,function(...e){t.onclose?.apply(this,e)}),J(e,a),$e()}Rr([`click`]);var gu={error:null,success:5e3,warning:1e4,info:7e3},_u=`gestalt-mobile.notification-history`;function vu(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function yu(e,t){try{let n=JSON.parse(e?.getItem(`gestalt-mobile.notification-history`)??`[]`);return Array.isArray(n)?n.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&[`error`,`success`,`warning`,`info`].includes(String(e.kind))&&typeof e.message==`string`&&typeof e.occurrences==`number`&&typeof e.createdAt==`number`&&typeof e.updatedAt==`number`).slice(-t):[]}catch{return[]}}function bu(e={}){let t=e.now??Date.now,n=e.setTimer??setTimeout,r=e.clearTimer??clearTimeout,i=new Set,a=new Set,o=new Map,s=[],c=e.historyLimit??50,l=yu(e.historyStorage,c),u=0,d=()=>s.map(e=>({...e})),f=()=>[...l].reverse().map(e=>({...e})),p=()=>i.forEach(e=>e(d())),m=()=>{try{e.historyStorage?.setItem(_u,JSON.stringify(l))}catch{}},h=()=>{m(),a.forEach(e=>e(f()))},g=e=>{let t=o.get(e);t?.handle&&r(t.handle),t&&(t.handle=null)},_=e=>{s.some(t=>t.id===e)&&(g(e),o.delete(e),s=s.filter(t=>t.id!==e),p())},v=e=>{let r=o.get(e);!r||r.pauseReasons.size>0||(r.startedAt=t(),r.handle=n(()=>_(e),r.remaining))};return{enqueue(e){if(e.code){let n=s.find(t=>t.kind===e.kind&&t.code===e.code);if(n)return s=s.map(e=>e.id===n.id?{...e,occurrences:e.occurrences+1}:e),l=l.map(e=>e.id===n.id?{...e,occurrences:e.occurrences+1,updatedAt:t()}:e),p(),h(),n.id}let n=t(),r=`toast-${n}-${++u}`,i={...e,id:r,occurrences:1};s=[...s,i],l=[...l,{...i,createdAt:n,updatedAt:n}].slice(-c);let a=gu[e.kind];return a!==null&&(o.set(r,{handle:null,remaining:a,startedAt:t(),pauseReasons:new Set}),v(r)),p(),h(),r},dismiss:_,pause(e,n){let r=o.get(e);!r||r.pauseReasons.has(n)||(r.pauseReasons.add(n),r.handle&&(r.remaining=Math.max(0,r.remaining-(t()-r.startedAt)),g(e)))},resume(e,t){let n=o.get(e);!n||!n.pauseReasons.delete(t)||n.pauseReasons.size>0||v(e)},snapshot:d,historySnapshot:f,subscribe(e){return i.add(e),e(d()),()=>i.delete(e)},subscribeHistory(e){return a.add(e),e(f()),()=>a.delete(e)}}}var xu=q(`<small class="svelte-1a0rutm"> </small>`),Su=q(`<section aria-atomic="true"><span class="toast-symbol svelte-1a0rutm" aria-hidden="true"> </span> <span class="toast-copy svelte-1a0rutm"><strong class="svelte-1a0rutm"> </strong> <span> </span> <!></span> <button type="button" class="svelte-1a0rutm"><span aria-hidden="true">×</span></button></section>`),Cu=q(`<div class="toast-viewport svelte-1a0rutm" aria-label="Notifications"></div>`);function wu(e,t){Qe(t,!0);let n=z([]),r=L(()=>G(n).slice(-3));Gi(()=>t.queue.subscribe(e=>B(n,e)));var i=Cu();Z(i,21,()=>G(r),e=>e.id,(e,n)=>{var r=Su();let i;var a=V(r),o=V(a,!0);F(a);var s=U(a,2),c=V(s),l=V(c,!0);F(c);var u=U(c,2),d=V(u,!0);F(u);var f=U(u,2),p=e=>{var t=xu(),r=V(t);F(t),W(()=>Y(r,`Repeated ${G(n).occurrences??``} times.`)),J(e,t)};X(f,e=>{G(n).occurrences>1&&e(p)}),F(s);var m=U(s,2);F(r),W(()=>{i=Si(r,1,`toast svelte-1a0rutm`,null,i,{error:G(n).kind===`error`,success:G(n).kind===`success`,warning:G(n).kind===`warning`}),Q(r,`role`,G(n).kind===`error`?`alert`:`status`),Q(r,`aria-live`,G(n).kind===`error`?`assertive`:`polite`),Y(o,G(n).kind===`error`||G(n).kind===`warning`?`!`:G(n).kind===`success`?`✓`:`i`),Y(l,G(n).kind===`error`?`Error`:G(n).kind===`success`?`Success`:G(n).kind===`warning`?`Warning`:`Info`),Y(d,G(n).message),Q(m,`aria-label`,`Dismiss ${G(n).kind} notification`)}),Lr(`pointerenter`,r,()=>t.queue.pause(G(n).id,`hover`)),Lr(`pointerleave`,r,()=>t.queue.resume(G(n).id,`hover`)),K(`focusin`,r,()=>t.queue.pause(G(n).id,`focus`)),K(`focusout`,r,()=>t.queue.resume(G(n).id,`focus`)),K(`click`,m,()=>t.queue.dismiss(G(n).id)),J(e,r)}),F(i),J(e,i),$e()}Rr([`focusin`,`focusout`,`click`]);var Tu=q(`<main class="evidence-page svelte-1j55xyh"><h1 class="svelte-1j55xyh">Git repository</h1> <p>Choose a destination and clone a repository.</p> <div class="evidence-composer svelte-1j55xyh"><label for="evidence-prompt">Prompt</label> <textarea id="evidence-prompt" class="evidence-prompt svelte-1j55xyh" rows="1">Review repository status</textarea></div></main> <nav class="evidence-nav svelte-1j55xyh" aria-label="Primary evidence navigation"><button type="button" class="svelte-1j55xyh">Sessions</button> <button type="button" aria-pressed="true" class="svelte-1j55xyh">Git</button> <button type="button" class="svelte-1j55xyh">Chat</button></nav> <!>`,1);function Eu(e,t){Qe(t,!0);let n=bu();Gi(()=>{t.variant===`stacked`&&n.enqueue({kind:`success`,message:`Cloned.`}),n.enqueue({kind:`error`,code:`GIT_CLONE_FAILED`,message:`Clone failed.`})});var r=Tu();wu(U(H(r),4),{get queue(){return n}}),J(e,r),$e()}var Du={sessionBase:()=>!0,gitRepositoryTarget:e=>e.isGitRepository,cloneDestination:e=>!e.isGitRepository};function Ou(e){let t=new Set,n=(e,r)=>{!e.isGitRepository&&r<=2&&t.add(e.id),e.children.forEach(e=>n(e,r+1))};return e.forEach(e=>n(e,1)),t}function ku(e,t){let n=new Set(e);return t.isGitRepository||(n.has(t.id)?n.delete(t.id):n.add(t.id)),n}function Au(e,t){let n=[],r=(e,i,a)=>{n.push({node:e,level:i,parentId:a}),!e.isGitRepository&&t.has(e.id)&&e.children.forEach(t=>r(t,i+1,e.id))};return e.forEach(e=>r(e,1,null)),n}function ju(e,t){let n=(e,r)=>{if(e.id===t)return r;for(let t of e.children){let i=n(t,[...r,e.id]);if(i)return i}return null};for(let t of e){let e=n(t,[]);if(e)return e}return[]}function Mu(e,t){for(let n of e){if(n.id===t)return n;let e=Mu(n.children,t);if(e)return e}}function Nu(e,t,n,r){if(e){let i=Mu(n,e);if(i&&r(i))return i.id;let a=ju(t,e);for(let e of a.toReversed()){let t=Mu(n,e);if(t&&r(t))return t.id}}return Pu(n).find(r)?.id??null}function Pu(e){let t=[],n=e=>{t.push(e),e.children.forEach(n)};return e.forEach(n),t}var Fu=q(`<button class="disclosure svelte-6z3q4v" type="button" tabindex="-1"><span aria-hidden="true"> </span></button>`),Iu=q(`<span class="disclosure-spacer svelte-6z3q4v" aria-hidden="true"></span>`),Lu=q(`<span class="repository-badge svelte-6z3q4v">Git</span>`),Ru=q(`<div class="tree-row svelte-6z3q4v"><!> <button type="button" role="treeitem"><span class="selection-mark svelte-6z3q4v" aria-hidden="true"> </span> <span class="node-copy svelte-6z3q4v"><span class="node-name svelte-6z3q4v"> </span> <span class="node-path svelte-6z3q4v"> </span></span> <!></button></div>`),zu=q(`<div class="filesystem-tree svelte-6z3q4v" role="tree"></div>`);function Bu(e,t){Qe(t,!0);let n=$(t,`isSelectable`,3,()=>!0),r=z(null),i=on({}),a=L(()=>Au(t.roots,t.expandedIds)),o=L(()=>G(r)&&G(a).some(({node:e})=>e.id===G(r))?G(r):t.selectedId&&G(a).some(({node:e})=>e.id===t.selectedId)?t.selectedId:G(a)[0]?.node.id??null);function s(e){return!e.isGitRepository&&e.children.length>0}function c(e){return e===`.`?`~/`:`~/${e}`}function l(e){B(r,e,!0),i[e]?.focus()}function u(e,t){let n=Math.max(0,Math.min(G(a).length-1,t)),r=G(a)[n];r&&n!==e&&l(r.node.id)}function d(e){n()(e)&&t.onselect(e)}function f(e){s(e)&&t.onexpandedchange(ku(t.expandedIds,e))}function p(e,n,r){let{node:i,parentId:o}=n;switch(e.key){case`ArrowUp`:e.preventDefault(),u(r,r-1);break;case`ArrowDown`:e.preventDefault(),u(r,r+1);break;case`ArrowRight`:if(!s(i))return;e.preventDefault(),t.expandedIds.has(i.id)?G(a)[r+1]?.parentId===i.id&&u(r,r+1):f(i);break;case`ArrowLeft`:if(!t.expandedIds.has(i.id)&&!o)return;e.preventDefault(),s(i)&&t.expandedIds.has(i.id)?f(i):o&&l(o);break;case`Home`:e.preventDefault(),u(r,0);break;case`End`:e.preventDefault(),u(r,G(a).length-1);break;case`Enter`:case` `:e.preventDefault(),d(i);break}}var m=zu();Z(m,23,()=>G(a),e=>e.node.id,(e,a,l)=>{let u=L(()=>G(a).node),m=L(()=>s(G(u)));var h=Ru();let g;var _=V(h),v=e=>{var n=Fu(),r=V(n),i=V(r,!0);F(r),F(n),W((e,t)=>{Q(n,`aria-label`,e),Y(i,t)},[()=>`${t.expandedIds.has(G(u).id)?`Collapse`:`Expand`} ${G(u).name}`,()=>t.expandedIds.has(G(u).id)?`−`:`+`]),K(`click`,n,()=>f(G(u))),J(e,n)},y=e=>{J(e,Iu())};X(_,e=>{G(m)?e(v):e(y,-1)});var b=U(_,2);let x;var S=V(b),C=V(S,!0);F(S);var w=U(S,2),T=V(w),E=V(T,!0);F(T);var D=U(T,2),ee=V(D,!0);F(D),F(w);var O=U(w,2),te=e=>{J(e,Lu())};X(O,e=>{G(u).isGitRepository&&e(te)}),F(b),Ui(b,(e,t)=>i[t.id]=e,e=>i?.[e.id],()=>[G(u)]),F(h),W((e,n,r,i,s)=>{g=wi(h,``,g,e),x=Si(b,1,`tree-item svelte-6z3q4v`,null,x,{selected:t.selectedId===G(u).id,repository:G(u).isGitRepository}),Q(b,`aria-level`,G(a).level),Q(b,`aria-expanded`,n),Q(b,`aria-selected`,t.selectedId===G(u).id),Q(b,`aria-disabled`,r),Q(b,`tabindex`,G(o)===G(u).id?0:-1),Q(b,`title`,i),Y(C,t.selectedId===G(u).id?`✓`:``),Y(E,G(u).name),Y(ee,s)},[()=>({"--tree-level":Math.min(G(a).level-1,6)}),()=>G(m)?t.expandedIds.has(G(u).id):void 0,()=>!n()(G(u)),()=>c(G(u).relativePath),()=>c(G(u).relativePath)]),Lr(`focus`,b,()=>B(r,G(u).id,!0)),K(`keydown`,b,e=>p(e,G(a),G(l))),K(`click`,b,()=>d(G(u))),J(e,h)}),F(m),W(()=>Q(m,`aria-label`,t.label)),J(e,m),$e()}Rr([`click`,`keydown`]);var Vu=q(`<section class="evidence-shell svelte-1d6w4ti" aria-labelledby="evidence-title"><p class="eyebrow svelte-1d6w4ti"> </p> <h1 id="evidence-title" class="svelte-1d6w4ti"> </h1> <p class="instructions svelte-1d6w4ti"> </p> <!></section>`);function Hu(e,t){Qe(t,!0);let n=(e,t)=>({id:e,name:t,relativePath:e,isGitRepository:!0,children:[]}),r=[{id:`.`,name:`development-workspace-with-a-long-name`,relativePath:`.`,isGitRepository:!1,children:[{id:`dyne`,name:`dyne`,relativePath:`dyne`,isGitRepository:!1,children:[{id:`dyne/mobile-applications`,name:`mobile-applications-and-experiments`,relativePath:`dyne/mobile-applications`,isGitRepository:!1,children:[n(`dyne/mobile-applications/gestalt-mobile`,`gestalt-mobile-with-an-extraordinarily-long-repository-name`)]},n(`dyne/zenroom`,`zenroom`),n(`dyne/zenflows`,`zenflows`),n(`dyne/did`,`did-toolkit`),n(`dyne/api`,`api-gateway`),n(`dyne/docs`,`documentation-portal`)]},{id:`personal`,name:`personal-projects`,relativePath:`personal`,isGitRepository:!1,children:[]}]}],i=z(on(new Set([`.`,`dyne`,`dyne/mobile-applications`]))),a=z(null),o=L(()=>t.context===`sessions`?`dyne/mobile-applications`:`dyne/mobile-applications/gestalt-mobile`),s=L(()=>G(a)??G(o));var c=Vu(),l=V(c),u=V(l,!0);F(l);var d=U(l,2),f=V(d,!0);F(d);var p=U(d,2),m=V(p,!0);F(p);var h=U(p,2);{let e=L(()=>t.context===`sessions`?`Session base`:`Git repository`),n=L(()=>t.context===`sessions`?Du.sessionBase:Du.gitRepositoryTarget);Bu(h,{get roots(){return r},get expandedIds(){return G(i)},get selectedId(){return G(s)},get label(){return G(e)},get isSelectable(){return G(n)},onexpandedchange:e=>B(i,e,!0),onselect:e=>B(a,e.id,!0)})}F(c),W(()=>{Y(u,t.context===`sessions`?`Sessions`:`Git`),Y(f,t.context===`sessions`?`Session base`:`Git repository`),Y(m,t.context===`sessions`?`Select the folder Codex should use as its working directory.`:`Select a repository for Git actions.`)}),J(e,c),$e()}function Uu(e,t=Date.now()){if(!e)return`Not fetched yet`;let n=Math.max(0,t-new Date(e).getTime()),r=Math.floor(n/6e4);if(r<1)return`Fetched just now`;if(r<60)return`Fetched ${r}m ago`;let i=Math.floor(r/60);return i<24?`Fetched ${i}h ago`:`Fetched ${Math.floor(i/24)}d ago`}function Wu(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown time`;let r=Math.round((n-t)/1e3),i=[[`year`,31536e3],[`month`,2592e3],[`week`,604800],[`day`,86400],[`hour`,3600],[`minute`,60],[`second`,1]],[a,o]=i.find(([,e])=>Math.abs(r)>=e)??i.at(-1);return new Intl.RelativeTimeFormat(void 0,{numeric:`auto`}).format(Math.round(r/o),a)}var Gu=q(`<p class="clone-status svelte-pudr3t" role="status"> </p>`),Ku=q(`<option> </option>`),qu=q(`<section aria-label="Confirm push"><p> </p> <button type="button">Confirm push</button> <button type="button">Cancel</button></section>`),Ju=q(`<li class="commit-entry svelte-pudr3t"><div class="commit-subject svelte-pudr3t"><code class="svelte-pudr3t"> </code><span> </span></div> <div class="commit-meta svelte-pudr3t"><span> </span><time class="svelte-pudr3t"> </time></div></li>`),Yu=q(`<section class="commit-history svelte-pudr3t" aria-labelledby="recent-commits-title"><h3 id="recent-commits-title" class="svelte-pudr3t">Recent commits</h3> <ol class="commit-list svelte-pudr3t" aria-label="Recent commits"></ol></section>`),Xu=q(`<div class="git-overview svelte-pudr3t"><div class="git-status svelte-pudr3t"><label for="git-branch">Branch</label> <select id="git-branch"></select> <p class="svelte-pudr3t"> </p> <p class="svelte-pudr3t"> </p> <p class="svelte-pudr3t"><time> </time></p> <p class="svelte-pudr3t"> </p></div> <div class="git-actions svelte-pudr3t"><button type="button" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" class="svelte-pudr3t"><span aria-hidden="true">↓</span> </button></div></div> <!> <!>`,1),Zu=q(`<p>This workspace is not a Git repository.</p>`),Qu=q(`<p role="status">Loading repository status…</p>`),$u=q(`<p><strong> </strong> is available as a Clone destination. Select a Git repository
|
|
21
|
+
to inspect branches and enable repository actions.</p> <div class="git-actions svelte-pudr3t" aria-label="Repository actions unavailable"><button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↓</span> Pull</button></div>`,1),ed=q(`<p>Select a folder above to choose a Clone destination or inspect a Git repository.</p> <div class="git-actions svelte-pudr3t" aria-label="Repository actions unavailable"><button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↓</span> Pull</button></div>`,1),td=q(`<p role="alert"> </p>`),nd=q(`<section class="git-view svelte-pudr3t" aria-labelledby="git-title"><h2 id="git-title" class="visually-hidden">Git</h2> <section class="git-tree svelte-pudr3t" aria-labelledby="git-tree-title"><div class="section-heading svelte-pudr3t"><h3 id="git-tree-title" class="svelte-pudr3t">Repository and clone destination</h3> <p class="svelte-pudr3t">Select any folder. Git repositories enable repository actions; other folders are clone
|
|
22
|
+
destinations.</p></div> <!> <button id="browse-files" type="button">Browse files</button></section> <form class="clone-form svelte-pudr3t"><div class="clone-controls svelte-pudr3t"><div class="clone-field clone-destination svelte-pudr3t"><span class="field-label svelte-pudr3t">Destination</span> <output aria-live="polite" class="svelte-pudr3t"> </output></div> <div class="clone-field svelte-pudr3t"><label for="git-clone-address">Git address</label> <input id="git-clone-address" name="address" required="" autocomplete="url" inputmode="url" enterkeyhint="done" placeholder="https://example.com/owner/repository.git" aria-describedby="clone-help"/></div> <button type="submit" class="svelte-pudr3t"> </button></div> <p id="clone-help" class="svelte-pudr3t">The repository is cloned inside the selected workspace.</p> <!></form> <section class="repository-details svelte-pudr3t" aria-labelledby="repository-details-title"><h3 id="repository-details-title" class="svelte-pudr3t">Repository details</h3> <!> <!></section></section>`);function rd(e,t){Qe(t,!0);let n=z(``),r=L(()=>t.selectedWorkspace&&!t.selectedWorkspace.isGitRepository?t.selectedWorkspace:null);function i(e){e.preventDefault(),!(!G(n).trim()||t.cloning)&&t.onclone(G(n).trim())}var a=nd(),o=U(V(a),2),s=U(V(o),2);{let e=L(()=>t.selectedWorkspace?.id??null);Bu(s,{get roots(){return t.workspaceTree},get expandedIds(){return t.expandedIds},get selectedId(){return G(e)},label:`Git repository and clone destination`,get onexpandedchange(){return t.onexpandedchange},get onselect(){return t.onselect}})}var c=U(s,2);F(o);var l=U(o,2),u=V(l),d=V(u),f=U(V(d),2),p=V(f,!0);F(f),F(d);var m=U(d,2),h=U(V(m),2);Ni(h),F(m);var g=U(m,2),_=V(g,!0);F(g),F(u);var v=U(u,4),y=e=>{var n=Gu(),r=V(n,!0);F(n),W(()=>Y(r,t.cloneStatus)),J(e,n)};X(v,e=>{t.cloneStatus&&e(y)}),F(l);var b=U(l,2),x=U(V(b),2),S=e=>{var n=Kr(),r=H(n),i=e=>{var n=Kr(),r=H(n),i=e=>{var n=Xu(),r=H(n),i=V(r),a=U(V(i),2);Z(a,20,()=>t.summary.branches??[],e=>e,(e,t)=>{var n=Ku(),r=V(n,!0);F(n);var i={};W(()=>{Y(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),J(e,n)}),F(a);var o;Ei(a);var s=U(a,2),c=V(s);F(s);var l=U(s,2),u=V(l);F(l);var d=U(l,2),f=V(d),p=V(f,!0);F(f),F(d);var m=U(d,2),h=V(m);F(m),F(i);var g=U(i,2),_=V(g),v=U(_,2),y=U(V(v));F(v),F(g),F(r);var b=U(r,2),x=e=>{var n=qu(),r=V(n),i=V(r);F(r);var a=U(r,2),o=U(a,2);F(n),W(()=>Y(i,`Push HEAD to ${t.summary.upstream??``}?`)),K(`click`,a,function(...e){t.onpush?.apply(this,e)}),K(`click`,o,function(...e){t.oncancelpush?.apply(this,e)}),J(e,n)};X(b,e=>{t.confirmingPush&&e(x)});var S=U(b,2),C=e=>{var n=Yu(),r=U(V(n),2);Z(r,21,()=>t.summary.commits,e=>e.hash,(e,t)=>{var n=Ju(),r=V(n),i=V(r),a=V(i,!0);F(i);var o=U(i),s=V(o,!0);F(o),F(r);var c=U(r,2),l=V(c),u=V(l,!0);F(l);var d=U(l),f=V(d,!0);F(d),F(c),F(n),W(e=>{Q(i,`title`,G(t).hash),Y(a,G(t).shortHash),Y(s,G(t).subject),Y(u,G(t).author),Q(d,`datetime`,G(t).authoredAt),Q(d,`title`,G(t).authoredAt),Y(f,e)},[()=>Wu(G(t).authoredAt)]),J(e,n)}),F(r),F(n),J(e,n)};X(S,e=>{t.summary.commits.length&&e(C)}),W(e=>{a.disabled=t.refreshing||t.checkingOut||!t.summary.branches?.length,o!==(o=t.summary.branch??``)&&(a.value=(a.__value=t.summary.branch??``)??``,Ti(a,t.summary.branch??``)),Y(c,`Upstream: ${t.summary.upstream??`none`??``}`),Y(u,`Ahead ${t.summary.ahead??``}; behind ${t.summary.behind??``}.`),Q(f,`datetime`,t.summary.fetchedAt??void 0),Y(p,e),Y(h,`Changes: ${t.summary.dirty.staged??``} staged, ${t.summary.dirty.unstaged??``} unstaged, ${t.summary.dirty.untracked??``} untracked.`),_.disabled=t.refreshing||t.checkingOut||!t.summary.upstream||t.summary.ahead<1||t.summary.behind>0,v.disabled=t.refreshing||t.checkingOut,Y(y,` ${t.refreshing?`Pulling…`:`Pull`}`)},[()=>Uu(t.summary.fetchedAt)]),K(`change`,a,e=>t.oncheckout(e.currentTarget.value)),K(`click`,_,function(...e){t.onopenpushconfirmation?.apply(this,e)}),K(`click`,v,function(...e){t.onpull?.apply(this,e)}),J(e,n)},a=e=>{J(e,Zu())};X(r,e=>{t.summary.available?e(i):e(a,-1)}),J(e,n)},a=e=>{J(e,Qu())};X(r,e=>{t.summary?e(i):t.error||e(a,1)}),J(e,n)},C=e=>{var n=$u(),r=H(n),i=V(r),a=V(i,!0);F(i),He(),F(r),He(2),W(()=>Y(a,t.selectedWorkspace.name)),J(e,n)},w=e=>{var t=ed();He(2),J(e,t)};X(x,e=>{t.selectedWorkspace?.isGitRepository?e(S):t.selectedWorkspace?e(C,1):e(w,-1)});var T=U(x,2),E=e=>{var n=td(),r=V(n,!0);F(n),W(()=>Y(r,t.error)),J(e,n)};X(T,e=>{t.error&&e(E)}),F(b),F(a),W(()=>{c.disabled=!t.selectedWorkspace,Y(p,G(r)?`~/${G(r).relativePath}`:`Select a non-repository folder`),g.disabled=t.cloning,Y(_,t.cloning?`Cloning…`:`Clone`)}),K(`click`,c,e=>t.onbrowsefiles(e.currentTarget)),Lr(`submit`,l,i),zi(h,()=>G(n),e=>B(n,e)),J(e,a),$e()}Rr([`click`,`change`]);var id=class{transport;isRepository;onChange;errorMessage;#e={workspaceId:null,summary:null,loading:!1,refreshing:!1,checkingOut:!1,error:null};#t=0;#n=null;#r=!1;constructor(e,t,n,r){this.transport=e,this.isRepository=t,this.onChange=n,this.errorMessage=r}get state(){return this.#e}select(e){this.#a();let t=e,n=!!(t&&this.isRepository(t));this.#s({workspaceId:t,summary:null,loading:n,refreshing:!1,checkingOut:!1,error:null}),n&&this.refresh()}async refresh(){let e=this.#e.workspaceId;if(!e||!this.isRepository(e))return;let t=this.#i(),n=this.#t;this.#s({...this.#e,loading:!0,error:null});try{let r=await this.transport.getSummary(e,t.signal);this.#o(n,e,t)&&this.#s({...this.#e,summary:r,loading:!1})}catch(r){this.#o(n,e,t)&&!t.signal.aborted&&this.#s({...this.#e,summary:null,loading:!1,error:this.errorMessage(r,`GIT_SUMMARY_FAILED`)})}}async pull(e){let t=this.#e.workspaceId;if(!t||this.#e.refreshing)return;let n=this.#i(),r=this.#t;this.#s({...this.#e,refreshing:!0,error:null});try{await this.transport.pull(t,e,n.signal),this.#o(r,t,n)&&(this.#s({...this.#e,refreshing:!1}),await this.refresh())}catch(e){this.#o(r,t,n)&&!n.signal.aborted&&this.#s({...this.#e,refreshing:!1,error:this.errorMessage(e,`GIT_PULL_FAILED`)})}}async checkout(e){let t=this.#e.workspaceId;if(!t||this.#e.checkingOut||e===this.#e.summary?.branch)return;let n=this.#i(),r=this.#t;this.#s({...this.#e,checkingOut:!0,error:null});try{await this.transport.checkout(t,e,n.signal),this.#o(r,t,n)&&(this.#s({...this.#e,checkingOut:!1}),await this.refresh())}catch(e){this.#o(r,t,n)&&!n.signal.aborted&&this.#s({...this.#e,checkingOut:!1,error:this.errorMessage(e,`GIT_CHECKOUT_FAILED`)})}}dispose(){this.#r=!0,this.#a()}#i(){return this.#a(),this.#n=new AbortController,++this.#t,this.#n}#a(){this.#n?.abort(),this.#n=null,++this.#t}#o(e,t,n){return!this.#r&&e===this.#t&&this.#e.workspaceId===t&&this.#n===n}#s(e){this.#r||(this.#e=e,this.onChange(e))}};function ad(e,t,n,r,i){let a=new Set(od(e).filter(e=>e.isGitRepository).map(e=>e.id)),o=Mu(t,n),s=o?od(o.children).filter(e=>e.isGitRepository&&!a.has(e.id)):[],c=sd(r),l=s.find(e=>e.name===c)??(s.length===1?s[0]:void 0),u=l?.id??o?.id??null,d=new Set(i);return u&&ju(t,u).forEach(e=>d.add(e)),!l&&o&&d.add(o.id),{selectedId:u,expandedIds:d}}function od(e){let t=[],n=e=>{t.push(e),e.children.forEach(n)};return e.forEach(n),t}function sd(e){return(e.trim().replace(/[?#].*$/,``).replace(/\/+$/,``).split(/[/:]/).at(-1)??``).replace(/\.git$/i,``)}function cd(e){if(typeof e!=`object`||!e)return null;let t=e.permissions;if(typeof t!=`object`||!t)return null;let n=t;return{permissions:{...n.network===null||n.network===void 0?{}:{network:n.network},...n.fileSystem===null||n.fileSystem===void 0?{}:{fileSystem:n.fileSystem}},scope:`turn`}}function ld(e){return{answers:Object.fromEntries(e.filter(e=>e.answer.trim()).map(e=>[e.id,{answers:[e.answer]}]))}}function ud(e){return[`Submitted quiz answers:`,...e.map(e=>`- ${e.header} — ${e.question}\n ${e.answer.trim().replaceAll(`
|
|
23
|
+
`,`
|
|
24
|
+
`)}`)].join(`
|
|
25
|
+
`)}function dd(e=fetch){async function t(e){let t=await e.json().catch(()=>null),n=typeof t?.code==`string`&&/^[A-Z0-9_]+$/.test(t.code)?t.code:void 0,r=n?.startsWith(`AUTOPILOT_`)&&e.status===409?`Relay request failed (${e.status}).`:typeof t?.detail==`string`&&t.detail.length<=600?t.detail:typeof t?.title==`string`?t.title:`Relay request failed (${e.status}).`;return Object.assign(Error(r),{...n?{code:n}:{},...typeof t?.replaceAllowed==`boolean`?{replaceAllowed:t.replaceAllowed}:{},status:e.status})}async function n(n,r,i={},a){let o=await e(n,{method:`POST`,headers:{"content-type":`application/json`,...i},body:JSON.stringify(r),signal:a});if(!o.ok)throw await t(o);return o.json()}async function r(n,r,i={}){let a=await e(n,{method:`PUT`,headers:{"content-type":`application/json`,...i},body:JSON.stringify(r)});if(!a.ok)throw await t(a);return a.json()}async function i(n,r,i,a){let o=await e(n,{method:`PUT`,headers:{"content-type":`application/octet-stream`,"idempotency-key":i},body:r,signal:a});if(!o.ok)throw await t(o);return o.json()}async function a(n,r,i){let a=await e(n,{method:`DELETE`,headers:{"content-type":`application/json`,"idempotency-key":i},body:JSON.stringify(r)});if(!a.ok)throw await t(a);return a.json()}async function o(n){let r=await e(n,{method:`DELETE`});if(!r.ok)throw await t(r)}async function s(n,r){let i=await e(n,r?{signal:r}:void 0);if(!i.ok)throw await t(i);return i.json()}async function c(n,r){let i=await e(n,{signal:r});if(i.status===204)return null;if(!i.ok)throw await t(i);return i.json()}return{debugConfirmation:e=>s(`/api/sessions/${encodeURIComponent(e)}/debug`),startSelfDebug:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/debug`,{confirmationId:t}),readDebugTrace:(e,t)=>s(`/api/sessions/${encodeURIComponent(e)}/debug/trace`,t),quit:()=>n(`/api/maintenance/quit`,{}),listSessions:e=>s(`/api/sessions`,e),checkWorkspaceFileReferences:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/references`,{paths:t},{},r),getWorkspaceFilePreview:(e,t,n)=>s(`/api/workspaces/${encodeURIComponent(e)}/files/preview?${new URLSearchParams({path:t})}`,n),listWorkspaceDirectory:(e,t={},n)=>{let r=new URLSearchParams;t.directory!==void 0&&r.set(`directory`,t.directory),t.cursor!==void 0&&r.set(`cursor`,t.cursor),t.limit!==void 0&&r.set(`limit`,String(t.limit));let i=r.size===0?``:`?${r}`;return s(`/api/workspaces/${encodeURIComponent(e)}/files${i}`,n)},copyWorkspaceEntry:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/copy`,t,{"idempotency-key":r}),moveWorkspaceEntry:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/move`,t,{"idempotency-key":r}),uploadWorkspaceFile:(e,t,n,r)=>{let a=new URLSearchParams({directory:t.directory,filename:t.filename,conflict:t.conflict});return i(`/api/workspaces/${encodeURIComponent(e)}/files/upload?${a}`,t.file,n,r)},deleteWorkspaceEntry:(e,t,n)=>a(`/api/workspaces/${encodeURIComponent(e)}/files`,{path:t,recursive:!0},n),getSession:e=>s(`/api/sessions/${encodeURIComponent(e)}`),refreshActivity:e=>n(`/api/sessions/${encodeURIComponent(e)}/activity/refresh`,{}),setAutopilot:(e,t,n)=>r(`/api/sessions/${encodeURIComponent(e)}/autopilot`,{enabled:t},n?{"idempotency-key":n}:{}),resolveAttention:(e,t,r)=>n(`/api/sessions/${encodeURIComponent(e)}/attention/${encodeURIComponent(t)}/resolve`,r),listRecentSessions:()=>s(`/api/sessions/recent-threads`),openRecentSession:(e,t,r=`codex`)=>n(`/api/sessions/recent-threads/open`,{threadId:e,cwd:t,provider:r}),listSessionModels:e=>n(`/api/session-models/${encodeURIComponent(e)}`,{}),startSession:(e,t={},r)=>n(`/api/sessions`,{workspaceId:e,profile:`default`,provider:`codex`,...t},r?{"idempotency-key":r}:{}),startTurn:(e,t,r)=>n(`/api/sessions/${encodeURIComponent(e)}/turns`,{text:t},r?{"idempotency-key":r}:{}),selectModel:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/model`,{model:t}),interruptTurn:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/turns/${encodeURIComponent(t)}/interrupt`,{}),queueTurnInput:(e,t,r,i)=>n(`/api/sessions/${encodeURIComponent(e)}/turns/${encodeURIComponent(t)}/queue`,{text:r},i?{"idempotency-key":i}:{}),restoreSession:e=>n(`/api/sessions/${encodeURIComponent(e)}/restore`,{}),releaseSession:e=>n(`/api/sessions/${encodeURIComponent(e)}/release`,{}),forgetSession:n=>e(`/api/sessions/${encodeURIComponent(n)}`,{method:`DELETE`}).then(async e=>{if(!e.ok)throw await t(e)}),getHistory:e=>s(`/api/sessions/${encodeURIComponent(e)}/history`),getPlan:(e,t)=>c(`/api/sessions/${encodeURIComponent(e)}/plan`,t),closePlan:e=>o(`/api/sessions/${encodeURIComponent(e)}/plan`),listWorkspacePlans:(e,t)=>s(`/api/workspaces/${encodeURIComponent(e)}/plans`,t),archiveWorkspacePlan:(e,t)=>n(`/api/workspaces/${encodeURIComponent(e)}/plans/${encodeURIComponent(t)}/archive`,{}),getWorkspacePlan:(e,t,n)=>s(`/api/workspaces/${encodeURIComponent(e)}/plans/${encodeURIComponent(t)}`,n),openSessionPlan:(e,t)=>r(`/api/sessions/${encodeURIComponent(e)}/plan`,{planName:t}),getGitSummary:(e,t)=>s(`/api/git/repositories/${encodeURIComponent(e)}`,t),cloneGitRepository:(e,t)=>n(`/api/git/clone`,{workspaceId:e,address:t}),refreshGit:(e,t)=>n(`/api/git/repositories/${encodeURIComponent(e)}/refresh`,{},t?{"idempotency-key":t}:{}),pullGit:(e,t,r)=>n(`/api/git/repositories/${encodeURIComponent(e)}/pull`,{},t?{"idempotency-key":t}:{},r),checkoutGitBranch:(e,t,r)=>n(`/api/git/repositories/${encodeURIComponent(e)}/checkout`,{branch:t},{},r),pushGit:(e,t)=>n(`/api/git/repositories/${encodeURIComponent(e)}/push`,{},t?{"idempotency-key":t}:{}),listAvailableSkills:(e,t,n=!1,r)=>s(`/api/skills?${new URLSearchParams({workspaceId:e,profile:t,...n?{refresh:`true`}:{}}).toString()}`,r),listSkillProfiles:e=>s(`/api/skill-profiles`,e),replaceSkillProfile:(e,t)=>r(`/api/skill-profiles/${encodeURIComponent(e)}`,t),deleteSkillProfile:e=>o(`/api/skill-profiles/${encodeURIComponent(e)}`),respondInteraction:(e,t,r,i)=>n(`/api/sessions/${encodeURIComponent(e)}/interactions/${encodeURIComponent(t)}`,r,i?{"idempotency-key":i}:{})}}var fd=[`authoring-start`,`work-start`,`checkpoint`,`update`,`supervision-start`,`resync`];function pd(e){return typeof e==`string`&&(fd.includes(e)||/^review:[A-Za-z0-9._-]{1,128}:REVIEWED$/.test(e)||/^l2:[A-Za-z0-9._-]{1,128}:(WIP|DONE)$/.test(e))}function md(e){if(!e||typeof e!=`object`)return!1;let t=e;return hd(t.plan)&&(t.reason===null||pd(t.reason))}function hd(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.title==`string`&&Array.isArray(t.steps)&&typeof t.totalSteps==`number`&&typeof t.doneSteps==`number`&&typeof t.allDone==`boolean`&&typeof t.currentStepId==`string`}function gd(e){return e instanceof Error?e.message:`Could not load the plan.`}function _d(e){return{...e,...e.skills?{skills:[...e.skills]}:{},description:{...e.description},children:e.children.map(_d)}}function vd(e){return{...e,steps:e.steps.map(_d)}}function yd(e,t){return e.kind===`unavailable`&&e.sessionId===t}function bd(e,t){let n=null,r={kind:`unavailable`,sessionId:null},i=0,a=0,o=null,s=0,c=e=>{++a,r=e,t(e)},l=(t,r)=>{o?.abort(),o=new AbortController;let a=++i,l=s;r||c({kind:`loading`,sessionId:t}),e.getPlan(t,o.signal).then(e=>{a!==i||n!==t||s===l&&c(e?{kind:`ready`,sessionId:t,plan:vd(e)}:{kind:`unavailable`,sessionId:t})}).catch(e=>{o?.signal.aborted||a!==i||n!==t||c({kind:`error`,sessionId:t,error:gd(e),...r?{plan:r}:{}})})};return{select(e){if(o?.abort(),n=e,s=0,!e){++i,c({kind:`unavailable`,sessionId:null});return}l(e,void 0)},refresh(e){if(n!==e)return;let t=r.kind===`ready`||r.kind===`closing`||r.kind===`error`?r.plan:void 0;l(e,t)},applyEvent(e,t){if(!(n!==e||t.sequence<=s)){if(t.type===`plan.updated`&&(hd(t.payload)||md(t.payload))){let n=md(t.payload)?t.payload.plan:t.payload;s=t.sequence,c({kind:`ready`,sessionId:e,plan:vd(n)})}t.type===`plan.closed`&&(s=t.sequence,c({kind:`unavailable`,sessionId:e}))}},async close(){if(r.kind!==`ready`&&r.kind!==`error`||!r.plan?.allDone)return null;let{sessionId:t,plan:i}=r;c({kind:`closing`,sessionId:t,plan:i});let o=a;try{return await e.closePlan(t),n===t?a===o?(c({kind:`unavailable`,sessionId:t}),`chat`):yd(r,t)?`chat`:null:null}catch(e){return n===t?a===o?(c({kind:`error`,sessionId:t,plan:i,error:gd(e)}),null):yd(r,t)?`chat`:null:null}},dispose(){o?.abort(),o=null,n=null,++i,c({kind:`unavailable`,sessionId:null})}}}function xd(e){if(!e)return null;let t=Sd(e.steps,e.currentStepId)?.measurement?.weeklyRemainingCurrent;return typeof t==`number`&&Number.isFinite(t)&&t>=0&&t<=100?Math.round(t):null}function Sd(e,t){for(let n of e){if(n.id===t)return n;let e=Sd(n.children,t);if(e)return e}}function Cd(e){let t=new Set,n=e=>{for(let n of e.matchAll(/=([^=\n]+)=/g)){let e=n[1].trim();e&&t.add(e)}};if(e?.kind===`org-source`)n(e.source);else if(e&&`plan`in e&&e.plan){let t=[...e.plan.steps];for(;t.length;){let e=t.pop();Object.values(e.description).forEach(e=>{e&&n(e)}),t.push(...e.children)}}return[...t]}var wd=q(`<a class="svelte-nywawl"><code class="svelte-nywawl"> </code></a>`),Td=q(`<code class="svelte-nywawl"> </code>`),Ed=q(`<span class="notes svelte-nywawl"></span>`);function Dd(e,t){Qe(t,!0);let n=$(t,`verifiedReferences`,19,()=>new Set),r=L(()=>t.text.split(/(=[^=\n]+=)/g));var i=Ed();Z(i,21,()=>G(r),ei,(e,r)=>{var i=Kr(),a=H(i),o=e=>{var i=Kr(),a=H(i),o=e=>{var n=wd(),i=V(n),a=V(i,!0);F(i),F(n),W((e,t)=>{Q(n,`href`,e),Y(a,t)},[()=>`#file-preview=${encodeURIComponent(G(r).slice(1,-1).trim())}`,()=>G(r).slice(1,-1)]),K(`click`,n,e=>{e.preventDefault(),t.onreference?.(G(r).slice(1,-1).trim())}),J(e,n)},s=L(()=>t.onreference&&n().has(G(r).slice(1,-1).trim())),c=e=>{var t=Td(),n=V(t,!0);F(t),W(e=>Y(n,e),[()=>G(r).slice(1,-1)]),J(e,t)};X(a,e=>{G(s)?e(o):e(c,-1)}),J(e,i)},s=L(()=>G(r).startsWith(`=`)&&G(r).endsWith(`=`)&&G(r).length>2),c=e=>{var t=Gr();W(()=>Y(t,G(r))),J(e,t)};X(a,e=>{G(s)?e(o):e(c,-1)}),J(e,i)}),F(i),J(e,i),$e()}Rr([`click`]);function Od(e,t){return t===void 0?`L${e}`:`L${e}.${t}`}function kd(e){let t=e.steps.filter(e=>e.reviewStatus===`REVIEWED`).length,n=e.steps.length,r=Ad(e),i=e.steps.find(e=>e.state===`DONE`&&e.reviewStatus===`UNREVIEWED`);return i?{phase:`awaiting review`,label:`Awaiting ${Od(e.steps.indexOf(i)+1)} review`,current:r,reviewedL1s:t,totalL1s:n}:n>0&&t===n?{phase:`terminal review`,label:`Terminal review`,current:r,reviewedL1s:t,totalL1s:n}:t>0&&!r?{phase:`milestone reported`,label:`Preparing milestone summary`,current:r,reviewedL1s:t,totalL1s:n}:r?{phase:`implementing`,label:`Implementing ${r.position} ${r.title}`,current:r,reviewedL1s:t,totalL1s:n}:{phase:e.allDone?`terminal review`:`implementing`,label:e.allDone?`Terminal review`:`Implementing`,current:r,reviewedL1s:t,totalL1s:n}}function Ad(e){for(let[t,n]of e.steps.entries()){if(n.id===e.currentStepId)return{id:n.id,position:Od(t+1),title:n.title,state:n.state};let r=n.children.findIndex(t=>t.id===e.currentStepId);if(r>=0){let e=n.children[r];return{id:e.id,position:Od(t+1,r+1),title:e.title,state:e.state}}}}var jd=q(`<span class="wip-effort svelte-hmxg46"> </span>`),Md=q(`<li class="svelte-hmxg46"><span class="wip-position svelte-hmxg46" aria-hidden="true"> </span> <span class="wip-title svelte-hmxg46"> </span> <!></li>`),Nd=q(`<ol class="wip-steps svelte-hmxg46" aria-label="Work in progress plan steps"></ol>`),Pd=q(`<li class="svelte-hmxg46"><span aria-hidden="true" class="position svelte-hmxg46"> </span> <span aria-hidden="true" class="state"> </span></li>`),Fd=q(`<ol class="step-markers svelte-hmxg46" aria-label="Plan step progress"></ol>`),Id=q(`<div><div class="progress-heading svelte-hmxg46"><span> </span> <span> </span></div> <progress class="svelte-hmxg46"> </progress> <span class="review-status"> </span> <!></div>`);function Ld(e,t){Qe(t,!0);let n=$(t,`compact`,3,!1),r=$(t,`label`,3,`Plan progress`),i=L(()=>t.plan.steps.flatMap((e,t)=>[{id:e.id,position:Od(t+1),state:e.state,level:e.level,title:e.title,...e.description.effort?{effort:e.description.effort}:{}},...e.children.map((e,n)=>({id:e.id,position:Od(t+1,n+1),state:e.state,level:e.level,title:e.title}))])),a=L(()=>G(i).filter(e=>e.state===`WIP`)),o=L(()=>kd(t.plan)),s=L(()=>Math.max(t.plan.totalSteps,1));var c=Id(),l=V(c),u=V(l),d=V(u);F(u);var f=U(u,2),p=V(f);F(f),F(l);var m=U(l,2),h=V(m);F(m);var g=U(m,2),_=V(g,!0);F(g);var v=U(g,2),y=e=>{var n=Nd();Z(n,21,()=>G(a),e=>e.id,(e,n)=>{var r=Md(),i=V(r),a=V(i);F(i);var o=U(i,2),s=V(o,!0);F(o);var c=U(o,2),l=e=>{var t=jd(),r=V(t);F(t),W(()=>Y(r,`Effort: ${G(n).effort??``}`)),J(e,t)};X(c,e=>{G(n).level===1&&G(n).effort&&e(l)}),F(r),W(()=>{Q(r,`aria-current`,G(n).id===t.plan.currentStepId?`step`:void 0),Q(r,`aria-label`,`${G(n).position}: ${G(n).title}, WIP${G(n).level===1&&G(n).effort?`, effort ${G(n).effort}`:``}`),Y(a,`${G(n).position??``} · WIP`),Y(s,G(n).title)}),J(e,r)}),F(n),J(e,n)},b=e=>{var n=Fd();Z(n,21,()=>G(i),e=>e.id,(e,n)=>{var r=Pd(),i=V(r),a=V(i,!0);F(i);var o=U(i,2),s=V(o,!0);F(o),F(r),W(()=>{Q(r,`data-state`,G(n).state),Q(r,`aria-current`,G(n).id===t.plan.currentStepId?`step`:void 0),Q(r,`aria-label`,`${G(n).position}: ${G(n).state}`),Y(a,G(n).position),Y(s,G(n).state)}),J(e,r)}),F(n),J(e,n)};X(v,e=>{n()&&G(a).length?e(y):!n()&&G(i).length&&e(b,1)}),F(c),W(()=>{Si(c,1,gi([`plan-progress`,{compact:n()}]),`svelte-hmxg46`),Y(d,`${t.plan.doneSteps??``} / ${t.plan.totalSteps??``} work items done`),Y(p,`· ${G(o).reviewedL1s??``} / ${G(o).totalL1s??``} reviewed`),Q(m,`aria-label`,r()),Pi(m,t.plan.doneSteps),Q(m,`max`,G(s)),Y(h,`${t.plan.doneSteps??``} of ${t.plan.totalSteps??``} work items done`),Q(g,`data-phase`,G(o).phase),Y(_,G(o).label)}),J(e,c),$e()}var Rd=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg">Loading plan…</p></section>`),zd=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg">No retained plan for this session.</p></section>`),Bd=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg"> </p></section>`),Vd=q(`<p class="svelte-3rmyvg"> </p>`),Hd=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Subtitle</dt> <dd class="svelte-3rmyvg"> </dd></div>`),Ud=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Date</dt> <dd class="svelte-3rmyvg"> </dd></div>`),Wd=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Keywords</dt> <dd class="svelte-3rmyvg"> </dd></div>`),Gd=q(`<dl class="metadata svelte-3rmyvg"><!> <!> <!></dl>`),Kd=q(`<p class="svelte-3rmyvg">No plan steps have been retained yet.</p>`),qd=q(`<p class="svelte-3rmyvg"><strong class="svelte-3rmyvg"> </strong> <!></p>`),Jd=q(`<p class="svelte-3rmyvg"><strong class="svelte-3rmyvg">Skills:</strong> </p>`),Yd=q(`<li class="svelte-3rmyvg"><details class="svelte-3rmyvg"><summary class="svelte-3rmyvg"><strong class="svelte-3rmyvg"><span class="position svelte-3rmyvg"> </span> </strong> <span class="svelte-3rmyvg"> </span> <span class="svelte-3rmyvg"> </span></summary> <!> <!></details></li>`),Xd=q(`<ol class="svelte-3rmyvg"></ol>`),Zd=q(`<li class="svelte-3rmyvg"><details class="svelte-3rmyvg"><summary class="svelte-3rmyvg"><strong class="svelte-3rmyvg"><span class="position svelte-3rmyvg"> </span> </strong> <span class="svelte-3rmyvg"> </span> <span class="svelte-3rmyvg"> </span> <span class="measurement svelte-3rmyvg"> </span></summary> <!> <!> <!></details></li>`),Qd=q(`<ol class="plan-steps svelte-3rmyvg"></ol>`),$d=q(`<section class="plan svelte-3rmyvg" aria-labelledby="plan-title"><header class="svelte-3rmyvg"><div class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg"> </h2></div> <button class="close svelte-3rmyvg" aria-label="Close plan and return to list">×</button></header> <!> <p class="svelte-3rmyvg"> </p> <!> <!> <!></section>`),ef=q(`<p class="visually-hidden svelte-3rmyvg" aria-live="polite" aria-atomic="true"> </p> <!>`,1);function tf(e,t){Qe(t,!0);let n={effort:`Effort`,goal:`Goal`,notes:`Notes`,why:`Why`,change:`Change`,tests:`Tests`,doneWhen:`Done when`},r=$(t,`verifiedReferences`,19,()=>new Set),i=z(on(new Set)),a=on({}),o=null,s=0,c=L(()=>t.state.kind===`ready`||t.state.kind===`closing`||t.state.kind===`error`?t.state.plan:void 0),l=L(()=>G(c)?m(G(c).steps,G(c).currentStepId):void 0),u=L(()=>G(c)?h(G(c).steps,G(c).currentStepId):void 0),d=L(()=>G(c)?kd(G(c)):void 0),f=L(()=>G(c)?g(G(c).steps,G(c).currentStepId):new Set),p=L(()=>t.state.kind===`loading`?`Loading plan.`:t.state.kind===`unavailable`?`No retained plan for this session.`:t.state.kind===`error`&&!G(c)?t.state.error:t.state.kind===`closing`?`Closing completed plan.`:G(c)?G(l)?`${G(d)?.label??`Current step: ${G(u)} ${G(l).title}`}. ${G(c).doneSteps} of ${G(c).totalSteps} work items done.${t.state.kind===`error`?` ${t.state.error}`:``}`:`${G(d)?.label??`Plan progress`}. ${G(c).doneSteps} of ${G(c).totalSteps} work items done.${t.state.kind===`error`?` ${t.state.error}`:``}`:``);Mn(()=>{let e=G(c)?.currentStepId||null;if(!e||o===e)return;let t=o===null;o=e;let n=++s;t||Tr().then(()=>{n!==s||G(c)?.currentStepId!==e||a[e]?.scrollIntoView({behavior:`auto`,block:`nearest`,inline:`nearest`})})});function m(e,t){for(let n of e){if(n.id===t)return n;let e=m(n.children,t);if(e)return e}}function h(e,t){for(let[n,r]of e.entries()){if(r.id===t)return Od(n+1);let e=r.children.findIndex(e=>e.id===t);if(e>=0)return Od(n+1,e+1)}}function g(e,t,n=[]){for(let r of e){if(r.id===t)return new Set([...n,r.id]);let e=g(r.children,t,[...n,r.id]);if(e.size)return e}return new Set}function _(e){return G(i).has(e)||G(f).has(e)}function v(e,t){B(i,t?new Set([...G(i),e]):new Set([...G(i)].filter(t=>t!==e)),!0)}function y(e){return e.description.goal??e.description.why??e.title}function b(e){let t=e.measurement;if(!t)return`Measurements unavailable`;let n=[];return t.elapsedSeconds!==void 0&&n.push(`${Math.floor(t.elapsedSeconds/60)}m ${t.elapsedSeconds%60}s elapsed`),t.weeklyPercentUsed!==void 0&&n.push(`${t.weeklyPercentUsed}% observed account-wide usage`),t.tokensUsed!==void 0&&n.push(`${t.tokensUsed.toLocaleString()} tokens used`),n.join(` · `)||`Measurements unavailable`}function x(e){return Object.keys(n).flatMap(t=>{let r=e.description[t];return r?[[n[t],r]]:[]})}var S=ef(),w=H(S),T=V(w,!0);F(w);var E=U(w,2),D=e=>{J(e,Rd())},ee=e=>{J(e,zd())},O=e=>{var n=Bd(),r=U(V(n),2),i=V(r,!0);F(r),F(n),W(()=>Y(i,t.state.error)),J(e,n)},te=e=>{var n=$d(),i=V(n),o=V(i),s=V(o),f=V(s,!0);F(s),F(o);var p=U(o,2);F(i);var m=U(i,2);Ld(m,{get plan(){return G(c)}});var h=U(m,2),g=V(h);F(h);var S=U(h,2),w=e=>{var n=Vd(),r=V(n,!0);F(n),W(()=>Y(r,t.state.error)),J(e,n)};X(S,e=>{t.state.kind===`error`&&e(w)});var T=U(S,2),E=e=>{var t=Gd(),n=V(t),r=e=>{var t=Hd(),n=U(V(t),2),r=V(n,!0);F(n),F(t),W(()=>Y(r,G(c).subtitle)),J(e,t)};X(n,e=>{G(c).subtitle&&e(r)});var i=U(n,2),a=e=>{var t=Ud(),n=U(V(t),2),r=V(n,!0);F(n),F(t),W(()=>Y(r,G(c).date)),J(e,t)};X(i,e=>{G(c).date&&e(a)});var o=U(i,2),s=e=>{var t=Wd(),n=U(V(t),2),r=V(n,!0);F(n),F(t),W(()=>Y(r,G(c).keywords)),J(e,t)};X(o,e=>{G(c).keywords&&e(s)}),F(t),J(e,t)};X(T,e=>{(G(c).subtitle||G(c).date||G(c).keywords)&&e(E)});var D=U(T,2),ee=e=>{J(e,Kd())},O=e=>{var n=Qd();Z(n,23,()=>G(c).steps,e=>e.id,(e,n,i)=>{var o=Zd(),s=V(o),c=V(s),l=V(c),u=V(l),d=V(u,!0);F(u);var f=U(u);F(l);var p=U(l,2),m=V(p);F(p);var h=U(p,2),g=V(h,!0);F(h);var S=U(h,2),w=V(S,!0);F(S),F(c);var T=U(c,2);Z(T,17,()=>x(G(n)),([e,t])=>e,(e,n)=>{var i=L(()=>C(G(n),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=qd(),c=V(s),l=V(c);F(c),Dd(U(c,2),{get text(){return o()},get onreference(){return t.onreference},get verifiedReferences(){return r()}}),F(s),W(()=>Y(l,`${a()??``}:`)),J(e,s)});var E=U(T,2),D=e=>{var t=Jd(),r=U(V(t));F(t),W(e=>Y(r,` ${e??``}`),[()=>G(n).skills.join(`, `)]),J(e,t)};X(E,e=>{G(n).skills?.length&&e(D)});var ee=U(E,2),O=e=>{var o=Xd();Z(o,23,()=>G(n).children,e=>e.id,(e,n,o)=>{var s=Yd(),c=V(s),l=V(c),u=V(l),d=V(u),f=V(d,!0);F(d);var p=U(d);F(u);var m=U(u,2),h=V(m);F(m);var g=U(m,2),b=V(g,!0);F(g),F(l);var S=U(l,2);Z(S,17,()=>x(G(n)),([e,t])=>e,(e,n)=>{var i=L(()=>C(G(n),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=qd(),c=V(s),l=V(c);F(c),Dd(U(c,2),{get text(){return o()},get onreference(){return t.onreference},get verifiedReferences(){return r()}}),F(s),W(()=>Y(l,`${a()??``}:`)),J(e,s)});var w=U(S,2),T=e=>{var t=Jd(),r=U(V(t));F(t),W(e=>Y(r,` ${e??``}`),[()=>G(n).skills.join(`, `)]),J(e,t)};X(w,e=>{G(n).skills?.length&&e(T)}),F(c),Ui(c,(e,t)=>a[t.id]=e,e=>a?.[e.id],()=>[G(n)]),F(s),W((e,t,r)=>{Q(c,`data-step-id`,G(n).id),c.open=e,Y(f,t),Y(p,` ${G(n).title??``}`),Y(h,`${G(n).state??``} · Priority ${G(n).priority??``}${G(n).reviewStatus?` · ${G(n).reviewStatus}`:``}`),Y(b,r)},[()=>_(G(n).id),()=>Od(G(i)+1,G(o)+1),()=>y(G(n))]),Lr(`toggle`,c,e=>v(G(n).id,e.currentTarget.open)),J(e,s)}),F(o),J(e,o)};X(ee,e=>{G(n).children.length&&e(O)}),F(s),Ui(s,(e,t)=>a[t.id]=e,e=>a?.[e.id],()=>[G(n)]),F(o),W((e,t,r,i)=>{Q(s,`data-step-id`,G(n).id),s.open=e,Y(d,t),Y(f,` ${G(n).title??``}`),Y(m,`${G(n).state??``} · Priority ${G(n).priority??``}${G(n).reviewStatus?` · ${G(n).reviewStatus}`:``}`),Y(g,r),Y(w,i)},[()=>_(G(n).id),()=>Od(G(i)+1),()=>y(G(n)),()=>b(G(n))]),Lr(`toggle`,s,e=>v(G(n).id,e.currentTarget.open)),J(e,o)}),F(n),J(e,n)};X(D,e=>{G(c).steps.length===0?e(ee):e(O,-1)}),F(n),W(()=>{Y(f,G(c).title),Y(g,`${G(d)?.label??``}. Current: ${G(l)?`${G(u)} ${G(l).title} (${G(l).state})`:`No current step`}`)}),K(`click`,p,function(...e){t.onclose?.apply(this,e)}),J(e,n)};X(E,e=>{t.state.kind===`loading`?e(D):t.state.kind===`unavailable`?e(ee,1):t.state.kind===`error`&&!G(c)?e(O,2):G(c)&&e(te,3)}),W(()=>Y(T,G(p))),J(e,S),$e()}Rr([`click`]);var nf=/^(\*+)\s+(?:(TODO|WIP|DONE)\s+)?(?:\[#([ABC])\]\s+)?(.+)$/,rf=/^#\+([A-Z][A-Z0-9_-]*):\s*(.*)$/i,af=/^:([A-Z][A-Z0-9_]*):\s*(.*)$/,of=/^-\s+([^:]+?)\s+::\s*(.*)$/;function sf(e){let t=[],n=[],r=[],i=e.replace(/\r\n?/g,`
|
|
26
|
+
`).split(`
|
|
27
|
+
`),a=null,o=!1,s=null,c=0,l=()=>{a&&r.push({...a,properties:[...a.properties],descriptions:[...a.descriptions],body:cf(a.body)})};for(let e of i){let r=nf.exec(e);if(r){l(),a={level:r[1].length,title:r[4].trim(),...r[2]?{state:r[2]}:{},...r[3]?{priority:r[3]}:{},properties:[],descriptions:[],body:[]},o=!1,s=null,c=0;continue}if(!a){let r=rf.exec(e);r?t.push([r[1].toUpperCase(),r[2].trim()]):n.push(e);continue}if(e===`:PROPERTIES:`){o=!0;continue}if(o&&e===`:END:`){o=!1,s=null,c=0;continue}if(o){let t=af.exec(e);t&&a.properties.push([t[1],t[2].trim()]);continue}let i=of.exec(e);if(i)a.descriptions.push([i[1].trim(),i[2].trim()]),s=a.descriptions.length-1,c=0;else if(s!==null&&/^[ \t]+\S/.test(e)){let[t,n]=a.descriptions[s];a.descriptions[s]=[t,`${n}${`
|
|
28
|
+
`.repeat(c+1)}${e.replace(/^(?: |\t)/,``)}`],c=0}else s!==null&&!e.trim()?c+=1:(s=null,c=0,a.body.push(e))}return l(),{metadata:t,preamble:cf(n),sections:r}}function cf(e){let t=[...e];for(;t[0]?.trim()===``;)t.shift();for(;t.at(-1)?.trim()===``;)t.pop();return t}var lf=q(`<div class="svelte-h7gaqo"><dt class="svelte-h7gaqo"> </dt> <dd class="svelte-h7gaqo"><!></dd></div>`),uf=q(`<dl class="metadata svelte-h7gaqo"></dl>`),df=q(`<p class="svelte-h7gaqo"><!></p>`),ff=q(`<p class="svelte-h7gaqo">This Org document has no headings.</p>`),pf=q(`<h3 class="svelte-h7gaqo"> </h3>`),mf=q(`<h4 class="svelte-h7gaqo"> </h4>`),hf=q(`<span> </span>`),gf=q(`<span class="priority svelte-h7gaqo"> </span>`),_f=q(`<dl class="descriptions svelte-h7gaqo"></dl>`),vf=q(`<p><!></p>`),yf=q(`<details class="properties svelte-h7gaqo"><summary class="svelte-h7gaqo">Properties</summary> <dl class="svelte-h7gaqo"></dl></details>`),bf=q(`<section class="org-section svelte-h7gaqo"><div class="section-heading svelte-h7gaqo"><!> <!> <!></div> <!> <!> <!></section>`),xf=q(`<div class="sections svelte-h7gaqo"></div>`),Sf=q(`<article class="org-document svelte-h7gaqo" aria-labelledby="org-document-title"><header class="svelte-h7gaqo"><div><h2 id="org-document-title" class="svelte-h7gaqo"> </h2> <code class="svelte-h7gaqo"> </code></div> <button class="close svelte-h7gaqo" type="button" aria-label="Close plan and return to list">×</button></header> <!> <!> <!></article>`);function Cf(e,t){Qe(t,!0);let n=$(t,`verifiedReferences`,19,()=>new Set),r=L(()=>sf(t.preview.source)),i=L(()=>G(r).metadata.filter(([e])=>e!==`TITLE`));var a=Sf(),o=V(a),s=V(o),c=V(s),l=V(c,!0);F(c);var u=U(c,2),d=V(u,!0);F(u),F(s);var f=U(s,2);F(o);var p=U(o,2),m=e=>{var r=uf();Z(r,21,()=>G(i),([e,t])=>`${e}:${t}`,(e,r)=>{var i=L(()=>C(G(r),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=lf(),c=V(s),l=V(c,!0);F(c);var u=U(c,2),d=V(u);{let e=L(()=>o()||`—`);Dd(d,{get text(){return G(e)},get onreference(){return t.onreference},get verifiedReferences(){return n()}})}F(u),F(s),W(()=>Y(l,a())),J(e,s)}),F(r),J(e,r)};X(p,e=>{G(i).length&&e(m)});var h=U(p,2);Z(h,19,()=>G(r).preamble,(e,t)=>`preamble:${t}:${e}`,(e,r)=>{var i=Kr(),a=H(i),o=e=>{var i=df();Dd(V(i),{get text(){return G(r)},get onreference(){return t.onreference},get verifiedReferences(){return n()}}),F(i),J(e,i)},s=L(()=>G(r).trim());X(a,e=>{G(s)&&e(o)}),J(e,i)});var g=U(h,2),_=e=>{J(e,ff())},v=e=>{var i=xf();Z(i,23,()=>G(r).sections,(e,t)=>`${t}:${e.level}:${e.title}`,(e,r)=>{var i=bf();let a;var o=V(i),s=V(o),c=e=>{var t=pf(),n=V(t,!0);F(t),W(()=>Y(n,G(r).title)),J(e,t)},l=e=>{var t=mf(),n=V(t,!0);F(t),W(()=>Y(n,G(r).title)),J(e,t)};X(s,e=>{G(r).level===1?e(c):e(l,-1)});var u=U(s,2),d=e=>{var t=hf(),n=V(t,!0);F(t),W(e=>{Si(t,1,e,`svelte-h7gaqo`),Y(n,G(r).state)},[()=>`state state-${G(r).state.toLowerCase()}`]),J(e,t)};X(u,e=>{G(r).state&&e(d)});var f=U(u,2),p=e=>{var t=gf(),n=V(t);F(t),W(()=>Y(n,`Priority ${G(r).priority??``}`)),J(e,t)};X(f,e=>{G(r).priority&&e(p)}),F(o);var m=U(o,2),h=e=>{var i=_f();Z(i,21,()=>G(r).descriptions,([e,t])=>`${e}:${t}`,(e,r)=>{var i=L(()=>C(G(r),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=lf(),c=V(s),l=V(c,!0);F(c);var u=U(c,2),d=V(u);{let e=L(()=>o()||`—`);Dd(d,{get text(){return G(e)},get onreference(){return t.onreference},get verifiedReferences(){return n()}})}F(u),F(s),W(()=>Y(l,a())),J(e,s)}),F(i),J(e,i)};X(m,e=>{G(r).descriptions.length&&e(h)});var g=U(m,2);Z(g,19,()=>G(r).body,(e,t)=>`${t}:${e}`,(e,r)=>{var i=Kr(),a=H(i),o=e=>{var i=vf();let a;Dd(V(i),{get text(){return G(r)},get onreference(){return t.onreference},get verifiedReferences(){return n()}}),F(i),W(e=>a=Si(i,1,`svelte-h7gaqo`,null,a,e),[()=>({"list-item":G(r).trimStart().startsWith(`- `)})]),J(e,i)},s=L(()=>G(r).trim());X(a,e=>{G(s)&&e(o)}),J(e,i)});var _=U(g,2),v=e=>{var i=yf(),a=U(V(i),2);Z(a,21,()=>G(r).properties,([e,t])=>`${e}:${t}`,(e,r)=>{var i=L(()=>C(G(r),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=lf(),c=V(s),l=V(c,!0);F(c);var u=U(c,2),d=V(u);{let e=L(()=>o()||`—`);Dd(d,{get text(){return G(e)},get onreference(){return t.onreference},get verifiedReferences(){return n()}})}F(u),F(s),W(()=>Y(l,a())),J(e,s)}),F(a),F(i),J(e,i)};X(_,e=>{G(r).properties.length&&e(v)}),F(i),W(e=>a=wi(i,``,a,e),[()=>({"--org-depth":Math.max(0,G(r).level-1)})]),J(e,i)}),F(i),J(e,i)};X(g,e=>{G(r).sections.length===0?e(_):e(v,-1)}),F(a),W(()=>{Y(l,t.preview.title),Y(d,t.preview.planName)}),K(`click`,f,function(...e){t.onclose?.apply(this,e)}),J(e,a),$e()}Rr([`click`]);var wf=q(`<span> </span>`),Tf=q(`<span class="subtitle svelte-x2ko9l"> </span>`),Ef=q(`<div class="catalog-progress svelte-x2ko9l"><progress class="svelte-x2ko9l"> </progress> <span class="svelte-x2ko9l"> </span></div> <!>`,1),Df=q(`<span class="subtitle svelte-x2ko9l">Org document</span>`),Of=q(`<span class="archive-tag svelte-x2ko9l">Archived</span>`),kf=q(`<li class="plan-row svelte-x2ko9l"><div class="plan-details svelte-x2ko9l"><strong> </strong> <div class="plan-path svelte-x2ko9l"><!> <span> </span></div> <!> <!></div> <div class="plan-actions svelte-x2ko9l"><!> <!></div></li>`),Af=q(`<p>Waiting for the application workspace…</p>`),jf=q(`<p>Finding Org plans…</p>`),Mf=q(`<p> </p>`),Nf=q(`<p>No .org files were found in .gestalt folders below the application workspace.</p>`),Pf=q(`<ul aria-label="Unfinished plans" class="svelte-x2ko9l"></ul>`),Ff=q(`<section class="completed svelte-x2ko9l" aria-labelledby="completed-plans-title"><h3 id="completed-plans-title" class="svelte-x2ko9l">Completed and archived</h3> <ul aria-label="Completed and archived plans" class="svelte-x2ko9l"></ul></section>`),If=q(`<p class="scope svelte-x2ko9l">Org plans in .gestalt folders below the application workspace.</p> <!> <!>`,1),Lf=q(`<section class="plans svelte-x2ko9l" aria-labelledby="plans-title"><div class="catalog-heading svelte-x2ko9l"><h2 id="plans-title" tabindex="-1" class="svelte-x2ko9l">ORG Plans</h2> <span role="status">(updating…)</span></div> <!></section>`);function Rf(e,t){Qe(t,!0);let n=(e,n=b)=>{let i=L(()=>n().planName.split(`/`)),a=L(()=>G(i).slice(0,-1)),s=L(()=>G(a).slice(0,2).filter((e,t)=>t===0||e!==`.gestalt`).join(`/`));var c=kf(),l=V(c),u=V(l),d=V(u,!0);F(u);var f=U(u,2),p=V(f),g=e=>{var t=wf(),n=V(t,!0);F(t),W(()=>Y(n,G(s))),J(e,t)};X(p,e=>{G(s)&&e(g)});var _=U(p,2),v=V(_,!0);F(_),F(f);var y=U(f,2),x=e=>{var t=Ef(),r=H(t),i=V(r),a=V(i);F(i);var o=U(i,2),s=V(o);F(o),F(r);var c=U(r,2),l=e=>{var t=Tf(),r=V(t,!0);F(t),W(()=>Y(r,n().subtitle)),J(e,t)};X(c,e=>{n().subtitle&&e(l)}),W(e=>{Q(i,`aria-label`,`Completion for ${n().title}`),Pi(i,n().doneSteps),Q(i,`max`,e),Y(a,`${n().doneSteps??``} of ${n().totalSteps??``} work items complete`),Y(s,`${n().doneSteps??``} / ${n().totalSteps??``}`)},[()=>Math.max(1,n().totalSteps)]),J(e,t)},S=e=>{J(e,Df())};X(y,e=>{n().previewAvailable!==!1&&n().totalSteps!==void 0&&n().doneSteps!==void 0?e(x):e(S,-1)});var C=U(y,2),w=e=>{J(e,Of())};X(C,e=>{n().archived&&e(w)}),F(l);var T=U(l,2),E=V(T);{let e=L(()=>`${n().allDone||n().archived?`Reopen`:`Open`} ${n().title}`);Va(E,{get label(){return G(e)},onclick:()=>m(n().planName),children:(e,t)=>{He();var r=Gr();W(()=>Y(r,n().allDone||n().archived?`Reopen`:`Open`)),J(e,r)},$$slots:{default:!0}})}var D=U(E,2),ee=e=>{{let i=L(()=>`Archive ${n().title}`),a=L(()=>!t.onarchive||n().archived||r().includes(n().planName));Va(e,{get label(){return G(i)},get disabled(){return G(a)},onclick:()=>h(n().planName),children:(e,t)=>{He();var i=Gr();W(e=>Y(i,e),[()=>r().includes(n().planName)?`Archiving…`:`Archive`]),J(e,i)},$$slots:{default:!0}})}};X(D,e=>{!n().allDone&&!n().archived&&e(ee)}),F(T),F(c),Ui(c,e=>o[n().planName]=e,()=>o?.[n().planName]),W(e=>{Q(c,`aria-label`,`${n().title} (${n().planName})`),Y(d,n().title),Q(f,`title`,n().planName),Y(v,e)},[()=>G(i).at(-1)]),J(e,c)},r=$(t,`archivingPlans`,19,()=>[]),i=z(on(new Set));Mn(()=>{let e=Cd(t.state),n=t.checkreferences,r=new AbortController;return B(i,new Set,!0),e.length&&n&&n(e,r.signal).then(e=>{r.signal.aborted||B(i,new Set(e),!0)}).catch(()=>{}),()=>r.abort()});let a=z(null),o=on({}),s=z(null),c=z(null),l=!1,u=!1,d=L(()=>t.catalog.kind===`ready`?t.catalog.entries.filter(e=>e.allDone!==!0&&!e.archived):[]),f=L(()=>t.catalog.kind===`ready`?t.catalog.entries.filter(e=>e.allDone===!0||e.archived):[]);function p(){t.onclose()}function m(e){B(c,e,!0),t.onopen(e)}function h(e){B(s,e,!0),t.onarchive?.(e)}Mn(()=>{let e=G(s);if(e&&t.catalog.kind===`ready`&&t.catalog.entries.some(t=>t.planName===e&&t.archived)&&queueMicrotask(()=>{o[e]?.querySelector(`button`)?.focus(),B(s,null)}),t.state){l=!0;return}if(l&&(l=!1,u=!0),!u)return;let n=t.catalog.kind,r=G(c);queueMicrotask(()=>{let e=r?o[r]?.querySelector(`button`):void 0;e?.isConnected?(e.focus(),u=!1):n!==`loading`&&(G(a)?.focus(),u=!1)})});var g=Kr(),_=H(g),v=e=>{Cf(e,{get preview(){return t.state},onclose:p,get onreference(){return t.onreference},get verifiedReferences(){return G(i)}})},y=e=>{tf(e,{get state(){return t.state},onclose:p,get onreference(){return t.onreference},get verifiedReferences(){return G(i)}})},x=e=>{var r=Lf(),i=V(r),o=V(i);Ui(o,e=>B(a,e),()=>G(a));var s=U(o,2);F(i);var c=U(i,2),l=e=>{J(e,Af())},u=e=>{J(e,jf())},p=e=>{var n=Mf(),r=V(n,!0);F(n),W(()=>Y(r,t.catalog.error)),J(e,n)},m=e=>{J(e,Nf())},h=e=>{var t=If(),r=U(H(t),2),i=e=>{var t=Pf();Z(t,21,()=>G(d),e=>e.planName,(e,t)=>{n(e,()=>G(t))}),F(t),J(e,t)};X(r,e=>{G(d).length>0&&e(i)});var a=U(r,2),o=e=>{var t=Ff(),r=U(V(t),2);Z(r,21,()=>G(f),e=>e.planName,(e,t)=>{n(e,()=>G(t))}),F(r),F(t),J(e,t)};X(a,e=>{G(f).length>0&&e(o)}),J(e,t)};X(c,e=>{t.catalog.kind===`no-workspace`?e(l):t.catalog.kind===`loading`?e(u,1):t.catalog.kind===`error`?e(p,2):t.catalog.entries.length===0?e(m,3):e(h,-1)}),F(r),W(()=>{Si(s,1,gi([`catalog-update`,{inactive:t.catalog.kind!==`ready`||!t.catalog.refreshing}]),`svelte-x2ko9l`),Q(s,`aria-hidden`,t.catalog.kind!==`ready`||!t.catalog.refreshing)}),J(e,r)};X(_,e=>{t.state?.kind===`org-source`?e(v):t.state?e(y,1):e(x,-1)}),J(e,g),$e()}var zf=`settings`,Bf=`drafts`,Vf=`cursors`,Hf=`selected-session`,Uf={text:``,revision:0},Wf=e=>{if(!e||typeof e!=`object`)return!1;let t=e,n=t.pending;return typeof t.text==`string`&&Number.isSafeInteger(t.revision)&&t.revision>=0&&(n===void 0||Array.isArray(n)&&n.every(e=>!!e&&typeof e.operationId==`string`&&typeof e.text==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0&&(e.kind===`send`||e.kind===`queue`||e.kind===`interrupt-send`)))};function Gf(e=globalThis.indexedDB){if(!e)return Kf;let t=il(e),n=new Map,r=new Map,i=async(e,i)=>{let a=r.get(e);if(a&&a.revision>i.revision)return;r.set(e,i);let o=(n.get(e)??Promise.resolve()).catch(()=>void 0).then(async()=>{if(r.get(e)===i)try{await ol(await t,Bf,e,i)}catch{}});n.set(e,o),await o};return{async readSelectedSession(){try{return await al(await t,zf,Hf)??null}catch{return null}},async saveSelectedSession(e){try{let n=await t;e?await ol(n,zf,Hf,e):await sl(n,zf,Hf)}catch{}},async readDraft(e){return(await this.readDraftEnvelope(e)).text},async saveDraft(e,t){let n=await this.readDraftEnvelope(e);await i(e,{text:t,revision:n.revision+1})},async readDraftEnvelope(e){try{let n=await al(await t,Bf,e),i=Wf(n)?n:typeof n==`string`?{text:n,revision:0}:Uf,a=r.get(e);return a&&a.revision>=i.revision?a:(r.set(e,i),i)}catch{return r.get(e)??Uf}},saveDraftEnvelope:i,replaceDraftText:async(e,t,n)=>{let a=r.get(e);await i(e,{text:t,revision:n,pending:a?.pending})},addPendingDraftOperation:async(e,t)=>{let n=r.get(e)??Uf;await i(e,{...n,pending:[...(n.pending??[]).filter(e=>e.operationId!==t.operationId),t].slice(-8)})},consumeAcceptedDraft:async(e,i,a)=>{let o=n.get(e)??Promise.resolve(),s=null,c=o.catch(()=>void 0).then(async()=>{let n=r.get(e);if(!n)try{let r=await al(await t,Bf,e);n=Wf(r)?r:typeof r==`string`?{text:r,revision:0}:Uf}catch{n=Uf}if(!(n.revision!==i||!n.pending?.some(e=>e.operationId===a))){s={text:``,revision:n.revision+1,pending:n.pending.filter(e=>e.operationId!==a)},r.set(e,s);try{await ol(await t,Bf,e,s)}catch{r.get(e)===s&&r.set(e,n),s=null}}});return n.set(e,c),await c,s},async readCursor(e){try{let n=await al(await t,Vf,e);return typeof n==`number`&&Number.isSafeInteger(n)&&n>=0?n:0}catch{return 0}},async saveCursor(e,n){try{await ol(await t,Vf,e,n)}catch{}}}}var Kf={readSelectedSession:async()=>null,saveSelectedSession:async()=>{},readDraft:async()=>``,saveDraft:async()=>{},readDraftEnvelope:async()=>Uf,saveDraftEnvelope:async()=>{},replaceDraftText:async()=>{},addPendingDraftOperation:async()=>{},consumeAcceptedDraft:async()=>null,readCursor:async()=>0,saveCursor:async()=>{}};function qf(e,t=Date.now()){if(e===null)return`Unknown activity time`;let n=Math.max(0,t-e),r=Math.floor(n/(3600*1e3));if(r<1)return`Less than an hour ago`;if(r<24)return`${r} hour${r===1?``:`s`} ago`;let i=Math.floor(r/24);return`${i} day${i===1?``:`s`} ago`}function Jf(e){let t=e.updatedAt?Date.parse(e.updatedAt):NaN;return{threadId:e.threadId??null,workspacePath:e.workspacePath??`Workspace unavailable`,updatedAt:Number.isFinite(t)?t:null}}function Yf(e,t){if(!t?.threadId||!t.workspacePath||!t.resumeCommand||e.some(e=>e.id===t.threadId&&(e.provider??`codex`)===(t.provider??`codex`)))return e;let n=t.updatedAt?Date.parse(t.updatedAt)/1e3:NaN,r={id:t.threadId,cwd:t.workspacePath,recencyAt:Number.isFinite(n)?n:null,resumeCommand:t.resumeCommand,...t.provider===void 0?{}:{provider:t.provider},...t.model===void 0?{}:{model:t.model},...t.effectiveSkillSelection?.selectedProfileName===void 0?{}:{skillProfile:t.effectiveSkillSelection.selectedProfileName},...t.lastOrgPlan===void 0?{}:{orgPlanFilename:t.lastOrgPlan.filename}};return[...e,r].sort((e,t)=>(t.recencyAt??-1/0)-(e.recencyAt??-1/0))}function Xf(e){let t=/^\/home\/[^/]+/.exec(e)?.[0];if(!t)return e;let n=e.slice(t.length);return n?`~${n}`:`~/`}var Zf=[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`],Qf=(e,t=b)=>{var n=np(),r=H(n),i=e=>{J(e,$f())};X(r,e=>{(t().plan||t().lastOrgPlan?.attached)&&e(i)});var a=U(r,2),o=e=>{var n=ep(),r=V(n),i=V(r,!0);F(r);var a=U(r,2),o=V(a,!0);F(a),F(n),W(()=>{Y(i,t().lastOrgPlan.title),Y(o,t().lastOrgPlan.filename)}),J(e,n)};X(a,e=>{t().lastOrgPlan&&e(o)});var s=U(a,2),c=e=>{var n=tp(),r=V(n);{let e=L(()=>`Plan progress for ${t().plan.title}`);Ld(r,{compact:!0,get plan(){return t().plan},get label(){return G(e)}})}F(n),J(e,n)};X(s,e=>{t().plan&&e(c)}),J(e,n)},$f=q(`<span class="profile-badge svelte-hxb22h">Org plan attached</span>`),ep=q(`<span class="org-plan-metadata svelte-hxb22h"><span class="org-plan-title svelte-hxb22h"> </span> <span class="org-plan-filename svelte-hxb22h"> </span></span>`),tp=q(`<div class="session-plan-progress svelte-hxb22h"><!></div>`),np=q(`<!> <!> <!>`,1),rp=q(`<details class="self-debug-details svelte-hxb22h"><summary class="svelte-hxb22h">Self DEBUG</summary> <!> <button type="button" class="svelte-hxb22h">Redacted diagnostic trace (JSON)</button></details>`),ip=q(`<details class="session-verdict svelte-hxb22h"><summary class="svelte-hxb22h"><span aria-hidden="true"></span> </summary> <p class="svelte-hxb22h"> </p></details>`),ap=q(`<time class="svelte-hxb22h"> </time>`),op=q(`<div class="svelte-hxb22h"> </div>`),sp=q(`<span class="profile-badge svelte-hxb22h"> </span>`),cp=q(`<span class="profile-badge svelte-hxb22h">Kimi</span>`),lp=q(`<li><div class="session-actions svelte-hxb22h" aria-label="Session actions"><!> <!> <!> <!> <!></div> <div class="session-details svelte-hxb22h"><!> <div class="session-summary svelte-hxb22h"><!> <!> <div class="workspace-path svelte-hxb22h"> </div> <!> <!> <!> <!> <!></div> <!> <!></div></li>`),up=q(`<section aria-labelledby="open-sessions-title" class="svelte-hxb22h"><h3 id="open-sessions-title" class="svelte-hxb22h">Open sessions</h3> <ul class="session-list svelte-hxb22h" aria-label="Open sessions"></ul></section>`),dp=q(`<li class="managed-session svelte-hxb22h"><div class="session-actions svelte-hxb22h"><!> <!> <!></div> <div class="session-details svelte-hxb22h"><!> <!> <div class="workspace-path svelte-hxb22h"> </div> <!> <!> <!> <!> <!></div></li>`),fp=q(`<ul class="session-list svelte-hxb22h" aria-label="Saved sessions"></ul>`),pp=q(`<p class="svelte-hxb22h">No saved sessions yet.</p>`),mp=q(`<option class="svelte-hxb22h"> </option>`),hp=q(`<option class="svelte-hxb22h">Loading models…</option>`),gp=q(`<option class="svelte-hxb22h">Choose automatically</option>`),_p=q(`<p class="skills-profile-error svelte-hxb22h" role="alert"> </p>`),vp=q(`<fieldset class="executor-settings svelte-hxb22h"><legend class="svelte-hxb22h">Org-plan executor</legend> <label for="executor-model" class="svelte-hxb22h">Executor model <select id="executor-model" class="svelte-hxb22h"></select></label> <label for="executor-thinking" class="svelte-hxb22h">Executor thinking <select id="executor-thinking" class="svelte-hxb22h"></select></label></fieldset>`),yp=q(`<label for="model-thinking" class="svelte-hxb22h">Model thinking <select id="model-thinking" class="svelte-hxb22h"></select></label>`),bp=q(`<label for="sandbox" class="svelte-hxb22h">Sandbox</label> <label for="approval-policy" class="svelte-hxb22h">Approval policy</label>`,1),xp=q(`<select id="sandbox" class="svelte-hxb22h"><option class="svelte-hxb22h">workspace-git (Git writable)</option><option class="svelte-hxb22h">workspace-write</option><option class="svelte-hxb22h">read-only</option><option class="svelte-hxb22h">danger-full-access</option></select> <select id="approval-policy" class="svelte-hxb22h"><option class="svelte-hxb22h">Ask on all commands</option><option class="svelte-hxb22h">Ask out of workspace</option><option class="svelte-hxb22h">Never ask for approval</option></select>`,1),Sp=q(`<li class="recent-session svelte-hxb22h"><div class="session-details svelte-hxb22h"><!> <div class="workspace-path svelte-hxb22h"> </div> <!> <!> <!> <!></div> <div class="session-actions svelte-hxb22h"><!> <!></div></li>`),Cp=q(`<ul class="session-list recent-session-list svelte-hxb22h" aria-label="Recent sessions"></ul>`),wp=q(`<p class="svelte-hxb22h">No other recent sessions found.</p>`),Tp=q(`<dialog aria-labelledby="close-session-title" class="svelte-hxb22h"><h2 id="close-session-title" class="svelte-hxb22h">Close session?</h2> <p class="svelte-hxb22h">You can reopen this session from the session list.</p> <div class="dialog-actions svelte-hxb22h"><!> <!></div></dialog> <section aria-labelledby="sessions-title" class="svelte-hxb22h"><h2 id="sessions-title" class="visually-hidden svelte-hxb22h">Sessions</h2> <!> <!> <form class="svelte-hxb22h"><h3 class="new-session-title svelte-hxb22h">New session</h3> <div class="session-base svelte-hxb22h"><!></div> <div class="essential-settings svelte-hxb22h"><label for="skills-profile" class="svelte-hxb22h">Skills profile <select id="skills-profile" class="svelte-hxb22h"><option class="svelte-hxb22h">Default</option><!></select></label> <label for="model" class="svelte-hxb22h">Model <select id="model" class="svelte-hxb22h"><!><!></select></label></div> <!> <details class="advanced-settings svelte-hxb22h"><summary class="svelte-hxb22h">Advanced settings</summary> <div class="advanced-content svelte-hxb22h"><section class="session-settings svelte-hxb22h" aria-label="New session settings"><div class="advanced-model-settings svelte-hxb22h"><!> <fieldset class="supervisor-settings svelte-hxb22h"><legend class="svelte-hxb22h">Main supervisor</legend> <!> <div class="provider-control svelte-hxb22h"><label for="session-provider" class="svelte-hxb22h">Provider</label> <select id="session-provider" class="svelte-hxb22h"><option class="svelte-hxb22h">Codex</option><option class="svelte-hxb22h"> </option></select></div></fieldset></div> <div class="session-setting-labels svelte-hxb22h"><!></div> <div class="session-setting-controls svelte-hxb22h"><!></div> <div class="session-secondary-actions svelte-hxb22h"><!> <!></div></section></div></details> <div class="create-session-actions svelte-hxb22h"><!></div></form> <section aria-labelledby="recent-sessions-title" class="svelte-hxb22h"><h3 id="recent-sessions-title" class="svelte-hxb22h">Recent sessions</h3> <!></section></section>`,1);function Ep(e,t){Qe(t,!0);let n=(e,t=b)=>{var n=Kr(),r=H(n),i=e=>{var n=rp(),r=U(V(n),2);wa(r,{get context(){return t().selfDebug.context}});var i=U(r,2);F(n),K(`click`,i,e=>ee()(t(),e.currentTarget)),J(e,n)};X(r,e=>{t().selfDebug&&e(i)}),J(e,n)},r=$(t,`activitySnapshots`,19,()=>new Map),i=$(t,`autopilotSnapshots`,19,()=>new Map),a=$(t,`autopilotPending`,19,()=>new Set),o=$(t,`autopilotAttention`,19,()=>new Map),s=$(t,`models`,19,()=>[]),c=$(t,`selectedModel`,3,``),l=$(t,`reasoningEffort`,3,`medium`),u=$(t,`executorModels`,19,()=>[]),d=$(t,`executorModel`,3,`gpt-5.6-terra`),f=$(t,`executorReasoningEffort`,3,`high`),p=$(t,`onreasoningchange`,3,()=>{}),m=$(t,`onexecutormodelchange`,3,()=>{}),h=$(t,`onexecutorreasoningchange`,3,()=>{}),g=$(t,`provider`,3,`codex`),_=$(t,`kimiAvailable`,3,!1),v=$(t,`modelsLoading`,3,!1),y=$(t,`onmodelchange`,3,()=>{}),x=$(t,`onproviderchange`,3,()=>{}),S=$(t,`onautopilottoggle`,3,()=>{}),C=$(t,`onactivityopen`,3,()=>{}),w=$(t,`onautopilotresolve`,3,()=>{}),T=$(t,`savingDefaults`,3,!1),E=$(t,`advancedExpanded`,15,!1),D=$(t,`onsavedefaults`,3,()=>{}),ee=$(t,`ondebugtrace`,3,()=>{}),O=L(()=>t.sessions.filter(e=>e.state===`ready`||e.state===`turnActive`)),te=L(()=>t.sessions.filter(e=>e.state!==`ready`&&e.state!==`turnActive`)),ne=L(()=>t.recentSessions.filter(e=>!G(O).some(t=>t.threadId===e.id&&(t.provider??`codex`)===(e.provider??`codex`)))),re=L(()=>Mu(t.workspaceTree,t.workspaceId)),ie=z(null),k=z(null);function ae(e){B(k,e,!0),G(ie)?.showModal()}var oe=Tp(),se=H(oe),ce=U(V(se),4),le=V(ce);Va(le,{onclick:()=>G(ie)?.close(),children:(e,t)=>{He(),J(e,Gr(`Cancel`))},$$slots:{default:!0}}),Va(U(le,2),{primary:!0,onclick:()=>{G(k)&&t.onclose(G(k)),G(ie)?.close()},children:(e,t)=>{He(),J(e,Gr(`Close session`))},$$slots:{default:!0}}),F(ce),F(se),Ui(se,e=>B(ie,e),()=>G(ie));var A=U(se,2),ue=U(V(A),2),de=e=>{var c=up(),l=U(V(c),2);Z(l,21,()=>G(O),e=>e.id,(e,c)=>{let l=L(()=>Jf(G(c))),u=L(()=>su(G(c).sessionStatus)?G(c).sessionStatus:null);var d=lp();let f;var p=V(d),m=V(p);{let e=L(()=>G(c).id===t.selectedSessionId?`page`:void 0);Va(m,{compact:!0,full:!0,get current(){return G(e)},onclick:()=>t.onselectopen(G(c).id),children:(e,t)=>{He(),J(e,Gr(`Open`))},$$slots:{default:!0}})}var h=U(m,2),g=e=>{Va(e,{compact:!0,full:!0,onclick:()=>t.oncopyresume(G(c).resumeCommand),children:(e,t)=>{He(),J(e,Gr(`Copy CLI`))},$$slots:{default:!0}})};X(h,e=>{G(c).resumeCommand&&G(c).provider!==`kimi`&&e(g)});var _=U(h,2),v=e=>{{let t=L(()=>i().get(G(c).id)??G(c).autopilot??null),n=L(()=>`session-autopilot-${G(c).id}`),r=L(()=>a().has(G(c).id));xo(e,{compact:!0,indicatorOnly:!0,get autopilot(){return G(t)},get controlId(){return G(n)},get pending(){return G(r)},ontoggle:e=>S()(G(c).id,e)})}};X(_,e=>{G(c).provider!==`kimi`&&e(v)});var y=U(_,2);{let e=L(()=>r().get(G(c).id)??G(c).agentActivity??null),t=L(()=>G(c).model??s()?.[0]);$a(y,{compact:!0,get activity(){return G(e)},get rootModel(){return G(t)},get plan(){return G(c).plan},onopen:()=>C()(G(c).id)})}Va(U(y,2),{compact:!0,full:!0,onclick:()=>ae(G(c).id),children:(e,t)=>{He(),J(e,Gr(`Close`))},$$slots:{default:!0}}),F(p);var b=U(p,2),x=V(b);n(x,()=>G(c));var T=U(x,2),E=V(T),D=e=>{var t=ip(),n=V(t),r=V(n);let i;var a=U(r);F(n);var o=U(n,2),s=V(o);F(o),F(t),W(()=>{Q(t,`data-state`,G(u).state),Q(t,`aria-label`,`${G(u).state===`working`?`Working`:`Idle`}: ${G(u).reason}`),Q(n,`aria-label`,`${G(u).state===`working`?`Working`:`Idle`}: ${G(u).reason}`),i=Si(r,1,`verdict-dot svelte-hxb22h`,null,i,{live:G(u).state===`working`&&G(u).confidence===`fresh`}),Y(a,` ${G(u).state===`working`?`Working`:`Idle`}`),Y(s,`${G(u).reason??``}. ${G(u).nextExpectedAction??``}
|
|
29
|
+
Evidence confidence: ${G(u).confidence??``}.`)}),J(e,t)};X(E,e=>{G(u)&&e(D)});var ee=U(E,2),O=e=>{var t=ap(),n=V(t,!0);F(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,r)},[()=>new Date(G(l).updatedAt).toISOString(),()=>qf(G(l).updatedAt)]),J(e,t)},te=e=>{var t=op(),n=V(t,!0);F(t),W(e=>Y(n,e),[()=>qf(null)]),J(e,t)};X(ee,e=>{G(l).updatedAt===null?e(te,-1):e(O)});var ne=U(ee,2),re=V(ne,!0);F(ne);var ie=U(ne,2),k=e=>{var t=sp(),n=V(t);F(t),W(()=>Y(n,`Model: ${G(c).model??``}`)),J(e,t)};X(ie,e=>{G(c).model&&e(k)});var oe=U(ie,2),se=e=>{J(e,cp())};X(oe,e=>{G(c).provider===`kimi`&&e(se)});var ce=U(oe,2),le=e=>{var t=sp(),n=V(t);F(t),W(()=>Y(n,`Branch: ${G(c).branch??``}`)),J(e,t)};X(ce,e=>{G(c).branch&&e(le)});var A=U(ce,2),ue=e=>{var t=sp(),n=V(t);F(t),W(()=>Y(n,`Skills profile: ${G(c).effectiveSkillSelection.selectedProfileName??``}`)),J(e,t)};X(A,e=>{G(c).effectiveSkillSelection?.selectedProfileName&&e(ue)}),Qf(U(A,2),()=>G(c)),F(T);var de=U(T,2);{let e=L(()=>o().get(G(c).id)??null),t=L(()=>`session-attention-${G(c).id}`),n=L(()=>a().has(G(c).id));To(de,{get attention(){return G(e)},get controlId(){return G(t)},get pending(){return G(n)},onresolve:(e,t)=>w()(G(c).id,e,t)})}var fe=U(de,2);{let e=L(()=>i().get(G(c).id)??G(c).autopilot??null),t=L(()=>o().get(G(c).id)??null),n=L(()=>`session-autopilot-safety-${G(c).id}`),r=L(()=>a().has(G(c).id));Do(fe,{get autopilot(){return G(e)},get attention(){return G(t)},get controlId(){return G(n)},get pending(){return G(r)},onrecover:()=>S()(G(c).id,!0),ondisable:()=>S()(G(c).id,!1)})}F(b),F(d),W(e=>{f=Si(d,1,`managed-session open-session svelte-hxb22h`,null,f,{"current-session":G(c).id===t.selectedSessionId}),Y(re,e)},[()=>Xf(G(l).workspacePath)]),J(e,d)}),F(l),F(c),J(e,c)};X(ue,e=>{G(O).length&&e(de)});var fe=U(ue,2),j=e=>{var r=fp();Z(r,21,()=>G(te),e=>e.id,(e,r)=>{let i=L(()=>Jf(G(r)));var a=dp(),o=V(a),s=V(o);{let e=L(()=>t.openingSessionId===G(r).id);Va(s,{compact:!0,full:!0,get disabled(){return G(e)},onclick:()=>t.onopen(G(r).id),children:(e,n)=>{He();var i=Gr();W(()=>Y(i,t.openingSessionId===G(r).id?`Opening…`:`Open`)),J(e,i)},$$slots:{default:!0}})}var c=U(s,2),l=e=>{Va(e,{compact:!0,full:!0,onclick:()=>t.oncopyresume(G(r).resumeCommand),children:(e,t)=>{He(),J(e,Gr(`Copy CLI`))},$$slots:{default:!0}})};X(c,e=>{G(r).resumeCommand&&G(r).provider!==`kimi`&&e(l)}),Va(U(c,2),{compact:!0,full:!0,onclick:()=>t.onforget(G(r).id),children:(e,t)=>{He(),J(e,Gr(`Forget`))},$$slots:{default:!0}}),F(o);var u=U(o,2),d=V(u);n(d,()=>G(r));var f=U(d,2),p=e=>{var t=ap(),n=V(t,!0);F(t),W((e,r)=>{Q(t,`datetime`,e),Y(n,r)},[()=>new Date(G(i).updatedAt).toISOString(),()=>qf(G(i).updatedAt)]),J(e,t)},m=e=>{var t=op(),n=V(t,!0);F(t),W(e=>Y(n,e),[()=>qf(null)]),J(e,t)};X(f,e=>{G(i).updatedAt===null?e(m,-1):e(p)});var h=U(f,2),g=V(h,!0);F(h);var _=U(h,2),v=e=>{var t=sp(),n=V(t);F(t),W(()=>Y(n,`Model: ${G(r).model??``}`)),J(e,t)};X(_,e=>{G(r).model&&e(v)});var y=U(_,2),b=e=>{J(e,cp())};X(y,e=>{G(r).provider===`kimi`&&e(b)});var x=U(y,2),S=e=>{var t=sp(),n=V(t);F(t),W(()=>Y(n,`Branch: ${G(r).branch??``}`)),J(e,t)};X(x,e=>{G(r).branch&&e(S)});var C=U(x,2),w=e=>{var t=sp(),n=V(t);F(t),W(()=>Y(n,`Skills profile: ${G(r).effectiveSkillSelection.selectedProfileName??``}`)),J(e,t)};X(C,e=>{G(r).effectiveSkillSelection?.selectedProfileName&&e(w)}),Qf(U(C,2),()=>G(r)),F(u),F(a),W(e=>Y(g,e),[()=>Xf(G(i).workspacePath)]),J(e,a)}),F(r),J(e,r)},M=e=>{J(e,pp())};X(fe,e=>{G(te).length?e(j):G(O).length||e(M,1)});var pe=U(fe,2),me=U(V(pe),2),he=V(me);{let e=L(()=>G(re)?.id??null);Bu(he,{get roots(){return t.workspaceTree},get expandedIds(){return t.expandedIds},get selectedId(){return G(e)},get isSelectable(){return Du.sessionBase},label:`Session base`,get onexpandedchange(){return t.onexpandedchange},onselect:e=>t.onworkspacechange(e.id)})}F(me);var ge=U(me,2),_e=V(ge),ve=U(V(_e)),ye=V(ve);ye.value=ye.__value=``,Z(U(ye),17,()=>t.skillProfiles,e=>e.name,(e,t)=>{var n=mp(),r=V(n,!0);F(n);var i={};W(()=>{Y(r,G(t).name),i!==(i=G(t).name)&&(n.value=(n.__value=G(t).name)??``)}),J(e,n)}),F(ve);var be;Ei(ve),F(_e);var xe=U(_e,2),Se=U(V(xe)),Ce=V(Se),we=e=>{var t=hp();t.value=t.__value=``,J(e,t)},Te=e=>{var t=gp();t.value=t.__value=``,J(e,t)};X(Ce,e=>{v()?e(we):s().length===0&&e(Te,1)}),Z(U(Ce),16,s,e=>e,(e,t)=>{var n=mp(),r=V(n,!0);F(n);var i={};W(()=>{Y(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),J(e,n)}),F(Se);var Ee;Ei(Se),F(xe),F(ge);var De=U(ge,2),Oe=e=>{var n=_p(),r=V(n,!0);F(n),W(()=>Y(r,t.skillProfileError)),J(e,n)};X(De,e=>{t.skillProfileError&&e(Oe)});var ke=U(De,2),Ae=U(V(ke),2),je=V(Ae),Me=V(je),Ne=V(Me),Pe=e=>{var t=vp(),n=U(V(t),2),r=U(V(n));Z(r,20,()=>[...new Set([d(),...u()])],e=>e,(e,t)=>{var n=mp(),r=V(n,!0);F(n);var i={};W(()=>{Y(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),J(e,n)}),F(r);var i;Ei(r),F(n);var a=U(n,2),o=U(V(a));Z(o,20,()=>Zf,e=>e,(e,t)=>{var n=mp(),r=V(n,!0);F(n);var i={};W(()=>{Y(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),J(e,n)}),F(o);var s;Ei(o),F(a),F(t),W(()=>{i!==(i=d())&&(r.value=(r.__value=d())??``,Ti(r,d())),s!==(s=f())&&(o.value=(o.__value=f())??``,Ti(o,f()))}),K(`change`,r,e=>m()(e.currentTarget.value)),K(`change`,o,e=>h()(e.currentTarget.value)),J(e,t)};X(Ne,e=>{g()===`codex`&&e(Pe)});var Fe=U(Ne,2),Ie=U(V(Fe),2),Le=e=>{var t=yp(),n=U(V(t));Z(n,20,()=>Zf,e=>e,(e,t)=>{var n=mp(),r=V(n,!0);F(n);var i={};W(()=>{Y(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),J(e,n)}),F(n);var r;Ei(n),F(t),W(()=>{r!==(r=l())&&(n.value=(n.__value=l())??``,Ti(n,l()))}),K(`change`,n,e=>p()(e.currentTarget.value)),J(e,t)};X(Ie,e=>{g()===`codex`&&e(Le)});var Re=U(Ie,2),N=U(V(Re),2),ze=V(N);ze.value=ze.__value=`codex`;var P=U(ze),Be=V(P);F(P),P.value=P.__value=`kimi`,F(N);var Ve;Ei(N),F(Re),F(Fe),F(Me);var Ue=U(Me,2);let We;var Ge=V(Ue),Ke=e=>{var t=bp();He(2),J(e,t)};X(Ge,e=>{g()!==`kimi`&&e(Ke)}),F(Ue);var qe=U(Ue,2);let Je;var Ye=V(qe),Xe=e=>{var n=xp(),r=H(n),i=V(r);i.value=i.__value=`workspace-git`;var a=U(i);a.value=a.__value=`workspace-write`;var o=U(a);o.value=o.__value=`read-only`;var s=U(o);s.value=s.__value=`danger-full-access`,F(r);var c;Ei(r);var l=U(r,2),u=V(l);u.value=u.__value=`untrusted`;var d=U(u);d.value=d.__value=`on-request`;var f=U(d);f.value=f.__value=`never`,F(l);var p;Ei(l),W(()=>{c!==(c=t.sandbox)&&(r.value=(r.__value=t.sandbox)??``,Ti(r,t.sandbox)),p!==(p=t.approvalPolicy)&&(l.value=(l.__value=t.approvalPolicy)??``,Ti(l,t.approvalPolicy))}),K(`change`,r,e=>t.onsandboxchange(e.currentTarget.value)),K(`change`,l,e=>t.onapprovalpolicychange(e.currentTarget.value)),J(e,n)};X(Ye,e=>{g()!==`kimi`&&e(Xe)}),F(qe);var Ze=U(qe,2),et=V(Ze);Va(et,{class:`manage-profiles-button`,id:`manage-skill-profiles`,onclick:e=>t.onmanageprofiles(e.currentTarget),children:(e,t)=>{He(),J(e,Gr(`Manage skill profiles`))},$$slots:{default:!0}});var tt=U(et,2);{let e=L(()=>T()||v()||!c());Va(tt,{class:`save-defaults-button`,get disabled(){return G(e)},get onclick(){return D()},children:(e,t)=>{He();var n=Gr();W(()=>Y(n,T()?`Saving…`:`Save as defaults`)),J(e,n)},$$slots:{default:!0}})}F(Ze),F(je),F(Ae),F(ke);var nt=U(ke,2),rt=V(nt);{let e=L(()=>!G(re)||t.startingSession||v()||s().length>0&&!c());Va(rt,{class:`new-session-button`,type:`submit`,full:!0,primary:!0,get disabled(){return G(e)},children:(e,n)=>{He();var r=Gr();W(()=>Y(r,t.startingSession?`Creating…`:`Create session`)),J(e,r)},$$slots:{default:!0}})}F(nt),F(pe);var it=U(pe,2),at=U(V(it),2),ot=e=>{var n=Cp();Z(n,21,()=>G(ne),e=>(e.provider??`codex`)+`:`+e.id,(e,n)=>{var r=Sp(),i=V(r),a=V(i),o=e=>{var t=ap(),r=V(t,!0);F(t),W((e,n)=>{Q(t,`datetime`,e),Y(r,n)},[()=>new Date(G(n).recencyAt*1e3).toISOString(),()=>qf(G(n).recencyAt*1e3)]),J(e,t)},s=e=>{var t=op(),n=V(t,!0);F(t),W(e=>Y(n,e),[()=>qf(null)]),J(e,t)};X(a,e=>{G(n).recencyAt===null?e(s,-1):e(o)});var c=U(a,2),l=V(c,!0);F(c);var u=U(c,2),d=e=>{var t=sp(),r=V(t);F(t),W(()=>Y(r,`Model: ${G(n).model??``}`)),J(e,t)};X(u,e=>{G(n).model&&e(d)});var f=U(u,2),p=e=>{J(e,cp())};X(f,e=>{G(n).provider===`kimi`&&e(p)});var m=U(f,2),h=e=>{var t=sp(),r=V(t);F(t),W(()=>Y(r,`Skills profile: ${G(n).skillProfile??``}`)),J(e,t)};X(m,e=>{G(n).skillProfile&&e(h)});var g=U(m,2),_=e=>{var t=sp(),r=V(t);F(t),W(()=>Y(r,`Org plan: ${G(n).orgPlanFilename??``}`)),J(e,t)};X(g,e=>{G(n).orgPlanFilename&&e(_)}),F(i);var v=U(i,2),y=V(v);Va(y,{onclick:()=>t.onopenrecent(G(n)),children:(e,t)=>{He(),J(e,Gr(`Open`))},$$slots:{default:!0}});var b=U(y,2),x=e=>{Va(e,{onclick:()=>t.oncopyresume(G(n).resumeCommand),children:(e,t)=>{He(),J(e,Gr(`Copy to CLI`))},$$slots:{default:!0}})};X(b,e=>{G(n).resumeCommand&&e(x)}),F(v),F(r),W(e=>Y(l,e),[()=>Xf(G(n).cwd)]),J(e,r)}),F(n),J(e,n)},st=e=>{J(e,wp())};X(at,e=>{G(ne).length?e(ot):e(st,-1)}),F(it),F(A),W(()=>{be!==(be=t.selectedSkillProfile)&&(ve.value=(ve.__value=t.selectedSkillProfile)??``,Ti(ve,t.selectedSkillProfile)),Se.disabled=v()||s().length===0,Ee!==(Ee=c())&&(Se.value=(Se.__value=c())??``,Ti(Se,c())),P.disabled=!_(),Y(Be,`Kimi${_()?``:` (unavailable)`}`),Ve!==(Ve=g())&&(N.value=(N.__value=g())??``,Ti(N,g())),We=wi(Ue,``,We,{"grid-template-columns":g()===`kimi`?`minmax(0, 1fr)`:`repeat(2, minmax(0, 1fr))`}),Je=wi(qe,``,Je,{"grid-template-columns":g()===`kimi`?`minmax(0, 1fr)`:`repeat(2, minmax(0, 1fr))`})}),Lr(`close`,se,()=>B(k,null)),Lr(`submit`,pe,e=>{e.preventDefault(),t.onstart()}),K(`change`,ve,e=>t.onskillprofilechange(e.currentTarget.value)),K(`change`,Se,e=>y()(e.currentTarget.value)),K(`change`,N,e=>x()(e.currentTarget.value)),Wi(`open`,`toggle`,ke,E,E),J(e,oe),$e()}Rr([`click`,`change`]);function Dp(e){let t={};return e.workspaceId||(t.workspaceId=`Choose a workspace.`),e.profile||(t.profile=`Choose a profile.`),e.profile&&e.profileState&&e.profileState!==`ok`&&(t.profile=`Sign in to this profile before starting Codex.`),t}var Op=class{transport;key;onChange;#e={starting:!1,error:null};#t=0;#n=!1;#r=null;constructor(e,t,n){this.transport=e,this.key=t,this.onChange=n}get state(){return this.#e}async start(e,t){if(this.#n||this.#e.starting||!e)return null;let n=++this.#t;this.#a({starting:!0,error:null});let r=this.#r??=this.key();try{let i=await this.transport.start(e,t,r);return this.#i(n)&&(this.#r=null),this.#i(n)?i:null}catch(e){return this.#i(n)&&this.#a({starting:!1,error:e instanceof Error?e.message:`Could not start session.`}),null}finally{this.#i(n)&&this.#a({...this.#e,starting:!1})}}dispose(){this.#n=!0,++this.#t}#i(e){return!this.#n&&e===this.#t}#a(e){this.#n||(this.#e=e,this.onChange(e))}};function kp({chatEnabled:e}){return[`sessions`,`git`,...e?[`chat`]:[],`plan`]}function Ap(e,t,n={chatEnabled:!0}){let r=kp(n);return r[(r.indexOf(e)+t+r.length)%r.length]}var jp=q(`<nav class="bottom-navigation" aria-label="Primary"><button>Sessions</button> <button>Git</button> <button>Chat</button> <button>Plan</button></nav>`);function Mp(e,t){Qe(t,!0);let n=$(t,`focusTab`,3,null),r=on({});Mn(()=>{n()&&r[n()]?.focus()});function i(e){let n=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:null;if(n===null)return;e.preventDefault();let i=Ap(t.activeTab,n,{chatEnabled:t.chatEnabled});t.onselect(i),r[i]?.focus()}var a=jp(),o=V(a);Ui(o,e=>r.sessions=e,()=>r?.sessions);var s=U(o,2);Ui(s,e=>r.git=e,()=>r?.git);var c=U(s,2);Ui(c,e=>r.chat=e,()=>r?.chat);var l=U(c,2);Ui(l,e=>r.plan=e,()=>r?.plan),F(a),W(()=>{Q(o,`aria-pressed`,t.activeTab===`sessions`),Q(s,`aria-pressed`,t.activeTab===`git`),Q(c,`aria-pressed`,t.activeTab===`chat`),c.disabled=!t.chatEnabled,Q(l,`aria-pressed`,t.activeTab===`plan`)}),K(`keydown`,o,i),K(`click`,o,()=>t.onselect(`sessions`)),K(`keydown`,s,i),K(`click`,s,()=>t.onselect(`git`)),K(`keydown`,c,i),K(`click`,c,()=>t.onselect(`chat`)),K(`keydown`,l,i),K(`click`,l,()=>t.onselect(`plan`)),J(e,a),$e()}Rr([`keydown`,`click`]);var Np=q(`<option> </option>`),Pp=q(`<p id="skills-status" aria-live="polite">Loading skills…</p>`),Fp=q(`<p id="skills-status">No skills were discovered for this workspace and Codex profile.</p>`),Ip=q(`<p id="skills-status" class="notice svelte-dg6sjj" role="status"> </p>`),Lp=q(`<p id="skills-status" class="error svelte-dg6sjj" role="alert"> </p>`),Rp=q(`<p id="skills-status" class="error svelte-dg6sjj" role="alert" tabindex="-1"> </p>`),zp=q(`<p id="skills-status" role="status">Profile saved.</p>`),Bp=q(`<p id="skills-status" role="status">Profile deleted.</p>`),Vp=q(`<li class="svelte-dg6sjj"><div class="svelte-dg6sjj"><strong> </strong> <span class="missing-state svelte-dg6sjj">Missing · disabled</span> <span class="path svelte-dg6sjj"> </span></div> <button type="button" class="remove-missing svelte-dg6sjj">Remove</button></li>`),Hp=q(`<section class="missing-skills svelte-dg6sjj" aria-labelledby="missing-skills-title"><h3 id="missing-skills-title" class="svelte-dg6sjj">Missing skills</h3> <p class="svelte-dg6sjj">These saved paths no longer exist. They are disabled for new sessions until restored or
|
|
30
|
+
removed from the profile.</p> <ul class="svelte-dg6sjj"></ul></section>`),Up=q(`<p class="svelte-dg6sjj"> </p>`),Wp=q(`<li> </li>`),Gp=q(`<dt class="svelte-dg6sjj">Tool dependencies</dt> <dd class="svelte-dg6sjj"><ul class="svelte-dg6sjj"></ul></dd>`,1),Kp=q(`<li class="skill-card svelte-dg6sjj"><label class="skill-toggle svelte-dg6sjj"><input type="checkbox" class="svelte-dg6sjj"/> <span class="svelte-dg6sjj"> </span> <span class="state svelte-dg6sjj"> </span></label> <div class="skill-details svelte-dg6sjj"><!> <!> <dl class="svelte-dg6sjj"><dt class="svelte-dg6sjj">Path</dt> <dd class="path svelte-dg6sjj"> </dd> <!></dl></div></li>`),qp=q(`<div class="skills-toolbar svelte-dg6sjj"><button type="button" class="refresh-skills svelte-dg6sjj" aria-label="Refresh skills"><span aria-hidden="true" class="svelte-dg6sjj">↻</span><span class="svelte-dg6sjj">Refresh</span></button> <p class="summary svelte-dg6sjj"> </p></div> <!> <ul class="skill-list svelte-dg6sjj"></ul>`,1),Jp=q(`<section class="skills-view svelte-dg6sjj" aria-labelledby="skills-title"><h2 id="skills-title"> </h2> <p class="intro svelte-dg6sjj">Create or edit a complete skills selection.</p> <form aria-describedby="skills-status" class="svelte-dg6sjj"><div class="field-grid svelte-dg6sjj"><label for="skills-existing-profile" class="svelte-dg6sjj">Skill profile</label> <select id="skills-existing-profile" class="svelte-dg6sjj"><option>New profile</option><option>Default</option><!></select> <label for="skills-save-as" class="svelte-dg6sjj">Save as</label> <input id="skills-save-as" name="save-as" autocomplete="off" class="svelte-dg6sjj"/></div> <p class="save-intent svelte-dg6sjj" aria-live="polite"> </p> <div class="profile-actions svelte-dg6sjj"><button type="button" class="svelte-dg6sjj">Delete profile</button> <button type="submit" class="svelte-dg6sjj"> </button></div></form> <dialog aria-labelledby="delete-profile-title" class="svelte-dg6sjj"><h3 id="delete-profile-title">Delete skill profile?</h3> <p> </p> <div class="dialog-actions svelte-dg6sjj"><button type="button" class="svelte-dg6sjj">Cancel</button> <button type="button" class="svelte-dg6sjj">Delete profile</button></div></dialog> <!> <!></section>`);function Yp(e,t){Qe(t,!0);let n=$(t,`skillsState`,7),r=$(t,`heading`,3,`Manage skill profiles`),i=z(0),a=z(null),o=z(null),s=z(null),c=z(null),l=z(`__new__`),u=L(()=>(G(i),n())),d=L(()=>G(u).profiles.filter(e=>!(`error`in e)));function f(){n(Object.assign(Object.create(Object.getPrototypeOf(n())),n())),B(i,G(i)+1)}async function p(){await t.onrefresh(),f()}function m(e){B(l,e.currentTarget.value,!0),G(l)===`__new__`||G(l)===`__default__`?G(u).selectDefaultProfile():G(u).selectProfile(G(l)),f()}async function h(e){e.preventDefault(),await G(u).save(),f(),G(u).status.kind===`saved`&&(B(l,G(u).selectedProfileName,!0),t.onprofileschange()),G(u).status.kind===`save-failed`&&(await Tr(),G(a)?.focus())}function g(){G(c)?.showModal()}async function _(){G(c)?.close(),await G(u).deleteSelectedProfile(),f(),G(u).status.kind===`deleted`&&(B(l,`__new__`),t.onprofileschange()),await Tr(),G(o)?.focus()}async function v(){G(c)?.close(),await Tr(),G(s)?.focus()}function y(e){return e&&/^#[0-9a-f]{3,8}$/i.test(e)?e:void 0}function b(e){return e.replace(/^\/(?:home|Users)\/[^/]+(?=\/|$)/,`~`)}function x(e){let t=e.currentTarget.closest(`.skill-card`);requestAnimationFrame(()=>t?.scrollIntoView({block:`nearest`,inline:`nearest`}))}var S=Jp(),C=V(S),w=V(C,!0);F(C);var T=U(C,4),E=V(T),D=U(V(E),2),ee=V(D);ee.value=ee.__value=`__new__`;var O=U(ee);O.value=O.__value=`__default__`,Z(U(O),17,()=>G(d),e=>e.name,(e,t)=>{var n=Np(),r=V(n,!0);F(n);var i={};W(()=>{Y(r,G(t).name),i!==(i=G(t).name)&&(n.value=(n.__value=G(t).name)??``)}),J(e,n)}),F(D),Ui(D,e=>B(o,e),()=>G(o));var te=U(D,4);Ni(te),F(E);var ne=U(E,2),re=V(ne,!0);F(ne);var ie=U(ne,2),k=V(ie);Ui(k,e=>B(s,e),()=>G(s));var ae=U(k,2),oe=V(ae,!0);F(ae),F(ie),F(T);var se=U(T,2),ce=U(V(se),2),le=V(ce);F(ce);var A=U(ce,2),ue=V(A),de=U(ue,2);F(A),F(se),Ui(se,e=>B(c,e),()=>G(c));var fe=U(se,2),j=e=>{J(e,Pp())},M=e=>{J(e,Fp())},pe=e=>{var t=Ip(),n=V(t);F(t),W(()=>Y(n,`Discovery warning: ${G(u).status.message??``}`)),J(e,t)},me=e=>{var t=Lp(),n=V(t,!0);F(t),W(()=>Y(n,G(u).status.message)),J(e,t)},he=e=>{var t=Rp(),n=V(t,!0);F(t),Ui(t,e=>B(a,e),()=>G(a)),W(()=>Y(n,G(u).status.message)),J(e,t)},ge=e=>{J(e,zp())},_e=e=>{J(e,Bp())},ve=e=>{var t=Lp(),n=V(t,!0);F(t),W(()=>Y(n,G(u).status.message)),J(e,t)};X(fe,e=>{G(u).status.kind===`loading`?e(j):G(u).status.kind===`empty`?e(M,1):G(u).status.kind===`warning`?e(pe,2):G(u).status.kind===`invalid-profile`||G(u).status.kind===`error`?e(me,3):G(u).status.kind===`save-failed`?e(he,4):G(u).status.kind===`saved`?e(ge,5):G(u).status.kind===`deleted`?e(_e,6):G(u).status.kind===`delete-failed`&&e(ve,7)});var ye=U(fe,2),be=e=>{var t=qp(),n=H(t),r=V(n),i=U(r,2),a=V(i);F(i),F(n);var o=U(n,2),s=e=>{var t=Hp(),n=U(V(t),4);Z(n,21,()=>G(u).missingSkills,e=>e.path,(e,t)=>{var n=Vp(),r=V(n),i=V(r),a=V(i,!0);F(i);var o=U(i,4),s=V(o,!0);F(o),F(r);var c=U(r,2);F(n),W(e=>{Y(a,G(t).name),Y(s,e),Q(c,`aria-label`,`Remove missing skill ${G(t).name} from profile`)},[()=>b(G(t).path)]),K(`click`,c,()=>{G(u).removeMissingSkill(G(t).path),f()}),J(e,n)}),F(n),F(t),J(e,t)};X(o,e=>{G(u).missingSkills.length>0&&e(s)});var c=U(o,2);Z(c,21,()=>G(u).skills,e=>e.path,(e,t)=>{var n=Kp();let r;var i=V(n),a=V(i);Ni(a);var o=U(a,2),s=V(o,!0);F(o);var c=U(o,2),l=V(c,!0);F(c),F(i);var d=U(i,2),p=V(d),m=e=>{var n=Up(),r=V(n,!0);F(n),W(()=>Y(r,G(t).description)),J(e,n)};X(p,e=>{G(t).description&&e(m)});var h=U(p,2),g=e=>{var n=Up(),r=V(n,!0);F(n),W(()=>Y(r,G(t).shortDescription)),J(e,n)};X(h,e=>{G(t).shortDescription&&e(g)});var _=U(h,2),v=U(V(_),2),S=V(v,!0);F(v);var C=U(v,2),w=e=>{var n=Gp(),r=U(H(n),2),i=V(r);Z(i,21,()=>G(t).dependencies.tools,e=>`${e.type}:${e.value}`,(e,t)=>{var n=Wp(),r=V(n);F(n),W(()=>Y(r,`${G(t).type??``}: ${G(t).value??``}${G(t).description?` — ${G(t).description}`:``}`)),J(e,n)}),F(i),F(r),J(e,n)};X(C,e=>{G(t).dependencies?.tools?.length&&e(w)}),F(_),F(d),F(n),W((e,o)=>{r=wi(n,``,r,e),Q(i,`for`,`skill-${G(t).path}`),Q(a,`id`,`skill-${G(t).path}`),Fi(a,G(t).enabled),a.disabled=G(t).alwaysAdvertised,Y(s,G(t).displayName??G(t).name),Y(l,G(t).alwaysAdvertised?`Always advertised`:G(t).enabled?`Enabled`:`Disabled`),Y(S,o)},[()=>({"--brand-color":y(G(t).brandColor)}),()=>b(G(t).path)]),Lr(`focus`,a,x),K(`change`,a,e=>{G(u).toggle(G(t).path,e.currentTarget.checked),f()}),J(e,n)}),F(c),W(()=>Y(a,`${G(u).enabledCount??``} of ${G(u).skills.length??``} skills enabled.`)),K(`click`,r,()=>void p()),J(e,t)};X(ye,e=>{(G(u).skills.length>0||G(u).missingSkills.length>0)&&e(be)}),F(S),W(()=>{Y(w,r()),Pi(te,G(u).saveAsName),Y(re,G(u).saveIntent===`replace`?`Saved the selected profile.`:`Creating a new saved profile.`),k.disabled=!G(u).selectedProfileName||G(u).status.kind===`deleting`,ae.disabled=G(u).status.kind===`saving`,Y(oe,G(u).status.kind===`saving`?`Saving profile…`:`Save profile`),Y(le,`Delete ${G(u).selectedProfileName??``}? Existing sessions keep their saved skill set.`)}),Lr(`submit`,T,h),K(`change`,D,m),Di(D,()=>G(l),e=>B(l,e)),K(`input`,te,e=>{G(u).saveAsName=e.currentTarget.value,f()}),K(`click`,k,g),K(`click`,ue,()=>void v()),K(`click`,de,()=>void _()),J(e,S),$e()}Rr([`change`,`input`,`click`]);var Xp=class{client;workspaceId=``;codexProfile=``;selectedProfileName=``;saveAsName=``;source=`native`;skills=[];missingSkills=[];profiles=[];status={kind:`idle`};baseline=new Map;missingBaseline=new Map;saving=!1;deleting=!1;request=null;generation=0;disposed=!1;constructor(e){this.client=e}get enabledCount(){return this.skills.filter(e=>e.enabled).length}get dirty(){return this.skills.some(e=>this.baseline.get(e.path)!==e.enabled)||this.missingSkills.some(e=>this.missingBaseline.get(e.path)?.enabled!==e.enabled)||[...this.missingBaseline].some(([e])=>!this.missingSkills.some(t=>t.path===e))}get saveIntent(){return this.profiles.some(e=>!(`error`in e)&&e.name===this.saveAsName.trim())?`replace`:`create`}async load(e,t){let n=this.beginRequest(),r=this.generation;this.workspaceId=e,this.codexProfile=t,this.status={kind:`loading`};try{let[i,a]=await Promise.all([this.client.listAvailableSkills(e,t,!0,n.signal),this.client.listSkillProfiles(n.signal)]);if(!this.current(r,n))return;this.applyAvailable(i),this.profiles=a.profiles.map(e=>`error`in e?e:{...e,skills:e.skills.filter(e=>!Zp(e.name))});let o=a.profiles.find(e=>`error`in e);o&&`error`in o?this.status={kind:`invalid-profile`,message:o.error.message}:i.errors.length?this.status={kind:`warning`,message:i.errors.map(e=>e.message).join(` `)}:this.status=this.skills.length?{kind:`ready`}:{kind:`empty`}}catch(e){if(!this.current(r,n)||n.signal.aborted)return;this.status={kind:`error`,message:Qp(e)}}}async refresh(){let e=this.beginRequest(),t=this.generation;this.status={kind:`loading`};try{let n=await this.client.listAvailableSkills(this.workspaceId,this.codexProfile,!0,e.signal);if(!this.current(t,e))return;this.applyAvailable(n),this.status=this.missingSkills.length?this.missingSkillsStatus():n.errors.length?{kind:`warning`,message:n.errors.map(e=>e.message).join(` `)}:this.skills.length?{kind:`ready`}:{kind:`empty`}}catch(n){if(!this.current(t,e)||e.signal.aborted)return;this.status={kind:`error`,message:Qp(n)}}}selectProfile(e){let t=this.profiles.find(t=>!(`error`in t)&&t.name===e);if(!t||`error`in t){this.status={kind:`invalid-profile`,message:`Select a valid saved profile.`};return}this.selectedProfileName=t.name,this.saveAsName=t.name;let n=new Map(t.skills.map(e=>[e.path,e.enabled])),r=new Set(this.skills.map(e=>e.path)),i=t.skills.filter(e=>!r.has(e.path));this.skills=this.skills.map(e=>({...e,enabled:n.get(e.path)??!1})),this.missingSkills=i.map(e=>({...e,enabled:!1})),this.baseline=new Map(this.skills.map(e=>[e.path,e.enabled])),this.missingBaseline=new Map(i.map(e=>[e.path,{...e}])),this.status=this.missingSkills.length?this.missingSkillsStatus():this.skills.length?{kind:`ready`}:{kind:`empty`}}selectDefaultProfile(){this.selectedProfileName=``,this.saveAsName=``,this.missingSkills=[],this.skills=this.skills.map(e=>({...e,enabled:e.effectiveEnabled})),this.captureBaseline(),this.status=this.skills.length?{kind:`ready`}:{kind:`empty`}}toggle(e,t){this.skills=this.skills.map(n=>n.path===e&&!n.alwaysAdvertised?{...n,enabled:t}:n)}removeMissingSkill(e){this.missingSkills=this.missingSkills.filter(t=>t.path!==e),this.status=this.missingSkills.length?this.missingSkillsStatus():this.skills.length?{kind:`ready`}:{kind:`empty`}}reset(){this.skills=this.skills.map(e=>({...e,enabled:this.baseline.get(e.path)??!1})),this.missingSkills=[...this.missingBaseline.values()].map(e=>({...e,enabled:!1})),this.missingSkills.length&&(this.status=this.missingSkillsStatus())}async save(){let e=this.saveAsName.trim();if(this.saving||this.deleting)return;if(!e){this.status={kind:`save-failed`,message:`Enter a profile name before saving.`};return}this.saving=!0,this.status={kind:`saving`};let t=this.savePayload(e);try{let n=await this.client.replaceSkillProfile(e,t);this.profiles=[...this.profiles.filter(e=>`error`in e||e.name!==n.name),n].sort((e,t)=>e.name.localeCompare(t.name)),this.selectedProfileName=n.name,this.saveAsName=n.name,this.captureBaseline(),this.status={kind:`saved`}}catch(e){this.status={kind:`save-failed`,message:Qp(e)}}finally{this.saving=!1}}async deleteSelectedProfile(){let e=this.selectedProfileName;if(!(this.saving||this.deleting)){if(!e){this.status={kind:`delete-failed`,message:`Select a saved profile before deleting.`};return}this.deleting=!0,this.status={kind:`deleting`};try{await this.client.deleteSkillProfile(e),this.profiles=this.profiles.filter(t=>`error`in t||t.name!==e),this.selectedProfileName=``,this.saveAsName=``,this.missingSkills=[],this.captureBaseline(),this.status={kind:`deleted`}}catch(e){this.status={kind:`delete-failed`,message:Qp(e)}}finally{this.deleting=!1}}}dispose(){this.disposed=!0,++this.generation,this.request?.abort(),this.request=null}beginRequest(){return this.request?.abort(),this.request=new AbortController,++this.generation,this.request}current(e,t){return!this.disposed&&e===this.generation&&this.request===t}savePayload(e=this.saveAsName.trim()){return{version:1,name:e,skills:this.skills.map(({name:e,path:t,enabled:n})=>({name:e,path:t,enabled:n})).concat(this.missingSkills).sort((e,t)=>e.path.localeCompare(t.path))}}applyAvailable(e){let t=new Map(this.skills.filter(e=>this.baseline.get(e.path)!==e.enabled).map(e=>[e.path,e.enabled])),n=new Map(this.missingSkills.map(e=>[e.path,e.enabled]));this.source=e.source;let r=e.skills.filter(e=>!e.alwaysAdvertised);this.skills=r.map(e=>({...e,enabled:t.get(e.path)??n.get(e.path)??e.effectiveEnabled}));let i=new Set(r.map(e=>e.path));this.missingSkills=this.missingSkills.filter(e=>!i.has(e.path)),this.baseline=new Map(r.map(e=>[e.path,this.baseline.get(e.path)??e.effectiveEnabled]))}captureBaseline(){this.baseline=new Map(this.skills.map(e=>[e.path,e.enabled])),this.missingBaseline=new Map(this.missingSkills.map(e=>[e.path,{...e}]))}missingSkillsStatus(){let e=this.missingSkills.length;return{kind:`warning`,message:`${e} saved ${e===1?`skill is`:`skills are`} missing and disabled. Remove ${e===1?`it`:`them`} from this profile, or restore the skill installation.`}}};function Zp(e){return e.startsWith(`gestalt:`)}function Qp(e){return e instanceof Error?e.message:`Unknown relay error.`}var $p=o(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),em=o((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),tm=o((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),nm=o(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),rm=o(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),im=o((e=>{var t=em().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),am=o((e=>{var t=em().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),om=o((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),sm=o((e=>{var t=tm(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),cm=o((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),lm=o((e=>{var t=cm();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),um=o(((e,t)=>{var n=lm();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),dm=o((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),fm=o((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
31
|
+
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),pm=o((e=>{var t=dm(),n=fm();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),mm=o((e=>{var t=em(),n=sm(),r=tm(),i=pm(),a=dm(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),hm=o((e=>{var t=em(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),gm=o(((e,t)=>{var n=pm();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),_m=o(((e,t)=>{var n=pm(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),vm=o(((e,t)=>{var n=pm();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),ym=o(((e,t)=>{var n=pm(),r=em();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
32
|
+
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),bm=o(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),xm=o((e=>{var t=pm(),n=gm(),r=_m(),i=vm(),a=ym(),o=fm(),s=em(),c=bm();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
|
|
33
|
+
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),Sm=o((e=>{var t=em(),n=tm(),r=nm(),i=rm(),a=im(),o=am(),s=om(),c=sm(),l=um(),u=mm(),d=hm(),f=pm(),p=xm();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
|
|
34
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
35
|
+
Minimum version required to store current data is: `+c+`.
|
|
36
|
+
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),Cm=o((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),wm=o((e=>{var t=Cm();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Tm=o((e=>{var t=Cm();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
37
|
+
`;return typeof a==`function`&&a(null,p),p}})),Em=c(o((e=>{var t=$p(),n=Sm(),r=wm(),i=Tm();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function Dm(e){return`${e.replace(/\/$/,``)}/?bootstrap=1`}async function Om(e){return Em.toDataURL(Dm(e),{errorCorrectionLevel:`M`,margin:1,width:256})}async function km(e){return Em.toDataURL(e,{errorCorrectionLevel:`M`,margin:1,width:256})}var Am=q(`<p class="feedback svelte-1nygetn" role="status"> </p>`),jm=q(`<span class="svelte-1nygetn">At least one authorized device is required.</span>`),Mm=q(`<li class="svelte-1nygetn"><form class="svelte-1nygetn"><label class="svelte-1nygetn">Nickname</label><input name="nickname" class="svelte-1nygetn"/> <p class="svelte-1nygetn"> <!><!></p> <button type="submit" class="svelte-1nygetn">Rename</button> <button type="button" class="svelte-1nygetn">Revoke</button> <!></form></li>`),Nm=q(`<ul aria-label="Authorized devices" class="svelte-1nygetn"></ul>`),Pm=q(`<p role="status" class="svelte-1nygetn">No authorized devices are available. Refresh this page before making changes.</p>`),Fm=q(`<button type="button" class="svelte-1nygetn">Create enrollment link</button>`),Im=q(`<img alt="QR code for the enrollment link" class="svelte-1nygetn"/>`),Lm=q(`<p role="status" class="svelte-1nygetn"> </p> <!> <label for="enrollment-link" class="svelte-1nygetn">Enrollment link</label><textarea id="enrollment-link" readonly="" rows="3" class="svelte-1nygetn"></textarea> <div class="actions svelte-1nygetn"><button type="button" class="svelte-1nygetn">Copy enrollment link</button><button type="button" class="svelte-1nygetn">Create passkey here</button><button type="button" class="svelte-1nygetn">Cancel link</button><button type="button" class="svelte-1nygetn">Replace link</button></div>`,1),Rm=q(`<main class="devices svelte-1nygetn" aria-labelledby="devices-title"><header class="svelte-1nygetn"><button type="button" class="svelte-1nygetn">Back</button> <h1 id="devices-title" class="svelte-1nygetn">Authorized devices</h1></header> <!> <!> <section aria-labelledby="add-title" class="svelte-1nygetn"><h2 id="add-title" class="svelte-1nygetn">Authorize another device</h2> <!></section></main> <dialog aria-labelledby="revoke-title" class="svelte-1nygetn"><h2 id="revoke-title" class="svelte-1nygetn">Revoke authorized device?</h2> <p class="svelte-1nygetn">This immediately signs out sessions created by this passkey.</p> <form method="dialog" class="svelte-1nygetn"><button type="submit" class="svelte-1nygetn">Keep device</button><button type="button" class="svelte-1nygetn">Revoke device</button></form></dialog>`,1);function zm(e,t){Qe(t,!0);let n=$(t,`oncreatepasskey`,3,()=>{}),r=z(on([])),i=z(``),a=z(null),o=z(`none`),s=z(null),c=z(null),l=z(null),u=z(null),d=z(on(Date.now())),f=L(()=>[...G(r)].sort((e,t)=>e.createdAt.localeCompare(t.createdAt))),p=L(()=>G(a)?Math.max(0,Math.ceil((Date.parse(G(a).expiresAt)-G(d))/1e3)):0),m=L(()=>`${Math.floor(G(p)/60)}:${String(G(p)%60).padStart(2,`0`)}`);function h(e){let t=e.trim();return[...t].length>=1&&[...t].length<=64}function g(){G(u)&&clearInterval(G(u)),B(u,null)}function _(){g(),B(u,setInterval(()=>void b(),15e3),!0)}function v(){return!!(G(a)&&G(o)===`pending`&&G(p)>0&&document.visibilityState===`visible`)}async function y(){try{B(r,(await t.client.list()).devices,!0)}catch{B(i,`Could not refresh authorized devices. Try again.`)}}async function b(){if(!v()){G(p)===0&&G(a)&&B(o,`expired`),g();return}try{B(o,(await t.client.ticketStatus()).status,!0),G(o)!==`pending`&&(g(),G(o)===`used`&&await y())}catch{g()}}async function x(){B(i,``);try{B(a,await t.client.createTicket(),!0),B(o,`pending`),B(s,await km(G(a).url),!0),B(d,Date.now(),!0),_()}catch{B(i,`Could not create an enrollment link. Try again.`)}}async function S(){try{B(o,(await t.client.cancelTicket()).status,!0),B(a,null),B(s,null),g()}catch{B(i,`Could not cancel the enrollment link. Try again.`)}}async function C(){await S(),G(i)||await x()}async function w(e,n){if(!h(n)){B(i,`Device nicknames must be 1–64 characters.`);return}B(i,``);try{await t.client.rename(e.id,n.trim()),await y()}catch{B(i,`Could not rename this device. Try again.`)}}function T(e){G(f).length>1&&(B(l,e,!0),G(c)?.showModal())}async function E(){if(G(l))try{await t.client.revoke(G(l).id),G(c)?.close(),G(l).current?t.onlock():await y()}catch{B(i,`This device could not be revoked. Try again.`)}}async function D(){if(G(a))try{await navigator.clipboard.writeText(G(a).url)}catch{B(i,`Copy is unavailable here. Select the visible link instead.`)}}function ee(){document.visibilityState===`visible`&&G(o)===`pending`&&G(p)>0?(b(),_()):g()}Gi(()=>{y(),document.addEventListener(`visibilitychange`,ee);let e=setInterval(()=>B(d,Date.now(),!0),1e3);return()=>clearInterval(e)}),Ki(()=>{g(),document.removeEventListener(`visibilitychange`,ee)});var O=Rm(),te=H(O),ne=V(te),re=V(ne);He(2),F(ne);var ie=U(ne,2),k=e=>{var t=Am(),n=V(t,!0);F(t),W(()=>Y(n,G(i))),J(e,t)};X(ie,e=>{G(i)&&e(k)});var ae=U(ie,2),oe=e=>{var t=Nm();Z(t,21,()=>G(f),e=>e.id,(e,t)=>{var n=Mm(),r=V(n),i=V(r),a=U(i);Ni(a);var o=U(a,2),s=V(o),c=U(s),l=e=>{var n=Gr();W(e=>Y(n,`· Last used ${e??``}`),[()=>new Date(G(t).lastUsedAt).toLocaleDateString()]),J(e,n)};X(c,e=>{G(t).lastUsedAt&&e(l)});var u=U(c),d=e=>{J(e,Gr(`· This device`))};X(u,e=>{G(t).current&&e(d)}),F(o);var p=U(o,4),m=U(p,2),h=e=>{var n=jm();W(()=>Q(n,`id`,`final-${G(t).id}`)),J(e,n)};X(m,e=>{G(f).length===1&&e(h)}),F(r),F(n),W(e=>{Q(i,`for`,`nickname-${G(t).id}`),Q(a,`id`,`nickname-${G(t).id}`),Pi(a,G(t).nickname),Q(a,`aria-label`,`Nickname for ${G(t).nickname}`),Y(s,`Added ${e??``}`),p.disabled=G(f).length===1,Q(p,`aria-describedby`,G(f).length===1?`final-${G(t).id}`:void 0)},[()=>new Date(G(t).createdAt).toLocaleDateString()]),Lr(`submit`,r,e=>{e.preventDefault(),w(G(t),String(new FormData(e.currentTarget).get(`nickname`)??``))}),K(`click`,p,()=>T(G(t))),J(e,n)}),F(t),J(e,t)},se=e=>{J(e,Pm())};X(ae,e=>{G(f).length?e(oe):e(se,-1)});var ce=U(ae,2),le=U(V(ce),2),A=e=>{var t=Fm();K(`click`,t,()=>void x()),J(e,t)},ue=e=>{var t=Lm(),r=H(t),i=V(r,!0);F(r);var c=U(r,2),l=e=>{var t=Im();W(()=>Q(t,`src`,G(s))),J(e,t)};X(c,e=>{G(s)&&e(l)});var u=U(c,3);Sn(u);var d=U(u,2),f=V(d),p=U(f),h=U(p),g=U(h);F(d),W(()=>{Y(i,G(o)===`pending`?`Enrollment link is active for ${G(m)}.`:`Enrollment link is ${G(o)}.`),Pi(u,G(a).url)}),K(`click`,f,()=>void D()),K(`click`,p,()=>n()(G(a).ticket)),K(`click`,h,()=>void S()),K(`click`,g,()=>void C()),J(e,t)};X(le,e=>{G(a)?e(ue,-1):e(A)}),F(ce),F(te);var de=U(te,2),fe=U(V(de),4),j=U(V(fe));F(fe),F(de),Ui(de,e=>B(c,e),()=>G(c)),K(`click`,re,function(...e){t.onclose?.apply(this,e)}),K(`click`,j,()=>void E()),J(e,O),$e()}Rr([`click`]);async function Bm(e){if(e=await e,!e.ok){let t;try{let n=await e.json();typeof n==`object`&&n&&`code`in n&&typeof n.code==`string`&&(t=n.code)}catch{}throw Error(t??`AUTH_REQUEST_FAILED_${e.status}`)}if(e.status!==204)return e.json()}function Vm(e){return{list:()=>Bm(e(`/api/auth/devices`,{credentials:`same-origin`})),rename:(t,n)=>Bm(e(`/api/auth/devices/${encodeURIComponent(t)}`,{method:`PATCH`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify({nickname:n})})),revoke:t=>Bm(e(`/api/auth/devices/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:`same-origin`})),createTicket:()=>Bm(e(`/api/auth/enrollment-tickets`,{method:`POST`,credentials:`same-origin`})),ticketStatus:()=>Bm(e(`/api/auth/enrollment-tickets/current`,{credentials:`same-origin`})),cancelTicket:()=>Bm(e(`/api/auth/enrollment-tickets/current`,{method:`DELETE`,credentials:`same-origin`}))}}var Hm=`gestalt-mobile.scratchpad`;function Um(){try{return window.localStorage}catch{return null}}function Wm(e){try{return e?.getItem(`gestalt-mobile.scratchpad`)??``}catch{return``}}function Gm(e,t){try{return e?(e.setItem(Hm,t),!0):!1}catch{return!1}}function Km(e){try{return e?(e.removeItem(Hm),!0):!1}catch{return!1}}var qm=q(`<p class="feedback svelte-eu5bnq" role="status"> </p>`),Jm=q(`<section class="clear-confirmation svelte-eu5bnq" aria-labelledby="clear-scratchpad-title"><p id="clear-scratchpad-title" class="svelte-eu5bnq"><strong>Clear the entire scratchpad?</strong></p> <p class="svelte-eu5bnq">This cannot be undone.</p> <div class="actions svelte-eu5bnq"><button type="button" class="svelte-eu5bnq">Keep text</button> <button type="button" class="danger svelte-eu5bnq">Clear all</button></div></section>`),Ym=q(`<footer class="actions svelte-eu5bnq"><button type="button" class="svelte-eu5bnq">Paste</button> <button type="button" class="svelte-eu5bnq">Select all</button> <button type="button" class="danger svelte-eu5bnq">Clear</button> <button type="button" class="svelte-eu5bnq">Close</button></footer>`),Xm=q(`<dialog aria-labelledby="scratchpad-title" class="svelte-eu5bnq"><section class="scratchpad-shell svelte-eu5bnq"><header class="svelte-eu5bnq"><div><h2 id="scratchpad-title" class="svelte-eu5bnq">Scratchpad</h2> <p id="scratchpad-help" class="svelte-eu5bnq">Saved automatically in this browser.</p></div> <button type="button" class="close svelte-eu5bnq" aria-label="Close scratchpad">×</button></header> <label for="scratchpad-text" class="svelte-eu5bnq">Scratchpad text</label> <textarea id="scratchpad-text" aria-describedby="scratchpad-help" class="svelte-eu5bnq"></textarea> <!> <!></section></dialog>`);function Zm(e,t){Qe(t,!0);let n=$(t,`storage`,19,Um),r=$(t,`clipboard`,19,()=>globalThis.navigator?.clipboard),i=z(null),a=z(null),o=z(null),s=z(``),c=z(!1),l=z(``);Gi(async()=>{B(s,Wm(n()),!0),await Tr(),G(i)?.showModal(),G(a)?.focus()});function u(e){B(s,e,!0),B(l,Gm(n(),e)?``:`This browser could not save the scratchpad. Keep this window open until you copy the text.`,!0)}async function d(){if(!r()?.readText){B(l,`Clipboard paste is unavailable here. Long-press the text field and choose Paste.`),G(a)?.focus();return}try{let e=await r().readText(),t=G(a)?.selectionStart??G(s).length,n=G(a)?.selectionEnd??G(s).length;u(`${G(s).slice(0,t)}${e}${G(s).slice(n)}`),await Tr();let i=t+e.length;G(a)?.focus(),G(a)?.setSelectionRange(i,i)}catch{B(l,`Clipboard paste was not permitted. Long-press the text field and choose Paste.`),G(a)?.focus()}}async function f(){B(c,!0),B(l,``),await Tr(),G(o)?.focus()}function p(){B(c,!1),G(a)?.focus()}function m(){if(!Km(n())){B(l,`This browser could not clear its saved scratchpad.`);return}B(s,``),B(c,!1),B(l,``),G(a)?.focus()}var h=Xm(),g=V(h),_=V(g),v=U(V(_),2);F(_);var y=U(_,4);Sn(y),Ui(y,e=>B(a,e),()=>G(a));var b=U(y,2),x=e=>{var t=qm(),n=V(t,!0);F(t),W(()=>Y(n,G(l))),J(e,t)};X(b,e=>{G(l)&&e(x)});var S=U(b,2),C=e=>{var t=Jm(),n=U(V(t),4),r=V(n);Ui(r,e=>B(o,e),()=>G(o));var i=U(r,2);F(n),F(t),K(`click`,r,p),K(`click`,i,m),J(e,t)},w=e=>{var t=Ym(),n=V(t),r=U(n,2),o=U(r,2),c=U(o,2);F(t),W(()=>o.disabled=!G(s)),K(`click`,n,()=>void d()),K(`click`,r,()=>G(a)?.select()),K(`click`,o,()=>void f()),K(`click`,c,()=>G(i)?.close()),J(e,t)};X(S,e=>{G(c)?e(C):e(w,-1)}),F(g),F(h),Ui(h,e=>B(i,e),()=>G(i)),W(()=>Pi(y,G(s))),Lr(`close`,h,function(...e){t.onclose?.apply(this,e)}),K(`click`,v,()=>G(i)?.close()),K(`input`,y,e=>u(e.currentTarget.value)),J(e,h),$e()}Rr([`click`,`input`]);var Qm=e=>typeof e==`object`&&e?Object.entries(e):[],$m=(e,t)=>`${e}/${JSON.stringify(t)}`;function eh(e){let t=new Set,n=[{value:e,id:``}];for(;n.length;){let e=n.pop(),r=Qm(e.value);if(r.length){t.add(e.id);for(let[t,i]of r)n.push({value:i,id:$m(e.id,t)})}}return t}function th(e,t){let n=[{value:e,id:``,depth:0,prefix:``,comma:``,label:`JSON root`}],r=[];for(;n.length;){let e=n.pop();if(`closing`in e){r.push(e.closing);continue}let i=Qm(e.value),a=e.value!==null&&typeof e.value==`object`,o=Array.isArray(e.value),s=o?`[`:`{`,c=o?`]`:`}`,l=i.length>0&&t.has(e.id);if(r.push({id:e.id,depth:e.depth,label:e.label,expandable:i.length>0,expanded:l,kind:a?`container`:e.value===null?`null`:typeof e.value,text:e.prefix+(a?s+(l?``:i.length?` … ${i.length} ${o?`items`:`keys`} ${c}`:c):JSON.stringify(e.value))+(l?``:e.comma)}),l){n.push({closing:{id:`${e.id}:close`,depth:e.depth,text:c+e.comma,expandable:!1,expanded:!1,label:e.label,kind:`container`}});for(let t=i.length-1;t>=0;t--){let[r,a]=i[t];n.push({value:a,id:$m(e.id,r),depth:e.depth+1,prefix:o?``:`${JSON.stringify(r)}: `,comma:t<i.length-1?`,`:``,label:`${e.label}${o?`[${r}]`:`.${r}`}`})}}}return r}var nh=q(`<button type="button" class="svelte-7x7m8l"> </button>`),rh=q(`<div class="json-row svelte-7x7m8l"><span class="fold-column svelte-7x7m8l"><!></span> <code class="svelte-7x7m8l"> </code></div>`),ih=q(`<div class="json-tree svelte-7x7m8l" aria-label="JSON contents"></div>`);function ah(e,t){Qe(t,!0);let n=$(t,`unfolded`,3,!1),r=L(()=>JSON.parse(t.text)),i=L(()=>n()?eh(G(r)):new Set([``])),a=L(()=>th(G(r),G(i)));function o(e){let t=new Set(G(i));if(t.has(e))t.delete(e);else{for(let n of t)n.startsWith(`${e}/`)&&t.delete(n);t.add(e)}B(i,t)}var s=ih();Z(s,21,()=>G(a),e=>e.id,(e,t)=>{var n=rh(),r=V(n),i=V(r),a=e=>{var n=nh(),r=V(n,!0);F(n),W(()=>{Q(n,`aria-label`,`${G(t).expanded?`Fold`:`Unfold`} ${G(t).label}`),Q(n,`aria-expanded`,G(t).expanded),Y(r,G(t).expanded?`−`:`+`)}),K(`click`,n,()=>o(G(t).id)),J(e,n)};X(i,e=>{G(t).expandable&&e(a)}),F(r);var s=U(r,2);let c;var l=V(s,!0);F(s),F(n),W(()=>{Q(n,`data-kind`,G(t).kind),c=wi(s,``,c,{"padding-inline-start":`${G(t).depth*1.2}em`}),Y(l,G(t).text)}),J(e,n)}),F(s),J(e,s),$e()}Rr([`click`]);var oh=q(`<button class="disclosure svelte-am0nvt" type="button"> </button>`),sh=q(`<span class="disclosure svelte-am0nvt"></span>`),ch=q(`<span class="unsupported svelte-am0nvt">Files cannot be destinations</span>`),lh=q(`<span class="unsupported svelte-am0nvt">Unsupported link</span>`),uh=q(`<span role="status">Loading…</span>`),dh=q(`<button type="button" class="svelte-am0nvt"> </button>`),fh=q(`<div role="group"><!> <!> <!> <!></div>`),ph=q(`<div role="treeitem"><div class="tree-row svelte-am0nvt" role="presentation"><!> <span class="tree-label svelte-am0nvt"> </span><!></div> <!></div>`),mh=q(`<p role="status">Loading files…</p>`),hh=q(`<button type="button" class="svelte-am0nvt">Retry loading files</button>`),gh=q(`<button type="button" class="svelte-am0nvt">Load more in root</button>`),_h=q(`<div class="file-tree svelte-am0nvt" role="tree" aria-label="Files"><!> <!> <!> <!></div>`);function vh(e,t){Qe(t,!0);let n=$(t,`directory`,3,``),r=$(t,`destinationMode`,3,!1),i=$(t,`ondestinationselect`,3,()=>{}),a=$(t,`onselectionchange`,3,()=>{}),o=on({}),s=z(``),c=L(()=>t.revision<0?{entries:[],loading:!1,error:!1}:u(n())),l=L(()=>{if(t.revision<0)return[];let e=[],r=(t,n)=>{for(let i of u(t).entries)e.push({entry:i,level:n,parent:t}),i.kind===`directory`&&d(i.path)&&r(i.path,n+1)};return r(n(),1),e});function u(e){return t.revision,t.controller.state(e)}function d(e){return t.revision,t.controller.expanded.has(e)}function f(e){B(s,e,!0),o[e]?.focus()}function p(e){d(e.path)?t.controller.collapse(e.path):t.controller.expand(e.path)}function m(e,n,r){e.stopPropagation();let i=n.entry,a=n.parent,o=e=>{let t=G(l)[Math.max(0,Math.min(G(l).length-1,e))];t&&f(t.entry.path)};switch(e.key){case`ArrowDown`:e.preventDefault(),o(r+1);break;case`ArrowUp`:e.preventDefault(),o(r-1);break;case`Home`:e.preventDefault(),o(0);break;case`End`:e.preventDefault(),o(G(l).length-1);break;case`ArrowRight`:i.kind===`directory`&&(e.preventDefault(),d(i.path)?o(r+1):p(i));break;case`ArrowLeft`:e.preventDefault(),i.kind===`directory`&&d(i.path)?t.controller.collapse(i.path):a&&f(a);break;case`Enter`:case` `:e.preventDefault(),h(i);break}}function h(e){if(e.kind!==`symlink`){if(r()){e.kind===`directory`&&i()(e.path);return}t.controller.select(e.path),a()(e.path)}}var g=_h();{let e=(n,i=b,a=b)=>{var c=Kr();Z(H(c),17,()=>u(i()).entries,e=>e.path,(n,i,c,f)=>{let g=L(()=>G(i).kind===`directory`),_=L(()=>G(l).find(e=>e.entry.path===G(i).path)),v=L(()=>G(l).findIndex(e=>e.entry.path===G(i).path));var y=ph();let b;var x=V(y);let S;var C=V(x),w=e=>{var t=oh(),n=V(t,!0);F(t),W((e,r)=>{Q(t,`aria-label`,e),Y(n,r)},[()=>`${d(G(i).path)?`Collapse`:`Expand`} ${G(i).name}`,()=>d(G(i).path)?`−`:`+`]),K(`click`,t,e=>{e.stopPropagation(),p(G(i))}),J(e,t)},T=e=>{J(e,sh())};X(C,e=>{G(g)?e(w):e(T,-1)});var E=U(C,2),D=V(E,!0);F(E);var ee=U(E),O=e=>{J(e,ch())},te=e=>{var t=lh();W(()=>Q(t,`id`,`${G(i).path}-unsupported`)),J(e,t)};X(ee,e=>{r()&&!G(g)?e(O):G(i).kind===`symlink`&&e(te,1)}),F(x);var ne=U(x,2),re=n=>{let r=L(()=>u(G(i).path));var o=fh(),s=V(o),c=e=>{J(e,uh())};X(s,e=>{G(r).loading&&e(c)});var l=U(s,2),d=e=>{var n=dh(),r=V(n);F(n),W(()=>Y(r,`Retry ${G(i).name??``}`)),K(`click`,n,()=>void t.controller.load(G(i).path)),J(e,n)};X(l,e=>{G(r).error&&e(d)});var f=U(l,2);e(f,()=>G(i).path,()=>a()+1);var p=U(f,2),m=e=>{var n=dh(),r=V(n);F(n),W(()=>Y(r,`Load more in ${G(i).name??``}`)),K(`click`,n,()=>void t.controller.load(G(i).path,!0)),J(e,n)};X(p,e=>{G(r).cursor&&e(m)}),F(o),W(()=>Q(o,`aria-label`,`Contents of ${G(i).name}`)),J(n,o)},ie=L(()=>G(g)&&d(G(i).path));X(ne,e=>{G(ie)&&e(re)}),F(y),Ui(y,(e,t)=>o[t.path]=e,e=>o?.[e.path],()=>[G(i)]),W(e=>{b=Si(y,1,`treeitem svelte-am0nvt`,null,b,{symlink:G(i).kind===`symlink`}),Q(y,`aria-level`,a()),Q(y,`aria-expanded`,e),Q(y,`aria-selected`,G(i).kind===`symlink`?`false`:t.controller.selectedPath===G(i).path),Q(y,`aria-disabled`,G(i).kind===`symlink`),Q(y,`aria-describedby`,G(i).kind===`symlink`?`${G(i).path}-unsupported`:void 0),Q(y,`tabindex`,G(s)===G(i).path||!G(s)&&G(v)===0?0:-1),S=wi(x,``,S,{"--level":a()}),Y(D,G(i).name)},[()=>G(g)?d(G(i).path):void 0]),Lr(`focus`,y,()=>B(s,G(i).path,!0)),K(`keydown`,y,e=>m(e,G(_),G(v))),K(`click`,y,e=>{e.stopPropagation(),h(G(i))}),J(n,y)}),J(n,c)};var _=V(g),v=e=>{J(e,mh())};X(_,e=>{G(c).loading&&e(v)});var y=U(_,2),x=e=>{var r=hh();K(`click`,r,()=>void t.controller.load(n())),J(e,r)};X(y,e=>{G(c).error&&e(x)});var S=U(y,2);e(S,n,()=>1);var C=U(S,2),w=e=>{var r=gh();K(`click`,r,()=>void t.controller.load(n(),!0)),J(e,r)};X(C,e=>{G(c).cursor&&e(w)}),F(g)}J(e,g),$e()}Rr([`keydown`,`click`]);var yh=class{workspaceId;read;changed;failed;expanded=new Set([``]);selectedPath=``;pages=new Map;generations=new Map;requests=new Map;version=0;constructor(e,t,n,r=()=>{}){this.workspaceId=e,this.read=t,this.changed=n,this.failed=r}state(e){return this.pages.get(e)??{entries:[],loading:!1,error:!1}}async load(e=``,t=!1){let n=this.state(e);if(n.loading||t&&!n.cursor)return;let r=(this.generations.get(e)??0)+1;this.generations.set(e,r),this.requests.get(e)?.abort();let i=new AbortController;this.requests.set(e,i),this.pages.set(e,{...n,loading:!0,error:!1}),this.publish();try{let a=await this.read(this.workspaceId,{directory:e,...t?{cursor:n.cursor}:{}},i.signal);if(i.signal.aborted||this.generations.get(e)!==r)return;let o=t?bh(n.entries,a.entries):a.entries;this.pages.set(e,{entries:o,cursor:a.nextCursor,loading:!1,error:!1})}catch(t){if(i.signal.aborted||this.generations.get(e)!==r)return;this.pages.set(e,{...n,loading:!1,error:!0}),this.failed(t)}finally{this.requests.get(e)===i&&this.requests.delete(e),this.publish()}}async expand(e){this.expanded.add(e),this.publish(),this.pages.has(e)||await this.load(e)}collapse(e){this.expanded.delete(e),this.generations.set(e,(this.generations.get(e)??0)+1),this.requests.get(e)?.abort(),this.publish()}async refresh(e=``){this.invalidateBranch(e),await this.load(e)}select(e){this.selectedPath=e,this.publish()}close(){this.requests.forEach(e=>e.abort()),this.requests.clear()}invalidateBranch(e){for(let t of[...this.pages.keys()])(t===e||t.startsWith(e?`${e}/`:``))&&(this.pages.delete(t),this.generations.set(t,(this.generations.get(t)??0)+1),this.requests.get(t)?.abort())}publish(){this.version+=1,this.changed()}};function bh(e,t){let n=new Set(e.map(e=>e.path));return[...e,...t.filter(e=>!n.has(e.path))]}function xh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Sh=xh();function Ch(e){Sh=e}var wh={exec:()=>null};function Th(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function Eh(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Oh.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Dh=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Oh={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Th(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Th(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Th(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Th(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Th(e=>RegExp(`^ {0,${e}}(?:</?(?:${Uh})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,`i`)),blockquoteBeginRegex:Th(e=>RegExp(`^ {0,${e}}>`))},kh=/^(?:[ \t]*(?:\n|$))+/,Ah=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jh=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mh=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Nh=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ph=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Fh=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ih=Eh(Fh).replace(/bull/g,Ph).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Lh=Eh(Fh).replace(/bull/g,Ph).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Rh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,zh=/^[^\n]+/,Bh=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Vh=Eh(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Bh).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Hh=Eh(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Ph).getRegex(),Uh=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Wh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Gh=Eh(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Wh).replace(`tag`,Uh).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Kh=e=>Eh(Rh).replace(`hr`,Mh).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Uh).getRegex(),qh=Kh(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Jh=Kh(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Yh={blockquote:Eh(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Jh).getRegex(),code:Ah,def:Vh,fences:jh,heading:Nh,hr:Mh,html:Gh,lheading:Ih,list:Hh,newline:kh,paragraph:qh,table:wh,text:zh},Xh=Eh(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Mh).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Uh).getRegex(),Zh={...Yh,lheading:Lh,table:Xh,paragraph:Eh(Rh).replace(`hr`,Mh).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Xh).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Uh).getRegex()},Qh={...Yh,html:Eh(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Wh).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:wh,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Eh(Rh).replace(`hr`,Mh).replace(`heading`,` *#{1,6} *[^
|
|
38
|
+
]`).replace(`lheading`,Ih).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},$h=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,eg=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,tg=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,ng=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,rg=/[\p{P}\p{S}]/u,ig=/[\s\p{P}\p{S}]/u,ag=/[^\s\p{P}\p{S}]/u,og=Eh(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,ig).getRegex(),sg=/[\p{Pi}\p{Ps}"']/u,cg=/(?!~)[\p{P}\p{S}]/u,lg=/(?!~)[\s\p{P}\p{S}]/u,ug=/(?:[^\s\p{P}\p{S}]|~)/u,dg=Eh(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Dh?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),fg=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,pg=Eh(fg,`u`).replace(/punct/g,rg).getRegex(),mg=Eh(fg,`u`).replace(/punct/g,cg).getRegex(),hg=Eh(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,sg).replace(/punct/g,rg).getRegex(),gg=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,_g=Eh(gg,`gu`).replace(/notPunctSpace/g,ag).replace(/punctSpace/g,ig).replace(/punct/g,rg).getRegex(),vg=Eh(gg,`gu`).replace(/notPunctSpace/g,ug).replace(/punctSpace/g,lg).replace(/punct/g,cg).getRegex(),yg=Eh(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ag).replace(/punctSpace/g,ig).replace(/punct/g,rg).getRegex(),bg=Eh(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,ag).replace(/punctSpace/g,ig).replace(/punct/g,rg).getRegex(),xg=Eh(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ag).replace(/punctSpace/g,ig).replace(/punct/g,rg).getRegex(),Sg=Eh(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,rg).getRegex(),Cg=Eh(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ag).replace(/punctSpace/g,ig).replace(/punct/g,rg).getRegex(),wg=Eh(/\\(punct)/,`gu`).replace(/punct/g,rg).getRegex(),Tg=Eh(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Eg=Eh(Wh).replace(`(?:-->|$)`,`-->`).getRegex(),Dg=Eh(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Eg).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Og=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,kg=Eh(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,Og).getRegex(),Ag=Eh(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,kg).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),jg=Eh(/^!?\[(label)\]\[(ref)\]/).replace(`label`,kg).replace(`ref`,Bh).getRegex(),Mg=Eh(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Bh).getRegex(),Ng=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,Pg=Eh(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,Og).getRegex(),Fg=Eh(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Eh(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Pg).replace(`ref`,Ng).getRegex()).replace(`nolink`,Eh(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Ng).getRegex()).getRegex(),Ig=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Lg=Eh(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),Rg={_backpedal:wh,anyPunctuation:wg,autolink:Tg,blockSkip:dg,br:tg,code:eg,del:wh,delLDelim:wh,delRDelim:wh,emStrongLDelim:pg,emStrongRDelimAst:_g,emStrongRDelimUnd:bg,escape:$h,link:Ag,nolink:Mg,punctuation:og,reflink:jg,reflinkSearch:Fg,tag:Dg,text:ng,url:wh},zg={...Rg,emStrongLDelim:hg,emStrongRDelimAst:yg,emStrongRDelimUnd:xg,link:Eh(/^!?\[(label)\]\((.*?)\)/).replace(`label`,kg).getRegex(),reflink:Eh(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,kg).getRegex()},Bg={...Rg,emStrongRDelimAst:vg,emStrongLDelim:mg,delLDelim:Sg,delRDelim:Cg,url:Eh(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,Lg).replace(`protocol`,Ig).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Eh(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,Ig).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},Vg={...Bg,br:Eh(tg).replace(`{2,}`,`*`).getRegex(),text:Eh(Bg.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Hg={normal:Yh,gfm:Zh,pedantic:Qh},Ug={normal:Rg,gfm:Bg,breaks:Vg,pedantic:zg},Wg={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Gg=e=>Wg[e];function Kg(e,t){if(t){if(Oh.escapeTest.test(e))return e.replace(Oh.escapeReplace,Gg)}else if(Oh.escapeTestNoEncode.test(e))return e.replace(Oh.escapeReplaceNoEncode,Gg);return e}function qg(e){return e.replace(Oh.numericCharacterReference,(e,t,n)=>{let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:String.fromCodePoint(r)})}function Jg(e){try{e=encodeURI(e).replace(Oh.percentDecode,`%`)}catch{return null}return e}function Yg(e,t){let n=e.replace(Oh.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Oh.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(Oh.slashPipe,`|`);return n}function Xg(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Zg(e){let t=e.split(`
|
|
39
|
+
`),n=t.length-1;for(;n>=0&&Oh.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
40
|
+
`)}function Qg(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function $g(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function e_(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function t_(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`;r.state.inLink=!0;let l=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),f=r.state.linkEmitted;if(r.state.linkEmitted=l,r.state.inLink=!1,!c){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:d}}function n_(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
41
|
+
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(`
|
|
42
|
+
`)}function r_(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var i_=class{options;rules;lexer;constructor(e){this.options=e||Sh}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Zg(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=n_(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Xg(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Xg(t[0],`
|
|
43
|
+
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Xg(t[0],`
|
|
44
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Xg(t[0],`
|
|
45
|
+
`).split(`
|
|
46
|
+
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
47
|
+
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
48
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
49
|
+
${s}`:s,r=r?`${r}
|
|
50
|
+
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
|
|
51
|
+
`),o=t.raw+`
|
|
52
|
+
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s;let c=o.substring(s.raw.length).replace(/^\n/,``),l=c?c.split(`
|
|
53
|
+
`).length:0,d=l?e.slice(0,-l):e;d.length>0&&(n=`${n}
|
|
54
|
+
${d.join(`
|
|
55
|
+
`)}`),r=r.substring(0,r.length-t.text.length)+s.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
|
|
56
|
+
`+e.join(`
|
|
57
|
+
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
58
|
+
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split(`
|
|
59
|
+
`,1)[0],l=t[1].length,u=this.options.pedantic?e_(c,l):c.replace(this.rules.other.leadingSpaceTab,e=>e_(e,l)),d=e.split(`
|
|
60
|
+
`,1)[0],f=!u.trim(),p=0;if(this.options.pedantic?(p=2,s=u.trimStart()):f?p=l+1:(p=u.search(this.rules.other.nonSpaceChar),p=p>4?1:p,s=u.slice(p),p+=l),f&&this.rules.other.blankLine.test(d)&&(r+=d+`
|
|
61
|
+
`,e=e.substring(d.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),i=this.rules.other.fencesBeginRegex(p),a=this.rules.other.headingBeginRegex(p),o=this.rules.other.htmlBeginRegex(p),c=this.rules.other.blockquoteBeginRegex(p);for(;e;){let l=e.split(`
|
|
62
|
+
`,1)[0],m;if(d=l,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting,` `),m=d):m=d.replace(this.rules.other.leadingSpaceTab,e=>e.replace(this.rules.other.tabCharGlobal,` `)),i.test(d)||a.test(d)||o.test(d)||c.test(d)||t.test(d)||n.test(d))break;if(m.search(this.rules.other.nonSpaceChar)>=p||!d.trim())s+=`
|
|
63
|
+
`+m.slice(p);else{if(f||u.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(u)||a.test(u)||n.test(u))break;s+=`
|
|
64
|
+
`+d}f=!d.trim(),r+=l+`
|
|
65
|
+
`,e=e.substring(l.length+1),u=m.slice(p)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Zg(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=Qg(t[1]).replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:Xg(t[0],`
|
|
66
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Yg(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
67
|
+
`):[],a={type:`table`,raw:Xg(t[0],`
|
|
68
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Yg(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:Xg(t[0],`
|
|
69
|
+
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
70
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&r_(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=Xg(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=$g(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let i=t[2],a=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(i);e&&(i=e[1],a=e[3])}else a=t[3]?t[3].slice(1,-1):``;return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(i=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i.slice(1):i.slice(1,-1)),t_(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,`$1`),title:a&&a.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&r_(e,n[1],r,this.rules))return;let i=t[Qg((n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `))];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return t_(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,o,s=i,c=0,l=r[0][0],u=n===l,d=l===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(o=[...a].length,r[3]||r[4]){s+=o;continue}else if(r[5]||r[6]){if(i%3&&!((i+o)%3)){c+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let t=[...r[0]][0].length,n=e.slice(0,i+r.index+t+o);if(Math.min(i,o)%2){let e=n.slice(1,-1);return{type:`em`,raw:n,text:e,tokens:this.lexer.inlineTokens(e)}}let l=n.slice(2,-2);return{type:`strong`,raw:n,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:e?t[0]:qg(t[0]),escaped:e}}}},a_=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Sh,this.options.tokenizer=this.options.tokenizer||new i_,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let t={other:Oh,block:Hg.normal,inline:Ug.normal};this.options.pedantic?(t.block=Hg.pedantic,t.inline=Ug.pedantic):this.options.gfm&&(t.block=Hg.gfm,this.options.breaks?t.inline=Ug.breaks:t.inline=Ug.gfm),this.tokenizer.rules=t}static get rules(){return{block:Hg,inline:Ug}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Oh.carriageReturn,`
|
|
71
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Oh.tabCharGlobal,` `).replace(Oh.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
72
|
+
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
73
|
+
`)?``:`
|
|
74
|
+
`)+i.raw,n.text+=`
|
|
75
|
+
`+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
76
|
+
`)?``:`
|
|
77
|
+
`)+i.raw,n.text+=`
|
|
78
|
+
`+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
79
|
+
`)?``:`
|
|
80
|
+
`)+i.raw,r.text+=`
|
|
81
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
82
|
+
`)?``:`
|
|
83
|
+
`)+i.raw,n.text+=`
|
|
84
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(!(e.charAt(0)===`!`||!Object.hasOwn(this.tokens.links,Qg(e.slice(n+1,-1))))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,t=n=>{let r=n.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,Qg(n.slice(r+1,-1))))return n;if(r>1&&n.charAt(0)!==`!`){let i=n.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,t)+`][`+`a`.repeat(n.length-r-2)+`]`}return`[`+`a`.repeat(n.length-2)+`]`};n=n.replace(e,t)}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,e=>`+`.repeat(e.length)),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+`[`+`a`.repeat(e.length-r-2)+`]`}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(n=>(o=n.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let n=t.at(-1);o.type===`text`&&n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e,n,i)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let s=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=o.raw,n.text+=o.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},o_=class{options;parser;constructor(e){this.options=e||Sh}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Oh.notSpaceStart)?.[0],i=e?e.replace(Oh.endingNewline,``)+`
|
|
85
|
+
`:``;return r?`<pre><code class="language-`+Kg(r)+`">`+(n?i:Kg(i,!0))+`</code></pre>
|
|
86
|
+
`:`<pre><code>`+(n?i:Kg(i,!0))+`</code></pre>
|
|
87
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
88
|
+
${this.parser.parse(e)}</blockquote>
|
|
89
|
+
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
90
|
+
`}hr(e){return`<hr>
|
|
91
|
+
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
92
|
+
`+r+`</`+i+`>
|
|
93
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
94
|
+
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
95
|
+
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
96
|
+
<thead>
|
|
97
|
+
`+t+`</thead>
|
|
98
|
+
`+r+`</table>
|
|
99
|
+
`}tablerow({text:e}){return`<tr>
|
|
100
|
+
${e}</tr>
|
|
101
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
102
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Kg(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?Kg(n,!0):this.parser.parseInline(r),o=Jg(e);if(o===null)return a;e=Kg(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+Kg(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Jg(e);if(i===null)return Kg(n);e=i;let a=`<img src="${Kg(e)}" alt="${Kg(n)}"`;return t&&(a+=` title="${Kg(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Kg(e.text)}},s_=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},c_=class e{options;renderer;textRenderer;constructor(e){this.options=e||Sh,this.options.renderer=this.options.renderer||new o_,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new s_}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},l_=class{options;block;constructor(e){this.options=e||Sh}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?a_.lex:a_.lexInline}provideParser(e=this.block){return e?c_.parse:c_.parseInline}},u_=new class{defaults=xh();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=c_;Renderer=o_;TextRenderer=s_;Lexer=a_;Tokenizer=i_;Hooks=l_;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new o_(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new i_(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new l_;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];l_.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&l_.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return a_.lex(e,t??this.defaults)}parser(e,t){return c_.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?a_.lex:a_.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?c_.parse:c_.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?a_.lex:a_.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?c_.parse:c_.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
103
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Kg(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function d_(e,t){return u_.parse(e,t)}d_.options=d_.setOptions=function(e){return u_.setOptions(e),d_.defaults=u_.defaults,Ch(d_.defaults),d_},d_.getDefaults=xh,d_.defaults=Sh;function f_(...e){return u_.use(...e),d_.defaults=u_.defaults,Ch(d_.defaults),d_}d_.use=f_,d_.walkTokens=function(e,t){return u_.walkTokens(e,t)},d_.parseInline=u_.parseInline,d_.Parser=c_,d_.parser=c_.parse,d_.Renderer=o_,d_.TextRenderer=s_,d_.Lexer=a_,d_.lexer=a_.lex,d_.Tokenizer=i_,d_.Hooks=l_,d_.parse=d_,d_.options,d_.setOptions,d_.walkTokens,d_.parseInline,c_.parse,a_.lex;function p_(e,t){this.v=e,this.k=t}function m_(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h_(e){if(Array.isArray(e))return e}function g_(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function __(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
104
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function v_(e,t){return h_(e)||g_(e,t)||y_(e,t)||__()}function y_(e,t){if(e){if(typeof e==`string`)return m_(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m_(e,t):void 0}}function b_(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof p_;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}b_.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},b_.prototype.next=function(e){return this._invoke(`next`,e)},b_.prototype.throw=function(e){return this._invoke(`throw`,e)},b_.prototype.return=function(e){return this._invoke(`return`,e)};var x_=Object.entries,S_=Object.setPrototypeOf,C_=Object.isFrozen,w_=Object.getPrototypeOf,T_=Object.getOwnPropertyDescriptor,E_=Object.freeze,D_=Object.seal,O_=Object.create,k_=typeof Reflect<`u`&&Reflect,A_=k_.apply,j_=k_.construct;E_||=function(e){return e},D_||=function(e){return e},A_||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},j_||=function(e){return new e(...[...arguments].slice(1))};var M_=Q_(Array.prototype.forEach);Array.prototype.indexOf;var N_=Q_(Array.prototype.lastIndexOf),P_=Q_(Array.prototype.pop),F_=Q_(Array.prototype.push);Array.prototype.slice;var I_=Q_(Array.prototype.splice),L_=Array.isArray,R_=Q_(String.prototype.toLowerCase),z_=Q_(String.prototype.toString),B_=Q_(String.prototype.match),V_=Q_(String.prototype.replace),H_=Q_(String.prototype.indexOf),U_=Q_(String.prototype.trim),W_=Q_(Number.prototype.toString),G_=Q_(Boolean.prototype.toString),K_=typeof BigInt>`u`?null:Q_(BigInt.prototype.toString),q_=typeof Symbol>`u`?null:Q_(Symbol.prototype.toString),J_=Q_(Object.prototype.hasOwnProperty),Y_=Q_(Object.prototype.toString),X_=Q_(RegExp.prototype.test),Z_=$_(TypeError);function Q_(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return A_(e,t,n)}}function $_(e){return function(){return j_(e,[...arguments])}}function ev(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:R_;if(S_&&S_(e,null),!L_(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(C_(t)||(t[r]=e),i=e)}e[i]=!0}return e}function tv(e){for(let t=0;t<e.length;t++)J_(e,t)||(e[t]=null);return e}function nv(e){let t=O_(null);for(let r of x_(e)){var n=v_(r,2);let i=n[0],a=n[1];J_(e,i)&&(L_(a)?t[i]=tv(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=nv(a):t[i]=a)}return t}function rv(e){switch(typeof e){case`string`:return e;case`number`:return W_(e);case`boolean`:return G_(e);case`bigint`:return K_?K_(e):`0`;case`symbol`:return q_?q_(e):`Symbol()`;case`undefined`:return Y_(e);case`function`:case`object`:{if(e===null)return Y_(e);let t=e,n=iv(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Y_(e)}return Y_(e)}default:return Y_(e)}}function iv(e,t){for(;e!==null;){let n=T_(e,t);if(n){if(n.get)return Q_(n.get);if(typeof n.value==`function`)return Q_(n.value)}e=w_(e)}function n(){return null}return n}function av(e){try{return X_(e,``),!0}catch{return!1}}var ov=E_(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),sv=E_(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),cv=E_([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),lv=E_([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),uv=E_(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),dv=E_([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),fv=E_([`#text`]),pv=E_(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),mv=E_(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),hv=E_(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),gv=E_([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),_v=D_(/{{[\w\W]*|^[\w\W]*}}/g),vv=D_(/<%[\w\W]*|^[\w\W]*%>/g),yv=D_(/\${[\w\W]*/g),bv=D_(/^data-[\-\w.\u00B7-\uFFFF]+$/),xv=D_(/^aria-[\-\w]+$/),Sv=D_(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Cv=D_(/^(?:\w+script|data):/i),wv=D_(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Tv=D_(/^html$/i),Ev=D_(/^[a-z][.\w]*(-[.\w]+)+$/i),Dv=D_(/<[/\w!]/g),Ov=D_(/<[/\w]/g),kv=D_(/<\/no(script|embed|frames)/i),Av=D_(/\/>/i),jv={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Mv=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],Nv=E_(ev({},Mv)),Pv=function(){let e={};return M_(Mv,t=>{e[t]=D_(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),E_(e)}(),Fv=function(){return typeof window>`u`?null:window},Iv=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Lv=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Rv=function(e,t,n,r){return J_(e,t)&&L_(e[t])?ev(r.base?nv(r.base):{},e[t],r.transform):n},zv=function(e,t,n){let r=J_(e,t)?e[t]:void 0;return r&&typeof r==`object`?nv(r):n()};function Bv(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Fv(),t=e=>Bv(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==jv.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=iv(d,`cloneNode`),p=iv(d,`remove`),m=iv(d,`removeAttributeNode`),h=iv(d,`nextSibling`),g=iv(d,`childNodes`),_=iv(d,`parentNode`),v=iv(d,`shadowRoot`),y=iv(d,`attributes`),b=o&&o.prototype?iv(o.prototype,`nodeType`):null,x=o&&o.prototype?iv(o.prototype,`nodeName`):null,S=o&&o.prototype?iv(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},w=function(e){return x?x(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let T,E=``,D,ee=!1,O=0,te=function(){if(O>0)throw Z_(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ne=function(e){te(),O++;try{return T.createHTML(e)}finally{O--}},re=function(e){te(),O++;try{return T.createScriptURL(e)}finally{O--}},ie=function(){return ee||=(D=Iv(u,i),!0),D},k=n,ae=k.implementation,oe=k.createNodeIterator,se=k.createDocumentFragment,ce=k.getElementsByTagName,le=r.importNode,A=Lv();t.isSupported=typeof x_==`function`&&typeof _==`function`&&ae&&ae.createHTMLDocument!==void 0;let ue=_v,de=vv,fe=yv,j=bv,M=xv,pe=Cv,me=wv,he=Ev,ge=Sv,_e=null,ve=ev({},[...ov,...sv,...cv,...uv,...fv]),ye=null,be=ev({},[...pv,...mv,...hv,...gv]),xe=Object.seal(O_(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Se=null,Ce=null,we=Object.seal(O_(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Te=!0,Ee=!0,De=!1,Oe=!0,ke=!1,Ae=!0,je=!1,Me=!1,Ne=null,Pe=null,Fe=!1,Ie=!1,Le=!1,Re=!1,N=!0,ze=!1,P=`user-content-`,Be=!0,Ve=!1,F={},He=null,Ue=ev({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),We=null,Ge=ev({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ke=null,qe=ev({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Je=`http://www.w3.org/1998/Math/MathML`,Ye=`http://www.w3.org/2000/svg`,Xe=`http://www.w3.org/1999/xhtml`,Ze=Xe,Qe=!1,$e=null,et=ev({},[Je,Ye,Xe],z_),tt=E_([`mi`,`mo`,`mn`,`ms`,`mtext`]),nt=ev({},tt),rt=E_([`annotation-xml`]),it=ev({},rt),at=ev({},[`title`,`style`,`font`,`a`,`script`]),ot=null,st=[`application/xhtml+xml`,`text/html`],I=null,ct=null,lt=n.createElement(`form`),ut=function(e){return e instanceof RegExp||e instanceof Function},dt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ct&&ct===e)return;(!e||typeof e!=`object`)&&(e={}),e=nv(e),ot=st.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,I=ot===`application/xhtml+xml`?z_:R_,_e=Rv(e,`ALLOWED_TAGS`,ve,{transform:I}),ye=Rv(e,`ALLOWED_ATTR`,be,{transform:I}),$e=Rv(e,`ALLOWED_NAMESPACES`,et,{transform:z_}),Ke=Rv(e,`ADD_URI_SAFE_ATTR`,qe,{transform:I,base:qe}),We=Rv(e,`ADD_DATA_URI_TAGS`,Ge,{transform:I,base:Ge}),He=Rv(e,`FORBID_CONTENTS`,Ue,{transform:I}),Se=Rv(e,`FORBID_TAGS`,nv({}),{transform:I}),Ce=Rv(e,`FORBID_ATTR`,nv({}),{transform:I}),F=J_(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?nv(e.USE_PROFILES):e.USE_PROFILES:!1,Te=e.ALLOW_ARIA_ATTR!==!1,Ee=e.ALLOW_DATA_ATTR!==!1,De=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Oe=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ke=e.SAFE_FOR_TEMPLATES||!1,Ae=e.SAFE_FOR_XML!==!1,je=e.WHOLE_DOCUMENT||!1,Ie=e.RETURN_DOM||!1,Le=e.RETURN_DOM_FRAGMENT||!1,Re=e.RETURN_TRUSTED_TYPE||!1,Fe=e.FORCE_BODY||!1,N=e.SANITIZE_DOM!==!1,ze=e.SANITIZE_NAMED_PROPS||!1,Be=e.KEEP_CONTENT!==!1,Ve=e.IN_PLACE||!1,ge=av(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Sv,Ze=typeof e.NAMESPACE==`string`?e.NAMESPACE:Xe,nt=zv(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>ev({},tt)),it=zv(e,`HTML_INTEGRATION_POINTS`,()=>ev({},rt));let t=zv(e,`CUSTOM_ELEMENT_HANDLING`,()=>O_(null));if(xe=O_(null),J_(t,`tagNameCheck`)&&ut(t.tagNameCheck)&&(xe.tagNameCheck=t.tagNameCheck),J_(t,`attributeNameCheck`)&&ut(t.attributeNameCheck)&&(xe.attributeNameCheck=t.attributeNameCheck),J_(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(xe.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),D_(xe),ke&&(Ee=!1),Le&&(Ie=!0),F&&(_e=ev({},fv),ye=O_(null),F.html===!0&&(ev(_e,ov),ev(ye,pv)),F.svg===!0&&(ev(_e,sv),ev(ye,mv),ev(ye,gv)),F.svgFilters===!0&&(ev(_e,cv),ev(ye,mv),ev(ye,gv)),F.mathMl===!0&&(ev(_e,uv),ev(ye,hv),ev(ye,gv))),we.tagCheck=null,we.attributeCheck=null,J_(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?we.tagCheck=e.ADD_TAGS:L_(e.ADD_TAGS)&&(_e===ve&&(_e=nv(_e)),ev(_e,e.ADD_TAGS,I))),J_(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?we.attributeCheck=e.ADD_ATTR:L_(e.ADD_ATTR)&&(ye===be&&(ye=nv(ye)),ev(ye,e.ADD_ATTR,I))),J_(e,`ADD_FORBID_CONTENTS`)&&L_(e.ADD_FORBID_CONTENTS)&&(He===Ue&&(He=nv(He)),ev(He,e.ADD_FORBID_CONTENTS,I)),Be&&(_e[`#text`]=!0),je&&ev(_e,[`html`,`head`,`body`]),_e.table&&(ev(_e,[`tbody`]),delete Se.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Z_(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Z_(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=T;T=e.TRUSTED_TYPES_POLICY;try{E=ne(``)}catch(e){throw T=t,e}}else e.TRUSTED_TYPES_POLICY===null?(T=void 0,E=``):(T===void 0&&(T=ie()),T&&typeof E==`string`&&(E=ne(``)));E_&&E_(e),ct=e},ft=ev({},[...sv,...cv,...lv]),pt=ev({},[...uv,...dv]),mt=function(e,t,n){return t.namespaceURI===Xe?e===`svg`:t.namespaceURI===Je?e===`svg`&&(n===`annotation-xml`||nt[n]):!!ft[e]},ht=function(e,t,n){return t.namespaceURI===Xe?e===`math`:t.namespaceURI===Ye?e===`math`&&it[n]:!!pt[e]},gt=function(e,t,n){return t.namespaceURI===Ye&&!it[n]||t.namespaceURI===Je&&!nt[n]?!1:!pt[e]&&(at[e]||!ft[e])},_t=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ze,tagName:`template`});let n=R_(e.tagName),r=R_(t.tagName);return $e[e.namespaceURI]?e.namespaceURI===Ye?mt(n,t,r):e.namespaceURI===Je?ht(n,t,r):e.namespaceURI===Xe?gt(n,t,r):!!(ot===`application/xhtml+xml`&&$e[e.namespaceURI]):!1},vt=function(e){F_(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw Z_(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},yt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},bt=function(e){Ct(e);let t=g(e);if(t){let e=[];M_(t,t=>{F_(e,t)}),M_(e,e=>{try{p(e)}catch{}})}let n=y(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&yt(e,r,i)}},xt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}F_(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`)if(Ie||Le)try{vt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},St=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||ye[I(i)]||yt(e,r,i)}},Ct=function(e){let t=[e];for(;t.length>0;){let e=t.pop();C(e)===jv.element&&St(e);let n=g(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},L=function(e,t){return Ae?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},wt=function(e){if(!Ae)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=C(e);if(n===jv.processingInstruction||n===jv.comment&&X_(Ov,e.data)){try{p(e)}catch{}continue}if(n===jv.element){let t=e,n=I(w(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&L(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=g(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Tt=function(e){let t=null,r=null;if(Fe)e=`<remove></remove>`+e;else{let t=B_(e,/^[\r\n\t ]+/);r=t&&t[0]}ot===`application/xhtml+xml`&&Ze===Xe&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=T?ne(e):e;if(Ze===Xe)try{t=new l().parseFromString(i,ot)}catch{}if(!t||!t.documentElement){t=ae.createDocument(Ze,`template`,null);try{t.documentElement.innerHTML=Qe?E:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ze===Xe?ce.call(t,je?`html`:`body`)[0]:je?t.documentElement:a},Et=function(e){let t=S?S(e):e.ownerDocument;return oe.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Dt=function(e){return e=V_(e,ue,` `),e=V_(e,de,` `),e=V_(e,fe,` `),e},Ot=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=oe.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Dt(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&M_(i,e=>{At(e.content)&&Ot(e.content)})},kt=function(e){let t=x?x(e):null;return typeof t!=`string`||I(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},At=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===jv.documentFragment}catch{return!1}},R=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function jt(e,n,r){e.length!==0&&M_(e,e=>{e.call(t,n,r,ct)})}let Mt=function(e,t){return!!(Ae&&e.hasChildNodes()&&!R(e.firstElementChild)&&X_(Dv,e.textContent)&&X_(Dv,e.innerHTML)||Ae&&e.namespaceURI===Xe&&Nv[t]&&(R(e.firstElementChild)||typeof e.textContent==`string`&&X_(Pv[t],e.textContent))||e.nodeType===jv.processingInstruction||Ae&&e.nodeType===jv.comment&&X_(Ov,e.data))},Nt=function(e,t){return e instanceof RegExp?X_(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Pt=function(e,t,n){if(!Se[t]&&Bt(t)&&Nt(xe.tagNameCheck,t))return!1;if(Be&&!He[t]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return vt(e),!0},Ft=function(e,t,n,r){return e.length===0?t:t===n||t===r?nv(t):t},It=function(e,t){return e===t||_(e)!==null?!1:(Ve&&Ct(e),!0)},Lt=function(e,n){if(jt(A.beforeSanitizeElements,e,null),It(e,n))return!0;if(kt(e))return vt(e),!0;let r=I(w(e));if(_e=Ft(A.uponSanitizeElement,_e,ve,Ne),jt(A.uponSanitizeElement,e,{tagName:r,allowedTags:_e}),It(e,n))return!0;if(Mt(e,r))return vt(e),!0;if(Se[r]||!(we.tagCheck instanceof Function&&we.tagCheck(r))&&!_e[r]){let t=Pt(e,r,n);return t===!1&&(jt(A.afterSanitizeElements,e,null),It(e,n))?!0:t}if(C(e)===jv.element&&!_t(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&X_(kv,e.innerHTML))return vt(e),!0;if(ke&&e.nodeType===jv.text){let n=Dt(e.textContent);e.textContent!==n&&(F_(t.removed,{element:e.cloneNode()}),e.textContent=n)}return jt(A.afterSanitizeElements,e,null),It(e,n)},Rt=function(e,t,r){if(Ce[t]||L(t,e)||N&&(t===`id`||t===`name`)&&(r in n||r in lt))return!1;let i=ye[t]||we.attributeCheck instanceof Function&&we.attributeCheck(t,e);return Ee&&X_(j,t)||Te&&X_(M,t)?!0:i?Ke[t]||X_(ge,V_(r,me,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&H_(r,`data:`)===0&&We[e]||De&&!X_(pe,V_(r,me,``))?!0:!r:Bt(e)&&Nt(xe.tagNameCheck,e)&&Nt(xe.attributeNameCheck,t,e)||t===`is`&&xe.allowCustomizedBuiltInElements&&Nt(xe.tagNameCheck,r)},zt=ev({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Bt=function(e){return!zt[R_(e)]&&X_(he,e)},Vt=function(e,t,n,r){if(T&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ne(r);case`TrustedScriptURL`:return re(r)}return r},Ht=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),kt(e)?(vt(e),!1):!0}catch{return xt(t,e),!1}},Ut=function(e,n){if(jt(A.beforeSanitizeAttributes,e,null),It(e,n))return;let r=e.attributes;if(!r||kt(e))return;ye=Ft(A.uponSanitizeAttribute,ye,be,Pe);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:ye,forceKeepAttr:void 0},a=r.length,o=I(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=I(s),d=l,f=s===`value`?d:U_(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,jt(A.uponSanitizeAttribute,e,i),f=i.attrValue,ze&&(u===`id`||u===`name`)&&H_(f,P)!==0&&(xt(s,e,n),f=P+f,p=!0),Ae&&X_(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){xt(s,e,n);continue}if(u===`attributename`&&B_(f,`href`)){xt(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){xt(s,e,n);continue}if(!Oe&&X_(Av,f)){xt(s,e,n);continue}if(ke&&(f=Dt(f)),!Rt(o,u,f)){xt(s,e,n);continue}f=Vt(o,u,c,f),f!==d&&Ht(e,s,c,f)&&p&&P_(t.removed)}}jt(A.afterSanitizeAttributes,e,null),It(e,n)},Wt=function(e){let t=null,n=Et(e);for(jt(A.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(jt(A.uponSanitizeShadowNode,t,null),Lt(t,e),Ut(t,e),At(t.content)&&Wt(t.content),C(t)===jv.element){let e=v(t);At(e)&&(Gt(e),Wt(e))}jt(A.afterSanitizeShadowDOM,e,null)},Gt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Wt(e.shadow);continue}let n=e.node,r=C(n)===jv.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&I(e)===`template`){let e=n.content;At(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);At(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Qe=!e,Qe&&(e=`<!-->`),typeof e!=`string`&&!R(e)&&(e=rv(e),typeof e!=`string`))throw Z_(`dirty is not a string, aborting`);if(!t.isSupported)return e;Me?(_e=Ne,ye=Pe):dt(n),(A.uponSanitizeElement.length>0||A.uponSanitizeAttribute.length>0)&&(_e=nv(_e)),A.uponSanitizeAttribute.length>0&&(ye=nv(ye)),t.removed=[];let c=Ve&&typeof e!=`string`&&R(e);if(c){wt(e);let t=w(e);if(typeof t==`string`){let n=I(t);if(!_e[n]||Se[n])throw bt(e),Z_(`root node is forbidden and cannot be sanitized in-place`)}if(kt(e))throw bt(e),Z_(`root node is clobbered and cannot be sanitized in-place`);try{Gt(e)}catch(t){throw bt(e),t}}else if(R(e))i=Tt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===jv.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Gt(i);else{if(!Ie&&!ke&&!je&&e.indexOf(`<`)===-1)return T&&Re?ne(e):e;if(i=Tt(e),!i)return Ie?null:Re?E:``}i&&Fe&&vt(i.firstChild);let l=c?e:i;try{let e=Et(l);for(;o=e.nextNode();)Lt(o,l),Ut(o,l),At(o.content)&&Wt(o.content)}catch(n){throw c&&(bt(e),M_(t.removed,e=>{e.element&&Ct(e.element)})),n}if(c){let n=!1;if(M_(t.removed,t=>{t.element&&(t.element===e&&(n=!0),Ct(t.element))}),n)throw Z_(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return ke&&Ot(e),e}if(Ie){if(ke&&Ot(i),Le)for(s=se.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(ye.shadowroot||ye.shadowrootmode)&&(s=le.call(r,s,!0)),s}let u=je?i.outerHTML:i.innerHTML;return je&&_e[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&X_(Tv,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
105
|
+
`+u),ke&&(u=Dt(u)),T&&Re?ne(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dt(e),Me=!0,Ne=_e,Pe=ye},t.clearConfig=function(){ct=null,Me=!1,Ne=null,Pe=null,T=D,E=``},t.isValidAttribute=function(e,t,n){ct||dt({});let r=I(e),i=I(t);return Rt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&J_(A,e)&&F_(A[e],t)},t.removeHook=function(e,t){if(J_(A,e)){if(t!==void 0){let n=N_(A[e],t);return n===-1?void 0:I_(A[e],n,1)[0]}return P_(A[e])}},t.removeHooks=function(e){J_(A,e)&&(A[e]=[])},t.removeAllHooks=function(){A=Lv()},t}var Vv=Bv();function Hv(e){if(e.kind!==`file`)return{format:`text`,text:``};if(/\.(md|markdown)$/i.test(e.path))return{format:`markdown`,text:e.content};if(/\.json$/i.test(e.path))try{return{format:`json`,text:JSON.stringify(JSON.parse(e.content),null,2)}}catch{}return{format:`text`,text:e.content}}function Uv(e){return Vv.sanitize(d_.parse(e,{async:!1,gfm:!0}),{ALLOWED_TAGS:[`p`,`br`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`strong`,`em`,`del`,`blockquote`,`ul`,`ol`,`li`,`pre`,`code`,`hr`,`table`,`thead`,`tbody`,`tr`,`th`,`td`,`a`],ALLOWED_ATTR:[`href`,`title`,`start`]})}function Wv(e,t){let n=t.trim();if(n.startsWith(`/`))return n;let r=e.split(`/`),i=r.indexOf(`.gestalt`);return[...i<0?[]:r.slice(0,i),n].filter(Boolean).join(`/`)}function Gv(e,t){return t.startsWith(`/`)?t:[...e.split(`/`).slice(0,-1),t].join(`/`)}var Kv=q(`<span class="format svelte-14yf39v"> </span>`),qv=q(`<p role="status">Loading preview…</p>`),Jv=q(`<p>This item could not be opened.</p> <!>`,1),Yv=q(`<p class="empty svelte-14yf39v">This folder is empty.</p>`),Xv=q(`<!> <!>`,1),Zv=q(`<div class="markdown svelte-14yf39v"></div>`),Qv=q(`<pre><code> </code></pre>`),$v=q(`<dialog class="file-viewer svelte-14yf39v" aria-labelledby="file-viewer-title"><header class="svelte-14yf39v"><div class="title svelte-14yf39v"><h2 id="file-viewer-title" tabindex="-1" class="svelte-14yf39v"> </h2> <p class="svelte-14yf39v"> </p></div> <!></header> <nav aria-label="Preview controls" class="svelte-14yf39v"><!> <!> <!> <!></nav> <div class="contents svelte-14yf39v"><!></div></dialog>`);function ey(e,t){Qe(t,!0);let n,r,i=z(null),a=z(!0),o=z(!1),s=z(!1),c=z(!1),l=z(0),u=z(null),d=z(on([])),f=z(``),p=L(()=>G(i)?Hv(G(i)):{format:`text`,text:``}),m=L(()=>G(p).format===`markdown`&&!G(s)?Uv(G(p).text):``),h=null,g=null;async function _(e,n=!0){n&&G(i)&&B(d,[...G(d),G(i).path],!0),h?.abort(),G(u)?.close(),B(u,null);let p=new AbortController;h=p,B(f,e,!0),B(a,!0),B(o,!1),B(i,null),B(s,!1),B(c,!1);try{let n=await t.readFile(t.target.workspaceId,e,p.signal);if(p.signal.aborted)return;if(B(i,n,!0),B(f,n.path,!0),n.kind===`directory`){let e=new yh(t.target.workspaceId,t.listDirectory,()=>{B(l,G(l)+1)},t.onerror);B(u,e,!0),await e.load(n.path)}}catch(e){if(p.signal.aborted)return;B(o,!0),t.onerror(e)}finally{p.signal.aborted||(B(a,!1),await Tr(),r?.focus())}}function v(){let e=G(d).at(-1);e!==void 0&&(B(d,G(d).slice(0,-1),!0),_(e,!1))}function y(e){let t=(e.target instanceof Element?e.target.closest(`a`):null)?.getAttribute(`href`);!t||/^(?:https?:|mailto:|#)/i.test(t)||(e.preventDefault(),_(Gv(G(f),t)))}function b(e){return e.addEventListener(`click`,y),{destroy:()=>e.removeEventListener(`click`,y)}}Gi(()=>(g=document.activeElement instanceof HTMLElement?document.activeElement:null,n.showModal(),_(t.target.path,!1),()=>{h?.abort(),G(u)?.close(),n.close(),g?.focus()}));var x=$v(),S=V(x),C=V(S),w=V(C),T=V(w,!0);F(w),Ui(w,e=>r=e,()=>r);var E=U(w,2),D=V(E,!0);F(E),F(C),Va(U(C,2),{get onclick(){return t.onclose},label:`Close file preview`,children:(e,t)=>{He(),J(e,Gr(`Close`))},$$slots:{default:!0}}),F(S);var ee=U(S,2),O=V(ee);{let e=L(()=>!G(d).length);Va(O,{onclick:v,get disabled(){return G(e)},children:(e,t)=>{He(),J(e,Gr(`Back`))},$$slots:{default:!0}})}var te=U(O,2),ne=e=>{Va(e,{onclick:()=>{B(s,!G(s))},get pressed(){return G(s)},children:(e,t)=>{He();var n=Gr();W(()=>Y(n,G(s)?`Show formatted`:`Show source`)),J(e,n)},$$slots:{default:!0}})};X(te,e=>{G(i)?.kind===`file`&&G(p).format!==`text`&&e(ne)});var re=U(te,2),ie=e=>{{let t=L(()=>G(c)?`Fold all JSON`:`Unfold all JSON`);Va(e,{onclick:()=>{B(c,!G(c))},get pressed(){return G(c)},get label(){return G(t)},children:(e,t)=>{He();var n=Gr();W(()=>Y(n,G(c)?`Unfolded`:`Folded`)),J(e,n)},$$slots:{default:!0}})}};X(re,e=>{G(p).format===`json`&&!G(s)&&e(ie)});var k=U(re,2),ae=e=>{var t=Kv(),n=V(t);F(t),W((e,t)=>Y(n,`${e??``} · ${t??``} bytes`),[()=>G(p).format.toUpperCase(),()=>G(i).size.toLocaleString()]),J(e,t)};X(k,e=>{G(i)?.kind===`file`&&e(ae)}),F(ee);var oe=U(ee,2),se=V(oe),ce=e=>{J(e,qv())},le=e=>{var t=Jv();Va(U(H(t),2),{onclick:()=>void _(G(f),!1),children:(e,t)=>{He(),J(e,Gr(`Retry`))},$$slots:{default:!0}}),J(e,t)},A=e=>{var t=Xv(),n=H(t);vh(n,{get controller(){return G(u)},get revision(){return G(l)},get directory(){return G(i).path},onselectionchange:e=>{let t=e.split(`/`).slice(0,-1).join(`/`),n=G(u)?.state(t).entries.find(t=>t.path===e);n?.kind===`file`?_(e):n?.kind===`directory`&&G(u)?.expand(e)}});var r=U(n,2),a=e=>{J(e,Yv())},o=L(()=>!G(u).state(G(i).path).entries.length&&!G(u).state(G(i).path).error);X(r,e=>{G(o)&&e(a)}),J(e,t)},ue=e=>{var t=Kr(),n=H(t),r=e=>{var t=Zv();li(t,()=>G(m),!0),F(t),fi(t,e=>b?.(e)),J(e,t)},a=e=>{ah(e,{get text(){return G(p).text},get unfolded(){return G(c)}})},o=e=>{var t=Qv();let n;var r=V(t),a=V(r,!0);F(r),F(t),W(()=>{n=Si(t,1,`svelte-14yf39v`,null,n,{json:G(p).format===`json`}),Y(a,G(s)?G(i).content:G(p).text)}),J(e,t)};X(n,e=>{G(m)?e(r):G(p).format===`json`&&!G(s)?e(a,1):e(o,-1)}),J(e,t)};X(se,e=>{G(a)?e(ce):G(o)?e(le,1):G(i)?.kind===`directory`&&G(u)?e(A,2):G(i)?.kind===`file`&&e(ue,3)}),F(oe),F(x),Ui(x,e=>n=e,()=>n),W(e=>{Y(T,e),Y(D,G(f)||`/`)},[()=>G(f).split(`/`).filter(Boolean).at(-1)||`Workspace files`]),Lr(`cancel`,x,e=>{e.preventDefault(),t.onclose()}),J(e,x),$e()}var ty=25*1024*1024;function ny(e){return[...e].map(e=>({file:e,status:e.size>26214400?`too-large`:`queued`}))}function ry(e){return e.findIndex(e=>e.status===`queued`)}var iy={phase:`idle`};function ay(e,t){return{phase:`picking`,kind:e,source:t}}function oy(e,t){return e.phase===`picking`?{...e,destination:t}:e}function sy(e){return e.phase!==`picking`||e.destination===void 0?e:{...e,phase:`submitting`}}function cy(e,t){return e.phase===`submitting`?{...e,phase:`conflict`,replaceAllowed:t}:e}function ly(e){return e.phase===`submitting`?{...e,phase:`failed`}:e}function uy(e,t){return e.phase!==`picking`||!e.source||e.kind===`move`&&dy(e.source)===t?!1:!(t===e.source||t.startsWith(`${e.source}/`))}function dy(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}var fy=q(`<li> </li>`),py=q(`<button type="button" class="svelte-qx7639">Replace</button>`),my=q(`<div class="browser-actions svelte-qx7639" aria-label="Upload conflict"><!> <button type="button" class="svelte-qx7639">Keep both</button> <button type="button" class="svelte-qx7639">Cancel remaining</button></div>`),hy=q(`<button type="button" class="svelte-qx7639">Cancel uploads</button>`),gy=q(`<section class="picker svelte-qx7639" aria-label="Upload queue" aria-live="polite"><p class="svelte-qx7639"> </p> <ul></ul> <!></section>`),_y=q(`<button type="button" class="svelte-qx7639">View</button>`),vy=q(`<div class="browser-actions svelte-qx7639" aria-label="Selected file actions"><!> <button type="button" class="svelte-qx7639">Copy</button> <button type="button" class="svelte-qx7639">Move</button> <button type="button" class="svelte-qx7639">Delete</button></div>`),yy=q(`<section class="picker svelte-qx7639" aria-label="Delete confirmation" aria-live="assertive"><h3> </h3> <p class="svelte-qx7639"> </p> <div class="browser-actions svelte-qx7639"><button type="button" class="svelte-qx7639">Cancel</button> <button type="button" class="svelte-qx7639"> </button></div></section>`),by=q(`<section class="picker svelte-qx7639" aria-label="Choose destination folder" aria-live="polite"><p class="svelte-qx7639"><strong> </strong> </p> <p class="svelte-qx7639"> </p> <div class="browser-actions svelte-qx7639"><button type="button" class="svelte-qx7639">Use root folder</button> <button type="button" class="svelte-qx7639"> </button> <button type="button" class="svelte-qx7639">Cancel</button></div></section>`),xy=q(`<section class="picker svelte-qx7639" tabindex="-1" aria-label="File conflict" aria-live="assertive"><h3>Destination already contains this item</h3> <p class="svelte-qx7639"> </p> <div class="browser-actions svelte-qx7639"><!> <button type="button" class="svelte-qx7639">Keep both</button> <button type="button" class="svelte-qx7639">Cancel</button></div></section>`),Sy=q(`<section class="picker svelte-qx7639" aria-label="Transfer failed"><p role="status" class="svelte-qx7639">Transfer could not be completed.</p> <div class="browser-actions svelte-qx7639"><button type="button" class="svelte-qx7639">Try again</button><button type="button" class="svelte-qx7639">Cancel</button></div></section>`),Cy=q(`<section aria-label="File browser error"><p class="svelte-qx7639">Files could not be read. Try again.</p></section>`),wy=q(`<p role="status" class="svelte-qx7639">This folder is empty.</p>`),Ty=q(`<dialog aria-labelledby="file-browser-title" class="svelte-qx7639"><section class="file-browser-shell svelte-qx7639"><header class="svelte-qx7639"><div class="svelte-qx7639"><h2 id="file-browser-title" tabindex="-1" class="svelte-qx7639"> </h2> <p class="svelte-qx7639"> </p></div> <button type="button" class="close svelte-qx7639" aria-label="Close file browser">×</button></header> <div class="browser-actions svelte-qx7639"><button type="button" class="svelte-qx7639">Refresh</button></div> <div class="upload-actions svelte-qx7639"><input class="visually-hidden svelte-qx7639" type="file" multiple="" aria-label="Choose files to upload"/> <p class="svelte-qx7639"> </p> <button type="button" class="svelte-qx7639">Upload files</button></div> <!> <!> <!> <!> <!> <!></section></dialog>`);function Ey(e,t){Qe(t,!0);let n=$(t,`onsuccess`,3,()=>{}),r=$(t,`onmutation`,3,()=>{}),i=z(null),a=z(null),o=z(0),s=z(null),c=z(on(iy)),l=z(null),u=z(``),d=z(!1),f=z(!1),p=z(null),m=z(null),h=z(on([])),g=z(!1),_=z(null),v=z(null),y=L(()=>G(o)<0?{entries:[],loading:!1,error:!1}:G(s)?.state(``)??{entries:[],loading:!0,error:!1}),b=L(()=>{if(!G(s)||!G(u))return;let e=G(u).includes(`/`)?G(u).slice(0,G(u).lastIndexOf(`/`)):``;return G(s).state(e).entries.find(e=>e.path===G(u))}),x=L(()=>`Files in ${t.root.relativePath===`.`?`~/`:`~/${t.root.relativePath}`}`);Gi(async()=>{B(s,new yh(t.root.id,t.listDirectory,()=>{B(o,G(o)+1)},t.onerror),!0),await Tr(),G(i)?.showModal(),G(a)?.focus(),await G(s).load()}),Ki(()=>G(s)?.close());function S(){G(c).phase===`submitting`||G(f)||(G(_)?.abort(),G(s)?.close(),G(i)?.close())}let C=L(()=>G(b)?.kind===`directory`||!G(u)?G(u):``),w=L(()=>G(C)||``);async function T(e=`reject`){if(!(G(g)||!G(s))){B(g,!0);try{for(;;){let n=G(v)?.index??ry(G(h));if(B(v,null),n<0)break;let i=G(h)[n];if(!i||i.status===`too-large`)continue;B(h,G(h).map((e,t)=>t===n?{...e,status:`uploading`}:e),!0);let a=new AbortController;B(_,a,!0);try{let o=await t.uploadFile(t.root.id,{directory:G(w),filename:i.file.name,conflict:e,file:i.file},io(),a.signal);B(h,G(h).map((e,t)=>t===n?{...e,status:`completed`,path:o.path}:e),!0),await G(s).refresh(G(w)),G(s).select(G(w)),B(u,G(w),!0),r()(),e=`reject`}catch(e){let r=e;if(r.status===409){B(h,G(h).map((e,t)=>t===n?{...e,status:`queued`}:e),!0),B(v,{index:n,replaceAllowed:r.replaceAllowed===!0},!0);break}B(h,G(h).map((e,t)=>t===n?{...e,status:a.signal.aborted?`cancelled`:`failed`}:e),!0),t.onerror(e)}finally{B(_,null)}}}finally{B(g,!1);let e=G(h).filter(e=>e.status===`completed`).length;e&&n()(`Uploaded ${e} file${e===1?``:`s`}.`)}}}function E(e){!e||e.length===0||(B(h,ny(e),!0),T())}function D(){G(_)?.abort(),B(h,G(h).map(e=>e.status===`queued`||e.status===`uploading`?{...e,status:`cancelled`}:e),!0),B(v,null)}function ee(e){if(G(c).phase===`submitting`||G(f)){e.preventDefault();return}e.preventDefault(),S()}async function O(){if(!(!G(u)||G(f))){B(f,!0);try{let e=G(u).includes(`/`)?G(u).slice(0,G(u).lastIndexOf(`/`)):``;await t.deleteEntry(t.root.id,G(u),io()),await G(s)?.refresh(e),G(s)?.select(e),B(u,e,!0),n()(`Deleted item.`),r()(),B(d,!1)}catch(e){t.onerror(e)}finally{B(f,!1)}}}async function te(){B(d,!0),await Tr(),G(p)?.focus()}function ne(e){G(u)&&B(c,ay(e,G(u)),!0)}function re(e){uy(G(c),e)&&B(c,oy(G(c),e),!0)}async function ie(e=`reject`){if(!G(s)||G(c).phase!==`picking`&&G(c).phase!==`conflict`)return;let i=G(c).phase===`picking`?sy(G(c)):{...G(c),phase:`submitting`};if(!(!i.source||i.destination===void 0||!i.kind)){B(c,i,!0);try{let a=await(i.kind===`copy`?t.copyEntry:t.moveEntry)(t.root.id,{source:i.source,destinationDirectory:i.destination,conflict:e},io()),o=i.source.includes(`/`)?i.source.slice(0,i.source.lastIndexOf(`/`)):``;i.kind===`copy`?await G(s).refresh(i.destination):await Promise.all([G(s).refresh(o),G(s).refresh(i.destination)]),G(s).select(a.path),n()(`${i.kind===`copy`?`Copied`:`Moved`} ${a.path}.`),r()(),B(c,iy,!0)}catch(e){let n=e;n.status===409?(B(c,cy(i,n.replaceAllowed===!0),!0),await Tr(),G(l)?.focus()):(B(c,ly(i),!0),t.onerror(e))}}}var k=Ty(),ae=V(k),oe=V(ae),se=V(oe),ce=V(se),le=V(ce,!0);F(ce),Ui(ce,e=>B(a,e),()=>G(a));var A=U(ce,2),ue=V(A,!0);F(A),F(se);var de=U(se,2);F(oe);var fe=U(oe,2),j=V(fe);F(fe);var M=U(fe,2),pe=V(M);Ui(pe,e=>B(m,e),()=>G(m));var me=U(pe,2),he=V(me);F(me);var ge=U(me,2);F(M);var _e=U(M,2),ve=e=>{var t=gy(),n=V(t),r=V(n);F(n);var i=U(n,2);Z(i,21,()=>G(h),e=>e.file,(e,t)=>{var n=fy(),r=V(n);F(n),W(()=>Y(r,`${G(t).file.name??``}: ${G(t).path??G(t).status??``}${G(t).status===`too-large`?` (maximum ${ty/1024/1024} MiB)`:``}`)),J(e,n)}),F(i);var a=U(i,2),o=e=>{var t=my(),n=V(t),r=e=>{var t=py();K(`click`,t,()=>void T(`replace`)),J(e,t)};X(n,e=>{G(v).replaceAllowed&&e(r)});var i=U(n,2),a=U(i,2);F(t),K(`click`,i,()=>void T(`keep-both`)),K(`click`,a,D),J(e,t)},s=e=>{var t=hy();K(`click`,t,D),J(e,t)};X(a,e=>{G(v)?e(o):G(g)&&e(s,1)}),F(t),W((e,t)=>Y(r,`${e??``} queued, ${t??``} completed`),[()=>G(h).filter(e=>e.status===`queued`).length,()=>G(h).filter(e=>e.status===`completed`).length]),J(e,t)};X(_e,e=>{G(h).length&&e(ve)});var ye=U(_e,2),be=e=>{var n=vy(),r=V(n),i=e=>{var n=_y();K(`click`,n,()=>t.onview?.(G(u))),J(e,n)};X(r,e=>{t.onview&&e(i)});var a=U(r,2),o=U(a,2),s=U(o,2);F(n),K(`click`,a,()=>ne(`copy`)),K(`click`,o,()=>ne(`move`)),K(`click`,s,()=>void te()),J(e,n)};X(ye,e=>{G(s)&&G(c).phase===`idle`&&G(b)&&G(b).kind!==`symlink`&&e(be)});var xe=U(ye,2),Se=e=>{var t=yy(),n=V(t),r=V(n,!0);F(n);var i=U(n,2),a=V(i,!0);F(i);var o=U(i,2),s=V(o);Ui(s,e=>B(p,e),()=>G(p));var c=U(s,2),l=V(c,!0);F(c),F(o),F(t),W(()=>{Y(r,G(b).kind===`directory`?`Delete folder and all contents`:`Delete file`),Y(a,G(u)),s.disabled=G(f),c.disabled=G(f),Y(l,G(f)?`Deleting…`:`Delete`)}),K(`click`,s,()=>B(d,!1)),K(`click`,c,()=>void O()),J(e,t)};X(xe,e=>{G(d)&&G(b)&&e(Se)});var Ce=U(xe,2),we=e=>{var t=by(),n=V(t),r=V(n),i=V(r);F(r);var a=U(r);F(n);var o=U(n,2),s=V(o);F(o);var l=U(o,2),u=V(l),d=U(u,2),f=V(d);F(d);var p=U(d,2);F(l),F(t),W(e=>{Y(i,`${G(c).kind===`copy`?`Copy`:`Move`}:`),Y(a,` ${G(c).source??``}`),Y(s,`Destination: ${(G(c).destination===``?`root folder`:G(c).destination??`choose a folder`)??``}`),u.disabled=e,d.disabled=G(c).destination===void 0,Y(f,`Confirm ${G(c).kind??``}`)},[()=>!uy(G(c),``)]),K(`click`,u,()=>re(``)),K(`click`,d,()=>void ie()),K(`click`,p,()=>B(c,iy,!0)),J(e,t)},Te=e=>{var t=xy(),n=U(V(t),2),r=V(n,!0);F(n);var i=U(n,2),a=V(i),o=e=>{var t=py();K(`click`,t,()=>void ie(`replace`)),J(e,t)};X(a,e=>{G(c).replaceAllowed&&e(o)});var s=U(a,2),u=U(s,2);F(i),F(t),Ui(t,e=>B(l,e),()=>G(l)),W(()=>Y(r,G(c).destination)),K(`click`,s,()=>void ie(`keep-both`)),K(`click`,u,()=>B(c,iy,!0)),J(e,t)},Ee=e=>{var t=Sy(),n=U(V(t),2),r=V(n),i=U(r);F(n),F(t),K(`click`,r,()=>B(c,{...G(c),phase:`picking`},!0)),K(`click`,i,()=>B(c,iy,!0)),J(e,t)};X(Ce,e=>{G(c).phase===`picking`?e(we):G(c).phase===`conflict`?e(Te,1):G(c).phase===`failed`&&e(Ee,2)});var De=U(Ce,2),Oe=e=>{J(e,Cy())},ke=e=>{J(e,wy())};X(De,e=>{G(s)&&!G(y).loading&&G(y).error?e(Oe):G(s)&&!G(y).loading&&G(y).entries.length===0&&e(ke,1)});var Ae=U(De,2),je=e=>{var t=Kr();$r(H(t),()=>G(o),e=>{{let t=L(()=>G(c).phase===`picking`);vh(e,{get controller(){return G(s)},get revision(){return G(o)},get destinationMode(){return G(t)},ondestinationselect:re,onselectionchange:e=>B(u,e,!0)})}}),J(e,t)};X(Ae,e=>{G(s)&&e(je)}),F(ae),F(k),Ui(k,e=>B(i,e),()=>G(i)),W(()=>{Y(le,G(x)),Y(ue,G(c).phase===`picking`?`Choose destination folder.`:`Browse folders and select a position.`),j.disabled=G(y).loading,Y(he,`Upload destination: ${(G(b)?.kind===`file`?`Select a folder first`:G(u)||`root folder`)??``}`),ge.disabled=G(b)?.kind===`file`||G(g)}),Lr(`close`,k,function(...e){t.onclose?.apply(this,e)}),Lr(`cancel`,k,ee),K(`click`,de,S),K(`click`,j,()=>void G(s)?.refresh()),K(`change`,pe,e=>E(e.currentTarget.files)),K(`click`,ge,()=>G(m)?.click()),J(e,k),$e()}Rr([`click`,`change`]);var Dy=q(`<main class="evidence-mode svelte-1d2e8zz"><!></main>`),Oy=q(`<span class="detached-chat-model svelte-1d2e8zz"> </span>`),ky=q(`<header class="detached-chat-header svelte-1d2e8zz"><div class="detached-chat-context svelte-1d2e8zz"><span class="svelte-1d2e8zz">Chat</span> <strong class="svelte-1d2e8zz"> </strong></div> <!></header>`),Ay=q(`<!> <!> <div class="chat-controls svelte-1d2e8zz" aria-label="Chat controls"><!> <!></div> <div class="chat-tail svelte-1d2e8zz" aria-hidden="true"></div>`,1),jy=q(`<p> </p>`),My=q(`<section class="chat-view svelte-1d2e8zz" aria-labelledby="chat-title"><h2 id="chat-title" class="visually-hidden">Chat</h2> <!> <!> <p class="visually-hidden" aria-live="polite" aria-atomic="true"> </p> <!></section>`),Ny=q(`<p>Loading skill profiles…</p>`),Py=q(`<section class="session-profile-manager" aria-labelledby="session-profile-manager-title"><div class="session-profile-manager-header svelte-1d2e8zz"><h2 id="session-profile-manager-title" tabindex="-1" class="svelte-1d2e8zz">Manage skill profiles</h2> <button type="button" class="close-profile-manager svelte-1d2e8zz" aria-label="Close skill profile editor">×</button></div> <!></section>`),Fy=q(`<!> <!> <!> <!> <!> <!>`,1),Iy=q(`<main class="swipe-surface svelte-1d2e8zz"><!> <!> <!> <!></main> <!>`,1);function Ly(e,t){Qe(t,!0);let n=$(t,`oncreatepasskey`,3,()=>{}),r=pl(location.search),i=z(null),a=z(on(r?`chat`:`sessions`)),o=z(!1),s=z(!1),c=z(!1),l=z(null),u=z(null),d=z(!1),f=z(null),p=null,m=0,h=z(null),g=z(null),_=!1,v=z(`Loading relay…`),y=z(on(Or(()=>t.theme))),b=z(on([])),x=`gpt-6.1-sol`,S=z(`medium`),C=z(`gpt-5.6-terra`),w=z(`high`),T=z({codex:[x],kimi:[]}),E=z([]),D=z(null),ee=z(`codex`),O=z({codex:x,kimi:``}),te=z(null),ne=z(null),re=L(()=>G(te)?.kimi.available??!1),ie=L(()=>G(re)?G(ee):`codex`),k=z([]),ae=z(null),oe=z(`list`),se=z([]),ce=z(``),le=z(``),A=z(``),ue=z(!1),de=z(!1),fe=z(on(new Set)),j=z(null),M=z(on([])),pe=z(new Map),me=z({snapshots:new Map,attention:new Map,pending:new Set,errors:new Map}),he=z(new Map),ge=0,_e=null,ve=L(()=>G(M).some(e=>e.id===G(j))),ye=z(on([])),be=z(`workspace-git`),xe=z(`never`),Se=z(on({starting:!1,error:null})),Ce=L(()=>G(Se).starting),we=z(null),Te=0,Ee=z(null),De=z(null),Oe=z(``),ke=0,Ae=new Map,je=z(on({kind:`unavailable`,sessionId:null})),Me=z({kind:`no-workspace`}),Ne=z(null),Pe=z(null),Fe=z(!1),Ie=null,Le=null,Re=0,N=null,ze=null,P=!1,Be=z(on([])),Ve=0,He=z(null),Ue=L(()=>G(b)[0]?.id??null),We=L(()=>G(M).find(e=>e.id===G(j))?.workspacePath??null),Ge=L(()=>G(M).find(e=>e.id===G(j))??null),Ke=L(()=>Da([{id:`debug`,label:`DEBUG`,tab:`chat`,available:e=>!!e.threadId,run:()=>void zt()}],G(a),G(Ge))),qe=L(()=>Xf(G(Ge)?.workspacePath??``)),Je=L(()=>G(Ge)?`${G(Ge).provider===`kimi`?`Kimi · `:``}${G(Ge).model??x}`:x);function Ye(e){return`kind`in e&&e.kind===`org-source`}function Xe(e){return r?e.filter(e=>e.id===G(j)):e}let Ze=L(()=>G(Ne)&&Ye(G(Ne))?G(Ne):G(Ne)?{kind:`ready`,sessionId:`catalog`,plan:G(Ne)}:G(Fe)?null:G(je).kind===`ready`||G(je).kind===`closing`||G(je).kind===`error`&&G(je).plan?G(je):null),et=L(()=>xd(G(je).kind===`ready`||G(je).kind===`closing`||G(je).kind===`error`?G(je).plan:void 0)),tt=z(on({workspaceId:null,summary:null,loading:!1,refreshing:!1,checkingOut:!1,error:null})),nt=L(()=>G(tt).workspaceId),rt=z(on(new Set)),it=z(!1),at=z(!1),ot=z(null),st=z(null),I=z(null),ct=on({}),lt=z({}),ut=z(null),dt=``,ft=new au({requestFrame:e=>requestAnimationFrame(e),cancelFrame:e=>cancelAnimationFrame(e),reducedMotion:()=>window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,scrollTail:e=>G(ut)?.scrollIntoView({block:`end`,behavior:e})}),pt=new ou(e=>void Tr().then(e),e=>{G(a)===`chat`&&ft.request(e)}),mt=L(()=>{let e=G(i)?.interactions.findLast(e=>e.state!==`pending`);return e?e.state===`submitting`?`Sending decision.`:e.state===`failed`?`Could not send decision. Retry is available.`:e.state===`resolved`?e.attemptedOutcome===`denied`?`Decision denied.`:e.attemptedOutcome===`dismissed`?`Request is no longer awaiting a response.`:e.attemptedOutcome===`answered`?`Answers sent.`:`Decision approved.`:``:``}),ht=dd((e,n)=>t.authorizedFetch(e,n)),gt=new _o(ht,e=>B(me,e)),_t=new ro({relay:ht,publish:e=>B(pe,new Map(e)),onEvent:(e,t)=>gt.observe(e,t),onAuthoritativeSnapshot:(e,t)=>gt.applyAuthoritative(e,t)}),vt=new ru({relay:ht,cache:dl(),publish:e=>B(i,e,!0),onSessionEvent:e=>ar(e),onRelayEvent:e=>{G(j)&&_t.observe(G(j),e)},onHistoryError:e=>{B(v,nr(e,`SESSION_HISTORY_READ_FAILED`),!0)},onSendError:(e,t)=>{let n=lu(e,`MESSAGE_SEND_FAILED`);if(n.code===`SESSION_WORKSPACE_UNAVAILABLE`){B(Ee,null),B(De,null),wt.enqueue({kind:`warning`,...n});return}B(Ee,n.message,!0),B(De,n.retryable?t:null,!0),B(v,nr(e,`MESSAGE_SEND_FAILED`),!0)},onSendAccepted:(e,t)=>{G(De)===t&&(B(Ee,null),B(De,null));let n=Ae.get(t);n&&n.sessionId===e&&dn(n)},onHistoryPromptAccepted:(e,t)=>{let n=Ae.get(t);n&&n.sessionId===e&&dn(n)}}),yt=new Op({start:ht.startSession},io,e=>B(Se,e,!0)),bt=new id({getSummary:ht.getGitSummary,pull:ht.pullGit,checkout:ht.checkoutGitBranch},e=>!!Mu(G(b),e)?.isGitRepository,e=>B(tt,e,!0),(e,t)=>nr(e,t)),xt=Vm((e,n)=>t.authorizedFetch(e,n)),St=bd({getPlan:ht.getPlan,closePlan:ht.closePlan},e=>{B(je,e,!0),(e.kind===`ready`||e.kind===`closing`)&&B(M,G(M).map(t=>t.id===e.sessionId?{...t,plan:e.plan}:t),!0)}),Ct=Gf(),wt=bu({historyStorage:vu()}),Tt=new URLSearchParams(location.search).get(`tree-evidence`),Et=new URLSearchParams(location.search).get(`toast-evidence`),Dt=new URLSearchParams(location.search).get(`activity-evidence`),Ot=Oo(window.sessionStorage),kt=new Set;Mn(()=>{for(let[e,t]of G(me).attention){let n=`${e}:${t.requestId}`;Ot.claim(n)&&wt.enqueue({kind:`error`,code:`AUTOPILOT_ATTENTION_${t.requestId}`,message:`Autopilot needs your attention.`})}}),Mn(()=>{let e=new Set;for(let[t,n]of G(me).errors){let r=`${t}:${n}`;e.add(r),!kt.has(r)&&(kt.add(r),wt.enqueue({kind:`error`,message:n}))}for(let t of kt)e.has(t)||kt.delete(t)});function At(){B(c,!0)}function R(){B(c,!1),Tr().then(()=>document.querySelector(`.menu-trigger`)?.focus())}function jt(){B(s,!1),Tr().then(()=>document.querySelector(`.menu-trigger`)?.focus())}async function Mt(){try{await ht.quit()}catch(e){throw nr(e,`QUIT_FAILED`),e}}Gi(async()=>{if(!(Tt===`sessions`||Tt===`git`||Et===`error`||Et===`stacked`))try{let e=await el(t.authorizedFetch);B(A,Nu(G(A)||null,G(b),e.workspaces,Du.sessionBase)??``,!0),B(b,e.workspaces,!0),B(k,e.profiles),B(T,{codex:[...new Set([x,...e.models?.codex??[]])],kimi:e.models?.kimi??[]}),B(O,{...G(O),kimi:G(O).kimi||(e.models?.kimi?.[0]??``)}),B(te,e.capabilities?.providers??null);try{if(e.sessionDefaultsError)throw Error(`SESSION_DEFAULTS_READ_FAILED`);let t=e.sessionDefaults;t&&(B(be,t.sandbox,!0),B(xe,t.approvalPolicy,!0),B(ce,t.skillProfile,!0),B(ee,t.provider,!0),B(S,t.reasoningEffort??`medium`,!0),B(C,t.executorModel??`gpt-5.6-terra`,!0),B(w,t.executorReasoningEffort??`high`,!0),B(O,{...G(O),[t.provider]:t.model}),Mu(e.workspaces,t.workspaceId)&&B(A,t.workspaceId,!0),G(T)[t.provider].includes(t.model)||B(T,{...G(T),[t.provider]:[t.model,...G(T)[t.provider]]}))}catch(e){nr(e,`SESSION_DEFAULTS_READ_FAILED`)}B(E,e.versions??[]),B(D,e.branding?.headerIconUrl??null,!0),r||await jn(),B(fe,Ou(G(b)),!0),B(rt,Ou(G(b)),!0);let n=r?null:await Ct.readSelectedSession();if(B(j,r?e.sessions.find(e=>e.id===r)?.id??null:e.sessions.some(e=>e.id===n)?n:e.sessions[0]?.id??null,!0),G(j)){let e=await Ct.readDraftEnvelope(G(j));B(Oe,e.text,!0),ke=e.revision,fn(G(j),e.pending)}B(M,e.sessions,!0);let i=Xe(e.sessions.filter(e=>[`ready`,`turnActive`].includes(e.state)));_t.bootstrap(i,G(j)),gt.bootstrap(i),r||Jt(),St.select(G(j)),G(j)?vt.select(G(j)):r&&B(v,`This session is no longer open in Gestalt Mobile.`)}catch(e){B(v,nr(e,`RELAY_UNAVAILABLE`),!0)}}),Mn(()=>{if(!G(ut))return;let e=new IntersectionObserver(([e])=>ft.observeTail(e?.isIntersecting??!1),{root:null});return e.observe(G(ut)),()=>e.disconnect()}),Mn(()=>{let e=G(i),t=G(a),n=e?JSON.stringify({messages:e.messages.map(({id:e,text:t,complete:n})=>[e,t,n]),activities:e.activities.map(({id:e,label:t,detail:n})=>[e,t,n]),interactions:e.interactions.map(({key:e,state:t,attemptedOutcome:n})=>[e,t,n])}):``;!n||n===dt||(dt=n,t===`chat`&&Nt(`content`))});function Nt(e){pt.schedule(e)}function Pt(){pt.invalidate(),ft.reset(),B(a,`chat`),In(`chat`),Nt(`initial`),Ln()}function Ft(e){B(y,oa(e),!0)}function It(){if(!G(j))return;let e=window.open(ml(location.href,G(j)),hl(G(j)),`popup,width=760,height=900`);if(!e){wt.enqueue({kind:`error`,message:`The Chat window was blocked. Allow pop-ups for this site and try again.`});return}try{e.opener=null}catch{}e.focus()}Ki(()=>{Ie?.abort(),Le?.abort(),pt.invalidate(),ft.cancel(),vt.dispose(),_t.dispose(),gt.dispose(),St.dispose(),bt.dispose(),yt.dispose(),G(ae)?.dispose()});async function Lt(e){B(ee,e,!0);let t=G(T)[e];if(!G(O)[e]&&t[0]&&B(O,{...G(O),[e]:t[0]}),!(t.length>0)){B(ne,e,!0);try{let t=await ht.listSessionModels(e);B(T,{...G(T),[e]:t.models}),!G(O)[e]&&t.models[0]&&B(O,{...G(O),[e]:t.models[0]})}catch(e){nr(e,`SESSION_MODELS_READ_FAILED`)}finally{G(ne)===e&&B(ne,null)}}}async function Rt(){if(!G(A)||G(Ce))return;let e=G(re)?G(ee):`codex`,t=Dp({workspaceId:G(A),profile:`default`,profileState:`ok`});if(t.profile){B(v,t.profile,!0);return}B(v,`Starting session…`);let n=await yt.start(G(A),{provider:e,sandbox:G(be),approvalPolicy:G(xe),model:G(O)[e]||void 0,...e===`codex`?{reasoningEffort:G(S),executorModel:G(C),executorReasoningEffort:G(w)}:{},skillProfile:G(ce)||void 0});if(!n){G(Se).error&&B(v,nr(Error(G(Se).error),`SESSION_START_FAILED`),!0);return}try{B(j,n.id,!0);for(let e of n.effectiveSkillSelection?.warnings??[])wt.enqueue({kind:`warning`,code:`SKILL_PROFILE_MISSING_SKILL`,message:e});St.select(n.id),Ct.saveSelectedSession(n.id),await Wt();let e=await Ct.readDraftEnvelope(n.id);B(Oe,e.text,!0),ke=e.revision,fn(n.id,e.pending),vt.select(n.id,{history:`empty`}),_t.select(n.id),Pt(),B(v,`Session started.`)}catch(e){B(v,nr(e,`SESSION_START_FAILED`),!0)}}async function zt(){if(!G(Ge)?.threadId||G(d))return;let e=G(Ge).id,t=++m;B(d,!0);try{let n=await ht.debugConfirmation(e);t===m&&G(j)===e&&G(a)===`chat`&&B(u,n)}catch(e){nr(e,`DEBUG_CONTEXT_FAILED`)}finally{t===m&&B(d,!1)}}function Bt(){B(u,null),queueMicrotask(()=>document.querySelector(`.menu-trigger`)?.focus())}async function Vt(){let e=G(u);if(e)try{let t=await ht.startSelfDebug(e.context.mobileSession,e.confirmationId);B(u,null),await Wt(),await Xt(t.id)}catch(e){throw nr(e,`DEBUG_START_FAILED`),Yt(),e}}function Ht(e,t){p=t,B(f,e)}function Ut(){B(f,null),queueMicrotask(()=>p?.focus())}async function Wt(){let e=++ge;_e?.abort();let t=new AbortController;_e=t;try{let n=await ht.listSessions(t.signal);if(e!==ge||t.signal.aborted)return;B(M,n.map(e=>G(he).has(e.id)?{...e,plan:G(he).get(e.id)}:e),!0);let r=Xe(G(M).filter(e=>[`ready`,`turnActive`].includes(e.state)));_t.bootstrap(r,G(j)),gt.bootstrap(r)}catch(e){if(t.signal.aborted||ir(e))return;throw e}finally{_e===t&&(_e=null)}}async function Gt(e,t){await gt.toggle(e,t),e===G(j)&&Wt().catch(()=>{})}async function Kt(e){await Gt(e,!0),await Tr(),e===G(j)&&document.getElementById(`chat-autopilot-${e}-button`)?.focus({preventScroll:!0})}async function qt(e,t,n){await gt.resolve(e,t,n),e===G(j)&&Wt().catch(()=>{})}async function Jt(){try{B(ye,await ht.listRecentSessions(),!0)}catch{B(ye,[],!0)}}async function Yt(){try{await Promise.all([Wt(),Jt()])}catch(e){B(v,nr(e,`SESSION_REFRESH_FAILED`),!0)}}async function Xt(e){B(v,`Opening session…`),B(we,e,!0);let t=++Te;try{B(j,e,!0),B(Ee,null),B(De,null),St.select(e),Ct.saveSelectedSession(e),vt.select(e),_t.select(e),Pt();let n=await Ct.readDraftEnvelope(e);t===Te&&G(j)===e&&(B(Oe,n.text,!0),ke=n.revision,fn(e,n.pending))}catch(e){B(v,nr(e,`SESSION_HISTORY_READ_FAILED`),!0)}finally{t===Te&&B(we,null)}}async function Zt(e){B(v,`Opening recent session…`);try{let t=await ht.openRecentSession(e.id,e.cwd,e.provider??`codex`);G(M).some(e=>e.id===t.id)||B(M,[...G(M),t],!0),Yt(),await Xt(t.id)}catch(e){B(v,nr(e,`SESSION_HISTORY_READ_FAILED`),!0)}}async function Qt(e){B(v,`Closing session…`);try{await ht.releaseSession(e),G(j)===e&&(B(j,null),B(a,`sessions`),Ct.saveSelectedSession(null),vt.select(null),_t.select(null),St.select(null)),await Yt(),B(v,`Session closed.`)}catch(e){B(v,nr(e,`SESSION_CLOSE_FAILED`),!0)}}async function $t(){B(ue,!0);try{if(!(await t.authorizedFetch(`/api/session-defaults`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({workspaceId:G(A),skillProfile:G(ce),provider:G(ie),model:G(O)[G(ie)],reasoningEffort:G(S),executorModel:G(C),executorReasoningEffort:G(w),sandbox:G(be),approvalPolicy:G(xe)})})).ok)throw Error(`SESSION_DEFAULTS_SAVE_FAILED`);B(v,`Session defaults saved.`),wt.enqueue({kind:`success`,message:`Session defaults saved.`})}catch(e){nr(e,`SESSION_DEFAULTS_SAVE_FAILED`)}finally{B(ue,!1)}}async function en(e){let t=G(M).find(t=>t.id===e);try{await ht.forgetSession(e),G(j)===e&&(vt.select(null),_t.select(null),B(j,null),Ct.saveSelectedSession(null),St.select(null)),await Yt(),B(ye,Yf(G(ye),t),!0)}catch(e){B(v,`Could not forget session: ${tr(e)}`)}}async function tn(e){await oc(e)?(B(v,`Resume command copied.`),wt.enqueue({kind:`success`,message:G(v)})):B(v,nr(Error(`SESSION_COPY_FAILED`),`SESSION_COPY_FAILED`),!0)}async function nn(e){if(!(!G(j)||G(i)?.activeTurnId))try{let t=await ht.selectModel(G(j),e);B(M,G(M).map(e=>e.id===t.id?{...e,...t}:e),!0),B(Oe,``),B(v,`Model changed to ${e}; it applies to the next turn.`)}catch(e){B(v,`Could not change model: ${tr(e)}`)}}async function rn(e){if(!G(j)||!G(Oe).trim()||!vt.canSubmit(e)||[...Ae.values()].some(e=>e.sessionId===G(j)&&e.revision===ke))return;let t=io(),n={sessionId:G(j),revision:ke,text:G(Oe),operationId:t,kind:e};Ae.set(t,n),Ct.addPendingDraftOperation(G(j),n),e===`send`?vt.send(n.text,t):e===`queue`?vt.queue(n.text,t):vt.interruptAndSend(n.text,t)}let an=()=>rn(`send`),sn=()=>rn(`queue`),cn=()=>rn(`interrupt-send`);async function dn(e){let t=await Ct.consumeAcceptedDraft(e.sessionId,e.revision,e.operationId);t&&Ae.delete(e.operationId),t&&e.sessionId===G(j)&&e.revision===ke?(G(De)===e.operationId&&(B(De,null),B(Ee,null)),B(Oe,``),ke=t.revision,Nt(`explicit`)):e.sessionId===G(j)&&e.revision===ke&&(B(Ee,null),B(De,e.operationId,!0),wt.enqueue({kind:`warning`,code:`PROMPT_LOCAL_RECOVERY_${e.operationId}`,message:`The accepted prompt could not be saved locally. Keep this text until recovery completes. Retry is available.`}))}function fn(e,t){for(let n of t??[])Ae.set(n.operationId,{sessionId:e,...n});e===G(j)&&(t?.length??0)>0&&(B(Ee,null),B(De,t[0].operationId,!0),wt.enqueue({kind:`warning`,code:`PROMPT_RECOVERY_${G(De)}`,message:`A submitted prompt is being recovered. It will not be sent again automatically. Retry is available.`}))}async function pn(){if(!G(De))return;B(Ee,null);let e=Ae.get(G(De));if(!e){await vt.retryPrompt(G(De));return}e.kind===`send`?await vt.send(e.text,e.operationId):e.kind===`queue`?await vt.queue(e.text,e.operationId):await vt.interruptAndSend(e.text,e.operationId)}async function mn(){await vt.interrupt()}function hn(){G(a)===`chat`&&G(j)&&vt.refresh()}function gn(e){if(r||e===`chat`&&!G(ve))return;let t=G(a)!==e;G(a)===`chat`&&e!==`chat`&&(pt.invalidate(),ft.cancel()),B(a,e,!0),In(e),e===`chat`&&(hn(),ft.reset(),Nt(`initial`),t&&Ln()),e===`git`&&G(nt)&&bt.refresh(),e===`plan`&&(G(j)&&St.refresh(G(j)),t||On()),e===`sessions`&&(G(oe)===`profile-manager`&&Fn(!1),Yt(),G(j)&&St.refresh(G(j)))}Mn(()=>{let e=G(Ue);G(a)===`plan`&&Or(()=>wn(e))});let _n=!1;function vn(){document.visibilityState!==`visible`||_n||(_n=!0,queueMicrotask(()=>{_n=!1,document.visibilityState===`visible`&&(G(a)===`git`&&G(nt)&&bt.refresh(),G(a)===`sessions`&&(Yt(),G(j)&&St.refresh(G(j))))}))}let yn=null;function bn(e){return e instanceof Element&&e.closest(`button, input, textarea, select, a, summary, [contenteditable]`)!==null}function xn(e){e.pointerType!==`touch`||bn(e.target)||(yn={pointerId:e.pointerId,x:e.clientX,y:e.clientY})}function Sn(e){if(!yn||e.pointerId!==yn.pointerId)return;let t=yn;yn=null;let n=e.clientX-t.x,r=e.clientY-t.y;Math.abs(n)<48||Math.abs(n)<=Math.abs(r)||gn(Ap(G(a),n<0?1:-1,{chatEnabled:G(ve)}))}function Cn(e){yn?.pointerId===e.pointerId&&(yn=null)}function wn(e=G(Ue),t=!1){if(Ie&&ze===e)return;if(Ie?.abort(),t||(Le?.abort(),B(Ne,null),B(Pe,null)),!e){B(Me,{kind:`no-workspace`});return}let n=new AbortController;Ie=n,ze=e;let r=++Re;B(Me,N?.workspaceId===e?{...N,refreshing:!0}:{kind:`loading`,workspaceId:e}),ht.listWorkspacePlans(e,n.signal).then(t=>{r!==Re||n.signal.aborted||(N={kind:`ready`,workspaceId:e,entries:t},B(Me,N))}).catch(t=>{r!==Re||n.signal.aborted||(G(Ze)||wt.enqueue({kind:`error`,code:`WORKSPACE_PLANS_READ_FAILED`,message:`Workspace Org files could not be listed. Try opening the Plan tab again.`}),B(Me,N?.workspaceId===e?N:{kind:`error`,workspaceId:e,error:t instanceof Error?t.message:`Could not load workspace plans.`}))}).finally(()=>{Ie===n&&(Ie=null)})}function Tn(e,t=!1,n=!0){let r=t?G(Ge)?.workspaceId:G(Ue);if(!r)return;Le?.abort();let i=new AbortController;Le=i;let o=++Ve;P=t,(t&&G(j)?ht.openSessionPlan(G(j),e):ht.getWorkspacePlan(r,e,i.signal)).then(t=>{o!==Ve||i.signal.aborted||(B(Ne,t),B(Pe,e,!0),B(Fe,!1),n&&Tr().then(()=>{requestAnimationFrame(()=>{o===Ve&&!i.signal.aborted&&G(a)===`plan`&&window.scrollTo({top:0,behavior:`instant`})})}))}).catch(()=>{o!==Ve||i.signal.aborted||wt.enqueue({kind:`error`,code:`WORKSPACE_PLAN_OPEN_${e}`,message:`This Org file could not be opened. Check that it is readable and try again.`})}).finally(()=>{Le===i&&(Le=null)})}function En(e){let t=G(Ge)?.workspaceId,n=G(We),r=n?ic(e,n):null;if(!t||!r){wt.enqueue({kind:`error`,code:`ORG_LINK_OUTSIDE_WORKSPACE`,message:`This Org file is not inside the selected workspace and cannot be opened.`});return}gn(`plan`),Tr().then(()=>{G(Ge)?.workspaceId!==t||G(We)!==n||Tn(r,!0)})}function Dn(){B(Ne,null),B(Pe,null),B(Fe,!0),wn()}function On(){G(j)&&St.refresh(G(j)),G(Pe)&&Tn(G(Pe),P,!1),wn(G(Ue),!0)}async function kn(e){let t=G(Ue);if(!(!t||G(Be).includes(e))){B(Be,[...G(Be),e],!0);try{await ht.archiveWorkspacePlan(t,e),N?.workspaceId===t&&(Ie?.abort(),Ie=null,N={...N,entries:N.entries.map(t=>t.planName===e?{...t,archived:!0}:t)},B(Me,N),wn(t,!0)),wt.enqueue({kind:`success`,message:`Plan archived.`})}catch{wt.enqueue({kind:`error`,code:`PLAN_ARCHIVE_FAILED`,message:`The plan could not be archived. Check that it is writable and try again.`})}finally{B(Be,G(Be).filter(t=>t!==e),!0)}}}async function An(e,t){let n=new Xp(ht);await n.load(e,t),B(ae,n,!0)}async function jn(){try{let e=await ht.listSkillProfiles();B(se,e.profiles.filter(e=>!(`error`in e)));let t=e.profiles.find(e=>`error`in e);B(le,t&&`error`in t?t.error.message:``,!0),G(se).some(e=>e.name===G(ce))||B(ce,``)}catch(e){B(se,[]),B(le,e instanceof Error?e.message:`Unable to load saved skill profiles.`,!0)}}async function Nn(e){let t=G(A)||G(b)[0]?.id||``,n=G(k).find(e=>e.state===`ok`)?.name??``;if(!t||!n){B(v,`Choose a workspace and available Codex profile before managing skill profiles.`);return}await An(t,n),B(oe,`profile-manager`)}function Pn(e){queueMicrotask(()=>e.focus())}async function Fn(e=!0){if(B(oe,`list`),await Tr(),e){let e=document.getElementById(`manage-skill-profiles`),t=e?.closest(`.advanced-settings`);t&&(t.open=!0),e?.focus()}}function In(e){requestAnimationFrame(()=>{G(a)===e&&e!==`chat`&&window.scrollTo({top:0})})}function Ln(){Tr().then(()=>{G(a)===`chat`&&document.getElementById(`message`)?.focus({preventScroll:!0})})}function zn(e){bt.select(e.id),B(it,!1)}async function Bn(e,t){let n=!G(Pe)||P,r=n?G(Ge)?.workspaceId:G(Ue),i=G(Pe)??``;if(!r)return[];let a=e=>n?e:Wv(i,e),o=new Set;try{for(let n=0;n<e.length;n+=64){if(t.aborted)return[];(await ht.checkWorkspaceFileReferences(r,e.slice(n,n+64).map(a),t)).paths.forEach(e=>o.add(e))}return e.filter(e=>o.has(a(e)))}catch(e){return t.aborted||nr(e,`WORKSPACE_FILES_READ_FAILED`),[]}}function Vn(e){let t=!G(Pe)||P,n=t?G(Ge)?.workspaceId:G(Ue);n&&B(l,{workspaceId:n,path:t?e:Wv(G(Pe)??``,e)},!0)}function Hn(e){let t=G(nt)?Mu(G(b),G(nt)):null;t&&(B(h,t,!0),B(g,e,!0))}async function Un(){B(h,null),await Tr(),G(g)?.focus({preventScroll:!0})}function Wn(){_||(_=!0,queueMicrotask(()=>{_=!1,G(nt)&&bt.refresh()}))}async function Gn(){let e=G(nt);!e||!Mu(G(b),e)?.isGitRepository||(B(st,G(st)??io(),!0),await bt.pull(G(st)),G(tt).error||B(st,null))}async function Kn(e){if(G(at))return;let n=G(nt)?Mu(G(b),G(nt)):void 0;if(!n||n.isGitRepository){B(ot,null),wt.enqueue({kind:`error`,code:`INVALID_CLONE_DESTINATION`,message:`Select a non-repository folder before cloning.`});return}let r=n.id;B(at,!0),B(ot,null);try{await ht.cloneGitRepository(r,e);let n=await el(t.authorizedFetch),i=ad(G(b),n.workspaces,r,e,G(rt));B(A,Nu(G(A)||null,G(b),n.workspaces,Du.sessionBase)??``,!0),B(b,n.workspaces,!0),bt.select(i.selectedId),B(rt,i.expandedIds,!0),B(ot,`Repository cloned into the selected workspace.`),wt.enqueue({kind:`success`,message:`Repository cloned.`})}catch(e){nr(e,`GIT_CLONE_FAILED`)}finally{B(at,!1)}}async function qn(e){G(nt)&&await bt.checkout(e)}async function Jn(){let e=G(nt);if(e){B(I,G(I)??io(),!0);try{await ht.pushGit(e,G(I)),B(it,!1),await bt.refresh(),B(I,null)}catch(e){nr(e,`GIT_PUSH_FAILED`)}}}async function Yn(e,t){Nt(`explicit`),await vt.respond(e,{decision:t})}async function Xn(e){Nt(`explicit`);let t=e.kind===`quiz`?Ss(e.payload):Cs(e.payload);if(!t)return;let n=t.questions.map(t=>({id:t.id,answer:ct[`${e.requestId}:${t.id}`]??``})),r=t.questions.map((e,t)=>({id:e.id,header:e.header,question:e.question,answer:n[t]?.answer??``}));B(lt,{...G(lt),[e.requestId]:r});let a=e.kind===`quiz`?ws(n):ld(n);try{let t=`quiz-answer:${e.requestId}`,n=G(i)?.prompts.find(e=>e.operationId===t);if(!n||n.state===`failed`){let e=ud(r);G(i)?.activeTurnId?await vt.queue(e,t):await vt.send(e,t)}let o=vt.view.prompts.find(e=>e.operationId===t);if(e.kind===`quiz`&&(!o||o.state===`failed`))return;await vt.respond(e.requestId,a)}catch{B(v,`Could not send quiz answers. Please try again.`)}}async function Zn(e){let t=cd(e.payload);if(!t){B(v,`Codex sent an invalid permission request.`);return}Nt(`explicit`),await vt.respond(e.requestId,t)}function Qn(e){e.kind===`quiz`||e.kind===`userInput`?Xn(e):e.kind===`permissionsApproval`?Zn(e):vt.retryInteraction(e.requestId)}function $n(e,t,n){ct[`${e}:${t}`]=n}function er(e){B(Oe,e,!0),ke+=1;let t=G(j);t&&Ct.replaceDraftText(t,e,ke)}function tr(e){return e instanceof Error?e.message:`Unknown relay error.`}function nr(e,t){let n=lu(e,t);return wt.enqueue({kind:`error`,...n}),n.message}function rr(e){wt.enqueue(e?{kind:`success`,message:`Code copied.`}:{kind:`error`,message:`Code could not be copied. Select it and copy it manually.`})}function ir(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}function ar(e){let t=G(j);if(!t||e.type===`agent.activity.updated`)return;if(e.type===`session.status.updated`){let n=e.payload;su(n)&&B(M,G(M).map(e=>e.id===t?{...e,sessionStatus:n}:e),!0);return}if(e.type===`session.updated`&&typeof e.payload==`object`&&e.payload!==null){let n=e.payload;n.id===t&&B(M,G(M).map(e=>e.id===t?{...e,...n}:e),!0);return}if(e.type!==`plan.updated`&&e.type!==`plan.closed`)return;if(St.applyEvent(t,e),e.type===`plan.closed`){B(he,new Map(G(he)).set(t,void 0)),B(M,G(M).map(e=>e.id===t?{...e,plan:void 0}:e),!0);return}let n=md(e.payload)?e.payload.plan:hd(e.payload)?e.payload:null;n&&B(he,new Map(G(he)).set(t,n)),n&&B(M,G(M).map(e=>e.id===t?{...e,plan:n}:e),!0)}var or=Kr();di(`1d2e8zz`,e=>{Rn(()=>{un.title=r&&G(qe)?`Chat · ${G(qe)} · Gestalt Mobile`:`Gestalt Mobile`})}),Lr(`focus`,ln,vn),Lr(`visibilitychange`,un,vn);var sr=H(or),cr=e=>{to(e,{})},lr=e=>{Eu(e,{get variant(){return Et}})},ur=e=>{var t=Dy();Hu(V(t),{get context(){return Tt}}),F(t),J(e,t)},dr=e=>{var d=Iy(),p=H(d),m=V(p),g=e=>{{let n=L(()=>G(a)===`chat`?Xf(G(M).find(e=>e.id===G(j))?.workspacePath??``):null),r=L(()=>G(a)===`chat`?G(Je):null),i=L(()=>G(a)===`chat`&&G(j)?It:void 0),c=L(()=>G(a)===`chat`&&G(Ge)?()=>{G(Ge)?.resumeCommand&&tn(G(Ge).resumeCommand)}:void 0),l=L(()=>!!G(Ge)?.resumeCommand);ba(e,{get theme(){return G(y)},get sessionPath(){return G(n)},get sessionModel(){return G(r)},get weeklyQuotaRemaining(){return G(et)},get brandIconUrl(){return G(D)},get componentVersions(){return G(E)},get contextualActions(){return G(Ke)},get passkeyAuthEnabled(){return t.passkeyAuthEnabled},get onlock(){return t.onlock},ondevices:()=>B(o,!0),onnotifications:()=>B(s,!0),onscratchpad:At,onquit:Mt,onthemechange:Ft,get ondetach(){return G(i)},get oncopytocli(){return G(c)},get copyToCliAvailable(){return G(l)}})}};X(m,e=>{!G(o)&&!G(s)&&!r&&e(g)});var _=U(m,2),ee=e=>{var t=ky(),n=V(t),i=U(V(n),2),a=V(i,!0);F(i),F(n);var o=U(n,2),s=e=>{var t=Oy(),n=V(t);F(t),W(()=>Y(n,`${G(Ge).provider===`kimi`?`Kimi · `:``}${G(Ge).model??``}`)),J(e,t)};X(o,e=>{G(Ge)?.model&&e(s)}),F(t),W(()=>{Q(i,`title`,G(qe)||r),Y(a,G(qe)||r)}),J(e,t)};X(_,e=>{r&&e(ee)});var te=U(_,2);wu(te,{get queue(){return wt}});var k=U(te,2),he=e=>{zm(e,{get client(){return xt},onclose:()=>{B(o,!1),Tr().then(()=>document.querySelector(`.menu-trigger`)?.focus())},get onlock(){return t.onlock},oncreatepasskey:e=>n()(e)})},ge=e=>{hu(e,{get queue(){return wt},onclose:jt})},_e=e=>{var t=Fy(),n=H(t),o=e=>{var t=My(),n=U(V(t),2);{let e=L(()=>G(j)?G(me).attention.get(G(j))??null:null),t=L(()=>`chat-attention-${G(j)??`none`}`),r=L(()=>G(j)?G(me).pending.has(G(j)):!1);To(n,{get attention(){return G(e)},get controlId(){return G(t)},get pending(){return G(r)},onresolve:(e,t)=>G(j)&&qt(G(j),e,t)})}var a=U(n,2);{let e=L(()=>G(j)?G(me).snapshots.get(G(j))??null:null),t=L(()=>G(j)?G(me).attention.get(G(j))??null:null),n=L(()=>`chat-autopilot-safety-${G(j)??`none`}`),r=L(()=>G(j)?G(me).pending.has(G(j)):!1);Do(a,{get autopilot(){return G(e)},get attention(){return G(t)},get controlId(){return G(n)},get pending(){return G(r)},onrecover:()=>G(j)&&void Kt(G(j)),ondisable:()=>G(j)&&Gt(G(j),!1)})}var o=U(a,2),s=V(o,!0);F(o);var c=U(o,2),l=e=>{var t=Ay(),n=H(t);{let e=L(()=>G(i)?[...G(i).messages]:[]),t=L(()=>G(i)?[...G(i).activities]:[]),r=L(()=>G(i)?.activeTurnId??null),a=L(()=>G(i)?.autopilotAuditTruncated??!1),o=L(()=>G(i)?[...G(i).interactions]:[]);Xc(n,{get messages(){return G(e)},get activities(){return G(t)},get activeTurnId(){return G(r)},get autopilotAuditTruncated(){return G(a)},get interactions(){return G(o)},get answers(){return ct},get submittedAnswers(){return G(lt)},onanswer:$n,onquiz:e=>void Xn(e),onpermission:e=>void Zn(e),ondecision:(e,t)=>void Yn(e,t),onretry:Qn,onopenorg:En,oncopyresult:rr})}var r=U(n,2);{let e=L(()=>G(i)?.status??G(v)),t=L(()=>G(i)?.activeTurnId??null),n=L(()=>G(i)?.starting??!1),a=L(()=>!!(G(M).find(e=>e.id===G(j))&&![`ready`,`turnActive`].includes(G(M).find(e=>e.id===G(j))?.state??``))),o=L(()=>G(De)!==null),s=L(()=>G(T)[G(M).find(e=>e.id===G(j))?.provider??`codex`]),c=L(()=>G(M).find(e=>e.id===G(j))?.provider??`codex`);Xo(r,{get status(){return G(e)},get message(){return G(Oe)},get activeTurnId(){return G(t)},get starting(){return G(n)},get detached(){return G(a)},get retryMessage(){return G(Ee)},get retryable(){return G(o)},get models(){return G(s)},get provider(){return G(c)},onchange:er,onscrollbottom:()=>Nt(`explicit`),onmodelselect:e=>void nn(e),onsend:()=>void an(),onqueue:()=>void sn(),oninterruptsend:()=>void cn(),onretry:()=>void pn(),oninterrupt:()=>void mn()})}var a=U(r,2),o=V(a),s=e=>{{let t=L(()=>G(me).snapshots.get(G(j))??null),n=L(()=>`chat-autopilot-${G(j)}`),r=L(()=>G(me).pending.has(G(j)));xo(e,{compact:!0,get autopilot(){return G(t)},get controlId(){return G(n)},get pending(){return G(r)},ontoggle:e=>G(j)&&Gt(G(j),e)})}};X(o,e=>{G(Ge)?.provider!==`kimi`&&e(s)});var c=U(o,2);{let e=L(()=>G(pe).get(G(j))??null),t=L(()=>G(M).find(e=>e.id===G(j))?.model??x),n=L(()=>G(M).find(e=>e.id===G(j))?.plan);$a(c,{compact:!0,get activity(){return G(e)},get rootModel(){return G(t)},get plan(){return G(n)},onopen:()=>G(j)&&void _t.resync(G(j))})}F(a),Ui(U(a,2),e=>B(ut,e),()=>G(ut)),J(e,t)},u=e=>{var t=jy(),n=V(t,!0);F(t),W(()=>Y(n,r?G(v):G(re)?`Start a session from the Sessions tab to chat with Codex or Kimi.`:`Start a session from the Sessions tab to chat with Codex.`)),J(e,t)};X(c,e=>{G(j)?e(l):e(u,-1)}),F(t),W(()=>Y(s,G(mt))),J(e,t)},s=e=>{Rf(e,{get catalog(){return G(Me)},get state(){return G(Ze)},onopen:Tn,onarchive:kn,get archivingPlans(){return G(Be)},onclose:Dn,onreference:Vn,checkreferences:Bn})},c=e=>{{let t=L(()=>G(nt)?Mu(G(b),G(nt))??null:null);rd(e,{get workspaceTree(){return G(b)},get selectedWorkspace(){return G(t)},get expandedIds(){return G(rt)},get summary(){return G(tt).summary},get refreshing(){return G(tt).refreshing},get checkingOut(){return G(tt).checkingOut},get cloning(){return G(at)},get error(){return G(tt).error},get cloneStatus(){return G(ot)},get confirmingPush(){return G(it)},onpull:()=>void Gn(),oncheckout:e=>void qn(e),onopenpushconfirmation:()=>B(it,!0),onpush:()=>void Jn(),oncancelpush:()=>B(it,!1),onselect:zn,onexpandedchange:e=>B(rt,e,!0),onbrowsefiles:Hn,onclone:e=>void Kn(e)})}},d=e=>{var t=Kr(),n=H(t),r=e=>{var t=Py(),n=V(t),r=V(n);pi(r,()=>Pn);var i=U(r,2);F(n);var a=U(n,2),o=e=>{Yp(e,{get skillsState(){return G(ae)},onrefresh:()=>G(ae)?.refresh()??Promise.resolve(),onprofileschange:()=>void jn(),heading:`Skill profile editor`})},s=e=>{J(e,Ny())};X(a,e=>{G(ae)?e(o):e(s,-1)}),F(t),K(`click`,i,()=>void Fn()),J(e,t)},i=e=>{{let t=L(()=>G(ne)===G(ie));Ep(e,{get sessions(){return G(M)},get recentSessions(){return G(ye)},get selectedSessionId(){return G(j)},get activitySnapshots(){return G(pe)},get autopilotSnapshots(){return G(me).snapshots},get autopilotPending(){return G(me).pending},get autopilotAttention(){return G(me).attention},get workspaceTree(){return G(b)},get workspaceId(){return G(A)},get expandedIds(){return G(fe)},get sandbox(){return G(be)},get approvalPolicy(){return G(xe)},get models(){return G(T)[G(ie)]},get selectedModel(){return G(O)[G(ie)]},get reasoningEffort(){return G(S)},get executorModels(){return G(T).codex},get executorModel(){return G(C)},get executorReasoningEffort(){return G(w)},onreasoningchange:e=>B(S,e,!0),onexecutormodelchange:e=>B(C,e,!0),onexecutorreasoningchange:e=>B(w,e,!0),get provider(){return G(ie)},get kimiAvailable(){return G(re)},get modelsLoading(){return G(t)},get skillProfiles(){return G(se)},get selectedSkillProfile(){return G(ce)},get skillProfileError(){return G(le)},get startingSession(){return G(Ce)},get openingSessionId(){return G(we)},get savingDefaults(){return G(ue)},onsavedefaults:()=>void $t(),onworkspacechange:e=>B(A,e,!0),onexpandedchange:e=>B(fe,e,!0),onsandboxchange:e=>B(be,e,!0),onapprovalpolicychange:e=>B(xe,e,!0),onmodelchange:e=>B(O,{...G(O),[G(ie)]:e}),onproviderchange:e=>void Lt(e),onskillprofilechange:e=>B(ce,e,!0),onmanageprofiles:e=>void Nn(e),onopen:Xt,onselectopen:Xt,onclose:e=>void Qt(e),onautopilottoggle:Gt,onactivityopen:e=>void _t.resync(e),onautopilotresolve:qt,onopenrecent:e=>void Zt(e),onforget:e=>void en(e),oncopyresume:e=>void tn(e),onstart:()=>void Rt(),ondebugtrace:(e,t)=>void Ht(e,t),get advancedExpanded(){return G(de)},set advancedExpanded(e){B(de,e,!0)}})}};X(n,e=>{G(oe)===`profile-manager`?e(r):e(i,-1)}),J(e,t)};X(n,e=>{G(a)===`chat`?e(o):G(a)===`plan`?e(s,1):G(a)===`git`?e(c,2):e(d,-1)});var p=U(n,2),m=e=>{Ea(e,{get confirmation(){return G(u)},onconfirm:Vt,onclose:Bt})};X(p,e=>{G(u)&&e(m)});var g=U(p,2),_=e=>{let t=L(()=>G(f));{let n=L(()=>({workspaceId:G(t).workspaceId??G(t).id,path:G(t).selfDebug.tracePath}));ey(e,{get target(){return G(n)},readFile:async(e,n,r)=>{let i=JSON.stringify(await ht.readDebugTrace(G(t).id,r),null,2);return{kind:`file`,path:n,content:i,size:new TextEncoder().encode(i).byteLength}},get listDirectory(){return ht.listWorkspaceDirectory},onclose:Ut,onerror:e=>nr(e,`DEBUG_TRACE_FAILED`)})}};X(g,e=>{G(f)?.selfDebug&&e(_)});var y=U(g,2),E=e=>{Ey(e,{get root(){return G(h)},onview:e=>{G(h)&&B(l,{workspaceId:G(h).id,path:e},!0)},get listDirectory(){return ht.listWorkspaceDirectory},get copyEntry(){return ht.copyWorkspaceEntry},get moveEntry(){return ht.moveWorkspaceEntry},get deleteEntry(){return ht.deleteWorkspaceEntry},get uploadFile(){return ht.uploadWorkspaceFile},onclose:()=>void Un(),onerror:e=>nr(e,`WORKSPACE_FILES_READ_FAILED`),onsuccess:e=>wt.enqueue({kind:`success`,message:e}),onmutation:Wn})};X(y,e=>{G(h)&&e(E)});var D=U(y,2),ee=e=>{ey(e,{get target(){return G(l)},get readFile(){return ht.getWorkspaceFilePreview},get listDirectory(){return ht.listWorkspaceDirectory},onclose:()=>{B(l,null)},onerror:e=>nr(e,`WORKSPACE_FILES_READ_FAILED`)})};X(D,e=>{G(l)&&e(ee)});var te=U(D,2),k=e=>{Mp(e,{get activeTab(){return G(a)},get chatEnabled(){return G(ve)},get focusTab(){return G(He)},onselect:gn})};X(te,e=>{r||e(k)}),J(e,t)};X(k,e=>{G(o)&&t.passkeyAuthEnabled?e(he):G(s)?e(ge,1):e(_e,-1)}),F(p);var Se=U(p,2),Te=e=>{Zm(e,{onclose:R})};X(Se,e=>{G(c)&&e(Te)}),K(`pointerdown`,p,xn),K(`pointerup`,p,Sn),Lr(`pointercancel`,p,Cn),J(e,d)};X(sr,e=>{Dt===`true`?e(cr):Et===`error`||Et===`stacked`?e(lr,1):Tt===`sessions`||Tt===`git`?e(ur,2):e(dr,-1)}),J(e,or),$e()}Rr([`pointerdown`,`pointerup`,`click`]);function Ry(){throw Error(`AUTH_RESPONSE_INVALID`)}async function zy(e){if(!e.ok){let t;try{let n=await e.json();typeof n==`object`&&n&&`code`in n&&typeof n.code==`string`&&(t=n.code)}catch{}throw Error(t??`AUTH_REQUEST_FAILED_${e.status}`)}return e.json()}function By(e){return!!e&&typeof e==`object`&&[`bootstrap`,`locked`,`authenticated`].includes(e.status)&&typeof e.publicOrigin==`string`&&(e.passkeyAuthEnabled===void 0||typeof e.passkeyAuthEnabled==`boolean`)}function Vy(e){return!!e&&typeof e==`object`&&!!e.options&&typeof e.options.challenge==`string`}function Hy(e){return!!e&&typeof e==`object`&&e.status===`authenticated`}function Uy(e=fetch){async function t(){let t=await zy(await e(`/api/auth/status`,{credentials:`same-origin`}));return By(t)||Ry(),t}async function n(t,n={}){let r=await zy(await e(t,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}));return Vy(r)||Ry(),r}async function r(t,n){let r=await zy(await e(t,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}));return Hy(r)||Ry(),r}return{status:t,registrationOptions:e=>n(`/api/auth/register/options`,e?{enrollmentTicket:e}:{}),verifyRegistration:(e,t)=>r(`/api/auth/register/verify`,{response:e,nickname:t}),loginOptions:()=>n(`/api/auth/login/options`),verifyLogin:e=>r(`/api/auth/login/verify`,{response:e}),logout:async()=>{let t=await e(`/api/auth/logout`,{method:`POST`,credentials:`same-origin`});if(!t.ok)throw Error(`AUTH_REQUEST_FAILED_${t.status}`)}}}function Wy(e,t=fetch){return async(n,r)=>{let i=await t(n,{...r,credentials:`same-origin`});return i.status===401&&(await i.clone().json().catch(()=>null))?.code===`AUTH_REQUIRED`&&e(),i}}function Gy(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Ky(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function qy(){return Jy.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var Jy={stubThis:e=>e};function Yy(e){let{id:t}=e;return{...e,id:Ky(t),transports:e.transports}}function Xy(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var Zy=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function Qy({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new Zy({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new Zy({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new Zy({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new Zy({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new Zy({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new Zy({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new Zy({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new Zy({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!Xy(t))return new Zy({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new Zy({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new Zy({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new Zy({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var $y=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},eb=[`cross-platform`,`platform`];function tb(e){if(e&&!(eb.indexOf(e)<0))return e}async function nb(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!qy())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:Ky(t.challenge),user:{...t.user,id:Ky(t.user.id)},excludeCredentials:t.excludeCredentials?.map(Yy)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=$y.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw Qy({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){rb(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=Gy(e))}catch(e){rb(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=Gy(c.getAuthenticatorData())}catch(e){rb(`getAuthenticatorData()`,e)}return{id:o,rawId:Gy(s),response:{attestationObject:Gy(c.attestationObject),clientDataJSON:Gy(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:tb(a.authenticatorAttachment)}}function rb(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function ib(){if(!qy())return ab.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?ab.stubThis(new Promise(e=>e(!1))):ab.stubThis(e.isConditionalMediationAvailable())}var ab={stubThis:e=>e};function ob({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new Zy({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new Zy({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!Xy(t))return new Zy({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new Zy({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new Zy({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function sb(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!qy())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(Yy));let a={...t,challenge:Ky(t.challenge),allowCredentials:i},o={};if(n){if(!await ib())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=$y.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw ob({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=Gy(u.userHandle)),{id:c,rawId:Gy(l),response:{authenticatorData:Gy(u.authenticatorData),clientDataJSON:Gy(u.clientDataJSON),signature:Gy(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:tb(s.authenticatorAttachment)}}function cb(e){return typeof e==`object`&&e?e:{}}function lb(e){let t=cb(e),n=typeof t.code==`string`?t.code:``;switch(n){case`ERROR_CEREMONY_ABORTED`:return`The passkey request was cancelled. You can safely try again.`;case`ERROR_INVALID_DOMAIN`:case`ERROR_INVALID_RP_ID`:return`The passkey provider rejected this site’s domain identity. Open the canonical HTTPS address and try again.`;case`ERROR_INVALID_USER_ID_LENGTH`:case`ERROR_MALFORMED_PUBKEYCREDPARAMS`:return`The relay supplied passkey options this browser could not use (${n}).`;case`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`:return`This passkey provider does not support the discoverable credential required for sign-in. Try another passkey provider or browser.`;case`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`:case`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`:return`This passkey provider could not perform the required screen-lock verification. Check the device screen lock or try another provider.`;case`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`:return`This passkey is already registered on this device. Try signing in instead.`;case`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`:return`This passkey provider supports none of the relay’s allowed cryptographic algorithms. Try another provider or browser.`;case`ERROR_AUTHENTICATOR_GENERAL_ERROR`:return`The phone’s passkey provider accepted device verification but could not create the credential (ERROR_AUTHENTICATOR_GENERAL_ERROR). Try another browser or passkey provider on this phone.`;case`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`:return lb(t.cause)}switch(typeof t.message==`string`?t.message:``){case`INVALID_REGISTRATION_REQUEST`:return`The relay did not understand the passkey response from this browser. Refresh the page and try again.`;case`REGISTRATION_COOKIE_MISSING`:return`The registration session cookie was not returned by this browser. Allow site cookies, refresh, and try again.`;case`REGISTRATION_NOT_AVAILABLE`:return`This registration attempt expired or is no longer available. Refresh the page and start again.`;case`REGISTRATION_VERIFICATION_FAILED`:return`Your device created the passkey, but the relay could not verify it. Try again and check the relay diagnostics if it persists.`;case`ORIGIN_NOT_ALLOWED`:return`This page is not using the relay’s configured public address. Open the canonical HTTPS address and try again.`;case`ENROLLMENT_NOT_AUTHORIZED`:return`This relay is no longer accepting first-device registration.`;case`AUTHENTICATION_FAILED`:return`We could not complete sign-in. Please try again.`}let r=typeof t.name==`string`?t.name:``;switch(r){case`NotAllowedError`:return`The passkey request was cancelled or timed out. Try again when ready.`;case`InvalidStateError`:return`This passkey is already registered on this device. Try signing in instead.`;case`AbortError`:return`The passkey request was cancelled. You can safely try again.`;case`SecurityError`:return`Passkeys require this device to use the configured secure site.`;case`ConstraintError`:case`DataError`:case`EncodingError`:return`This browser could not use the passkey options supplied by the relay. Refresh the page and try again.`;case`NetworkError`:return`The connection was interrupted while completing the passkey request. Check the connection and try again.`;case`OperationError`:case`UnknownError`:return`This browser or passkey provider could not finish the passkey request after device verification. Try again or use another browser on this device.`;case`TypeError`:return`This browser rejected the passkey request data. Refresh the page and try again.`;default:return/^[A-Za-z]+Error$/.test(r)?`The passkey request failed inside this browser (${r}). Try another browser or passkey provider on this device.`:`We could not complete authentication. Please try again.`}}function ub(){return typeof window<`u`&&window.isSecureContext&&window.PublicKeyCredential!==void 0}function db(e,t){async function n(n){t({kind:`checking`});try{let{status:r,publicOrigin:i,passkeyAuthEnabled:a=!0}=await e.status();if(!a){let e={kind:`authenticated`,passkeyAuthEnabled:!1};return t(e),e}if(!ub()){let e={kind:`unsupported`,message:`Passkeys require a secure browser on this device.`};return t(e),e}let o=r===`authenticated`?{kind:`authenticated`,passkeyAuthEnabled:!0}:r===`bootstrap`?{kind:`bootstrap`,publicOrigin:i}:n?{kind:`enrollment`,publicOrigin:i}:{kind:`locked`};return t(o),o}catch{let e={kind:`error`,message:`We could not check this device. Please try again.`};return t(e),e}}function r(){t({kind:`authenticated`,passkeyAuthEnabled:!0})}function i(e){t({kind:`locked`,...e?{message:e}:{}})}return{check:n,retry:n,authenticated:r,locked:i}}var fb=q(`<p class="warning svelte-1c5qcm6">This one-time link authorizes one new passkey. Choose a nickname and complete the passkey
|
|
106
|
+
prompt before it expires.</p>`),pb=q(`<p class="warning svelte-1c5qcm6"><strong class="svelte-1c5qcm6">Trust-on-first-use:</strong> anyone who can reach an empty relay instance could claim
|
|
107
|
+
first-device access. Enroll this device before exposing the instance, and confirm you are at the
|
|
108
|
+
canonical address before continuing.</p>`),mb=q(`<p class="error svelte-1c5qcm6">Passkeys require a secure browser on this device.</p>`),hb=q(`<p class="feedback svelte-1c5qcm6"> </p>`),gb=q(`<img alt="QR code for the first-device setup link" class="svelte-1c5qcm6"/>`),_b=q(`<div class="handoff svelte-1c5qcm6"><!> <div class="svelte-1c5qcm6"><h2 class="svelte-1c5qcm6">Continue on your phone</h2> <p class="svelte-1c5qcm6">Scanning opens this same setup page. You will still choose a nickname and explicitly
|
|
109
|
+
authorize that device.</p> <a class="svelte-1c5qcm6"> </a> <button type="button" class="copy svelte-1c5qcm6">Copy setup link</button></div></div>`),vb=q(`<main class="enrollment svelte-1c5qcm6" aria-live="polite"><section class="card svelte-1c5qcm6" aria-labelledby="enrollment-title"><p class="brand svelte-1c5qcm6">Gestalt / Dyne</p> <h1 id="enrollment-title" class="svelte-1c5qcm6"> </h1> <!> <label for="device-nickname" class="svelte-1c5qcm6">Device nickname</label> <input id="device-nickname" name="device-nickname" autocomplete="nickname" required="" enterkeyhint="done" class="svelte-1c5qcm6"/> <button class="authorize svelte-1c5qcm6" type="button"> </button> <!> <!> <!></section></main>`);function yb(e,t){Qe(t,!0);let n=z(``),r=z(null),i=z(!1),a=z(null),o=!0,s=!0,c=L(()=>Dm(t.canonicalOrigin)),l=null;function u(){return window.isSecureContext&&window.PublicKeyCredential!==void 0}function d(){l&&clearInterval(l),l=null}function f(e){if(o=!1,d(),e===`authenticated`){t.onAuthenticated();return}t.onLocked(`Another device has already enrolled this relay. Sign in with that device’s passkey.`)}async function p(){if(document.visibilityState===`visible`)try{let e=await t.client.status();if(e.status!==`bootstrap`){if(!s)return;f(e.status)}}catch{}}Gi(()=>{t.enrollmentTicket||Om(t.canonicalOrigin).then(e=>{s&&B(a,e,!0)}).catch(()=>{s&&B(r,`Setup QR unavailable. Use the setup link below.`)});let e=window.matchMedia?.(`(min-width: 768px)`).matches??!1;!t.enrollmentTicket&&e&&(l=setInterval(()=>void p(),15e3))}),Ki(()=>{s=!1,o=!1,d()});async function m(){if(!navigator.clipboard?.writeText){B(r,`Copy is unavailable here. Select and copy the visible setup link.`);return}try{await navigator.clipboard.writeText(G(c)),B(r,`Setup link copied.`)}catch{B(r,`Copy is unavailable here. Select and copy the visible setup link.`)}}async function h(){let e=G(n).trim();if(!e){B(r,`Enter a device nickname before authorizing it.`);return}if(!u()){B(r,`Passkeys require a secure browser on this device.`);return}if(!(G(i)||!o)){B(i,!0),B(r,null);try{let{options:n}=await t.client.registrationOptions(t.enrollmentTicket);if(!s||!o)return;let r=await nb({optionsJSON:n});if(!s||!o||(await t.client.verifyRegistration(r,e),!s||!o))return;d(),t.onAuthenticated()}catch(e){if(e instanceof Error&&[`AUTH_REQUEST_FAILED_409`,`BOOTSTRAP_ALREADY_CLAIMED`].includes(e.message)){d(),t.onLocked(`Another device completed setup first. Sign in with that device’s passkey.`);return}B(r,lb(e),!0)}finally{B(i,!1)}}}var g=vb(),_=V(g),v=U(V(_),2),y=V(v,!0);F(v);var b=U(v,2),x=e=>{J(e,fb())},S=e=>{J(e,pb())};X(b,e=>{t.enrollmentTicket?e(x):e(S,-1)});var C=U(b,4);Ni(C);var w=U(C,2),T=V(w,!0);F(w);var E=U(w,2),D=e=>{J(e,mb())},ee=L(()=>!u());X(E,e=>{G(ee)&&e(D)});var O=U(E,2),te=e=>{var t=hb(),n=V(t,!0);F(t),W(()=>Y(n,G(r))),J(e,t)};X(O,e=>{G(r)&&e(te)});var ne=U(O,2),re=e=>{var t=_b(),n=V(t),r=e=>{var t=gb();W(()=>Q(t,`src`,G(a))),J(e,t)};X(n,e=>{G(a)&&e(r)});var i=U(n,2),o=U(V(i),4),s=V(o,!0);F(o);var l=U(o,2);F(i),F(t),W(()=>{Q(o,`href`,G(c)),Y(s,G(c))}),K(`click`,l,()=>void m()),J(e,t)};X(ne,e=>{t.enrollmentTicket||e(re)}),F(_),F(g),W(e=>{Y(y,t.enrollmentTicket?`Authorize this device`:`Authorize the first device`),w.disabled=e,Y(T,G(i)?`Authorizing device…`:`Authorize this device`)},[()=>G(i)||!u()]),zi(C,()=>G(n),e=>B(n,e)),K(`click`,w,()=>void h()),J(e,g),$e()}Rr([`click`]);var bb=q(`<p class="error svelte-1byekj9">Passkeys require this relay to be opened over a secure connection.</p>`),xb=q(`<p class="error svelte-1byekj9">This browser does not support passkeys. Use an authorized browser or device.</p>`),Sb=q(`<p class="svelte-1byekj9"> </p> <button class="sign-in svelte-1byekj9" type="button"> </button>`,1),Cb=q(`<main class="login svelte-1byekj9" aria-live="polite"><section class="card svelte-1byekj9" aria-labelledby="login-title"><p class="brand svelte-1byekj9">Gestalt / Dyne</p> <h1 id="login-title" class="svelte-1byekj9">Unlock relay</h1> <!></section></main>`);function wb(e,t){Qe(t,!0);let n=z(``),r=z(!1),i=z(void 0);function a(){return window.isSecureContext&&window.PublicKeyCredential!==void 0}function o(e){return e instanceof Error&&[`NotAllowedError`,`AbortError`,`SecurityError`].includes(e.name)?lb(e):`We could not complete sign-in. Please try again.`}Gi(()=>{B(n,t.message??`Use a passkey from an authorized device to unlock this relay.`,!0),G(i)?.focus()});async function s(){if(!(G(r)||!a())){B(r,!0),B(n,``);try{let{options:e}=await t.client.loginOptions(),n=await sb({optionsJSON:e});await t.client.verifyLogin(n),t.onAuthenticated()}catch(e){B(n,o(e),!0)}finally{B(r,!1)}}}var c=Cb(),l=V(c),u=U(V(l),4),d=e=>{J(e,bb())},f=e=>{J(e,xb())},p=e=>{var t=Sb(),a=H(t),o=V(a,!0);F(a);var c=U(a,2),l=V(c,!0);F(c),Ui(c,e=>B(i,e),()=>G(i)),W(()=>{Y(o,G(n)),c.disabled=G(r),Y(l,G(r)?`Waiting for passkey…`:`Sign in with a passkey`)}),K(`click`,c,()=>void s()),J(e,t)};X(u,e=>{window.isSecureContext?window.PublicKeyCredential===void 0?e(f,1):e(p,-1):e(d)}),F(l),F(c),J(e,c),$e()}Rr([`click`]);var Tb=q(`<p>Checking this device…</p>`),Eb=q(`<h1 class="svelte-y74n0s">Passkey support is required</h1> <p> </p>`,1),Db=q(`<h1 class="svelte-y74n0s">Unable to check this device</h1> <p> </p> <button type="button" class="svelte-y74n0s">Try again</button>`,1),Ob=q(`<main class="auth-gate svelte-y74n0s" aria-live="polite"><!></main>`);function kb(e,t){Qe(t,!0);let n=$(t,`initialTheme`,3,`dyne-org`),r=z(void 0),i=L(()=>G(r)??t.enrollmentTicket),a=z(on({kind:`checking`})),o=!1,s=Uy(),c=db(s,e=>B(a,e,!0)),l=Wy(()=>c.locked(`Your session ended. Sign in with your passkey to continue.`));Gi(()=>{c.check(G(i))});function u(e){B(r,e,!0),B(a,{kind:`enrollment`,publicOrigin:G(a).kind===`authenticated`?``:`http://localhost`},!0)}async function d(){if(!(o||G(a).kind!==`authenticated`)){o=!0,c.locked(`Relay locked. Sign in with your passkey to continue.`);try{await s.logout()}catch{c.locked(`Relay locked locally. Recheck your connection before signing in again.`)}finally{o=!1}}}var f=Kr(),p=H(f),m=e=>{Ly(e,{get authorizedFetch(){return l},get theme(){return n()},get passkeyAuthEnabled(){return G(a).passkeyAuthEnabled},onlock:()=>void d(),oncreatepasskey:u})},h=e=>{yb(e,{get client(){return s},get canonicalOrigin(){return G(a).publicOrigin},get enrollmentTicket(){return G(i)},onAuthenticated:()=>c.authenticated(),onLocked:e=>c.locked(e)})},g=e=>{wb(e,{get client(){return s},get message(){return G(a).message},onAuthenticated:()=>c.authenticated()})},_=e=>{var t=Ob(),n=V(t),r=e=>{J(e,Tb())},i=e=>{var t=Eb(),n=U(H(t),2),r=V(n,!0);F(n),W(()=>Y(r,G(a).message)),J(e,t)},o=e=>{var t=Db(),n=U(H(t),2),r=V(n,!0);F(n);var i=U(n,2);W(()=>Y(r,G(a).message)),K(`click`,i,()=>void c.retry()),J(e,t)};X(n,e=>{G(a).kind===`checking`?e(r):G(a).kind===`unsupported`?e(i,1):G(a).kind===`error`&&e(o,2)}),F(t),J(e,t)};X(p,e=>{G(a).kind===`authenticated`?e(m):G(a).kind===`bootstrap`||G(a).kind===`enrollment`?e(h,1):G(a).kind===`locked`?e(g,2):e(_,-1)}),J(e,f),$e()}Rr([`click`]);function Ab(e,t){let n=e.hash;if(!n.startsWith(`#enroll=`))return;let r=/^#enroll=([^&]+)$/.exec(n);if(t.replaceState(t.state,``,`${e.pathname}${e.search}`),!(!r||!r[1]))try{return decodeURIComponent(r[1])||void 0}catch{return}}function jb(e,t,n,r=qr,i={}){return r(kb,{target:e,props:{enrollmentTicket:Ab(t,n),initialTheme:aa(i)}})}function Mb(){return{readyState:document.readyState,addLoadListener:e=>window.addEventListener(`load`,e,{once:!0}),serviceWorker:navigator.serviceWorker}}function Nb(e=Mb()){if(!e.serviceWorker)return;let t=()=>{e.serviceWorker?.register(`/service-worker.js`,{scope:`/`}).catch(()=>void 0)};if(e.readyState===`complete`){t();return}e.addLoadListener(t)}var Pb=document.getElementById(`app`);if(!Pb)throw Error(`Missing application mount target`);jb(Pb,window.location,window.history),Nb();
|