@timqi/pier 0.0.28 → 0.0.29

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 (60) hide show
  1. package/dist/agent/config-sync.js +12 -1
  2. package/dist/agent/config.js +31 -23
  3. package/dist/agent/events.js +24 -4
  4. package/dist/core/router.js +10 -0
  5. package/dist/db.js +18 -0
  6. package/dist/web/public/assets/{activity-DVamP8fs.js → activity-D3m4L2IL.js} +1 -1
  7. package/dist/web/public/assets/activity-D3m4L2IL.js.br +0 -0
  8. package/dist/web/public/assets/activity-D3m4L2IL.js.gz +0 -0
  9. package/dist/web/public/assets/{boards-BKtjPwus.js → boards-BIObcQeX.js} +1 -1
  10. package/dist/web/public/assets/boards-BIObcQeX.js.br +0 -0
  11. package/dist/web/public/assets/boards-BIObcQeX.js.gz +0 -0
  12. package/dist/web/public/assets/{explorer-CjO9NAKQ.js → explorer-C_rSWPNB.js} +1 -1
  13. package/dist/web/public/assets/explorer-C_rSWPNB.js.br +0 -0
  14. package/dist/web/public/assets/explorer-C_rSWPNB.js.gz +0 -0
  15. package/dist/web/public/assets/index-CX3fYZY5.css +2 -0
  16. package/dist/web/public/assets/index-CX3fYZY5.css.br +0 -0
  17. package/dist/web/public/assets/index-CX3fYZY5.css.gz +0 -0
  18. package/dist/web/public/assets/index-uFsZkKOQ.js +85 -0
  19. package/dist/web/public/assets/index-uFsZkKOQ.js.br +0 -0
  20. package/dist/web/public/assets/index-uFsZkKOQ.js.gz +0 -0
  21. package/dist/web/public/assets/runs-Ch6DZq6O.js +1 -0
  22. package/dist/web/public/assets/runs-Ch6DZq6O.js.br +0 -0
  23. package/dist/web/public/assets/runs-Ch6DZq6O.js.gz +0 -0
  24. package/dist/web/public/assets/{settings-B8JWLbpL.js → settings-BWcEIEcv.js} +1 -1
  25. package/dist/web/public/assets/settings-BWcEIEcv.js.br +0 -0
  26. package/dist/web/public/assets/settings-BWcEIEcv.js.gz +0 -0
  27. package/dist/web/public/assets/{task-runs-BZ1brkLC.js → task-runs-DPkwv2UE.js} +1 -1
  28. package/dist/web/public/assets/task-runs-DPkwv2UE.js.br +0 -0
  29. package/dist/web/public/assets/task-runs-DPkwv2UE.js.gz +0 -0
  30. package/dist/web/public/assets/{tasks-BoYiBQpq.js → tasks-DTiCi2mH.js} +2 -2
  31. package/dist/web/public/assets/tasks-DTiCi2mH.js.br +0 -0
  32. package/dist/web/public/assets/tasks-DTiCi2mH.js.gz +0 -0
  33. package/dist/web/public/index.html +36 -23
  34. package/dist/web/public/index.html.br +0 -0
  35. package/dist/web/public/index.html.gz +0 -0
  36. package/dist/web/server.js +18 -31
  37. package/dist/web/session-state.js +54 -33
  38. package/package.json +1 -1
  39. package/skills/pier-tasks/SKILL.md +113 -79
  40. package/dist/web/public/assets/activity-DVamP8fs.js.br +0 -0
  41. package/dist/web/public/assets/activity-DVamP8fs.js.gz +0 -0
  42. package/dist/web/public/assets/boards-BKtjPwus.js.br +0 -0
  43. package/dist/web/public/assets/boards-BKtjPwus.js.gz +0 -0
  44. package/dist/web/public/assets/explorer-CjO9NAKQ.js.br +0 -0
  45. package/dist/web/public/assets/explorer-CjO9NAKQ.js.gz +0 -0
  46. package/dist/web/public/assets/index-C23sXyS3.css +0 -2
  47. package/dist/web/public/assets/index-C23sXyS3.css.br +0 -0
  48. package/dist/web/public/assets/index-C23sXyS3.css.gz +0 -0
  49. package/dist/web/public/assets/index-DzWnvhXb.js +0 -85
  50. package/dist/web/public/assets/index-DzWnvhXb.js.br +0 -0
  51. package/dist/web/public/assets/index-DzWnvhXb.js.gz +0 -0
  52. package/dist/web/public/assets/runs-CxIZAx1s.js +0 -1
  53. package/dist/web/public/assets/runs-CxIZAx1s.js.br +0 -0
  54. package/dist/web/public/assets/runs-CxIZAx1s.js.gz +0 -0
  55. package/dist/web/public/assets/settings-B8JWLbpL.js.br +0 -0
  56. package/dist/web/public/assets/settings-B8JWLbpL.js.gz +0 -0
  57. package/dist/web/public/assets/task-runs-BZ1brkLC.js.br +0 -0
  58. package/dist/web/public/assets/task-runs-BZ1brkLC.js.gz +0 -0
  59. package/dist/web/public/assets/tasks-BoYiBQpq.js.br +0 -0
  60. package/dist/web/public/assets/tasks-BoYiBQpq.js.gz +0 -0
