@liip/liipgpt 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/chat/index.html +1 -1
- package/chat/liipgpt-chat.iife.js +138 -169
- package/lib/index.d.ts +1 -0
- package/lib/liipgpt-client.d.ts +5 -29
- package/lib/liipgpt-client.js +4303 -1288
- package/lib/liipgpt-client.umd.cjs +48 -46
- package/lib/types.d.ts +434 -0
- package/package.json +1 -1
|
@@ -1,62 +1,64 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
]`).replace("lheading",
|
|
3
|
-
`).map(
|
|
4
|
-
`)}class
|
|
5
|
-
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const n=t[0],
|
|
6
|
-
`)}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let n=
|
|
1
|
+
(function(F,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):(F=typeof globalThis<"u"?globalThis:F||self,V(F.LiipGPTClient={}))})(this,function(F){"use strict";var ma=Object.defineProperty;var ga=(F,V,ze)=>V in F?ma(F,V,{enumerable:!0,configurable:!0,writable:!0,value:ze}):F[V]=ze;var O=(F,V,ze)=>ga(F,typeof V!="symbol"?V+"":V,ze);const V=new Map;class ze{get length(){return V.size}clear(){V.clear()}getItem(e){return V.get(e)||null}key(e){return Array.from(V.keys())[e]||null}removeItem(e){V.delete(e)}setItem(e,t){V.set(e,String(t))}}const vn=globalThis.localStorage??new ze;function Ut(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Oe=Ut();function _n(s){Oe=s}const Ke={exec:()=>null};function N(s,e=""){let t=typeof s=="string"?s:s.source;const n={replace:(r,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(Q.caret,"$1"),t=t.replace(r,i),n},getRegex:()=>new RegExp(t,e)};return n}const Q={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:s=>new RegExp(`^( {0,3}${s})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}#`),htmlBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}<(?:[a-z].*>|!--)`,"i")},pr=/^(?:[ \t]*(?:\n|$))+/,mr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,gr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,et=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,yr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Vt=/(?:[*+-]|\d{1,9}[.)])/,kn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,bn=N(kn).replace(/bull/g,Vt).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}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),vr=N(kn).replace(/bull/g,Vt).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}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ht=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,_r=/^[^\n]+/,Gt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,kr=N(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Gt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),br=N(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Vt).getRegex(),Et="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",Wt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xr=N("^ {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",Wt).replace("tag",Et).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xn=N(Ht).replace("hr",et).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",Et).getRegex(),Qt={blockquote:N(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xn).getRegex(),code:mr,def:kr,fences:gr,heading:yr,hr:et,html:xr,lheading:bn,list:br,newline:pr,paragraph:xn,table:Ke,text:_r},wn=N("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",et).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\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",Et).getRegex(),wr={...Qt,lheading:vr,table:wn,paragraph:N(Ht).replace("hr",et).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",wn).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",Et).getRegex()},Tr={...Qt,html:N(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Wt).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:Ke,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:N(Ht).replace("hr",et).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",bn).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Sr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Rr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Tn=/^( {2,}|\\)\n(?!\s*$)/,Er=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ct=/[\p{P}\p{S}]/u,Xt=/[\s\p{P}\p{S}]/u,Sn=/[^\s\p{P}\p{S}]/u,Cr=N(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xt).getRegex(),Rn=/(?!~)[\p{P}\p{S}]/u,Ar=/(?!~)[\s\p{P}\p{S}]/u,Ir=/(?:[^\s\p{P}\p{S}]|~)/u,$r=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,En=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Or=N(En,"u").replace(/punct/g,Ct).getRegex(),Nr=N(En,"u").replace(/punct/g,Rn).getRegex(),Cn="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Zr=N(Cn,"gu").replace(/notPunctSpace/g,Sn).replace(/punctSpace/g,Xt).replace(/punct/g,Ct).getRegex(),jr=N(Cn,"gu").replace(/notPunctSpace/g,Ir).replace(/punctSpace/g,Ar).replace(/punct/g,Rn).getRegex(),Lr=N("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Sn).replace(/punctSpace/g,Xt).replace(/punct/g,Ct).getRegex(),Dr=N(/\\(punct)/,"gu").replace(/punct/g,Ct).getRegex(),Pr=N(/^<(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(),zr=N(Wt).replace("(?:-->|$)","-->").getRegex(),Mr=N("^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",zr).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),At=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Br=N(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",At).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),An=N(/^!?\[(label)\]\[(ref)\]/).replace("label",At).replace("ref",Gt).getRegex(),In=N(/^!?\[(ref)\](?:\[\])?/).replace("ref",Gt).getRegex(),qr=N("reflink|nolink(?!\\()","g").replace("reflink",An).replace("nolink",In).getRegex(),Jt={_backpedal:Ke,anyPunctuation:Dr,autolink:Pr,blockSkip:$r,br:Tn,code:Rr,del:Ke,emStrongLDelim:Or,emStrongRDelimAst:Zr,emStrongRDelimUnd:Lr,escape:Sr,link:Br,nolink:In,punctuation:Cr,reflink:An,reflinkSearch:qr,tag:Mr,text:Er,url:Ke},Fr={...Jt,link:N(/^!?\[(label)\]\((.*?)\)/).replace("label",At).getRegex(),reflink:N(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",At).getRegex()},Yt={...Jt,emStrongRDelimAst:jr,emStrongLDelim:Nr,url:N(/^((?: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~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ur={...Yt,br:N(Tn).replace("{2,}","*").getRegex(),text:N(Yt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},It={normal:Qt,gfm:wr,pedantic:Tr},tt={normal:Jt,gfm:Yt,breaks:Ur,pedantic:Fr},Vr={"&":"&","<":"<",">":">",'"':""","'":"'"},$n=s=>Vr[s];function fe(s,e){if(e){if(Q.escapeTest.test(s))return s.replace(Q.escapeReplace,$n)}else if(Q.escapeTestNoEncode.test(s))return s.replace(Q.escapeReplaceNoEncode,$n);return s}function On(s){try{s=encodeURI(s).replace(Q.percentDecode,"%")}catch{return null}return s}function Nn(s,e){var a;const t=s.replace(Q.findPipe,(i,o,c)=>{let l=!1,u=o;for(;--u>=0&&c[u]==="\\";)l=!l;return l?"|":" |"}),n=t.split(Q.splitPipe);let r=0;if(n[0].trim()||n.shift(),n.length>0&&!((a=n.at(-1))!=null&&a.trim())&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(Q.slashPipe,"|");return n}function nt(s,e,t){const n=s.length;if(n===0)return"";let r=0;for(;r<n&&s.charAt(n-r-1)===e;)r++;return s.slice(0,n-r)}function Hr(s,e){if(s.indexOf(e[1])===-1)return-1;let t=0;for(let n=0;n<s.length;n++)if(s[n]==="\\")n++;else if(s[n]===e[0])t++;else if(s[n]===e[1]&&(t--,t<0))return n;return-1}function Zn(s,e,t,n,r){const a=e.href,i=e.title||null,o=s[1].replace(r.other.outputLinkReplace,"$1");if(s[0].charAt(0)!=="!"){n.state.inLink=!0;const c={type:"link",raw:t,href:a,title:i,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=!1,c}return{type:"image",raw:t,href:a,title:i,text:o}}function Gr(s,e,t){const n=s.match(t.other.indentCodeCompensation);if(n===null)return e;const r=n[1];return e.split(`
|
|
3
|
+
`).map(a=>{const i=a.match(t.other.beginningSpace);if(i===null)return a;const[o]=i;return o.length>=r.length?a.slice(r.length):a}).join(`
|
|
4
|
+
`)}class $t{constructor(e){O(this,"options");O(this,"rules");O(this,"lexer");this.options=e||Oe}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 n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:nt(n,`
|
|
5
|
+
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const n=t[0],r=Gr(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){const r=nt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:nt(t[0],`
|
|
6
|
+
`)}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let n=nt(t[0],`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),
|
|
9
|
-
`),
|
|
10
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");
|
|
11
|
-
${
|
|
12
|
-
${
|
|
8
|
+
`),r="",a="";const i=[];for(;n.length>0;){let o=!1;const c=[];let l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))c.push(n[l]),o=!0;else if(!o)c.push(n[l]);else break;n=n.slice(l);const u=c.join(`
|
|
9
|
+
`),f=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
10
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
11
|
+
${u}`:u,a=a?`${a}
|
|
12
|
+
${f}`:f;const v=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,i,!0),this.lexer.state.top=v,n.length===0)break;const T=i.at(-1);if((T==null?void 0:T.type)==="code")break;if((T==null?void 0:T.type)==="blockquote"){const M=T,j=M.raw+`
|
|
13
13
|
`+n.join(`
|
|
14
|
-
`),
|
|
14
|
+
`),ee=this.blockquote(j);i[i.length-1]=ee,r=r.substring(0,r.length-M.raw.length)+ee.raw,a=a.substring(0,a.length-M.text.length)+ee.text;break}else if((T==null?void 0:T.type)==="list"){const M=T,j=M.raw+`
|
|
15
15
|
`+n.join(`
|
|
16
|
-
`),
|
|
17
|
-
`);continue}}return{type:"blockquote",raw:
|
|
18
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,
|
|
19
|
-
`,1)[0],
|
|
20
|
-
`,e=e.substring(
|
|
21
|
-
`,1)[0];let
|
|
22
|
-
`+
|
|
23
|
-
`+
|
|
24
|
-
`,e=e.substring(
|
|
25
|
-
`):[],i={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===
|
|
26
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}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:t[1]}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;const i=
|
|
27
|
-
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){var
|
|
28
|
-
`:t.push(
|
|
29
|
-
`+
|
|
30
|
-
`+
|
|
31
|
-
`+
|
|
32
|
-
`+
|
|
33
|
-
`+
|
|
34
|
-
`+
|
|
35
|
-
`+
|
|
36
|
-
`+
|
|
37
|
-
`;return
|
|
38
|
-
`:"<pre><code>"+(n?
|
|
16
|
+
`),ee=this.list(j);i[i.length-1]=ee,r=r.substring(0,r.length-T.raw.length)+ee.raw,a=a.substring(0,a.length-M.raw.length)+ee.raw,n=j.substring(i.at(-1).raw.length).split(`
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:a}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const r=n.length>1,a={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const i=this.rules.other.listItemRegex(n);let o=!1;for(;e;){let l=!1,u="",f="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;u=t[0],e=e.substring(u.length);let v=t[2].split(`
|
|
18
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,bt=>" ".repeat(3*bt.length)),T=e.split(`
|
|
19
|
+
`,1)[0],M=!v.trim(),j=0;if(this.options.pedantic?(j=2,f=v.trimStart()):M?j=t[1].length+1:(j=t[2].search(this.rules.other.nonSpaceChar),j=j>4?1:j,f=v.slice(j),j+=t[1].length),M&&this.rules.other.blankLine.test(T)&&(u+=T+`
|
|
20
|
+
`,e=e.substring(T.length+1),l=!0),!l){const bt=this.rules.other.nextBulletRegex(j),te=this.rules.other.hrRegex(j),ye=this.rules.other.fencesBeginRegex(j),xt=this.rules.other.headingBeginRegex(j),Bt=this.rules.other.htmlBeginRegex(j);for(;e;){const Ge=e.split(`
|
|
21
|
+
`,1)[0];let Ae;if(T=Ge,this.options.pedantic?(T=T.replace(this.rules.other.listReplaceNesting," "),Ae=T):Ae=T.replace(this.rules.other.tabCharGlobal," "),ye.test(T)||xt.test(T)||Bt.test(T)||bt.test(T)||te.test(T))break;if(Ae.search(this.rules.other.nonSpaceChar)>=j||!T.trim())f+=`
|
|
22
|
+
`+Ae.slice(j);else{if(M||v.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ye.test(v)||xt.test(v)||te.test(v))break;f+=`
|
|
23
|
+
`+T}!M&&!T.trim()&&(M=!0),u+=Ge+`
|
|
24
|
+
`,e=e.substring(Ge.length+1),v=Ae.slice(j)}}a.loose||(o?a.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(o=!0));let ee=null,kt;this.options.gfm&&(ee=this.rules.other.listIsTask.exec(f),ee&&(kt=ee[0]!=="[ ] ",f=f.replace(this.rules.other.listReplaceTask,""))),a.items.push({type:"list_item",raw:u,task:!!ee,checked:kt,loose:!1,text:f,tokens:[]}),a.raw+=u}const c=a.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let l=0;l<a.items.length;l++)if(this.lexer.state.top=!1,a.items[l].tokens=this.lexer.blockTokens(a.items[l].text,[]),!a.loose){const u=a.items[l].tokens.filter(v=>v.type==="space"),f=u.length>0&&u.some(v=>this.rules.other.anyLine.test(v.raw));a.loose=f}if(a.loose)for(let l=0;l<a.items.length;l++)a.items[l].loose=!0;return a}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:r,title:a}}}table(e){var o;const t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;const n=Nn(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
|
+
`):[],i={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(const c of r)this.rules.other.tableAlignRight.test(c)?i.align.push("right"):this.rules.other.tableAlignCenter.test(c)?i.align.push("center"):this.rules.other.tableAlignLeft.test(c)?i.align.push("left"):i.align.push(null);for(let c=0;c<n.length;c++)i.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:i.align[c]});for(const c of a)i.rows.push(Nn(c,i.header.length).map((l,u)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[u]})));return i}}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 n=t[1].charAt(t[1].length-1)===`
|
|
26
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}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:t[1]}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;const i=nt(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{const i=Hr(t[2],"()");if(i>-1){const c=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let r=t[2],a="";if(this.options.pedantic){const i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],a=i[3])}else a=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Zn(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=t[r.toLowerCase()];if(!a){const i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return Zn(n,a,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const i=[...r[0]].length-1;let o,c,l=i,u=0;const f=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(f.lastIndex=0,t=t.slice(-1*e.length+i);(r=f.exec(t))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(c=[...o].length,r[3]||r[4]){l+=c;continue}else if((r[5]||r[6])&&i%3&&!((i+c)%3)){u+=c;continue}if(l-=c,l>0)continue;c=Math.min(c,c+l+u);const v=[...r[0]][0].length,T=e.slice(0,i+r.index+v+c);if(Math.min(i,c)%2){const j=T.slice(1,-1);return{type:"em",raw:T,text:j,tokens:this.lexer.inlineTokens(j)}}const M=T.slice(2,-2);return{type:"strong",raw:T,text:M,tokens:this.lexer.inlineTokens(M)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," ");const r=this.rules.other.nonSpaceChar.test(n),a=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&a&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}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 n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,a;if(t[2]==="@")r=t[0],a="mailto:"+r;else{let i;do i=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(i!==t[0]);r=t[0],t[1]==="www."?a="http://"+t[0]:a=t[0]}return{type:"link",raw:t[0],text:r,href:a,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){const n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}}class ie{constructor(e){O(this,"tokens");O(this,"options");O(this,"state");O(this,"tokenizer");O(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Oe,this.options.tokenizer=this.options.tokenizer||new $t,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={other:Q,block:It.normal,inline:tt.normal};this.options.pedantic?(t.block=It.pedantic,t.inline=tt.pedantic):this.options.gfm&&(t.block=It.gfm,this.options.breaks?t.inline=tt.breaks:t.inline=tt.gfm),this.tokenizer.rules=t}static get rules(){return{block:It,inline:tt}}static lex(e,t){return new ie(t).lex(e)}static lexInline(e,t){return new ie(t).inlineTokens(e)}lex(e){e=e.replace(Q.carriageReturn,`
|
|
27
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){var r,a,i;for(this.options.pedantic&&(e=e.replace(Q.tabCharGlobal," ").replace(Q.spaceLine,""));e;){let o;if((a=(r=this.options.extensions)==null?void 0:r.block)!=null&&a.some(l=>(o=l.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);const l=t.at(-1);o.raw.length===1&&l!==void 0?l.raw+=`
|
|
28
|
+
`:t.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);const l=t.at(-1);(l==null?void 0:l.type)==="paragraph"||(l==null?void 0:l.type)==="text"?(l.raw+=`
|
|
29
|
+
`+o.raw,l.text+=`
|
|
30
|
+
`+o.text,this.inlineQueue.at(-1).src=l.text):t.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length);const l=t.at(-1);(l==null?void 0:l.type)==="paragraph"||(l==null?void 0:l.type)==="text"?(l.raw+=`
|
|
31
|
+
`+o.raw,l.text+=`
|
|
32
|
+
`+o.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title});continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),t.push(o);continue}let c=e;if((i=this.options.extensions)!=null&&i.startBlock){let l=1/0;const u=e.slice(1);let f;this.options.extensions.startBlock.forEach(v=>{f=v.call({lexer:this},u),typeof f=="number"&&f>=0&&(l=Math.min(l,f))}),l<1/0&&l>=0&&(c=e.substring(0,l+1))}if(this.state.top&&(o=this.tokenizer.paragraph(c))){const l=t.at(-1);n&&(l==null?void 0:l.type)==="paragraph"?(l.raw+=`
|
|
33
|
+
`+o.raw,l.text+=`
|
|
34
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):t.push(o),n=c.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);const l=t.at(-1);(l==null?void 0:l.type)==="text"?(l.raw+=`
|
|
35
|
+
`+o.raw,l.text+=`
|
|
36
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):t.push(o);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var o,c,l;let n=e,r=null;if(this.tokens.links){const u=Object.keys(this.tokens.links);if(u.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)u.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a=!1,i="";for(;e;){a||(i=""),a=!1;let u;if((c=(o=this.options.extensions)==null?void 0:o.inline)!=null&&c.some(v=>(u=v.call({lexer:this},e,t))?(e=e.substring(u.raw.length),t.push(u),!0):!1))continue;if(u=this.tokenizer.escape(e)){e=e.substring(u.raw.length),t.push(u);continue}if(u=this.tokenizer.tag(e)){e=e.substring(u.raw.length),t.push(u);continue}if(u=this.tokenizer.link(e)){e=e.substring(u.raw.length),t.push(u);continue}if(u=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(u.raw.length);const v=t.at(-1);u.type==="text"&&(v==null?void 0:v.type)==="text"?(v.raw+=u.raw,v.text+=u.text):t.push(u);continue}if(u=this.tokenizer.emStrong(e,n,i)){e=e.substring(u.raw.length),t.push(u);continue}if(u=this.tokenizer.codespan(e)){e=e.substring(u.raw.length),t.push(u);continue}if(u=this.tokenizer.br(e)){e=e.substring(u.raw.length),t.push(u);continue}if(u=this.tokenizer.del(e)){e=e.substring(u.raw.length),t.push(u);continue}if(u=this.tokenizer.autolink(e)){e=e.substring(u.raw.length),t.push(u);continue}if(!this.state.inLink&&(u=this.tokenizer.url(e))){e=e.substring(u.raw.length),t.push(u);continue}let f=e;if((l=this.options.extensions)!=null&&l.startInline){let v=1/0;const T=e.slice(1);let M;this.options.extensions.startInline.forEach(j=>{M=j.call({lexer:this},T),typeof M=="number"&&M>=0&&(v=Math.min(v,M))}),v<1/0&&v>=0&&(f=e.substring(0,v+1))}if(u=this.tokenizer.inlineText(f)){e=e.substring(u.raw.length),u.raw.slice(-1)!=="_"&&(i=u.raw.slice(-1)),a=!0;const v=t.at(-1);(v==null?void 0:v.type)==="text"?(v.raw+=u.raw,v.text+=u.text):t.push(u);continue}if(e){const v="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(v);break}else throw new Error(v)}}return t}}class Ot{constructor(e){O(this,"options");O(this,"parser");this.options=e||Oe}space(e){return""}code({text:e,lang:t,escaped:n}){var i;const r=(i=(t||"").match(Q.notSpaceStart))==null?void 0:i[0],a=e.replace(Q.endingNewline,"")+`
|
|
37
|
+
`;return r?'<pre><code class="language-'+fe(r)+'">'+(n?a:fe(a,!0))+`</code></pre>
|
|
38
|
+
`:"<pre><code>"+(n?a:fe(a,!0))+`</code></pre>
|
|
39
39
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
40
40
|
${this.parser.parse(e)}</blockquote>
|
|
41
41
|
`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
42
42
|
`}hr(e){return`<hr>
|
|
43
|
-
`}list(e){const t=e.ordered,n=e.start;let
|
|
44
|
-
`+
|
|
45
|
-
`}listitem(e){var n;let t="";if(e.task){const
|
|
43
|
+
`}list(e){const t=e.ordered,n=e.start;let r="";for(let o=0;o<e.items.length;o++){const c=e.items[o];r+=this.listitem(c)}const a=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+a+i+`>
|
|
44
|
+
`+r+"</"+a+`>
|
|
45
|
+
`}listitem(e){var n;let t="";if(e.task){const r=this.checkbox({checked:!!e.checked});e.loose?((n=e.tokens[0])==null?void 0:n.type)==="paragraph"?(e.tokens[0].text=r+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=r+" "+fe(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):t+=r+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
|
|
46
46
|
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
47
|
-
`}table(e){let t="",n="";for(let
|
|
47
|
+
`}table(e){let t="",n="";for(let a=0;a<e.header.length;a++)n+=this.tablecell(e.header[a]);t+=this.tablerow({text:n});let r="";for(let a=0;a<e.rows.length;a++){const i=e.rows[a];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
48
48
|
<thead>
|
|
49
49
|
`+t+`</thead>
|
|
50
|
-
`+
|
|
50
|
+
`+r+`</table>
|
|
51
51
|
`}tablerow({text:e}){return`<tr>
|
|
52
52
|
${e}</tr>
|
|
53
53
|
`}tablecell(e){const t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
54
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${
|
|
55
|
-
`+this.renderer.text(
|
|
56
|
-
Please report this to https://github.com/markedjs/marked.`,e){const s="<p>An error occurred:</p><pre>"+K(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}}const ae=new kt;function $(h,e){return ae.parse(h,e)}$.options=$.setOptions=function(h){return ae.setOptions(h),$.defaults=ae.defaults,rt($.defaults),$},$.getDefaults=Ne,$.defaults=ie,$.use=function(...h){return ae.use(...h),$.defaults=ae.defaults,rt($.defaults),$},$.walkTokens=function(h,e){return ae.walkTokens(h,e)},$.parseInline=ae.parseInline,$.Parser=Q,$.parser=Q.parse,$.Renderer=ze,$.TextRenderer=Ge,$.Lexer=Z,$.lexer=Z.lex,$.Tokenizer=Le,$.Hooks=xe,$.parse=$,$.options,$.setOptions,$.use,$.walkTokens,$.parseInline,Q.parse,Z.lex;const un=h=>({extensions:[{name:"footnote",level:"inline",start(e){var t;return(t=e.match(/\[\^(\d+)\]/))==null?void 0:t.index},tokenizer(e){const n=/^\[\^(\d+)\]/.exec(e);if(n){const[s,r]=n;return{type:"footnote",raw:s,refNumber:r}}},renderer(e){if(e.type==="footnote"){const t=parseInt(e.refNumber),n=h.sources.all.find(r=>r.referenceNumber==t);n||console.error("Could not find ref with number",t);let s;return n!=null&&n.usedNumber?s=n.usedNumber:(s=h.sources.used.push(n),n.usedNumber=s),` <liipgpt-reference-number data-ref-number="${e.refNumber}" data-used-number="${s}" data-source="${JSON.stringify(n).replace(/"/g,""")}"></liipgpt-reference-number>`}}}]}),hn={hr(){return""}},bt=(h,e)=>new kt().use(un(e)).use({renderer:hn}).parse(h);var pn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ze={exports:{}};/** @license
|
|
54
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${fe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){const r=this.parser.parseInline(n),a=On(e);if(a===null)return r;e=a;let i='<a href="'+e+'"';return t&&(i+=' title="'+fe(t)+'"'),i+=">"+r+"</a>",i}image({href:e,title:t,text:n}){const r=On(e);if(r===null)return fe(n);e=r;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${fe(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:fe(e.text)}}class Kt{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}}class oe{constructor(e){O(this,"options");O(this,"renderer");O(this,"textRenderer");this.options=e||Oe,this.options.renderer=this.options.renderer||new Ot,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Kt}static parse(e,t){return new oe(t).parse(e)}static parseInline(e,t){return new oe(t).parseInline(e)}parse(e,t=!0){var r,a;let n="";for(let i=0;i<e.length;i++){const o=e[i];if((a=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&a[o.type]){const l=o,u=this.options.extensions.renderers[l.type].call({parser:this},l);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){n+=u||"";continue}}const c=o;switch(c.type){case"space":{n+=this.renderer.space(c);continue}case"hr":{n+=this.renderer.hr(c);continue}case"heading":{n+=this.renderer.heading(c);continue}case"code":{n+=this.renderer.code(c);continue}case"table":{n+=this.renderer.table(c);continue}case"blockquote":{n+=this.renderer.blockquote(c);continue}case"list":{n+=this.renderer.list(c);continue}case"html":{n+=this.renderer.html(c);continue}case"paragraph":{n+=this.renderer.paragraph(c);continue}case"text":{let l=c,u=this.renderer.text(l);for(;i+1<e.length&&e[i+1].type==="text";)l=e[++i],u+=`
|
|
55
|
+
`+this.renderer.text(l);t?n+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u,escaped:!0}]}):n+=u;continue}default:{const l='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,t=this.renderer){var r,a;let n="";for(let i=0;i<e.length;i++){const o=e[i];if((a=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&a[o.type]){const l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){n+=l||"";continue}}const c=o;switch(c.type){case"escape":{n+=t.text(c);break}case"html":{n+=t.html(c);break}case"link":{n+=t.link(c);break}case"image":{n+=t.image(c);break}case"strong":{n+=t.strong(c);break}case"em":{n+=t.em(c);break}case"codespan":{n+=t.codespan(c);break}case"br":{n+=t.br(c);break}case"del":{n+=t.del(c);break}case"text":{n+=t.text(c);break}default:{const l='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}}class rt{constructor(e){O(this,"options");O(this,"block");this.options=e||Oe}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?ie.lex:ie.lexInline}provideParser(){return this.block?oe.parse:oe.parseInline}}O(rt,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class jn{constructor(...e){O(this,"defaults",Ut());O(this,"options",this.setOptions);O(this,"parse",this.parseMarkdown(!0));O(this,"parseInline",this.parseMarkdown(!1));O(this,"Parser",oe);O(this,"Renderer",Ot);O(this,"TextRenderer",Kt);O(this,"Lexer",ie);O(this,"Tokenizer",$t);O(this,"Hooks",rt);this.use(...e)}walkTokens(e,t){var r,a;let n=[];for(const i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{const o=i;for(const c of o.header)n=n.concat(this.walkTokens(c.tokens,t));for(const c of o.rows)for(const l of c)n=n.concat(this.walkTokens(l.tokens,t));break}case"list":{const o=i;n=n.concat(this.walkTokens(o.items,t));break}default:{const o=i;(a=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&a[o.type]?this.defaults.extensions.childTokens[o.type].forEach(c=>{const l=o[c].flat(1/0);n=n.concat(this.walkTokens(l,t))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const i=t.renderers[a.name];i?t.renderers[a.name]=function(...o){let c=a.renderer.apply(this,o);return c===!1&&(c=i.apply(this,o)),c}:t.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=t[a.level];i?i.unshift(a.tokenizer):t[a.level]=[a.tokenizer],a.start&&(a.level==="block"?t.startBlock?t.startBlock.push(a.start):t.startBlock=[a.start]:a.level==="inline"&&(t.startInline?t.startInline.push(a.start):t.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(t.childTokens[a.name]=a.childTokens)}),r.extensions=t),n.renderer){const a=this.defaults.renderer||new Ot(this.defaults);for(const i in n.renderer){if(!(i in a))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const o=i,c=n.renderer[o],l=a[o];a[o]=(...u)=>{let f=c.apply(a,u);return f===!1&&(f=l.apply(a,u)),f||""}}r.renderer=a}if(n.tokenizer){const a=this.defaults.tokenizer||new $t(this.defaults);for(const i in n.tokenizer){if(!(i in a))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const o=i,c=n.tokenizer[o],l=a[o];a[o]=(...u)=>{let f=c.apply(a,u);return f===!1&&(f=l.apply(a,u)),f}}r.tokenizer=a}if(n.hooks){const a=this.defaults.hooks||new rt;for(const i in n.hooks){if(!(i in a))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const o=i,c=n.hooks[o],l=a[o];rt.passThroughHooks.has(i)?a[o]=u=>{if(this.defaults.async)return Promise.resolve(c.call(a,u)).then(v=>l.call(a,v));const f=c.call(a,u);return l.call(a,f)}:a[o]=(...u)=>{let f=c.apply(a,u);return f===!1&&(f=l.apply(a,u)),f}}r.hooks=a}if(n.walkTokens){const a=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(o){let c=[];return c.push(i.call(this,o)),a&&(c=c.concat(a.call(this,o))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ie.lex(e,t??this.defaults)}parser(e,t){return oe.parse(e,t??this.defaults)}parseMarkdown(e){return(n,r)=>{const a={...r},i={...this.defaults,...a},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&a.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=e);const c=i.hooks?i.hooks.provideLexer():e?ie.lex:ie.lexInline,l=i.hooks?i.hooks.provideParser():e?oe.parse:oe.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then(u=>c(u,i)).then(u=>i.hooks?i.hooks.processAllTokens(u):u).then(u=>i.walkTokens?Promise.all(this.walkTokens(u,i.walkTokens)).then(()=>u):u).then(u=>l(u,i)).then(u=>i.hooks?i.hooks.postprocess(u):u).catch(o);try{i.hooks&&(n=i.hooks.preprocess(n));let u=c(n,i);i.hooks&&(u=i.hooks.processAllTokens(u)),i.walkTokens&&this.walkTokens(u,i.walkTokens);let f=l(u,i);return i.hooks&&(f=i.hooks.postprocess(f)),f}catch(u){return o(u)}}}onError(e,t){return n=>{if(n.message+=`
|
|
56
|
+
Please report this to https://github.com/markedjs/marked.`,e){const r="<p>An error occurred:</p><pre>"+fe(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}}const Ne=new jn;function D(s,e){return Ne.parse(s,e)}D.options=D.setOptions=function(s){return Ne.setOptions(s),D.defaults=Ne.defaults,_n(D.defaults),D},D.getDefaults=Ut,D.defaults=Oe,D.use=function(...s){return Ne.use(...s),D.defaults=Ne.defaults,_n(D.defaults),D},D.walkTokens=function(s,e){return Ne.walkTokens(s,e)},D.parseInline=Ne.parseInline,D.Parser=oe,D.parser=oe.parse,D.Renderer=Ot,D.TextRenderer=Kt,D.Lexer=ie,D.lexer=ie.lex,D.Tokenizer=$t,D.Hooks=rt,D.parse=D,D.options,D.setOptions,D.use,D.walkTokens,D.parseInline,oe.parse,ie.lex;const Wr=s=>({extensions:[{name:"footnote",level:"inline",start(e){var t;return(t=e.match(/\[\^(\d+)\]/))==null?void 0:t.index},tokenizer(e){const n=/^\[\^(\d+)\]/.exec(e);if(n){const[r,a]=n;return{type:"footnote",raw:r,refNumber:a}}},renderer(e){if(e.type==="footnote"){const t=parseInt(e.refNumber),n=s.sources.all.find(a=>a.referenceNumber==t);n||console.error("Could not find ref with number",t);let r;return n!=null&&n.usedNumber?r=n.usedNumber:(r=s.sources.used.push(n),n.usedNumber=r),` <liipgpt-reference-number data-ref-number="${e.refNumber}" data-used-number="${r}" data-source="${JSON.stringify(n).replace(/"/g,""")}"></liipgpt-reference-number>`}}}]}),Qr={hr(){return""}},Ln=(s,e)=>new jn().use(Wr(e)).use({renderer:Qr}).parse(s);var I;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(I||(I={}));var en;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(en||(en={}));const y=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ve=s=>{switch(typeof s){case"undefined":return y.undefined;case"string":return y.string;case"number":return isNaN(s)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(s)?y.array:s===null?y.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?y.promise:typeof Map<"u"&&s instanceof Map?y.map:typeof Set<"u"&&s instanceof Set?y.set:typeof Date<"u"&&s instanceof Date?y.date:y.object;default:return y.unknown}},h=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Xr=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class ne extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},n={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return r(this),n}static assert(e){if(!(e instanceof ne))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}ne.create=s=>new ne(s);const Me=(s,e)=>{let t;switch(s.code){case h.invalid_type:s.received===y.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,I.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${I.joinValues(s.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${I.joinValues(s.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${I.joinValues(s.options)}, received '${s.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:I.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case h.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case h.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,I.assertNever(s)}return{message:t}};let Dn=Me;function Jr(s){Dn=s}function Nt(){return Dn}const Zt=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}},Yr=[];function p(s,e){const t=Nt(),n=Zt({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===Me?void 0:Me].filter(r=>!!r)});s.common.issues.push(n)}class W{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if(r.status==="aborted")return w;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t){const a=await r.key,i=await r.value;n.push({key:a,value:i})}return W.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return w;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const w=Object.freeze({status:"aborted"}),Be=s=>({status:"dirty",value:s}),X=s=>({status:"valid",value:s}),tn=s=>s.status==="aborted",nn=s=>s.status==="dirty",Ze=s=>s.status==="valid",st=s=>typeof Promise<"u"&&s instanceof Promise;function jt(s,e,t,n){if(typeof e=="function"?s!==e||!0:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(s)}function Pn(s,e,t,n,r){if(typeof e=="function"?s!==e||!0:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}typeof SuppressedError=="function"&&SuppressedError;var _;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(_||(_={}));var at,it;class pe{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const zn=(s,e)=>{if(Ze(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ne(s.common.issues);return this._error=t,this._error}}};function E(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{var c,l;const{message:u}=s;return i.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:(c=u??n)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(l=u??t)!==null&&l!==void 0?l:o.defaultError}},description:r}}class C{get description(){return this._def.description}_getType(e){return ve(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ve(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new W,ctx:{common:e.parent.common,data:e.data,parsedType:ve(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(st(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ve(e)},a=this._parseSync({data:e,path:r.path,parent:r});return zn(r,a)}"~validate"(e){var t,n;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ve(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:r});return Ze(a)?{value:a.value}:{issues:r.common.issues}}catch(a){!((n=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(a=>Ze(a)?{value:a.value}:{issues:r.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ve(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(st(r)?r:Promise.resolve(r));return zn(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:h.custom,...n(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new ue({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return ge.create(this,this._def)}nullable(){return Ce.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ce.create(this)}promise(){return Ve.create(this,this._def)}or(e){return ut.create([this,e],this._def)}and(e){return dt.create(this,e,this._def)}transform(e){return new ue({...E(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new gt({...E(this._def),innerType:this,defaultValue:t,typeName:x.ZodDefault})}brand(){return new an({typeName:x.ZodBranded,type:this,...E(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new yt({...E(this._def),innerType:this,catchValue:t,typeName:x.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return vt.create(this,e)}readonly(){return _t.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Kr=/^c[^\s-]{8,}$/i,es=/^[0-9a-z]+$/,ts=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ns=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,rs=/^[a-z0-9_-]{21}$/i,ss=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,as=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,is=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,os="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let rn;const ls=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,us=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ds=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,hs=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,fs=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ps=new RegExp(`^${Mn}$`);function Bn(s){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`),e}function ms(s){return new RegExp(`^${Bn(s)}$`)}function qn(s){let e=`${Mn}T${Bn(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function gs(s,e){return!!((e==="v4"||!e)&&ls.test(s)||(e==="v6"||!e)&&us.test(s))}function ys(s,e){if(!ss.test(s))return!1;try{const[t]=s.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(n));return!(typeof r!="object"||r===null||!r.typ||!r.alg||e&&r.alg!==e)}catch{return!1}}function vs(s,e){return!!((e==="v4"||!e)&&cs.test(s)||(e==="v6"||!e)&&ds.test(s))}class le extends C{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const a=this._getOrReturnCtx(e);return p(a,{code:h.invalid_type,expected:y.string,received:a.parsedType}),w}const n=new W;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?p(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&p(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")is.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"email",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")rn||(rn=new RegExp(os,"u")),rn.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"emoji",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")ns.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"uuid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")rs.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"nanoid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Kr.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"cuid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")es.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"cuid2",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ts.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"ulid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),p(r,{validation:"url",code:h.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"regex",code:h.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?qn(a).test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?ps.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?ms(a).test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?as.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"duration",code:h.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?gs(e.data,a.version)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"ip",code:h.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?ys(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"jwt",code:h.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?vs(e.data,a.version)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"cidr",code:h.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?hs.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"base64",code:h.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?fs.test(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{validation:"base64url",code:h.invalid_string,message:a.message}),n.dirty()):I.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:h.invalid_string,..._.errToObj(n)})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",..._.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",..._.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",..._.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,..._.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,..._.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",..._.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,..._.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,..._.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,..._.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,..._.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,..._.errToObj(t)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new le({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}le.create=s=>{var e;return new le({checks:[],typeName:x.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...E(s)})};function _s(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=parseInt(s.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}class Se extends C{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){const a=this._getOrReturnCtx(e);return p(a,{code:h.invalid_type,expected:y.number,received:a.parsedType}),w}let n;const r=new W;for(const a of this._def.checks)a.kind==="int"?I.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?_s(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),p(n,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:h.not_finite,message:a.message}),r.dirty()):I.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,n,r){return new Se({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:_.toString(r)}]})}_addCheck(e){return new Se({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&I.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Se.create=s=>new Se({checks:[],typeName:x.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...E(s)});class Re extends C{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let n;const r=new W;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),p(n,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):I.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return p(t,{code:h.invalid_type,expected:y.bigint,received:t.parsedType}),w}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,n,r){return new Re({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:_.toString(r)}]})}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Re.create=s=>{var e;return new Re({checks:[],typeName:x.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...E(s)})};class ot extends C{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const n=this._getOrReturnCtx(e);return p(n,{code:h.invalid_type,expected:y.boolean,received:n.parsedType}),w}return X(e.data)}}ot.create=s=>new ot({typeName:x.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...E(s)});class je extends C{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const a=this._getOrReturnCtx(e);return p(a,{code:h.invalid_type,expected:y.date,received:a.parsedType}),w}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return p(a,{code:h.invalid_date}),w}const n=new W;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):I.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new je({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}je.create=s=>new je({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:x.ZodDate,...E(s)});class Lt extends C{_parse(e){if(this._getType(e)!==y.symbol){const n=this._getOrReturnCtx(e);return p(n,{code:h.invalid_type,expected:y.symbol,received:n.parsedType}),w}return X(e.data)}}Lt.create=s=>new Lt({typeName:x.ZodSymbol,...E(s)});class lt extends C{_parse(e){if(this._getType(e)!==y.undefined){const n=this._getOrReturnCtx(e);return p(n,{code:h.invalid_type,expected:y.undefined,received:n.parsedType}),w}return X(e.data)}}lt.create=s=>new lt({typeName:x.ZodUndefined,...E(s)});class ct extends C{_parse(e){if(this._getType(e)!==y.null){const n=this._getOrReturnCtx(e);return p(n,{code:h.invalid_type,expected:y.null,received:n.parsedType}),w}return X(e.data)}}ct.create=s=>new ct({typeName:x.ZodNull,...E(s)});class qe extends C{constructor(){super(...arguments),this._any=!0}_parse(e){return X(e.data)}}qe.create=s=>new qe({typeName:x.ZodAny,...E(s)});class Le extends C{constructor(){super(...arguments),this._unknown=!0}_parse(e){return X(e.data)}}Le.create=s=>new Le({typeName:x.ZodUnknown,...E(s)});class _e extends C{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:h.invalid_type,expected:y.never,received:t.parsedType}),w}}_e.create=s=>new _e({typeName:x.ZodNever,...E(s)});class Dt extends C{_parse(e){if(this._getType(e)!==y.undefined){const n=this._getOrReturnCtx(e);return p(n,{code:h.invalid_type,expected:y.void,received:n.parsedType}),w}return X(e.data)}}Dt.create=s=>new Dt({typeName:x.ZodVoid,...E(s)});class ce extends C{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==y.array)return p(t,{code:h.invalid_type,expected:y.array,received:t.parsedType}),w;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(p(t,{code:i?h.too_big:h.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(p(t,{code:h.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(p(t,{code:h.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new pe(t,i,t.path,o)))).then(i=>W.mergeArray(n,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new pe(t,i,t.path,o)));return W.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new ce({...this._def,minLength:{value:e,message:_.toString(t)}})}max(e,t){return new ce({...this._def,maxLength:{value:e,message:_.toString(t)}})}length(e,t){return new ce({...this._def,exactLength:{value:e,message:_.toString(t)}})}nonempty(e){return this.min(1,e)}}ce.create=(s,e)=>new ce({type:s,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...E(e)});function Fe(s){if(s instanceof z){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=ge.create(Fe(n))}return new z({...s._def,shape:()=>e})}else return s instanceof ce?new ce({...s._def,type:Fe(s.element)}):s instanceof ge?ge.create(Fe(s.unwrap())):s instanceof Ce?Ce.create(Fe(s.unwrap())):s instanceof me?me.create(s.items.map(e=>Fe(e))):s}class z extends C{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=I.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==y.object){const l=this._getOrReturnCtx(e);return p(l,{code:h.invalid_type,expected:y.object,received:l.parsedType}),w}const{status:n,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof _e&&this._def.unknownKeys==="strip"))for(const l in r.data)i.includes(l)||o.push(l);const c=[];for(const l of i){const u=a[l],f=r.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new pe(r,f,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof _e){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(l==="strict")o.length>0&&(p(r,{code:h.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const u of o){const f=r.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new pe(r,f,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const f=await u.key,v=await u.value;l.push({key:f,value:v,alwaysSet:u.alwaysSet})}return l}).then(l=>W.mergeObjectSync(n,l)):W.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new z({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,a,i,o;const c=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=_.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new z({...this._def,unknownKeys:"strip"})}passthrough(){return new z({...this._def,unknownKeys:"passthrough"})}extend(e){return new z({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new z({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new z({...this._def,catchall:e})}pick(e){const t={};return I.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new z({...this._def,shape:()=>t})}omit(e){const t={};return I.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new z({...this._def,shape:()=>t})}deepPartial(){return Fe(this)}partial(e){const t={};return I.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new z({...this._def,shape:()=>t})}required(e){const t={};return I.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof ge;)a=a._def.innerType;t[n]=a}}),new z({...this._def,shape:()=>t})}keyof(){return Fn(I.objectKeys(this.shape))}}z.create=(s,e)=>new z({shape:()=>s,unknownKeys:"strip",catchall:_e.create(),typeName:x.ZodObject,...E(e)}),z.strictCreate=(s,e)=>new z({shape:()=>s,unknownKeys:"strict",catchall:_e.create(),typeName:x.ZodObject,...E(e)}),z.lazycreate=(s,e)=>new z({shape:s,unknownKeys:"strip",catchall:_e.create(),typeName:x.ZodObject,...E(e)});class ut extends C{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function r(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new ne(o.ctx.common.issues));return p(t,{code:h.invalid_union,unionErrors:i}),w}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of n){const l={...t,common:{...t.common,issues:[]},parent:null},u=c._parseSync({data:t.data,path:t.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new ne(c));return p(t,{code:h.invalid_union,unionErrors:o}),w}}get options(){return this._def.options}}ut.create=(s,e)=>new ut({options:s,typeName:x.ZodUnion,...E(e)});const ke=s=>s instanceof ft?ke(s.schema):s instanceof ue?ke(s.innerType()):s instanceof pt?[s.value]:s instanceof Ee?s.options:s instanceof mt?I.objectValues(s.enum):s instanceof gt?ke(s._def.innerType):s instanceof lt?[void 0]:s instanceof ct?[null]:s instanceof ge?[void 0,...ke(s.unwrap())]:s instanceof Ce?[null,...ke(s.unwrap())]:s instanceof an||s instanceof _t?ke(s.unwrap()):s instanceof yt?ke(s._def.innerType):[];class Pt extends C{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.object)return p(t,{code:h.invalid_type,expected:y.object,received:t.parsedType}),w;const n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),w)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const a of t){const i=ke(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new Pt({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...E(n)})}}function sn(s,e){const t=ve(s),n=ve(e);if(s===e)return{valid:!0,data:s};if(t===y.object&&n===y.object){const r=I.objectKeys(e),a=I.objectKeys(s).filter(o=>r.indexOf(o)!==-1),i={...s,...e};for(const o of a){const c=sn(s[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===y.array&&n===y.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],c=sn(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return t===y.date&&n===y.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class dt extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(tn(a)||tn(i))return w;const o=sn(a.value,i.value);return o.valid?((nn(a)||nn(i))&&t.dirty(),{status:t.value,value:o.data}):(p(n,{code:h.invalid_intersection_types}),w)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}dt.create=(s,e,t)=>new dt({left:s,right:e,typeName:x.ZodIntersection,...E(t)});class me extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.array)return p(n,{code:h.invalid_type,expected:y.array,received:n.parsedType}),w;if(n.data.length<this._def.items.length)return p(n,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new pe(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>W.mergeArray(t,i)):W.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new me({...this._def,rest:e})}}me.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new me({items:s,typeName:x.ZodTuple,rest:null,...E(e)})};class ht extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return p(n,{code:h.invalid_type,expected:y.object,received:n.parsedType}),w;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new pe(n,o,n.path,o)),value:i._parse(new pe(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?W.mergeObjectAsync(t,r):W.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof C?new ht({keyType:e,valueType:t,typeName:x.ZodRecord,...E(n)}):new ht({keyType:le.create(),valueType:e,typeName:x.ZodRecord,...E(t)})}}class zt extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.map)return p(n,{code:h.invalid_type,expected:y.map,received:n.parsedType}),w;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:r._parse(new pe(n,o,n.path,[l,"key"])),value:a._parse(new pe(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return w;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),o.set(l.value,u.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return w;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),o.set(l.value,u.value)}return{status:t.value,value:o}}}}zt.create=(s,e,t)=>new zt({valueType:e,keyType:s,typeName:x.ZodMap,...E(t)});class De extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.set)return p(n,{code:h.invalid_type,expected:y.set,received:n.parsedType}),w;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(p(n,{code:h.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(p(n,{code:h.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const u of c){if(u.status==="aborted")return w;u.status==="dirty"&&t.dirty(),l.add(u.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new pe(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new De({...this._def,minSize:{value:e,message:_.toString(t)}})}max(e,t){return new De({...this._def,maxSize:{value:e,message:_.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}De.create=(s,e)=>new De({valueType:s,minSize:null,maxSize:null,typeName:x.ZodSet,...E(e)});class Ue extends C{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.function)return p(t,{code:h.invalid_type,expected:y.function,received:t.parsedType}),w;function n(o,c){return Zt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Nt(),Me].filter(l=>!!l),issueData:{code:h.invalid_arguments,argumentsError:c}})}function r(o,c){return Zt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Nt(),Me].filter(l=>!!l),issueData:{code:h.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ve){const o=this;return X(async function(...c){const l=new ne([]),u=await o._def.args.parseAsync(c,a).catch(T=>{throw l.addIssue(n(c,T)),l}),f=await Reflect.apply(i,this,u);return await o._def.returns._def.type.parseAsync(f,a).catch(T=>{throw l.addIssue(r(f,T)),l})})}else{const o=this;return X(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new ne([n(c,l.error)]);const u=Reflect.apply(i,this,l.data),f=o._def.returns.safeParse(u,a);if(!f.success)throw new ne([r(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ue({...this._def,args:me.create(e).rest(Le.create())})}returns(e){return new Ue({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ue({args:e||me.create([]).rest(Le.create()),returns:t||Le.create(),typeName:x.ZodFunction,...E(n)})}}class ft extends C{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ft.create=(s,e)=>new ft({getter:s,typeName:x.ZodLazy,...E(e)});class pt extends C{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:e.data}}get value(){return this._def.value}}pt.create=(s,e)=>new pt({value:s,typeName:x.ZodLiteral,...E(e)});function Fn(s,e){return new Ee({values:s,typeName:x.ZodEnum,...E(e)})}class Ee extends C{constructor(){super(...arguments),at.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{expected:I.joinValues(n),received:t.parsedType,code:h.invalid_type}),w}if(jt(this,at)||Pn(this,at,new Set(this._def.values)),!jt(this,at).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:h.invalid_enum_value,options:n}),w}return X(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ee.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ee.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}at=new WeakMap,Ee.create=Fn;class mt extends C{constructor(){super(...arguments),it.set(this,void 0)}_parse(e){const t=I.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==y.string&&n.parsedType!==y.number){const r=I.objectValues(t);return p(n,{expected:I.joinValues(r),received:n.parsedType,code:h.invalid_type}),w}if(jt(this,it)||Pn(this,it,new Set(I.getValidEnumValues(this._def.values))),!jt(this,it).has(e.data)){const r=I.objectValues(t);return p(n,{received:n.data,code:h.invalid_enum_value,options:r}),w}return X(e.data)}get enum(){return this._def.values}}it=new WeakMap,mt.create=(s,e)=>new mt({values:s,typeName:x.ZodNativeEnum,...E(e)});class Ve extends C{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.promise&&t.common.async===!1)return p(t,{code:h.invalid_type,expected:y.promise,received:t.parsedType}),w;const n=t.parsedType===y.promise?t.data:Promise.resolve(t.data);return X(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ve.create=(s,e)=>new Ve({type:s,typeName:x.ZodPromise,...E(e)});class ue extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{p(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return w;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?w:c.status==="dirty"||t.value==="dirty"?Be(c.value):c});{if(t.value==="aborted")return w;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?w:o.status==="dirty"||t.value==="dirty"?Be(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?w:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?w:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ze(i))return i;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Ze(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);I.assertNever(r)}}ue.create=(s,e,t)=>new ue({schema:s,typeName:x.ZodEffects,effect:e,...E(t)}),ue.createWithPreprocess=(s,e,t)=>new ue({schema:e,effect:{type:"preprocess",transform:s},typeName:x.ZodEffects,...E(t)});class ge extends C{_parse(e){return this._getType(e)===y.undefined?X(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ge.create=(s,e)=>new ge({innerType:s,typeName:x.ZodOptional,...E(e)});class Ce extends C{_parse(e){return this._getType(e)===y.null?X(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ce.create=(s,e)=>new Ce({innerType:s,typeName:x.ZodNullable,...E(e)});class gt extends C{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}gt.create=(s,e)=>new gt({innerType:s,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...E(e)});class yt extends C{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return st(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ne(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ne(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}yt.create=(s,e)=>new yt({innerType:s,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...E(e)});class Mt extends C{_parse(e){if(this._getType(e)!==y.nan){const n=this._getOrReturnCtx(e);return p(n,{code:h.invalid_type,expected:y.nan,received:n.parsedType}),w}return{status:"valid",value:e.data}}}Mt.create=s=>new Mt({typeName:x.ZodNaN,...E(s)});const ks=Symbol("zod_brand");class an extends C{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class vt extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?w:a.status==="dirty"?(t.dirty(),Be(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?w:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new vt({in:e,out:t,typeName:x.ZodPipeline})}}class _t extends C{_parse(e){const t=this._def.innerType._parse(e),n=r=>(Ze(r)&&(r.value=Object.freeze(r.value)),r);return st(t)?t.then(r=>n(r)):n(t)}unwrap(){return this._def.innerType}}_t.create=(s,e)=>new _t({innerType:s,typeName:x.ZodReadonly,...E(e)});function Un(s,e){const t=typeof s=="function"?s(e):typeof s=="string"?{message:s}:s;return typeof t=="string"?{message:t}:t}function Vn(s,e={},t){return s?qe.create().superRefine((n,r)=>{var a,i;const o=s(n);if(o instanceof Promise)return o.then(c=>{var l,u;if(!c){const f=Un(e,n),v=(u=(l=f.fatal)!==null&&l!==void 0?l:t)!==null&&u!==void 0?u:!0;r.addIssue({code:"custom",...f,fatal:v})}});if(!o){const c=Un(e,n),l=(i=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0;r.addIssue({code:"custom",...c,fatal:l})}}):qe.create()}const bs={object:z.lazycreate};var x;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(x||(x={}));const xs=(s,e={message:`Input not instance of ${s.name}`})=>Vn(t=>t instanceof s,e),Hn=le.create,Gn=Se.create,ws=Mt.create,Ts=Re.create,Wn=ot.create,Ss=je.create,Rs=Lt.create,Es=lt.create,Cs=ct.create,As=qe.create,Is=Le.create,$s=_e.create,Os=Dt.create,Ns=ce.create,Zs=z.create,js=z.strictCreate,Ls=ut.create,Ds=Pt.create,Ps=dt.create,zs=me.create,Ms=ht.create,Bs=zt.create,qs=De.create,Fs=Ue.create,Us=ft.create,Vs=pt.create,Hs=Ee.create,Gs=mt.create,Ws=Ve.create,Qn=ue.create,Qs=ge.create,Xs=Ce.create,Js=ue.createWithPreprocess,Ys=vt.create;var Z=Object.freeze({__proto__:null,defaultErrorMap:Me,setErrorMap:Jr,getErrorMap:Nt,makeIssue:Zt,EMPTY_PATH:Yr,addIssueToContext:p,ParseStatus:W,INVALID:w,DIRTY:Be,OK:X,isAborted:tn,isDirty:nn,isValid:Ze,isAsync:st,get util(){return I},get objectUtil(){return en},ZodParsedType:y,getParsedType:ve,ZodType:C,datetimeRegex:qn,ZodString:le,ZodNumber:Se,ZodBigInt:Re,ZodBoolean:ot,ZodDate:je,ZodSymbol:Lt,ZodUndefined:lt,ZodNull:ct,ZodAny:qe,ZodUnknown:Le,ZodNever:_e,ZodVoid:Dt,ZodArray:ce,ZodObject:z,ZodUnion:ut,ZodDiscriminatedUnion:Pt,ZodIntersection:dt,ZodTuple:me,ZodRecord:ht,ZodMap:zt,ZodSet:De,ZodFunction:Ue,ZodLazy:ft,ZodLiteral:pt,ZodEnum:Ee,ZodNativeEnum:mt,ZodPromise:Ve,ZodEffects:ue,ZodTransformer:ue,ZodOptional:ge,ZodNullable:Ce,ZodDefault:gt,ZodCatch:yt,ZodNaN:Mt,BRAND:ks,ZodBranded:an,ZodPipeline:vt,ZodReadonly:_t,custom:Vn,Schema:C,ZodSchema:C,late:bs,get ZodFirstPartyTypeKind(){return x},coerce:{string:s=>le.create({...s,coerce:!0}),number:s=>Se.create({...s,coerce:!0}),boolean:s=>ot.create({...s,coerce:!0}),bigint:s=>Re.create({...s,coerce:!0}),date:s=>je.create({...s,coerce:!0})},any:As,array:Ns,bigint:Ts,boolean:Wn,date:Ss,discriminatedUnion:Ds,effect:Qn,enum:Hs,function:Fs,instanceof:xs,intersection:Ps,lazy:Us,literal:Vs,map:Bs,nan:ws,nativeEnum:Gs,never:$s,null:Cs,nullable:Xs,number:Gn,object:Zs,oboolean:()=>Wn().optional(),onumber:()=>Gn().optional(),optional:Qs,ostring:()=>Hn().optional(),pipeline:Ys,preprocess:Js,promise:Ws,record:Ms,set:qs,strictObject:js,string:Hn,symbol:Rs,transformer:Qn,tuple:zs,undefined:Es,union:Ls,unknown:Is,void:Os,NEVER:w,ZodIssueCode:h,quotelessJson:Xr,ZodError:ne});const Xn=Z.object({label:Z.string(),options:Z.array(Z.object({label:Z.string(),value:Z.number()}))}),on=Z.object({enabled:Z.boolean(),impact:Xn,quality:Xn}),Jn=Z.object({classification:on.optional()}),Yn=Z.object({label:Z.string(),icon:Z.string(),url:Z.string(),target:Z.string()}),Kn=Z.object({menu:Z.record(Z.array(Yn)).optional(),supportedLanguages:Z.array(Z.enum(["en","de","fr","it"])).optional(),classification:on.optional()}),er=Z.object({label:Z.string().nullable(),question:Z.string()}),tr=Z.object({predefinedQuestions:Z.array(er)}),nr=Z.union([Z.object({maintenance:Z.literal(!0)}),Z.object({id:Z.string(),cID:Z.string()})]);var Ks=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ln={exports:{}};/** @license
|
|
57
57
|
* eventsource.js
|
|
58
58
|
* Available under MIT License (MIT)
|
|
59
59
|
* https://github.com/Yaffle/EventSource/
|
|
60
|
-
*/(function(
|
|
61
|
-
`),
|
|
62
|
-
`,
|
|
60
|
+
*/(function(s,e){(function(t){var n=t.setTimeout,r=t.clearTimeout,a=t.XMLHttpRequest,i=t.XDomainRequest,o=t.ActiveXObject,c=t.EventSource,l=t.document,u=t.Promise,f=t.fetch,v=t.Response,T=t.TextDecoder,M=t.TextEncoder,j=t.AbortController;if(typeof window<"u"&&typeof l<"u"&&!("readyState"in l)&&l.body==null&&(l.readyState="loading",window.addEventListener("load",function(d){l.readyState="complete"},!1)),a==null&&o!=null&&(a=function(){return new o("Microsoft.XMLHTTP")}),Object.create==null&&(Object.create=function(d){function g(){}return g.prototype=d,new g}),Date.now||(Date.now=function(){return new Date().getTime()}),j==null){var ee=f;f=function(d,g){var k=g.signal;return ee(d,{headers:g.headers,credentials:g.credentials,cache:g.cache}).then(function(m){var S=m.body.getReader();return k._reader=S,k._aborted&&k._reader.cancel(),{status:m.status,statusText:m.statusText,headers:m.headers,body:{getReader:function(){return S}}}})},j=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){this.signal._reader!=null&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function kt(){this.bitsNeeded=0,this.codePoint=0}kt.prototype.decode=function(d){function g(L,P,R){if(R===1)return L>=128>>P&&L<<P<=2047;if(R===2)return L>=2048>>P&&L<<P<=55295||L>=57344>>P&&L<<P<=65535;if(R===3)return L>=65536>>P&&L<<P<=1114111;throw new Error}function k(L,P){if(L===6*1)return P>>6>15?3:P>31?2:1;if(L===6*2)return P>15?3:2;if(L===6*3)return 3;throw new Error}for(var m=65533,S="",b=this.bitsNeeded,A=this.codePoint,B=0;B<d.length;B+=1){var $=d[B];b!==0&&($<128||$>191||!g(A<<6|$&63,b-6,k(b,A)))&&(b=0,A=m,S+=String.fromCharCode(A)),b===0?($>=0&&$<=127?(b=0,A=$):$>=192&&$<=223?(b=6*1,A=$&31):$>=224&&$<=239?(b=6*2,A=$&15):$>=240&&$<=247?(b=6*3,A=$&7):(b=0,A=m),b!==0&&!g(A,b,k(b,A))&&(b=0,A=m)):(b-=6,A=A<<6|$&63),b===0&&(A<=65535?S+=String.fromCharCode(A):(S+=String.fromCharCode(55296+(A-65535-1>>10)),S+=String.fromCharCode(56320+(A-65535-1&1023))))}return this.bitsNeeded=b,this.codePoint=A,S};var bt=function(){try{return new T().decode(new M().encode("test"),{stream:!0})==="test"}catch(d){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+d)}return!1};(T==null||M==null||!bt())&&(T=kt);var te=function(){};function ye(d){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=te,this.onload=te,this.onerror=te,this.onreadystatechange=te,this._contentType="",this._xhr=d,this._sendTimeout=0,this._abort=te}ye.prototype.open=function(d,g){this._abort(!0);var k=this,m=this._xhr,S=1,b=0;this._abort=function(R){k._sendTimeout!==0&&(r(k._sendTimeout),k._sendTimeout=0),(S===1||S===2||S===3)&&(S=4,m.onload=te,m.onerror=te,m.onabort=te,m.onprogress=te,m.onreadystatechange=te,m.abort(),b!==0&&(r(b),b=0),R||(k.readyState=4,k.onabort(null),k.onreadystatechange())),S=0};var A=function(){if(S===1){var R=0,q="",be=void 0;if("contentType"in m)R=200,q="OK",be=m.contentType;else try{R=m.status,q=m.statusText,be=m.getResponseHeader("Content-Type")}catch{R=0,q="",be=void 0}R!==0&&(S=2,k.readyState=2,k.status=R,k.statusText=q,k._contentType=be,k.onreadystatechange())}},B=function(){if(A(),S===2||S===3){S=3;var R="";try{R=m.responseText}catch{}k.readyState=3,k.responseText=R,k.onprogress()}},$=function(R,q){if((q==null||q.preventDefault==null)&&(q={preventDefault:te}),B(),S===1||S===2||S===3){if(S=4,b!==0&&(r(b),b=0),k.readyState=4,R==="load")k.onload(q);else if(R==="error")k.onerror(q);else if(R==="abort")k.onabort(q);else throw new TypeError;k.onreadystatechange()}},L=function(R){m!=null&&(m.readyState===4?(!("onload"in m)||!("onerror"in m)||!("onabort"in m))&&$(m.responseText===""?"error":"load",R):m.readyState===3?"onprogress"in m||B():m.readyState===2&&A())},P=function(){b=n(function(){P()},500),m.readyState===3&&B()};"onload"in m&&(m.onload=function(R){$("load",R)}),"onerror"in m&&(m.onerror=function(R){$("error",R)}),"onabort"in m&&(m.onabort=function(R){$("abort",R)}),"onprogress"in m&&(m.onprogress=B),"onreadystatechange"in m&&(m.onreadystatechange=function(R){L(R)}),("contentType"in m||!("ontimeout"in a.prototype))&&(g+=(g.indexOf("?")===-1?"?":"&")+"padding=true"),m.open(d,g,!0),"readyState"in m&&(b=n(function(){P()},0))},ye.prototype.abort=function(){this._abort(!1)},ye.prototype.getResponseHeader=function(d){return this._contentType},ye.prototype.setRequestHeader=function(d,g){var k=this._xhr;"setRequestHeader"in k&&k.setRequestHeader(d,g)},ye.prototype.getAllResponseHeaders=function(){return this._xhr.getAllResponseHeaders!=null&&this._xhr.getAllResponseHeaders()||""},ye.prototype.send=function(){if((!("ontimeout"in a.prototype)||!("sendAsBinary"in a.prototype)&&!("mozAnon"in a.prototype))&&l!=null&&l.readyState!=null&&l.readyState!=="complete"){var d=this;d._sendTimeout=n(function(){d._sendTimeout=0,d.send()},4);return}var g=this._xhr;"withCredentials"in g&&(g.withCredentials=this.withCredentials);try{g.send(void 0)}catch(k){throw k}};function xt(d){return d.replace(/[A-Z]/g,function(g){return String.fromCharCode(g.charCodeAt(0)+32)})}function Bt(d){for(var g=Object.create(null),k=d.split(`\r
|
|
61
|
+
`),m=0;m<k.length;m+=1){var S=k[m],b=S.split(": "),A=b.shift(),B=b.join(": ");g[xt(A)]=B}this._map=g}Bt.prototype.get=function(d){return this._map[xt(d)]},a!=null&&a.HEADERS_RECEIVED==null&&(a.HEADERS_RECEIVED=2);function Ge(){}Ge.prototype.open=function(d,g,k,m,S,b,A){d.open("GET",S);var B=0;d.onprogress=function(){var L=d.responseText,P=L.slice(B);B+=P.length,k(P)},d.onerror=function(L){L.preventDefault(),m(new Error("NetworkError"))},d.onload=function(){m(null)},d.onabort=function(){m(null)},d.onreadystatechange=function(){if(d.readyState===a.HEADERS_RECEIVED){var L=d.status,P=d.statusText,R=d.getResponseHeader("Content-Type"),q=d.getAllResponseHeaders();g(L,P,R,new Bt(q))}},d.withCredentials=b;for(var $ in A)Object.prototype.hasOwnProperty.call(A,$)&&d.setRequestHeader($,A[$]);return d.send(),d};function Ae(d){this._headers=d}Ae.prototype.get=function(d){return this._headers.get(d)};function or(){}or.prototype.open=function(d,g,k,m,S,b,A){var B=null,$=new j,L=$.signal,P=new T;return f(S,{headers:A,credentials:b?"include":"same-origin",signal:L,cache:"no-store"}).then(function(R){return B=R.body.getReader(),g(R.status,R.statusText,R.headers.get("Content-Type"),new Ae(R.headers)),new u(function(q,be){var St=function(){B.read().then(function(re){if(re.done)q(void 0);else{var J=P.decode(re.value,{stream:!0});k(J),St()}}).catch(function(re){be(re)})};St()})}).catch(function(R){if(R.name!=="AbortError")return R}).then(function(R){m(R)}),{abort:function(){B!=null&&B.cancel(),$.abort()}}};function wt(){this._listeners=Object.create(null)}function lr(d){n(function(){throw d},0)}wt.prototype.dispatchEvent=function(d){d.target=this;var g=this._listeners[d.type];if(g!=null)for(var k=g.length,m=0;m<k;m+=1){var S=g[m];try{typeof S.handleEvent=="function"?S.handleEvent(d):S.call(this,d)}catch(b){lr(b)}}},wt.prototype.addEventListener=function(d,g){d=String(d);var k=this._listeners,m=k[d];m==null&&(m=[],k[d]=m);for(var S=!1,b=0;b<m.length;b+=1)m[b]===g&&(S=!0);S||m.push(g)},wt.prototype.removeEventListener=function(d,g){d=String(d);var k=this._listeners,m=k[d];if(m!=null){for(var S=[],b=0;b<m.length;b+=1)m[b]!==g&&S.push(m[b]);S.length===0?delete k[d]:k[d]=S}};function We(d){this.type=d,this.target=void 0}function cr(d,g){We.call(this,d),this.data=g.data,this.lastEventId=g.lastEventId}cr.prototype=Object.create(We.prototype);function un(d,g){We.call(this,d),this.status=g.status,this.statusText=g.statusText,this.headers=g.headers}un.prototype=Object.create(We.prototype);function ur(d,g){We.call(this,d),this.error=g.error}ur.prototype=Object.create(We.prototype);var dn=-1,Ie=0,Qe=1,Tt=2,hn=-1,$e=0,fn=1,dr=2,ia=3,oa=/^text\/event\-stream(;.*)?$/i,la=1e3,ca=18e6,pn=function(d,g){var k=d==null?g:parseInt(d,10);return k!==k&&(k=g),mn(k)},mn=function(d){return Math.min(Math.max(d,la),ca)},Xe=function(d,g,k){try{typeof g=="function"&&g.call(d,k)}catch(m){lr(m)}};function de(d,g){wt.call(this),g=g||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,ha(this,d,g)}function ua(){return a!=null&&"withCredentials"in a.prototype||i==null?new a:new i}var da=f!=null&&v!=null&&"body"in v.prototype;function ha(d,g,k){g=String(g);var m=!!k.withCredentials,S=k.lastEventIdQueryParameterName||"lastEventId",b=mn(1e3),A=pn(k.heartbeatTimeout,45e3),B="",$=b,L=!1,P=0,R=k.headers||{},q=k.Transport,be=da&&q==null?void 0:new ye(q!=null?new q:ua()),St=q!=null&&typeof q!="string"?new q:be==null?new or:new Ge,re=void 0,J=0,he=dn,Je="",qt="",xe="",Ft="",Y=$e,gn=0,Pe=0,fa=function(H,U,se,ae){if(he===Ie)if(H===200&&se!=null&&oa.test(se)){he=Qe,L=Date.now(),$=b,d.readyState=Qe;var K=new un("open",{status:H,statusText:U,headers:ae});d.dispatchEvent(K),Xe(d,d.onopen,K)}else{var G="";H!==200?(U&&(U=U.replace(/\s+/g," ")),G="EventSource's response has a status "+H+" "+U+" that is not 200. Aborting the connection."):G="EventSource's response has a Content-Type specifying an unsupported type: "+(se==null?"-":se.replace(/\s+/g," "))+". Aborting the connection.",yn();var K=new un("error",{status:H,statusText:U,headers:ae});d.dispatchEvent(K),Xe(d,d.onerror,K),console.error(G)}},pa=function(H){if(he===Qe){for(var U=-1,se=0;se<H.length;se+=1){var ae=H.charCodeAt(se);(ae===10||ae===13)&&(U=se)}var K=(U!==-1?Ft:"")+H.slice(0,U+1);Ft=(U===-1?Ft:"")+H.slice(U+1),H!==""&&(L=Date.now(),P+=H.length);for(var G=0;G<K.length;G+=1){var ae=K.charCodeAt(G);if(Y===hn&&ae===10)Y=$e;else if(Y===hn&&(Y=$e),ae===13||ae===10){if(Y!==$e){Y===fn&&(Pe=G+1);var we=K.slice(gn,Pe-1),Te=K.slice(Pe+(Pe<G&&K.charCodeAt(Pe)===32?1:0),G);we==="data"?(Je+=`
|
|
62
|
+
`,Je+=Te):we==="id"?qt=Te:we==="event"?xe=Te:we==="retry"?(b=pn(Te,b),$=b):we==="heartbeatTimeout"&&(A=pn(Te,A),J!==0&&(r(J),J=n(function(){Rt()},A)))}if(Y===$e){if(Je!==""){B=qt,xe===""&&(xe="message");var Ye=new cr(xe,{data:Je.slice(1),lastEventId:qt});if(d.dispatchEvent(Ye),xe==="open"?Xe(d,d.onopen,Ye):xe==="message"?Xe(d,d.onmessage,Ye):xe==="error"&&Xe(d,d.onerror,Ye),he===Tt)return}Je="",xe=""}Y=ae===13?hn:$e}else Y===$e&&(gn=G,Y=fn),Y===fn?ae===58&&(Pe=G+1,Y=dr):Y===dr&&(Y=ia)}}},fr=function(H){if(he===Qe||he===Ie){he=dn,J!==0&&(r(J),J=0),J=n(function(){Rt()},$),$=mn(Math.min(b*16,$*2)),d.readyState=Ie;var U=new ur("error",{error:H});d.dispatchEvent(U),Xe(d,d.onerror,U),H!=null&&console.error(H)}},yn=function(){he=Tt,re!=null&&(re.abort(),re=void 0),J!==0&&(r(J),J=0),d.readyState=Tt},Rt=function(){if(J=0,he!==dn){if(!L&&re!=null)fr(new Error("No activity within "+A+" milliseconds. "+(he===Ie?"No response received.":P+" chars received.")+" Reconnecting.")),re!=null&&(re.abort(),re=void 0);else{var H=Math.max((L||Date.now())+A-Date.now(),1);L=!1,J=n(function(){Rt()},H)}return}L=!1,P=0,J=n(function(){Rt()},A),he=Ie,Je="",xe="",qt=B,Ft="",gn=0,Pe=0,Y=$e;var U=g;if(g.slice(0,5)!=="data:"&&g.slice(0,5)!=="blob:"&&B!==""){var se=g.indexOf("?");U=se===-1?g:g.slice(0,se+1)+g.slice(se+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,function(Te,Ye){return Ye===S?"":Te}),U+=(g.indexOf("?")===-1?"?":"&")+S+"="+encodeURIComponent(B)}var ae=d.withCredentials,K={};K.Accept="text/event-stream";var G=d.headers;if(G!=null)for(var we in G)Object.prototype.hasOwnProperty.call(G,we)&&(K[we]=G[we]);try{re=St.open(be,fa,pa,fr,U,ae,K)}catch(Te){throw yn(),Te}};d.url=g,d.readyState=Ie,d.withCredentials=m,d.headers=R,d._close=yn,Rt()}de.prototype=Object.create(wt.prototype),de.prototype.CONNECTING=Ie,de.prototype.OPEN=Qe,de.prototype.CLOSED=Tt,de.prototype.close=function(){this._close()},de.CONNECTING=Ie,de.OPEN=Qe,de.CLOSED=Tt,de.prototype.withCredentials=void 0;var hr=c;a!=null&&(c==null||!("withCredentials"in c.prototype))&&(hr=de),function(d){{var g=d(e);g!==void 0&&(s.exports=g)}}(function(d){d.EventSourcePolyfill=de,d.NativeEventSource=c,d.EventSource=hr})})(typeof globalThis>"u"?typeof window<"u"?window:typeof self<"u"?self:Ks:globalThis)})(ln,ln.exports);var rr=ln.exports;const cn=()=>{};function ea(s,e){return s!=s?e==e:s!==e||s!==null&&typeof s=="object"||typeof s=="function"}const He=[];function ta(s,e=cn){let t=null;const n=new Set;function r(o){if(ea(s,o)&&(s=o,t)){const c=!He.length;for(const l of n)l[1](),He.push(l,s);if(c){for(let l=0;l<He.length;l+=2)He[l][0](He[l+1]);He.length=0}}}function a(o){r(o(s))}function i(o,c=cn){const l=[o,c];return n.add(l),n.size===1&&(t=e(r,a)||cn),o(s),()=>{n.delete(l),n.size===0&&t&&(t(),t=null)}}return{set:r,update:a,subscribe:i}}const sr=s=>Object.fromEntries(Object.entries(s).filter(([e,t])=>t!=null)),na=s=>{try{return new URL(s).hostname}catch{return s}},ra=s=>{let e=[],t=s.usedLinks.title??"";return t.includes(">")&&(e=t.split(">").map(n=>n.trim()),t=e.pop()??""),{url:s.usedLinks.url,title:s.usedLinks.title,referenceNumber:s.usedLinks.number,domainName:na(s.usedLinks.url),breadcrumb:e,generated:{summary:s.usedLinks.description??s.usedLinks.summary??""}}},ar=(s,e)=>{const t=s.all.length,n=ra(e);return n.referenceNumber=t+1,s.all.push(n),s},sa=rr.NativeEventSource||rr.EventSourcePolyfill;let ir;class aa{constructor({apiUrl:e,apiKey:t="X9hL4Gp5W2D7eRtF",strict:n}){O(this,"apiUrl");O(this,"apiKey");O(this,"strict");O(this,"lastRequestId");O(this,"idToQuestionsMap",new Map);O(this,"metadata");this.apiUrl=e,this.apiKey=t,this.strict=n??!1,this.metadata=this.getUserData(),ir=this}async getUserData(){var e;try{const t=vn.getItem("uID"),n=await this.fetchData("/log",nr,{},{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({referrer:((e=globalThis==null?void 0:globalThis.document)==null?void 0:e.referrer)||null,uID:t})});if("maintenance"in n&&n.maintenance)return{mode:"maintenance"};if(!("id"in n))throw new Error("Invalid response format: missing user id");return vn.setItem("uID",n.id),{mode:"ready",userId:n.id,conversationId:n.cID}}catch(t){throw t instanceof Response?new Error(`Failed to initialize client: ${t.status} - ${await t.text()}`):new Error(`Failed to initialize client: ${t instanceof Error?t.message:"Unknown error"}`)}}static getInstance(){return ir}async postData(e,t,n){const r=await fetch(`${this.apiUrl}${e}`,{method:"POST",headers:{"Content-Type":"application/json","api-key":this.apiKey},body:JSON.stringify(t)});if(!r.ok){const a=await r.text();throw new Error(`${n}: ${r.status} - ${a}`)}return r}async fetchData(e,t,n={},r={}){const a=`${this.apiUrl}${e}?${new URLSearchParams(sr(n)).toString()}`,i={...r,headers:{...(r==null?void 0:r.headers)||{},"api-key":this.apiKey}},o=await fetch(a,i);if(!o.ok){const v=await o.text();throw new Error(`API request failed: ${o.status} - ${v}`)}const c=await o.json(),{success:l,data:u,error:f}=t.safeParse(c);if(this.strict){if(!l)throw console.error(`Server response has wrong type:
|
|
63
|
+
`,{error:f,url:a,opts:i,data:c}),new Error(`Server response has wrong type: ${f.message}`);return u}else return l||console.warn(`Server response has wrong type:
|
|
64
|
+
`,{error:f,url:a,opts:i,data:c}),c}async fetchSSE(e,t={}){return new sa(`${this.apiUrl}${e}?${new URLSearchParams({...sr(t),key:this.apiKey}).toString()}`)}async quickFeedback(e){const t=e.messageId??this.lastRequestId,n={...e,rID:t,query:this.idToQuestionsMap.get(t)};return this.postData("/quickfeedback",n,"Got an error when trying to post quick feedback")}async feedback(e){try{const t=await this.metadata;if(t.mode!=="ready")throw new Error("Can not post feedback unless we are in ready mode");const n=e.messageId??this.lastRequestId,r={body:e.body,email:e.email,rID:n,uID:t.userId,query:this.idToQuestionsMap.get(n)};return this.postData("/feedback",r,"Got an error when trying to post feedback")}catch(t){throw t instanceof Response?new Error(`Feedback submission failed: ${t.status} - ${await t.text()}`):new Error(`Feedback submission failed: ${t instanceof Error?t.message:"Unknown error"}`)}}async getClassification(e={}){return(await this.fetchData("/chatconfig",Jn,e)).classification}async classification({impact:e,quality:t,messageId:n}){return this.postData("/classification",{impact:e,quality:t,rID:n??this.lastRequestId},"Got an error when trying to post feedback classification")}async getPredefinedQuestions(e){return(await this.fetchData("/topics/questions",tr,e)).predefinedQuestions}async getChatConfig(){return this.fetchData("/chatconfig",Kn)}async getMenu(e){var t;try{return((t=(await this.getChatConfig()).menu)==null?void 0:t[e.language])??[]}catch(n){throw new Error(`Failed to load menu: ${n instanceof Error?n.message:"Unknown error"}`)}}async getUsedLanguages(){try{const e=await this.getChatConfig();return Object.keys(e.menu??{})}catch(e){throw new Error(`Failed to load languages: ${e instanceof Error?e.message:"Unknown error"}`)}}async chatInternal(e,t={}){const n=await this.metadata;let r="";if(t.modes&&(r=`mode:${t.modes.join(",")} `),n.mode==="maintenance")throw new Error("Can not chat in maintenance mode");return this.fetchSSE("/assistant/sse",{query:r+e,uID:n.userId,cID:n.conversationId,lang:t.lang,model:t.model,chat:"true"})}chat(e,t={}){const n=ta({state:"loading"});let r=!0,a=!1;const i=new Date().toISOString();return this.chatInternal(e,t).then(o=>{let c;o.onmessage=l=>{const u=JSON.parse(l.data);"id"in u&&(this.lastRequestId=u.id,c=u.id,this.idToQuestionsMap.set(u.id,e)),"response"in u?u.response==="__CLR__"?r=!1:(u.response==="__THIS_IS_THE_ANSWER_END__"||u.response==="__THIS_IS_THE_END__")&&!a?(a=!0,n.update(f=>f.state!=="streaming"?(console.warn(`State transition: ${f.state} => done.`,"There is probably an issue with the message"),{payload:{id:c,type:"bot",time:new Date().toISOString(),sources:{all:[],used:[]},partial:!1,message:{markdown:"",html:""}},state:"done"}):{payload:{...f.payload,partial:!1},state:"done"})):r===!1&&a===!1&&n.update(f=>{if(f.state==="streaming"){const v=f.payload.message.markdown+u.response;return{state:"streaming",payload:{...f.payload,partial:!0,id:c,message:{markdown:v,html:Ln(v,f.payload)}}}}if(f.state==="loading"){const v=u.response;return{state:"streaming",payload:{type:"bot",id:c,time:i,partial:!0,sources:{all:[],used:[]},message:{markdown:v,html:Ln(v,{sources:{all:[],used:[]}})}}}}else throw console.error("Invalid message state",f),new Error("Invalid message state")}):"usedLinks"in u&&n.update(f=>{var v;if(f.state==="loading")return{state:"streaming",payload:{type:"bot",id:c,time:i,partial:!0,message:{markdown:"",html:""},sources:ar({all:[],used:[]},u)}};if(f.state==="streaming")return{state:"streaming",payload:{...f.payload,id:c,partial:!0,sources:ar((v=f.payload)==null?void 0:v.sources,u)}};throw console.error("Invalid source state",f),new Error("Invalid source state")})},o.onerror=()=>{o.close(),n.set({state:"error",errorMessage:"EventSource error"})}}).catch(o=>{console.error(o),n.set({state:"error",errorMessage:o.message})}),n}search(e,t={}){return this.metadata=this.getUserData(),this.chat(`prompt:SEARCH ${e}`,t)}transformURL(e){if(e.startsWith("file://")){const t=e.replace("file://",`${this.apiUrl}/files/`),n=new URL(t);return n.searchParams.append("key",this.apiKey),n.toString()}return e}}F.LiipGPTClient=aa,F.chatConfigSchema=Kn,F.classificationConfigSchema=on,F.classificationResponseSchema=Jn,F.menuItemSchema=Yn,F.predefinedQuestionSchema=er,F.predefinedQuestionsResponseSchema=tr,F.userDataResponseSchema=nr,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|