@timqi/pier 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -7
- package/dist/channels/slack-tool.js +28 -3
- package/dist/core/router.js +18 -4
- package/dist/main.js +98 -4
- package/dist/service.js +50 -0
- package/dist/settings.js +9 -1
- package/dist/tasks/service.js +13 -0
- package/dist/update.js +59 -7
- package/dist/web/auth.js +14 -4
- package/dist/web/explorer.js +12 -11
- package/dist/web/files.js +2 -1
- package/dist/web/instance.js +73 -7
- package/dist/web/providers.js +16 -4
- package/dist/web/public/assets/index-cCIuQnDr.css +2 -0
- package/dist/web/public/assets/index-fASxMPr6.js +90 -0
- package/dist/web/public/index.html +10 -7
- package/dist/web/server.js +69 -6
- package/docs/deploy.md +23 -1
- package/package.json +1 -1
- package/skills/pier-boards/SKILL.md +16 -7
- package/skills/pier-slack/SKILL.md +17 -1
- package/dist/web/public/assets/index-BK64pHmP.js +0 -90
- package/dist/web/public/assets/index-De4GlOq4.css +0 -2
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),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 l=(e,t,n=`POST`)=>fetch(e,{method:n,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function u(e,t){return(await e.json().catch(()=>({}))).error??`${t} (${e.status})`}async function d(e,t,n,r){let i=window.prompt(e);if(!i?.trim())return{sent:!1};try{let e=await l(t,{message:i,...n});return{sent:!0,...e.ok?{}:{error:await u(e,r)}}}catch(e){return{sent:!0,error:`${r}: ${String(e)}`}}}function f(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 p(e){if(Array.isArray(e))return e}function m(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 h(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function g(e,t){return p(e)||m(e,t)||_(e,t)||h()}function _(e,t){if(e){if(typeof e==`string`)return f(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)?f(e,t):void 0}}var v=Object.entries,y=Object.setPrototypeOf,b=Object.isFrozen,x=Object.getPrototypeOf,S=Object.getOwnPropertyDescriptor,C=Object.freeze,w=Object.seal,T=Object.create,E=typeof Reflect<`u`&&Reflect,D=E.apply,O=E.construct;C||=function(e){return e},w||=function(e){return e},D||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},O||=function(e){return new e(...[...arguments].slice(1))};var k=F(Array.prototype.forEach),A=F(Array.prototype.lastIndexOf),ee=F(Array.prototype.pop),j=F(Array.prototype.push),te=F(Array.prototype.splice),M=Array.isArray,ne=F(String.prototype.toLowerCase),N=F(String.prototype.toString),re=F(String.prototype.match),ie=F(String.prototype.replace),ae=F(String.prototype.indexOf),oe=F(String.prototype.trim),se=F(Number.prototype.toString),ce=F(Boolean.prototype.toString),le=typeof BigInt>`u`?null:F(BigInt.prototype.toString),ue=typeof Symbol>`u`?null:F(Symbol.prototype.toString),de=F(Object.prototype.hasOwnProperty),fe=F(Object.prototype.toString),P=F(RegExp.prototype.test),pe=me(TypeError);function F(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return D(e,t,n)}}function me(e){return function(){return O(e,[...arguments])}}function I(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ne;if(y&&y(e,null),!M(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(b(t)||(t[r]=e),i=e)}e[i]=!0}return e}function he(e){for(let t=0;t<e.length;t++)de(e,t)||(e[t]=null);return e}function ge(e){let t=T(null);for(let r of v(e)){var n=g(r,2);let i=n[0],a=n[1];de(e,i)&&(t[i]=M(a)?he(a):a&&typeof a==`object`&&a.constructor===Object?ge(a):a)}return t}function _e(e){switch(typeof e){case`string`:return e;case`number`:return se(e);case`boolean`:return ce(e);case`bigint`:return le?le(e):`0`;case`symbol`:return ue?ue(e):`Symbol()`;case`undefined`:return fe(e);case`function`:case`object`:{if(e===null)return fe(e);let t=e,n=ve(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:fe(e)}return fe(e)}default:return fe(e)}}function ve(e,t){for(;e!==null;){let n=S(e,t);if(n){if(n.get)return F(n.get);if(typeof n.value==`function`)return F(n.value)}e=x(e)}function n(){return null}return n}function ye(e){try{return P(e,``),!0}catch{return!1}}var be=C(`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(`.`)),xe=C(`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(`.`)),Se=C([`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`]),Ce=C([`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`]),we=C(`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(`.`)),Te=C([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Ee=C([`#text`]),De=C(`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(`.`)),Oe=C(`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(`.`)),ke=C(`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(`.`)),Ae=C([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),je=w(/{{[\w\W]*|^[\w\W]*}}/g),Me=w(/<%[\w\W]*|^[\w\W]*%>/g),Ne=w(/\${[\w\W]*/g),Pe=w(/^data-[\-\w.\u00B7-\uFFFF]+$/),Fe=w(/^aria-[\-\w]+$/),Ie=w(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Le=w(/^(?:\w+script|data):/i),Re=w(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ze=w(/^html$/i),Be=w(/^[a-z][.\w]*(-[.\w]+)+$/i),Ve=w(/<[/\w!]/g),He=w(/<[/\w]/g),Ue=w(/<\/no(script|embed|frames)/i),We=w(/\/>/i),Ge={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ke=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],qe=C(I({},Ke)),Je=function(){let e={};return k(Ke,t=>{e[t]=w(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),C(e)}(),Ye=function(){return typeof window>`u`?null:window},Xe=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}},Ze=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Qe=function(e,t,n,r){return de(e,t)&&M(e[t])?I(r.base?ge(r.base):{},e[t],r.transform):n},$e=function(e,t,n){let r=de(e,t)?e[t]:void 0;return r&&typeof r==`object`?ge(r):n()};function et(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ye(),t=e=>et(e);if(t.version=`3.4.14`,t.removed=[],!e||!e.document||e.document.nodeType!==Ge.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=ve(d,`cloneNode`),p=ve(d,`remove`),m=ve(d,`nextSibling`),h=ve(d,`childNodes`),g=ve(d,`parentNode`),_=ve(d,`shadowRoot`),y=ve(d,`attributes`),b=o&&o.prototype?ve(o.prototype,`nodeType`):null,x=o&&o.prototype?ve(o.prototype,`nodeName`):null,S=o&&o.prototype?ve(o.prototype,`ownerDocument`):null,E=function(e){return b?b(e):e.nodeType},D=function(e){return x?x(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let O,se=``,ce,le=!1,ue=0,fe=function(){if(ue>0)throw pe(`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.`)},F=function(e){fe(),ue++;try{return O.createHTML(e)}finally{ue--}},me=function(e){fe(),ue++;try{return O.createScriptURL(e)}finally{ue--}},he=function(){return le||=(ce=Xe(u,i),!0),ce},Ke=n,tt=Ke.implementation,nt=Ke.createNodeIterator,rt=Ke.createDocumentFragment,it=Ke.getElementsByTagName,at=r.importNode,L=Ze();t.isSupported=typeof v==`function`&&typeof g==`function`&&tt&&tt.createHTMLDocument!==void 0;let R=je,ot=Me,z=Ne,st=Pe,ct=Fe,lt=Le,ut=Re,dt=Be,ft=Ie,B=null,pt=I({},[...be,...xe,...Se,...we,...Ee]),V=null,mt=I({},[...De,...Oe,...ke,...Ae]),ht=Object.seal(T(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}})),gt=null,_t=null,vt=Object.seal(T(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),yt=!0,bt=!0,xt=!1,St=!0,Ct=!1,wt=!0,Tt=!1,Et=!1,Dt=null,Ot=null,kt=!1,At=!1,jt=!1,Mt=!1,Nt=!0,Pt=!1,Ft=`user-content-`,It=!0,Lt=!1,Rt={},zt=null,Bt=I({},`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(`.`)),Vt=null,Ht=I({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ut=null,Wt=I({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Gt=`http://www.w3.org/1998/Math/MathML`,Kt=`http://www.w3.org/2000/svg`,qt=`http://www.w3.org/1999/xhtml`,Jt=qt,Yt=!1,Xt=null,Zt=I({},[Gt,Kt,qt],N),Qt=C([`mi`,`mo`,`mn`,`ms`,`mtext`]),$t=I({},Qt),en=C([`annotation-xml`]),tn=I({},en),nn=I({},[`title`,`style`,`font`,`a`,`script`]),rn=null,an=[`application/xhtml+xml`,`text/html`],H=null,on=null,sn=n.createElement(`form`),cn=function(e){return e instanceof RegExp||e instanceof Function},ln=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(on&&on===e)return;(!e||typeof e!=`object`)&&(e={}),e=ge(e),rn=an.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,H=rn===`application/xhtml+xml`?N:ne,B=Qe(e,`ALLOWED_TAGS`,pt,{transform:H}),V=Qe(e,`ALLOWED_ATTR`,mt,{transform:H}),Xt=Qe(e,`ALLOWED_NAMESPACES`,Zt,{transform:N}),Ut=Qe(e,`ADD_URI_SAFE_ATTR`,Wt,{transform:H,base:Wt}),Vt=Qe(e,`ADD_DATA_URI_TAGS`,Ht,{transform:H,base:Ht}),zt=Qe(e,`FORBID_CONTENTS`,Bt,{transform:H}),gt=Qe(e,`FORBID_TAGS`,ge({}),{transform:H}),_t=Qe(e,`FORBID_ATTR`,ge({}),{transform:H}),Rt=de(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?ge(e.USE_PROFILES):e.USE_PROFILES:!1,yt=e.ALLOW_ARIA_ATTR!==!1,bt=e.ALLOW_DATA_ATTR!==!1,xt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,St=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ct=e.SAFE_FOR_TEMPLATES||!1,wt=e.SAFE_FOR_XML!==!1,Tt=e.WHOLE_DOCUMENT||!1,At=e.RETURN_DOM||!1,jt=e.RETURN_DOM_FRAGMENT||!1,Mt=e.RETURN_TRUSTED_TYPE||!1,kt=e.FORCE_BODY||!1,Nt=e.SANITIZE_DOM!==!1,Pt=e.SANITIZE_NAMED_PROPS||!1,It=e.KEEP_CONTENT!==!1,Lt=e.IN_PLACE||!1,ft=ye(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Ie,Jt=typeof e.NAMESPACE==`string`?e.NAMESPACE:qt,$t=$e(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>I({},Qt)),tn=$e(e,`HTML_INTEGRATION_POINTS`,()=>I({},en));let t=$e(e,`CUSTOM_ELEMENT_HANDLING`,()=>T(null));if(ht=T(null),de(t,`tagNameCheck`)&&cn(t.tagNameCheck)&&(ht.tagNameCheck=t.tagNameCheck),de(t,`attributeNameCheck`)&&cn(t.attributeNameCheck)&&(ht.attributeNameCheck=t.attributeNameCheck),de(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(ht.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),w(ht),Ct&&(bt=!1),jt&&(At=!0),Rt&&(B=I({},Ee),V=T(null),Rt.html===!0&&(I(B,be),I(V,De)),Rt.svg===!0&&(I(B,xe),I(V,Oe),I(V,Ae)),Rt.svgFilters===!0&&(I(B,Se),I(V,Oe),I(V,Ae)),Rt.mathMl===!0&&(I(B,we),I(V,ke),I(V,Ae))),vt.tagCheck=null,vt.attributeCheck=null,de(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?vt.tagCheck=e.ADD_TAGS:M(e.ADD_TAGS)&&(B===pt&&(B=ge(B)),I(B,e.ADD_TAGS,H))),de(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?vt.attributeCheck=e.ADD_ATTR:M(e.ADD_ATTR)&&(V===mt&&(V=ge(V)),I(V,e.ADD_ATTR,H))),de(e,`ADD_FORBID_CONTENTS`)&&M(e.ADD_FORBID_CONTENTS)&&(zt===Bt&&(zt=ge(zt)),I(zt,e.ADD_FORBID_CONTENTS,H)),It&&(B[`#text`]=!0),Tt&&I(B,[`html`,`head`,`body`]),B.table&&(I(B,[`tbody`]),delete gt.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw pe(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw pe(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=O;O=e.TRUSTED_TYPES_POLICY;try{se=F(``)}catch(e){throw O=t,e}}else e.TRUSTED_TYPES_POLICY===null?(O=void 0,se=``):(O===void 0&&(O=he()),O&&typeof se==`string`&&(se=F(``)));C&&C(e),on=e},un=I({},[...xe,...Se,...Ce]),dn=I({},[...we,...Te]),fn=function(e,t,n){return t.namespaceURI===qt?e===`svg`:t.namespaceURI===Gt?e===`svg`&&(n===`annotation-xml`||$t[n]):!!un[e]},pn=function(e,t,n){return t.namespaceURI===qt?e===`math`:t.namespaceURI===Kt?e===`math`&&tn[n]:!!dn[e]},mn=function(e,t,n){return t.namespaceURI===Kt&&!tn[n]||t.namespaceURI===Gt&&!$t[n]?!1:!dn[e]&&(nn[e]||!un[e])},hn=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:Jt,tagName:`template`});let n=ne(e.tagName),r=ne(t.tagName);return Xt[e.namespaceURI]?e.namespaceURI===Kt?fn(n,t,r):e.namespaceURI===Gt?pn(n,t,r):e.namespaceURI===qt?mn(n,t,r):!!(rn===`application/xhtml+xml`&&Xt[e.namespaceURI]):!1},gn=function(e){j(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw pe(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},_n=function(e,t,n){try{e.removeAttributeNode(t)}catch{try{e.removeAttribute(n)}catch{}}},vn=function(e){xn(e);let t=h(e);if(t){let e=[];k(t,t=>{j(e,t)}),k(e,e=>{try{p(e)}catch{}})}let n=y(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&_n(e,r,i)}},yn=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}j(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(At||jt)try{gn(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},bn=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||V[H(i)]||_n(e,r,i)}},xn=function(e){let t=[e];for(;t.length>0;){let e=t.pop();E(e)===Ge.element&&bn(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Sn=function(e,t){return wt?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Cn=function(e){if(!wt)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=E(e);if(n===Ge.processingInstruction||n===Ge.comment&&P(He,e.data)){try{p(e)}catch{}continue}if(n===Ge.element){let t=e,n=H(D(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Sn(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},wn=function(e){let t=null,r=null;if(kt)e=`<remove></remove>`+e;else{let t=re(e,/^[\r\n\t ]+/);r=t&&t[0]}rn===`application/xhtml+xml`&&Jt===qt&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=O?F(e):e;if(Jt===qt)try{t=new l().parseFromString(i,rn)}catch{}if(!t||!t.documentElement){t=tt.createDocument(Jt,`template`,null);try{t.documentElement.innerHTML=Yt?se:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Jt===qt?it.call(t,Tt?`html`:`body`)[0]:Tt?t.documentElement:a},Tn=function(e){let t=S?S(e):e.ownerDocument;return nt.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},En=function(e){return e=ie(e,R,` `),e=ie(e,ot,` `),e=ie(e,z,` `),e},Dn=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=nt.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=En(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&k(i,e=>{kn(e.content)&&Dn(e.content)})},On=function(e){let t=x?x(e):null;return typeof t!=`string`||H(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==h(e)},kn=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===Ge.documentFragment}catch{return!1}},An=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function U(e,n,r){e.length!==0&&k(e,e=>{e.call(t,n,r,on)})}let jn=function(e,t){return!!(wt&&e.hasChildNodes()&&!An(e.firstElementChild)&&P(Ve,e.textContent)&&P(Ve,e.innerHTML)||wt&&e.namespaceURI===qt&&qe[t]&&(An(e.firstElementChild)||typeof e.textContent==`string`&&P(Je[t],e.textContent))||e.nodeType===Ge.processingInstruction||wt&&e.nodeType===Ge.comment&&P(He,e.data))},Mn=function(e,t){return e instanceof RegExp?P(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},W=function(e,t,n){if(!gt[t]&&Rn(t)&&Mn(ht.tagNameCheck,t))return!1;if(It&&!zt[t]){let t=g(e),r=h(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,m(e))}}}return gn(e),!0},Nn=function(e,t,n,r){return e.length===0?t:t===n||t===r?ge(t):t},Pn=function(e,t){return e===t||g(e)!==null?!1:(Lt&&xn(e),!0)},Fn=function(e,n){if(U(L.beforeSanitizeElements,e,null),Pn(e,n))return!0;if(On(e))return gn(e),!0;let r=H(D(e));if(B=Nn(L.uponSanitizeElement,B,pt,Dt),U(L.uponSanitizeElement,e,{tagName:r,allowedTags:B}),Pn(e,n))return!0;if(jn(e,r))return gn(e),!0;if(gt[r]||!(vt.tagCheck instanceof Function&&vt.tagCheck(r))&&!B[r]){let t=W(e,r,n);return t===!1&&U(L.afterSanitizeElements,e,null),t}if(E(e)===Ge.element&&!hn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&P(Ue,e.innerHTML))return gn(e),!0;if(Ct&&e.nodeType===Ge.text){let n=En(e.textContent);e.textContent!==n&&(j(t.removed,{element:e.cloneNode()}),e.textContent=n)}return U(L.afterSanitizeElements,e,null),!1},In=function(e,t,r){if(_t[t]||Sn(t,e)||Nt&&(t===`id`||t===`name`)&&(r in n||r in sn))return!1;let i=V[t]||vt.attributeCheck instanceof Function&&vt.attributeCheck(t,e);return bt&&P(st,t)||yt&&P(ct,t)?!0:i?Ut[t]||P(ft,ie(r,ut,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ae(r,`data:`)===0&&Vt[e]||xt&&!P(lt,ie(r,ut,``))?!0:!r:Rn(e)&&Mn(ht.tagNameCheck,e)&&Mn(ht.attributeNameCheck,t,e)||t===`is`&&ht.allowCustomizedBuiltInElements&&Mn(ht.tagNameCheck,r)},Ln=I({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Rn=function(e){return!Ln[ne(e)]&&P(dt,e)},zn=function(e,t,n,r){if(O&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return F(r);case`TrustedScriptURL`:return me(r)}return r},Bn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),On(e)?gn(e):ee(t.removed)}catch{yn(n,e)}},Vn=function(e){U(L.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||On(e))return;V=Nn(L.uponSanitizeAttribute,V,mt,Ot);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0},r=t.length,i=H(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=H(o),u=c,d=o===`value`?u:oe(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,U(L.uponSanitizeAttribute,e,n),d=n.attrValue,Pt&&(l===`id`||l===`name`)&&ae(d,Ft)!==0&&(yn(o,e,a),d=Ft+d),wt&&P(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){yn(o,e,a);continue}if(l===`attributename`&&re(d,`href`)){yn(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){yn(o,e,a);continue}if(!St&&P(We,d)){yn(o,e,a);continue}if(Ct&&(d=En(d)),!In(i,l,d)){yn(o,e,a);continue}d=zn(i,l,s,d),d!==u&&Bn(e,o,s,d)}}U(L.afterSanitizeAttributes,e,null)},Hn=function(e){let t=null,n=Tn(e);for(U(L.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(U(L.uponSanitizeShadowNode,t,null),Fn(t,e),Vn(t),kn(t.content)&&Hn(t.content),E(t)===Ge.element){let e=_(t);kn(e)&&(Un(e),Hn(e))}U(L.afterSanitizeShadowDOM,e,null)},Un=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Hn(e.shadow);continue}let n=e.node,r=E(n)===Ge.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&H(e)===`template`){let e=n.content;kn(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);kn(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(Yt=!e,Yt&&(e=`<!-->`),typeof e!=`string`&&!An(e)&&(e=_e(e),typeof e!=`string`))throw pe(`dirty is not a string, aborting`);if(!t.isSupported)return e;Et?(B=Dt,V=Ot):ln(n),(L.uponSanitizeElement.length>0||L.uponSanitizeAttribute.length>0)&&(B=ge(B)),L.uponSanitizeAttribute.length>0&&(V=ge(V)),t.removed=[];let c=Lt&&typeof e!=`string`&&An(e);if(c){Cn(e);let t=D(e);if(typeof t==`string`){let n=H(t);if(!B[n]||gt[n])throw vn(e),pe(`root node is forbidden and cannot be sanitized in-place`)}if(On(e))throw vn(e),pe(`root node is clobbered and cannot be sanitized in-place`);try{Un(e)}catch(t){throw vn(e),t}}else if(An(e))i=wn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Ge.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Un(a);else{if(!At&&!Ct&&!Tt&&e.indexOf(`<`)===-1)return O&&Mt?F(e):e;if(i=wn(e),!i)return At?null:Mt?se:``}i&&kt&&gn(i.firstChild);let l=c?e:i;try{let e=Tn(l);for(;o=e.nextNode();)Fn(o,l),Vn(o),kn(o.content)&&Hn(o.content)}catch(n){throw c&&(vn(e),k(t.removed,e=>{e.element&&xn(e.element)})),n}if(c)return k(t.removed,e=>{e.element&&xn(e.element)}),Ct&&Dn(e),e;if(At){if(Ct&&Dn(i),jt)for(s=rt.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(V.shadowroot||V.shadowrootmode)&&(s=at.call(r,s,!0)),s}let u=Tt?i.outerHTML:i.innerHTML;return Tt&&B[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&P(ze,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
|
-
`+u),Ct&&(u=En(u)),O&&Mt?F(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ln(e),Et=!0,Dt=B,Ot=V},t.clearConfig=function(){on=null,Et=!1,Dt=null,Ot=null,O=ce,se=``},t.isValidAttribute=function(e,t,n){on||ln({});let r=H(e),i=H(t);return In(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&de(L,e)&&j(L[e],t)},t.removeHook=function(e,t){if(de(L,e)){if(t!==void 0){let n=A(L[e],t);return n===-1?void 0:te(L[e],n,1)[0]}return ee(L[e])}},t.removeHooks=function(e){de(L,e)&&(L[e]=[])},t.removeAllHooks=function(){L=Ze()},t}var tt=et();function nt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var rt=nt();function it(e){rt=e}var at={exec:()=>null};function L(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 R(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(z.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ot=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),z={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:L(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:L(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:L(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:L(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:L(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:L(e=>RegExp(`^ {0,${e}}>`))},st=/^(?:[ \t]*(?:\n|$))+/,ct=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,lt=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ut=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,dt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ft=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,B=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,pt=R(B).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(),V=R(B).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(),mt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,ht=/^[^\n]+/,gt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,_t=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,gt).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),vt=R(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ft).getRegex(),yt=`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`,bt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xt=R(`^ {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`,bt).replace(`tag`,yt).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),St=e=>R(mt).replace(`hr`,ut).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`,yt).getRegex(),Ct=St(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),wt=St(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Tt={blockquote:R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,wt).getRegex(),code:ct,def:_t,fences:lt,heading:dt,hr:ut,html:xt,lheading:pt,list:vt,newline:st,paragraph:Ct,table:at,text:ht},Et=R(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,ut).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`,yt).getRegex(),Dt={...Tt,lheading:V,table:Et,paragraph:R(mt).replace(`hr`,ut).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Et).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`,yt).getRegex()},Ot={...Tt,html:R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,bt).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:at,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:R(mt).replace(`hr`,ut).replace(`heading`,` *#{1,6} *[^
|
|
4
|
-
]`).replace(`lheading`,pt).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},kt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,At=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,jt=/^( {2,}|\\)\n(?!\s*$)/,Mt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Nt=/[\p{P}\p{S}]/u,Pt=/[\s\p{P}\p{S}]/u,Ft=/[^\s\p{P}\p{S}]/u,It=R(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Pt).getRegex(),Lt=/[\p{Pi}\p{Ps}"']/u,Rt=/(?!~)[\p{P}\p{S}]/u,zt=/(?!~)[\s\p{P}\p{S}]/u,Bt=/(?:[^\s\p{P}\p{S}]|~)/u,Vt=R(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,ot?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Ht=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ut=R(Ht,`u`).replace(/punct/g,Nt).getRegex(),Wt=R(Ht,`u`).replace(/punct/g,Rt).getRegex(),Gt=R(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Lt).replace(/punct/g,Nt).getRegex(),Kt=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,qt=R(Kt,`gu`).replace(/notPunctSpace/g,Ft).replace(/punctSpace/g,Pt).replace(/punct/g,Nt).getRegex(),Jt=R(Kt,`gu`).replace(/notPunctSpace/g,Bt).replace(/punctSpace/g,zt).replace(/punct/g,Rt).getRegex(),Yt=R(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Ft).replace(/punctSpace/g,Pt).replace(/punct/g,Nt).getRegex(),Xt=R(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Ft).replace(/punctSpace/g,Pt).replace(/punct/g,Nt).getRegex(),Zt=R(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Ft).replace(/punctSpace/g,Pt).replace(/punct/g,Nt).getRegex(),Qt=R(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Nt).getRegex(),$t=R(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Ft).replace(/punctSpace/g,Pt).replace(/punct/g,Nt).getRegex(),en=R(/\\(punct)/,`gu`).replace(/punct/g,Nt).getRegex(),tn=R(/^<(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(),nn=R(bt).replace(`(?:-->|$)`,`-->`).getRegex(),rn=R(`^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`,nn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),an=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,H=R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,an).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),on=R(/^!?\[(label)\]\[(ref)\]/).replace(`label`,an).replace(`ref`,gt).getRegex(),sn=R(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,gt).getRegex(),cn=R(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,on).replace(`nolink`,sn).getRegex(),ln=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,un={_backpedal:at,anyPunctuation:en,autolink:tn,blockSkip:Vt,br:jt,code:At,del:at,delLDelim:at,delRDelim:at,emStrongLDelim:Ut,emStrongRDelimAst:qt,emStrongRDelimUnd:Xt,escape:kt,link:H,nolink:sn,punctuation:It,reflink:on,reflinkSearch:cn,tag:rn,text:Mt,url:at},dn={...un,emStrongLDelim:Gt,emStrongRDelimAst:Yt,emStrongRDelimUnd:Zt,link:R(/^!?\[(label)\]\((.*?)\)/).replace(`label`,an).getRegex(),reflink:R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,an).getRegex()},fn={...un,emStrongRDelimAst:Jt,emStrongLDelim:Wt,delLDelim:Qt,delRDelim:$t,url:R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,ln).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:R(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,ln).getRegex()},pn={...fn,br:R(jt).replace(`{2,}`,`*`).getRegex(),text:R(fn.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},mn={normal:Tt,gfm:Dt,pedantic:Ot},hn={normal:un,gfm:fn,breaks:pn,pedantic:dn},gn={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},_n=e=>gn[e];function vn(e,t){if(t){if(z.escapeTest.test(e))return e.replace(z.escapeReplace,_n)}else if(z.escapeTestNoEncode.test(e))return e.replace(z.escapeReplaceNoEncode,_n);return e}function yn(e){try{e=encodeURI(e).replace(z.percentDecode,`%`)}catch{return null}return e}function bn(e,t){let n=e.replace(z.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(z.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(z.slashPipe,`|`);return n}function xn(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 Sn(e){let t=e.split(`
|
|
5
|
-
`),n=t.length-1;for(;n>=0&&z.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
6
|
-
`)}function Cn(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 wn(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 Tn(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 En(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
7
|
-
`).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(`
|
|
8
|
-
`)}var Dn=class{options;rules;lexer;constructor(e){this.options=e||rt}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]:Sn(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=En(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=xn(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:xn(t[0],`
|
|
9
|
-
`),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:xn(t[0],`
|
|
10
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=xn(t[0],`
|
|
11
|
-
`).split(`
|
|
12
|
-
`),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(`
|
|
13
|
-
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
15
|
-
${s}`:s,r=r?`${r}
|
|
16
|
-
${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(`
|
|
17
|
-
`),o=t.raw+`
|
|
18
|
-
`+a.replace(this.rules.other.blockquoteSetextReplace2,``),s=this.blockquote(o);i[i.length-1]=s,n=`${n}
|
|
19
|
-
${a}`,r=r.substring(0,r.length-t.text.length)+s.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
20
|
-
`+e.join(`
|
|
21
|
-
`),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(`
|
|
22
|
-
`);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=wn(t[2].split(`
|
|
23
|
-
`,1)[0],t[1].length),l=e.split(`
|
|
24
|
-
`,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+`
|
|
25
|
-
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
|
|
26
|
-
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
27
|
-
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
28
|
-
`+l}u=!l.trim(),r+=p+`
|
|
29
|
-
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items)if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e of i.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Sn(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:xn(t[0],`
|
|
30
|
-
`),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=bn(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
31
|
-
`):[],a={type:`table`,raw:xn(t[0],`
|
|
32
|
-
`),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(bn(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:xn(t[0],`
|
|
33
|
-
`),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)===`
|
|
34
|
-
`?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=xn(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Cn(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)),Tn(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 Tn(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}}}},On=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||rt,this.options.tokenizer=this.options.tokenizer||new Dn,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:z,block:mn.normal,inline:hn.normal};this.options.pedantic?(t.block=mn.pedantic,t.inline=hn.pedantic):this.options.gfm&&(t.block=mn.gfm,t.inline=this.options.breaks?hn.breaks:hn.gfm),this.tokenizer.rules=t}static get rules(){return{block:mn,inline:hn}}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(z.carriageReturn,`
|
|
35
|
-
`),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(z.tabCharGlobal,` `).replace(z.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+=`
|
|
36
|
-
`: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(`
|
|
37
|
-
`)?``:`
|
|
38
|
-
`)+i.raw,n.text+=`
|
|
39
|
-
`+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(`
|
|
40
|
-
`)?``:`
|
|
41
|
-
`)+i.raw,n.text+=`
|
|
42
|
-
`+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(`
|
|
43
|
-
`)?``:`
|
|
44
|
-
`)+i.raw,r.text+=`
|
|
45
|
-
`+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(`
|
|
46
|
-
`)?``:`
|
|
47
|
-
`)+i.raw,n.text+=`
|
|
48
|
-
`+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)}},kn=class{options;parser;constructor(e){this.options=e||rt}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(z.notSpaceStart)?.[0],i=e.replace(z.endingNewline,``)+`
|
|
49
|
-
`;return r?`<pre><code class="language-`+vn(r)+`">`+(n?i:vn(i,!0))+`</code></pre>
|
|
50
|
-
`:`<pre><code>`+(n?i:vn(i,!0))+`</code></pre>
|
|
51
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
52
|
-
${this.parser.parse(e)}</blockquote>
|
|
53
|
-
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
54
|
-
`}hr(e){return`<hr>
|
|
55
|
-
`}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+`>
|
|
56
|
-
`+r+`</`+i+`>
|
|
57
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
58
|
-
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
59
|
-
`}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>
|
|
60
|
-
<thead>
|
|
61
|
-
`+t+`</thead>
|
|
62
|
-
`+r+`</table>
|
|
63
|
-
`}tablerow({text:e}){return`<tr>
|
|
64
|
-
${e}</tr>
|
|
65
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
66
|
-
`}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>${vn(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=yn(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+vn(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=yn(e);if(i===null)return vn(n);e=i;let a=`<img src="${e}" alt="${vn(n)}"`;return t&&(a+=` title="${vn(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:vn(e.text)}},An=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}},U=class e{options;renderer;textRenderer;constructor(e){this.options=e||rt,this.options.renderer=this.options.renderer||new kn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new An}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}},jn=class{options;block;constructor(e){this.options=e||rt}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?On.lex:On.lexInline}provideParser(e=this.block){return e?U.parse:U.parseInline}},Mn=new class{defaults=nt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=U;Renderer=kn;TextRenderer=An;Lexer=On;Tokenizer=Dn;Hooks=jn;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 kn(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 Dn(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 jn;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]=jn.passThroughHooks.has(n)?e=>{if(this.defaults.async&&jn.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 On.lex(e,t??this.defaults)}parser(e,t){return U.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?On.lex:On.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?U.parse:U.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?On.lex:On.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?U.parse:U.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+=`
|
|
67
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+vn(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function W(e,t){return Mn.parse(e,t)}W.options=W.setOptions=function(e){return Mn.setOptions(e),W.defaults=Mn.defaults,it(W.defaults),W},W.getDefaults=nt,W.defaults=rt;function Nn(...e){return Mn.use(...e),W.defaults=Mn.defaults,it(W.defaults),W}W.use=Nn,W.walkTokens=function(e,t){return Mn.walkTokens(e,t)},W.parseInline=Mn.parseInline,W.Parser=U,W.parser=U.parse,W.Renderer=kn,W.TextRenderer=An,W.Lexer=On,W.lexer=On.lex,W.Tokenizer=Dn,W.Hooks=jn,W.parse=W,W.options,W.setOptions,W.walkTokens,W.parseInline,U.parse,On.lex;var Pn=/[\u201c\u201d"\u2018\u2019'()\uff08\uff09\u300c\u300d\u300e\u300f\u3010\u3011\u300a\u300b\u3008\u3009[\]]/;function Fn(e){let t=[],n=e=>`\uE010${t.push(e)-1}\uE011`,r=e.replace(/```[\s\S]*?```/g,e=>n(e)).replace(/`[^`\n]+`/g,e=>n(e));return r=r.replace(/\*\*(\S|\S[\s\S]*?\S)\*\*/g,(e,t)=>{let n=``,r=``,i=t;for(;i.length>1&&Pn.test(i[0]);)n+=i[0],i=i.slice(1);for(;i.length>1&&Pn.test(i.at(-1));)r=i.at(-1)+r,i=i.slice(0,-1);return n||r?`${n}**${i}**${r}`:e}),r.replace(/\uE010(\d+)\uE011/g,(e,n)=>t[Number(n)]??``)}var In=e=>!e.text.trim()&&e.suggestions.length===0,Ln=e=>e===`xhigh`?`Extra high`:e[0].toUpperCase()+e.slice(1),Rn=e=>{if(e<1e3)return String(e);let t=e/1e3;return t>=9.95?`${Math.round(t)}K`:`${t.toFixed(1)}K`};function zn(e){let t=Math.max(1,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`}var Bn=e=>`${zn(e.durationMs)} · ${Rn(e.tokens)} tok`,Vn=/(?:^|\n)[ \t]*-{3,}[ \t]*\r?\n((?:[ \t]*\[[^\]\r\n]+\][ \t]*(?:[||][ \t]*)?)+)\s*$/,Hn=/\[([^\]\r\n]+)\]/g,Un=5,Wn=/<silent>([\s\S]*?)<\/silent>/gi;function Gn(e){let t=[...e.matchAll(Wn)].map(e=>(e[1]??``).trim()).filter(Boolean);return t.length?t.join(` · `):void 0}function Kn(e,t){let n=Fn(e.replace(Wn,``).trim()),r=Gn(e),i=Vn.exec(n);if(!i?.[1])return{text:n,suggestions:[],meta:t,silence:r};let a=[...i[1].matchAll(Hn)].map(e=>(e[1]??``).trim()).filter(Boolean).slice(0,Un);return a.length?{text:n.slice(0,i.index).trimEnd(),suggestions:a,meta:t,silence:r}:{text:n,suggestions:[],meta:t,silence:r}}var G=e=>{let t=document.querySelector(e);if(!t)throw Error(`missing element: ${e}`);return t};function qn(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`}function K(e,t,...n){let r=document.createElement(e);return t&&(r.className=t),r.append(...n),r}var Jn=e=>e.split(`/`).filter(Boolean).pop()??e;function Yn(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Xn(e,t,n){return{visible:!1,show(n){this.visible=!0,e.classList.remove(`hidden`),e.classList.add(`flex`),t(n)},hide(){n?.(),this.visible=!1,e.classList.add(`hidden`),e.classList.remove(`flex`)}}}function Zn(e){let t=K(`span`,`help`);t.innerHTML=tt.sanitize(W.parseInline(e,{async:!1}));for(let e of t.querySelectorAll(`a`))e.target=`_blank`,e.rel=`noreferrer`;return t}async function Qn(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 $n(e,t){let n=K(`button`,e,`Copy`);n.title=`Copy to clipboard`;let r;return n.onclick=async e=>{e.stopPropagation(),n.textContent=await Qn(t()).then(()=>`Copied`,()=>`Failed`),clearTimeout(r),r=setTimeout(()=>n.textContent=`Copy`,1200)},n}function er(e,t){let n=document.createElement(`details`);n.className=e;let r=K(`summary`,`flex cursor-pointer select-none items-center gap-1.5`);return r.append(K(`span`,`chev`,`▶`),...t),n.append(r),{el:n,summary:r}}var tr=G(`#image-dialog`),nr=G(`#image-full`),rr=G(`#image-prev`),ir=G(`#image-next`),ar=[],or=0;function sr(e){ar.length<2||(or=(or+e+ar.length)%ar.length,nr.src=ar[or])}function cr(e){let t=new URL(e,location.href).href;ar=[...G(`#turns`).querySelectorAll(`img.thumb`)].map(e=>e.src),or=Math.max(0,ar.indexOf(t)),nr.src=t;let n=ar.length<2?`none`:`flex`;rr.style.display=n,ir.style.display=n,tr.showModal()}tr.onclick=()=>tr.close();var lr=(e,t)=>{e.onclick=e=>{e.stopPropagation(),sr(t)}};lr(rr,-1),lr(ir,1),tr.onkeydown=e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),sr(e.key===`ArrowLeft`?-1:1))};function ur(e){let t=e.querySelector(`:scope > .thumbs`);if(t)return t;let n=K(`div`,`thumbs`);return e.append(n),n}function dr(e){let t=document.createElement(`img`);return t.src=e,t.loading=`lazy`,t.className=`thumb`,t.onclick=()=>cr(e),t}var fr=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`bmp`]),pr=new Set([`txt`,`md`,`log`,`json`,`csv`,`yaml`,`yml`]),mr=524288,hr=G(`#file-dialog`),gr=G(`#file-name`),_r=G(`#file-text`),vr=G(`#file-download`);G(`#file-close`).onclick=()=>hr.close();var yr=e=>e.split(`.`).pop()?.toLowerCase()??``,br=(e,t,n=!1)=>`/api/sessions/${encodeURIComponent(e)}/files?path=${encodeURIComponent(t)}${n?`&download=1`:``}`;function xr(e,t){return e.replace(/\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)/g,(e,n)=>{let r=n;try{r=decodeURIComponent(n)}catch{}return`](${br(t,r)})`})}var Sr=e=>/^\/api\/sessions\/[^/]+\/files\?/.test(e);function Cr(e,t){let n=Jn(t)||`file`,r=br(e,t);return fr.has(yr(n))?Er(r,n):Dr(r,n)}function wr(e){return new URLSearchParams(e.slice(e.indexOf(`?`)+1)).get(`path`)??``}async function Tr(e,t){gr.textContent=t,vr.href=`${e}&download=1`,_r.textContent=`loading…`,hr.showModal();let n=await fetch(e),r=n.ok?await n.text():`failed to load: ${n.status}`;_r.textContent=r.length>mr?`${r.slice(0,mr)}\n…`:r}function Er(e,t){let n=dr(e);return n.alt=t,n}function Dr(e,t){let n=yr(t),r=K(`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=K(`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=K(`span`,`min-w-0 truncate text-[13px] font-medium text-neutral-800`,t),o=K(`span`,`ml-1 flex flex-none items-center gap-0.5`);if(pr.has(n)||n===`pdf`){let r=K(`button`,`icon-btn h-6 w-6 text-[13px]`,`◉`);r.title=`Preview`,r.onclick=r=>{r.preventDefault(),n===`pdf`?window.open(e,`_blank`,`noopener`):Tr(e,t)},o.append(r)}let s=document.createElement(`a`);return s.className=`icon-btn h-6 w-6 text-[13px] no-underline`,s.href=`${e}&download=1`,s.download=t,s.title=`Download`,s.textContent=`↓`,o.append(s),r.append(i,a,o),r}function Or(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=K(`div`,`thumbs`);r.append(...t),n.after(r)}}function kr(e){let t=[];for(let n of e.querySelectorAll(`img`)){let e=n.getAttribute(`src`)??``;if(!Sr(e))continue;let r=Er(e,Jn(wr(e)));n.replaceWith(r),t.push(r)}for(let n of e.querySelectorAll(`a`)){let e=n.getAttribute(`href`)??``;if(!Sr(e))continue;let r=Jn(wr(e))||n.textContent?.trim()||`file`,i=fr.has(yr(r))?Er(e,r):Dr(e,r);n.replaceWith(i),t.push(i)}t.length&&Or(t)}var Ar=e=>`[${e.split(`/`).pop()??`file`}](file://${encodeURI(e).replace(/\(/g,`%28`).replace(/\)/g,`%29`)})`,jr=/^\[[^\]\n]*\]\(\s*<?file:\/\/(\/[^)>\s]*)>?\s*\)$/;function Mr(e){let t=e.split(`
|
|
68
|
-
`),n=t.length;for(;n>0&&jr.test(t[n-1].trim());)n--;let r=t.slice(n).map(e=>{let t=jr.exec(e.trim())[1];try{return decodeURIComponent(t)}catch{return t}});return{text:t.slice(0,n).join(`
|
|
69
|
-
`).trimEnd(),paths:r}}var Nr=c(o(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}var o=`</span>`,s=e=>!!e.scope,c=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`},l=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=c(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+=o)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},u=(e={})=>{let t={children:[]};return Object.assign(t,e),t},d=class e{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=u({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},f=class extends d{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function p(e){return e?typeof e==`string`?e:e.source:null}function m(e){return _(`(?=`,e,`)`)}function h(e){return _(`(?:`,e,`)*`)}function g(e){return _(`(?:`,e,`)?`)}function _(...e){return e.map(e=>p(e)).join(``)}function v(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function y(...e){return`(`+(v(e).capture?``:`?:`)+e.map(e=>p(e)).join(`|`)+`)`}function b(e){return RegExp(e.toString()+`|`).exec(``).length-1}function x(e,t){let n=e&&e.exec(t);return n&&n.index===0}var S=new RegExp(y(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function C(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=p(e),i=``;for(;r.length>0;){let e=S.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],(e[0]===`(`||/^\(\?[<']/.test(e[0]))&&n++)}return i}).map(e=>`(${e})`).join(t)}var w=/\b\B/,T=`[a-zA-Z]\\w*`,E=`[a-zA-Z_]\\w*`,D=`\\b\\d+(\\.\\d+)?`,O=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,k=`\\b(0b[01]+)`,A=`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,ee=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=_(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},j={begin:`\\\\[\\s\\S]`,relevance:0},te={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[j]},M={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[j]},ne={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},N=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=y(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:_(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},re=N(`//`,`$`),ie=N(`/\\*`,`\\*/`),ae=N(`#`,`$`),oe=Object.freeze({__proto__:null,APOS_STRING_MODE:te,BACKSLASH_ESCAPE:j,BINARY_NUMBER_MODE:{scope:`number`,begin:k,relevance:0},BINARY_NUMBER_RE:k,COMMENT:N,C_BLOCK_COMMENT_MODE:ie,C_LINE_COMMENT_MODE:re,C_NUMBER_MODE:{scope:`number`,begin:O,relevance:0},C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:ae,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:{begin:`\\.\\s*[a-zA-Z_]\\w*`,relevance:0},NUMBER_MODE:{scope:`number`,begin:D,relevance:0},NUMBER_RE:D,PHRASAL_WORDS_MODE:ne,QUOTE_STRING_MODE:M,REGEXP_MODE:{scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[j,{begin:/\[/,end:/\]/,relevance:0,contains:[j]}]},RE_STARTERS_RE:A,SHEBANG:ee,TITLE_MODE:{scope:`title`,begin:T,relevance:0},UNDERSCORE_IDENT_RE:E,UNDERSCORE_TITLE_MODE:{scope:`title`,begin:E,relevance:0}});function se(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function ce(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function le(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=se,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function ue(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function de(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function fe(e,t){e.relevance===void 0&&(e.relevance=1)}var P=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=_(n.beforeMatch,m(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},pe=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],F=`keyword`;function me(e,t,n=F){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,me(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,I(n[0],n[1])]})}}function I(e,t){return t?Number(t):+!he(e)}function he(e){return pe.includes(e.toLowerCase())}var ge={},_e=e=>{console.error(e)},ve=(e,...t)=>{console.log(`WARN: ${e}`,...t)},ye=(e,t)=>{ge[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),ge[`${e}/${t}`]=!0)},be=Error();function xe(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=b(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function Se(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw _e(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),be;if(typeof e.beginScope!=`object`||e.beginScope===null)throw _e(`beginScope must be object`),be;xe(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function Ce(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw _e(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),be;if(typeof e.endScope!=`object`||e.endScope===null)throw _e(`endScope must be object`),be;xe(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function we(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function Te(e){we(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),Se(e),Ce(e)}function Ee(e){function t(t,n){return new RegExp(p(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(C(e,{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[ce,de,Te,P].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[le,ue,fe].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s||=/\w+/,n.keywords&&=me(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(n.begin||=/\B|\b/,a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=p(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||=[],n.contains=[].concat(...n.contains.map(function(e){return Oe(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||=[],e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function De(e){return e?e.endsWithParent||De(e.starts):!1}function Oe(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:De(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var ke=`11.12.0`,Ae=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},je=i,Me=a,Ne=Symbol(`nomatch`),Pe=7,Fe=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:f};function u(e){return l.noHighlightRe.test(e)}function d(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=te(n[1]);return t||(ve(s.replace(`{}`,n[1])),ve(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||te(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(ye(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),ye(`10.7.0`,`Please use highlight(code, options) instead.
|
|
70
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};ae(`before:highlight`,a);let o=a.result?a.result:v(a.language,a.code,n);return o.code=a.code,ae(`after:highlight`,o),o}function v(e,n,i,a){let c=Object.create(null);function u(e,t){return e.keywords[t]}function d(){if(!A.keywords){j.addText(M);return}let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(M),n=``;for(;t;){n+=M.substring(e,t.index);let r=D.case_insensitive?t[0].toLowerCase():t[0],i=u(A,r);if(i){let[e,a]=i;if(j.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=Pe&&(ne+=a),e.startsWith(`_`))n+=t[0];else{let n=D.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(M)}n+=M.substring(e),j.addText(n)}function f(){if(M===``)return;let e=null;if(typeof A.subLanguage==`string`){if(!t[A.subLanguage]){j.addText(M);return}e=v(A.subLanguage,M,!0,ee[A.subLanguage]),ee[A.subLanguage]=e._top}else e=S(M,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(ne+=e.relevance),j.__addSublanguage(e._emitter,e.language)}function p(){A.subLanguage==null?d():f(),M=``}function m(e,t){e!==``&&(j.startScope(t),j.addText(e),j.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=D.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(M=i,d(),M=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&j.openNode(D.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(M,D.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),M=``):e.beginScope._multi&&(h(e.beginScope,t),M=``)),A=Object.create(e,{parent:{value:A}}),A}function _(e,t,n){let i=x(e.endRe,n);if(i){if(e[`on:end`]){let n=new r(e);e[`on:end`](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return _(e.parent,t,n)}function y(e){return A.matcher.regexIndex===0?(M+=e[0],1):(ie=!0,0)}function b(e){let t=e[0],n=e.rule,i=new r(n),a=[n.__beforeBegin,n[`on:begin`]];for(let n of a)if(n&&(n(e,i),i.isMatchIgnored))return y(t);return n.skip?M+=t:(n.excludeBegin&&(M+=t),p(),!n.returnBegin&&!n.excludeBegin&&(M=t)),g(n,e),n.returnBegin?0:t.length}function C(e){let t=e[0],r=n.substring(e.index),i=_(A,e,r);if(!i)return Ne;let a=A;A.endScope&&A.endScope._wrap?(p(),m(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),h(A.endScope,e)):a.skip?M+=t:(a.returnEnd||a.excludeEnd||(M+=t),p(),a.excludeEnd&&(M=t));do A.scope&&j.closeNode(),!A.skip&&!A.subLanguage&&(ne+=A.relevance),A=A.parent;while(A!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function w(){let e=[];for(let t=A;t!==D;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>j.openNode(e))}let T={};function E(t,r){let a=r&&r[0];if(M+=t,a==null)return p(),0;if(T.type===`begin`&&r.type===`end`&&T.index===r.index&&a===``){if(M+=n.slice(r.index,r.index+1),!o){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=T.rule,t}return 1}if(T=r,r.type===`begin`)return b(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(A.scope||`<unnamed>`)+`"`);throw e.mode=A,e}if(r.type===`end`){let e=C(r);if(e!==Ne)return e}if(r.type===`illegal`&&a===``)return r.index===n.length||(M+=`
|
|
71
|
-
`),1;if(re>1e5&&re>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return M+=a,a.length}let D=te(e);if(!D)throw _e(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let O=Ee(D),k=``,A=a||O,ee={},j=new l.__emitter(l);w();let M=``,ne=0,N=0,re=0,ie=!1;try{if(D.__emitTokens)D.__emitTokens(n,j);else{for(A.matcher.considerAll();;){re++,ie?ie=!1:A.matcher.considerAll(),A.matcher.lastIndex=N;let e=A.matcher.exec(n);if(!e)break;let t=E(n.substring(N,e.index),e);N=e.index+t}E(n.substring(N))}return j.finalize(),k=j.toHTML(),{language:e,value:k,relevance:ne,illegal:!1,_emitter:j,_top:A}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:je(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:N,context:n.slice(N-100,N+100),mode:t.mode,resultSoFar:k},_emitter:j};if(o)return{language:e,value:je(n),illegal:!1,relevance:0,errorRaised:t,_emitter:j,_top:A};throw t}}function b(e){let t={value:je(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}function S(e,n){n=n||l.languages||Object.keys(t);let r=b(e),i=n.filter(te).filter(ne).map(t=>v(t,e,!1));i.unshift(r);let[a,o]=i.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(te(e.language).supersetOf===t.language)return 1;if(te(t.language).supersetOf===e.language)return-1}return 0}),s=a;return s.secondBest=o,s}function C(e,t,n){let r=t&&i[t]||n;e.classList.add(`hljs`),e.classList.add(`language-${r}`)}function w(e){let t=null,n=d(e);if(u(n))return;if(ae(`before:highlightElement`,{el:e,language:n}),e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn(`One of your code blocks includes unescaped HTML. This is a potentially serious security risk.`),console.warn(`https://github.com/highlightjs/highlight.js/wiki/security`),console.warn(`The element with unescaped HTML:`),console.warn(e)),l.throwUnescapedHTML))throw new Ae(`One of your code blocks includes unescaped HTML.`,e.innerHTML);t=e;let r=t.textContent,i=n?p(r,{language:n,ignoreIllegals:!0}):S(r);e.innerHTML=i.value,e.dataset.highlighted=`yes`,C(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),ae(`after:highlightElement`,{el:e,result:i,text:r})}function T(e){l=Me(l,e)}let E=()=>{k(),ye(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),ye(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let O=!1;function k(){function e(){k()}if(document.readyState===`loading`){O||window.addEventListener(`DOMContentLoaded`,e,!1),O=!0;return}document.querySelectorAll(l.cssSelector).forEach(w)}function A(n,r){let i=null;try{i=r(e)}catch(e){if(_e(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)_e(e);else throw e;i=c}i.name||(i.name=n),t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&M(i.aliases,{languageName:n})}function ee(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function j(){return Object.keys(t)}function te(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function M(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function ne(e){let t=te(e);return t&&!t.disableAutodetect}function N(e){e[`before:highlightBlock`]&&!e[`before:highlightElement`]&&(e[`before:highlightElement`]=t=>{e[`before:highlightBlock`](Object.assign({block:t.el},t))}),e[`after:highlightBlock`]&&!e[`after:highlightElement`]&&(e[`after:highlightElement`]=t=>{e[`after:highlightBlock`](Object.assign({block:t.el},t))})}function re(e){N(e),a.push(e)}function ie(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function ae(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function se(e){return ye(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),ye(`10.7.0`,`Please use highlightElement now.`),w(e)}Object.assign(e,{highlight:p,highlightAuto:S,highlightAll:k,highlightElement:w,highlightBlock:se,configure:T,initHighlighting:E,initHighlightingOnLoad:D,registerLanguage:A,unregisterLanguage:ee,listLanguages:j,getLanguage:te,registerAliases:M,autoDetection:ne,inherit:Me,addPlugin:re,removePlugin:ie}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=ke,e.regex={concat:_,lookahead:m,either:y,optional:g,anyNumberOfTimes:h};for(let e in oe)typeof oe[e]==`object`&&n(oe[e]);return Object.assign(e,oe),e},Ie=Fe({});Ie.newInstance=()=>Fe({}),t.exports=Ie,Ie.HighlightJS=Ie,Ie.default=Ie}))()).default;function Pr(e){let t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:[`self`,{begin:/:-/,contains:[n]}]};Object.assign(n,{className:`variable`,variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,`(?![\\w\\d])(?![$])`)},r]});let i={className:`subst`,begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:`comment`}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:`string`})]}},s={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(s);let c={match:/\\"/},l={className:`string`,begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:`number`},e.NUMBER_MODE,n]},f=e.SHEBANG({binary:`(${[`fish`,`bash`,`zsh`,`sh`,`csh`,`ksh`,`tcsh`,`dash`,`scsh`].join(`|`)})`,relevance:10}),p={className:`function`,begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=[`if`,`then`,`else`,`elif`,`fi`,`time`,`for`,`while`,`until`,`in`,`do`,`done`,`case`,`esac`,`coproc`,`function`,`select`],h=[`true`,`false`],g={match:/(\/[a-z._-]+)+/},_=[`break`,`cd`,`continue`,`eval`,`exec`,`exit`,`export`,`getopts`,`hash`,`pwd`,`readonly`,`return`,`shift`,`test`,`times`,`trap`,`umask`,`unset`],v=[`alias`,`bind`,`builtin`,`caller`,`command`,`declare`,`echo`,`enable`,`help`,`let`,`local`,`logout`,`mapfile`,`printf`,`read`,`readarray`,`source`,`sudo`,`type`,`typeset`,`ulimit`,`unalias`],y=`autoload.bg.bindkey.bye.cap.chdir.clone.comparguments.compcall.compctl.compdescribe.compfiles.compgroups.compquote.comptags.comptry.compvalues.dirs.disable.disown.echotc.echoti.emulate.fc.fg.float.functions.getcap.getln.history.integer.jobs.kill.limit.log.noglob.popd.print.pushd.pushln.rehash.sched.setcap.setopt.stat.suspend.ttyctl.unfunction.unhash.unlimit.unsetopt.vared.wait.whence.where.which.zcompile.zformat.zftp.zle.zmodload.zparseopts.zprof.zpty.zregexparse.zsocket.zstyle.ztcp`.split(`.`),b=`chcon.chgrp.chown.chmod.cp.dd.df.dir.dircolors.ln.ls.mkdir.mkfifo.mknod.mktemp.mv.realpath.rm.rmdir.shred.sync.touch.truncate.vdir.b2sum.base32.base64.cat.cksum.comm.csplit.cut.expand.fmt.fold.head.join.md5sum.nl.numfmt.od.paste.ptx.pr.sha1sum.sha224sum.sha256sum.sha384sum.sha512sum.shuf.sort.split.sum.tac.tail.tr.tsort.unexpand.uniq.wc.arch.basename.chroot.date.dirname.du.echo.env.expr.factor.groups.hostid.id.link.logname.nice.nohup.nproc.pathchk.pinky.printenv.printf.pwd.readlink.runcon.seq.sleep.stat.stdbuf.stty.tee.test.timeout.tty.uname.unlink.uptime.users.who.whoami.yes`.split(`.`);return{name:`Bash`,aliases:[`sh`,`zsh`],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:h,built_in:[..._,...v,`set`,`shopt`,...y,...b]},contains:[f,e.SHEBANG(),p,d,a,o,g,s,c,l,u,n]}}var Fr=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},UNICODE_RANGE:{scope:`number`,begin:/\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,5}(-[0-9A-Fa-f][0-9A-Fa-f]{0,5})?/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),Ir=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),Lr=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),Rr=[...Ir,...Lr],zr=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),Br=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),Vr=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),Hr=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.corner-bottom-left-shape.corner-bottom-right-shape.corner-shape.corner-top-left-shape.corner-top-right-shape.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.unicode-range.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function Ur(e){let t=e.regex,n=Fr(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i=/@-?\w[\w]*(-\w+)*/,a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:`CSS`,case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:`from to`},classNameAliases:{keyframePosition:`selector-tag`},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:`selector-id`,begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:`selector-class`,begin:`\\.[a-zA-Z-][a-zA-Z0-9_-]*`,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,variants:[{begin:`:(`+Br.join(`|`)+`)`},{begin:`:(:)?(`+Vr.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+Hr.join(`|`)+`)\\b`},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:`url data-uri`},contains:[...a,{className:`string`,begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:`[{;]`,relevance:0,illegal:/:/,contains:[{className:`keyword`,begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:zr.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+Rr.join(`|`)+`)\\b`}]}}function Wr(e){let t=e.regex;return{name:`Diff`,aliases:[`patch`],contains:[{className:`meta`,relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+,\d+ +\+\d+ +@@/,/^@@ +-\d+ +\+\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:`comment`,variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:`addition`,begin:/^\+/,end:/$/},{className:`deletion`,begin:/^-/,end:/$/},{className:`addition`,begin:/^!/,end:/$/}]}}function Gr(e){let t={keyword:[`break`,`case`,`chan`,`const`,`continue`,`default`,`defer`,`else`,`fallthrough`,`for`,`func`,`go`,`goto`,`if`,`import`,`interface`,`map`,`package`,`range`,`return`,`select`,`struct`,`switch`,`type`,`var`],type:[`bool`,`byte`,`complex64`,`complex128`,`error`,`float32`,`float64`,`int8`,`int16`,`int32`,`int64`,`string`,`uint8`,`uint16`,`uint32`,`uint64`,`int`,`uint`,`uintptr`,`rune`],literal:[`true`,`false`,`iota`,`nil`],built_in:[`append`,`cap`,`close`,`complex`,`copy`,`imag`,`len`,`make`,`new`,`panic`,`print`,`println`,`real`,`recover`,`delete`]};return{name:`Go`,aliases:[`golang`],keywords:t,illegal:`</`,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:`string`,variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:`number`,variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\b0[bB](_?[01])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:`function`,beginKeywords:`func`,end:`\\s*(\\{|$)`,excludeEnd:!0,contains:[e.TITLE_MODE,{className:`params`,begin:/\(/,end:/\)/,endsParent:!0,keywords:t,illegal:/["']/}]}]}}var Kr=`[A-Za-z$_][0-9A-Za-z$_]*`,qr=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),Jr=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],Yr=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),Xr=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],Zr=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],Qr=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`self`,`global`],$r=[].concat(Zr,Yr,Xr);function ei(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=Kr,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:Kr,keyword:qr,literal:Jr,built_in:$r,"variable.language":Qr},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:r+`(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...Yr,...Xr]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...Zr,`super`,`import`,`await`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},ee=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,j={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ee)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},j,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:ee,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$`+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}var ti={scope:`number`,match:`([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity`,relevance:0};function ni(e){let t={className:`attr`,begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:`punctuation`,relevance:0},r=[`true`,`false`,`null`],i={scope:`literal`,beginKeywords:r.join(` `)};return{name:`JSON`,aliases:[`jsonc`,`json5`],keywords:{literal:r},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,i,ti,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:`\\S`}}function ri(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:`>`,subLanguage:`xml`,relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},i={className:`code`,variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:`(~{3,})[^~](.|\\n)*?\\1~*[ ]*`},{begin:"```",end:"```+[ ]*$"},{begin:`~~~`,end:`~~~+[ ]*$`},{begin:"`.+?`"},{begin:`(?=^( {4}|\\t))`,contains:[{begin:`^( {4}|\\t)`,end:`(\\n)$`}],relevance:0}]},a={className:`bullet`,begin:`^[ ]*([*+-]|(\\d+\\.))(?=\\s+)`,end:`\\s+`,excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:`symbol`,begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:`link`,begin:/:\s*/,end:/$/,excludeBegin:!0}]},s={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:`string`,relevance:0,begin:`\\[`,end:`\\]`,excludeBegin:!0,returnEnd:!0},{className:`link`,relevance:0,begin:`\\]\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0},{className:`symbol`,relevance:0,begin:`\\]\\[`,end:`\\]`,excludeBegin:!0,excludeEnd:!0}]},c={className:`strong`,contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},l={className:`emphasis`,contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(c,{contains:[]}),d=e.inherit(l,{contains:[]});c.contains.push(d),l.contains.push(u);let f=[n,s];return[c,l,u,d].forEach(e=>{e.contains=e.contains.concat(f)}),f=f.concat(c,l),{name:`Markdown`,aliases:[`md`,`mkdown`,`mkd`],contains:[{className:`section`,variants:[{begin:`^#{1,6}`,end:`$`,contains:f},{begin:`(?=^.+?\\n[=-]{2,}$)`,contains:[{begin:`^[=-]*$`},{begin:`^`,end:`\\n`,contains:f}]}]},n,a,r,c,l,{className:`quote`,begin:`^>\\s+`,contains:f,end:`$`},i,s,o,{scope:`literal`,match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function ii(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=`and.as.assert.async.await.break.case.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.lazy.match.nonlocal|10.not.or.pass.raise.return.try.while.with.yield`.split(`.`),i={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:`__import__.abs.aiter.all.anext.any.ascii.bin.bool.breakpoint.bytearray.bytes.callable.chr.classmethod.compile.complex.delattr.dict.dir.divmod.enumerate.eval.exec.filter.float.format.frozendict.frozenset.getattr.globals.hasattr.hash.help.hex.id.input.int.isinstance.issubclass.iter.len.list.locals.map.max.memoryview.min.next.object.oct.open.ord.pow.print.property.range.repr.reversed.round.sentinel.set.setattr.slice.sorted.staticmethod.str.sum.super.tuple.type.vars.zip`.split(`.`),literal:[`__debug__`,`Ellipsis`,`False`,`None`,`NotImplemented`,`True`],type:[`Any`,`Callable`,`Coroutine`,`Dict`,`List`,`Literal`,`Generic`,`Optional`,`Sequence`,`Set`,`Tuple`,`Type`,`Union`]},a={className:`meta`,begin:/^(>>>|\.\.\.) /},o={className:`subst`,begin:/\{/,end:/\}/,keywords:i,illegal:/#/},s={begin:/\{\{/,relevance:0},c={className:`string`,contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,s,o]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,s,o]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,o]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},l=`[0-9](_?[0-9])*`,u=`(\\b(${l}))?\\.(${l})|\\b(${l})\\.`,d=`\\b|${r.join(`|`)}`,f={className:`number`,relevance:0,variants:[{begin:`(\\b(${l})|(${u}))[eE][+-]?(${l})[jJ]?(?=${d})`},{begin:`(${u})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${d})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${d})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${d})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${d})`},{begin:`\\b(${l})[jJ](?=${d})`}]},p={className:`comment`,begin:t.lookahead(/# type:/),end:/$/,keywords:i,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},m={className:`params`,variants:[{className:``,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:[`self`,a,f,c,e.HASH_COMMENT_MODE]}]};return o.contains=[c,f,a],{name:`Python`,aliases:[`py`,`gyp`,`ipython`],unicodeRegex:!0,keywords:i,illegal:/(<\/|\?)|=>/,contains:[a,f,{scope:`variable.language`,match:/\bself\b/},{beginKeywords:`if`,relevance:0},{match:/\bor\b/,scope:`keyword`},c,p,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:`keyword`,3:`title.function`},contains:[m]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:`keyword`,3:`title.class`,6:`title.class.inherited`}},{className:`meta`,begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[f,m,c]}]}}function ai(e){let t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),a={scope:`title.function.invoke`,relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,i,t.lookahead(/\s*\(/))},o=`([ui](8|16|32|64|128|size)|f(16|32|64|128))?`,s=`abstract.as.async.await.become.box.break.const.continue.crate.do.dyn.else.enum.extern.false.final.fn.for.if.impl.in.let.loop.macro.match.mod.move.mut.override.priv.pub.raw.ref.return.self.Self.static.struct.super.trait.true.try.type.typeof.union.unsafe.unsized.use.virtual.where.while.yield`.split(`.`),c=[`true`,`false`,`Some`,`None`,`Ok`,`Err`],l=`drop .Copy.Send.Sized.Sync.Drop.Fn.FnMut.FnOnce.ToOwned.Clone.Debug.PartialEq.PartialOrd.Eq.Ord.AsRef.AsMut.Into.From.Default.Iterator.Extend.IntoIterator.DoubleEndedIterator.ExactSizeIterator.SliceConcatExt.ToString.assert!.assert_eq!.bitflags!.bytes!.cfg!.col!.concat!.concat_idents!.debug_assert!.debug_assert_eq!.env!.eprintln!.panic!.file!.format!.format_args!.include_bytes!.include_str!.line!.local_data_key!.module_path!.option_env!.print!.println!.select!.stringify!.try!.unimplemented!.unreachable!.vec!.write!.writeln!.macro_rules!.assert_ne!.debug_assert_ne!`.split(`.`),u=[`i8`,`i16`,`i32`,`i64`,`i128`,`isize`,`u8`,`u16`,`u32`,`u64`,`u128`,`usize`,`f16`,`f32`,`f64`,`f128`,`str`,`char`,`bool`,`Box`,`Option`,`Result`,`String`,`Vec`];return{name:`Rust`,aliases:[`rs`],keywords:{$pattern:e.IDENT_RE+`!?`,type:u,keyword:s,literal:c,built_in:l},illegal:`</`,contains:[e.C_LINE_COMMENT_MODE,e.COMMENT(`/\\*`,`\\*/`,{contains:[`self`]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:`symbol`,begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:`string`,variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:`char.escape`,match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:`number`,variants:[{begin:`\\b0b([01_]+)`+o},{begin:`\\b0o([0-7_]+)`+o},{begin:`\\b0x([A-Fa-f0-9_]+)`+o},{begin:`\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)`+o}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:`keyword`,3:`keyword`}},{begin:[/fn/,/\s+/,r],scope:{1:`keyword`,3:`title.function`}},{scope:`meta`,begin:`#!?\\[`,end:`\\]`,contains:[{scope:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:`keyword`,3:`keyword`,4:`variable`}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:`keyword`,3:`variable`,5:`keyword`}},{begin:[/type/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}},{begin:e.IDENT_RE+`::`,keywords:{keyword:`Self`,built_in:l,type:u}},{scope:`punctuation`,begin:`->`},a]}}function oi(e){return{name:`Shell Session`,aliases:[`console`,`shellsession`],contains:[{className:`meta.prompt`,begin:/^\s{0,3}[./~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:`bash`}}]}}function si(e){let t=e.regex,n=e.COMMENT(`--`,`$`),r={scope:`string`,variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},a=[`true`,`false`,`unknown`],o=[`double precision`,`large object`,`with timezone`,`without timezone`],s=`bigint.binary.blob.boolean.char.character.clob.date.dec.decfloat.decimal.float.int.integer.interval.nchar.nclob.national.numeric.real.row.smallint.time.timestamp.varchar.varying.varbinary`.split(`.`),c=[`add`,`asc`,`collation`,`desc`,`final`,`first`,`last`,`view`],l=`abs.acos.all.allocate.alter.and.any.are.array.array_agg.array_max_cardinality.as.asensitive.asin.asymmetric.at.atan.atomic.authorization.avg.begin.begin_frame.begin_partition.between.bigint.binary.blob.boolean.both.by.call.called.cardinality.cascaded.case.cast.ceil.ceiling.char.char_length.character.character_length.check.classifier.clob.close.coalesce.collate.collect.column.commit.condition.connect.constraint.contains.convert.copy.corr.corresponding.cos.cosh.count.covar_pop.covar_samp.create.cross.cube.cume_dist.current.current_catalog.current_date.current_default_transform_group.current_path.current_role.current_row.current_schema.current_time.current_timestamp.current_path.current_role.current_transform_group_for_type.current_user.cursor.cycle.date.day.deallocate.dec.decimal.decfloat.declare.default.define.delete.dense_rank.deref.describe.deterministic.disconnect.distinct.double.drop.dynamic.each.element.else.empty.end.end_frame.end_partition.end-exec.equals.escape.every.except.exec.execute.exists.exp.external.extract.false.fetch.filter.first_value.float.floor.for.foreign.frame_row.free.from.full.function.fusion.get.global.grant.group.grouping.groups.having.hold.hour.identity.in.indicator.initial.inner.inout.insensitive.insert.int.integer.intersect.intersection.interval.into.is.join.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.language.large.last_value.lateral.lead.leading.left.like.like_regex.listagg.ln.local.localtime.localtimestamp.log.log10.lower.match.match_number.match_recognize.matches.max.member.merge.method.min.minute.mod.modifies.module.month.multiset.national.natural.nchar.nclob.new.no.none.normalize.not.nth_value.ntile.null.nullif.numeric.octet_length.occurrences_regex.of.offset.old.omit.on.one.only.open.or.order.out.outer.over.overlaps.overlay.parameter.partition.pattern.per.percent.percent_rank.percentile_cont.percentile_disc.period.portion.position.position_regex.power.precedes.precision.prepare.primary.procedure.ptf.range.rank.reads.real.recursive.ref.references.referencing.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.release.result.return.returns.revoke.right.rollback.rollup.row.row_number.rows.running.savepoint.scope.scroll.search.second.seek.select.sensitive.session_user.set.show.similar.sin.sinh.skip.smallint.some.specific.specifictype.sql.sqlexception.sqlstate.sqlwarning.sqrt.start.static.stddev_pop.stddev_samp.submultiset.subset.substring.substring_regex.succeeds.sum.symmetric.system.system_time.system_user.table.tablesample.tan.tanh.then.time.timestamp.timezone_hour.timezone_minute.to.trailing.translate.translate_regex.translation.treat.trigger.trim.trim_array.true.truncate.uescape.union.unique.unknown.unnest.update.upper.user.using.value.values.value_of.var_pop.var_samp.varbinary.varchar.varying.versioning.when.whenever.where.width_bucket.window.with.within.without.year`.split(`.`),u=`abs.acos.array_agg.asin.atan.avg.cast.ceil.ceiling.coalesce.corr.cos.cosh.count.covar_pop.covar_samp.cume_dist.dense_rank.deref.element.exp.extract.first_value.floor.json_array.json_arrayagg.json_exists.json_object.json_objectagg.json_query.json_table.json_table_primitive.json_value.lag.last_value.lead.listagg.ln.log.log10.lower.max.min.mod.nth_value.ntile.nullif.percent_rank.percentile_cont.percentile_disc.position.position_regex.power.rank.regr_avgx.regr_avgy.regr_count.regr_intercept.regr_r2.regr_slope.regr_sxx.regr_sxy.regr_syy.row_number.sin.sinh.sqrt.stddev_pop.stddev_samp.substring.substring_regex.sum.tan.tanh.translate.translate_regex.treat.trim.trim_array.unnest.upper.value_of.var_pop.var_samp.width_bucket`.split(`.`),d=[`current_catalog`,`current_date`,`current_default_transform_group`,`current_path`,`current_role`,`current_schema`,`current_transform_group_for_type`,`current_user`,`session_user`,`system_time`,`system_user`,`current_time`,`localtime`,`current_timestamp`,`localtimestamp`],f=[`create table`,`insert into`,`primary key`,`foreign key`,`not null`,`alter table`,`add constraint`,`grouping sets`,`on overflow`,`character set`,`respect nulls`,`ignore nulls`,`nulls first`,`nulls last`,`depth first`,`breadth first`],p=u,m=[...l,...c].filter(e=>!u.includes(e)),h={scope:`variable`,match:/@[a-z0-9][a-z0-9_]*/},g={scope:`operator`,match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},_={match:t.concat(/\b/,t.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function v(e){return t.concat(/\b/,t.either(...e.map(e=>e.replace(/\s+/,`\\s+`))),/\b/)}let y={scope:`keyword`,match:v(f),relevance:0};function b(e,{exceptions:t,when:n}={}){let r=n;return t||=[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:r(e)?`${e}|0`:e)}return{name:`SQL`,case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:b(m,{when:e=>e.length<3}),literal:a,type:s,built_in:d},contains:[{scope:`type`,match:v(o)},y,_,h,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,g]}}var ci=`[A-Za-z$_][0-9A-Za-z$_]*`,li=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),ui=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],di=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),fi=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],pi=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],mi=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`self`,`global`],hi=[].concat(pi,di,fi);function gi(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=ci,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:ci,keyword:li,literal:ui,built_in:hi,"variable.language":mi},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:r+`(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...di,...fi]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...pi,`super`,`import`,`await`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},ee=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,j={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ee)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},j,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:ee,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$`+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function _i(e){let t=e.regex,n=gi(e),r=ci,i=[`any`,`void`,`number`,`boolean`,`string`,`object`,`never`,`symbol`,`bigint`,`unknown`],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:`keyword`,3:`title.class`}},o={beginKeywords:`interface`,end:/\{/,excludeEnd:!0,keywords:{keyword:`interface extends`,built_in:i},contains:[n.exports.CLASS_REFERENCE]},s={className:`meta`,relevance:10,begin:/^\s*['"]use strict['"]/},c={$pattern:ci,keyword:li.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:ui,built_in:hi.concat(i),"variable.language":mi},l={className:`meta`,begin:`@`+r},u=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(r===-1)throw Error(`can not find mode to replace`);e.contains.splice(r,1,n)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(l);let d=n.contains.find(e=>e.scope===`attr`),f=Object.assign({},d,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,d,f]),n.contains=n.contains.concat([l,a,o,f]),u(n,`shebang`,e.SHEBANG()),u(n,`use_strict`,s);let p=n.contains.find(e=>e.label===`func.def`);return p.relevance=0,Object.assign(n,{name:`TypeScript`,aliases:[`ts`,`tsx`,`mts`,`cts`]}),n}function vi(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:`symbol`,begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:`keyword`,begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:`string`}),c=e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:`attr`,begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:`string`,endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:`HTML, XML`,aliases:[`html`,`xhtml`,`rss`,`atom`,`xjb`,`xsd`,`xsl`,`plist`,`wsf`,`svg`],case_insensitive:!0,unicodeRegex:!0,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,s,o,{begin:/\[/,end:/\]/,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,contains:[a,o,c,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:`meta`,end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:`tag`,begin:/<style(?=\s|>)/,end:/>/,keywords:{name:`style`},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:`css`}},{className:`tag`,begin:/<script(?=\s|>)/,end:/>/,keywords:{name:`script`},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:`javascript`}},{className:`tag`,begin:/<>|<\/>/},{className:`tag`,begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:`name`,begin:n,relevance:0,starts:l}]},{className:`tag`,begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:`name`,begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function yi(e){let t=`true false yes no null`,n=`[\\w#;/?:@&=+$,.~*'()[\\]]+`,r={className:`attr`,variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:`template-variable`,variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},a={className:`string`,relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:`char.escape`,relevance:0}]},o={className:`string`,relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},s=e.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),c={className:`number`,begin:`\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b`},l={end:`,`,endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},u={begin:/\{/,end:/\}/,contains:[l],illegal:`\\n`,relevance:0},d={begin:`\\[`,end:`\\]`,contains:[l],illegal:`\\n`,relevance:0},f=[r,{className:`meta`,begin:`^---\\s*$`,relevance:10},{className:`string`,begin:`[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*`},{begin:`<%[%=-]?`,end:`[%-]?%>`,subLanguage:`ruby`,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:`type`,begin:`!\\w+!`+n},{className:`type`,begin:`!<`+n+`>`},{className:`type`,begin:`!`+n},{className:`type`,begin:`!!`+n},{className:`meta`,begin:`&`+e.UNDERSCORE_IDENT_RE+`$`},{className:`meta`,begin:`\\*`+e.UNDERSCORE_IDENT_RE+`$`},{className:`bullet`,begin:`-(?=[ ]|$)`,relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},c,{className:`number`,begin:e.C_NUMBER_RE+`\\b`,relevance:0},u,d,a,o],p=[...f];return p.pop(),p.push(s),l.contains=p,{name:`YAML`,case_insensitive:!0,aliases:[`yml`],contains:f}}for(let[e,t]of Object.entries({bash:Pr,css:Ur,diff:Wr,go:Gr,javascript:ei,json:ni,markdown:ri,python:ii,rust:ai,shell:oi,sql:si,typescript:_i,xml:vi,yaml:yi}))Nr.registerLanguage(e,t);function bi(e){for(let t of e.querySelectorAll(`pre code[class]`)){let e=/(?:language|lang)-(\S+)/.exec(t.className)?.[1]?.toLowerCase();!e||!Nr.getLanguage(e)||(t.innerHTML=Nr.highlight(t.textContent??``,{language:e}).value)}}var xi={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,py:`python`,rs:`rust`,sh:`bash`,zsh:`bash`,md:`markdown`,yml:`yaml`,html:`xml`,htm:`xml`,svg:`xml`,patch:`diff`};function Si(e){let t=e.split(`.`).pop()?.toLowerCase()??``,n=xi[t]??t;return Nr.getLanguage(n)?n:null}function Ci(e,t){let n=document.createElement(`span`);return t&&e.length<=500?n.innerHTML=Nr.highlight(e,{language:t}).value:n.textContent=e,n}var wi=null,Ti=`cursor-pointer rounded-full border border-indigo-200 bg-indigo-50 px-2.5 py-0.5 text-[12.5px] text-indigo-700 transition-colors hover:border-indigo-300 hover:bg-indigo-100`;function Ei(){wi=null}function Di(e,t,n){if(wi?.remove(),wi=null,!t.length)return;let r=K(`div`,`mt-1.5 flex flex-wrap gap-1.5`);for(let e of t){let t=K(`button`,Ti,e);t.type=`button`,t.onclick=()=>{wi===r&&(wi=null),r.remove(),n(e)},r.append(t)}e.append(r),wi=r}var Oi,ki;function Ai(e,t){Oi=e,ki=t}var ji={queued:`border-amber-200 bg-amber-50 text-amber-800`,running:`border-green-200 bg-green-50 text-green-800`,succeeded:`border-neutral-200 bg-neutral-50 text-neutral-600`,failed:`border-red-200 bg-red-50 text-red-700`,cancelled:`border-neutral-200 bg-neutral-50 text-neutral-500`,interrupted:`border-amber-200 bg-amber-50 text-amber-800`,skipped:`border-neutral-200 bg-neutral-50 text-neutral-500`},Mi=new Map;async function Ni(e){let t=await e;t.sent&&t.error&&ki.append(`error`,t.error)}async function Pi(e,t){try{let n=await fetch(e,{method:`POST`});n.ok||ki.append(`error`,await u(n,t))}catch(e){ki.append(`error`,`${t}: ${String(e)}`)}}async function Fi(e){let t=Oi.sessionId();t&&await Ni(d(`Reply to subagent`,`/api/task-messages/${e}/reply`,{sourceSessionId:t},`reply failed`))}function Ii(e){let t=K(`button`,`flex-none text-[11px] font-semibold normal-case text-cyan-800 hover:underline`,`Reply`);return t.onclick=()=>void Fi(e),t}function Li(e){let t=Mi.get(e.runId);t&&!t.isConnected&&(Mi.delete(e.runId),t=void 0),t||(t=K(`div`,`mx-5 my-1.5 border px-3 py-2 text-[13px]`),t.dataset.kind=`background-run`,ki.el.append(t),Mi.set(e.runId,t)),t.className=`mx-5 my-1.5 border px-3 py-2 text-[13px] ${ji[e.state]}`;let n=e.state===`queued`||e.state===`running`,r=`/api/task-runs/${e.runId}`,i=n?K(`span`,`spinner`):K(`span`,`w-3 flex-none text-center`,e.state===`succeeded`?`✓`:e.state===`failed`?`✕`:`·`),a=K(`button`,`min-w-0 truncate text-left font-medium hover:underline`,e.taskName);a.onclick=()=>Oi.showTasks(e.taskId);let o=K(`div`,`flex items-center gap-2`,i,K(`span`,`flex-none text-[11px] font-semibold uppercase`,e.state),a),s=K(`div`,`ml-auto flex flex-none items-center gap-2`);if(e.targetSessionId){let t=K(`button`,`font-mono text-[11px] hover:underline`,`Open`);t.title=`Open ${e.targetSessionId}`,t.onclick=()=>Oi.select(e.targetSessionId),s.append(t)}if(n){let e=K(`button`,`text-[11px] font-semibold hover:underline`,`Steer`),t={mode:`steer`,sourceSessionId:Oi.sessionId()};e.onclick=()=>void Ni(d(`Steer subagent`,`${r}/steer`,t,`could not steer the run`));let n=K(`button`,`text-[11px] font-semibold hover:underline`,`Stop`);n.onclick=()=>void Pi(`${r}/cancel`,`could not stop the run`),s.append(e,n)}else if(e.targetSessionId&&e.sessionMode!==null){let e=K(`button`,`text-[11px] font-semibold hover:underline`,`Continue`),t={sourceSessionId:Oi.sessionId()};e.onclick=()=>void Ni(d(`Continue subagent`,`${r}/resume`,t,`could not continue`)),s.append(e)}o.append(s);let c=Math.max(0,Math.round(((e.finishedAt??Date.now())-(e.startedAt??e.queuedAt))/1e3));t.replaceChildren(o,K(`div`,`mt-1 text-[11px] opacity-70`,`${e.sessionMode??`task`} · depth ${e.depth} · ${c}s · ${e.runId}`)),ki.scroll()}var q=null;function Ri(){q&&!q.toolRows.size&&Ji(`done`)}var zi=null;function Bi(){q=null,zi=null,Mi.clear()}function Vi(){let e=zi;return!e||q?.el===e||(zi=null,e!==ki.el.lastElementChild)?null:(e.remove(),e.dataset.adopted=`1`,Ui(e,e.dataset.status),e)}var Hi={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`,failed:`text-red-600 open:bg-red-50`,interrupted:`text-amber-700 open:bg-amber-50`};function Ui(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 ${Hi[t]}`}var Wi={failed:`✕`,interrupted:`⏸`};function Gi(e){return e===`running`?K(`span`,`spinner`):e===`done`?K(`span`,`hidden`):K(`span`,`flex-none text-[12px] font-bold`,Wi[e])}function Ki(e){if(q)return q;let t=Gi(`running`),n=K(`span`,`truncate`,`working…`),{el:r}=er(``,[t,n]);r.dataset.kind=`activity`,Ui(r,`running`);let i=K(`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`);return r.append(i),ki.el.append(r),zi=r,ki.scroll(),q={el:r,statusIcon:t,headline:n,rowsEl:i,toolRows:new Map,thinking:null,steps:0,failedSteps:0,startTs:e,sawError:!1},q}function qi(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}`,Ui(e.el,t);let a=Gi(t);e.statusIcon.replaceWith(a),e.statusIcon=a}function Ji(e){if(!q)return;for(let{statusEl:e}of q.toolRows.values())e.textContent===`running…`&&(e.textContent=`interrupted`);let t=q.steps>0&&q.failedSteps===q.steps;qi(q,(q.sawError||t)&&e===`done`?`failed`:e),q=null}function Yi(){q&&(q.sawError=!0)}function Xi(e,t,n,r){let i=Ki(e);i.steps+=1,i.thinking=null;let a=JSON.stringify(r,null,2)??``,o=a.replace(/\s+/g,` `),s=K(`span`,`ml-auto flex-none text-black/40`,`running…`),{el:c}=er(`rounded-md px-1 py-0.5 font-mono text-[12.5px] hover:bg-black/[0.03]`,[K(`span`,`flex-none font-semibold`,n),K(`span`,`truncate text-black/50`,o.length>100?o.slice(0,100)+`…`:o),s]),l=K(`pre`,`max-h-40 overflow-y-auto whitespace-pre-wrap rounded bg-black/[0.04] p-1.5 text-[12px]`,a),u=K(`pre`,`hidden max-h-56 overflow-y-auto whitespace-pre-wrap rounded bg-black/[0.04] p-1.5 text-[12px]`);c.append(K(`div`,`mt-1 flex flex-col gap-1 pl-4`,l,u)),i.toolRows.set(t,{el:c,statusEl:s,outputPre:u}),i.rowsEl.append(c),i.rowsEl.scrollTop=i.rowsEl.scrollHeight,qi(i,`running`,n),ki.scroll()}function Zi(e,t,n){let r=q;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,8e3)+`…`:n,i.outputPre.classList.remove(`hidden`)),t&&(r.failedSteps+=1)),qi(r,`running`)}function Qi(e,t){let n=Ki(e);if(!n.thinking){let{el:e,summary:t}=er(`rounded-md px-1 py-0.5 text-[12.5px] italic text-black/50 hover:bg-black/[0.03]`,[K(`span`,`truncate`,`thinking…`)]),r=K(`div`,`mt-1 max-h-56 overflow-y-auto whitespace-pre-wrap pl-4 not-italic text-black/60`,``);e.append(r),n.rowsEl.append(e),n.thinking={pre:r,summary:t},qi(n,`running`,`thinking…`)}let r=n.thinking;r.pre.textContent=((r.pre.textContent??``)+t).slice(-4e3);let i=(r.pre.textContent??``).split(`
|
|
72
|
-
`).filter(Boolean).pop()??`thinking…`,a=r.summary.lastElementChild;a.textContent=i.length>90?`…`+i.slice(-90):i}var $i=0;function ea(e,t=0,n=!1){let r=Date.now()-t;for(let t of e){if(t.kind===`thinking`){Qi(r,t.text??``);continue}let e=t.id??`replay-${++$i}`;Xi(r,e,t.toolName??``,t.args),t.output!==void 0&&Zi(e,t.isError??!1,t.output)}n||Ji(e.some(e=>e.kind===`tool`&&e.output===void 0)?`interrupted`:`done`)}var ta,na=G(`#turns`);function ra(e){ta=e,Ai(e,{el:na,append:J,scroll:ia})}function ia(e=!1){let t=na.scrollHeight-na.scrollTop-na.clientHeight<80;(e||t)&&(na.scrollTop=na.scrollHeight)}var aa={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 J(e,t,n=!1){Ri();let r=e===`assistant`?Vi():null,i=aa[e],a=K(`div`,`group relative border-l-2 px-5 ${na.lastElementChild?.dataset.kind===e?`pt-1 pb-2.5`:`mt-1.5 py-2.5`} ${i.row}`);a.dataset.kind=e;let o=e===`user`?Mr(t):null,s=K(`div`,`whitespace-pre-wrap break-words ${i.body}`,o?.text??t);o?.paths.length&&(s.dataset.raw=t),n&&da(s,t),r&&(a.classList.add(`flow-root`),a.append(r)),a.append(s);let c=ta.sessionId();if(o?.paths.length&&c){let e=ur(a);for(let t of o.paths)e.append(Cr(c,t))}if(e===`user`){let e=K(`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=()=>sa(a,s),a.append(e)}return na.append(a),ia(),s}function oa(e,t){let n=t.kind===`task-callback`?`Task callback`:t.kind===`task-message`?t.messageKind===`decision`?`Decision needed`:`Task ${t.messageKind.replace(`_`,` `)}`:`Agent task input`;Ri();let r=K(`div`,`mt-1.5 border-l-2 border-l-cyan-500 bg-cyan-50 px-5 py-2.5`);r.dataset.kind=`system`;let i=K(`div`,`mb-1 flex items-center gap-2 text-[11px] font-semibold uppercase text-cyan-800`,K(`span`,``,n));if(t.sourceSessionId&&t.sourceSessionId!==`console`){let e=K(`button`,`truncate font-mono normal-case text-cyan-700 hover:underline`,t.sourceSessionId.slice(0,12));e.title=`Open source session`,e.onclick=()=>ta.select(t.sourceSessionId),i.append(K(`span`,`text-cyan-400`,`from`),e)}let a=K(`button`,`ml-auto flex-none font-mono normal-case text-cyan-700 hover:underline`,`run ${t.runId.slice(0,8)}`);a.onclick=()=>ta.showTasks(t.taskId),i.append(a),t.kind===`task-message`&&t.messageKind===`decision`&&i.append(Ii(t.messageId));let o=[`max-h-[min(18rem,40dvh)]`,`overflow-hidden`],s=K(`div`,`whitespace-pre-wrap break-words text-[14px] text-neutral-800 ${o.join(` `)}`,e);r.append(i,s),na.append(r);let c=e.length>800||e.split(`
|
|
73
|
-
`).length>12;if(s.clientHeight?s.scrollHeight>s.clientHeight+1:c){let e=K(`button`,`mx-auto mt-1.5 block w-fit rounded border border-cyan-200 bg-white px-2 py-1 text-[12px] font-medium text-cyan-800 shadow-sm hover:bg-cyan-100 pointer-coarse:py-3.5`,`Show full message`);e.setAttribute(`type`,`button`),e.onclick=()=>{let t=s.classList.toggle(o[0]);s.classList.toggle(o[1],t),e.textContent=t?`Show full message`:`Collapse message`,s.tabIndex=-1,s.focus({preventScroll:!0})},r.append(e)}else s.classList.remove(...o);ia()}function sa(e,t){if(ta.sessionState()!==`idle`){J(`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();ca(e,r)}}}async function ca(e,t){let n=ta.sessionId();if(!n)return;let r=[...na.querySelectorAll(`[data-kind="user"]`)].indexOf(e);for(;e.nextElementSibling;)e.nextElementSibling.remove();e.remove(),ta.ownTurn(t),J(`user`,t),ia(!0);let i=await l(`/api/sessions/${n}/turns/${r}/edit`,{text:t});if(!i.ok){let e=await u(i,`edit failed`);await ta.reload(n),J(`error`,e)}}function la(e,t){if(!t)return;let n=new Date(t.completedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1});(e.parentElement??e).append(K(`span`,`absolute -top-2.5 right-3 z-10 hidden rounded border border-neutral-200 bg-white px-1.5 py-0.5 text-[11.5px] text-neutral-500 shadow-sm group-hover:inline`,`${n} · ${Bn(t)}`))}function ua(e){for(let t of e.querySelectorAll(`pre`)){let e=t.querySelector(`code`);if(!e)continue;let n=K(`div`,`group/code relative`);t.replaceWith(n),n.append(t,$n(`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`,()=>e.textContent??``))}}function da(e,t,n=!1){let r=ta.sessionId(),i=r?xr(t,r):t;e.innerHTML=tt.sanitize(W.parse(i,{async:!1})),e.classList.remove(`whitespace-pre-wrap`),e.classList.add(`md`),bi(e),!n&&(ua(e),kr(e))}function fa(e,t,n,r=!1){let{text:i,suggestions:a}=Kn(t);return In({text:i,suggestions:a})?pa(e,Gn(t)):da(e,i),la(e,n),r&&Di(e.parentElement??e,a,e=>ta.send(`auto`,e)),e}function pa(e,t){e.classList.remove(`md`,`whitespace-pre-wrap`),e.replaceChildren(K(`span`,`text-[12.5px] italic text-black/40`,t?`Stayed silent — ${t}`:`Stayed silent.`))}var ma=(e,t,n=!1)=>fa(J(`assistant`,``),e,t,n),ha=null,ga=null,_a=!1,va=80;function ya(){if(ga){_a=!0;return}_a=!1,ha&&(da(ha,Kn(ha.dataset.raw??``).text,!0),ia()),ga=setTimeout(()=>{ga=null,_a&&ya()},va)}function ba(){ga&&clearTimeout(ga),ga=null,_a=!1}function xa(e){ha||=J(`assistant`,``),ha.dataset.raw=(ha.dataset.raw??``)+e,ya()}function Sa(e=!1){if(!ha)return;let t=ha;ha=null,ba(),fa(t,t.dataset.raw??``,void 0,e)}function Ca(e,t){Ji(`done`),ha?(e&&(ha.dataset.raw=e),la(ha,t)):e&&ma(e,t,!0),Sa(!0)}function wa(){Ji(`interrupted`),Sa()}function Ta(){na.replaceChildren(),ha=null,ba(),Bi(),Ei()}function Ea(e,t,n){let r=new Map(n.map(e=>[e.runId,e])),i=e=>{for(let t of e){let e=r.get(t);e&&(Li(e),r.delete(t))}},a=e.reduce((e,t,n)=>t.role===`assistant`?n:e,-1);for(let[n,o]of e.entries()){let s=t===`streaming`&&n===e.length-1&&(!o.text||(o.steps?.some(e=>e.kind===`tool`&&e.output===void 0)??!1)),c=o.steps;if(c?.length&&(ea(c,o.meta?.durationMs,s),i([...r.keys()].filter(e=>c.some(t=>t.output?.includes(e))))),o.text){if(o.role===`system`&&o.origin){i(o.origin.kind===`task-message`?[o.origin.runId]:o.origin.runIds??[o.origin.runId]),oa(o.text,o.origin);continue}o.role===`assistant`?ma(o.text,o.meta,t===`idle`&&n===a):J(o.role,o.text)}}for(let e of r.values())Li(e);ia(!0)}var Da=window.fetch.bind(window),Oa=20,ka=6e4,Aa=[],ja=new Map,Ma=e=>e instanceof Error?e.stack??`${e.name}: ${e.message}`:void 0;function Na(e,t){let n=t===void 0?e:`${e}: ${String(t)}`,r=Date.now();r-(ja.get(n)??-6e4)<ka||(ja.size>100&&ja.clear(),ja.set(n,r),Aa=Aa.filter(e=>r-e<6e4),!(Aa.length>=Oa)&&(Aa.push(r),Da(`/api/client-log`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:n,stack:Ma(t),view:location.hash||`/`}),keepalive:!0}).catch(()=>{}),J(`error`,n)))}function Pa(){window.__pierReporting=!0,window.addEventListener(`error`,e=>{Na(`script error: ${e.message}`,e.error)}),window.addEventListener(`unhandledrejection`,e=>{Na(`unhandled rejection`,e.reason)})}var Fa=window.fetch.bind(window),Ia=()=>{location.assign(`/login?next=${encodeURIComponent(location.pathname+location.hash)}`)};function La(){window.fetch=async(...e)=>{let t=await Fa(...e);return t.status===401&&Ia(),t}}function Ra(e,t){if(e.readyState!==EventSource.CLOSED)return;let n=()=>Na(`${t} stream disconnected — reload to reconnect`);Fa(`/api/sessions`).then(e=>e.status===401?Ia():n(),n)}var za,Ba=G(`#composer`),Y=G(`#input`),Va=G(`#send`),Ha=G(`#send-plane`),Ua=G(`#send-queue`),Wa=G(`#stop`),Ga=G(`#queue-panel`),Ka=G(`#queue-rows`),qa=G(`#queue-label`),Ja=G(`#image-strip`),Ya=G(`#attach-input`),Xa=!1,Za=[],Qa=[];function $a(){Y.focus()}function eo(e){let t=Qa.indexOf(e);return t<0?!1:(Qa.splice(t,1),!0)}function to(e){Qa.push(e)}function no(){Qa=[]}function ro(){let e=za.sessionState()===`streaming`;Va.className=`flex h-7 w-7 flex-none cursor-pointer items-center justify-center rounded-lg ${e?`bg-amber-100 text-amber-700 hover:bg-amber-200 active:bg-amber-300`:`bg-indigo-600 text-white hover:bg-indigo-500 active:bg-indigo-700`}`,Va.title=e?`Queue — delivered when the turn ends`:`Send`,Ha.classList.toggle(`hidden`,e),Ua.classList.toggle(`hidden`,!e),Wa.classList.toggle(`hidden`,!e),Wa.classList.toggle(`flex`,e)}function io(){let e=za.chatVisible()&&Xa;Ga.classList.toggle(`hidden`,!e),Ga.classList.toggle(`flex`,e)}function ao(e,t){let n=[...e.map(e=>({mode:`steer`,text:e})),...t.map(e=>({mode:`queued`,text:e}))];Xa=n.length>0,qa.textContent=n.length>1?`Queued · ${n.length}`:`Queued`,io(),Ka.replaceChildren(...n.map(e=>{let t=K(`li`,`flex items-start gap-2 text-[13px] leading-[18px]`);return e.mode===`steer`&&t.append(K(`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(K(`span`,`min-w-0 whitespace-pre-wrap break-words text-neutral-700`,e.text)),t}))}var oo=8;function so(){Ja.classList.toggle(`hidden`,Za.length===0),Ja.classList.toggle(`flex`,Za.length>0),Ja.replaceChildren(...Za.map((e,t)=>{let n=e.mimeType.startsWith(`image/`)?Object.assign(document.createElement(`img`),{src:`data:${e.mimeType};base64,${e.data}`,className:`h-16 w-16 rounded-md border border-neutral-200 object-cover`}):K(`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=K(`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=()=>{Za.splice(t,1),so()},K(`div`,`relative`,n,r)}))}function co(e){if(Za.length>=oo){J(`error`,`attachment limit is ${oo} files per message`);return}if(e.size>33554432){J(`error`,`${e.name||`file`} is too large (32MB max)`);return}let t=new FileReader;t.onload=()=>{let n=t.result;Za.push({data:n.slice(n.indexOf(`,`)+1),mimeType:e.type||`application/octet-stream`,name:e.name||void 0}),so()},t.readAsDataURL(e)}async function lo(e){let t=[];for(let n of e){let e=await l(`/api/inbox`,n);if(!e.ok)return null;let{path:r}=await e.json();t.push(Ar(r))}return t}var uo=e=>`pier.draft.${e}`;function fo(){let e=za.sessionId();e&&(Y.value.trim()?localStorage.setItem(uo(e),Y.value):localStorage.removeItem(uo(e)))}function po(e){Y.value=localStorage.getItem(uo(e))??``,mo(),Za=[],so()}function mo(){Y.style.height=`auto`,Y.style.height=`${Math.min(Y.scrollHeight,192)}px`}var ho=!1;async function go(e,t){let n=(t??Y.value).trim(),r=t===void 0?Za:[],i=za.sessionId();if(!(!n&&r.length===0||!i)){if(t===void 0){if(ho)return;ho=!0,Y.value=``,mo(),fo(),Za=[],so()}try{let t=[];if(r.length){let e=await lo(r);if(e===null){J(`error`,`attachment upload failed`),Y.value=[n,Y.value.trim()].filter(Boolean).join(`
|
|
74
|
-
`),mo(),fo(),Za=r,so();return}t=e}let a=[n,...t].filter(Boolean).join(`
|
|
75
|
-
`),o=za.sessionState()===`idle`&&e===`auto`;o?za.setState(`streaming`):ro(),(o||e===`steer`)&&(to(a),J(`user`,a),ia(!0));let s=await l(`/api/sessions/${i}/messages`,{text:a,mode:e});if(!s.ok){let e=await u(s,`send failed`);await za.reload(i),J(`error`,e)}}finally{t===void 0&&(ho=!1)}}}async function _o(e){let t=za.sessionId();if(!t)return;ao([],[]);let n=await l(`/api/sessions/${t}/queue/deliver`,{mode:e});n.ok||J(`error`,`queue ${e} failed: ${n.status}`)}async function vo(){let e=za.sessionId();if(!e)return;let t=await fetch(`/api/sessions/${e}/queue/recall`,{method:`POST`});if(!t.ok)return;let{messages:n}=await t.json();n.length&&(Y.value=[Y.value.trim(),...n].filter(Boolean).join(`
|
|
76
|
-
`),mo(),fo(),Y.focus()),ao([],[])}function yo(e){za=e,Wa.onclick=()=>{let e=za.sessionId();e&&fetch(`/api/sessions/${e}/abort`,{method:`POST`})},G(`#queue-steer`).onclick=()=>void _o(`steer`),G(`#queue-restart`).onclick=()=>void _o(`restart`),G(`#queue-recall`).onclick=()=>void vo(),Ba.onsubmit=e=>{e.preventDefault(),go(`auto`)},Y.oninput=()=>{mo(),fo()};let t=!matchMedia(`(pointer: coarse)`).matches;Y.onkeydown=e=>{e.isComposing||e.keyCode===229||t&&e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),go(`auto`))},Y.onpaste=e=>{for(let t of e.clipboardData?.items??[]){let e=t.kind===`file`?t.getAsFile():null;e&&co(e)}let t=e.clipboardData?.getData(`text/plain`)??``,n=t.trim();!n||n===t||(e.preventDefault(),Y.setRangeText(n,Y.selectionStart??0,Y.selectionEnd??0,`end`),mo(),fo())},na.ondragover=e=>e.preventDefault(),na.ondrop=e=>{e.preventDefault();for(let t of e.dataTransfer?.files??[])co(t)},G(`#attach`).onclick=()=>Ya.click(),Ya.onchange=()=>{for(let e of Ya.files??[])co(e);Ya.value=``},ro()}var bo=null;function xo(e){bo&&!bo.contains(e.target)&&wo()}function So(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),wo())}function Co(e){bo&&!bo.contains(e.target)&&wo()}function wo(){bo&&=(document.removeEventListener(`pointerdown`,xo,!0),document.removeEventListener(`keydown`,So,!0),window.removeEventListener(`scroll`,Co,!0),window.removeEventListener(`resize`,wo),bo.remove(),null)}var To=()=>window.innerWidth<640;function Eo(e,t){wo();let n=To();if(bo=K(`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]`}`),bo.append(t),(e.closest(`dialog[open]`)??document.body).append(bo),!n){let t=e.getBoundingClientRect();bo.style.top=`${Math.max(8,Math.min(t.bottom+4,window.innerHeight-bo.offsetHeight-8))}px`,bo.style.left=`${Math.max(8,Math.min(t.left,window.innerWidth-bo.offsetWidth-8))}px`}document.addEventListener(`pointerdown`,xo,!0),document.addEventListener(`keydown`,So,!0),window.addEventListener(`scroll`,Co,!0),window.addEventListener(`resize`,wo)}function Do(e){let t=K(`button`,`flex w-full cursor-pointer items-center gap-2 px-3 text-left hover:bg-neutral-100 active:bg-neutral-100 ${To()?`py-3`:`py-1.5`}`,K(`span`,`flex-none w-3 text-indigo-600`,e.checked?`✓`:``),K(`span`,`truncate`,e.label));return e.hint&&t.append(K(`span`,`ml-auto flex-none text-[11.5px] text-neutral-400`,e.hint)),t.onclick=()=>e.onSelect(),t}function Oo(e,t){Eo(e,K(`div`,``,...t.map(Do)))}var ko=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Ao=`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,X=(e,t=!1)=>jo(e,`${t?`btn btn-primary`:`btn`} text-[12.5px]`),jo=(e,t=``)=>{let n=K(`button`,t,e);return n.type=`button`,n};function Mo(e,t,n){let r=X(e);return t&&r.classList.add(`bg-neutral-200`),r.onclick=n,r}function No(e,t,n){let r=jo(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 Po(e,t,...n){let r=K(`section`,`rounded-xl border border-neutral-200 bg-white shadow-xs`),i=K(`div`,`rounded-t-xl border-b border-neutral-200/70 bg-neutral-50/70 px-4 py-2.5`);return i.append(K(`h2`,`text-[13px] font-semibold text-neutral-700`,e)),t&&i.append(K(`p`,`mt-0.5 text-[11.5px] leading-snug text-neutral-500`,t)),r.append(i,K(`div`,`flex flex-col gap-4 px-4 py-3.5`,...n)),r}function Z(e,t,n={}){let r=K(`div`,`flex flex-col gap-1.5`),i=K(`div`,`flex items-center gap-1.5`,K(`span`,Ao,e));return n.help&&i.append(n.help),r.append(i,t),n.hint&&r.append(K(`span`,`text-[11.5px] leading-snug text-neutral-400`,n.hint)),r}var Fo=`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`,Io=(e,t,n,r=!1)=>{let i=document.createElement(`input`);return i.className=r?`${Fo} font-mono`:Fo,i.value=e,i.placeholder=t,i.oninput=()=>n(i.value),i},Q=(e=``,t=`text`)=>{let n=document.createElement(`input`);return n.type=t,n.className=Fo,n.value=e,n},Lo=(e,t)=>{let n=document.createElement(`select`);return n.className=`${Fo} select`,n.append(...e.map(([e,t])=>new Option(e,t))),n.value=t,n},Ro=(e=``,t=4)=>{let n=document.createElement(`textarea`);return n.className=`${Fo} resize-y font-mono`,n.value=e,n.rows=t,n.spellcheck=!1,n};function zo(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=K(`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=K(`label`,`flex cursor-pointer gap-2.5 ${e?`items-start`:`items-center`}`);if(s.append(a,o),e){let n=K(`span`,`flex items-center gap-1.5`,K(`span`,`text-[13px] text-neutral-700`,e));i&&n.append(i);let r=K(`span`,`flex min-w-0 flex-col`,n);t&&r.append(K(`span`,`text-[11.5px] leading-snug text-neutral-400`,t)),s.append(r)}return s}var Bo={idle:`text-neutral-400`,saving:`text-neutral-400`,saved:`text-green-700`,failed:`text-red-600`};function $(e,t,n){e.className=`text-[11.5px] ${Bo[t]}`,e.textContent=n}var Vo=(e,t)=>K(`span`,`flex-none rounded-full px-1.5 py-px text-[10px] font-medium uppercase tracking-wide ring-1 ${t}`,e),Ho=e=>K(`p`,`rounded-lg border border-dashed border-neutral-200 px-3 py-4 text-center text-[12.5px] text-neutral-400`,e);function Uo(e,t,n=`left`){let r=K(`span`,`group relative inline-flex`),i=jo(`?`,`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=K(`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=K(`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(K(`span`,`text-[12.5px] font-semibold text-neutral-800`,e));let s=K(`ol`,`flex list-decimal flex-col gap-1.5 pl-4`);for(let e of t){let t=K(`li`,`marker:text-neutral-400`);t.append(typeof e==`string`?Zn(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 Wo=(e,t)=>K(`span`,`flex flex-col gap-1`,Zn(e),t),Go=e=>`${e.provider}/${e.id}`,Ko=`pier.modelFavorites`,qo=e=>`${Go(e)}@${e.thinking}`,Jo=null;async function Yo(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).modelMenu}function Xo(){try{let e=JSON.parse(localStorage.getItem(Ko)??`[]`);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 Zo(e){let t=K(`button`,`flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-3 py-1.5 text-left`,K(`span`,`w-3 flex-none text-indigo-600`,e.checked?`✓`:``),K(`span`,`truncate`,e.label));e.hint&&t.append(K(`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=K(`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()},K(`div`,`group/row flex w-full items-center hover:bg-neutral-100`,t,n)}function Qo({models:e,current:t,thinkingLevel:n,thinkingLevels:r,onPick:i,onThinkingPick:a}){let o=Xo(),s=n,c=K(`div`,`flex w-72 flex-col`),l=K(`div`,`flex flex-col gap-2 border-b border-neutral-200 px-2 py-2`),u=document.createElement(`input`);if(u.type=`search`,u.placeholder=`Search models`,u.setAttribute(`aria-label`,`Search models`),u.className=`w-full rounded-md border border-neutral-300 px-2 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`,l.append(u),r.length){let e=K(`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 r){let n=document.createElement(`option`);n.value=e,n.textContent=Ln(e),t.append(n)}t.value=n,t.onchange=()=>{s=t.value,g(u.value),a(s)},e.append(K(`span`,`font-medium`,`Reasoning`),t),l.append(e)}let d=e=>{let t=qo(e);o=o.some(e=>qo(e)===t)?o.filter(e=>qo(e)!==t):[...o,e],localStorage.setItem(Ko,JSON.stringify(o)),g(u.value)},f=(e,t)=>o.some(n=>qo(n)===`${Go(e)}@${t}`),p=K(`div`,`max-h-72 overflow-y-auto py-1`),m=new Map(e.map(e=>[Go(e),e])),h=(e,n,r)=>{let a=n.map(e=>({e,model:m.get(Go(e))})).filter(e=>!!e.model&&(!r||Go(e.model).toLowerCase().includes(r)));a.length&&p.append(K(`div`,`px-3 pb-0.5 pt-1 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),...a.map(({e,model:n})=>{let r=e.thinking??s;return Zo({label:n.id,hint:e.thinking?Ln(e.thinking):void 0,title:e.note,checked:!!t&&Go(t)===Go(n)&&s===r,starred:f(n,r),onSelect:()=>i(n,e.thinking),onStar:()=>d({provider:n.provider,id:n.id,thinking:r})})}),K(`div`,`my-1 border-t border-neutral-100`))},g=n=>{p.replaceChildren();let r=n.trim().toLowerCase();h(`Pinned`,Jo??[],r),h(`Starred`,o,r);let a=new Map;for(let t of e){if(r&&!Go(t).toLowerCase().includes(r))continue;let e=a.get(t.provider);e?e.push(t):a.set(t.provider,[t])}if(!a.size){p.append(K(`div`,`px-3 py-2 text-[12.5px] text-neutral-400`,e.length?`No matching models.`:`No models available.`));return}for(let[e,n]of a){let a=n.some(e=>!!t&&Go(t)===Go(e)),o=document.createElement(`details`);o.open=a||r.length>0;let c=K(`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`,K(`span`,`chev`,`▶`),K(`span`,`truncate`,e),K(`span`,`ml-auto flex-none normal-case text-neutral-300`,String(n.length)));o.append(c,...n.map(e=>Zo({label:e.id,checked:!!t&&Go(t)===Go(e),starred:f(e,s),onSelect:()=>i(e),onStar:()=>d({provider:e.provider,id:e.id,thinking:s})}))),p.append(o)}};return u.oninput=()=>g(u.value),g(``),Yo().then(e=>{let t=JSON.stringify(e)!==JSON.stringify(Jo);Jo=e,t&&g(u.value)}).catch(e=>Na(`model menu unavailable`,e)),c.append(l,p),queueMicrotask(()=>u.focus()),c}function $o(e,t,n,r){let i=jo(t.model?`${t.model.id}${t.thinking?` · ${Ln(t.thinking)}`:``}`:t.thinking?`Pi default · ${Ln(t.thinking)}`:`Pi default`,`${Fo} flex cursor-pointer items-center gap-1.5 truncate text-left hover:bg-neutral-50 ${t.model?`text-neutral-700`:`text-neutral-400`}`);return i.title=t.model?`${t.model.provider}/${t.model.id}`:`Whatever the project and Pi pick`,i.onclick=()=>{let e=Qo({models:n,current:t.model,thinkingLevel:t.thinking??`medium`,thinkingLevels:[...ko],onPick:(e,n)=>{wo(),r({model:e,thinking:n??t.thinking})},onThinkingPick:e=>r({...t,thinking:e})}),a=jo(`Pi default`,`w-full cursor-pointer px-3 py-1.5 text-left text-[12.5px] text-neutral-500 hover:bg-neutral-100`);a.onclick=()=>{wo(),r({model:null,thinking:null})};let o=K(`div`,`flex flex-col`);o.append(e,K(`div`,`border-t border-neutral-200`),a),Eo(i,o)},Z(e,i)}var es=async e=>{let t=e?.startsWith(`/`)?`?path=${encodeURIComponent(e)}`:``,n=await fetch(`/api/fs/dirs${t}`);return n.ok?await n.json():null},ts=(e,t,n)=>{let r=jo(e,`flex w-full cursor-pointer items-center gap-1.5 px-3 py-1 text-left ${t}`);return r.onclick=n,r};function ns(e,t){let n=K(`div`,`flex-none border-t border-neutral-200`),r=ts(`+ 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=K(`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 l(`/api/fs/dirs`,{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 rs(e,t){let n=jo(`Browse…`,`flex-none cursor-pointer rounded-md border border-neutral-300 px-2 py-1 text-[12px] text-neutral-600 hover:bg-neutral-100`),r=n=>{e.value=n,e.dispatchEvent(new Event(`input`,{bubbles:!0})),t?.(n),wo()};async function i(e){let t=await es(e);if(!t)return;let a=K(`div`,`flex max-h-80 w-80 flex-col`),o=jo(`Use`,`ml-auto flex-none cursor-pointer rounded bg-indigo-600 px-2 py-0.5 text-[11.5px] text-white`);o.onclick=()=>r(t.path);let s=K(`div`,`flex flex-none items-center gap-2 border-b border-neutral-200 px-3 py-1.5`,K(`span`,`truncate font-mono text-[11.5px] text-neutral-500`,t.path),o),c=K(`div`,`min-h-0 flex-1 overflow-y-auto py-0.5 text-[12.5px]`);t.parent&&c.append(ts(`../`,`font-mono text-neutral-500 hover:bg-neutral-100`,()=>void i(t.parent)));for(let e of t.entries)c.append(ts(e,`truncate hover:bg-neutral-100`,()=>void i(`${t.path}/${e}`.replace(`//`,`/`))));t.entries.length||c.append(K(`p`,`px-3 py-1.5 text-[12px] text-neutral-400`,`No sub-folders.`)),a.append(s,c,ns(t.path,e=>void i(e))),Eo(n,a)}return n.onclick=()=>void i(e.value.trim()||void 0),n}function is(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:K(`div`,`flex items-center gap-1.5`,r,rs(r,n)),input:r}}var as,os=G(`#project-tree`),ss=G(`#archive-dialog`),cs=G(`#archive-list`),ls=G(`#archive-search`),us=G(`#archive-count`),ds=G(`#new-dialog`),fs=G(`#known-projects`),ps=`pier.collapsedProjects`,ms=new Set(hs());function hs(){try{let e=JSON.parse(localStorage.getItem(ps)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function gs(e,t){t?ms.add(e):ms.delete(e),localStorage.setItem(ps,JSON.stringify([...ms]))}function _s(e){let t=new Map;for(let n of e){let e=t.get(n.cwd);e?e.push(n):t.set(n.cwd,[n])}return t}var vs=`ml-auto hidden flex-none rounded px-1 leading-none text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700 group-hover:block pointer-coarse:block`;function ys(e){let[t,n]=e.state===`streaming`?[`bg-green-500 animate-pulse`,`working…`]:e.unread?[`bg-amber-500`,`turn finished — not viewed yet`]:e.activeRuns>0?[`bg-sky-500`,`${e.activeRuns} subagent${e.activeRuns>1?`s`:``} running`]:[`bg-neutral-300`,`idle`],r=K(`span`,`h-2 w-2 flex-none rounded-full ${t}`);return r.title=n,r}async function bs(e,t){e.pinned=t,Cs(),as.onPinsChanged(),(await l(`/api/sessions/${e.id}/pin`,{pinned:t})).ok||(e.pinned=!t,Cs(),as.onPinsChanged())}function xs(e){let t=K(`li`,`group flex cursor-pointer items-center gap-1.5 py-1.5 pl-6 pr-3 hover:bg-neutral-100 ${e.id===as.currentId()?`bg-indigo-50 hover:bg-indigo-50`:``}`),n=K(`button`,vs,`⋯`);return n.title=`Session actions`,n.onclick=t=>{t.stopPropagation(),as.sessionMenu(n,e)},t.append(ys(e),K(`span`,`truncate`,e.title??`untitled`),n),t.onclick=()=>as.select(e.id),t}function Ss(e,t){let n=K(`span`,`ml-auto flex-none text-[11px] text-neutral-400 group-hover:hidden`,String(t.length)),r=K(`button`,vs,`+`);r.title=`New session in ${e}`,r.onclick=t=>{t.preventDefault(),t.stopPropagation(),as.createSession(e)};let i=K(`button`,vs.replace(`ml-auto `,``),`⋯`);i.title=`Project actions`,i.onclick=t=>{t.preventDefault(),t.stopPropagation(),Oo(i,[{label:`Browse files`,onSelect:()=>{wo(),as.openFiles(e)}}])};let{el:a,summary:o}=er(`border-b border-neutral-200/70`,[K(`span`,`truncate font-mono text-[11px] font-semibold uppercase tracking-wide text-neutral-500`,Jn(e)),n,r,i]);o.className+=` group px-3 py-1.5 hover:bg-neutral-100`,o.title=e,a.open=!ms.has(e),a.ontoggle=()=>gs(e,!a.open);let s=K(`ul`,`pb-1`);return s.append(...t.map(xs)),a.append(s),a}function Cs(){let e=as.sessions(),t=_s(e.filter(e=>e.pinned));os.replaceChildren(...t.size?[...t].map(([e,t])=>Ss(e,t)):[K(`p`,`px-3 py-2 text-[12.5px] leading-snug text-neutral-400`,`No projects yet — create a session, or pin one from All sessions.`)]),us.textContent=String(e.length),fs.replaceChildren(...[..._s(e).keys()].map(e=>{let t=document.createElement(`option`);return t.value=e,t})),ss.open&&Ts()}function ws(e){let t=K(`button`,`flex-none rounded px-1.5 py-0.5 text-[11.5px] ${e.pinned?`bg-indigo-50 text-indigo-600`:`text-neutral-400 hover:bg-neutral-200 hover:text-neutral-700`}`,e.pinned?`pinned`:`pin`);t.title=e.pinned?`Remove from Projects`:`Pin to Projects`,t.onclick=t=>{t.stopPropagation(),bs(e,!e.pinned)};let n=K(`li`,`flex cursor-pointer items-center gap-2 px-3 py-1.5 hover:bg-neutral-100`,ys(e),K(`span`,`truncate`,e.title??`untitled`),K(`span`,`ml-auto flex-none text-[11px] text-neutral-400`,qn(e.createdAt)),t);return n.onclick=()=>{ss.close(),as.select(e.id)},n}function Ts(){let e=ls.value.trim().toLowerCase(),t=as.sessions().filter(t=>!e||`${t.title??``} ${t.cwd}`.toLowerCase().includes(e)),n=[];for(let[e,r]of _s(t)){let t=K(`li`,`truncate px-3 pb-0.5 pt-2 font-mono text-[11px] font-semibold uppercase tracking-wide text-neutral-500`,Jn(e));t.title=e,n.push(t,...r.map(ws))}cs.replaceChildren(...n.length?n:[K(`li`,`px-3 py-3 text-[13px] text-neutral-400`,`No matching sessions.`)])}function Es(e){as=e,G(`#new-cwd-row`).append(rs(G(`#new-cwd`))),G(`#new-session`).onclick=()=>{G(`#new-cwd`).value=``,ds.showModal()},G(`#new-cancel`).onclick=()=>ds.close(),G(`#new-form`).onsubmit=()=>void as.createSession(G(`#new-cwd`).value.trim()),G(`#open-archive`).onclick=()=>{ls.value=``,Ts(),ss.showModal(),ls.focus()},G(`#archive-close`).onclick=()=>ss.close(),ls.oninput=()=>Ts()}var Ds;function Os(e){Ds=e}var ks=G(`#chat-title`),As=G(`#chat-menu`),js=G(`#session-meta`),Ms=null,Ns=null,Ps=null;function Fs(){Ms=null,Ns=null,Ps=null,Vs()}function Is(e,t,n){Ms=e,Ns=t,Ps=n,Rs()}function Ls(e){Ns&&(Ns={...Ns,tokens:e},Vs())}function Rs(){let e=Ds.currentSession();ks.textContent=e?e.title??`Untitled session`:`no session`,As.classList.toggle(`hidden`,!e),e&&(As.onclick=()=>qs(As,e)),Vs(),Ds.syncBar()}var zs=(e,t)=>Math.min(100,Math.round(e/t.contextWindow*100)),Bs=e=>e.tokens===null?`?/${Rn(e.contextWindow)}`:`${Rn(e.tokens)}/${Rn(e.contextWindow)} · ${100-zs(e.tokens,e)}% left`;function Vs(){let e=Ns,t=e?.tokens??null,n=Ds.currentId(),r=[];if(n){let e=(e,t)=>{let r=K(`button`,`flex-none cursor-pointer font-mono ${t}`,e);return r.title=`Change model or reasoning`,r.onclick=()=>void Us(r,n),r};Ms&&r.push(e(Ms.id,`rounded bg-indigo-50 px-1.5 py-px font-medium text-indigo-700 hover:bg-indigo-100`)),Ps&&r.push(e(Ps,`text-neutral-500 hover:text-indigo-700`))}if(e&&t!==null){let n=zs(t,e),i=n>=90?`text-red-700`:n>=70?`text-amber-700`:`text-neutral-500`;r.push(K(`span`,`flex-none font-mono ${i}`,Rn(t).toLowerCase()))}let i=r.flatMap((e,t)=>t===0?[e]:[K(`span`,`text-neutral-300`,`·`),e]);js.replaceChildren(...i),js.classList.toggle(`hidden`,r.length===0),js.classList.toggle(`flex`,r.length>0)}function Hs(e,t){let n=[[`Title`,t.title??`untitled`],[`Directory`,t.cwd],[`Session`,t.id]];t.id===Ds.currentId()&&(n.push([`Model`,Ms?.id??`—`]),n.push([`Context`,Ns?Bs(Ns):`—`]));let r=K(`div`,`flex max-w-80 flex-col gap-1.5 px-3 py-2`);for(let[e,t]of n){let n=K(`div`,`flex items-center gap-1.5`,K(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),$n(`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));r.append(K(`div`,`group flex flex-col`,n,K(`span`,`break-all font-mono text-[12px] text-neutral-700`,t)))}Eo(e,r)}async function Us(e,t){try{let[n,r]=await Promise.all([fetch(`/api/sessions/${t}/models`),fetch(`/api/sessions/${t}/thinking`)]);if(!n.ok||!r.ok)throw Error(`HTTP ${n.ok?r.status:n.status}`);let i=await n.json(),a=await r.json();Eo(e,Qo({models:i,current:t===Ds.currentId()?Ms:null,thinkingLevel:a.level,thinkingLevels:a.levels,onPick:(e,n)=>{wo(),Ws(t,e,n)},onThinkingPick:e=>void Ks(t,e)}))}catch(e){J(`error`,`model options failed: ${String(e)}`)}}async function Ws(e,t,n){await Gs(e,t)&&n&&await Ks(e,n)}async function Gs(e,t){let n=Ms;e===Ds.currentId()&&(Ms=t,Rs());let r=await l(`/api/sessions/${e}/model`,t);if(!r.ok){let{error:t}=await r.json().catch(()=>({}));return e===Ds.currentId()&&(Ms=n,Rs()),J(`error`,`model change failed: ${t??r.status}`),!1}let{model:i}=await r.json();return e===Ds.currentId()&&i&&(Ms=i,Rs()),!0}async function Ks(e,t){let n=await l(`/api/sessions/${e}/thinking`,{level:t});if(!n.ok){J(`error`,`reasoning change failed: ${n.status}`);return}let{level:r}=await n.json();e===Ds.currentId()&&(Ps=r,Vs())}function qs(e,t){Oo(e,[{label:`Session info`,onSelect:()=>Hs(e,t)},{label:t.pinned?`Remove from Projects`:`Pin to Projects`,checked:t.pinned,onSelect:()=>{wo(),bs(t,!t.pinned)}},{label:`Model`,hint:t.id===Ds.currentId()?Ms?.id??`…`:``,onSelect:()=>void Us(e,t.id)},{label:`Browse files`,onSelect:()=>{wo(),Ds.openFiles(t.cwd)}}])}var Js=G(`#sidebar`),Ys=G(`#drawer-scrim`),Xs=G(`#mobile-title`),Zs=G(`#mobile-menu`);function Qs(){delete Js.dataset.open,Ys.classList.add(`hidden`)}function $s(e,t){Xs.textContent=e,Zs.classList.toggle(`hidden`,!t)}var ec=`pier.railClosed`;localStorage.getItem(ec)===`1`&&(document.body.dataset.rail=`closed`);function tc(e){document.body.dataset.rail=e?`closed`:``,localStorage.setItem(ec,e?`1`:`0`)}function nc(e){G(`#drawer-toggle`).onclick=()=>{if(Js.dataset.open!==void 0)return Qs();Js.dataset.open=``,Ys.classList.remove(`hidden`)},Ys.onclick=Qs,Zs.onclick=()=>e.sessionMenu(Zs),G(`#rail-toggle`).onclick=()=>tc(document.body.dataset.rail!==`closed`)}var rc=`https://github.com/timqi/pier`,ic=[`text-neutral-400`,`hover:text-neutral-700`],ac=[`rounded-full`,`bg-emerald-50`,`px-1.5`,`text-emerald-700`,`ring-1`,`ring-inset`,`ring-emerald-600/20`,`hover:bg-emerald-100`];function oc(e){let t=G(`#version`);t.textContent=`v${e}`,fetch(`/api/update`).then(e=>e.json()).then(({latest:n,available:r})=>{!r||!n||(t.textContent=`v${e} → ${n}`,t.href=`${rc}/releases`,t.title=`${n} is out. Update with: pier update`,t.classList.remove(...ic),t.classList.add(...ac))}).catch(()=>{})}var sc=(e,t={})=>{let n=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n},cc=e=>e===null?`-`:Yn(Date.now()-e);function lc(e,t,n){let r=`sessions`,i=`active`,a={sessions:[],runs:[],messages:[]};async function o(){let t=await fetch(`/api/activity?scope=${i}`);if(!t.ok){e.replaceChildren(K(`p`,`p-4 text-[13px] text-red-600`,`Failed to load activity: ${t.status}`));return}a=await t.json(),s()}function s(){let t=K(`header`,`flex h-10 flex-none items-center gap-2 border-b border-neutral-200 px-4 max-md:hidden`,K(`span`,`font-medium`,`Activity`)),a=K(`div`,`tabstrip`);a.append(Mo(`Sessions`,r===`sessions`,()=>{r=`sessions`,s()}),Mo(`Dependencies`,r===`dependencies`,()=>{r=`dependencies`,s()}),Mo(`Tasks`,!1,()=>n()));let u=K(`div`,`ml-auto flex gap-1 max-md:ml-0 max-md:w-full`);u.append(Mo(`Active`,i===`active`,()=>{i=`active`,o()}),Mo(`Last 24h`,i===`recent`,()=>{i=`recent`,o()})),a.append(u);let d=K(`div`,`min-h-0 flex-1 overflow-auto`);r===`sessions`?c(d):l(d),e.replaceChildren(t,a,d)}function c(e){let n=document.createElement(`table`);n.className=`w-full min-w-[38rem] table-fixed text-left text-[12.5px]`,n.innerHTML=`<thead class="bg-neutral-50 text-[10.5px] uppercase text-neutral-400"><tr>
|
|
77
|
-
<th class="w-[34%] px-4 py-2 font-semibold">Session</th>
|
|
78
|
-
<th class="w-[38%] px-2 py-2 font-semibold">Project</th>
|
|
79
|
-
<th class="w-[14%] px-2 py-2 font-semibold">State</th>
|
|
80
|
-
<th class="px-2 py-2 font-semibold">Duration</th></tr></thead>`;let r=document.createElement(`tbody`);for(let e of a.sessions){let n=document.createElement(`tr`);n.className=`cursor-pointer border-b border-neutral-100 hover:bg-neutral-50`,n.onclick=()=>t(e.id),n.append(K(`td`,`px-4 py-2.5`,K(`div`,`truncate font-medium`,e.title??`Untitled session`),K(`div`,`truncate font-mono text-[11px] text-neutral-400`,e.id)),K(`td`,`truncate px-2 py-2.5 font-mono text-[11.5px]`,e.cwd||`-`),K(`td`,`px-2 py-2.5`,K(`span`,`mr-2 inline-block h-2 w-2 rounded-full ${e.state===`streaming`?`animate-pulse bg-green-500`:`bg-neutral-300`}`),e.state),K(`td`,`px-2 py-2.5 text-neutral-500`,cc(e.stateSince))),r.append(n)}n.append(r),e.append(n),a.sessions.length||e.append(K(`p`,`p-4 text-[13px] text-neutral-400`,i===`active`?`No active sessions.`:`No sessions in the last 24 hours.`))}function l(e){let r=new Map,o=[],s=(e,t,n,i)=>{r.has(e)||r.set(e,{id:e,label:t,kind:n,state:i})};for(let e of a.sessions)s(e.id,e.title??e.id.slice(0,10),`session`,e.state);for(let e of a.runs){let t=e.invokedBySessionId??`scheduler`,n=e.targetSessionId??(e.context.definition.action.type===`bash`?`process:${e.id}`:`task:${e.id}`);s(t,t===`scheduler`?`Scheduler`:t.slice(0,10),t===`scheduler`?`scheduler`:`session`),s(n,e.targetSessionId?e.targetSessionId.slice(0,10):e.context.definition.action.type===`bash`?`Bash process`:`Task`,e.targetSessionId?`session`:e.context.definition.action.type===`bash`?`process`:`task`),o.push({from:t,to:n,run:e,kind:`invocation`}),e.callbackSessionId&&(s(e.callbackSessionId,e.callbackSessionId.slice(0,10),`session`),o.push({from:n,to:e.callbackSessionId,run:e,kind:`callback`}))}for(let e of a.messages){if(!e.fromSessionId||!e.toSessionId||e.fromSessionId===e.toSessionId)continue;let t=a.runs.find(t=>t.id===e.runId);if(t){for(let t of[e.fromSessionId,e.toSessionId])s(t,t===`console`?`Console`:t.slice(0,10),t===`console`?`console`:`session`);o.push({from:e.fromSessionId,to:e.toSessionId,run:t,kind:`message`})}}if(!r.size){e.append(K(`p`,`p-4 text-[13px] text-neutral-400`,i===`active`?`No active dependencies.`:`No dependencies in the last 24 hours.`));return}let c=[...r.values()],l=new Set(o.map(e=>e.to)),u=new Map,d=c.filter(e=>!l.has(e.id)).map(e=>e.id);d.length||d.push(c[0].id);for(let e of d)u.set(e,0);for(;d.length;){let e=d.shift();for(let t of o)t.from!==e||u.has(t.to)||(u.set(t.to,u.get(e)+1),d.push(t.to))}for(let e of c)u.has(e.id)||u.set(e.id,0);let f=new Map;for(let e of c){let t=u.get(e.id);f.set(t,[...f.get(t)??[],e])}let p=Math.max(...f.keys())+1,m=Math.max(...[...f.values()].map(e=>e.length)),h=o.some(e=>e.from!==e.to&&u.get(e.from)===u.get(e.to))?40:0,g=56+p*180+(p-1)*110+h,_=56+m*46+(m-1)*30,v=new Map;for(let[e,t]of f)t.forEach((t,n)=>v.set(t.id,{x:28+e*290+90,y:28+n*76+23}));let y=sc(`svg`,{width:String(g),height:String(_),viewBox:`0 0 ${g} ${_}`,class:`block`}),b=sc(`defs`);for(let[e,t]of[[`activity-arrow`,`#a3a3a3`],[`activity-arrow-cb`,`#0891b2`],[`activity-arrow-msg`,`#d97706`]]){let n=sc(`marker`,{id:e,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto-start-reverse`});n.append(sc(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:t})),b.append(n)}y.append(b);let x=new Set;for(let e of o){let t=`${e.from}→${e.to}:${e.kind}`;if(x.has(t))continue;x.add(t);let r=v.get(e.from),i=v.get(e.to),a=sc(`path`,{d:r.x===i.x?`M ${r.x+90} ${r.y} C ${r.x+90+46} ${r.y}, ${i.x+90+46} ${i.y}, ${i.x+90} ${i.y}`:(()=>{let e=i.x>r.x,t=r.x+(e?90:-90),n=i.x+(e?-90:90),a=Math.max(36,Math.abs(n-t)*.45)*(e?1:-1);return`M ${t} ${r.y} C ${t+a} ${r.y}, ${n-a} ${i.y}, ${n} ${i.y}`})(),fill:`none`,stroke:e.kind===`callback`?`#0891b2`:e.kind===`message`?`#d97706`:`#a3a3a3`,"stroke-width":`1.5`,"marker-end":e.kind===`callback`?`url(#activity-arrow-cb)`:e.kind===`message`?`url(#activity-arrow-msg)`:`url(#activity-arrow)`});e.kind===`callback`&&a.setAttribute(`stroke-dasharray`,`6 5`),e.kind===`message`&&a.setAttribute(`stroke-dasharray`,`2 5`),a.classList.add(`cursor-pointer`),a.onclick=()=>n(e.run.taskId),y.append(a)}let S={scheduler:{fill:`#f5f3ff`,stroke:`#a78bfa`,text:`#5b21b6`},console:{fill:`#eff6ff`,stroke:`#93c5fd`,text:`#1d4ed8`},task:{fill:`#fffbeb`,stroke:`#fbbf24`,text:`#92400e`},process:{fill:`#f5f5f5`,stroke:`#a3a3a3`,text:`#525252`,dash:`4 3`}},C=/[\u1100-\u11FF\u2E80-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6]/,w=(e,t)=>{let n=0;for(let r=0;r<e.length;r++)if(n+=C.test(e[r])?2:1,n>t)return`${e.slice(0,r)}…`;return e};for(let e of c){let n=v.get(e.id),r=e.kind===`session`?e.state===`streaming`?{fill:`#ffffff`,stroke:`#10b981`,text:`#262626`}:{fill:`#fafafa`,stroke:`#d4d4d4`,text:`#737373`}:S[e.kind],i=sc(`g`,{transform:`translate(${n.x},${n.y})`});e.kind===`session`&&i.classList.add(`cursor-pointer`),i.onclick=()=>{e.kind===`session`&&t(e.id)};let a=sc(`rect`,{x:`-90`,y:`-23`,width:`180`,height:`46`,rx:`10`,fill:r.fill,stroke:r.stroke,"stroke-width":e.kind===`session`&&e.state===`streaming`?`1.5`:`1`});r.dash&&a.setAttribute(`stroke-dasharray`,r.dash),i.append(a);let o=-78;if(e.kind===`session`){let t=sc(`circle`,{cx:`-75`,cy:`0`,r:`3.5`,fill:e.state===`streaming`?`#10b981`:`#d4d4d4`});if(e.state===`streaming`){let e=sc(`animate`,{attributeName:`opacity`,values:`1;0.3;1`,dur:`1.6s`,repeatCount:`indefinite`});t.append(e)}i.append(t),o=-64}let s=sc(`text`,{x:String(o),"text-anchor":`start`,"dominant-baseline":`middle`,"font-size":`11.5`,"font-weight":e.kind===`session`?`500`:`400`,fill:r.text});s.textContent=w(e.label,e.kind===`session`?22:25);let c=sc(`title`);c.textContent=e.label===e.id?e.id:`${e.label}\n${e.id}`,i.append(s,c),y.append(i)}let T=e=>K(`span`,`inline-block h-2 w-2 rounded-full ${e}`);e.append(K(`div`,`w-max p-4`,y),K(`div`,`flex flex-wrap gap-x-5 gap-y-1 border-t border-neutral-200 px-4 py-2 text-[11px] text-neutral-500`,K(`span`,``,`Solid: task invocation`),K(`span`,`text-cyan-700`,`Dashed: callback`),K(`span`,`text-amber-700`,`Dotted: supervisor/control`),K(`span`,`inline-flex items-center gap-1.5`,T(`bg-emerald-500`),`streaming`),K(`span`,`inline-flex items-center gap-1.5`,T(`bg-neutral-300`),`idle`)))}let u=Xn(e,e=>{e===`dependencies`?r=`dependencies`:e===`sessions`&&(r=`sessions`),o()});return Object.assign(u,{refresh(){u.visible&&o()}})}function uc(e,t){let n=[],r=``,i=K(`header`,`sticky top-0 z-30 flex h-10 items-center gap-3 border-b border-neutral-200 bg-white px-4`,K(`span`,`font-medium max-md:hidden`,`Boards`)),a=K(`div`,`px-4 py-5`);e.append(K(`div`,`min-h-0 flex-1 overflow-y-auto`,i,a));async function o(e,t){let n=await l(`/api/boards/${e}`,{public:t},`PATCH`);n.ok||(r=`Could not change ${e}: ${n.status}`,await f())}async function s(e){let t=await fetch(`/api/boards/${e}`,{method:`DELETE`});t.ok||(r=`Could not delete ${e}: ${t.status}`),await f()}function c(e){let n=K(`div`,`group flex flex-col gap-1 border-b border-neutral-200/70 px-1 py-2.5 last:border-b-0`),r=document.createElement(`a`);r.className=`truncate font-medium text-neutral-800 hover:text-indigo-700`,r.href=`/boards/${e.slug}/`,r.target=`_blank`,r.rel=`noreferrer`,r.textContent=e.title;let i=K(`div`,`flex items-center gap-2`,r,K(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,e.slug)),a=zo(``,``,e.public,t=>{e.public=t,o(e.slug,t)});a.className=`ml-auto flex flex-none cursor-pointer items-center gap-1.5 text-[11.5px] text-neutral-500`,a.append(K(`span`,``,`Public`));let c=jo(`Delete`,`flex-none cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100`);c.title=`Renames the folder on disk; nothing is erased`,c.onclick=()=>void s(e.slug),i.append(a,c),n.append(i);let l=K(`div`,`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11.5px] text-neutral-500`);e.description&&l.append(K(`span`,`min-w-0 truncate`,e.description)),l.append(K(`span`,`flex-none text-neutral-400`,qn(Date.parse(e.updatedAt))));for(let n of e.sessions){let e=jo(n.slice(0,8),`flex-none cursor-pointer font-mono text-indigo-600 hover:underline`);e.title=`Open session ${n}`,e.onclick=()=>t(n),l.append(e)}if(e.public){let t=K(`span`,`flex-none font-mono text-neutral-400`,`/p/${e.slug}/`);t.title=`Public URL — anyone who can reach Pier can read this`,l.append(t)}return n.append(l),n}let u=[{title:`Public`,hint:`Readable at /p/<slug>/ by anyone who can reach Pier.`,wanted:!0},{title:`Private`,hint:`Reachable from the Console only.`,wanted:!1}];function d(){let e=K(`div`,`mx-auto flex max-w-3xl flex-col`);n.length===0&&e.append(K(`p`,`rounded-xl border border-dashed border-neutral-300 px-4 py-6 text-center text-[12.5px] text-neutral-500`,`No boards yet. Ask an agent to build one — it writes a folder under ~/.pier/boards.`));for(let{title:t,hint:r,wanted:i}of u){let a=n.filter(e=>e.public===i);if(a.length===0)continue;let o=K(`section`,`mb-6`);o.append(K(`h2`,`text-[13px] font-semibold text-neutral-700`,t)),o.append(K(`p`,`mb-1 text-[11.5px] leading-snug text-neutral-500`,r));let s=K(`div`,`rounded-xl border border-neutral-200 bg-white px-3`);s.append(...a.map(c)),o.append(s),e.append(o)}a.replaceChildren(...r?[K(`p`,`mb-3 text-[13px] text-red-600`,r)]:[],e)}async function f(){let e=await fetch(`/api/boards`);if(!e.ok)return r=`Could not load boards: ${e.status}`,d();n=await e.json(),d(),r=``}let p=Xn(e,()=>void f());return window.addEventListener(`focus`,()=>{p.visible&&f()}),p}var dc=e=>[e.subject,e.body,[e.author,e.at?new Date(e.at).toLocaleString():``].filter(Boolean).join(` · `)].filter(Boolean).join(`
|
|
81
|
-
|
|
82
|
-
`),fc=null;function pc(){fc&&(fc.remove(),fc=null,document.removeEventListener(`pointerdown`,pc,!0),window.removeEventListener(`scroll`,pc,!0))}function mc(e,t){e.onmouseenter=()=>{pc();let n=t();if(!n)return;fc=K(`div`,`pointer-events-none fixed z-50 max-w-96 whitespace-pre-wrap rounded-lg bg-neutral-800/95 px-3 py-2 font-sans text-[11.5px] leading-snug text-neutral-100 shadow-lg`),fc.textContent=n,document.body.append(fc),document.addEventListener(`pointerdown`,pc,!0),window.addEventListener(`scroll`,pc,!0);let r=e.getBoundingClientRect();fc.style.left=`${Math.max(8,Math.min(r.left,window.innerWidth-fc.offsetWidth-8))}px`,fc.style.top=r.bottom+6+fc.offsetHeight>window.innerHeight?`${r.top-fc.offsetHeight-6}px`:`${r.bottom+6}px`},e.onmouseleave=pc}function hc(e,t,n){let r=K(`button`,`flex w-full cursor-pointer items-center gap-1.5 px-2 py-1 text-left hover:bg-neutral-100`,K(`span`,`w-3 flex-none text-indigo-600`,e.value===t?`✓`:``),K(`span`,`flex-none font-mono text-[11.5px] text-neutral-800`,e.label??e.value));return e.subject&&r.append(K(`span`,`min-w-0 truncate text-[11px] text-neutral-400`,e.subject)),e.author&&r.append(K(`span`,`ml-auto flex-none pl-1.5 text-[10.5px] text-neutral-400`,`${e.author} · ${e.at?qn(e.at):``}`)),mc(r,()=>dc(e)),r.onclick=()=>n(e.value),r}function gc(e,t,n,r){let{base:i,head:a}=n,o=()=>a&&i===`${a}~1`?a:``,s=o()?`commit`:`compare`,c=t.commits[0],l=e=>[...e?[{value:``,label:`Working tree`,subject:`the files on disk, uncommitted changes included`}]:[],{value:`HEAD`,subject:c?.subject,body:c?.body,author:c?.author,at:c?.at},...t.refs.map(e=>({value:e.name,subject:e.subject})),...t.commits.map(e=>({value:e.hash,subject:e.subject,body:e.body,author:e.author,at:e.at}))],u=K(`div`,`flex w-[38rem] max-w-full flex-col`);function d(){let e=(e,t)=>{let n=K(`button`,`cursor-pointer rounded-full px-2.5 py-0.5 text-[11.5px] ${s===t?`bg-indigo-50 font-medium text-indigo-700`:`text-neutral-500 hover:bg-neutral-100`}`,e);return n.onclick=()=>{s=t,d()},n},n=(e,t,n,r)=>K(`div`,`flex min-w-0 flex-1 flex-col`,K(`div`,`flex-none px-2 pb-0.5 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e),K(`div`,`min-h-0 flex-1 overflow-y-auto`,...t.map(e=>hc(e,n,r)))),c=s===`compare`?K(`div`,`flex h-72 min-h-0 divide-x divide-neutral-200 pb-1`,n(`base`,l(!1),i,e=>{i=e,d(),r(i,a)}),n(`to`,l(!0),a,e=>{a=e,d(),r(i,a)})):K(`div`,`flex h-72 min-h-0 flex-col overflow-y-auto pb-1`,...t.commits.map(e=>hc({value:e.hash,...e},o(),e=>{i=`${e}~1`,a=e,wo(),r(i,a)})));u.replaceChildren(K(`div`,`flex flex-none items-center gap-1 border-b border-neutral-200 px-2 py-1.5`,e(`Compare two points`,`compare`),e(`One commit`,`commit`)),c)}d(),Eo(e,u)}var _c=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,vc={A:`text-emerald-600`,M:`text-amber-600`,D:`text-red-600`},yc=2e4,bc=30,xc=(e,t=`indigo`)=>{let n=K(`button`,`min-w-0 cursor-pointer truncate rounded-md px-2 py-0.5 text-left font-mono text-[11.5px] ${t===`indigo`?`bg-indigo-50 font-medium text-indigo-700 hover:bg-indigo-100`:`bg-neutral-100 text-neutral-600 hover:bg-neutral-200`}`,e);return n.type=`button`,n};function Sc(e,t,n){let r=``,i={branch:null,refs:[],commits:[]},a=`HEAD`,o=``,s=new Map,c=!0,l=!1,u=[],d=new Set,f=null,p=null,m=K(`header`,`flex h-10 flex-none items-center gap-2 border-b border-neutral-200 bg-white px-3`),h=K(`div`,`flex-none border-b border-neutral-200`),g=K(`div`,`min-h-0 flex-1 overflow-y-auto py-1`),_=K(`aside`,`flex w-64 flex-none flex-col border-r border-neutral-200 text-[12.5px] max-md:h-2/5 max-md:w-full max-md:border-b max-md:border-r-0`,h,g),v=K(`div`,`h-full min-w-0 overflow-auto`),y=K(`div`,`pointer-events-none absolute inset-y-0 right-0 z-20 hidden w-2`),b=K(`section`,`relative min-w-0 flex-1`,v,y);e.append(m,K(`div`,`flex min-h-0 flex-1 max-md:flex-col`,_,b));let x=(e,t)=>`/api/explorer/${e}?${new URLSearchParams({root:r,...t})}`;async function S(e){let t=await fetch(e),n=null;try{n=await t.json()}catch{}if(!t.ok||n===null)throw Error(n?.error??`HTTP ${t.status}`);return n}let C=(e,t=`text-neutral-400`)=>K(`p`,`px-4 py-3 text-[12.5px] ${t}`,e),w=e=>{let t=0;for(let n of s.keys())n.startsWith(`${e}/`)&&t++;return t};function T(e,t){let n=new Set(t.map(e=>e.name)),r=e?`${e}/`:``;for(let[e,i]of s){if(i.status!==`D`||!e.startsWith(r))continue;let a=e.slice(r.length).split(`/`)[0];n.has(a)||(n.add(a),t.push({name:a,dir:e.slice(r.length).includes(`/`)}))}let a=t;return c&&i.branch&&(a=t.filter(e=>e.dir?w(`${r}${e.name}`)>0:s.has(`${r}${e.name}`))),a.sort((e,t)=>Number(t.dir)-Number(e.dir)||e.name.localeCompare(t.name)),a.map(e=>e.dir?D(`${r}${e.name}`,e.name):k(`${r}${e.name}`,e.name))}async function E(e,t){try{let{entries:n}=await S(x(`ls`,{path:t}));e.replaceChildren(...T(t,n)),e.childElementCount||e.append(C(c?`No changes.`:`Empty.`))}catch(n){let r=T(t,[]);r.length?e.replaceChildren(...r):e.replaceChildren(C(String(n),`text-red-600`))}}function D(e,t){let n=w(e),r=[K(`span`,`truncate`,t)];n&&r.push(K(`span`,`ml-auto flex-none rounded bg-amber-100/80 px-1 font-mono text-[10px] text-amber-700`,String(n)));let{el:a,summary:o}=er(``,r);o.className+=` px-2 py-0.5 hover:bg-neutral-100`;let s=K(`div`,`pl-3`);a.append(s);let u=!1,f=()=>{u||(u=!0,s.append(C(`…`)),E(s,e))};return a.ontoggle=()=>{d[a.open?`add`:`delete`](e),a.open&&f()},(c&&i.branch&&!l||d.has(e))&&(a.open=!0,f()),a}function O(e){p?.classList.remove(`bg-indigo-50`,`text-indigo-700`),p=e,e.classList.add(`bg-indigo-50`,`text-indigo-700`)}function k(e,t){let n=s.get(e)?.status,r=K(`button`,`flex w-full cursor-pointer items-center gap-1.5 px-2 py-0.5 pl-6 text-left hover:bg-neutral-100`,K(`span`,`truncate`,t));return n&&r.append(K(`span`,`ml-auto flex-none font-mono text-[10.5px] font-semibold ${vc[n]??`text-neutral-500`}`,n)),r.title=e,e===f&&O(r),r.onclick=()=>{O(r),f=e,ae(e)},r}let A=()=>void E(g,``),ee=(e,t)=>[...e?[K(`span`,`flex-none font-mono text-[10.5px] font-semibold text-emerald-600`,`+${e}`)]:[],...t?[K(`span`,`flex-none font-mono text-[10.5px] font-semibold text-red-600`,`−${t}`)]:[]];function j(e,t,n){let r=s.get(e),i=K(`div`,`sticky top-0 z-10 flex items-center gap-2 border-b border-neutral-200 bg-white px-4 py-1.5 font-mono text-[11.5px] text-neutral-500`,K(`span`,`truncate`,e));r&&(i.append(K(`span`,`flex-none font-semibold ${vc[r.status]??``}`,r.status)),i.append(...ee(r.add,r.del)));let a=K(`div`,`ml-auto flex flex-none items-center gap-2`);if(n&&a.append(n),t){let t=document.createElement(`a`);t.className=`flex-none text-neutral-400 hover:text-indigo-700 hover:underline`,t.href=x(`file`,{path:e}),t.download=Jn(e),t.textContent=`Download`,a.append(t)}return i.append(a),i}function te(e,t){let n=e.length<=yc?t:null,r=Math.max(2,...e.map(e=>e.nums.reduce((e,t)=>Math.max(e,String(t).length),0))),i=K(`div`,`py-2 font-mono text-[12px] leading-[1.5]`);for(let t of e){let e=K(`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=K(`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(M(t,n)),i.append(e)}return i}function M(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=Ci(e.text,t);return r.className=n,r}let[r,i]=e.mark,a=Ci(e.text.slice(r,i),t);return a.className=`rounded-xs ${e.tone===`add`?`bg-emerald-200/80`:`bg-red-200/70`}`,K(`span`,n,Ci(e.text.slice(0,r),t),a,Ci(e.text.slice(i),t))}function ne(e){let t=0;for(;t<e.length;){if(e[t].tone!==`del`){t++;continue}let n=t;for(;t<e.length&&e[t].tone===`del`;)t++;let r=t;for(;t<e.length&&e[t].tone===`add`;)t++;let i=Math.min(r-n,t-r);for(let t=0;t<i;t++){let i=e[n+t],a=e[r+t],o=Math.min(i.text.length,a.text.length),s=0;for(;s<o&&i.text[s]===a.text[s];)s++;let c=0;for(;c<o-s&&i.text[i.text.length-1-c]===a.text[a.text.length-1-c];)c++;s+c!==0&&(i.mark=[s,i.text.length-c],a.mark=[s,a.text.length-c])}}}function N(){y.classList.add(`hidden`),y.replaceChildren()}let re=0,ie=e=>e===re;function ae(e){let t=++re;return s.has(e)?P(e,t):oe(e,t)}async function oe(e,t){if(!ie(t))return;N();let n=x(`file`,{path:e}),r=K(`div`,`min-w-0`);if(v.classList.remove(`flex`,`flex-col`),v.replaceChildren(j(e,!0),r),_c.test(e)){let e=K(`img`,`max-w-full p-4`);e.src=n,e.onerror=()=>r.replaceChildren(C(`Could not load image.`,`text-red-600`)),r.append(e);return}if(e.toLowerCase().endsWith(`.pdf`)){let t=document.createElement(`iframe`);t.className=`h-full w-full`,t.src=n,v.replaceChildren(j(e,!0),t),v.classList.add(`flex`,`flex-col`);return}r.append(C(`…`));let i=await fetch(n);if(!ie(t))return;if(!i.ok){let{error:e}=await i.json().catch(()=>({}));r.replaceChildren(C(e??`HTTP ${i.status}`,`text-red-600`));return}if(!(i.headers.get(`content-type`)??``).startsWith(`text/plain`)){r.replaceChildren(C(`Binary file — use Download.`));return}let a=(await i.text()).split(`
|
|
83
|
-
`);ie(t)&&(a.at(-1)===``&&a.pop(),r.replaceChildren(te(a.map((e,t)=>({nums:[t+1],text:e,tone:``})),Si(e))))}function se(e){let t=[],n=0,r=0,i=!1,a=e.split(`
|
|
84
|
-
`);a.at(-1)===``&&a.pop();for(let e of a){let a=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);if(a){i&&t.push({nums:[``,``],text:`⋯`,tone:``}),[n,r]=[Number(a[1]),Number(a[2])],i=!0;continue}!i||e.startsWith(`\\`)||(e.startsWith(`+`)?t.push({nums:[``,r++],text:e.slice(1),tone:`add`}):e.startsWith(`-`)?t.push({nums:[n++,``],text:e.slice(1),tone:`del`}):t.push({nums:[n++,r++],text:e.slice(1),tone:``}))}return t}function ce(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n].tone;if(!r)continue;let i=t.at(-1);i&&i.end===n-1?(i.end=n,(r===`add`&&i.tone===`del`||r===`del`&&i.tone===`add`)&&(i.tone=`mixed`)):t.push({start:n,end:n,tone:r})}return t}let le={add:`bg-emerald-400`,del:`bg-red-400`,mixed:`bg-amber-400`};function ue(e,t,n){y.replaceChildren(...e.map(e=>{let r=K(`button`,`pointer-events-auto absolute w-full cursor-pointer ${le[e.tone]}`);return r.style.top=`${e.start/t*100}%`,r.style.height=`${Math.max(.4,(e.end-e.start+1)/t*100)}%`,r.title=`line ${de(n,e.start)}`,r.onclick=()=>n[e.start].scrollIntoView({block:`center`}),r})),y.classList.remove(`hidden`)}let de=(e,t)=>e[t]?.querySelector(`span`)?.textContent?.trim()||String(t+1);function fe(e,t){let n=-1,r=K(`span`,`flex-none text-[10.5px] text-neutral-400`,`${e.length} change${e.length===1?``:`s`}`),i=i=>{e.length&&(n=(n+i+e.length)%e.length,t[e[n].start].scrollIntoView({block:`center`}),r.textContent=`${n+1}/${e.length}`)},a=(e,t,n)=>{let r=K(`button`,`icon-btn flex-none`,e);return r.title=n,r.onclick=()=>i(t),r};return K(`div`,`flex flex-none items-center gap-1`,r,a(`↑`,-1,`Previous change`),a(`↓`,1,`Next change`))}async function P(e,t){N(),v.classList.remove(`flex`,`flex-col`);let n=s.get(e)?.status!==`D`;v.replaceChildren(j(e,n),C(`…`));try{let{diff:r}=await S(x(`diff`,{base:a,head:o,file:e,context:`99999`}));if(!ie(t))return;if(!r||/^Binary files /m.test(r))return oe(e,t);let i=se(r);ne(i);let s=te(i,Si(e)),c=[...s.children],l=ce(i);v.replaceChildren(j(e,n,fe(l,c)),s),ue(l,i.length,c)}catch(n){ie(t)&&v.replaceChildren(j(e,!1),C(String(n),`text-red-600`))}}let pe=()=>o&&a===`${o}~1`?o:``,F=()=>i.commits.find(e=>e.hash===pe())?.subject??``,me=()=>pe()?`${pe()} — ${F()||`commit`}`:`${a} ↔ ${o||`working tree`}`,I=(e,t,n,r)=>{let i=K(`button`,`flex h-6 w-6 flex-none cursor-pointer items-center justify-center rounded-md ${n?`bg-indigo-50 text-indigo-700`:`text-neutral-400 hover:bg-neutral-100 hover:text-neutral-700`}`);return i.innerHTML=e,i.title=t,i.onclick=r,i};function he(){let e=I(`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" class="h-3.5 w-3.5"><path d="M2.5 3h11l-4.25 5v4.5l-2.5 1.25V8L2.5 3z" stroke-linejoin="round"/></svg>`,`Show only files that differ`,c,()=>{c=!c,he(),A()}),t=I(`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" class="h-3.5 w-3.5"><path d="m4.5 2.5 3.5 3 3.5-3M4.5 13.5l3.5-3 3.5 3" stroke-linecap="round" stroke-linejoin="round"/></svg>`,l?`Restore folders`:`Collapse all folders`,l,()=>{if(l=!l,l)u=[...d],d.clear();else for(let e of u)d.add(e);he(),A()});if(!i.branch){h.replaceChildren(K(`div`,`flex items-center justify-end gap-1 p-1.5`,t));return}let n=xc(me());if(pe()){let e=i.commits.find(e=>e.hash===pe());mc(n,()=>e?dc(e):``)}else n.title=`Choose what to diff`;n.onclick=()=>gc(n,i,{base:a,head:o},(e,t)=>{a=e,o=t,_e()});let[r,f]=[0,0];for(let e of s.values())r+=e.add,f+=e.del;h.replaceChildren(K(`div`,`flex flex-col gap-1 p-2`,n,K(`div`,`flex items-center gap-1.5 pl-1`,K(`span`,`text-[11px] text-neutral-400`,`${s.size} changed file${s.size===1?``:`s`}`),...ee(r,f),K(`span`,`ml-auto`),e,t)))}async function ge(){if(s=new Map,!i.branch)return;let{files:e}=await S(x(`diff`,{base:a,head:o}));for(let t of e)s.set(t.path,{status:t.status,add:t.add,del:t.del});if(s.size<=bc)for(let e of s.keys()){let t=e.split(`/`);for(let e=1;e<t.length;e++)d.add(t.slice(0,e).join(`/`))}}async function _e(){try{await ge()}catch(e){he(),g.replaceChildren(C(String(e),`text-red-600`));return}he(),A(),f&&ae(f)}function ve(){let e=xc(r,`neutral`);e.className+=` max-w-72`,e.title=`Switch project`,e.onclick=()=>Oo(e,t().map(e=>({label:e,checked:e===r,onSelect:()=>{wo(),n(e)}}))),m.replaceChildren(e,K(`span`,`truncate font-mono text-[11.5px] text-neutral-400`,i.branch?`⎇ ${i.branch}`:`no git`))}let ye=()=>i.refs.some(e=>e.name===`main`)?`main`:i.refs.some(e=>e.name===`master`)?`master`:`HEAD`;async function be(){if(ve(),f=null,p=null,d.clear(),N(),v.classList.remove(`flex`,`flex-col`),v.replaceChildren(C(`Select a file.`)),!r){h.replaceChildren(),g.replaceChildren(),v.replaceChildren(C(`No projects yet — create a session first.`));return}try{i=await S(x(`git`,{}))}catch(e){i={branch:null,refs:[],commits:[]},v.replaceChildren(C(String(e),`text-red-600`))}a=ye(),o=``,ve(),await _e()}return Xn(e,e=>{let n=e&&t().includes(e)?e:r||(t()[0]??``);if(n===r&&g.childElementCount)return ve();r=n,be()})}var Cc={display_information:{name:`Pier`,description:`Coding agent sessions in Slack threads`,background_color:`#262626`},features:{bot_user:{display_name:`Pier`,always_online:!1},app_home:{messages_tab_enabled:!0,messages_tab_read_only_enabled:!1}},oauth_config:{scopes:{bot:[`chat:write`,`reactions:write`,`channels:history`,`channels:read`,`groups:history`,`groups:read`,`im:history`,`im:write`,`mpim:history`,`mpim:read`,`mpim:write`,`users:read`,`files:read`]}},settings:{event_subscriptions:{bot_events:[`message.channels`,`message.groups`,`message.im`,`message.mpim`]},interactivity:{is_enabled:!0},socket_mode_enabled:!0,token_rotation_enabled:!1}},wc=()=>`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(Cc))}`,Tc=()=>Uo(`Getting a bot token`,[`Open [@BotFather](https://t.me/BotFather) in Telegram.`,"Send `/newbot`, pick a display name, then a username ending in `bot`.","Copy the token it prints (`123456789:AA…`) and paste it here.","Send `/setprivacy` → `Disable` if the bot should see plain group messages. Left enabled it only ever receives mentions, replies and commands — the usual reason a bot looks dead in a group.","Send `/setjoingroups` → `Enable`, then add the bot to your group or forum."]),Ec=(e=`left`)=>Uo(`Enabling topics on a group`,["In Telegram open the group → `Edit` → turn on `Topics`. Owner only; group size no longer matters.","The group becomes a forum supergroup and the existing chat becomes its `General` topic.","Make the bot an admin with `Manage Topics`. That is the one right topic creation needs — without it Pier logs the failure and answers in General instead.","Send one message in the group so Pier discovers it, then enable it under `Chats` below.","After that, a message in General opens its own topic with its own session. A reply, or anything starting with `/`, stays where it was sent."],e);function Dc(){let e=X(`Create Slack app ↗`,!0);e.classList.add(`mt-1`,`w-fit`),e.onclick=()=>window.open(wc(),`_blank`,`noreferrer`);let t=$n(`btn w-fit text-[12.5px]`,()=>JSON.stringify(Cc,null,2));return Uo(`Creating a Slack app`,[Wo(`Opens Slack with every scope, event and Socket Mode already filled in. Pick your workspace → Create.`,e),"`Install to Workspace` → allow. Then `OAuth & Permissions` → copy the bot token (`xoxb-…`) into the field above.","`Basic Information` → `App-Level Tokens` → `Generate` with scope `connections:write`. Paste that `xapp-…` token below. The manifest cannot mint this one for you.","In Slack, invite the bot where you want it: `/invite @Pier`. It answers in threads only, so it never adds noise to the channel.",Wo(`Prefer to paste it yourself? Create the app from a manifest and use this:`,t)])}var Oc=()=>Uo(`What agent access allows`,["Gives agent sessions a `slack` tool: read a channel's history for a time range, read one thread, and post a message.",`Pier performs every call itself — the bot token is never given to the agent, and Slack's own membership rules still apply, so the bot reaches only channels it was invited to.`,`Every read fetches live from Slack — Pier keeps no message archive.`,`This includes sessions started by tasks and subagents. Switch it off if an agent should never post to your workspace on its own.`]),kc=(e=`left`)=>Uo(`How Slack threads work here`,[`Pier never posts in a channel's main flow. A message in the channel is answered in *its own thread*; a message in a thread is answered in that thread.`,`Each thread is its own Pi session, so one channel hosts many parallel sessions.`,`The same applies in a DM: every new message you send there starts its own thread and its own session. Reply *inside* a thread to continue that conversation.`,"Inside a thread Pier already owns, no `@mention` is needed — continuing that thread is addressing it.","Commands are bare words after a mention: `@bot settings`, `@bot stop`, `@bot bind <code>`. Slack's client swallows an unregistered `/command` before it ever reaches an app."],e),Ac=[[`telegram`,`Telegram`],[`slack`,`Slack`],[`lark`,`Lark`]],jc=(e,t)=>K(`span`,`flex items-center gap-1.5 text-[13px] text-neutral-400`,K(`span`,``,e),t),Mc={dm:`bg-sky-50 text-sky-700 ring-sky-200`,group:`bg-neutral-100 text-neutral-600 ring-neutral-200`,forum:`bg-violet-50 text-violet-700 ring-violet-200`},Nc=`pier.channelsPlatform`;function Pc(e){let t=localStorage.getItem(Nc),n=Ac.some(([e])=>e===t)?t:`telegram`,r=null,i=[],a=K(`div`,`ml-auto flex items-center gap-1.5 text-[11.5px]`),o=K(`div`,`sticky top-0 z-30 flex items-center gap-1 border-b border-neutral-200 bg-white px-4 py-2`,a),s=K(`div`,`px-4 py-5`);e.append(K(`div`,`min-h-0 flex-1 overflow-y-auto bg-neutral-50/60`,o,s));function c(){o.replaceChildren(...Ac.map(([e,t])=>No(t,e===n,()=>{u&&_(),n=e,localStorage.setItem(Nc,e),v()})),a)}let u,d=!1,f=null;function p(e){if(a.replaceChildren(),e!==`clean`){if(a.className=`ml-auto flex items-center gap-1.5 text-[11.5px] ${Bo[e]}`,e===`saving`)a.append(K(`span`,`spinner`),K(`span`,``,`Saving…`));else if(e===`saved`)a.append(K(`span`,``,`✓`),K(`span`,``,`Saved`)),setTimeout(()=>{a.textContent?.includes(`Saved`)&&p(`clean`)},2e3);else{let e=jo(`Retry`,`cursor-pointer underline`);e.onclick=_,a.append(K(`span`,``,`⚠`),K(`span`,``,`Save failed`),e)}}}function m(){p(`saving`),clearTimeout(u),u=setTimeout(_,500)}let h=e=>t=>{e(t),m()};async function g(e){d=!0,p(`saving`);try{p((await l(`/api/channels/${e.platform}`,e.config,`PUT`)).ok?`saved`:`failed`)}catch{p(`failed`)}finally{d=!1;let e=f;f=null,e&&g(e)}}function _(){if(clearTimeout(u),u=void 0,!r)return;let e={platform:n,config:r};d?f=e:g(e)}async function v(){if(!i.length){let e=await fetch(`/api/models`);e.ok&&(i=await e.json())}let e=await fetch(`/api/channels/${n}`);if(!e.ok){r=null,c(),s.replaceChildren(Ho(`Failed to load: ${e.status}`));return}r=await e.json(),p(`clean`),w()}function y(e){let t=n===`slack`,r=Io(e.token,t?`xoxb-…`:`123456789:AA…`,h(t=>e.token=t),!0),i=Io(e.appToken,`xapp-…`,h(t=>e.appToken=t),!0),a=is(e.cwd,`(pier process cwd)`,h(t=>e.cwd=t));return Po(`Connection`,t?`Pier connects over Socket Mode; no public URL or webhook needed.`:`Pier polls Telegram for updates; no public URL or webhook needed.`,zo(`Enabled`,`Start the adapter when Pier boots.`,e.enabled,h(t=>{e.enabled=t,c()})),Z(`Bot token`,r,{hint:`Stored locally, shown masked once saved.`,help:n===`telegram`?Tc():t?Dc():void 0}),...t?[Z(`App-level token`,i,{hint:`Opens the Socket Mode connection. Needs connections:write.`}),zo(`Agent access`,`Let agent sessions read channel history and post through the slack tool. Off makes the tool refuse; inbound messages are unaffected.`,e.agentTool,h(t=>e.agentTool=t),Oc())]:[],Z(`Default working directory`,a.el,{hint:`Where sessions this channel opens start.`}))}function b(e){return Po(`Defaults for new chats`,`Copied into a group the first time the bot sees it; changing them here never touches a group that already exists. DMs are always bound-users-only.`,zo(`Require mention in groups`,`Ignore group messages that do not @mention or reply to the bot.`,e.requireMention,h(t=>e.requireMention=t)),zo(`Require bound user`,`Only users bound with a code below can drive the agent.`,e.requireBind,h(t=>e.requireBind=t)),...n===`slack`?[jc(`Thread mode: always on`,kc())]:[zo(`Topic mode`,`In a forum group, each new request opens its own topic and its own session.`,e.topicMode,h(t=>e.topicMode=t),Ec())],$o(`Model & reasoning`,e,i,h(t=>{e.model=t.model,e.thinking=t.thinking,w()})))}function x(e){let t=K(`span`,`font-mono text-[15px] font-semibold tracking-widest`),r=K(`div`,`hidden items-center gap-2 rounded-lg bg-indigo-50 px-3 py-2 text-[12.5px] text-indigo-800`,t,K(`span`,`text-[11.5px] text-indigo-500`,`DM the bot /bind <code> · expires in 10 min`)),i=X(`Generate bind code`);i.onclick=async()=>{let e=await fetch(`/api/channels/${n}/bind-code`,{method:`POST`});if(!e.ok)return;let{code:i}=await e.json();t.textContent=i,r.classList.replace(`hidden`,`flex`)};let a=K(`div`,`flex flex-col`);e.users.length||a.append(Ho(`No bound users yet.`));for(let t of e.users){let e=jo(`Remove`,`cursor-pointer text-[11.5px] text-neutral-400 opacity-0 transition-opacity hover:text-red-600 group-hover:opacity-100`);e.onclick=async()=>{await fetch(`/api/channels/${n}/users/${encodeURIComponent(t.id)}`,{method:`DELETE`}),await v()},a.append(K(`div`,`group flex items-center gap-2.5 border-b border-neutral-100 py-2 last:border-0`,K(`span`,`flex h-6 w-6 flex-none items-center justify-center rounded-full bg-neutral-100 text-[11px] font-semibold text-neutral-500`,(t.name[0]??`?`).toUpperCase()),K(`span`,`min-w-0 flex-1 truncate text-[13px] text-neutral-700`,t.name),K(`span`,`flex-none font-mono text-[11.5px] text-neutral-400`,t.id),e))}return Po(`Bound users`,`A code is single-use and expires; redeeming it in a DM binds that account.`,a,K(`div`,`flex flex-col gap-2`,i,r))}function S(e,t){let r=K(`div`,`rounded-xl border px-3.5 py-3 transition-colors ${t.enabled?`border-neutral-200 bg-white`:`border-neutral-200 bg-neutral-50/60`}`),a=K(`div`,`flex items-center gap-2`,K(`span`,`min-w-0 flex-1 truncate text-[13px] font-medium ${t.enabled?`text-neutral-800`:`text-neutral-400`}`,t.name||t.id),Vo(t.kind,Mc[t.kind]),K(`span`,`flex-none font-mono text-[11px] text-neutral-400`,t.id)),o=zo(``,``,t.enabled,h(e=>{t.enabled=e,w()}));o.classList.add(`flex-none`,`items-center`),a.append(o);let s=K(`div`,`mt-3 flex flex-wrap items-center gap-x-6 gap-y-2`);t.kind===`dm`?s.append(K(`span`,`text-[13px] text-neutral-400`,n===`slack`?`Direct message · bound users only, mention not applicable`:`Direct message · bound users only, mention and topics not applicable`)):s.append(zo(`Require mention`,``,t.requireMention,h(e=>t.requireMention=e)),zo(`Require bind`,``,t.requireBind,h(e=>t.requireBind=e)),n===`slack`?jc(`Thread mode: always on`,kc(`right`)):t.kind===`forum`?zo(`Topic mode`,``,t.topicMode,h(e=>t.topicMode=e),Ec(`right`)):jc(`Topic mode: forum groups only`,Ec(`right`)));let c=K(`div`,`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,Z(`Working directory`,is(t.cwd,``,h(e=>t.cwd=e)).el),$o(`Model & reasoning`,t,i,h(e=>{t.model=e.model,t.thinking=e.thinking,w()})));return r.append(a,s,c),r}function C(e){let t=K(`div`,`flex flex-col gap-2.5`);return e.chats.length?t.append(...e.chats.map(t=>S(e,t))):t.append(Ho(`None yet. Chats appear here after the bot sees a message in them.`)),Po(n===`slack`?`Channels`:`Chats`,`Discovered from inbound traffic — no platform reliably lists every chat a bot is in.`,t)}function w(){if(!r)return;if(c(),!r.supported){s.replaceChildren(Ho(`${Ac.find(([e])=>e===n)?.[1]} is planned — no adapter yet.`));return}let e=K(`div`,`mx-auto flex max-w-3xl flex-col gap-4`);e.append(y(r),b(r),x(r),C(r)),s.replaceChildren(e)}return Xn(e,()=>void v(),()=>{u&&_()})}function Fc(e,t){let n=`global`,r=null,i=0,a=0,o=``,s=document.createElement(`select`);s.className=`select w-full rounded-md border border-neutral-300 px-2 py-1 text-[12.5px] focus:border-indigo-400 focus:outline-none`,s.onchange=()=>{n=s.value,r=null,x.clear(),g()};let c=K(`div`,`flex flex-none flex-col gap-1 border-b border-neutral-200 px-3 pb-2.5 pt-2`);c.append(K(`span`,`text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,`Scope`),s);let d=K(`div`,`min-h-0 flex-1 overflow-y-auto py-1`),f=K(`nav`,`flex w-64 flex-none flex-col border-r border-neutral-200 text-[13px]`);f.append(c,d);let p=K(`div`,`flex min-w-0 flex-1 flex-col`),m=K(`div`,`flex min-h-0 flex-1`);m.append(f,p),e.append(m);let h=(e=``)=>`?scope=${encodeURIComponent(n)}${e}`;async function g(){let e=++i;a++;let t=await fetch(`/api/config${h()}`,{cache:`no-store`});if(e!==i)return;if(!t.ok){C(null),T(`failed to load config: ${t.status}`);return}let s=await t.json();e===i&&(n===`global`&&s.dir&&(o=s.dir,k()),C(s),r||w())}function _(e){return K(`div`,`px-3 pb-0.5 pt-2.5 text-[10.5px] font-semibold uppercase tracking-wide text-neutral-400`,e)}let v=()=>{let e=K(`span`,`flex-none rounded bg-neutral-100 px-1 text-[10px] font-semibold uppercase tracking-wide text-neutral-500`,`link`);return e.title=`Reached through a symlink`,e};function y(e,t,n,r,i=0,a=!1){let o=K(`button`,`flex w-full cursor-pointer items-center gap-1.5 py-1 pr-3 text-left hover:bg-neutral-100 ${t?`bg-indigo-50 hover:bg-indigo-50`:``} ${n?`text-neutral-400`:``}`);return o.append(K(`span`,`truncate`,e)),a&&o.append(v()),o.style.paddingLeft=`${20+i*14}px`,o.title=e,o.onclick=r,o}function b(e){let t={files:[],dirs:new Map,link:!0};for(let n of e){let e=n.name.split(`/`),r=t;for(let t of e.slice(0,-1)){let e=r.dirs.get(t);e||r.dirs.set(t,e={files:[],dirs:new Map,link:!0}),e.link&&=n.link,r=e}r.files.push({name:e[e.length-1],link:n.link})}return t}let x=new Set;function S(e,t,n,r,i,a){let o=[];for(let[s,c]of t.dirs){let t=n?`${n}/${s}`:s,l=`${e}:${t}`,u=document.createElement(`details`);u.open=x.has(l),u.ontoggle=()=>u.open?x.add(l):x.delete(l);let d=K(`summary`,`flex cursor-pointer select-none items-center gap-1 truncate py-1 pr-3 hover:bg-neutral-100`);d.style.paddingLeft=`${20+r*14}px`,d.title=t,d.append(K(`span`,`chev`,`▶`),K(`span`,`truncate text-neutral-600`,s)),c.link&&d.append(v()),u.append(d,...S(e,c,t,r+1,i,a)),o.push(u)}for(let s of t.files){let t={type:`resource`,kind:e,name:n?`${n}/${s.name}`:s.name};o.push(y(s.name,i(t),!1,()=>a(t),r,s.link))}return o}function C(e){if(!e){d.replaceChildren();return}let t=e=>JSON.stringify(e)===JSON.stringify(r),n=t=>{r=t,C(e),t.type===`file`?D(t.name):O(t.kind,t.name)},i=[];i.push(_(`Files`));for(let r of e.files){let e={type:`file`,name:r.name};i.push(y(r.name,t(e),!r.exists,()=>n(e)))}for(let r of[`extensions`,`skills`]){i.push(_(`${r} (read-only)`));let a=e.resources[r];a.length||i.push(K(`p`,`py-1 pl-5 pr-3 text-[12.5px] text-neutral-400`,`none`)),i.push(...S(r,b(a),``,0,t,n))}d.replaceChildren(...i)}function w(){p.replaceChildren(K(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Select a file to edit, or browse extensions and skills.`))}function T(e){p.replaceChildren(K(`p`,`px-4 py-3 text-[13px] text-red-600`,e))}let E=(e,...t)=>K(`div`,`flex flex-none items-center gap-3 border-b border-neutral-200 px-4 py-2`,K(`span`,`font-mono text-[12.5px] text-neutral-500`,e),...t);async function D(e){let t=++a,n=await fetch(`/api/config/files/${encodeURIComponent(e)}${h()}`,{cache:`no-store`});if(!n.ok){t===a&&T(`failed to load ${e}: ${n.status}`);return}let{content:r}=await n.json();if(t!==a)return;let i=r,o=K(`span`,`text-[11.5px] text-neutral-400`,``),s=K(`button`,`btn btn-primary ml-auto text-[12.5px]`,`Save`),c=document.createElement(`textarea`);c.className=`block min-h-0 flex-1 resize-none bg-white p-4 font-mono text-[13px] leading-relaxed focus:outline-none`,c.spellcheck=!1,c.value=r;let d=async()=>{if(s.disabled)return;let t=c.value;s.disabled=!0,$(o,`saving`,`saving…`);try{let n=await l(`/api/config/files/${encodeURIComponent(e)}${h()}`,{content:t,expected:i},`PUT`);if(!n.ok)return $(o,`failed`,await u(n,`save failed`));let r=await n.json();i=r.content,c.value===t?(c.value=r.content,$(o,`saved`,`saved — applies to new sessions`)):$(o,`idle`,`saved; newer changes are unsaved`)}catch(e){$(o,`failed`,`save failed: ${String(e)}`)}finally{s.disabled=!1}};s.onclick=()=>void d(),c.onkeydown=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),d())},c.oninput=()=>{$(o,`idle`,`unsaved changes`)},p.replaceChildren(E(e,o,s),c),c.focus()}async function O(e,t){let n=++a,r=await fetch(`/api/config/resource${h(`&kind=${e}&name=${encodeURIComponent(t)}`)}`,{cache:`no-store`});if(!r.ok){n===a&&T(`failed to load ${t}: ${r.status}`);return}let{content:i}=await r.json();n===a&&p.replaceChildren(E(t,K(`span`,`ml-auto text-[11px] uppercase tracking-wide text-neutral-400`,`read-only`)),K(`pre`,`min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-4 font-mono text-[12.5px]`,i))}function k(){s.replaceChildren(new Option(o?`Global (${o})`:`Global`,`global`),...t().map(e=>new Option(`${Jn(e)} — ${e}`,e))),[...s.options].some(e=>e.value===n)||(n=`global`),s.value=n}return Xn(e,()=>{k(),g()})}var Ic=e=>`${e.provider}/${e.id}`,Lc=[`hardest reasoning — architecture, gnarly debugging`,`long autonomous implementation runs`,`balanced default — implementation, review`,`cheap & fast — listings, extraction, simple checks`,`cross-vendor second opinion`];function Rc(){let e=[],t=[],n=!1,r=K(`span`,`text-[11.5px]`,``),i=X(`Save menu`,!0),a=K(`div`,`flex min-w-0 flex-col gap-2`),o=K(`div`,`flex items-center gap-2`),s=K(`div`,`mx-auto flex w-full max-w-3xl min-w-0 flex-col gap-6`);function c(){n=!0,$(r,`idle`,`unsaved changes`)}function d(t){let n=Q(t.note??``);n.classList.remove(`w-full`),n.classList.add(`min-w-0`,`flex-1`),n.placeholder=`why this one — pick a preset or write your own`,n.setAttribute(`list`,`model-menu-notes`),n.oninput=()=>{t.note=n.value,c()};let r=Lo([[`thinking: model default`,``],...ko.map(e=>[`thinking: ${Ln(e)}`,e])],t.thinking??``);r.classList.replace(`w-full`,`w-44`),r.classList.add(`flex-none`),r.onchange=()=>{r.value?t.thinking=r.value:delete t.thinking,c()};let i=X(`Remove`);i.classList.add(`flex-none`),i.onclick=()=>{e=e.filter(e=>e!==t),c(),p()};let a=K(`span`,`w-52 flex-none truncate font-mono text-[12px] text-neutral-700`,Ic(t));return a.title=Ic(t),K(`div`,`flex min-w-0 items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 shadow-2xs max-md:flex-wrap`,a,r,n,i)}function f(){let n=t.filter(t=>!e.some(e=>Ic(e)===Ic(t))),r=Lo(n.map(e=>[Ic(e),Ic(e)]),n[0]?Ic(n[0]):``);r.classList.replace(`w-full`,`flex-1`),r.classList.add(`min-w-0`);let i=X(`+ Pin model`);i.classList.add(`flex-none`,`whitespace-nowrap`),i.disabled=n.length===0,i.onclick=()=>{let t=n.find(e=>Ic(e)===r.value);t&&(e.push({...t}),c(),p())},o.replaceChildren(r,i)}function p(){a.replaceChildren(...e.length?e.map(d):[Ho(`Nothing pinned — every picker shows the curated catalog as is.`)]),f()}async function m(){$(r,`saving`,`saving…`);let t=await l(`/api/settings`,{modelMenu:e.map(({provider:e,id:t,thinking:n,note:r})=>({provider:e,id:t,...n?{thinking:n}:{},...r?.trim()?{note:r.trim()}:{}}))},`PUT`);if(!t.ok)return $(r,`failed`,await u(t,`Could not save`));e=(await t.json()).modelMenu,n=!1,$(r,`saved`,`Saved — agents see it on their next models call.`),p()}i.onclick=()=>void m();function h(){n||(async()=>{let[n,i]=await Promise.all([fetch(`/api/settings`),fetch(`/api/models`)]);if(!n.ok)return $(r,`failed`,await u(n,`Could not load the menu`));e=(await n.json()).modelMenu,t=i.ok?await i.json():[],r.textContent=``,p()})()}let g=K(`datalist`,``);return g.id=`model-menu-notes`,g.append(...Lc.map(e=>new Option(e))),s.append(Po(`Model menu`,`Which few models this deployment favors, each with a usual reasoning level and one line of intent. Pinned entries lead every model picker, and agents delegating work match your notes against the task instead of guessing ids.`,Z(`Pinned models`,a,{hint:`The note is what an agent matches a task against — say when to reach for it, not what it is.`}),Z(`Add`,o,{hint:`The list is the live catalog — only models that exist right now can be pinned.`}),K(`div`,`flex items-center gap-3`,i,r),g)),{el:s,load:h}}var zc=(e,t)=>{let n;try{n=new URL(e)}catch{return null}if(n.protocol!==`http:`&&n.protocol!==`https:`)return null;let r=K(`a`,`text-indigo-600 hover:underline`,t);return r.href=n.href,r.target=`_blank`,r.rel=`noreferrer`,r};function Bc(e,t,n,r){let i=document.createElement(`dialog`);i.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let a=K(`div`,`flex flex-col gap-2`),o=K(`div`,`flex flex-col gap-2`),s=K(`p`,`text-[12.5px] text-neutral-400`,`Starting…`),c=X(`Cancel`),d=(e,t)=>{s.className=`text-[12.5px] ${Bo[e]}`,s.textContent=t};i.append(K(`div`,`border-b border-neutral-200 px-4 py-2.5 text-[14px] font-semibold`,t),K(`div`,`flex max-h-[65vh] flex-col gap-3 overflow-y-auto px-4 py-3`,a,o,s),K(`div`,`flex justify-end border-t border-neutral-200 px-4 py-2.5`,c)),document.body.append(i),i.showModal();let f=e.id,p=e.state,m,h,g=new Set,_=!1,v=!1,y=async e=>{if(!v){if(e&&p===`running`){v=!0,c.disabled=!0;try{let e=await l(`/api/providers/flows/${f}/cancel`,{});if(!e.ok&&e.status!==404){d(`failed`,await u(e,`Could not cancel authentication flow`));return}}catch(e){d(`failed`,`Could not cancel authentication flow: ${String(e)}`);return}finally{v=!1,c.disabled=!1}}clearTimeout(m),i.close()}};c.onclick=()=>void y(!0),i.oncancel=e=>{e.preventDefault(),y(!0)},i.onclose=()=>{_=!0,clearTimeout(m),i.remove()};let b=e=>{if(e.type===`auth_url`){let t=K(`div`,`flex flex-col gap-1 text-[12.5px] text-neutral-600`);return e.instructions&&t.append(K(`p`,``,e.instructions)),t.append(zc(e.url,`Open authorization page`)??K(`span`,`text-red-600`,`Invalid authorization URL`)),t}if(e.type===`device_code`){let t=K(`div`,`flex flex-col gap-2 text-[12.5px] text-neutral-600`);return t.append(K(`div`,`flex items-center gap-2`,K(`code`,`font-mono text-[17px] font-semibold text-neutral-800`,e.userCode),$n(`btn text-[11px]`,()=>e.userCode))),t.append(zc(e.verificationUri,`Open verification page`)??K(`span`,`text-red-600`,`Invalid verification URL`)),t}let t=K(`div`,`text-[12.5px] text-neutral-600`,e.message);if(e.type===`info`)for(let n of e.links??[]){let e=zc(n.url,n.label??n.url);e&&t.append(` `,e)}return t},x=(e,t)=>{h=t.id;let n;if(t.type===`select`){let e=document.createElement(`select`);e.append(...t.options.map(e=>new Option(e.description?`${e.label} — ${e.description}`:e.label,e.id))),n=e}else{let e=Q(``,t.type===`secret`?`password`:`text`);e.placeholder=t.placeholder??``,e.autocomplete=`off`,n=e}n.className=`${n.tagName===`SELECT`?`select `:``}w-full rounded-lg border border-neutral-300 bg-white px-2.5 py-1.5 text-[12.5px] focus:border-indigo-400 focus:outline-none`;let r=X(`Continue`,!0);r.type=`submit`;let i=K(`form`,`flex flex-col gap-2`,K(`label`,`text-[12.5px] font-medium text-neutral-700`,t.message),n,K(`div`,`flex justify-end`,r));i.onsubmit=i=>{i.preventDefault(),r.disabled=!0,(async()=>{try{let r=await l(`/api/providers/flows/${e.id}/respond`,{promptId:t.id,value:n.value});if(_)return;if(!r.ok){d(`failed`,await u(r,`Could not submit response`));return}g.add(t.id),h=void 0,o.replaceChildren(),d(`saving`,`Waiting for provider…`)}catch(e){_||d(`failed`,`Could not submit response: ${String(e)}`)}finally{r.disabled=!1}})()},o.replaceChildren(i),n.focus()},S=e=>{p=e.state,a.replaceChildren(...e.events.map(b));let t=e.prompt&&!g.has(e.prompt.id)?e.prompt:void 0;if(t?.id!==h&&(t?x(e,t):(h=void 0,o.replaceChildren())),e.state===`running`){d(`saving`,t?`Waiting for your response.`:`Waiting for provider…`);return}clearTimeout(m),o.replaceChildren(),e.state===`succeeded`?d(`saved`,`${n} configured.`):d(`failed`,e.state===`cancelled`?`Cancelled.`:e.error??`Authentication failed.`),c.textContent=`Close`,c.onclick=()=>void y(!1),e.state===`succeeded`&&r()},C=async()=>{if(!(_||p!==`running`))try{let e=await fetch(`/api/providers/flows/${f}`,{cache:`no-store`});if(_)return;if(!e.ok){d(`failed`,await u(e,`Authentication status unavailable`)),e.status===404?p=`failed`:m=setTimeout(()=>void C(),1e3);return}S(await e.json()),p===`running`&&(m=setTimeout(()=>void C(),500))}catch(e){if(_)return;d(`failed`,`Authentication status unavailable: ${String(e)}`),m=setTimeout(()=>void C(),1e3)}};S(e),p===`running`&&(m=setTimeout(()=>void C(),500))}var Vc=[`anthropic`,`openai`,`openai-codex`,`google`,`openrouter`,`deepseek`],Hc=[[`OpenAI Chat Completions`,`openai-completions`],[`OpenAI Responses`,`openai-responses`],[`Anthropic Messages`,`anthropic-messages`],[`Google Generative AI`,`google-generative-ai`]],Uc=`__custom__`;async function Wc(e){let t=X(`Add provider`,!0);t.classList.add(`ml-auto`);let n=K(`div`,`flex flex-none items-center gap-3 border-b border-neutral-200 px-4 py-2`,K(`span`,`font-mono text-[12.5px] text-neutral-500`,`Providers`),t),r=K(`div`,`min-h-0 flex-1 overflow-y-auto`);e.replaceChildren(n,r);let i=async()=>{r.replaceChildren(K(`p`,`px-4 py-3 text-[13px] text-neutral-400`,`Loading…`));try{let e=await fetch(`/api/providers`,{cache:`no-store`});if(!e.ok){r.replaceChildren(Ho(await u(e,`Could not load providers`)));return}let n=await e.json();t.onclick=()=>Kc(n,void 0,i),o(n)}catch(e){r.replaceChildren(Ho(`Could not load providers: ${String(e)}`))}},a=async e=>{if(window.confirm(`Remove the stored credential for ${e.name}?`))try{let t=await l(`/api/providers/${encodeURIComponent(e.id)}/logout`,{});if(!t.ok){window.alert(await u(t,`Could not remove credential`));return}await i()}catch(e){window.alert(`Could not remove credential: ${String(e)}`)}},o=e=>{let t=e.filter(e=>e.configured);if(!t.length){r.replaceChildren(Ho(`No providers configured.`));return}r.replaceChildren(...t.map(t=>{let n=K(`div`,`min-w-0 flex-1`,K(`div`,`truncate text-[13px] font-medium text-neutral-700`,t.name),K(`div`,`truncate font-mono text-[11px] text-neutral-400`,t.id)),r=t.stored===`api_key`?`API key`:t.stored===`oauth`?`OAuth`:t.source??`configured`,o=t.endpoint??`Default endpoint`,s=K(`div`,`flex min-w-32 flex-col items-start gap-1`,Vo(`configured`,`bg-emerald-50 text-emerald-700 ring-emerald-200`),K(`span`,`max-w-48 truncate text-[11px] text-neutral-500`,r),K(`span`,`max-w-48 truncate text-[11px] text-neutral-400`,o));s.title=o;let c=K(`div`,`flex flex-wrap justify-end gap-1.5`);if(t.builtin||t.api&&t.models){let n=X(`Edit`);n.onclick=()=>Kc(e,t,i),c.append(n)}if(t.stored){let e=X(`Remove credential`);e.onclick=()=>void a(t),c.append(e)}return K(`div`,`grid grid-cols-[minmax(8rem,1fr)_minmax(8rem,auto)_minmax(9rem,auto)] items-center gap-3 border-b border-neutral-100 px-4 py-2.5 max-sm:grid-cols-[1fr_auto]`,n,s,c)}))};await i()}function Gc(e,t){let n=t.filter(e=>!e.configured&&e.methods.length&&(e.builtin||e.api!==void 0&&e.models!==void 0)),r=(t,n)=>{if(!n.length)return;let r=document.createElement(`optgroup`);r.label=t,r.append(...n.map(e=>new Option(e.name,e.id))),e.append(r)};r(`Common`,Vc.flatMap(e=>n.filter(t=>t.id===e))),r(`More providers`,n.filter(e=>e.builtin&&!Vc.includes(e.id)).sort((e,t)=>e.name.localeCompare(t.name))),r(`Custom providers`,n.filter(e=>!e.builtin).sort((e,t)=>e.name.localeCompare(t.name))),e.append(new Option(`Custom provider…`,Uc))}function Kc(e,t,n){let r=document.createElement(`dialog`);r.className=`m-auto w-[min(32rem,92vw)] rounded-lg border border-neutral-200 bg-white p-0 shadow-xl backdrop:bg-black/30`;let i=document.createElement(`select`);i.className=`${Fo} select`,t||Gc(i,e);let a=Q(),o=Q(),s=Q(),c=document.createElement(`select`);c.className=`${Fo} select`,c.append(...Hc.map(([e,t])=>new Option(e,t)));let d=Ro(``,4);d.placeholder=`model-id
|
|
85
|
-
another-model-id`;let f=document.createElement(`input`);f.type=`checkbox`;let p=document.createElement(`select`);p.className=`${Fo} select`;let m=K(`div`,`flex flex-col gap-4`),h=K(`span`,`text-[11.5px] text-red-600`,``),g=X(`Cancel`),_=X(t?`Save`:`Add`,!0);_.type=`submit`;let v=()=>t??e.find(e=>e.id===i.value),y=()=>{let e=v(),n=e?!e.builtin:i.value===Uc;a.value=e?.id??``,a.disabled=t!==void 0,o.value=e?.name??``,s.value=e?.endpoint??``,c.value=e?.api??`openai-completions`,d.value=e?.models?.map(e=>e.id).join(`
|
|
86
|
-
`)??``;let r=e?.models?.map(e=>e.reasoning)??[];f.checked=r.length?r.every(Boolean):!e,f.indeterminate=r.some(Boolean)&&!r.every(Boolean);let l=[];e?.configured&&l.push(new Option(`Keep current authentication`,``));let u=e?.methods??[{type:`api_key`,name:`API key`}];for(let t of u.filter(t=>e?.builtin!==!1||t.type===`api_key`))l.push(new Option(t.name,t.type));p.replaceChildren(...l);let h=[];t||h.push(Z(`Provider`,i)),n?h.push(Z(`Provider ID`,a),Z(`Display name`,o),Z(`Endpoint`,s),Z(`API format`,c),Z(`Models`,d),Z(`Model capabilities`,K(`label`,`flex items-center gap-2 text-[12.5px] text-neutral-600`,f,K(`span`,``,`Reasoning`)))):(s.placeholder=`Provider default`,h.push(Z(`Endpoint`,s))),h.push(Z(`Authentication`,p)),m.replaceChildren(...h)};i.onchange=y,y();let b=K(`form`,`flex flex-col gap-4 px-4 py-3`,m,K(`div`,`flex items-center justify-end gap-2`,h,g,_)),x=!1;g.onclick=()=>{x||r.close()},r.oncancel=e=>{x&&e.preventDefault()},b.onsubmit=e=>{if(e.preventDefault(),x)return;h.textContent=``;let t=v(),m=(t?!t.builtin:i.value===Uc)?{kind:`custom`,id:a.value.trim(),...o.value.trim()?{name:o.value.trim()}:{},endpoint:s.value.trim(),api:c.value,models:[...new Set(d.value.split(`
|
|
87
|
-
`).map(e=>e.trim()).filter(Boolean))].map(e=>({id:e,reasoning:f.indeterminate?t?.models?.find(t=>t.id===e)?.reasoning??f.checked:f.checked}))}:{kind:`builtin`,id:t.id,...s.value.trim()?{endpoint:s.value.trim()}:{}},y=p.value||null;x=!0,_.disabled=!0,g.disabled=!0,(async()=>{try{let e=await l(`/api/providers/setup`,{setup:m,authType:y});if(!e.ok){h.textContent=await u(e,`Could not configure provider`);return}if(r.close(),e.status===202){let t=p.selectedOptions[0]?.textContent??`Authentication`;Bc(await e.json(),m.id,t,()=>void n())}else await n()}catch(e){h.textContent=`Could not configure provider: ${String(e)}`}finally{x=!1,_.disabled=!1,g.disabled=!1}})()},r.append(K(`div`,`border-b border-neutral-200 px-4 py-2.5 text-[14px] font-semibold`,t?`Edit ${t.name}`:`Add provider`),b),r.onclose=()=>r.remove(),document.body.append(r),r.showModal(),(t?s:i).focus()}var qc=[[`providers`,`Providers`],[`models`,`Models`],[`files`,`Agent files`],[`channels`,`Channels`],[`instance`,`Instance`],[`security`,`Security`]],Jc=e=>qc.some(([t])=>t===e),Yc=`pier.settingsTopic`;function Xc(e,t,n){let r=localStorage.getItem(Yc)??void 0,i=Jc(r)?r:`providers`,a=K(`header`,`flex h-10 flex-none items-center gap-3 border-b border-neutral-200 bg-white px-4 max-md:hidden`,K(`span`,`font-medium`,`Settings`)),o=K(`div`,`tabstrip bg-white`);function s(){o.replaceChildren(...qc.map(([e,t])=>No(t,e===i,()=>n(e))))}let c=Q();c.placeholder=`https://pier.example.com`,c.autocomplete=`off`;let d=K(`span`,`text-[11.5px]`,``),f=X(`Save`,!0);async function p(){$(d,`saving`,`saving…`);let e=await l(`/api/settings`,{publicUrl:c.value},`PUT`);if(!e.ok)return $(d,`failed`,await u(e,`Could not save`));let{publicUrl:t}=await e.json();c.value=t,$(d,`saved`,t?`Saved — boards link as ${t}/p/<slug>/`:`Cleared.`)}f.onclick=()=>void p(),c.onkeydown=e=>{e.key===`Enter`&&p()};let m=Po(`Public URL`,`Where this Pier is reached from outside — the proxy's address, not the port it listens on.`,Z(`Base URL`,c,{hint:`Agents read it to hand you a clickable board link instead of a path. Nothing here changes what Pier serves; leave it empty if Pier is only reachable locally.`}),K(`div`,`flex items-center gap-3`,f,d)),h=Q(``,`password`),g=Q(``,`password`),_=Q(``,`password`);for(let e of[h,g,_])e.autocomplete=`off`;let v=K(`span`,`text-[11.5px]`,``),y=X(`Change password`,!0);async function b(){if(g.value!==_.value)return $(v,`failed`,`The two new passwords differ.`);$(v,`saving`,`changing…`);let e=await l(`/api/password`,{current:h.value,next:g.value});if(!e.ok)return $(v,`failed`,await u(e,`Could not change the password`));for(let e of[h,g,_])e.value=``;$(v,`saved`,`Changed. Every other signed-in browser has to sign in again.`)}y.onclick=()=>void b(),_.onkeydown=e=>{e.key===`Enter`&&b()};let x=K(`div`,`mx-auto flex max-w-2xl flex-col gap-6`,m,Po(`Password`,`One shared password guards every page and API route. Changing it signs out every other browser.`,Z(`Current password`,h),Z(`New password`,g,{hint:`At least 10 characters.`}),Z(`Repeat new password`,_),K(`div`,`flex items-center gap-3`,y,v))),S=e=>K(`div`,`hidden min-h-0 flex-1 overflow-y-auto bg-neutral-50/60`,K(`div`,`px-4 py-5`,e)),C=Rc(),w=K(`div`,`mx-auto flex max-w-2xl flex-col gap-6`),T=K(`section`,`hidden min-h-0 flex-1 flex-col`),E=Pc(T),D=K(`section`,`hidden min-h-0 flex-1 flex-col`),O=Fc(D,t);function k(){v.textContent=``,(async()=>{let e=await fetch(`/api/settings`);if(!e.ok)return $(d,`failed`,await u(e,`Could not load settings`));c.value=(await e.json()).publicUrl,d.textContent=``})()}let A=K(`div`,`mx-auto flex max-w-2xl flex-col gap-6`);async function ee(){let e=await fetch(`/api/secrets`);if(!e.ok){A.replaceChildren(Ho(await u(e,`Could not load key status`)));return}j(await e.json())}function j(e,t){let n=e.state===`locked`,r=K(`span`,`text-[11.5px]`,``);t&&$(r,`saved`,t);let i=[K(`div`,`flex items-center gap-2`,Vo(e.state,n?`bg-red-50 text-red-700 ring-red-200`:`bg-emerald-50 text-emerald-700 ring-emerald-200`),K(`span`,`text-[12.5px] text-neutral-600`,n?`Stored credentials cannot be read until the key is unlocked.`:e.mode===`vt`?`Key mode: vt:// — unlocking takes one vt approval per process start.`:`Key mode: file — the key sits raw in master.key; switch to vt:// to require an approval.`))];if(n){i.push(K(`p`,`text-[12.5px] leading-snug text-red-600`,e.reason??`No reason reported.`));let t=X(`Unlock`,!0);t.onclick=()=>{$(r,`saving`,`unlocking… (vt mode waits on your approval)`),(async()=>{let e=await l(`/api/secrets/unlock`,{});if(!e.ok)return $(r,`failed`,await u(e,`Could not unlock`));j(await e.json(),`Unlocked — channels are starting.`)})()},i.push(K(`div`,`flex items-center gap-3`,t,r))}else{let t=async(e,t,n)=>{if(!window.confirm(t))return;$(r,`saving`,e===`vt`?`rotating… (vt asks for an approval)`:`rotating…`);let i=await l(`/api/secrets/rotate`,{mode:e});if(!i.ok)return $(r,`failed`,await u(i,`Could not rotate`));j(await i.json(),n)},n=e.mode??`file`,a=X(`Rotate key`,!0);a.onclick=()=>void t(n,`Generate a new master key? Stored credentials stay valid; the old key stops working.`,`Rotated.`);let o=n===`vt`?`file`:`vt`,s=X(o===`vt`?`Switch to vt://`:`Switch to file`);s.onclick=()=>void t(o,o===`vt`?`Move the master key into vt? Every process start will then wait on a vt approval.`:`Store the master key raw in master.key? Anyone who can read the file can read every credential.`,o===`vt`?`Switched to vt:// mode.`:`Switched to file mode.`),i.push(K(`div`,`flex items-center gap-3`,a,s,r))}A.replaceChildren(Po(`Master key`,`Seals every credential Pier stores (channel tokens, API keys). Rotating rewraps the key file; no stored data is rewritten.`,...i))}let te=S(x),M=S(w),ne=S(C.el),N=S(A),re=[[`instance`,te,k],[`providers`,M,()=>void Wc(w)],[`models`,ne,()=>C.load()],[`security`,N,()=>void ee()]];e.append(a,o,te,M,ne,T,D,N);function ie(e){Jc(e)&&(i=e),localStorage.setItem(Yc,i),s();for(let[e,t,n]of re){let r=e===i;t.classList.toggle(`hidden`,!r),r&&n()}i===`channels`?E.show():E.hide(),i===`files`?O.show():O.hide()}return Xn(e,ie)}function Zc(e,t){let n=e.map(e=>[`${e.title??`Untitled`} · ${e.cwd}`,e.id]);return t&&!n.some(([,e])=>e===t)&&n.push([`Current session · ${t}`,t]),n}function Qc(e,t){let n=document.createElement(`dialog`);n.className=`m-auto w-[38.75rem] max-w-[94vw] rounded-lg border border-neutral-200 p-0 shadow-xl backdrop:bg-black/20`;let r=document.createElement(`form`);r.className=`flex max-h-[88vh] flex-col`;let i=K(`span`,`mr-auto text-[12px] text-red-600`),a=K(`header`,`flex h-11 flex-none items-center border-b border-neutral-200 px-4 font-medium`,t?`Edit task`:`New task`),o=K(`div`,`grid min-h-0 flex-1 grid-cols-2 gap-3 overflow-y-auto p-4`),s=Q(t?.name??``);s.required=!0;let c=Q(t?.description??``),l=Q(String(t?.timeoutSeconds??900),`number`);l.min=`1`,l.max=`86400`;let u=Lo([[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watch`,`watch`]],t?.trigger.type??`manual`),d=Lo([[`Bash`,`bash`],[`Agent`,`agent`],[`Task`,`task`]],t?.action.type??`bash`),f=Lo([[`No callback`,`none`],[`Invoking session`,`origin`],[`Specific session`,`session`]],t?.callback.type??`none`),p=t?.callback.type===`session`?t.callback.sessionId:null,m=Lo(Zc(e.sessions(),p),p??``),h=Z(`Callback session`,m);h.classList.toggle(`hidden`,f.value!==`session`),f.onchange=()=>h.classList.toggle(`hidden`,f.value!==`session`),o.append(Z(`Name`,s),Z(`Description`,c),Z(`Trigger`,u),Z(`Action`,d),Z(`Callback`,f),h,Z(`Timeout (seconds)`,l));let g=K(`div`,`col-span-2 grid grid-cols-2 gap-3 border-t border-neutral-200 pt-3`);o.append(g);let _=()=>{g.replaceChildren();let a,o,p,h,_,v;if(u.value===`cron`)a=Q(t?.trigger.type===`cron`?t.trigger.expression:`0 9 * * *`),o=Q(t?.trigger.type===`cron`?t.trigger.timezone:Intl.DateTimeFormat().resolvedOptions().timeZone),g.append(Z(`Cron`,a),Z(`Timezone`,o));else if(u.value===`watch`){p=Ro(t?.trigger.type===`watch`?t.trigger.script:``,4),v=Q(t?.trigger.type===`watch`?t.trigger.cwd:e.sessions()[0]?.cwd??``),h=Q(String(t?.trigger.type===`watch`?t.trigger.intervalSeconds:60),`number`),_=Lo([[`Continue after matches`,`repeat`],[`Stop after first match`,`once`]],t?.trigger.type===`watch`?t.trigger.mode:`repeat`);let n=Z(`Probe script (0=match, 1=no match)`,p);n.classList.add(`col-span-2`),g.append(n,Z(`Probe directory`,v),Z(`Interval (seconds)`,h),Z(`Mode`,_))}let y,b,x,S,C,w,T,E,D,O,k;if(d.value===`bash`){b=Q(t?.action.type===`bash`?t.action.cwd:e.sessions()[0]?.cwd??``),y=Ro(t?.action.type===`bash`?t.action.script:``,6);let n=Z(`Bash script`,y);n.classList.add(`col-span-2`),g.append(Z(`Working directory`,b),K(`span`,``),n)}else if(d.value===`agent`){let n=e.sessions(),r=t?.action.type===`agent`?t.action:null,i=r?.session.mode===`reuse`?r.session.sessionId:``,a=Zc(n,i||null);x=Lo([[`Reuse session`,`reuse`],[`Fresh child per run`,`fresh`],[`Fork caller context`,`fork`]],r?.session.mode??`fresh`),S=Lo(a,i||a[0]?.[1]||``),C=Q((r?.session.mode===`fresh`||r?.session.mode===`fork`?r.session.cwd??``:``)||n[0]?.cwd||``),w=Ro(r?.prompt??``,6),T=Lo([[`Normal project tools`,`write`],[`Read only`,`read`]],r?.launch?.capabilities??`write`),E=Lo([[`Project default`,``],[`Off`,`off`],[`Low`,`low`],[`Medium`,`medium`],[`High`,`high`],[`Extra high`,`xhigh`]],r?.launch?.thinking??``),D=Q(r?.launch?.model?.provider??``),O=Q(r?.launch?.model?.id??``);let o=Z(`Session`,S),s=Z(`Child directory`,C),c=[Z(`Capabilities`,T),Z(`Thinking`,E),Z(`Model provider (optional)`,D),Z(`Model id (optional)`,O)],l=()=>{let e=x?.value===`reuse`;o.classList.toggle(`hidden`,!e),s.classList.toggle(`hidden`,e);for(let t of c)t.classList.toggle(`hidden`,e)};x.onchange=l,l();let u=Z(`Prompt`,w);u.classList.add(`col-span-2`),g.append(Z(`Session policy`,x),o,s,...c,u)}else k=Lo(e.tasks().filter(e=>e.id!==t?.id&&!e.archived).map(e=>[e.name,e.id]),t?.action.type===`task`?t.action.taskId:``),g.append(Z(`Target task`,k));r.onsubmit=r=>{r.preventDefault();let g=u.value===`manual`?{type:`manual`}:u.value===`cron`?{type:`cron`,expression:a.value,timezone:o.value}:{type:`watch`,script:p.value,cwd:v.value,intervalSeconds:Number(h.value),mode:_.value},A=d.value===`agent`&&x.value!==`reuse`?{capabilities:T.value,...E.value?{thinking:E.value}:{},...D.value.trim()&&O.value.trim()?{model:{provider:D.value.trim(),id:O.value.trim()}}:{}}:void 0,ee=d.value===`bash`?{type:`bash`,cwd:b.value,script:y.value}:d.value===`agent`?{type:`agent`,prompt:w.value,session:x.value===`reuse`?{mode:`reuse`,sessionId:S.value}:x.value===`fork`?{mode:`fork`,...C.value.trim()?{cwd:C.value.trim()}:{}}:{mode:`fresh`,cwd:C.value},...A?{launch:A}:{}}:{type:`task`,taskId:k.value},j=f.value===`origin`?{type:`origin`}:f.value===`session`?{type:`session`,sessionId:m.value}:{type:`none`},te={name:s.value,description:c.value,trigger:g,action:ee,callback:j,timeoutSeconds:Number(l.value)};i.textContent=``,$c(t?.id,te,n,i,e.onSaved)}};u.onchange=_,d.onchange=_,_();let v=X(`Cancel`);v.onclick=()=>n.close();let y=X(`Save`,!0);y.type=`submit`;let b=K(`footer`,`flex flex-none justify-end gap-2 border-t border-neutral-200 px-4 py-3`);b.append(i,v,y),r.append(a,o,b),n.append(r),n.addEventListener(`close`,()=>n.remove()),document.body.append(n),n.showModal(),s.focus()}async function $c(e,t,n,r,i){let a=await l(e?`/api/tasks/${e}`:`/api/tasks`,t,e?`PATCH`:`POST`);if(!a.ok){r.textContent=(await a.json()).error??`Task save failed`;return}let o=await a.json(),s=`task`in o?o.task:o;n.close(),i(s.id)}var el=e=>e===null?`-`:new Date(e).toLocaleString(),tl=e=>e.startedAt===null?`-`:Yn((e.finishedAt??Date.now())-e.startedAt);function nl(e,t,n){let r=K(`div`,`divide-y divide-neutral-100`);for(let i of t){let t=K(`button`,`grid w-full cursor-pointer grid-cols-[7.5rem_1fr_7.5rem_6.25rem] gap-3 px-4 py-2.5 text-left text-[12.5px] hover:bg-neutral-50`);t.append(K(`span`,`font-medium`,i.state),K(`span`,`truncate text-neutral-500`,el(i.queuedAt)),K(`span`,`text-neutral-500`,i.triggerSource),K(`span`,`text-right text-neutral-500`,tl(i))),t.onclick=()=>void rl(e,i.id,r,n),r.append(t)}t.length||r.append(K(`p`,`p-4 text-[13px] text-neutral-400`,`No runs yet.`)),e.replaceChildren(r)}async function rl(e,t,n,r){let[i,a]=await Promise.all([fetch(`/api/task-runs/${t}`),fetch(`/api/task-runs/${t}/messages`)]);if(!i.ok)return;let o=await i.json(),s=a.ok?await a.json():[],c=X(`Back to runs`);c.onclick=()=>e.replaceChildren(n);let l=K(`div`,`flex items-center gap-2 border-b border-neutral-200 px-4 py-2`);if(l.append(c,K(`span`,`font-mono text-[12px] text-neutral-400`,o.id)),o.targetSessionId){let e=X(`Open session`);e.classList.add(`ml-auto`),e.onclick=()=>r.openSession(o.targetSessionId),l.append(e)}if(o.state===`queued`||o.state===`running`){let e=X(`Steer`);e.onclick=()=>void il(d(`Steer subagent`,`/api/task-runs/${o.id}/steer`,{mode:`steer`,sourceSessionId:r.currentSessionId()},`Run control failed`),r);let t=X(`Stop`);t.onclick=()=>void r.mutate(`/api/task-runs/${o.id}/cancel`),l.append(e,t)}else if(o.targetSessionId){let e=X(`Continue`);e.onclick=()=>void il(d(`Continue subagent`,`/api/task-runs/${o.id}/resume`,{sourceSessionId:r.currentSessionId()},`Run control failed`),r),l.append(e)}let u=K(`div`,`min-h-0 flex-1 overflow-auto`),f=K(`pre`,`whitespace-pre-wrap break-words p-4 font-mono text-[12px]`,JSON.stringify(o,null,2));if(u.append(f),s.length){let e=K(`div`,`border-t border-neutral-200`);e.append(K(`div`,`px-4 py-2 text-[11px] font-semibold uppercase text-neutral-400`,`Messages`));for(let t of s){let n=K(`div`,`grid grid-cols-[6.25rem_6.25rem_1fr] gap-3 border-t border-neutral-100 px-4 py-2 text-[12px]`);n.append(K(`span`,`font-medium`,t.kind),K(`span`,`text-neutral-500`,t.state),K(`span`,`whitespace-pre-wrap`,t.content)),e.append(n)}u.append(e)}e.replaceChildren(l,u)}async function il(e,t){let n=await e;n.sent&&(n.error?t.onError(n.error):await t.reload())}var al=e=>e.trigger.type===`manual`?`Manual`:e.trigger.type===`cron`?`${e.trigger.expression} (${e.trigger.timezone})`:`Every ${e.trigger.intervalSeconds}s · ${e.trigger.mode}`,ol=e=>e.action.type===`agent`?`Agent · ${e.action.session.mode}`:e.action.type===`bash`?`Bash`:`Task`;function sl(e,t,n,r,i){let a=[],o=[],s=null,c=`active`;async function u(){let e=await fetch(`/api/tasks?state=${c===`archived`?`archived`:`active`}${c===`subagent`?`&kind=subagent`:``}`);if(!e.ok)return d(`Failed to load tasks: ${e.status}`);a=await e.json(),o=c===`archived`||c===`subagent`?await f():a,c!==`active`&&c!==`archived`&&c!==`subagent`&&(a=a.filter(e=>e.trigger.type===c)),s?await b(s):v()}function d(t){e.replaceChildren(K(`p`,`p-4 text-[13px] text-red-600`,t))}async function f(){let e=await fetch(`/api/tasks?state=active`);return e.ok?await e.json():o}let p={sessions:t,tasks:()=>o,onSaved:e=>{s=e,u()}},m={openSession:n,currentSessionId:r,mutate:C,onError:d,reload:u};function h(e,t){let n=K(`header`,`flex h-10 flex-none items-center gap-2 border-b border-neutral-200 px-4`);if(n.append(typeof e==`string`?K(`span`,`truncate font-medium max-md:hidden`,e):e),t.length){let e=K(`div`,`ml-auto flex items-center gap-2`);e.append(...t),n.append(e)}return n}function g(){return K(`div`,`tabstrip`,Mo(`Sessions`,!1,()=>i(`sessions`)),Mo(`Dependencies`,!1,()=>i(`dependencies`)),Mo(`Tasks`,!0,_))}function _(){s=null,v()}function v(){let t=X(`New task`,!0);t.onclick=()=>Qc(p);let n=g(),r=K(`div`,`ml-auto flex flex-none items-center gap-1 pl-1 max-md:ml-0 max-md:w-full max-md:overflow-x-auto max-md:pl-0`);for(let[e,t]of[[`All`,`active`],[`Manual`,`manual`],[`Scheduled`,`cron`],[`Watching`,`watch`],[`Subagents`,`subagent`],[`Archived`,`archived`]])r.append(Mo(e,c===t,()=>{c=t,s=null,u()}));n.append(r);let i=document.createElement(`table`);i.className=`w-full min-w-[52rem] table-fixed text-left text-[12.5px]`,i.innerHTML=`<thead class="sticky top-0 bg-neutral-50 text-[10.5px] uppercase text-neutral-400"><tr>
|
|
88
|
-
<th class="w-[24%] px-4 py-2 font-semibold">Name</th><th class="w-[10%] px-2 py-2 font-semibold">Action</th>
|
|
89
|
-
<th class="w-[23%] px-2 py-2 font-semibold">Trigger</th><th class="w-[17%] px-2 py-2 font-semibold">Next</th>
|
|
90
|
-
<th class="w-[14%] px-2 py-2 font-semibold">Last result</th><th class="px-2 py-2 font-semibold"></th></tr></thead>`;let o=document.createElement(`tbody`);for(let e of a)o.append(y(e));i.append(o),e.replaceChildren(h(`Tasks`,[t]),n,K(`div`,`min-h-0 flex-1 overflow-auto`,i))}function y(e){let t=document.createElement(`tr`);t.className=`cursor-pointer border-b border-neutral-100 hover:bg-neutral-50`,t.onclick=()=>{s=e.id,b(e.id)};let n=e.archived?`Archived`:e.enabled?`Enabled`:`Paused`;t.append(K(`td`,`truncate py-2.5 pl-4 pr-2`,K(`div`,`truncate font-medium`,e.name),K(`div`,`text-[11px] text-neutral-400`,n)));for(let n of[ol(e),al(e),el(e.nextRunAt),e.lastRun?`${e.lastRun.state} · ${tl(e.lastRun)}`:`-`])t.append(K(`td`,`truncate px-2 py-2.5`,n));let r=X(`Run`);return r.disabled=e.archived,r.onclick=t=>{t.stopPropagation(),S(e.id)},t.append(K(`td`,`px-2 py-1 text-right`,r)),t}async function b(t){let[n,r]=await Promise.all([fetch(`/api/tasks/${t}`),fetch(`/api/tasks/${t}/runs`)]);if(!n.ok||!r.ok)return d(`Failed to load task`);let i=await n.json(),a=await r.json(),o=X(`Tasks`);o.className=`cursor-pointer text-neutral-500 hover:underline`,o.onclick=_;let s=K(`span`,`flex min-w-0 items-center gap-1.5`,o,K(`span`,`text-neutral-400`,`›`),K(`span`,`truncate font-medium`,i.name)),c=X(`Run now`,!0);c.disabled=i.archived,c.onclick=()=>void S(i.id);let l=X(i.enabled?`Pause`:`Resume`);l.disabled=i.archived||i.trigger.type===`manual`,l.onclick=()=>void C(`/api/tasks/${i.id}/${i.enabled?`pause`:`resume`}`);let u=X(`Edit`);u.disabled=i.archived,u.onclick=()=>Qc(p,i);let f=X(`Archive`);f.disabled=i.archived,f.onclick=()=>void C(`/api/tasks/${i.id}/archive`);let v=K(`div`,`flex flex-none gap-1 border-b border-neutral-200 px-4 py-2`),y=X(`Definition`),b=X(`Runs (${a.length})`),w=K(`div`,`min-h-0 flex-1 overflow-auto`),T=()=>{y.classList.add(`bg-neutral-200`),b.classList.remove(`bg-neutral-200`),x(w,i)};y.onclick=T,b.onclick=()=>{b.classList.add(`bg-neutral-200`),y.classList.remove(`bg-neutral-200`),nl(w,a,m)},v.append(y,b),e.replaceChildren(h(s,[c,l,u,f]),g(),v,w),a.length?b.click():T()}function x(e,t){let r=K(`div`,`grid max-w-4xl grid-cols-[9.375rem_minmax(0,1fr)] gap-x-5 gap-y-3 p-4 text-[13px]`),i=[[`Status`,t.archived?`Archived`:t.enabled?`Enabled`:`Paused`],[`Trigger`,al(t)],[`Action`,ol(t)],[`Timeout`,`${t.timeoutSeconds}s`],[`Next run`,el(t.nextRunAt)],[`Revision`,String(t.revision)],[`Created by`,t.createdBySessionId??t.creator],[`Callback`,t.callback.type===`session`?t.callback.sessionId:t.callback.type],[`Description`,t.description||`-`]];t.action.type===`agent`&&(i.push([`Session policy`,t.action.session.mode]),t.action.session.mode===`reuse`&&i.push([`Session`,t.action.session.sessionId]),t.action.session.mode===`fresh`&&i.push([`Directory`,t.action.session.cwd]),t.action.session.mode===`fork`&&i.push([`Directory`,t.action.session.cwd??`Caller project`]),t.action.launch?.model&&i.push([`Model`,`${t.action.launch.model.provider}/${t.action.launch.model.id}`]),t.action.launch?.thinking&&i.push([`Thinking`,t.action.launch.thinking]),t.action.launch?.capabilities&&i.push([`Capabilities`,t.action.launch.capabilities]),i.push([`Prompt`,t.action.prompt])),t.action.type===`bash`&&i.push([`Directory`,t.action.cwd],[`Script`,t.action.script]),t.action.type===`task`&&i.push([`Target task`,t.action.taskId]),t.trigger.type===`watch`&&i.push([`Probe`,t.trigger.script]);for(let[e,t]of i)r.append(K(`span`,`text-[11px] font-semibold uppercase text-neutral-400`,e),K(`pre`,`whitespace-pre-wrap break-words font-mono text-[12.5px]`,t));if(t.action.type===`agent`&&t.action.session.mode===`reuse`){let{sessionId:e}=t.action.session,i=X(`Open session`);i.onclick=()=>n(e),r.append(K(`span`,``,``),i)}e.replaceChildren(r)}async function S(e){let t=await l(`/api/tasks/${e}/run`,{sourceSessionId:r()});if(!t.ok)return d((await t.json()).error??`Failed to run task`);s=e,await b(e)}async function C(e){let t=await fetch(e,{method:`POST`});if(!t.ok)return d((await t.json()).error??`Task update failed`);await u()}let w=Xn(e,e=>{e&&(s=e),u()});return Object.assign(w,{refresh(e){w.visible&&(!s||!e||s===e)&&u()}})}var cl,ll=G(`#chat-header`),ul=G(`#chat-title`),dl=[ll,na,G(`#composer`)],fl=!0,pl=()=>fl,ml,hl,gl=[],_l=new Map,vl=`activity`,yl={tasks:`Tasks`,activity:`Activity`,boards:`Boards`,settings:`Settings`,files:`Files`},bl=e=>ml.refresh(e),xl=()=>hl.refresh();function Sl(){let e=gl.find(e=>e.view.visible);e?$s(yl[e.name],!1):$s(ul.textContent??``,cl.currentSession()!==void 0)}function Cl(e,t){(e===`tasks`||e===`activity`)&&(vl=e),jl({kind:`console`,name:e,arg:t}),Qs(),fl=!1;for(let e of dl)e.classList.add(`hidden`);io();for(let n of gl)n.name===e?n.view.show(t):n.view.hide();for(let[t,n]of _l)n.classList.toggle(`bg-indigo-50`,t===e||t===`activity`&&e===`tasks`);Sl()}var wl=e=>Cl(`tasks`,e),Tl=e=>Cl(`files`,e);function El(){if(gl.some(({view:e})=>e.visible)){for(let{view:e}of gl)e.hide();for(let e of _l.values())e.classList.remove(`bg-indigo-50`);fl=!0;for(let e of dl)e.classList.remove(`hidden`);io(),Sl(),cl.maybeAckRead()}}var Dl=e=>e.kind===`session`?`#/session/${encodeURIComponent(e.id)}`:`#/${e.name}${e.arg?`/${encodeURIComponent(e.arg)}`:``}`,Ol={config:`files`,channels:`channels`,providers:`providers`};function kl(){let[e=``,t]=location.hash.replace(/^#\/?/,``).split(`/`);if(Ol[e])return{kind:`console`,name:`settings`,arg:Ol[e]};let n=gl.find(t=>t.name===e)?.name;return n?{kind:`console`,name:n,arg:t?decodeURIComponent(t):void 0}:e===`session`&&t?{kind:`session`,id:decodeURIComponent(t)}:null}var Al=!1;function jl(e,t=!1){if(Al)return;let n=Dl(e);location.hash!==n&&(t?history.replaceState(null,``,n):location.hash=n)}var Ml=e=>jl({kind:`session`,id:e});function Nl(){let e=kl(),t=cl.sessions(),n=cl.currentId(),r=e?.kind===`session`?e.id:null,i=r&&t.some(e=>e.id===r)?r:n??(t.find(e=>e.pinned)??t[0])?.id??null;Al=!0;try{i&&i!==n&&cl.select(i),e?.kind===`console`?Cl(e.name,e.arg):El(),i||Rs()}finally{Al=!1}e?.kind!==`console`&&i&&jl({kind:`session`,id:i},!0)}function Pl(e){cl=e,ml=sl(G(`#tasks-view`),()=>cl.sessions().map(({id:e,cwd:t,title:n})=>({id:e,cwd:t,title:n})),e.select,()=>cl.currentId(),e=>Cl(`activity`,e)),hl=lc(G(`#activity-view`),e.select,wl),gl=[{name:`tasks`,view:ml},{name:`activity`,view:hl},{name:`boards`,view:uc(G(`#boards-view`),e.select)},{name:`files`,view:Sc(G(`#files-view`),()=>[..._s(cl.sessions()).keys()],e=>Cl(`files`,e))},{name:`settings`,view:Xc(G(`#settings-view`),()=>[..._s(cl.sessions()).keys()],e=>Cl(`settings`,e))}];for(let e of[`activity`,`boards`,`settings`]){let t=G(`#open-${e}`);_l.set(e,t),t.onclick=()=>Cl(e===`activity`?vl:e)}let t=G(`#console-section`);t.open=localStorage.getItem(`pier.consoleCollapsed`)!==`1`,t.ontoggle=()=>localStorage.setItem(`pier.consoleCollapsed`,t.open?`0`:`1`),window.onhashchange=Nl}var Fl=[],Il=null,Ll=`idle`,Rl=null,zl=0,Bl=!1;async function Vl(e){let t=await l(`/api/sessions`,{cwd:e});if(!t.ok){J(`error`,`session create failed: ${t.status}`);return}let{id:n}=await t.json();await Hl(),await Xl(n),$a()}async function Hl(){Fl=await(await fetch(`/api/sessions`)).json(),Fl.sort((e,t)=>t.createdAt-e.createdAt),Cs(),Ul()}function Ul(){if(document.hidden||!pl())return;let e=Fl.find(e=>e.id===Il);e?.unread&&(e.unread=!1,Cs(),fetch(`/api/sessions/${e.id}/read`,{method:`POST`}))}function Wl(){let e=Fl.find(e=>e.id===Il);return e||!Il?e:{id:Il,cwd:`—`,createdAt:Date.now(),state:Ll,pinned:!1,unread:!1,activeRuns:0}}function Gl(e,t){let n=Fl.find(t=>t.id===e);!n||n.title||!t.trim()||(n.title=t.trim().slice(0,80),Cs(),Rs())}function Kl(e){Ll=e;let t=Fl.find(e=>e.id===Il);t&&(t.state=e),Cs(),Rs(),ro(),e===`idle`&&Hl()}function ql(e){if(!(e.sessionId!==Il||e.seq<=zl))switch(zl=e.seq,e.type){case`turn-start`:Bl=!0;break;case`system-input`:Sa(),oa(e.text,e.origin);break;case`task-status`:Li(e.run);break;case`user-message`:if(Gl(e.sessionId,e.text),eo(e.text))break;Sa(),J(`user`,e.text),ia();break;case`text-delta`:xa(e.text);break;case`thinking-delta`:Qi(e.ts,e.text);break;case`tool-start`:Sa(),Xi(e.ts,e.toolCallId,e.toolName,e.args);break;case`tool-end`:Zi(e.toolCallId,e.isError,e.output);break;case`turn-end`:Bl=!1,Ca(e.text,e.meta),e.meta&&Ls(e.meta.tokens);break;case`queue-state`:ao(e.steering,e.followUp);break;case`error`:Yi(),J(`error`,e.message);break;case`state`:e.state===`idle`&&Bl&&(Bl=!1,wa()),e.state===`idle`&&ao([],[]),Kl(e.state)}}function Jl(){let e=new EventSource(`/api/events`);e.onopen=()=>void Hl(),e.onerror=()=>Ra(e,`Workspace`),e.onmessage=e=>{let t=JSON.parse(e.data);if(t.type===`sessions-changed`){Hl();return}if(t.type===`tasks-changed`||t.type===`task-run-changed`||t.type===`task-message-changed`||t.type===`task-group-changed`){bl(t.type===`task-run-changed`?t.taskId:void 0),xl(),t.type===`task-run-changed`&&Hl();return}if(xl(),t.sessionId===Il)return;let n=Fl.find(e=>e.id===t.sessionId);n&&(n.state=t.state,Cs())}}function Yl(e,t){Rl?.close();let n=new EventSource(`/api/sessions/${e}/events?after=${t}`);n.onmessage=e=>ql(JSON.parse(e.data)),n.onerror=()=>Ra(n,`Session`),Rl=n}async function Xl(e){El(),Qs(),Ml(e),e!==Il&&(fo(),Il=e,Ll=Fl.find(t=>t.id===e)?.state??`idle`,po(e),Cs(),Rs(),Ul(),await Zl(e))}async function Zl(e){Rl?.close(),Ta(),ao([],[]),Fs(),Bl=!1,no(),zl=0;let t=await fetch(`/api/sessions/${e}/history`),n=t.ok?await t.json():null;if(Il===e){if(!n){J(`error`,`failed to load session: ${t.status}`);return}Ea(n.turns,n.state,n.backgroundRuns),zl=n.lastSeq,Bl=n.state===`streaming`,Kl(n.state),ao(n.queue.steering,n.queue.followUp),Is(n.model,n.context,n.thinkingLevel),Yl(e,n.lastSeq)}}Pa(),La();var Ql=async e=>{Il===e&&await Zl(e)};ra({sessionId:()=>Il,sessionState:()=>Ll,select:e=>void Xl(e),showTasks:wl,send:(e,t)=>void go(e,t),ownTurn:e=>{to(e),Kl(`streaming`)},reload:Ql}),yo({sessionId:()=>Il,sessionState:()=>Ll,chatVisible:pl,setState:Kl,reload:Ql}),nc({sessionMenu:e=>{let t=Wl();t&&qs(e,t)}}),Es({sessions:()=>Fl,currentId:()=>Il,select:e=>void Xl(e),sessionMenu:qs,createSession:Vl,openFiles:Tl,onPinsChanged:Rs}),Os({currentId:()=>Il,currentSession:Wl,syncBar:Sl,openFiles:Tl}),Pl({sessions:()=>Fl,currentId:()=>Il,currentSession:Wl,select:e=>void Xl(e),maybeAckRead:Ul}),oc(`0.0.2`),document.addEventListener(`visibilitychange`,Ul),Jl(),Hl().then(Nl);
|