@@ -1,85 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tasks-BoYiBQpq.js","assets/task-runs-BZ1brkLC.js","assets/runs-CxIZAx1s.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`,an=j,on=!1,sn=null,cn=C({},[rn,A,j],Ae),ln=_([`mi`,`mo`,`mn`,`ms`,`mtext`]),un=C({},ln),dn=_([`annotation-xml`]),fn=C({},dn),pn=C({},[`title`,`style`,`font`,`a`,`script`]),mn=null,hn=[`application/xhtml+xml`,`text/html`],M=null,gn=null,_n=n.createElement(`form`),vn=function(e){return e instanceof RegExp||e instanceof Function},yn=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(gn&&gn===e)return;(!e||typeof e!=`object`)&&(e={}),e=w(e),mn=hn.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,M=mn===`application/xhtml+xml`?Ae:ke,E=St(e,`ALLOWED_TAGS`,Dt,{transform:M}),D=St(e,`ALLOWED_ATTR`,Ot,{transform:M}),sn=St(e,`ALLOWED_NAMESPACES`,cn,{transform:Ae}),tn=St(e,`ADD_URI_SAFE_ATTR`,nn,{transform:M,base:nn}),$t=St(e,`ADD_DATA_URI_TAGS`,en,{transform:M,base:en}),Zt=St(e,`FORBID_CONTENTS`,Qt,{transform:M}),kt=St(e,`FORBID_TAGS`,w({}),{transform:M}),k=St(e,`FORBID_ATTR`,w({}),{transform:M}),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,an=typeof e.NAMESPACE==`string`?e.NAMESPACE:j,un=Ct(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>C({},ln)),fn=Ct(e,`HTML_INTEGRATION_POINTS`,()=>C({},dn));let t=Ct(e,`CUSTOM_ELEMENT_HANDLING`,()=>ye(null));if(O=ye(null),b(t,`tagNameCheck`)&&vn(t.tagNameCheck)&&(O.tagNameCheck=t.tagNameCheck),b(t,`attributeNameCheck`)&&vn(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,M))),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,M))),b(e,`ADD_FORBID_CONTENTS`)&&Oe(e.ADD_FORBID_CONTENTS)&&(Zt===Qt&&(Zt=w(Zt)),C(Zt,e.ADD_FORBID_CONTENTS,M)),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),gn=e},bn=C({},[...Ke,...qe,...Je]),xn=C({},[...Ye,...Xe]),Sn=function(e,t,n){return t.namespaceURI===j?e===`svg`:t.namespaceURI===rn?e===`svg`&&(n===`annotation-xml`||un[n]):!!bn[e]},Cn=function(e,t,n){return t.namespaceURI===j?e===`math`:t.namespaceURI===A?e===`math`&&fn[n]:!!xn[e]},wn=function(e,t,n){return t.namespaceURI===A&&!fn[n]||t.namespaceURI===rn&&!un[n]?!1:!xn[e]&&(pn[e]||!bn[e])},Tn=function(e){let t=ne(e);(!t||!t.tagName)&&(t={namespaceURI:an,tagName:`template`});let n=ke(e.tagName),r=ke(t.tagName);return sn[e.namespaceURI]?e.namespaceURI===A?Sn(n,t,r):e.namespaceURI===rn?Cn(n,t,r):e.namespaceURI===j?wn(n,t,r):!!(mn===`application/xhtml+xml`&&sn[e.namespaceURI]):!1},En=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`)}},Dn=function(e,t,n){try{e.removeAttributeNode(t)}catch{try{e.removeAttribute(n)}catch{}}},On=function(e){jn(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`&&Dn(e,r,i)}},kn=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{En(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},An=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[M(i)]||Dn(e,r,i)}},jn=function(e){let t=[e];for(;t.length>0;){let e=t.pop();oe(e)===T.element&&An(e);let n=te(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Mn=function(e,t){return It?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Nn=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=M(se(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Mn(`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])}},Pn=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]}mn===`application/xhtml+xml`&&an===j&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=g?pe(e):e;if(an===j)try{t=new l().parseFromString(i,mn)}catch{}if(!t||!t.documentElement){t=ve.createDocument(an,`template`,null);try{t.documentElement.innerHTML=on?ce:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),an===j?Se.call(t,Lt?`html`:`body`)[0]:Lt?t.documentElement:a},Fn=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)},In=function(e){return e=Me(e,Ie,` `),e=Me(e,Le,` `),e=Me(e,Re,` `),e},Ln=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=In(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&Ce(i,e=>{zn(e.content)&&Ln(e.content)})},Rn=function(e){let t=m?m(e):null;return typeof t!=`string`||M(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)},zn=function(e){if(!ae||typeof e!=`object`||!e)return!1;try{return ae(e)===T.documentFragment}catch{return!1}},Bn=function(e){if(!ae||typeof e!=`object`||!e)return!1;try{return typeof ae(e)==`number`}catch{return!1}};function N(e,n,r){e.length!==0&&Ce(e,e=>{e.call(t,n,r,gn)})}let Vn=function(e,t){return!!(It&&e.hasChildNodes()&&!Bn(e.firstElementChild)&&x(ft,e.textContent)&&x(ft,e.innerHTML)||It&&e.namespaceURI===j&&_t[t]&&(Bn(e.firstElementChild)||typeof e.textContent==`string`&&x(vt[t],e.textContent))||e.nodeType===T.processingInstruction||It&&e.nodeType===T.comment&&x(pt,e.data))},Hn=function(e,t){return e instanceof RegExp?x(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Un=function(e,t,n){if(!kt[t]&&Yn(t)&&Hn(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 En(e),!0},Wn=function(e,t,n,r){return e.length===0?t:t===n||t===r?w(t):t},Gn=function(e,t){return e===t||ne(e)!==null?!1:(Yt&&jn(e),!0)},Kn=function(e,n){if(N(y.beforeSanitizeElements,e,null),Gn(e,n))return!0;if(Rn(e))return En(e),!0;let r=M(se(e));if(E=Wn(y.uponSanitizeElement,E,Dt,zt),N(y.uponSanitizeElement,e,{tagName:r,allowedTags:E}),Gn(e,n))return!0;if(Vn(e,r))return En(e),!0;if(kt[r]||!(At.tagCheck instanceof Function&&At.tagCheck(r))&&!E[r]){let t=Un(e,r,n);return t===!1&&N(y.afterSanitizeElements,e,null),t}if(oe(e)===T.element&&!Tn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&x(mt,e.innerHTML))return En(e),!0;if(Ft&&e.nodeType===T.text){let n=In(e.textContent);e.textContent!==n&&(Ee(t.removed,{element:e.cloneNode()}),e.textContent=n)}return N(y.afterSanitizeElements,e,null),!1},qn=function(e,t,r){if(k[t]||Mn(t,e)||Gt&&(t===`id`||t===`name`)&&(r in n||r in _n))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:Yn(e)&&Hn(O.tagNameCheck,e)&&Hn(O.attributeNameCheck,t,e)||t===`is`&&O.allowCustomizedBuiltInElements&&Hn(O.tagNameCheck,r)},Jn=C({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Yn=function(e){return!Jn[ke(e)]&&x(Tt,e)},P=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},Xn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Rn(e)?En(e):Te(t.removed)}catch{kn(n,e)}},Zn=function(e){N(y.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Rn(e))return;D=Wn(y.uponSanitizeAttribute,D,Ot,Bt);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:D,forceKeepAttr:void 0},r=t.length,i=M(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=M(o),u=c,d=o===`value`?u:Pe(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,N(y.uponSanitizeAttribute,e,n),d=n.attrValue,Kt&&(l===`id`||l===`name`)&&Ne(d,qt)!==0&&(kn(o,e,a),d=qt+d),It&&x(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){kn(o,e,a);continue}if(l===`attributename`&&je(d,`href`)){kn(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){kn(o,e,a);continue}if(!Pt&&x(ht,d)){kn(o,e,a);continue}if(Ft&&(d=In(d)),!qn(i,l,d)){kn(o,e,a);continue}d=P(i,l,s,d),d!==u&&Xn(e,o,s,d)}}N(y.afterSanitizeAttributes,e,null)},F=function(e){let t=null,n=Fn(e);for(N(y.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(N(y.uponSanitizeShadowNode,t,null),Kn(t,e),Zn(t),zn(t.content)&&F(t.content),oe(t)===T.element){let e=re(t);zn(e)&&(Qn(e),F(e))}N(y.afterSanitizeShadowDOM,e,null)},Qn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){F(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`&&M(e)===`template`){let e=n.content;zn(e)&&t.push({node:e,shadow:null})}}if(r){let e=re(n);zn(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(on=!e,on&&(e=`<!-->`),typeof e!=`string`&&!Bn(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):yn(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`&&Bn(e);if(c){Nn(e);let t=se(e);if(typeof t==`string`){let n=M(t);if(!E[n]||kt[n])throw On(e),ze(`root node is forbidden and cannot be sanitized in-place`)}if(Rn(e))throw On(e),ze(`root node is clobbered and cannot be sanitized in-place`);try{Qn(e)}catch(t){throw On(e),t}}else if(Bn(e))i=Pn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===T.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Qn(a);else{if(!Ht&&!Ft&&!Lt&&e.indexOf(`<`)===-1)return g&&Wt?pe(e):e;if(i=Pn(e),!i)return Ht?null:Wt?ce:``}i&&Vt&&En(i.firstChild);let l=c?e:i;try{let e=Fn(l);for(;o=e.nextNode();)Kn(o,l),Zn(o),zn(o.content)&&F(o.content)}catch(n){throw c&&(On(e),Ce(t.removed,e=>{e.element&&jn(e.element)})),n}if(c)return Ce(t.removed,e=>{e.element&&jn(e.element)}),Ft&&Ln(e),e;if(Ht){if(Ft&&Ln(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=In(u)),g&&Wt?pe(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yn(e),Rt=!0,zt=E,Bt=D},t.clearConfig=function(){gn=null,Rt=!1,zt=null,Bt=null,g=le,ce=``},t.isValidAttribute=function(e,t,n){gn||yn({});let r=M(e),i=M(t);return qn(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,an=/[^\s\p{P}\p{S}]/u,on=O(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,j).getRegex(),sn=/[\p{Pi}\p{Ps}"']/u,cn=/(?!~)[\p{P}\p{S}]/u,ln=/(?!~)[\s\p{P}\p{S}]/u,un=/(?:[^\s\p{P}\p{S}]|~)/u,dn=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(),fn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,pn=O(fn,`u`).replace(/punct/g,A).getRegex(),mn=O(fn,`u`).replace(/punct/g,cn).getRegex(),hn=O(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,sn).replace(/punct/g,A).getRegex(),M=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,gn=O(M,`gu`).replace(/notPunctSpace/g,an).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),_n=O(M,`gu`).replace(/notPunctSpace/g,un).replace(/punctSpace/g,ln).replace(/punct/g,cn).getRegex(),vn=O(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,an).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),yn=O(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,an).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),bn=O(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,an).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),xn=O(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,A).getRegex(),Sn=O(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,an).replace(/punctSpace/g,j).replace(/punct/g,A).getRegex(),Cn=O(/\\(punct)/,`gu`).replace(/punct/g,A).getRegex(),wn=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(),Tn=O(Gt).replace(`(?:-->|$)`,`-->`).getRegex(),En=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`,Tn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Dn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,On=O(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Dn).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),kn=O(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Dn).replace(`ref`,Vt).getRegex(),An=O(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Vt).getRegex(),jn=O(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,kn).replace(`nolink`,An).getRegex(),Mn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Nn={_backpedal:D,anyPunctuation:Cn,autolink:wn,blockSkip:dn,br:nn,code:tn,del:D,delLDelim:D,delRDelim:D,emStrongLDelim:pn,emStrongRDelimAst:gn,emStrongRDelimUnd:yn,escape:en,link:On,nolink:An,punctuation:on,reflink:kn,reflinkSearch:jn,tag:En,text:rn,url:D},Pn={...Nn,emStrongLDelim:hn,emStrongRDelimAst:vn,emStrongRDelimUnd:bn,link:O(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Dn).getRegex(),reflink:O(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Dn).getRegex()},Fn={...Nn,emStrongRDelimAst:_n,emStrongLDelim:mn,delLDelim:xn,delRDelim:Sn,url:O(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Mn).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`,Mn).getRegex()},In={...Fn,br:O(nn).replace(`{2,}`,`*`).getRegex(),text:O(Fn.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Ln={normal:Xt,gfm:Qt,pedantic:$t},Rn={normal:Nn,gfm:Fn,breaks:In,pedantic:Pn},zn={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Bn=e=>zn[e];function N(e,t){if(t){if(k.escapeTest.test(e))return e.replace(k.escapeReplace,Bn)}else if(k.escapeTestNoEncode.test(e))return e.replace(k.escapeReplaceNoEncode,Bn);return e}function Vn(e){try{e=encodeURI(e).replace(k.percentDecode,`%`)}catch{return null}return e}function Hn(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 Un(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 Wn(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 Gn(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 Kn(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 qn(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 Jn(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 Yn=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]:Wn(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=Jn(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=Un(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Un(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:Un(t[0],`
13
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Un(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=Kn(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=Wn(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:Un(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=Hn(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:Un(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(Hn(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:Un(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=Un(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Gn(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)),qn(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 qn(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}}}},P=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 Yn,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:Ln.normal,inline:Rn.normal};this.options.pedantic?(t.block=Ln.pedantic,t.inline=Rn.pedantic):this.options.gfm&&(t.block=Ln.gfm,t.inline=this.options.breaks?Rn.breaks:Rn.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ln,inline:Rn}}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)}},Xn=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-`+N(r)+`">`+(n?i:N(i,!0))+`</code></pre>
53
- `:`<pre><code>`+(n?i:N(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>${N(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=Vn(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+N(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=Vn(e);if(i===null)return N(n);e=i;let a=`<img src="${e}" alt="${N(n)}"`;return t&&(a+=` title="${N(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:N(e.text)}},Zn=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}},F=class e{options;renderer;textRenderer;constructor(e){this.options=e||E,this.options.renderer=this.options.renderer||new Xn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Zn}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}},Qn=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?P.lex:P.lexInline}provideParser(e=this.block){return e?F.parse:F.parseInline}},$n=new class{defaults=Et();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=F;Renderer=Xn;TextRenderer=Zn;Lexer=P;Tokenizer=Yn;Hooks=Qn;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 Xn(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 Yn(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 Qn;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]=Qn.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Qn.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 P.lex(e,t??this.defaults)}parser(e,t){return F.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?P.lex:P.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?F.parse:F.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?P.lex:P.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?F.parse:F.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>`+N(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function I(e,t){return $n.parse(e,t)}I.options=I.setOptions=function(e){return $n.setOptions(e),I.defaults=$n.defaults,Dt(I.defaults),I},I.getDefaults=Et,I.defaults=E;function er(...e){return $n.use(...e),I.defaults=$n.defaults,Dt(I.defaults),I}I.use=er,I.walkTokens=function(e,t){return $n.walkTokens(e,t)},I.parseInline=$n.parseInline,I.Parser=F,I.parser=F.parse,I.Renderer=Xn,I.TextRenderer=Zn,I.Lexer=P,I.lexer=P.lex,I.Tokenizer=Yn,I.Hooks=Qn,I.parse=I,I.options,I.setOptions,I.walkTokens,I.parseInline,F.parse,P.lex;var L=e=>{let t=document.querySelector(e);if(!t)throw Error(`missing element: ${e}`);return t};function tr(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 nr=e=>{let t=tr(e);return t===`now`?`just now`:`${t} ago`};function R(e,t,...n){let r=document.createElement(e);return t&&(r.className=t),r.append(...n),r}var rr=e=>e.split(`/`).filter(Boolean).pop()??e,ir=e=>`New session in ${rr(e)}`;function ar(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 or(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function sr(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 cr(e){let t=R(`span`,`help`);return t.innerHTML=Tt.sanitize(I.parseInline(e,{async:!1})),lr(t),t}function lr(e){for(let t of e.querySelectorAll(`a`))(t.getAttribute(`href`)??``).startsWith(`#`)||(t.target=`_blank`,t.rel=`noreferrer`)}async function ur(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 dr(e,t){let n=R(`button`,e,`Copy`);n.title=`Copy to clipboard`;let r;return n.onclick=async e=>{e.stopPropagation(),n.textContent=await ur(t()).then(()=>`Copied`,()=>`Failed`),clearTimeout(r),r=setTimeout(()=>n.textContent=`Copy`,1200)},n}function fr(e,t){let n=document.createElement(`details`);n.className=e;let r=R(`summary`,`flex cursor-pointer select-none items-center gap-1.5`);return r.append(R(`span`,`chev`,`▶`),...t),n.append(r),{el:n,summary:r}}var pr=`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,mr=(e,t=!1)=>hr(e,`${t?`btn btn-primary`:`btn`} text-[12.5px]`),hr=(e,t=``)=>{let n=R(`button`,t,e);return n.type=`button`,n},gr=(...e)=>R(`div`,`flex min-h-10 flex-none flex-wrap items-center gap-2 border-b border-neutral-200 px-4 py-2`,...e);function _r(e,t,n){let r=R(`div`,`inline-flex flex-none items-center gap-0.5 rounded-lg bg-neutral-100 p-0.5`);for(let[i,a]of e){let e=a===t,o=hr(i,`cursor-pointer whitespace-nowrap rounded-md px-2.5 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 vr(e,t,n){let r=hr(e,`flex cursor-pointer items-center gap-1.5 rounded-full px-3 py-1 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 yr(e,t,...n){let r=R(`section`,`rounded-xl border border-neutral-200 bg-white shadow-xs`),i=R(`div`,`rounded-t-xl border-b border-neutral-200/70 bg-neutral-50/70 px-4 py-2.5`);return i.append(R(`h2`,`text-[13px] font-semibold text-neutral-700`,e)),t&&i.append(R(`p`,`mt-0.5 text-[11.5px] leading-snug text-neutral-500`,t)),r.append(i,R(`div`,`flex flex-col gap-4 px-4 py-3.5`,...n)),r}function br(e,t,n={}){let r=R(`div`,`flex flex-col gap-1.5`),i=R(`div`,`flex items-center gap-1.5`,R(`span`,pr,e));return n.help&&i.append(n.help),r.append(i,t),n.hint&&r.append(R(`span`,`text-[11.5px] leading-snug text-neutral-400`,n.hint)),r}var xr=`w-full rounded-lg border border-neutral-300 bg-white px-2.5 py-1.5 text-[12.5px] transition-colors placeholder:text-neutral-400 focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 focus:outline-none`,Sr=(e,t,n,r=!1)=>{let i=document.createElement(`input`);return i.className=r?`${xr} font-mono`:xr,i.value=e,i.placeholder=t,i.oninput=()=>n(i.value),i},Cr=(e=``,t=`text`)=>{let n=document.createElement(`input`);return n.type=t,n.className=xr,n.value=e,n},wr=(e,t)=>{let n=document.createElement(`select`);return n.className=`${xr} select`,n.append(...e.map(([e,t])=>new Option(e,t))),n.value=t,n},Tr=(e=``,t=4)=>{let n=document.createElement(`textarea`);return n.className=`${xr} resize-y font-mono`,n.value=e,n.rows=t,n.spellcheck=!1,n};function Er(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=R(`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 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=R(`label`,`flex cursor-pointer gap-2.5 ${e?`items-start`:`items-center`}`);if(s.append(a,o),e){let n=R(`span`,`flex items-center gap-1.5`,R(`span`,`text-[13px] text-neutral-700`,e));i&&n.append(i);let r=R(`span`,`flex min-w-0 flex-col`,n);t&&r.append(R(`span`,`text-[11.5px] leading-snug text-neutral-400`,t)),s.append(r)}return s}var Dr={idle:`text-neutral-400`,saving:`text-neutral-400`,saved:`text-green-700`,failed:`text-red-600`};function z(e,t,n){e.className=`text-[11.5px] ${Dr[t]}`,e.textContent=n}var Or=(e,t,n)=>R(`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?[R(`span`,`inline-block h-1.5 w-1.5 flex-none rounded-full ${n}`)]:[],e),kr=e=>R(`p`,`rounded-lg border border-dashed border-neutral-200 px-3 py-4 text-center text-[12.5px] text-neutral-400`,e);function Ar(e,t,n=`left`){let r=R(`span`,`group relative inline-flex`),i=hr(`?`,`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=R(`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=R(`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(R(`span`,`text-[12.5px] font-semibold text-neutral-800`,e));let s=R(`ol`,`flex list-decimal flex-col gap-1.5 pl-4`);for(let e of t){let t=R(`li`,`marker:text-neutral-400`);t.append(typeof e==`string`?cr(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 jr=(e,t)=>R(`span`,`flex flex-col gap-1`,cr(e),t),Mr=e=>`[${e.split(`/`).pop()??`file`}](file://${encodeURI(e).replace(/\(/g,`%28`).replace(/\)/g,`%29`)})`,Nr=/^ {0,3}(`{3,}|~{3,})/;function Pr(e){let t=[],n,r=0;for(let i of e.split(`
71
- `)){let e=Nr.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 Fr(e,t,n){let r=Pr(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 Ir=/^\[[^\]\n]*\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)$/;function Lr(e){let t=e.split(`
72
- `),n=t.length;for(;n>0&&Ir.test(t[n-1].trim());)n--;let r=t.slice(n).map(e=>{let t=Ir.exec(e.trim())[1];try{return decodeURIComponent(t)}catch{return t}});return{text:t.slice(0,n).join(`
73
- `).trimEnd(),paths:r}}var Rr=`modulepreload`,zr=function(e){return`/`+e},Br={},Vr=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=zr(t,n),t=s(t),t in Br)return;Br[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`:Rr,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)})},Hr,Ur;function Wr(){return Ur??=Vr(()=>import(`./hljs-tWqyD59G.js`).then(e=>Hr=e.default,e=>{console.warn(`highlighting unavailable — code stays plain text`,e)}),[]),Ur}async function Gr(e){let t=await Wr();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 Kr={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 qr(e){let t=await Wr(),n=e.split(`.`).pop()?.toLowerCase()??``,r=Kr[n]??n;return t?.getLanguage(r)?r:null}function Jr(e,t){let n=document.createElement(`span`);return Hr&&t&&e.length<=500?n.innerHTML=Hr.highlight(e,{language:t}).value:n.textContent=e,n}var Yr=2e4;function Xr(e){let t=e.split(`
74
- `);return t.at(-1)===``&&t.pop(),t.map((e,t)=>({nums:[t+1],text:e,tone:``}))}function Zr(e,t){let n=e.length<=Yr?t:null,r=Math.max(2,...e.map(e=>e.nums.reduce((e,t)=>Math.max(e,String(t).length),0))),i=R(`div`,`py-2 font-mono text-[12px] leading-[1.5]`);for(let t of e){let e=R(`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=R(`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(Qr(t,n)),i.append(e)}return i}function Qr(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=Jr(e.text,t);return r.className=n,r}let[r,i]=e.mark,a=Jr(e.text.slice(r,i),t);return a.className=`rounded-xs ${e.tone===`add`?`bg-emerald-200/80`:`bg-red-200/70`}`,R(`span`,n,Jr(e.text.slice(0,r),t),a,Jr(e.text.slice(i),t))}var $r=L(`#image-dialog`),ei=L(`#image-full`),ti=L(`#image-prev`),ni=L(`#image-next`),ri=[],ii=0;function ai(e){ri.length<2||(ii=(ii+e+ri.length)%ri.length,ei.src=ri[ii])}function oi(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,$r.showModal()}$r.onclick=()=>$r.close();var si=(e,t)=>{e.onclick=e=>{e.stopPropagation(),ai(t)}};si(ti,-1),si(ni,1),$r.onkeydown=e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),ai(e.key===`ArrowLeft`?-1:1))};function ci(e){let t=e.querySelector(`:scope > .thumbs`);if(t)return t;let n=R(`div`,`thumbs`);return e.append(n),n}function li(e){let t=document.createElement(`img`);return t.src=e,t.loading=`lazy`,t.className=`thumb`,t.onclick=()=>oi(t),t}var ui=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`bmp`]),di=524288,fi=L(`#file-dialog`),pi=L(`#file-name`),mi=L(`#file-text`),hi=L(`#file-download`);L(`#file-close`).onclick=()=>fi.close();var gi=e=>e.split(`.`).pop()?.toLowerCase()??``,_i=(e,t,n=!1)=>`/api/sessions/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}${n?`&download=1`:``}`;function vi(e,t){return Fr(e,/\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)/g,e=>{let n=e[1];try{n=decodeURIComponent(n)}catch{}return`](${_i(t,n)})`})}var yi=e=>/^\/api\/sessions\/[^/]+\/files\?/.test(e);function bi(e,t){let n=rr(t)||`file`,r=_i(e,t);return ui.has(gi(n))?Ti(r,n):Ei(r,n)}function xi(e){return new URLSearchParams(e.slice(e.indexOf(`?`)+1)).get(`path`)??``}var Si=(e,t=`text-neutral-500`)=>R(`div`,`px-3 py-2 text-[12.5px] ${t}`,e),Ci=0;async function wi(e,t){let n=++Ci;pi.textContent=t,hi.href=`${e}&download=1`,mi.replaceChildren(Si(`loading…`)),fi.showModal();let r=e=>{n===Ci&&mi.replaceChildren(e)},i;try{i=await fetch(e)}catch(e){return r(Si(`failed to load: ${String(e)}`,`text-red-600`))}if(!i.ok)return r(Si(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(Si(`Binary file — use Download.`));let o=await i.text(),s=o.length>di?`${o.slice(0,di)}\n…`:o,c=await qr(t);r(Zr(Xr(s),c))}function Ti(e,t){let n=li(e);return n.alt=t,n}function Ei(e,t){let n=gi(t),r=R(`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=R(`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=R(`span`,`min-w-0 truncate text-[13px] font-medium text-neutral-800`,t),o=R(`span`,`ml-1 flex flex-none items-center gap-0.5`),s=R(`button`,`icon-btn h-6 w-6 text-[13px]`,`◉`);s.title=`Preview`,s.onclick=r=>{r.preventDefault(),n===`pdf`?window.open(e,`_blank`,`noopener`):wi(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 Di(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=R(`div`,`thumbs`);r.append(...t),n.after(r)}}function Oi(e){let t=[];for(let n of e.querySelectorAll(`img`)){let e=n.getAttribute(`src`)??``;if(!yi(e))continue;let r=Ti(e,rr(xi(e)));n.replaceWith(r),t.push(r)}for(let n of e.querySelectorAll(`a`)){let e=n.getAttribute(`href`)??``;if(!yi(e))continue;let r=rr(xi(e))||n.textContent?.trim()||`file`,i=ui.has(gi(r))?Ti(e,r):Ei(e,r);n.replaceWith(i),t.push(i)}t.length&&Di(t)}var ki=null,Ai=`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 ji(){ki=null}function Mi(e,t,n){if(ki?.remove(),ki=null,!t.length)return;let r=R(`div`,`mt-1.5 flex flex-wrap gap-1.5`);for(let e of t){let t=R(`button`,Ai,e);t.type=`button`,t.onclick=()=>{ki===r&&(ki=null),r.remove(),n(e)},r.append(t)}e.append(r),ki=r}var Ni=8e3,Pi=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Fi=e=>typeof e==`string`&&Pi.includes(e),Ii,Li;function Ri(e,t){Ii=e,Li=t}var zi=e=>e.slice(0,8),Bi=e=>`group relative mt-1.5 border-l-2 px-5 py-2 ${e}`,Vi=e=>R(`div`,Bi(e));function Hi(e,t){let n=e.split(`
75
- `).length,r=t?e.length>300||n>4:e.length>800||n>12,i=[t?`max-h-24`:`max-h-[min(18rem,40dvh)]`,`overflow-hidden`],a=R(`div`,`mt-1 whitespace-pre-wrap break-words text-[14px] text-neutral-800 ${i.join(` `)}`,e),o=R(`button`,`mx-auto mt-1.5 hidden w-fit rounded border border-black/10 bg-white px-2 py-1 text-[12px] font-medium text-neutral-700 shadow-sm hover:bg-black/[0.03] pointer-coarse:py-3.5 dark:border-neutral-200 dark:bg-neutral-50`,`Show full message`);return o.setAttribute(`type`,`button`),o.onclick=()=>{let e=a.classList.toggle(i[0]);a.classList.toggle(i[1],e),o.textContent=e?`Show full message`:`Collapse message`,a.tabIndex=-1,a.focus({preventScroll:!0})},queueMicrotask(()=>{(a.clientHeight?a.scrollHeight>a.clientHeight+1:r)?o.classList.remove(`hidden`):a.classList.remove(...i)}),[a,o]}function Ui(e){let t=R(`div`,`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-neutral-500`,e.glyph);t.append(R(`span`,`flex-none font-semibold uppercase ${e.labelCls}`,e.label)),e.taskName&&t.append(R(`span`,`min-w-0 grow basis-0 truncate text-[12.5px] font-medium text-neutral-800`,e.taskName));let n=R(`div`,`ml-auto flex min-w-0 flex-wrap items-center gap-x-2 font-mono`);if(e.note&&n.append(R(`span`,`flex-none`,e.note)),e.model){let t=R(`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=R(`span`,`flex-none`,e.thinking);t.title=`Reasoning effort`,n.append(t)}let r=R(`button`,`flex-none hover:underline`,zi(e.runId));if(r.title=`Run ${e.runId}`,r.onclick=()=>Ii.showRun(e.runId),n.append(r),e.sessionId&&e.sessionId!==`console`){let t=e.sessionId,r=R(`button`,`flex-none text-indigo-600 hover:underline`,zi(t));r.title=`Open session ${t}`,r.onclick=()=>Ii.select(t),n.append(r)}return t.append(n),t}var Wi=`bg-fuchsia-50/70`,Gi={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:`·`}},Ki=e=>Gi[e].glyph?R(`span`,`w-3 flex-none text-center font-bold ${Gi[e].label}`,Gi[e].glyph):R(`span`,`spinner ${Gi[e].label}`),qi=new Map,Ji=new WeakMap;async function Yi(e,t){let n=await g(e,`POST`,t);n&&Li.append(`error`,n)}function Xi(e){for(let[e,t]of qi)t.isConnected||qi.delete(e);let t=qi.get(e.runId);t||(t=Vi(`${Gi[e.state].edge} ${Wi}`),t.dataset.kind=`background-run`,Li.el.append(t),qi.set(e.runId,t)),t.className=Bi(`${Gi[e.state].edge} ${Wi}`);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=Ui({glyph:Ki(e.state),label:e.state,labelCls:Gi[e.state].label,taskName:e.taskName,note:`${e.sessionMode??`task`} · depth ${String(e.depth)} · ${String(i)}s`,runId:e.runId,sessionId:e.targetSessionId}),o=R(`div`,`flex flex-none items-center gap-2 text-[11px] font-semibold text-neutral-700`);if(n){let t=R(`button`,`hover:underline`,`Stop`);t.onclick=()=>{window.confirm(`Stop "${e.taskName}"?`)&&Yi(`${r}/cancel`,`could not stop the run`)},o.append(t)}o.childElementCount&&a.append(o);let s=Ji.get(t);!s&&e.prompt!==null&&(s=Hi(e.prompt,!0),Ji.set(t,s)),t.replaceChildren(a,...s??[]),Li.scroll()}var B=null,Zi=null,Qi=null,$i=!1;function ea(){if(!Zi)return;Zi.text=Zi.text.slice(-4e3),Zi.pre.textContent=Zi.text;let e=Zi.text.split(`
76
- `).filter(Boolean).pop()??`thinking…`,t=Zi.summary.lastElementChild;t.textContent=e.length>90?`…`+e.slice(-90):e}function ta(){if(Qi){$i=!0;return}$i=!1,ea(),Qi=setTimeout(()=>{Qi=null,$i&&ta()},80)}function na(){Qi&&clearTimeout(Qi),Qi=null,$i&&ea(),$i=!1}var ra=new WeakMap,ia=e=>{let t=ra.get(e)??[];return ra.set(e,t),t};function aa(){B&&!B.toolRows.size&&_a(`done`)}var oa=null;function sa(){B=null,oa=null,Zi=null,na(),qi.clear()}function ca(){let e=oa;return!e||B?.el===e||(oa=null,e!==Li.el.lastElementChild)?null:(e.remove(),e.dataset.adopted=`1`,ua(e,e.dataset.status),e)}var la={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 ua(e,t){e.dataset.status=t,e.className=`${e.dataset.adopted?`float-left min-w-[6.5rem] pr-3 tabular-nums mt-[3px] open:float-none open:mt-0 open:mb-1.5 open:min-w-0 open:pr-0`:`mx-5 my-1.5`} rounded-md text-[11.5px] leading-[1.35] open:border open:border-black/[0.06] open:px-2 open:py-1.5 dark:open:border-neutral-200 ${la[t]}`}var da={failed:`✕`,interrupted:`⏸`};function fa(e){return e===`running`?R(`span`,`spinner`):e===`done`?R(`span`,`hidden`):R(`span`,`flex-none text-[12px] font-bold`,da[e])}function pa(e){if(B)return B;let t=fa(`running`),n=R(`span`,`min-w-0 truncate`,`working…`),{el:r}=fr(``,[t,n]);r.dataset.kind=`activity`,ua(r,`running`);let i=R(`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),ma(r,i),Li.el.append(r),oa=r,Li.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 ma(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 ha(e){Li.bulk()||!e.el.open||!e.rowsEl.dataset.follow||(e.rowsEl.scrollTop=e.rowsEl.scrollHeight)}function ga(e,t,n){let r=Math.max(1,Math.round((Date.now()-e.startTs)/1e3)),i=`${e.steps} step${e.steps===1?``:`s`} · ${r}s`;e.headline.textContent=t===`running`&&n?`${i} · ${n}`:t===`done`?i:`${i} · ${t}`,ua(e.el,t);let a=fa(t);e.statusIcon.replaceWith(a),e.statusIcon=a}function _a(e){if(!B)return;na();for(let{statusEl:e}of B.toolRows.values())e.textContent===`running…`&&(e.textContent=`interrupted`);let t=B.steps>0&&B.failedSteps===B.steps;ga(B,(B.sawError||t)&&e===`done`?`failed`:e),B=null}function va(){B&&(B.sawError=!0)}function ya(e){let t=e.slice(0,400).replace(/\s+/g,` `);return t.length>100?t.slice(0,100)+`…`:t}function ba(e,t,n,r){let i=pa(e);i.steps+=1,na(),i.thinking=null;let a=JSON.stringify(r,null,2)??``,o=R(`span`,`ml-auto flex-none text-neutral-400`,`running…`),s=R(`span`,`min-w-0 truncate text-neutral-500`,ya(a)),{el:c}=fr(`rounded-md px-1 py-0.5 font-mono text-[12.5px] hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[R(`span`,`flex-none font-semibold`,n),s,o]),l=R(`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=R(`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(R(`div`,`mt-1 flex flex-col gap-1 pl-4`,l,u)),ia(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),ha(i),ga(i,`running`,n),Li.scroll()}function xa(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,Ni)+`…`:n,i.outputPre.classList.remove(`hidden`)),t&&(r.failedSteps+=1)),ga(r,`running`)}function Sa(e,t){let n=pa(e);if(!n.thinking){na();let{el:e,summary:t}=fr(`rounded-md px-1 py-0.5 text-[12.5px] italic text-neutral-500 hover:bg-black/[0.03] dark:hover:bg-neutral-100`,[R(`span`,`min-w-0 truncate`,`thinking…`)]),r=R(`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:``},Zi=n.thinking,ha(n),ga(n,`running`,`thinking…`)}n.thinking.text+=t,ta()}var Ca=0;function wa(e,t=0,n=!1,r){let i=Date.now()-t,a=pa(i).el;for(let t of e){if(t.kind===`thinking`){Sa(i,t.text??``);continue}let e=t.id??`replay-${++Ca}`;ba(i,e,t.toolName??``,t.args),t.done&&xa(e,t.isError??!1,t.output??``)}r!==void 0&&e.some(e=>e.kind===`tool`&&e.args===void 0)&&Ta(a,r),!n&&_a(e.some(e=>e.kind===`tool`&&!e.done)?`interrupted`:`done`)}function Ta(e,t){let n=()=>{e.open&&(e.removeEventListener(`toggle`,n),Ea(e,t))};e.addEventListener(`toggle`,n)}async function Ea(e,t){let n=Ii.sessionId(),r=ia(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=ya(r),n.output&&(t.outputPre.textContent=n.output,t.outputPre.classList.remove(`hidden`))}}var Da,V=L(`#turns`);function Oa(e){Da=e,Ri(e,{el:V,append:H,scroll:Fa,bulk:()=>ka})}var ka=!1,Aa=()=>V.scrollHeight-V.scrollTop-V.clientHeight<80,ja=!0;V.addEventListener(`scroll`,()=>{ka||(ja=Aa())},{passive:!0});var Ma=0;function Na(){!ja||ka||Ma||(Ma=requestAnimationFrame(()=>{Ma=0,ja&&!ka&&(V.scrollTop=V.scrollHeight)}))}new ResizeObserver(Na).observe(V),V.addEventListener(`load`,Na,!0),new MutationObserver(Na).observe(V,{childList:!0,subtree:!0,characterData:!0});function Pa(){Aa()&&(ja=!0)}function Fa(e=!1){ka||(e&&(ja=!0),ja&&(V.scrollTop=V.scrollHeight))}var Ia=500,La=0,Ra=0,za=null;function Ba(){for(;V.childElementCount>Ia;){let e=V.firstElementChild;e.remove(),e!==za&&(e.dataset.kind===`user`&&La++,Ra++)}Ra&&(za||(za=R(`div`,`px-5 py-2 text-center text-[11.5px] italic text-neutral-400`),za.dataset.kind=`trim`),za.textContent=`${Ra} earlier row${Ra===1?``:`s`} not shown — still in the transcript, not on this screen`,V.firstElementChild!==za&&V.prepend(za))}var Va={user:{row:`border-l-indigo-500 bg-indigo-50`,body:`text-neutral-900`},assistant:{row:`border-l-transparent`,body:`text-neutral-900`},error:{row:`border-l-red-400 bg-red-50`,body:`text-red-700`},system:{row:`border-l-cyan-500 bg-cyan-50`,body:`text-neutral-800`}};function H(e,t,n=!1,r){aa();let i=e===`assistant`?ca():null,a=Va[e],o=e===`user`&&r!==void 0&&Za(r)?r:void 0,s=R(`div`,`group relative border-l-2 px-5 ${o===void 0&&V.lastElementChild?.dataset.kind===e?`pt-1 pb-2.5`:`mt-1.5 py-2.5`} ${a.row}`);s.dataset.kind=e;let c=e===`user`?Lr(t):null,l=c?.text??t,u=e===`user`?te(l):null,d=u?.id||u?.when?u:null,ee=d?.id&&d.id!==`web`?d:null,f=R(`div`,`whitespace-pre-wrap break-words ${a.body}`,d?.text??l);(c?.paths.length||d)&&(f.dataset.raw=t),n&&oo(f,t),i&&(s.classList.add(`flow-root`),s.append(i)),(ee||o!==void 0)&&s.append(Ha(ee,o)),s.append(f);let p=Da.sessionId();if(c?.paths.length&&p){let e=ci(s);for(let t of c.paths)e.append(bi(p,t))}if(e===`user`){let e=R(`button`,`absolute right-2 top-1 hidden h-6 w-6 items-center justify-center rounded text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700 group-hover:flex pointer-coarse:flex`);e.title=`Edit — resends from here; this message and later turns leave the context`,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=()=>Ka(s,f),s.append(e)}return V.append(s),Ba(),Fa(),f}function Ha(e,t){let n=R(`div`,`mb-1 flex items-baseline gap-2 text-[11.5px] leading-tight`),r=e?.name??e?.id;if(r){let t=R(`span`,`font-semibold text-indigo-700`,r);e?.id&&(t.title=e.id),n.append(t)}return t!==void 0&&n.append(Qa(t,`font-mono text-[11px] text-indigo-600`)),n}var Ua={"task-delegation":[`▶`,`delegated`,`text-cyan-700`],"task-callback":[`↩`,`callback`,`text-cyan-700`],decision:[`?`,`decision needed`,`text-amber-700`]};function Wa(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 Ga(e,t){let n=t.kind===`task-message`?t.messageKind:t.kind,[r,i,a]=Ua[n]??[`↩`,n.replace(`_`,` `),`text-cyan-700`];aa();let o=Vi(n===`decision`?`border-l-amber-400 bg-amber-50`:`border-l-cyan-500 bg-cyan-50`);o.dataset.kind=`system`;let[s,c]=Wa(e),l=t.kind===`task-callback`?t.state:void 0,u=Ui({glyph:l?Ki(l):R(`span`,`w-3 flex-none text-center font-bold ${a}`,r),label:l?`${i} \u00b7 ${l}`:i,labelCls:l?Gi[l].label:a,...t.source?{taskName:t.source.taskName,model:t.source.model,thinking:t.source.thinking}:s?{taskName:s.split(`
80
- `)[0]}:{},runId:t.runId,sessionId:t.sourceSessionId});o.append(u),o.append(...Hi(c,t.kind===`task-delegation`)),V.append(o),Ba(),Fa()}function Ka(e,t){if(Da.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-md border border-indigo-300 bg-white px-2 py-1 focus:outline-none`;let r=()=>{n.style.height=`auto`,n.style.height=`${Math.min(n.scrollHeight,192)}px`};n.oninput=r,t.classList.add(`hidden`),t.after(n),r(),n.focus(),n.setSelectionRange(n.value.length,n.value.length);let i=()=>{n.remove(),t.classList.remove(`hidden`)};n.onkeydown=t=>{if(!(t.isComposing||t.keyCode===229)&&(t.key===`Escape`&&i(),t.key===`Enter`&&!t.shiftKey)){t.preventDefault();let r=n.value.trim();if(!r)return i();qa(e,r)}}}async function qa(e,t){let n=Da.sessionId();if(!n)return;let r=La+[...V.querySelectorAll(`[data-kind="user"]`)].indexOf(e);for(;e.nextElementSibling;)e.nextElementSibling.remove();e.remove(),Da.ownTurn(t),H(`user`,t,!1,Date.now()),Fa(!0);let i=await m(`/api/sessions/${n}/turns/${r}/edit`,{text:t});if(!i.ok){let e=await h(i,`edit failed`);await Da.reload(n),H(`error`,e)}}var Ja=6e5,Ya=null,Xa=(e,t)=>new Date(e).toDateString()===new Date(t).toDateString();function Za(e){let t=Ya;return Ya=e,t===null||e-t>=Ja||!Xa(t,e)}function Qa(e,t){let n=R(`div`,t);return n.dataset.at=String(e),$a(n),to??=setInterval(no,6e4),n}function $a(e){let t=Number(e.dataset.at);e.textContent=`${ar(t)} · ${nr(t)}`}var eo=null,to;function no(){let e=V.querySelectorAll(`[data-at]`);if(!e.length){clearInterval(to),to=void 0;return}for(let t of e)$a(t)}function ro(e,t){t&&(eo?.remove(),eo=Qa(t.completedAt,`mt-1 font-mono text-[11px] text-neutral-400`),(e.parentElement??e).append(eo))}function io(e){for(let t of e.querySelectorAll(`pre`)){let e=t.querySelector(`code`);if(!e)continue;let n=R(`div`,`group/code relative`);t.replaceWith(n),n.append(t,dr(`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 ao(e){let t=Da.sessionId(),n=R(`div`,``);return n.innerHTML=Tt.sanitize(I.parse(t?vi(e,t):e,{async:!1})),lr(n),n}function oo(e,t){e.replaceChildren(...ao(t).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`),Gr(e),io(e),Oi(e)}function so(e,t,r,i=!1){let{text:a,suggestions:o}=u(t);return n({text:a,suggestions:o})?co(e,l(t)):oo(e,a),i&&Mi(e.parentElement??e,o,e=>Da.send(`auto`,e)),ro(e,r),e}function co(e,t){e.classList.remove(`md`,`whitespace-pre-wrap`),e.replaceChildren(R(`span`,`text-[12.5px] italic text-neutral-400`,t?`Stayed silent — ${t}`:`Stayed silent.`))}var lo=(e,t,n=!1)=>so(H(`assistant`,``),e,t,n),U=null,uo=null,fo=!1,po=0,mo=0;function ho(e){let t=e.dataset.raw??``;for(;e.childNodes.length>mo;)e.lastChild.remove();let n=f(t,po);n>po&&(e.append(...ao(d(t.slice(po,n))).childNodes),po=n,mo=e.childNodes.length),e.append(...ao(u(t.slice(po)).text).childNodes),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`)}function go(){if(uo){fo=!0;return}fo=!1,U&&(ho(U),Fa()),uo=setTimeout(()=>{uo=null,fo&&go()},80)}function _o(){uo&&clearTimeout(uo),uo=null,fo=!1}function vo(e){U||(U=H(`assistant`,``),po=0,mo=0),U.dataset.raw=(U.dataset.raw??``)+e,go()}function yo(e=!1,t){if(!U)return;let n=U;U=null,_o(),so(n,n.dataset.raw??``,t,e)}function bo(e,t){if(_a(`done`),U){e&&(U.dataset.raw=e),yo(!0,t);return}e&&lo(e,t,!0)}function xo(){_a(`interrupted`),yo()}function So(){V.replaceChildren(),La=0,Ra=0,za=null,Ya=null,eo=null,U=null,_o(),sa(),ji()}function Co(e){if(!e){V.querySelector(`[data-kind="loading"]`)?.remove();return}let t=R(`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(R(`div`,`skeleton h-3.5 ${e}`));V.append(t)}function wo(e,t,n){Co(!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&&(Xi(e),r.delete(t))}},o=e.reduce((e,t,n)=>t.role===`assistant`?n:e,-1);ka=!0;try{for(let[n,r]of e.entries()){let s=t===`streaming`&&n===e.length-1&&(!r.text||(r.steps?.some(e=>e.kind===`tool`&&!e.done)??!1)),c=r.steps;if(c?.length&&(wa(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]),Ga(r.text,r.origin);continue}r.role===`assistant`?lo(r.text,r.meta,t===`idle`&&n===o):H(r.role,r.text,!1,r.at)}}for(let e of r.values())Xi(e)}finally{ka=!1}Fa(!0)}var To=window.fetch.bind(window),Eo=20,Do=6e4,Oo=[],ko=new Map,Ao=e=>e instanceof Error?e.stack??`${e.name}: ${e.message}`:void 0;function jo(e,t){let n=t===void 0?e:`${e}: ${String(t)}`,r=Date.now();return r-(ko.get(n)??-6e4)<Do||(ko.size>100&&ko.clear(),ko.set(n,r),Oo=Oo.filter(e=>r-e<6e4),Oo.length>=Eo)?null:(Oo.push(r),To(`/api/client-log`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:n,stack:Ao(t),view:location.hash||`/`}),keepalive:!0}).catch(()=>{}),H(`error`,n))}function Mo(){window.__pierReporting=!0,window.addEventListener(`error`,e=>{jo(`script error: ${e.message}`,e.error)}),window.addEventListener(`unhandledrejection`,e=>{jo(`unhandled rejection`,e.reason)})}var No=window.fetch.bind(window),Po=()=>{location.assign(`/login?next=${encodeURIComponent(location.pathname+location.hash)}`)};function Fo(){window.fetch=async(...e)=>{let t=await No(...e);return t.status===401&&Po(),t}}function Io(e,t){if(e.readyState!==EventSource.CLOSED)return;let n=()=>{let e=jo(`${t} stream disconnected`);if(!e)return;let n=mr(`Reload`);n.classList.add(`ml-2`,`align-middle`),n.onclick=()=>location.reload(),e.append(` `,n)};No(`/api/sessions`).then(e=>e.status===401?Po():n(),n)}var Lo=/Mac|iP(?:hone|ad|od)/.test(navigator.userAgent),Ro=Lo?`⌘`:`Ctrl+`,zo=Lo?`⇧`:`Shift+`,Bo=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 Vo(e){let{key:t,shift:n,meta:r}=Bo(e);return`${r?`⌘`:Ro}${n?zo:``}${t.toUpperCase()}`}var Ho=`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 Uo(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=R(`div`,Ho,t,R(`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 Wo(e,t,n,r,i){Uo(e,n,Vo(t)),Jo(t,r,i)}function Go(e,t,n,r){Uo(e,t,`Esc`),document.addEventListener(`keydown`,e=>{e.key!==`Escape`||e.isComposing||e.defaultPrevented||document.querySelector(`dialog[open]`)||!r()||(e.preventDefault(),n())})}var Ko=`input, textarea, select, [contenteditable]`;function qo(e,t,n,r,i){Uo(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?.(Ko)||document.querySelector(`dialog[open]`)||!i()||(e.preventDefault(),r())})}function Jo(e,t,n){let{key:r,shift:i,meta:a}=Bo(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,Yo=L(`#composer`),G=L(`#input`),Xo=L(`#send`),Zo=L(`#send-plane`),Qo=L(`#send-queue`),$o=L(`#stop`),es=L(`#queue-panel`),ts=L(`#queue-rows`),ns=L(`#queue-label`),rs=R(`div`,`hidden max-h-48 overflow-y-auto border-t border-neutral-200 px-3 py-1.5 text-[13px]`);es.after(rs);var is=L(`#image-strip`),as=L(`#attach-input`),os=!1,ss=0,cs=new Set,ls=[],us=[];function ds(){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 fs(){G.focus()}function ps(e){let t=us.indexOf(e);return t<0?!1:(us.splice(t,1),!0)}function ms(e){us.push(e)}function hs(){us=[]}function gs(){let e=W.sessionState()===`streaming`,t=W.sessionId()!==null,n=W.starting();Xo.disabled=!t,Xo.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`}`,Xo.title=t?e?`Queue — delivered when the turn ends`:`Send`:n?`Starting the session…`:`No session`,G.placeholder=n?`Starting the session…`:`Message…`,Zo.classList.toggle(`hidden`,e),Qo.classList.toggle(`hidden`,!e),$o.classList.toggle(`hidden`,!e),$o.classList.toggle(`flex`,e)}function _s(){let e=W.chatVisible()&&os;es.classList.toggle(`hidden`,!e),es.classList.toggle(`flex`,e),rs.classList.toggle(`hidden`,!W.chatVisible()||!rs.childElementCount)}function vs(e,t=!1){let n=W.sessionId();if(rs.replaceChildren(...e.map(e=>{let t=R(`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(R(`summary`,`cursor-pointer break-words text-amber-700`,`Queue recovery: ${r}${i} (in memory)`));for(let n of[...e.steering,...e.followUp]){let e=R(`div`,`flex items-start gap-2 border-t border-neutral-100 py-1`);e.append(R(`span`,`min-w-0 flex-1 whitespace-pre-wrap break-words`,n),dr(`flex-none cursor-pointer px-1 text-neutral-500 hover:text-neutral-800`,()=>n)),t.append(e)}e.error&&t.append(R(`div`,`break-words text-red-600`,e.error));let a=R(`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=R(`div`,`flex flex-wrap items-center gap-x-2 py-1 text-amber-700`,`Automatic queue paused: acceptance unknown (in memory)`),t=R(`button`,`cursor-pointer underline`,`Recall queue`);t.title=`Clear the live queue and return its messages to the composer`,t.onclick=()=>void Ms(),e.append(t),rs.prepend(e)}_s()}function ys(e,t){++ss;let n=[...e.map(e=>({mode:`steer`,text:e})),...t.map(e=>({mode:`queued`,text:e}))];os=n.length>0,ns.textContent=n.length>1?`Queued · ${n.length}`:`Queued`,_s(),ts.replaceChildren(...n.map(e=>{let t=R(`li`,`flex items-start gap-2 text-[13px] leading-[18px]`);return e.mode===`steer`&&t.append(R(`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(R(`span`,`min-w-0 whitespace-pre-wrap break-words text-neutral-700`,e.text)),t}))}var bs=8;function xs(){is.classList.toggle(`hidden`,ls.length===0),is.classList.toggle(`flex`,ls.length>0),is.replaceChildren(...ls.map((e,t)=>{let n=e.mimeType.startsWith(`image/`)?li(`data:${e.mimeType};base64,${e.data}`):R(`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=R(`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=()=>{ls.splice(t,1),xs()},R(`div`,`relative`,n,r)}))}function Ss(e){if(ls.length>=bs){H(`error`,`attachment limit is ${bs} 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;ls.push({data:n.slice(n.indexOf(`,`)+1),mimeType:e.type||`application/octet-stream`,name:e.name||void 0}),xs()},t.readAsDataURL(e)}async function Cs(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(Mr(r))}return t}var ws=e=>`pier.draft.${e}`,Ts=0;function Es(e=W.sessionId(),t=G.value){e&&(t?localStorage.setItem(ws(e),t):localStorage.removeItem(ws(e)))}function Ds(e){++Ts,G.value=localStorage.getItem(ws(e))??``,Os(),ls=[],xs()}function Os(){let e=G.style.height;G.style.height=`auto`;let t=`${Math.min(G.scrollHeight,192)}px`;G.style.height=t,t!==e&&Fa()}var ks=!1;async function As(e,t){let n=(t??G.value).trim(),r=t===void 0?ls:[],i=W.sessionId();if(!(!n&&r.length===0||!i)){if(t===void 0){if(ks)return;ks=!0,G.value=``,Os(),Es(),ls=[],xs()}try{let t=[];if(r.length){let e=await Cs(r);if(e===null){H(`error`,`attachment upload failed`),G.value=[n,G.value.trim()].filter(Boolean).join(`
81
- `),Os(),Es(),ls=r,xs();return}t=e}let a=[n,...t].filter(Boolean).join(`
82
- `),o=W.sessionState()===`idle`&&e===`auto`;o?W.setState(`streaming`):gs(),(o||e===`steer`)&&(ms(a),H(`user`,a,!1,Date.now()),Fa(!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&&(ks=!1)}}}async function js(e){let t=W.sessionId();if(!t)return;ys([],[]);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 Ms(){let e=W.sessionId();if(!e||cs.has(e))return;cs.add(e);let t=ss,n=Ts,r=document.activeElement;try{Es();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(ws(e))??``,i=(t?[t,...a]:a).join(`
83
- `);o&&(G.value=i,Os(),n===Ts&&W.chatVisible()&&document.activeElement===r&&G.focus()),Es(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===ss&&ys([],[])}finally{cs.delete(e)}}function Ns(e){W=e,ds();let t=()=>{let e=W.sessionId();e&&fetch(`/api/sessions/${e}/abort`,{method:`POST`})};$o.onclick=t,Go($o,`Stop the running turn`,t,()=>W.sessionState()===`streaming`&&W.chatVisible()),L(`#queue-steer`).onclick=()=>void js(`steer`),L(`#queue-restart`).onclick=()=>void js(`restart`),L(`#queue-recall`).onclick=()=>void Ms(),Yo.onsubmit=e=>{e.preventDefault(),As(`auto`)},qo(G,[`/`],`Write a message`,fs,W.chatVisible),G.onfocus=Pa,G.oninput=()=>{Os(),Es()};let n=!matchMedia(`(pointer: coarse)`).matches;G.onkeydown=e=>{e.isComposing||e.keyCode===229||n&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),As(`auto`))},G.onpaste=e=>{for(let t of e.clipboardData?.items??[]){let e=t.kind===`file`?t.getAsFile():null;e&&Ss(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`),Os(),Es())},V.ondragover=e=>e.preventDefault(),V.ondrop=e=>{e.preventDefault();for(let t of e.dataTransfer?.files??[])Ss(t)},L(`#attach`).onclick=()=>as.click(),as.onchange=()=>{for(let e of as.files??[])Ss(e);as.value=``},gs()}var Ps=`pier.push`,Fs=`/sw.js`,Is=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints>1&&/Macintosh/.test(navigator.userAgent),Ls=()=>matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0;function Rs(){return window.isSecureContext?Is()&&!Ls()?`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 zs=[[/iPhone/,`iPhone`],[/iPad/,`iPad`],[/Android/,`Android`],[/Macintosh/,`Mac`],[/Windows/,`Windows`]],Bs=[[/Edg\//,`Edge`],[/Chrome\//,`Chrome`],[/Firefox\//,`Firefox`],[/Safari\//,`Safari`]];function Vs(){let e=navigator.userAgent,t=(t,n)=>t.find(([t])=>t.test(e))?.[1]??n;return`${t(zs,`Linux`)} · ${t(Bs,`browser`)}${Ls()?` (installed)`:``}`}var Hs=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},Us=null;async function Ws(){return!(`serviceWorker`in navigator)||!window.isSecureContext?null:(Us??=await navigator.serviceWorker.register(Fs,{scope:`/`}).catch(e=>(console.warn(`service worker registration failed`,e),null)),Us)}var Gs=(e,t)=>{let n=e?new Uint8Array(e):null;return n?.length===t.length&&n.every((e,n)=>e===t[n])};async function Ks(e){let{publicKey:t}=await se(`/api/push`,`Could not read this instance's push key`),n=Hs(t),r=await e.pushManager.getSubscription();if(r){if(Gs(r.options.applicationServerKey,n))return r;await r.unsubscribe()}return e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:n})}async function qs(e){return m(`/api/push/subscribe`,{...e.toJSON(),label:Vs()})}async function Js(){Zs();let e=await Ws();if(!(!e||localStorage.getItem(Ps)!==`on`)&&!(!(`Notification`in window)||Notification.permission!==`granted`))try{await qs(await Ks(e))}catch(e){console.warn(`re-registering this browser for notifications failed`,e)}}var Ys=null,Xs=null;function Zs(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),Ys=e,Xs?.()}),window.addEventListener(`appinstalled`,()=>{Ys=null,Xs?.()})}function Qs(e){let t=navigator;(e>0?t.setAppBadge?.(e):t.clearAppBadge?.())?.catch(()=>{})}function $s(){let e=R(`span`,`text-[11.5px]`,``),t=mr(`Send a test notification`),n=R(`div`,`flex items-center gap-3`,t,e),r=R(`div`,`flex flex-col gap-4`),i=()=>localStorage.getItem(Ps)===`on`;async function a(){z(e,`saving`,`asking this browser…`);let t=await Notification.requestPermission();if(t!==`granted`)return localStorage.setItem(Ps,`off`),c(),z(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 Ws();if(!n)return z(e,`failed`,`This browser refused to register a service worker.`);try{let t=await qs(await Ks(n));if(!t.ok)return z(e,`failed`,await h(t,`Could not register this browser`));localStorage.setItem(Ps,`on`),c(),z(e,`saved`,`This browser will be notified when a turn finishes unseen.`)}catch(t){z(e,`failed`,`Could not subscribe: ${String(t)}`)}}async function o(){localStorage.setItem(Ps,`off`),c();let t=await(await Ws())?.pushManager.getSubscription();t&&(await m(`/api/push/unsubscribe`,{endpoint:t.endpoint}),await t.unsubscribe()),z(e,`idle`,`This browser will not be notified.`)}t.onclick=()=>{z(e,`saving`,`sending…`),(async()=>{let t=await m(`/api/push/test`,{});if(!t.ok)return z(e,`failed`,await h(t,`Could not send`));let{sent:n,failed:r}=await t.json();z(e,r?`failed`:`saved`,`Handed ${String(n)} device(s) to their push service${r?`, ${String(r)} refused`:``}.`)})()};function s(){if(!Ys)return[];let e=mr(`Install Pier`,!0);return e.onclick=()=>{let e=Ys;e&&e.prompt().then(()=>e.userChoice).finally(()=>{Ys=null,c()})},[R(`div`,`flex items-center gap-3`,e,R(`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=Rs();if(e){r.replaceChildren(...s(),R(`p`,`text-[12.5px] leading-snug text-neutral-500`,e));return}let c=i()&&Notification.permission===`granted`;t.disabled=!c,r.replaceChildren(...s(),Er(`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 Xs=c,c(),yr(`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 ec(e){K&&!K.contains(e.target)&&q()}function tc(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),q())}function nc(e){K&&!K.contains(e.target)&&q()}function q(){K&&=(document.removeEventListener(`pointerdown`,ec,!0),document.removeEventListener(`keydown`,tc,!0),window.removeEventListener(`scroll`,nc,!0),window.removeEventListener(`resize`,q),K.remove(),null)}var rc=null;function ic(e){let t=e.getBoundingClientRect(),n={top:t.bottom+4,left:t.left};return t.width||t.height?n:rc?.anchor===e?{top:rc.top,left:rc.left}:n}var ac=()=>window.innerWidth<640;function oc(e,t){q();let n=ac();if(K=R(`div`,`fixed z-50 rounded-lg border border-neutral-200 bg-white py-1 shadow-lg ${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.append(t),(e.closest(`dialog[open]`)??document.body).append(K),!n){let t=ic(e);rc={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`,ec,!0),document.addEventListener(`keydown`,tc,!0),window.addEventListener(`scroll`,nc,!0),window.addEventListener(`resize`,q)}function sc(e){let t=R(`button`,`flex w-full cursor-pointer items-center gap-2 px-3 text-left hover:bg-neutral-100 active:bg-neutral-100 ${ac()?`py-3`:`py-1.5`}`,R(`span`,`flex-none w-3 text-indigo-600`,e.checked?`✓`:``),R(`span`,`truncate`,e.label));return e.hint&&t.append(R(`span`,`ml-auto flex-none text-[11.5px] text-neutral-400`,e.hint)),t.onclick=()=>e.onSelect(),t}function cc(e,t){oc(e,R(`div`,``,...t.map(sc)))}var J=e=>`${e.provider}/${e.id}`,lc=`pier.modelFavorites`,uc=e=>`${J(e)}@${e.thinking}`,dc=null;async function fc(){let{modelMenu:e}=await se(`/api/settings`,`Could not read the pinned model menu`);return e}function pc(){try{let e=JSON.parse(localStorage.getItem(lc)??`[]`);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 mc(e){let t=R(`button`,`flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-3 py-1.5 text-left`,R(`span`,`w-3 flex-none text-indigo-600`,e.checked?`✓`:``),R(`span`,`truncate`,e.label));e.hint&&t.append(R(`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=R(`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()},R(`div`,`group/row flex w-full items-center hover:bg-neutral-100`,t,n)}function hc({models:e,current:t,thinkingLevel:n,thinkingLevels:i,onPick:a,onThinkingPick:o}){let s=pc(),c=n,l=R(`div`,`flex w-72 flex-col`),u=R(`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=R(`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(R(`span`,`font-medium`,`Reasoning`),t),u.append(e)}let ee=e=>{let t=uc(e);s=s.some(e=>uc(e)===t)?s.filter(e=>uc(e)!==t):[...s,e],localStorage.setItem(lc,JSON.stringify(s)),re(d.value)},f=(e,t)=>s.some(n=>uc(n)===`${J(e)}@${t}`),p=R(`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(R(`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 mc({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})})}),R(`div`,`my-1 border-t border-neutral-100`))},re=n=>{p.replaceChildren();let r=n.trim().toLowerCase();ne(`Pinned`,dc??[],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(R(`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=R(`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`,R(`span`,`chev`,`▶`),R(`span`,`truncate`,e),R(`span`,`ml-auto flex-none normal-case text-neutral-300`,String(n.length)));o.append(s,...n.map(e=>mc({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(``),fc().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(dc);dc=e,t&&re(d.value)}).catch(e=>jo(`model menu unavailable`,e)),l.append(u,p),queueMicrotask(()=>d.focus()),l}function gc(e,t,n,i){let a=hr(t.model?`${t.model.id}${t.thinking?` · ${r(t.thinking)}`:``}`:t.thinking?`Pi default · ${r(t.thinking)}`:`Pi default`,`${xr} 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=hc({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...Pi],onPick:(e,n)=>{q(),i({model:e,thinking:n??t.thinking})},onThinkingPick:e=>i({...t,thinking:e})}),r=hr(`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=R(`div`,`flex flex-col`);o.append(e,R(`div`,`border-t border-neutral-200`),r),oc(a,o)},br(e,a)}var _c=async e=>{let t=await oe(`/api/fs/ls${e?.startsWith(`/`)?`?path=${encodeURIComponent(e)}`:``}`,`Could not list directories`);return t.ok?t.value:null},vc=e=>e.entries.filter(e=>e.dir&&!e.name.startsWith(`.`)).map(e=>e.name),yc=(e,t,n)=>{let r=hr(e,`flex w-full cursor-pointer items-center gap-1.5 px-3 py-1 text-left ${t}`);return r.onclick=n,r};function bc(e,t){let n=R(`div`,`flex-none border-t border-neutral-200`),r=yc(`+ 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=R(`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 xc(e,t,n){let r=e=>{n(e),q()};async function i(t){let n=await _c(t);if(!n)return;let a=R(`div`,`flex max-h-80 w-80 flex-col`),o=hr(`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=R(`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 _c(t);if(!n){c.textContent=`${t} is not a folder this can read`,c.classList.remove(`hidden`);return}r(n.path)};let l=R(`div`,`flex flex-none items-center gap-2 border-b border-neutral-200 px-3 py-1.5`,s,o),u=R(`div`,`min-h-0 flex-1 overflow-y-auto py-0.5 text-[12.5px]`);n.parent&&u.append(yc(`../`,`font-mono text-neutral-500 hover:bg-neutral-100`,()=>void i(n.parent)));let d=vc(n);for(let e of d)u.append(yc(e,`truncate hover:bg-neutral-100`,()=>void i(`${n.path}/${e}`.replace(`//`,`/`))));d.length||u.append(R(`p`,`px-3 py-1.5 text-[12px] text-neutral-400`,`No sub-folders.`)),a.append(l,c,u,bc(n.path,e=>void i(e))),oc(e,a)}i(t)}function Sc(e,t,n,r){cc(e,[...t.map(e=>({label:e.path,...e.hint?{hint:e.hint}:{},checked:e.path===n,onSelect:()=>{q(),r(e.path)}})),{label:`Browse…`,onSelect:()=>xc(e,n||void 0,r)}])}var Cc=(e,t)=>n=>{e.value=n,e.dispatchEvent(new Event(`input`,{bubbles:!0})),t?.(n)};function wc(e,t){let n=hr(`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=()=>xc(n,e.value.trim()||void 0,Cc(e,t)),n}function Tc(e,t){let n=Cc(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 Sc(e,i,r,n);xc(e,r,n)},e.addEventListener(`input`,()=>q())}function Ec(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:R(`div`,`flex items-center gap-1.5`,r,wc(r,n)),input:r}}var Dc=L(`#sidebar`),Oc=L(`#drawer-scrim`),kc=L(`#mobile-title`),Ac=L(`#mobile-menu`);function jc(){delete Dc.dataset.open,Oc.classList.add(`hidden`)}function Mc(e,t){kc.textContent=e,kc.classList.toggle(`cursor-pointer`,t),Ac.classList.toggle(`hidden`,!t)}var Nc=`pier.railClosed`;localStorage.getItem(Nc)===`1`&&(document.body.dataset.rail=`closed`);function Pc(e){document.body.dataset.rail=e?`closed`:``,localStorage.setItem(Nc,e?`1`:`0`)}function Fc(){if(Dc.dataset.open!==void 0)return jc();Dc.dataset.open=``,Oc.classList.remove(`hidden`)}var Ic=()=>window.innerWidth<768,Lc=[L(`#rail-toggle`),L(`#drawer-toggle`)],Rc=`attention absolute -right-0.5 -top-0.5 rounded-full bg-amber-500`,zc=e=>e===1?R(`span`,`${Rc} h-2 w-2`):R(`span`,`${Rc} 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 Bc(e){for(let t of Lc)t.querySelector(`.attention`)?.remove(),e&&t.append(zc(e))}var Vc=20,Hc=.35,Uc=8;function Wc(){let e=-1,t=0,n=!1,r=!1,i=1,a=e=>{Dc.style.transition=`none`,Dc.style.transform=`translateX(${String(e-i)}px)`,Oc.classList.remove(`hidden`),Oc.style.opacity=String(e/i)},o=t=>{Dc.style.transition=``,Dc.style.transform=``,Oc.style.opacity=``,t?(Dc.dataset.open=``,Oc.classList.remove(`hidden`)):jc(),e=-1,r=!1};window.addEventListener(`touchstart`,a=>{if(r||(e=-1,!Ic()||a.touches.length!==1))return;let o=a.touches[0],s=Dc.dataset.open!==void 0;if(i=Dc.offsetWidth||1,s){if(o.clientX>i)return}else{if(o.clientX>Vc||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)<Uc)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=Dc.getBoundingClientRect().right;o(n?t>i*Hc:t>i*.65)};window.addEventListener(`touchend`,s),window.addEventListener(`touchcancel`,s)}function Gc(e){Wc(),L(`#drawer-toggle`).onclick=Fc,Oc.onclick=jc,Ac.onclick=()=>e.sessionMenu(Ac),kc.onclick=()=>{Ac.classList.contains(`hidden`)||e.sessionInfo(kc)};let t=L(`#rail-toggle`);t.onclick=()=>Pc(document.body.dataset.rail!==`closed`),Wo(t,`meta+b`,`Toggle sidebar`,()=>Ic()?Fc():Pc(document.body.dataset.rail!==`closed`))}var Y,Kc=L(`#session-list`),qc=L(`#archive-dialog`),Jc=L(`#archive-list`),Yc=L(`#archive-search`),Xc=L(`#archive-count`),Zc=L(`#new-dialog`);function Qc(e,t){return e===t?0:e===void 0?-1:t===void 0?1:e-t}var $c=e=>e.modified??e.createdAt;function el(e){return{pinned:e.filter(e=>e.pinned).sort((e,t)=>Qc(e.sort,t.sort)||t.createdAt-e.createdAt),rest:e.filter(e=>!e.pinned).sort((e,t)=>$c(t)-$c(e))}}function tl(e,t){let{pinned:n,rest:r}=el(e),i=[...n,...r].slice(0,t);return{rows:i,hidden:e.length-i.length}}var nl=e=>[...new Set([...e].sort((e,t)=>t.createdAt-e.createdAt).map(e=>e.cwd))];function rl(e,t,n,r){let i=e.filter(e=>e!==t);return i.splice(i.indexOf(n)+ +!!r,0,t),i}function il(e,t,n){let r=rl(el(Y.sessions()).pinned.map(e=>e.id),e,t,n),i=new Map(r.map((e,t)=>[e,t]));for(let e of Y.sessions()){let t=i.get(e.id);t!==void 0&&(e.sort=t)}Cl();let a=()=>void Y.loadSessions();m(`/api/sessions/order`,{sessions:r}).then(e=>{e.ok||a()},a)}var al=null;function ol(e,t){e.style.boxShadow=t===null?``:`inset 0 ${t?-2:2}px 0 0 #818cf8`}function sl(e,t,n){e.draggable=!0,e.ondragstart=e=>{al=t,e.dataTransfer?.setData(`text/plain`,t)},e.ondragend=()=>{al=null,Cl(!0)};let r=t=>{let n=e.getBoundingClientRect();return t.clientY>n.top+n.height/2},i=e=>!al||al===t?!1:(e.preventDefault(),!0);e.ondragover=t=>{i(t)&&ol(e,r(t))},e.ondragleave=()=>ol(e,null),e.ondrop=t=>{let a=al;ol(e,null),i(t)&&a&&n(a,r(t))}}var cl=`h-5 w-5 flex-none items-center justify-center rounded leading-none text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700`,ll=`hidden group-hover:flex pointer-coarse:flex ${cl}`,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=R(`span`,`h-2 w-2 flex-none rounded-full ${t[0]}`);return n.title=t[1],[n]}var fl=e=>`<svg viewBox="0 0 24 24" fill="${e?`currentColor`:`none`}" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-3.5 w-3.5"><path d="M12 17v5" /><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z" /></svg>`;function pl(e,t){let n=R(`button`,t?ll:`flex ${cl}`);return n.innerHTML=fl(e.pinned),n.title=e.pinned?`Unpin`:`Pin to top`,n.onclick=t=>{t.stopPropagation(),gl(e,!e.pinned)},n}async function ml(e,t,n,r,i){let a=t=>{e(t),Cl(),Y.onPinsChanged()};a(t),(await m(r,i)).ok||a(n)}async function hl(e){let t=window.prompt(`Session name — empty resets it to the first message`,e.title??``);t!==null&&await ml(t=>e.title=t,t.trim()||void 0,e.title,`/api/sessions/${e.id}/rename`,{name:t})}var gl=(e,t)=>ml(t=>e.pinned=t,t,!t,`/api/sessions/${e.id}/pin`,{pinned:t}),_l=`flex-none font-mono text-[10px] uppercase leading-[15px] text-neutral-300`,vl=e=>e.channel&&e.channel!==`web`?[R(`span`,_l,e.channel[0]??``)]:[];function yl(e){let t=R(`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=pl(e,!0),r=R(`button`,ll,`⋯`);return r.title=`Session actions`,r.onclick=t=>{t.stopPropagation(),Y.sessionMenu(r,e)},t.append(...dl(e),R(`span`,`truncate`,e.title??`untitled`),R(`div`,`ml-auto flex flex-none items-center gap-1`,...vl(e),n,r)),t.onclick=()=>Y.select(e.id),t.title=[e.cwd,`active ${tr($c(e))} ago · created ${new Date(e.createdAt).toLocaleDateString()}`,...e.channel&&e.channel!==`web`?[`answering ${e.channel}`]:[]].join(`
85
- `),e.pinned&&sl(t,e.id,(t,n)=>il(t,e.id,n)),t}var bl=()=>`${Y.currentId()??``}\n${Sl}\n${JSON.stringify(Y.sessions())}`,xl=``,Sl=20;function Cl(e=!1){let t=bl();if(t===xl&&!e)return;xl=t;let n=Y.sessions(),r=n.filter(ul);Bc(r.length),Qs(r.length);let{rows:i,hidden:a}=tl(n,Sl),o=i.map(yl);if(a>0){let e=R(`li`,`cursor-pointer px-3 py-1.5 text-[12.5px] text-neutral-400 hover:bg-neutral-100`,`Load more (${a})`);e.onclick=()=>{Sl+=20,Cl()},o.push(e)}Kc.replaceChildren(...o.length?[R(`ul`,`pb-1`,...o)]:[R(`p`,`px-3 py-2 text-[12.5px] leading-snug text-neutral-400`,`No sessions yet — create one.`)]),qc.open&&Ml()}var wl=[{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`}],Tl=[],El=0,Dl={ArrowDown:1,ArrowUp:-1},Ol={n:1,j:1,p:-1,k:-1};function kl(e){if(Tl.length){El=(e+Tl.length)%Tl.length;for(let[e,{el:t}]of Tl.entries())t.classList.toggle(`bg-indigo-100`,e===El),t.classList.toggle(`border-indigo-500`,e===El);Tl[El]?.el.scrollIntoView({block:`nearest`})}}function Al(e){let t=R(`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(R(`span`,`min-w-0 flex-1 truncate`,e.label),R(`span`,`max-w-[45%] flex-none truncate text-[11.5px] text-neutral-400`,e.detail)),e.session&&t.append(R(`span`,`flex-none text-[11px] text-neutral-400`,tr(e.session.createdAt)),pl(e.session,!1)),t.onclick=e.open,t}var jl=e=>R(`li`,`px-3 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-neutral-400`,e);function Ml(){let e=Yc.value.trim().toLowerCase(),t=t=>!e||t.toLowerCase().includes(e),n=e=>()=>{qc.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??ir(e.cwd),detail:[rr(e.cwd),r(e)].filter(Boolean).join(` · `),open:n(()=>Y.select(e.id)),session:e}),s=i.filter(e=>e.state===`streaming`),c=el(i.filter(e=>e.state!==`streaming`)),l=[`Console`,wl.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)],[`Pinned`,c.pinned.map(o)],[`Sessions`,c.rest.map(o)]];e?u.unshift(l):u.push(l),Tl=[];let d=[];for(let[e,t]of u)if(t.length){d.push(jl(e));for(let e of t){let t=Al(e);Tl.push({el:t,open:e.open}),d.push(t)}}Jc.replaceChildren(...d.length?d:[R(`li`,`px-3 py-3 text-[13px] text-neutral-400`,`Nothing matches.`)]),Xc.textContent=String(Tl.length),kl(El)}function Nl(){if(qc.open)return qc.close();Yc.value=``,El=0,Ml(),qc.showModal(),Yc.focus(),Y.loadSessions().then(()=>{qc.open&&Ml()})}function Pl(e){Y=e,Tc(L(`#new-cwd`),()=>nl(Y.sessions()).map(e=>({path:e})));let t=L(`#new-session`),n=()=>{let e=Y.sessions().find(e=>e.id===Y.currentId())?.cwd??``,t=L(`#new-cwd`);t.value=e,Zc.showModal(),t.select()};t.onclick=n,Wo(t,`shift+o`,`New session`,n,()=>Zc.open),L(`#new-cancel`).onclick=()=>Zc.close(),L(`#new-form`).onsubmit=()=>void Y.createSession(L(`#new-cwd`).value.trim());let r=L(`#open-archive`);r.onclick=Nl,Wo(r,`k`,`Search sessions and Console`,Nl,()=>qc.open),L(`#archive-close`).onclick=()=>qc.close(),Yc.oninput=()=>{El=0,Ml()},Yc.onkeydown=e=>{let t=e.altKey||e.metaKey||e.shiftKey||!e.key?void 0:e.ctrlKey?Ol[e.key.toLowerCase()]:Dl[e.key];if(t!==void 0){e.preventDefault(),kl(El+t);return}e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),Tl[El]?.open())}}var X;function Fl(e){X=e,Jo(Ll,()=>{let e=X.currentSession();e&&(q(),gl(e,!e.pinned))},Il),Jo(Rl,()=>{X.currentSession()&&(q(),X.toggleFiles())},Il)}var Il=()=>document.querySelector(`dialog[open]`)!==null,Ll=`d`,Rl=`i`,zl=L(`#chat-title`),Bl=L(`#chat-menu`),Vl=L(`#session-meta`),Hl=null,Ul=null,Wl=null,Gl=null;function Kl(){Hl=null,Ul=null,Wl=null,Gl=null,eu()}function ql(e,t,n,r){Hl=e,Ul=t,Wl=n,Gl=r,Zl()}function Jl(e){Gl=e.completedAt,Ul&&={...Ul,tokens:e.tokens},eu()}var Yl=null;function Xl(e){Yl=e===null?null:ir(e),Zl()}function Zl(){let e=X.currentSession();e&&(Yl=null),zl.textContent=e?e.title??ir(e.cwd):Yl??X.currentId()??`no session`,zl.classList.toggle(`cursor-pointer`,!!e),zl.title=e?`Session info`:``,zl.onclick=e?()=>tu(zl,e):null,Bl.classList.toggle(`hidden`,!e),e&&(Bl.onclick=()=>su(Bl,e)),eu(),X.syncBar()}var Ql=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),$l=e=>e.tokens===null?`?/${i(e.contextWindow)}`:`${i(e.tokens)}/${i(e.contextWindow)} · ${100-Ql(e.tokens,e)}% left`;function eu(){let e=Ul,t=e?.tokens??null,n=X.currentId(),r=[];if(!n&&Yl&&r.push(R(`span`,`flex flex-none items-center gap-1.5 text-neutral-500`,R(`span`,`spinner`),`starting…`)),n){let e=(e,t)=>{let r=R(`button`,`flex-none cursor-pointer font-mono ${t}`,e);return r.title=`Change model or reasoning`,r.onclick=()=>void nu(r,n),r};Hl&&r.push(e(Hl.id,`rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),Wl&&r.push(e(Wl,`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(R(`span`,`flex-none font-mono ${a}`,i(t).toLowerCase()))}let a=r.flatMap((e,t)=>t===0?[e]:[R(`span`,`text-neutral-300`,`·`),e]);Vl.replaceChildren(...a),Vl.classList.toggle(`hidden`,r.length===0),Vl.classList.toggle(`flex`,r.length>0)}function tu(e,t){let n=[[`Title`,t.title??`untitled`],[`Directory`,t.cwd],[`Session`,t.id]],r=t.id===X.currentId();if(r&&(n.push([`Model`,Hl?.id??`—`]),n.push([`Reasoning`,Wl??`—`]),n.push([`Context`,Ul?$l(Ul):`—`])),n.push([`Created`,ar(t.createdAt),nr(t.createdAt)]),r){let e=Gl;n.push(e===null?[`Last reply`,`—`]:[`Last reply`,ar(e),nr(e)])}let i=R(`div`,`flex max-w-80 flex-col gap-1.5 px-3 py-2`);for(let[e,t,r]of n){let n=R(`div`,`flex items-center gap-1.5`,R(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),dr(`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=R(`span`,`break-all font-mono text-[12px] text-neutral-700`,t);r&&a.append(R(`span`,`ml-1.5 font-sans text-[11px] text-neutral-400`,r)),i.append(R(`div`,`group flex flex-col`,n,a))}oc(e,i)}async function nu(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`)]);oc(e,hc({models:n,current:t===X.currentId()?Hl:null,thinkingLevel:r.level,thinkingLevels:r.levels,onPick:(e,n)=>{q(),ru(t,e,n)},onThinkingPick:e=>void au(t,e)}))}catch(e){H(`error`,`model options failed: ${String(e)}`)}}async function ru(e,t,n){await iu(e,t)&&n&&await au(e,n)}async function iu(e,t){let n=Hl;e===X.currentId()&&(Hl=t,Zl());let r=await m(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===X.currentId()&&(Hl=n,Zl()),H(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===X.currentId()&&i&&(Hl=i,Zl()),!0}async function au(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()&&(Wl=r,eu())}async function ou(e){let t=await m(`/api/sessions/${e}/compact`,{});t.ok||H(`error`,`compact failed: ${await h(t,`no reason given`)}`)}function su(e,t){let n=t.id===X.currentId();cc(e,[{label:`Session info`,onSelect:()=>tu(e,t)},{label:`Rename…`,onSelect:()=>{q(),hl(t)}},{label:t.pinned?`Unpin`:`Pin`,hint:n?Vo(Ll):``,onSelect:()=>{q(),gl(t,!t.pinned)}},{label:`Model`,hint:n?Hl?.id??`…`:``,onSelect:()=>void nu(e,t.id)},{label:`Compact context`,onSelect:()=>{q(),ou(t.id)}},{label:`New session here`,hint:rr(t.cwd),onSelect:()=>{q(),X.createSession(t.cwd)}},{label:`Browse files`,hint:n?Vo(Rl):``,onSelect:()=>{q(),X.openFiles(n?void 0:t.cwd)}}])}var cu=`pier.theme`,lu=[`system`,`light`,`dark`],uu=window.matchMedia(`(prefers-color-scheme: dark)`),du={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>`},fu=()=>{let e=null;try{e=localStorage.getItem(cu)}catch{return`system`}return e===`light`||e===`dark`?e:`system`},pu=()=>{let e=fu();return e===`system`?uu.matches?`dark`:`light`:e};function mu(){let e=pu();document.documentElement.dataset.theme=e,L(`meta[name="theme-color"]`).setAttribute(`content`,e===`dark`?`#1c1c1c`:`#fafafa`),window.dispatchEvent(new Event(`pier:theme`))}function hu(){let e=L(`#theme-toggle`),t=()=>{let t=fu();e.title=`Theme: ${t}${t===`system`?` (${pu()})`:``}`,e.innerHTML=du[t],mu()};e.onclick=()=>{let e=lu[(lu.indexOf(fu())+1)%lu.length];try{e===`system`?localStorage.removeItem(cu):localStorage.setItem(cu,e)}catch{}t()},uu.addEventListener(`change`,t),t()}var gu=`https://github.com/timqi/pier`,_u=[`text-neutral-400`,`hover:text-neutral-700`],vu=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`],yu=18e5,Z=null,bu=L(`#version`);function xu(e){let t=Z?.available===!0&&Z.latest!==null;bu.textContent=`v${e}`,bu.title=t?`Pier ${Z?.latest} is out`:``,bu.classList.remove(...t?_u:vu),bu.classList.add(...t?vu:_u)}var Su=e=>R(`p`,`px-3 py-1 text-[12px] leading-snug text-neutral-500`,e);function Cu(){let e=R(`div`,`flex w-72 flex-col gap-1 py-1`);if(!Z)return e.append(Su(`Checking the registry…`)),e;let{current:t,latest:n,available:r,canApply:i,problem:a}=Z;e.append(R(`p`,`px-3 py-1 text-[12.5px] font-medium text-neutral-700`,r?`Pier ${n} is out`:`Pier ${t}`)),e.append(Su(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=R(`span`,`px-3 text-[11.5px] text-neutral-400`,``),s=R(`div`,`flex items-center gap-2 px-3 py-1.5`);if(a&&e.append(R(`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=mr(`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=R(`a`,`btn text-[12.5px] no-underline`,`Source`);c.href=r?`${gu}/releases`:gu,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(Su(`No service manager owns this Pier, so it cannot restart itself — update it with: pier update`));let l=Er(`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(R(`div`,`mt-1 border-t border-neutral-200 px-3 pb-1 pt-2`,l)),e}async function wu(e){let t=await oe(`/api/update`,`Update check failed`);t.ok&&(Z=t.value,xu(Z.current||e))}function Tu(e){xu(e),bu.onclick=e=>{e.preventDefault(),oc(bu,Cu())};let t=()=>void wu(e).catch(()=>{});t(),setInterval(t,yu)}var Q,Eu=L(`#chat-header`),Du=L(`#chat-title`),Ou=[Eu,V,L(`#composer`)],ku=()=>Iu===null,Au,ju,Mu,Nu=new Map,Pu=new Map,Fu=new Map,Iu=null,Lu=0,Ru=[`files`],zu=new Map,Bu={tasks:`Tasks`,runs:`Runs`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},Vu=[`tasks`,`runs`,`activity`],Hu=`Automation`,Uu=L(`#automation-view`),Wu=L(`#automation-tabs`),Gu=e=>Vu.includes(e)?`tasks`:e;function Ku(e){let t=e!==null&&Vu.includes(e);Uu.classList.toggle(`hidden`,!t),Uu.classList.toggle(`flex`,t),t&&Wu.replaceChildren(...Vu.map(t=>vr(Bu[t],t===e,()=>Zu(t))))}var qu=e=>Au?.refresh(e),Ju=()=>ju?.refresh(),Yu=()=>Mu?.refresh();function Xu(){Iu?Mc(Vu.includes(Iu)?Hu:Bu[Iu],!1):Mc(Du.textContent??``,Q.currentSession()!==void 0)}function Zu(e,t,n){if(Ru.includes(e)){let t=ld();t&&(t.kind!==`console`||t.name!==e)&&zu.set(e,t)}dd({kind:`console`,name:e,arg:t,query:n}),jc(),Iu=e;for(let e of Ou)e.classList.add(`hidden`);_s();for(let[t,n]of Nu)t!==e&&n.hide();for(let[t,n]of Fu)n.classList.toggle(`bg-indigo-50`,t===Gu(e));Ku(e),Xu(),Qu(e,t,n,++Lu)}async function Qu(e,t,n,r){let i=Nu.get(e);if(!i){let t=Pu.get(e);if(!t){let n=L(`#${e}-view`);t=md[e](n).catch(t=>(console.warn(`${e} view failed to load`,t),sr(n,()=>n.replaceChildren(R(`p`,`p-4 text-[13px] text-red-600`,`Could not load ${Bu[e]} — reload the page.`))))),Pu.set(e,t)}i=await t,Nu.set(e,i),Pu.delete(e)}Iu===e&&r===Lu&&i.show(t,n)}var $u=e=>Zu(`tasks`,e),ed=(e={},t)=>Zu(`runs`,t,new URLSearchParams(e).toString()),td=e=>ed({},e),nd=e=>Zu(`files`,e),rd=(e,t)=>{Iu===e?ad(e):Zu(e,t)},id=e=>rd(`files`,e);function ad(e){let t=Q.currentId(),n=zu.get(e)??(t?{kind:`session`,id:t}:null);zu.delete(e),n?dd(n):(history.replaceState(null,``,`#/`),od())}function od(){if(Iu){Iu=null;for(let e of Nu.values())e.hide();for(let e of Fu.values())e.classList.remove(`bg-indigo-50`);Ku(null);for(let e of Ou)e.classList.remove(`hidden`);_s(),Xu(),Q.maybeAckRead()}}var sd=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}${e.query?`?${e.query}`:``}`,cd={config:`files`,channels:`channels`,providers:`models`};function ld(){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 cd[n]?{kind:`console`,name:`settings`,arg:cd[n]}:Object.hasOwn(Bu,n)?{kind:`console`,name:n,arg:a,query:i}:n===`session`&&a?{kind:`session`,id:a}:null}var ud=!1;function dd(e,t=!1){if(ud)return;let n=sd(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var fd=e=>dd({kind:`session`,id:e});function pd(){let e=ld(),t=Q.sessions(),n=Q.currentId(),r=e?.kind===`session`?e.id:null,{pinned:i,rest:a}=el(t),o=r??n??(i[0]??a[0])?.id??null;ud=!0;try{o&&o!==n&&Q.select(o),e?.kind===`console`?Zu(e.name,e.arg,e.query):od(),o||Zl()}finally{ud=!1}e?.kind!==`console`&&o&&dd({kind:`session`,id:o},!0)}var md={tasks:async e=>Au=(await Vr(async()=>{let{createTasksView:e}=await import(`./tasks-BoYiBQpq.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(),ed,$u),runs:async e=>ju=(await Vr(async()=>{let{createRunsView:e}=await import(`./runs-CxIZAx1s.js`);return{createRunsView:e}},__vite__mapDeps([2,1]))).createRunsView(e,Q.select,ed,$u),activity:async e=>Mu=(await Vr(async()=>{let{createActivityView:e}=await import(`./activity-DVamP8fs.js`);return{createActivityView:e}},[])).createActivityView(e,Q.select,td),boards:async e=>(await Vr(async()=>{let{createBoardsView:e}=await import(`./boards-BKtjPwus.js`);return{createBoardsView:e}},[])).createBoardsView(e,Q.select),files:async e=>(await Vr(async()=>{let{createExplorerView:e}=await import(`./explorer-CjO9NAKQ.js`);return{createExplorerView:e}},[])).createExplorerView(e,()=>Q.currentSession(),e=>Zu(`files`,e),()=>ad(`files`)),settings:async e=>(await Vr(async()=>{let{createSettingsView:e}=await import(`./settings-B8JWLbpL.js`);return{createSettingsView:e}},[])).createSettingsView(e,()=>nl(Q.sessions()),e=>Zu(`settings`,e))};function hd(e){Q=e;for(let e of[`tasks`,`boards`,`settings`]){let t=L(`#open-${e}`);Fu.set(e,t),t.onclick=()=>Zu(e)}let t=L(`#console-section`);t.open=localStorage.getItem(`pier.consoleCollapsed`)!==`1`,t.ontoggle=()=>localStorage.setItem(`pier.consoleCollapsed`,t.open?`0`:`1`),window.onhashchange=pd}var gd=[],_d=0,vd=0,yd=!1,$=null,bd=`idle`,xd=null,Sd=0,Cd=!1,wd=!1;async function Td(e){let t=++_d;++vd,yd=!1,od(),jc(),$=null,xd?.close(),xd=null,So(),vs([]),Kl(),Xl(e),Co(!0),wd=!0,gs();let n=await m(`/api/sessions`,{cwd:e});if(t!==_d)return;if(wd=!1,!n.ok){Co(!1),Xl(null),gs(),H(`error`,`session create failed: ${n.status}`);return}let{id:r}=await n.json();t===_d&&(gd.unshift({id:r,cwd:e,createdAt:Date.now(),state:`idle`,pinned:!1,unread:!1,channel:`web`,activeRuns:0}),await Fd(r),$===r&&fs())}function Ed(e){gd=e.map(e=>({...e,title:ie(e.title)})),gd.sort((e,t)=>t.createdAt-e.createdAt),Cl(),Od()}var Dd=ae(async()=>{Ed(await se(`/api/sessions`,`Could not load sessions`))});function Od(){if(document.hidden||!document.hasFocus()||!ku())return;let e=gd.find(e=>e.id===$);e?.unread&&(e.unread=!1,Cl(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function kd(){return gd.find(e=>e.id===$)}function Ad(e,t){let n=gd.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),Cl(),Zl())}function jd(e){bd=e;let t=gd.find(e=>e.id===$);t&&(t.state=e),Cl(),Zl(),gs(),e===`idle`&&Dd()}function Md(e){if(!(e.sessionId!==$||e.seq<=Sd))switch(Sd=e.seq,e.type){case`turn-start`:Cd=!0;break;case`system-input`:yo(),Ga(e.text,e.origin);break;case`task-status`:Xi(e.run);break;case`user-message`:{let t=te(e.text).text;if(Ad(e.sessionId,t),ps(t))break;yo(),H(`user`,e.text,!1,e.ts),Fa();break}case`text-delta`:vo(e.text);break;case`thinking-delta`:Sa(e.ts,e.text);break;case`tool-start`:yo(),ba(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:xa(e.toolCallId,e.isError,e.output);break;case`turn-end`:Cd=!1,bo(e.text,e.meta),e.meta&&Jl(e.meta);break;case`queue-state`:ys(e.steering,e.followUp);break;case`queue-recovery`:vs(e.batches,e.uncertain);break;case`context-compacted`:yo(),H(`system`,`Context compacted — ${i(e.before)} → ${i(e.after)}`,!1,e.ts),Fa();break;case`error`:va(),H(`error`,e.message);break;case`state`:e.state===`idle`&&Cd&&(Cd=!1,xo()),e.state===`idle`&&ys([],[]),jd(e.state)}}function Nd(){let e=new EventSource(`/api/events`);e.onopen=()=>void Dd(),e.onerror=()=>Io(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){Dd();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){qu(t.type===`task-run-changed`?t.taskId:void 0),Ju(),Yu(),t.type===`task-run-changed`&&Dd();return}if(Yu(),t.sessionId===$)return;let n=gd.find(e=>e.id===t.sessionId);n&&(n.state=t.state,Cl())}}function Pd(e,t,n){xd?.close();let r=new EventSource(`/api/sessions/${e}/events?after=${t}`),i=()=>xd===r&&$===e&&n===vd;r.onmessage=e=>{i()&&Md(JSON.parse(e.data))},r.addEventListener(`reset`,()=>{i()&&Id(e)}),r.onerror=()=>{i()&&Io(r,`Session`)},xd=r}async function Fd(e){od(),jc(),fd(e),!(e===$&&(xd||yd))&&(++_d,++vd,wd=!1,Es(),$=e,bd=gd.find(t=>t.id===e)?.state??`idle`,Ds(e),Cl(),Zl(),Od(),await Id(e))}async function Id(e){if($!==e)return;let t=++vd;xd?.close(),xd=null,yd=!0,So(),ys([],[]),vs([]),Kl(),Cd=!1,hs(),Sd=0,Co(!0);let n=await oe(`/api/sessions/${e}/history`,`failed to load session`);if($!==e||t!==vd)return;if(yd=!1,!n.ok){Co(!1),H(`error`,n.error);return}let r=n.value;wo(r.turns,r.state,r.backgroundRuns),Sd=r.lastSeq,Cd=r.state===`streaming`,jd(r.state),ys(r.queue.steering,r.queue.followUp),vs(r.queueRecovery,r.queueUncertain);let i=r.turns.reduce((e,t)=>t.meta?.completedAt??e,null);ql(r.model,r.context,r.thinkingLevel,i),Pd(e,`${r.epoch}:${r.lastSeq}`,t)}Mo(),Fo(),hu();var Ld=async e=>{$===e&&await Id(e)};Oa({sessionId:()=>$,sessionState:()=>bd,select:e=>void Fd(e),showRun:td,send:(e,t)=>void As(e,t),ownTurn:e=>{ms(e),jd(`streaming`)},reload:Ld}),Ns({sessionId:()=>$,starting:()=>wd,sessionState:()=>bd,chatVisible:ku,setState:jd,reload:Ld}),Gc({sessionMenu:e=>{let t=kd();t&&su(e,t)},sessionInfo:e=>{let t=kd();t&&tu(e,t)}}),Pl({sessions:()=>gd,loadSessions:Dd,currentId:()=>$,select:e=>void Fd(e),sessionMenu:su,createSession:Td,openConsole:Zu,onPinsChanged:Zl}),Fl({currentId:()=>$,currentSession:kd,createSession:e=>void Td(e),syncBar:Xu,openFiles:nd,toggleFiles:id}),hd({sessions:()=>gd,loadSessions:Dd,currentId:()=>$,currentSession:kd,select:e=>void Fd(e),maybeAckRead:Od}),Tu(`0.0.28`),Js(),document.addEventListener(`visibilitychange`,Od),window.addEventListener(`focus`,Od),Nd(),Dd().then(pd);export{gr as A,ir as B,vr as C,Sr as D,z as E,dr as F,g as G,h as H,fr as I,r as J,m as K,or as L,nr as M,rr as N,Tr as O,sr as P,R,Cr as S,wr as T,oe as U,ae as V,se as W,mr as _,oc as a,br as b,Pi as c,Xr as d,qr as f,hr as g,Or as h,q as i,jr as j,Er as k,Fi as l,Dr as m,Sc as n,$s as o,xr as p,ie as q,gc as r,qo as s,Ec as t,Zr as u,yr as v,_r as w,Ar as x,kr as y,tr as z};
@@ -1 +0,0 @@
1
- import{A as e,G as t,P as n,R as r,T as i,U as a,V as o,_ as s,p as c,y as l}from"./index-DzWnvhXb.js";import{c as u,i as d,n as f,o as p,s as m}from"./task-runs-BZ1brkLC.js";function h(h,g,_,v){let y=new URLSearchParams,b=[],x=``,S=r(`div`,`min-h-0 flex-1 overflow-auto`),C=r(`div`,``),w={selectedId:null,rawOpen:!1,scrollTop:0,drawn:``},T=(e,t)=>_(Object.fromEntries(e),t),E=e=>{h.querySelector(`[role=alert]`)?.remove();let t=r(`p`,`p-4 text-[13px] text-red-600`,e);t.setAttribute(`role`,`alert`),h.append(t)},D={openSession:g,openTask:v,openRun:e=>T(y,e),mutate:async e=>{let n=await t(e,`POST`,`Run update failed`);n?E(n):await O()}},O=o(async()=>{let e=w.selectedId;if(e)return d(S,e,()=>T(y),D,w);let t=y.toString(),n=await a(`/api/task-runs?${t}`,`Could not load runs`);if(t!==y.toString()||w.selectedId)return;if(!n.ok)return E(n.error);h.querySelector(`[role=alert]`)?.remove();let r=JSON.stringify(n.value);x!==t+r&&(x=t+r,M(n.value))});function k(e,t){let n=new URLSearchParams(y);t?n.set(e,t):n.delete(e),n.delete(`cursor`),T(n)}function A(){if(x=``,S=r(`div`,`min-h-0 flex-1 overflow-auto`),w.selectedId){h.replaceChildren(S);return}C=j(),h.replaceChildren(C,S)}function j(){let t=e();t.classList.add(`text-[12px]`,`text-neutral-500`);let n=(e,n,r)=>{let a=i(r,y.get(n)??``);a.classList.add(`!w-auto`,`max-w-full`,`pr-8`),a.setAttribute(`aria-label`,e),a.onchange=()=>k(n,a.value),t.append(a)};n(`State`,`state`,[[`All states`,``],...[`queued`,`running`,`succeeded`,`failed`,`cancelled`,`interrupted`,`skipped`].map(e=>[e,e])]),n(`Source`,`source`,[[`All sources`,``],...[`manual`,`agent`,`cron`,`watch`,`task`].map(e=>[e,e])]);let a=b.map(e=>[e.name+(e.archived?` (archived)`:``),e.id]),o=y.get(`taskId`);o&&!b.some(e=>e.id===o)&&a.push([o,o]),n(`Task`,`taskId`,[[`All tasks`,``],...a]);for(let[e,n]of[[`From`,`since`],[`Through`,`until`]]){let i=r(`input`,`${c} !w-auto min-w-0`);i.type=`datetime-local`,i.setAttribute(`aria-label`,e);let a=y.get(n);if(a){let e=new Date(Number(a));Number.isFinite(e.getTime())&&(i.value=new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16))}i.onchange=()=>k(n,i.value?String(new Date(i.value).getTime()):``),t.append(r(`label`,`flex min-w-0 items-center gap-2`,e,i))}let l=[...y.keys()].filter(e=>e!==`cursor`&&e!==`showUnmatched`).length,u=s(l?`Reset filters (${l})`:`Reset filters`);return u.classList.add(`ml-auto`),u.disabled=!l,u.onclick=()=>_({}),t.append(u),t}function M(e){let t=r(`input`,``);t.type=`checkbox`,t.checked=y.get(`showUnmatched`)===`true`,t.onchange=()=>k(`showUnmatched`,t.checked?`true`:``);let n=r(`label`,`flex items-center gap-2 border-b border-neutral-100 bg-neutral-50/60 px-4 py-1.5 text-[11.5px] text-neutral-500`,t,`Show unmatched probes`),i=r(`div`,`divide-y divide-neutral-100`);for(let t of e.runs){let e=r(`div`,`px-4 py-3 text-[12px] transition-colors hover:bg-neutral-50`),n=r(`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]`);n.setAttribute(`type`,`button`),n.onclick=()=>T(y,t.id),n.append(r(`span`,`flex min-w-0 items-center gap-2`,m(t),r(`span`,`min-w-0 truncate font-medium text-neutral-800`,t.context.definition.name)),r(`span`,`text-right font-mono text-[11.5px] text-neutral-400 md:order-2`,u(t)),r(`span`,`col-span-2 text-neutral-500 md:order-1 md:col-span-1`,f(t.queuedAt)),r(`span`,`col-span-2 break-all font-mono text-[11px] text-neutral-400 md:order-3 md:col-span-3`,`${t.id} · ${t.triggerSource}`)),e.append(n);let a=p(t);a&&e.append(r(`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=r(`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 n=r(`button`,`${s} cursor-pointer transition-colors hover:bg-neutral-200 hover:text-neutral-800`,e);n.setAttribute(`type`,`button`),n.onclick=t,o.append(n)};if(t.parentRunId&&c(`Parent ${t.parentRunId}`,()=>T(y,t.parentRunId)),t.resumedFromRunId&&c(`Resumed from ${t.resumedFromRunId}`,()=>T(y,t.resumedFromRunId)),t.result?.type===`task`){let e=t.result.runId;c(`Child result ${e}`,()=>T(y,e))}t.groupId&&o.append(r(`span`,s,`Group ${t.groupId}`)),o.childElementCount&&e.append(o),i.append(e)}e.runs.length||i.append(r(`div`,`p-4`,l(`No matching runs.`)));let a=r(`div`,`flex items-center gap-3 border-t border-neutral-200 p-4`);if(y.has(`cursor`)){let e=s(`Newest`);e.onclick=()=>k(`cursor`,``),a.append(e)}if(e.nextCursor){let t=s(`Older runs`);t.onclick=()=>{let t=new URLSearchParams(y);t.set(`cursor`,JSON.stringify(e.nextCursor)),T(t)},a.append(t)}let o=S.scrollTop;S.replaceChildren(n,i,a),S.scrollTop=o}async function N(){let e=await a(`/api/tasks?kind=task`,`Could not load task filters`);if(!e.ok)return E(e.error);if(JSON.stringify(b)!==JSON.stringify(e.value)&&(b=e.value,!w.selectedId&&C.isConnected)){let e=j();C.replaceWith(e),C=e}}let P=n(h,(e,t)=>{y=new URLSearchParams(t),w.selectedId!==(e||null)&&(w.rawOpen=!1,w.scrollTop=0),w.selectedId=e||null,A(),O(),e||N()});return Object.assign(P,{refresh(){P.visible&&O()}})}export{h as createRunsView};