UNPKG

@buildshipapp/chat-widget

Version:

A chat widget that can be paired with BuildShip workflows built using the Assistant API.

1 lines 79.7 kB
function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},e.apply(this,arguments)}const t=Math.min,n=Math.max,i=Math.round,r=Math.floor,o=e=>({x:e,y:e}),s={left:"right",right:"left",bottom:"top",top:"bottom"},a={start:"end",end:"start"};function l(e,i,r){return n(e,t(i,r))}function c(e,t){return"function"==typeof e?e(t):e}function u(e){return e.split("-")[0]}function d(e){return e.split("-")[1]}function h(e){return"x"===e?"y":"x"}function p(e){return"y"===e?"height":"width"}function f(e){return["top","bottom"].includes(u(e))?"y":"x"}function g(e){return h(f(e))}function b(e){return e.replace(/start|end/g,e=>a[e])}function m(e){return e.replace(/left|right|bottom|top/g,e=>s[e])}function w(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function x(e,t,n){let{reference:i,floating:r}=e;const o=f(t),s=g(t),a=p(s),l=u(t),c="y"===o,h=i.x+i.width/2-r.width/2,b=i.y+i.height/2-r.height/2,m=i[a]/2-r[a]/2;let w;switch(l){case"top":w={x:h,y:i.y-r.height};break;case"bottom":w={x:h,y:i.y+i.height};break;case"right":w={x:i.x+i.width,y:b};break;case"left":w={x:i.x-r.width,y:b};break;default:w={x:i.x,y:i.y}}switch(d(t)){case"start":w[s]-=m*(n&&c?-1:1);break;case"end":w[s]+=m*(n&&c?-1:1)}return w}async function k(e,t){var n;void 0===t&&(t={});const{x:i,y:r,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:p=!1,padding:f=0}=c(t,e),g=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(f),b=a[p?"floating"===h?"reference":"floating":h],m=w(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(b)))||n?b:b.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),x="floating"===h?{...s.floating,x:i,y:r}:s.reference,k=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),y=await(null==o.isElement?void 0:o.isElement(k))&&await(null==o.getScale?void 0:o.getScale(k))||{x:1,y:1},v=w(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:k,strategy:l}):x);return{top:(m.top-v.top+g.top)/y.y,bottom:(v.bottom-m.bottom+g.bottom)/y.y,left:(m.left-v.left+g.left)/y.x,right:(v.right-m.right+g.right)/y.x}}function y(e){return E(e)?(e.nodeName||"").toLowerCase():"#document"}function v(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function _(e){var t;return null==(t=(E(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function E(e){return e instanceof Node||e instanceof v(e).Node}function R(e){return e instanceof Element||e instanceof v(e).Element}function T(e){return e instanceof HTMLElement||e instanceof v(e).HTMLElement}function S(e){return"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof v(e).ShadowRoot)}function $(e){const{overflow:t,overflowX:n,overflowY:i,display:r}=O(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&!["inline","contents"].includes(r)}function C(e){return["table","td","th"].includes(y(e))}function A(e){const t=z(),n=O(e);return"none"!==n.transform||"none"!==n.perspective||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","perspective","filter"].some(e=>(n.willChange||"").includes(e))||["paint","layout","strict","content"].some(e=>(n.contain||"").includes(e))}function z(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function I(e){return["html","body","#document"].includes(y(e))}function O(e){return v(e).getComputedStyle(e)}function L(e){return R(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function P(e){if("html"===y(e))return e;const t=e.assignedSlot||e.parentNode||S(e)&&e.host||_(e);return S(t)?t.host:t}function N(e){const t=P(e);return I(t)?e.ownerDocument?e.ownerDocument.body:e.body:T(t)&&$(t)?t:N(t)}function D(e,t,n){var i;void 0===t&&(t=[]),void 0===n&&(n=!0);const r=N(e),o=r===(null==(i=e.ownerDocument)?void 0:i.body),s=v(r);return o?t.concat(s,s.visualViewport||[],$(r)?r:[],s.frameElement&&n?D(s.frameElement):[]):t.concat(r,D(r,[],n))}function F(e){const t=O(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=T(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=i(n)!==s||i(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function B(e){return R(e)?e:e.contextElement}function M(e){const t=B(e);if(!T(t))return o(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:a}=F(t);let l=(a?i(n.width):n.width)/r,c=(a?i(n.height):n.height)/s;return l&&Number.isFinite(l)||(l=1),c&&Number.isFinite(c)||(c=1),{x:l,y:c}}const j=/*#__PURE__*/o(0);function q(e){const t=v(e);return z()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:j}function Z(e,t,n,i){void 0===t&&(t=!1),void 0===n&&(n=!1);const r=e.getBoundingClientRect(),s=B(e);let a=o(1);t&&(i?R(i)&&(a=M(i)):a=M(e));const l=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==v(e))&&t}(s,n,i)?q(s):o(0);let c=(r.left+l.x)/a.x,u=(r.top+l.y)/a.y,d=r.width/a.x,h=r.height/a.y;if(s){const e=v(s),t=i&&R(i)?v(i):i;let n=e,r=n.frameElement;for(;r&&i&&t!==n;){const e=M(r),t=r.getBoundingClientRect(),i=O(r),o=t.left+(r.clientLeft+parseFloat(i.paddingLeft))*e.x,s=t.top+(r.clientTop+parseFloat(i.paddingTop))*e.y;c*=e.x,u*=e.y,d*=e.x,h*=e.y,c+=o,u+=s,n=v(r),r=n.frameElement}}return w({width:d,height:h,x:c,y:u})}const H=[":popover-open",":modal"];function G(e){return H.some(t=>{try{return e.matches(t)}catch(e){return!1}})}function V(e){return Z(_(e)).left+L(e).scrollLeft}function W(e,t,i){let r;if("viewport"===t)r=function(e,t){const n=v(e),i=_(e),r=n.visualViewport;let o=i.clientWidth,s=i.clientHeight,a=0,l=0;if(r){o=r.width,s=r.height;const e=z();(!e||e&&"fixed"===t)&&(a=r.offsetLeft,l=r.offsetTop)}return{width:o,height:s,x:a,y:l}}(e,i);else if("document"===t)r=function(e){const t=_(e),i=L(e),r=e.ownerDocument.body,o=n(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=n(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-i.scrollLeft+V(e);const l=-i.scrollTop;return"rtl"===O(r).direction&&(a+=n(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:l}}(_(e));else if(R(t))r=function(e,t){const n=Z(e,!0,"fixed"===t),i=n.top+e.clientTop,r=n.left+e.clientLeft,s=T(e)?M(e):o(1);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:r*s.x,y:i*s.y}}(t,i);else{const n=q(e);r={...t,x:t.x-n.x,y:t.y-n.y}}return w(r)}function Q(e,t){const n=P(e);return!(n===t||!R(n)||I(n))&&("fixed"===O(n).position||Q(n,t))}function K(e,t,n){const i=T(t),r=_(t),s="fixed"===n,a=Z(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=o(0);if(i||!i&&!s)if(("body"!==y(t)||$(r))&&(l=L(t)),i){const e=Z(t,!0,s,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else r&&(c.x=V(r));return{x:a.left+l.scrollLeft-c.x,y:a.top+l.scrollTop-c.y,width:a.width,height:a.height}}function U(e,t){return T(e)&&"fixed"!==O(e).position?t?t(e):e.offsetParent:null}function Y(e,t){const n=v(e);if(!T(e)||G(e))return n;let i=U(e,t);for(;i&&C(i)&&"static"===O(i).position;)i=U(i,t);return i&&("html"===y(i)||"body"===y(i)&&"static"===O(i).position&&!A(i))?n:i||function(e){let t=P(e);for(;T(t)&&!I(t);){if(A(t))return t;t=P(t)}return null}(e)||n}const X={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:i,strategy:r}=e;const s="fixed"===r,a=_(i),l=!!t&&G(t.floating);if(i===a||l&&s)return n;let c={scrollLeft:0,scrollTop:0},u=o(1);const d=o(0),h=T(i);if((h||!h&&!s)&&(("body"!==y(i)||$(a))&&(c=L(i)),T(i))){const e=Z(i);u=M(i),d.x=e.x+i.clientLeft,d.y=e.y+i.clientTop}return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x,y:n.y*u.y-c.scrollTop*u.y+d.y}},getDocumentElement:_,getClippingRect:function(e){let{element:i,boundary:r,rootBoundary:o,strategy:s}=e;const a=[..."clippingAncestors"===r?function(e,t){const n=t.get(e);if(n)return n;let i=D(e,[],!1).filter(e=>R(e)&&"body"!==y(e)),r=null;const o="fixed"===O(e).position;let s=o?P(e):e;for(;R(s)&&!I(s);){const t=O(s),n=A(s);n||"fixed"!==t.position||(r=null),(o?!n&&!r:!n&&"static"===t.position&&r&&["absolute","fixed"].includes(r.position)||$(s)&&!n&&Q(e,s))?i=i.filter(e=>e!==s):r=t,s=P(s)}return t.set(e,i),i}(i,this._c):[].concat(r),o],l=a.reduce((e,r)=>{const o=W(i,r,s);return e.top=n(o.top,e.top),e.right=t(o.right,e.right),e.bottom=t(o.bottom,e.bottom),e.left=n(o.left,e.left),e},W(i,a[0],s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:Y,getElementRects:async function(e){const t=this.getOffsetParent||Y,n=this.getDimensions;return{reference:K(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,...await n(e.floating)}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=F(e);return{width:t,height:n}},getScale:M,isElement:R,isRTL:function(e){return"rtl"===O(e).direction}},J=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:i,placement:r}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...d}=c(e,t),p={x:n,y:i},g=await k(t,d),b=f(u(r)),m=h(b);let w=p[m],x=p[b];o&&(w=l(w+g["y"===m?"top":"left"],w,w-g["y"===m?"bottom":"right"])),s&&(x=l(x+g["y"===b?"top":"left"],x,x-g["y"===b?"bottom":"right"]));const y=a.fn({...t,[m]:w,[b]:x});return{...y,data:{x:y.x-n,y:y.y-i}}}}},ee=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,i;const{placement:r,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:h}=t,{mainAxis:f=!0,crossAxis:w=!0,fallbackPlacements:x,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:_=!0,...E}=c(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const R=u(r),T=u(a)===a,S=await(null==l.isRTL?void 0:l.isRTL(h.floating)),$=x||(T||!_?[m(a)]:function(e){const t=m(e);return[b(e),t,b(t)]}(a));x||"none"===v||$.push(...function(e,t,n,i){const r=d(e);let o=function(e,t,n){const i=["left","right"],r=["right","left"],o=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?r:i:t?i:r;case"left":case"right":return t?o:s;default:return[]}}(u(e),"start"===n,i);return r&&(o=o.map(e=>e+"-"+r),t&&(o=o.concat(o.map(b)))),o}(a,_,v,S));const C=[a,...$],A=await k(t,E),z=[];let I=(null==(i=o.flip)?void 0:i.overflows)||[];if(f&&z.push(A[R]),w){const e=function(e,t,n){void 0===n&&(n=!1);const i=d(e),r=g(e),o=p(r);let s="x"===r?i===(n?"end":"start")?"right":"left":"start"===i?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=m(s)),[s,m(s)]}(r,s,S);z.push(A[e[0]],A[e[1]])}if(I=[...I,{placement:r,overflows:z}],!z.every(e=>e<=0)){var O,L;const e=((null==(O=o.flip)?void 0:O.index)||0)+1,t=C[e];if(t)return{data:{index:e,overflows:I},reset:{placement:t}};let n=null==(L=I.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:L.placement;if(!n)switch(y){case"bestFit":{var P;const e=null==(P=I.map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:P[0];e&&(n=e);break}case"initialPlacement":n=a}if(r!==n)return{reset:{placement:n}}}return{}}}},te=(e,t,n)=>{const i=new Map,r={platform:X,...n},o={...r.platform,_c:i};return(async(e,t,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:r}),{x:u,y:d}=x(c,i,l),h=i,p={},f=0;for(let n=0;n<a.length;n++){const{name:o,fn:g}=a[n],{x:b,y:m,data:w,reset:k}=await g({x:u,y:d,initialPlacement:i,placement:h,strategy:r,middlewareData:p,rects:c,platform:s,elements:{reference:e,floating:t}});u=null!=b?b:u,d=null!=m?m:d,p={...p,[o]:{...p[o],...w}},k&&f<=50&&(f++,"object"==typeof k&&(k.placement&&(h=k.placement),k.rects&&(c=!0===k.rects?await s.getElementRects({reference:e,floating:t,strategy:r}):k.rects),({x:u,y:d}=x(c,h,l))),n=-1)}return{x:u,y:d,placement:h,strategy:r,middlewareData:p}})(e,t,{...r,platform:o})};var ne=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],ie=/* #__PURE__ */ne.join(","),re="undefined"==typeof Element,oe=re?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,se=!re&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},ae=function e(t,n){var i;void 0===n&&(n=!0);var r=null==t||null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"inert");return""===r||"true"===r||n&&t&&e(t.parentNode)},le=function(e,t,n){if(ae(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(ie));return t&&oe.call(e,ie)&&i.unshift(e),i.filter(n)},ce=function e(t,n,i){for(var r=[],o=Array.from(t);o.length;){var s=o.shift();if(!ae(s,!1))if("SLOT"===s.tagName){var a=s.assignedElements(),l=e(a.length?a:s.children,!0,i);i.flatten?r.push.apply(r,l):r.push({scopeParent:s,candidates:l})}else{oe.call(s,ie)&&i.filter(s)&&(n||!t.includes(s))&&r.push(s);var c=s.shadowRoot||"function"==typeof i.getShadowRoot&&i.getShadowRoot(s),u=!ae(c,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(s));if(c&&u){var d=e(!0===c?s.children:c.children,!0,i);i.flatten?r.push.apply(r,d):r.push({scopeParent:s,candidates:d})}else o.unshift.apply(o,s.children)}}return r},ue=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},de=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!ue(e)?0:e.tabIndex},he=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},pe=function(e){return"INPUT"===e.tagName},fe=function(e){var t=e.getBoundingClientRect();return 0===t.width&&0===t.height},ge=function(e,t){return!(t.disabled||ae(t)||function(e){return pe(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,i=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var r=oe.call(e,"details>summary:first-of-type");if(oe.call(r?e.parentElement:e,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return fe(e)}else{if("function"==typeof i){for(var o=e;e;){var s=e.parentElement,a=se(e);if(s&&!s.shadowRoot&&!0===i(s))return fe(e);e=e.assignedSlot?e.assignedSlot:s||a===e.ownerDocument?s:a.host}e=o}if(function(e){var t,n,i,r,o=e&&se(e),s=null===(t=o)||void 0===t?void 0:t.host,a=!1;if(o&&o!==e)for(a=!!(null!==(n=s)&&void 0!==n&&null!==(i=n.ownerDocument)&&void 0!==i&&i.contains(s)||null!=e&&null!==(r=e.ownerDocument)&&void 0!==r&&r.contains(e));!a&&s;){var l,c,u;a=!(null===(c=s=null===(l=o=se(s))||void 0===l?void 0:l.host)||void 0===c||null===(u=c.ownerDocument)||void 0===u||!u.contains(s))}return a}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(e){return"SUMMARY"===e.tagName})}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var i=t.children.item(n);if("LEGEND"===i.tagName)return!!oe.call(t,"fieldset[disabled] *")||!i.contains(e)}return!0}t=t.parentElement}return!1}(t))},be=function(e,t){return!(function(e){return function(e){return pe(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||se(e),i=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=i(window.CSS.escape(e.name));else try{t=i(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var r=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!r||r===e}(e)}(t)||de(t)<0||!ge(e,t))},me=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},we=function e(t){var n=[],i=[];return t.forEach(function(t,r){var o=!!t.scopeParent,s=o?t.scopeParent:t,a=function(e,t){var n=de(e);return n<0&&t&&!ue(e)?0:n}(s,o),l=o?e(t.candidates):s;0===a?o?n.push.apply(n,l):n.push(s):i.push({documentOrder:r,tabIndex:a,item:t,isScope:o,content:l})}),i.sort(he).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(n)},xe=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==oe.call(e,ie)&&be(t,e)},ke=/* #__PURE__ */ne.concat("iframe").join(","),ye=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==oe.call(e,ke)&&ge(t,e)};function ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function _e(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ve(Object(n),!0).forEach(function(t){var i,r,o;i=e,o=n[t],(r=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(r=t))in i?Object.defineProperty(i,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):i[r]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ve(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Ee=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},Re=function(e){return Ee(e)&&!e.shiftKey},Te=function(e){return Ee(e)&&e.shiftKey},Se=function(e){return setTimeout(e,0)},$e=function(e,t){var n=-1;return e.every(function(e,i){return!t(e)||(n=i,!1)}),n},Ce=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return"function"==typeof e?e.apply(void 0,n):e},Ae=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},ze=[];let Ie={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Oe(e){Ie=e}const Le=/[&<>"']/,Pe=new RegExp(Le.source,"g"),Ne=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,De=new RegExp(Ne.source,"g"),Fe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Be=e=>Fe[e];function Me(e,t){if(t){if(Le.test(e))return e.replace(Pe,Be)}else if(Ne.test(e))return e.replace(De,Be);return e}const je=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function qe(e){return e.replace(je,(e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):"")}const Ze=/(^|[^\[])\^/g;function He(e,t){let n="string"==typeof e?e:e.source;t=t||"";const i={replace:(e,t)=>{let r="string"==typeof t?t:t.source;return r=r.replace(Ze,"$1"),n=n.replace(e,r),i},getRegex:()=>new RegExp(n,t)};return i}function Ge(e){try{e=encodeURI(e).replace(/%25/g,"%")}catch(e){return null}return e}const Ve={exec:()=>null};function We(e,t){const n=e.replace(/\|/g,(e,t,n)=>{let i=!1,r=t;for(;--r>=0&&"\\"===n[r];)i=!i;return i?"|":" |"}).split(/ \|/);let i=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(/\\\|/g,"|");return n}function Qe(e,t,n){const i=e.length;if(0===i)return"";let r=0;for(;r<i;){const o=e.charAt(i-r-1);if(o!==t||n){if(o===t||!n)break;r++}else r++}return e.slice(0,i-r)}function Ke(e,t,n,i){const r=t.href,o=t.title?Me(t.title):null,s=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){i.state.inLink=!0;const e={type:"link",raw:n,href:r,title:o,text:s,tokens:i.inlineTokens(s)};return i.state.inLink=!1,e}return{type:"image",raw:n,href:r,title:o,text:Me(s)}}class Ue{options;rules;lexer;constructor(e){this.options=e||Ie}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Qe(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const i=n[1];return t.split("\n").map(e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=i.length?e.slice(i.length):e}).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=Qe(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=Qe(t[0].replace(/^ *>[ \t]?/gm,""),"\n"),n=this.lexer.state.top;this.lexer.state.top=!0;const i=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:i,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const i=n.length>1,r={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");const o=new RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`);let s="",a="",l=!1;for(;e;){let n=!1;if(!(t=o.exec(e)))break;if(this.rules.block.hr.test(e))break;s=t[0],e=e.substring(s.length);let i=t[2].split("\n",1)[0].replace(/^\t+/,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],u=0;this.options.pedantic?(u=2,a=i.trimStart()):(u=t[2].search(/[^ ]/),u=u>4?1:u,a=i.slice(u),u+=t[1].length);let d=!1;if(!i&&/^ *$/.test(c)&&(s+=c+"\n",e=e.substring(c.length+1),n=!0),!n){const t=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),n=new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),r=new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),o=new RegExp(`^ {0,${Math.min(3,u-1)}}#`);for(;e;){const l=e.split("\n",1)[0];if(c=l,this.options.pedantic&&(c=c.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),r.test(c))break;if(o.test(c))break;if(t.test(c))break;if(n.test(e))break;if(c.search(/[^ ]/)>=u||!c.trim())a+="\n"+c.slice(u);else{if(d)break;if(i.search(/[^ ]/)>=4)break;if(r.test(i))break;if(o.test(i))break;if(n.test(i))break;a+="\n"+c}d||c.trim()||(d=!0),s+=l+"\n",e=e.substring(l.length+1),i=c.slice(u)}}r.loose||(l?r.loose=!0:/\n *\n *$/.test(s)&&(l=!0));let h,p=null;this.options.gfm&&(p=/^\[[ xX]\] /.exec(a),p&&(h="[ ] "!==p[0],a=a.replace(/^\[[ xX]\] +/,""))),r.items.push({type:"list_item",raw:s,task:!!p,checked:h,loose:!1,text:a,tokens:[]}),r.raw+=s}r.items[r.items.length-1].raw=s.trimEnd(),r.items[r.items.length-1].text=a.trimEnd(),r.raw=r.raw.trimEnd();for(let e=0;e<r.items.length;e++)if(this.lexer.state.top=!1,r.items[e].tokens=this.lexer.blockTokens(r.items[e].text,[]),!r.loose){const t=r.items[e].tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>/\n.*\n/.test(e.raw));r.loose=n}if(r.loose)for(let e=0;e<r.items.length;e++)r.items[e].loose=!0;return r}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const e=t[1].toLowerCase().replace(/\s+/g," "),n=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:i}}}table(e){const t=this.rules.block.table.exec(e);if(!t)return;if(!/[:|]/.test(t[2]))return;const n=We(t[1]),i=t[2].replace(/^\||\| *$/g,"").split("|"),r=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(const e of i)/^ *-+: *$/.test(e)?o.align.push("right"):/^ *:-+: *$/.test(e)?o.align.push("center"):/^ *:-+ *$/.test(e)?o.align.push("left"):o.align.push(null);for(const e of n)o.header.push({text:e,tokens:this.lexer.inline(e)});for(const e of r)o.rows.push(We(e,o.header.length).map(e=>({text:e,tokens:this.lexer.inline(e)})));return o}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const 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){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:Me(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.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){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;const t=Qe(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return-1}(t[2],"()");if(e>-1){const n=(0===t[0].indexOf("!")?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],i="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^</.test(n)&&(n=this.options.pedantic&&!/>$/.test(e)?n.slice(1):n.slice(1,-1)),Ke(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:i?i.replace(this.rules.inline.anyPunctuation,"$1"):i},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(/\s+/g," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Ke(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(i&&(!i[3]||!n.match(/[\p{L}\p{N}]/u))&&(!i[1]&&!i[2]||!n||this.rules.inline.punctuation.exec(n))){const n=[...i[0]].length-1;let r,o,s=n,a=0;const l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(i=l.exec(t));){if(r=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!r)continue;if(o=[...r].length,i[3]||i[4]){s+=o;continue}if((i[5]||i[6])&&n%3&&!((n+o)%3)){a+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s+a);const t=[...i[0]][0].length,l=e.slice(0,n+i.index+t+o);if(Math.min(n,o)%2){const e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}const c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),i=/^ /.test(e)&&/ $/.test(e);return n&&i&&(e=e.substring(1,e.length-1)),e=Me(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=Me(t[1]),n="mailto:"+e):(e=Me(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=Me(t[0]),n="mailto:"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==t[0]);e=Me(t[0]),n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:Me(t[0]),{type:"text",raw:t[0],text:e}}}}const Ye=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Xe=/(?:[*+-]|\d{1,9}[.)])/,Je=He(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Xe).getRegex(),et=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,tt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,nt=He(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",tt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),it=He(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Xe).getRegex(),rt="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",ot=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,st=He("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\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",ot).replace("tag",rt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),at=He(et).replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",rt).getRegex(),lt={blockquote:He(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",at).getRegex(),code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,def:nt,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:Ye,html:st,lheading:Je,list:it,newline:/^(?: *(?:\n|$))+/,paragraph:at,table:Ve,text:/^[^\n]+/},ct=He("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",rt).getRegex(),ut={...lt,table:ct,paragraph:He(et).replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ct).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",rt).getRegex()},dt={...lt,html:He("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",ot).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:Ve,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:He(et).replace("hr",Ye).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Je).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ht=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,pt=/^( {2,}|\\)\n(?!\s*$)/,ft="\\p{P}\\p{S}",gt=He(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,ft).getRegex(),bt=He(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,ft).getRegex(),mt=He("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,ft).getRegex(),wt=He("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,ft).getRegex(),xt=He(/\\([punct])/,"gu").replace(/punct/g,ft).getRegex(),kt=He(/^<(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(),yt=He(ot).replace("(?:--\x3e|$)","--\x3e").getRegex(),vt=He("^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",yt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_t=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Et=He(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",_t).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Rt=He(/^!?\[(label)\]\[(ref)\]/).replace("label",_t).replace("ref",tt).getRegex(),Tt=He(/^!?\[(ref)\](?:\[\])?/).replace("ref",tt).getRegex(),St={_backpedal:Ve,anyPunctuation:xt,autolink:kt,blockSkip:/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,br:pt,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:Ve,emStrongLDelim:bt,emStrongRDelimAst:mt,emStrongRDelimUnd:wt,escape:ht,link:Et,nolink:Tt,punctuation:gt,reflink:Rt,reflinkSearch:He("reflink|nolink(?!\\()","g").replace("reflink",Rt).replace("nolink",Tt).getRegex(),tag:vt,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:Ve},$t={...St,link:He(/^!?\[(label)\]\((.*?)\)/).replace("label",_t).getRegex(),reflink:He(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",_t).getRegex()},Ct={...St,escape:He(ht).replace("])","~|])").getRegex(),url:He(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").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~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},At={...Ct,br:He(pt).replace("{2,}","*").getRegex(),text:He(Ct.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},zt={normal:lt,gfm:ut,pedantic:dt},It={normal:St,gfm:Ct,breaks:At,pedantic:$t};class Ot{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ie,this.options.tokenizer=this.options.tokenizer||new Ue,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:zt.normal,inline:It.normal};this.options.pedantic?(t.block=zt.pedantic,t.inline=It.pedantic):this.options.gfm&&(t.block=zt.gfm,t.inline=this.options.breaks?It.breaks:It.gfm),this.tokenizer.rules=t}static get rules(){return{block:zt,inline:It}}static lex(e,t){return new Ot(t).lex(e)}static lexInline(e,t){return new Ot(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){let n,i,r,o;for(e=this.options.pedantic?e.replace(/\t/g," ").replace(/^ +$/gm,""):e.replace(/^( *)(\t+)/gm,(e,t,n)=>t+" ".repeat(n.length));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),i=t[t.length-1],!i||"paragraph"!==i.type&&"text"!==i.type?t.push(n):(i.raw+="\n"+n.raw,i.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),i=t[t.length-1],!i||"paragraph"!==i.type&&"text"!==i.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(i.raw+="\n"+n.raw,i.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(r=e,this.options.extensions&&this.options.extensions.startBlock){let t=Infinity;const n=e.slice(1);let i;this.options.extensions.startBlock.forEach(e=>{i=e.call({lexer:this},n),"number"==typeof i&&i>=0&&(t=Math.min(t,i))}),t<Infinity&&t>=0&&(r=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(r)))i=t[t.length-1],o&&"paragraph"===i.type?(i.raw+="\n"+n.raw,i.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(n),o=r.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),i=t[t.length-1],i&&"text"===i.type?(i.raw+="\n"+n.raw,i.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,i,r,o,s,a,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(o=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(o=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(o=this.tokenizer.rules.inline.anyPunctuation.exec(l));)l=l.slice(0,o.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(s||(a=""),s=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),i=t[t.length-1],i&&"text"===n.type&&"text"===i.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),i=t[t.length-1],i&&"text"===n.type&&"text"===i.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,l,a))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e))){if(r=e,this.options.extensions&&this.options.extensions.startInline){let t=Infinity;const n=e.slice(1);let i;this.options.extensions.startInline.forEach(e=>{i=e.call({lexer:this},n),"number"==typeof i&&i>=0&&(t=Math.min(t,i))}),t<Infinity&&t>=0&&(r=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(r))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(a=n.raw.slice(-1)),s=!0,i=t[t.length-1],i&&"text"===i.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class Lt{options;constructor(e){this.options=e||Ie}code(e,t,n){const i=(t||"").match(/^\S*/)?.[0];return e=e.replace(/\n$/,"")+"\n",i?'<pre><code class="language-'+Me(i)+'">'+(n?e:Me(e,!0))+"</code></pre>\n":"<pre><code>"+(n?e:Me(e,!0))+"</code></pre>\n"}blockquote(e){return`<blockquote>\n${e}</blockquote>\n`}html(e,t){return e}heading(e,t,n){return`<h${t}>${e}</h${t}>\n`}hr(){return"<hr>\n"}list(e,t,n){const i=t?"ol":"ul";return"<"+i+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"</"+i+">\n"}listitem(e,t,n){return`<li>${e}</li>\n`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph(e){return`<p>${e}</p>\n`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),"<table>\n<thead>\n"+e+"</thead>\n"+t+"</table>\n"}tablerow(e){return`<tr>\n${e}</tr>\n`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,n){const i=Ge(e);if(null===i)return n;let r='<a href="'+(e=i)+'"';return t&&(r+=' title="'+t+'"'),r+=">"+n+"</a>",r}image(e,t,n){const i=Ge(e);if(null===i)return n;let r=`<img src="${e=i}" alt="${n}"`;return t&&(r+=` title="${t}"`),r+=">",r}text(e){return e}}class Pt{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class Nt{options;renderer;textRenderer;constructor(e){this.options=e||Ie,this.options.renderer=this.options.renderer||new Lt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Pt}static parse(e,t){return new Nt(t).parse(e)}static parseInline(e,t){return new Nt(t).parseInline(e)}parse(e,t=!0){let n="";for(let i=0;i<e.length;i++){const r=e[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const e=r,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==t||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(e.type)){n+=t||"";continue}}switch(r.type){case"space":continue;case"hr":n+=this.renderer.hr();continue;case"heading":{const e=r;n+=this.renderer.heading(this.parseInline(e.tokens),e.depth,qe(this.parseInline(e.tokens,this.textRenderer)));continue}case"code":n+=this.renderer.code(r.text,r.lang,!!r.escaped);continue;case"table":{const e=r;let t="",i="";for(let t=0;t<e.header.length;t++)i+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(i);let o="";for(let t=0;t<e.rows.length;t++){const n=e.rows[t];i="";for(let t=0;t<n.length;t++)i+=this.renderer.tablecell(this.parseInline(n[t].tokens),{header:!1,align:e.align[t]});o+=this.renderer.tablerow(i)}n+=this.renderer.table(t,o);continue}case"blockquote":{const e=this.parse(r.tokens);n+=this.renderer.blockquote(e);continue}case"list":{const e=r,t=e.ordered,i=e.start,o=e.loose;let s="";for(let t=0;t<e.items.length;t++){const n=e.items[t],i=n.checked,r=n.task;let a="";if(n.task){const e=this.renderer.checkbox(!!i);o?n.tokens.length>0&&"paragraph"===n.tokens[0].type?(n.tokens[0].text=e+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&"text"===n.tokens[0].tokens[0].type&&(n.tokens[0].tokens[0].text=e+" "+n.tokens[0].tokens[0].text)):n.tokens.unshift({type:"text",text:e+" "}):a+=e+" "}a+=this.parse(n.tokens,o),s+=this.renderer.listitem(a,r,!!i)}n+=this.renderer.list(s,t,i);continue}case"html":n+=this.renderer.html(r.text,r.block);continue;case"paragraph":n+=this.renderer.paragraph(this.parseInline(r.tokens));continue;case"text":{let o=r,s=o.tokens?this.parseInline(o.tokens):o.text;for(;i+1<e.length&&"text"===e[i+1].type;)o=e[++i],s+="\n"+(o.tokens?this.parseInline(o.tokens):o.text);n+=t?this.renderer.paragraph(s):s;continue}default:{const e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}parseInline(e,t){t=t||this.renderer;let n="";for(let i=0;i<e.length;i++){const r=e[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const e=this.options.extensions.renderers[r.type].call({parser:this},r);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type)){n+=e||"";continue}}switch(r.type){case"escape":case"text":n+=t.text(r.text);break;case"html":n+=t.html(r.text);break;case"link":n+=t.link(r.href,r.title,this.parseInline(r.tokens,t));break;case"image":n+=t.image(r.href,r.title,r.text);break;case"strong":n+=t.strong(this.parseInline(r.tokens,t));break;case"em":n+=t.em(this.parseInline(r.tokens,t));break;case"codespan":n+=t.codespan(r.text);break;case"br":n+=t.br();break;case"del":n+=t.del(this.parseInline(r.tokens,t));break;default:{const e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}}class Dt{options;constructor(e){this.options=e||Ie}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}const Ft=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.#e(Ot.lex,Nt.parse);parseInline=this.#e(Ot.lexInline,Nt.parseInline);Parser=Nt;Renderer=Lt;TextRenderer=Pt;Lexer=Ot;Tokenizer=Ue;Hooks=Dt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(const i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{const e=i;for(const i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(const i of e.rows)for(const e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":n=n.concat(this.walkTokens(i.items,t));break;default:{const e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{const r=e[i].flat(Infinity);n=n.concat(this.walkTokens(r,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.star