@timqi/pier 0.0.29 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +58 -125
  2. package/dist/agent/config.js +24 -11
  3. package/dist/agent/credentials.js +11 -23
  4. package/dist/agent/events.js +43 -62
  5. package/dist/agent/listing.js +113 -68
  6. package/dist/agent/pi.js +204 -211
  7. package/dist/boards/boards.js +19 -29
  8. package/dist/channels/attach.js +14 -42
  9. package/dist/channels/chains.js +33 -37
  10. package/dist/channels/chunk.js +8 -28
  11. package/dist/channels/commands.js +3 -14
  12. package/dist/channels/config.js +33 -52
  13. package/dist/channels/control.js +4 -13
  14. package/dist/channels/conversations.js +8 -25
  15. package/dist/channels/dedup.js +8 -17
  16. package/dist/channels/gatekeeper.js +13 -23
  17. package/dist/channels/lark-api.js +23 -63
  18. package/dist/channels/lark-outbound.js +12 -44
  19. package/dist/channels/lark-panel.js +8 -24
  20. package/dist/channels/lark-render.js +18 -62
  21. package/dist/channels/lark.js +52 -141
  22. package/dist/channels/lines.js +13 -15
  23. package/dist/channels/panel.js +16 -36
  24. package/dist/channels/receipts.js +29 -52
  25. package/dist/channels/routes.js +3 -9
  26. package/dist/channels/runtime.js +12 -23
  27. package/dist/channels/slack-api.js +34 -86
  28. package/dist/channels/slack-directory.js +7 -23
  29. package/dist/channels/slack-outbound.js +12 -56
  30. package/dist/channels/slack-panel.js +4 -13
  31. package/dist/channels/slack-render.js +23 -91
  32. package/dist/channels/slack-tool.js +48 -171
  33. package/dist/channels/slack.js +73 -239
  34. package/dist/channels/telegram-api.js +8 -20
  35. package/dist/channels/telegram-panel.js +5 -21
  36. package/dist/channels/telegram-render.js +13 -40
  37. package/dist/channels/telegram.js +54 -146
  38. package/dist/channels/types.js +5 -16
  39. package/dist/cli.js +17 -41
  40. package/dist/config-sync.js +87 -4
  41. package/dist/core/hub.js +7 -20
  42. package/dist/core/identity.js +20 -59
  43. package/dist/core/inbound-file.js +15 -49
  44. package/dist/core/inbox.js +13 -35
  45. package/dist/core/queue.js +3 -5
  46. package/dist/core/reply.js +41 -142
  47. package/dist/core/router.js +209 -260
  48. package/dist/core/types.js +17 -1
  49. package/dist/db.js +98 -252
  50. package/dist/drain.js +58 -51
  51. package/dist/extensions/index.js +3 -11
  52. package/dist/extensions/web/anthropic.js +3 -9
  53. package/dist/extensions/web/artifacts.js +2 -5
  54. package/dist/extensions/web/content.js +6 -14
  55. package/dist/extensions/web/http.js +2 -6
  56. package/dist/extensions/web/language.js +8 -18
  57. package/dist/extensions/web/openai.js +1 -1
  58. package/dist/extensions/web/provider.js +5 -18
  59. package/dist/extensions/web/tools.js +19 -63
  60. package/dist/lock.js +98 -0
  61. package/dist/log.js +9 -26
  62. package/dist/main.js +87 -179
  63. package/dist/paths.js +10 -26
  64. package/dist/secrets.js +19 -46
  65. package/dist/service.js +33 -75
  66. package/dist/settings.js +42 -65
  67. package/dist/tasks/agent.js +129 -114
  68. package/dist/tasks/callbacks.js +9 -19
  69. package/dist/tasks/command.js +29 -14
  70. package/dist/tasks/definitions.js +39 -62
  71. package/dist/tasks/execution.js +46 -42
  72. package/dist/tasks/groups.js +41 -35
  73. package/dist/tasks/messages.js +121 -182
  74. package/dist/tasks/outbox.js +61 -55
  75. package/dist/tasks/routes.js +5 -11
  76. package/dist/tasks/runs.js +14 -13
  77. package/dist/tasks/service.js +53 -54
  78. package/dist/tasks/store.js +53 -30
  79. package/dist/tasks/tool.js +132 -61
  80. package/dist/tools-task.js +20 -60
  81. package/dist/tools.js +100 -327
  82. package/dist/update.js +21 -44
  83. package/dist/web/auth.js +118 -179
  84. package/dist/web/config-sync.js +2 -2
  85. package/dist/web/config.js +3 -7
  86. package/dist/web/explorer.js +10 -21
  87. package/dist/web/fs.js +20 -42
  88. package/dist/web/instance.js +45 -85
  89. package/dist/web/providers.js +14 -13
  90. package/dist/web/public/assets/{activity-D3m4L2IL.js → activity-B89_hH7q.js} +2 -2
  91. package/dist/web/public/assets/activity-B89_hH7q.js.br +0 -0
  92. package/dist/web/public/assets/activity-B89_hH7q.js.gz +0 -0
  93. package/dist/web/public/assets/boards-BeKW0ZXK.js +1 -0
  94. package/dist/web/public/assets/boards-BeKW0ZXK.js.br +0 -0
  95. package/dist/web/public/assets/boards-BeKW0ZXK.js.gz +0 -0
  96. package/dist/web/public/assets/explorer-DIuMlaV3.js +4 -0
  97. package/dist/web/public/assets/explorer-DIuMlaV3.js.br +0 -0
  98. package/dist/web/public/assets/explorer-DIuMlaV3.js.gz +0 -0
  99. package/dist/web/public/assets/index-DzXDXra_.js +85 -0
  100. package/dist/web/public/assets/index-DzXDXra_.js.br +0 -0
  101. package/dist/web/public/assets/index-DzXDXra_.js.gz +0 -0
  102. package/dist/web/public/assets/index-eqQLVS8Q.css +2 -0
  103. package/dist/web/public/assets/index-eqQLVS8Q.css.br +0 -0
  104. package/dist/web/public/assets/index-eqQLVS8Q.css.gz +0 -0
  105. package/dist/web/public/assets/runs-Cwy0mN8i.js +1 -0
  106. package/dist/web/public/assets/runs-Cwy0mN8i.js.br +0 -0
  107. package/dist/web/public/assets/runs-Cwy0mN8i.js.gz +0 -0
  108. package/dist/web/public/assets/settings-DzZLmujq.js +5 -0
  109. package/dist/web/public/assets/settings-DzZLmujq.js.br +0 -0
  110. package/dist/web/public/assets/settings-DzZLmujq.js.gz +0 -0
  111. package/dist/web/public/assets/task-runs-BCakxFk8.js +3 -0
  112. package/dist/web/public/assets/task-runs-BCakxFk8.js.br +0 -0
  113. package/dist/web/public/assets/task-runs-BCakxFk8.js.gz +0 -0
  114. package/dist/web/public/assets/tasks-BlzEbk11.js +4 -0
  115. package/dist/web/public/assets/tasks-BlzEbk11.js.br +0 -0
  116. package/dist/web/public/assets/tasks-BlzEbk11.js.gz +0 -0
  117. package/dist/web/public/index.html +100 -130
  118. package/dist/web/public/index.html.br +0 -0
  119. package/dist/web/public/index.html.gz +0 -0
  120. package/dist/web/public/manifest.webmanifest +2 -2
  121. package/dist/web/public/manifest.webmanifest.br +0 -0
  122. package/dist/web/public/manifest.webmanifest.gz +0 -0
  123. package/dist/web/public/sw.js +14 -2
  124. package/dist/web/public/sw.js.br +0 -0
  125. package/dist/web/public/sw.js.gz +0 -0
  126. package/dist/web/push.js +55 -77
  127. package/dist/web/route.js +3 -7
  128. package/dist/web/server.js +131 -180
  129. package/dist/web/session-state.js +14 -54
  130. package/dist/web/types.js +2 -4
  131. package/dist/web/webpush.js +10 -25
  132. package/docs/deploy.md +115 -330
  133. package/package.json +2 -1
  134. package/skills/pier-boards/SKILL.md +81 -160
  135. package/skills/pier-help/SKILL.md +23 -20
  136. package/skills/pier-slack/SKILL.md +2 -2
  137. package/skills/pier-tasks/SKILL.md +153 -160
  138. package/dist/config-sync-fetch.js +0 -84
  139. package/dist/limits.js +0 -14
  140. package/dist/web/public/assets/activity-D3m4L2IL.js.br +0 -0
  141. package/dist/web/public/assets/activity-D3m4L2IL.js.gz +0 -0
  142. package/dist/web/public/assets/boards-BIObcQeX.js +0 -1
  143. package/dist/web/public/assets/boards-BIObcQeX.js.br +0 -0
  144. package/dist/web/public/assets/boards-BIObcQeX.js.gz +0 -0
  145. package/dist/web/public/assets/explorer-C_rSWPNB.js +0 -4
  146. package/dist/web/public/assets/explorer-C_rSWPNB.js.br +0 -0
  147. package/dist/web/public/assets/explorer-C_rSWPNB.js.gz +0 -0
  148. package/dist/web/public/assets/index-CX3fYZY5.css +0 -2
  149. package/dist/web/public/assets/index-CX3fYZY5.css.br +0 -0
  150. package/dist/web/public/assets/index-CX3fYZY5.css.gz +0 -0
  151. package/dist/web/public/assets/index-uFsZkKOQ.js +0 -85
  152. package/dist/web/public/assets/index-uFsZkKOQ.js.br +0 -0
  153. package/dist/web/public/assets/index-uFsZkKOQ.js.gz +0 -0
  154. package/dist/web/public/assets/runs-Ch6DZq6O.js +0 -1
  155. package/dist/web/public/assets/runs-Ch6DZq6O.js.br +0 -0
  156. package/dist/web/public/assets/runs-Ch6DZq6O.js.gz +0 -0
  157. package/dist/web/public/assets/settings-BWcEIEcv.js +0 -5
  158. package/dist/web/public/assets/settings-BWcEIEcv.js.br +0 -0
  159. package/dist/web/public/assets/settings-BWcEIEcv.js.gz +0 -0
  160. package/dist/web/public/assets/task-runs-DPkwv2UE.js +0 -3
  161. package/dist/web/public/assets/task-runs-DPkwv2UE.js.br +0 -0
  162. package/dist/web/public/assets/task-runs-DPkwv2UE.js.gz +0 -0
  163. package/dist/web/public/assets/tasks-DTiCi2mH.js +0 -4
  164. package/dist/web/public/assets/tasks-DTiCi2mH.js.br +0 -0
  165. package/dist/web/public/assets/tasks-DTiCi2mH.js.gz +0 -0
