@timqi/pier 0.1.9 → 0.1.10
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/dist/boards/boards.js +104 -41
- package/dist/channels/handoff.js +6 -2
- package/dist/main.js +3 -1
- package/dist/web/auth.js +6 -5
- package/dist/web/public/assets/{activity-DE9Dct4L.js → activity-C9PhqKVX.js} +1 -1
- package/dist/web/public/assets/activity-C9PhqKVX.js.br +0 -0
- package/dist/web/public/assets/activity-C9PhqKVX.js.gz +0 -0
- package/dist/web/public/assets/{boards-il6ceDEs.js → boards-YW0uAwJI.js} +1 -1
- package/dist/web/public/assets/boards-YW0uAwJI.js.br +0 -0
- package/dist/web/public/assets/boards-YW0uAwJI.js.gz +0 -0
- package/dist/web/public/assets/{explorer-JDO21aAs.js → explorer-BNm0Cr51.js} +1 -1
- package/dist/web/public/assets/explorer-BNm0Cr51.js.br +0 -0
- package/dist/web/public/assets/explorer-BNm0Cr51.js.gz +0 -0
- package/dist/web/public/assets/index-Bfy7U1wv.js +85 -0
- package/dist/web/public/assets/index-Bfy7U1wv.js.br +0 -0
- package/dist/web/public/assets/index-Bfy7U1wv.js.gz +0 -0
- package/dist/web/public/assets/{runs-CsINd08H.js → runs-BNv9MSL2.js} +1 -1
- package/dist/web/public/assets/runs-BNv9MSL2.js.br +0 -0
- package/dist/web/public/assets/runs-BNv9MSL2.js.gz +0 -0
- package/dist/web/public/assets/{settings-ChwAWwE_.js → settings-Dxxux4Un.js} +1 -1
- package/dist/web/public/assets/settings-Dxxux4Un.js.br +0 -0
- package/dist/web/public/assets/settings-Dxxux4Un.js.gz +0 -0
- package/dist/web/public/assets/{task-runs-I0eOy3HT.js → task-runs-I1jLSvYq.js} +1 -1
- package/dist/web/public/assets/task-runs-I1jLSvYq.js.br +0 -0
- package/dist/web/public/assets/task-runs-I1jLSvYq.js.gz +0 -0
- package/dist/web/public/assets/{tasks-D3i9Kc5-.js → tasks-DqrNu2Tz.js} +1 -1
- package/dist/web/public/assets/tasks-DqrNu2Tz.js.br +0 -0
- package/dist/web/public/assets/tasks-DqrNu2Tz.js.gz +0 -0
- package/dist/web/public/index.html +1 -1
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/server.js +1 -1
- package/package.json +1 -1
- package/skills/pier-boards/SKILL.md +1 -1
- package/dist/web/public/assets/activity-DE9Dct4L.js.br +0 -0
- package/dist/web/public/assets/activity-DE9Dct4L.js.gz +0 -0
- package/dist/web/public/assets/boards-il6ceDEs.js.br +0 -0
- package/dist/web/public/assets/boards-il6ceDEs.js.gz +0 -0
- package/dist/web/public/assets/explorer-JDO21aAs.js.br +0 -0
- package/dist/web/public/assets/explorer-JDO21aAs.js.gz +0 -0
- package/dist/web/public/assets/index-BNjWeodx.js +0 -85
- package/dist/web/public/assets/index-BNjWeodx.js.br +0 -0
- package/dist/web/public/assets/index-BNjWeodx.js.gz +0 -0
- package/dist/web/public/assets/runs-CsINd08H.js.br +0 -0
- package/dist/web/public/assets/runs-CsINd08H.js.gz +0 -0
- package/dist/web/public/assets/settings-ChwAWwE_.js.br +0 -0
- package/dist/web/public/assets/settings-ChwAWwE_.js.gz +0 -0
- package/dist/web/public/assets/task-runs-I0eOy3HT.js.br +0 -0
- package/dist/web/public/assets/task-runs-I0eOy3HT.js.gz +0 -0
- package/dist/web/public/assets/tasks-D3i9Kc5-.js.br +0 -0
- package/dist/web/public/assets/tasks-D3i9Kc5-.js.gz +0 -0
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-D3i9Kc5-.js","assets/task-runs-I0eOy3HT.js","assets/runs-CsINd08H.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
(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),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},t=([e,n,r])=>{let i=document.createElementNS(`http://www.w3.org/2000/svg`,e);return Object.keys(n).forEach(e=>{i.setAttribute(e,String(n[e]))}),r?.length&&r.forEach(e=>{let n=t(e);i.appendChild(n)}),i},n=(n,r={})=>t([`svg`,{...e,...r},n]),r=[[`path`,{d:`m12 19-7-7 7-7`}],[`path`,{d:`M19 12H5`}]],i=[[`path`,{d:`M7 7h10v10`}],[`path`,{d:`M7 17 17 7`}]],a=[[`path`,{d:`m5 12 7-7 7 7`}],[`path`,{d:`M12 19V5`}]],o=[[`path`,{d:`M20 6 9 17l-5-5`}]],s=[[`path`,{d:`m6 9 6 6 6-6`}]],c=[[`path`,{d:`m15 18-6-6 6-6`}]],l=[[`path`,{d:`m9 18 6-6-6-6`}]],u=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}],[`path`,{d:`M12 17h.01`}]],d=[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M12 6v6l4 2`}]],f=[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`}],[`path`,{d:`m9 10-5 5 5 5`}]],p=[[`path`,{d:`M12 15V3`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}],[`path`,{d:`m7 10 5 5 5-5`}]],m=[[`circle`,{cx:`12`,cy:`12`,r:`1`}],[`circle`,{cx:`19`,cy:`12`,r:`1`}],[`circle`,{cx:`5`,cy:`12`,r:`1`}]],ee=[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],te=[[`path`,{d:`M12 10v6`}],[`path`,{d:`M9 13h6`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`}]],ne=[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`}]],re=[[`path`,{d:`M13 5h8`}],[`path`,{d:`M13 12h8`}],[`path`,{d:`M13 19h8`}],[`path`,{d:`m3 17 2 2 4-4`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`}]],h=[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`}]],ie=[[`path`,{d:`M4 5h16`}],[`path`,{d:`M4 12h16`}],[`path`,{d:`M4 19h16`}]],ae=[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}]],oe=[[`path`,{d:`M5 12h14`}]],se=[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`}]],g=[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`}]],ce=[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`}]],le=[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}],[`path`,{d:`m15 5 4 4`}]],ue=[[`path`,{d:`M5 12h14`}],[`path`,{d:`M12 5v14`}]],de=[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`}],[`path`,{d:`M21 3v5h-5`}]],fe=[[`path`,{d:`m21 21-4.34-4.34`}],[`circle`,{cx:`11`,cy:`11`,r:`8`}]],pe=[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],me=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}]],he=[[`circle`,{cx:`12`,cy:`12`,r:`4`}],[`path`,{d:`M12 2v2`}],[`path`,{d:`M12 20v2`}],[`path`,{d:`m4.93 4.93 1.41 1.41`}],[`path`,{d:`m17.66 17.66 1.41 1.41`}],[`path`,{d:`M2 12h2`}],[`path`,{d:`M20 12h2`}],[`path`,{d:`m6.34 17.66-1.41 1.41`}],[`path`,{d:`m19.07 4.93-1.41 1.41`}]],ge=[[`path`,{d:`M9 14 4 9l5-5`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`}]],_e=[[`path`,{d:`M18 6 6 18`}],[`path`,{d:`m6 6 12 12`}]],_=(e,t=`h-3.5 w-3.5`)=>n(e,{class:`flex-none ${t}`,"aria-hidden":`true`,focusable:`false`});function ve(){let e={ArrowUp:a,ChevronLeft:c,ChevronRight:l,Clock:d,Ellipsis:m,LayoutDashboard:ne,ListTodo:re,Menu:ie,Plus:ue,RotateCw:de,Search:fe,Settings:pe,Square:me,Undo2:ge,X:_e};for(let t of document.querySelectorAll(`[data-icon]`)){let n=e[t.dataset.icon];if(!n)throw Error(`Unknown shell icon: ${t.dataset.icon}`);t.replaceChildren(_(n,`h-full w-full`))}let t=_(s);t.setAttribute(`stroke`,`#737373`),document.documentElement.style.setProperty(`--select-chevron`,`url("data:image/svg+xml,${encodeURIComponent(t.outerHTML)}")`)}var ye=/[\u201c\u201d"\u2018\u2019'()\uff08\uff09\u300c\u300d\u300e\u300f\u3010\u3011\u300a\u300b\u3008\u3009[\]]/;function be(e){let t=[],n=e=>`\uE010${t.push(e)-1}\uE011`,r=e.replace(/```[\s\S]*?```/g,e=>n(e)).replace(/`[^`\n]+`/g,e=>n(e));return r=r.replace(/\*\*(\S|\S[\s\S]*?\S)\*\*/g,(e,t)=>{let n=``,r=``,i=t;for(;i.length>1&&ye.test(i[0]);)n+=i[0],i=i.slice(1);for(;i.length>1&&ye.test(i.at(-1));)r=i.at(-1)+r,i=i.slice(0,-1);return n||r?`${n}**${i}**${r}`:e}),r.replace(/\uE010(\d+)\uE011/g,(e,n)=>t[Number(n)]??``)}var v=e=>!e.text.trim()&&e.suggestions.length===0,xe=e=>e===`xhigh`?`Extra high`:e[0].toUpperCase()+e.slice(1),Se=e=>{if(e<1e3)return String(e);let t=e/1e3;return t>=9.95?`${Math.round(t)}K`:`${t.toFixed(1)}K`},Ce=/(?:^|\n)[ \t]*-{3,}[ \t]*\r?\n((?:[ \t]*\[[^\]\r\n]+\][ \t]*(?:[||][ \t]*)?)+)\s*$/,we=/\[([^\]\r\n]+)\]/g,Te=5,Ee=String.raw`[\u200B-\u200D\u2060\uFEFF]*`,De=e=>e.split(``).join(Ee),Oe=RegExp(`${De(`<silent>`)}([\\s\\S]*?)${De(`</silent>`)}`,`gi`),ke=RegExp(`<(\\/?)${De(`silent>`)}`,`gi`);function y(e){let t=[...e.matchAll(Oe)].map(e=>(e[1]??``).trim()).filter(Boolean);return t.length?t.join(` · `):void 0}function Ae(e,t){let n=b(e),r=y(e),i=Ce.exec(n);if(!i?.[1])return{text:n,suggestions:[],meta:t,silence:r};let a=[...i[1].matchAll(we)].map(e=>(e[1]??``).trim()).filter(Boolean).slice(0,Te);return a.length?{text:n.slice(0,i.index).trimEnd(),suggestions:a,meta:t,silence:r}:{text:n,suggestions:[],meta:t,silence:r}}var b=e=>be(e.replace(Oe,``).trim()),je=/^(?:\s|[-*+>]|\d+[.)])/;function Me(e,t=0){let n=e.lastIndexOf(`
|
|
3
|
-
`)+1,r=``,i=!1,a=t,o=-1,s=``;for(let c=t;c<n;){let t=e.indexOf(`
|
|
4
|
-
`,c),n=e.slice(c,t);c=t+1;let l=/^\s*(`{3,}|~{3,})(.*)$/.exec(n);if(!r&&!i&&!n.trim()){o<0&&s&&(o=c);continue}!r&&!i&&o>=0&&!(je.test(s)&&je.test(n))&&(a=o);let u=l?.[1]??``;if(!r&&u&&!i?r=u:r&&u[0]===r[0]&&u.length>=r.length&&!l?.[2]?.trim()&&(r=``),!r&&(!u||i))for(let e of n.matchAll(ke))i=!e[1];o=-1,s=n}return a}var Ne=String.raw`(?<when>(?:\d{4}-\d{2}-\d{2} )?\d{1,2}:\d{2})`,Pe=new RegExp(String.raw`^\[(?:(?<name>[^\n[\]<>]*)<(?<id>[^\n[\]<>]+)>)? ?${Ne}? ?(?<where>[a-z]+:[^\s[\]<>]+)?\]\n`),Fe=new RegExp(String.raw`^\[(?<name>[^\n[\]<>]*?) ${Ne}(?: (?<where>[a-z]+))?\]\n`);function Ie(e){let t=Pe.exec(e),{id:n,when:r,where:i}=t?.groups??{},a=n||r||i?t:Fe.exec(e);return a?.groups?{...a.groups.name?{name:a.groups.name}:{},...a.groups.id?{id:a.groups.id}:{},...a.groups.when?{when:a.groups.when}:{},...a.groups.where?{where:a.groups.where}:{},text:e.slice(a[0].length)}:{text:e}}var Le=/(?:\n\[[^\]\n]*(?:\]\(\s*<?file:\/\/[^\n]*|$))+$/,Re=/^\s*`[^`\n]{40,}`\s+(\S[\s\S]*)$/;function ze(e){if(!e)return e;let{text:t}=Ie(e);return t===e?e:t.replace(Le,``).replace(Re,`$1`).replace(/\s+/g,` `).trim()||e}var Be=e=>[...new Set([...e].sort((e,t)=>t.createdAt-e.createdAt).map(e=>e.cwd))];function Ve(e){let t=Be(e),n=new Set(t);return t.filter(e=>{let t=e.lastIndexOf(`/`),r=e.indexOf(`.`,t+2);return r<0||!n.has(e.slice(0,r))})}function He(e){let t,n=!1;return()=>(n=!0,t??=(async()=>{for(;n;)n=!1,await e()})().finally(()=>{t=void 0}))}var Ue=(e,t)=>({method:t,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),x=(e,t,n=`POST`)=>fetch(e,Ue(t,n)),We=(e,t,n,r=`POST`)=>C(e,n,Ue(t,r));async function S(e,t){return(await e.json().catch(()=>({}))).error??`${t} (${e.status})`}async function C(e,t,n){let r;try{r=await fetch(e,n)}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}if(!r.ok)return{ok:!1,error:await S(r,t)};try{return{ok:!0,value:await r.json()}}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}}async function Ge(e,t,n){let r=await C(e,t,n);if(!r.ok)throw Error(r.error);return r.value}async function Ke(e,t,n){try{let r=await fetch(e,{method:t});return r.ok?void 0:await S(r,n)}catch(e){return`${n}: ${String(e)}`}}function qe(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 Je(e){if(Array.isArray(e))return e}function Ye(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)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 Xe(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ze(e,t){return Je(e)||Ye(e,t)||Qe(e,t)||Xe()}function Qe(e,t){if(e){if(typeof e==`string`)return qe(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)?qe(e,t):void 0}}var $e=Object.entries,et=Object.setPrototypeOf,tt=Object.isFrozen,nt=Object.getPrototypeOf,rt=Object.getOwnPropertyDescriptor,w=Object.freeze,T=Object.seal,it=Object.create,at=typeof Reflect<`u`&&Reflect,ot=at.apply,st=at.construct;w||=function(e){return e},T||=function(e){return e},ot||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},st||=function(e){return new e(...[...arguments].slice(1))};var ct=O(Array.prototype.forEach),lt=O(Array.prototype.lastIndexOf),ut=O(Array.prototype.pop),dt=O(Array.prototype.push),ft=O(Array.prototype.splice),pt=Array.isArray,mt=O(String.prototype.toLowerCase),ht=O(String.prototype.toString),gt=O(String.prototype.match),_t=O(String.prototype.replace),vt=O(String.prototype.indexOf),yt=O(String.prototype.trim),bt=O(Number.prototype.toString),xt=O(Boolean.prototype.toString),St=typeof BigInt>`u`?null:O(BigInt.prototype.toString),Ct=typeof Symbol>`u`?null:O(Symbol.prototype.toString),E=O(Object.prototype.hasOwnProperty),wt=O(Object.prototype.toString),D=O(RegExp.prototype.test),Tt=Et(TypeError);function O(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return ot(e,t,n)}}function Et(e){return function(){return st(e,[...arguments])}}function k(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mt;if(et&&et(e,null),!pt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(tt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Dt(e){for(let t=0;t<e.length;t++)E(e,t)||(e[t]=null);return e}function A(e){let t=it(null);for(let r of $e(e)){var n=Ze(r,2);let i=n[0],a=n[1];E(e,i)&&(t[i]=pt(a)?Dt(a):a&&typeof a==`object`&&a.constructor===Object?A(a):a)}return t}function Ot(e){switch(typeof e){case`string`:return e;case`number`:return bt(e);case`boolean`:return xt(e);case`bigint`:return St?St(e):`0`;case`symbol`:return Ct?Ct(e):`Symbol()`;case`undefined`:return wt(e);case`function`:case`object`:{if(e===null)return wt(e);let t=e,n=kt(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:wt(e)}return wt(e)}default:return wt(e)}}function kt(e,t){for(;e!==null;){let n=rt(e,t);if(n){if(n.get)return O(n.get);if(typeof n.value==`function`)return O(n.value)}e=nt(e)}function n(){return null}return n}function At(e){try{return D(e,``),!0}catch{return!1}}var jt=w(`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(`.`)),Mt=w(`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(`.`)),Nt=w([`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`]),Pt=w([`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`]),Ft=w(`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(`.`)),It=w([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Lt=w([`#text`]),Rt=w(`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(`.`)),zt=w(`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(`.`)),Bt=w(`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(`.`)),Vt=w([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ht=T(/{{[\w\W]*|^[\w\W]*}}/g),Ut=T(/<%[\w\W]*|^[\w\W]*%>/g),Wt=T(/\${[\w\W]*/g),Gt=T(/^data-[\-\w.\u00B7-\uFFFF]+$/),Kt=T(/^aria-[\-\w]+$/),qt=T(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Jt=T(/^(?:\w+script|data):/i),Yt=T(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xt=T(/^html$/i),Zt=T(/^[a-z][.\w]*(-[.\w]+)+$/i),Qt=T(/<[/\w!]/g),$t=T(/<[/\w]/g),en=T(/<\/no(script|embed|frames)/i),tn=T(/\/>/i),j={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},nn=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],rn=w(k({},nn)),an=function(){let e={};return ct(nn,t=>{e[t]=T(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),w(e)}(),on=function(){return typeof window>`u`?null:window},sn=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}},cn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},ln=function(e,t,n,r){return E(e,t)&&pt(e[t])?k(r.base?A(r.base):{},e[t],r.transform):n},un=function(e,t,n){let r=E(e,t)?e[t]:void 0;return r&&typeof r==`object`?A(r):n()};function dn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:on(),t=e=>dn(e);if(t.version=`3.4.14`,t.removed=[],!e||!e.document||e.document.nodeType!==j.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=kt(d,`cloneNode`),p=kt(d,`remove`),m=kt(d,`nextSibling`),ee=kt(d,`childNodes`),te=kt(d,`parentNode`),ne=kt(d,`shadowRoot`),re=kt(d,`attributes`),h=o&&o.prototype?kt(o.prototype,`nodeType`):null,ie=o&&o.prototype?kt(o.prototype,`nodeName`):null,ae=o&&o.prototype?kt(o.prototype,`ownerDocument`):null,oe=function(e){return h?h(e):e.nodeType},se=function(e){return ie?ie(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let g,ce=``,le,ue=!1,de=0,fe=function(){if(de>0)throw Tt(`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.`)},pe=function(e){fe(),de++;try{return g.createHTML(e)}finally{de--}},me=function(e){fe(),de++;try{return g.createScriptURL(e)}finally{de--}},he=function(){return ue||=(le=sn(u,i),!0),le},ge=n,_e=ge.implementation,_=ge.createNodeIterator,ve=ge.createDocumentFragment,ye=ge.getElementsByTagName,be=r.importNode,v=cn();t.isSupported=typeof $e==`function`&&typeof te==`function`&&_e&&_e.createHTMLDocument!==void 0;let xe=Ht,Se=Ut,Ce=Wt,we=Gt,Te=Kt,Ee=Jt,De=Yt,Oe=Zt,ke=qt,y=null,Ae=k({},[...jt,...Mt,...Nt,...Ft,...Lt]),b=null,je=k({},[...Rt,...zt,...Bt,...Vt]),Me=Object.seal(it(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}})),Ne=null,Pe=null,Fe=Object.seal(it(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ie=!0,Le=!0,Re=!1,ze=!0,Be=!1,Ve=!0,He=!1,Ue=!1,x=null,We=null,S=!1,C=!1,Ge=!1,Ke=!1,qe=!0,Je=!1,Ye=`user-content-`,Xe=!0,Ze=!1,Qe={},et=null,tt=k({},`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(`.`)),nt=null,rt=k({},[`audio`,`video`,`img`,`source`,`image`,`track`]),at=null,ot=k({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),st=`http://www.w3.org/1998/Math/MathML`,bt=`http://www.w3.org/2000/svg`,xt=`http://www.w3.org/1999/xhtml`,St=xt,Ct=!1,wt=null,O=k({},[st,bt,xt],ht),Et=w([`mi`,`mo`,`mn`,`ms`,`mtext`]),Dt=k({},Et),nn=w([`annotation-xml`]),fn=k({},nn),pn=k({},[`title`,`style`,`font`,`a`,`script`]),mn=null,hn=[`application/xhtml+xml`,`text/html`],M=null,gn=null,N=n.createElement(`form`),_n=function(e){return e instanceof RegExp||e instanceof Function},P=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(gn&&gn===e)return;(!e||typeof e!=`object`)&&(e={}),e=A(e),mn=hn.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,M=mn===`application/xhtml+xml`?ht:mt,y=ln(e,`ALLOWED_TAGS`,Ae,{transform:M}),b=ln(e,`ALLOWED_ATTR`,je,{transform:M}),wt=ln(e,`ALLOWED_NAMESPACES`,O,{transform:ht}),at=ln(e,`ADD_URI_SAFE_ATTR`,ot,{transform:M,base:ot}),nt=ln(e,`ADD_DATA_URI_TAGS`,rt,{transform:M,base:rt}),et=ln(e,`FORBID_CONTENTS`,tt,{transform:M}),Ne=ln(e,`FORBID_TAGS`,A({}),{transform:M}),Pe=ln(e,`FORBID_ATTR`,A({}),{transform:M}),Qe=E(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?A(e.USE_PROFILES):e.USE_PROFILES:!1,Ie=e.ALLOW_ARIA_ATTR!==!1,Le=e.ALLOW_DATA_ATTR!==!1,Re=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ze=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Be=e.SAFE_FOR_TEMPLATES||!1,Ve=e.SAFE_FOR_XML!==!1,He=e.WHOLE_DOCUMENT||!1,C=e.RETURN_DOM||!1,Ge=e.RETURN_DOM_FRAGMENT||!1,Ke=e.RETURN_TRUSTED_TYPE||!1,S=e.FORCE_BODY||!1,qe=e.SANITIZE_DOM!==!1,Je=e.SANITIZE_NAMED_PROPS||!1,Xe=e.KEEP_CONTENT!==!1,Ze=e.IN_PLACE||!1,ke=At(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:qt,St=typeof e.NAMESPACE==`string`?e.NAMESPACE:xt,Dt=un(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>k({},Et)),fn=un(e,`HTML_INTEGRATION_POINTS`,()=>k({},nn));let t=un(e,`CUSTOM_ELEMENT_HANDLING`,()=>it(null));if(Me=it(null),E(t,`tagNameCheck`)&&_n(t.tagNameCheck)&&(Me.tagNameCheck=t.tagNameCheck),E(t,`attributeNameCheck`)&&_n(t.attributeNameCheck)&&(Me.attributeNameCheck=t.attributeNameCheck),E(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Me.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),T(Me),Be&&(Le=!1),Ge&&(C=!0),Qe&&(y=k({},Lt),b=it(null),Qe.html===!0&&(k(y,jt),k(b,Rt)),Qe.svg===!0&&(k(y,Mt),k(b,zt),k(b,Vt)),Qe.svgFilters===!0&&(k(y,Nt),k(b,zt),k(b,Vt)),Qe.mathMl===!0&&(k(y,Ft),k(b,Bt),k(b,Vt))),Fe.tagCheck=null,Fe.attributeCheck=null,E(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Fe.tagCheck=e.ADD_TAGS:pt(e.ADD_TAGS)&&(y===Ae&&(y=A(y)),k(y,e.ADD_TAGS,M))),E(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Fe.attributeCheck=e.ADD_ATTR:pt(e.ADD_ATTR)&&(b===je&&(b=A(b)),k(b,e.ADD_ATTR,M))),E(e,`ADD_FORBID_CONTENTS`)&&pt(e.ADD_FORBID_CONTENTS)&&(et===tt&&(et=A(et)),k(et,e.ADD_FORBID_CONTENTS,M)),Xe&&(y[`#text`]=!0),He&&k(y,[`html`,`head`,`body`]),y.table&&(k(y,[`tbody`]),delete Ne.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Tt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Tt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=g;g=e.TRUSTED_TYPES_POLICY;try{ce=pe(``)}catch(e){throw g=t,e}}else e.TRUSTED_TYPES_POLICY===null?(g=void 0,ce=``):(g===void 0&&(g=he()),g&&typeof ce==`string`&&(ce=pe(``)));w&&w(e),gn=e},vn=k({},[...Mt,...Nt,...Pt]),yn=k({},[...Ft,...It]),bn=function(e,t,n){return t.namespaceURI===xt?e===`svg`:t.namespaceURI===st?e===`svg`&&(n===`annotation-xml`||Dt[n]):!!vn[e]},xn=function(e,t,n){return t.namespaceURI===xt?e===`math`:t.namespaceURI===bt?e===`math`&&fn[n]:!!yn[e]},Sn=function(e,t,n){return t.namespaceURI===bt&&!fn[n]||t.namespaceURI===st&&!Dt[n]?!1:!yn[e]&&(pn[e]||!vn[e])},Cn=function(e){let t=te(e);(!t||!t.tagName)&&(t={namespaceURI:St,tagName:`template`});let n=mt(e.tagName),r=mt(t.tagName);return wt[e.namespaceURI]?e.namespaceURI===bt?bn(n,t,r):e.namespaceURI===st?xn(n,t,r):e.namespaceURI===xt?Sn(n,t,r):!!(mn===`application/xhtml+xml`&&wt[e.namespaceURI]):!1},wn=function(e){dt(t.removed,{element:e});try{te(e).removeChild(e)}catch{if(p(e),!te(e))throw Tt(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Tn=function(e,t,n){try{e.removeAttributeNode(t)}catch{try{e.removeAttribute(n)}catch{}}},En=function(e){kn(e);let t=ee(e);if(t){let e=[];ct(t,t=>{dt(e,t)}),ct(e,e=>{try{p(e)}catch{}})}let n=re(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&Tn(e,r,i)}},Dn=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}dt(t.removed,{attribute:r||null,from:n});try{r?n.removeAttributeNode(r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(C||Ge)try{wn(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},On=function(e){let t=re(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||b[M(i)]||Tn(e,r,i)}},kn=function(e){let t=[e];for(;t.length>0;){let e=t.pop();oe(e)===j.element&&On(e);let n=ee(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},An=function(e,t){return Ve?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},jn=function(e){if(!Ve)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=oe(e);if(n===j.processingInstruction||n===j.comment&&D($t,e.data)){try{p(e)}catch{}continue}if(n===j.element){let t=e,n=M(se(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&An(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=ee(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Mn=function(e){let t=null,r=null;if(S)e=`<remove></remove>`+e;else{let t=gt(e,/^[\r\n\t ]+/);r=t&&t[0]}mn===`application/xhtml+xml`&&St===xt&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=g?pe(e):e;if(St===xt)try{t=new l().parseFromString(i,mn)}catch{}if(!t||!t.documentElement){t=_e.createDocument(St,`template`,null);try{t.documentElement.innerHTML=Ct?ce:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),St===xt?ye.call(t,He?`html`:`body`)[0]:He?t.documentElement:a},Nn=function(e){let t=ae?ae(e):e.ownerDocument;return _.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Pn=function(e){return e=_t(e,xe,` `),e=_t(e,Se,` `),e=_t(e,Ce,` `),e},Fn=function(e){e.normalize();let t=ae?ae(e):e.ownerDocument,n=_.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=Pn(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&ct(i,e=>{Ln(e.content)&&Fn(e.content)})},In=function(e){let t=ie?ie(e):null;return typeof t!=`string`||M(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==re(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==h(e)||e.childNodes!==ee(e)},Ln=function(e){if(!h||typeof e!=`object`||!e)return!1;try{return h(e)===j.documentFragment}catch{return!1}},Rn=function(e){if(!h||typeof e!=`object`||!e)return!1;try{return typeof h(e)==`number`}catch{return!1}};function zn(e,n,r){e.length!==0&&ct(e,e=>{e.call(t,n,r,gn)})}let Bn=function(e,t){return!!(Ve&&e.hasChildNodes()&&!Rn(e.firstElementChild)&&D(Qt,e.textContent)&&D(Qt,e.innerHTML)||Ve&&e.namespaceURI===xt&&rn[t]&&(Rn(e.firstElementChild)||typeof e.textContent==`string`&&D(an[t],e.textContent))||e.nodeType===j.processingInstruction||Ve&&e.nodeType===j.comment&&D($t,e.data))},Vn=function(e,t){return e instanceof RegExp?D(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Hn=function(e,t,n){if(!Ne[t]&&Jn(t)&&Vn(Me.tagNameCheck,t))return!1;if(Xe&&!et[t]){let t=te(e),r=ee(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,m(e))}}}return wn(e),!0},Un=function(e,t,n,r){return e.length===0?t:t===n||t===r?A(t):t},Wn=function(e,t){return e===t||te(e)!==null?!1:(Ze&&kn(e),!0)},Gn=function(e,n){if(zn(v.beforeSanitizeElements,e,null),Wn(e,n))return!0;if(In(e))return wn(e),!0;let r=M(se(e));if(y=Un(v.uponSanitizeElement,y,Ae,x),zn(v.uponSanitizeElement,e,{tagName:r,allowedTags:y}),Wn(e,n))return!0;if(Bn(e,r))return wn(e),!0;if(Ne[r]||!(Fe.tagCheck instanceof Function&&Fe.tagCheck(r))&&!y[r]){let t=Hn(e,r,n);return t===!1&&zn(v.afterSanitizeElements,e,null),t}if(oe(e)===j.element&&!Cn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&D(en,e.innerHTML))return wn(e),!0;if(Be&&e.nodeType===j.text){let n=Pn(e.textContent);e.textContent!==n&&(dt(t.removed,{element:e.cloneNode()}),e.textContent=n)}return zn(v.afterSanitizeElements,e,null),!1},Kn=function(e,t,r){if(Pe[t]||An(t,e)||qe&&(t===`id`||t===`name`)&&(r in n||r in N))return!1;let i=b[t]||Fe.attributeCheck instanceof Function&&Fe.attributeCheck(t,e);return Le&&D(we,t)||Ie&&D(Te,t)?!0:i?at[t]||D(ke,_t(r,De,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&vt(r,`data:`)===0&&nt[e]||Re&&!D(Ee,_t(r,De,``))?!0:!r:Jn(e)&&Vn(Me.tagNameCheck,e)&&Vn(Me.attributeNameCheck,t,e)||t===`is`&&Me.allowCustomizedBuiltInElements&&Vn(Me.tagNameCheck,r)},qn=k({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Jn=function(e){return!qn[mt(e)]&&D(Oe,e)},Yn=function(e,t,n,r){if(g&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return pe(r);case`TrustedScriptURL`:return me(r)}return r},Xn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),In(e)?wn(e):ut(t.removed)}catch{Dn(n,e)}},Zn=function(e){zn(v.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||In(e))return;b=Un(v.uponSanitizeAttribute,b,je,We);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:b,forceKeepAttr:void 0},r=t.length,i=M(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=M(o),u=c,d=o===`value`?u:yt(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,zn(v.uponSanitizeAttribute,e,n),d=n.attrValue,Je&&(l===`id`||l===`name`)&&vt(d,Ye)!==0&&(Dn(o,e,a),d=Ye+d),Ve&&D(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){Dn(o,e,a);continue}if(l===`attributename`&>(d,`href`)){Dn(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){Dn(o,e,a);continue}if(!ze&&D(tn,d)){Dn(o,e,a);continue}if(Be&&(d=Pn(d)),!Kn(i,l,d)){Dn(o,e,a);continue}d=Yn(i,l,s,d),d!==u&&Xn(e,o,s,d)}}zn(v.afterSanitizeAttributes,e,null)},Qn=function(e){let t=null,n=Nn(e);for(zn(v.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(zn(v.uponSanitizeShadowNode,t,null),Gn(t,e),Zn(t),Ln(t.content)&&Qn(t.content),oe(t)===j.element){let e=ne(t);Ln(e)&&($n(e),Qn(e))}zn(v.afterSanitizeShadowDOM,e,null)},$n=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Qn(e.shadow);continue}let n=e.node,r=oe(n)===j.element,i=ee(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=ie?ie(n):null;if(typeof e==`string`&&M(e)===`template`){let e=n.content;Ln(e)&&t.push({node:e,shadow:null})}}if(r){let e=ne(n);Ln(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(Ct=!e,Ct&&(e=`<!-->`),typeof e!=`string`&&!Rn(e)&&(e=Ot(e),typeof e!=`string`))throw Tt(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ue?(y=x,b=We):P(n),(v.uponSanitizeElement.length>0||v.uponSanitizeAttribute.length>0)&&(y=A(y)),v.uponSanitizeAttribute.length>0&&(b=A(b)),t.removed=[];let c=Ze&&typeof e!=`string`&&Rn(e);if(c){jn(e);let t=se(e);if(typeof t==`string`){let n=M(t);if(!y[n]||Ne[n])throw En(e),Tt(`root node is forbidden and cannot be sanitized in-place`)}if(In(e))throw En(e),Tt(`root node is clobbered and cannot be sanitized in-place`);try{$n(e)}catch(t){throw En(e),t}}else if(Rn(e))i=Mn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===j.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),$n(a);else{if(!C&&!Be&&!He&&e.indexOf(`<`)===-1)return g&&Ke?pe(e):e;if(i=Mn(e),!i)return C?null:Ke?ce:``}i&&S&&wn(i.firstChild);let l=c?e:i;try{let e=Nn(l);for(;o=e.nextNode();)Gn(o,l),Zn(o),Ln(o.content)&&Qn(o.content)}catch(n){throw c&&(En(e),ct(t.removed,e=>{e.element&&kn(e.element)})),n}if(c)return ct(t.removed,e=>{e.element&&kn(e.element)}),Be&&Fn(e),e;if(C){if(Be&&Fn(i),Ge)for(s=ve.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(b.shadowroot||b.shadowrootmode)&&(s=be.call(r,s,!0)),s}let u=He?i.outerHTML:i.innerHTML;return He&&y[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&D(Xt,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
6
|
-
`+u),Be&&(u=Pn(u)),g&&Ke?pe(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};P(e),Ue=!0,x=y,We=b},t.clearConfig=function(){gn=null,Ue=!1,x=null,We=null,g=le,ce=``},t.isValidAttribute=function(e,t,n){gn||P({});let r=M(e),i=M(t);return Kn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&E(v,e)&&dt(v[e],t)},t.removeHook=function(e,t){if(E(v,e)){if(t!==void 0){let n=lt(v[e],t);return n===-1?void 0:ft(v[e],n,1)[0]}return ut(v[e])}},t.removeHooks=function(e){E(v,e)&&(v[e]=[])},t.removeAllHooks=function(){v=cn()},t}var fn=dn();function pn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var mn=pn();function hn(e){mn=e}var M={exec:()=>null};function gn(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 N(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(P.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var _n=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),P={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,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,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:gn(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:gn(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:gn(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:gn(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:gn(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:gn(e=>RegExp(`^ {0,${e}}>`))},vn=/^(?:[ \t]*(?:\n|$))+/,yn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,bn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,xn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Sn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Cn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,wn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Tn=N(wn).replace(/bull/g,Cn).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(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),En=N(wn).replace(/bull/g,Cn).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(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Dn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,On=/^[^\n]+/,kn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,An=N(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,kn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),jn=N(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Cn).getRegex(),Mn=`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`,Nn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pn=N(`^ {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][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Nn).replace(`tag`,Mn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Fn=e=>N(Dn).replace(`hr`,xn).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`,Mn).getRegex(),In=Fn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Ln=Fn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Rn={blockquote:N(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Ln).getRegex(),code:yn,def:An,fences:bn,heading:Sn,hr:xn,html:Pn,lheading:Tn,list:jn,newline:vn,paragraph:In,table:M,text:On},zn=N(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,xn).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`,Mn).getRegex(),Bn={...Rn,lheading:En,table:zn,paragraph:N(Dn).replace(`hr`,xn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,zn).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`,Mn).getRegex()},Vn={...Rn,html:N(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Nn).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:M,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:N(Dn).replace(`hr`,xn).replace(`heading`,` *#{1,6} *[^
|
|
7
|
-
]`).replace(`lheading`,Tn).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Hn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Un=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Wn=/^( {2,}|\\)\n(?!\s*$)/,Gn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Kn=/[\p{P}\p{S}]/u,qn=/[\s\p{P}\p{S}]/u,Jn=/[^\s\p{P}\p{S}]/u,Yn=N(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,qn).getRegex(),Xn=/[\p{Pi}\p{Ps}"']/u,Zn=/(?!~)[\p{P}\p{S}]/u,Qn=/(?!~)[\s\p{P}\p{S}]/u,$n=/(?:[^\s\p{P}\p{S}]|~)/u,er=N(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,_n?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),tr=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,nr=N(tr,`u`).replace(/punct/g,Kn).getRegex(),rr=N(tr,`u`).replace(/punct/g,Zn).getRegex(),ir=N(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Xn).replace(/punct/g,Kn).getRegex(),ar=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,or=N(ar,`gu`).replace(/notPunctSpace/g,Jn).replace(/punctSpace/g,qn).replace(/punct/g,Kn).getRegex(),sr=N(ar,`gu`).replace(/notPunctSpace/g,$n).replace(/punctSpace/g,Qn).replace(/punct/g,Zn).getRegex(),cr=N(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Jn).replace(/punctSpace/g,qn).replace(/punct/g,Kn).getRegex(),lr=N(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Jn).replace(/punctSpace/g,qn).replace(/punct/g,Kn).getRegex(),ur=N(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Jn).replace(/punctSpace/g,qn).replace(/punct/g,Kn).getRegex(),dr=N(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Kn).getRegex(),fr=N(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Jn).replace(/punctSpace/g,qn).replace(/punct/g,Kn).getRegex(),pr=N(/\\(punct)/,`gu`).replace(/punct/g,Kn).getRegex(),mr=N(/^<(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(),hr=N(Nn).replace(`(?:-->|$)`,`-->`).getRegex(),gr=N(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,hr).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_r=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,vr=N(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,_r).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),yr=N(/^!?\[(label)\]\[(ref)\]/).replace(`label`,_r).replace(`ref`,kn).getRegex(),br=N(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,kn).getRegex(),xr=N(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,yr).replace(`nolink`,br).getRegex(),Sr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Cr={_backpedal:M,anyPunctuation:pr,autolink:mr,blockSkip:er,br:Wn,code:Un,del:M,delLDelim:M,delRDelim:M,emStrongLDelim:nr,emStrongRDelimAst:or,emStrongRDelimUnd:lr,escape:Hn,link:vr,nolink:br,punctuation:Yn,reflink:yr,reflinkSearch:xr,tag:gr,text:Gn,url:M},wr={...Cr,emStrongLDelim:ir,emStrongRDelimAst:cr,emStrongRDelimUnd:ur,link:N(/^!?\[(label)\]\((.*?)\)/).replace(`label`,_r).getRegex(),reflink:N(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,_r).getRegex()},Tr={...Cr,emStrongRDelimAst:sr,emStrongLDelim:rr,delLDelim:dr,delRDelim:fr,url:N(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Sr).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:N(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Sr).getRegex()},Er={...Tr,br:N(Wn).replace(`{2,}`,`*`).getRegex(),text:N(Tr.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Dr={normal:Rn,gfm:Bn,pedantic:Vn},Or={normal:Cr,gfm:Tr,breaks:Er,pedantic:wr},kr={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Ar=e=>kr[e];function jr(e,t){if(t){if(P.escapeTest.test(e))return e.replace(P.escapeReplace,Ar)}else if(P.escapeTestNoEncode.test(e))return e.replace(P.escapeReplaceNoEncode,Ar);return e}function Mr(e){try{e=encodeURI(e).replace(P.percentDecode,`%`)}catch{return null}return e}function Nr(e,t){let n=e.replace(P.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(P.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(P.slashPipe,`|`);return n}function Pr(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 Fr(e){let t=e.split(`
|
|
8
|
-
`),n=t.length-1;for(;n>=0&&P.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
9
|
-
`)}function Ir(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 Lr(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 Rr(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function zr(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
10
|
-
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
11
|
-
`)}var Br=class{options;rules;lexer;constructor(e){this.options=e||mn}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]:Fr(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=zr(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=Pr(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Pr(t[0],`
|
|
12
|
-
`),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:Pr(t[0],`
|
|
13
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Pr(t[0],`
|
|
14
|
-
`).split(`
|
|
15
|
-
`),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(`
|
|
16
|
-
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
17
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
18
|
-
${s}`:s,r=r?`${r}
|
|
19
|
-
${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(`
|
|
20
|
-
`),o=t.raw+`
|
|
21
|
-
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s,n=`${n}
|
|
22
|
-
${a}`,r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
23
|
-
`+e.join(`
|
|
24
|
-
`),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(`
|
|
25
|
-
`);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=Lr(t[2].split(`
|
|
26
|
-
`,1)[0],t[1].length),l=e.split(`
|
|
27
|
-
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
28
|
-
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
|
|
29
|
-
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
30
|
-
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
31
|
-
`+l}u=!l.trim(),r+=p+`
|
|
32
|
-
`,e=e.substring(p.length+1),c=m.slice(d)}}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=Fr(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=t[1].toLowerCase().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:Pr(t[0],`
|
|
33
|
-
`),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=Nr(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
34
|
-
`):[],a={type:`table`,raw:Pr(t[0],`
|
|
35
|
-
`),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(Nr(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:Pr(t[0],`
|
|
36
|
-
`),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)===`
|
|
37
|
-
`?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 e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Pr(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Ir(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 n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Rr(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.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 e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Rr(n,e,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}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,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,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:t[0],escaped:e}}}},Vr=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||mn,this.options.tokenizer=this.options.tokenizer||new Br,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:P,block:Dr.normal,inline:Or.normal};this.options.pedantic?(t.block=Dr.pedantic,t.inline=Or.pedantic):this.options.gfm&&(t.block=Dr.gfm,t.inline=this.options.breaks?Or.breaks:Or.gfm),this.tokenizer.rules=t}static get rules(){return{block:Dr,inline:Or}}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(P.carriageReturn,`
|
|
38
|
-
`),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(P.tabCharGlobal,` `).replace(P.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+=`
|
|
39
|
-
`: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(`
|
|
40
|
-
`)?``:`
|
|
41
|
-
`)+i.raw,n.text+=`
|
|
42
|
-
`+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(`
|
|
43
|
-
`)?``:`
|
|
44
|
-
`)+i.raw,n.text+=`
|
|
45
|
-
`+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(`
|
|
46
|
-
`)?``:`
|
|
47
|
-
`)+i.raw,r.text+=`
|
|
48
|
-
`+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(`
|
|
49
|
-
`)?``:`
|
|
50
|
-
`)+i.raw,n.text+=`
|
|
51
|
-
`+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}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links){let e=Object.keys(this.tokens.links);e.length>0&&(n=n.replace(this.tokenizer.rules.inline.reflinkSearch,t=>e.includes(t.slice(t.lastIndexOf(`[`)+1,-1))?`[`+`a`.repeat(t.length-2)+`]`: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)}},Hr=class{options;parser;constructor(e){this.options=e||mn}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(P.notSpaceStart)?.[0],i=e.replace(P.endingNewline,``)+`
|
|
52
|
-
`;return r?`<pre><code class="language-`+jr(r)+`">`+(n?i:jr(i,!0))+`</code></pre>
|
|
53
|
-
`:`<pre><code>`+(n?i:jr(i,!0))+`</code></pre>
|
|
54
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
55
|
-
${this.parser.parse(e)}</blockquote>
|
|
56
|
-
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
57
|
-
`}hr(e){return`<hr>
|
|
58
|
-
`}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+`>
|
|
59
|
-
`+r+`</`+i+`>
|
|
60
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
61
|
-
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
62
|
-
`}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>
|
|
63
|
-
<thead>
|
|
64
|
-
`+t+`</thead>
|
|
65
|
-
`+r+`</table>
|
|
66
|
-
`}tablerow({text:e}){return`<tr>
|
|
67
|
-
${e}</tr>
|
|
68
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
69
|
-
`}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>${jr(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Mr(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+jr(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Mr(e);if(i===null)return jr(n);e=i;let a=`<img src="${e}" alt="${jr(n)}"`;return t&&(a+=` title="${jr(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:jr(e.text)}},Ur=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}},Wr=class e{options;renderer;textRenderer;constructor(e){this.options=e||mn,this.options.renderer=this.options.renderer||new Hr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ur}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}},Gr=class{options;block;constructor(e){this.options=e||mn}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?Vr.lex:Vr.lexInline}provideParser(e=this.block){return e?Wr.parse:Wr.parseInline}},Kr=new class{defaults=pn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Wr;Renderer=Hr;TextRenderer=Ur;Lexer=Vr;Tokenizer=Br;Hooks=Gr;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 Hr(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 Br(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 Gr;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];t[r]=Gr.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Gr.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)}:(...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 Vr.lex(e,t??this.defaults)}parser(e,t){return Wr.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?Vr.lex:Vr.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?Wr.parse:Wr.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?Vr.lex:Vr.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?Wr.parse:Wr.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+=`
|
|
70
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+jr(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function F(e,t){return Kr.parse(e,t)}F.options=F.setOptions=function(e){return Kr.setOptions(e),F.defaults=Kr.defaults,hn(F.defaults),F},F.getDefaults=pn,F.defaults=mn;function qr(...e){return Kr.use(...e),F.defaults=Kr.defaults,hn(F.defaults),F}F.use=qr,F.walkTokens=function(e,t){return Kr.walkTokens(e,t)},F.parseInline=Kr.parseInline,F.Parser=Wr,F.parser=Wr.parse,F.Renderer=Hr,F.TextRenderer=Ur,F.Lexer=Vr,F.lexer=Vr.lex,F.Tokenizer=Br,F.Hooks=Gr,F.parse=F,F.options,F.setOptions,F.walkTokens,F.parseInline,Wr.parse,Vr.lex;var I=e=>{let t=document.querySelector(e);if(!t)throw Error(`missing element: ${e}`);return t};function Jr(e){let t=Math.round((Date.now()-e)/6e4);return t<1?`now`:t<60?`${t}m`:t<1440?`${Math.round(t/60)}h`:`${Math.round(t/1440)}d`}var Yr=e=>{let t=Jr(e);return t===`now`?`just now`:`${t} ago`};function L(e,t,...n){let r=document.createElement(e);return t&&(r.className=t),r.append(...n),r}var Xr=e=>e.split(`/`).filter(Boolean).pop()??e,Zr=e=>`New session in ${Xr(e)}`;function Qr(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function $r(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function ei(e,t,n){return{visible:!1,show(n,r){this.visible=!0,e.classList.remove(`hidden`),e.classList.add(`flex`),t(n,r)},hide(){n?.(),this.visible=!1,e.classList.add(`hidden`),e.classList.remove(`flex`)}}}function ti(e){let t=L(`span`,`help`);return t.innerHTML=fn.sanitize(F.parseInline(e,{async:!1})),ni(t),t}function ni(e){for(let t of e.querySelectorAll(`a`))(t.getAttribute(`href`)??``).startsWith(`#`)||(t.target=`_blank`,t.rel=`noreferrer`)}async function ri(e){if(navigator.clipboard)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);t.value=e,t.className=`fixed opacity-0`,document.body.append(t),t.select();let n=document.execCommand(`copy`);if(t.remove(),!n)throw Error(`clipboard unavailable`)}function ii(e,t){let n=L(`button`,e,`Copy`);n.title=`Copy to clipboard`;let r;return n.onclick=async e=>{e.stopPropagation(),n.textContent=await ri(t()).then(()=>`Copied`,()=>`Failed`),clearTimeout(r),r=setTimeout(()=>n.textContent=`Copy`,1200)},n}var ai=450,oi=8,si=700;function ci(e,t){let n,r,i={x:0,y:0},a=!1,o=()=>clearTimeout(n),s=t=>{e.classList.remove(`bg-emerald-100`,`bg-red-100`),e.classList.add(t),clearTimeout(r),r=setTimeout(()=>e.classList.remove(t),si)};e.addEventListener(`pointerdown`,e=>{a=!1,i={x:e.clientX,y:e.clientY},o(),n=setTimeout(()=>{a=!0,ri(t()).then(()=>s(`bg-emerald-100`),()=>s(`bg-red-100`))},ai)}),e.addEventListener(`pointermove`,e=>{Math.hypot(e.clientX-i.x,e.clientY-i.y)>oi&&o()});for(let t of[`pointerup`,`pointercancel`,`pointerleave`])e.addEventListener(t,o);e.addEventListener(`click`,e=>{a&&(e.preventDefault(),e.stopImmediatePropagation())})}function li(e,t){let n=document.createElement(`details`);n.className=e;let r=L(`summary`,`flex cursor-pointer select-none items-center gap-1.5`);return r.append(_(l,`chev h-3 w-3`),...t),n.append(r),{el:n,summary:r}}var ui=(e,t=!1)=>di(e,`${t?`btn btn-primary`:`btn`} text-[12.5px]`),di=(e,t=``)=>{let n=L(`button`,t,e);return n.type=`button`,n},fi=e=>L(`span`,`mr-1 flex-none font-medium max-md:hidden`,e),pi=(...e)=>L(`div`,`toolbar flex min-h-10 flex-none flex-wrap items-center gap-2 px-4 py-2`,...e);function mi(e,t,n){let r=L(`div`,`inline-flex flex-none items-center gap-0.5 rounded-full bg-neutral-100 p-1`);for(let[i,a,o]of e){let e=a===t,s=di(o?``:i,`cursor-pointer whitespace-nowrap rounded-full text-[12px] transition-colors ${o?`flex h-7 w-7 items-center justify-center`:`px-3 py-1`} ${e?`bg-white font-medium text-neutral-800 shadow-xs`:`text-neutral-500 hover:text-neutral-700`}`);o&&(s.append(_(o,`h-4 w-4`)),s.setAttribute(`aria-label`,i),s.title=i),s.setAttribute(`aria-pressed`,String(e)),s.onclick=()=>n(a),r.append(s)}return r}function hi(e,t,n){let r=L(`div`,`flex flex-wrap items-center gap-2`);r.setAttribute(`role`,`radiogroup`);let i=e.map(([e])=>e),a=e.map(([e,t])=>{let n=di(``,`flex h-10 w-10 cursor-pointer items-center justify-center rounded-full ring-neutral-800 ring-offset-2 ring-offset-white transition-shadow hover:ring-2`);return n.style.background=t,n.setAttribute(`role`,`radio`),n.setAttribute(`aria-label`,e),n.title=e,n}),s=e=>{a.forEach((t,n)=>{let r=i[n]===e;t.classList.toggle(`ring-2`,r),t.setAttribute(`aria-checked`,String(r)),t.tabIndex=r?0:-1,t.replaceChildren(...r?[_(o,`h-4 w-4 text-white dark:text-neutral-950`)]:[])})},c=e=>{s(e),n(e)};return a.forEach((e,t)=>{e.onclick=()=>c(i[t]),e.onkeydown=e=>{let n=e.key===`ArrowRight`||e.key===`ArrowDown`?1:e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:0;if(!n)return;e.preventDefault();let r=(t+n+i.length)%i.length;a[r].focus(),c(i[r])}}),s(t),r.append(...a),r}function gi(e,t,n){let r=di(e,`flex cursor-pointer items-center gap-1.5 rounded-full px-3.5 py-2 text-[13px] transition-colors ${t?`bg-indigo-50 font-medium text-indigo-700 ring-1 ring-indigo-200/70`:`text-neutral-600 hover:bg-neutral-100`}`);return r.onclick=n,r}var _i=`rounded-3xl border border-neutral-200 bg-white shadow-sm`,vi=`border-b border-neutral-200/70 bg-neutral-50/50`,yi=`${_i} flex flex-col overflow-hidden`,bi=`${vi} flex flex-none items-center`;function xi(e,t,...n){let r=L(`section`,_i),i=L(`div`,`rounded-t-3xl ${vi} px-5 py-4`);return i.append(L(`h2`,`text-[14px] font-semibold text-neutral-800`,e)),t&&i.append(L(`p`,`mt-1 text-[12px] leading-normal text-neutral-500`,t)),r.append(i,L(`div`,`flex flex-col gap-4 px-5 py-5`,...n)),r}function Si(e,t,n={}){let r=L(`div`,`flex flex-col gap-1.5`),i=L(`div`,`flex items-center gap-1.5`,L(`span`,`field-label`,e));return n.help&&i.append(n.help),r.append(i,t),n.hint&&r.append(L(`span`,`text-[11.5px] leading-snug text-neutral-400`,n.hint)),r}var Ci=`w-full rounded-xl border border-neutral-200 bg-neutral-50/60 px-3 py-2.5 text-[12.5px] transition-colors placeholder:text-neutral-400 hover:border-neutral-300 focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 focus:outline-none`,wi=`${Ci} cursor-pointer truncate text-left hover:bg-neutral-50`,Ti=(e,t,n,r=!1)=>{let i=document.createElement(`input`);return i.className=r?`${Ci} font-mono`:Ci,i.value=e,i.placeholder=t,i.oninput=()=>n(i.value),i},Ei=(e=``,t=`text`)=>{let n=document.createElement(`input`);return n.type=t,n.className=Ci,n.value=e,n},Di=(e,t)=>{let n=document.createElement(`select`);return n.className=`${Ci} select`,n.append(...e.map(([e,t])=>new Option(e,t))),n.value=t,n},Oi=(e=``,t=4)=>{let n=document.createElement(`textarea`);return n.className=`${Ci} resize-y font-mono`,n.value=e,n.rows=t,n.spellcheck=!1,n};function ki(e,t,n,r,i){let a=document.createElement(`input`);a.type=`checkbox`,a.className=`peer sr-only`,a.checked=n,a.onchange=()=>r(a.checked);let o=L(`span`,`relative h-4 w-7 flex-none rounded-full bg-neutral-300 transition-colors after:absolute after:left-0.5 after:top-0.5 after:h-3 after:w-3 after:rounded-full after:bg-white dark:after:bg-neutral-950 after:shadow-sm after:transition-transform peer-checked:bg-indigo-600 peer-checked:after:translate-x-3 peer-focus-visible:ring-2 peer-focus-visible:ring-indigo-200 peer-disabled:cursor-not-allowed peer-disabled:opacity-45`),s=L(`label`,`flex cursor-pointer gap-2.5 ${e?`items-start`:`items-center`}`);if(s.append(a,o),e){let n=L(`span`,`flex items-center gap-1.5`,L(`span`,`text-[13px] text-neutral-700`,e));i&&n.append(i);let r=L(`span`,`flex min-w-0 flex-col`,n);t&&r.append(L(`span`,`text-[11.5px] leading-snug text-neutral-400`,t)),s.append(r)}return s}var Ai={idle:`text-neutral-400`,saving:`text-neutral-400`,saved:`text-green-700`,failed:`text-red-600`};function R(e,t,n){e.className=`text-[11.5px] ${Ai[t]}`,e.textContent=n}var ji=(e,t,n)=>L(`span`,`inline-flex flex-none items-center gap-1 rounded-full px-1.5 py-px text-[10px] font-medium uppercase tracking-wide ring-1 ${t}`,...n?[L(`span`,`inline-block h-1.5 w-1.5 flex-none rounded-full ${n}`)]:[],e);function Mi(e,t,n,r={}){let i=L(`div`,`flex min-w-0 flex-col`,L(`span`,`flex min-w-0 items-center gap-2`,L(`span`,`truncate text-[12.5px] text-neutral-700`,e),...r.tag?[r.tag]:[]),L(`span`,`truncate text-[11.5px] text-neutral-400`,t));return r.title&&(i.title=r.title),L(`div`,`flex items-center justify-between gap-3 rounded-lg border border-neutral-200 px-3 py-2`,i,n)}var Ni=e=>L(`p`,`rounded-lg border border-dashed border-neutral-200 px-3 py-4 text-center text-[12.5px] text-neutral-400`,e);function Pi(e,t){let n=L(`span`,`group relative inline-flex`),r=di(``,`flex h-4 w-4 cursor-help items-center justify-center text-neutral-400 transition-colors group-hover:text-indigo-500`);r.append(_(u,`h-full w-full`)),r.setAttribute(`aria-label`,e);let i=L(`span`,`absolute left-0 top-full z-20 hidden w-[min(27rem,calc(100vw-3rem))] pt-1.5 group-hover:block`),a=L(`span`,`flex flex-col gap-2 rounded-xl border border-neutral-200 bg-white p-3.5 text-[12px] font-normal normal-case leading-[1.55] tracking-normal text-neutral-600 shadow-xl`);a.append(L(`span`,`text-[12.5px] font-semibold text-neutral-800`,e));let o=L(`ol`,`flex list-decimal flex-col gap-1.5 pl-4`);for(let e of t){let t=L(`li`,`marker:text-neutral-400`);t.append(typeof e==`string`?ti(e):e),o.append(t)}return a.append(o),i.append(a),r.onclick=()=>{let e=i.classList.contains(`hidden`);i.classList.toggle(`hidden`,!e),i.classList.toggle(`block`,e),r.classList.toggle(`text-indigo-500`,e)},n.append(r,i),n}var Fi=(e,t)=>L(`span`,`flex flex-col gap-1`,ti(e),t),Ii=e=>`[${e.split(`/`).pop()??`file`}](file://${encodeURI(e).replace(/\(/g,`%28`).replace(/\)/g,`%29`)})`,Li=/^ {0,3}(`{3,}|~{3,})/;function Ri(e){let t=[],n,r=0;for(let i of e.split(`
|
|
71
|
-
`)){let e=Li.exec(i)?.[1];if(n!==void 0)t.push([r,r+i.length]),e&&e[0]===n[0]&&e.length>=n.length&&(n=void 0);else if(e)n=e,t.push([r,r+i.length]);else{let e=[...i.matchAll(/`+/g)];for(let n=0;n<e.length;n++){let i=e[n],a=n+1;for(;a<e.length&&e[a][0].length!==i[0].length;)a++;if(a===e.length)break;t.push([r+i.index,r+e[a].index+e[a][0].length]),n=a}}r+=i.length+1}return t}function zi(e,t,n){let r=Ri(e),i=``,a=0;for(let o of e.matchAll(t)){let t=o.index,s=t+o[0].length;r.some(([e,n])=>t<n&&s>e)||(i+=e.slice(a,t)+n(o),a=s)}return i+e.slice(a)}var Bi=/^\[[^\]\n]*\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)$/;function Vi(e){let t=e.split(`
|
|
72
|
-
`),n=t.length;for(;n>0&&Bi.test(t[n-1].trim());)n--;let r=t.slice(n).map(e=>{let t=Bi.exec(e.trim())[1];try{return decodeURIComponent(t)}catch{return t}});return{text:t.slice(0,n).join(`
|
|
73
|
-
`).trimEnd(),paths:r}}var Hi=`modulepreload`,Ui=function(e){return`/app/`+e},Wi={},Gi=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ui(t,n),t=s(t),t in Wi)return;Wi[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Hi,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ki,qi;function Ji(){return qi??=Gi(()=>import(`./hljs-tWqyD59G.js`).then(e=>Ki=e.default,e=>{console.warn(`highlighting unavailable — code stays plain text`,e)}),[]),qi}async function Yi(e){let t=await Ji();if(t)for(let n of e.querySelectorAll(`pre code[class]`)){let e=/(?:language|lang)-(\S+)/.exec(n.className)?.[1]?.toLowerCase();!e||!t.getLanguage(e)||(n.innerHTML=t.highlight(n.textContent??``,{language:e}).value)}}var Xi={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,py:`python`,rs:`rust`,sh:`bash`,zsh:`bash`,md:`markdown`,yml:`yaml`,html:`xml`,htm:`xml`,svg:`xml`,patch:`diff`};async function Zi(e){let t=await Ji(),n=e.split(`.`).pop()?.toLowerCase()??``,r=Xi[n]??n;return t?.getLanguage(r)?r:null}function Qi(e,t){let n=document.createElement(`span`);return Ki&&t&&e.length<=500?n.innerHTML=Ki.highlight(e,{language:t}).value:n.textContent=e,n}var $i=2e4;function ea(e){let t=e.split(`
|
|
74
|
-
`);return t.at(-1)===``&&t.pop(),t.map((e,t)=>({nums:[t+1],text:e,tone:``}))}function ta(e,t){let n=e.length<=$i?t:null,r=Math.max(2,...e.map(e=>e.nums.reduce((e,t)=>Math.max(e,String(t).length),0))),i=L(`div`,`py-2 font-mono text-[12px] leading-[1.5]`);for(let t of e){let e=L(`div`,`flex pl-2 pr-4 ${t.tone===`add`?`bg-emerald-50`:t.tone===`del`?`bg-red-50`:``}`);for(let n of t.nums){let t=L(`span`,`flex-none select-none pr-1.5 text-right text-neutral-300`,n===``?``:String(n));t.style.width=`calc(${r}ch + 0.375rem)`,e.append(t)}t.nums.length===1&&typeof t.nums[0]==`number`&&(e.dataset.line=String(t.nums[0])),e.append(na(t,n)),i.append(e)}return i}function na(e,t){let n=`min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere]`;if(!e.mark||e.mark[0]>=e.mark[1]){let r=Qi(e.text,t);return r.className=n,r}let[r,i]=e.mark,a=Qi(e.text.slice(r,i),t);return a.className=`rounded-xs ${e.tone===`add`?`bg-emerald-200/80`:`bg-red-200/70`}`,L(`span`,n,Qi(e.text.slice(0,r),t),a,Qi(e.text.slice(i),t))}var z=null,ra=null,ia=null;function aa(e){z&&!z.contains(e.target)&&e.target!==ia&&B()}var oa={ArrowDown:1,ArrowUp:-1},sa={n:1,j:1,p:-1,k:-1},ca=()=>z!==null;function la(e){if(!(e.altKey||e.metaKey||e.shiftKey||!e.key))return e.ctrlKey?sa[e.key.toLowerCase()]:oa[e.key]}function ua(e,t){let n=[...e.querySelectorAll(`button:not(:disabled)`)];if(!n.length)return!1;let r=n.indexOf(document.activeElement);return n[t===`first`?0:t===`last`?n.length-1:r<0?t>0?0:n.length-1:(r+t+n.length)%n.length]?.focus(),!0}function da(e){if(e.dataset.menu===`true`)return{rows:e,ends:!0};let t=e.querySelector(`[data-list]`);return t?{rows:t,ends:!1}:null}function fa(e){let t=z?da(z):null;if(t){let n=(t.ends?e.key===`Home`?`first`:e.key===`End`?`last`:void 0:void 0)??la(e);if(n!==void 0&&ua(t.rows,n)){e.preventDefault();return}}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),B())}function pa(e){z&&!z.contains(e.target)&&B()}function B(){if(!z)return;document.removeEventListener(`pointerdown`,aa,!0),document.removeEventListener(`focusin`,aa,!0),document.removeEventListener(`keydown`,fa,!0),window.removeEventListener(`scroll`,pa,!0),window.removeEventListener(`resize`,B);let e=z;z=null,ia?.remove(),ia=null,e.contains(document.activeElement)&&ra?.focus({preventScroll:!0}),ra?.removeAttribute(`aria-expanded`),ra=null,e.inert=!0,e.dataset.closing=``,Promise.allSettled(e.getAnimations().map(e=>e.finished)).then(()=>e.remove())}var ma=null;function ha(e){let t=e.getBoundingClientRect(),n={top:t.bottom+4,left:t.left};return t.width||t.height?n:ma?.anchor===e?{top:ma.top,left:ma.left}:n}var ga=()=>window.innerWidth<640;function _a(e,t){B(),document.querySelectorAll(`.glass-menu[data-closing]`).forEach(e=>e.remove());let n=ga();z=L(`div`,`glass-menu fixed z-50 border border-neutral-200 p-2 font-sans leading-6 ${n?`rounded-3xl inset-x-2 bottom-2 max-h-[70dvh] overflow-y-auto pb-[calc(0.25rem+env(safe-area-inset-bottom))] text-[16px]`:`rounded-2xl min-w-60 max-w-[min(42rem,calc(100vw-1rem))] max-h-[calc(100dvh-1rem)] overflow-y-auto text-[15px]`}`),z.dataset.presentation=n?`sheet`:`popover`,z.append(t);let r=e.closest(`dialog[open]`)??document.body;if(n&&(ia=L(`div`,`fixed inset-0 z-50 bg-black/15`),ia.onclick=e=>{e.stopPropagation(),B()},r.append(ia)),r.append(z),!n){let t=ha(e);ma={anchor:e,...t},z.style.top=`${Math.max(8,Math.min(t.top,window.innerHeight-z.offsetHeight-8))}px`,z.style.left=`${Math.max(8,Math.min(t.left,window.innerWidth-z.offsetWidth-8))}px`}return ra=e,ra.setAttribute(`aria-expanded`,`true`),z.tabIndex=-1,(z.querySelector(`button, input, select, [tabindex='0']`)??z).focus({preventScroll:!0}),document.addEventListener(`pointerdown`,aa,!0),document.addEventListener(`focusin`,aa,!0),document.addEventListener(`keydown`,fa,!0),window.addEventListener(`scroll`,pa,!0),window.addEventListener(`resize`,B),z}function va(e){let t=L(`button`,`flex w-full cursor-pointer items-center gap-2 rounded-xl px-3 text-left transition-colors hover:bg-indigo-50 hover:text-indigo-700 active:bg-indigo-100 ${ga()?`min-h-12 py-3`:`min-h-10 py-2`}`,...e.checked===void 0?[]:[_(o,`h-3 w-3 text-indigo-600 ${e.checked?``:`invisible`}`)],L(`span`,`min-w-0 truncate`,e.label));if(e.hint){let n=L(`span`,`ml-auto max-w-28 shrink-[999] truncate text-[13px] text-neutral-500`,e.hint);n.title=e.hint,t.append(n)}return e.disabled&&(t.disabled=!0,t.classList.add(`cursor-default`,`text-neutral-400`,`hover:bg-transparent`,`hover:text-neutral-400`)),t.onclick=()=>e.onSelect(),t}function ya(e,t,n){let r=L(`div`,``);if(n&&ga()){let e=L(`button`,`icon-btn h-11 w-11`,_(_e));e.setAttribute(`aria-label`,`Close session actions`),e.onclick=B,r.append(L(`div`,`flex items-center gap-3 border-b border-neutral-200 px-3 pb-1 mb-1`,L(`span`,`min-w-0 flex-1 truncate text-sm font-medium text-neutral-500`,n),e))}for(let e of t)e.separatorBefore&&r.append(L(`hr`,`my-2 border-neutral-200`)),r.append(va(e));_a(e,r),z&&(z.dataset.menu=`true`,z.setAttribute(`aria-label`,n?`Actions for ${n}`:`Actions`),z.setAttribute(`role`,`group`))}var ba=async e=>{let t=await C(`/api/fs/ls${e?.startsWith(`/`)?`?path=${encodeURIComponent(e)}`:``}`,`Could not list directories`);return t.ok?t.value:null},xa=e=>e.entries.filter(e=>e.dir&&!e.name.startsWith(`.`)).map(e=>e.name),Sa=`flex w-full min-h-10 cursor-pointer items-center gap-2 rounded-xl px-3 py-2 text-left transition-colors hover:bg-indigo-50 hover:text-indigo-700 active:bg-indigo-100`,Ca=`font-mono text-[0.875rem]`,wa=(e,t,n)=>{let r=di(e,`${Sa} ${t}`);return r.onclick=n,r};function Ta(e,t){let n=L(`div`,`mt-2 flex-none border-t border-neutral-200 pt-2`),r=wa(`New folder`,`text-neutral-500`,()=>{let r=document.createElement(`input`);r.className=`w-full rounded-xl border-0 bg-neutral-100 px-3 py-2 ${Ca} focus:outline-none`,r.placeholder=`folder-name`;let i=L(`p`,`hidden px-3 pt-1 text-[0.8125rem] text-red-600`);r.onkeydown=async n=>{if(n.key!==`Enter`)return;n.preventDefault();let a=await x(`/api/fs/mkdir`,{path:e,name:r.value});if(!a.ok){i.textContent=(await a.json()).error??`could not create`,i.classList.remove(`hidden`);return}t((await a.json()).path)},n.replaceChildren(r,i),r.focus()});return r.prepend(_(ue)),n.append(r),n}function Ea(e,t,n){let r=e=>{n(e),B()};async function i(t){let n=await ba(t);if(!n)return;let a=L(`div`,`flex max-h-[60dvh] w-full flex-col sm:w-88`),o=di(`Use`,`btn btn-primary ml-auto flex-none px-3 py-1 text-[0.8125rem]`);o.onclick=()=>r(n.path);let s=document.createElement(`input`);s.className=`min-w-0 flex-1 border-0 bg-transparent ${Ca} text-neutral-600 focus:outline-none`,s.value=n.path,s.spellcheck=!1,s.title=`Type or paste a path, then Enter`,s.onfocus=()=>s.select();let c=L(`p`,`hidden flex-none px-3 pb-1 text-[0.8125rem] text-red-600`);s.onkeydown=async e=>{if(e.key!==`Enter`)return;e.preventDefault(),e.stopPropagation();let t=s.value.trim();if(!t)return;let n=await ba(t);if(!n){c.textContent=`${t} is not a folder this can read`,c.classList.remove(`hidden`);return}r(n.path)};let l=L(`div`,`mb-2 flex flex-none items-center gap-2 border-b border-neutral-200 px-3 pb-2 pt-1`,s,o),u=L(`div`,`min-h-0 flex-1 overflow-y-auto`);u.dataset.list=``,n.parent&&u.append(wa(`../`,`${Ca} text-neutral-500`,()=>void i(n.parent)));let d=xa(n);for(let e of d)u.append(wa(e,`truncate`,()=>void i(`${n.path}/${e}`.replace(`//`,`/`))));d.length||u.append(L(`p`,`px-3 py-2 text-[0.8125rem] text-neutral-400`,`No sub-folders.`)),a.append(l,c,u,Ta(n.path,e=>void i(e))),_a(e,a)}i(t)}function Da(e,t,n,r){ya(e,[...t.map(e=>({label:e.path,...e.hint?{hint:e.hint}:{},checked:e.path===n,onSelect:()=>{B(),r(e.path)}})),{label:`Browse…`,onSelect:()=>Ea(e,n||void 0,r)}])}var Oa=(e,t)=>n=>{e.value=n,e.dispatchEvent(new Event(`input`,{bubbles:!0})),t?.(n)};function ka(e,t){let n=di(`Browse…`,`flex-none cursor-pointer rounded-md border border-neutral-300 px-2 py-1 text-[12px] text-neutral-600 hover:bg-neutral-100`);return n.onclick=()=>Ea(n,e.value.trim()||void 0,Oa(e,t)),n}function Aa(e,t,n){let r=document.createElement(`input`);return r.className=`min-w-0 flex-1 rounded-md border border-neutral-300 bg-white px-2 py-1 font-mono text-[12.5px] focus:border-indigo-400 focus:outline-none`,r.value=e,r.placeholder=t,r.oninput=()=>n(r.value),{el:L(`div`,`flex items-center gap-1.5`,r,ka(r,n)),input:r}}var ja=I(`#image-dialog`),V=I(`#image-stage`),Ma=I(`#image-full`),Na=I(`#image-prev`),Pa=I(`#image-next`),Fa=I(`#image-close`),Ia=[],La=0;function Ra(e){Ia.length<2||(La=(La+e+Ia.length)%Ia.length,Va(!1),Ma.src=Ia[La])}var za=2.5,Ba=()=>V.dataset.zoom!==void 0;function Va(e,t){if(!e){delete V.dataset.zoom,Ma.style.cssText=``;return}let n=Ma.getBoundingClientRect(),r=V.getBoundingClientRect(),i=t?(t.x-n.left)/n.width:.5,a=t?(t.y-n.top)/n.height:.5,o=n.width*za,s=n.height*za;V.dataset.zoom=``,Ma.style.width=`${String(o)}px`,Ma.style.height=`${String(s)}px`,V.scrollLeft=i*o-r.width/2,V.scrollTop=a*s-r.height/2}function Ha(e){let t=e.closest(`[data-gallery]`);Ia=t?[...t.querySelectorAll(`img.thumb`)].map(e=>e.src):[e.src],La=Math.max(0,Ia.indexOf(e.src)),Ma.src=e.src;let n=Ia.length<2?`none`:`flex`;Na.style.display=n,Pa.style.display=n,ja.showModal()}var Ua=4,Wa,Ga=!1;V.onpointerdown=e=>{Ga=!1,!(!Ba()||e.button!==0)&&(Wa={x:e.clientX,y:e.clientY,left:V.scrollLeft,top:V.scrollTop},V.setPointerCapture(e.pointerId))},V.onpointermove=e=>{if(!Wa)return;let t=e.clientX-Wa.x,n=e.clientY-Wa.y;(Math.abs(t)>Ua||Math.abs(n)>Ua)&&(Ga=!0),V.scrollLeft=Wa.left-t,V.scrollTop=Wa.top-n};var Ka=()=>{Wa=void 0};V.onpointerup=Ka,V.onpointercancel=Ka,V.onclick=e=>{Ga||(e.target===Ma?Va(!Ba(),{x:e.clientX,y:e.clientY}):ja.close())},Fa.onclick=()=>ja.close(),ja.onclose=()=>Va(!1),Na.onclick=()=>Ra(-1),Pa.onclick=()=>Ra(1),ja.onkeydown=e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),Ra(e.key===`ArrowLeft`?-1:1))};function qa(e){let t=e.querySelector(`:scope > .thumbs`);if(t)return t;let n=L(`div`,`thumbs`);return e.append(n),n}function Ja(e){let t=document.createElement(`img`);return t.src=e,t.loading=`lazy`,t.className=`thumb`,t.onclick=()=>Ha(t),t}var Ya=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`bmp`]),Xa=524288,Za=I(`#file-dialog`),Qa=I(`#file-name`),$a=I(`#file-text`),eo=I(`#file-download`);I(`#file-close`).onclick=()=>Za.close();var to=e=>e.split(`.`).pop()?.toLowerCase()??``,no=(e,t,n=!1)=>`/api/sessions/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}${n?`&download=1`:``}`,ro=e=>decodeURIComponent(/^\/api\/sessions\/([^/]+)\//.exec(e)?.[1]??``),io=e=>e.slice(0,e.lastIndexOf(`/`))||`/`,ao=(e,t)=>`${e===`/`?``:e}/${t}`;function oo(e,t){return zi(e,/\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)/g,e=>{let n=e[1];try{n=decodeURIComponent(n)}catch{}return`](${no(t,n)})`})}var so=e=>/^\/api\/sessions\/[^/]+\/files\?/.test(e);function co(e,t){let n=Xr(t)||`file`,r=no(e,t);return Ya.has(to(n))?Co(r,n):wo(r,n)}function lo(e){return new URLSearchParams(e.slice(e.indexOf(`?`)+1)).get(`path`)??``}var uo=(e,t=`text-neutral-500`)=>L(`div`,`px-3 py-2 text-[12.5px] [overflow-wrap:anywhere] ${t}`,e),fo=0;function po(e,t,n){if(eo.hidden=n,n){Qa.replaceChildren(t);return}let r=io(t),i=di(`${r}/`,`min-w-0 cursor-pointer truncate text-neutral-400 hover:text-indigo-600`);i.title=`Browse ${r}`,i.onclick=()=>void ho(e,r),Qa.replaceChildren(i,L(`span`,`flex-none`,Xr(t)))}function mo(e,t){let n=L(`div`,`flex flex-col py-1`),r=(e,t,n)=>{let r=di(e,`flex w-full cursor-pointer items-center px-3 py-1.5 text-left font-mono text-[12.5px] hover:bg-indigo-50 hover:text-indigo-700 ${t}`);return r.onclick=n,r};t.parent&&n.append(r(`../`,`text-neutral-500`,()=>void ho(e,t.parent)));for(let i of t.entries){let a=ao(t.path,i.name);n.append(i.dir?r(`${i.name}/`,`text-neutral-800`,()=>void ho(e,a)):r(i.name,`text-neutral-600`,()=>void go(no(e,a),i.name)))}return t.entries.length||n.append(uo(`Empty folder.`)),n}async function ho(e,t){let n=++fo;po(e,t,!0),$a.replaceChildren(uo(`loading…`)),Za.open||Za.showModal();let r=await ba(t);n===fo&&$a.replaceChildren(r?mo(e,r):uo(`failed to list: ${t}`,`text-red-600`))}async function go(e,t,n){let r=++fo;po(ro(e),lo(e)||t,!1),eo.href=`${e}&download=1`,$a.replaceChildren(uo(`loading…`)),Za.open||Za.showModal();let i=e=>{r===fo&&$a.replaceChildren(e)},a;try{a=await fetch(e)}catch(e){return i(uo(`failed to load: ${String(e)}`,`text-red-600`))}if(!a.ok){let t=lo(e),n=a.status===404?await ba(t):null;return r===fo?n?void ho(ro(e),t):i(uo(`${await S(a,`failed to load`)}: ${t}`,`text-red-600`)):void 0}let o=a.headers.get(`content-type`)??``;if(!o.startsWith(`text/`)&&!o.startsWith(`image/svg+xml`))return i(uo(`Binary file — use Download.`));let s=await a.text(),c=s.length>Xa?`${s.slice(0,Xa)}\n…`:s,l=await Zi(t),u=ta(ea(c),l);if(i(u),n===void 0||r!==fo)return;let d=u.querySelector(`[data-line="${String(n)}"]`);d?.classList.add(`bg-indigo-100`),d?.scrollIntoView({block:`center`})}var _o=new Set(`ts.tsx.mts.cts.js.jsx.mjs.cjs.json.md.css.html.py.rs.go.rb.java.c.h.cpp.hpp.sh.sql.yml.yaml.toml.ini.conf.txt.lock`.split(`.`)),vo=/^(?:~|\/(?:home|Users|root|tmp|var|opt|etc|srv|mnt|media|data|usr))(?:\/|$)/;function yo(e){let t=/^([^\s`"'()[\]{}<>]+?)(?::(\d+))?(?::\d+)?$/.exec(e);if(!t||e.includes(`://`))return null;let n=t[1],r=n.includes(`.`)?to(n):``;return!vo.test(n)&&(!r||!_o.has(r)&&!n.includes(`/`))?null:{path:n,line:t[2]===void 0?void 0:Number(t[2])}}var bo;async function xo(e,t,n){let r=t;r.startsWith(`~`)&&(bo??=ba().then(e=>e?.path??null),r=`${await bo??`~`}${r.slice(1)}`),await go(no(e,r),Xr(r),n)}function So(e,t,n){for(let r of e.querySelectorAll(`:not(pre) > code`)){let e=yo(r.textContent?.trim()??``);if(!e||r.closest(`a`))continue;let i=e.path.startsWith(`/`)||e.path.startsWith(`~`)?e.path:n?`${n}/${e.path}`:null;if(!i)continue;let a=()=>void xo(t,i,e.line);r.classList.add(`fileref`),r.tabIndex=0,r.setAttribute(`role`,`button`),r.title=e.line===void 0?i:`${i}:${String(e.line)}`,r.onclick=a,r.addEventListener(`pointerup`,()=>r.blur()),r.onkeydown=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())}}}function Co(e,t){let n=Ja(e);return n.alt=t,n}function wo(e,t){let n=to(t),r=L(`span`,`inline-flex max-w-full items-center gap-2.5 rounded-lg border border-neutral-200 bg-neutral-50 px-2.5 py-1.5 no-underline`),i=L(`span`,`flex h-7 w-7 flex-none items-center justify-center rounded-md bg-indigo-50 text-[10px] font-semibold uppercase text-indigo-600`,n.slice(0,4)||`file`),a=L(`span`,`min-w-0 truncate text-[13px] font-medium text-neutral-800`,t),o=L(`span`,`ml-1 flex flex-none items-center gap-0.5`),s=L(`button`,`icon-btn h-6 w-6 text-[13px]`,_(ee));s.setAttribute(`aria-label`,`Preview`),s.title=`Preview`,s.onclick=r=>{r.preventDefault(),n===`pdf`?window.open(e,`_blank`,`noopener`):go(e,t)},o.append(s);let c=document.createElement(`a`);return c.className=`icon-btn h-6 w-6 text-[13px] no-underline`,c.href=`${e}&download=1`,c.download=t,c.title=`Download`,c.append(_(p)),c.setAttribute(`aria-label`,`Download`),o.append(c),r.append(i,a,o),r}function To(e){let t=new Set;for(let n of e)n.parentElement&&t.add(n.parentElement);for(let n of t){let t=[...n.children].filter(t=>e.includes(t));if([...n.childNodes].every(e=>e.nodeType===Node.TEXT_NODE?!e.textContent?.trim():t.includes(e))){n.classList.add(`thumbs`);continue}let r=L(`div`,`thumbs`);r.append(...t),n.after(r)}}function Eo(e){let t=[];for(let n of e.querySelectorAll(`img`)){let e=n.getAttribute(`src`)??``;if(!so(e))continue;let r=Co(e,Xr(lo(e)));n.replaceWith(r),t.push(r)}for(let n of e.querySelectorAll(`a`)){let e=n.getAttribute(`href`)??``;if(!so(e))continue;let r=Xr(lo(e))||n.textContent?.trim()||`file`,i=Ya.has(to(r))?Co(e,r):wo(e,r);n.replaceWith(i),t.push(i)}t.length&&To(t)}var Do=null,Oo=`max-w-full cursor-pointer break-words rounded-full border border-indigo-200 bg-indigo-50 px-2.5 py-0.5 text-left text-[12.5px] text-indigo-700 transition-colors hover:border-indigo-300 hover:bg-indigo-100`;function ko(){Do=null}function Ao(e,t,n){if(Do?.remove(),Do=null,!t.length)return;let r=L(`div`,`mt-1.5 flex flex-wrap gap-1.5`);for(let e of t){let t=L(`button`,Oo,e);t.type=`button`,t.onclick=()=>{Do===r&&(Do=null),r.remove(),n(e)},r.append(t)}e.append(r),Do=r}var jo=8e3,Mo=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],No=e=>typeof e==`string`&&Mo.includes(e),Po,Fo;function Io(e,t){Po=e,Fo=t}var Lo=e=>e.slice(0,8),Ro=e=>`system-card group relative mt-1.5 rounded-xl px-4 py-2.5 ${e}`,zo=e=>L(`div`,Ro(e));function Bo(e){let t=e.length>240||e.split(`
|
|
75
|
-
`).length>4,n=[`max-h-[4lh]`,`overflow-hidden`],r=L(`div`,`mt-1 whitespace-pre-wrap break-words text-[12.5px] leading-normal text-neutral-500 ${n.join(` `)}`,e),i=L(`button`,`mt-1 hidden w-fit rounded-md px-1 py-1 text-[11px] pointer-coarse:min-h-11 pointer-coarse:px-2 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-700`,`Show full message`);return i.setAttribute(`type`,`button`),i.setAttribute(`aria-expanded`,`false`),i.onclick=()=>{let e=r.getBoundingClientRect().height;r.getAnimations().forEach(e=>e.cancel());let t=r.classList.toggle(n[0]),a=r.getBoundingClientRect().height,o=matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.animate(o?[{opacity:.8},{opacity:1}]:[{maxHeight:`${e}px`,opacity:.8},{maxHeight:`${a}px`,opacity:1}],{duration:o?120:180,easing:`cubic-bezier(0.2, 0.8, 0.2, 1)`}),i.textContent=t?`Show full message`:`Collapse message`,i.setAttribute(`aria-expanded`,String(!t)),r.tabIndex=-1,r.focus({preventScroll:!0})},queueMicrotask(()=>{(r.clientHeight?r.scrollHeight>r.clientHeight+1:t)?i.classList.remove(`hidden`):r.classList.remove(...n)}),[r,i]}function Vo(e){let t=L(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-neutral-500`,e.glyph);t.append(L(`span`,`run-label flex-none font-semibold ${e.labelCls}`,e.label)),e.taskName&&t.append(L(`span`,`min-w-0 grow basis-0 truncate text-[12.5px] font-medium text-neutral-800 max-md:order-1 max-md:basis-full max-md:whitespace-normal max-md:line-clamp-2`,e.taskName));let n=L(`div`,`ml-auto flex min-w-0 flex-wrap items-center gap-x-2 font-mono`);if(e.note&&n.append(L(`span`,`flex-none`,e.note)),e.model){let t=L(`span`,`flex-none rounded bg-black/[0.05] px-1.5 py-px font-medium text-neutral-700 dark:bg-neutral-200`,e.model.id);t.title=`${e.model.provider} / ${e.model.id}`,n.append(t)}if(e.thinking){let t=L(`span`,`flex-none`,e.thinking);t.title=`Reasoning effort`,n.append(t)}let r=L(`button`,`flex-none hover:underline`,Lo(e.runId));if(r.title=`Run ${e.runId}`,r.onclick=()=>Po.showRun(e.runId),n.append(r),e.sessionId&&e.sessionId!==`console`){let t=e.sessionId,r=L(`button`,`flex-none text-indigo-600 hover:underline`,Lo(t));r.title=`Open session ${t}`,r.onclick=()=>Po.select(t),n.append(r)}return t.append(n),t}var Ho={queued:{edge:`border-l-amber-400`,label:`text-amber-700`,glyph:h},running:{edge:`border-l-fuchsia-500`,label:`text-fuchsia-700`,glyph:h},succeeded:{edge:`border-l-green-500`,label:`text-green-700`,glyph:o},failed:{edge:`border-l-red-500`,label:`text-red-600`,glyph:_e},cancelled:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:oe},interrupted:{edge:`border-l-amber-400`,label:`text-amber-700`,glyph:ce},skipped:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:oe}},Uo=e=>_(Ho[e].glyph,`h-3 w-3 ${e===`queued`||e===`running`?`spinner`:``} ${Ho[e].label}`),Wo=new Map,Go=new WeakMap;function Ko(e){for(let[e,t]of Wo)t.isConnected||Wo.delete(e);let t=Wo.get(e.runId);t||(t=zo(Ho[e.state].edge),t.dataset.kind=`background-run`,Fo.el.append(t),Wo.set(e.runId,t)),t.className=Ro(Ho[e.state].edge);let n=e.state===`queued`||e.state===`running`;t.toggleAttribute(`data-active`,n);let r=Math.max(0,Math.round(((e.finishedAt??Date.now())-(e.startedAt??e.queuedAt))/1e3)),i=Vo({glyph:Uo(e.state),label:`run · ${e.state}`,labelCls:Ho[e.state].label,taskName:e.taskName,note:`${e.sessionMode??`task`} · ${String(r)}s`,runId:e.runId,sessionId:e.targetSessionId}),a=Go.get(t);!a&&e.prompt!==null&&(a=Bo(e.prompt),Go.set(t,a)),t.replaceChildren(i,...a??[]),Fo.scroll()}var H=null,qo=null,Jo=null,Yo=!1;function Xo(){if(!qo)return;qo.text=qo.text.slice(-4e3),qo.pre.textContent=qo.text;let e=qo.text.split(`
|
|
76
|
-
`).filter(Boolean).pop()??`thinking…`,t=qo.summary.lastElementChild;t.textContent=e.length>90?`…`+e.slice(-90):e}function Zo(){if(Jo){Yo=!0;return}Yo=!1,Xo(),Jo=setTimeout(()=>{Jo=null,Yo&&Zo()},80)}function Qo(){Jo&&clearTimeout(Jo),Jo=null,Yo&&Xo(),Yo=!1}var $o=new WeakMap,es=e=>{let t=$o.get(e)??[];return $o.set(e,t),t};function ts(){H&&!H.toolRows.size&&hs(`done`)}var ns=null;function rs(){H=null,ns=null,qo=null,Qo(),Wo.clear()}function is(){let e=ns;return!e||H?.el===e||(ns=null,e!==Fo.el.lastElementChild)?null:(e.remove(),e.dataset.adopted=`1`,os(e,e.dataset.status),e)}var as={running:`text-green-700 open:bg-green-50`,done:`text-neutral-400 hover:text-neutral-600 open:bg-black/[0.02] open:text-neutral-500 dark:open:bg-neutral-100`,failed:`text-red-600 open:bg-red-50`,interrupted:`text-amber-700 open:bg-amber-50`};function os(e,t){e.dataset.status=t,e.className=`px-2 py-1 rounded-xl text-[11.5px] leading-normal open:border open:border-neutral-200 open:px-3 open:py-2 ${as[t]}`}var ss={failed:_e,interrupted:ce};function cs(e){return e===`running`?_(h,`spinner`):e===`done`?L(`span`,`hidden`):_(ss[e],`h-3 w-3`)}function ls(e){if(H)return H;let t=cs(`running`),n=L(`span`,`min-w-0 truncate`,`working…`),{el:r}=li(``,[t,n]);r.dataset.kind=`activity`,os(r,`running`);let i=L(`div`,`mt-1.5 flex max-h-64 flex-col gap-1 overflow-y-auto overscroll-contain border-t border-black/5 pt-1.5 dark:border-neutral-200`);return r.append(i),fs(r,i),Fo.el.append(r),ns=r,Fo.scroll(),H={el:r,statusIcon:t,headline:n,rowsEl:i,toolRows:new Map,thinking:null,steps:0,failedSteps:0,startTs:e,sawError:!1},H}function us(e,t=``){let n=ls(e);Qo(),n.thinking=null;let r=L(`div`,`whitespace-pre-wrap break-words text-[13px] text-neutral-600`,t);r.dataset.raw=t;let i=L(`div`,`rounded-lg bg-neutral-50 px-2 py-1.5`,L(`span`,`text-[10px] font-medium text-neutral-400`,`Update`),r);return i.dataset.kind=`progress`,n.rowsEl.append(i),ms(n,`running`,`writing…`),ps(n),Fo.scroll(),r}function ds(e){let t=e.closest(`details[data-kind="activity"]`);e.parentElement?.remove(),t&&!t.lastElementChild?.childElementCount&&(H?.el===t&&(H=null),ns===t&&(ns=null),t.remove())}function fs(e,t){t.dataset.follow=`1`,t.addEventListener(`scroll`,()=>{let e=t.scrollHeight-t.scrollTop-t.clientHeight<24;t.dataset.follow=e?`1`:``}),e.addEventListener(`toggle`,()=>{e.open&&(t.scrollTop=t.scrollHeight,t.dataset.follow=`1`)})}function ps(e){Fo.bulk()||!e.el.open||!e.rowsEl.dataset.follow||(e.rowsEl.scrollTop=e.rowsEl.scrollHeight)}function ms(e,t,n){let r=Math.max(1,Math.round((Date.now()-e.startTs)/1e3)),i=`${e.steps?`${e.steps} step${e.steps===1?``:`s`}`:`Progress`} · ${r}s`;e.headline.textContent=t===`running`&&n?`${i} · ${n}`:t===`done`?`Completed · ${i}`:`${i} · ${t}`,os(e.el,t);let a=cs(t);e.statusIcon.replaceWith(a),e.statusIcon=a}function hs(e){if(!H)return;Qo();for(let{statusEl:e}of H.toolRows.values())e.textContent===`running…`&&(e.textContent=`interrupted`);let t=H.steps>0&&H.failedSteps===H.steps;ms(H,(H.sawError||t)&&e===`done`?`failed`:e===`done`&&H.toolRows.size?`interrupted`:e),H=null}function gs(){H&&(H.sawError=!0)}function _s(e){let t=e.slice(0,400).replace(/\s+/g,` `);return t.length>100?t.slice(0,100)+`…`:t}function vs(e,t,n,r){let i=ls(e);i.steps+=1,Qo(),i.thinking=null;let a=JSON.stringify(r,null,2)??``,o=L(`span`,`ml-auto flex-none text-neutral-400`,`running…`),s=L(`span`,`min-w-0 truncate text-neutral-500`,_s(a)),{el:c}=li(`rounded-md px-1 py-0.5 font-mono text-[12.5px] hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[L(`span`,`flex-none font-semibold`,n),s,o]),l=L(`pre`,`max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded bg-black/[0.04] p-1.5 text-[12px] dark:bg-neutral-100`,a),u=L(`pre`,`hidden max-h-56 overflow-y-auto whitespace-pre-wrap break-words rounded bg-black/[0.04] p-1.5 text-[12px] dark:bg-neutral-100`);c.append(L(`div`,`mt-1 flex flex-col gap-1 pl-4`,l,u)),es(i.el).push({tool:n,call:t,preview:s,argsPre:l,outputPre:u}),i.toolRows.set(t,{el:c,statusEl:o,outputPre:u}),i.rowsEl.append(c),ps(i),ms(i,`running`,n),Fo.scroll()}function ys(e,t,n){let r=H;if(!r)return;let i=r.toolRows.get(e);r.toolRows.delete(e),i&&(i.statusEl.textContent=t?`failed`:`ok`,i.statusEl.className=`ml-auto flex-none ${t?`text-red-600`:`text-green-700`}`,i.el.classList.toggle(`bg-red-50`,t),i.el.classList.toggle(`text-red-700`,t),n&&(i.outputPre.textContent=n.length>8e3?n.slice(0,jo)+`…`:n,i.outputPre.classList.remove(`hidden`)),t&&(r.failedSteps+=1)),ms(r,`running`)}function bs(e,t){let n=ls(e);if(!n.thinking){Qo();let{el:e,summary:t}=li(`rounded-md px-1 py-0.5 text-[12.5px] italic text-neutral-500 hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[L(`span`,`min-w-0 truncate`,`thinking…`)]),r=L(`div`,`mt-1 max-h-56 overflow-y-auto whitespace-pre-wrap break-words pl-4 not-italic text-neutral-500`,``);e.append(r),n.rowsEl.append(e),n.thinking={pre:r,summary:t,text:``},qo=n.thinking,ps(n),ms(n,`running`,`thinking…`)}n.thinking.text+=t,Zo()}var xs=0;function Ss(e,t=0,n=!1,r){let i=Date.now()-t,a=ls(i).el;for(let t of e){if(t.kind===`progress`){us(i,t.text??``);continue}if(t.kind===`thinking`){bs(i,t.text??``);continue}let e=t.id??`replay-${++xs}`;vs(i,e,t.toolName??``,t.args),t.done&&ys(e,t.isError??!1,t.output??``)}r!==void 0&&e.some(e=>e.kind===`tool`&&e.args===void 0)&&Cs(a,r),!n&&hs(e.some(e=>e.kind===`tool`&&!e.done)?`interrupted`:`done`)}function Cs(e,t){let n=()=>{e.open&&(e.removeEventListener(`toggle`,n),ws(e,t))};e.addEventListener(`toggle`,n)}async function ws(e,t){let n=Po.sessionId(),r=es(e),i=new Set(r.filter(e=>!e.argsPre.textContent)),a=e=>{for(let t of i)t.argsPre.textContent=e};if(a(`loading…`),!n)return a(`no session`);let o=await C(`/api/sessions/${n}/turns/${t}/steps`,`could not load these steps`);if(!o.ok)return a(o.error);let s=o.value.steps.filter(e=>e.kind===`tool`);for(let[e,t]of r.entries()){if(!i.has(t))continue;let n=s[e];if(!(n&&(n.id?n.id===t.call:n.toolName===t.tool))){t.argsPre.textContent=`detail no longer available — reload the session`;continue}let r=JSON.stringify(n.args,null,2)??``;t.argsPre.textContent=r,t.preview.textContent=_s(r),n.output&&(t.outputPre.textContent=n.output,t.outputPre.classList.remove(`hidden`))}}var Ts,U=I(`#turns`);function Es(e){Ts=e,Io(e,{el:U,scroll:Ps,bulk:()=>Ds})}var Ds=!1,Os=()=>U.scrollHeight-U.scrollTop-U.clientHeight<80,ks=!0,As=0;U.addEventListener(`scroll`,()=>{let e=U.scrollTop,t=e<As-4;As=e,!Ds&&(t||Os())&&(ks=Os())},{passive:!0});var js=0;function Ms(){!ks||Ds||js||(js=requestAnimationFrame(()=>{js=0,ks&&!Ds&&(U.scrollTop=U.scrollHeight)}))}new ResizeObserver(Ms).observe(U),U.addEventListener(`load`,Ms,!0),new MutationObserver(Ms).observe(U,{childList:!0,subtree:!0,characterData:!0});function Ns(){Os()&&(ks=!0)}function Ps(e=!1){Ds||(e&&(ks=!0),ks&&(U.scrollTop=U.scrollHeight))}var Fs=1200;function Is(e,t){let n=U.querySelector(`[data-kind="${e}"][data-at="${t}"]`);return n?(Rs(n),!0):!1}function Ls(){let e=U.querySelectorAll(`[data-kind="background-run"][data-active]`),t=e[e.length-1];return t?(Rs(t),!0):!1}function Rs(e){ks=!1,e.scrollIntoView({block:e.offsetHeight>U.clientHeight?`start`:`center`}),e.dataset.reveal=``,setTimeout(()=>delete e.dataset.reveal,Fs)}var zs=500,Bs=0,Vs=0,Hs=null;function Us(){for(;U.childElementCount>zs;){let e=U.firstElementChild;e.remove(),e!==Hs&&(e.dataset.kind===`user`&&Bs++,Vs++)}Vs&&(Hs||(Hs=L(`div`,`px-5 py-2 text-center text-[11.5px] italic text-neutral-400`),Hs.dataset.kind=`trim`),Hs.textContent=`${Vs} earlier row${Vs===1?``:`s`} not shown — still in the transcript, not on this screen`,U.firstElementChild!==Hs&&U.prepend(Hs))}var Ws={user:{row:``,body:`text-inherit`},assistant:{row:``,body:`text-neutral-900`},error:{row:`border-l-red-400 bg-red-50`,body:`text-red-700`},system:{row:`system-card border-l-cyan-500`,body:`text-neutral-500`}};function W(e,t,n=!1,r){ts();let i=e===`assistant`?is():null,a=Ws[e],o=e===`user`&&r!==void 0&&oc(r)?r:void 0,s=o===void 0&&U.lastElementChild?.dataset.kind===e,c=L(`div`,`group relative ${a.row}`);c.dataset.kind=e,s&&(c.dataset.grouped=``),Ds||(c.dataset.enter=``);let l=e===`user`?Vi(t):null,u=l?.text??t,d=e===`user`?Ie(u):null,f=d?.id||d?.when||d?.where?d:null,p=f&&(f.id?f.id!==`web`:f.name)?f:null,m=L(`div`,`whitespace-pre-wrap break-words ${a.body}`,f?.text??u);(l?.paths.length||f)&&(m.dataset.raw=t),n&&uc(m,t),r!==void 0&&sc(c,r),p&&c.append(Gs(p)),c.append(m);let ee=Ts.sessionId();if(l?.paths.length&&ee){let e=qa(c);for(let t of l.paths)e.append(co(ee,t))}if(e===`user`){Ys?.();let e=L(`button`,`message-edit absolute right-full top-1 flex h-8 w-8 items-center justify-center rounded-full`);e.title=`Edit message — resends it and drops everything after it`,e.setAttribute(`type`,`button`),e.setAttribute(`aria-label`,`Edit message`),e.append(_(le)),e.onclick=()=>Qs(c,m),c.append(e)}if(o!==void 0){let e=L(`div`,`my-3 text-center text-[11px] text-neutral-400`);e.dataset.kind=`time`,e.dataset.at=String(o),rc(e),nc??=setInterval(ic,6e4),e.title=Qr(o),U.append(e)}return i&&U.append(i),U.append(c),Us(),Ps(),m}function Gs(e){let t=L(`div`,`mb-1 flex flex-wrap items-baseline gap-x-2 gap-y-1 text-[11.5px] leading-tight opacity-85`),n=e?.name??e?.id;if(n){let r=L(`span`,`font-semibold text-inherit`,n);e?.id&&(r.title=e.id),t.append(r)}let r=Ts.sessionChannel();return r&&r!==`web`&&t.append(L(`span`,`text-[10px] uppercase tracking-wide opacity-60`,r)),t}var Ks={"task-delegation":[i,`delegated`,`text-cyan-700`],"task-callback":[f,`callback`,`text-cyan-700`]};function qs(e){let t=e.indexOf(`
|
|
77
|
-
|
|
78
|
-
`);if(t<0)return[null,e];let n=e.slice(0,t);return n.length>600||n.split(`
|
|
79
|
-
`).length>6?[null,e]:[n,e.slice(t+2)]}function Js(e,t){let n=t.kind===`task-message`?t.messageKind:t.kind,[r,i,a]=Ks[n]??[f,n.replace(`_`,` `),`text-cyan-700`];ts();let o=t.kind===`task-callback`?t.state:void 0,s=zo(o?Ho[o].edge:`border-l-cyan-500`);s.dataset.kind=`system`;let[c,l]=qs(e),u=Vo({glyph:o?Uo(o):_(r,`h-3 w-3 ${a}`),label:o?`${i} \u00b7 ${o}`:i,labelCls:o?Ho[o].label:a,...t.source?{taskName:t.source.taskName,model:t.source.model,thinking:t.source.thinking}:c?{taskName:c.split(`
|
|
80
|
-
`)[0]}:{},runId:t.runId,sessionId:t.sourceSessionId});s.append(u),s.append(...Bo(l)),U.append(s),Us(),Ps()}var Ys=null,Xs=e=>e.isConnected&&e.dataset.kind===`user`;function Zs(e){let t=0;for(let n=e.nextElementSibling;n;n=n.nextElementSibling){let e=n.dataset.kind;(e===`user`||e===`assistant`||e===`system`)&&t++}return t}function Qs(e,t){if(!Xs(e)||e.querySelector(`textarea`))return;if(Ys?.(),Ts.sessionState()!==`idle`){W(`error`,`can't edit while streaming — stop the turn first`);return}let n=document.createElement(`textarea`);n.value=t.dataset.raw??t.textContent??``,n.className=`block w-full resize-none rounded-xl border border-indigo-300 bg-white px-3 py-2 text-neutral-900 focus:outline-none`,n.setAttribute(`aria-label`,`Edit message`);let r=ui(`Send edit`,!0),i=ui(`Cancel`),a=Zs(e),o=L(`div`,`mt-2 flex flex-wrap items-center justify-end gap-2`);a&&o.append(L(`div`,`mr-auto text-[11.5px] text-neutral-500`,`sending drops the ${a} message${a===1?``:`s`} after this one`)),o.append(i,r);let s=L(`div`,`message-editor`,n,o),c=()=>{n.style.height=`auto`,n.style.height=`${Math.min(n.scrollHeight,192)}px`,r.disabled=!n.value.trim()};n.oninput=c,e.dataset.editing=``,t.classList.add(`hidden`),t.after(s),c(),n.focus(),n.setSelectionRange(n.value.length,n.value.length);let l=()=>{s.remove(),t.classList.remove(`hidden`),delete e.dataset.editing,Ys=null};Ys=l,i.onclick=()=>{l(),e.querySelector(`.message-edit`)?.focus({preventScroll:!0})},r.onclick=()=>{let t=n.value.trim();t&&$s(e,t)},s.onkeydown=e=>{e.isComposing||e.keyCode===229||(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i.click()),e.key===`Enter`&&!e.shiftKey&&e.target===n&&(e.preventDefault(),r.click()))}}async function $s(e,t){let n=Ts.sessionId();if(!n||!Xs(e))return;if(Ts.sessionState()!==`idle`){W(`error`,`can't edit while streaming — stop the turn first`);return}Ys?.();let r=[...U.querySelectorAll(`[data-kind="user"]`)],i=r.indexOf(e),a=Bs+i,o=r[i-1]?.dataset.at;tc=o===void 0?null:Number(o);let s=e.previousElementSibling;for(s?.dataset.kind===`time`&&s.remove();e.nextElementSibling;)e.nextElementSibling.remove();e.remove(),Ts.ownTurn(t),W(`user`,t,!1,Date.now()),Ps(!0);let c=await x(`/api/sessions/${n}/turns/${a}/edit`,{text:t});if(!c.ok){let e=await S(c,`edit failed`);await Ts.reload(n),W(`error`,e)}}var ec=6e5,tc=null,nc;function rc(e){let t=Number(e.dataset.at);e.textContent=`${Qr(t).slice(0,16)} · ${Yr(t)}`}function ic(){let e=U.querySelectorAll(`[data-kind="time"]`);for(let t of e)rc(t);e.length||(clearInterval(nc),nc=void 0)}var ac=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString();function oc(e){let t=tc;return tc=e,t===null||e-t>=ec||!ac(t,e)}function sc(e,t){e.dataset.at=String(t),e.dataset.time=Qr(t).slice(11)}function cc(e){for(let t of e.querySelectorAll(`pre`)){let e=t.querySelector(`code`);if(!e)continue;let n=L(`div`,`group/code relative`);t.replaceWith(n),n.append(t,ii(`absolute right-1.5 top-1.5 cursor-pointer rounded border border-black/[0.08] bg-white/85 px-1.5 py-0.5 text-[11px] text-neutral-500 opacity-0 transition-opacity hover:bg-white hover:text-neutral-800 focus:opacity-100 group-hover/code:opacity-100 pointer-coarse:opacity-100 dark:border-neutral-200`,()=>e.textContent??``))}}function lc(e){let t=Ts.sessionId(),n=L(`div`,``);return n.innerHTML=fn.sanitize(F.parse(t?oo(e,t):e,{async:!1})),ni(n),n}function uc(e,t){e.replaceChildren(...lc(t).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`),Yi(e),cc(e);for(let t of e.querySelectorAll(`:not(pre) > code`))ci(t,()=>t.textContent??``);Eo(e);let n=Ts.sessionId();n&&So(e,n,Ts.sessionCwd())}function dc(e,t,n,r=!1){let{text:i,suggestions:a}=Ae(t);return v({text:i,suggestions:a})?fc(e,y(t)):uc(e,i),r&&Ao(e.parentElement??e,a,e=>Ts.send(`auto`,e)),n&&sc(e.parentElement??e,n.completedAt),e}function fc(e,t){e.classList.remove(`md`,`whitespace-pre-wrap`),e.replaceChildren(L(`span`,`text-[12.5px] italic text-neutral-400`,t?`Stayed silent — ${t}`:`Stayed silent.`))}var pc=(e,t,n=!1)=>dc(W(`assistant`,``),e,t,n),G=null,mc=null,hc=!1,gc=0,_c=0;function vc(e){let t=e.dataset.raw??``;for(;e.childNodes.length>_c;)e.lastChild.remove();let n=Me(t,gc);n>gc&&(e.append(...lc(b(t.slice(gc,n))).childNodes),gc=n,_c=e.childNodes.length),e.append(...lc(Ae(t.slice(gc)).text).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`)}function yc(){if(mc){hc=!0;return}hc=!1,G&&(vc(G),Ps()),mc=setTimeout(()=>{mc=null,hc&&yc()},80)}function bc(){mc&&clearTimeout(mc),mc=null,hc=!1}function xc(e){G||(G=us(Date.now()),gc=0,_c=0),G.dataset.raw=(G.dataset.raw??``)+e,yc()}function Sc(){if(!G)return;let e=G;G=null,bc(),e.classList.remove(`md`),e.classList.add(`whitespace-pre-wrap`),e.textContent=e.dataset.raw??``}function Cc(){if(!G)return;let e=G.dataset.raw;return ds(G),G=null,bc(),e}function wc(e,t){e===``&&Sc();let n=Cc();hs(`done`);let r=e??n;r&&pc(r,t,!0)}function Tc(){let e=Cc();hs(`interrupted`),e&&pc(e)}function Ec(){Ys?.(),clearInterval(nc),nc=void 0,U.replaceChildren(),Bs=0,Vs=0,Hs=null,tc=null,G=null,bc(),rs(),ko()}function Dc(e){if(!e){U.querySelector(`[data-kind="loading"]`)?.remove();return}let t=L(`div`,`flex flex-col gap-3 px-5 py-4`);t.dataset.kind=`loading`;for(let e of[`w-2/5`,`w-4/5`,`w-3/5`,`w-1/3`,`w-2/3`])t.append(L(`div`,`skeleton h-3.5 ${e}`));U.append(t)}function Oc(e,t,n){Dc(!1);let r=new Map(n.map(e=>[e.runId,e])),i=e=>[...r].filter(([,t])=>t.queuedAt<=e).map(([e])=>e),a=e=>{for(let t of e){let e=r.get(t);e&&(Ko(e),r.delete(t))}},o=e.reduce((e,t,n)=>t.role===`assistant`?n:e,-1);Ds=!0;try{for(let[n,r]of e.entries()){let s=t===`streaming`&&n===e.length-1&&r.role===`assistant`,c=r.steps;if(c?.length&&(Ss(c,r.meta?.durationMs,s,n),r.meta&&a(i(r.meta.completedAt))),r.text){if(r.role===`system`&&r.origin){a(r.origin.kind===`task-message`?[r.origin.runId]:r.origin.runIds??[r.origin.runId]),Js(r.text,r.origin);continue}s?xc(r.text):r.role===`assistant`?pc(r.text,r.meta,t===`idle`&&n===o):W(r.role,r.text,!1,r.at)}}for(let e of r.values())Ko(e)}finally{Ds=!1}Ps(!0)}var kc=window.fetch.bind(window),Ac=20,jc=6e4,Mc=[],Nc=new Map,Pc=e=>e instanceof Error?e.stack??`${e.name}: ${e.message}`:void 0;function Fc(e,t){let n=t===void 0?e:`${e}: ${String(t)}`,r=Date.now();return r-(Nc.get(n)??-6e4)<jc||(Nc.size>100&&Nc.clear(),Nc.set(n,r),Mc=Mc.filter(e=>r-e<6e4),Mc.length>=Ac)?null:(Mc.push(r),kc(`/api/client-log`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:n,stack:Pc(t),view:location.hash||`/`}),keepalive:!0}).catch(()=>{}),W(`error`,n))}function Ic(){window.__pierReporting=!0,window.addEventListener(`error`,e=>{!e.error&&e.message.includes(`ResizeObserver loop`)||Fc(`script error: ${e.message}`,e.error)}),window.addEventListener(`unhandledrejection`,e=>{Fc(`unhandled rejection`,e.reason)})}var Lc=window.fetch.bind(window),Rc=()=>{location.assign(`/login?next=${encodeURIComponent(location.pathname+location.hash)}`)};function zc(){window.fetch=async(...e)=>{let t=await Lc(...e);return t.status===401&&Rc(),t}}function Bc(e,t){if(e.readyState!==EventSource.CLOSED)return;let n=()=>{let e=Fc(`${t} stream disconnected`);if(!e)return;let n=ui(`Reload`);n.classList.add(`ml-2`,`align-middle`),n.onclick=()=>location.reload(),e.append(` `,n)};Lc(`/api/sessions`).then(e=>e.status===401?Rc():n(),n)}var Vc=/Mac|iP(?:hone|ad|od)/.test(navigator.userAgent),Hc=Vc?`⌘`:`Ctrl+`,Uc=Vc?`⇧`:`Shift+`,Wc=e=>{let t=e.startsWith(`meta+`),n=t?e.slice(5):e;return n.startsWith(`shift+`)?{key:n.slice(6),shift:!0,meta:t}:{key:n,shift:!1,meta:t}};function Gc(e){let{key:t,shift:n,meta:r}=Wc(e);return`${r?`⌘`:Hc}${n?Uc:``}${t.toUpperCase()}`}var Kc=()=>document.querySelector(`dialog[open]`)!==null,qc={"[":`{`,"]":`}`},Jc=`pointer-events-none fixed z-50 flex items-center gap-2 whitespace-nowrap rounded-md bg-neutral-800 px-2 py-1 text-[11.5px] text-neutral-100 shadow-lg`;function Yc(e,t,n){e.removeAttribute(`title`);let r=null,i=()=>{r?.remove(),r=null,document.removeEventListener(`keydown`,i,!0)};e.addEventListener(`pointerenter`,a=>{if(a.pointerType!==`mouse`)return;i(),r=L(`div`,Jc,t,L(`kbd`,`rounded bg-white/15 px-1 py-px font-sans text-[10.5px]`,n)),document.body.append(r);let o=e.getBoundingClientRect(),s=o.bottom+6,c=s+r.offsetHeight+8<=window.innerHeight;r.style.top=`${c?s:Math.max(8,o.top-r.offsetHeight-6)}px`,r.style.left=`${Math.max(8,Math.min(o.left,window.innerWidth-r.offsetWidth-8))}px`,document.addEventListener(`keydown`,i,!0)}),e.addEventListener(`pointerleave`,i),e.addEventListener(`pointerdown`,i)}function Xc(e,t,n,r,i){Yc(e,n,Gc(t)),el(t,r,i)}function Zc(e,t,n,r){Yc(e,t,`Esc`),document.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.isComposing||e.defaultPrevented||Kc()||!r()||(e.preventDefault(),n())})}var Qc=`input, textarea, select, [contenteditable]`;function $c(e,t,n,r,i){Yc(e,n,t[0].toUpperCase()),document.addEventListener(`keydown`,e=>{e.metaKey||e.ctrlKey||e.altKey||e.isComposing||e.defaultPrevented||!e.key||!t.includes(e.key.toLowerCase())||e.target?.closest?.(Qc)||Kc()||!i()||(e.preventDefault(),r())})}function el(e,t,n){let{key:r,shift:i,meta:a}=Wc(e),o=qc[r];document.addEventListener(`keydown`,e=>{if(!e.key||e.altKey||e.shiftKey!==i)return;let s=e.key.toLowerCase();(s===r||s===o)&&((a?!e.metaKey:!e.metaKey&&!e.ctrlKey)||n?.()||(e.preventDefault(),e.stopPropagation(),t()))},!0)}var K,tl=I(`#composer`),q=I(`#input`),nl=I(`#send`),rl=I(`#send-arrow`),il=I(`#send-queue`),al=I(`#stop`),ol=I(`#queue-panel`),sl=I(`#queue-rows`),cl=I(`#queue-label`),ll=L(`div`,`hidden max-h-48 overflow-y-auto border-t border-neutral-200 px-4 py-2 text-[13px]`);ll.id=`recovery-panel`,ol.after(ll);var ul=I(`#image-strip`),dl=I(`#attach-input`),fl=!1,pl=0,ml=new Set,hl=[],gl=[];function _l(){let e=window.visualViewport;if(!e)return;let t=()=>{let t=e.scale<=1.05&&window.innerHeight-e.height-e.offsetTop>80;t?document.body.dataset.kb=``:delete document.body.dataset.kb,document.body.style.height=t?`${String(e.height)}px`:``,t&&window.scrollY&&window.scrollTo(0,0)};e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t)}function vl(){let e=tl.parentElement,t=[ol,ll,tl],n=new ResizeObserver(()=>{let n=t.reduce((e,t)=>e+t.offsetHeight,0);e.style.setProperty(`--dock-h`,`${String(n)}px`)});for(let e of t)n.observe(e,{box:`border-box`})}function yl(){q.focus()}function bl(e){let t=gl.indexOf(e);return t<0?!1:(gl.splice(t,1),!0)}function xl(e){gl.push(e)}function Sl(){gl=[]}function Cl(){let e=K.sessionState()===`streaming`,t=K.sessionId()!==null,n=K.starting();nl.disabled=!t,nl.className=`flex h-7 w-7 flex-none items-center justify-center rounded-lg ${t?e?`cursor-pointer bg-amber-100 text-amber-700 hover:bg-amber-200 active:bg-amber-300`:`cursor-pointer bg-indigo-600 text-white hover:bg-indigo-500 active:bg-indigo-700 dark:text-neutral-50`:`cursor-default bg-neutral-100 text-neutral-400`}`,nl.title=t?e?`Queue — delivered when the turn ends`:`Send`:n?`Starting the session…`:`No session`,q.placeholder=n?`Starting the session…`:`Message…`,rl.classList.toggle(`hidden`,e),il.classList.toggle(`hidden`,!e),al.classList.toggle(`hidden`,!e),al.classList.toggle(`flex`,e)}function wl(){let e=K.chatVisible()&&fl;ol.classList.toggle(`hidden`,!e),ol.classList.toggle(`flex`,e),ll.classList.toggle(`hidden`,!K.chatVisible()||!ll.childElementCount)}function Tl(e,t=!1){let n=K.sessionId();if(ll.replaceChildren(...e.map(e=>{let t=L(`details`,`py-1`),r=e.status===`submitting`?`Handing off`:e.status===`not-submitted`?`Not submitted`:`Acceptance unknown`,i=e.status===`submitting`?``:`; automatic queue paused`;t.append(L(`summary`,`cursor-pointer break-words text-amber-700`,`Queue recovery: ${r}${i} (in memory)`));for(let n of[...e.steering,...e.followUp]){let e=L(`div`,`flex items-start gap-2 border-t border-neutral-100 py-1`);e.append(L(`span`,`min-w-0 flex-1 whitespace-pre-wrap break-words`,n),ii(`flex-none cursor-pointer px-1 text-neutral-500 hover:text-neutral-800`,()=>n)),t.append(e)}e.error&&t.append(L(`div`,`break-words text-red-600`,e.error));let a=L(`button`,`cursor-pointer py-1 text-neutral-500 disabled:cursor-default disabled:opacity-40`,`Acknowledge`);return a.type=`button`,a.disabled=e.status===`submitting`,a.title=`Remove this recovery copy without sending it`,a.onclick=async()=>{if(!n||!confirm(`Remove this recovery copy? This does not resend the messages.`))return;let t=await x(`/api/sessions/${n}/queue/recovery/${e.id}/ack`,{}),r=t.ok?null:await S(t,`Could not acknowledge queue recovery`);K.sessionId()===n&&(r===null?await K.reload(n):W(`error`,r))},t.append(a),t})),t){let e=L(`div`,`flex flex-wrap items-center gap-x-2 py-1 text-amber-700`,`Automatic queue paused: acceptance unknown (in memory)`),t=L(`button`,`cursor-pointer underline`,`Recall queue`);t.title=`Clear the live queue and return its messages to the composer`,t.onclick=()=>void Hl(),e.append(t),ll.prepend(e)}wl()}function El(e,t){++pl;let n=[...e.map(e=>({mode:`steer`,text:e})),...t.map(e=>({mode:`queued`,text:e}))];fl=n.length>0,cl.textContent=n.length>1?`Queued · ${n.length}`:`Queued`,wl(),sl.replaceChildren(...n.map(e=>{let t=L(`li`,`flex items-start gap-2 text-[13px] leading-[18px]`);return e.mode===`steer`&&t.append(L(`span`,`flex-none rounded bg-indigo-100 px-1 py-0.5 text-[10.5px] font-semibold uppercase tracking-wide text-indigo-700`,e.mode)),t.append(L(`span`,`min-w-0 whitespace-pre-wrap break-words text-neutral-700`,e.text)),t}))}var Dl=8;function Ol(){let e=K.sessionId();e&&hl.length?Fl.set(e,hl):e&&Fl.delete(e),ul.classList.toggle(`hidden`,hl.length===0),ul.classList.toggle(`flex`,hl.length>0),ul.replaceChildren(...hl.map((e,t)=>{let n=e.mimeType.startsWith(`image/`)?Ja(`data:${e.mimeType};base64,${e.data}`):L(`span`,`flex h-16 max-w-40 items-center truncate rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[12px] text-neutral-700`,e.name??`file`),r=L(`button`,`absolute -right-1.5 -top-1.5 flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-neutral-700 text-[10px] leading-none text-white hover:bg-red-600`,_(_e,`h-3 w-3`));return r.setAttribute(`type`,`button`),r.setAttribute(`aria-label`,`Remove ${e.name??`attachment`}`),r.onclick=()=>{hl.splice(t,1),Ol()},L(`div`,`relative`,n,r)}))}function kl(e){if(hl.length>=Dl){W(`error`,`attachment limit is ${Dl} files per message`);return}if(e.size>33554432){W(`error`,`${e.name||`file`} is too large (32MB max)`);return}let t=new FileReader;t.onload=()=>{let n=t.result;hl.push({data:n.slice(n.indexOf(`,`)+1),mimeType:e.type||`application/octet-stream`,name:e.name||void 0}),Ol()},t.readAsDataURL(e)}async function Al(e){let t=[];for(let n of e){let e=await x(`/api/inbox`,n);if(!e.ok)return null;let{path:r}=await e.json();t.push(Ii(r))}return t}var jl=`pier.draft.`,Ml=e=>`${jl}${e}`,Nl=0;function Pl(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(jl)&&e.push(n)}for(let t of e){let e=localStorage.getItem(t);e&&!sessionStorage.getItem(t)&&sessionStorage.setItem(t,e),localStorage.removeItem(t)}}catch(e){console.warn(`could not move older drafts out of localStorage`,e)}}var Fl=new Map;function Il(e=K.sessionId(),t=q.value){e&&(t?sessionStorage.setItem(Ml(e),t):sessionStorage.removeItem(Ml(e)))}function Ll(e){++Nl,q.value=sessionStorage.getItem(Ml(e))??``,Rl(),hl=Fl.get(e)??[],Ol()}function Rl(){let e=q.style.height;q.style.height=`auto`;let t=`${Math.min(q.scrollHeight,192)}px`;q.style.height=t,t!==e&&Ps()}var zl=!1;async function Bl(e,t){let n=(t??q.value).trim(),r=t===void 0?hl:[],i=K.sessionId();if(!(!n&&r.length===0||!i)){if(t===void 0){if(zl)return;zl=!0,q.value=``,Rl(),Il(),hl=[],Ol()}try{let t=[];if(r.length){let e=await Al(r);if(e===null){W(`error`,`attachment upload failed`),q.value=[n,q.value.trim()].filter(Boolean).join(`
|
|
81
|
-
`),Rl(),Il(),hl=r,Ol();return}t=e}let a=[n,...t].filter(Boolean).join(`
|
|
82
|
-
`),o=K.sessionState()===`idle`&&e===`auto`;o?K.setState(`streaming`):Cl(),(o||e===`steer`)&&(xl(a),W(`user`,a,!1,Date.now()),Ps(!0));let s=await x(`/api/sessions/${i}/messages`,{text:a,mode:e});if(!s.ok){let e=await S(s,`send failed`);await K.reload(i),W(`error`,e)}}finally{t===void 0&&(zl=!1)}}}async function Vl(e){let t=K.sessionId();if(!t)return;El([],[]);let n=await x(`/api/sessions/${t}/queue/deliver`,{mode:e});if(!n.ok){let r=await S(n,`Queue ${e} failed`);await K.reload(t),K.sessionId()===t&&W(`error`,r)}}async function Hl(){let e=K.sessionId();if(!e||ml.has(e))return;ml.add(e);let t=pl,n=Nl,r=document.activeElement;try{Il();let i=await fetch(`/api/sessions/${e}/queue/recall`,{method:`POST`});if(!i.ok){let t=await S(i,`Could not recall queued messages`);K.sessionId()===e&&W(`error`,t);return}let{messages:a}=await i.json(),o=K.sessionId()===e;if(a.length)try{let t=o?q.value:sessionStorage.getItem(Ml(e))??``,i=(t?[t,...a]:a).join(`
|
|
83
|
-
`);o&&(q.value=i,Rl(),n===Nl&&K.chatVisible()&&document.activeElement===r&&q.focus()),Il(e,i)}catch(t){W(`error`,`Could not save recalled messages for session ${e}: ${String(t)}\nRecalled messages (not saved):\n${a.join(`
|
|
84
|
-
`)}`)}o&&t===pl&&El([],[])}finally{ml.delete(e)}}function Ul(e){K=e,Pl(),_l(),vl();let t=()=>{let e=K.sessionId();e&&fetch(`/api/sessions/${e}/abort`,{method:`POST`})};al.onclick=t,Zc(al,`Stop the running turn`,t,()=>K.sessionState()===`streaming`&&K.chatVisible()),I(`#queue-steer`).onclick=()=>void Vl(`steer`),I(`#queue-restart`).onclick=()=>void Vl(`restart`),I(`#queue-recall`).onclick=()=>void Hl(),tl.onsubmit=e=>{e.preventDefault(),Bl(`auto`)},$c(q,[`/`],`Write a message`,yl,K.chatVisible),q.onfocus=Ns,q.oninput=()=>{Rl(),Il()};let n=!matchMedia(`(pointer: coarse)`).matches;q.onkeydown=e=>{e.isComposing||e.keyCode===229||n&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Bl(`auto`))},q.onpaste=e=>{for(let t of e.clipboardData?.items??[]){let e=t.kind===`file`?t.getAsFile():null;e&&kl(e)}let t=e.clipboardData?.getData(`text/plain`)??``,n=t.trim();!n||n===t||(e.preventDefault(),q.setRangeText(n,q.selectionStart??0,q.selectionEnd??0,`end`),Rl(),Il())},U.ondragover=e=>e.preventDefault(),U.ondrop=e=>{e.preventDefault();for(let t of e.dataTransfer?.files??[])kl(t)},I(`#attach`).onclick=()=>dl.click(),dl.onchange=()=>{for(let e of dl.files??[])kl(e);dl.value=``},Cl()}var Wl=`pier.push`,Gl=`/app/sw.js`,Kl=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints>1&&/Macintosh/.test(navigator.userAgent),ql=()=>matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0;function Jl(){return window.isSecureContext?Kl()&&!ql()?`On iPhone and iPad, notifications work only from the installed app: Share → Add to Home Screen, then open Pier from that icon.`:!(`serviceWorker`in navigator)||!(`PushManager`in window)||!(`Notification`in window)?`This browser has no Web Push support.`:``:`Notifications need HTTPS. Reach this Pier through its public URL, not over plain http.`}var Yl=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/Macintosh/,`Mac`],[/Windows/,`Windows`]],Xl=[[/Edg\//,`Edge`],[/Chrome\//,`Chrome`],[/Firefox\//,`Firefox`],[/Safari\//,`Safari`]];function Zl(){let e=navigator.userAgent,t=(t,n)=>t.find(([t])=>t.test(e))?.[1]??n;return`${t(Yl,`Linux`)} · ${t(Xl,`browser`)}${ql()?` (installed)`:``}`}var Ql=e=>{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},$l=null;async function eu(){return!(`serviceWorker`in navigator)||!window.isSecureContext?null:($l??=await navigator.serviceWorker.register(Gl,{scope:`/app/`}).catch(e=>(console.warn(`service worker registration failed`,e),null)),$l)}var tu=(e,t)=>{let n=e?new Uint8Array(e):null;return n?.length===t.length&&n.every((e,n)=>e===t[n])};async function nu(e){let{publicKey:t}=await Ge(`/api/push`,`Could not read this instance's push key`),n=Ql(t),r=await e.pushManager.getSubscription();if(r){if(tu(r.options.applicationServerKey,n))return r;await r.unsubscribe()}return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}async function ru(e){return x(`/api/push/subscribe`,{...e.toJSON(),label:Zl()})}async function iu(){su();let e=await eu();if(!(!e||localStorage.getItem(Wl)!==`on`)&&!(!(`Notification`in window)||Notification.permission!==`granted`))try{await ru(await nu(e))}catch(e){console.warn(`re-registering this browser for notifications failed`,e)}}var au=null,ou=null;function su(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),au=e,ou?.()}),window.addEventListener(`appinstalled`,()=>{au=null,ou?.()})}function cu(e){let t=navigator;(e>0?t.setAppBadge?.(e):t.clearAppBadge?.())?.catch(()=>{})}function lu(){let e=L(`span`,`text-[11.5px]`,``),t=ui(`Send a test notification`),n=L(`div`,`flex items-center gap-3`,t,e),r=L(`div`,`flex flex-col gap-4`),i=()=>localStorage.getItem(Wl)===`on`,a=L(`div`,`flex flex-col gap-2`),o=L(`span`,`text-[11.5px]`,``),s=L(`div`,`flex flex-col gap-2`,a,o);async function c(e){R(o,`saving`,`removing…`);try{let t=await x(`/api/push/unsubscribe`,{endpoint:e.endpoint});if(!t.ok)R(o,`failed`,await S(t,`Could not remove it`));else{let t=await(await eu())?.pushManager.getSubscription();t?.endpoint===e.endpoint&&(localStorage.setItem(Wl,`off`),await t.unsubscribe(),p()),R(o,`saved`,`Removed.`)}}catch(e){R(o,`failed`,`Could not remove it: ${String(e)}`)}await l()}async function l(){let e=await C(`/api/push/subscriptions`,`Could not load subscribed devices`);if(!e.ok)return R(o,`failed`,e.error);if(!e.value.devices.length){a.replaceChildren(Ni(`No device is subscribed.`));return}a.replaceChildren(...e.value.devices.map(e=>{let t=ui(`Remove`);return t.onclick=()=>{t.disabled=!0,c(e)},Mi(e.label,`subscribed ${Yr(e.createdAt)}`,t,{tag:e.current?ji(`This browser`,`bg-neutral-50 text-neutral-500 ring-neutral-200`):void 0})}))}async function u(){R(e,`saving`,`asking this browser…`);let t=await Notification.requestPermission();if(t!==`granted`)return localStorage.setItem(Wl,`off`),p(),R(e,`failed`,t===`denied`?`Notifications are blocked for this site — allow them in the browser's site settings, then try again.`:`No answer to the permission prompt.`);let n=await eu();if(!n)return R(e,`failed`,`This browser refused to register a service worker.`);try{let t=await ru(await nu(n));if(!t.ok)return R(e,`failed`,await S(t,`Could not register this browser`));localStorage.setItem(Wl,`on`),p(),R(e,`saved`,`This browser will be notified when a turn finishes unseen.`),l()}catch(t){R(e,`failed`,`Could not subscribe: ${String(t)}`)}}async function d(){localStorage.setItem(Wl,`off`),p();let t=await(await eu())?.pushManager.getSubscription();t&&(await x(`/api/push/unsubscribe`,{endpoint:t.endpoint}),await t.unsubscribe()),R(e,`idle`,`This browser will not be notified.`),l()}t.onclick=()=>{R(e,`saving`,`sending…`),(async()=>{let t=await x(`/api/push/test`,{});if(!t.ok)return R(e,`failed`,await S(t,`Could not send`));let{sent:n,failed:r}=await t.json();R(e,r?`failed`:`saved`,`Handed ${String(n)} device(s) to their push service${r?`, ${String(r)} refused`:``}.`)})()};function f(){if(!au)return[];let e=ui(`Install Pier`,!0);return e.onclick=()=>{let e=au;e&&e.prompt().then(()=>e.userChoice).finally(()=>{au=null,p()})},[L(`div`,`flex items-center gap-3`,e,L(`span`,`text-[11.5px] leading-snug text-neutral-500`,`Its own window and icon — and where notifications look like an app's.`))]}function p(){let e=Jl();if(e){r.replaceChildren(...f(),L(`p`,`text-[12.5px] leading-snug text-neutral-500`,e),s);return}let a=i()&&Notification.permission===`granted`;t.disabled=!a,r.replaceChildren(...f(),ki(`Notify this device`,`A turn that finishes while nobody is looking at it becomes a notification here. Per browser — each device is enabled on its own.`,a,e=>void(e?u():d())),n,s)}return ou=p,p(),{el:xi(`Notifications`,`Web Push, so a finished turn reaches you with the workbench closed. Installed — Chrome's address-bar icon, or Share → Add to Home Screen on iOS — Pier notifies you the way an app does.`,r),load:()=>{R(o,`idle`,``),l()}}}var J=I(`#sidebar`),uu=I(`#drawer-scrim`),du=I(`#mobile-title`),fu=I(`#mobile-menu`),pu=I(`#session-meta`);function mu(){delete J.dataset.open,uu.classList.add(`hidden`),Su()}function hu(e,t){du.textContent=e,du.classList.toggle(`cursor-pointer`,t),fu.classList.toggle(`hidden`,!t)}var gu=`pier.railClosed`;localStorage.getItem(gu)===`1`&&(document.body.dataset.rail=`closed`);function _u(e){document.body.dataset.rail=e?`closed`:``,localStorage.setItem(gu,e?`1`:`0`),Su()}function vu(){if(J.dataset.open!==void 0)return mu();J.dataset.open=``,uu.classList.remove(`hidden`),Su()}var yu=window.matchMedia(`(width < 48rem)`),bu=()=>yu.matches;function xu(){bu()?I(`#mobile-bar`).append(pu):I(`#chat-menu`).before(pu)}function Su(){let e=bu()&&J.dataset.open!==void 0,t=I(`main`);t.inert=e,J.inert=bu()?!e:document.body.dataset.rail===`closed`,I(`#drawer-toggle`).setAttribute(`aria-expanded`,String(e)),e&&!J.contains(document.activeElement)&&I(`#new-session`).focus(),J.inert&&J.contains(document.activeElement)&&I(bu()?`#drawer-toggle`:`#rail-toggle`).focus()}var Cu=[I(`#rail-toggle`),I(`#drawer-toggle`)],wu=`attention absolute -right-0.5 -top-0.5 rounded-full bg-amber-500`,Tu=e=>e===1?L(`span`,`${wu} h-2 w-2`):L(`span`,`${wu} flex h-3.5 min-w-3.5 items-center justify-center px-0.5 text-[9px] font-semibold text-white`,e>9?`9+`:String(e));function Eu(e){for(let t of Cu)t.querySelector(`.attention`)?.remove(),e&&t.append(Tu(e))}var Du=20,Ou=.35,ku=8;function Au(){let e=-1,t=0,n=!1,r=!1,i=1,a=e=>{J.style.transition=`none`,J.style.transform=`translateX(${String(e-i)}px)`,uu.style.transition=`none`,uu.classList.remove(`hidden`),uu.style.opacity=String(e/i)},o=t=>{J.style.transition=``,J.style.transform=``,uu.style.transition=``,uu.style.opacity=``,t?(J.dataset.open=``,uu.classList.remove(`hidden`),Su()):mu(),e=-1,r=!1};window.addEventListener(`touchstart`,a=>{if(r||(e=-1,!bu()||a.touches.length!==1))return;let o=a.touches[0],s=J.dataset.open!==void 0;if(i=J.offsetWidth||1,s){if(o.clientX>i)return}else{if(o.clientX>Du||a.target?.closest(`button, a, input, textarea, select`))return;a.preventDefault()}e=o.clientX,t=o.clientY,n=!s},{passive:!1}),window.addEventListener(`touchmove`,o=>{if(e<0)return;let s=o.touches[0],c=s.clientX-e;if(!r){if(Math.abs(s.clientY-t)>Math.abs(c))return void(e=-1);if(Math.abs(c)<ku)return;r=!0}o.preventDefault(),a(Math.max(0,Math.min(i,n?c:i+c)))},{passive:!1});let s=()=>{if(e<0)return;if(!r)return void(e=-1);let t=J.getBoundingClientRect().right;o(n?t>i*Ou:t>i*.65)};window.addEventListener(`touchend`,s),window.addEventListener(`touchcancel`,s)}function ju(e){Au(),Su(),xu(),yu.addEventListener(`change`,()=>{mu(),xu()}),I(`#drawer-toggle`).setAttribute(`aria-controls`,`sidebar`),J.addEventListener(`keydown`,e=>{if(!(!bu()||J.dataset.open===void 0||e.defaultPrevented||e.isComposing)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),mu();else if(e.key===`Tab`){let t=[...J.querySelectorAll(`button, a[href], summary`)].filter(e=>e.getClientRects().length&&!e.matches(`:disabled`)),n=e.shiftKey?t.at(-1):t[0],r=e.shiftKey?t[0]:t.at(-1);document.activeElement===r&&(e.preventDefault(),n?.focus())}}}),I(`#drawer-toggle`).onclick=vu,uu.onclick=mu,fu.onclick=()=>e.sessionMenu(fu),du.onclick=()=>{fu.classList.contains(`hidden`)||e.sessionInfo(du)};let t=I(`#rail-toggle`);t.onclick=()=>_u(document.body.dataset.rail!==`closed`),Xc(t,`meta+b`,`Toggle sidebar`,()=>bu()?vu():_u(document.body.dataset.rail!==`closed`))}var Y,Mu=I(`#session-list`),Nu=I(`#new-session`),Pu=e=>e.modified??e.createdAt;function Fu(e){return{top:e.filter(e=>e.rank!==void 0).sort((e,t)=>(e.rank??0)-(t.rank??0)),rest:e.filter(e=>e.rank===void 0).sort((e,t)=>t.createdAt-e.createdAt)}}function Iu(e,t){let{top:n,rest:r}=Fu(e),i=[...n,...r].slice(0,t);return{rows:i,hidden:e.length-i.length}}function Lu(e,t,n){let{top:r,rest:i}=Fu(e),a=[...r,...i];if(!a.length)return;let o=a.findIndex(e=>e.id===t),s=o<0?a[0]:a[(o+n+a.length)%a.length];return s&&s.id!==t?s.id:void 0}var Ru=8,zu=`session-more hidden h-7 w-7 flex-none cursor-pointer items-center justify-center rounded-lg text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700`,Bu=e=>e.unread,Vu=e=>`${e} subagent${e>1?`s`:``} running`,Hu=e=>e.state===`streaming`||Bu(e)||e.activeRuns>0;function Uu(e){if(!Hu(e))return[];let t=e.state===`streaming`?[`bg-green-500 animate-pulse`,`working…`]:Bu(e)?[`bg-amber-500`,`turn finished — not viewed yet`]:[`bg-sky-500`,Vu(e.activeRuns)],n=L(`span`,`h-2 w-2 flex-none rounded-full ${t[0]}`);return n.title=t[1],[n]}async function Wu(e){let t=window.prompt(`Session name — empty resets it to the first message`,e.title??``);if(t===null)return;let n=e.title,r=t=>{e.title=t,Zu(),Y.onTitleChanged()};r(t.trim()||void 0),(await x(`/api/sessions/${e.id}/rename`,{name:t})).ok||r(n)}var Gu=`flex-none text-xs font-medium uppercase leading-5 text-neutral-500`,Ku=e=>e.channel&&e.channel!==`web`?[L(`span`,Gu,e.channel[0]??``)]:[];function qu(e,t=L(`button`,zu,_(m))){let n=e.id===Y.currentId(),r=L(`li`,`flex items-center gap-1 hover:bg-neutral-100 ${n?`bg-indigo-50 hover:bg-indigo-50`:``}`);t.setAttribute(`type`,`button`),t.setAttribute(`aria-label`,`Session actions: ${e.title??`untitled`}`),t.title=`Session actions`,t.onclick=n=>{n.stopPropagation(),Y.sessionMenu(t,e)};let i=L(`button`,`session-open flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-lg text-left`,L(`span`,`min-w-0 flex-1 truncate`,e.title??`untitled`),...Uu(e));return i.setAttribute(`type`,`button`),n&&i.setAttribute(`aria-current`,`page`),i.onclick=()=>Y.select(e.id),r.dataset.sessionId=e.id,r.append(i,...Ku(e),t),r.title=[e.cwd,`active ${Jr(Pu(e))} ago · created ${new Date(e.createdAt).toLocaleDateString()}`,...e.channel&&e.channel!==`web`?[`answering ${e.channel}`]:[]].join(`
|
|
85
|
-
`),r}var Ju=()=>`${Y.currentId()??``}\n${Xu}\n${JSON.stringify(Y.sessions())}`,Yu=``,Xu=20;function Zu(){let e=Ju();if(e===Yu)return;Yu=e;let t=Y.sessions(),n=t.filter(Bu);Eu(n.length),cu(n.length);let{rows:r,hidden:i}=Iu(t,Xu),a=Mu.querySelector(`.session-more[aria-expanded='true']`),o=a?.closest(`[data-session-id]`)?.dataset.sessionId,s=r.map(e=>qu(e,e.id===o?a:void 0));if(i>0){let e=L(`button`,`session-open w-full cursor-pointer rounded-lg text-left text-sm text-neutral-500`,`Load more (${i})`);e.id=`session-load-more`,e.setAttribute(`type`,`button`),e.onclick=()=>{Xu+=20,Zu(),Mu.querySelectorAll(`.session-open`)[r.length]?.focus()},s.push(L(`li`,`hover:bg-neutral-100`,e))}let c=document.activeElement,l=c?.closest(`[data-session-id]`)?.dataset.sessionId,u=c?.classList.contains(`session-more`)?`.session-more`:`.session-open`;if(Mu.replaceChildren(...s.length?[L(`ul`,`pb-1`,...s)]:[L(`p`,`px-3 py-2 text-sm leading-normal text-neutral-500`,`No sessions yet — create one.`)]),l){let e=[...Mu.querySelectorAll(`[data-session-id]`)].find(e=>e.dataset.sessionId===l);e?.querySelector(`.session-open`)?.focus({preventScroll:!0}),u===`.session-more`&&e?.querySelector(u)?.focus({preventScroll:!0})}else c?.id===`session-load-more`&&(Mu.querySelector(`#session-load-more`)??Mu.querySelector(`.session-open`)??I(`#new-session`)).focus({preventScroll:!0});Ad()}function Qu(){if(Nu.getAttribute(`aria-expanded`)===`true`)return B();let e=Y.sessions().find(e=>e.id===Y.currentId())?.cwd,t=Ve(Y.sessions()).slice(0,Ru);if(e&&!t.includes(e)&&t.unshift(e),!t.length)return Ea(Nu,void 0,Y.createSession);Da(Nu,t.map(e=>({path:e,hint:Xr(e)})),e,Y.createSession)}function $u(e){Y=e,Nu.onclick=Qu,Xc(Nu,`shift+o`,`New session`,Qu,Kc);let t=e=>{let t=Lu(Y.sessions(),Y.currentId(),e);t&&Y.select(t)};el(`shift+[`,()=>t(-1),Kc),el(`shift+]`,()=>t(1),Kc)}var ed,td=I(`#palette`),nd=I(`#palette-input`),rd=I(`#palette-list`),id=I(`#palette-count`),ad=[{name:`tasks`,icon:re,label:`Tasks`,detail:`Automation — task definitions and schedules`},{name:`runs`,icon:re,label:`Runs`,detail:`Automation — executions, subagents and callbacks`},{name:`activity`,icon:re,label:`Activity`,detail:`Automation — sessions and relationships`},{name:`boards`,icon:ne,label:`Boards`,detail:`Console — the static pages Pier publishes`},{name:`settings`,icon:pe,label:`Settings`,detail:`Console — models and providers, agent files and extensions, channels, password, sign out, security`}],od=7,sd=3,cd=8,ld=80,ud=``,dd,fd,pd;function md(e){ud!==e&&(clearTimeout(pd),fd?.abort(),fd=void 0,ud=e,dd=void 0,e&&(pd=setTimeout(()=>{let t=fd=new AbortController;C(`/api/search?q=${encodeURIComponent(e)}`,`Search unavailable`,{signal:t.signal}).then(n=>{t.signal.aborted||ud!==e||(fd=void 0,dd=n.ok?{hits:n.value.hits}:{error:n.error},td.open&&kd())})},ld)))}var hd=[],gd=0;function _d(e){if(hd.length){gd=(e+hd.length)%hd.length;for(let[e,{el:t}]of hd.entries())t.classList.toggle(`bg-indigo-50`,e===gd),t.setAttribute(`aria-selected`,String(e===gd));hd[gd]?.el.scrollIntoView({block:`nearest`})}}var vd=e=>e.hit?.at??e.session?.createdAt;function yd(e){let t=L(`span`,`min-w-0 flex-1 truncate text-neutral-500`);for(let n of e.replaceAll(/\s+/g,` `).split(``)){let[e=``,r]=n.split(``,2);r===void 0?t.append(e):t.append(L(`span`,`font-medium text-neutral-800`,e),r)}return t}var bd=`flex min-w-0 flex-1 items-baseline gap-2`,xd=`shrink-0 truncate`,Sd=`min-w-[2.5em] truncate text-[0.8125rem] text-neutral-400`,Cd=`flex-none text-[0.75rem] tabular-nums text-neutral-400`,wd=`flex h-7 w-7 flex-none items-center justify-center rounded-[8px] bg-neutral-100 text-neutral-500`;function Td(e){let t=L(`li`,`palette-row flex cursor-pointer items-center gap-3 rounded-[10px] px-2 leading-5 ${e.hit?`py-1.5`:`min-h-10`}`);t.setAttribute(`role`,`option`),t.append(L(`span`,wd,_(e.icon,`h-4 w-4`)));let n=L(`div`,`flex min-w-0 flex-1 flex-col`),r=L(`div`,`flex items-center gap-2`);e.session&&r.append(...Uu(e.session));let i=L(`span`,bd,L(`span`,`${xd} ${e.detail?`max-w-[calc(100%-3em)]`:`max-w-full`}`,e.label));e.detail&&i.append(L(`span`,Sd,e.detail)),r.append(i);let a=vd(e);return a!==void 0&&r.append(L(`span`,Cd,Jr(a))),n.append(r),e.hit&&n.append(L(`div`,`flex items-baseline gap-2 text-[0.8125rem] leading-5`,L(`span`,`flex-none text-[0.75rem] text-neutral-400`,e.hit.role===`user`?`You`:`Agent`),yd(e.hit.snippet))),t.append(n),t.onclick=e.open,t}var Ed=e=>L(`li`,`px-2 pb-1.5 pt-4 text-[0.6875rem] font-semibold leading-4 tracking-[0.02em] text-neutral-400 first:pt-2`,e);function Dd(e,t){let n=L(`li`,`px-2 py-2 pl-12 text-[0.8125rem] leading-5 text-neutral-400`,e);return t&&(n.title=t),n}var Od=e=>e.channel&&e.channel!==`web`?e.channel:``;function kd(){let e=nd.value.trim(),t=e.toLowerCase().split(/\s+/).filter(Boolean),n=e=>{let n=e.toLowerCase();return t.every(e=>n.includes(e))},r=e=>()=>{td.close(),e()},i=ed.sessions(),a=new Map(i.map(e=>[e.id,e])),{top:o,rest:s}=Fu(i),c=[...o,...s],l=e=>({icon:ae,label:e.title??Zr(e.cwd),detail:[Xr(e.cwd),Od(e)].filter(Boolean).join(` · `),open:r(()=>void ed.select(e.id)),session:e}),u=e=>({icon:te,label:Zr(e),detail:e,open:r(()=>void ed.createSession(e))}),d=ad.filter(t=>!e||n(`${t.label} ${t.detail}`)).map(({name:e,icon:t,label:n,detail:i})=>({icon:t,label:n,detail:i,open:r(()=>ed.openConsole(e))})),f={icon:te,label:`New session in…`,detail:`Pick a directory`,open:r(Qu)},p=[];if(e){let t=Ve(i).filter(e=>n(Xr(e))).slice(0,sd),o=c.filter(e=>n(`${e.title??``} ${e.cwd} ${Od(e)}`)).slice(0,cd),s=new Set(o.map(e=>e.id)),m=o.map(l);if(ud!==e||!dd)m.push(Dd(`Searching messages…`));else if(`error`in dd)m.push(Dd(`Message search unavailable`,dd.error));else{for(let e of dd.hits){if(m.length>=cd)break;let t=a.get(e.sessionId);!t||s.has(t.id)||m.push({...l(t),hit:e,open:r(()=>void ed.select(t.id).then(()=>Is(e.role,e.at)))})}m.length||m.push(Dd(`No sessions match`))}p.push([`Actions`,[...t.map(u),...n(f.label)?[f]:[],...d]],[`Sessions`,m])}else{let e=a.get(ed.currentId()??``);p.push([`Running`,c.filter(Hu).map(l)],[`Recent`,c.filter(e=>!Hu(e)).slice(0,od).map(l)],[`Actions`,[...e?[u(e.cwd)]:[],f]],[`Console`,d])}hd=[];let m=[];for(let[e,t]of p)if(t.length){m.push(Ed(e));for(let e of t){if(e instanceof HTMLElement){m.push(e);continue}let t=Td(e);hd.push({el:t,open:e.open}),m.push(t)}}rd.replaceChildren(...m.length?m:[Dd(`Nothing matches`)]),id.textContent=`${hd.length} ${hd.length===1?`row`:`rows`}`,_d(Math.min(gd,Math.max(0,hd.length-1)))}function Ad(){td.open&&kd()}function jd(){if(td.open)return td.close();nd.value=``,gd=0,md(``),kd(),td.showModal(),nd.focus(),ed.loadSessions().then(Ad)}function Md(e){ed=e;let t=I(`#open-palette`);t.onclick=jd,Xc(t,`k`,`Search sessions, messages and Console`,jd,()=>td.open||ca()),td.onclick=e=>{e.target===td&&td.close()},td.onclose=()=>md(``),nd.oninput=()=>{gd=0,md(nd.value.trim()),kd()},nd.onkeydown=e=>{let t=la(e);if(t!==void 0){e.preventDefault(),_d(gd+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),hd[gd]?.open())}}var Nd=0,Pd=e=>`${e.provider}/${e.id}`,Fd=null;async function Id(){let{modelMenu:e}=await Ge(`/api/settings`,`Could not read the pinned model menu`);return e}function Ld(e){let t=L(`button`,`flex w-full min-w-0 cursor-pointer items-center gap-2 px-3 py-1.5 text-left hover:bg-neutral-100`,_(o,`h-3 w-3 text-indigo-600 ${e.checked?``:`invisible`}`),L(`span`,`truncate`,e.label));return e.hint&&t.append(L(`span`,`ml-auto flex-none text-[11.5px] text-neutral-400`,e.hint)),e.title&&(t.title=e.title),t.onclick=()=>e.onSelect(),t}function Rd({models:e,current:t,thinkingLevel:n,thinkingLevels:r,onPick:i,onThinkingPick:a}){let o=n,s=L(`div`,`flex w-full min-w-0 flex-col sm:min-w-72`),c=L(`div`,`flex flex-col gap-2 border-b border-neutral-200 px-2 py-2`),u=document.createElement(`input`);if(u.type=`search`,u.placeholder=`Search models`,u.setAttribute(`aria-label`,`Search models`),u.className=`w-full rounded-md border border-neutral-300 px-2 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`,c.append(u),r.length){let e=document.createElement(`details`),t=L(`span`,`ml-auto font-medium text-indigo-700`,xe(o)),n=L(`summary`,`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-xl px-3 text-sm text-neutral-700 hover:bg-neutral-100 [&::-webkit-details-marker]:hidden`,L(`span`,`font-medium`,`Reasoning effort`),t,_(l,`chev h-3 w-3 text-neutral-400`)),i=L(`fieldset`,`grid grid-cols-2 gap-1 rounded-xl bg-neutral-50 p-1`);i.append(L(`legend`,`sr-only`,`Reasoning effort`));let s=`reasoning-${++Nd}`;for(let e of r){let n=document.createElement(`input`);n.type=`radio`,n.name=s,n.value=e,n.checked=e===o,n.className=`peer sr-only`,n.onchange=()=>{n.checked&&(o=e,t.textContent=xe(o),m(u.value),a(o))},i.append(L(`label`,`relative cursor-pointer`,n,L(`span`,`flex min-h-11 items-center rounded-lg border border-transparent px-3 text-sm text-neutral-700 hover:bg-neutral-100 peer-checked:border-indigo-200 peer-checked:bg-indigo-50 peer-checked:font-semibold peer-checked:text-indigo-700 peer-focus-visible:outline-2 peer-focus-visible:outline-indigo-500`,xe(e))))}e.append(n,i),c.append(e)}let d=L(`div`,`max-h-72 overflow-y-auto py-1`),f=new Map(e.map(e=>[Pd(e),e])),p=e=>{let n=(Fd??[]).map(e=>({e,model:f.get(Pd(e))})).filter(t=>!!t.model&&(!e||Pd(t.model).toLowerCase().includes(e)));n.length&&d.append(L(`div`,`px-3 pb-0.5 pt-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Pinned`),...n.map(({e,model:n})=>Ld({label:n.id,hint:xe(e.thinking),title:e.note,checked:!!t&&Pd(t)===Pd(n)&&o===e.thinking,onSelect:()=>i(n,e.thinking)})),L(`div`,`my-1 border-t border-neutral-100`))},m=n=>{d.replaceChildren();let r=n.trim().toLowerCase();p(r);let a=new Map;for(let t of e){if(r&&!Pd(t).toLowerCase().includes(r))continue;let e=a.get(t.provider);e?e.push(t):a.set(t.provider,[t])}if(!a.size){d.append(L(`div`,`px-3 py-2 text-[12.5px] text-neutral-400`,e.length?`No matching models.`:`No models available.`));return}for(let[e,n]of a){let a=n.some(e=>!!t&&Pd(t)===Pd(e)),o=document.createElement(`details`);o.open=a||r.length>0;let s=L(`summary`,`flex cursor-pointer select-none items-center gap-1.5 px-3 py-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400 hover:bg-neutral-100`,_(l,`chev h-3 w-3`),L(`span`,`truncate`,e),L(`span`,`ml-auto flex-none normal-case text-neutral-300`,String(n.length)));o.append(s,...n.map(e=>Ld({label:e.id,checked:!!t&&Pd(t)===Pd(e),onSelect:()=>i(e)}))),d.append(o)}};return u.oninput=()=>m(u.value),m(``),Id().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(Fd);Fd=e,t&&m(u.value)}).catch(e=>Fc(`model menu unavailable`,e)),s.append(c,d),queueMicrotask(()=>u.focus()),s}function zd(e,t,n,r){let i=di(t.model?`${t.model.id}${t.thinking?` · ${xe(t.thinking)}`:``}`:t.thinking?`Pi default · ${xe(t.thinking)}`:`Pi default`,`${wi} flex items-center gap-1.5 ${t.model?`text-neutral-700`:`text-neutral-400`}`);return i.title=t.model?`${t.model.provider}/${t.model.id}`:`Whatever the project and Pi pick`,i.onclick=()=>{let e=Rd({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...Mo],onPick:(e,n)=>{B(),r({model:e,thinking:n??t.thinking})},onThinkingPick:e=>{t={...t,thinking:e},r(t)}}),a=di(`Pi default`,`w-full cursor-pointer px-3 py-1.5 text-left text-[12.5px] text-neutral-500 hover:bg-neutral-100`);a.onclick=()=>{B(),r({model:null,thinking:null})};let o=L(`div`,`flex flex-col`);o.append(e,L(`div`,`border-t border-neutral-200`),a),_a(i,o)},Si(e,i)}var X;function Bd(e){X=e,el(Vd,()=>{X.currentSession()&&(B(),X.toggleFiles())},Kc)}var Vd=`i`,Hd=I(`#chat-title`),Ud=I(`#chat-menu`),Wd=I(`#session-meta`),Gd=null,Kd=new Map,qd=e=>`${e.provider}/${e.id}`,Z=null,Jd=null,Yd=null,Xd=null;function Zd(){Z=null,Jd=null,Yd=null,Xd=null,sf()}function Qd(e,t,n,r){Z=e,Jd=t,Yd=n,Xd=r,nf()}function $d(e){Xd=e.completedAt,Jd&&={...Jd,tokens:e.tokens},sf()}var ef=null;function tf(e){ef=e===null?null:Zr(e),nf()}function nf(){let e=X.currentSession();e&&(ef=null),Hd.textContent=e?e.title??Zr(e.cwd):ef??X.currentId()??`no session`,Hd.classList.toggle(`cursor-pointer`,!!e),Hd.title=e?`Session info`:``,Hd.onclick=e?()=>cf(Hd,e):null,Ud.classList.toggle(`hidden`,!e),e&&(Ud.onclick=()=>hf(Ud,e)),sf(),X.syncBar()}var rf=70,af=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),of=e=>e.tokens===null?`?/${Se(e.contextWindow)}`:`${Se(e.tokens)}/${Se(e.contextWindow)} · ${100-af(e.tokens,e)}% left`;function sf(){let e=Jd,t=e?.tokens??null,n=X.currentId(),r=X.currentSession()?.activeRuns??0,i=[];if(r>0){let e=L(`button`,`flex flex-none cursor-pointer items-center gap-1 rounded bg-sky-50 px-1.5 py-px font-medium text-sky-700 hover:bg-sky-100`,_(h,`spinner h-3 w-3`),`${r} running`);e.title=`${Vu(r)} · show the newest`,e.onclick=()=>{Ls()||W(`error`,`no run card left in this transcript — reload the session to see it`)},i.push(e)}if(!n&&ef&&i.push(L(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,_(h,`spinner`),`starting…`)),n){let e=(e,t)=>{let r=L(`button`,`cursor-pointer font-mono ${t}`,e);return r.title=`Change model or reasoning`,r.onclick=()=>void lf(r,n),r};Z&&i.push(e(Z.id,`min-w-0 truncate rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),Yd&&i.push(e(Yd,`flex-none text-neutral-500 hover:text-indigo-700`))}let a=0;if(e&&t!==null){a=af(t,e);let n=a>=90?`text-red-700`:a>=rf?`text-amber-700`:`text-neutral-500`;i.push(L(`span`,`flex-none font-mono ${n}`,Se(t).toLowerCase()))}let o=i.flatMap((e,t)=>t===0?[e]:[L(`span`,`flex-none text-neutral-300`,`·`),e]);Wd.replaceChildren(...o),Wd.classList.toggle(`hidden`,i.length===0),Wd.classList.toggle(`flex`,i.length>0),Wd.toggleAttribute(`data-urgent`,!n&&!!ef||r>0||a>=rf)}function cf(e,t,n){let i=[[`Directory`,t.cwd],[`Session`,t.id]],a=t.id===X.currentId();if(a&&(i.push([`Model`,Z?.id??`—`]),i.push([`Reasoning`,Yd??`—`]),i.push([`Context`,Jd?of(Jd):`—`])),i.push([`Created`,Qr(t.createdAt),Yr(t.createdAt)]),a){let e=Xd;i.push(e===null?[`Last reply`,`—`]:[`Last reply`,Qr(e),Yr(e)])}let o=L(`div`,`w-[min(26rem,calc(100vw-2rem))] max-sm:w-full rounded-xl bg-white px-3 py-3 font-sans text-[15px] leading-normal`),s=L(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,_(_e));s.setAttribute(`aria-label`,`Close session info`),s.onclick=B;let c=L(`div`,`sticky top-0 z-10 flex items-start gap-2 bg-white pb-2`,L(`div`,`min-w-0 flex-1`,L(`div`,`text-sm font-medium text-neutral-500`,`Session info`),L(`h2`,`mt-1 [overflow-wrap:anywhere] text-lg leading-7 font-semibold text-neutral-900`,t.title??Zr(t.cwd))),s);if(n){let e=L(`button`,`icon-btn h-11 w-11 sm:h-8 sm:w-8`,_(r));e.setAttribute(`aria-label`,`Back to session actions`),e.onclick=n,c.prepend(e)}o.append(c);let l=L(`dl`,``);for(let[e,t,n]of i){let r=e===`Directory`||e===`Session`,i=L(`dd`,`min-w-0 flex items-start gap-2 text-neutral-700 ${r?`font-mono text-sm leading-6`:``}`,L(`span`,`min-w-0 flex-1 [overflow-wrap:anywhere]`,t));if(r){let n=ii(`min-h-11 min-w-11 sm:min-h-8 shrink-0 cursor-pointer rounded-lg px-2 py-1 text-[13px] font-sans text-neutral-500 hover:bg-neutral-100 focus-visible:outline-2`,()=>t);n.setAttribute(`aria-label`,`Copy ${e.toLowerCase()}`),i.append(n)}n&&i.firstElementChild?.append(L(`span`,`ml-2 inline-block font-sans text-[13px] leading-5 text-neutral-500`,n));let a=e===`Model`||e===`Created`;l.append(L(`div`,`grid gap-1 py-1.5 sm:grid-cols-[5.5rem_minmax(0,1fr)] sm:gap-3 ${a?`mt-2 border-t border-neutral-200 pt-2.5`:``}`,L(`dt`,`text-[15px] text-neutral-500`,e===`Session`?`Session ID`:e),i))}return o.append(l),_a(e,o)}async function lf(e,t,n){let r=L(`div`,`px-3 py-3 text-[15px] text-neutral-500`,`Loading models…`),i=L(`div`,`w-[min(24rem,calc(100vw-2rem))] min-w-0 max-sm:w-full`,r),a=r;n&&i.prepend(pf(e,n,`Close model picker`)),_a(e,i);let o=()=>a.isConnected&&!a.closest(`[inert]`),s=``,c=(n,r,o)=>{let c=JSON.stringify([n,r,o]);if(c===s)return;s=c;let l=Rd({models:n,current:t===X.currentId()?Z:null,thinkingLevel:r,thinkingLevels:o,onPick:(e,n)=>{B(),uf(t,e,n)},onThinkingPick:e=>void ff(t,e)});a.replaceWith(l),a=l,_a(e,i)},l=t===X.currentId()&&Z?Kd.get(qd(Z)):void 0;Gd&&l&&Yd&&c(Gd,Yd,l);try{let[e,n]=await Promise.all([Ge(`/api/sessions/${t}/models`,`Could not load models`),Ge(`/api/sessions/${t}/thinking`,`Could not read the reasoning level`)]);if(Gd=e,t===X.currentId()&&Z&&Kd.set(qd(Z),n.levels),!o())return;c(e,n.level,n.levels)}catch(e){s?W(`error`,`model options are stale: ${String(e)}`):o()?(r.textContent=`Could not load models: ${String(e)}`,r.setAttribute(`role`,`alert`)):W(`error`,`model options failed: ${String(e)}`)}}async function uf(e,t,n){await df(e,t)&&n&&await ff(e,n)}async function df(e,t){let n=Z;e===X.currentId()&&(Z=t,nf());let r=await x(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===X.currentId()&&(Z=n,nf()),W(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===X.currentId()&&i&&(Z=i,nf()),!0}async function ff(e,t){let n=await x(`/api/sessions/${e}/thinking`,{level:t});if(!n.ok){W(`error`,`reasoning change failed: ${n.status}`);return}let{level:r}=await n.json();e===X.currentId()&&(Yd=r,sf())}function pf(e,t,n){let i=L(`button`,`icon-btn h-11 w-11`,_(r));i.setAttribute(`aria-label`,`Back to session actions`),i.onclick=()=>hf(e,t);let a=L(`button`,`icon-btn h-11 w-11`,_(_e));a.setAttribute(`aria-label`,n),a.onclick=B;let o=L(`span`,`min-w-0 flex-1 truncate text-sm font-medium`,t.title??Zr(t.cwd));return o.title=o.textContent??``,L(`div`,`flex items-center gap-2 border-b border-neutral-200 pb-2 mb-2`,i,o,a)}async function mf(e,t){let n=L(`p`,`px-3 py-2 text-[15px] text-neutral-500`,`Loading chats…`),r=L(`div`,`w-[min(24rem,calc(100vw-2rem))] min-w-0 max-sm:w-full`,pf(e,t,`Close chat picker`),L(`div`,`px-3 pb-1 text-sm font-medium text-neutral-500`,`Continue in a chat`),L(`p`,`px-3 pb-2 text-[13px] text-neutral-500`,`Chats the bot has seen. A chat appears here after its first message to the bot.`),n);_a(e,r);let i=await C(`/api/handoff/targets`,`Could not list chats`);if(!r.isConnected)return;if(!i.ok){n.textContent=i.error,n.setAttribute(`role`,`alert`);return}if(!i.value.targets.length){n.textContent=`No chats yet — message the bot once in Lark or Slack, then come back.`;return}let a=L(`p`,`hidden px-3 pt-1 text-[13px] text-red-600`);a.setAttribute(`role`,`alert`);let o=L(`div`,``);o.dataset.list=``;for(let e of i.value.targets){let n=L(`button`,`flex w-full min-h-10 cursor-pointer items-center gap-2 rounded-xl px-3 py-2 text-left transition-colors hover:bg-indigo-50 hover:text-indigo-700 active:bg-indigo-100`,L(`span`,`min-w-0 truncate`,`${e.platform[0].toUpperCase()}${e.platform.slice(1)} · ${e.kind===`dm`?`DM`:`group`} · ${e.name||e.chatId}`));n.onclick=async()=>{let n=await x(`/api/handoff`,{sessionId:t.id,platform:e.platform,chatId:e.chatId});if(n.ok)return B();a.textContent=(await n.json().catch(()=>({}))).error??`handoff failed: ${String(n.status)}`,a.classList.remove(`hidden`)},o.append(n)}n.replaceWith(o,a),o.querySelector(`button`)?.focus({preventScroll:!0})}function hf(e,t){let n=t.id===X.currentId();ya(e,[{label:`Rename…`,onSelect:()=>{B(),Wu(t)}},{label:`Session info`,onSelect:()=>cf(e,t,()=>hf(e,t))},{label:`New session here`,separatorBefore:!0,hint:Xr(t.cwd),onSelect:()=>{B(),X.createSession(t.cwd)}},{label:`Browse files`,hint:n?Gc(Vd):``,onSelect:()=>{B(),X.openFiles(n?void 0:t.cwd)}},{label:`Continue in Lark/Slack…`,...t.channel&&t.channel!==`web`?{hint:`answers in ${t.channel}`,disabled:!0}:{},onSelect:()=>void mf(e,t)},{label:`Model & reasoning…`,separatorBefore:!0,hint:n?Z?.id??`…`:``,onSelect:()=>void lf(e,t.id,t)}],t.title??Zr(t.cwd))}var gf=`pier.theme`,_f=[`system`,`light`,`dark`],vf=window.matchMedia(`(prefers-color-scheme: dark)`),yf={system:se,light:he,dark:g},bf=()=>{let e=null;try{e=localStorage.getItem(gf)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},xf=()=>{let e=bf();return e===`system`?vf.matches?`dark`:`light`:e};function Sf(){let e=xf();document.documentElement.dataset.theme=e;let t=getComputedStyle(document.documentElement).getPropertyValue(`--workbench-canvas`).trim();I(`meta[name="theme-color"]`).setAttribute(`content`,t),window.dispatchEvent(new Event(`pier:theme`))}function Cf(){let e=I(`#theme-toggle`),t=()=>{let t=bf();e.title=`Theme: ${t}${t===`system`?` (${xf()})`:``}`,e.replaceChildren(_(yf[t])),e.setAttribute(`aria-label`,e.title),Sf()};e.onclick=()=>{let e=_f[(_f.indexOf(bf())+1)%_f.length];try{e===`system`?localStorage.removeItem(gf):localStorage.setItem(gf,e)}catch{}t()},vf.addEventListener(`change`,t),t()}var wf=`https://github.com/timqi/pier`,Tf=[`text-neutral-400`,`hover:text-neutral-700`],Ef=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],Df=18e5,Of=null,kf=I(`#version`);function Af(e){let t=Of?.available===!0&&Of.latest!==null;kf.textContent=`v${e}`,kf.title=t?`Pier ${Of?.latest} is out`:``,kf.classList.remove(...t?Tf:Ef),kf.classList.add(...t?Ef:Tf)}var jf=(e,t=`px-3 py-1 text-[12px] leading-snug text-neutral-500`)=>L(`p`,t,e);function Mf(){let e=L(`div`,`flex w-72 flex-col gap-1 py-1`);if(!Of)return e.append(jf(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=Of,o=L(`span`,``,``),s=(e,t)=>R(o,e?`failed`:`idle`,t),c=L(`div`,`flex items-center gap-2 px-3 py-1.5`);if(e.append(jf(r?`Pier ${n} is out`:`Pier ${t}`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`),jf(r?`You are running ${t}.`:n===null?`The registry could not be reached, so this may not be the latest.`:`This is the latest release.`)),a&&e.append(jf(a,`mx-3 my-1 rounded-md bg-red-50 px-2 py-1.5 text-[11.5px] leading-snug text-red-700`)),r&&i&&!a){let e=ui(`Update now`,!0);e.onclick=()=>void(async()=>{e.disabled=!0,s(!1,`starting the updater…`);let t=await x(`/api/update`,{});if(!t.ok)return e.disabled=!1,s(!0,await S(t,`Could not update`));let{draining:n}=await t.json();s(!1,n?`Waiting for running work to finish — Pier then installs and restarts.`:`Installing — Pier restarts once it is on disk, and this page reconnects on its own.`)})(),c.append(e)}c.append(Object.assign(L(`a`,`btn text-[12.5px] no-underline`,`Source`),{href:r?`${wf}/releases`:wf,target:`_blank`,rel:`noreferrer`,title:`Pier is free software (AGPL-3.0)`})),e.append(c,L(`div`,`px-3`,o)),r&&!i&&!a&&e.append(jf(`No service manager owns this Pier, so it cannot restart itself — update it with: pier update`));let l=ki(`Update automatically`,i?`Installs a new release once nothing is running — no turn in flight, no task run.`:`Needs the systemd service (pier service install); nothing here can restart Pier.`,Of.autoUpdate,e=>void(async()=>{Of&&(Of.autoUpdate=e);let t=await x(`/api/settings`,{autoUpdate:e},`PUT`);t.ok||(Of&&(Of.autoUpdate=!e),u&&(u.checked=!e),s(!0,await S(t,`Could not save`)))})()),u=l.querySelector(`input`);return u&&(u.disabled=!i),e.append(L(`div`,`mt-1 border-t border-neutral-200 px-3 pb-1 pt-2`,l)),e}async function Nf(e){let t=await C(`/api/update`,`Update check failed`);t.ok&&Af((Of=t.value).current||e)}function Pf(e){Af(e),kf.onclick=e=>{e.preventDefault(),_a(kf,Mf())};let t=()=>void Nf(e);t(),setInterval(t,Df)}var Q,Ff=I(`#chat-header`),If=I(`#chat-title`),Lf=[Ff,U,I(`#composer`)],Rf=()=>Gf===null,zf,Bf,Vf,Hf=new Map,Uf=new Map,Wf=new Map,Gf=null,Kf=0,qf=[`files`],Jf=new Map,Yf={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},Xf=[`tasks`,`runs`,`activity`],Zf=`Automation`,Qf=I(`#automation-view`),$f=I(`#automation-tabs`),ep=e=>Xf.includes(e)?`tasks`:e;function tp(e,t){let n=e!==null&&Xf.includes(e);if(Qf.classList.toggle(`hidden`,!n),Qf.classList.toggle(`flex`,n),!n)return;let r=[];if(e===`tasks`&&!t){let e=ui(`New task`,!0);e.classList.add(`ml-auto`),e.disabled=!zf,e.onclick=()=>zf?.create(),r.push(e)}$f.replaceChildren(fi(Zf),...Xf.map(t=>gi(Yf[t],t===e,()=>op(t))),...r)}var np=e=>zf?.refresh(e),rp=()=>Bf?.refresh(),ip=()=>Vf?.refresh();function ap(){Gf?hu(Xf.includes(Gf)?Zf:Yf[Gf],!1):hu(If.textContent??``,Q.currentSession()!==void 0)}function op(e,t,n){if(qf.includes(e)){let t=vp();t&&(t.kind!==`console`||t.name!==e)&&Jf.set(e,t)}bp({kind:`console`,name:e,arg:t,query:n}),mu(),Gf=e;for(let e of Lf)e.classList.add(`hidden`);wl();for(let[t,n]of Hf)t!==e&&n.hide();for(let[t,n]of Wf)n.classList.toggle(`bg-indigo-50`,t===ep(e));tp(e,t),ap(),sp(e,t,n,++Kf)}async function sp(e,t,n,r){let i=Hf.get(e);if(!i){let t=Uf.get(e);if(!t){let n=I(`#${e}-view`);t=Cp[e](n).catch(t=>(console.warn(`${e} view failed to load`,t),ei(n,()=>n.replaceChildren(L(`p`,`p-4 text-[13px] text-red-600`,`Could not load ${Yf[e]} — reload the page.`))))),Uf.set(e,t)}i=await t,Hf.set(e,i),Uf.delete(e)}Gf===e&&r===Kf&&(i.show(t,n),e===`tasks`&&tp(e,t))}var cp=e=>op(`tasks`,e),lp=(e={},t)=>op(`runs`,t,new URLSearchParams(e).toString()),up=e=>lp({},e),dp=(e,t)=>op(`files`,e,t?new URLSearchParams({select:t}).toString():void 0),fp=(e,t)=>{Gf===e?mp(e):op(e,t)},pp=e=>fp(`files`,e);function mp(e){let t=Q.currentId(),n=Jf.get(e)??(t?{kind:`session`,id:t}:null);Jf.delete(e),n?bp(n):(history.replaceState(null,``,`#/`),hp())}function hp(){if(Gf){Gf=null;for(let e of Hf.values())e.hide();for(let e of Wf.values())e.classList.remove(`bg-indigo-50`);tp(null);for(let e of Lf)e.classList.remove(`hidden`);wl(),ap(),Q.maybeAckRead()}}var gp=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,_p={config:`files`,channels:`channels`,providers:`models`};function vp(){let e=location.hash.replace(/^#\/?/,``),t=e.indexOf(`?`),[n=``,r]=(t<0?e:e.slice(0,t)).split(`/`),i=t<0?void 0:e.slice(t+1)||void 0,a;try{a=r?decodeURIComponent(r):void 0}catch{return null}return _p[n]?{kind:`console`,name:`settings`,arg:_p[n]}:Object.hasOwn(Yf,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var yp=!1;function bp(e,t=!1){if(yp)return;let n=gp(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var xp=e=>bp({kind:`session`,id:e});function Sp(){let e=vp(),t=Q.sessions(),n=Q.currentId(),r=e?.kind===`session`?e.id:null,{top:i,rest:a}=Fu(t),o=r??n??(i[0]??a[0])?.id??null;yp=!0;try{o&&o!==n&&Q.select(o),e?.kind===`console`?op(e.name,e.arg,e.query):hp(),o||nf()}finally{yp=!1}e?.kind!==`console`&&o&&bp({kind:`session`,id:o},!0)}var Cp={tasks:async e=>zf=(await Gi(async()=>{let{createTasksView:e}=await import(`./tasks-D3i9Kc5-.js`);return{createTasksView:e}},__vite__mapDeps([0,1]))).createTasksView(e,()=>Q.sessions().map(({id:e,cwd:t,title:n})=>({id:e,cwd:t,title:n})),Q.loadSessions,Q.select,()=>Q.currentId(),lp,cp),runs:async e=>Bf=(await Gi(async()=>{let{createRunsView:e}=await import(`./runs-CsINd08H.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Q.select,lp,cp),activity:async e=>Vf=(await Gi(async()=>{let{createActivityView:e}=await import(`./activity-DE9Dct4L.js`);return{createActivityView:e}},[])).createActivityView(e,Q.select,up),boards:async e=>(await Gi(async()=>{let{createBoardsView:e}=await import(`./boards-il6ceDEs.js`);return{createBoardsView:e}},[])).createBoardsView(e,Q.select),files:async e=>(await Gi(async()=>{let{createExplorerView:e}=await import(`./explorer-JDO21aAs.js`);return{createExplorerView:e}},[])).createExplorerView(e,()=>Q.currentSession(),e=>op(`files`,e),()=>mp(`files`)),settings:async e=>(await Gi(async()=>{let{createSettingsView:e}=await import(`./settings-ChwAWwE_.js`);return{createSettingsView:e}},[])).createSettingsView(e,()=>Ve(Q.sessions()),e=>op(`settings`,e),dp)};function wp(e){Q=e;for(let e of[`tasks`,`boards`,`settings`]){let t=I(`#open-${e}`);Wf.set(e,t),t.onclick=()=>op(e)}let t=I(`#console-section`);t.open=localStorage.getItem(`pier.consoleCollapsed`)!==`1`,t.ontoggle=()=>localStorage.setItem(`pier.consoleCollapsed`,t.open?`0`:`1`),window.onhashchange=Sp}var Tp=[],Ep=null,Dp=0,Op=0,kp=!1,$=null,Ap=`idle`,jp=null,Mp=0,Np=!1,Pp=!1;async function Fp(e){let t=++Dp;++Op,kp=!1,hp(),mu(),$=null,jp?.close(),jp=null,Ec(),Tl([]),Zd(),tf(e),Dc(!0),Pp=!0,Cl();let n=await x(`/api/sessions`,{cwd:e});if(t!==Dp)return;if(Pp=!1,!n.ok){Dc(!1),tf(null),Cl(),W(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();t===Dp&&(Tp.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,unread:!1,channel:`web`,activeRuns:0}),await Kp(r),$===r&&yl())}function Ip(e){Tp=e.map(e=>({...e,title:ze(e.title)})),Tp.sort((e,t)=>t.createdAt-e.createdAt),Zu(),nf(),Rp()}var Lp=He(async()=>{Ip(await Ge(`/api/sessions`,`Could not load sessions`))});function Rp(){if(document.hidden||!document.hasFocus()||!Rf())return;let e=Tp.find(e=>e.id===$);e?.unread&&(e.unread=!1,Zu(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function zp(){return Tp.find(e=>e.id===$)??(Ep&&Ep.id===$?Ep:void 0)}async function Bp(e){let t=await C(`/api/sessions/${e}`,`failed to load session`);$!==e||!t.ok||(Ep={...t.value,title:ze(t.value.title)},nf())}function Vp(e,t){let n=Tp.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),Zu(),nf())}function Hp(e){Ap=e;let t=Tp.find(e=>e.id===$);t&&(t.state=e),Zu(),nf(),Cl(),e===`idle`&&Lp()}function Up(e){if(!(e.sessionId!==$||e.seq<=Mp))switch(Mp=e.seq,e.type){case`turn-start`:Np=!0;break;case`system-input`:Sc(),Js(e.text,e.origin);break;case`task-status`:Ko(e.run);break;case`user-message`:{let t=Ie(e.text).text;if(Vp(e.sessionId,t),bl(t))break;Sc(),W(`user`,e.text,!1,e.ts),Ps();break}case`text-start`:Sc();break;case`text-delta`:xc(e.text);break;case`thinking-delta`:Sc(),bs(e.ts,e.text);break;case`tool-start`:Sc(),vs(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:ys(e.toolCallId,e.isError,e.output);break;case`turn-end`:Np=!1,wc(e.text,e.meta),e.meta&&$d(e.meta);break;case`queue-state`:El(e.steering,e.followUp);break;case`queue-recovery`:Tl(e.batches,e.uncertain);break;case`context-compacted`:Sc(),W(`system`,`Context compacted — ${Se(e.before)} → ${Se(e.after)}`,!1,e.ts),Ps();break;case`error`:gs(),W(`error`,e.message);break;case`state`:e.state===`idle`&&Np&&(Np=!1,Tc()),e.state===`idle`&&El([],[]),Hp(e.state)}}function Wp(){let e=new EventSource(`/api/events`);e.onopen=()=>{Lp(),np(),rp(),ip()},e.onerror=()=>Bc(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){Lp();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){np(t.type===`task-run-changed`?t.taskId:void 0),rp(),ip(),t.type===`task-run-changed`&&Lp();return}if(ip(),t.sessionId===$)return;let n=Tp.find(e=>e.id===t.sessionId);n&&(n.state=t.state,Zu())}}function Gp(e,t,n){jp?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>jp===r&&$===e&&n===Op;r.onmessage=e=>{i()&&Up(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&qp(e)}),r.onerror=()=>{i()&&Bc(r,`Session`)},jp=r}async function Kp(e){hp(),mu(),xp(e),!(e===$&&(jp||kp))&&(++Dp,++Op,Pp=!1,Il(),$=e,Ep=null,Tp.some(t=>t.id===e)||Bp(e),Ap=Tp.find(t=>t.id===e)?.state??`idle`,Ll(e),Zu(),nf(),Rp(),await qp(e))}async function qp(e){if($!==e)return;let t=++Op;jp?.close(),jp=null,kp=!0,Ec(),El([],[]),Tl([]),Zd(),Np=!1,Sl(),Mp=0,Dc(!0);let n=await C(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||t!==Op)return;if(kp=!1,!n.ok){Dc(!1),W(`error`,n.error);return}let r=n.value;Oc(r.turns,r.state,r.backgroundRuns),Mp=r.lastSeq,Np=r.state===`streaming`,Hp(r.state),El(r.queue.steering,r.queue.followUp),Tl(r.queueRecovery,r.queueUncertain);let i=r.turns.reduce((e,t)=>t.meta?.completedAt??e,null);Qd(r.model,r.context,r.thinkingLevel,i),Gp(e,`${r.epoch}:${r.lastSeq}`,t)}Ic(),ve(),zc(),Cf();var Jp=async e=>{$===e&&await qp(e)};Es({sessionId:()=>$,sessionCwd:()=>zp()?.cwd??null,sessionChannel:()=>zp()?.channel??null,sessionState:()=>Ap,select:e=>void Kp(e),showRun:up,send:(e,t)=>void Bl(e,t),ownTurn:e=>{xl(e),Hp(`streaming`)},reload:Jp}),Ul({sessionId:()=>$,starting:()=>Pp,sessionState:()=>Ap,chatVisible:Rf,setState:Hp,reload:Jp}),ju({sessionMenu:e=>{let t=zp();t&&hf(e,t)},sessionInfo:e=>{let t=zp();t&&cf(e,t)}}),$u({sessions:()=>Tp,currentId:()=>$,select:e=>void Kp(e),sessionMenu:hf,createSession:Fp,onTitleChanged:nf}),Md({sessions:()=>Tp,loadSessions:Lp,currentId:()=>$,select:Kp,createSession:Fp,openConsole:op}),Bd({currentId:()=>$,currentSession:zp,createSession:e=>void Fp(e),syncBar:ap,openFiles:dp,toggleFiles:pp}),wp({sessions:()=>Tp,loadSessions:Lp,currentId:()=>$,currentSession:zp,select:e=>void Kp(e),maybeAckRead:Rp}),Pf(`0.1.9`),iu(),document.addEventListener(`gesturestart`,e=>e.preventDefault()),document.addEventListener(`visibilitychange`,Rp),window.addEventListener(`focus`,Rp),Wp(),Lp().then(Sp);export{S as $,Pi as A,ki as B,ji as C,Mi as D,xi as E,Di as F,ei as G,Fi as H,R as I,$r as J,ii as K,hi as L,fi as M,gi as N,Ni as O,mi as P,He as Q,Ti as R,Ai as S,ui as T,Yr as U,pi as V,Xr as W,Jr as X,L as Y,Zr as Z,Ci as _,$c as a,ze as at,_i as b,Aa as c,_e as ct,ya as d,l as dt,C as et,_a as f,s as ft,bi as g,Zi as h,lu as i,x as it,Ei as j,Si as k,Da as l,ue as lt,ea as m,a as mt,zd as n,We as nt,Mo as o,xe as ot,ta as p,o as pt,li as q,Rd as r,Ke as rt,No as s,_ as st,cf as t,Ge as tt,B as u,h as ut,wi as v,di as w,vi as x,yi as y,Oi as z};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|