@maggioli-rd/aicore-agent-chat 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aicore-agent-chat.js +1 -1
- package/dist/aicore-agent-chat.js.map +1 -1
- package/dist/chunks/{core-Bv-wH5q-.js → core-CdSjbHFC.js} +2 -2
- package/dist/chunks/core-CdSjbHFC.js.map +1 -0
- package/dist/chunks/{src-B6Ho1bEF.js → src-CfPZVl62.js} +2 -2
- package/dist/chunks/{src-B6Ho1bEF.js.map → src-CfPZVl62.js.map} +1 -1
- package/dist/core.js +1 -1
- package/dist/define.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/core-Bv-wH5q-.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var t=class extends Error{status;kind;errorCode;requestId;retryAfter;authDescription;constructor(e,t){super(e.message||`HTTP ${e.status}`),this.name=`AicoreError`,this.status=e.status,this.errorCode=e.errorCode,this.requestId=e.requestId,this.retryAfter=e.retryAfter,this.authDescription=e.authDescription,this.kind=t??r(e)}},n=/* @__PURE__ */ new Set([`tenant_required`,`tenant_not_allowed`,`tenant_not_registered`]);function r({status:e,errorCode:t}){return e===0?`network`:t&&n.has(t)?`tenant_refused`:e===401?`auth_required`:e===403?`forbidden`:e===404?`not_found`:e===409?`busy`:e===423?`locked`:e===429?`rate_limited`:`http`}function i(e){return e instanceof t?e:new t({status:0,message:String(e)})}function a(e,t){return e instanceof DOMException&&e.name===`AbortError`||t?.aborted===!0}function o(e){if(!e)return{};let t=t=>RegExp(`${t}="([^"]*)"`).exec(e)?.[1];return{error:t(`error`),description:t(`error_description`)}}function s(e){return e.status===401&&o(e.headers.get(`WWW-Authenticate`)).error===`invalid_token`}async function c(n){let r=n.headers.get(`Retry-After`)?.trim(),i={status:n.status,message:``,requestId:n.headers.get(`X-Request-Id`)??void 0,retryAfter:r&&/^\d+$/.test(r)?Number(r):void 0,authDescription:o(n.headers.get(`WWW-Authenticate`)).description};try{let t=await n.json();if(e(t)){let e=[];typeof t.message==`string`&&t.message&&e.push(t.message),typeof t.detail==`string`&&t.detail&&e.push(t.detail),i.message=[...new Set(e)].join(`: `),typeof t.error_code==`string`&&(i.errorCode=t.error_code),typeof t.request_id==`string`&&(i.requestId=t.request_id)}}catch{}return new t(i)}var l=class{#e=``;#t=``;#n=[];#r;#i=!1;push(e){let t=e;this.#i&&t.startsWith(`
|
|
2
2
|
`)&&(t=t.slice(1)),this.#i=!1,this.#e+=t;let n=[],r=/\r\n|\r|\n/g,i=0,a;for(;(a=r.exec(this.#e))!==null;){if(a[0]===`\r`&&a.index===this.#e.length-1){this.#i=!0;let e=this.#a(this.#e.slice(i,a.index));e&&n.push(e),i=this.#e.length;break}let e=this.#a(this.#e.slice(i,a.index));e&&n.push(e),i=a.index+a[0].length}return this.#e=this.#e.slice(i),n}end(){this.#e=``,this.#s()}#a(e){if(e===``)return this.#o();if(e.startsWith(`:`))return null;let t=e.indexOf(`:`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``;return r.startsWith(` `)&&(r=r.slice(1)),n===`event`?this.#t=r:n===`data`?this.#n.push(r):n===`id`&&!r.includes(`\0`)&&(this.#r=r),null}#o(){if(this.#n.length===0&&this.#t===``)return this.#s(),null;let e={event:this.#t||`message`,data:this.#n.join(`
|
|
3
3
|
`)};return this.#r!==void 0&&(e.id=this.#r),this.#s(),e}#s(){this.#t=``,this.#n=[],this.#r=void 0}};async function*u(e){let t=e.getReader(),n=new TextDecoder,r=new l;try{for(;;){let{done:e,value:i}=await t.read(),a=e?n.decode():n.decode(i,{stream:!0});if(yield*r.push(a),e)break}r.end()}finally{await t.cancel().catch(()=>t.releaseLock())}}function d(e){try{return e.data?JSON.parse(e.data):{}}catch{return{raw:e.data}}}var f=3e4;function p(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}function m(t){let n=t.split(`.`)[1];if(!n)return null;try{let t=JSON.parse(p(n));return e(t)?t:null}catch{return null}}function h(e){let t=m(e)?.exp;return typeof t==`number`?t*1e3:null}var g=class{#e;#t;#n=null;#r=0;#i=null;#a=!1;#o=0;constructor(e,t=Date.now){this.#e=e,this.#t=t}get(){return this.#n&&this.#t()<this.#r-3e4?Promise.resolve(this.#n):this.#s(!1)}refresh(){return this.#n=null,this.#r=0,this.#s(!0)}clear(){this.#n=null,this.#r=0,this.#i=null,this.#a=!1,this.#o++}#s(e){if(this.#i&&(this.#a||!e))return this.#i;let n=++this.#o,r=Promise.resolve().then(()=>this.#e({retry:e})).then(e=>{if(!e)throw new t({status:401,message:`No token available for the user`},`auth_required`);return n===this.#o&&(this.#n=e,this.#r=h(e)??0),e}).finally(()=>{this.#i===r&&(this.#i=null,this.#a=!1)});return this.#i=r,this.#a=e,r}},_={text:``,result:null,sources:[],activity:null,title:null,error:null,finished:!1},ee=t=>e(t)?t:{};function v(e,t,n){let r=ee(n),i=e=>{let t=r[e];return typeof t==`string`&&t?t:void 0};switch(t){case`token`:return typeof r.text==`string`?{...e,text:e.text+r.text}:e;case`truncate`:return{...e,text:``};case`result`:return{...e,result:r.payload??null};case`context`:return{...e,sources:Array.isArray(r.context)?r.context:[]};case`title`:return{...e,title:i(`title`)??e.title};case`nop`:return i(`message`)?{...e,activity:i(`message`)}:e;case`error`:{let t=i(`error_code`),n=i(`detail`),a=i(`trace_id`);return{...e,error:{code:typeof r.code==`number`?r.code:500,...i(`message`)?{message:i(`message`)}:{},...t?{errorCode:t}:{},...n?{detail:n}:{},...a?{traceId:a}:{}}}}case`done`:return{...e,finished:!0,activity:null};default:return e}}function y({text:e,result:t}){return e||t==null?e:typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===1&&`text`in t&&typeof t.text==`string`?t.text:"```json\n"+JSON.stringify(t,null,2)+"\n```"}function b({message:e,detail:t,traceId:n},r={}){let{failed:i=`The agent could not answer.`,trace:a=e=>`Trace ${e}`}=r,o=[e??i];return t&&o.push(t),n&&!e?.includes(n)&&o.push(a(n)),o.join(`
|
|
4
|
-
`)}var x={conversation:`aicore-conversation`,turn:`aicore-turn`,error:`aicore-error`,authRequired:`aicore-auth-required`,tenantRefused:`aicore-tenant-refused`},S=3,te=1e3;function ne(e){let t=e.trim().replace(/\/+$/,``);return t.endsWith(`/api/v1`)?t:`${t}/api/v1`}function re(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var C=e=>e instanceof t&&(e.status===0||e.status>=502);function w(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})})}var ie=class extends EventTarget{apiBase;tenant;#e;#t;#n;#r;#i;#a=null;constructor(e){super(),this.apiBase=ne(e.baseUrl),this.tenant=e.tenant??null,this.#e=new g(e.getToken),this.#t=e.fetch??globalThis.fetch.bind(globalThis),this.#n=e.onRequest,this.#r=e.onIdentityChange}clearToken(){this.#e.clear()}async checkIdentity(){try{await this.#l(!1)}catch{}}#o(e,t,n){let r=new Headers({Accept:t.accept??`application/json`,Authorization:`Bearer ${e}`});return this.tenant&&r.set(`X-Tenant`,this.tenant),t.body!==void 0&&r.set(`Content-Type`,`application/json`),n&&r.set(`Idempotency-Key`,n),t.lastEventId&&r.set(`Last-Event-ID`,t.lastEventId),{method:t.method??`GET`,headers:r,body:t.form??(t.body===void 0?void 0:JSON.stringify(t.body)),credentials:`omit`,cache:`no-store`,signal:t.signal}}async#s(e,n,r){let i=performance.now(),o;try{o=await this.#t(this.apiBase+e,n)}catch(o){throw a(o,n.signal??void 0)?o:(this.#c(n,e,0,i,r),new t({status:0,message:`AI-CORE unreachable`}))}return this.#c(n,e,o.status,i,r,o),o}#c(e,t,n,r,i,a){this.#n?.({method:e.method??`GET`,path:t,status:n,requestId:a?.headers.get(`X-Request-Id`)??void 0,durationMs:Math.round(performance.now()-r),retriedWithFreshToken:i})}async#l(e){let n;try{n=await(e?this.#e.refresh():this.#e.get())}catch(e){throw e instanceof t?e:new t({status:0,message:`No token available: ${e instanceof Error?e.message:String(e)}`},`auth_required`)}let r=m(n)?.sub,i=typeof r==`string`&&r!==``?r:null,a=this.#i!==void 0&&(i===null||this.#i===null?n!==this.#a:i!==this.#i);return this.#i=i,this.#a=n,a&&this.#r?.(),n}async#u(e,t={}){let n=t.idempotent?re():void 0;try{let r=await this.#l(!1),i=await this.#s(e,this.#o(r,t,n),!1);if(s(i)&&(r=await this.#l(!0),i=await this.#s(e,this.#o(r,t,n),!0)),!i.ok)throw await c(i);return i}catch(e){if(a(e,t.signal))throw e;let n=i(e);throw t.report!==!1&&this.#f(n),n}}async#d(e,t){return await(await this.#u(e,t)).json()}#f(e){this.dispatchEvent(new CustomEvent(x.error,{detail:e})),e.kind===`auth_required`&&this.dispatchEvent(new CustomEvent(x.authRequired,{detail:e})),e.kind===`tenant_refused`&&this.dispatchEvent(new CustomEvent(x.tenantRefused,{detail:e}))}listAgents(e){let t=new URLSearchParams({limit:`200`});return e&&t.set(`cursor`,e),this.#d(`/agents?${t.toString()}`)}getAgent(e){return this.#d(`/agents/${encodeURIComponent(e)}`)}listConversations(e,t){let n=new URLSearchParams({id_agent:e,limit:`50`});return t&&n.set(`cursor`,t),this.#d(`/conversations?${n.toString()}`)}async openConversation(e){let t=await this.#d(`/agents/${encodeURIComponent(e)}/conversations`,{method:`POST`,idempotent:!0});return this.dispatchEvent(new CustomEvent(x.conversation,{detail:{idConv:t.id_conv,idAgent:e}})),t}async history(e){let t=[],n=null;do{let r=new URLSearchParams({limit:`
|
|
4
|
+
`)}var x={conversation:`aicore-conversation`,turn:`aicore-turn`,error:`aicore-error`,authRequired:`aicore-auth-required`,tenantRefused:`aicore-tenant-refused`},S=3,te=1e3;function ne(e){let t=e.trim().replace(/\/+$/,``);return t.endsWith(`/api/v1`)?t:`${t}/api/v1`}function re(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var C=e=>e instanceof t&&(e.status===0||e.status>=502);function w(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})})}var ie=class extends EventTarget{apiBase;tenant;#e;#t;#n;#r;#i;#a=null;constructor(e){super(),this.apiBase=ne(e.baseUrl),this.tenant=e.tenant??null,this.#e=new g(e.getToken),this.#t=e.fetch??globalThis.fetch.bind(globalThis),this.#n=e.onRequest,this.#r=e.onIdentityChange}clearToken(){this.#e.clear()}async checkIdentity(){try{await this.#l(!1)}catch{}}#o(e,t,n){let r=new Headers({Accept:t.accept??`application/json`,Authorization:`Bearer ${e}`});return this.tenant&&r.set(`X-Tenant`,this.tenant),t.body!==void 0&&r.set(`Content-Type`,`application/json`),n&&r.set(`Idempotency-Key`,n),t.lastEventId&&r.set(`Last-Event-ID`,t.lastEventId),{method:t.method??`GET`,headers:r,body:t.form??(t.body===void 0?void 0:JSON.stringify(t.body)),credentials:`omit`,cache:`no-store`,signal:t.signal}}async#s(e,n,r){let i=performance.now(),o;try{o=await this.#t(this.apiBase+e,n)}catch(o){throw a(o,n.signal??void 0)?o:(this.#c(n,e,0,i,r),new t({status:0,message:`AI-CORE unreachable`}))}return this.#c(n,e,o.status,i,r,o),o}#c(e,t,n,r,i,a){this.#n?.({method:e.method??`GET`,path:t,status:n,requestId:a?.headers.get(`X-Request-Id`)??void 0,durationMs:Math.round(performance.now()-r),retriedWithFreshToken:i})}async#l(e){let n;try{n=await(e?this.#e.refresh():this.#e.get())}catch(e){throw e instanceof t?e:new t({status:0,message:`No token available: ${e instanceof Error?e.message:String(e)}`},`auth_required`)}let r=m(n)?.sub,i=typeof r==`string`&&r!==``?r:null,a=this.#i!==void 0&&(i===null||this.#i===null?n!==this.#a:i!==this.#i);return this.#i=i,this.#a=n,a&&this.#r?.(),n}async#u(e,t={}){let n=t.idempotent?re():void 0;try{let r=await this.#l(!1),i=await this.#s(e,this.#o(r,t,n),!1);if(s(i)&&(r=await this.#l(!0),i=await this.#s(e,this.#o(r,t,n),!0)),!i.ok)throw await c(i);return i}catch(e){if(a(e,t.signal))throw e;let n=i(e);throw t.report!==!1&&this.#f(n),n}}async#d(e,t){return await(await this.#u(e,t)).json()}#f(e){this.dispatchEvent(new CustomEvent(x.error,{detail:e})),e.kind===`auth_required`&&this.dispatchEvent(new CustomEvent(x.authRequired,{detail:e})),e.kind===`tenant_refused`&&this.dispatchEvent(new CustomEvent(x.tenantRefused,{detail:e}))}listAgents(e){let t=new URLSearchParams({limit:`200`});return e&&t.set(`cursor`,e),this.#d(`/agents?${t.toString()}`)}getAgent(e){return this.#d(`/agents/${encodeURIComponent(e)}`)}listConversations(e,t){let n=new URLSearchParams({id_agent:e,limit:`50`});return t&&n.set(`cursor`,t),this.#d(`/conversations?${n.toString()}`)}async openConversation(e){let t=await this.#d(`/agents/${encodeURIComponent(e)}/conversations`,{method:`POST`,idempotent:!0});return this.dispatchEvent(new CustomEvent(x.conversation,{detail:{idConv:t.id_conv,idAgent:e}})),t}async history(e){let t=[],n=null;do{let r=new URLSearchParams({limit:`100`});n&&r.set(`cursor`,n);let i=await this.#d(`/conversations/${encodeURIComponent(e)}/messages?${r.toString()}`);t.push(...i.items),n=i.next_cursor}while(n);return t}renameConversation(e,t){return this.#d(`/conversations/${encodeURIComponent(e)}`,{method:`PATCH`,body:{title:t}})}async deleteConversation(e){await this.#u(`/conversations/${encodeURIComponent(e)}`,{method:`DELETE`})}sendMessage(e,t){return this.#d(`/conversations/${encodeURIComponent(e)}/messages`,{method:`POST`,body:t,idempotent:!0})}uploadFile(e,t){let n=new FormData;return n.append(`file`,t,t.name),this.#d(`/conversations/${encodeURIComponent(e)}/files`,{method:`POST`,form:n})}listFiles(e){return this.#d(`/conversations/${encodeURIComponent(e)}/files`)}async deleteFile(e,t){await this.#u(`/conversations/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`,{method:`DELETE`})}async sendFeedback(e,t,n,r){await this.#u(`/conversations/${encodeURIComponent(e)}/messages/${encodeURIComponent(t)}/feedback`,{method:`PUT`,body:r?{rating:n,text:r}:{rating:n}})}async*streamTurn(e,n,r){let i=`/conversations/${encodeURIComponent(e)}/stream?id_query=${encodeURIComponent(n)}`,o,s=0;for(let e=!1;;e=!0){let n=o,c=null;try{c=await this.#u(i,{signal:r,accept:`text/event-stream`,lastEventId:o,report:!1})}catch(t){if(a(t,r))return;if(!e||!C(t))throw t}if(c?.body)try{for await(let e of u(c.body))if(e.id!==void 0&&(o=e.id),yield{kind:e.event,data:d(e),id:e.id},e.event===`done`)return}catch(e){if(a(e,r))return}if(o!==n&&(s=0),++s>S)throw new t({status:0,message:`Connection lost while streaming`});if(await w(te*2**(s-1),r),r?.aborted)return}}async ask(e){let n=e.idConv??(await this.openConversation(e.idAgent)).id_conv;e.onConversation?.(n);let{id_query:r}=await this.sendMessage(n,e.request),i=_,a=!1;try{for await(let t of this.streamTurn(n,r,e.signal))i=v(i,t.kind,t.data),e.onUpdate?.(i,t)}catch(e){if(e instanceof t&&e.status===410)a=!0;else throw e instanceof t&&this.#f(e),e}return(a||i.error?.code===410)&&(i=await this.#p(n,r)),this.dispatchEvent(new CustomEvent(x.turn,{detail:{idConv:n,idQuery:r,turn:i}})),{idConv:n,idQuery:r,turn:i}}async#p(e,t){let n=(await this.history(e)).find(e=>e.role===`assistant`&&e.id_query===t);return{..._,text:n?.content??``,sources:n?.sources??[],finished:!0}}};function ae(e,t){this.v=e,this.k=t}function oe(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 se(e){if(Array.isArray(e))return e}function ce(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){if(Object(n)!==n)return;c=!1}else 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 le(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
5
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ue(e,t){return se(e)||ce(e,t)||de(e,t)||le()}function de(e,t){if(e){if(typeof e==`string`)return oe(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)?oe(e,t):void 0}}function fe(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof ae;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}fe.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},fe.prototype.next=function(e){return this._invoke(`next`,e)},fe.prototype.throw=function(e){return this._invoke(`throw`,e)},fe.prototype.return=function(e){return this._invoke(`return`,e)};var pe=Object.entries,me=Object.setPrototypeOf,he=Object.isFrozen,ge=Object.getPrototypeOf,_e=Object.getOwnPropertyDescriptor,T=Object.freeze,E=Object.seal,ve=Object.create,D=typeof Reflect<`u`&&Reflect,ye=D.apply,be=D.construct;T||=function(e){return e},E||=function(e){return e},ye||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},be||=function(e){return new e(...[...arguments].slice(1))};var xe=A(Array.prototype.forEach);Array.prototype.indexOf;var Se=A(Array.prototype.lastIndexOf),Ce=A(Array.prototype.pop),we=A(Array.prototype.push),Te=A(Array.prototype.slice),Ee=A(Array.prototype.splice),De=Array.isArray,Oe=Ue(Set),ke=A(Set.prototype.add),Ae=A(Set.prototype.has),je=A(String.prototype.toLowerCase),Me=A(String.prototype.toString),Ne=A(String.prototype.match),Pe=A(String.prototype.replace),Fe=A(String.prototype.indexOf),Ie=A(String.prototype.trim),Le=A(Number.prototype.toString),Re=A(Boolean.prototype.toString),ze=typeof BigInt>`u`?null:A(BigInt.prototype.toString),Be=typeof Symbol>`u`?null:A(Symbol.prototype.toString),O=A(Object.prototype.hasOwnProperty),Ve=A(Object.prototype.toString),k=A(RegExp.prototype.test),He=Ue(TypeError);function A(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return ye(e,t,n)}}function Ue(e){return function(){return be(e,[...arguments])}}function j(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:je;if(me&&me(e,null),!De(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(he(t)||(t[r]=e),i=e)}e[i]=!0}return e}function M(e){for(let t=0;t<e.length;t++)O(e,t)||(e[t]=null);return e}function N(e){let t=ve(null);for(let r of pe(e)){var n=ue(r,2);let i=n[0],a=n[1];O(e,i)&&(t[i]=De(a)?M(a):a&&typeof a==`object`&&a.constructor===Object?N(a):a)}return t}function We(e){switch(typeof e){case`string`:return e;case`number`:return Le(e);case`boolean`:return Re(e);case`bigint`:return ze?ze(e):`0`;case`symbol`:return Be?Be(e):`Symbol()`;case`undefined`:return Ve(e);case`function`:case`object`:{if(e===null)return Ve(e);let t=e,n=P(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Ve(e)}return Ve(e)}default:return Ve(e)}}function P(e,t){for(;e!==null;){let n=_e(e,t);if(n){if(n.get)return A(n.get);if(typeof n.value==`function`)return A(n.value)}e=ge(e)}function n(){return null}return n}function Ge(e,t){for(;e!==null;){let n=_e(e,t);if(n)return n.get?A(n.get):null;e=ge(e)}return null}function Ke(e){try{return k(e,``),!0}catch{return!1}}var qe=T(/* @__PURE__ */ `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(`.`)),Je=T(/* @__PURE__ */ `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(`.`)),Ye=T([`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`]),Xe=T([`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`]),Ze=T(/* @__PURE__ */ `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(`.`)),Qe=T([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),$e=T([`#text`]),et=T(/* @__PURE__ */ `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(`.`)),tt=T(/* @__PURE__ */ `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(`.`)),nt=T(/* @__PURE__ */ `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(`.`)),rt=T([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),it=E(/{{[\w\W]*|^[\w\W]*}}/g),at=E(/<%[\w\W]*|^[\w\W]*%>/g),ot=E(/\${[\w\W]*/g),st=E(/^data-[\-\w.\u00B7-\uFFFF]+$/),ct=E(/^aria-[\-\w]+$/),lt=E(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ut=E(/^(?:\w+script|data):/i),dt=E(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ft=E(/^html$/i),pt=E(/^[a-z][.\w]*(-[.\w]+)+$/i),mt=E(/<[/\w!]/g),ht=E(/<[/\w]/g),gt=E(/<\/no(script|embed|frames)/i),_t=E(/\/>/i),F={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},vt=T(j({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),yt=function(){return typeof window>`u`?null:window},bt=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},xt=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},St=function(e,t,n,r){return O(e,t)&&De(e[t])?j(r.base?N(r.base):{},e[t],r.transform):n},Ct=function(e,t,n){let r=O(e,t)?e[t]:void 0;return r&&typeof r==`object`?N(r):n()};function wt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yt(),t=e=>wt(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==F.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=P(d,`cloneNode`),p=P(d,`remove`),m=P(d,`removeAttributeNode`),h=P(d,`nextSibling`),g=P(d,`childNodes`),_=P(d,`parentNode`),ee=P(d,`shadowRoot`),v=P(d,`attributes`),y=o&&o.prototype?P(o.prototype,`nodeType`):null,b=o&&o.prototype?P(o.prototype,`nodeName`):null,x=o&&o.prototype?P(o.prototype,`ownerDocument`):null,S=function(e){return y?y(e):e.nodeType},te=function(e){return b?b(e):e.nodeName},ne=Ge(d,`namespaceURI`),re=function(e){return ne?ne(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let C,w=``,ie,ae=!1,oe=0,se=function(){if(oe>0)throw He(`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.`)},ce=function(e){se(),oe++;try{return C.createHTML(e)}finally{oe--}},le=function(e){se(),oe++;try{return C.createScriptURL(e)}finally{oe--}},ue=function(){return ae||=(ie=bt(u,i),!0),ie},de=n,fe=de.implementation,me=de.createNodeIterator,he=de.createDocumentFragment,ge=de.getElementsByTagName,_e=r.importNode,D=xt();t.isSupported=typeof pe==`function`&&typeof _==`function`&&fe&&fe.createHTMLDocument!==void 0;let ye=it,be=at,Le=ot,Re=st,ze=ct,Be=ut,Ve=dt,A=pt,Ue=lt,M=null,Tt=j({},[...qe,...Je,...Ye,...Ze,...$e]),I=null,L=j({},[...et,...tt,...nt,...rt]),R=Object.seal(ve(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}})),z=null,Et=null,B=Object.seal(ve(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Dt=!0,V=!0,Ot=!1,kt=!0,H=!1,U=!0,At=!1,jt=!1,Mt=null,Nt=null,Pt=!1,Ft=!1,It=!1,Lt=!1,Rt=!0,zt=!1,Bt=`user-content-`,Vt=!0,Ht=!1,Ut=null,Wt={},Gt=null,Kt=j({},/* @__PURE__ */ `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(`.`)),qt=null,Jt=j({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Yt=null,Xt=j({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Zt=`http://www.w3.org/1998/Math/MathML`,Qt=`http://www.w3.org/2000/svg`,W=`http://www.w3.org/1999/xhtml`,G=W,$t=!1,en=null,tn=j({},[Zt,Qt,W],Me),nn=T([`mi`,`mo`,`mn`,`ms`,`mtext`]),rn=j({},nn),an=T([`annotation-xml`]),on=j({},an),sn=j({},[`title`,`style`,`font`,`a`,`script`]),cn=null,ln=[`application/xhtml+xml`,`text/html`],K=null,un=null,dn=n.createElement(`form`),fn=function(e){return e instanceof RegExp||e instanceof Function},pn=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(un&&un===e)return;e&&typeof e==`object`||(e={}),e=N(e),cn=ln.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,K=cn===`application/xhtml+xml`?Me:je,M=St(e,`ALLOWED_TAGS`,Tt,{transform:K}),I=St(e,`ALLOWED_ATTR`,L,{transform:K}),en=St(e,`ALLOWED_NAMESPACES`,tn,{transform:Me}),Yt=St(e,`ADD_URI_SAFE_ATTR`,Xt,{transform:K,base:Xt}),qt=St(e,`ADD_DATA_URI_TAGS`,Jt,{transform:K,base:Jt}),Gt=St(e,`FORBID_CONTENTS`,Kt,{transform:K}),z=St(e,`FORBID_TAGS`,N({}),{transform:K}),Et=St(e,`FORBID_ATTR`,N({}),{transform:K}),Wt=O(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?N(e.USE_PROFILES):e.USE_PROFILES:!1,Dt=e.ALLOW_ARIA_ATTR!==!1,V=e.ALLOW_DATA_ATTR!==!1,Ot=e.ALLOW_UNKNOWN_PROTOCOLS||!1,kt=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=e.SAFE_FOR_TEMPLATES||!1,U=e.SAFE_FOR_XML!==!1,At=e.WHOLE_DOCUMENT||!1,Ft=e.RETURN_DOM||!1,It=e.RETURN_DOM_FRAGMENT||!1,Lt=e.RETURN_TRUSTED_TYPE||!1,Pt=e.FORCE_BODY||!1,Rt=e.SANITIZE_DOM!==!1,zt=e.SANITIZE_NAMED_PROPS||!1,Vt=e.KEEP_CONTENT!==!1,Ht=e.IN_PLACE||!1,Ue=Ke(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:lt,G=typeof e.NAMESPACE==`string`?e.NAMESPACE:W,rn=Ct(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>j({},nn)),on=Ct(e,`HTML_INTEGRATION_POINTS`,()=>j({},an));let t=Ct(e,`CUSTOM_ELEMENT_HANDLING`,()=>ve(null));if(R=ve(null),O(t,`tagNameCheck`)&&fn(t.tagNameCheck)&&(R.tagNameCheck=t.tagNameCheck),O(t,`attributeNameCheck`)&&fn(t.attributeNameCheck)&&(R.attributeNameCheck=t.attributeNameCheck),O(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(R.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),E(R),H&&(V=!1),It&&(Ft=!0),Wt&&(M=j({},$e),I=ve(null),Wt.html===!0&&(j(M,qe),j(I,et)),Wt.svg===!0&&(j(M,Je),j(I,tt),j(I,rt)),Wt.svgFilters===!0&&(j(M,Ye),j(I,tt),j(I,rt)),Wt.mathMl===!0&&(j(M,Ze),j(I,nt),j(I,rt))),B.tagCheck=null,B.attributeCheck=null,O(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?B.tagCheck=e.ADD_TAGS:De(e.ADD_TAGS)&&(M===Tt&&(M=N(M)),j(M,e.ADD_TAGS,K))),O(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?B.attributeCheck=e.ADD_ATTR:De(e.ADD_ATTR)&&(I===L&&(I=N(I)),j(I,e.ADD_ATTR,K))),O(e,`ADD_FORBID_CONTENTS`)&&De(e.ADD_FORBID_CONTENTS)&&(Gt===Kt&&(Gt=N(Gt)),j(Gt,e.ADD_FORBID_CONTENTS,K)),Vt&&(M[`#text`]=!0),At&&j(M,[`html`,`head`,`body`]),M.table&&(j(M,[`tbody`]),delete z.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw He(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw He(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=C;C=e.TRUSTED_TYPES_POLICY;try{w=ce(``)}catch(e){throw C=t,e}}else e.TRUSTED_TYPES_POLICY===null?(C=void 0,w=``):(C===void 0&&(C=ue()),C&&typeof w==`string`&&(w=ce(``)));T&&T(e),un=e},mn=j({},[...Je,...Ye,...Xe]),hn=j({},[...Ze,...Qe]),gn=function(e,t,n){return t.namespaceURI===W?e===`svg`:t.namespaceURI===Zt?e===`svg`&&(n===`annotation-xml`||rn[n]):!!mn[e]},_n=function(e,t,n){return t.namespaceURI===W?e===`math`:t.namespaceURI===Qt?e===`math`&&on[n]:!!hn[e]},vn=function(e,t,n){return t.namespaceURI===Qt&&!on[n]||t.namespaceURI===Zt&&!rn[n]?!1:!hn[e]&&(sn[e]||!mn[e])},yn=function(e){let t=re(e),n=je(te(e)),r=_(e),i,a;return r&&S(r)===F.element?(i={namespaceURI:re(r)},a=je(te(r))):(i={namespaceURI:G},a=`template`),en[t]?t===Qt?gn(n,i,a):t===Zt?_n(n,i,a):t===W?vn(n,i,a):!!(cn===`application/xhtml+xml`&&en[t]):!1},bn=function(e){we(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw He(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},xn=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Sn=function(e){En(e);let t=g(e);t&&xe(Te(t),e=>{try{p(e)}catch{}});let n=S(e)===F.element?v(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&xn(e,r,i)}},Cn=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}we(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ft||It)try{bn(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},wn=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||I[K(i)]||xn(e,r,i)}},Tn=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&S(e)===F.element){let t=ee(e);q(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},En=function(e){Tn(e,e=>{S(e)===F.element&&wn(e)})},Dn=function(e){let t=[];return Tn(e,e=>{t.push(e)},!0),t},On=function(e,t){let n=Oe();xe(Dn(e),e=>{S(e)===F.element&&ke(n,e)}),xe(t,e=>{S(e)===F.element&&!Ae(n,e)&&wn(e)})},kn=function(e,n){let r=!1;return xe(t.removed,t=>{t.element&&(r||=t.element===e,En(t.element))}),On(e,n),r},An=function(e,t){let n=Ut,r=null,i=()=>(r||(r=Oe(),xe(t,e=>{ke(r,e)})),r);for(let t=0;;t++){let r=Dn(e),a=[e],o=!1;if(xe(r,e=>{S(e)===F.documentFragment?we(a,e):!o&&!Ae(n,e)&&(o=Ae(i(),e))}),!o)return;if(t>=8)throw He(`the tree kept changing during in-place sanitization; refusing to return it`);xe(a,(t,n)=>{jn(t,n>0,e,i())})}},jn=function(e,t,n,r){let i=In(e),a;for(;a=i.nextNode();)Ae(r,a)&&!Ae(Ut,a)&&(t&&Y(D.uponSanitizeShadowNode,a,null),Kn(a,n),$n(a,n),q(a.content)&&er(a.content))},Mn=function(e){Ut&&ke(Ut,e)},Nn=function(e,t){return U?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Pn=function(e){U&&Tn(e,e=>{let t=S(e);if(t===F.processingInstruction||t===F.comment&&k(ht,e.data)){try{p(e)}catch{}return!1}if(t===F.element){let t=e,n=K(te(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Nn(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},Fn=function(e){let t=null,r=null;if(Pt)e=`<remove></remove>`+e;else{let t=Ne(e,/^[\r\n\t ]+/);r=t&&t[0]}cn===`application/xhtml+xml`&&G===W&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=C?ce(e):e;if(G===W)try{t=new l().parseFromString(i,cn)}catch{}if(!t||!t.documentElement){t=fe.createDocument(G,`template`,null);try{t.documentElement.innerHTML=$t?w:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),G===W?ge.call(t,At?`html`:`body`)[0]:At?t.documentElement:a},In=function(e){let t=x?x(e):e.ownerDocument;return me.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ln=function(e){return e=Pe(e,ye,` `),e=Pe(e,be,` `),e=Pe(e,Le,` `),e},Rn=function(e){zn(e);let t=e.querySelectorAll?.call(e,`template`);t&&xe(t,e=>{q(e.content)&&Rn(e.content)})},zn=function(e){e.normalize();let t=x?x(e):e.ownerDocument,n=me.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=Ln(r.data),r=n.nextNode()},Bn=function(e){let t=b?b(e):null;return typeof t!=`string`||K(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==g(e)},q=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===F.documentFragment}catch{return!1}},J=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Y(e,n,r){e.length!==0&&xe(e,e=>{e.call(t,n,r,un)})}let Vn=function(e,t){return!!(U&&e.hasChildNodes()&&!J(e.firstElementChild)&&k(mt,e.textContent)&&k(mt,e.innerHTML)||U&&vt[t]&&S(e)===F.element&&re(e)===W&&(J(e.firstElementChild)||typeof e.textContent==`string`&&k(mt,e.textContent))||e.nodeType===F.processingInstruction||U&&e.nodeType===F.comment&&k(ht,e.data))},Hn=function(e,t){return e instanceof RegExp?k(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Un=function(e,t,n){if(!z[t]&&Yn(t)&&Hn(R.tagNameCheck,t))return!1;if(Vt&&!Gt[t]&&!Gt[je(t)]){let t=_(e),r=g(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,h(e))}}}return bn(e),!0},Wn=function(e,t,n,r){return e.length===0?t:t===n||t===r?N(t):t},Gn=function(e,t){return e===t||_(e)!==null?!1:(Ht&&En(e),!0)},Kn=function(e,n){if(Mn(e),Y(D.beforeSanitizeElements,e,null),Gn(e,n))return!0;if(Bn(e))return bn(e),!0;let r=K(te(e));if(M=Wn(D.uponSanitizeElement,M,Tt,Mt),Y(D.uponSanitizeElement,e,{tagName:r,allowedTags:M}),Gn(e,n))return!0;if(Vn(e,r))return bn(e),!0;if(z[r]||!(B.tagCheck instanceof Function&&B.tagCheck(r))&&!M[r]){let t=Un(e,r,n);return t===!1&&(Y(D.afterSanitizeElements,e,null),Gn(e,n))?!0:t}if(S(e)===F.element&&!yn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&k(gt,e.innerHTML))return bn(e),!0;if(H&&e.nodeType===F.text){let n=Ln(e.textContent);e.textContent!==n&&(we(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Y(D.afterSanitizeElements,e,null),Gn(e,n)},qn=function(e,t,r){if(Et[t]||Nn(t,e)||Rt&&(t===`id`||t===`name`)&&(r in n||r in dn))return!1;let i=I[t]||B.attributeCheck instanceof Function&&B.attributeCheck(t,e);return V&&k(Re,t)||Dt&&k(ze,t)?!0:i?Yt[t]||k(Ue,Pe(r,Ve,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Fe(r,`data:`)===0&&qt[e]||Ot&&!k(Be,Pe(r,Ve,``))?!0:!r:Yn(e)&&Hn(R.tagNameCheck,e)&&Hn(R.attributeNameCheck,t,e)||t===`is`&&R.allowCustomizedBuiltInElements&&Hn(R.tagNameCheck,r)},Jn=j({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Yn=function(e){return!Jn[je(e)]&&k(A,e)},Xn=function(e,t,n,r){if(C&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ce(r);case`TrustedScriptURL`:return le(r)}return r},Zn=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Bn(e)||(bn(e),!1)}catch{return Cn(t,e),!1}},Qn=function(e,t){return U&&k(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:je(e)===`attributename`&&Ne(t,`href`)!==null},$n=function(e,n){if(Y(D.beforeSanitizeAttributes,e,null),Gn(e,n))return;let r=e.attributes;if(!r||Bn(e))return;I=Wn(D.uponSanitizeAttribute,I,L,Nt);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:I,forceKeepAttr:void 0},a=r.length,o=K(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=K(s),d=l,f=s===`value`?d:Ie(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Y(D.uponSanitizeAttribute,e,i),f=i.attrValue,zt&&(u===`id`||u===`name`)&&Fe(f,Bt)!==0&&(Cn(s,e,n),f=Bt+f,p=!0),Qn(s,f)?Cn(s,e,n):i.forceKeepAttr||(i.keepAttr?!kt&&k(_t,f)?Cn(s,e,n):(H&&(f=Ln(f)),qn(o,u,f)?(f=Xn(o,u,c,f),f!==d&&Zn(e,s,c,f)&&p&&Ce(t.removed)):Cn(s,e,n)):Cn(s,e,n))}Y(D.afterSanitizeAttributes,e,null),Gn(e,n)},er=function(e){let t=null,n=In(e);for(Y(D.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Y(D.uponSanitizeShadowNode,t,null),Kn(t,e),$n(t,e),q(t.content)&&er(t.content),S(t)===F.element){let e=ee(t);q(e)&&(tr(e),er(e))}H&&zn(e),Y(D.afterSanitizeShadowDOM,e,null)},tr=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){er(e.shadow);continue}let n=e.node,r=S(n)===F.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&K(e)===`template`){let e=n.content;q(e)&&t.push({node:e,shadow:null})}}if(r){let e=ee(n);q(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($t=!e,$t&&(e=`<!-->`),typeof e!=`string`&&!J(e)&&(e=We(e),typeof e!=`string`))throw He(`dirty is not a string, aborting`);if(!t.isSupported)return e;jt?(M=Mt,I=Nt):pn(n),(D.uponSanitizeElement.length>0||D.uponSanitizeAttribute.length>0)&&(M=N(M)),D.uponSanitizeAttribute.length>0&&(I=N(I)),t.removed=[];let c=Ht&&typeof e!=`string`&&J(e),l=[],u=Ut;if(c){Pn(e);let t=te(e);if(typeof t==`string`){let n=K(t);if(!M[n]||z[n])throw Sn(e),He(`root node is forbidden and cannot be sanitized in-place`)}if(Bn(e))throw Sn(e),He(`root node is clobbered and cannot be sanitized in-place`);l=Dn(e),Ut=Oe()}else if(J(e))i=Fn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===F.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),tr(i);else{if(!Ft&&!H&&!At&&e.indexOf(`<`)===-1)return C&&Lt?ce(e):e;if(i=Fn(e),!i)return Ft?null:Lt?w:``}i&&Pt&&bn(i.firstChild);let d=c?e:i;try{c&&tr(e);let t=In(d);for(;o=t.nextNode();)Kn(o,d),$n(o,d),q(o.content)&&er(o.content);c&&An(e,l)}catch(t){throw c&&(Sn(e),kn(e,l)),t}finally{Ut=u}if(c){if(kn(e,l))throw He(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return H&&Rn(e),e}if(Ft){if(H&&Rn(i),It)for(s=he.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(I.shadowroot||I.shadowrootmode)&&(s=_e.call(r,s,!0)),s}let f=At?i.outerHTML:i.innerHTML;return At&&M[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&k(ft,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
6
6
|
`+f),H&&(f=Ln(f)),C&&Lt?ce(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};pn(e),jt=!0,Mt=M,Nt=I},t.clearConfig=function(){un=null,jt=!1,Mt=null,Nt=null,C=ie,w=``},t.isValidAttribute=function(e,t,n){un||pn({});let r=K(e),i=K(t);return typeof n==`string`&&(Qn(t,n)||!kt&&k(_t,n))?!1:qn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&O(D,e)&&we(D[e],t)},t.removeHook=function(e,t){if(O(D,e)){if(t!==void 0){let n=Se(D[e],t);return n===-1?void 0:Ee(D[e],n,1)[0]}return Ce(D[e])}},t.removeHooks=function(e){O(D,e)&&(D[e]=[])},t.removeAllHooks=function(){D=xt()},t}var Tt=wt();function I(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var L=I();function R(e){L=e}var z={exec:()=>null};function Et(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 B(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(V.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Dt=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),V={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,listInterruptsParagraph:/^ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {0,3}>)([ \t]+)/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\][ \t]+\S/,listReplaceTask:/^\[[ xX]\][ \t]+/,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,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,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:Et(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Et(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Et(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Et(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:Et(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Et(e=>RegExp(`^ {0,${e}}(?:</?(?:${Bt})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:Et(e=>RegExp(`^ {0,${e}}>`)),nestedContainerMarkers:/^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/},Ot=/^(?:[ \t]*(?:\n|$))+/,kt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,H=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/,U=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,At=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,jt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Mt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/,Nt=B(Mt).replace(/bull/g,jt).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(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Pt=B(Mt).replace(/bull/g,jt).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(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ft=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,It=/^[^\n]+/,Lt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/,Rt=B(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Lt).replace(`title`,/(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex(),zt=B(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,jt).getRegex(),Bt=`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`,Vt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ht=B(`^ {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)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Vt).replace(`tag`,Bt).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ut=e=>B(Ft).replace(`hr`,U).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`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Bt).getRegex(),Wt=Ut(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Gt=Ut(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Kt={blockquote:B(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Gt).getRegex(),code:kt,def:Rt,fences:H,heading:At,hr:U,html:Ht,lheading:Nt,list:zt,newline:Ot,paragraph:Wt,table:z,text:It},qt=B(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,U).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`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Bt).getRegex(),Jt={...Kt,lheading:Pt,table:qt,paragraph:B(Ft).replace(`hr`,U).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,qt).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Bt).getRegex()},Yt={...Kt,html:B(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace(`comment`,Vt).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:z,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:B(Ft).replace(`hr`,U).replace(`heading`,` *#{1,6} *[^
|
|
7
7
|
]`).replace(`lheading`,Nt).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Xt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Zt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Qt=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,W=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,G=/[\p{P}\p{S}]/u,$t=/[\s\p{P}\p{S}]/u,en=/[^\s\p{P}\p{S}]/u,tn=B(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,$t).getRegex(),nn=/[\p{Pi}\p{Ps}"']/u,rn=/(?!~)[\p{P}\p{S}]/u,an=/(?!~)[\s\p{P}\p{S}]/u,on=/(?:[^\s\p{P}\p{S}]|~)/u,sn=B(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Dt?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),cn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ln=B(cn,`u`).replace(/punct/g,G).getRegex(),K=B(cn,`u`).replace(/punct/g,rn).getRegex(),un=B(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,nn).replace(/punct/g,G).getRegex(),dn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,fn=B(dn,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),pn=B(dn,`gu`).replace(/notPunctSpace/g,on).replace(/punctSpace/g,an).replace(/punct/g,rn).getRegex(),mn=B(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),hn=B(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),gn=B(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),_n=B(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,G).getRegex(),vn=B(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),yn=B(/\\(punct)/,`gu`).replace(/punct/g,G).getRegex(),bn=B(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,G).getRegex(),xn=B(/^<(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(),Sn=B(Vt).replace(`(?:-->|$)`,`-->`).getRegex(),Cn=B(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Sn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),wn=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Tn=B(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,wn).getRegex(),En=B(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,Tn).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex(),Dn=B(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Tn).replace(`ref`,Lt).getRegex(),On=B(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Lt).getRegex(),kn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,An=B(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,wn).getRegex(),jn=B(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,B(/^!?\[(label)\]\[(ref)\]/).replace(`label`,An).replace(`ref`,kn).getRegex()).replace(`nolink`,B(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,kn).getRegex()).getRegex(),Mn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Nn=B(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),Pn={_backpedal:z,anyPunctuation:yn,anyPunctuationOutsideCode:bn,autolink:xn,blockSkip:sn,br:Qt,code:Zt,del:z,delLDelim:z,delRDelim:z,emStrongLDelim:ln,emStrongRDelimAst:fn,emStrongRDelimUnd:hn,escape:Xt,link:En,nolink:On,punctuation:tn,reflink:Dn,reflinkSearch:jn,tag:Cn,text:W,url:z},Fn={...Pn,emStrongLDelim:un,emStrongRDelimAst:mn,emStrongRDelimUnd:gn,link:B(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Tn).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Tn).getRegex()},In={...Pn,emStrongRDelimAst:pn,emStrongLDelim:K,delLDelim:_n,delRDelim:vn,url:B(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,Nn).replace(`protocol`,Mn).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:B(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|wwwStart|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,Mn).replace(/emailProtocol/g,/(?:mailto|xmpp):/).replace(`wwwStart`,Dt?`(?<![^\\s*_~(])www\\.`:`www\\.`).getRegex()},Ln={...In,br:B(Qt).replace(`{2,}`,`*`).getRegex(),text:B(In.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Rn={normal:Kt,gfm:Jt,pedantic:Yt},zn={normal:Pn,gfm:In,breaks:Ln,pedantic:Fn},Bn={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},q=e=>Bn[e];function J(e,t){if(t){if(V.escapeTest.test(e))return e.replace(V.escapeReplace,q)}else if(V.escapeTestNoEncode.test(e))return e.replace(V.escapeReplaceNoEncode,q);return e}function Y(e){return V.numericCharacterReference.test(e)?e.replace(V.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&`:String.fromCodePoint(r)}):e}function Vn(e){try{e=encodeURI(e).replace(V.percentDecode,`%`)}catch{return null}return e}function Hn(e,t){let n=e.replace(V.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(V.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(V.slashPipe,`|`);return n}function Un(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Wn(e){let t=e.split(`
|