@@ -1,85 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-DTiCi2mH.js","assets/task-runs-DPkwv2UE.js","assets/runs-Ch6DZq6O.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=/[\u201c\u201d"\u2018\u2019'()\uff08\uff09\u300c\u300d\u300e\u300f\u3010\u3011\u300a\u300b\u3008\u3009[\]]/;function t(t){let n=[],r=e=>`\uE010${n.push(e)-1}\uE011`,i=t.replace(/```[\s\S]*?```/g,e=>r(e)).replace(/`[^`\n]+`/g,e=>r(e));return i=i.replace(/\*\*(\S|\S[\s\S]*?\S)\*\*/g,(t,n)=>{let r=``,i=``,a=n;for(;a.length>1&&e.test(a[0]);)r+=a[0],a=a.slice(1);for(;a.length>1&&e.test(a.at(-1));)i=a.at(-1)+i,a=a.slice(0,-1);return r||i?`${r}**${a}**${i}`:t}),i.replace(/\uE010(\d+)\uE011/g,(e,t)=>n[Number(t)]??``)}var n=e=>!e.text.trim()&&e.suggestions.length===0,r=e=>e===`xhigh`?`Extra high`:e[0].toUpperCase()+e.slice(1),i=e=>{if(e<1e3)return String(e);let t=e/1e3;return t>=9.95?`${Math.round(t)}K`:`${t.toFixed(1)}K`},a=/(?:^|\n)[ \t]*-{3,}[ \t]*\r?\n((?:[ \t]*\[[^\]\r\n]+\][ \t]*(?:[||][ \t]*)?)+)\s*$/,o=/\[([^\]\r\n]+)\]/g,s=5,c=/<silent>([\s\S]*?)<\/silent>/gi;function l(e){let t=[...e.matchAll(c)].map(e=>(e[1]??``).trim()).filter(Boolean);return t.length?t.join(` · `):void 0}function u(e,t){let n=d(e),r=l(e),i=a.exec(n);if(!i?.[1])return{text:n,suggestions:[],meta:t,silence:r};let c=[...i[1].matchAll(o)].map(e=>(e[1]??``).trim()).filter(Boolean).slice(0,s);return c.length?{text:n.slice(0,i.index).trimEnd(),suggestions:c,meta:t,silence:r}:{text:n,suggestions:[],meta:t,silence:r}}var d=e=>t(e.replace(c,``).trim()),ee=/^(?:\s|[-*+>]|\d+[.)])/;function f(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&&!(ee.test(s)&&ee.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(/<(\/?)silent>/gi))i=!e[1];o=-1,s=n}return a}var p=/^\[(?:([^\n[\]<>]*)<([^\n[\]<>]+)>)? ?((?:\d{4}-\d{2}-\d{2} )?\d{1,2}:\d{2})?\]\n/;function te(e){let t=p.exec(e);return!t?.[2]&&!t?.[3]?{text:e}:{...t[1]?{name:t[1]}:{},...t[2]?{id:t[2]}:{},...t[3]?{when:t[3]}:{},text:e.slice(t[0].length)}}var ne=/(?:\n\[[^\]\n]*(?:\]\(\s*<?file:\/\/[^\n]*|$))+$/,re=/^\s*`[^`\n]{40,}`\s+(\S[\s\S]*)$/;function ie(e){if(!e)return e;let{text:t}=te(e);return t===e?e:t.replace(ne,``).replace(re,`$1`).replace(/\s+/g,` `).trim()||e}function ae(e){let t,n=!1;return()=>(n=!0,t??=(async()=>{for(;n;)n=!1,await e()})().finally(()=>{t=void 0}))}var m=(e,t,n=`POST`)=>fetch(e,{method:n,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function h(e,t){return(await e.json().catch(()=>({}))).error??`${t} (${e.status})`}async function oe(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 h(r,t)};try{return{ok:!0,value:await r.json()}}catch(e){return{ok:!1,error:`${t}: ${String(e)}`}}}async function se(e,t,n){let r=await oe(e,t,n);if(!r.ok)throw Error(r.error);return r.value}async function g(e,t,n){try{let r=await fetch(e,{method:t});return r.ok?void 0:await h(r,n)}catch(e){return`${n}: ${String(e)}`}}function ce(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 le(e){if(Array.isArray(e))return e}function ue(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 de(){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 fe(e,t){return le(e)||ue(e,t)||pe(e,t)||de()}function pe(e,t){if(e){if(typeof e==`string`)return ce(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)?ce(e,t):void 0}}var me=Object.entries,he=Object.setPrototypeOf,ge=Object.isFrozen,_e=Object.getPrototypeOf,ve=Object.getOwnPropertyDescriptor,_=Object.freeze,v=Object.seal,ye=Object.create,be=typeof Reflect<`u`&&Reflect,xe=be.apply,Se=be.construct;_||=function(e){return e},v||=function(e){return e},xe||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Se||=function(e){return new e(...[...arguments].slice(1))};var Ce=S(Array.prototype.forEach),we=S(Array.prototype.lastIndexOf),Te=S(Array.prototype.pop),Ee=S(Array.prototype.push),De=S(Array.prototype.splice),Oe=Array.isArray,ke=S(String.prototype.toLowerCase),Ae=S(String.prototype.toString),je=S(String.prototype.match),Me=S(String.prototype.replace),Ne=S(String.prototype.indexOf),Pe=S(String.prototype.trim),Fe=S(Number.prototype.toString),y=S(Boolean.prototype.toString),Ie=typeof BigInt>`u`?null:S(BigInt.prototype.toString),Le=typeof Symbol>`u`?null:S(Symbol.prototype.toString),b=S(Object.prototype.hasOwnProperty),Re=S(Object.prototype.toString),x=S(RegExp.prototype.test),ze=Be(TypeError);function S(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return xe(e,t,n)}}function Be(e){return function(){return Se(e,[...arguments])}}function C(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ke;if(he&&he(e,null),!Oe(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ge(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ve(e){for(let t=0;t<e.length;t++)b(e,t)||(e[t]=null);return e}function w(e){let t=ye(null);for(let r of me(e)){var n=fe(r,2);let i=n[0],a=n[1];b(e,i)&&(t[i]=Oe(a)?Ve(a):a&&typeof a==`object`&&a.constructor===Object?w(a):a)}return t}function He(e){switch(typeof e){case`string`:return e;case`number`:return Fe(e);case`boolean`:return y(e);case`bigint`:return Ie?Ie(e):`0`;case`symbol`:return Le?Le(e):`Symbol()`;case`undefined`:return Re(e);case`function`:case`object`:{if(e===null)return Re(e);let t=e,n=Ue(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Re(e)}return Re(e)}default:return Re(e)}}function Ue(e,t){for(;e!==null;){let n=ve(e,t);if(n){if(n.get)return S(n.get);if(typeof n.value==`function`)return S(n.value)}e=_e(e)}function n(){return null}return n}function We(e){try{return x(e,``),!0}catch{return!1}}var Ge=_(`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(`.`)),Ke=_(`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(`.`)),qe=_([`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`]),Je=_([`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`]),Ye=_(`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(`.`)),Xe=_([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Ze=_([`#text`]),Qe=_(`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(`.`)),$e=_(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),et=_(`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(`.`)),tt=_([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),nt=v(/{{[\w\W]*|^[\w\W]*}}/g),rt=v(/<%[\w\W]*|^[\w\W]*%>/g),it=v(/\${[\w\W]*/g),at=v(/^data-[\-\w.\u00B7-\uFFFF]+$/),ot=v(/^aria-[\-\w]+$/),st=v(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ct=v(/^(?:\w+script|data):/i),lt=v(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ut=v(/^html$/i),dt=v(/^[a-z][.\w]*(-[.\w]+)+$/i),ft=v(/<[/\w!]/g),pt=v(/<[/\w]/g),mt=v(/<\/no(script|embed|frames)/i),ht=v(/\/>/i),T={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},gt=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],_t=_(C({},gt)),vt=function(){let e={};return Ce(gt,t=>{e[t]=v(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),_(e)}(),yt=function(){return typeof window>`u`?null:window},bt=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}},xt=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},St=function(e,t,n,r){return b(e,t)&&Oe(e[t])?C(r.base?w(r.base):{},e[t],r.transform):n},Ct=function(e,t,n){let r=b(e,t)?e[t]:void 0;return r&&typeof r==`object`?w(r):n()};function wt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yt(),t=e=>wt(e);if(t.version=`3.4.14`,t.removed=[],!e||!e.document||e.document.nodeType!==T.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,ee=Ue(d,`cloneNode`),f=Ue(d,`remove`),p=Ue(d,`nextSibling`),te=Ue(d,`childNodes`),ne=Ue(d,`parentNode`),re=Ue(d,`shadowRoot`),ie=Ue(d,`attributes`),ae=o&&o.prototype?Ue(o.prototype,`nodeType`):null,m=o&&o.prototype?Ue(o.prototype,`nodeName`):null,h=o&&o.prototype?Ue(o.prototype,`ownerDocument`):null,oe=function(e){return ae?ae(e):e.nodeType},se=function(e){return m?m(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 ze(`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--}},he=function(e){fe(),de++;try{return g.createScriptURL(e)}finally{de--}},ge=function(){return ue||=(le=bt(u,i),!0),le},_e=n,ve=_e.implementation,be=_e.createNodeIterator,xe=_e.createDocumentFragment,Se=_e.getElementsByTagName,Fe=r.importNode,y=xt();t.isSupported=typeof me==`function`&&typeof ne==`function`&&ve&&ve.createHTMLDocument!==void 0;let Ie=nt,Le=rt,Re=it,S=at,Be=ot,Ve=ct,gt=lt,Tt=dt,Et=st,E=null,Dt=C({},[...Ge,...Ke,...qe,...Ye,...Ze]),D=null,Ot=C({},[...Qe,...$e,...et,...tt]),O=Object.seal(ye(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}})),kt=null,k=null,At=Object.seal(ye(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),jt=!0,Mt=!0,Nt=!1,Pt=!0,Ft=!1,It=!0,Lt=!1,Rt=!1,zt=null,Bt=null,Vt=!1,Ht=!1,Ut=!1,Wt=!1,Gt=!0,Kt=!1,qt=`user-content-`,Jt=!0,Yt=!1,Xt={},Zt=null,Qt=C({},`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(`.`)),$t=null,en=C({},[`audio`,`video`,`img`,`source`,`image`,`track`]),tn=null,nn=C({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),rn=`http://www.w3.org/1998/Math/MathML`,A=`http://www.w3.org/2000/svg`,j=`http://www.w3.org/1999/xhtml`,M=j,an=!1,on=null,sn=C({},[rn,A,j],Ae),cn=_([`mi`,`mo`,`mn`,`ms`,`mtext`]),ln=C({},cn),un=_([`annotation-xml`]),dn=C({},un),fn=C({},[`title`,`style`,`font`,`a`,`script`]),pn=null,mn=[`application/xhtml+xml`,`text/html`],N=null,hn=null,gn=n.createElement(`form`),_n=function(e){return e instanceof RegExp||e instanceof Function},vn=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(hn&&hn===e)return;(!e||typeof e!=`object`)&&(e={}),e=w(e),pn=mn.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,N=pn===`application/xhtml+xml`?Ae:ke,E=St(e,`ALLOWED_TAGS`,Dt,{transform:N}),D=St(e,`ALLOWED_ATTR`,Ot,{transform:N}),on=St(e,`ALLOWED_NAMESPACES`,sn,{transform:Ae}),tn=St(e,`ADD_URI_SAFE_ATTR`,nn,{transform:N,base:nn}),$t=St(e,`ADD_DATA_URI_TAGS`,en,{transform:N,base:en}),Zt=St(e,`FORBID_CONTENTS`,Qt,{transform:N}),kt=St(e,`FORBID_TAGS`,w({}),{transform:N}),k=St(e,`FORBID_ATTR`,w({}),{transform:N}),Xt=b(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?w(e.USE_PROFILES):e.USE_PROFILES:!1,jt=e.ALLOW_ARIA_ATTR!==!1,Mt=e.ALLOW_DATA_ATTR!==!1,Nt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Pt=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ft=e.SAFE_FOR_TEMPLATES||!1,It=e.SAFE_FOR_XML!==!1,Lt=e.WHOLE_DOCUMENT||!1,Ht=e.RETURN_DOM||!1,Ut=e.RETURN_DOM_FRAGMENT||!1,Wt=e.RETURN_TRUSTED_TYPE||!1,Vt=e.FORCE_BODY||!1,Gt=e.SANITIZE_DOM!==!1,Kt=e.SANITIZE_NAMED_PROPS||!1,Jt=e.KEEP_CONTENT!==!1,Yt=e.IN_PLACE||!1,Et=We(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:st,M=typeof e.NAMESPACE==`string`?e.NAMESPACE:j,ln=Ct(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>C({},cn)),dn=Ct(e,`HTML_INTEGRATION_POINTS`,()=>C({},un));let t=Ct(e,`CUSTOM_ELEMENT_HANDLING`,()=>ye(null));if(O=ye(null),b(t,`tagNameCheck`)&&_n(t.tagNameCheck)&&(O.tagNameCheck=t.tagNameCheck),b(t,`attributeNameCheck`)&&_n(t.attributeNameCheck)&&(O.attributeNameCheck=t.attributeNameCheck),b(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(O.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),v(O),Ft&&(Mt=!1),Ut&&(Ht=!0),Xt&&(E=C({},Ze),D=ye(null),Xt.html===!0&&(C(E,Ge),C(D,Qe)),Xt.svg===!0&&(C(E,Ke),C(D,$e),C(D,tt)),Xt.svgFilters===!0&&(C(E,qe),C(D,$e),C(D,tt)),Xt.mathMl===!0&&(C(E,Ye),C(D,et),C(D,tt))),At.tagCheck=null,At.attributeCheck=null,b(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?At.tagCheck=e.ADD_TAGS:Oe(e.ADD_TAGS)&&(E===Dt&&(E=w(E)),C(E,e.ADD_TAGS,N))),b(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?At.attributeCheck=e.ADD_ATTR:Oe(e.ADD_ATTR)&&(D===Ot&&(D=w(D)),C(D,e.ADD_ATTR,N))),b(e,`ADD_FORBID_CONTENTS`)&&Oe(e.ADD_FORBID_CONTENTS)&&(Zt===Qt&&(Zt=w(Zt)),C(Zt,e.ADD_FORBID_CONTENTS,N)),Jt&&(E[`#text`]=!0),Lt&&C(E,[`html`,`head`,`body`]),E.table&&(C(E,[`tbody`]),delete kt.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw ze(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw ze(`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=ge()),g&&typeof ce==`string`&&(ce=pe(``)));_&&_(e),hn=e},yn=C({},[...Ke,...qe,...Je]),bn=C({},[...Ye,...Xe]),xn=function(e,t,n){return t.namespaceURI===j?e===`svg`:t.namespaceURI===rn?e===`svg`&&(n===`annotation-xml`||ln[n]):!!yn[e]},Sn=function(e,t,n){return t.namespaceURI===j?e===`math`:t.namespaceURI===A?e===`math`&&dn[n]:!!bn[e]},Cn=function(e,t,n){return t.namespaceURI===A&&!dn[n]||t.namespaceURI===rn&&!ln[n]?!1:!bn[e]&&(fn[e]||!yn[e])},wn=function(e){let t=ne(e);(!t||!t.tagName)&&(t={namespaceURI:M,tagName:`template`});let n=ke(e.tagName),r=ke(t.tagName);return on[e.namespaceURI]?e.namespaceURI===A?xn(n,t,r):e.namespaceURI===rn?Sn(n,t,r):e.namespaceURI===j?Cn(n,t,r):!!(pn===`application/xhtml+xml`&&on[e.namespaceURI]):!1},Tn=function(e){Ee(t.removed,{element:e});try{ne(e).removeChild(e)}catch{if(f(e),!ne(e))throw ze(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},En=function(e,t,n){try{e.removeAttributeNode(t)}catch{try{e.removeAttribute(n)}catch{}}},Dn=function(e){An(e);let t=te(e);if(t){let e=[];Ce(t,t=>{Ee(e,t)}),Ce(e,e=>{try{f(e)}catch{}})}let n=ie(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&En(e,r,i)}},On=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}Ee(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(Ht||Ut)try{Tn(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},kn=function(e){let t=ie(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||D[N(i)]||En(e,r,i)}},An=function(e){let t=[e];for(;t.length>0;){let e=t.pop();oe(e)===T.element&&kn(e);let n=te(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},jn=function(e,t){return It?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Mn=function(e){if(!It)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=oe(e);if(n===T.processingInstruction||n===T.comment&&x(pt,e.data)){try{f(e)}catch{}continue}if(n===T.element){let t=e,n=N(se(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&jn(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=te(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Nn=function(e){let t=null,r=null;if(Vt)e=`<remove></remove>`+e;else{let t=je(e,/^[\r\n\t ]+/);r=t&&t[0]}pn===`application/xhtml+xml`&&M===j&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=g?pe(e):e;if(M===j)try{t=new l().parseFromString(i,pn)}catch{}if(!t||!t.documentElement){t=ve.createDocument(M,`template`,null);try{t.documentElement.innerHTML=an?ce:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),M===j?Se.call(t,Lt?`html`:`body`)[0]:Lt?t.documentElement:a},Pn=function(e){let t=h?h(e):e.ownerDocument;return be.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Fn=function(e){return e=Me(e,Ie,` `),e=Me(e,Le,` `),e=Me(e,Re,` `),e},In=function(e){e.normalize();let t=h?h(e):e.ownerDocument,n=be.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=Fn(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&Ce(i,e=>{Rn(e.content)&&In(e.content)})},Ln=function(e){let t=m?m(e):null;return typeof t!=`string`||N(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==ie(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==ae(e)||e.childNodes!==te(e)},Rn=function(e){if(!ae||typeof e!=`object`||!e)return!1;try{return ae(e)===T.documentFragment}catch{return!1}},zn=function(e){if(!ae||typeof e!=`object`||!e)return!1;try{return typeof ae(e)==`number`}catch{return!1}};function P(e,n,r){e.length!==0&&Ce(e,e=>{e.call(t,n,r,hn)})}let Bn=function(e,t){return!!(It&&e.hasChildNodes()&&!zn(e.firstElementChild)&&x(ft,e.textContent)&&x(ft,e.innerHTML)||It&&e.namespaceURI===j&&_t[t]&&(zn(e.firstElementChild)||typeof e.textContent==`string`&&x(vt[t],e.textContent))||e.nodeType===T.processingInstruction||It&&e.nodeType===T.comment&&x(pt,e.data))},Vn=function(e,t){return e instanceof RegExp?x(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Hn=function(e,t,n){if(!kt[t]&&Jn(t)&&Vn(O.tagNameCheck,t))return!1;if(Jt&&!Zt[t]){let t=ne(e),r=te(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?ee(r[a],!0):r[a];t.insertBefore(i,p(e))}}}return Tn(e),!0},Un=function(e,t,n,r){return e.length===0?t:t===n||t===r?w(t):t},Wn=function(e,t){return e===t||ne(e)!==null?!1:(Yt&&An(e),!0)},Gn=function(e,n){if(P(y.beforeSanitizeElements,e,null),Wn(e,n))return!0;if(Ln(e))return Tn(e),!0;let r=N(se(e));if(E=Un(y.uponSanitizeElement,E,Dt,zt),P(y.uponSanitizeElement,e,{tagName:r,allowedTags:E}),Wn(e,n))return!0;if(Bn(e,r))return Tn(e),!0;if(kt[r]||!(At.tagCheck instanceof Function&&At.tagCheck(r))&&!E[r]){let t=Hn(e,r,n);return t===!1&&P(y.afterSanitizeElements,e,null),t}if(oe(e)===T.element&&!wn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&x(mt,e.innerHTML))return Tn(e),!0;if(Ft&&e.nodeType===T.text){let n=Fn(e.textContent);e.textContent!==n&&(Ee(t.removed,{element:e.cloneNode()}),e.textContent=n)}return P(y.afterSanitizeElements,e,null),!1},Kn=function(e,t,r){if(k[t]||jn(t,e)||Gt&&(t===`id`||t===`name`)&&(r in n||r in gn))return!1;let i=D[t]||At.attributeCheck instanceof Function&&At.attributeCheck(t,e);return Mt&&x(S,t)||jt&&x(Be,t)?!0:i?tn[t]||x(Et,Me(r,gt,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Ne(r,`data:`)===0&&$t[e]||Nt&&!x(Ve,Me(r,gt,``))?!0:!r:Jn(e)&&Vn(O.tagNameCheck,e)&&Vn(O.attributeNameCheck,t,e)||t===`is`&&O.allowCustomizedBuiltInElements&&Vn(O.tagNameCheck,r)},qn=C({},[`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[ke(e)]&&x(Tt,e)},F=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 he(r)}return r},Yn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Ln(e)?Tn(e):Te(t.removed)}catch{On(n,e)}},Xn=function(e){P(y.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Ln(e))return;D=Un(y.uponSanitizeAttribute,D,Ot,Bt);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:D,forceKeepAttr:void 0},r=t.length,i=N(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=N(o),u=c,d=o===`value`?u:Pe(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,P(y.uponSanitizeAttribute,e,n),d=n.attrValue,Kt&&(l===`id`||l===`name`)&&Ne(d,qt)!==0&&(On(o,e,a),d=qt+d),It&&x(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){On(o,e,a);continue}if(l===`attributename`&&je(d,`href`)){On(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){On(o,e,a);continue}if(!Pt&&x(ht,d)){On(o,e,a);continue}if(Ft&&(d=Fn(d)),!Kn(i,l,d)){On(o,e,a);continue}d=F(i,l,s,d),d!==u&&Yn(e,o,s,d)}}P(y.afterSanitizeAttributes,e,null)},I=function(e){let t=null,n=Pn(e);for(P(y.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(P(y.uponSanitizeShadowNode,t,null),Gn(t,e),Xn(t),Rn(t.content)&&I(t.content),oe(t)===T.element){let e=re(t);Rn(e)&&(Zn(e),I(e))}P(y.afterSanitizeShadowDOM,e,null)},Zn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){I(e.shadow);continue}let n=e.node,r=oe(n)===T.element,i=te(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=m?m(n):null;if(typeof e==`string`&&N(e)===`template`){let e=n.content;Rn(e)&&t.push({node:e,shadow:null})}}if(r){let e=re(n);Rn(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(an=!e,an&&(e=`<!-->`),typeof e!=`string`&&!zn(e)&&(e=He(e),typeof e!=`string`))throw ze(`dirty is not a string, aborting`);if(!t.isSupported)return e;Rt?(E=zt,D=Bt):vn(n),(y.uponSanitizeElement.length>0||y.uponSanitizeAttribute.length>0)&&(E=w(E)),y.uponSanitizeAttribute.length>0&&(D=w(D)),t.removed=[];let c=Yt&&typeof e!=`string`&&zn(e);if(c){Mn(e);let t=se(e);if(typeof t==`string`){let n=N(t);if(!E[n]||kt[n])throw Dn(e),ze(`root node is forbidden and cannot be sanitized in-place`)}if(Ln(e))throw Dn(e),ze(`root node is clobbered and cannot be sanitized in-place`);try{Zn(e)}catch(t){throw Dn(e),t}}else if(zn(e))i=Nn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===T.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Zn(a);else{if(!Ht&&!Ft&&!Lt&&e.indexOf(`<`)===-1)return g&&Wt?pe(e):e;if(i=Nn(e),!i)return Ht?null:Wt?ce:``}i&&Vt&&Tn(i.firstChild);let l=c?e:i;try{let e=Pn(l);for(;o=e.nextNode();)Gn(o,l),Xn(o),Rn(o.content)&&I(o.content)}catch(n){throw c&&(Dn(e),Ce(t.removed,e=>{e.element&&An(e.element)})),n}if(c)return Ce(t.removed,e=>{e.element&&An(e.element)}),Ft&&In(e),e;if(Ht){if(Ft&&In(i),Ut)for(s=xe.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(D.shadowroot||D.shadowrootmode)&&(s=Fe.call(r,s,!0)),s}let u=Lt?i.outerHTML:i.innerHTML;return Lt&&E[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&x(ut,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
6
- `+u),Ft&&(u=Fn(u)),g&&Wt?pe(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vn(e),Rt=!0,zt=E,Bt=D},t.clearConfig=function(){hn=null,Rt=!1,zt=null,Bt=null,g=le,ce=``},t.isValidAttribute=function(e,t,n){hn||vn({});let r=N(e),i=N(t);return Kn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&b(y,e)&&Ee(y[e],t)},t.removeHook=function(e,t){if(b(y,e)){if(t!==void 0){let n=we(y[e],t);return n===-1?void 0:De(y[e],n,1)[0]}return Te(y[e])}},t.removeHooks=function(e){b(y,e)&&(y[e]=[])},t.removeAllHooks=function(){y=xt()},t}var Tt=wt();function Et(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var E=Et();function Dt(e){E=e}var D={exec:()=>null};function Ot(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 O(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(k.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var kt=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),k={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:Ot(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Ot(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Ot(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Ot(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Ot(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Ot(e=>RegExp(`^ {0,${e}}>`))},At=/^(?:[ \t]*(?:\n|$))+/,jt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Mt=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Nt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Pt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ft=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,It=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Lt=O(It).replace(/bull/g,Ft).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(),Rt=O(It).replace(/bull/g,Ft).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(),zt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Bt=/^[^\n]+/,Vt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ht=O(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Vt).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ut=O(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Ft).getRegex(),Wt=`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`,Gt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Kt=O(`^ {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`,Gt).replace(`tag`,Wt).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),qt=e=>O(zt).replace(`hr`,Nt).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`,Wt).getRegex(),Jt=qt(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Yt=qt(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Xt={blockquote:O(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Yt).getRegex(),code:jt,def:Ht,fences:Mt,heading:Pt,hr:Nt,html:Kt,lheading:Lt,list:Ut,newline:At,paragraph:Jt,table:D,text:Bt},Zt=O(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Nt).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`,Wt).getRegex(),Qt={...Xt,lheading:Rt,table:Zt,paragraph:O(zt).replace(`hr`,Nt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Zt).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`,Wt).getRegex()},$t={...Xt,html:O(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Gt).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:D,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:O(zt).replace(`hr`,Nt).replace(`heading`,` *#{1,6} *[^
7
- ]`).replace(`lheading`,Lt).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},en=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,tn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,nn=/^( {2,}|\\)\n(?!\s*$)/,rn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,A=/[\p{P}\p{S}]/u,j=/[\s\p{P}\p{S}]/u,M=/[^\s\p{P}\p{S}]/u,an=O(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,j).getRegex(),on=/[\p{Pi}\p{Ps}"']/u,sn=/(?!~)[\p{P}\p{S}]/u,cn=/(?!~)[\s\p{P}\p{S}]/u,ln=/(?:[^\s\p{P}\p{S}]|~)/u,un=O(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,kt?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),dn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,fn=O(dn,`u`).replace(/punct/g,A).getRegex(),pn=O(dn,`u`).replace(/punct/g,sn).getRegex(),mn=O(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,on).replace(/punct/g,A).getRegex(),N=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,hn=O(N,`gu`).replace(/notPunctSpace/g,M).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),gn=O(N,`gu`).replace(/notPunctSpace/g,ln).replace(/punctSpace/g,cn).replace(/punct/g,sn).getRegex(),_n=O(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,M).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),vn=O(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,M).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),yn=O(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,M).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),bn=O(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,A).getRegex(),xn=O(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,M).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),Sn=O(/\\(punct)/,`gu`).replace(/punct/g,A).getRegex(),Cn=O(/^<(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(),wn=O(Gt).replace(`(?:-->|$)`,`-->`).getRegex(),Tn=O(`^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`,wn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),En=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Dn=O(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,En).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),On=O(/^!?\[(label)\]\[(ref)\]/).replace(`label`,En).replace(`ref`,Vt).getRegex(),kn=O(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Vt).getRegex(),An=O(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,On).replace(`nolink`,kn).getRegex(),jn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Mn={_backpedal:D,anyPunctuation:Sn,autolink:Cn,blockSkip:un,br:nn,code:tn,del:D,delLDelim:D,delRDelim:D,emStrongLDelim:fn,emStrongRDelimAst:hn,emStrongRDelimUnd:vn,escape:en,link:Dn,nolink:kn,punctuation:an,reflink:On,reflinkSearch:An,tag:Tn,text:rn,url:D},Nn={...Mn,emStrongLDelim:mn,emStrongRDelimAst:_n,emStrongRDelimUnd:yn,link:O(/^!?\[(label)\]\((.*?)\)/).replace(`label`,En).getRegex(),reflink:O(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,En).getRegex()},Pn={...Mn,emStrongRDelimAst:gn,emStrongLDelim:pn,delLDelim:bn,delRDelim:xn,url:O(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,jn).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:O(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,jn).getRegex()},Fn={...Pn,br:O(nn).replace(`{2,}`,`*`).getRegex(),text:O(Pn.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},In={normal:Xt,gfm:Qt,pedantic:$t},Ln={normal:Mn,gfm:Pn,breaks:Fn,pedantic:Nn},Rn={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},zn=e=>Rn[e];function P(e,t){if(t){if(k.escapeTest.test(e))return e.replace(k.escapeReplace,zn)}else if(k.escapeTestNoEncode.test(e))return e.replace(k.escapeReplaceNoEncode,zn);return e}function Bn(e){try{e=encodeURI(e).replace(k.percentDecode,`%`)}catch{return null}return e}function Vn(e,t){let n=e.replace(k.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(k.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(k.slashPipe,`|`);return n}function Hn(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 Un(e){let t=e.split(`
8
- `),n=t.length-1;for(;n>=0&&k.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
9
- `)}function Wn(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 Gn(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 Kn(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 qn(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 Jn=class{options;rules;lexer;constructor(e){this.options=e||E}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]:Un(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=qn(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=Hn(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Hn(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:Hn(t[0],`
13
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Hn(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=Gn(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),ee=this.rules.other.blockquoteBeginRegex(d);for(;e;){let f=e.split(`
29
- `,1)[0],p;if(l=f,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||ee.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
30
- `+p.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+=f+`
32
- `,e=e.substring(f.length+1),c=p.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=Un(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:Hn(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=Vn(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:Hn(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(Vn(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:Hn(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=Hn(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Wn(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)),Kn(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 Kn(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}}}},F=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||E,this.options.tokenizer=this.options.tokenizer||new Jn,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:k,block:In.normal,inline:Ln.normal};this.options.pedantic?(t.block=In.pedantic,t.inline=Ln.pedantic):this.options.gfm&&(t.block=In.gfm,t.inline=this.options.breaks?Ln.breaks:Ln.gfm),this.tokenizer.rules=t}static get rules(){return{block:In,inline:Ln}}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(k.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(k.tabCharGlobal,` `).replace(k.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)}},Yn=class{options;parser;constructor(e){this.options=e||E}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(k.notSpaceStart)?.[0],i=e.replace(k.endingNewline,``)+`
52
- `;return r?`<pre><code class="language-`+P(r)+`">`+(n?i:P(i,!0))+`</code></pre>
53
- `:`<pre><code>`+(n?i:P(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>${P(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=Bn(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+P(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=Bn(e);if(i===null)return P(n);e=i;let a=`<img src="${e}" alt="${P(n)}"`;return t&&(a+=` title="${P(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:P(e.text)}},Xn=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}},I=class e{options;renderer;textRenderer;constructor(e){this.options=e||E,this.options.renderer=this.options.renderer||new Yn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Xn}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}},Zn=class{options;block;constructor(e){this.options=e||E}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?F.lex:F.lexInline}provideParser(e=this.block){return e?I.parse:I.parseInline}},Qn=new class{defaults=Et();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=I;Renderer=Yn;TextRenderer=Xn;Lexer=F;Tokenizer=Jn;Hooks=Zn;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 Yn(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 Jn(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 Zn;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]=Zn.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Zn.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 F.lex(e,t??this.defaults)}parser(e,t){return I.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?F.lex:F.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?I.parse:I.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?F.lex:F.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?I.parse:I.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>`+P(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function L(e,t){return Qn.parse(e,t)}L.options=L.setOptions=function(e){return Qn.setOptions(e),L.defaults=Qn.defaults,Dt(L.defaults),L},L.getDefaults=Et,L.defaults=E;function $n(...e){return Qn.use(...e),L.defaults=Qn.defaults,Dt(L.defaults),L}L.use=$n,L.walkTokens=function(e,t){return Qn.walkTokens(e,t)},L.parseInline=Qn.parseInline,L.Parser=I,L.parser=I.parse,L.Renderer=Yn,L.TextRenderer=Xn,L.Lexer=F,L.lexer=F.lex,L.Tokenizer=Jn,L.Hooks=Zn,L.parse=L,L.options,L.setOptions,L.walkTokens,L.parseInline,I.parse,F.lex;var R=e=>{let t=document.querySelector(e);if(!t)throw Error(`missing element: ${e}`);return t};function er(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 tr=e=>{let t=er(e);return t===`now`?`just now`:`${t} ago`};function z(e,t,...n){let r=document.createElement(e);return t&&(r.className=t),r.append(...n),r}var nr=e=>e.split(`/`).filter(Boolean).pop()??e,rr=e=>`New session in ${nr(e)}`;function ir(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 ar(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function or(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 sr(e){let t=z(`span`,`help`);return t.innerHTML=Tt.sanitize(L.parseInline(e,{async:!1})),cr(t),t}function cr(e){for(let t of e.querySelectorAll(`a`))(t.getAttribute(`href`)??``).startsWith(`#`)||(t.target=`_blank`,t.rel=`noreferrer`)}async function lr(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 ur(e,t){let n=z(`button`,e,`Copy`);n.title=`Copy to clipboard`;let r;return n.onclick=async e=>{e.stopPropagation(),n.textContent=await lr(t()).then(()=>`Copied`,()=>`Failed`),clearTimeout(r),r=setTimeout(()=>n.textContent=`Copy`,1200)},n}function dr(e,t){let n=document.createElement(`details`);n.className=e;let r=z(`summary`,`flex cursor-pointer select-none items-center gap-1.5`);return r.append(z(`span`,`chev`,`▸`),...t),n.append(r),{el:n,summary:r}}var fr=(e,t=!1)=>pr(e,`${t?`btn btn-primary`:`btn`} text-[12.5px]`),pr=(e,t=``)=>{let n=z(`button`,t,e);return n.type=`button`,n},mr=(...e)=>z(`div`,`flex min-h-10 flex-none flex-wrap items-center gap-2 border-b border-neutral-200 px-4 py-2`,...e);function hr(e,t,n){let r=z(`div`,`inline-flex flex-none items-center gap-0.5 rounded-full bg-neutral-100 p-1`);for(let[i,a]of e){let e=a===t,o=pr(i,`cursor-pointer whitespace-nowrap rounded-full px-3 py-1 text-[12px] transition-colors ${e?`bg-white font-medium text-neutral-800 shadow-xs`:`text-neutral-500 hover:text-neutral-700`}`);o.setAttribute(`aria-pressed`,String(e)),o.onclick=()=>n(a),r.append(o)}return r}function gr(e,t,n){let r=pr(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}function _r(e,t,...n){let r=z(`section`,`rounded-3xl border border-neutral-200 bg-white shadow-sm`),i=z(`div`,`rounded-t-3xl border-b border-neutral-200/70 bg-neutral-50/50 px-5 py-4`);return i.append(z(`h2`,`text-[14px] font-semibold text-neutral-800`,e)),t&&i.append(z(`p`,`mt-1 text-[12px] leading-normal text-neutral-500`,t)),r.append(i,z(`div`,`flex flex-col gap-4 px-5 py-5`,...n)),r}function vr(e,t,n={}){let r=z(`div`,`flex flex-col gap-1.5`),i=z(`div`,`flex items-center gap-1.5`,z(`span`,`field-label`,e));return n.help&&i.append(n.help),r.append(i,t),n.hint&&r.append(z(`span`,`text-[11.5px] leading-snug text-neutral-400`,n.hint)),r}var yr=`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`,br=(e,t,n,r=!1)=>{let i=document.createElement(`input`);return i.className=r?`${yr} font-mono`:yr,i.value=e,i.placeholder=t,i.oninput=()=>n(i.value),i},xr=(e=``,t=`text`)=>{let n=document.createElement(`input`);return n.type=t,n.className=yr,n.value=e,n},Sr=(e,t)=>{let n=document.createElement(`select`);return n.className=`${yr} select`,n.append(...e.map(([e,t])=>new Option(e,t))),n.value=t,n},Cr=(e=``,t=4)=>{let n=document.createElement(`textarea`);return n.className=`${yr} resize-y font-mono`,n.value=e,n.rows=t,n.spellcheck=!1,n};function wr(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=z(`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`),s=z(`label`,`flex cursor-pointer gap-2.5 ${e?`items-start`:`items-center`}`);if(s.append(a,o),e){let n=z(`span`,`flex items-center gap-1.5`,z(`span`,`text-[13px] text-neutral-700`,e));i&&n.append(i);let r=z(`span`,`flex min-w-0 flex-col`,n);t&&r.append(z(`span`,`text-[11.5px] leading-snug text-neutral-400`,t)),s.append(r)}return s}var Tr={idle:`text-neutral-400`,saving:`text-neutral-400`,saved:`text-green-700`,failed:`text-red-600`};function Er(e,t,n){e.className=`text-[11.5px] ${Tr[t]}`,e.textContent=n}var Dr=(e,t,n)=>z(`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?[z(`span`,`inline-block h-1.5 w-1.5 flex-none rounded-full ${n}`)]:[],e),Or=e=>z(`p`,`rounded-lg border border-dashed border-neutral-200 px-3 py-4 text-center text-[12.5px] text-neutral-400`,e);function kr(e,t,n=`left`){let r=z(`span`,`group relative inline-flex`),i=pr(`?`,`flex h-4 w-4 cursor-help items-center justify-center rounded-full border border-neutral-300 text-[9px] font-bold text-neutral-400 transition-colors group-hover:border-indigo-400 group-hover:text-indigo-500`),a=z(`span`,`absolute ${n===`right`?`right-0`:`left-0`} top-full z-20 hidden w-[min(27rem,calc(100vw-3rem))] pt-1.5 group-hover:block`),o=z(`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`);o.append(z(`span`,`text-[12.5px] font-semibold text-neutral-800`,e));let s=z(`ol`,`flex list-decimal flex-col gap-1.5 pl-4`);for(let e of t){let t=z(`li`,`marker:text-neutral-400`);t.append(typeof e==`string`?sr(e):e),s.append(t)}return o.append(s),a.append(o),i.onclick=()=>{let e=a.classList.contains(`hidden`);a.classList.toggle(`hidden`,!e),a.classList.toggle(`block`,e),i.classList.toggle(`border-indigo-400`,e),i.classList.toggle(`text-indigo-500`,e)},r.append(i,a),r}var Ar=(e,t)=>z(`span`,`flex flex-col gap-1`,sr(e),t),jr=e=>`[${e.split(`/`).pop()??`file`}](file://${encodeURI(e).replace(/\(/g,`%28`).replace(/\)/g,`%29`)})`,Mr=/^ {0,3}(`{3,}|~{3,})/;function Nr(e){let t=[],n,r=0;for(let i of e.split(`
71
- `)){let e=Mr.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 Pr(e,t,n){let r=Nr(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 Fr=/^\[[^\]\n]*\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)$/;function Ir(e){let t=e.split(`
72
- `),n=t.length;for(;n>0&&Fr.test(t[n-1].trim());)n--;let r=t.slice(n).map(e=>{let t=Fr.exec(e.trim())[1];try{return decodeURIComponent(t)}catch{return t}});return{text:t.slice(0,n).join(`
73
- `).trimEnd(),paths:r}}var Lr=`modulepreload`,Rr=function(e){return`/`+e},zr={},Br=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=Rr(t,n),t=s(t),t in zr)return;zr[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`:Lr,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)})},Vr,Hr;function Ur(){return Hr??=Br(()=>import(`./hljs-tWqyD59G.js`).then(e=>Vr=e.default,e=>{console.warn(`highlighting unavailable — code stays plain text`,e)}),[]),Hr}async function Wr(e){let t=await Ur();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 Gr={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 Kr(e){let t=await Ur(),n=e.split(`.`).pop()?.toLowerCase()??``,r=Gr[n]??n;return t?.getLanguage(r)?r:null}function qr(e,t){let n=document.createElement(`span`);return Vr&&t&&e.length<=500?n.innerHTML=Vr.highlight(e,{language:t}).value:n.textContent=e,n}var Jr=2e4;function Yr(e){let t=e.split(`
74
- `);return t.at(-1)===``&&t.pop(),t.map((e,t)=>({nums:[t+1],text:e,tone:``}))}function Xr(e,t){let n=e.length<=Jr?t:null,r=Math.max(2,...e.map(e=>e.nums.reduce((e,t)=>Math.max(e,String(t).length),0))),i=z(`div`,`py-2 font-mono text-[12px] leading-[1.5]`);for(let t of e){let e=z(`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=z(`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)}e.append(Zr(t,n)),i.append(e)}return i}function Zr(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=qr(e.text,t);return r.className=n,r}let[r,i]=e.mark,a=qr(e.text.slice(r,i),t);return a.className=`rounded-xs ${e.tone===`add`?`bg-emerald-200/80`:`bg-red-200/70`}`,z(`span`,n,qr(e.text.slice(0,r),t),a,qr(e.text.slice(i),t))}var Qr=R(`#image-dialog`),$r=R(`#image-stage`),ei=R(`#image-full`),ti=R(`#image-prev`),ni=R(`#image-next`),ri=[],ii=0;function ai(e){ri.length<2||(ii=(ii+e+ri.length)%ri.length,ci(!1),ei.src=ri[ii])}var oi=2.5,si=()=>$r.dataset.zoom!==void 0;function ci(e,t){if(!e){delete $r.dataset.zoom,ei.style.cssText=``;return}let n=ei.getBoundingClientRect(),r=$r.getBoundingClientRect(),i=t?(t.x-n.left)/n.width:.5,a=t?(t.y-n.top)/n.height:.5,o=n.width*oi,s=n.height*oi;$r.dataset.zoom=``,ei.style.width=`${String(o)}px`,ei.style.height=`${String(s)}px`,$r.scrollLeft=i*o-r.width/2,$r.scrollTop=a*s-r.height/2}function li(e){let t=e.closest(`[data-gallery]`);ri=t?[...t.querySelectorAll(`img.thumb`)].map(e=>e.src):[e.src],ii=Math.max(0,ri.indexOf(e.src)),ei.src=e.src;let n=ri.length<2?`none`:`flex`;ti.style.display=n,ni.style.display=n,Qr.showModal()}var ui=260,di;$r.onclick=e=>{if(di!==void 0){clearTimeout(di),di=void 0,ci(!si(),{x:e.clientX,y:e.clientY});return}di=window.setTimeout(()=>{di=void 0,si()?ci(!1):Qr.close()},ui)},Qr.onclose=()=>{clearTimeout(di),di=void 0,ci(!1)},ti.onclick=()=>ai(-1),ni.onclick=()=>ai(1),Qr.onkeydown=e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),ai(e.key===`ArrowLeft`?-1:1))};function fi(e){let t=e.querySelector(`:scope > .thumbs`);if(t)return t;let n=z(`div`,`thumbs`);return e.append(n),n}function pi(e){let t=document.createElement(`img`);return t.src=e,t.loading=`lazy`,t.className=`thumb`,t.onclick=()=>li(t),t}var mi=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`bmp`]),hi=524288,gi=R(`#file-dialog`),_i=R(`#file-name`),vi=R(`#file-text`),yi=R(`#file-download`);R(`#file-close`).onclick=()=>gi.close();var bi=e=>e.split(`.`).pop()?.toLowerCase()??``,xi=(e,t,n=!1)=>`/api/sessions/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}${n?`&download=1`:``}`;function Si(e,t){return Pr(e,/\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)/g,e=>{let n=e[1];try{n=decodeURIComponent(n)}catch{}return`](${xi(t,n)})`})}var Ci=e=>/^\/api\/sessions\/[^/]+\/files\?/.test(e);function wi(e,t){let n=nr(t)||`file`,r=xi(e,t);return mi.has(bi(n))?ki(r,n):Ai(r,n)}function Ti(e){return new URLSearchParams(e.slice(e.indexOf(`?`)+1)).get(`path`)??``}var Ei=(e,t=`text-neutral-500`)=>z(`div`,`px-3 py-2 text-[12.5px] ${t}`,e),Di=0;async function Oi(e,t){let n=++Di;_i.textContent=t,yi.href=`${e}&download=1`,vi.replaceChildren(Ei(`loading…`)),gi.showModal();let r=e=>{n===Di&&vi.replaceChildren(e)},i;try{i=await fetch(e)}catch(e){return r(Ei(`failed to load: ${String(e)}`,`text-red-600`))}if(!i.ok)return r(Ei(await h(i,`failed to load`),`text-red-600`));let a=i.headers.get(`content-type`)??``;if(!a.startsWith(`text/`)&&!a.startsWith(`image/svg+xml`))return r(Ei(`Binary file — use Download.`));let o=await i.text(),s=o.length>hi?`${o.slice(0,hi)}\n…`:o,c=await Kr(t);r(Xr(Yr(s),c))}function ki(e,t){let n=pi(e);return n.alt=t,n}function Ai(e,t){let n=bi(t),r=z(`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=z(`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=z(`span`,`min-w-0 truncate text-[13px] font-medium text-neutral-800`,t),o=z(`span`,`ml-1 flex flex-none items-center gap-0.5`),s=z(`button`,`icon-btn h-6 w-6 text-[13px]`,`◉`);s.title=`Preview`,s.onclick=r=>{r.preventDefault(),n===`pdf`?window.open(e,`_blank`,`noopener`):Oi(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.textContent=`↓`,o.append(c),r.append(i,a,o),r}function ji(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=z(`div`,`thumbs`);r.append(...t),n.after(r)}}function Mi(e){let t=[];for(let n of e.querySelectorAll(`img`)){let e=n.getAttribute(`src`)??``;if(!Ci(e))continue;let r=ki(e,nr(Ti(e)));n.replaceWith(r),t.push(r)}for(let n of e.querySelectorAll(`a`)){let e=n.getAttribute(`href`)??``;if(!Ci(e))continue;let r=nr(Ti(e))||n.textContent?.trim()||`file`,i=mi.has(bi(r))?ki(e,r):Ai(e,r);n.replaceWith(i),t.push(i)}t.length&&ji(t)}var Ni=null,Pi=`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 Fi(){Ni=null}function Ii(e,t,n){if(Ni?.remove(),Ni=null,!t.length)return;let r=z(`div`,`mt-1.5 flex flex-wrap gap-1.5`);for(let e of t){let t=z(`button`,Pi,e);t.type=`button`,t.onclick=()=>{Ni===r&&(Ni=null),r.remove(),n(e)},r.append(t)}e.append(r),Ni=r}var Li=8e3,Ri=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],zi=e=>typeof e==`string`&&Ri.includes(e),Bi,Vi;function Hi(e,t){Bi=e,Vi=t}var Ui=e=>e.slice(0,8),Wi=e=>`system-card group relative mt-1.5 rounded-xl px-4 py-2.5 ${e}`,Gi=e=>z(`div`,Wi(e));function Ki(e){let t=e.length>240||e.split(`
75
- `).length>4,n=[`max-h-[4lh]`,`overflow-hidden`],r=z(`div`,`mt-1 whitespace-pre-wrap break-words text-[12.5px] leading-normal text-neutral-500 ${n.join(` `)}`,e),i=z(`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 qi(e){let t=z(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-neutral-500`,e.glyph);t.append(z(`span`,`run-label flex-none font-semibold ${e.labelCls}`,e.label)),e.taskName&&t.append(z(`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=z(`div`,`ml-auto flex min-w-0 flex-wrap items-center gap-x-2 font-mono`);if(e.note&&n.append(z(`span`,`flex-none`,e.note)),e.model){let t=z(`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=z(`span`,`flex-none`,e.thinking);t.title=`Reasoning effort`,n.append(t)}let r=z(`button`,`flex-none hover:underline`,Ui(e.runId));if(r.title=`Run ${e.runId}`,r.onclick=()=>Bi.showRun(e.runId),n.append(r),e.sessionId&&e.sessionId!==`console`){let t=e.sessionId,r=z(`button`,`flex-none text-indigo-600 hover:underline`,Ui(t));r.title=`Open session ${t}`,r.onclick=()=>Bi.select(t),n.append(r)}return t.append(n),t}var Ji={queued:{edge:`border-l-amber-400`,label:`text-amber-700`,glyph:``},running:{edge:`border-l-fuchsia-500`,label:`text-fuchsia-700`,glyph:``},succeeded:{edge:`border-l-green-500`,label:`text-green-700`,glyph:`✓`},failed:{edge:`border-l-red-500`,label:`text-red-600`,glyph:`✕`},cancelled:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:`·`},interrupted:{edge:`border-l-amber-400`,label:`text-amber-700`,glyph:`⏸`},skipped:{edge:`border-l-neutral-300`,label:`text-neutral-500`,glyph:`·`}},Yi=e=>Ji[e].glyph?z(`span`,`w-3 flex-none text-center font-bold ${Ji[e].label}`,Ji[e].glyph):z(`span`,`spinner ${Ji[e].label}`),Xi=new Map,Zi=new WeakMap;async function Qi(e,t){let n=await g(e,`POST`,t);n&&Vi.append(`error`,n)}function $i(e){for(let[e,t]of Xi)t.isConnected||Xi.delete(e);let t=Xi.get(e.runId);t||(t=Gi(Ji[e.state].edge),t.dataset.kind=`background-run`,Vi.el.append(t),Xi.set(e.runId,t)),t.className=Wi(Ji[e.state].edge);let n=e.state===`queued`||e.state===`running`,r=`/api/task-runs/${e.runId}`,i=Math.max(0,Math.round(((e.finishedAt??Date.now())-(e.startedAt??e.queuedAt))/1e3)),a=qi({glyph:Yi(e.state),label:`run · ${e.state}`,labelCls:Ji[e.state].label,taskName:e.taskName,note:`${e.sessionMode??`task`} · depth ${String(e.depth)} · ${String(i)}s`,runId:e.runId,sessionId:e.targetSessionId}),o=z(`div`,`flex flex-none items-center gap-2 text-[11px] font-semibold text-neutral-700`);if(n){let t=z(`button`,`hover:underline`,`Stop`);t.onclick=()=>{window.confirm(`Stop "${e.taskName}"?`)&&Qi(`${r}/cancel`,`could not stop the run`)},o.append(t)}o.childElementCount&&a.append(o);let s=Zi.get(t);!s&&e.prompt!==null&&(s=Ki(e.prompt),Zi.set(t,s)),t.replaceChildren(a,...s??[]),Vi.scroll()}var B=null,ea=null,ta=null,na=!1;function ra(){if(!ea)return;ea.text=ea.text.slice(-4e3),ea.pre.textContent=ea.text;let e=ea.text.split(`
76
- `).filter(Boolean).pop()??`thinking…`,t=ea.summary.lastElementChild;t.textContent=e.length>90?`…`+e.slice(-90):e}function ia(){if(ta){na=!0;return}na=!1,ra(),ta=setTimeout(()=>{ta=null,na&&ia()},80)}function aa(){ta&&clearTimeout(ta),ta=null,na&&ra(),na=!1}var oa=new WeakMap,sa=e=>{let t=oa.get(e)??[];return oa.set(e,t),t};function ca(){B&&!B.toolRows.size&&Sa(`done`)}var la=null;function ua(){B=null,la=null,ea=null,aa(),Xi.clear()}function da(){let e=la;return!e||B?.el===e||(la=null,e!==Vi.el.lastElementChild)?null:(e.remove(),e.dataset.adopted=`1`,pa(e,e.dataset.status),e)}var fa={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 pa(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 ${fa[t]}`}var ma={failed:`✕`,interrupted:`⏸`};function ha(e){return e===`running`?z(`span`,`spinner`):e===`done`?z(`span`,`hidden`):z(`span`,`flex-none text-[12px] font-bold`,ma[e])}function ga(e){if(B)return B;let t=ha(`running`),n=z(`span`,`min-w-0 truncate`,`working…`),{el:r}=dr(``,[t,n]);r.dataset.kind=`activity`,pa(r,`running`);let i=z(`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),ya(r,i),Vi.el.append(r),la=r,Vi.scroll(),B={el:r,statusIcon:t,headline:n,rowsEl:i,toolRows:new Map,thinking:null,steps:0,failedSteps:0,startTs:e,sawError:!1},B}function _a(e,t=``){let n=ga(e);aa(),n.thinking=null;let r=z(`div`,`whitespace-pre-wrap break-words text-[13px] text-neutral-600`,t);r.dataset.raw=t;let i=z(`div`,`rounded-lg bg-neutral-50 px-2 py-1.5`,z(`span`,`text-[10px] font-medium text-neutral-400`,`Update`),r);return i.dataset.kind=`progress`,n.rowsEl.append(i),xa(n,`running`,`writing…`),ba(n),Vi.scroll(),r}function va(e){let t=e.closest(`details[data-kind="activity"]`);e.parentElement?.remove(),t&&!t.lastElementChild?.childElementCount&&(B?.el===t&&(B=null),la===t&&(la=null),t.remove())}function ya(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 ba(e){Vi.bulk()||!e.el.open||!e.rowsEl.dataset.follow||(e.rowsEl.scrollTop=e.rowsEl.scrollHeight)}function xa(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}`,pa(e.el,t);let a=ha(t);e.statusIcon.replaceWith(a),e.statusIcon=a}function Sa(e){if(!B)return;aa();for(let{statusEl:e}of B.toolRows.values())e.textContent===`running…`&&(e.textContent=`interrupted`);let t=B.steps>0&&B.failedSteps===B.steps;xa(B,(B.sawError||t)&&e===`done`?`failed`:e===`done`&&B.toolRows.size?`interrupted`:e),B=null}function Ca(){B&&(B.sawError=!0)}function wa(e){let t=e.slice(0,400).replace(/\s+/g,` `);return t.length>100?t.slice(0,100)+`…`:t}function Ta(e,t,n,r){let i=ga(e);i.steps+=1,aa(),i.thinking=null;let a=JSON.stringify(r,null,2)??``,o=z(`span`,`ml-auto flex-none text-neutral-400`,`running…`),s=z(`span`,`min-w-0 truncate text-neutral-500`,wa(a)),{el:c}=dr(`rounded-md px-1 py-0.5 font-mono text-[12.5px] hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[z(`span`,`flex-none font-semibold`,n),s,o]),l=z(`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=z(`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(z(`div`,`mt-1 flex flex-col gap-1 pl-4`,l,u)),sa(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),ba(i),xa(i,`running`,n),Vi.scroll()}function Ea(e,t,n){let r=B;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,Li)+`…`:n,i.outputPre.classList.remove(`hidden`)),t&&(r.failedSteps+=1)),xa(r,`running`)}function Da(e,t){let n=ga(e);if(!n.thinking){aa();let{el:e,summary:t}=dr(`rounded-md px-1 py-0.5 text-[12.5px] italic text-neutral-500 hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[z(`span`,`min-w-0 truncate`,`thinking…`)]),r=z(`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:``},ea=n.thinking,ba(n),xa(n,`running`,`thinking…`)}n.thinking.text+=t,ia()}var Oa=0;function ka(e,t=0,n=!1,r){let i=Date.now()-t,a=ga(i).el;for(let t of e){if(t.kind===`progress`){_a(i,t.text??``);continue}if(t.kind===`thinking`){Da(i,t.text??``);continue}let e=t.id??`replay-${++Oa}`;Ta(i,e,t.toolName??``,t.args),t.done&&Ea(e,t.isError??!1,t.output??``)}r!==void 0&&e.some(e=>e.kind===`tool`&&e.args===void 0)&&Aa(a,r),!n&&Sa(e.some(e=>e.kind===`tool`&&!e.done)?`interrupted`:`done`)}function Aa(e,t){let n=()=>{e.open&&(e.removeEventListener(`toggle`,n),ja(e,t))};e.addEventListener(`toggle`,n)}async function ja(e,t){let n=Bi.sessionId(),r=sa(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 oe(`/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=wa(r),n.output&&(t.outputPre.textContent=n.output,t.outputPre.classList.remove(`hidden`))}}var Ma,V=R(`#turns`);function Na(e){Ma=e,Hi(e,{el:V,append:H,scroll:Ba,bulk:()=>Pa})}var Pa=!1,Fa=()=>V.scrollHeight-V.scrollTop-V.clientHeight<80,Ia=!0;V.addEventListener(`scroll`,()=>{Pa||(Ia=Fa())},{passive:!0});var La=0;function Ra(){!Ia||Pa||La||(La=requestAnimationFrame(()=>{La=0,Ia&&!Pa&&(V.scrollTop=V.scrollHeight)}))}new ResizeObserver(Ra).observe(V),V.addEventListener(`load`,Ra,!0),new MutationObserver(Ra).observe(V,{childList:!0,subtree:!0,characterData:!0});function za(){Fa()&&(Ia=!0)}function Ba(e=!1){Pa||(e&&(Ia=!0),Ia&&(V.scrollTop=V.scrollHeight))}var Va=500,Ha=0,Ua=0,Wa=null;function Ga(){for(;V.childElementCount>Va;){let e=V.firstElementChild;e.remove(),e!==Wa&&(e.dataset.kind===`user`&&Ha++,Ua++)}Ua&&(Wa||(Wa=z(`div`,`px-5 py-2 text-center text-[11.5px] italic text-neutral-400`),Wa.dataset.kind=`trim`),Wa.textContent=`${Ua} earlier row${Ua===1?``:`s`} not shown — still in the transcript, not on this screen`,V.firstElementChild!==Wa&&V.prepend(Wa))}var Ka={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 H(e,t,n=!1,r){ca();let i=e===`assistant`?da():null,a=Ka[e],o=e===`user`&&r!==void 0&&so(r)?r:void 0,s=o===void 0&&V.lastElementChild?.dataset.kind===e,c=z(`div`,`group relative ${a.row}`);c.dataset.kind=e,s&&(c.dataset.grouped=``),Pa||(c.dataset.enter=``);let l=e===`user`?Ir(t):null,u=l?.text??t,d=e===`user`?te(u):null,ee=d?.id||d?.when?d:null,f=ee?.id&&ee.id!==`web`?ee:null,p=z(`div`,`whitespace-pre-wrap break-words ${a.body}`,ee?.text??u);(l?.paths.length||ee)&&(p.dataset.raw=t),n&&po(p,t),r!==void 0&&lo(c,r),f&&c.append(qa(f)),c.append(p);let ne=Ma.sessionId();if(l?.paths.length&&ne){let e=fi(c);for(let t of l.paths)e.append(wi(ne,t))}if(e===`user`){Za?.(),V.querySelector(`.message-edit`)?.remove();let e=z(`button`,`message-edit absolute right-full top-1 flex h-8 w-8 items-center justify-center rounded-full`);e.title=`Edit latest message — resends it and replaces the reply`,e.setAttribute(`type`,`button`),e.setAttribute(`aria-label`,`Edit message`),e.innerHTML=`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="h-3.5 w-3.5"><path d="m10.7 2.3 3 3L6 13H3v-3l7.7-7.7zM9.3 3.7l3 3"/></svg>`,e.onclick=()=>$a(c,p),c.append(e)}if(o!==void 0){let e=z(`div`,`my-3 text-center text-[11px] text-neutral-400`);e.dataset.kind=`time`,e.dataset.at=String(o),io(e),ro??=setInterval(ao,6e4),e.title=ir(o),V.append(e)}return i&&V.append(i),V.append(c),Ga(),Ba(),p}function qa(e){let t=z(`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=z(`span`,`font-semibold text-inherit`,n);e?.id&&(r.title=e.id),t.append(r)}return t}var Ja={"task-delegation":[`↗`,`delegated`,`text-cyan-700`],"task-callback":[`↩`,`callback`,`text-cyan-700`],decision:[`?`,`decision needed`,`text-amber-700`]};function Ya(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 Xa(e,t){let n=t.kind===`task-message`?t.messageKind:t.kind,[r,i,a]=Ja[n]??[`↩`,n.replace(`_`,` `),`text-cyan-700`];ca();let o=t.kind===`task-callback`?t.state:void 0,s=Gi(o?Ji[o].edge:n===`decision`?`border-l-amber-400`:`border-l-cyan-500`);s.dataset.kind=`system`;let[c,l]=Ya(e),u=qi({glyph:o?Yi(o):z(`span`,`w-3 flex-none text-center font-bold ${a}`,r),label:o?`${i} \u00b7 ${o}`:i,labelCls:o?Ji[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(...Ki(l)),V.append(s),Ga(),Ba()}var Za=null,Qa=e=>e.isConnected&&V.querySelector(`.message-edit`)?.parentElement===e;function $a(e,t){if(!Qa(e))return;if(Ma.sessionState()!==`idle`){H(`error`,`can't edit while streaming — stop the turn first`);return}if(e.querySelector(`textarea`))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 latest message`);let r=fr(`Send edit`,!0),i=fr(`Cancel`),a=z(`div`,`message-editor`,n,z(`div`,`mt-2 flex flex-wrap justify-end gap-2`,i,r)),o=()=>{n.style.height=`auto`,n.style.height=`${Math.min(n.scrollHeight,192)}px`,r.disabled=!n.value.trim()};n.oninput=o,e.dataset.editing=``,t.classList.add(`hidden`),t.after(a),o(),n.focus(),n.setSelectionRange(n.value.length,n.value.length);let s=()=>{a.remove(),t.classList.remove(`hidden`),delete e.dataset.editing,Za=null};Za=s,i.onclick=()=>{s(),e.querySelector(`.message-edit`)?.focus({preventScroll:!0})},r.onclick=()=>{let t=n.value.trim();t&&eo(e,t)},a.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 eo(e,t){let n=Ma.sessionId();if(!n||!Qa(e))return;if(Ma.sessionState()!==`idle`){H(`error`,`can't edit while streaming — stop the turn first`);return}Za?.();let r=[...V.querySelectorAll(`[data-kind="user"]`)],i=Ha+r.indexOf(e),a=r[r.length-2]?.dataset.at;no=a===void 0?null:Number(a);let o=e.previousElementSibling;for(o?.dataset.kind===`time`&&o.remove();e.nextElementSibling;)e.nextElementSibling.remove();e.remove(),Ma.ownTurn(t),H(`user`,t,!1,Date.now()),Ba(!0);let s=await m(`/api/sessions/${n}/turns/${i}/edit`,{text:t});if(!s.ok){let e=await h(s,`edit failed`);await Ma.reload(n),H(`error`,e)}}var to=6e5,no=null,ro;function io(e){let t=Number(e.dataset.at);e.textContent=`${ir(t).slice(0,16)} · ${tr(t)}`}function ao(){let e=V.querySelectorAll(`[data-kind="time"]`);for(let t of e)io(t);e.length||(clearInterval(ro),ro=void 0)}var oo=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString();function so(e){let t=no;return no=e,t===null||e-t>=to||!oo(t,e)}function co(e,t){t&&lo(e.parentElement??e,t.completedAt)}function lo(e,t){e.dataset.at=String(t),e.dataset.time=ir(t).slice(11)}function uo(e){for(let t of e.querySelectorAll(`pre`)){let e=t.querySelector(`code`);if(!e)continue;let n=z(`div`,`group/code relative`);t.replaceWith(n),n.append(t,ur(`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 fo(e){let t=Ma.sessionId(),n=z(`div`,``);return n.innerHTML=Tt.sanitize(L.parse(t?Si(e,t):e,{async:!1})),cr(n),n}function po(e,t){e.replaceChildren(...fo(t).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`),Wr(e),uo(e),Mi(e)}function mo(e,t,r,i=!1){let{text:a,suggestions:o}=u(t);return n({text:a,suggestions:o})?ho(e,l(t)):po(e,a),i&&Ii(e.parentElement??e,o,e=>Ma.send(`auto`,e)),co(e,r),e}function ho(e,t){e.classList.remove(`md`,`whitespace-pre-wrap`),e.replaceChildren(z(`span`,`text-[12.5px] italic text-neutral-400`,t?`Stayed silent — ${t}`:`Stayed silent.`))}var go=(e,t,n=!1)=>mo(H(`assistant`,``),e,t,n),U=null,_o=null,vo=!1,yo=0,bo=0;function xo(e){let t=e.dataset.raw??``;for(;e.childNodes.length>bo;)e.lastChild.remove();let n=f(t,yo);n>yo&&(e.append(...fo(d(t.slice(yo,n))).childNodes),yo=n,bo=e.childNodes.length),e.append(...fo(u(t.slice(yo)).text).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`)}function So(){if(_o){vo=!0;return}vo=!1,U&&(xo(U),Ba()),_o=setTimeout(()=>{_o=null,vo&&So()},80)}function Co(){_o&&clearTimeout(_o),_o=null,vo=!1}function wo(e){U||(U=_a(Date.now()),yo=0,bo=0),U.dataset.raw=(U.dataset.raw??``)+e,So()}function To(){if(!U)return;let e=U;U=null,Co(),e.classList.remove(`md`),e.classList.add(`whitespace-pre-wrap`),e.textContent=e.dataset.raw??``}function Eo(){if(!U)return;let e=U.dataset.raw;return va(U),U=null,Co(),e}function Do(e,t){e===``&&To();let n=Eo();Sa(`done`);let r=e??n;r&&go(r,t,!0)}function Oo(){let e=Eo();Sa(`interrupted`),e&&go(e)}function ko(){Za?.(),clearInterval(ro),ro=void 0,V.replaceChildren(),Ha=0,Ua=0,Wa=null,no=null,U=null,Co(),ua(),Fi()}function Ao(e){if(!e){V.querySelector(`[data-kind="loading"]`)?.remove();return}let t=z(`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(z(`div`,`skeleton h-3.5 ${e}`));V.append(t)}function jo(e,t,n){Ao(!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&&($i(e),r.delete(t))}},o=e.reduce((e,t,n)=>t.role===`assistant`?n:e,-1);Pa=!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&&(ka(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]),Xa(r.text,r.origin);continue}s?wo(r.text):r.role===`assistant`?go(r.text,r.meta,t===`idle`&&n===o):H(r.role,r.text,!1,r.at)}}for(let e of r.values())$i(e)}finally{Pa=!1}Ba(!0)}var Mo=window.fetch.bind(window),No=20,Po=6e4,Fo=[],Io=new Map,Lo=e=>e instanceof Error?e.stack??`${e.name}: ${e.message}`:void 0;function Ro(e,t){let n=t===void 0?e:`${e}: ${String(t)}`,r=Date.now();return r-(Io.get(n)??-6e4)<Po||(Io.size>100&&Io.clear(),Io.set(n,r),Fo=Fo.filter(e=>r-e<6e4),Fo.length>=No)?null:(Fo.push(r),Mo(`/api/client-log`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:n,stack:Lo(t),view:location.hash||`/`}),keepalive:!0}).catch(()=>{}),H(`error`,n))}function zo(){window.__pierReporting=!0,window.addEventListener(`error`,e=>{Ro(`script error: ${e.message}`,e.error)}),window.addEventListener(`unhandledrejection`,e=>{Ro(`unhandled rejection`,e.reason)})}var Bo=window.fetch.bind(window),Vo=()=>{location.assign(`/login?next=${encodeURIComponent(location.pathname+location.hash)}`)};function Ho(){window.fetch=async(...e)=>{let t=await Bo(...e);return t.status===401&&Vo(),t}}function Uo(e,t){if(e.readyState!==EventSource.CLOSED)return;let n=()=>{let e=Ro(`${t} stream disconnected`);if(!e)return;let n=fr(`Reload`);n.classList.add(`ml-2`,`align-middle`),n.onclick=()=>location.reload(),e.append(` `,n)};Bo(`/api/sessions`).then(e=>e.status===401?Vo():n(),n)}var Wo=/Mac|iP(?:hone|ad|od)/.test(navigator.userAgent),Go=Wo?`⌘`:`Ctrl+`,Ko=Wo?`⇧`:`Shift+`,qo=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 Jo(e){let{key:t,shift:n,meta:r}=qo(e);return`${r?`⌘`:Go}${n?Ko:``}${t.toUpperCase()}`}var Yo=`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 Xo(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=z(`div`,Yo,t,z(`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 Zo(e,t,n,r,i){Xo(e,n,Jo(t)),ts(t,r,i)}function Qo(e,t,n,r){Xo(e,t,`Esc`),document.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.isComposing||e.defaultPrevented||document.querySelector(`dialog[open]`)||!r()||(e.preventDefault(),n())})}var $o=`input, textarea, select, [contenteditable]`;function es(e,t,n,r,i){Xo(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?.($o)||document.querySelector(`dialog[open]`)||!i()||(e.preventDefault(),r())})}function ts(e,t,n){let{key:r,shift:i,meta:a}=qo(e);document.addEventListener(`keydown`,e=>{!e.key||e.key.toLowerCase()!==r||e.altKey||e.shiftKey!==i||(a?!e.metaKey:!e.metaKey&&!e.ctrlKey)||n?.()||(e.preventDefault(),e.stopPropagation(),t())},!0)}var W,ns=R(`#composer`),G=R(`#input`),rs=R(`#send`),is=R(`#send-plane`),as=R(`#send-queue`),os=R(`#stop`),ss=R(`#queue-panel`),cs=R(`#queue-rows`),ls=R(`#queue-label`),us=z(`div`,`hidden max-h-48 overflow-y-auto border-t border-neutral-200 px-3 py-1.5 text-[13px]`);ss.after(us);var ds=R(`#image-strip`),fs=R(`#attach-input`),ps=!1,ms=0,hs=new Set,gs=[],_s=[];function vs(){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 ys(){G.focus()}function bs(e){let t=_s.indexOf(e);return t<0?!1:(_s.splice(t,1),!0)}function xs(e){_s.push(e)}function Ss(){_s=[]}function Cs(){let e=W.sessionState()===`streaming`,t=W.sessionId()!==null,n=W.starting();rs.disabled=!t,rs.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`}`,rs.title=t?e?`Queue — delivered when the turn ends`:`Send`:n?`Starting the session…`:`No session`,G.placeholder=n?`Starting the session…`:`Message…`,is.classList.toggle(`hidden`,e),as.classList.toggle(`hidden`,!e),os.classList.toggle(`hidden`,!e),os.classList.toggle(`flex`,e)}function ws(){let e=W.chatVisible()&&ps;ss.classList.toggle(`hidden`,!e),ss.classList.toggle(`flex`,e),us.classList.toggle(`hidden`,!W.chatVisible()||!us.childElementCount)}function Ts(e,t=!1){let n=W.sessionId();if(us.replaceChildren(...e.map(e=>{let t=z(`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(z(`summary`,`cursor-pointer break-words text-amber-700`,`Queue recovery: ${r}${i} (in memory)`));for(let n of[...e.steering,...e.followUp]){let e=z(`div`,`flex items-start gap-2 border-t border-neutral-100 py-1`);e.append(z(`span`,`min-w-0 flex-1 whitespace-pre-wrap break-words`,n),ur(`flex-none cursor-pointer px-1 text-neutral-500 hover:text-neutral-800`,()=>n)),t.append(e)}e.error&&t.append(z(`div`,`break-words text-red-600`,e.error));let a=z(`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 m(`/api/sessions/${n}/queue/recovery/${e.id}/ack`,{}),r=t.ok?null:await h(t,`Could not acknowledge queue recovery`);W.sessionId()===n&&(r===null?await W.reload(n):H(`error`,r))},t.append(a),t})),t){let e=z(`div`,`flex flex-wrap items-center gap-x-2 py-1 text-amber-700`,`Automatic queue paused: acceptance unknown (in memory)`),t=z(`button`,`cursor-pointer underline`,`Recall queue`);t.title=`Clear the live queue and return its messages to the composer`,t.onclick=()=>void zs(),e.append(t),us.prepend(e)}ws()}function Es(e,t){++ms;let n=[...e.map(e=>({mode:`steer`,text:e})),...t.map(e=>({mode:`queued`,text:e}))];ps=n.length>0,ls.textContent=n.length>1?`Queued · ${n.length}`:`Queued`,ws(),cs.replaceChildren(...n.map(e=>{let t=z(`li`,`flex items-start gap-2 text-[13px] leading-[18px]`);return e.mode===`steer`&&t.append(z(`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(z(`span`,`min-w-0 whitespace-pre-wrap break-words text-neutral-700`,e.text)),t}))}var Ds=8;function Os(){ds.classList.toggle(`hidden`,gs.length===0),ds.classList.toggle(`flex`,gs.length>0),ds.replaceChildren(...gs.map((e,t)=>{let n=e.mimeType.startsWith(`image/`)?pi(`data:${e.mimeType};base64,${e.data}`):z(`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=z(`button`,`absolute -right-1.5 -top-1.5 h-4 w-4 cursor-pointer rounded-full bg-neutral-700 text-[10px] leading-none text-white hover:bg-red-600`,`×`);return r.onclick=()=>{gs.splice(t,1),Os()},z(`div`,`relative`,n,r)}))}function ks(e){if(gs.length>=Ds){H(`error`,`attachment limit is ${Ds} files per message`);return}if(e.size>33554432){H(`error`,`${e.name||`file`} is too large (32MB max)`);return}let t=new FileReader;t.onload=()=>{let n=t.result;gs.push({data:n.slice(n.indexOf(`,`)+1),mimeType:e.type||`application/octet-stream`,name:e.name||void 0}),Os()},t.readAsDataURL(e)}async function As(e){let t=[];for(let n of e){let e=await m(`/api/inbox`,n);if(!e.ok)return null;let{path:r}=await e.json();t.push(jr(r))}return t}var js=e=>`pier.draft.${e}`,Ms=0;function Ns(e=W.sessionId(),t=G.value){e&&(t?localStorage.setItem(js(e),t):localStorage.removeItem(js(e)))}function Ps(e){++Ms,G.value=localStorage.getItem(js(e))??``,Fs(),gs=[],Os()}function Fs(){let e=G.style.height;G.style.height=`auto`;let t=`${Math.min(G.scrollHeight,192)}px`;G.style.height=t,t!==e&&Ba()}var Is=!1;async function Ls(e,t){let n=(t??G.value).trim(),r=t===void 0?gs:[],i=W.sessionId();if(!(!n&&r.length===0||!i)){if(t===void 0){if(Is)return;Is=!0,G.value=``,Fs(),Ns(),gs=[],Os()}try{let t=[];if(r.length){let e=await As(r);if(e===null){H(`error`,`attachment upload failed`),G.value=[n,G.value.trim()].filter(Boolean).join(`
81
- `),Fs(),Ns(),gs=r,Os();return}t=e}let a=[n,...t].filter(Boolean).join(`
82
- `),o=W.sessionState()===`idle`&&e===`auto`;o?W.setState(`streaming`):Cs(),(o||e===`steer`)&&(xs(a),H(`user`,a,!1,Date.now()),Ba(!0));let s=await m(`/api/sessions/${i}/messages`,{text:a,mode:e});if(!s.ok){let e=await h(s,`send failed`);await W.reload(i),H(`error`,e)}}finally{t===void 0&&(Is=!1)}}}async function Rs(e){let t=W.sessionId();if(!t)return;Es([],[]);let n=await m(`/api/sessions/${t}/queue/deliver`,{mode:e});if(!n.ok){let r=await h(n,`Queue ${e} failed`);await W.reload(t),W.sessionId()===t&&H(`error`,r)}}async function zs(){let e=W.sessionId();if(!e||hs.has(e))return;hs.add(e);let t=ms,n=Ms,r=document.activeElement;try{Ns();let i=await fetch(`/api/sessions/${e}/queue/recall`,{method:`POST`});if(!i.ok){let t=await h(i,`Could not recall queued messages`);W.sessionId()===e&&H(`error`,t);return}let{messages:a}=await i.json(),o=W.sessionId()===e;if(a.length)try{let t=o?G.value:localStorage.getItem(js(e))??``,i=(t?[t,...a]:a).join(`
83
- `);o&&(G.value=i,Fs(),n===Ms&&W.chatVisible()&&document.activeElement===r&&G.focus()),Ns(e,i)}catch(t){H(`error`,`Could not save recalled messages for session ${e}: ${String(t)}\nRecalled messages (not saved):\n${a.join(`
84
- `)}`)}o&&t===ms&&Es([],[])}finally{hs.delete(e)}}function Bs(e){W=e,vs();let t=()=>{let e=W.sessionId();e&&fetch(`/api/sessions/${e}/abort`,{method:`POST`})};os.onclick=t,Qo(os,`Stop the running turn`,t,()=>W.sessionState()===`streaming`&&W.chatVisible()),R(`#queue-steer`).onclick=()=>void Rs(`steer`),R(`#queue-restart`).onclick=()=>void Rs(`restart`),R(`#queue-recall`).onclick=()=>void zs(),ns.onsubmit=e=>{e.preventDefault(),Ls(`auto`)},es(G,[`/`],`Write a message`,ys,W.chatVisible),G.onfocus=za,G.oninput=()=>{Fs(),Ns()};let n=!matchMedia(`(pointer: coarse)`).matches;G.onkeydown=e=>{e.isComposing||e.keyCode===229||n&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ls(`auto`))},G.onpaste=e=>{for(let t of e.clipboardData?.items??[]){let e=t.kind===`file`?t.getAsFile():null;e&&ks(e)}let t=e.clipboardData?.getData(`text/plain`)??``,n=t.trim();!n||n===t||(e.preventDefault(),G.setRangeText(n,G.selectionStart??0,G.selectionEnd??0,`end`),Fs(),Ns())},V.ondragover=e=>e.preventDefault(),V.ondrop=e=>{e.preventDefault();for(let t of e.dataTransfer?.files??[])ks(t)},R(`#attach`).onclick=()=>fs.click(),fs.onchange=()=>{for(let e of fs.files??[])ks(e);fs.value=``},Cs()}var Vs=`pier.push`,Hs=`/sw.js`,Us=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints>1&&/Macintosh/.test(navigator.userAgent),Ws=()=>matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0;function Gs(){return window.isSecureContext?Us()&&!Ws()?`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 Ks=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/Macintosh/,`Mac`],[/Windows/,`Windows`]],qs=[[/Edg\//,`Edge`],[/Chrome\//,`Chrome`],[/Firefox\//,`Firefox`],[/Safari\//,`Safari`]];function Js(){let e=navigator.userAgent,t=(t,n)=>t.find(([t])=>t.test(e))?.[1]??n;return`${t(Ks,`Linux`)} · ${t(qs,`browser`)}${Ws()?` (installed)`:``}`}var Ys=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},Xs=null;async function Zs(){return!(`serviceWorker`in navigator)||!window.isSecureContext?null:(Xs??=await navigator.serviceWorker.register(Hs,{scope:`/`}).catch(e=>(console.warn(`service worker registration failed`,e),null)),Xs)}var Qs=(e,t)=>{let n=e?new Uint8Array(e):null;return n?.length===t.length&&n.every((e,n)=>e===t[n])};async function $s(e){let{publicKey:t}=await se(`/api/push`,`Could not read this instance's push key`),n=Ys(t),r=await e.pushManager.getSubscription();if(r){if(Qs(r.options.applicationServerKey,n))return r;await r.unsubscribe()}return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}async function ec(e){return m(`/api/push/subscribe`,{...e.toJSON(),label:Js()})}async function tc(){ic();let e=await Zs();if(!(!e||localStorage.getItem(Vs)!==`on`)&&!(!(`Notification`in window)||Notification.permission!==`granted`))try{await ec(await $s(e))}catch(e){console.warn(`re-registering this browser for notifications failed`,e)}}var nc=null,rc=null;function ic(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),nc=e,rc?.()}),window.addEventListener(`appinstalled`,()=>{nc=null,rc?.()})}function ac(e){let t=navigator;(e>0?t.setAppBadge?.(e):t.clearAppBadge?.())?.catch(()=>{})}function oc(){let e=z(`span`,`text-[11.5px]`,``),t=fr(`Send a test notification`),n=z(`div`,`flex items-center gap-3`,t,e),r=z(`div`,`flex flex-col gap-4`),i=()=>localStorage.getItem(Vs)===`on`;async function a(){Er(e,`saving`,`asking this browser…`);let t=await Notification.requestPermission();if(t!==`granted`)return localStorage.setItem(Vs,`off`),c(),Er(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 Zs();if(!n)return Er(e,`failed`,`This browser refused to register a service worker.`);try{let t=await ec(await $s(n));if(!t.ok)return Er(e,`failed`,await h(t,`Could not register this browser`));localStorage.setItem(Vs,`on`),c(),Er(e,`saved`,`This browser will be notified when a turn finishes unseen.`)}catch(t){Er(e,`failed`,`Could not subscribe: ${String(t)}`)}}async function o(){localStorage.setItem(Vs,`off`),c();let t=await(await Zs())?.pushManager.getSubscription();t&&(await m(`/api/push/unsubscribe`,{endpoint:t.endpoint}),await t.unsubscribe()),Er(e,`idle`,`This browser will not be notified.`)}t.onclick=()=>{Er(e,`saving`,`sending…`),(async()=>{let t=await m(`/api/push/test`,{});if(!t.ok)return Er(e,`failed`,await h(t,`Could not send`));let{sent:n,failed:r}=await t.json();Er(e,r?`failed`:`saved`,`Handed ${String(n)} device(s) to their push service${r?`, ${String(r)} refused`:``}.`)})()};function s(){if(!nc)return[];let e=fr(`Install Pier`,!0);return e.onclick=()=>{let e=nc;e&&e.prompt().then(()=>e.userChoice).finally(()=>{nc=null,c()})},[z(`div`,`flex items-center gap-3`,e,z(`span`,`text-[11.5px] leading-snug text-neutral-500`,`Its own window and icon — and where notifications look like an app's.`))]}function c(){let e=Gs();if(e){r.replaceChildren(...s(),z(`p`,`text-[12.5px] leading-snug text-neutral-500`,e));return}let c=i()&&Notification.permission===`granted`;t.disabled=!c,r.replaceChildren(...s(),wr(`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.`,c,e=>void(e?a():o())),n)}return rc=c,c(),_r(`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)}var K=null;function sc(e){K&&!K.contains(e.target)&&q()}function cc(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),q())}function lc(e){K&&!K.contains(e.target)&&q()}function q(){if(!K)return;document.removeEventListener(`pointerdown`,sc,!0),document.removeEventListener(`keydown`,cc,!0),window.removeEventListener(`scroll`,lc,!0),window.removeEventListener(`resize`,q);let e=K;K=null,e.inert=!0,e.dataset.closing=``,Promise.allSettled(e.getAnimations().map(e=>e.finished)).then(()=>e.remove())}var uc=null;function dc(e){let t=e.getBoundingClientRect(),n={top:t.bottom+4,left:t.left};return t.width||t.height?n:uc?.anchor===e?{top:uc.top,left:uc.left}:n}var fc=()=>window.innerWidth<640;function pc(e,t){q(),document.querySelectorAll(`.glass-menu[data-closing]`).forEach(e=>e.remove());let n=fc();if(K=z(`div`,`glass glass-menu fixed z-50 rounded-3xl border border-neutral-200 p-2 ${n?`inset-x-2 bottom-2 max-h-[70dvh] overflow-y-auto pb-[calc(0.25rem+env(safe-area-inset-bottom))] text-[16px]`:`min-w-52 max-w-[min(42rem,calc(100vw-1rem))] text-[13px]`}`),K.dataset.presentation=n?`sheet`:`popover`,K.append(t),(e.closest(`dialog[open]`)??document.body).append(K),!n){let t=dc(e);uc={anchor:e,...t},K.style.top=`${Math.max(8,Math.min(t.top,window.innerHeight-K.offsetHeight-8))}px`,K.style.left=`${Math.max(8,Math.min(t.left,window.innerWidth-K.offsetWidth-8))}px`}document.addEventListener(`pointerdown`,sc,!0),document.addEventListener(`keydown`,cc,!0),window.addEventListener(`scroll`,lc,!0),window.addEventListener(`resize`,q)}function mc(e){let t=z(`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 ${fc()?`py-3`:`py-1.5`}`,z(`span`,`flex-none w-3 text-indigo-600`,e.checked?`✓`:``),z(`span`,`truncate`,e.label));return e.hint&&t.append(z(`span`,`ml-auto flex-none text-[11.5px] text-neutral-400`,e.hint)),t.onclick=()=>e.onSelect(),t}function hc(e,t){pc(e,z(`div`,``,...t.map(mc)))}var J=e=>`${e.provider}/${e.id}`,gc=`pier.modelFavorites`,_c=e=>`${J(e)}@${e.thinking}`,vc=null;async function yc(){let{modelMenu:e}=await se(`/api/settings`,`Could not read the pinned model menu`);return e}function bc(){try{let e=JSON.parse(localStorage.getItem(gc)??`[]`);return Array.isArray(e)?e.filter(e=>{let t=e;return!!t&&typeof t==`object`&&typeof t.provider==`string`&&typeof t.id==`string`&&typeof t.thinking==`string`}):[]}catch{return[]}}function xc(e){let t=z(`button`,`flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-3 py-1.5 text-left`,z(`span`,`w-3 flex-none text-indigo-600`,e.checked?`✓`:``),z(`span`,`truncate`,e.label));e.hint&&t.append(z(`span`,`ml-auto flex-none text-[11.5px] text-neutral-400`,e.hint)),e.title&&(t.title=e.title),t.onclick=()=>e.onSelect();let n=z(`button`,`flex-none cursor-pointer px-2 py-1.5 leading-none ${e.starred?`text-amber-500`:`text-neutral-300 opacity-0 hover:text-amber-500 group-hover/row:opacity-100`}`,e.starred?`★`:`☆`);return n.title=e.starred?`Unstar`:`Star this model + reasoning`,n.onclick=t=>{t.stopPropagation(),e.onStar()},z(`div`,`group/row flex w-full items-center hover:bg-neutral-100`,t,n)}function Sc({models:e,current:t,thinkingLevel:n,thinkingLevels:i,onPick:a,onThinkingPick:o}){let s=bc(),c=n,l=z(`div`,`flex w-72 flex-col`),u=z(`div`,`flex flex-col gap-2 border-b border-neutral-200 px-2 py-2`),d=document.createElement(`input`);if(d.type=`search`,d.placeholder=`Search models`,d.setAttribute(`aria-label`,`Search models`),d.className=`w-full rounded-md border border-neutral-300 px-2 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`,u.append(d),i.length){let e=z(`label`,`flex items-center gap-2 px-1 text-[12px] text-neutral-500`),t=document.createElement(`select`);t.className=`select ml-auto rounded-md border border-neutral-300 px-2 py-1 text-[12px] text-neutral-700 focus:border-indigo-400 focus:outline-none`,t.setAttribute(`aria-label`,`Reasoning level`);for(let e of i){let n=document.createElement(`option`);n.value=e,n.textContent=r(e),t.append(n)}t.value=n,t.onchange=()=>{c=t.value,re(d.value),o(c)},e.append(z(`span`,`font-medium`,`Reasoning`),t),u.append(e)}let ee=e=>{let t=_c(e);s=s.some(e=>_c(e)===t)?s.filter(e=>_c(e)!==t):[...s,e],localStorage.setItem(gc,JSON.stringify(s)),re(d.value)},f=(e,t)=>s.some(n=>_c(n)===`${J(e)}@${t}`),p=z(`div`,`max-h-72 overflow-y-auto py-1`),te=new Map(e.map(e=>[J(e),e])),ne=(e,n,i)=>{let o=n.map(e=>({e,model:te.get(J(e))})).filter(e=>!!e.model&&(!i||J(e.model).toLowerCase().includes(i)));o.length&&p.append(z(`div`,`px-3 pb-0.5 pt-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),...o.map(({e,model:n})=>{let i=e.thinking??c;return xc({label:n.id,hint:e.thinking?r(e.thinking):void 0,title:e.note,checked:!!t&&J(t)===J(n)&&c===i,starred:f(n,i),onSelect:()=>a(n,e.thinking),onStar:()=>ee({provider:n.provider,id:n.id,thinking:i})})}),z(`div`,`my-1 border-t border-neutral-100`))},re=n=>{p.replaceChildren();let r=n.trim().toLowerCase();ne(`Pinned`,vc??[],r),ne(`Starred`,s,r);let i=new Map;for(let t of e){if(r&&!J(t).toLowerCase().includes(r))continue;let e=i.get(t.provider);e?e.push(t):i.set(t.provider,[t])}if(!i.size){p.append(z(`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 i){let i=n.some(e=>!!t&&J(t)===J(e)),o=document.createElement(`details`);o.open=i||r.length>0;let s=z(`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`,z(`span`,`chev`,`▶`),z(`span`,`truncate`,e),z(`span`,`ml-auto flex-none normal-case text-neutral-300`,String(n.length)));o.append(s,...n.map(e=>xc({label:e.id,checked:!!t&&J(t)===J(e),starred:f(e,c),onSelect:()=>a(e),onStar:()=>ee({provider:e.provider,id:e.id,thinking:c})}))),p.append(o)}};return d.oninput=()=>re(d.value),re(``),yc().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(vc);vc=e,t&&re(d.value)}).catch(e=>Ro(`model menu unavailable`,e)),l.append(u,p),queueMicrotask(()=>d.focus()),l}function Cc(e,t,n,i){let a=pr(t.model?`${t.model.id}${t.thinking?` · ${r(t.thinking)}`:``}`:t.thinking?`Pi default · ${r(t.thinking)}`:`Pi default`,`${yr} flex cursor-pointer items-center gap-1.5 truncate text-left hover:bg-neutral-50 ${t.model?`text-neutral-700`:`text-neutral-400`}`);return a.title=t.model?`${t.model.provider}/${t.model.id}`:`Whatever the project and Pi pick`,a.onclick=()=>{let e=Sc({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...Ri],onPick:(e,n)=>{q(),i({model:e,thinking:n??t.thinking})},onThinkingPick:e=>i({...t,thinking:e})}),r=pr(`Pi default`,`w-full cursor-pointer px-3 py-1.5 text-left text-[12.5px] text-neutral-500 hover:bg-neutral-100`);r.onclick=()=>{q(),i({model:null,thinking:null})};let o=z(`div`,`flex flex-col`);o.append(e,z(`div`,`border-t border-neutral-200`),r),pc(a,o)},vr(e,a)}var wc=async e=>{let t=await oe(`/api/fs/ls${e?.startsWith(`/`)?`?path=${encodeURIComponent(e)}`:``}`,`Could not list directories`);return t.ok?t.value:null},Tc=e=>e.entries.filter(e=>e.dir&&!e.name.startsWith(`.`)).map(e=>e.name),Ec=(e,t,n)=>{let r=pr(e,`flex w-full cursor-pointer items-center gap-1.5 px-3 py-1 text-left ${t}`);return r.onclick=n,r};function Dc(e,t){let n=z(`div`,`flex-none border-t border-neutral-200`),r=Ec(`+ New folder`,`text-[12px] text-neutral-500 hover:bg-neutral-100`,()=>{let r=document.createElement(`input`);r.className=`w-full border-0 bg-transparent px-3 py-1 font-mono text-[12.5px] focus:outline-none`,r.placeholder=`folder-name`;let i=z(`p`,`hidden px-3 pb-1 text-[11.5px] text-red-600`);r.onkeydown=async n=>{if(n.key!==`Enter`)return;n.preventDefault();let a=await m(`/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 n.append(r),n}function Oc(e,t,n){let r=e=>{n(e),q()};async function i(t){let n=await wc(t);if(!n)return;let a=z(`div`,`flex max-h-80 w-80 flex-col`),o=pr(`Use`,`ml-auto flex-none cursor-pointer rounded bg-indigo-600 px-2 py-0.5 text-[11.5px] text-white dark:text-neutral-50`);o.onclick=()=>r(n.path);let s=document.createElement(`input`);s.className=`min-w-0 flex-1 border-0 bg-transparent font-mono text-[11.5px] text-neutral-500 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=z(`p`,`hidden flex-none px-3 pb-1 text-[11.5px] 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 wc(t);if(!n){c.textContent=`${t} is not a folder this can read`,c.classList.remove(`hidden`);return}r(n.path)};let l=z(`div`,`flex flex-none items-center gap-2 border-b border-neutral-200 px-3 py-1.5`,s,o),u=z(`div`,`min-h-0 flex-1 overflow-y-auto py-0.5 text-[12.5px]`);n.parent&&u.append(Ec(`../`,`font-mono text-neutral-500 hover:bg-neutral-100`,()=>void i(n.parent)));let d=Tc(n);for(let e of d)u.append(Ec(e,`truncate hover:bg-neutral-100`,()=>void i(`${n.path}/${e}`.replace(`//`,`/`))));d.length||u.append(z(`p`,`px-3 py-1.5 text-[12px] text-neutral-400`,`No sub-folders.`)),a.append(l,c,u,Dc(n.path,e=>void i(e))),pc(e,a)}i(t)}function kc(e,t,n,r){hc(e,[...t.map(e=>({label:e.path,...e.hint?{hint:e.hint}:{},checked:e.path===n,onSelect:()=>{q(),r(e.path)}})),{label:`Browse…`,onSelect:()=>Oc(e,n||void 0,r)}])}var Ac=(e,t)=>n=>{e.value=n,e.dispatchEvent(new Event(`input`,{bubbles:!0})),t?.(n)};function jc(e,t){let n=pr(`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=()=>Oc(n,e.value.trim()||void 0,Ac(e,t)),n}function Mc(e,t){let n=Ac(e);e.classList.add(`select`),e.title=`Pick a project folder, or type a path`,e.onclick=()=>{let r=e.value.trim()||void 0,i=t();if(i.length)return kc(e,i,r,n);Oc(e,r,n)},e.addEventListener(`input`,()=>q())}function Nc(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:z(`div`,`flex items-center gap-1.5`,r,jc(r,n)),input:r}}var Pc=R(`#sidebar`),Fc=R(`#drawer-scrim`),Ic=R(`#mobile-title`),Lc=R(`#mobile-menu`);function Rc(){delete Pc.dataset.open,Fc.classList.add(`hidden`)}function zc(e,t){Ic.textContent=e,Ic.classList.toggle(`cursor-pointer`,t),Lc.classList.toggle(`hidden`,!t)}var Bc=`pier.railClosed`;localStorage.getItem(Bc)===`1`&&(document.body.dataset.rail=`closed`);function Vc(e){document.body.dataset.rail=e?`closed`:``,localStorage.setItem(Bc,e?`1`:`0`)}function Hc(){if(Pc.dataset.open!==void 0)return Rc();Pc.dataset.open=``,Fc.classList.remove(`hidden`)}var Uc=()=>window.innerWidth<768,Wc=[R(`#rail-toggle`),R(`#drawer-toggle`)],Gc=`attention absolute -right-0.5 -top-0.5 rounded-full bg-amber-500`,Kc=e=>e===1?z(`span`,`${Gc} h-2 w-2`):z(`span`,`${Gc} 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 qc(e){for(let t of Wc)t.querySelector(`.attention`)?.remove(),e&&t.append(Kc(e))}var Jc=20,Yc=.35,Xc=8;function Zc(){let e=-1,t=0,n=!1,r=!1,i=1,a=e=>{Pc.style.transition=`none`,Pc.style.transform=`translateX(${String(e-i)}px)`,Fc.style.transition=`none`,Fc.classList.remove(`hidden`),Fc.style.opacity=String(e/i)},o=t=>{Pc.style.transition=``,Pc.style.transform=``,Fc.style.transition=``,Fc.style.opacity=``,t?(Pc.dataset.open=``,Fc.classList.remove(`hidden`)):Rc(),e=-1,r=!1};window.addEventListener(`touchstart`,a=>{if(r||(e=-1,!Uc()||a.touches.length!==1))return;let o=a.touches[0],s=Pc.dataset.open!==void 0;if(i=Pc.offsetWidth||1,s){if(o.clientX>i)return}else{if(o.clientX>Jc||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)<Xc)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=Pc.getBoundingClientRect().right;o(n?t>i*Yc:t>i*.65)};window.addEventListener(`touchend`,s),window.addEventListener(`touchcancel`,s)}function Qc(e){Zc(),R(`#drawer-toggle`).onclick=Hc,Fc.onclick=Rc,Lc.onclick=()=>e.sessionMenu(Lc),Ic.onclick=()=>{Lc.classList.contains(`hidden`)||e.sessionInfo(Ic)};let t=R(`#rail-toggle`);t.onclick=()=>Vc(document.body.dataset.rail!==`closed`),Zo(t,`meta+b`,`Toggle sidebar`,()=>Uc()?Hc():Vc(document.body.dataset.rail!==`closed`))}var Y,$c=R(`#session-list`),el=R(`#archive-dialog`),tl=R(`#archive-list`),nl=R(`#archive-search`),rl=R(`#archive-count`),il=R(`#new-dialog`),al=e=>e.modified??e.createdAt;function ol(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 sl(e,t){let{top:n,rest:r}=ol(e),i=[...n,...r].slice(0,t);return{rows:i,hidden:e.length-i.length}}var cl=e=>[...new Set([...e].sort((e,t)=>t.createdAt-e.createdAt).map(e=>e.cwd))],ll=`hidden group-hover:flex pointer-coarse:flex h-5 w-5 flex-none items-center justify-center rounded leading-none text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700`,ul=e=>e.unread&&e.channel===`web`;function dl(e){let t=e.state===`streaming`?[`bg-green-500 animate-pulse`,`working…`]:ul(e)?[`bg-amber-500`,`turn finished — not viewed yet`]:e.activeRuns>0?[`bg-sky-500`,`${e.activeRuns} subagent${e.activeRuns>1?`s`:``} running`]:null;if(!t)return[];let n=z(`span`,`h-2 w-2 flex-none rounded-full ${t[0]}`);return n.title=t[1],[n]}async function fl(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,yl(),Y.onTitleChanged()};r(t.trim()||void 0),(await m(`/api/sessions/${e.id}/rename`,{name:t})).ok||r(n)}var pl=`flex-none font-mono text-[10px] uppercase leading-[15px] text-neutral-300`,ml=e=>e.channel&&e.channel!==`web`?[z(`span`,pl,e.channel[0]??``)]:[];function hl(e){let t=z(`li`,`group flex cursor-pointer items-center gap-1.5 px-3 py-1.5 hover:bg-neutral-100 ${e.id===Y.currentId()?`bg-indigo-50 hover:bg-indigo-50`:``}`),n=z(`button`,ll,`⋯`);return n.title=`Session actions`,n.onclick=t=>{t.stopPropagation(),Y.sessionMenu(n,e)},t.append(...dl(e),z(`span`,`truncate`,e.title??`untitled`),z(`div`,`ml-auto flex flex-none items-center gap-1`,...ml(e),n)),t.onclick=()=>Y.select(e.id),t.title=[e.cwd,`active ${er(al(e))} ago · created ${new Date(e.createdAt).toLocaleDateString()}`,...e.channel&&e.channel!==`web`?[`answering ${e.channel}`]:[]].join(`
85
- `),t}var gl=()=>`${Y.currentId()??``}\n${vl}\n${JSON.stringify(Y.sessions())}`,_l=``,vl=20;function yl(){let e=gl();if(e===_l)return;_l=e;let t=Y.sessions(),n=t.filter(ul);qc(n.length),ac(n.length);let{rows:r,hidden:i}=sl(t,vl),a=r.map(hl);if(i>0){let e=z(`li`,`cursor-pointer px-3 py-1.5 text-[12.5px] text-neutral-400 hover:bg-neutral-100`,`Load more (${i})`);e.onclick=()=>{vl+=20,yl()},a.push(e)}$c.replaceChildren(...a.length?[z(`ul`,`pb-1`,...a)]:[z(`p`,`px-3 py-2 text-[12.5px] leading-snug text-neutral-400`,`No sessions yet — create one.`)]),el.open&&Ol()}var bl=[{name:`tasks`,label:`Tasks`,detail:`Automation — task definitions and schedules`},{name:`runs`,label:`Runs`,detail:`Automation — executions, subagents, decisions and callbacks`},{name:`activity`,label:`Activity`,detail:`Automation — sessions and relationships`},{name:`boards`,label:`Boards`,detail:`Console — the static pages Pier publishes`},{name:`settings`,label:`Settings`,detail:`Console — models and providers, agent files and extensions, channels, password, sign out, security`}],xl=[],Sl=0,Cl={ArrowDown:1,ArrowUp:-1},wl={n:1,j:1,p:-1,k:-1};function Tl(e){if(xl.length){Sl=(e+xl.length)%xl.length;for(let[e,{el:t}]of xl.entries())t.classList.toggle(`bg-indigo-100`,e===Sl),t.classList.toggle(`border-indigo-500`,e===Sl);xl[Sl]?.el.scrollIntoView({block:`nearest`})}}function El(e){let t=z(`li`,`flex cursor-pointer items-center gap-2 border-l-2 border-transparent px-3 py-1.5 hover:bg-neutral-100`);return e.session&&t.append(...dl(e.session)),t.append(z(`span`,`min-w-0 flex-1 truncate`,e.label),z(`span`,`max-w-[45%] flex-none truncate text-[11.5px] text-neutral-400`,e.detail)),e.session&&t.append(z(`span`,`flex-none text-[11px] text-neutral-400`,er(e.session.createdAt))),t.onclick=e.open,t}var Dl=e=>z(`li`,`px-3 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-neutral-400`,e);function Ol(){let e=nl.value.trim().toLowerCase(),t=t=>!e||t.toLowerCase().includes(e),n=e=>()=>{el.close(),e()},r=e=>e.channel&&e.channel!==`web`?e.channel:``,i=Y.sessions().filter(e=>t(`${e.title??``} ${e.cwd} ${r(e)}`)),a=(e,t)=>t.createdAt-e.createdAt,o=e=>({label:e.title??rr(e.cwd),detail:[nr(e.cwd),r(e)].filter(Boolean).join(` · `),open:n(()=>Y.select(e.id)),session:e}),s=i.filter(e=>e.state===`streaming`),c=ol(i.filter(e=>e.state!==`streaming`)),l=[`Console`,bl.filter(e=>t(`${e.label} ${e.detail}`)).map(({name:e,label:t,detail:r})=>({label:t,detail:r,open:n(()=>Y.openConsole(e))}))],u=[[`Running`,s.sort(a).map(o)],[`Recent`,c.top.map(o)],[`Sessions`,c.rest.map(o)]];e?u.unshift(l):u.push(l),xl=[];let d=[];for(let[e,t]of u)if(t.length){d.push(Dl(e));for(let e of t){let t=El(e);xl.push({el:t,open:e.open}),d.push(t)}}tl.replaceChildren(...d.length?d:[z(`li`,`px-3 py-3 text-[13px] text-neutral-400`,`Nothing matches.`)]),rl.textContent=String(xl.length),Tl(Sl)}function kl(){if(el.open)return el.close();nl.value=``,Sl=0,Ol(),el.showModal(),nl.focus(),Y.loadSessions().then(()=>{el.open&&Ol()})}function Al(e){Y=e,Mc(R(`#new-cwd`),()=>cl(Y.sessions()).map(e=>({path:e})));let t=R(`#new-session`),n=()=>{let e=Y.sessions().find(e=>e.id===Y.currentId())?.cwd??``,t=R(`#new-cwd`);t.value=e,il.showModal(),t.select()};t.onclick=n,Zo(t,`shift+o`,`New session`,n,()=>il.open),R(`#new-cancel`).onclick=()=>il.close(),R(`#new-form`).onsubmit=()=>void Y.createSession(R(`#new-cwd`).value.trim());let r=R(`#open-archive`);r.onclick=kl,Zo(r,`k`,`Search sessions and Console`,kl,()=>el.open),R(`#archive-close`).onclick=()=>el.close(),nl.oninput=()=>{Sl=0,Ol()},nl.onkeydown=e=>{let t=e.altKey||e.metaKey||e.shiftKey||!e.key?void 0:e.ctrlKey?wl[e.key.toLowerCase()]:Cl[e.key];if(t!==void 0){e.preventDefault(),Tl(Sl+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),xl[Sl]?.open())}}var X;function jl(e){X=e,ts(Nl,()=>{X.currentSession()&&(q(),X.toggleFiles())},Ml)}var Ml=()=>document.querySelector(`dialog[open]`)!==null,Nl=`i`,Pl=R(`#chat-title`),Fl=R(`#chat-menu`),Il=R(`#session-meta`),Ll=null,Rl=null,zl=null,Bl=null;function Vl(){Ll=null,Rl=null,zl=null,Bl=null,Yl()}function Hl(e,t,n,r){Ll=e,Rl=t,zl=n,Bl=r,Kl()}function Ul(e){Bl=e.completedAt,Rl&&={...Rl,tokens:e.tokens},Yl()}var Wl=null;function Gl(e){Wl=e===null?null:rr(e),Kl()}function Kl(){let e=X.currentSession();e&&(Wl=null),Pl.textContent=e?e.title??rr(e.cwd):Wl??X.currentId()??`no session`,Pl.classList.toggle(`cursor-pointer`,!!e),Pl.title=e?`Session info`:``,Pl.onclick=e?()=>Xl(Pl,e):null,Fl.classList.toggle(`hidden`,!e),e&&(Fl.onclick=()=>nu(Fl,e)),Yl(),X.syncBar()}var ql=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),Jl=e=>e.tokens===null?`?/${i(e.contextWindow)}`:`${i(e.tokens)}/${i(e.contextWindow)} · ${100-ql(e.tokens,e)}% left`;function Yl(){let e=Rl,t=e?.tokens??null,n=X.currentId(),r=[];if(!n&&Wl&&r.push(z(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,z(`span`,`spinner`),`starting…`)),n){let e=(e,t)=>{let r=z(`button`,`flex-none cursor-pointer font-mono ${t}`,e);return r.title=`Change model or reasoning`,r.onclick=()=>void Zl(r,n),r};Ll&&r.push(e(Ll.id,`rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),zl&&r.push(e(zl,`text-neutral-500 hover:text-indigo-700`))}if(e&&t!==null){let n=ql(t,e),a=n>=90?`text-red-700`:n>=70?`text-amber-700`:`text-neutral-500`;r.push(z(`span`,`flex-none font-mono ${a}`,i(t).toLowerCase()))}let a=r.flatMap((e,t)=>t===0?[e]:[z(`span`,`text-neutral-300`,`·`),e]);Il.replaceChildren(...a),Il.classList.toggle(`hidden`,r.length===0),Il.classList.toggle(`flex`,r.length>0)}function Xl(e,t){let n=[[`Title`,t.title??`untitled`],[`Directory`,t.cwd],[`Session`,t.id]],r=t.id===X.currentId();if(r&&(n.push([`Model`,Ll?.id??`—`]),n.push([`Reasoning`,zl??`—`]),n.push([`Context`,Rl?Jl(Rl):`—`])),n.push([`Created`,ir(t.createdAt),tr(t.createdAt)]),r){let e=Bl;n.push(e===null?[`Last reply`,`—`]:[`Last reply`,ir(e),tr(e)])}let i=z(`div`,`flex max-w-80 flex-col gap-1.5 px-3 py-2`);for(let[e,t,r]of n){let n=z(`div`,`flex items-center gap-1.5`,z(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),ur(`cursor-pointer text-[10.5px] uppercase tracking-wide text-neutral-400 opacity-0 hover:text-neutral-700 focus:opacity-100 group-hover:opacity-100 pointer-coarse:opacity-100`,()=>t)),a=z(`span`,`break-all font-mono text-[12px] text-neutral-700`,t);r&&a.append(z(`span`,`ml-1.5 font-sans text-[11px] text-neutral-400`,r)),i.append(z(`div`,`group flex flex-col`,n,a))}pc(e,i)}async function Zl(e,t){try{let[n,r]=await Promise.all([se(`/api/sessions/${t}/models`,`Could not load models`),se(`/api/sessions/${t}/thinking`,`Could not read the reasoning level`)]);pc(e,Sc({models:n,current:t===X.currentId()?Ll:null,thinkingLevel:r.level,thinkingLevels:r.levels,onPick:(e,n)=>{q(),Ql(t,e,n)},onThinkingPick:e=>void eu(t,e)}))}catch(e){H(`error`,`model options failed: ${String(e)}`)}}async function Ql(e,t,n){await $l(e,t)&&n&&await eu(e,n)}async function $l(e,t){let n=Ll;e===X.currentId()&&(Ll=t,Kl());let r=await m(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===X.currentId()&&(Ll=n,Kl()),H(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===X.currentId()&&i&&(Ll=i,Kl()),!0}async function eu(e,t){let n=await m(`/api/sessions/${e}/thinking`,{level:t});if(!n.ok){H(`error`,`reasoning change failed: ${n.status}`);return}let{level:r}=await n.json();e===X.currentId()&&(zl=r,Yl())}async function tu(e){let t=await m(`/api/sessions/${e}/compact`,{});t.ok||H(`error`,`compact failed: ${await h(t,`no reason given`)}`)}function nu(e,t){let n=t.id===X.currentId();hc(e,[{label:`Session info`,onSelect:()=>Xl(e,t)},{label:`Rename…`,onSelect:()=>{q(),fl(t)}},{label:`Model`,hint:n?Ll?.id??`…`:``,onSelect:()=>void Zl(e,t.id)},{label:`Compact context`,onSelect:()=>{q(),tu(t.id)}},{label:`New session here`,hint:nr(t.cwd),onSelect:()=>{q(),X.createSession(t.cwd)}},{label:`Browse files`,hint:n?Jo(Nl):``,onSelect:()=>{q(),X.openFiles(n?void 0:t.cwd)}}])}var ru=`pier.theme`,iu=[`system`,`light`,`dark`],au=window.matchMedia(`(prefers-color-scheme: dark)`),ou={system:`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" class="h-3.5 w-3.5"><circle cx="8" cy="8" r="5.25"/><path d="M8 2.75a5.25 5.25 0 0 0 0 10.5z" fill="currentColor" stroke="none"/></svg>`,light:`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" class="h-3.5 w-3.5"><circle cx="8" cy="8" r="3.1"/><path d="M8 1.5v1.4M8 13.1v1.4M1.5 8h1.4M13.1 8h1.4M3.4 3.4l1 1M11.6 11.6l1 1M12.6 3.4l-1 1M4.4 11.6l-1 1"/></svg>`,dark:`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" class="h-3.5 w-3.5"><path d="M13 9.4A5.6 5.6 0 0 1 6.6 3a5.6 5.6 0 1 0 6.4 6.4z"/></svg>`},su=()=>{let e=null;try{e=localStorage.getItem(ru)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},cu=()=>{let e=su();return e===`system`?au.matches?`dark`:`light`:e};function lu(){let e=cu();document.documentElement.dataset.theme=e,R(`meta[name="theme-color"]`).setAttribute(`content`,e===`dark`?`#1c1c1c`:`#fafafa`),window.dispatchEvent(new Event(`pier:theme`))}function uu(){let e=R(`#theme-toggle`),t=()=>{let t=su();e.title=`Theme: ${t}${t===`system`?` (${cu()})`:``}`,e.innerHTML=ou[t],lu()};e.onclick=()=>{let e=iu[(iu.indexOf(su())+1)%iu.length];try{e===`system`?localStorage.removeItem(ru):localStorage.setItem(ru,e)}catch{}t()},au.addEventListener(`change`,t),t()}var du=`https://github.com/timqi/pier`,fu=[`text-neutral-400`,`hover:text-neutral-700`],pu=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],mu=18e5,Z=null,hu=R(`#version`);function gu(e){let t=Z?.available===!0&&Z.latest!==null;hu.textContent=`v${e}`,hu.title=t?`Pier ${Z?.latest} is out`:``,hu.classList.remove(...t?fu:pu),hu.classList.add(...t?pu:fu)}var _u=e=>z(`p`,`px-3 py-1 text-[12px] leading-snug text-neutral-500`,e);function vu(){let e=z(`div`,`flex w-72 flex-col gap-1 py-1`);if(!Z)return e.append(_u(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=Z;e.append(z(`p`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`,r?`Pier ${n} is out`:`Pier ${t}`)),e.append(_u(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.`));let o=z(`span`,`px-3 text-[11.5px] text-neutral-400`,``),s=z(`div`,`flex items-center gap-2 px-3 py-1.5`);if(a&&e.append(z(`p`,`mx-3 my-1 rounded-md bg-red-50 px-2 py-1.5 text-[11.5px] leading-snug text-red-700`,a)),r&&i&&!a){let e=fr(`Update now`,!0);e.onclick=()=>{e.disabled=!0,o.className=`px-3 text-[11.5px] text-neutral-400`,o.textContent=`starting the updater…`,(async()=>{let t=await m(`/api/update`,{});if(!t.ok){e.disabled=!1,o.className=`px-3 text-[11.5px] text-red-600`,o.textContent=await h(t,`Could not update`);return}let{draining:n}=await t.json();o.textContent=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.`})()},s.append(e)}let c=z(`a`,`btn text-[12.5px] no-underline`,`Source`);c.href=r?`${du}/releases`:du,c.target=`_blank`,c.rel=`noreferrer`,c.title=`Pier is free software (AGPL-3.0)`,s.append(c),e.append(s,o),r&&!i&&!a&&e.append(_u(`No service manager owns this Pier, so it cannot restart itself — update it with: pier update`));let l=wr(`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.`,Z.autoUpdate,e=>{Z&&(Z.autoUpdate=e),(async()=>{let t=await m(`/api/settings`,{autoUpdate:e},`PUT`);if(t.ok)return;Z&&(Z.autoUpdate=!e);let n=l.querySelector(`input`);n&&(n.checked=!e),o.className=`px-3 text-[11.5px] text-red-600`,o.textContent=await h(t,`Could not save`)})()});if(!i){let e=l.querySelector(`input`);e&&(e.disabled=!0)}return e.append(z(`div`,`mt-1 border-t border-neutral-200 px-3 pb-1 pt-2`,l)),e}async function yu(e){let t=await oe(`/api/update`,`Update check failed`);t.ok&&(Z=t.value,gu(Z.current||e))}function bu(e){gu(e),hu.onclick=e=>{e.preventDefault(),pc(hu,vu())};let t=()=>void yu(e).catch(()=>{});t(),setInterval(t,mu)}var Q,xu=R(`#chat-header`),Su=R(`#chat-title`),Cu=[xu,V,R(`#composer`)],wu=()=>ju===null,Tu,Eu,Du,Ou=new Map,ku=new Map,Au=new Map,ju=null,Mu=0,Nu=[`files`],Pu=new Map,Fu={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},Iu=[`tasks`,`runs`,`activity`],Lu=`Automation`,Ru=R(`#automation-view`),zu=R(`#automation-tabs`),Bu=e=>Iu.includes(e)?`tasks`:e;function Vu(e,t){let n=e!==null&&Iu.includes(e);if(Ru.classList.toggle(`hidden`,!n),Ru.classList.toggle(`flex`,n),!n)return;let r=[];if(e===`tasks`&&!t){let e=fr(`New task`,!0);e.classList.add(`ml-auto`),e.disabled=!Tu,e.onclick=()=>Tu?.create(),r.push(e)}zu.replaceChildren(...Iu.map(t=>gr(Fu[t],t===e,()=>Ku(t))),...r)}var Hu=e=>Tu?.refresh(e),Uu=()=>Eu?.refresh(),Wu=()=>Du?.refresh();function Gu(){ju?zc(Iu.includes(ju)?Lu:Fu[ju],!1):zc(Su.textContent??``,Q.currentSession()!==void 0)}function Ku(e,t,n){if(Nu.includes(e)){let t=id();t&&(t.kind!==`console`||t.name!==e)&&Pu.set(e,t)}od({kind:`console`,name:e,arg:t,query:n}),Rc(),ju=e;for(let e of Cu)e.classList.add(`hidden`);ws();for(let[t,n]of Ou)t!==e&&n.hide();for(let[t,n]of Au)n.classList.toggle(`bg-indigo-50`,t===Bu(e));Vu(e,t),Gu(),qu(e,t,n,++Mu)}async function qu(e,t,n,r){let i=Ou.get(e);if(!i){let t=ku.get(e);if(!t){let n=R(`#${e}-view`);t=ld[e](n).catch(t=>(console.warn(`${e} view failed to load`,t),or(n,()=>n.replaceChildren(z(`p`,`p-4 text-[13px] text-red-600`,`Could not load ${Fu[e]} — reload the page.`))))),ku.set(e,t)}i=await t,Ou.set(e,i),ku.delete(e)}ju===e&&r===Mu&&(i.show(t,n),e===`tasks`&&Vu(e,t))}var Ju=e=>Ku(`tasks`,e),Yu=(e={},t)=>Ku(`runs`,t,new URLSearchParams(e).toString()),Xu=e=>Yu({},e),Zu=e=>Ku(`files`,e),Qu=(e,t)=>{ju===e?ed(e):Ku(e,t)},$u=e=>Qu(`files`,e);function ed(e){let t=Q.currentId(),n=Pu.get(e)??(t?{kind:`session`,id:t}:null);Pu.delete(e),n?od(n):(history.replaceState(null,``,`#/`),td())}function td(){if(ju){ju=null;for(let e of Ou.values())e.hide();for(let e of Au.values())e.classList.remove(`bg-indigo-50`);Vu(null);for(let e of Cu)e.classList.remove(`hidden`);ws(),Gu(),Q.maybeAckRead()}}var nd=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,rd={config:`files`,channels:`channels`,providers:`models`};function id(){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 rd[n]?{kind:`console`,name:`settings`,arg:rd[n]}:Object.hasOwn(Fu,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var ad=!1;function od(e,t=!1){if(ad)return;let n=nd(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var sd=e=>od({kind:`session`,id:e});function cd(){let e=id(),t=Q.sessions(),n=Q.currentId(),r=e?.kind===`session`?e.id:null,{top:i,rest:a}=ol(t),o=r??n??(i[0]??a[0])?.id??null;ad=!0;try{o&&o!==n&&Q.select(o),e?.kind===`console`?Ku(e.name,e.arg,e.query):td(),o||Kl()}finally{ad=!1}e?.kind!==`console`&&o&&od({kind:`session`,id:o},!0)}var ld={tasks:async e=>Tu=(await Br(async()=>{let{createTasksView:e}=await import(`./tasks-DTiCi2mH.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(),Yu,Ju),runs:async e=>Eu=(await Br(async()=>{let{createRunsView:e}=await import(`./runs-Ch6DZq6O.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Q.select,Yu,Ju),activity:async e=>Du=(await Br(async()=>{let{createActivityView:e}=await import(`./activity-D3m4L2IL.js`);return{createActivityView:e}},[])).createActivityView(e,Q.select,Xu),boards:async e=>(await Br(async()=>{let{createBoardsView:e}=await import(`./boards-BIObcQeX.js`);return{createBoardsView:e}},[])).createBoardsView(e,Q.select),files:async e=>(await Br(async()=>{let{createExplorerView:e}=await import(`./explorer-C_rSWPNB.js`);return{createExplorerView:e}},[])).createExplorerView(e,()=>Q.currentSession(),e=>Ku(`files`,e),()=>ed(`files`)),settings:async e=>(await Br(async()=>{let{createSettingsView:e}=await import(`./settings-BWcEIEcv.js`);return{createSettingsView:e}},[])).createSettingsView(e,()=>cl(Q.sessions()),e=>Ku(`settings`,e))};function ud(e){Q=e;for(let e of[`tasks`,`boards`,`settings`]){let t=R(`#open-${e}`);Au.set(e,t),t.onclick=()=>Ku(e)}let t=R(`#console-section`);t.open=localStorage.getItem(`pier.consoleCollapsed`)!==`1`,t.ontoggle=()=>localStorage.setItem(`pier.consoleCollapsed`,t.open?`0`:`1`),window.onhashchange=cd}var dd=[],fd=0,pd=0,md=!1,$=null,hd=`idle`,gd=null,_d=0,vd=!1,yd=!1;async function bd(e){let t=++fd;++pd,md=!1,td(),Rc(),$=null,gd?.close(),gd=null,ko(),Ts([]),Vl(),Gl(e),Ao(!0),yd=!0,Cs();let n=await m(`/api/sessions`,{cwd:e});if(t!==fd)return;if(yd=!1,!n.ok){Ao(!1),Gl(null),Cs(),H(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();t===fd&&(dd.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,unread:!1,channel:`web`,activeRuns:0}),await Ad(r),$===r&&ys())}function xd(e){dd=e.map(e=>({...e,title:ie(e.title)})),dd.sort((e,t)=>t.createdAt-e.createdAt),yl(),Cd()}var Sd=ae(async()=>{xd(await se(`/api/sessions`,`Could not load sessions`))});function Cd(){if(document.hidden||!document.hasFocus()||!wu())return;let e=dd.find(e=>e.id===$);e?.unread&&(e.unread=!1,yl(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function wd(){return dd.find(e=>e.id===$)}function Td(e,t){let n=dd.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),yl(),Kl())}function Ed(e){hd=e;let t=dd.find(e=>e.id===$);t&&(t.state=e),yl(),Kl(),Cs(),e===`idle`&&Sd()}function Dd(e){if(!(e.sessionId!==$||e.seq<=_d))switch(_d=e.seq,e.type){case`turn-start`:vd=!0;break;case`system-input`:To(),Xa(e.text,e.origin);break;case`task-status`:$i(e.run);break;case`user-message`:{let t=te(e.text).text;if(Td(e.sessionId,t),bs(t))break;To(),H(`user`,e.text,!1,e.ts),Ba();break}case`text-start`:To();break;case`text-delta`:wo(e.text);break;case`thinking-delta`:To(),Da(e.ts,e.text);break;case`tool-start`:To(),Ta(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:Ea(e.toolCallId,e.isError,e.output);break;case`turn-end`:vd=!1,Do(e.text,e.meta),e.meta&&Ul(e.meta);break;case`queue-state`:Es(e.steering,e.followUp);break;case`queue-recovery`:Ts(e.batches,e.uncertain);break;case`context-compacted`:To(),H(`system`,`Context compacted — ${i(e.before)} → ${i(e.after)}`,!1,e.ts),Ba();break;case`error`:Ca(),H(`error`,e.message);break;case`state`:e.state===`idle`&&vd&&(vd=!1,Oo()),e.state===`idle`&&Es([],[]),Ed(e.state)}}function Od(){let e=new EventSource(`/api/events`);e.onopen=()=>void Sd(),e.onerror=()=>Uo(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){Sd();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){Hu(t.type===`task-run-changed`?t.taskId:void 0),Uu(),Wu(),t.type===`task-run-changed`&&Sd();return}if(Wu(),t.sessionId===$)return;let n=dd.find(e=>e.id===t.sessionId);n&&(n.state=t.state,yl())}}function kd(e,t,n){gd?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>gd===r&&$===e&&n===pd;r.onmessage=e=>{i()&&Dd(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&jd(e)}),r.onerror=()=>{i()&&Uo(r,`Session`)},gd=r}async function Ad(e){td(),Rc(),sd(e),!(e===$&&(gd||md))&&(++fd,++pd,yd=!1,Ns(),$=e,hd=dd.find(t=>t.id===e)?.state??`idle`,Ps(e),yl(),Kl(),Cd(),await jd(e))}async function jd(e){if($!==e)return;let t=++pd;gd?.close(),gd=null,md=!0,ko(),Es([],[]),Ts([]),Vl(),vd=!1,Ss(),_d=0,Ao(!0);let n=await oe(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||t!==pd)return;if(md=!1,!n.ok){Ao(!1),H(`error`,n.error);return}let r=n.value;jo(r.turns,r.state,r.backgroundRuns),_d=r.lastSeq,vd=r.state===`streaming`,Ed(r.state),Es(r.queue.steering,r.queue.followUp),Ts(r.queueRecovery,r.queueUncertain);let i=r.turns.reduce((e,t)=>t.meta?.completedAt??e,null);Hl(r.model,r.context,r.thinkingLevel,i),kd(e,`${r.epoch}:${r.lastSeq}`,t)}zo(),Ho(),uu();var Md=async e=>{$===e&&await jd(e)};Na({sessionId:()=>$,sessionState:()=>hd,select:e=>void Ad(e),showRun:Xu,send:(e,t)=>void Ls(e,t),ownTurn:e=>{xs(e),Ed(`streaming`)},reload:Md}),Bs({sessionId:()=>$,starting:()=>yd,sessionState:()=>hd,chatVisible:wu,setState:Ed,reload:Md}),Qc({sessionMenu:e=>{let t=wd();t&&nu(e,t)},sessionInfo:e=>{let t=wd();t&&Xl(e,t)}}),Al({sessions:()=>dd,loadSessions:Sd,currentId:()=>$,select:e=>void Ad(e),sessionMenu:nu,createSession:bd,openConsole:Ku,onTitleChanged:Kl}),jl({currentId:()=>$,currentSession:wd,createSession:e=>void bd(e),syncBar:Gu,openFiles:Zu,toggleFiles:$u}),ud({sessions:()=>dd,loadSessions:Sd,currentId:()=>$,currentSession:wd,select:e=>void Ad(e),maybeAckRead:Cd}),bu(`0.0.29`),tc(),document.addEventListener(`gesturestart`,e=>e.preventDefault()),document.addEventListener(`visibilitychange`,Cd),window.addEventListener(`focus`,Cd),Od(),Sd().then(cd);export{mr as A,rr as B,gr as C,br as D,Er as E,ur as F,g as G,h as H,dr as I,r as J,m as K,ar as L,tr as M,nr as N,Cr as O,or as P,z as R,xr as S,Sr as T,oe as U,ae as V,se as W,fr as _,pc as a,vr as b,Ri as c,Yr as d,Kr as f,pr as g,Dr as h,q as i,Ar as j,wr as k,zi as l,Tr as m,kc as n,oc as o,yr as p,ie as q,Cc as r,es as s,Nc as t,Xr as u,_r as v,hr as w,kr as x,Or as y,er as z};
@@ -1 +0,0 @@
1
- import{G as e,P as t,R as n,T as r,U as i,V as a,_ as o,p as s,y as c}from"./index-uFsZkKOQ.js";import{c as l,i as u,n as d,o as f,s as p}from"./task-runs-DPkwv2UE.js";function m(m,h,g,_){let v=new URLSearchParams,y=[],b=``,x=n(`div`,`min-h-0 flex-1 overflow-auto`),S,C={selectedId:null,rawOpen:!1,scrollTop:0,drawn:``},w=(e,t)=>g(Object.fromEntries(e),t),T=e=>{m.querySelector(`[role=alert]`)?.remove();let t=n(`p`,`p-4 text-[13px] text-red-600`,e);t.setAttribute(`role`,`alert`),m.append(t)},E={openSession:h,openTask:_,openRun:e=>w(v,e),mutate:async t=>{let n=await e(t,`POST`,`Run update failed`);n?T(n):await D()}},D=a(async()=>{let e=C.selectedId;if(e)return u(x,e,()=>w(v),E,C);let t=v.toString(),n=await i(`/api/task-runs?${t}`,`Could not load runs`);if(t!==v.toString()||C.selectedId)return;if(!n.ok)return T(n.error);m.querySelector(`[role=alert]`)?.remove();let r=JSON.stringify(n.value);b!==t+r&&(b=t+r,M(n.value))});function O(e,t){let n=new URLSearchParams(v);t?n.set(e,t):n.delete(e),n.delete(`cursor`),w(n)}function k(){if(b=``,x=n(`div`,`min-h-0 flex-1 overflow-auto`),S=void 0,C.selectedId){m.replaceChildren(x);return}m.replaceChildren(j(),x)}function A(){let e=y.map(e=>[e.name+(e.archived?` (archived)`:``),e.id]),t=v.get(`taskId`);return t&&!y.some(e=>e.id===t)&&e.push([t,t]),[[`All tasks`,``],...e]}function j(){let e=n(`div`,`automation-filters run-filters`),t=(t,i,a)=>{let o=r(a,v.get(i)??``);return o.dataset.active=String(!!v.get(i)),o.setAttribute(`aria-label`,t),o.onchange=()=>O(i,o.value),e.append(n(`label`,`filter-field ${i===`taskId`?`filter-wide`:``}`,n(`span`,``,t),o)),o};t(`State`,`state`,[[`All states`,``],...[`queued`,`running`,`succeeded`,`failed`,`cancelled`,`interrupted`,`skipped`].map(e=>[e,e])]),t(`Source`,`source`,[[`All sources`,``],...[`manual`,`agent`,`cron`,`watch`,`task`].map(e=>[e,e])]),S=t(`Task`,`taskId`,A());let i=n(`details`,`filter-dates`),a=Number(v.has(`since`))+Number(v.has(`until`));i.open=a>0,i.append(n(`summary`,`flex cursor-pointer items-center gap-1.5 py-1 text-[12px] text-neutral-600`,n(`span`,`chev`,`▸`),a?`Date range (${a})`:`Date range`));let c=n(`div`,`filter-date-fields`);for(let[e,t]of[[`From`,`since`],[`Through`,`until`]]){let r=n(`input`,s);r.type=`datetime-local`,r.setAttribute(`aria-label`,e);let i=v.get(t);if(i){let e=new Date(Number(i));Number.isFinite(e.getTime())&&(r.value=new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16))}r.dataset.active=String(!!r.value),r.onchange=()=>O(t,r.value?String(new Date(r.value).getTime()):``),c.append(n(`label`,`filter-field`,n(`span`,``,e),r))}i.append(c);let l=n(`input`,`h-4 w-4 flex-none`);l.type=`checkbox`,l.checked=v.get(`showUnmatched`)===`true`,l.onchange=()=>O(`showUnmatched`,l.checked?`true`:``);let u=n(`label`,`flex min-h-10 cursor-pointer items-center gap-2 text-[11.5px] text-neutral-500`,l,`Show unmatched probes`),d=[...v.keys()].filter(e=>e!==`cursor`).length,f=o(d?`Reset filters (${d})`:`Reset filters`);return f.classList.add(`filter-action`),f.disabled=!d,f.onclick=()=>g({}),e.append(i,n(`div`,`filter-footer`,u,f)),e}function M(e){let t=n(`div`,`divide-y divide-neutral-100`);for(let r of e.runs){let e=n(`div`,`px-4 py-3 text-[12px] transition-colors hover:bg-neutral-50`),i=n(`button`,`grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 text-left md:grid-cols-[minmax(0,1fr)_12rem_5rem]`);i.setAttribute(`type`,`button`),i.onclick=()=>w(v,r.id),i.append(n(`span`,`flex min-w-0 items-center gap-2`,p(r),n(`span`,`min-w-0 truncate font-medium text-neutral-800`,r.context.definition.name)),n(`span`,`text-right font-mono text-[11.5px] text-neutral-400 md:order-2`,l(r)),n(`span`,`col-span-2 text-neutral-500 md:order-1 md:col-span-1`,d(r.queuedAt)),n(`span`,`col-span-2 break-all font-mono text-[11px] text-neutral-400 md:order-3 md:col-span-3`,`${r.id} · ${r.triggerSource}`)),e.append(i);let a=f(r);a&&e.append(n(`p`,`mt-1.5 inline-block break-words rounded-md bg-amber-50 px-2 py-0.5 text-[11.5px] text-amber-700 ring-1 ring-amber-200`,a));let o=n(`div`,`mt-1.5 flex flex-wrap gap-1.5 text-[11px] text-neutral-500`),s=`max-w-full break-all rounded-md bg-neutral-100 px-1.5 py-0.5 text-left`,c=(e,t)=>{let r=n(`button`,`${s} cursor-pointer transition-colors hover:bg-neutral-200 hover:text-neutral-800`,e);r.setAttribute(`type`,`button`),r.onclick=t,o.append(r)};if(r.parentRunId&&c(`Parent ${r.parentRunId}`,()=>w(v,r.parentRunId)),r.resumedFromRunId&&c(`Resumed from ${r.resumedFromRunId}`,()=>w(v,r.resumedFromRunId)),r.result?.type===`task`){let e=r.result.runId;c(`Child result ${e}`,()=>w(v,e))}r.groupId&&o.append(n(`span`,s,`Group ${r.groupId}`)),o.childElementCount&&e.append(o),t.append(e)}e.runs.length||t.append(n(`div`,`p-4`,c(`No matching runs.`)));let r=n(`div`,`flex items-center gap-3 border-t border-neutral-200 p-4`);if(v.has(`cursor`)){let e=o(`Newest`);e.onclick=()=>O(`cursor`,``),r.append(e)}if(e.nextCursor){let t=o(`Older runs`);t.onclick=()=>{let t=new URLSearchParams(v);t.set(`cursor`,JSON.stringify(e.nextCursor)),w(t)},r.append(t)}let i=x.scrollTop;x.replaceChildren(t,r),x.scrollTop=i}async function N(){let e=await i(`/api/tasks?kind=task`,`Could not load task filters`);if(!e.ok)return T(e.error);JSON.stringify(y)!==JSON.stringify(e.value)&&(y=e.value,!C.selectedId&&S?.isConnected&&(S.replaceChildren(...A().map(([e,t])=>new Option(e,t))),S.value=v.get(`taskId`)??``))}let P=t(m,(e,t)=>{v=new URLSearchParams(t),C.selectedId!==(e||null)&&(C.rawOpen=!1,C.scrollTop=0),C.selectedId=e||null,k(),D(),e||N()});return Object.assign(P,{refresh(){P.visible&&D()}})}export{m as createRunsView};