@wubaoqi/guancopilot 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/NOTICE.md +7 -0
  2. package/README.md +17 -2
  3. package/assets/guanbi.wasm +2 -2
  4. package/bin/guancopilot +0 -0
  5. package/bin/guanvm +0 -0
  6. package/bin/runtime.cjs +1 -0
  7. package/licenses/browser-_speed-highlight_core-LICENSE +121 -0
  8. package/licenses/browser-_speed-highlight_core-package.json +14 -0
  9. package/licenses/browser-dompurify-package.json +10 -0
  10. package/licenses/browser-marked-package.json +10 -0
  11. package/licenses/{github.com_google_pprof_v0.0.0-20250317173921-a4b03ec1a45e-LICENSE → github.com_santhosh-tekuri_jsonschema_v6_v6.0.3-LICENSE} +1 -28
  12. package/manifest.json +45 -133
  13. package/package.json +1 -1
  14. package/plugin/guancopilot.js +142 -112
  15. package/licenses/browser-highlight.js-LICENSE +0 -29
  16. package/licenses/github.com_davecgh_go-spew_v1.1.1-LICENSE +0 -15
  17. package/licenses/github.com_go-quicktest_qt_v1.101.0-LICENSE +0 -21
  18. package/licenses/github.com_golang-jwt_jwt_v5_v5.3.1-LICENSE +0 -9
  19. package/licenses/github.com_google_go-cmp_v0.7.0-LICENSE +0 -27
  20. package/licenses/github.com_hashicorp_golang-lru_v2_v2.0.7-LICENSE +0 -364
  21. package/licenses/github.com_kr_pretty_v0.3.1-License +0 -19
  22. package/licenses/github.com_kr_text_v0.2.0-License +0 -19
  23. package/licenses/github.com_pmezard_go-difflib_v1.0.0-LICENSE +0 -27
  24. package/licenses/github.com_rogpeppe_go-internal_v1.14.1-LICENSE +0 -27
  25. package/licenses/github.com_stretchr_testify_v1.11.1-LICENSE +0 -21
  26. package/licenses/golang.org_x_mod_v0.36.0-LICENSE +0 -27
  27. package/licenses/golang.org_x_mod_v0.38.0-LICENSE +0 -27
  28. package/licenses/golang.org_x_sync_v0.20.0-LICENSE +0 -27
  29. package/licenses/golang.org_x_tools_v0.45.0-LICENSE +0 -27
  30. package/licenses/golang.org_x_tools_v0.48.0-LICENSE +0 -27
  31. package/licenses/gopkg.in_yaml.v3_v3.0.1-LICENSE +0 -50
  32. package/licenses/gopkg.in_yaml.v3_v3.0.1-NOTICE +0 -13
  33. package/licenses/modernc.org_cc_v4_v4.28.4-LICENSE +0 -27
  34. package/licenses/modernc.org_ccgo_v4_v4.34.4-LICENSE +0 -27
  35. package/licenses/modernc.org_fileutil_v1.4.0-LICENSE +0 -27
  36. package/licenses/modernc.org_gc_v2_v2.6.5-LICENSE +0 -69
  37. package/licenses/modernc.org_gc_v3_v3.1.3-LICENSE +0 -69
  38. package/licenses/modernc.org_goabi0_v0.2.0-LICENSE +0 -26
  39. package/licenses/modernc.org_opt_v0.2.0-LICENSE +0 -27
  40. package/licenses/modernc.org_sortutil_v1.2.1-LICENSE +0 -27
  41. package/licenses/modernc.org_strutil_v1.2.1-LICENSE +0 -27
  42. package/licenses/modernc.org_token_v1.1.0-LICENSE +0 -27
@@ -1,75 +1,73 @@
1
- // GuanCopilot: console injection / manual BI installation. No auto-publish.
2
- (()=>{var Co=Object.create;var Ir=Object.defineProperty;var Oo=Object.getOwnPropertyDescriptor;var Io=Object.getOwnPropertyNames;var Mo=Object.getPrototypeOf,Lo=Object.prototype.hasOwnProperty;var No=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var zo=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Io(e))!Lo.call(t,i)&&i!==n&&Ir(t,i,{get:()=>e[i],enumerable:!(r=Oo(e,i))||r.enumerable});return t};var Do=(t,e,n)=>(n=t!=null?Co(Mo(t)):{},zo(e||!t||!t.__esModule?Ir(n,"default",{value:t,enumerable:!0}):n,t));var Ui=No((Rl,Bi)=>{function Ai(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(e=>{let n=t[e],r=typeof n;(r==="object"||r==="function")&&!Object.isFrozen(n)&&Ai(n)}),t}var pn=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function Ri(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function tt(t,...e){let n=Object.create(null);for(let r in t)n[r]=t[r];return e.forEach(function(r){for(let i in r)n[i]=r[i]}),n}var bs="</span>",ki=t=>!!t.scope,xs=(t,{prefix:e})=>{if(t.startsWith("language:"))return t.replace("language:","language-");if(t.includes(".")){let n=t.split(".");return[`${e}${n.shift()}`,...n.map((r,i)=>`${r}${"_".repeat(i+1)}`)].join(" ")}return`${e}${t}`},rr=class{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=Ri(e)}openNode(e){if(!ki(e))return;let n=xs(e.scope,{prefix:this.classPrefix});this.span(n)}closeNode(e){ki(e)&&(this.buffer+=bs)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},_i=(t={})=>{let e={children:[]};return Object.assign(e,t),e},ir=class t{constructor(){this.rootNode=_i(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let n=_i({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return typeof n=="string"?e.addText(n):n.children&&(e.openNode(n),n.children.forEach(r=>this._walk(e,r)),e.closeNode(n)),e}static _collapse(e){typeof e!="string"&&e.children&&(e.children.every(n=>typeof n=="string")?e.children=[e.children.join("")]:e.children.forEach(n=>{t._collapse(n)}))}},or=class extends ir{constructor(e){super(),this.options=e}addText(e){e!==""&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,n){let r=e.root;n&&(r.scope=`language:${n}`),this.add(r)}toHTML(){return new rr(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function qt(t){return t?typeof t=="string"?t:t.source:null}function Ci(t){return ht("(?=",t,")")}function ws(t){return ht("(?:",t,")*")}function ys(t){return ht("(?:",t,")?")}function ht(...t){return t.map(n=>qt(n)).join("")}function ks(t){let e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function sr(...t){return"("+(ks(t).capture?"":"?:")+t.map(r=>qt(r)).join("|")+")"}function Oi(t){return new RegExp(t.toString()+"|").exec("").length-1}function _s(t,e){let n=t&&t.exec(e);return n&&n.index===0}var Es=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function lr(t,{joinWith:e}){let n=0;return t.map(r=>{n+=1;let i=n,a=qt(r),s="";for(;a.length>0;){let o=Es.exec(a);if(!o){s+=a;break}s+=a.substring(0,o.index),a=a.substring(o.index+o[0].length),o[0][0]==="\\"&&o[1]?s+="\\"+String(Number(o[1])+i):(s+=o[0],o[0]==="("&&n++)}return s}).map(r=>`(${r})`).join(e)}var vs=/\b\B/,Ii="[a-zA-Z]\\w*",cr="[a-zA-Z_]\\w*",Mi="\\b\\d+(\\.\\d+)?",Li="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Ni="\\b(0b[01]+)",Ss="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Ts=(t={})=>{let e=/^#![ ]*\//;return t.binary&&(t.begin=ht(e,/.*\b/,t.binary,/\b.*/)),tt({scope:"meta",begin:e,end:/$/,relevance:0,"on:begin":(n,r)=>{n.index!==0&&r.ignoreMatch()}},t)},Zt={begin:"\\\\[\\s\\S]",relevance:0},As={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Zt]},Rs={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Zt]},Cs={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},dn=function(t,e,n={}){let r=tt({scope:"comment",begin:t,end:e,contains:[]},n);r.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=sr("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:ht(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},Os=dn("//","$"),Is=dn("/\\*","\\*/"),Ms=dn("#","$"),Ls={scope:"number",begin:Mi,relevance:0},Ns={scope:"number",begin:Li,relevance:0},zs={scope:"number",begin:Ni,relevance:0},Ds={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Zt,{begin:/\[/,end:/\]/,relevance:0,contains:[Zt]}]},$s={scope:"title",begin:Ii,relevance:0},Ps={scope:"title",begin:cr,relevance:0},Bs={begin:"\\.\\s*"+cr,relevance:0},Us=function(t){return Object.assign(t,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})},cn=Object.freeze({__proto__:null,APOS_STRING_MODE:As,BACKSLASH_ESCAPE:Zt,BINARY_NUMBER_MODE:zs,BINARY_NUMBER_RE:Ni,COMMENT:dn,C_BLOCK_COMMENT_MODE:Is,C_LINE_COMMENT_MODE:Os,C_NUMBER_MODE:Ns,C_NUMBER_RE:Li,END_SAME_AS_BEGIN:Us,HASH_COMMENT_MODE:Ms,IDENT_RE:Ii,MATCH_NOTHING_RE:vs,METHOD_GUARD:Bs,NUMBER_MODE:Ls,NUMBER_RE:Mi,PHRASAL_WORDS_MODE:Cs,QUOTE_STRING_MODE:Rs,REGEXP_MODE:Ds,RE_STARTERS_RE:Ss,SHEBANG:Ts,TITLE_MODE:$s,UNDERSCORE_IDENT_RE:cr,UNDERSCORE_TITLE_MODE:Ps});function Hs(t,e){t.input[t.index-1]==="."&&e.ignoreMatch()}function Fs(t,e){t.className!==void 0&&(t.scope=t.className,delete t.className)}function js(t,e){e&&t.beginKeywords&&(t.begin="\\b("+t.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",t.__beforeBegin=Hs,t.keywords=t.keywords||t.beginKeywords,delete t.beginKeywords,t.relevance===void 0&&(t.relevance=0))}function Gs(t,e){Array.isArray(t.illegal)&&(t.illegal=sr(...t.illegal))}function Ws(t,e){if(t.match){if(t.begin||t.end)throw new Error("begin & end are not supported with match");t.begin=t.match,delete t.match}}function qs(t,e){t.relevance===void 0&&(t.relevance=1)}var Zs=(t,e)=>{if(!t.beforeMatch)return;if(t.starts)throw new Error("beforeMatch cannot be used with starts");let n=Object.assign({},t);Object.keys(t).forEach(r=>{delete t[r]}),t.keywords=n.keywords,t.begin=ht(n.beforeMatch,Ci(n.begin)),t.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},t.relevance=0,delete n.beforeMatch},Ks=["of","and","for","in","not","or","if","then","parent","list","value"],Ys="keyword";function zi(t,e,n=Ys){let r=Object.create(null);return typeof t=="string"?i(n,t.split(" ")):Array.isArray(t)?i(n,t):Object.keys(t).forEach(function(a){Object.assign(r,zi(t[a],e,a))}),r;function i(a,s){e&&(s=s.map(o=>o.toLowerCase())),s.forEach(function(o){let c=o.split("|");r[c[0]]=[a,Xs(c[0],c[1])]})}}function Xs(t,e){return e?Number(e):Vs(t)?0:1}function Vs(t){return Ks.includes(t.toLowerCase())}var Ei={},ft=t=>{console.error(t)},vi=(t,...e)=>{console.log(`WARN: ${t}`,...e)},Tt=(t,e)=>{Ei[`${t}/${e}`]||(console.log(`Deprecated as of ${t}. ${e}`),Ei[`${t}/${e}`]=!0)},un=new Error;function Di(t,e,{key:n}){let r=0,i=t[n],a={},s={};for(let o=1;o<=e.length;o++)s[o+r]=i[o],a[o+r]=!0,r+=Oi(e[o-1]);t[n]=s,t[n]._emit=a,t[n]._multi=!0}function Qs(t){if(Array.isArray(t.begin)){if(t.skip||t.excludeBegin||t.returnBegin)throw ft("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),un;if(typeof t.beginScope!="object"||t.beginScope===null)throw ft("beginScope must be object"),un;Di(t,t.begin,{key:"beginScope"}),t.begin=lr(t.begin,{joinWith:""})}}function Js(t){if(Array.isArray(t.end)){if(t.skip||t.excludeEnd||t.returnEnd)throw ft("skip, excludeEnd, returnEnd not compatible with endScope: {}"),un;if(typeof t.endScope!="object"||t.endScope===null)throw ft("endScope must be object"),un;Di(t,t.end,{key:"endScope"}),t.end=lr(t.end,{joinWith:""})}}function el(t){t.scope&&typeof t.scope=="object"&&t.scope!==null&&(t.beginScope=t.scope,delete t.scope)}function tl(t){el(t),typeof t.beginScope=="string"&&(t.beginScope={_wrap:t.beginScope}),typeof t.endScope=="string"&&(t.endScope={_wrap:t.endScope}),Qs(t),Js(t)}function nl(t){function e(s,o){return new RegExp(qt(s),"m"+(t.case_insensitive?"i":"")+(t.unicodeRegex?"u":"")+(o?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(o,c){c.position=this.position++,this.matchIndexes[this.matchAt]=c,this.regexes.push([c,o]),this.matchAt+=Oi(o)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let o=this.regexes.map(c=>c[1]);this.matcherRe=e(lr(o,{joinWith:"|"}),!0),this.lastIndex=0}exec(o){this.matcherRe.lastIndex=this.lastIndex;let c=this.matcherRe.exec(o);if(!c)return null;let u=c.findIndex((f,b)=>b>0&&f!==void 0),p=this.matchIndexes[u];return c.splice(0,u),Object.assign(c,p)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(o){if(this.multiRegexes[o])return this.multiRegexes[o];let c=new n;return this.rules.slice(o).forEach(([u,p])=>c.addRule(u,p)),c.compile(),this.multiRegexes[o]=c,c}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(o,c){this.rules.push([o,c]),c.type==="begin"&&this.count++}exec(o){let c=this.getMatcher(this.regexIndex);c.lastIndex=this.lastIndex;let u=c.exec(o);if(this.resumingScanAtSamePosition()&&!(u&&u.index===this.lastIndex)){let p=this.getMatcher(0);p.lastIndex=this.lastIndex+1,u=p.exec(o)}return u&&(this.regexIndex+=u.position+1,this.regexIndex===this.count&&this.considerAll()),u}}function i(s){let o=new r;return s.contains.forEach(c=>o.addRule(c.begin,{rule:c,type:"begin"})),s.terminatorEnd&&o.addRule(s.terminatorEnd,{type:"end"}),s.illegal&&o.addRule(s.illegal,{type:"illegal"}),o}function a(s,o){let c=s;if(s.isCompiled)return c;[Fs,Ws,tl,Zs].forEach(p=>p(s,o)),t.compilerExtensions.forEach(p=>p(s,o)),s.__beforeBegin=null,[js,Gs,qs].forEach(p=>p(s,o)),s.isCompiled=!0;let u=null;return typeof s.keywords=="object"&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),u=s.keywords.$pattern,delete s.keywords.$pattern),u=u||/\w+/,s.keywords&&(s.keywords=zi(s.keywords,t.case_insensitive)),c.keywordPatternRe=e(u,!0),o&&(s.begin||(s.begin=/\B|\b/),c.beginRe=e(c.begin),!s.end&&!s.endsWithParent&&(s.end=/\B|\b/),s.end&&(c.endRe=e(c.end)),c.terminatorEnd=qt(c.end)||"",s.endsWithParent&&o.terminatorEnd&&(c.terminatorEnd+=(s.end?"|":"")+o.terminatorEnd)),s.illegal&&(c.illegalRe=e(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map(function(p){return rl(p==="self"?s:p)})),s.contains.forEach(function(p){a(p,c)}),s.starts&&a(s.starts,o),c.matcher=i(c),c}if(t.compilerExtensions||(t.compilerExtensions=[]),t.contains&&t.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return t.classNameAliases=tt(t.classNameAliases||{}),a(t)}function $i(t){return t?t.endsWithParent||$i(t.starts):!1}function rl(t){return t.variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(e){return tt(t,{variants:null},e)})),t.cachedVariants?t.cachedVariants:$i(t)?tt(t,{starts:t.starts?tt(t.starts):null}):Object.isFrozen(t)?tt(t):t}var il="11.11.1",ar=class extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}},nr=Ri,Si=tt,Ti=Symbol("nomatch"),ol=7,Pi=function(t){let e=Object.create(null),n=Object.create(null),r=[],i=!0,a="Could not find the language '{}', did you forget to load/include a language module?",s={disableAutodetect:!0,name:"Plain text",contains:[]},o={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:or};function c(g){return o.noHighlightRe.test(g)}function u(g){let m=g.className+" ";m+=g.parentNode?g.parentNode.className:"";let C=o.languageDetectRe.exec(m);if(C){let S=G(C[1]);return S||(vi(a.replace("{}",C[1])),vi("Falling back to no-highlight mode for this block.",g)),S?C[1]:"no-highlight"}return m.split(/\s+/).find(S=>c(S)||G(S))}function p(g,m,C){let S="",D="";typeof m=="object"?(S=g,C=m.ignoreIllegals,D=m.language):(Tt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Tt("10.7.0",`Please use highlight(code, options) instead.
3
- https://github.com/highlightjs/highlight.js/issues/2277`),D=g,S=m),C===void 0&&(C=!0);let Y={code:S,language:D};ae("before:highlight",Y);let le=Y.result?Y.result:f(Y.language,Y.code,C);return le.code=Y.code,ae("after:highlight",le),le}function f(g,m,C,S){let D=Object.create(null);function Y(M,B){return M.keywords[B]}function le(){if(!$.keywords){ie.addText(te);return}let M=0;$.keywordPatternRe.lastIndex=0;let B=$.keywordPatternRe.exec(te),Z="";for(;B;){Z+=te.substring(M,B.index);let J=ge.case_insensitive?B[0].toLowerCase():B[0],h=Y($,J);if(h){let[z,W]=h;if(ie.addText(Z),Z="",D[J]=(D[J]||0)+1,D[J]<=ol&&(ve+=W),z.startsWith("_"))Z+=B[0];else{let V=ge.classNameAliases[z]||z;Te(B[0],V)}}else Z+=B[0];M=$.keywordPatternRe.lastIndex,B=$.keywordPatternRe.exec(te)}Z+=te.substring(M),ie.addText(Z)}function de(){if(te==="")return;let M=null;if(typeof $.subLanguage=="string"){if(!e[$.subLanguage]){ie.addText(te);return}M=f($.subLanguage,te,!0,Ye[$.subLanguage]),Ye[$.subLanguage]=M._top}else M=x(te,$.subLanguage.length?$.subLanguage:null);$.relevance>0&&(ve+=M.relevance),ie.__addSublanguage(M._emitter,M.language)}function ce(){$.subLanguage!=null?de():le(),te=""}function Te(M,B){M!==""&&(ie.startScope(B),ie.addText(M),ie.endScope())}function re(M,B){let Z=1,J=B.length-1;for(;Z<=J;){if(!M._emit[Z]){Z++;continue}let h=ge.classNameAliases[M[Z]]||M[Z],z=B[Z];h?Te(z,h):(te=z,le(),te=""),Z++}}function gt(M,B){return M.scope&&typeof M.scope=="string"&&ie.openNode(ge.classNameAliases[M.scope]||M.scope),M.beginScope&&(M.beginScope._wrap?(Te(te,ge.classNameAliases[M.beginScope._wrap]||M.beginScope._wrap),te=""):M.beginScope._multi&&(re(M.beginScope,B),te="")),$=Object.create(M,{parent:{value:$}}),$}function Ne(M,B,Z){let J=_s(M.endRe,Z);if(J){if(M["on:end"]){let h=new pn(M);M["on:end"](B,h),h.isMatchIgnored&&(J=!1)}if(J){for(;M.endsParent&&M.parent;)M=M.parent;return M}}if(M.endsWithParent)return Ne(M.parent,B,Z)}function Ct(M){return $.matcher.regexIndex===0?(te+=M[0],1):(He=!0,0)}function Ot(M){let B=M[0],Z=M.rule,J=new pn(Z),h=[Z.__beforeBegin,Z["on:begin"]];for(let z of h)if(z&&(z(M,J),J.isMatchIgnored))return Ct(B);return Z.skip?te+=B:(Z.excludeBegin&&(te+=B),ce(),!Z.returnBegin&&!Z.excludeBegin&&(te=B)),gt(Z,M),Z.returnBegin?0:B.length}function ze(M){let B=M[0],Z=m.substring(M.index),J=Ne($,M,Z);if(!J)return Ti;let h=$;$.endScope&&$.endScope._wrap?(ce(),Te(B,$.endScope._wrap)):$.endScope&&$.endScope._multi?(ce(),re($.endScope,M)):h.skip?te+=B:(h.returnEnd||h.excludeEnd||(te+=B),ce(),h.excludeEnd&&(te=B));do $.scope&&ie.closeNode(),!$.skip&&!$.subLanguage&&(ve+=$.relevance),$=$.parent;while($!==J.parent);return J.starts&&gt(J.starts,M),h.returnEnd?0:B.length}function Ue(){let M=[];for(let B=$;B!==ge;B=B.parent)B.scope&&M.unshift(B.scope);M.forEach(B=>ie.openNode(B))}let Oe={};function rt(M,B){let Z=B&&B[0];if(te+=M,Z==null)return ce(),0;if(Oe.type==="begin"&&B.type==="end"&&Oe.index===B.index&&Z===""){if(te+=m.slice(B.index,B.index+1),!i){let J=new Error(`0 width match regex (${g})`);throw J.languageName=g,J.badRule=Oe.rule,J}return 1}if(Oe=B,B.type==="begin")return Ot(B);if(B.type==="illegal"&&!C){let J=new Error('Illegal lexeme "'+Z+'" for mode "'+($.scope||"<unnamed>")+'"');throw J.mode=$,J}else if(B.type==="end"){let J=ze(B);if(J!==Ti)return J}if(B.type==="illegal"&&Z==="")return te+=`
4
- `,1;if(qe>1e5&&qe>B.index*3)throw new Error("potential infinite loop, way more iterations than matches");return te+=Z,Z.length}let ge=G(g);if(!ge)throw ft(a.replace("{}",g)),new Error('Unknown language: "'+g+'"');let oe=nl(ge),De="",$=S||oe,Ye={},ie=new o.__emitter(o);Ue();let te="",ve=0,be=0,qe=0,He=!1;try{if(ge.__emitTokens)ge.__emitTokens(m,ie);else{for($.matcher.considerAll();;){qe++,He?He=!1:$.matcher.considerAll(),$.matcher.lastIndex=be;let M=$.matcher.exec(m);if(!M)break;let B=m.substring(be,M.index),Z=rt(B,M);be=M.index+Z}rt(m.substring(be))}return ie.finalize(),De=ie.toHTML(),{language:g,value:De,relevance:ve,illegal:!1,_emitter:ie,_top:$}}catch(M){if(M.message&&M.message.includes("Illegal"))return{language:g,value:nr(m),illegal:!0,relevance:0,_illegalBy:{message:M.message,index:be,context:m.slice(be-100,be+100),mode:M.mode,resultSoFar:De},_emitter:ie};if(i)return{language:g,value:nr(m),illegal:!1,relevance:0,errorRaised:M,_emitter:ie,_top:$};throw M}}function b(g){let m={value:nr(g),illegal:!1,relevance:0,_top:s,_emitter:new o.__emitter(o)};return m._emitter.addText(g),m}function x(g,m){m=m||o.languages||Object.keys(e);let C=b(g),S=m.filter(G).filter(N).map(ce=>f(ce,g,!1));S.unshift(C);let D=S.sort((ce,Te)=>{if(ce.relevance!==Te.relevance)return Te.relevance-ce.relevance;if(ce.language&&Te.language){if(G(ce.language).supersetOf===Te.language)return 1;if(G(Te.language).supersetOf===ce.language)return-1}return 0}),[Y,le]=D,de=Y;return de.secondBest=le,de}function T(g,m,C){let S=m&&n[m]||C;g.classList.add("hljs"),g.classList.add(`language-${S}`)}function k(g){let m=null,C=u(g);if(c(C))return;if(ae("before:highlightElement",{el:g,language:C}),g.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",g);return}if(g.children.length>0&&(o.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(g)),o.throwUnescapedHTML))throw new ar("One of your code blocks includes unescaped HTML.",g.innerHTML);m=g;let S=m.textContent,D=C?p(S,{language:C,ignoreIllegals:!0}):x(S);g.innerHTML=D.value,g.dataset.highlighted="yes",T(g,C,D.language),g.result={language:D.language,re:D.relevance,relevance:D.relevance},D.secondBest&&(g.secondBest={language:D.secondBest.language,relevance:D.secondBest.relevance}),ae("after:highlightElement",{el:g,result:D,text:S})}function O(g){o=Si(o,g)}let E=()=>{H(),Tt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function L(){H(),Tt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let I=!1;function H(){function g(){H()}if(document.readyState==="loading"){I||window.addEventListener("DOMContentLoaded",g,!1),I=!0;return}document.querySelectorAll(o.cssSelector).forEach(k)}function U(g,m){let C=null;try{C=m(t)}catch(S){if(ft("Language definition for '{}' could not be registered.".replace("{}",g)),i)ft(S);else throw S;C=s}C.name||(C.name=g),e[g]=C,C.rawDefinition=m.bind(null,t),C.aliases&&q(C.aliases,{languageName:g})}function A(g){delete e[g];for(let m of Object.keys(n))n[m]===g&&delete n[m]}function P(){return Object.keys(e)}function G(g){return g=(g||"").toLowerCase(),e[g]||e[n[g]]}function q(g,{languageName:m}){typeof g=="string"&&(g=[g]),g.forEach(C=>{n[C.toLowerCase()]=m})}function N(g){let m=G(g);return m&&!m.disableAutodetect}function R(g){g["before:highlightBlock"]&&!g["before:highlightElement"]&&(g["before:highlightElement"]=m=>{g["before:highlightBlock"](Object.assign({block:m.el},m))}),g["after:highlightBlock"]&&!g["after:highlightElement"]&&(g["after:highlightElement"]=m=>{g["after:highlightBlock"](Object.assign({block:m.el},m))})}function F(g){R(g),r.push(g)}function Q(g){let m=r.indexOf(g);m!==-1&&r.splice(m,1)}function ae(g,m){let C=g;r.forEach(function(S){S[C]&&S[C](m)})}function v(g){return Tt("10.7.0","highlightBlock will be removed entirely in v12.0"),Tt("10.7.0","Please use highlightElement now."),k(g)}Object.assign(t,{highlight:p,highlightAuto:x,highlightAll:H,highlightElement:k,highlightBlock:v,configure:O,initHighlighting:E,initHighlightingOnLoad:L,registerLanguage:U,unregisterLanguage:A,listLanguages:P,getLanguage:G,registerAliases:q,autoDetection:N,inherit:Si,addPlugin:F,removePlugin:Q}),t.debugMode=function(){i=!1},t.safeMode=function(){i=!0},t.versionString=il,t.regex={concat:ht,lookahead:Ci,either:sr,optional:ys,anyNumberOfTimes:ws};for(let g in cn)typeof cn[g]=="object"&&Ai(cn[g]);return Object.assign(t,cn),t},At=Pi({});At.newInstance=()=>Pi({});Bi.exports=At;At.HighlightJS=At;At.default=At});var zt="http://127.0.0.1:19090";function Dt(t=zt){let e;try{e=new URL(t.trim())}catch{throw new Error("\u8BF7\u8F93\u5165\u5B8C\u6574\u7684 guanloop \u5730\u5740\uFF08http:// \u6216 https://\uFF09")}if(!["http:","https:"].includes(e.protocol)||e.username||e.password||e.search||e.hash||e.pathname!=="/")throw new Error("guanloop \u5730\u5740\u53EA\u80FD\u5305\u542B\u534F\u8BAE\u3001\u4E3B\u673A\u548C\u7AEF\u53E3");return e.origin}function en(t){return!["127.0.0.1","localhost","[::1]"].includes(new URL(Dt(t)).hostname)}function st(t){return t.startsWith("/data-dev/offline-dev/")}function $o(t){let e=(t?.response||t)?.uIdToken;if(typeof e!="string"||!e.trim())throw new Error("BI \u672A\u8FD4\u56DE\u767B\u5F55\u51ED\u8BC1\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");return e}function Mr({fetch:t,origin:e,active:n,onLocalStatus:r=()=>{},baseUrl:i=zt,pairingCode:a="",domId:s=()=>""}){i=Dt(i),a=a.trim();let o=null,c=null,u=null,p=null;async function f(k,O,E){if(!n())throw new Error("\u8BF7\u56DE\u5230\u79BB\u7EBF\u5F00\u53D1\u9875\u9762");let L=AbortSignal.any([AbortSignal.timeout(E),...O.signal?[O.signal]:[]]),{responseType:I,...H}=O,U=await t(k,{...H,signal:L,cache:"no-store",redirect:"error"});if(!U.ok){let A=await U.json().catch(()=>null),P=new Error(A?.error||`\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${U.status}\uFF09`);throw P.status=U.status,P.submissionStatus=A?.submissionStatus,P.stage=A?.stage,P}return U.status===204?null:I==="blob"?U.blob():U.json()}async function b(){if(en(i)&&!a)throw new Error("\u8FDC\u7A0B guanloop \u9700\u8981 pairing code\uFF0C\u8BF7\u6253\u5F00\u8FDE\u63A5\u8BBE\u7F6E");return u&&u.expiresAt>Date.now()+6e4?u:(p||(p=f(i+"/api/browser-sessions",{method:"POST",credentials:"omit",headers:{"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{}},body:JSON.stringify({client:"guanloop-plugin"})},6e4).then(async k=>{if(typeof k?.token!="string"||!k.token||!Number.isFinite(k.expiresAt)||k.expiresAt<=Date.now())throw new Error("guanloop \u672A\u8FD4\u56DE\u6709\u6548\u4F1A\u8BDD");if(u=k,o&&(await f(i+"/api/bi-connections",{method:"POST",credentials:"omit",headers:{Authorization:`Bearer ${k.token}`,"Content-Type":"application/json"},body:JSON.stringify({baseUrl:e,domId:s(),uidToken:await T()})},3e4)).id!==o.id)throw o=null,u=null,new Error("BI \u8EAB\u4EFD\u53D1\u751F\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5");return u}).finally(()=>{p=null})),p)}async function x(k,{method:O="GET",body:E,rawBody:L,responseType:I,signal:H,timeout:U=12e4}={}){if(!k.startsWith("/api/"))throw new Error("\u65E0\u6548\u7684\u672C\u5730\u63A5\u53E3");try{let A=async q=>f(i+k,{method:O,signal:H,responseType:I,credentials:"omit",headers:{Authorization:`Bearer ${q.token}`,...E?{"Content-Type":"application/json"}:{}},...L!==void 0?{body:L}:E?{body:JSON.stringify(E)}:{}},U),P=await b(),G;try{G=await A(P)}catch(q){if(q.status!==401)throw q;u===P&&(u=null),G=await A(await b())}return r(!0),G}catch(A){throw A.name!=="AbortError"&&r(!!A.status&&![401,403].includes(A.status)),A}}async function T(){return $o(await f(e+"/api/user/token",{credentials:"include"},15e3))}return{api:x,async health(){let k=await x("/api/status",{timeout:4e3});if(k.service!=="guanloop"||k.status!=="ok")throw r(!1),new Error("\u6B64\u670D\u52A1\u5730\u5740\u672A\u8FDE\u63A5\u5230 guanloop");return k},async connect(){return await b(),o=await x("/api/bi-connections",{method:"POST",body:{baseUrl:e,domId:s(),uidToken:await T()}}),o},async refresh(){if(!o)throw new Error("\u8BF7\u5148\u8FDE\u63A5");return c||(c=(async()=>{let k=await x(`/api/bi-connections/${o.id}/credential`,{method:"PUT",body:{uidToken:await T(),domId:s()}});if(k.site!==o.site||k.principal!==o.principal||k.domId!==o.domId)throw new Error("BI \u8EAB\u4EFD\u53D1\u751F\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5");return k})().finally(()=>{c=null})),c}}}function Lr(t){return t.type==="userMessage"?(t.content||[]).filter(e=>e.type==="text").map(e=>e.text).join(`
5
- `):t.type==="agentMessage"?t.text||"":t.type==="commandExecution"?`$ ${t.command||""}
6
- ${t.aggregatedOutput||""}`:""}function Dn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ut=Dn();function Gr(t){ut=t}var ct={exec:()=>null};function _t(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=e[r];return i||(i=t(r),e[r]=i),i}}function X(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace(ye.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var Po=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),ye={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:_t(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:_t(t=>new RegExp(`^ {0,${t}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:_t(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:_t(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:_t(t=>new RegExp(`^ {0,${t}}(?:</?(?:${Ut})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,"i")),blockquoteBeginRegex:_t(t=>new RegExp(`^ {0,${t}}>`))},Bo=/^(?:[ \t]*(?:\n|$))+/,Uo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ho=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Bt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Fo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,$n=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Wr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,qr=X(Wr).replace(/bull/g,$n).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),jo=X(Wr).replace(/bull/g,$n).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Pn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Go=/^[^\n]+/,Bn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Wo=X(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Bn).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),qo=X(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,$n).getRegex(),Ut="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",Un=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Zo=X("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Un).replace("tag",Ut).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Zr=t=>X(Pn).replace("hr",Bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Ut).getRegex(),Ko=Zr(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Yo=Zr(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Xo=X(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Yo).getRegex(),Hn={blockquote:Xo,code:Uo,def:Wo,fences:Ho,heading:Fo,hr:Bt,html:Zo,lheading:qr,list:qo,newline:Bo,paragraph:Ko,table:ct,text:Go},Nr=X("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Ut).getRegex(),Vo={...Hn,lheading:jo,table:Nr,paragraph:X(Pn).replace("hr",Bt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Nr).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Ut).getRegex()},Qo={...Hn,html:X(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Un).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:ct,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:X(Pn).replace("hr",Bt).replace("heading",` *#{1,6} *[^
7
- ]`).replace("lheading",qr).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Jo=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ea=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Kr=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,ta=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,We=/[\p{P}\p{S}]/u,Et=/[\s\p{P}\p{S}]/u,Ht=/[^\s\p{P}\p{S}]/u,na=X(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Et).getRegex(),ra=/[\p{Pi}\p{Ps}"']/u,Yr=/(?!~)[\p{P}\p{S}]/u,ia=/(?!~)[\s\p{P}\p{S}]/u,oa=/(?:[^\s\p{P}\p{S}]|~)/u,aa=X(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Po?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Xr=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,sa=X(Xr,"u").replace(/punct/g,We).getRegex(),la=X(Xr,"u").replace(/punct/g,Yr).getRegex(),ca=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,pa=X(ca,"u").replace(/openQuote/g,ra).replace(/punct/g,We).getRegex(),Vr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ua=X(Vr,"gu").replace(/notPunctSpace/g,Ht).replace(/punctSpace/g,Et).replace(/punct/g,We).getRegex(),da=X(Vr,"gu").replace(/notPunctSpace/g,oa).replace(/punctSpace/g,ia).replace(/punct/g,Yr).getRegex(),fa="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",ha=X(fa,"gu").replace(/notPunctSpace/g,Ht).replace(/punctSpace/g,Et).replace(/punct/g,We).getRegex(),ga=X("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ht).replace(/punctSpace/g,Et).replace(/punct/g,We).getRegex(),ma="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",ba=X(ma,"gu").replace(/notPunctSpace/g,Ht).replace(/punctSpace/g,Et).replace(/punct/g,We).getRegex(),xa=X(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,We).getRegex(),wa="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ya=X(wa,"gu").replace(/notPunctSpace/g,Ht).replace(/punctSpace/g,Et).replace(/punct/g,We).getRegex(),ka=X(/\\(punct)/,"gu").replace(/punct/g,We).getRegex(),_a=X(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,"gu").replace(/punct/g,We).getRegex(),Ea=X(/^<(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(),va=X(Un).replace("(?:-->|$)","-->").getRegex(),Sa=X("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",va).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Qr=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,nn=X(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",Qr).getRegex(),Ta=X(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label",nn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Aa=X(/^!?\[(label)\]\[(ref)\]/).replace("label",nn).replace("ref",Bn).getRegex(),Ra=X(/^!?\[(ref)\](?:\[\])?/).replace("ref",Bn).getRegex(),zr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,Ca=X(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",Qr).getRegex(),Oa=X("reflink|nolink(?!\\()","g").replace("reflink",X(/^!?\[(label)\]\[(ref)\]/).replace("label",Ca).replace("ref",zr).getRegex()).replace("nolink",X(/^!?\[(ref)\](?:\[\])?/).replace("ref",zr).getRegex()).getRegex(),Dr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ia=/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/,Ma=X(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,Ia).getRegex(),Fn={_backpedal:ct,anyPunctuation:ka,anyPunctuationOutsideCode:_a,autolink:Ea,blockSkip:aa,br:Kr,code:ea,del:ct,delLDelim:ct,delRDelim:ct,emStrongLDelim:sa,emStrongRDelimAst:ua,emStrongRDelimUnd:ga,escape:Jo,link:Ta,nolink:Ra,punctuation:na,reflink:Aa,reflinkSearch:Oa,tag:Sa,text:ta,url:ct},La={...Fn,emStrongLDelim:pa,emStrongRDelimAst:ha,emStrongRDelimUnd:ba,link:X(/^!?\[(label)\]\((.*?)\)/).replace("label",nn).getRegex(),reflink:X(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",nn).getRegex()},Ln={...Fn,emStrongRDelimAst:da,emStrongLDelim:la,delLDelim:xa,delRDelim:ya,url:X(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol",Ma).replace("protocol",Dr).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:X(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol",Dr).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},Na={...Ln,br:X(Kr).replace("{2,}","*").getRegex(),text:X(Ln.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},tn={normal:Hn,gfm:Vo,pedantic:Qo},$t={normal:Fn,gfm:Ln,breaks:Na,pedantic:La},za={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},$r=t=>za[t];function Ie(t,e){if(e){if(ye.escapeTest.test(t))return t.replace(ye.escapeReplace,$r)}else if(ye.escapeTestNoEncode.test(t))return t.replace(ye.escapeReplaceNoEncode,$r);return t}function Da(t){return ye.numericCharacterReference.test(t)?t.replace(ye.numericCharacterReferenceOrAmpersand,(e,n,r)=>{if(n===void 0&&r===void 0)return"&amp;";let i=n===void 0?Number.parseInt(r,16):Number.parseInt(n,10);return i===0||i>1114111||i>=55296&&i<=57343?"\uFFFD":i===38?"&amp;":String.fromCodePoint(i)}):t}function Pr(t){try{t=encodeURI(t).replace(ye.percentDecode,"%")}catch{return null}return t}function Br(t,e){let n=t.replace(ye.findPipe,(a,s,o)=>{let c=!1,u=s;for(;--u>=0&&o[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(ye.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(ye.slashPipe,"|");return r}function Je(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r;){let a=t.charAt(r-i-1);if(a===e&&!n)i++;else if(a!==e&&n)i++;else break}return t.slice(0,r-i)}function Ur(t){let e=t.split(`
8
- `),n=e.length-1;for(;n>=0&&ye.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
9
- `)}function rn(t){return t.trim().toLowerCase().toUpperCase().toLowerCase()}function Hr(t,e){if(t.indexOf(e[0])===-1&&t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Mn(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let a=4-n%4;r+=" ".repeat(a),n+=a}else r+=i,n++;return r}function Fr(t,e,n,r,i){let a=e.href,s=e.title||null,o=t[1].replace(i.other.outputLinkReplace,"$1"),c=t[0].charAt(0)==="!",u=r.state.inLink,p=r.state.linkEmitted,f=r.state.inRawBlock;r.state.inLink=!0,r.state.linkEmitted=!1;let b=r.inlineTokens(o),x=r.state.linkEmitted;if(r.state.linkEmitted=p,r.state.inLink=u,!c){if(x){r.state.inRawBlock=f;return}r.state.linkEmitted=!0}return{type:c?"image":"link",raw:n,href:a,title:s,text:o,tokens:b}}function $a(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
10
- `).map(a=>{let s=a.match(n.other.beginningSpace);if(s===null)return a;let[o]=s;return a.slice(Math.min(o.length,i.length))}).join(`
11
- `)}function jr(t,e,n,r){if(!e.includes("<"))return!1;for(let i=0;i<e.length;i++){if(e[i]==="\\"){i++;continue}if(e[i]==="`"){let o=r.inline.code.exec(e.slice(i));if(o){i+=o[0].length-1;continue}}if(e[i]!=="<")continue;let a=t.slice(n+i),s=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(s){if(s[0].length>e.length-i)return!0;i+=s[0].length-1}}return!1}var on=class{options;rules;lexer;constructor(t){this.options=t||ut}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:Ur(e[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=$a(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=Je(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceTabChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Je(e[0],`
12
- `),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Je(e[0],`
13
- `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Je(e[0],`
1
+ // GuanCopilot — generated; edit frontend/src, then run npm run build.
2
+ "use strict";(()=>{function Ze(n=globalThis.crypto){if(typeof n.randomUUID=="function")return n.randomUUID();let e=n.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,i=>i.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var qt="http://127.0.0.1:19090";function Pt(n=qt){let e;try{e=new URL(n.trim())}catch{throw new Error("请输入完整的 guanloop 地址(http:// 或 https://)")}if(!["http:","https:"].includes(e.protocol)||e.username||e.password||e.search||e.hash||e.pathname!=="/")throw new Error("guanloop 地址只能包含协议、主机和端口");return e.origin}function Wt(n){return!["127.0.0.1","localhost","[::1]"].includes(new URL(Pt(n)).hostname)}var Gt=class extends Error{status;submissionStatus;stage;code;retryAfterMs;constructor(e,t){super(t?.error||`请求失败(HTTP ${e})`),this.status=e,this.submissionStatus=t?.submissionStatus,this.stage=t?.stage,this.code=t?.code,typeof t?.retryAfterMs=="number"&&Number.isFinite(t.retryAfterMs)&&(this.retryAfterMs=t.retryAfterMs)}};function fn(n,e,t="请返回当前应用页面"){return async(i,r={},o=3e4)=>{if(!e())throw new Error(t);let l=AbortSignal.any([AbortSignal.timeout(o),...r.signal?[r.signal]:[]]),{responseType:a,...d}=r,p=await n(i,{...d,signal:l,cache:"no-store",redirect:"error"});if(!p.ok)throw new Gt(p.status,await p.json().catch(()=>null));return p.status===204?null:a==="blob"?p.blob():p.json()}}function Ir(n){let e=Pt(n.baseUrl),t=(n.pairingCode||"").trim(),i=fn(n.fetch,n.active,n.inactiveMessage),r=fn(n.fetch,()=>!0),o=n.binding,l=n.onLocalStatus||(()=>{}),a=null,d=null,p=null,f=null,c=(v,L=!1)=>async(A,b={})=>{if(!A.startsWith("/api/"))throw new Error("无效的本地接口");let{method:y="GET",body:E,rawBody:_,responseType:U,signal:F,timeout:O=12e4,providerToken:q=""}=b;return(L?r:i)(e+A,{method:y,signal:F,responseType:U,credentials:"omit",headers:{Authorization:`Bearer ${v.token}`,...E?{"Content-Type":"application/json"}:{},...q?{"X-GuanCopilot-Provider":q}:{}},..._!==void 0?{body:_}:E?{body:JSON.stringify(E)}:{}},O)};async function m(){if(Wt(e)&&!t)throw new Error("远程 guanloop 需要 pairing code,请打开连接设置");return d&&d.expiresAt>Date.now()+6e4?d:(p||(p=(async()=>{let v=await i(e+"/api/browser-sessions",{method:"POST",credentials:"omit",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify({client:"guanloop-plugin"})},6e4);if(typeof v?.token!="string"||!v.token||!Number.isFinite(v.expiresAt)||v.expiresAt<=Date.now())throw new Error("guanloop 未返回有效会话");if(a){let L=a;try{let A=await o.connect(c(v),L);if(A.id!==L.id||A.site!==L.site||A.principal!==L.principal||A.domId!==L.domId)throw new Error("应用身份发生变化,请重新连接")}catch(A){throw a=null,d=null,o.reset?.(),A}}return d=v,v})().finally(()=>{p=null})),p)}let g=async(v,L)=>{if(!v.startsWith("/api/"))throw new Error("无效的本地接口");try{let A=await m(),b;try{b=await c(A)(v,L)}catch(y){if(!(y instanceof Gt)||y.status!==401)throw y;d===A&&(d=null),b=await c(await m())(v,L)}return l(!0),b}catch(A){throw A.name!=="AbortError"&&l(A instanceof Gt&&![401,403].includes(A.status)),A}};return{api:g,withdrawBrowserTools(v,L){!d||!a||d.expiresAt<=Date.now()||!/^[a-f0-9]{64}$/.test(L)||!v.startsWith(`/api/connections/${encodeURIComponent(a.id)}/webmcp?`)||r(e+v,{method:"DELETE",keepalive:!0,credentials:"omit",headers:{Authorization:`Bearer ${d.token}`,"X-GuanCopilot-Provider":L}},5e3).catch(()=>{})},async health(){let v=await g("/api/status",{timeout:4e3});if(v.service!=="guanloop"||v.status!=="ok")throw l(!1),new Error("此服务地址未连接到 guanloop");return v},async connect(){return await m(),a=await o.connect(g,a),a},async refresh(){if(!a)throw new Error("请先连接");return f||(f=o.refresh(g,a).finally(()=>{f=null})),f},async disconnect(){let v=a,L=d;try{v&&L&&await o.disconnect?.(c(L,!0),v)}finally{a=null,d=null,o.reset?.()}}}}function zn(n){return n.startsWith("/data-dev/offline-dev/")}function vo(n){let e=(n?.response||n)?.uIdToken;if(typeof e!="string"||!e.trim())throw new Error("BI 未返回登录凭证,请重新登录");return e}function Rr({fetch:n,origin:e,active:t,domId:i=()=>"",...r}){let o="请回到离线开发页面或当前观远 BI 页面",l=fn(n,t,o),a=async()=>vo(await l(e+"/api/user/token",{credentials:"include"},15e3));return Ir({fetch:n,active:t,...r,inactiveMessage:o,binding:{async connect(d){return d("/api/bi-connections",{method:"POST",body:{baseUrl:e,domId:i(),uidToken:await a()}})},async refresh(d,p){let f=await d(`/api/bi-connections/${p.id}/credential`,{method:"PUT",body:{uidToken:await a(),domId:i()}});if(f.site!==p.site||f.principal!==p.principal||f.domId!==p.domId)throw new Error("BI 身份发生变化,请重新连接");return f},async disconnect(d,p){await d(`/api/bi-connections/${p.id}`,{method:"DELETE",timeout:5e3})}}})}function Cr(n){return n.type==="userMessage"?(n.content||[]).filter(e=>e.type==="text").map(e=>e.text).join(`
3
+ `):n.type==="agentMessage"?n.text||"":n.type==="commandExecution"?`$ ${n.command||""}
4
+ ${n.aggregatedOutput||""}`:""}var Lr={schemaVersion:1,id:"guandata",name:"观远 BI",version:"0.2.0",platformApi:1,cli:"",browser:{entry:"guandata-inject.js",matches:["http://*/*","https://*/*"]},tools:{allowed:[]},vm:{commands:[],skills:[]}};function _r(n){return n.hybrid&&(n.hybrid.sites&&Object.freeze(n.hybrid.sites),Object.freeze(n.hybrid.browserTools),Object.freeze(n.hybrid.remoteTools),Object.freeze(n.hybrid)),Object.freeze(n.browser.matches),Object.freeze(n.browser),Object.freeze(n.tools.allowed),Object.freeze(n.tools),Object.freeze(n.vm.commands),Object.freeze(n.vm.skills),Object.freeze(n.vm),Object.freeze(n)}function Yt(n,e){let t;try{t=new URL(e)}catch{return!1}return!["http:","https:"].includes(t.protocol)||t.username||t.password?!1:n.browser.matches.some(i=>{if(!i.endsWith("/*"))return!1;let r=i.slice(0,-2);return r===t.origin||r===`${t.protocol}//*`})}function Or(n,e=n){function t(r){let o=n.find(l=>l.id===r);if(!o)throw new Error("此应用尚未安装");return o}function i(r,o){return e.find(l=>Yt(l,r)&&(l.id!=="guandata"||o))||null}return{applications:n,applicationById:t,detectApplication:i}}var{applications:Ss,applicationById:$n,detectApplication:Pr}=Or(Object.freeze([Lr].map(_r)));function Mr(n,e,t=""){let i=e&&t?$n(t):e?Pr(n.location.href,typeof n.GD?.getUser=="function"):$n("guandata");if(!i)throw new Error("请先打开已登录的观远 BI 页面");let r=i;if(!Yt(r,n.location.href))throw new Error(`当前网址不属于 ${r.name} 支持的站点,请打开对应应用页面`);if(r.id!=="guandata")throw new Error("此应用尚未安装");let o=()=>{try{return n.GD?.getUser?.()}catch{return}},l=()=>{let a=o();return JSON.stringify([a?.domId||"",a?.loginId||a?.name||""])};return{manifest:r,requiresBrowserTools:!1,requiresWindowBridge:!1,active(a){return Yt(r,n.location.href)&&(a?!!t||typeof n.GD?.getUser=="function":zn(n.location.pathname))},identity(a){let d=o();return{environment:`${a?.domId||d?.domId||d?.domainName||r.name} · ${n.location.host}`,account:a?.display||`${d?.loginId||d?.name||"未登录"}(待验证)`}},subscribeRoute(a,d){let p=n.GD;p?.on?.("gd-route-change",a),d.addEventListener("abort",()=>p?.off?.("gd-route-change",a),{once:!0})},session(a){let d,p=!1,f=()=>{p||(p=!0,a())},c=()=>{let m=l();if(!m)throw new Error(`请先登录 ${r.name},等待页面加载后重新连接`);if(d===void 0&&(d=m),p||m!==d)throw f(),new Error(`${r.name} 登录会话已变化,请重新连接`)};return{assertCurrent:c,client(m){let g=Rr({...m,origin:n.location.origin,domId:()=>o()?.domId||""});return{...g,async connect(){c();let v=await g.connect();return c(),v},async refresh(){c();let v=await g.refresh();return c(),v}}},tools(m){return c(),[]}}}}}var To=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,95}$/,Un=new WeakMap;function hn(n,e){let t=JSON.stringify(n);if(t===void 0||new TextEncoder().encode(t).length>e)throw new Error("WebMCP data exceeds its limit");return JSON.parse(t)}function Nr(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}var Bn=class extends EventTarget{mode="compat";#e=new Map;#n=new WeakMap;#r;constructor(e){super(),this.#r=e}async registerTool(e,t={}){if(t.signal?.throwIfAborted(),t.exposedTo?.length)throw new Error("Cross-origin exposure requires native WebMCP");if(!To.test(e.name)||typeof e.description!="string"||!e.description.trim()||new TextEncoder().encode(e.description).length>8192||typeof e.execute!="function"||!Nr(e.inputSchema)||e.inputSchema.type!=="object")throw new Error("Invalid WebMCP tool");if(this.#e.size>=128)throw new Error("Too many WebMCP tools");if(this.#e.has(e.name))throw new Error("WebMCP tool name already registered");let i={metadata:{name:e.name,description:e.description,inputSchema:hn(e.inputSchema,32768),annotations:hn(e.annotations||{},4096),origin:this.#r},execute:e.execute};this.#e.set(e.name,i),t.signal?.addEventListener("abort",()=>{this.#e.get(i.metadata.name)===i&&(this.#e.delete(i.metadata.name),this.dispatchEvent(new Event("toolchange")))},{once:!0}),this.dispatchEvent(new Event("toolchange"))}async getTools(e={}){if(e.fromOrigins?.some(t=>t!==this.#r))throw new Error("Cross-origin discovery requires native WebMCP");return[...this.#e.values()].sort((t,i)=>t.metadata.name.localeCompare(i.metadata.name)).map(t=>{let i=hn(t.metadata,49152);return this.#n.set(i,t),i})}async executeTool(e,t={},i={}){let r=this.#n.get(e);if(!r||this.#e.get(r.metadata.name)!==r)throw new Error("Stale or unknown WebMCP tool");if(!Nr(t))throw new Error("WebMCP input must be an object");let o=hn(t,262144),l=i.signal||new AbortController().signal;l.throwIfAborted();let a=()=>{},d=new Promise((p,f)=>{a=()=>f(l.reason),l.addEventListener("abort",a,{once:!0})});try{return await Promise.race([Promise.resolve().then(()=>(l.throwIfAborted(),r.execute(o,{signal:l}))),d])}finally{l.removeEventListener("abort",a)}}};function Dr(n){return!n||typeof n!="object"?!1:["registerTool","getTools","executeTool","addEventListener","removeEventListener"].every(e=>typeof n[e]=="function")}function zr(n){let e=n.modelContext;if(e!==void 0){if(!Dr(e))throw new Error("Unsupported native WebMCP API version");return Un.get(n)===e?{context:e,mode:"compat"}:{context:e,mode:"native"}}let t=n.defaultView?.navigator?.modelContext;if(t!==void 0){if(!Dr(t))throw new Error("Unsupported legacy WebMCP API version");return{context:t,mode:"legacy"}}let i=Un.get(n);return i||(i=new Bn(n.location.origin),Object.defineProperty(n,"modelContext",{value:i,configurable:!0}),Un.set(n,i)),{context:i,mode:"compat"}}async function $r(n,e,t){let i=new AbortController,r=AbortSignal.any([t,i.signal]);try{for(let o of e)r.throwIfAborted(),await n.registerTool(o,{signal:r})}catch(o){throw i.abort(),o}return()=>i.abort()}var Ur=/^[a-f0-9]{64}$/,Ao=/^[a-f0-9]{32}$/,Fn=n=>new TextEncoder().encode(JSON.stringify(n)).length,mn=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),Xt=class extends Error{};function Br(n,e){return e.throwIfAborted(),new Promise((t,i)=>{let r=()=>{clearTimeout(l),e.removeEventListener("abort",o)},o=()=>{r(),i(e.reason)},l=setTimeout(()=>{r(),t()},n);e.addEventListener("abort",o,{once:!0})})}function So(n,e){return e.throwIfAborted(),new Promise((t,i)=>{let r=()=>{o(),i(e.reason)},o=()=>e.removeEventListener("abort",r);e.addEventListener("abort",r,{once:!0}),n.then(l=>{o(),t(l)},l=>{o(),i(l)})})}var gn=class{#e;#n;#r;#i;#d;#b;#s;#t=new AbortController;#l=1;#o;#c;#y;#x=!1;#a="";#f;#u=new Map;#p=new Set;#w=!1;constructor(e){this.#e=e.api,this.#n=e.context,this.#r=e.manifest,this.#d=e.documentId,this.#b=e.origin,this.#i=`/api/connections/${encodeURIComponent(e.connectionId)}/webmcp`,this.#s=e.onStatus||(()=>{})}#h=()=>{this.#l++,this.#o?.abort.abort(),this.refresh().catch(()=>this.#g())};async start(){this.#t.signal.throwIfAborted(),this.#x||(this.#x=!0,this.#n.addEventListener("toolchange",this.#h));try{await this.refresh(),this.#y||=this.#E().catch(()=>this.#g())}catch(e){throw this.#g(),e}}refresh(){return this.#c||(this.#c=this.#k().finally(()=>{this.#c=void 0})),this.#c}async#k(){for(;!this.#t.signal.aborted&&(!this.#o||this.#o.generation!==this.#l);){let e=this.#l,t=await this.#n.getTools();if(this.#t.signal.aborted)return;if(e!==this.#l)continue;let i=new Map,r=[];for(let a of t)if(this.#r.tools.allowed.includes(a.name)){if(a.origin&&a.origin!==this.#b)throw new Error("Unexpected tool origin");if(i.has(a.name))throw new Error("Ambiguous tool name");i.set(a.name,a),r.push({name:a.name,description:a.description,inputSchema:a.inputSchema,annotations:{readOnlyHint:a.annotations?.readOnlyHint===!0,consequentialHint:a.annotations?.consequentialHint===!0,untrustedContentHint:a.annotations?.untrustedContentHint===!0}})}r.sort((a,d)=>a.name.localeCompare(d.name));let o=JSON.parse(JSON.stringify({version:1,appId:this.#r.id,cli:this.#r.cli,documentId:this.#d,generation:e,tools:r}));if(Fn(o)>524288)throw new Error("Tool directory exceeds limit");let l=await this.#v(o);if(!mn(l)||typeof l.revision!="string"||!Ur.test(l.revision)||l.cli!==this.#r.cli||typeof l.providerToken!="string"||!Ur.test(l.providerToken))throw new Error("Invalid mailbox publication");this.#a=l.providerToken,this.#f={documentId:this.#d,revision:l.revision},!(e!==this.#l||this.#t.signal.aborted)&&(this.#o?.abort.abort(),this.#o={documentId:this.#d,revision:l.revision,generation:e,handles:i,abort:new AbortController},this.#s({state:"ready",message:`${i.size} 个浏览器工具已连接`,count:i.size}))}}async#v(e){let t=Date.now()+5e4;for(;;){if(this.#t.signal.throwIfAborted(),Date.now()>=t)throw new Error("同一身份的另一个页面仍在使用浏览器工具,请关闭该页面后重连");try{return await this.#e.api(this.#i,{method:"PUT",body:e,providerToken:this.#a,signal:this.#t.signal,timeout:Math.min(3e4,Math.max(1,t-Date.now()))})}catch(i){let r=i;if(r.status!==409||r.code!=="BROWSER_PROVIDER_BUSY")throw i;let o=t-Date.now();if(o<=0)throw new Error("同一身份的另一个页面仍在使用浏览器工具,请关闭该页面后重连");this.#s({state:"waiting",message:"正在等待已有页面释放工具连接,将自动重连;刷新后可能需等待约 45 秒。若另一页面仍在线,请先关闭该页面。"});let l=typeof r.retryAfterMs=="number"&&Number.isFinite(r.retryAfterMs)?r.retryAfterMs:1e3;await Br(Math.min(1e3,Math.max(100,l),o),this.#t.signal)}}}pagehide(){if(this.#w)return;this.#w=!0;let e=this.#f;try{e&&this.#a&&this.#e.withdrawBrowserTools?.(this.#i+this.#m(e),this.#a)}catch{}}#m(e){return`?documentId=${encodeURIComponent(e.documentId)}&revision=${encodeURIComponent(e.revision)}`}async#E(){let e=250;for(;!this.#t.signal.aborted;){await this.refresh();let t=this.#o;if(!t||t.abort.signal.aborted)continue;let i=AbortSignal.any([this.#t.signal,t.abort.signal]);try{let r=await this.#e.api(`${this.#i}/poll${this.#m(t)}`,{signal:i,timeout:25e3,providerToken:this.#a});if(i.aborted)continue;if(!mn(r)||!Array.isArray(r.requests)||r.requests.length>1||!Array.isArray(r.cancelled)||r.cancelled.length>16)throw new Xt("Invalid mailbox batch");e=250;for(let o of r.cancelled)typeof o=="string"&&this.#u.get(o)?.abort();for(let o of r.requests){if(!mn(o)||typeof o.requestId!="string"||!Ao.test(o.requestId))throw new Xt("Invalid mailbox request");this.#p.has(o.requestId)||(this.#p.add(o.requestId),this.#p.size>1024&&this.#p.delete(this.#p.values().next().value),this.#T(t,o))}}catch(r){if(i.aborted)continue;if(r instanceof Xt)throw r;let o=r?.status;if(o&&[400,401,403,404,409].includes(o))throw new Error("Browser provider needs reconnection");this.#s({state:"error",message:"浏览器工具连接暂不可用,正在重连"}),await Br(e,this.#t.signal),e=Math.min(e*2,5e3)}}}async#T(e,t){let i=new AbortController,r=AbortSignal.any([i.signal,e.abort.signal,this.#t.signal]),o=Math.min(t.deadline-Date.now(),12e4),l=setTimeout(()=>i.abort(),Math.max(o,0)),a=this.#a,d={requestId:t.requestId,documentId:e.documentId,revision:e.revision},p;try{if(this.#u.size>=16||t.documentId!==e.documentId||t.revision!==e.revision||!Number.isFinite(o)||o<=0||!mn(t.arguments)||Fn(t.arguments)>262144)throw new Error("Stale or invalid tool invocation");let f=e.handles.get(t.tool);if(!f)throw new Error("Tool is not available");this.#u.set(t.requestId,i),r.throwIfAborted();let c=Promise.resolve().then(()=>(r.throwIfAborted(),this.#n.executeTool(f,t.arguments,{signal:r}))),m=await So(c,r),g=m===void 0?null:m;if(Fn(g)>4<<20)throw new Error("Tool result exceeds limit");p={...d,result:g}}catch{p={...d,error:{code:"TOOL_ERROR",message:"browser tool failed",outcome:"unknown"}}}finally{clearTimeout(l),this.#u.delete(t.requestId)}if(!(this.#t.signal.aborted||e.abort.signal.aborted))try{await this.#e.api(`${this.#i}/results`,{method:"POST",body:p,providerToken:a,signal:this.#t.signal,timeout:1e4})}catch{this.#t.signal.aborted||this.#s({state:"error",message:"工具结果未确认,请检查任务状态"})}}#g(){this.#t.signal.aborted||(this.#t.abort(),this.#o?.abort.abort(),this.#n.removeEventListener("toolchange",this.#h),this.#s({state:"error",message:"浏览器工具连接已停止,请重新连接当前页面",terminal:!0}))}async stop(){this.#t.abort(),this.#o?.abort.abort(),this.#n.removeEventListener("toolchange",this.#h);try{await this.#c}catch{}let e=this.#f,t=this.#a;if(e&&t)try{await this.#e.api(this.#i+this.#m(e),{method:"DELETE",providerToken:t,signal:AbortSignal.timeout(5e3),timeout:5e3})}catch{}this.#a="",this.#s({state:"stopped",message:"浏览器工具已断开"})}};var bn=class{#e=new AbortController;#n;#r;#i;constructor(e){this.#i=e}async start(){let e=this.#i,t=this.#e.signal;t.throwIfAborted();let{context:i}=zr(e.document);this.#r=await $r(i,e.tools,t),t.throwIfAborted();let r=e.document.defaultView.crypto.getRandomValues(new Uint8Array(16));this.#n=new gn({api:e.api,context:i,manifest:e.manifest,connectionId:e.connectionId,documentId:Array.from(r,o=>o.toString(16).padStart(2,"0")).join(""),origin:e.document.location.origin,onStatus:e.onStatus});try{await this.#n.start()}catch(o){throw await this.stop(),o}}async stop(){let e=this.#n?.stop();this.#e.abort(),this.#r?.(),await e}pagehide(){this.#n?.pagehide()}};function Fr(n,e){return{update(){},reset(){},connect(){},linked:()=>!1}}function Wn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yt=Wn();function Qr(n){yt=n}var xt={exec:()=>null};function Mt(n){let e=[];return t=>{let i=Math.max(0,Math.min(3,t-1)),r=e[i];return r||(r=n(i),e[i]=r),r}}function B(n,e=""){let t=typeof n=="string"?n:n.source,i={replace:(r,o)=>{let l=typeof o=="string"?o:o.source;return l=l.replace(ue.caret,"$1"),t=t.replace(r,l),i},getRegex:()=>new RegExp(t,e)};return i}var Io=((n="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+n)}catch{return!1}})(),ue={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Mt(n=>new RegExp(`^ {0,${n}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Mt(n=>new RegExp(`^ {0,${n}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Mt(n=>new RegExp(`^ {0,${n}}(?:\`\`\`|~~~)`)),headingBeginRegex:Mt(n=>new RegExp(`^ {0,${n}}#`)),htmlBeginRegex:Mt(n=>new RegExp(`^ {0,${n}}(?:</?(?:${Qt})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,"i")),blockquoteBeginRegex:Mt(n=>new RegExp(`^ {0,${n}}>`))},Ro=/^(?:[ \t]*(?:\n|$))+/,Co=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Lo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Kt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,_o=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Yn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Jr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ei=B(Jr).replace(/bull/g,Yn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Oo=B(Jr).replace(/bull/g,Yn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Xn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Po=/^[^\n]+/,Vn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Mo=B(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Vn).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),No=B(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Yn).getRegex(),Qt="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",Zn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Do=B("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Zn).replace("tag",Qt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ti=n=>B(Xn).replace("hr",Kt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",n).replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Qt).getRegex(),zo=ti(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),$o=ti(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Uo=B(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",$o).getRegex(),Kn={blockquote:Uo,code:Co,def:Mo,fences:Lo,heading:_o,hr:Kt,html:Do,lheading:ei,list:No,newline:Ro,paragraph:zo,table:xt,text:Po},Hr=B("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Kt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Qt).getRegex(),Bo={...Kn,lheading:Oo,table:Hr,paragraph:B(Xn).replace("hr",Kt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Hr).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Qt).getRegex()},Fo={...Kn,html:B(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Zn).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:xt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:B(Xn).replace("hr",Kt).replace("heading",` *#{1,6} *[^
5
+ ]`).replace("lheading",ei).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ho=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,jo=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ni=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Go=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ke=/[\p{P}\p{S}]/u,Nt=/[\s\p{P}\p{S}]/u,Jt=/[^\s\p{P}\p{S}]/u,qo=B(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Nt).getRegex(),Wo=/[\p{Pi}\p{Ps}"']/u,ri=/(?!~)[\p{P}\p{S}]/u,Yo=/(?!~)[\s\p{P}\p{S}]/u,Xo=/(?:[^\s\p{P}\p{S}]|~)/u,Vo=B(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Io?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ii=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Zo=B(ii,"u").replace(/punct/g,Ke).getRegex(),Ko=B(ii,"u").replace(/punct/g,ri).getRegex(),Qo=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Jo=B(Qo,"u").replace(/openQuote/g,Wo).replace(/punct/g,Ke).getRegex(),oi="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ea=B(oi,"gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),ta=B(oi,"gu").replace(/notPunctSpace/g,Xo).replace(/punctSpace/g,Yo).replace(/punct/g,ri).getRegex(),na="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",ra=B(na,"gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),ia=B("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),oa="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",aa=B(oa,"gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),sa=B(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ke).getRegex(),la="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ca=B(la,"gu").replace(/notPunctSpace/g,Jt).replace(/punctSpace/g,Nt).replace(/punct/g,Ke).getRegex(),pa=B(/\\(punct)/,"gu").replace(/punct/g,Ke).getRegex(),da=B(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,"gu").replace(/punct/g,Ke).getRegex(),ua=B(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),fa=B(Zn).replace("(?:-->|$)","-->").getRegex(),ha=B("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",fa).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ai=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,wn=B(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",ai).getRegex(),ma=B(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label",wn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ga=B(/^!?\[(label)\]\[(ref)\]/).replace("label",wn).replace("ref",Vn).getRegex(),ba=B(/^!?\[(ref)\](?:\[\])?/).replace("ref",Vn).getRegex(),jr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,xa=B(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",ai).getRegex(),wa=B("reflink|nolink(?!\\()","g").replace("reflink",B(/^!?\[(label)\]\[(ref)\]/).replace("label",xa).replace("ref",jr).getRegex()).replace("nolink",B(/^!?\[(ref)\](?:\[\])?/).replace("ref",jr).getRegex()).getRegex(),Gr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ya=/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/,ka=B(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,ya).getRegex(),Qn={_backpedal:xt,anyPunctuation:pa,anyPunctuationOutsideCode:da,autolink:ua,blockSkip:Vo,br:ni,code:jo,del:xt,delLDelim:xt,delRDelim:xt,emStrongLDelim:Zo,emStrongRDelimAst:ea,emStrongRDelimUnd:ia,escape:Ho,link:ma,nolink:ba,punctuation:qo,reflink:ga,reflinkSearch:wa,tag:ha,text:Go,url:xt},va={...Qn,emStrongLDelim:Jo,emStrongRDelimAst:ra,emStrongRDelimUnd:aa,link:B(/^!?\[(label)\]\((.*?)\)/).replace("label",wn).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",wn).getRegex()},jn={...Qn,emStrongRDelimAst:ta,emStrongLDelim:Ko,delLDelim:sa,delRDelim:ca,url:B(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol",ka).replace("protocol",Gr).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:B(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol",Gr).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},Ea={...jn,br:B(ni).replace("{2,}","*").getRegex(),text:B(jn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},xn={normal:Kn,gfm:Bo,pedantic:Fo},Vt={normal:Qn,gfm:jn,breaks:Ea,pedantic:va},Ta={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},qr=n=>Ta[n];function _e(n,e){if(e){if(ue.escapeTest.test(n))return n.replace(ue.escapeReplace,qr)}else if(ue.escapeTestNoEncode.test(n))return n.replace(ue.escapeReplaceNoEncode,qr);return n}function Aa(n){return ue.numericCharacterReference.test(n)?n.replace(ue.numericCharacterReferenceOrAmpersand,(e,t,i)=>{if(t===void 0&&i===void 0)return"&amp;";let r=t===void 0?Number.parseInt(i,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?"�":r===38?"&amp;":String.fromCodePoint(r)}):n}function Wr(n){try{n=encodeURI(n).replace(ue.percentDecode,"%")}catch{return null}return n}function Yr(n,e){let t=n.replace(ue.findPipe,(o,l,a)=>{let d=!1,p=l;for(;--p>=0&&a[p]==="\\";)d=!d;return d?"|":" |"}),i=t.split(ue.splitPipe),r=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(ue.slashPipe,"|");return i}function pt(n,e,t){let i=n.length;if(i===0)return"";let r=0;for(;r<i;){let o=n.charAt(i-r-1);if(o===e&&!t)r++;else if(o!==e&&t)r++;else break}return n.slice(0,i-r)}function Xr(n){let e=n.split(`
6
+ `),t=e.length-1;for(;t>=0&&ue.blankLine.test(e[t]);)t--;return e.length-t<=2?n:e.slice(0,t+1).join(`
7
+ `)}function yn(n){return n.trim().toLowerCase().toUpperCase().toLowerCase()}function Vr(n,e){if(n.indexOf(e[0])===-1&&n.indexOf(e[1])===-1)return-1;let t=0;for(let i=0;i<n.length;i++)if(n[i]==="\\")i++;else if(n[i]===e[0])t++;else if(n[i]===e[1]&&(t--,t<0))return i;return t>0?-2:-1}function Hn(n,e=0){let t=e,i="";for(let r of n)if(r===" "){let o=4-t%4;i+=" ".repeat(o),t+=o}else i+=r,t++;return i}function Zr(n,e,t,i,r){let o=e.href,l=e.title||null,a=n[1].replace(r.other.outputLinkReplace,"$1"),d=n[0].charAt(0)==="!",p=i.state.inLink,f=i.state.linkEmitted,c=i.state.inRawBlock;i.state.inLink=!0,i.state.linkEmitted=!1;let m=i.inlineTokens(a),g=i.state.linkEmitted;if(i.state.linkEmitted=f,i.state.inLink=p,!d){if(g){i.state.inRawBlock=c;return}i.state.linkEmitted=!0}return{type:d?"image":"link",raw:t,href:o,title:l,text:a,tokens:m}}function Sa(n,e,t){let i=n.match(t.other.indentCodeCompensation);if(i===null)return e;let r=i[1];return e.split(`
8
+ `).map(o=>{let l=o.match(t.other.beginningSpace);if(l===null)return o;let[a]=l;return o.slice(Math.min(a.length,r.length))}).join(`
9
+ `)}function Kr(n,e,t,i){if(!e.includes("<"))return!1;for(let r=0;r<e.length;r++){if(e[r]==="\\"){r++;continue}if(e[r]==="`"){let a=i.inline.code.exec(e.slice(r));if(a){r+=a[0].length-1;continue}}if(e[r]!=="<")continue;let o=n.slice(t+r),l=i.inline.tag.exec(o)||i.inline.autolink.exec(o);if(l){if(l[0].length>e.length-r)return!0;r+=l[0].length-1}}return!1}var kn=class{options;rules;lexer;constructor(n){this.options=n||yt}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=this.options.pedantic?e[0]:Xr(e[0]),i=t.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t,codeBlockStyle:"indented",text:i}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],i=Sa(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:i}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let i=pt(t,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceTabChar.test(i))&&(t=i.trim())}return{type:"heading",raw:pt(e[0],`
10
+ `),depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:pt(e[0],`
11
+ `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=pt(e[0],`
14
12
  `).split(`
15
- `),r="",i="",a=[];for(;n.length>0;){let s=!1,o=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))o.push(n[c]),s=!0;else if(!s)o.push(n[c]);else break;n=n.slice(c);let u=o.join(`
16
- `),p=u.replace(this.rules.other.blockquoteSetextReplace,`
17
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
18
- ${u}`:u,i=i?`${i}
19
- ${p}`:p;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,a,!0),this.lexer.state.top=f,n.length===0)break;let b=a.at(-1);if(b?.type==="code"||b?.type==="heading"||b?.type==="hr"||b?.type==="html")break;if(b?.type==="blockquote"){let x=b,T=n.join(`
20
- `),k=x.raw+`
21
- `+T.replace(this.rules.other.blockquoteSetextReplace2,""),O=this.blockquote(k);a[a.length-1]=O;let E=k.substring(O.raw.length).replace(/^\n/,""),L=E?E.split(`
22
- `).length:0,I=L?n.slice(0,-L):n;I.length>0&&(r=`${r}
23
- ${I.join(`
24
- `)}`),i=i.substring(0,i.length-x.text.length)+O.text;break}else if(b?.type==="list"){let x=b,T=x.raw+`
25
- `+n.join(`
26
- `),k=this.list(T);a[a.length-1]=k,r=r.substring(0,r.length-b.raw.length)+k.raw,i=i.substring(0,i.length-x.raw.length)+k.raw,n=T.substring(a.at(-1).raw.length).split(`
27
- `);continue}}return{type:"blockquote",raw:r,tokens:a,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=t,r=()=>n.length-t.length,i=e[1].trim(),a=i.length>1,s={type:"list",raw:"",ordered:a,start:a?+i.slice(0,-1):"",loose:!1,items:[]};i=a?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=a?i:"[*+-]");let o=this.rules.other.listItemRegex(i),c=!1;for(;t;){let p=!1,f="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;let b=r();t=t.substring(e[0].length);let x=e[2].split(`
28
- `,1)[0],T=e[1].length,k=this.options.pedantic?Mn(x,T):x.replace(this.rules.other.leadingSpaceTab,H=>Mn(H,T)),O=t.split(`
29
- `,1)[0],E=!k.trim(),L=0;if(this.options.pedantic?(L=2,f=k.trimStart()):E?L=T+1:(L=k.search(this.rules.other.nonSpaceChar),L=L>4?1:L,f=k.slice(L),L+=T),E&&this.rules.other.blankLine.test(O)&&(t=t.substring(O.length+1),p=!0),!p){let H=this.rules.other.nextBulletRegex(L),U=this.rules.other.hrRegex(L),A=this.rules.other.fencesBeginRegex(L),P=this.rules.other.headingBeginRegex(L),G=this.rules.other.htmlBeginRegex(L),q=this.rules.other.blockquoteBeginRegex(L);for(;t;){let N=t.split(`
30
- `,1)[0],R;if(O=N,this.options.pedantic?(O=O.replace(this.rules.other.listReplaceNesting," "),R=O):R=O.replace(this.rules.other.leadingSpaceTab,F=>Mn(F)),A.test(O)||P.test(O)||G.test(O)||q.test(O)||H.test(O)||U.test(O))break;if(R.search(this.rules.other.nonSpaceChar)>=L||!O.trim())f+=`
31
- `+R.slice(L);else{if(E||k.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||A.test(k)||P.test(k)||U.test(k))break;f+=`
32
- `+O}E=!O.trim(),t=t.substring(N.length+1),k=R.slice(L)}}let I=n.slice(b,r());s.loose||(c?s.loose=!0:this.rules.other.doubleBlankLine.test(I)&&(c=!0)),s.items.push({type:"list_item",raw:I,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,tokens:[]})}let u=s.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;s.raw=n.slice(0,r()).trimEnd();for(let p of s.items)if(this.lexer.state.top=!1,p.tokens=this.lexer.blockTokens(p.text,[]),!s.loose){let f=p.tokens.filter(x=>x.type==="space"),b=f.length>0&&f.some(x=>this.rules.other.anyLine.test(x.raw));s.loose=b}for(let p of s.items){let f=p.tokens[0];if(p.task&&(f?.type==="text"||f?.type==="paragraph")){p.text=p.text.replace(this.rules.other.listReplaceTask,""),f.raw=f.raw.replace(this.rules.other.listReplaceTask,""),f.text=f.text.replace(this.rules.other.listReplaceTask,"");for(let x=this.lexer.inlineQueue.length-1;x>=0;x--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[x].src)){this.lexer.inlineQueue[x].src=this.lexer.inlineQueue[x].src.replace(this.rules.other.listReplaceTask,"");break}let b=this.rules.other.listTaskCheckbox.exec(p.raw);if(b){let x={type:"checkbox",raw:b[0]+" ",checked:b[0]!=="[ ]"};p.checked=x.checked,s.loose?p.tokens[0]&&["paragraph","text"].includes(p.tokens[0].type)&&"tokens"in p.tokens[0]&&p.tokens[0].tokens?(p.tokens[0].raw=x.raw+p.tokens[0].raw,p.tokens[0].text=x.raw+p.tokens[0].text,p.tokens[0].tokens.unshift(x)):p.tokens.unshift({type:"paragraph",raw:x.raw,text:x.raw,tokens:[x]}):p.tokens.unshift(x)}}else p.task&&(p.task=!1)}if(s.loose)for(let p of s.items){p.loose=!0;for(let f of p.tokens)f.type==="text"&&(f.type="paragraph")}return s}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=Ur(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){if(!this.rules.other.startAngleBracket.test(e[2])&&Hr(e[2],"()")!==-1)return;let n=rn(e[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:Je(e[0],`
33
- `),href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Br(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
34
- `):[],a={type:"table",raw:Je(e[0],`
35
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let s of r)this.rules.other.tableAlignRight.test(s)?a.align.push("right"):this.rules.other.tableAlignCenter.test(s)?a.align.push("center"):this.rules.other.tableAlignLeft.test(s)?a.align.push("left"):a.align.push(null);for(let s=0;s<n.length;s++)a.header.push({text:n[s],tokens:this.lexer.inline(n[s]),header:!0,align:a.align[s]});for(let s of i)a.rows.push(Br(s,a.header.length).map((o,c)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:a.align[c]})));return a}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:Je(e[0],`
36
- `),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
37
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){if(this.lexer.state.linkParenPossible===!1)return;let e=this.rules.inline.link.exec(t);if(e){let n=e[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&jr(t,e[1],n,this.rules))return;let r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let s=Je(r.slice(0,-1),"\\");if((r.length-s.length)%2===0)return}else{let s=Hr(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let i=e[2],a="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(i);s&&(i=s[1],a=s[3])}else a=e[3]?e[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i=i.slice(1):i=i.slice(1,-1)),Fr(e,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=n[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&jr(t,n[1],r,this.rules))return;let i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=e[rn(i)];if(!a){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return Fr(n,a,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,s,o=i,c=0,u=r[0][0],p=n===u,f=u==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(f.lastIndex=0,e=e.slice(-1*t.length+i);(r=f.exec(e))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(s=[...a].length,r[3]||r[4]){o+=s;continue}else if(r[5]||r[6]){if(i%3&&!((i+s)%3)){c+=s;continue}if(p)break}if(o-=s,o>0)continue;s=Math.min(s,s+o+c);let b=[...r[0]][0].length,x=t.slice(0,i+r.index+b+s);if(Math.min(i,s)%2){let k=x.slice(1,-1);return{type:"em",raw:x,text:k,tokens:this.lexer.inlineTokens(k)}}let T=x.slice(2,-2);return{type:"strong",raw:x,text:T,tokens:this.lexer.inlineTokens(T)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,a,s,o=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*t.length+i);(r=c.exec(e))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a||(s=[...a].length,s!==i))continue;if(r[3]||r[4]){o+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o);let u=[...r[0]][0].length,p=t.slice(0,i+r.index+u+s),f=p.slice(i,-i);return{type:"del",raw:p,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,autolink:!0,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,autolink:!0,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:n?e[0]:Da(e[0]),escaped:n}}}},Pe=class Nn{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ut,this.options.tokenizer=this.options.tokenizer||new on,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let n={other:ye,block:tn.normal,inline:$t.normal};this.options.pedantic?(n.block=tn.pedantic,n.inline=$t.pedantic):this.options.gfm&&(n.block=tn.gfm,this.options.breaks?n.inline=$t.breaks:n.inline=$t.gfm),this.tokenizer.rules=n}static get rules(){return{block:tn,inline:$t}}static lex(e,n){return new Nn(n).lex(e)}static lexInline(e,n){return new Nn(n).inlineTokens(e)}lex(e){e=e.replace(ye.carriageReturn,`
38
- `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ye.tabCharGlobal," ").replace(ye.spaceLine,""));let i=1/0;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let a;if(this.options.extensions?.block?.some(o=>(a=o.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let o=n.at(-1);a.raw.length===1&&o!==void 0?o.raw+=`
39
- `:n.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
13
+ `),i="",r="",o=[];for(;t.length>0;){let l=!1,a=[],d;for(d=0;d<t.length;d++)if(this.rules.other.blockquoteStart.test(t[d]))a.push(t[d]),l=!0;else if(!l)a.push(t[d]);else break;t=t.slice(d);let p=a.join(`
14
+ `),f=p.replace(this.rules.other.blockquoteSetextReplace,`
15
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
16
+ ${p}`:p,r=r?`${r}
17
+ ${f}`:f;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,o,!0),this.lexer.state.top=c,t.length===0)break;let m=o.at(-1);if(m?.type==="code"||m?.type==="heading"||m?.type==="hr"||m?.type==="html")break;if(m?.type==="blockquote"){let g=m,v=t.join(`
18
+ `),L=g.raw+`
19
+ `+v.replace(this.rules.other.blockquoteSetextReplace2,""),A=this.blockquote(L);o[o.length-1]=A;let b=L.substring(A.raw.length).replace(/^\n/,""),y=b?b.split(`
20
+ `).length:0,E=y?t.slice(0,-y):t;E.length>0&&(i=`${i}
21
+ ${E.join(`
22
+ `)}`),r=r.substring(0,r.length-g.text.length)+A.text;break}else if(m?.type==="list"){let g=m,v=g.raw+`
23
+ `+t.join(`
24
+ `),L=this.list(v);o[o.length-1]=L,i=i.substring(0,i.length-m.raw.length)+L.raw,r=r.substring(0,r.length-g.raw.length)+L.raw,t=v.substring(o.at(-1).raw.length).split(`
25
+ `);continue}}return{type:"blockquote",raw:i,tokens:o,text:r}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=n,i=()=>t.length-n.length,r=e[1].trim(),o=r.length>1,l={type:"list",raw:"",ordered:o,start:o?+r.slice(0,-1):"",loose:!1,items:[]};r=o?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=o?r:"[*+-]");let a=this.rules.other.listItemRegex(r),d=!1;for(;n;){let f=!1,c="";if(!(e=a.exec(n))||this.rules.block.hr.test(n))break;let m=i();n=n.substring(e[0].length);let g=e[2].split(`
26
+ `,1)[0],v=e[1].length,L=this.options.pedantic?Hn(g,v):g.replace(this.rules.other.leadingSpaceTab,_=>Hn(_,v)),A=n.split(`
27
+ `,1)[0],b=!L.trim(),y=0;if(this.options.pedantic?(y=2,c=L.trimStart()):b?y=v+1:(y=L.search(this.rules.other.nonSpaceChar),y=y>4?1:y,c=L.slice(y),y+=v),b&&this.rules.other.blankLine.test(A)&&(n=n.substring(A.length+1),f=!0),!f){let _=this.rules.other.nextBulletRegex(y),U=this.rules.other.hrRegex(y),F=this.rules.other.fencesBeginRegex(y),O=this.rules.other.headingBeginRegex(y),q=this.rules.other.htmlBeginRegex(y),H=this.rules.other.blockquoteBeginRegex(y);for(;n;){let T=n.split(`
28
+ `,1)[0],C;if(A=T,this.options.pedantic?(A=A.replace(this.rules.other.listReplaceNesting," "),C=A):C=A.replace(this.rules.other.leadingSpaceTab,$=>Hn($)),F.test(A)||O.test(A)||q.test(A)||H.test(A)||_.test(A)||U.test(A))break;if(C.search(this.rules.other.nonSpaceChar)>=y||!A.trim())c+=`
29
+ `+C.slice(y);else{if(b||L.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||F.test(L)||O.test(L)||U.test(L))break;c+=`
30
+ `+A}b=!A.trim(),n=n.substring(T.length+1),L=C.slice(y)}}let E=t.slice(m,i());l.loose||(d?l.loose=!0:this.rules.other.doubleBlankLine.test(E)&&(d=!0)),l.items.push({type:"list_item",raw:E,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]})}let p=l.items.at(-1);if(p)p.raw=p.raw.trimEnd(),p.text=p.text.trimEnd();else return;l.raw=t.slice(0,i()).trimEnd();for(let f of l.items)if(this.lexer.state.top=!1,f.tokens=this.lexer.blockTokens(f.text,[]),!l.loose){let c=f.tokens.filter(g=>g.type==="space"),m=c.length>0&&c.some(g=>this.rules.other.anyLine.test(g.raw));l.loose=m}for(let f of l.items){let c=f.tokens[0];if(f.task&&(c?.type==="text"||c?.type==="paragraph")){f.text=f.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let g=this.lexer.inlineQueue.length-1;g>=0;g--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[g].src)){this.lexer.inlineQueue[g].src=this.lexer.inlineQueue[g].src.replace(this.rules.other.listReplaceTask,"");break}let m=this.rules.other.listTaskCheckbox.exec(f.raw);if(m){let g={type:"checkbox",raw:m[0]+" ",checked:m[0]!=="[ ]"};f.checked=g.checked,l.loose?f.tokens[0]&&["paragraph","text"].includes(f.tokens[0].type)&&"tokens"in f.tokens[0]&&f.tokens[0].tokens?(f.tokens[0].raw=g.raw+f.tokens[0].raw,f.tokens[0].text=g.raw+f.tokens[0].text,f.tokens[0].tokens.unshift(g)):f.tokens.unshift({type:"paragraph",raw:g.raw,text:g.raw,tokens:[g]}):f.tokens.unshift(g)}}else f.task&&(f.task=!1)}if(l.loose)for(let f of l.items){f.loose=!0;for(let c of f.tokens)c.type==="text"&&(c.type="paragraph")}return l}}html(n){let e=this.rules.block.html.exec(n);if(e){let t=Xr(e[0]);return{type:"html",block:!0,raw:t,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:t}}}def(n){let e=this.rules.block.def.exec(n);if(e){if(!this.rules.other.startAngleBracket.test(e[2])&&Vr(e[2],"()")!==-1)return;let t=yn(e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:pt(e[0],`
31
+ `),href:i,title:r}}}table(n){let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Yr(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
32
+ `):[],o={type:"table",raw:pt(e[0],`
33
+ `),header:[],align:[],rows:[]};if(t.length===i.length){for(let l of i)this.rules.other.tableAlignRight.test(l)?o.align.push("right"):this.rules.other.tableAlignCenter.test(l)?o.align.push("center"):this.rules.other.tableAlignLeft.test(l)?o.align.push("left"):o.align.push(null);for(let l=0;l<t.length;l++)o.header.push({text:t[l],tokens:this.lexer.inline(t[l]),header:!0,align:o.align[l]});for(let l of r)o.rows.push(Yr(l,o.header.length).map((a,d)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:o.align[d]})));return o}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:pt(e[0],`
34
+ `),depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
35
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){if(this.lexer.state.linkParenPossible===!1)return;let e=this.rules.inline.link.exec(n);if(e){let t=e[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&Kr(n,e[1],t,this.rules))return;let i=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(i)){if(!this.rules.other.endAngleBracket.test(i))return;let l=pt(i.slice(0,-1),"\\");if((i.length-l.length)%2===0)return}else{let l=Vr(e[2],"()");if(l===-2)return;if(l>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+l;e[2]=e[2].substring(0,l),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],o="";if(this.options.pedantic){let l=this.rules.other.pedanticHrefTitle.exec(r);l&&(r=l[1],o=l[3])}else o=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(i)?r=r.slice(1):r=r.slice(1,-1)),Zr(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let i=t[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&Kr(n,t[1],i,this.rules))return;let r=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=e[yn(r)];if(!o){let l=t[0].charAt(0);return{type:"text",raw:l,text:l}}return Zr(t,o,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let i=this.rules.inline.emStrongLDelim.exec(n);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!t||this.rules.inline.punctuation.exec(t))){let r=[...i[0]].length-1,o,l,a=r,d=0,p=i[0][0],f=t===p,c=p==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*n.length+r);(i=c.exec(e))!==null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(l=[...o].length,i[3]||i[4]){a+=l;continue}else if(i[5]||i[6]){if(r%3&&!((r+l)%3)){d+=l;continue}if(f)break}if(a-=l,a>0)continue;l=Math.min(l,l+a+d);let m=[...i[0]][0].length,g=n.slice(0,r+i.index+m+l);if(Math.min(r,l)%2){let L=g.slice(1,-1);return{type:"em",raw:g,text:L,tokens:this.lexer.inlineTokens(L)}}let v=g.slice(2,-2);return{type:"strong",raw:g,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(t),r=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return i&&r&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let i=this.rules.inline.delLDelim.exec(n);if(i&&(!i[1]||!t||this.rules.inline.punctuation.exec(t))){let r=[...i[0]].length-1,o,l,a=r,d=this.rules.inline.delRDelim;for(d.lastIndex=0,e=e.slice(-1*n.length+r);(i=d.exec(e))!==null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o||(l=[...o].length,l!==r))continue;if(i[3]||i[4]){a+=l;continue}if(a-=l,a>0)continue;l=Math.min(l,l+a);let p=[...i[0]][0].length,f=n.slice(0,r+i.index+p+l),c=f.slice(r,-r);return{type:"del",raw:f,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,i;return e[2]==="@"?(t=e[1],i="mailto:"+t):(t=e[1],i=t),{type:"link",raw:e[0],text:t,href:i,autolink:!0,tokens:[{type:"text",raw:t,text:t}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let t,i;if(e[2]==="@")t=e[0],i="mailto:"+t;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);t=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:t,href:i,autolink:!0,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:t?e[0]:Aa(e[0]),escaped:t}}}},je=class Gn{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||yt,this.options.tokenizer=this.options.tokenizer||new kn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let t={other:ue,block:xn.normal,inline:Vt.normal};this.options.pedantic?(t.block=xn.pedantic,t.inline=Vt.pedantic):this.options.gfm&&(t.block=xn.gfm,this.options.breaks?t.inline=Vt.breaks:t.inline=Vt.gfm),this.tokenizer.rules=t}static get rules(){return{block:xn,inline:Vt}}static lex(e,t){return new Gn(t).lex(e)}static lexInline(e,t){return new Gn(t).inlineTokens(e)}lex(e){e=e.replace(ue.carriageReturn,`
36
+ `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let i=this.inlineQueue[t];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],i=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ue.tabCharGlobal," ").replace(ue.spaceLine,""));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(a=>(o=a.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);let a=t.at(-1);o.raw.length===1&&a!==void 0?a.raw+=`
37
+ `:t.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
40
38
  `)?"":`
41
- `)+a.raw,o.text+=`
42
- `+a.text,this.inlineQueue.at(-1).src=o.text):n.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
39
+ `)+o.raw,a.text+=`
40
+ `+o.text,this.inlineQueue.at(-1).src=a.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);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
43
41
  `)?"":`
44
- `)+a.raw,o.text+=`
45
- `+a.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},n.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),n.push(a);continue}let s=e;if(this.options.extensions?.startBlock){let o=1/0,c=e.slice(1),u;this.options.extensions.startBlock.forEach(p=>{u=p.call({lexer:this},c),typeof u=="number"&&u>=0&&(o=Math.min(o,u))}),o<1/0&&o>=0&&(s=e.substring(0,o+1))}if(this.state.top&&(a=this.tokenizer.paragraph(s))){let o=n.at(-1);r&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
42
+ `)+o.raw,a.text+=`
43
+ `+o.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},t.push(o));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 l=e;if(this.options.extensions?.startBlock){let a=1/0,d=e.slice(1),p;this.options.extensions.startBlock.forEach(f=>{p=f.call({lexer:this},d),typeof p=="number"&&p>=0&&(a=Math.min(a,p))}),a<1/0&&a>=0&&(l=e.substring(0,a+1))}if(this.state.top&&(o=this.tokenizer.paragraph(l))){let a=t.at(-1);i&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
46
44
  `)?"":`
47
- `)+a.raw,o.text+=`
48
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(a),r=s.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
45
+ `)+o.raw,a.text+=`
46
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(o),i=l.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);let a=t.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
49
47
  `)?"":`
50
- `)+a.raw,o.text+=`
51
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}linkInText(e){if(!e.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&e.charAt(r.index-1)!=="!")return!0;for(let r of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let i=r[0],a=i.lastIndexOf("[");if(!(i.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,rn(i.slice(a+1,-1))))&&!(a>1&&this.linkInText(i.slice(1,a-1))))return!0}return!1}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=this.state.linkParenPossible;this.state.linkParenPossible=r&&e.includes(")");try{return this.#e(e,n)}finally{this.state.linkParenPossible=r}}#e(e,n){let r=e;if(this.tokens.links&&e.includes("[")){let o=this.tokenizer.rules.inline.reflinkSearch,c=u=>{let p=u.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,rn(u.slice(p+1,-1))))return u;if(p>1&&u.charAt(0)!=="!"){let f=u.slice(1,p-1);if(this.linkInText(f))return"["+f.replace(o,c)+"]["+"a".repeat(u.length-p-2)+"]"}return"["+"a".repeat(u.length-2)+"]"};r=r.replace(o,c)}r=r.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(o,c,u)=>u?"+".repeat(o.length):c?c+o.slice(c.length,-c.length).replace(/`/g,"+")+c:o),r=r.replace(this.tokenizer.rules.inline.blockSkip,(o,c,u)=>{let p=u?u.length:0;return o.slice(0,p)+"["+"a".repeat(o.length-p-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,a="",s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(a=""),i=!1;let o;if(this.options.extensions?.inline?.some(u=>(o=u.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let u=n.at(-1);o.type==="text"&&u?.type==="text"?(u.raw+=o.raw,u.text+=o.text):n.push(o);continue}if(o=this.tokenizer.emStrong(e,r,a)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.del(e,r,a)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),n.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),n.push(o);continue}let c=e;if(this.options.extensions?.startInline){let u=1/0,p=e.slice(1),f;this.options.extensions.startInline.forEach(b=>{f=b.call({lexer:this},p),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(o=this.tokenizer.inlineText(c)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(a=o.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=o.raw,u.text+=o.text):n.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},an=class{options;parser;constructor(t){this.options=t||ut}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(ye.notSpaceStart)?.[0],i=t?t.replace(ye.endingNewline,"")+`
52
- `:"";return r?'<pre><code class="language-'+Ie(r)+'">'+(n?i:Ie(i,!0))+`</code></pre>
53
- `:"<pre><code>"+(n?i:Ie(i,!0))+`</code></pre>
54
- `}blockquote({tokens:t}){return`<blockquote>
55
- ${this.parser.parse(t)}</blockquote>
56
- `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
57
- `}hr(t){return`<hr>
58
- `}list(t){let e=t.ordered,n=t.start,r="";for(let s=0;s<t.items.length;s++){let o=t.items[s];r+=this.listitem(o)}let i=e?"ol":"ul",a=e&&n!==1?' start="'+n+'"':"";return"<"+i+a+`>
59
- `+r+"</"+i+`>
60
- `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
61
- `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
62
- `}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){let a=t.rows[i];n="";for(let s=0;s<a.length;s++)n+=this.tablecell(a[s]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
48
+ `)+o.raw,a.text+=`
49
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes("["))return!1;let t=this.tokenizer.rules.inline.link;for(let i of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(i[0])&&e.charAt(i.index-1)!=="!")return!0;for(let i of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let r=i[0],o=r.lastIndexOf("[");if(!(r.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,yn(r.slice(o+1,-1))))&&!(o>1&&this.linkInText(r.slice(1,o-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let i=this.state.linkParenPossible;this.state.linkParenPossible=i&&e.includes(")");try{return this.#e(e,t)}finally{this.state.linkParenPossible=i}}#e(e,t){let i=e;if(this.tokens.links&&e.includes("[")){let a=this.tokenizer.rules.inline.reflinkSearch,d=p=>{let f=p.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,yn(p.slice(f+1,-1))))return p;if(f>1&&p.charAt(0)!=="!"){let c=p.slice(1,f-1);if(this.linkInText(c))return"["+c.replace(a,d)+"]["+"a".repeat(p.length-f-2)+"]"}return"["+"a".repeat(p.length-2)+"]"};i=i.replace(a,d)}i=i.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(a,d,p)=>p?"+".repeat(a.length):d?d+a.slice(d.length,-d.length).replace(/`/g,"+")+d:a),i=i.replace(this.tokenizer.rules.inline.blockSkip,(a,d,p)=>{let f=p?p.length:0;return a.slice(0,f)+"["+"a".repeat(a.length-f-2)+"]"}),i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,o="",l=1/0;for(;e;){if(e.length<l)l=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(o=""),r=!1;let a;if(this.options.extensions?.inline?.some(p=>(a=p.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let p=t.at(-1);a.type==="text"&&p?.type==="text"?(p.raw+=a.raw,p.text+=a.text):t.push(a);continue}if(a=this.tokenizer.emStrong(e,i,o)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.del(e,i,o)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),t.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),t.push(a);continue}let d=e;if(this.options.extensions?.startInline){let p=1/0,f=e.slice(1),c;this.options.extensions.startInline.forEach(m=>{c=m.call({lexer:this},f),typeof c=="number"&&c>=0&&(p=Math.min(p,c))}),p<1/0&&p>=0&&(d=e.substring(0,p+1))}if(a=this.tokenizer.inlineText(d)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(o=a.raw.slice(-1)),r=!0;let p=t.at(-1);p?.type==="text"?(p.raw+=a.raw,p.text+=a.text):t.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(this.options.silent)console.error(t);else throw new Error(t)}},vn=class{options;parser;constructor(n){this.options=n||yt}space(n){return""}code({text:n,lang:e,escaped:t}){let i=(e||"").match(ue.notSpaceStart)?.[0],r=n?n.replace(ue.endingNewline,"")+`
50
+ `:"";return i?'<pre><code class="language-'+_e(i)+'">'+(t?r:_e(r,!0))+`</code></pre>
51
+ `:"<pre><code>"+(t?r:_e(r,!0))+`</code></pre>
52
+ `}blockquote({tokens:n}){return`<blockquote>
53
+ ${this.parser.parse(n)}</blockquote>
54
+ `}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
55
+ `}hr(n){return`<hr>
56
+ `}list(n){let e=n.ordered,t=n.start,i="";for(let l=0;l<n.items.length;l++){let a=n.items[l];i+=this.listitem(a)}let r=e?"ol":"ul",o=e&&t!==1?' start="'+t+'"':"";return"<"+r+o+`>
57
+ `+i+"</"+r+`>
58
+ `}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
59
+ `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
60
+ `}table(n){let e="",t="";for(let r=0;r<n.header.length;r++)t+=this.tablecell(n.header[r]);e+=this.tablerow({text:t});let i="";for(let r=0;r<n.rows.length;r++){let o=n.rows[r];t="";for(let l=0;l<o.length;l++)t+=this.tablecell(o[l]);i+=this.tablerow({text:t})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
63
61
  <thead>
64
62
  `+e+`</thead>
65
- `+r+`</table>
66
- `}tablerow({text:t}){return`<tr>
67
- ${t}</tr>
68
- `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
69
- `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ie(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,text:n,tokens:r,autolink:i}){let a=i?Ie(n,!0):this.parser.parseInline(r),s=Pr(t);if(s===null)return a;t=Ie(s,i);let o='<a href="'+t+'"';return e&&(o+=' title="'+Ie(e)+'"'),o+=">"+a+"</a>",o}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Pr(t);if(i===null)return Ie(n);t=i;let a=`<img src="${Ie(t)}" alt="${Ie(n)}"`;return e&&(a+=` title="${Ie(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ie(t.text)}},jn=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Be=class zn{options;renderer;textRenderer;constructor(e){this.options=e||ut,this.options.renderer=this.options.renderer||new an,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new jn}static parse(e,n){return new zn(n).parse(e)}static parseInline(e,n){return new zn(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let s=i,o=this.options.extensions.renderers[s.type].call({parser:this},s);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(s.type)){n+=o||"";continue}}let a=i;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let a=e[i];if(this.options.extensions?.renderers?.[a.type]){let o=this.options.extensions.renderers[a.type].call({parser:this},a);if(o!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(a.type)){r+=o||"";continue}}let s=a;switch(s.type){case"escape":{r+=n.text(s);break}case"html":{r+=n.html(s);break}case"link":{r+=n.link(s);break}case"image":{r+=n.image(s);break}case"checkbox":{r+=n.checkbox(s);break}case"strong":{r+=n.strong(s);break}case"em":{r+=n.em(s);break}case"codespan":{r+=n.codespan(s);break}case"br":{r+=n.br(s);break}case"del":{r+=n.del(s);break}case"text":{r+=n.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}},Pt=class{options;block;constructor(t){this.options=t||ut}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Pe.lex:Pe.lexInline}provideParser(t=this.block){return t?Be.parse:Be.parseInline}};function lt(t,e){if(Array.isArray(e))for(let n=0;n<e.length;n++)t.push(e[n]);else t.push(e)}var Gn=class{defaults=Dn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Be;Renderer=an;TextRenderer=jn;Lexer=Pe;Tokenizer=on;Hooks=Pt;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(lt(n,e.call(this,r)),r.type){case"table":{let i=r;for(let a of i.header)lt(n,this.walkTokens(a.tokens,e));for(let a of i.rows)for(let s of a)lt(n,this.walkTokens(s.tokens,e));break}case"list":{let i=r;lt(n,this.walkTokens(i.items,e));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(a=>{let s=i[a].flat(1/0);lt(n,this.walkTokens(s,e))}):i.tokens&&lt(n,this.walkTokens(i.tokens,e))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let a=e.renderers[i.name];a?e.renderers[i.name]=function(...s){let o=i.renderer.apply(this,s);return o===!1&&(o=a.apply(this,s)),o}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[i.level];a?a.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new an(this.defaults);for(let a in n.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let s=a,o=n.renderer[s],c=i[s];i[s]=(...u)=>{let p=o.apply(i,u);return p===!1&&(p=c.apply(i,u)),p||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new on(this.defaults);for(let a in n.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let s=a,o=n.tokenizer[s],c=i[s];i[s]=(...u)=>{let p=o.apply(i,u);return p===!1&&(p=c.apply(i,u)),p}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Pt;for(let a in n.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let s=a,o=n.hooks[s],c=i[s];Pt.passThroughHooks.has(a)?i[s]=u=>{if(this.defaults.async&&Pt.passThroughHooksRespectAsync.has(a))return(async()=>{let f=await o.call(i,u);return c.call(i,f)})();let p=o.call(i,u);return c.call(i,p)}:i[s]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await o.apply(i,u);return f===!1&&(f=await c.apply(i,u)),f})();let p=o.apply(i,u);return p===!1&&(p=c.apply(i,u)),p}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,a=n.walkTokens;r.walkTokens=function(s){let o=[];return o.push(a.call(this,s)),i&&lt(o,i.call(this,s)),o}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Pe.lex(t,e??this.defaults)}parser(t,e){return Be.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let s=i.hooks?await i.hooks.preprocess(e):e,o=await(i.hooks?await i.hooks.provideLexer(t):t?Pe.lex:Pe.lexInline)(s,i),c=i.hooks?await i.hooks.processAllTokens(o):o;i.walkTokens&&await Promise.all(this.walkTokens(c,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser(t):t?Be.parse:Be.parseInline)(c,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(a);try{i.hooks&&(e=i.hooks.preprocess(e));let s=(i.hooks?i.hooks.provideLexer(t):t?Pe.lex:Pe.lexInline)(e,i);i.hooks&&(s=i.hooks.processAllTokens(s)),i.walkTokens&&this.walkTokens(s,i.walkTokens);let o=(i.hooks?i.hooks.provideParser(t):t?Be.parse:Be.parseInline)(s,i);return i.hooks&&(o=i.hooks.postprocess(o)),o}catch(s){return a(s)}}}onError(t,e){return n=>{if(n.message+=`
70
- Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+Ie(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},pt=new Gn;function se(t,e){return pt.parse(t,e)}se.options=se.setOptions=function(t){return pt.setOptions(t),se.defaults=pt.defaults,Gr(se.defaults),se};se.getDefaults=Dn;se.defaults=ut;function Pa(...t){return pt.use(...t),se.defaults=pt.defaults,Gr(se.defaults),se}se.use=Pa;se.walkTokens=function(t,e){return pt.walkTokens(t,e)};se.parseInline=pt.parseInline;se.Parser=Be;se.parser=Be.parse;se.Renderer=an;se.TextRenderer=jn;se.Lexer=Pe;se.lexer=Pe.lex;se.Tokenizer=on;se.Hooks=Pt;se.parse=se;var gl=se.options,ml=se.setOptions,bl=se.walkTokens,xl=se.parseInline;var wl=Be.parse,yl=Pe.lex;function Ba(t,e){this.v=t,this.k=e}function Jr(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Ua(t){if(Array.isArray(t))return t}function Ha(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,a,s,o=[],c=!0,u=!1;try{if(a=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(o.push(r.value),o.length!==e);c=!0);}catch(p){u=!0,i=p}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return o}}function Fa(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
71
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ja(t,e){return Ua(t)||Ha(t,e)||Ga(t,e)||Fa()}function Ga(t,e){if(t){if(typeof t=="string")return Jr(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Jr(t,e):void 0}}function sn(t){var e,n;function r(a,s){try{var o=t[a](s),c=o.value,u=c instanceof Ba;Promise.resolve(u?c.v:c).then(function(p){if(u){var f=a==="return"&&c.k?a:"next";if(!c.k||p.done)return r(f,p);p=t[f](p).value}i(!!o.done,p)},function(p){r("throw",p)})}catch(p){i(2,p)}}function i(a,s){a===2?e.reject(s):e.resolve({value:s,done:a}),(e=e.next)?r(e.key,e.arg):n=null}this._invoke=function(a,s){return new Promise(function(o,c){var u={key:a,arg:s,resolve:o,reject:c,next:null};n?n=n.next=u:(e=n=u,r(a,s))})},typeof t.return!="function"&&(this.return=void 0)}sn.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},sn.prototype.next=function(t){return this._invoke("next",t)},sn.prototype.throw=function(t){return this._invoke("throw",t)},sn.prototype.return=function(t){return this._invoke("return",t)};var hi=Object.entries,ei=Object.setPrototypeOf,Wa=Object.isFrozen,gi=Object.getPrototypeOf,mi=Object.getOwnPropertyDescriptor,ke=Object.freeze,Ee=Object.seal,vt=Object.create,bi=typeof Reflect<"u"&&Reflect,er=bi.apply,tr=bi.construct;ke||(ke=function(e){return e});Ee||(Ee=function(e){return e});er||(er=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];return e.apply(n,i)});tr||(tr=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});var Ze=ue(Array.prototype.forEach);Array.prototype.indexOf;var qa=ue(Array.prototype.lastIndexOf),ti=ue(Array.prototype.pop),Ft=ue(Array.prototype.push),Za=ue(Array.prototype.slice),Ka=ue(Array.prototype.splice),St=Array.isArray,Wn=xi(Set),qn=ue(Set.prototype.add),jt=ue(Set.prototype.has),dt=ue(String.prototype.toLowerCase),Zn=ue(String.prototype.toString),ni=ue(String.prototype.match),Gt=ue(String.prototype.replace),ri=ue(String.prototype.indexOf),Ya=ue(String.prototype.trim),Xa=ue(Number.prototype.toString),Va=ue(Boolean.prototype.toString),ii=typeof BigInt>"u"?null:ue(BigInt.prototype.toString),oi=typeof Symbol>"u"?null:ue(Symbol.prototype.toString),Ce=ue(Object.prototype.hasOwnProperty),Wt=ue(Object.prototype.toString),_e=ue(RegExp.prototype.test),Ke=xi(TypeError);function ue(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return er(t,e,r)}}function xi(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return tr(t,n)}}function ne(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:dt;if(ei&&ei(t,null),!St(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let a=n(i);a!==i&&(Wa(e)||(e[r]=a),i=a)}t[i]=!0}return t}function Qa(t){for(let e=0;e<t.length;e++)Ce(t,e)||(t[e]=null);return t}function Me(t){let e=vt(null);for(let r of hi(t)){var n=ja(r,2);let i=n[0],a=n[1];Ce(t,i)&&(St(a)?e[i]=Qa(a):a&&typeof a=="object"&&a.constructor===Object?e[i]=Me(a):e[i]=a)}return e}function Ja(t){switch(typeof t){case"string":return t;case"number":return Xa(t);case"boolean":return Va(t);case"bigint":return ii?ii(t):"0";case"symbol":return oi?oi(t):"Symbol()";case"undefined":return Wt(t);case"function":case"object":{if(t===null)return Wt(t);let e=t,n=Le(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:Wt(r)}return Wt(t)}default:return Wt(t)}}function Le(t,e){for(;t!==null;){let r=mi(t,e);if(r){if(r.get)return ue(r.get);if(typeof r.value=="function")return ue(r.value)}t=gi(t)}function n(){return null}return n}function es(t,e){for(;t!==null;){let n=mi(t,e);if(n)return n.get?ue(n.get):null;t=gi(t)}return null}function ts(t){try{return _e(t,""),!0}catch{return!1}}var ai=ke(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Kn=ke(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Yn=ke(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ns=ke(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Xn=ke(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),rs=ke(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),si=ke(["#text"]),li=ke(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Vn=ke(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ci=ke(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),ln=ke(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),is=Ee(/{{[\w\W]*|^[\w\W]*}}/g),os=Ee(/<%[\w\W]*|^[\w\W]*%>/g),as=Ee(/\${[\w\W]*/g),ss=Ee(/^data-[\-\w.\u00B7-\uFFFF]+$/),ls=Ee(/^aria-[\-\w]+$/),pi=Ee(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cs=Ee(/^(?:\w+script|data):/i),ps=Ee(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),us=Ee(/^html$/i),ds=Ee(/^[a-z][.\w]*(-[.\w]+)+$/i),Qn=Ee(/<[/\w!]/g),ui=Ee(/<[/\w]/g),fs=Ee(/<\/no(script|embed|frames)/i),di=Ee(/\/>/i),me={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},hs=ke(ne({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),gs=function(){return typeof window>"u"?null:window},ms=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let a="dompurify"+(r?"#"+r:"");try{return e.createPolicy(a,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},fi=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},et=function(e,n,r,i){return Ce(e,n)&&St(e[n])?ne(i.base?Me(i.base):{},e[n],i.transform):r},Jn=function(e,n,r){let i=Ce(e,n)?e[n]:void 0;return i&&typeof i=="object"?Me(i):r()};function wi(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gs(),e=_=>wi(_);if(e.version="3.4.17",e.removed=[],!t||!t.document||t.document.nodeType!==me.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,i=r.currentScript;t.DocumentFragment;let a=t.HTMLTemplateElement,s=t.Node,o=t.Element,c=t.NodeFilter;t.NamedNodeMap===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let u=t.DOMParser,p=t.trustedTypes,f=o.prototype,b=Le(f,"cloneNode"),x=Le(f,"remove"),T=Le(f,"removeAttributeNode"),k=Le(f,"nextSibling"),O=Le(f,"childNodes"),E=Le(f,"parentNode"),L=Le(f,"shadowRoot"),I=Le(f,"attributes"),H=s&&s.prototype?Le(s.prototype,"nodeType"):null,U=s&&s.prototype?Le(s.prototype,"nodeName"):null,A=s&&s.prototype?Le(s.prototype,"ownerDocument"):null,P=function(l){return H?H(l):l.nodeType},G=function(l){return U?U(l):l.nodeName},q=es(f,"namespaceURI"),N=function(l){return q?q(l):l.namespaceURI};if(typeof a=="function"){let _=n.createElement("template");_.content&&_.content.ownerDocument&&(n=_.content.ownerDocument)}let R,F="",Q,ae=!1,v=0,g=function(){if(v>0)throw Ke('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},m=function(l){g(),v++;try{return R.createHTML(l)}finally{v--}},C=function(l){g(),v++;try{return R.createScriptURL(l)}finally{v--}},S=function(){return ae||(Q=ms(p,i),ae=!0),Q},D=n,Y=D.implementation,le=D.createNodeIterator,de=D.createDocumentFragment,ce=D.getElementsByTagName,Te=r.importNode,re=fi();e.isSupported=typeof hi=="function"&&typeof E=="function"&&Y&&Y.createHTMLDocument!==void 0;let gt=is,Ne=os,Ct=as,Ot=ss,ze=ls,Ue=cs,Oe=ps,rt=ds,ge=pi,oe=null,De=ne({},[...ai,...Kn,...Yn,...Xn,...si]),$=null,Ye=ne({},[...li,...Vn,...ci,...ln]),ie=Object.seal(vt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),te=null,ve=null,be=Object.seal(vt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),qe=!0,He=!0,M=!1,B=!0,Z=!1,J=!0,h=!1,z=!1,W=null,V=null,fe=!1,pe=!1,xe=!1,Fe=!1,Xe=!0,it=!1,It="user-content-",mn=!0,bn=!1,ot=null,mt={},at=null,pr=ne({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),ur=null,dr=ne({},["audio","video","img","source","image","track"]),fr=null,hr=ne({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Yt="http://www.w3.org/1998/Math/MathML",Xt="http://www.w3.org/2000/svg",je="http://www.w3.org/1999/xhtml",bt=je,xn=!1,wn=null,lo=ne({},[Yt,Xt,je],Zn),gr=ke(["mi","mo","mn","ms","mtext"]),yn=ne({},gr),mr=ke(["annotation-xml"]),kn=ne({},mr),co=ne({},["title","style","font","a","script"]),Mt=null,po=["application/xhtml+xml","text/html"],uo="text/html",he=null,xt=null,fo=n.createElement("form"),br=function(l){return l instanceof RegExp||l instanceof Function},_n=function(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(xt&&xt===l)return;(!l||typeof l!="object")&&(l={}),l=Me(l),Mt=po.indexOf(l.PARSER_MEDIA_TYPE)===-1?uo:l.PARSER_MEDIA_TYPE,he=Mt==="application/xhtml+xml"?Zn:dt,oe=et(l,"ALLOWED_TAGS",De,{transform:he}),$=et(l,"ALLOWED_ATTR",Ye,{transform:he}),wn=et(l,"ALLOWED_NAMESPACES",lo,{transform:Zn}),fr=et(l,"ADD_URI_SAFE_ATTR",hr,{transform:he,base:hr}),ur=et(l,"ADD_DATA_URI_TAGS",dr,{transform:he,base:dr}),at=et(l,"FORBID_CONTENTS",pr,{transform:he}),te=et(l,"FORBID_TAGS",Me({}),{transform:he}),ve=et(l,"FORBID_ATTR",Me({}),{transform:he}),mt=Ce(l,"USE_PROFILES")?l.USE_PROFILES&&typeof l.USE_PROFILES=="object"?Me(l.USE_PROFILES):l.USE_PROFILES:!1,qe=l.ALLOW_ARIA_ATTR!==!1,He=l.ALLOW_DATA_ATTR!==!1,M=l.ALLOW_UNKNOWN_PROTOCOLS||!1,B=l.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Z=l.SAFE_FOR_TEMPLATES||!1,J=l.SAFE_FOR_XML!==!1,h=l.WHOLE_DOCUMENT||!1,pe=l.RETURN_DOM||!1,xe=l.RETURN_DOM_FRAGMENT||!1,Fe=l.RETURN_TRUSTED_TYPE||!1,fe=l.FORCE_BODY||!1,Xe=l.SANITIZE_DOM!==!1,it=l.SANITIZE_NAMED_PROPS||!1,mn=l.KEEP_CONTENT!==!1,bn=l.IN_PLACE||!1,ge=ts(l.ALLOWED_URI_REGEXP)?l.ALLOWED_URI_REGEXP:pi,bt=typeof l.NAMESPACE=="string"?l.NAMESPACE:je,yn=Jn(l,"MATHML_TEXT_INTEGRATION_POINTS",()=>ne({},gr)),kn=Jn(l,"HTML_INTEGRATION_POINTS",()=>ne({},mr));let d=Jn(l,"CUSTOM_ELEMENT_HANDLING",()=>vt(null));if(ie=vt(null),Ce(d,"tagNameCheck")&&br(d.tagNameCheck)&&(ie.tagNameCheck=d.tagNameCheck),Ce(d,"attributeNameCheck")&&br(d.attributeNameCheck)&&(ie.attributeNameCheck=d.attributeNameCheck),Ce(d,"allowCustomizedBuiltInElements")&&typeof d.allowCustomizedBuiltInElements=="boolean"&&(ie.allowCustomizedBuiltInElements=d.allowCustomizedBuiltInElements),Ee(ie),Z&&(He=!1),xe&&(pe=!0),mt&&(oe=ne({},si),$=vt(null),mt.html===!0&&(ne(oe,ai),ne($,li)),mt.svg===!0&&(ne(oe,Kn),ne($,Vn),ne($,ln)),mt.svgFilters===!0&&(ne(oe,Yn),ne($,Vn),ne($,ln)),mt.mathMl===!0&&(ne(oe,Xn),ne($,ci),ne($,ln))),be.tagCheck=null,be.attributeCheck=null,Ce(l,"ADD_TAGS")&&(typeof l.ADD_TAGS=="function"?be.tagCheck=l.ADD_TAGS:St(l.ADD_TAGS)&&(oe===De&&(oe=Me(oe)),ne(oe,l.ADD_TAGS,he))),Ce(l,"ADD_ATTR")&&(typeof l.ADD_ATTR=="function"?be.attributeCheck=l.ADD_ATTR:St(l.ADD_ATTR)&&($===Ye&&($=Me($)),ne($,l.ADD_ATTR,he))),Ce(l,"ADD_FORBID_CONTENTS")&&St(l.ADD_FORBID_CONTENTS)&&(at===pr&&(at=Me(at)),ne(at,l.ADD_FORBID_CONTENTS,he)),mn&&(oe["#text"]=!0),h&&ne(oe,["html","head","body"]),oe.table&&(ne(oe,["tbody"]),delete te.tbody),l.TRUSTED_TYPES_POLICY){if(typeof l.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof l.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let w=R;R=l.TRUSTED_TYPES_POLICY;try{F=m("")}catch(y){throw R=w,y}}else l.TRUSTED_TYPES_POLICY===null?(R=void 0,F=""):(R===void 0&&(R=S()),R&&typeof F=="string"&&(F=m("")));ke&&ke(l),xt=l},xr=ne({},[...Kn,...Yn,...ns]),wr=ne({},[...Xn,...rs]),ho=function(l,d,w){return d.namespaceURI===je?l==="svg":d.namespaceURI===Yt?l==="svg"&&(w==="annotation-xml"||yn[w]):!!xr[l]},go=function(l,d,w){return d.namespaceURI===je?l==="math":d.namespaceURI===Xt?l==="math"&&kn[w]:!!wr[l]},mo=function(l,d,w){return d.namespaceURI===Xt&&!kn[w]||d.namespaceURI===Yt&&!yn[w]?!1:!wr[l]&&(co[l]||!xr[l])},bo=function(l){let d=N(l),w=dt(G(l)),y=E(l),j,K;return y&&P(y)===me.element?(j={namespaceURI:N(y)},K=dt(G(y))):(j={namespaceURI:bt},K="template"),wn[d]?d===Xt?ho(w,j,K):d===Yt?go(w,j,K):d===je?mo(w,j,K):!!(Mt==="application/xhtml+xml"&&wn[d]):!1},Ve=function(l){Ft(e.removed,{element:l});try{E(l).removeChild(l)}catch{if(x(l),!E(l))throw Ke("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},yr=function(l,d,w){try{T(l,d)}catch{try{l.removeAttribute(w)}catch{}}},En=function(l){Sn(l);let d=O(l);d&&Ze(Za(d),y=>{try{x(y)}catch{}});let w=P(l)===me.element?I(l):null;if(w)for(let y=w.length-1;y>=0;--y){let j=w[y],K=j&&j.name;typeof K=="string"&&yr(l,j,K)}},wt=function(l,d,w){if(!w)try{w=d.getAttributeNode(l)}catch{w=null}Ft(e.removed,{attribute:w||null,from:d});try{w?T(d,w):d.removeAttribute(l)}catch{try{d.removeAttribute(l)}catch{}}if(l==="is")if(pe||xe)try{Ve(d)}catch{}else try{d.setAttribute(l,"")}catch{}},kr=function(l){let d=I(l);if(d)for(let w=d.length-1;w>=0;--w){let y=d[w],j=y&&y.name;typeof j!="string"||$[he(j)]||yr(l,y,j)}},vn=function(l,d){let w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,y=[l];for(;y.length>0;){let j=y.pop();if(d(j)===!1)continue;if(w&&P(j)===me.element){let ee=L(j);Qe(ee)&&y.push(ee)}let K=O(j);if(K)for(let ee=K.length-1;ee>=0;--ee)y.push(K[ee])}},Sn=function(l){vn(l,d=>{P(d)===me.element&&kr(d)})},Tn=function(l){let d=[];return vn(l,w=>{d.push(w)},!0),d},xo=function(l,d){let w=Wn();Ze(Tn(l),y=>{P(y)===me.element&&qn(w,y)}),Ze(d,y=>{P(y)===me.element&&!jt(w,y)&&kr(y)})},_r=function(l,d){let w=!1;return Ze(e.removed,y=>{y.element&&(w=w||y.element===l,Sn(y.element))}),xo(l,d),w},wo=8,yo=function(l,d){let w=ot,y=null,j=()=>(y||(y=Wn(),Ze(d,K=>{qn(y,K)})),y);for(let K=0;;K++){let ee=Tn(l),we=[l],Ge=!1;if(Ze(ee,Se=>{P(Se)===me.documentFragment?Ft(we,Se):!Ge&&!jt(w,Se)&&(Ge=jt(j(),Se))}),!Ge)return;if(K>=wo)throw Ke("the tree kept changing during in-place sanitization; refusing to return it");Ze(we,(Se,Ae)=>{ko(Se,Ae>0,l,j())})}},ko=function(l,d,w,y){let j=An(l),K;for(;K=j.nextNode();)!jt(y,K)||jt(ot,K)||(d&&$e(re.uponSanitizeShadowNode,K,null),Cn(K,w),On(K,w),Qe(K.content)&&Nt(K.content))},_o=function(l){ot&&qn(ot,l)},Er=function(l,d){return J?l==="patchsrc"?!0:l==="for"&&d!=="label"&&d!=="output":!1},Eo=function(l){J&&vn(l,d=>{let w=P(d);if(w===me.processingInstruction||w===me.comment&&_e(ui,d.data)){try{x(d)}catch{}return!1}if(w===me.element){let y=d,j=he(G(d));try{y.hasAttribute&&y.hasAttribute("patchsrc")&&y.removeAttribute("patchsrc"),y.hasAttribute&&y.hasAttribute("for")&&Er("for",j)&&y.removeAttribute("for")}catch{}}return!0})},vr=function(l){let d=null,w=null;if(fe)l="<remove></remove>"+l;else{let K=ni(l,/^[\r\n\t ]+/);w=K&&K[0]}Mt==="application/xhtml+xml"&&bt===je&&(l='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+l+"</body></html>");let y=R?m(l):l;if(bt===je)try{d=new u().parseFromString(y,Mt)}catch{}if(!d||!d.documentElement){d=Y.createDocument(bt,"template",null);try{d.documentElement.innerHTML=xn?F:y}catch{}}let j=d.body||d.documentElement;return l&&w&&j.insertBefore(n.createTextNode(w),j.childNodes[0]||null),bt===je?ce.call(d,h?"html":"body")[0]:h?d.documentElement:j},An=function(l){let d=A?A(l):l.ownerDocument;return le.call(d||l,l,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Vt=function(l){return l=Gt(l,gt," "),l=Gt(l,Ne," "),l=Gt(l,Ct," "),l},Rn=function(l){var d;Sr(l);let w=(d=l.querySelectorAll)===null||d===void 0?void 0:d.call(l,"template");w&&Ze(w,y=>{Qe(y.content)&&Rn(y.content)})},Sr=function(l){l.normalize();let d=A?A(l):l.ownerDocument,w=le.call(d||l,l,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),y=w.nextNode();for(;y;)y.data=Vt(y.data),y=w.nextNode()},Qt=function(l){let d=U?U(l):null;return typeof d!="string"||he(d)!=="form"?!1:typeof l.nodeName!="string"||typeof l.textContent!="string"||typeof l.removeChild!="function"||l.attributes!==I(l)||typeof l.removeAttribute!="function"||typeof l.removeAttributeNode!="function"||typeof l.getAttributeNode!="function"||typeof l.setAttribute!="function"||typeof l.namespaceURI!="string"||typeof l.insertBefore!="function"||typeof l.hasChildNodes!="function"||l.nodeType!==H(l)||l.childNodes!==O(l)},Qe=function(l){if(!H||typeof l!="object"||l===null)return!1;try{return H(l)===me.documentFragment}catch{return!1}},Lt=function(l){if(!H||typeof l!="object"||l===null)return!1;try{return typeof H(l)=="number"}catch{return!1}};function $e(_,l,d){_.length!==0&&Ze(_,w=>{w.call(e,l,d,xt)})}let vo=function(l,d){return!!(J&&l.hasChildNodes()&&!Lt(l.firstElementChild)&&_e(Qn,l.textContent)&&_e(Qn,l.innerHTML)||J&&hs[d]&&P(l)===me.element&&N(l)===je&&(Lt(l.firstElementChild)||typeof l.textContent=="string"&&_e(Qn,l.textContent))||l.nodeType===me.processingInstruction||J&&l.nodeType===me.comment&&_e(ui,l.data))},Jt=function(l,d){if(l instanceof RegExp)return _e(l,d);if(l instanceof Function){for(var w=arguments.length,y=new Array(w>2?w-2:0),j=2;j<w;j++)y[j-2]=arguments[j];return!!l(d,...y)}return!1},So=function(l,d,w){if(!te[d]&&Rr(d)&&Jt(ie.tagNameCheck,d))return!1;if(mn&&!at[d]&&!at[dt(d)]){let y=E(l),j=O(l);if(j&&y){let K=j.length;for(let ee=K-1;ee>=0;--ee){let we=l===w?b(j[ee],!0):j[ee];y.insertBefore(we,k(l))}}}return Ve(l),!0},Tr=function(l,d,w,y){return l.length===0?d:d===w||d===y?Me(d):d},yt=function(l,d){return l===d||E(l)!==null?!1:(bn&&Sn(l),!0)},Cn=function(l,d){if(_o(l),$e(re.beforeSanitizeElements,l,null),yt(l,d))return!0;if(Qt(l))return Ve(l),!0;let w=he(G(l));if(oe=Tr(re.uponSanitizeElement,oe,De,W),$e(re.uponSanitizeElement,l,{tagName:w,allowedTags:oe}),yt(l,d))return!0;if(vo(l,w))return Ve(l),!0;if(te[w]||!(be.tagCheck instanceof Function&&be.tagCheck(w))&&!oe[w]){let y=So(l,w,d);return y===!1&&($e(re.afterSanitizeElements,l,null),yt(l,d))?!0:y}if(P(l)===me.element&&!bo(l)||(w==="noscript"||w==="noembed"||w==="noframes")&&_e(fs,l.innerHTML))return Ve(l),!0;if(Z&&l.nodeType===me.text){let y=Vt(l.textContent);l.textContent!==y&&(Ft(e.removed,{element:l.cloneNode()}),l.textContent=y)}return $e(re.afterSanitizeElements,l,null),yt(l,d)},Ar=function(l,d,w){if(ve[d]||Er(d,l)||Xe&&(d==="id"||d==="name")&&(w in n||w in fo))return!1;let y=$[d]||be.attributeCheck instanceof Function&&be.attributeCheck(d,l);return He&&_e(Ot,d)||qe&&_e(ze,d)?!0:y?fr[d]||_e(ge,Gt(w,Oe,""))||(d==="src"||d==="xlink:href"||d==="href")&&l!=="script"&&ri(w,"data:")===0&&ur[l]||M&&!_e(Ue,Gt(w,Oe,""))?!0:!w:Rr(l)&&Jt(ie.tagNameCheck,l)&&Jt(ie.attributeNameCheck,d,l)||d==="is"&&ie.allowCustomizedBuiltInElements&&Jt(ie.tagNameCheck,w)},To=ne({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Rr=function(l){return!To[dt(l)]&&_e(rt,l)},Ao=function(l,d,w,y){if(R&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!w)switch(p.getAttributeType(l,d)){case"TrustedHTML":return m(y);case"TrustedScriptURL":return C(y)}return y},Ro=function(l,d,w,y){try{return w?l.setAttributeNS(w,d,y):l.setAttribute(d,y),Qt(l)?(Ve(l),!1):!0}catch{return wt(d,l),!1}},Cr=function(l,d){return J&&_e(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)?!0:dt(l)==="attributename"&&ni(d,"href")!==null},On=function(l,d){if($e(re.beforeSanitizeAttributes,l,null),yt(l,d))return;let w=l.attributes;if(!w||Qt(l))return;$=Tr(re.uponSanitizeAttribute,$,Ye,V);let y={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$,forceKeepAttr:void 0},j=w.length,K=he(l.nodeName);for(;j--;){let ee=w[j],we=ee.name,Ge=ee.namespaceURI,Se=ee.value,Ae=he(we),kt=Se,Re=we==="value"?kt:Ya(kt),Or=!1;if(y.attrName=Ae,y.attrValue=Re,y.keepAttr=!0,y.forceKeepAttr=void 0,$e(re.uponSanitizeAttribute,l,y),Re=y.attrValue,it&&(Ae==="id"||Ae==="name")&&ri(Re,It)!==0&&(wt(we,l,ee),Re=It+Re,Or=!0),Cr(we,Re)){wt(we,l,ee);continue}if(!y.forceKeepAttr){if(!y.keepAttr){wt(we,l,ee);continue}if(!B&&_e(di,Re)){wt(we,l,ee);continue}if(Z&&(Re=Vt(Re)),!Ar(K,Ae,Re)){wt(we,l,ee);continue}Re=Ao(K,Ae,Ge,Re),Re!==kt&&Ro(l,we,Ge,Re)&&Or&&ti(e.removed)}}$e(re.afterSanitizeAttributes,l,null),yt(l,d)},Nt=function(l){let d=null,w=An(l);for($e(re.beforeSanitizeShadowDOM,l,null);d=w.nextNode();)if($e(re.uponSanitizeShadowNode,d,null),Cn(d,l),On(d,l),Qe(d.content)&&Nt(d.content),P(d)===me.element){let y=L(d);Qe(y)&&(In(y),Nt(y))}Z&&Sr(l),$e(re.afterSanitizeShadowDOM,l,null)},In=function(l){let d=[{node:l,shadow:null}];for(;d.length>0;){let w=d.pop();if(w.shadow){Nt(w.shadow);continue}let y=w.node,j=P(y)===me.element,K=O(y);if(K)for(let ee=K.length-1;ee>=0;--ee)d.push({node:K[ee],shadow:null});if(j){let ee=U?U(y):null;if(typeof ee=="string"&&he(ee)==="template"){let we=y.content;Qe(we)&&d.push({node:we,shadow:null})}}if(j){let ee=L(y);Qe(ee)&&d.push({node:null,shadow:ee},{node:ee,shadow:null})}}};return e.sanitize=function(_){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=null,w=null,y=null,j=null;if(xn=!_,xn&&(_="<!-->"),typeof _!="string"&&!Lt(_)&&(_=Ja(_),typeof _!="string"))throw Ke("dirty is not a string, aborting");if(!e.isSupported)return _;z?(oe=W,$=V):_n(l),(re.uponSanitizeElement.length>0||re.uponSanitizeAttribute.length>0)&&(oe=Me(oe)),re.uponSanitizeAttribute.length>0&&($=Me($)),e.removed=[];let K=bn&&typeof _!="string"&&Lt(_),ee=[],we=ot;if(K){Eo(_);let Ae=G(_);if(typeof Ae=="string"){let kt=he(Ae);if(!oe[kt]||te[kt])throw En(_),Ke("root node is forbidden and cannot be sanitized in-place")}if(Qt(_))throw En(_),Ke("root node is clobbered and cannot be sanitized in-place");ee=Tn(_),ot=Wn()}else if(Lt(_))d=vr("<!---->"),w=d.ownerDocument.importNode(_,!0),w.nodeType===me.element&&w.nodeName==="BODY"||w.nodeName==="HTML"?d=w:d.appendChild(w),In(d);else{if(!pe&&!Z&&!h&&_.indexOf("<")===-1)return R&&Fe?m(_):_;if(d=vr(_),!d)return pe?null:Fe?F:""}d&&fe&&Ve(d.firstChild);let Ge=K?_:d;try{K&&In(_);let Ae=An(Ge);for(;y=Ae.nextNode();)Cn(y,Ge),On(y,Ge),Qe(y.content)&&Nt(y.content);K&&yo(_,ee)}catch(Ae){throw K&&(En(_),_r(_,ee)),Ae}finally{ot=we}if(K){if(_r(_,ee))throw Ke("a node selected for removal could not be safely returned; refusing to sanitize in place");return Z&&Rn(_),_}if(pe){if(Z&&Rn(d),xe)for(j=de.call(d.ownerDocument);d.firstChild;)j.appendChild(d.firstChild);else j=d;return($.shadowroot||$.shadowrootmode)&&(j=Te.call(r,j,!0)),j}let Se=h?d.outerHTML:d.innerHTML;return h&&oe["!doctype"]&&d.ownerDocument&&d.ownerDocument.doctype&&d.ownerDocument.doctype.name&&_e(us,d.ownerDocument.doctype.name)&&(Se="<!DOCTYPE "+d.ownerDocument.doctype.name+`>
72
- `+Se),Z&&(Se=Vt(Se)),R&&Fe?m(Se):Se},e.setConfig=function(){let _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_n(_),z=!0,W=oe,V=$},e.clearConfig=function(){xt=null,z=!1,W=null,V=null,R=Q,F=""},e.isValidAttribute=function(_,l,d){xt||_n({});let w=he(_),y=he(l);return typeof d=="string"&&(Cr(l,d)||!B&&_e(di,d))?!1:Ar(w,y,d)},e.addHook=function(_,l){typeof l=="function"&&Ce(re,_)&&Ft(re[_],l)},e.removeHook=function(_,l){if(Ce(re,_)){if(l!==void 0){let d=qa(re[_],l);return d===-1?void 0:Ka(re[_],d,1)[0]}return ti(re[_])}},e.removeHooks=function(_){Ce(re,_)&&(re[_]=[])},e.removeAllHooks=function(){re=fi()},e}var yi=wi();var Hi=Do(Ui(),1);var fn=Hi.default;function Fi(t){let e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},a=["true","false","unknown"],s=["double precision","large object","with timezone","without timezone"],o=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],c=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],p=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],b=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],x=p,T=[...u,...c].filter(U=>!p.includes(U)),k={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},O={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},E={match:e.concat(/\b/,e.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function L(U){return e.concat(/\b/,e.either(...U.map(A=>A.replace(/\s+/,"\\s+"))),/\b/)}let I={scope:"keyword",match:L(b),relevance:0};function H(U,{exceptions:A,when:P}={}){let G=P;return A=A||[],U.map(q=>q.match(/\|\d+$/)||A.includes(q)?q:G(q)?`${q}|0`:q)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:H(T,{when:U=>U.length<3}),literal:a,type:o,built_in:f},contains:[{scope:"type",match:L(s)},I,E,k,r,i,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,O]}}function ji(t){let e=t.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});let i={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},a=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),s={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},o={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,i]};i.contains.push(o);let c={match:/\\"/},u={className:"string",begin:/'/,end:/'/},p={match:/\\'/},f={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},b=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],x=t.SHEBANG({binary:`(${b.join("|")})`,relevance:10}),T={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},k=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],O=["true","false"],E={match:/(\/[a-z._-]+)+/},L=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],I=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],H=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],U=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:k,literal:O,built_in:[...L,...I,"set","shopt",...H,...U]},contains:[x,t.SHEBANG(),T,f,a,s,E,o,c,u,p,n]}}var Gi="[A-Za-z$_][0-9A-Za-z$_]*",al=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],sl=["true","false","null","undefined","NaN","Infinity"],Wi=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],qi=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Zi=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],ll=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],cl=[].concat(Zi,Wi,qi);function Ki(t){let e=t.regex,n=(C,{after:S})=>{let D="</"+C[0].slice(1);return C.input.indexOf(D,S)!==-1},r=Gi,i={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,s={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(C,S)=>{let D=C[0].length+C.index,Y=C.input[D];if(Y==="<"||Y===","){S.ignoreMatch();return}Y===">"&&(n(C,{after:D})||S.ignoreMatch());let le,de=C.input.substring(D);if(le=de.match(/^\s*=/)){S.ignoreMatch();return}if((le=de.match(/^\s+extends\s+/))&&le.index===0){S.ignoreMatch();return}}},o={$pattern:Gi,keyword:al,literal:sl,built_in:cl,"variable.language":ll},c="[0-9](_?[0-9])*",u=`\\.(${c})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${p})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${p})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},b={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,b],subLanguage:"xml"}},T={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,b],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,b],subLanguage:"graphql"}},O={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,b]},L={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},I=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,x,T,k,O,{match:/\$\d+/},f];b.contains=I.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(I)});let H=[].concat(L,b.contains),U=H.concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(H)}]),A={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:U},P={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},G={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Wi,...qi]}},q={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[A],illegal:/%/},R={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function F(C){return e.concat("(?!",C.join("|"),")")}let Q={match:e.concat(/\b/,F([...Zi,"super","import"].map(C=>`${C}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},ae={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},v={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},A]},g="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",m={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(g)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[A]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:U,CLASS_REFERENCE:G},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),q,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,x,T,k,O,L,{match:/\$\d+/},f,G,{scope:"attr",match:r+e.lookahead(":"),relevance:0},m,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[L,t.REGEXP_MODE,{className:"function",begin:g,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:U}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:s.begin,"on:begin":s.isTrulyOpeningTag,end:s.end}],subLanguage:"xml",contains:[{begin:s.begin,end:s.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[A,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},ae,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[A]},Q,R,P,v,{match:/\$[(.]/}]}}function Yi(t){let e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,i,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function Xi(t){let e=t.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],o={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:o,illegal:/#/},p={begin:/\{\{/,relevance:0},f={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c,p,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c,p,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,p,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,p,u]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},b="[0-9](_?[0-9])*",x=`(\\b(${b}))?\\.(${b})|\\b(${b})\\.`,T=`\\b|${r.join("|")}`,k={className:"number",relevance:0,variants:[{begin:`(\\b(${b})|(${x}))[eE][+-]?(${b})[jJ]?(?=${T})`},{begin:`(${x})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${T})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${T})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${T})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${T})`},{begin:`\\b(${b})[jJ](?=${T})`}]},O={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:o,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},E={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:["self",c,k,f,t.HASH_COMMENT_MODE]}]};return u.contains=[f,k,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:o,illegal:/(<\/|\?)|=>/,contains:[c,k,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,O,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[E]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[k,E,f]}]}}for(let[t,e]of Object.entries({sql:Fi,bash:ji,javascript:Ki,json:Yi,python:Xi}))fn.registerLanguage(t,e);function Vi(t){let e=new Gn({gfm:!0,breaks:!1}),n=yi(t),r=t.document;return(i,a)=>{let s=n.sanitize(e.parse(a),{RETURN_DOM_FRAGMENT:!0,ALLOWED_TAGS:["p","br","strong","em","del","code","pre","blockquote","ul","ol","li","hr","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","th","td","a"],ALLOWED_ATTR:["href","title","class","start","align"],ALLOW_DATA_ATTR:!1});for(let o of s.querySelectorAll("a")){let c=o.getAttribute("href");if(c)try{["http:","https:","mailto:"].includes(new URL(c,t.location.href).protocol)||o.removeAttribute("href")}catch{o.removeAttribute("href")}o.target="_blank",o.rel="noopener noreferrer",o.referrerPolicy="no-referrer"}for(let o of s.querySelectorAll("table")){let c=r.createElement("div");c.className="table-scroll",o.replaceWith(c),c.append(o)}for(let o of s.querySelectorAll("pre")){let c=o.querySelector("code");if(!c)continue;let u=r.createElement("div");u.className="code-block";let p=r.createElement("div");p.className="code-header";let f=r.createElement("span"),b=c.className.match(/\blanguage-([\w-]+)/)?.[1];if(f.textContent=b?.toUpperCase()||"CODE",b&&fn.getLanguage(b)){let T=c.textContent,k=fn.highlight(T,{language:b,ignoreIllegals:!0}).value;c.replaceChildren(n.sanitize(k,{RETURN_DOM_FRAGMENT:!0,ALLOWED_TAGS:["span"],ALLOWED_ATTR:["class"],ALLOW_DATA_ATTR:!1}))}let x=r.createElement("button");x.type="button",x.textContent="\u590D\u5236",x.addEventListener("click",async()=>{try{await t.navigator.clipboard.writeText(c.textContent),x.textContent="\u5DF2\u590D\u5236"}catch{x.textContent="\u590D\u5236\u5931\u8D25"}}),p.append(f,x),o.replaceWith(u),u.append(p,o)}i.replaceChildren(s)}}var Qi=`
63
+ `+i+`</table>
64
+ `}tablerow({text:n}){return`<tr>
65
+ ${n}</tr>
66
+ `}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
67
+ `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${_e(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,text:t,tokens:i,autolink:r}){let o=r?_e(t,!0):this.parser.parseInline(i),l=Wr(n);if(l===null)return o;n=_e(l,r);let a='<a href="'+n+'"';return e&&(a+=' title="'+_e(e)+'"'),a+=">"+o+"</a>",a}image({href:n,title:e,text:t,tokens:i}){i&&(t=this.parser.parseInline(i,this.parser.textRenderer));let r=Wr(n);if(r===null)return _e(t);n=r;let o=`<img src="${_e(n)}" alt="${_e(t)}"`;return e&&(o+=` title="${_e(e)}"`),o+=">",o}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:_e(n.text)}},Jn=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},Ge=class qn{options;renderer;textRenderer;constructor(e){this.options=e||yt,this.options.renderer=this.options.renderer||new vn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Jn}static parse(e,t){return new qn(t).parse(e)}static parseInline(e,t){return new qn(t).parseInline(e)}parse(e){this.renderer.parser=this;let t="";for(let i=0;i<e.length;i++){let r=e[i];if(this.options.extensions?.renderers?.[r.type]){let l=r,a=this.options.extensions.renderers[l.type].call({parser:this},l);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(l.type)){t+=a||"";continue}}let o=r;switch(o.type){case"space":{t+=this.renderer.space(o);break}case"hr":{t+=this.renderer.hr(o);break}case"heading":{t+=this.renderer.heading(o);break}case"code":{t+=this.renderer.code(o);break}case"table":{t+=this.renderer.table(o);break}case"blockquote":{t+=this.renderer.blockquote(o);break}case"list":{t+=this.renderer.list(o);break}case"checkbox":{t+=this.renderer.checkbox(o);break}case"html":{t+=this.renderer.html(o);break}case"def":{t+=this.renderer.def(o);break}case"paragraph":{t+=this.renderer.paragraph(o);break}case"text":{t+=this.renderer.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let i="";for(let r=0;r<e.length;r++){let o=e[r];if(this.options.extensions?.renderers?.[o.type]){let a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){i+=a||"";continue}}let l=o;switch(l.type){case"escape":{i+=t.text(l);break}case"html":{i+=t.html(l);break}case"link":{i+=t.link(l);break}case"image":{i+=t.image(l);break}case"checkbox":{i+=t.checkbox(l);break}case"strong":{i+=t.strong(l);break}case"em":{i+=t.em(l);break}case"codespan":{i+=t.codespan(l);break}case"br":{i+=t.br(l);break}case"del":{i+=t.del(l);break}case"text":{i+=t.text(l);break}default:{let a='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return i}},Zt=class{options;block;constructor(n){this.options=n||yt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(n=this.block){return n?je.lex:je.lexInline}provideParser(n=this.block){return n?Ge.parse:Ge.parseInline}};function bt(n,e){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.push(e[t]);else n.push(e)}var er=class{defaults=Wn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ge;Renderer=vn;TextRenderer=Jn;Lexer=je;Tokenizer=kn;Hooks=Zt;constructor(...n){this.use(...n)}walkTokens(n,e){let t=[];for(let i of n)switch(bt(t,e.call(this,i)),i.type){case"table":{let r=i;for(let o of r.header)bt(t,this.walkTokens(o.tokens,e));for(let o of r.rows)for(let l of o)bt(t,this.walkTokens(l.tokens,e));break}case"list":{let r=i;bt(t,this.walkTokens(r.items,e));break}default:{let r=i;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(o=>{let l=r[o].flat(1/0);bt(t,this.walkTokens(l,e))}):r.tokens&&bt(t,this.walkTokens(r.tokens,e))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let i={...t};if(i.async=this.defaults.async||i.async||!1,t.extensions&&(t.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=e.renderers[r.name];o?e.renderers[r.name]=function(...l){let a=r.renderer.apply(this,l);return a===!1&&(a=o.apply(this,l)),a}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[r.level];o?o.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),i.extensions=e),t.renderer){let r=this.defaults.renderer||new vn(this.defaults);for(let o in t.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let l=o,a=t.renderer[l],d=r[l];r[l]=(...p)=>{let f=a.apply(r,p);return f===!1&&(f=d.apply(r,p)),f||""}}i.renderer=r}if(t.tokenizer){let r=this.defaults.tokenizer||new kn(this.defaults);for(let o in t.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let l=o,a=t.tokenizer[l],d=r[l];r[l]=(...p)=>{let f=a.apply(r,p);return f===!1&&(f=d.apply(r,p)),f}}i.tokenizer=r}if(t.hooks){let r=this.defaults.hooks||new Zt;for(let o in t.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let l=o,a=t.hooks[l],d=r[l];Zt.passThroughHooks.has(o)?r[l]=p=>{if(this.defaults.async&&Zt.passThroughHooksRespectAsync.has(o))return(async()=>{let c=await a.call(r,p);return d.call(r,c)})();let f=a.call(r,p);return d.call(r,f)}:r[l]=(...p)=>{if(this.defaults.async)return(async()=>{let c=await a.apply(r,p);return c===!1&&(c=await d.apply(r,p)),c})();let f=a.apply(r,p);return f===!1&&(f=d.apply(r,p)),f}}i.hooks=r}if(t.walkTokens){let r=this.defaults.walkTokens,o=t.walkTokens;i.walkTokens=function(l){let a=[];return a.push(o.call(this,l)),r&&bt(a,r.call(this,l)),a}}this.defaults={...this.defaults,...i}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return je.lex(n,e??this.defaults)}parser(n,e){return Ge.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let i={...t},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.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 e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=n),r.async)return(async()=>{let l=r.hooks?await r.hooks.preprocess(e):e,a=await(r.hooks?await r.hooks.provideLexer(n):n?je.lex:je.lexInline)(l,r),d=r.hooks?await r.hooks.processAllTokens(a):a;r.walkTokens&&await Promise.all(this.walkTokens(d,r.walkTokens));let p=await(r.hooks?await r.hooks.provideParser(n):n?Ge.parse:Ge.parseInline)(d,r);return r.hooks?await r.hooks.postprocess(p):p})().catch(o);try{r.hooks&&(e=r.hooks.preprocess(e));let l=(r.hooks?r.hooks.provideLexer(n):n?je.lex:je.lexInline)(e,r);r.hooks&&(l=r.hooks.processAllTokens(l)),r.walkTokens&&this.walkTokens(l,r.walkTokens);let a=(r.hooks?r.hooks.provideParser(n):n?Ge.parse:Ge.parseInline)(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}onError(n,e){return t=>{if(t.message+=`
68
+ Please report this to https://github.com/markedjs/marked.`,n){let i="<p>An error occurred:</p><pre>"+_e(t.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(t);throw t}}},wt=new er;function ie(n,e){return wt.parse(n,e)}ie.options=ie.setOptions=function(n){return wt.setOptions(n),ie.defaults=wt.defaults,Qr(ie.defaults),ie};ie.getDefaults=Wn;ie.defaults=yt;function Ia(...n){return wt.use(...n),ie.defaults=wt.defaults,Qr(ie.defaults),ie}ie.use=Ia;ie.walkTokens=function(n,e){return wt.walkTokens(n,e)};ie.parseInline=wt.parseInline;ie.Parser=Ge;ie.parser=Ge.parse;ie.Renderer=vn;ie.TextRenderer=Jn;ie.Lexer=je;ie.lexer=je.lex;ie.Tokenizer=kn;ie.Hooks=Zt;ie.parse=ie;var Fs=ie.options,Hs=ie.setOptions,js=ie.walkTokens,Gs=ie.parseInline;var qs=Ge.parse,Ws=je.lex;function Ra(n,e){this.v=n,this.k=e}function si(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=Array(e);t<e;t++)i[t]=n[t];return i}function Ca(n){if(Array.isArray(n))return n}function La(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var i,r,o,l,a=[],d=!0,p=!1;try{if(o=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;d=!1}else for(;!(d=(i=o.call(t)).done)&&(a.push(i.value),a.length!==e);d=!0);}catch(f){p=!0,r=f}finally{try{if(!d&&t.return!=null&&(l=t.return(),Object(l)!==l))return}finally{if(p)throw r}}return a}}function _a(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
69
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oa(n,e){return Ca(n)||La(n,e)||Pa(n,e)||_a()}function Pa(n,e){if(n){if(typeof n=="string")return si(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?si(n,e):void 0}}function En(n){var e,t;function i(o,l){try{var a=n[o](l),d=a.value,p=d instanceof Ra;Promise.resolve(p?d.v:d).then(function(f){if(p){var c=o==="return"&&d.k?o:"next";if(!d.k||f.done)return i(c,f);f=n[c](f).value}r(!!a.done,f)},function(f){i("throw",f)})}catch(f){r(2,f)}}function r(o,l){o===2?e.reject(l):e.resolve({value:l,done:o}),(e=e.next)?i(e.key,e.arg):t=null}this._invoke=function(o,l){return new Promise(function(a,d){var p={key:o,arg:l,resolve:a,reject:d,next:null};t?t=t.next=p:(e=t=p,i(o,l))})},typeof n.return!="function"&&(this.return=void 0)}En.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},En.prototype.next=function(n){return this._invoke("next",n)},En.prototype.throw=function(n){return this._invoke("throw",n)},En.prototype.return=function(n){return this._invoke("return",n)};var vi=Object.entries,li=Object.setPrototypeOf,Ma=Object.isFrozen,Ei=Object.getPrototypeOf,Ti=Object.getOwnPropertyDescriptor,fe=Object.freeze,be=Object.seal,Dt=Object.create,Ai=typeof Reflect<"u"&&Reflect,pr=Ai.apply,dr=Ai.construct;fe||(fe=function(e){return e});be||(be=function(e){return e});pr||(pr=function(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return e.apply(t,r)});dr||(dr=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return new e(...i)});var tt=ae(Array.prototype.forEach);Array.prototype.indexOf;var Na=ae(Array.prototype.lastIndexOf),ci=ae(Array.prototype.pop),en=ae(Array.prototype.push),Da=ae(Array.prototype.slice),za=ae(Array.prototype.splice),zt=Array.isArray,tr=Si(Set),nr=ae(Set.prototype.add),tn=ae(Set.prototype.has),kt=ae(String.prototype.toLowerCase),rr=ae(String.prototype.toString),pi=ae(String.prototype.match),nn=ae(String.prototype.replace),di=ae(String.prototype.indexOf),$a=ae(String.prototype.trim),Ua=ae(Number.prototype.toString),Ba=ae(Boolean.prototype.toString),ui=typeof BigInt>"u"?null:ae(BigInt.prototype.toString),fi=typeof Symbol>"u"?null:ae(Symbol.prototype.toString),Re=ae(Object.prototype.hasOwnProperty),rn=ae(Object.prototype.toString),ge=ae(RegExp.prototype.test),nt=Si(TypeError);function ae(n){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return pr(n,e,i)}}function Si(n){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return dr(n,t)}}function Y(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kt;if(li&&li(n,null),!zt(e))return n;let i=e.length;for(;i--;){let r=e[i];if(typeof r=="string"){let o=t(r);o!==r&&(Ma(e)||(e[i]=o),r=o)}n[r]=!0}return n}function Fa(n){for(let e=0;e<n.length;e++)Re(n,e)||(n[e]=null);return n}function Oe(n){let e=Dt(null);for(let i of vi(n)){var t=Oa(i,2);let r=t[0],o=t[1];Re(n,r)&&(zt(o)?e[r]=Fa(o):o&&typeof o=="object"&&o.constructor===Object?e[r]=Oe(o):e[r]=o)}return e}function Ha(n){switch(typeof n){case"string":return n;case"number":return Ua(n);case"boolean":return Ba(n);case"bigint":return ui?ui(n):"0";case"symbol":return fi?fi(n):"Symbol()";case"undefined":return rn(n);case"function":case"object":{if(n===null)return rn(n);let e=n,t=ze(e,"toString");if(typeof t=="function"){let i=t(e);return typeof i=="string"?i:rn(i)}return rn(n)}default:return rn(n)}}function ze(n,e){for(;n!==null;){let i=Ti(n,e);if(i){if(i.get)return ae(i.get);if(typeof i.value=="function")return ae(i.value)}n=Ei(n)}function t(){return null}return t}function ja(n,e){for(;n!==null;){let t=Ti(n,e);if(t)return t.get?ae(t.get):null;n=Ei(n)}return null}function Ga(n){try{return ge(n,""),!0}catch{return!1}}var hi=fe(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ir=fe(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),or=fe(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),qa=fe(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ar=fe(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Wa=fe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),mi=fe(["#text"]),gi=fe(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),sr=fe(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),bi=fe(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Tn=fe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ya=be(/{{[\w\W]*|^[\w\W]*}}/g),Xa=be(/<%[\w\W]*|^[\w\W]*%>/g),Va=be(/\${[\w\W]*/g),Za=be(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ka=be(/^aria-[\-\w]+$/),xi=be(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Qa=be(/^(?:\w+script|data):/i),Ja=be(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),es=be(/^html$/i),ts=be(/^[a-z][.\w]*(-[.\w]+)+$/i),lr=be(/<[/\w!]/g),wi=be(/<[/\w]/g),ns=be(/<\/no(script|embed|frames)/i),yi=be(/\/>/i),ce={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},rs=fe(Y({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),is=function(){return typeof window>"u"?null:window},os=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(i=t.getAttribute(r));let o="dompurify"+(i?"#"+i:"");try{return e.createPolicy(o,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},ki=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},dt=function(e,t,i,r){return Re(e,t)&&zt(e[t])?Y(r.base?Oe(r.base):{},e[t],r.transform):i},cr=function(e,t,i){let r=Re(e,t)?e[t]:void 0;return r&&typeof r=="object"?Oe(r):i()};function Ii(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:is(),e=k=>Ii(k);if(e.version="3.4.17",e.removed=[],!n||!n.document||n.document.nodeType!==ce.document||!n.Element)return e.isSupported=!1,e;let t=n.document,i=t,r=i.currentScript;n.DocumentFragment;let o=n.HTMLTemplateElement,l=n.Node,a=n.Element,d=n.NodeFilter;n.NamedNodeMap===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;let p=n.DOMParser,f=n.trustedTypes,c=a.prototype,m=ze(c,"cloneNode"),g=ze(c,"remove"),v=ze(c,"removeAttributeNode"),L=ze(c,"nextSibling"),A=ze(c,"childNodes"),b=ze(c,"parentNode"),y=ze(c,"shadowRoot"),E=ze(c,"attributes"),_=l&&l.prototype?ze(l.prototype,"nodeType"):null,U=l&&l.prototype?ze(l.prototype,"nodeName"):null,F=l&&l.prototype?ze(l.prototype,"ownerDocument"):null,O=function(s){return _?_(s):s.nodeType},q=function(s){return U?U(s):s.nodeName},H=ja(c,"namespaceURI"),T=function(s){return H?H(s):s.namespaceURI};if(typeof o=="function"){let k=t.createElement("template");k.content&&k.content.ownerDocument&&(t=k.content.ownerDocument)}let C,$="",te,ne=!1,S=0,P=function(){if(S>0)throw nt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},I=function(s){P(),S++;try{return C.createHTML(s)}finally{S--}},M=function(s){P(),S++;try{return C.createScriptURL(s)}finally{S--}},G=function(){return ne||(te=os(f,r),ne=!0),te},V=t,re=V.implementation,he=V.createNodeIterator,we=V.createDocumentFragment,Qe=V.getElementsByTagName,rt=i.importNode,Q=ki();e.isSupported=typeof vi=="function"&&typeof b=="function"&&re&&re.createHTMLDocument!==void 0;let qe=Ya,Ce=Xa,vt=Va,$e=Za,Pe=Ka,Ue=Qa,an=Ja,Z=ts,J=xi,ee=null,it=Y({},[...hi,...ir,...or,...ar,...mi]),W=null,Le=Y({},[...gi,...sr,...bi,...Tn]),Ee=Object.seal(Dt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Je=null,Et=null,Me=Object.seal(Dt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),sn=!0,Be=!0,ln=!1,Ut=!0,me=!1,ye=!0,ke=!1,Tt=!1,Fe=null,ot=null,ft=!1,Ne=!1,At=!1,ht=!1,mt=!0,Te=!1,xe="user-content-",St=!0,We=!1,Ye=null,et={},Xe=null,at=Y({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),It=null,gt=Y({},["audio","video","img","source","image","track"]),st=null,Bt=Y({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rt="http://www.w3.org/1998/Math/MathML",h="http://www.w3.org/2000/svg",R="http://www.w3.org/1999/xhtml",N=R,K=!1,se=null,oe=Y({},[Rt,h,R],rr),X=fe(["mi","mo","mn","ms","mtext"]),de=Y({},X),De=fe(["annotation-xml"]),Ae=Y({},De),cn=Y({},["title","style","font","a","script"]),Ft=null,ro=["application/xhtml+xml","text/html"],io="text/html",le=null,Ct=null,oo=t.createElement("form"),fr=function(s){return s instanceof RegExp||s instanceof Function},In=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ct&&Ct===s)return;(!s||typeof s!="object")&&(s={}),s=Oe(s),Ft=ro.indexOf(s.PARSER_MEDIA_TYPE)===-1?io:s.PARSER_MEDIA_TYPE,le=Ft==="application/xhtml+xml"?rr:kt,ee=dt(s,"ALLOWED_TAGS",it,{transform:le}),W=dt(s,"ALLOWED_ATTR",Le,{transform:le}),se=dt(s,"ALLOWED_NAMESPACES",oe,{transform:rr}),st=dt(s,"ADD_URI_SAFE_ATTR",Bt,{transform:le,base:Bt}),It=dt(s,"ADD_DATA_URI_TAGS",gt,{transform:le,base:gt}),Xe=dt(s,"FORBID_CONTENTS",at,{transform:le}),Je=dt(s,"FORBID_TAGS",Oe({}),{transform:le}),Et=dt(s,"FORBID_ATTR",Oe({}),{transform:le}),et=Re(s,"USE_PROFILES")?s.USE_PROFILES&&typeof s.USE_PROFILES=="object"?Oe(s.USE_PROFILES):s.USE_PROFILES:!1,sn=s.ALLOW_ARIA_ATTR!==!1,Be=s.ALLOW_DATA_ATTR!==!1,ln=s.ALLOW_UNKNOWN_PROTOCOLS||!1,Ut=s.ALLOW_SELF_CLOSE_IN_ATTR!==!1,me=s.SAFE_FOR_TEMPLATES||!1,ye=s.SAFE_FOR_XML!==!1,ke=s.WHOLE_DOCUMENT||!1,Ne=s.RETURN_DOM||!1,At=s.RETURN_DOM_FRAGMENT||!1,ht=s.RETURN_TRUSTED_TYPE||!1,ft=s.FORCE_BODY||!1,mt=s.SANITIZE_DOM!==!1,Te=s.SANITIZE_NAMED_PROPS||!1,St=s.KEEP_CONTENT!==!1,We=s.IN_PLACE||!1,J=Ga(s.ALLOWED_URI_REGEXP)?s.ALLOWED_URI_REGEXP:xi,N=typeof s.NAMESPACE=="string"?s.NAMESPACE:R,de=cr(s,"MATHML_TEXT_INTEGRATION_POINTS",()=>Y({},X)),Ae=cr(s,"HTML_INTEGRATION_POINTS",()=>Y({},De));let u=cr(s,"CUSTOM_ELEMENT_HANDLING",()=>Dt(null));if(Ee=Dt(null),Re(u,"tagNameCheck")&&fr(u.tagNameCheck)&&(Ee.tagNameCheck=u.tagNameCheck),Re(u,"attributeNameCheck")&&fr(u.attributeNameCheck)&&(Ee.attributeNameCheck=u.attributeNameCheck),Re(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(Ee.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),be(Ee),me&&(Be=!1),At&&(Ne=!0),et&&(ee=Y({},mi),W=Dt(null),et.html===!0&&(Y(ee,hi),Y(W,gi)),et.svg===!0&&(Y(ee,ir),Y(W,sr),Y(W,Tn)),et.svgFilters===!0&&(Y(ee,or),Y(W,sr),Y(W,Tn)),et.mathMl===!0&&(Y(ee,ar),Y(W,bi),Y(W,Tn))),Me.tagCheck=null,Me.attributeCheck=null,Re(s,"ADD_TAGS")&&(typeof s.ADD_TAGS=="function"?Me.tagCheck=s.ADD_TAGS:zt(s.ADD_TAGS)&&(ee===it&&(ee=Oe(ee)),Y(ee,s.ADD_TAGS,le))),Re(s,"ADD_ATTR")&&(typeof s.ADD_ATTR=="function"?Me.attributeCheck=s.ADD_ATTR:zt(s.ADD_ATTR)&&(W===Le&&(W=Oe(W)),Y(W,s.ADD_ATTR,le))),Re(s,"ADD_FORBID_CONTENTS")&&zt(s.ADD_FORBID_CONTENTS)&&(Xe===at&&(Xe=Oe(Xe)),Y(Xe,s.ADD_FORBID_CONTENTS,le)),St&&(ee["#text"]=!0),ke&&Y(ee,["html","head","body"]),ee.table&&(Y(ee,["tbody"]),delete Je.tbody),s.TRUSTED_TYPES_POLICY){if(typeof s.TRUSTED_TYPES_POLICY.createHTML!="function")throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof s.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw nt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let x=C;C=s.TRUSTED_TYPES_POLICY;try{$=I("")}catch(w){throw C=x,w}}else s.TRUSTED_TYPES_POLICY===null?(C=void 0,$=""):(C===void 0&&(C=G()),C&&typeof $=="string"&&($=I("")));fe&&fe(s),Ct=s},hr=Y({},[...ir,...or,...qa]),mr=Y({},[...ar,...Wa]),ao=function(s,u,x){return u.namespaceURI===R?s==="svg":u.namespaceURI===Rt?s==="svg"&&(x==="annotation-xml"||de[x]):!!hr[s]},so=function(s,u,x){return u.namespaceURI===R?s==="math":u.namespaceURI===h?s==="math"&&Ae[x]:!!mr[s]},lo=function(s,u,x){return u.namespaceURI===h&&!Ae[x]||u.namespaceURI===Rt&&!de[x]?!1:!mr[s]&&(cn[s]||!hr[s])},co=function(s){let u=T(s),x=kt(q(s)),w=b(s),D,z;return w&&O(w)===ce.element?(D={namespaceURI:T(w)},z=kt(q(w))):(D={namespaceURI:N},z="template"),se[u]?u===h?ao(x,D,z):u===Rt?so(x,D,z):u===R?lo(x,D,z):!!(Ft==="application/xhtml+xml"&&se[u]):!1},lt=function(s){en(e.removed,{element:s});try{b(s).removeChild(s)}catch{if(g(s),!b(s))throw nt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},gr=function(s,u,x){try{v(s,u)}catch{try{s.removeAttribute(x)}catch{}}},Rn=function(s){Ln(s);let u=A(s);u&&tt(Da(u),w=>{try{g(w)}catch{}});let x=O(s)===ce.element?E(s):null;if(x)for(let w=x.length-1;w>=0;--w){let D=x[w],z=D&&D.name;typeof z=="string"&&gr(s,D,z)}},Lt=function(s,u,x){if(!x)try{x=u.getAttributeNode(s)}catch{x=null}en(e.removed,{attribute:x||null,from:u});try{x?v(u,x):u.removeAttribute(s)}catch{try{u.removeAttribute(s)}catch{}}if(s==="is")if(Ne||At)try{lt(u)}catch{}else try{u.setAttribute(s,"")}catch{}},br=function(s){let u=E(s);if(u)for(let x=u.length-1;x>=0;--x){let w=u[x],D=w&&w.name;typeof D!="string"||W[le(D)]||gr(s,w,D)}},Cn=function(s,u){let x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,w=[s];for(;w.length>0;){let D=w.pop();if(u(D)===!1)continue;if(x&&O(D)===ce.element){let j=y(D);ct(j)&&w.push(j)}let z=A(D);if(z)for(let j=z.length-1;j>=0;--j)w.push(z[j])}},Ln=function(s){Cn(s,u=>{O(u)===ce.element&&br(u)})},_n=function(s){let u=[];return Cn(s,x=>{u.push(x)},!0),u},po=function(s,u){let x=tr();tt(_n(s),w=>{O(w)===ce.element&&nr(x,w)}),tt(u,w=>{O(w)===ce.element&&!tn(x,w)&&br(w)})},xr=function(s,u){let x=!1;return tt(e.removed,w=>{w.element&&(x=x||w.element===s,Ln(w.element))}),po(s,u),x},uo=8,fo=function(s,u){let x=Ye,w=null,D=()=>(w||(w=tr(),tt(u,z=>{nr(w,z)})),w);for(let z=0;;z++){let j=_n(s),pe=[s],Ve=!1;if(tt(j,ve=>{O(ve)===ce.documentFragment?en(pe,ve):!Ve&&!tn(x,ve)&&(Ve=tn(D(),ve))}),!Ve)return;if(z>=uo)throw nt("the tree kept changing during in-place sanitization; refusing to return it");tt(pe,(ve,Se)=>{ho(ve,Se>0,s,D())})}},ho=function(s,u,x,w){let D=On(s),z;for(;z=D.nextNode();)!tn(w,z)||tn(Ye,z)||(u&&He(Q.uponSanitizeShadowNode,z,null),Mn(z,x),Nn(z,x),ct(z.content)&&jt(z.content))},mo=function(s){Ye&&nr(Ye,s)},wr=function(s,u){return ye?s==="patchsrc"?!0:s==="for"&&u!=="label"&&u!=="output":!1},go=function(s){ye&&Cn(s,u=>{let x=O(u);if(x===ce.processingInstruction||x===ce.comment&&ge(wi,u.data)){try{g(u)}catch{}return!1}if(x===ce.element){let w=u,D=le(q(u));try{w.hasAttribute&&w.hasAttribute("patchsrc")&&w.removeAttribute("patchsrc"),w.hasAttribute&&w.hasAttribute("for")&&wr("for",D)&&w.removeAttribute("for")}catch{}}return!0})},yr=function(s){let u=null,x=null;if(ft)s="<remove></remove>"+s;else{let z=pi(s,/^[\r\n\t ]+/);x=z&&z[0]}Ft==="application/xhtml+xml"&&N===R&&(s='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+s+"</body></html>");let w=C?I(s):s;if(N===R)try{u=new p().parseFromString(w,Ft)}catch{}if(!u||!u.documentElement){u=re.createDocument(N,"template",null);try{u.documentElement.innerHTML=K?$:w}catch{}}let D=u.body||u.documentElement;return s&&x&&D.insertBefore(t.createTextNode(x),D.childNodes[0]||null),N===R?Qe.call(u,ke?"html":"body")[0]:ke?u.documentElement:D},On=function(s){let u=F?F(s):s.ownerDocument;return he.call(u||s,s,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},pn=function(s){return s=nn(s,qe," "),s=nn(s,Ce," "),s=nn(s,vt," "),s},Pn=function(s){var u;kr(s);let x=(u=s.querySelectorAll)===null||u===void 0?void 0:u.call(s,"template");x&&tt(x,w=>{ct(w.content)&&Pn(w.content)})},kr=function(s){s.normalize();let u=F?F(s):s.ownerDocument,x=he.call(u||s,s,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null),w=x.nextNode();for(;w;)w.data=pn(w.data),w=x.nextNode()},dn=function(s){let u=U?U(s):null;return typeof u!="string"||le(u)!=="form"?!1:typeof s.nodeName!="string"||typeof s.textContent!="string"||typeof s.removeChild!="function"||s.attributes!==E(s)||typeof s.removeAttribute!="function"||typeof s.removeAttributeNode!="function"||typeof s.getAttributeNode!="function"||typeof s.setAttribute!="function"||typeof s.namespaceURI!="string"||typeof s.insertBefore!="function"||typeof s.hasChildNodes!="function"||s.nodeType!==_(s)||s.childNodes!==A(s)},ct=function(s){if(!_||typeof s!="object"||s===null)return!1;try{return _(s)===ce.documentFragment}catch{return!1}},Ht=function(s){if(!_||typeof s!="object"||s===null)return!1;try{return typeof _(s)=="number"}catch{return!1}};function He(k,s,u){k.length!==0&&tt(k,x=>{x.call(e,s,u,Ct)})}let bo=function(s,u){return!!(ye&&s.hasChildNodes()&&!Ht(s.firstElementChild)&&ge(lr,s.textContent)&&ge(lr,s.innerHTML)||ye&&rs[u]&&O(s)===ce.element&&T(s)===R&&(Ht(s.firstElementChild)||typeof s.textContent=="string"&&ge(lr,s.textContent))||s.nodeType===ce.processingInstruction||ye&&s.nodeType===ce.comment&&ge(wi,s.data))},un=function(s,u){if(s instanceof RegExp)return ge(s,u);if(s instanceof Function){for(var x=arguments.length,w=new Array(x>2?x-2:0),D=2;D<x;D++)w[D-2]=arguments[D];return!!s(u,...w)}return!1},xo=function(s,u,x){if(!Je[u]&&Tr(u)&&un(Ee.tagNameCheck,u))return!1;if(St&&!Xe[u]&&!Xe[kt(u)]){let w=b(s),D=A(s);if(D&&w){let z=D.length;for(let j=z-1;j>=0;--j){let pe=s===x?m(D[j],!0):D[j];w.insertBefore(pe,L(s))}}}return lt(s),!0},vr=function(s,u,x,w){return s.length===0?u:u===x||u===w?Oe(u):u},_t=function(s,u){return s===u||b(s)!==null?!1:(We&&Ln(s),!0)},Mn=function(s,u){if(mo(s),He(Q.beforeSanitizeElements,s,null),_t(s,u))return!0;if(dn(s))return lt(s),!0;let x=le(q(s));if(ee=vr(Q.uponSanitizeElement,ee,it,Fe),He(Q.uponSanitizeElement,s,{tagName:x,allowedTags:ee}),_t(s,u))return!0;if(bo(s,x))return lt(s),!0;if(Je[x]||!(Me.tagCheck instanceof Function&&Me.tagCheck(x))&&!ee[x]){let w=xo(s,x,u);return w===!1&&(He(Q.afterSanitizeElements,s,null),_t(s,u))?!0:w}if(O(s)===ce.element&&!co(s)||(x==="noscript"||x==="noembed"||x==="noframes")&&ge(ns,s.innerHTML))return lt(s),!0;if(me&&s.nodeType===ce.text){let w=pn(s.textContent);s.textContent!==w&&(en(e.removed,{element:s.cloneNode()}),s.textContent=w)}return He(Q.afterSanitizeElements,s,null),_t(s,u)},Er=function(s,u,x){if(Et[u]||wr(u,s)||mt&&(u==="id"||u==="name")&&(x in t||x in oo))return!1;let w=W[u]||Me.attributeCheck instanceof Function&&Me.attributeCheck(u,s);return Be&&ge($e,u)||sn&&ge(Pe,u)?!0:w?st[u]||ge(J,nn(x,an,""))||(u==="src"||u==="xlink:href"||u==="href")&&s!=="script"&&di(x,"data:")===0&&It[s]||ln&&!ge(Ue,nn(x,an,""))?!0:!x:Tr(s)&&un(Ee.tagNameCheck,s)&&un(Ee.attributeNameCheck,u,s)||u==="is"&&Ee.allowCustomizedBuiltInElements&&un(Ee.tagNameCheck,x)},wo=Y({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Tr=function(s){return!wo[kt(s)]&&ge(Z,s)},yo=function(s,u,x,w){if(C&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!x)switch(f.getAttributeType(s,u)){case"TrustedHTML":return I(w);case"TrustedScriptURL":return M(w)}return w},ko=function(s,u,x,w){try{return x?s.setAttributeNS(x,u,w):s.setAttribute(u,w),dn(s)?(lt(s),!1):!0}catch{return Lt(u,s),!1}},Ar=function(s,u){return ye&&ge(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)?!0:kt(s)==="attributename"&&pi(u,"href")!==null},Nn=function(s,u){if(He(Q.beforeSanitizeAttributes,s,null),_t(s,u))return;let x=s.attributes;if(!x||dn(s))return;W=vr(Q.uponSanitizeAttribute,W,Le,ot);let w={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0},D=x.length,z=le(s.nodeName);for(;D--;){let j=x[D],pe=j.name,Ve=j.namespaceURI,ve=j.value,Se=le(pe),Ot=ve,Ie=pe==="value"?Ot:$a(Ot),Sr=!1;if(w.attrName=Se,w.attrValue=Ie,w.keepAttr=!0,w.forceKeepAttr=void 0,He(Q.uponSanitizeAttribute,s,w),Ie=w.attrValue,Te&&(Se==="id"||Se==="name")&&di(Ie,xe)!==0&&(Lt(pe,s,j),Ie=xe+Ie,Sr=!0),Ar(pe,Ie)){Lt(pe,s,j);continue}if(!w.forceKeepAttr){if(!w.keepAttr){Lt(pe,s,j);continue}if(!Ut&&ge(yi,Ie)){Lt(pe,s,j);continue}if(me&&(Ie=pn(Ie)),!Er(z,Se,Ie)){Lt(pe,s,j);continue}Ie=yo(z,Se,Ve,Ie),Ie!==Ot&&ko(s,pe,Ve,Ie)&&Sr&&ci(e.removed)}}He(Q.afterSanitizeAttributes,s,null),_t(s,u)},jt=function(s){let u=null,x=On(s);for(He(Q.beforeSanitizeShadowDOM,s,null);u=x.nextNode();)if(He(Q.uponSanitizeShadowNode,u,null),Mn(u,s),Nn(u,s),ct(u.content)&&jt(u.content),O(u)===ce.element){let w=y(u);ct(w)&&(Dn(w),jt(w))}me&&kr(s),He(Q.afterSanitizeShadowDOM,s,null)},Dn=function(s){let u=[{node:s,shadow:null}];for(;u.length>0;){let x=u.pop();if(x.shadow){jt(x.shadow);continue}let w=x.node,D=O(w)===ce.element,z=A(w);if(z)for(let j=z.length-1;j>=0;--j)u.push({node:z[j],shadow:null});if(D){let j=U?U(w):null;if(typeof j=="string"&&le(j)==="template"){let pe=w.content;ct(pe)&&u.push({node:pe,shadow:null})}}if(D){let j=y(w);ct(j)&&u.push({node:null,shadow:j},{node:j,shadow:null})}}};return e.sanitize=function(k){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,x=null,w=null,D=null;if(K=!k,K&&(k="<!-->"),typeof k!="string"&&!Ht(k)&&(k=Ha(k),typeof k!="string"))throw nt("dirty is not a string, aborting");if(!e.isSupported)return k;Tt?(ee=Fe,W=ot):In(s),(Q.uponSanitizeElement.length>0||Q.uponSanitizeAttribute.length>0)&&(ee=Oe(ee)),Q.uponSanitizeAttribute.length>0&&(W=Oe(W)),e.removed=[];let z=We&&typeof k!="string"&&Ht(k),j=[],pe=Ye;if(z){go(k);let Se=q(k);if(typeof Se=="string"){let Ot=le(Se);if(!ee[Ot]||Je[Ot])throw Rn(k),nt("root node is forbidden and cannot be sanitized in-place")}if(dn(k))throw Rn(k),nt("root node is clobbered and cannot be sanitized in-place");j=_n(k),Ye=tr()}else if(Ht(k))u=yr("<!---->"),x=u.ownerDocument.importNode(k,!0),x.nodeType===ce.element&&x.nodeName==="BODY"||x.nodeName==="HTML"?u=x:u.appendChild(x),Dn(u);else{if(!Ne&&!me&&!ke&&k.indexOf("<")===-1)return C&&ht?I(k):k;if(u=yr(k),!u)return Ne?null:ht?$:""}u&&ft&&lt(u.firstChild);let Ve=z?k:u;try{z&&Dn(k);let Se=On(Ve);for(;w=Se.nextNode();)Mn(w,Ve),Nn(w,Ve),ct(w.content)&&jt(w.content);z&&fo(k,j)}catch(Se){throw z&&(Rn(k),xr(k,j)),Se}finally{Ye=pe}if(z){if(xr(k,j))throw nt("a node selected for removal could not be safely returned; refusing to sanitize in place");return me&&Pn(k),k}if(Ne){if(me&&Pn(u),At)for(D=we.call(u.ownerDocument);u.firstChild;)D.appendChild(u.firstChild);else D=u;return(W.shadowroot||W.shadowrootmode)&&(D=rt.call(i,D,!0)),D}let ve=ke?u.outerHTML:u.innerHTML;return ke&&ee["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&ge(es,u.ownerDocument.doctype.name)&&(ve="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
70
+ `+ve),me&&(ve=pn(ve)),C&&ht?I(ve):ve},e.setConfig=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};In(k),Tt=!0,Fe=ee,ot=W},e.clearConfig=function(){Ct=null,Tt=!1,Fe=null,ot=null,C=te,$=""},e.isValidAttribute=function(k,s,u){Ct||In({});let x=le(k),w=le(s);return typeof u=="string"&&(Ar(s,u)||!Ut&&ge(yi,u))?!1:Er(x,w,u)},e.addHook=function(k,s){typeof s=="function"&&Re(Q,k)&&en(Q[k],s)},e.removeHook=function(k,s){if(Re(Q,k)){if(s!==void 0){let u=Na(Q[k],s);return u===-1?void 0:za(Q[k],u,1)[0]}return ci(Q[k])}},e.removeHooks=function(k){Re(Q,k)&&(Q[k]=[])},e.removeAllHooks=function(){Q=ki()},e}var Ri=Ii();var as={num:{type:"num",match:/(\.e?|\b)\d(e-|[\d.oxa-fA-F_])*(\.|\b)/g},str:{type:"str",match:/(["'])(\\[^]|(?!\1)[^\r\n\\])*\1?/g},strDouble:{type:"str",match:/"((?!")[^\r\n\\]|\\[^])*"?/g}};function*Ci(n,e,t,i){let r=0;try{let o,l,a={},d,p=[],f=typeof e=="string"?yield e:e,c=[...f.sub??f];for(;r<n.length;){for(a.index=null,o=c.length;o-- >0;){if(l=c[o].expand?as[c[o].expand]:c[o],p[o]===void 0||p[o].match.index<r){if(l.match.lastIndex=r,d=l.match.exec(n),d===null){c.splice(o,1),p.splice(o,1);continue}p[o]={match:d,lastIndex:l.match.lastIndex}}p[o].match[0]&&(p[o].match.index<=a.index||a.index===null)&&(a={part:l,index:p[o].match.index,match:p[o].match[0],end:p[o].lastIndex})}if(a.index===null)break;t(n.slice(r,a.index),f.type),r=a.index,a.part.sub?yield*Ci(a.match,typeof a.part.sub=="string"?a.part.sub:typeof a.part.sub=="function"?a.part.sub(a.match):a.part,t,a.part.type):t(a.match,a.part.type),r=a.end}t(n.slice(r,n.length),f.type)}catch{t(n.slice(r),i)}}function Li(n,e,t,i={}){let r=Ci(n,e,t),o=r.next();for(;!o.done;)o=r.next(i.languages?.[o.value])}var _i=[{match:/--.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{type:"func",match:/\b(AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/gi},{type:"kwd",match:/\b(ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:S|ING)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/gi},{type:"num",match:/\.?\d[\d.oxa-fA-F-]*|\bNULL\b/gi},{type:"bool",match:/\b(TRUE|FALSE)\b/gi},{type:"oper",match:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|IN|ILIKE|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/gi},{type:"var",match:/@\S+/g}];var Oi={type:"var",match:/\$\w+|\${[^}]*}|\$\([^)]*\)/g},Pi=[{type:"cmnt",sub:"todo",match:/#.*/g},{type:"str",match:/(["'])((?!\1)[^\r\n\\]|\\[^])*\1?/g,sub:[Oi]},{type:"oper",match:/(?<=\s|^)\.*\/[a-z/_.-]+/gi},{type:"kwd",match:/\s-[a-zA-Z]+|[&|;]+|\b(unset|readonly|shift|export|if|fi|else|elif|while|do|done|for|until|case|esac|break|continue|exit|return|trap|wait|eval|exec|then|declare|enable|local|select|typeset|time|add|remove|install|update|delete)(?=\s|$)/g},{expand:"num"},{type:"func",match:/(?<=(^|\||\&\&|\;)\s*)[a-z_.-]+(?=\s|$)/gmi},{type:"bool",match:/(?<=\s|^)(true|false)(?=\s|$)/g},{type:"oper",match:/[=(){}<>!]+/g},{type:"var",match:/(?<=\s|^)[\w_]+(?=\s*=)/g},Oi];var Mi=[{match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{match:/\/\*\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"jsdoc"},{match:/\/\/.*\n?|\/\*((?!\*\/)[^])*(\*\/)?/g,type:"cmnt",sub:"todo"},{expand:"str"},{match:/`((?!`)[^]|\\[^])*`?/g,type:"str",sub:[{match:new class{exec(n){let e=this.lastIndex,t,i=r=>{for(;++e<n.length-2;)if(n[e]=="{")i();else if(n[e]=="}")return};for(;e<n.length;++e)if(n[e-1]!="\\"&&n[e]=="$"&&n[e+1]=="{")return t=e++,i(e),this.lastIndex=e+1,{index:t,0:n.slice(t,e+1)};return null}},sub:[{type:"kwd",match:/^\${|}$/g},{match:/(?!^\$|{)[^]+(?=}$)/g,sub:"js"}]}]},{type:"kwd",match:/=>|(?<![^.]\.)\b(this|set|get|as|async|await|break|case|catch|class|const|constructor|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|if|implements|import|in|instanceof|interface|let|var|of|new|package|private|protected|public|return|static|super|switch|throw|throws|try|typeof|void|while|with|yield)\b/g},{match:/(?<=[^\w$)\]'"`\s]\s*|\b(case|do|else|in|instanceof|new|of|return|throw|typeof|void|yield|await)\s+|^\s*)\/((?!\/)[^\r\n\\]|\\.)+\/\w*/gm,type:"oper",sub:"regex"},{expand:"num"},{type:"num",match:/\b(NaN|null|undefined|[A-Z][A-Z_]*)\b/g},{type:"bool",match:/\b(true|false)\b/g},{type:"var",match:/#[\w$]+/g},{type:"oper",match:/[/*+:?&|%^~=!,<>.^-]+/g},{type:"class",match:/\b[A-Z][\w_]*\b/g},{type:"func",match:/[a-zA-Z$_][\w$_]*(?=\s*((\?\.)?\s*\(|=\s*(\(?[\w,{}\[\])]+\)? =>|function\b)))/g}];var Ni=[{type:"var",match:/(("|')((?!\2)[^\r\n\\]|\\[^])*\2|[a-zA-Z]\w*)(?=\s*:)/g},{expand:"str"},{expand:"num"},{type:"num",match:/\bnull\b/g},{type:"bool",match:/\b(true|false)\b/g}];var Di=[{match:/#.*/g,type:"cmnt",sub:"todo"},{type:"str",match:/f("""|''')(\\[^]|(?!\1)[^])*\1?|f("|')(\\[^]|(?!\3).)*\3?/gi,sub:[{type:"var",match:/{[^{}]*}/g,sub:[{match:/(?!^{)[^]*(?=}$)/g,sub:"py"}]}]},{match:/("""|''')(\\[^]|(?!\1)[^])*\1?/g,type:"cmnt",sub:"todo"},{expand:"str"},{type:"kwd",match:/\b(and|as|assert|async|await|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\b/g},{type:"bool",match:/\b(False|True|None)\b/g},{expand:"num"},{type:"func",match:/[a-z_]\w*(?=\s*\()/gi},{type:"oper",match:/[-/*+<>,=!&|^%]+/g},{type:"class",match:/\b[A-Z][\w_]*\b/g}];var ss={type:"cmnt",sub:[{type:"err",match:/\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g},{type:"class",match:/\bIDEA\b/g},{type:"insert",match:/\b(CHANGED|FIX|CHANGE)\b/g},{type:"oper",match:/\bQUESTION\b/g}]},zi={type:"cmnt",sub:[{type:"kwd",match:/@\w+/g},{type:"type",match:/{[\w\s|<>,.@\[\]]+}/g},{type:"var",match:/\[[\w\s="']+\]/g},...ss.sub]};var $i={type:"cmnt",sub:[{type:"err",match:/\b(TODO|FIXME|DEBUG|OPTIMIZE|WARNING|XXX|BUG)\b/g},{type:"class",match:/\bIDEA\b/g},{type:"insert",match:/\b(CHANGED|FIX|CHANGE)\b/g},{type:"oper",match:/\bQUESTION\b/g}]};var Ui={type:"oper",sub:[{match:/^(?!\/).*/gm,type:"cmnt",sub:"todo"},{type:"num",match:/\[((?!\])[^\\]|\\.)*\]/g},{type:"kwd",match:/\||\^|\$|\\.|\w+($|\r|\n)/g},{type:"var",match:/[*+?.]|\{\d+(,\d*)?\}/g}]};var Bi={sql:_i,bash:Pi,js:Mi,json:Ni,py:Di,jsdoc:zi,todo:$i,regex:Ui},ls={javascript:"js",jsx:"js",mjs:"js",cjs:"js",python:"py",gyp:"py",ipython:"py",sh:"bash",shell:"bash",zsh:"bash",jsonc:"json"},cs={kwd:"keyword",str:"string",cmnt:"comment",num:"number",bool:"literal",func:"title",class:"title",section:"section",var:"variable",type:"type",oper:"operator",esc:"meta",err:"deletion",insert:"addition",deleted:"deletion"};function Fi(n,e){let t=Bi[ls[e]||e];if(!t)return;let i=n.textContent||"",r=n.ownerDocument,o=r.createDocumentFragment();Li(i,t,(l,a)=>{if(!a){o.append(r.createTextNode(l));return}let d=r.createElement("span");d.className=`hljs-${cs[a]}`,d.textContent=l,o.append(d)},{languages:Bi}),o.textContent===i&&n.replaceChildren(o)}function Hi(n){let e=new er({gfm:!0,breaks:!1}),t=Ri(n),i=n.document;return(r,o)=>{let l=t.sanitize(e.parse(o),{RETURN_DOM_FRAGMENT:!0,ALLOWED_TAGS:["p","br","strong","em","del","code","pre","blockquote","ul","ol","li","hr","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","th","td","a"],ALLOWED_ATTR:["href","title","class","start","align"],ALLOW_DATA_ATTR:!1});for(let a of l.querySelectorAll("a")){let d=a.getAttribute("href");if(d)try{["http:","https:","mailto:"].includes(new URL(d,n.location.href).protocol)||a.removeAttribute("href")}catch{a.removeAttribute("href")}a.target="_blank",a.rel="noopener noreferrer",a.referrerPolicy="no-referrer"}for(let a of l.querySelectorAll("table")){let d=i.createElement("div");d.className="table-scroll",a.replaceWith(d),d.append(a)}for(let a of l.querySelectorAll("pre")){let d=a.querySelector("code");if(!d)continue;let p=i.createElement("div");p.className="code-block";let f=i.createElement("div");f.className="code-header";let c=i.createElement("span"),m=d.className.match(/\blanguage-([\w-]+)/)?.[1];c.textContent=m?.toUpperCase()||"CODE",m&&Fi(d,m);let g=i.createElement("button");g.type="button",g.textContent="复制",g.addEventListener("click",async()=>{try{await n.navigator.clipboard.writeText(d.textContent),g.textContent="已复制"}catch{g.textContent="复制失败"}}),f.append(c,g),a.replaceWith(p),p.append(f,a)}r.replaceChildren(l)}}var ji=`
73
71
  #panel{--solar-bg:#fdf6e3;--solar-raised:#eee8d5;--solar-text:#657b83;--solar-strong:#586e75;--solar-muted:#93a1a1;--solar-blue:#268bd2;--solar-cyan:#2aa198;--solar-green:#859900;--solar-red:#dc322f;--solar-yellow:#b58900;--solar-magenta:#d33682}
74
72
  .markdown code{background:var(--solar-raised);color:var(--solar-strong)}
75
73
  .markdown pre,#file-preview-content,#terminal-output{background:var(--solar-bg);color:var(--solar-text);scrollbar-color:var(--solar-muted) var(--solar-bg);color-scheme:light}
@@ -78,7 +76,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
78
76
  #terminal-pane .workspace-tools,#terminal-form{background:var(--solar-raised);color:var(--solar-strong)}#terminal-input{background:var(--solar-bg);border-color:#d9d2bd;color:var(--solar-strong)}#terminal-input::placeholder{color:var(--solar-muted)}#terminal-prompt{color:var(--solar-green)}#terminal-pane .terminal-help{background:var(--solar-bg);color:var(--solar-text)}
79
77
  .markdown pre::selection,.markdown pre ::selection,#terminal-output::selection,#file-preview-content::selection{background:var(--solar-raised);color:var(--solar-strong)}
80
78
  .hljs-comment,.hljs-quote{color:var(--solar-muted);font-style:italic}.hljs-keyword,.hljs-selector-tag,.hljs-addition{color:var(--solar-green)}.hljs-string,.hljs-regexp,.hljs-meta .hljs-string{color:var(--solar-cyan)}.hljs-number,.hljs-literal{color:var(--solar-magenta)}.hljs-title,.hljs-section,.hljs-name{color:var(--solar-blue)}.hljs-type,.hljs-built_in,.hljs-attr{color:var(--solar-yellow)}.hljs-variable,.hljs-template-variable,.hljs-deletion{color:var(--solar-red)}.hljs-meta{color:#cb4b16}
81
- `;var pl={settings:'<path d="M3 4h10M3 8h10M3 12h10M6 2v4M10 6v4M6 10v4"/>',plus:'<path d="M8 3v10M3 8h10"/>',refresh:'<path d="M13 7a5 5 0 1 0-1 4M13 3v4H9"/>',expand:'<path d="M6 3H3v3m7-3h3v3M3 10v3h3m7-3v3h-3"/>',close:'<path d="m4 4 8 8M12 4l-8 8"/>',arrow:'<path d="M8 13V3M4 7l4-4 4 4"/>'},nt=t=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${pl[t]}</svg>`,Ji=`
79
+ `;var ds={settings:'<path d="M3 4h10M3 8h10M3 12h10M6 2v4M10 6v4M6 10v4"/>',plus:'<path d="M8 3v10M3 8h10"/>',refresh:'<path d="M13 7a5 5 0 1 0-1 4M13 3v4H9"/>',expand:'<path d="M6 3H3v3m7-3h3v3M3 10v3h3m7-3v3h-3"/>',close:'<path d="m4 4 8 8M12 4l-8 8"/>',arrow:'<path d="M8 13V3M4 7l4-4 4 4"/>'},ut=n=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ds[n]}</svg>`,Gi=`
82
80
  <style>
83
81
  :host{all:initial;position:fixed;right:64px;bottom:20px;z-index:2147483000;font:13px/1.6 var(--guanloop-font,-apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif);color:#343a3f;--accent:#1a827f;--muted:#76838d;--line:#e5e9ee;--surface:#f5f7fa}
84
82
  :host([hidden]),[hidden]{display:none!important}*{box-sizing:border-box}button,input,textarea,select{font:inherit;color:inherit}button{cursor:pointer;border:1px solid var(--line);background:#fff;border-radius:6px;padding:4px 9px;line-height:1.4;display:inline-flex;align-items:center;justify-content:center;gap:4px}button:hover{background:var(--surface);border-color:#c9d4dc}button:disabled{opacity:.4;cursor:default}button:focus-visible,select:focus-visible,textarea:focus-visible{outline:2px solid #1a827f80;outline-offset:2px}.icon-button{width:28px;height:28px;padding:5px;border-color:transparent;background:transparent;flex:none}.primary,#launcher{background:var(--accent);color:#fff;border-color:var(--accent)}.primary:hover,#launcher:hover{background:#146d6a;border-color:#146d6a}
@@ -86,7 +84,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
86
84
  #panel{position:fixed;display:flex;flex-direction:column;isolation:isolate;background:#fff;border:1px solid #d4dde3;border-radius:10px;box-shadow:0 12px 48px #253d4926;overflow:hidden;min-width:0;min-height:0}#panel[data-interacting=true]{user-select:none}#drag-handle{height:38px;flex:none;display:flex;align-items:center;padding:0 10px 0 14px;gap:7px;cursor:grab;touch-action:none;border-bottom:1px solid var(--line);background:#fff}#drag-handle:active{cursor:grabbing}#drag-handle strong{font-size:13px;font-weight:650;letter-spacing:.1px}.grip{display:flex;gap:2px;padding:2px;margin-right:1px;color:#a6b3bc}.grip:before,.grip:after{content:"";width:2px;height:12px;background:radial-gradient(circle,currentColor 1px,transparent 1px) 0 0/2px 4px}.header-spacer{flex:1}#layout-mode{max-width:80px;border:0;background:transparent;font-size:11px;padding:4px 2px;color:#657581;cursor:pointer}#expand[aria-pressed=true]{background:#e7f3f1;color:var(--accent)}
87
85
  #identity{height:27px;flex:none;display:flex;align-items:center;gap:10px;padding:0 14px;background:#fafbfc;font-size:11px;white-space:nowrap;border-bottom:1px solid var(--line);color:#667781}#environment{flex:1;min-width:40px;overflow:hidden;text-overflow:ellipsis}#account{max-width:38%;overflow:hidden;text-overflow:ellipsis;color:#52636e}#backend{display:flex;align-items:center;gap:5px;flex:none;font-size:10px}#backend-dot{width:6px;height:6px;border-radius:50%;background:#98a5ad}#backend-dot[data-connected=true]{background:#21a565;box-shadow:0 0 0 2px #e2f5e9}#backend-dot[data-connected=false]{background:#d94c47}#setup{padding:8px 14px;background:#fff9ee;border-bottom:1px solid #f0e4ca;display:flex;align-items:center;gap:8px}small{font-size:11px;color:var(--muted)}
88
86
  #toolbar{height:36px;flex:none;display:flex;align-items:center;gap:4px;padding:3px 10px 3px 12px;border-bottom:1px solid var(--line)}#conversations{flex:1;min-width:0;border:0;background:transparent;padding:3px 22px 3px 0;font-size:12px;cursor:pointer;white-space:nowrap;text-overflow:ellipsis}#new{font-size:11px;border-color:transparent;white-space:nowrap;height:28px;padding:0 5px}#refresh{margin-left:2px}
89
- #messages{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#c8d3db transparent;padding:5px 18px 10px;scroll-padding:12px}#messages:empty:before{content:"\u4ECE\u5F53\u524D\u4EFB\u52A1\u5F00\u59CBA\u67E5\u770B\u8282\u70B9\u3001\u7406\u89E3 SQL\uFF0C\u6216\u68B3\u7406\u6570\u636E\u8840\u7F18\u3002";white-space:pre-line;display:block;padding:36px 8px;color:#85939d;font-size:12px;line-height:2;text-align:center}article{margin:10px 0 16px;min-width:0}article>b{display:block;font-size:10px;line-height:1.5;font-weight:600;color:var(--accent);margin:0 0 5px;letter-spacing:.2px}article[data-role=userMessage]{margin-left:36px;background:var(--surface);border:1px solid #edf0f4;padding:8px 11px;border-radius:8px 8px 2px 8px}article[data-role=userMessage]>b{display:none}article[data-role=userMessage] pre{font-family:inherit;font-size:12px;line-height:1.65;margin:0}pre{font:12px/1.65 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}article[data-role=commandExecution]{margin:5px 0;border:1px solid var(--line);border-radius:5px;background:#fafbfc;font-size:11px}article[data-role=commandExecution]>b{display:none}details{min-width:0}summary{padding:5px 8px;color:#788792;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font:11px/1.5 ui-monospace,monospace}details[open] summary{white-space:normal;overflow-wrap:anywhere;border-bottom:1px solid var(--line)}details pre{padding:8px;max-height:240px;overflow:auto;font-size:11px}
87
+ #messages{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#c8d3db transparent;padding:5px 18px 10px;scroll-padding:12px}#messages:empty:before{content:"从当前任务开始A查看节点、理解 SQL,或梳理数据血缘。";white-space:pre-line;display:block;padding:36px 8px;color:#85939d;font-size:12px;line-height:2;text-align:center}article{margin:10px 0 16px;min-width:0}article>b{display:block;font-size:10px;line-height:1.5;font-weight:600;color:var(--accent);margin:0 0 5px;letter-spacing:.2px}article[data-role=userMessage]{margin-left:36px;background:var(--surface);border:1px solid #edf0f4;padding:8px 11px;border-radius:8px 8px 2px 8px}article[data-role=userMessage]>b{display:none}article[data-role=userMessage] pre{font-family:inherit;font-size:12px;line-height:1.65;margin:0}pre{font:12px/1.65 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere;margin:0}article[data-role=commandExecution]{margin:5px 0;border:1px solid var(--line);border-radius:5px;background:#fafbfc;font-size:11px}article[data-role=commandExecution]>b{display:none}details{min-width:0}summary{padding:5px 8px;color:#788792;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font:11px/1.5 ui-monospace,monospace}details[open] summary{white-space:normal;overflow-wrap:anywhere;border-bottom:1px solid var(--line)}details pre{padding:8px;max-height:240px;overflow:auto;font-size:11px}
90
88
  .markdown{font-size:13px;line-height:1.75;overflow-wrap:anywhere}.markdown>:first-child{margin-top:0}.markdown>:last-child{margin-bottom:0}.markdown p,.markdown ul,.markdown ol,.markdown blockquote{margin:8px 0}.markdown h1,.markdown h2,.markdown h3,.markdown h4{font-size:14px;line-height:1.55;margin:16px 0 7px;color:#253640}.markdown ul,.markdown ol{padding-left:20px}.markdown li+li{margin-top:3px}.markdown code{font:11px/1.65 ui-monospace,SFMono-Regular,Menlo,monospace;background:#eef2f5;padding:1px 4px;border-radius:3px}.markdown pre{white-space:pre;overflow-x:auto;overflow-wrap:normal;padding:11px 12px;margin:0;background:#182831;color:#e7f1f4;border-radius:0 0 6px 6px;scrollbar-width:thin;scrollbar-color:#637a87 #182831}.markdown pre code{padding:0;background:none;color:inherit}.table-scroll{overflow-x:auto;margin:10px 0;border:1px solid #dce4e9;border-radius:5px}.markdown table{border-collapse:collapse;min-width:100%;font-size:11px;line-height:1.65}.markdown th,.markdown td{border-right:1px solid #e2e8ed;border-bottom:1px solid #e2e8ed;padding:6px 8px;text-align:left;min-width:84px;vertical-align:top}.markdown tr>:last-child{border-right:0}.markdown tbody tr:last-child td{border-bottom:0}.markdown th{background:#f1f5f7;font-weight:600;white-space:nowrap}.markdown tbody tr:nth-child(even){background:#fafcfd}.markdown td code{font-size:10px}.markdown blockquote{border-left:2px solid #a7c9c4;padding-left:10px;color:#687d85}.code-block{margin:10px 0}.code-header{display:flex;align-items:center;justify-content:space-between;height:27px;padding:3px 8px 3px 11px;background:#e9eff2;border-radius:6px 6px 0 0;font-size:10px;color:#637982;letter-spacing:.6px}.code-header button{padding:1px 7px;font-size:10px;border-color:transparent;background:transparent;color:#556f79;letter-spacing:0}.markdown a{color:var(--accent);text-underline-offset:2px}.markdown hr{border:0;border-top:1px solid var(--line);margin:14px 0}
91
89
  #activity{flex:none;min-height:23px;display:flex;align-items:flex-start;gap:6px;padding:3px 14px;border-top:1px solid var(--line);background:#fcfdfd}#activity-mark{flex:none;width:4px;height:4px;margin-top:6px;border-radius:50%;background:#98adae}#activity[data-busy=true] #activity-mark{background:var(--accent);box-shadow:0 0 0 3px #e6f4f2}#status{font-size:10px;line-height:17px;color:#768991;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}#status[data-error=true]{color:#b44139;white-space:pre-wrap;overflow-wrap:anywhere;max-height:85px;overflow:auto}
92
90
  #compose{flex:none;padding:8px 11px 8px;border-top:1px solid var(--line);background:#fff}#composer-box{border:1px solid #d8e2e8;border-radius:7px;transition:border-color .1s}#composer-box:focus-within{border-color:#78b8af;box-shadow:0 0 0 2px #1a827f0b}textarea{display:block;width:100%;border:0;background:transparent;resize:none;min-height:36px;max-height:126px;padding:8px 10px 3px;line-height:1.55;font-size:12px;border-radius:7px;outline:0!important}textarea::placeholder{color:#98a5af}textarea:disabled{opacity:.65}#actions{display:flex;align-items:center;justify-content:flex-end;gap:5px;padding:2px 6px 5px;min-height:30px}#hint{font-size:10px;color:#9aa7b1;margin-right:auto;padding-left:4px}#send{height:25px;padding:2px 8px;font-size:11px;border-radius:5px}#stop{height:25px;padding:2px 7px;font-size:11px;border-color:transparent;background:transparent;color:#b7524b}#panel:not([data-busy=true]) #stop{display:none}
@@ -100,61 +98,93 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
100
98
  @container(max-width:700px){#files-pane[data-file-layout=split][data-has-selection=true] #file-surface{grid-template-columns:1fr}#files-pane[data-file-layout=split][data-has-selection=true] #file-list-shell{display:none}#file-preview{border-left:0}.file-columns,.file-row{grid-template-columns:minmax(70px,1fr) 60px 88px}.file-modified,.file-columns>span:nth-child(3){display:none}}
101
99
  @container(min-width:701px){#files-pane[data-file-layout=split][data-has-selection=true] .file-columns,#files-pane[data-file-layout=split][data-has-selection=true] .file-row{grid-template-columns:minmax(70px,1fr) 55px 88px}#files-pane[data-file-layout=split][data-has-selection=true] .file-modified,#files-pane[data-file-layout=split][data-has-selection=true] .file-columns>span:nth-child(3){display:none}}
102
100
  #setup{display:block;flex:none}.access-row{display:flex;gap:8px;align-items:center}.access-row small{font-size:11px;line-height:1.6}#connect{white-space:nowrap}#access-help{font-size:11px;margin-top:8px;line-height:1.7}#access-help summary{font:inherit;white-space:normal;padding:0;color:var(--accent)}#access-help ol{padding-left:20px;margin:6px 0}#access-help small{font-size:10px}
103
- ${Qi}
101
+ #exec-connection{margin-top:16px;padding-top:16px;border-top:1px solid var(--line);display:flex;flex-direction:column;gap:8px}#exec-connection strong{font-size:13px}#exec-show{align-self:flex-start}#exec-details{display:flex;flex-direction:column;gap:7px}#exec-details input{font:11px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;background:#fdf6e3;color:#586e75}#exec-actions{display:flex;gap:6px;flex-wrap:wrap}#exec-actions button{font-size:11px}#exec-status{font-size:11px;color:var(--accent);overflow-wrap:anywhere}
102
+ #exec-token-row{display:flex;align-items:center;gap:6px}#exec-token-row input{flex:1;min-width:0;width:0}#exec-token-row button{flex:none;font-size:11px;white-space:nowrap}
103
+ ${ji}
104
104
  @media(prefers-reduced-motion:reduce){*{transition:none!important}}
105
105
  </style>
106
- <button id="launcher" aria-label="\u6253\u5F00\u89C2\u8FDC Copilot"><span class="launch-mark" aria-hidden="true">\u203A_</span>Copilot</button>
107
- <section id="panel" role="dialog" aria-label="\u89C2\u8FDC Copilot" aria-modal="false" hidden>
108
- <header id="drag-handle" title="\u62D6\u52A8\u79FB\u52A8\u7A97\u53E3\uFF1B\u53CC\u51FB\u5C55\u5F00\u6216\u8FD8\u539F"><span class="grip" aria-hidden="true"></span><strong>\u89C2\u8FDC Copilot</strong><span class="header-spacer"></span><button id="settings-button" class="icon-button" aria-label="\u8FDE\u63A5\u8BBE\u7F6E" title="\u8FDE\u63A5\u8BBE\u7F6E">${nt("settings")}</button><select id="layout-mode" aria-label="\u7A97\u53E3\u5E03\u5C40"><option value="compact">\u6D6E\u7A97</option><option value="wide">\u9605\u8BFB</option><option value="full">\u5C55\u5F00</option></select><button id="expand" class="icon-button" aria-label="\u5C55\u5F00\u7A97\u53E3" title="\u5C55\u5F00\u7A97\u53E3">${nt("expand")}</button><button id="close" class="icon-button" aria-label="\u6536\u8D77\u7A97\u53E3" title="\u6536\u8D77\u7A97\u53E3">${nt("close")}</button></header>
109
- <div id="identity"><span id="environment"></span><span id="account"></span><span id="backend" role="status"><span id="backend-dot"></span><span id="backend-label">guanloop \xB7 \u8FDE\u63A5\u4E2D</span></span></div>
110
- <div id="setup"><div class="access-row"><button id="connect">\u8FDE\u63A5\u672C\u673A\u52A9\u624B</button><small id="setup-hint">\u9996\u6B21\u8FDE\u63A5\u65F6\uFF0C\u8BF7\u5728\u6D4F\u89C8\u5668\u5F39\u7A97\u4E2D\u9009\u62E9\u300C\u5141\u8BB8\u300D\u3002</small></div><details id="access-help" hidden><summary>\u6062\u590D\u672C\u673A\u8BBF\u95EE\u6388\u6743\uFF08Chrome\uFF09</summary><ol><li>\u70B9\u51FB\u5730\u5740\u680F\u5DE6\u4FA7\u7684\u7F51\u7AD9\u8BBE\u7F6E\u56FE\u6807\uFF0C\u6253\u5F00\u300C\u7F51\u7AD9\u8BBE\u7F6E\u300D\u3002</li><li>\u5C06\u300C\u672C\u673A\u4E0A\u7684\u5E94\u7528 / \u672C\u5730\u7F51\u7EDC\u8BBF\u95EE\u300D\u6539\u4E3A\u300C\u5141\u8BB8\u300D\u3002</li><li>\u56DE\u5230\u5F53\u524D BI \u9875\u9762\uFF0C\u70B9\u51FB\u300C\u68C0\u67E5\u6388\u6743\u5E76\u91CD\u8FDE\u300D\uFF1B\u4ECD\u672A\u751F\u6548\u65F6\u5237\u65B0\u9875\u9762\u3002</li></ol><small>\u6743\u9650\u5DF2\u88AB\u62D2\u7EDD\u65F6\uFF0C\u7F51\u9875\u65E0\u6CD5\u4EE3\u66FF\u4F60\u6062\u590D\u6388\u6743\uFF1B\u4F01\u4E1A\u7B56\u7565\u6216\u5D4C\u5165\u9875\u9762\u4E5F\u53EF\u80FD\u9650\u5236\u6B64\u6743\u9650\u3002</small></details></div>
111
- <nav id="workspace-tabs" aria-label="\u5DE5\u4F5C\u533A"><button type="button" data-pane="chat" aria-selected="true">\u5BF9\u8BDD</button><button type="button" data-pane="files" aria-selected="false">\u6587\u4EF6</button><button type="button" data-pane="terminal" aria-selected="false">\u7EC8\u7AEF</button><span id="workspace-label">\u5F53\u524D BI \u8D26\u53F7\u7684\u5171\u4EAB\u5DE5\u4F5C\u533A</span></nav>
112
- <div id="toolbar"><button id="history-button" title="\u6309\u73AF\u5883\u548C\u8D26\u53F7\u7BA1\u7406\u5386\u53F2">\u5386\u53F2</button><span id="conversation-title">\u65B0\u5BF9\u8BDD</span><select id="model" aria-label="\u5BF9\u8BDD\u6A21\u578B" title="\u5BF9\u8BDD\u6A21\u578B"><option value="">\u8BFB\u53D6\u6A21\u578B\u4E2D\u2026</option></select><select id="effort" aria-label="\u601D\u8003\u5F3A\u5EA6" title="\u601D\u8003\u5F3A\u5EA6"><option value="">\u81EA\u52A8</option></select><button id="new" title="\u65B0\u5BF9\u8BDD">${nt("plus")}\u65B0\u5BF9\u8BDD</button><button id="refresh" class="icon-button" aria-label="\u5237\u65B0\u5386\u53F2" title="\u5237\u65B0\u5386\u53F2">${nt("refresh")}</button></div>
113
- <div id="messages" role="log" aria-label="\u5BF9\u8BDD\u5185\u5BB9"></div>
106
+ <button id="launcher" aria-label="打开观远 Copilot"><span class="launch-mark" aria-hidden="true">›_</span>Copilot</button>
107
+ <section id="panel" role="dialog" aria-label="观远 Copilot" aria-modal="false" hidden>
108
+ <header id="drag-handle" title="拖动移动窗口;双击展开或还原"><span class="grip" aria-hidden="true"></span><strong>观远 Copilot</strong><span class="header-spacer"></span><button id="settings-button" class="icon-button" aria-label="连接设置" title="连接设置">${ut("settings")}</button><select id="layout-mode" aria-label="窗口布局"><option value="compact">浮窗</option><option value="wide">阅读</option><option value="full">展开</option></select><button id="expand" class="icon-button" aria-label="展开窗口" title="展开窗口">${ut("expand")}</button><button id="close" class="icon-button" aria-label="收起窗口" title="收起窗口">${ut("close")}</button></header>
109
+ <div id="identity"><span id="environment"></span><span id="account"></span><span id="backend" role="status"><span id="backend-dot"></span><span id="backend-label">guanloop · 连接中</span></span></div>
110
+ <div id="setup"><div class="access-row"><button id="connect">连接本机助手</button><small id="setup-hint">首次连接时,请在浏览器弹窗中选择「允许」。</small></div><details id="access-help" hidden><summary>恢复本机访问授权(Chrome)</summary><ol><li>点击地址栏左侧的网站设置图标,打开「网站设置」。</li><li>将「本机上的应用 / 本地网络访问」改为「允许」。</li><li>回到当前 BI 页面,点击「检查授权并重连」;仍未生效时刷新页面。</li></ol><small>权限已被拒绝时,网页无法代替你恢复授权;企业策略或嵌入页面也可能限制此权限。</small></details></div>
111
+ <nav id="workspace-tabs" aria-label="工作区"><button type="button" data-pane="chat" aria-selected="true">对话</button><button type="button" data-pane="files" aria-selected="false">文件</button><button type="button" data-pane="terminal" aria-selected="false">终端</button><span id="workspace-label">当前 BI 账号的共享工作区</span></nav>
112
+ <div id="toolbar"><button id="history-button" title="按环境和账号管理历史">历史</button><span id="conversation-title">新对话</span><select id="model" aria-label="对话模型" title="对话模型"><option value="">读取模型中…</option></select><select id="effort" aria-label="思考强度" title="思考强度"><option value="">自动</option></select><button id="new" title="新对话">${ut("plus")}新对话</button><button id="refresh" class="icon-button" aria-label="刷新历史" title="刷新历史">${ut("refresh")}</button></div>
113
+ <div id="messages" role="log" aria-label="对话内容"></div>
114
114
  <div id="activity" role="status"><span id="activity-mark"></span><span id="status"></span></div>
115
- <form id="compose"><div id="composer-box"><textarea id="prompt" rows="1" aria-label="\u6D88\u606F" placeholder="\u8BE2\u95EE\u5F53\u524D\u4EFB\u52A1\u3001\u8282\u70B9\u6216 SQL\u2026" disabled></textarea><div id="actions"><span id="hint">Enter \u53D1\u9001 \xB7 Shift+Enter \u6362\u884C</span><button id="stop" type="button" disabled>\u25A0 \u505C\u6B62</button><button id="send" class="primary" disabled>\u53D1\u9001 ${nt("arrow")}</button></div></div></form>
116
- <section id="files-pane" class="workspace-pane" aria-label="\u5DE5\u4F5C\u533A\u6587\u4EF6" data-file-layout="split" data-has-selection="false" hidden>
117
- <div class="file-heading"><strong>\u5DE5\u4F5C\u533A\u6587\u4EF6</strong><span id="file-workspace"></span><span id="file-count">0 \u9879</span></div>
118
- <div class="workspace-tools file-path-tools"><select id="file-scope" aria-label="\u6587\u4EF6\u7A7A\u95F4"><option value="">\u5171\u4EAB\u5DE5\u4F5C\u533A</option></select><button type="button" id="file-parent" title="\u4E0A\u4E00\u7EA7\u76EE\u5F55">\u4E0A\u7EA7</button><input id="file-path" aria-label="\u865A\u62DF\u76EE\u5F55" value="/"><button type="button" id="file-refresh">\u5237\u65B0</button><label class="upload-button">\u4E0A\u4F20<input type="file" id="file-upload" multiple></label></div>
119
- <div class="file-filter-tools"><input id="file-search" type="search" aria-label="\u7B5B\u9009\u6587\u4EF6" placeholder="\u7B5B\u9009\u5F53\u524D\u76EE\u5F55\u2026"><select id="file-sort" aria-label="\u6587\u4EF6\u6392\u5E8F"><option value="name">\u540D\u79F0</option><option value="modified">\u6700\u8FD1\u4FEE\u6539</option></select><select id="file-layout" aria-label="\u6587\u4EF6\u5E03\u5C40"><option value="split">\u5206\u680F</option><option value="list">\u5217\u8868</option><option value="focus">\u4E13\u6CE8\u9884\u89C8</option></select></div>
120
- <div id="file-readonly" hidden>\u65E7\u5BF9\u8BDD\u5DE5\u4F5C\u533A\u4EC5\u4F9B\u8BFB\u53D6\u548C\u4E0B\u8F7D</div><div id="file-error" role="status"></div><div id="file-notice" role="status"></div>
121
- <div id="file-surface"><div id="file-list-shell"><div class="file-columns"><span>\u540D\u79F0</span><span>\u5927\u5C0F</span><span>\u4FEE\u6539\u65F6\u95F4</span><span>\u64CD\u4F5C</span></div><div id="file-list"></div></div>
122
- <section id="file-preview" aria-label="\u6587\u4EF6\u9884\u89C8" hidden><header><div><strong id="file-preview-name"></strong><small id="file-preview-meta"></small></div><button type="button" id="file-preview-close">\u5173\u95ED\u9884\u89C8</button></header><div id="file-preview-path"></div><div class="file-preview-actions"><button type="button" id="file-preview-download">\u4E0B\u8F7D\u6587\u4EF6</button><button type="button" id="file-preview-delete" class="file-remove">\u5220\u9664\u6587\u4EF6</button></div><div id="file-preview-note"></div><pre id="file-preview-content"></pre></section>
115
+ <form id="compose"><div id="composer-box"><textarea id="prompt" rows="1" aria-label="消息" placeholder="询问当前任务、节点或 SQL…" disabled></textarea><div id="actions"><span id="hint">Enter 发送 · Shift+Enter 换行</span><button id="stop" type="button" disabled>■ 停止</button><button id="send" class="primary" disabled>发送 ${ut("arrow")}</button></div></div></form>
116
+ <section id="files-pane" class="workspace-pane" aria-label="工作区文件" data-file-layout="split" data-has-selection="false" hidden>
117
+ <div class="file-heading"><strong>工作区文件</strong><span id="file-workspace"></span><span id="file-count">0 项</span></div>
118
+ <div class="workspace-tools file-path-tools"><select id="file-scope" aria-label="文件空间"><option value="">共享工作区</option></select><button type="button" id="file-parent" title="上一级目录">上级</button><input id="file-path" aria-label="虚拟目录" value="/"><button type="button" id="file-refresh">刷新</button><label class="upload-button">上传<input type="file" id="file-upload" multiple></label></div>
119
+ <div class="file-filter-tools"><input id="file-search" type="search" aria-label="筛选文件" placeholder="筛选当前目录…"><select id="file-sort" aria-label="文件排序"><option value="name">名称</option><option value="modified">最近修改</option></select><select id="file-layout" aria-label="文件布局"><option value="split">分栏</option><option value="list">列表</option><option value="focus">专注预览</option></select></div>
120
+ <div id="file-readonly" hidden>旧对话工作区仅供读取和下载</div><div id="file-error" role="status"></div><div id="file-notice" role="status"></div>
121
+ <div id="file-surface"><div id="file-list-shell"><div class="file-columns"><span>名称</span><span>大小</span><span>修改时间</span><span>操作</span></div><div id="file-list"></div></div>
122
+ <section id="file-preview" aria-label="文件预览" hidden><header><div><strong id="file-preview-name"></strong><small id="file-preview-meta"></small></div><button type="button" id="file-preview-close">关闭预览</button></header><div id="file-preview-path"></div><div class="file-preview-actions"><button type="button" id="file-preview-download">下载文件</button><button type="button" id="file-preview-delete" class="file-remove">删除文件</button></div><div id="file-preview-note"></div><pre id="file-preview-content"></pre></section>
123
123
  </div>
124
- <footer id="file-help">\u540C\u4E00 BI URL \xB7 domID \xB7 \u8D26\u53F7\u5171\u4EAB\u6587\u4EF6 \xB7 \u4E0A\u4F20/\u4E0B\u8F7D\u4E0A\u9650 32 MiB</footer>
125
- <div id="file-confirm" hidden><div role="alertdialog" aria-modal="true" aria-labelledby="file-confirm-title" aria-describedby="file-confirm-hint"><strong id="file-confirm-title">\u786E\u8BA4\u5220\u9664</strong><b id="file-confirm-name"></b><small id="file-confirm-path"></small><p id="file-confirm-hint"></p><div><button type="button" id="file-delete-cancel">\u53D6\u6D88</button><button type="button" id="file-delete-confirm">\u786E\u8BA4\u5220\u9664</button></div></div></div>
124
+ <footer id="file-help">同一 BI URL · domID · 账号共享文件 · 上传/下载上限 32 MiB</footer>
125
+ <div id="file-confirm" hidden><div role="alertdialog" aria-modal="true" aria-labelledby="file-confirm-title" aria-describedby="file-confirm-hint"><strong id="file-confirm-title">确认删除</strong><b id="file-confirm-name"></b><small id="file-confirm-path"></small><p id="file-confirm-hint"></p><div><button type="button" id="file-delete-cancel">取消</button><button type="button" id="file-delete-confirm">确认删除</button></div></div></div>
126
126
  </section>
127
- <section id="terminal-pane" class="workspace-pane" aria-label="GuanVM \u7EC8\u7AEF" hidden>
128
- <div class="workspace-tools"><strong>GuanVM /bin/sh</strong><small id="terminal-cwd">/</small><span class="header-spacer"></span><button type="button" id="terminal-reconnect">\u91CD\u8FDE</button><button type="button" id="terminal-clear">\u6E05\u5C4F</button></div>
129
- <small class="terminal-help">\u8FD0\u884C\u5728\u5F53\u524D\u8D26\u53F7\u7684\u5171\u4EAB\u5DE5\u4F5C\u533A \xB7 BI \u51ED\u8BC1\u81EA\u52A8\u6CE8\u5165 \xB7 \u652F\u6301 stdin\uFF1B\u6682\u4E0D\u652F\u6301\u5168\u5C4F PTY \u7A0B\u5E8F</small>
130
- <pre id="terminal-output" role="log" aria-label="\u7EC8\u7AEF\u8F93\u51FA" tabindex="0"></pre>
131
- <div id="terminal-error" role="status"></div><form id="terminal-form"><span id="terminal-prompt">$</span><input id="terminal-input" aria-label="\u7EC8\u7AEF\u547D\u4EE4\u6216\u6807\u51C6\u8F93\u5165" placeholder="\u8F93\u5165\u547D\u4EE4\u2026" autocomplete="off" spellcheck="false"><button type="submit" id="terminal-run">\u6267\u884C</button><button type="button" id="terminal-eof" disabled>EOF</button><button type="button" id="terminal-stop" disabled>\u505C\u6B62</button></form>
127
+ <section id="terminal-pane" class="workspace-pane" aria-label="GuanVM 终端" hidden>
128
+ <div class="workspace-tools"><strong>GuanVM /bin/sh</strong><small id="terminal-cwd">/</small><span class="header-spacer"></span><button type="button" id="terminal-reconnect">重连</button><button type="button" id="terminal-clear">清屏</button></div>
129
+ <small class="terminal-help">运行在当前账号的共享工作区 · BI 凭证自动注入 · 支持 stdin;暂不支持全屏 PTY 程序</small>
130
+ <pre id="terminal-output" role="log" aria-label="终端输出" tabindex="0"></pre>
131
+ <div id="terminal-error" role="status"></div><form id="terminal-form"><span id="terminal-prompt">$</span><input id="terminal-input" aria-label="终端命令或标准输入" placeholder="输入命令…" autocomplete="off" spellcheck="false"><button type="submit" id="terminal-run">执行</button><button type="button" id="terminal-eof" disabled>EOF</button><button type="button" id="terminal-stop" disabled>停止</button></form>
132
132
  </section>
133
- <section id="history-manager" class="sheet" role="dialog" aria-label="\u5BF9\u8BDD\u5386\u53F2\u7BA1\u7406" hidden>
134
- <header class="sheet-header"><div><strong>\u5BF9\u8BDD\u5386\u53F2</strong><small>\u4EC5\u5C55\u793A\u5F53\u524D BI \u73AF\u5883\u3001domID \u4E0E\u5DF2\u9A8C\u8BC1\u8D26\u53F7\u7684\u5BF9\u8BDD</small></div><button id="history-close" class="icon-button" aria-label="\u5173\u95ED\u5386\u53F2">${nt("close")}</button></header>
135
- <div id="history-workspace"><nav id="history-groups" aria-label="BI \u73AF\u5883\u3001domID \u4E0E\u8D26\u53F7"></nav><div id="history-main"><div id="history-filters"><input id="history-search" type="search" placeholder="\u641C\u7D22\u5BF9\u8BDD\u6807\u9898" aria-label="\u641C\u7D22\u5BF9\u8BDD"><label><input id="history-archived" type="checkbox">\u5DF2\u5F52\u6863</label></div><div id="history-context"></div><div id="history-rows"></div><div id="history-error" role="status"></div></div></div>
133
+ <section id="history-manager" class="sheet" role="dialog" aria-label="对话历史管理" hidden>
134
+ <header class="sheet-header"><div><strong>对话历史</strong><small>仅展示当前 BI 环境、domID 与已验证账号的对话</small></div><button id="history-close" class="icon-button" aria-label="关闭历史">${ut("close")}</button></header>
135
+ <div id="history-workspace"><nav id="history-groups" aria-label="BI 环境、domID 与账号"></nav><div id="history-main"><div id="history-filters"><input id="history-search" type="search" placeholder="搜索对话标题" aria-label="搜索对话"><label><input id="history-archived" type="checkbox">已归档</label></div><div id="history-context"></div><div id="history-rows"></div><div id="history-error" role="status"></div></div></div>
136
136
  </section>
137
- <section id="settings" class="sheet" role="dialog" aria-label="\u8FDE\u63A5\u8BBE\u7F6E" hidden>
138
- <header class="sheet-header"><div><strong>\u8FDE\u63A5\u8BBE\u7F6E</strong><small>guanloop \u540E\u53F0\u670D\u52A1</small></div><button id="settings-close" class="icon-button" aria-label="\u5173\u95ED\u8BBE\u7F6E">${nt("close")}</button></header>
139
- <form id="settings-form"><label for="backend-address">\u670D\u52A1\u5730\u5740</label><input id="backend-address" type="url" placeholder="http://127.0.0.1:19090" required autocomplete="off"><small>\u672C\u5730\u5730\u5740\u81EA\u52A8\u8FDE\u63A5\uFF1B\u8FDC\u7A0B\u670D\u52A1\u8BF7\u5148\u7528 --expose \u542F\u52A8\u3002</small>
140
- <div id="pairing-field"><label for="pairing-code">Pairing code <small id="pairing-hint"></small></label><input id="pairing-code" type="password" autocomplete="off" placeholder="\u7C98\u8D34\u670D\u52A1\u542F\u52A8\u65F6\u663E\u793A\u7684\u914D\u5BF9\u7801"><small>\u4EC5\u4FDD\u5B58\u5728\u672C\u9875\u9762\u5185\u5B58\u4E2D\uFF0C\u670D\u52A1\u91CD\u542F\u540E\u9700\u91CD\u65B0\u914D\u5BF9\u3002</small></div>
141
- <small id="transport-hint">HTTPS BI \u9875\u9762\u8FDE\u63A5\u8FDC\u7A0B\u540E\u53F0\u65F6\uFF0C\u8BF7\u4F7F\u7528 HTTPS \u670D\u52A1\u5730\u5740\u3002</small><div id="settings-error" role="status"></div><button class="primary" id="settings-save">\u4FDD\u5B58\u5E76\u8FDE\u63A5</button>
137
+ <section id="settings" class="sheet" role="dialog" aria-label="连接设置" hidden>
138
+ <header class="sheet-header"><div><strong>连接设置</strong><small>guanloop 后台服务</small></div><button id="settings-close" class="icon-button" aria-label="关闭设置">${ut("close")}</button></header>
139
+ <form id="settings-form"><label for="backend-address">服务地址</label><input id="backend-address" type="url" placeholder="http://127.0.0.1:19090" required autocomplete="off"><small>本地地址自动连接;远程服务请先用 --expose 启动。</small>
140
+ <div id="pairing-field"><label for="pairing-code">Pairing code <small id="pairing-hint"></small></label><input id="pairing-code" type="password" autocomplete="off" placeholder="粘贴服务启动时显示的配对码"><small>仅保存在本页面内存中,服务重启后需重新配对。</small></div>
141
+ <small id="transport-hint">HTTPS BI 页面连接远程后台时,请使用 HTTPS 服务地址。</small><div id="settings-error" role="status"></div><button class="primary" id="settings-save">保存并连接</button>
142
+ ${""}
143
+ <section id="exec-connection" aria-label="在其他 Codex 中连接">
144
+ <strong>在其他 Codex 中连接</strong><small>连接当前应用的 GuanVM 工作区,共享文件,并保留本地 Codex 的环境与工具。</small>
145
+ <button type="button" id="exec-show" disabled>显示连接信息</button>
146
+ <div id="exec-details" hidden>
147
+ <label for="exec-url">Exec-server WebSocket</label><input id="exec-url" readonly autocomplete="off" spellcheck="false">
148
+ <label for="exec-workspace">共享工作区</label><input id="exec-workspace" readonly autocomplete="off" spellcheck="false">
149
+ <label for="exec-token">工作区执行凭证</label><div id="exec-token-row"><input id="exec-token" type="password" readonly autocomplete="off" spellcheck="false"><button type="button" id="exec-toggle-token" aria-controls="exec-token" aria-pressed="false">显示凭证</button><button type="button" id="exec-copy-token">复制凭证</button></div>
150
+ <div id="exec-actions"><button type="button" id="exec-copy-instructions" class="primary">复制连接说明</button><button type="button" id="exec-copy-config">复制环境配置</button><button type="button" id="exec-copy-url">复制地址</button><button type="button" id="exec-hide">隐藏</button></div>
151
+ <small>配置含当前账号的工作区执行凭证,请勿提交到 Git。默认本机地址仅同一台电脑可达;请保持后台运行和 BI 登录有效。每个外部 Codex 请分别获取连接信息;后台重启或身份解绑后需重新获取。</small>
152
+ </div><div id="exec-status" role="status" aria-live="polite"></div>
153
+ </section>
142
154
  </form>
143
155
  </section>
144
- ${["n","s","w","e","nw","ne","sw","se"].map(t=>`<span class="resize-handle" data-resize="${t}" aria-hidden="true"></span>`).join("")}
145
- </section>`;function Rt(t,e){let n=Math.min(12,e.width/8,e.height/8),r=Math.max(1,e.width-n*2),i=Math.max(1,e.height-n*2),a=Math.min(r,Math.max(Math.min(360,r),t.width)),s=Math.min(i,Math.max(Math.min(300,i),t.height));return{x:Math.max(n,Math.min(e.width-a-n,t.x)),y:Math.max(n,Math.min(e.height-s-n,t.y)),width:a,height:s}}function Kt(t,e){let n=t==="full"?e.width-24:Math.min(t==="wide"?920:560,e.width-24),r=t==="compact"?Math.min(800,e.height-88):e.height-32;return Rt({width:n,height:r,x:t==="compact"?e.width-n-16:(e.width-n)/2,y:t==="compact"?72:16},e)}function ul(t,e,n,r,i){if(e==="move")return Rt({...t,x:t.x+n,y:t.y+r},i);let a=Math.min(360,i.width-24),s=Math.min(300,i.height-24),o=t.x,c=t.y,u=o+t.width,p=c+t.height;return e.includes("w")&&(o=Math.max(12,Math.min(u-a,o+n))),e.includes("e")&&(u=Math.min(i.width-12,Math.max(o+a,u+n))),e.includes("n")&&(c=Math.max(12,Math.min(p-s,c+r))),e.includes("s")&&(p=Math.min(i.height-12,Math.max(c+s,p+r))),Rt({x:o,y:c,width:u-o,height:p-c},i)}function eo(t,e,n){let r=e.getElementById("panel"),i=e.getElementById("drag-handle"),a=e.getElementById("layout-mode"),s=e.getElementById("expand"),o=()=>({width:t.innerWidth,height:t.innerHeight}),c="guanloop.panel.layout.v1",u="compact",p=Kt(u,o()),f=null,b=null;try{let I=JSON.parse(t.localStorage.getItem(c));I&&["compact","wide","full"].includes(I.mode)&&["x","y","width","height"].every(H=>Number.isFinite(I.rect?.[H]))&&(u=I.mode,p=u==="full"?Kt(u,o()):Rt(I.rect,o()))}catch{}let x=()=>{try{t.localStorage.setItem(c,JSON.stringify({mode:u,rect:p}))}catch{}},T=()=>{Object.assign(r.style,{left:`${p.x}px`,top:`${p.y}px`,width:`${p.width}px`,height:`${p.height}px`}),r.dataset.layout=u,a.value=u,s.setAttribute("aria-label",u==="full"?"\u8FD8\u539F\u7A97\u53E3":"\u5C55\u5F00\u7A97\u53E3"),s.title=u==="full"?"\u8FD8\u539F\u7A97\u53E3":"\u5C55\u5F00\u7A97\u53E3",s.setAttribute("aria-pressed",String(u==="full"))},k=I=>{u!=="full"&&I==="full"&&(f={mode:u,rect:{...p}}),u=I,p=Kt(u,o()),T(),x()},O=()=>{u==="full"?(u=f?.mode||"compact",p=Rt(f?.rect||Kt(u,o()),o()),T(),x()):k("full")};a.addEventListener("change",()=>k(a.value),{signal:n}),s.addEventListener("click",O,{signal:n}),i.addEventListener("dblclick",I=>{I.target.closest("button, select, a")||O()},{signal:n});let E=(I,H)=>{I.button!==0||I.isPrimary===!1||u==="full"||H==="move"&&I.target.closest("button, select, a")||(b={id:I.pointerId,x:I.clientX,y:I.clientY,rect:{...p},direction:H,target:I.currentTarget},b.target.setPointerCapture(I.pointerId),r.dataset.interacting="true",I.preventDefault())};i.addEventListener("pointerdown",I=>E(I,"move"),{signal:n});for(let I of e.querySelectorAll("[data-resize]"))I.addEventListener("pointerdown",H=>E(H,I.dataset.resize),{signal:n});t.addEventListener("pointermove",I=>{!b||I.pointerId!==b.id||(p=ul(b.rect,b.direction,I.clientX-b.x,I.clientY-b.y,o()),u==="wide"&&(u="compact"),T())},{signal:n});let L=I=>{!b||I.pointerId!==b.id||(b.target.hasPointerCapture(b.id)&&b.target.releasePointerCapture(b.id),b=null,delete r.dataset.interacting,x())};t.addEventListener("pointerup",L,{signal:n}),t.addEventListener("pointercancel",L,{signal:n}),t.addEventListener("blur",()=>{b&&L({pointerId:b.id})},{signal:n}),t.addEventListener("resize",()=>{p=u==="full"?Kt(u,o()):Rt(p,o()),T()},{signal:n}),T()}function to(t,e){let n=x=>t.getElementById(x),r=[],i=[],a="",s=0,o=(x,T,k)=>{let O=t.ownerDocument.createElement(x);return T&&(O.textContent=T),k&&(O.className=k),O},c=x=>{n("history-error").textContent=x.message},u=()=>a===e.connection()?.id;function p(){n("history-groups").replaceChildren();for(let E of r){let L=o("button","","history-group");L.type="button",L.dataset.connectionId=E.id,L.setAttribute("aria-current",String(E.id===a)),L.title=`${E.site}
146
- ${E.domId||""}
147
- ${E.display||E.principal}
148
- ${E.principal}`,L.append(o("span",String(E.count),"group-count"),o("strong",new URL(E.site).host+(new URL(E.site).pathname==="/"?"":new URL(E.site).pathname)),o("small",E.display||E.principal)),E.id===e.connection()?.id&&L.append(o("small","\u5F53\u524D\u767B\u5F55\u8D26\u53F7")),L.onclick=()=>f(E.id).catch(c),n("history-groups").append(L)}let x=r.find(E=>E.id===a);n("history-context").textContent=x?`${x.site} \xB7 ${x.domId||""} \xB7 ${x.display||x.principal}${u()?"":" \xB7 \u8BF7\u5728\u6B64\u73AF\u5883\u4EE5\u8BE5\u8D26\u53F7\u767B\u5F55\u540E\u7EE7\u7EED\u5BF9\u8BDD"}`:"";let T=n("history-search").value.trim().toLocaleLowerCase(),k=n("history-archived").checked,O=i.filter(E=>!!E.archived===k&&(E.title||"").toLocaleLowerCase().includes(T));n("history-rows").replaceChildren(),O.length||n("history-rows").append(o("div",T?"\u6CA1\u6709\u5339\u914D\u7684\u5BF9\u8BDD":k?"\u6682\u65E0\u5F52\u6863\u5BF9\u8BDD":"\u6682\u65E0\u5BF9\u8BDD","empty-state"));for(let E of O){let L=o("div","","history-row");L.dataset.id=E.id,L.dataset.selected=String(E.id===e.selected());let I=o("button","","history-open");I.type="button",I.title=E.title||"\u672A\u547D\u540D\u5BF9\u8BDD",I.append(o("strong",E.title||"\u672A\u547D\u540D\u5BF9\u8BDD"),o("small",`${new Date((E.updatedAt||E.createdAt)*1e3).toLocaleString()} \xB7 ${E.model||"\u684C\u9762\u9ED8\u8BA4"} \xB7 ${{idle:"\u672A\u5F00\u59CB",running:"\u6267\u884C\u4E2D",completed:"\u5DF2\u5B8C\u6210",interrupted:"\u5DF2\u505C\u6B62",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4",failed:"\u5931\u8D25"}[E.status]||E.status}`)),I.disabled=!u()||e.busy(),I.onclick=async()=>{try{await e.select(E.id),b()}catch(P){c(P)}};let H=o("div","","history-actions"),U=o("button","\u91CD\u547D\u540D");U.type="button",U.disabled=!u()||e.busy(),U.onclick=()=>{let P=o("input","","history-rename");P.value=E.title,P.maxLength=150,P.setAttribute("aria-label","\u65B0\u7684\u5BF9\u8BDD\u6807\u9898");let G=o("button","\u4FDD\u5B58");G.type="button";let q=o("button","\u53D6\u6D88");q.type="button",q.onclick=p;let N=async()=>{try{G.disabled=!0,await e.client().api(`/api/conversations/${E.id}`,{method:"PUT",body:{title:P.value}}),await e.updated(),await f(a)}catch(R){G.disabled=!1,c(R)}};G.onclick=N,P.onkeydown=R=>{R.key==="Enter"&&!R.isComposing&&(R.preventDefault(),N()),R.key==="Escape"&&p()},L.replaceChildren(P,G,q),P.focus(),P.select()};let A=o("button",E.archived?"\u6062\u590D":"\u5F52\u6863");A.type="button",A.disabled=!u()||e.busy(),A.onclick=async()=>{try{A.disabled=!0,await e.client().api(`/api/conversations/${E.id}`,{method:"PUT",body:{archived:!E.archived}}),await e.updated(),await f(a)}catch(P){c(P),A.disabled=!1}},H.append(U,A),L.append(I,H),n("history-rows").append(L)}}async function f(x){let T=++s,k=e.client();n("history-error").textContent="",n("history-rows").replaceChildren(o("div","\u6B63\u5728\u8BFB\u53D6\u5386\u53F2\u2026","empty-state"));let O=await k.api(`/api/history-groups?connectionId=${encodeURIComponent(e.connection()?.id||"")}`),E=x||e.connection()?.id||O[0]?.id||"",L=E?await k.api(`/api/conversations?connectionId=${encodeURIComponent(E)}`):[];T!==s||k!==e.client()||(r=O.filter(I=>I.id===e.connection()?.id),a=E,i=L,p())}function b(){n("history-manager").hidden=!0,n("history-button").focus()}return n("history-button").onclick=()=>{n("settings").hidden=!0,n("history-manager").hidden=!1,f(e.connection()?.id).catch(c)},n("history-close").onclick=b,n("history-search").oninput=p,n("history-archived").onchange=p,{close:b,reload:()=>f(a),invalidate:()=>{s++,b()}}}function no(t,e){let n=v=>t.getElementById(v),r=t.ownerDocument,i=(v,g,m)=>{let C=r.createElement(v);return g&&(C.textContent=g),m&&(C.className=m),C},a="/",s=0,o=[],c=null,u=null,p=!1,f=!1,b="split",x=()=>n("file-scope").value,T=()=>!!x()||a==="/skills"||a.startsWith("/skills/"),k=(v=a)=>`/api/workspaces/${e.connection()?.id}/files?path=${encodeURIComponent(v)}${x()?"&legacyConversationId="+encodeURIComponent(x()):""}`,O=v=>v<1024?`${v} B`:v<1048576?`${(v/1024).toFixed(1)} KiB`:`${(v/1048576).toFixed(1)} MiB`,E=v=>v?new Date(v).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"\u2014",L=v=>(a==="/"?"":a)+"/"+v;function I(v){v.name!=="AbortError"&&(n("file-error").textContent=v.message)}function H(){n("file-list").inert=p||f,n("file-refresh").disabled=p||f||!e.connection(),n("file-upload").disabled=f||T()||!e.connection(),n("file-scope").disabled=f,n("file-path").disabled=f,n("file-parent").disabled=a==="/"||p||f,n("file-delete-confirm").disabled=f,n("file-delete-cancel").disabled=f,n("file-delete-confirm").textContent=f?"\u6B63\u5728\u5220\u9664\u2026":"\u786E\u8BA4\u5220\u9664",n("files-pane").dataset.fileLayout=b,n("files-pane").dataset.hasSelection=String(!!c)}function U(){let v=x();n("file-scope").replaceChildren(new Option("\u5171\u4EAB\u5DE5\u4F5C\u533A",""));for(let m of e.conversations())m.legacyWorkspace&&n("file-scope").add(new Option(`\u65E7\u6587\u4EF6 \xB7 ${m.title||m.id}`,m.id));[...n("file-scope").options].some(m=>m.value===v)&&(n("file-scope").value=v);let g=e.connection();n("file-workspace").textContent=g?`${new URL(g.site||"http://localhost").host} \xB7 ${g.domId||"\u2014"} \xB7 ${g.display||g.principal||"\u5F53\u524D\u8D26\u53F7"}`:"\u8BF7\u5148\u8FDE\u63A5\u5F53\u524D BI \u8D26\u53F7",n("file-workspace").title=g?.workspaceId||"",n("file-readonly").hidden=!T(),n("file-readonly").textContent=x()?"\u65E7\u5BF9\u8BDD\u5DE5\u4F5C\u533A\u4EC5\u4F9B\u8BFB\u53D6\u548C\u4E0B\u8F7D":"\u5185\u7F6E\u6280\u80FD\u76EE\u5F55\u53EA\u8BFB",H()}function A(){c=null,n("file-preview").hidden=!0,n("file-preview-content").textContent="",n("file-preview-note").textContent="",u=null,n("file-confirm").hidden=!0,H()}function P(){let v=n("file-search").value.trim().toLocaleLowerCase(),g=o.filter(m=>m.name.toLocaleLowerCase().includes(v));g.sort((m,C)=>Number(C.directory)-Number(m.directory)||(n("file-sort").value==="modified"?(C.modifiedAt||0)-(m.modifiedAt||0):m.name.localeCompare(C.name))),n("file-list").replaceChildren(),g.length||n("file-list").append(i("div",v?"\u6CA1\u6709\u5339\u914D\u7684\u6587\u4EF6":"\u76EE\u5F55\u4E3A\u7A7A\u3002\u4E0A\u4F20\u6587\u4EF6\uFF0C\u6216\u8BA9 AI \u5728\u8FD9\u91CC\u751F\u6210\u9884\u5904\u7406\u7ED3\u679C\u3002","empty-state"));for(let m of g){let C=i("div","","file-row");C.dataset.selected=String(c?.name===m.name);let S=i("button","","file-name");S.type="button",S.title=m.name,S.setAttribute("aria-label",`${m.directory?"\u6253\u5F00\u76EE\u5F55":"\u9884\u89C8"} ${m.name}`);let D=i("span",m.directory?"\u76EE\u5F55":m.name.includes(".")?m.name.split(".").pop().slice(0,6).toUpperCase():"\u6587\u4EF6","file-kind");S.append(D,i("span",m.name,"file-label")),S.onclick=()=>{p||f||!o.includes(m)||(m.directory?q(m.path):N(m))};let Y=i("div","","file-row-actions");if(!m.directory){let de=i("button","\u4E0B\u8F7D");de.type="button",de.title=`\u4E0B\u8F7D ${m.name}`,de.onclick=()=>{!o.includes(m)||p||f||R(m.path,m.name).catch(I)},Y.append(de)}let le=i("button","\u5220\u9664","file-remove");le.type="button",le.disabled=T()||f||m.path==="/skills",le.setAttribute("aria-label",`\u5220\u9664 ${m.name}`),le.onclick=()=>F(m),Y.append(le),C.append(S,i("span",m.directory?"\u2014":O(m.size),"file-size"),i("time",E(m.modifiedAt),"file-modified"),Y),n("file-list").append(C)}n("file-count").textContent=`${g.length}${v?" / "+o.length:""} \u9879`,H()}async function G(){if(f)return;let v=++s,g=e.connection(),m=e.client(),C=x();p=!0,o=[],n("file-list").replaceChildren(i("div","\u6B63\u5728\u8BFB\u53D6\u76EE\u5F55\u2026","empty-state")),n("file-error").textContent="",n("file-notice").textContent="",A(),H();try{if(!g)throw Error("\u8BF7\u5148\u8FDE\u63A5\u5F53\u524D BI \u8D26\u53F7");let S=await m.api(k());if(v!==s||g!==e.connection()||m!==e.client()||C!==x())return;a=S.path,o=S.entries.map(D=>({...D,path:L(D.name)})),n("file-path").value=a,U(),P()}catch(S){v===s&&I(S)}finally{v===s&&(p=!1,H())}}function q(v){a=v,G()}async function N(v){if(p||f||!o.includes(v))return;let g=s,m=e.connection(),C=e.client(),S=v.path;c=v,n("file-preview").hidden=!1,n("file-preview-name").textContent=v.name,n("file-preview-path").textContent=S,n("file-preview-meta").textContent=`${O(v.size)} \xB7 ${E(v.modifiedAt)}`,n("file-preview-content").textContent="",n("file-preview-note").textContent="\u6B63\u5728\u8BFB\u53D6\u2026",n("file-preview-download").onclick=()=>R(S,v.name).catch(I),n("file-preview-delete").disabled=T(),n("file-preview-delete").onclick=()=>F(v),P();try{if(v.size>1048576)throw Error("\u6587\u4EF6\u8D85\u8FC7 1 MiB\uFF0C\u8BF7\u4E0B\u8F7D\u67E5\u770B\u3002");let D=await C.api(k(S),{responseType:"blob"}),Y=new Uint8Array(await D.arrayBuffer());if(g!==s||c!==v||m!==e.connection()||C!==e.client())return;if(Y.includes(0))throw Error("\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u8BF7\u4E0B\u8F7D\u67E5\u770B\u3002");n("file-preview-content").textContent=new TextDecoder().decode(Y),n("file-preview-note").textContent=""}catch(D){g===s&&c===v&&(n("file-preview-note").textContent=D.message)}}async function R(v,g){let m=e.client(),C=e.connection(),S=await m.api(k(v),{responseType:"blob"});if(C!==e.connection()||m!==e.client())return;let D=URL.createObjectURL(S),Y=i("a");Y.href=D,Y.download=g,Y.click(),setTimeout(()=>URL.revokeObjectURL(D),1e3)}function F(v){T()||p||f||!o.includes(v)||v.path==="/skills"||(u={entry:v,path:v.path,connection:e.connection(),client:e.client(),scope:x()},n("file-confirm-name").textContent=v.name,n("file-confirm-path").textContent=u.path,n("file-confirm-hint").textContent=v.directory?"\u4EC5\u80FD\u5220\u9664\u7A7A\u76EE\u5F55\u3002\u5220\u9664\u540E\u65E0\u6CD5\u6062\u590D\u3002":"\u6B64\u64CD\u4F5C\u4F1A\u6C38\u4E45\u5220\u9664\u5DE5\u4F5C\u533A\u4E2D\u7684\u6587\u4EF6\uFF0C\u65E0\u6CD5\u6062\u590D\u3002",n("file-confirm").hidden=!1,H(),n("file-delete-cancel").focus())}async function Q(){let v=u;if(!v||f||T())return;let{entry:g,path:m,connection:C,client:S}=v;f=!0,H();try{if(await e.refreshCredential(),v!==u||C!==e.connection()||S!==e.client()||v.scope!==x()||(await S.api(k(m),{method:"DELETE"}),C!==e.connection()||S!==e.client()))return;o=o.filter(D=>D.name!==g.name),A(),P(),n("file-notice").textContent=`\u5DF2\u5220\u9664 ${g.name}`}catch(D){C===e.connection()&&S===e.client()&&(I(D),(!D.status||D.status>=500)&&(n("file-error").textContent+=" \xB7 \u5982\u72B6\u6001\u4E0D\u786E\u5B9A\uFF0C\u8BF7\u5237\u65B0\u5217\u8868\u786E\u8BA4\u3002"))}finally{f=!1,u===v&&(u=null,n("file-confirm").hidden=!0),H(),P()}}function ae(){s++,o=[],a="/",p=!1,f=!1,A(),n("file-list").replaceChildren(),n("file-search").value="",n("file-path").value="/",n("file-error").textContent="",n("file-notice").textContent="",n("file-count").textContent="0 \u9879",U()}return n("file-refresh").onclick=()=>q(n("file-path").value),n("file-path").onkeydown=v=>{v.key==="Enter"&&n("file-refresh").click()},n("file-parent").onclick=()=>q(a.slice(0,a.lastIndexOf("/"))||"/"),n("file-scope").onchange=()=>q("/"),n("file-preview-close").onclick=()=>{A(),P()},n("file-search").oninput=P,n("file-sort").onchange=P,n("file-layout").onchange=()=>{b=n("file-layout").value,H()},n("file-delete-confirm").onclick=()=>{Q()},n("file-delete-cancel").onclick=()=>{u=null,n("file-confirm").hidden=!0},n("file-confirm").onkeydown=v=>{v.key==="Escape"&&!f&&(u=null,n("file-confirm").hidden=!0)},n("file-upload").onchange=async()=>{let v=[...n("file-upload").files],g=s,m=e.connection(),C=e.client(),S=a,D=x();try{if(T())throw Error("\u65E7\u5BF9\u8BDD\u6587\u4EF6\u4EC5\u4F9B\u8BFB\u53D6");await e.refreshCredential();for(let Y of v){if(g!==s||m!==e.connection()||C!==e.client()||x()!==D)return;if(Y.size>33554432)throw Error(`${Y.name} \u8D85\u8FC7 32 MiB`);await C.api(k((S==="/"?"":S)+"/"+Y.name),{method:"PUT",rawBody:Y,responseType:"blob"})}g===s&&await G()}catch(Y){m===e.connection()&&C===e.client()&&I(Y)}finally{n("file-upload").value=""}},{open:G,update:U,reset:ae}}function ro(t,e){let n=N=>t.getElementById(N),r=t.ownerDocument,i="chat",a=0,s=null,o=null,c="",u=0,p=!1,f="/",b=[],x=0,T=(N,R,F)=>{let Q=r.createElement(N);return R&&(Q.textContent=R),F&&(Q.className=F),Q},k=(N,R)=>{let F=e.connection();if(!F)throw Error("\u8BF7\u5148\u8FDE\u63A5\u5F53\u524D BI \u8D26\u53F7");return e.client().api(`/api/workspaces/${F.id}${N}`,R)},O=(N,R)=>{R.name!=="AbortError"&&(n(N).textContent=R.message)};function E(){let N=!!e.connection();n("terminal-input").disabled=!N,n("terminal-run").disabled=!N||p,n("terminal-input").placeholder=c?"\u8F93\u5165\u53D1\u9001\u81F3 stdin\u2026":"\u8F93\u5165\u547D\u4EE4\u2026",n("terminal-run").textContent=c?"\u8F93\u5165":"\u6267\u884C",n("terminal-stop").disabled=!c||p,n("terminal-eof").disabled=!c||p,n("terminal-cwd").textContent=f,n("terminal-prompt").textContent=c?"\u203A":"$"}function L(){q.update(),n("workspace-label").title=e.connection()?.workspaceId||"",E()}function I(N){let R=n("terminal-output"),F=R.scrollHeight-R.scrollTop-R.clientHeight<64;R.textContent=(R.textContent+N.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,"").replace(/\x1b\][^\x07]*(?:\x07|$)/g,"")).slice(-5e5),F&&(R.scrollTop=R.scrollHeight)}async function H(){if(o)return;if(s)return s;let N=a,R=(async()=>{await e.refreshCredential();let F=e.connection(),Q=e.client(),ae=await k("/terminals",{method:"POST"});if(N!==a||F!==e.connection()||Q!==e.client()){Q.api(`/api/workspaces/${F.id}/terminals/${ae.id}`,{method:"DELETE"}).catch(()=>{});return}o=ae.id,f=decodeURIComponent(new URL(ae.shell.cwd).pathname),I(`\u5DF2\u8FDE\u63A5\u5F53\u524D BI \u8D26\u53F7\u7684 GuanVM \u5171\u4EAB\u5DE5\u4F5C\u533A\u3002
149
- `),E()})();s=R;try{return await R}finally{s===R&&(s=null)}}async function U(N,R,F,Q,ae){let v=new Map;for(;N===a&&e.active()&&o===Q&&c===ae;){let g=await R.api(`/api/workspaces/${F.id}/terminals/${Q}`,{method:"POST",body:{action:"read",processId:ae,afterSeq:u}});if(N!==a||o!==Q||F!==e.connection())return;for(let m of g.chunks||[]){let C=v.get(m.stream);C||(C=new TextDecoder,v.set(m.stream,C)),I(C.decode(Uint8Array.from(atob(m.chunk),S=>S.charCodeAt(0)),{stream:!0}))}if(u=g.nextSeq,g.shell?.cwd&&(f=decodeURIComponent(new URL(g.shell.cwd).pathname)),g.finished){for(let m of v.values())I(m.decode());I(`
150
- [exit ${g.exitCode}${g.failure?" \xB7 "+String(g.failure):""}]
151
- `),c="",E();return}}}async function A(N){if(N.preventDefault(),p)return;let R=n("terminal-input").value;if(R.trim()){p=!0,n("terminal-error").textContent="",E();try{if(c){await P(R+`
152
- `,!1),n("terminal-input").value="";return}if(await e.refreshCredential(),await H(),!o)return;let F=e.connection(),Q=e.client(),ae=o,v=crypto.randomUUID();I(`${f} $ ${R}
153
- `),b.push(R),x=b.length,u=0,c=v,n("terminal-input").value="",await k(`/terminals/${ae}`,{method:"POST",body:{action:"start",command:R,processId:v}}),U(a,Q,F,ae,v).catch(g=>{O("terminal-error",g),E()})}catch(F){O("terminal-error",F),c&&(n("terminal-error").textContent+=" \xB7 \u6267\u884C\u72B6\u6001\u9700\u786E\u8BA4\uFF0C\u8BF7\u505C\u6B62\u6216\u91CD\u8FDE\uFF0C\u4E0D\u8981\u91CD\u590D\u6267\u884C\u3002")}finally{p=!1,E()}}}async function P(N,R){let F=new TextEncoder().encode(N);if(F.length>32768)throw Error("\u5355\u6B21\u6807\u51C6\u8F93\u5165\u4E0A\u9650 32 KiB");await k(`/terminals/${o}`,{method:"POST",body:{action:"stdin",processId:c,data:btoa(String.fromCharCode(...F)),closeStdin:R,writeId:crypto.randomUUID()}})}function G(){if(a++,s=null,q.reset(),o&&e.connection()){let N=e.connection(),R=e.client(),F=o;R.api(`/api/workspaces/${N.id}/terminals/${F}`,{method:"DELETE",timeout:1e4}).catch(()=>{})}o=null,c="",u=0,f="/",b=[],x=0,n("terminal-output").textContent="",n("file-list").replaceChildren(),n("file-preview").hidden=!0,n("file-error").textContent="",n("terminal-error").textContent=""}let q=no(t,e);for(let N of t.querySelectorAll("[data-pane]"))N.onclick=()=>{i=N.dataset.pane,n("panel").dataset.pane=i;for(let R of t.querySelectorAll("[data-pane]"))R.setAttribute("aria-selected",String(R.dataset.pane===i));n("files-pane").hidden=i!=="files",n("terminal-pane").hidden=i!=="terminal",n("history-manager").hidden=!0,n("settings").hidden=!0,i==="files"&&q.open(),i==="terminal"&&(E(),H().catch(R=>O("terminal-error",R)))};return n("terminal-form").onsubmit=A,n("terminal-stop").onclick=async()=>{p=!0,E();try{await k(`/terminals/${o}`,{method:"POST",body:{action:"stop",processId:c}})}catch(N){O("terminal-error",N)}finally{p=!1,E()}},n("terminal-eof").onclick=()=>P("",!0).catch(N=>O("terminal-error",N)),n("terminal-clear").onclick=()=>{n("terminal-output").textContent=""},n("terminal-reconnect").onclick=()=>{G(),H().catch(N=>O("terminal-error",N))},n("terminal-input").onkeydown=N=>{(N.ctrlKey||N.metaKey)&&N.key==="c"&&!t.getSelection?.()?.toString()&&c&&(N.preventDefault(),n("terminal-stop").click()),!c&&["ArrowUp","ArrowDown"].includes(N.key)&&(N.preventDefault(),x=Math.max(0,Math.min(b.length,x+(N.key==="ArrowUp"?-1:1))),n("terminal-input").value=b[x]||"")},{update:L,reset:G}}function dl(t,e){let n=t.navigator?.userAgent||"",r=new URL(e);return/Safari\//.test(n)&&!/(?:Chrome|Chromium|Edg|CriOS|FxiOS)\//.test(n)&&t.location.protocol==="https:"&&r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)}function io(t,e,{signal:n,onClosed:r=()=>{}}={}){let i=new URL(e).origin,a=t.fetch.bind(t),s=dl(t,i),o=null,c="",u=null,p,f,b,x=!1,T=null,k=new Map;function O(U){f?.(U);for(let A of k.values())A.cleanup(),A.reject(U);k.clear()}function E(U){if(U.source!==o||U.origin!==i||U.data?.channel!==c)return;let A=U.data;if(A.type==="ready"){clearTimeout(b),p?.();return}let P=k.get(A.id);if(P){if(A.type==="response"){k.delete(A.id),P.cleanup();try{P.resolve(new t.Response([204,205,304].includes(A.status)?null:A.body,{status:A.status,headers:A.headers}))}catch(G){P.reject(G)}}if(A.type==="error"){k.delete(A.id),P.cleanup();let G=new Error(A.message);G.name=A.name||"Error",P.reject(G)}}}t.addEventListener("message",E);function L(){n?.removeEventListener("abort",L),x=!0,clearTimeout(b),clearInterval(T),t.removeEventListener("message",E),O(new Error("\u672C\u673A\u8FDE\u63A5\u5DF2\u5173\u95ED")),o?.close(),o=null}n?.addEventListener("abort",L,{once:!0});function I(){if(s){if(x)throw Error("\u672C\u673A\u8FDE\u63A5\u5DF2\u5173\u95ED");if(!(o&&!o.closed)){if(c=t.crypto.randomUUID(),u=new Promise((U,A)=>{p=U,f=A}),u.catch(()=>{}),o=t.open(i+"/browser-bridge?origin="+encodeURIComponent(t.location.origin)+"&channel="+encodeURIComponent(c),"guanloop-"+c,"popup,width=480,height=320"),!o)throw f(new Error("Safari \u672A\u80FD\u6253\u5F00\u672C\u673A\u8FDE\u63A5\u7A97\u53E3\uFF0C\u8BF7\u5141\u8BB8\u6B64\u7AD9\u70B9\u7684\u5F39\u51FA\u5F0F\u7A97\u53E3\u540E\u91CD\u8BD5")),Error("Safari \u672A\u80FD\u6253\u5F00\u672C\u673A\u8FDE\u63A5\u7A97\u53E3\uFF0C\u8BF7\u5141\u8BB8\u6B64\u7AD9\u70B9\u7684\u5F39\u51FA\u5F0F\u7A97\u53E3\u540E\u91CD\u8BD5");b=setTimeout(()=>{f(new Error("\u672C\u673A\u8FDE\u63A5\u7A97\u53E3\u672A\u5C31\u7EEA\uFF0C\u8BF7\u786E\u8BA4 guancopilot \u5DF2\u66F4\u65B0\u5E76\u542F\u52A8")),o?.close(),o=null,clearInterval(T),r()},15e3),clearInterval(T),T=setInterval(()=>{o?.closed&&(clearInterval(T),clearTimeout(b),O(new Error("\u672C\u673A\u8FDE\u63A5\u7A97\u53E3\u5DF2\u5173\u95ED\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00 Copilot")),o=null,r())},1e3)}}}async function H(U,A={}){if(!s||new URL(U).origin!==i)return a(U,A);if(!o||o.closed)throw Error("\u8BF7\u70B9\u51FB\u8FDE\u63A5\uFF0C\u6253\u5F00 Safari \u672C\u673A\u8FDE\u63A5\u7A97\u53E3");let P=()=>A.signal?.reason||new t.DOMException("\u8BF7\u6C42\u5DF2\u53D6\u6D88","AbortError");if(await new Promise((q,N)=>{let R=()=>{F(),N(P())},F=()=>A.signal?.removeEventListener("abort",R);if(A.signal?.aborted){N(P());return}A.signal?.addEventListener("abort",R,{once:!0}),u.then(()=>{F(),q()},Q=>{F(),N(Q)})}),A.signal?.aborted)throw P();let G=A.body==null?void 0:typeof A.body=="string"?new t.TextEncoder().encode(A.body).buffer:await new t.Blob([A.body]).arrayBuffer();if(A.signal?.aborted)throw P();return new Promise((q,N)=>{let R=t.crypto.randomUUID(),F=()=>A.signal?.removeEventListener("abort",Q),Q=()=>{k.delete(R),F(),o?.postMessage({type:"abort",id:R,channel:c},i),N(P())};k.set(R,{resolve:q,reject:N,cleanup:F}),A.signal?.addEventListener("abort",Q,{once:!0});let ae=new URL(U).pathname+new URL(U).search;try{o.postMessage({type:"request",channel:c,id:R,path:ae,method:A.method||"GET",headers:A.headers,body:G},i)}catch(v){k.delete(R),F(),N(v)}})}return{required:s,open:I,fetch:H,dispose:L}}function oo({navigator:t,address:e,onChange:n=()=>{},signal:r}){let i=new URL(e).hostname,a=["localhost","[::1]"].includes(i)||/^127(?:\.\d{1,3}){3}$/.test(i),s=i.split(".").map(Number),o=i.endsWith(".local")||/^\[(?:fc|fd|fe[89ab])/i.test(i)||s.length===4&&(s[0]===10||s[0]===172&&s[1]>=16&&s[1]<=31||s[0]===192&&s[1]===168||s[0]===169&&s[1]===254),c="unknown",u=null,p=!1,f=null,b=a?["loopback-network","local-network-access"]:["local-network","local-network-access"],x=()=>{p||(c=u.state,n(c))};function T(){p=!0,u?.removeEventListener?.("change",x)}r?.addEventListener("abort",T,{once:!0});async function k(){return p||!a&&!o?c:f||(f=(async()=>{let O=t?.userAgent?.match(/(?:Chrome|Chromium|Edg)\/(\d+)/);if(O&&Number(O[1])<137||!t?.permissions?.query)return c;for(let E of b)try{let L=await t.permissions.query({name:E});return p||(u?.removeEventListener?.("change",x),u=L,u.addEventListener?.("change",x),x()),c}catch{}return c})().finally(()=>{f=null}),f)}return{get state(){return c},check:k,dispose:T}}var hn={none:"None",minimal:"Minimal",low:"Low",medium:"Medium",high:"High"};function gn(t,e){let n=t?.data?.find(i=>i.model===e),r=new Set((n?.supportedReasoningEfforts||[]).map(i=>i.reasoningEffort));return Object.keys(hn).filter(i=>r.has(i))}function ao(t,e,n=""){let r=gn(t,e),i=t?.data?.find(a=>a.model===e);for(let a of[n,e===t?.defaultModel?t.defaultReasoningEffort:"",i?.defaultReasoningEffort,"medium","high","low",...r])if(r.includes(a))return a;return""}function so(){let t="guancopilot-local-root";document.getElementById(t)?.dispatchEvent(new Event("guancopilot-dispose"));let e=document.createElement("div");e.id=t;let n=e.attachShadow({mode:"open"});n.innerHTML=Ji;let r=h=>n.getElementById(h),i=zt;try{i=Dt(localStorage.getItem("guanloop.backend")||zt)}catch{}let a="",s=null,o=!1,c=[],u,p,f="",b=!1,x=!1,T=!1,k=!1,O=0,E=null,L=!1,I=null,H=null,U=!1,A=null,P=!1,G=!1,q=null,N=null,R=null,F=!1,Q=!1,ae=!1,v=new AbortController;e.style.setProperty("--guanloop-font",getComputedStyle(document.body).fontFamily),eo(globalThis,n,v.signal);let g=new Map,m=new Map,C=Vi(globalThis);function S(h,z=!1){r("status").textContent=h,r("status").dataset.error=String(z),r("status").title=h}function D(){r("activity").dataset.busy=String(b||x||T),r("panel").dataset.busy=String(b||x),r("stop").textContent=Q?"\u505C\u6B62\u4E2D\u2026":"\u25A0 \u505C\u6B62",r("prompt").disabled=!p||!U||b||x||T,r("send").disabled=!p||!U||b||x||T,r("stop").disabled=!p||!f||!b||Q,r("history-button").disabled=!p||T||x,r("model").disabled=!p||!o||b||x||T,r("effort").disabled=r("model").disabled||!gn(s,r("model").value).length,r("settings-button").disabled=b||x||T||L,r("send").disabled||=!o,r("new").disabled=!p||b||x||T,r("refresh").disabled=!p||b||x||T}function Y(){let h=globalThis.GD?.getUser?.()||{};r("environment").textContent=`${p?.domId||h.domId||h.domainName||"BI"} \xB7 ${location.host}`,r("account").textContent=p?.display||`${h.loginId||h.name||"\u672A\u767B\u5F55"}\uFF08\u5F85\u9A8C\u8BC1\uFF09`,r("environment").title=`\u73AF\u5883\uFF1A${r("environment").textContent}`,r("account").title=`\u8D26\u53F7\uFF1A${r("account").textContent}`}function le(h){U=h,r("backend-dot").dataset.connected=String(h),r("backend-label").textContent=`guanloop \xB7 ${h?"\u5DF2\u8FDE\u63A5":"\u672A\u8FDE\u63A5"}`,D()}function de(h){k||h.name==="AbortError"||S(h.message,!0)}function ce(){O++,E?.abort(),E=null}function Te(h){ve.reset(),ce(),p=null,c=[],ve.update(),f="",T=!1,g.clear(),m.clear(),r("messages").replaceChildren(),r("conversation-title").textContent="\u8BF7\u91CD\u65B0\u8FDE\u63A5",te.invalidate(),ve?.reset(),r("setup").hidden=!1,b=!1,D(),Y(),S(`\u767B\u5F55\u51ED\u8BC1\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5\uFF1A${h.message}`,!0)}function re(h){let z=Lr(h),W=h.type==="userMessage"?z.replace(/^当前 BI 页面:https?:\/\/[^\s]+\n\n/,""):z;if(!W)return;let V=r("messages"),fe=V.scrollHeight-V.scrollTop-V.clientHeight<64,pe=g.get(h.id);if(!pe){pe=document.createElement("article"),pe.dataset.role=h.type,h.type==="userMessage"&&W!==z&&(pe.title=z.split(`
154
- `,1)[0]);let Fe=document.createElement("b");if(Fe.textContent={userMessage:"\u4F60",agentMessage:"Copilot",commandExecution:"\u547D\u4EE4\u6267\u884C"}[h.type],h.type==="commandExecution"){let Xe=document.createElement("details"),it=document.createElement("summary");it.textContent=h.command||"\u6267\u884C\u8BE6\u60C5",it.title=it.textContent;let It=document.createElement("pre");It.className="message-body",Xe.append(it,It),pe.append(Fe,Xe)}else{let Xe=document.createElement(h.type==="agentMessage"?"div":"pre");Xe.className=h.type==="agentMessage"?"message-body markdown":"message-body",pe.append(Fe,Xe)}g.set(h.id,pe),r("messages").append(pe)}let xe=pe.querySelector(".message-body");h.type==="agentMessage"?C(xe,W):xe.textContent=W,fe&&(V.scrollTop=V.scrollHeight)}function gt(h,z){if(g.has(h))return;let W=`stream-${h}`;m.set(W,(m.get(W)||"")+z),R===null&&(R=setTimeout(()=>{R=null;for(let[V,fe]of m)re({id:V,type:"agentMessage",text:fe})},80))}async function Ne(){let h=await u.api(`/api/conversations?connectionId=${p.id}`);c=h,ve?.update(),r("conversation-title").textContent=h.find(z=>z.id===f)?.title||"\u65B0\u5BF9\u8BDD",r("conversation-title").title=r("conversation-title").textContent}async function Ct(h){let z=await u.api(`/api/conversations/${h}/history`,{signal:E.signal});if(h!==f)return;for(let V of[...z.data||z.turns||[]].reverse())for(let fe of V.items||[])re(fe);let W=(z.data||z.turns||[])[0];return W&&(b=W.status==="inProgress"),z.eventSequence||0}async function Ot(h,z,W=0){for(;!k&&z===O&&!E.signal.aborted;)try{let V=await u.api(`/api/conversations/${h}/events?after=${W}`,{signal:E.signal});if(z!==O)return;for(let fe of V){W=fe.sequence;let{method:pe,params:xe={},id:Fe}=fe.message;Fe!==void 0&&pe&&S(`Codex \u9700\u8981\u4EA4\u4E92\uFF1A${pe}\u3002\u6B64\u7B80\u7248\u6682\u4E0D\u652F\u6301\u8BE5\u4EA4\u4E92\u3002`,!0),pe==="item/agentMessage/delta"&&(S("Copilot \u6B63\u5728\u56DE\u590D\u2026"),gt(xe.itemId,xe.delta)),pe==="item/completed"&&(g.get(`stream-${xe.item.id}`)?.remove(),g.delete(`stream-${xe.item.id}`),m.delete(`stream-${xe.item.id}`),re(xe.item)),pe==="turn/started"&&(b=!0,D()),pe==="turn/completed"&&(b=Q,Q||(F=!1),D(),S(Q?"\u6B63\u5728\u786E\u8BA4\u8FDC\u7A0B\u547D\u4EE4\u5DF2\u505C\u6B62\u2026":xe.turn.status==="completed"?`\u5DF2\u5B8C\u6210 \xB7 ${p.display}`:xe.turn.status==="interrupted"?"\u5DF2\u505C\u6B62\uFF0C\u53EF\u4EE5\u7EE7\u7EED\u5BF9\u8BDD":`\u5BF9\u8BDD\u72B6\u6001\uFF1A${xe.turn.status}`,xe.turn.status==="failed")),pe==="error"&&S(xe.error?.message||"Codex \u6267\u884C\u5931\u8D25",!0)}V.length===0&&await new Promise(fe=>setTimeout(fe,500))}catch(V){if(z!==O||V.name==="AbortError")return;S(`\u4E8B\u4EF6\u8FDE\u63A5\u4E2D\u65AD\uFF1A${V.message}\u3002\u8BF7\u70B9\u51FB\u5237\u65B0\u8BFB\u53D6\u5386\u53F2\u3002`,!0),b=!1,D();return}}async function ze(h){ce();let z=O;T=!0,f=h,g.clear(),m.clear(),r("messages").replaceChildren(),r("conversation-title").textContent=c.find(W=>W.id===h)?.title||"\u65B0\u5BF9\u8BDD",!h&&s&&(r("model").value=s.defaultModel,$()),b=!1,D();try{if(!h||(await Ue(),z!==O))return;E=new AbortController;let W=await u.api(`/api/conversations/${h}`);if(z!==O)return;if(W.connectionId!==p.id)throw new Error("\u6B64\u5BF9\u8BDD\u5C5E\u4E8E\u5176\u4ED6 BI \u73AF\u5883\u6216\u8D26\u53F7");De(W.model||s?.defaultModel||""),$(W.reasoningEffort),b=["running","unknown"].includes(W.status),D();let V=W.status!=="idle"?await Ct(h):0;z===O&&Ot(h,z,V)}finally{z===O&&(T=!1,D())}}async function Ue(){let h=u,z=p;try{await h.refresh()}catch(W){throw u===h&&p===z&&Te(W),W}}function Oe(){let h=q?.state==="denied";r("connect").textContent=N?.required?"\u6253\u5F00\u672C\u673A\u8FDE\u63A5\u7A97\u53E3":h?"\u68C0\u67E5\u6388\u6743\u5E76\u91CD\u8FDE":"\u8FDE\u63A5\u672C\u673A\u52A9\u624B",r("setup-hint").textContent=N?.required?"Safari \u901A\u8FC7\u672C\u673A\u8FDE\u63A5\u7A97\u53E3\u901A\u4FE1\uFF0C\u8BF7\u4FDD\u6301\u8BE5\u7A97\u53E3\u6253\u5F00\u5E76\u8FD4\u56DE BI \u9875\u9762\u3002":h?"Chrome \u5DF2\u963B\u6B62\u672C\u673A\u8BBF\u95EE\u3002\u5C55\u5F00\u4E0B\u65B9\u6307\u5F15\u6062\u590D\u6388\u6743\u540E\uFF0C\u70B9\u51FB\u91CD\u8FDE\u3002":"\u9996\u6B21\u8FDE\u63A5\u65F6\uFF0C\u8BF7\u5728\u6D4F\u89C8\u5668\u5F39\u7A97\u4E2D\u9009\u62E9\u300C\u5141\u8BB8\u300D\u3002\u4EC5\u8FDE\u63A5\u4F60\u914D\u7F6E\u7684 guanloop \u540E\u53F0\u3002",r("access-help").hidden=!h}function rt(){q?.dispose(),G=!1;let h=oo({navigator:globalThis.navigator,address:i,signal:v.signal,onChange:z=>{q!==h||k||(Oe(),z==="denied"&&(G=!1,ce(),le(!1),r("setup").hidden=!1),z==="granted"&&(G=!0,!p&&!L&&ge()))}});q=h,Oe(),h.check()}async function ge(h=!1){if(L)return;if(h&&N?.required)try{N.open()}catch(V){de(V);return}if(!h&&q?.state!=="granted"&&!G){Oe();return}if(q?.state==="denied"){let V=q;if(await V.check(),V!==q||k||L)return;if(V.state==="denied"){Oe(),S("\u6D4F\u89C8\u5668\u5DF2\u62D2\u7EDD\u672C\u673A\u8BBF\u95EE\uFF0C\u8BF7\u6309\u4E0A\u65B9\u6307\u5F15\u6062\u590D\u6388\u6743\u540E\u91CD\u8FDE\u3002",!0);return}}G=!0,ve?.reset();let z=p,W=f;L=!0,r("connect").disabled=!0,ce(),p=null,c=[],ve.update(),o=!1,r("setup").hidden=!1,r("messages").replaceChildren(),g.clear(),m.clear(),Y(),D(),S(N?.required?"\u6B63\u5728\u8FDE\u63A5\u672C\u673A\u7A97\u53E3\u2026\u7A97\u53E3\u5C31\u7EEA\u540E\u8BF7\u8FD4\u56DE BI \u9875\u9762\u3002":"\u6B63\u5728\u8FDE\u63A5\u672C\u673A\u52A9\u624B\u2026\u6D4F\u89C8\u5668\u82E5\u5F39\u51FA\u672C\u673A\u8BBF\u95EE\u6388\u6743\uFF0C\u8BF7\u9009\u62E9\u300C\u5141\u8BB8\u300D\u3002");try{await u.health(),p=await u.connect(),f="",r("setup").hidden=!0,r("messages").replaceChildren(),await Ne(),Y(),S("\u6B63\u5728\u8BFB\u53D6 Codex \u53EF\u7528\u6A21\u578B\u2026"),await Ye(),S(`\u5DF2\u8FDE\u63A5 ${p.display} \xB7 ${p.site}`),W&&z?.principal===p.principal&&z?.site===p.site&&z?.domId===p.domId&&await ze(W),D()}catch(V){if(r("setup").hidden=!1,!V.status&&V.name!=="AbortError"){let fe=q;if(await fe?.check(),fe!==q||k)return;fe?.state!=="granted"&&(G=!1),Oe(),N?.required?S(V.message,!0):fe?.state==="denied"?S("\u6D4F\u89C8\u5668\u5DF2\u62D2\u7EDD\u672C\u673A\u8BBF\u95EE\uFF0C\u8BF7\u6309\u4E0A\u65B9\u6307\u5F15\u6062\u590D\u6388\u6743\u540E\u91CD\u8FDE\u3002",!0):S("\u672A\u80FD\u8FDE\u63A5 guanloop\u3002\u8BF7\u786E\u8BA4\u672C\u673A\u5DF2\u8FD0\u884C guancopilot\uFF1B\u82E5\u6D4F\u89C8\u5668\u663E\u793A\u6388\u6743\u5F39\u7A97\uFF0C\u8BF7\u9009\u62E9\u300C\u5141\u8BB8\u300D\u540E\u91CD\u8BD5\u3002",!0)}else de(V)}finally{L=!1,r("connect").disabled=!1}}function oe(){let h=i,z=a;N?.dispose();let W=io(globalThis,h,{signal:v.signal,onClosed:()=>{N===W&&!k&&(G=!1,le(!1),ce(),r("setup").hidden=!1,S("Safari \u672C\u673A\u8FDE\u63A5\u7A97\u53E3\u5DF2\u5173\u95ED\uFF0C\u8BF7\u70B9\u51FB\u4E0A\u65B9\u6309\u94AE\u91CD\u65B0\u6253\u5F00\u3002",!0))}});return N=W,Mr({fetch:W.fetch,origin:location.origin,baseUrl:h,pairingCode:z,domId:()=>globalThis.GD?.getUser?.()?.domId||"",active:()=>!k&&h===i&&z===a&&st(location.pathname),onLocalStatus:V=>{h===i&&z===a&&le(V)}})}function De(h){h&&![...r("model").options].some(z=>z.value===h)&&r("model").add(new Option(`${h}\uFF08\u5386\u53F2\u6A21\u578B\uFF09`,h)),r("model").value=h}function $(h=""){r("effort").replaceChildren();for(let z of gn(s,r("model").value))r("effort").add(new Option(hn[z],z));r("effort").options.length||r("effort").add(new Option("\u81EA\u52A8","")),r("effort").value=ao(s,r("model").value,h)}async function Ye(){o=!1,D();try{s=await u.api("/api/models",{timeout:4e4}),r("model").replaceChildren();for(let h of s.data)r("model").add(new Option(`${h.displayName||h.model}${h.model===s.defaultModel?" \xB7 \u684C\u9762\u9ED8\u8BA4":""}`,h.model));De(c.find(h=>h.id===f)?.model||s.defaultModel),$(c.find(h=>h.id===f)?.reasoningEffort),r("model").title=`\u9ED8\u8BA4\u6A21\u578B\u914D\u7F6E\uFF1A${s.configSource}
155
- \u684C\u9762\u9ED8\u8BA4\uFF1A${s.defaultModel}${s.defaultReasoningEffort?" \xB7 "+s.defaultReasoningEffort:""}`,o=!0}finally{D()}}async function ie(h){if(h&&$(),!f){D();return}let z=r("model").value,W=r("effort").value;T=!0,D();try{await Ue(),await u.api(`/api/conversations/${f}`,{method:"PUT",body:{model:z,reasoningEffort:W}}),await Ne(),S(`\u5BF9\u8BDD\u8BBE\u7F6E\u5DF2\u66F4\u65B0\uFF1A${z} \xB7 ${hn[W]||"\u81EA\u52A8"}`)}catch(V){De(c.find(fe=>fe.id===f)?.model||s?.defaultModel||""),$(c.find(fe=>fe.id===f)?.reasoningEffort),de(V)}finally{T=!1,D()}}r("model").onchange=()=>ie(!0),r("effort").onchange=()=>ie(!1);let te=to(n,{client:()=>u,connection:()=>p,selected:()=>f,busy:()=>b||x||T,select:ze,updated:async()=>{await Ne(),c.find(z=>z.id===f)?.archived&&await ze("")}}),ve=ro(n,{client:()=>u,connection:()=>p,conversations:()=>c,refreshCredential:Ue,active:()=>!k&&st(location.pathname)});function be(){let h=!1;try{h=en(r("backend-address").value)}catch{}r("pairing-hint").textContent=h?"\uFF08\u8FDC\u7A0B\u5730\u5740\u5FC5\u586B\uFF09":"\uFF08\u4EC5\u670D\u52A1\u542F\u7528 --expose \u65F6\u9700\u8981\uFF09",r("pairing-code").required=h,r("transport-hint").hidden=!h}function qe(){b||x||T||L||(te.close(),r("backend-address").value=i,r("pairing-code").value=a,r("settings-error").textContent="",r("settings").hidden=!1,be())}r("settings-button").onclick=qe,r("backend").onclick=qe,r("settings-close").onclick=()=>{r("settings").hidden=!0,r("settings-button").focus()},r("backend-address").oninput=be,r("settings-form").onsubmit=async h=>{if(h.preventDefault(),!(b||x||T||L))try{let z=Dt(r("backend-address").value),W=r("pairing-code").value.trim();if(en(z)&&!W)throw new Error("\u8FDC\u7A0B\u5730\u5740\u5FC5\u987B\u586B\u5199 pairing code");ce(),te.invalidate(),ve?.reset(),i=z,a=W;try{localStorage.setItem("guanloop.backend",i)}catch{}u=oe(),rt(),p=null,f="",s=null,o=!1,le(!1),A=null,r("setup").hidden=!1,r("messages").replaceChildren(),g.clear(),m.clear(),r("conversation-title").textContent="\u65B0\u5BF9\u8BDD",r("settings-form").setAttribute("aria-busy","true"),await ge(!0),p&&o?r("settings").hidden=!0:r("settings-error").textContent=r("status").textContent}catch(z){r("settings-error").textContent=z.message}finally{r("settings-form").removeAttribute("aria-busy"),D()}},r("connect").addEventListener("click",()=>{ge(!0)});function He(){let h=r("prompt");h.style.height="auto",h.style.height=`${Math.min(126,Math.max(36,h.scrollHeight))}px`}r("prompt").addEventListener("input",He),r("prompt").addEventListener("keydown",h=>{h.key==="Enter"&&!h.shiftKey&&!h.isComposing&&h.keyCode!==229&&(h.preventDefault(),h.stopPropagation(),r("send").disabled||r("compose").requestSubmit())}),r("compose").addEventListener("submit",async h=>{h.preventDefault();let z=r("prompt").value.trim();if(!(!p||!o||b||x||T||!z)){x=!0,F=Q=!1,b=!0,D();try{if(await Ue(),F){b=!1,S("\u5DF2\u505C\u6B62\uFF0C\u6D88\u606F\u5C1A\u672A\u53D1\u9001");return}if(f){let W=c.find(V=>V.id===f);(W?.model!==r("model").value||(W?.reasoningEffort||"")!==r("effort").value)&&(await u.api(`/api/conversations/${f}`,{method:"PUT",body:{model:r("model").value,reasoningEffort:r("effort").value}}),await Ne())}else{let W=await u.api("/api/conversations",{method:"POST",body:{connectionId:p.id,title:z.slice(0,40),model:r("model").value,reasoningEffort:r("effort").value}});await Ne(),await ze(W.id)}if(F){b=!1,S("\u5DF2\u505C\u6B62\uFF0C\u6D88\u606F\u5C1A\u672A\u53D1\u9001");return}b=!0,D(),S("\u5DF2\u63D0\u4EA4\u7ED9\u672C\u5730 Codex\u2026"),ae=!0,await u.api(`/api/conversations/${f}/messages`,{method:"POST",body:{clientMessageId:crypto.randomUUID(),text:`\u5F53\u524D BI \u9875\u9762\uFF1A${location.origin}${location.pathname}
156
+ ${["n","s","w","e","nw","ne","sw","se"].map(n=>`<span class="resize-handle" data-resize="${n}" aria-hidden="true"></span>`).join("")}
157
+ </section>`;function $t(n,e){let t=Math.min(12,e.width/8,e.height/8),i=Math.max(1,e.width-t*2),r=Math.max(1,e.height-t*2),o=Math.min(i,Math.max(Math.min(360,i),n.width)),l=Math.min(r,Math.max(Math.min(300,r),n.height));return{x:Math.max(t,Math.min(e.width-o-t,n.x)),y:Math.max(t,Math.min(e.height-l-t,n.y)),width:o,height:l}}function on(n,e){let t=n==="full"?e.width-24:Math.min(n==="wide"?920:560,e.width-24),i=n==="compact"?Math.min(800,e.height-88):e.height-32;return $t({width:t,height:i,x:n==="compact"?e.width-t-16:(e.width-t)/2,y:n==="compact"?72:16},e)}function us(n,e,t,i,r){if(e==="move")return $t({...n,x:n.x+t,y:n.y+i},r);let o=Math.min(360,r.width-24),l=Math.min(300,r.height-24),a=n.x,d=n.y,p=a+n.width,f=d+n.height;return e.includes("w")&&(a=Math.max(12,Math.min(p-o,a+t))),e.includes("e")&&(p=Math.min(r.width-12,Math.max(a+o,p+t))),e.includes("n")&&(d=Math.max(12,Math.min(f-l,d+i))),e.includes("s")&&(f=Math.min(r.height-12,Math.max(d+l,f+i))),$t({x:a,y:d,width:p-a,height:f-d},r)}function qi(n,e,t){let i=e.getElementById("panel"),r=e.getElementById("drag-handle"),o=e.getElementById("layout-mode"),l=e.getElementById("expand"),a=()=>({width:n.innerWidth,height:n.innerHeight}),d="guanloop.panel.layout.v1",p="compact",f=on(p,a()),c=null,m=null;try{let E=JSON.parse(n.localStorage.getItem(d));E&&["compact","wide","full"].includes(E.mode)&&["x","y","width","height"].every(_=>Number.isFinite(E.rect?.[_]))&&(p=E.mode,f=p==="full"?on(p,a()):$t(E.rect,a()))}catch{}let g=()=>{try{n.localStorage.setItem(d,JSON.stringify({mode:p,rect:f}))}catch{}},v=()=>{Object.assign(i.style,{left:`${f.x}px`,top:`${f.y}px`,width:`${f.width}px`,height:`${f.height}px`}),i.dataset.layout=p,o.value=p,l.setAttribute("aria-label",p==="full"?"还原窗口":"展开窗口"),l.title=p==="full"?"还原窗口":"展开窗口",l.setAttribute("aria-pressed",String(p==="full"))},L=E=>{p!=="full"&&E==="full"&&(c={mode:p,rect:{...f}}),p=E,f=on(p,a()),v(),g()},A=()=>{p==="full"?(p=c?.mode||"compact",f=$t(c?.rect||on(p,a()),a()),v(),g()):L("full")};o.addEventListener("change",()=>L(o.value),{signal:t}),l.addEventListener("click",A,{signal:t}),r.addEventListener("dblclick",E=>{E.target.closest("button, select, a")||A()},{signal:t});let b=(E,_)=>{E.button!==0||E.isPrimary===!1||p==="full"||_==="move"&&E.target.closest("button, select, a")||(m={id:E.pointerId,x:E.clientX,y:E.clientY,rect:{...f},direction:_,target:E.currentTarget},m.target.setPointerCapture(E.pointerId),i.dataset.interacting="true",E.preventDefault())};r.addEventListener("pointerdown",E=>b(E,"move"),{signal:t});for(let E of e.querySelectorAll("[data-resize]"))E.addEventListener("pointerdown",_=>b(_,E.dataset.resize),{signal:t});n.addEventListener("pointermove",E=>{!m||E.pointerId!==m.id||(f=us(m.rect,m.direction,E.clientX-m.x,E.clientY-m.y,a()),p==="wide"&&(p="compact"),v())},{signal:t});let y=E=>{!m||E.pointerId!==m.id||(m.target.hasPointerCapture(m.id)&&m.target.releasePointerCapture(m.id),m=null,delete i.dataset.interacting,g())};n.addEventListener("pointerup",y,{signal:t}),n.addEventListener("pointercancel",y,{signal:t}),n.addEventListener("blur",()=>{m&&y({pointerId:m.id})},{signal:t}),n.addEventListener("resize",()=>{f=p==="full"?on(p,a()):$t(f,a()),v()},{signal:t}),v()}function Wi(n,e){let t=g=>n.getElementById(g),i=[],r=[],o="",l=0,a=(g,v,L)=>{let A=n.ownerDocument.createElement(g);return v&&(A.textContent=v),L&&(A.className=L),A},d=g=>{t("history-error").textContent=g.message},p=()=>o===e.connection()?.id;function f(){t("history-groups").replaceChildren();for(let b of i){let y=a("button","","history-group");y.type="button",y.dataset.connectionId=b.id,y.setAttribute("aria-current",String(b.id===o)),y.title=`${b.site}
158
+ ${b.domId||""}
159
+ ${b.display||b.principal}
160
+ ${b.principal}`,y.append(a("span",String(b.count),"group-count"),a("strong",new URL(b.site).host+(new URL(b.site).pathname==="/"?"":new URL(b.site).pathname)),a("small",b.display||b.principal)),b.id===e.connection()?.id&&y.append(a("small","当前登录账号")),y.onclick=()=>c(b.id).catch(d),t("history-groups").append(y)}let g=i.find(b=>b.id===o);t("history-context").textContent=g?`${g.site} · ${g.domId||""} · ${g.display||g.principal}${p()?"":" · 请在此环境以该账号登录后继续对话"}`:"";let v=t("history-search").value.trim().toLocaleLowerCase(),L=t("history-archived").checked,A=r.filter(b=>!!b.archived===L&&(b.title||"").toLocaleLowerCase().includes(v));t("history-rows").replaceChildren(),A.length||t("history-rows").append(a("div",v?"没有匹配的对话":L?"暂无归档对话":"暂无对话","empty-state"));for(let b of A){let y=a("div","","history-row");y.dataset.id=b.id,y.dataset.selected=String(b.id===e.selected());let E=a("button","","history-open");E.type="button",E.title=b.title||"未命名对话",E.append(a("strong",b.title||"未命名对话"),a("small",`${new Date((b.updatedAt||b.createdAt)*1e3).toLocaleString()} · ${b.model||"桌面默认"} · ${{idle:"未开始",running:"执行中",completed:"已完成",interrupted:"已停止",unknown:"状态待确认",failed:"失败"}[b.status]||b.status}`)),E.disabled=!p()||e.busy(),E.onclick=async()=>{try{await e.select(b.id),m()}catch(O){d(O)}};let _=a("div","","history-actions"),U=a("button","重命名");U.type="button",U.disabled=!p()||e.busy(),U.onclick=()=>{let O=a("input","","history-rename");O.value=b.title,O.maxLength=150,O.setAttribute("aria-label","新的对话标题");let q=a("button","保存");q.type="button";let H=a("button","取消");H.type="button",H.onclick=f;let T=async()=>{try{q.disabled=!0,await e.client().api(`/api/conversations/${b.id}`,{method:"PUT",body:{title:O.value}}),await e.updated(),await c(o)}catch(C){q.disabled=!1,d(C)}};q.onclick=T,O.onkeydown=C=>{C.key==="Enter"&&!C.isComposing&&(C.preventDefault(),T()),C.key==="Escape"&&f()},y.replaceChildren(O,q,H),O.focus(),O.select()};let F=a("button",b.archived?"恢复":"归档");F.type="button",F.disabled=!p()||e.busy(),F.onclick=async()=>{try{F.disabled=!0,await e.client().api(`/api/conversations/${b.id}`,{method:"PUT",body:{archived:!b.archived}}),await e.updated(),await c(o)}catch(O){d(O),F.disabled=!1}},_.append(U,F),y.append(E,_),t("history-rows").append(y)}}async function c(g){let v=++l,L=e.client();t("history-error").textContent="",t("history-rows").replaceChildren(a("div","正在读取历史…","empty-state"));let A=await L.api(`/api/history-groups?connectionId=${encodeURIComponent(e.connection()?.id||"")}`),b=g||e.connection()?.id||A[0]?.id||"",y=b?await L.api(`/api/conversations?connectionId=${encodeURIComponent(b)}`):[];v!==l||L!==e.client()||(i=A.filter(E=>E.id===e.connection()?.id),o=b,r=y,f())}function m(){t("history-manager").hidden=!0,t("history-button").focus()}return t("history-button").onclick=()=>{t("settings").hidden=!0,t("history-manager").hidden=!1,c(e.connection()?.id).catch(d)},t("history-close").onclick=m,t("history-search").oninput=f,t("history-archived").onchange=f,{close:m,reload:()=>c(o),invalidate:()=>{l++,m()}}}function Yi(n,e){let t=S=>n.getElementById(S),i=n.ownerDocument,r=(S,P,I)=>{let M=i.createElement(S);return P&&(M.textContent=P),I&&(M.className=I),M},o="/",l=0,a=[],d=null,p=null,f=!1,c=!1,m="split",g=()=>t("file-scope").value,v=()=>!!g()||o==="/skills"||o.startsWith("/skills/"),L=(S=o)=>`/api/workspaces/${e.connection()?.id}/files?path=${encodeURIComponent(S)}${g()?"&legacyConversationId="+encodeURIComponent(g()):""}`,A=S=>S<1024?`${S} B`:S<1048576?`${(S/1024).toFixed(1)} KiB`:`${(S/1048576).toFixed(1)} MiB`,b=S=>S?new Date(S).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—",y=S=>(o==="/"?"":o)+"/"+S;function E(S){S.name!=="AbortError"&&(t("file-error").textContent=S.message)}function _(){t("file-list").inert=f||c,t("file-refresh").disabled=f||c||!e.connection(),t("file-upload").disabled=c||v()||!e.connection(),t("file-scope").disabled=c,t("file-path").disabled=c,t("file-parent").disabled=o==="/"||f||c,t("file-delete-confirm").disabled=c,t("file-delete-cancel").disabled=c,t("file-delete-confirm").textContent=c?"正在删除…":"确认删除",t("files-pane").dataset.fileLayout=m,t("files-pane").dataset.hasSelection=String(!!d)}function U(){let S=g();t("file-scope").replaceChildren(new Option(e.connection()?.identityMode==="session-only"?"会话工作区":"共享工作区",""));for(let I of e.conversations())I.legacyWorkspace&&t("file-scope").add(new Option(`旧文件 · ${I.title||I.id}`,I.id));[...t("file-scope").options].some(I=>I.value===S)&&(t("file-scope").value=S);let P=e.connection();t("file-workspace").textContent=P?P.identityMode==="session-only"?`${new URL(P.site).host} · 当前浏览器会话`:`${new URL(P.site||"http://localhost").host} · ${P.domId||"—"} · ${P.display||P.principal||"当前账号"}`:"请先连接当前应用",t("file-workspace").title=P?.workspaceId||"",t("file-readonly").hidden=!v(),t("file-readonly").textContent=g()?"旧对话工作区仅供读取和下载":"内置技能目录只读",_()}function F(){d=null,t("file-preview").hidden=!0,t("file-preview-content").textContent="",t("file-preview-note").textContent="",p=null,t("file-confirm").hidden=!0,_()}function O(){let S=t("file-search").value.trim().toLocaleLowerCase(),P=a.filter(I=>I.name.toLocaleLowerCase().includes(S));P.sort((I,M)=>Number(M.directory)-Number(I.directory)||(t("file-sort").value==="modified"?(M.modifiedAt||0)-(I.modifiedAt||0):I.name.localeCompare(M.name))),t("file-list").replaceChildren(),P.length||t("file-list").append(r("div",S?"没有匹配的文件":"目录为空。上传文件,或让 AI 在这里生成预处理结果。","empty-state"));for(let I of P){let M=r("div","","file-row");M.dataset.selected=String(d?.name===I.name);let G=r("button","","file-name");G.type="button",G.title=I.name,G.setAttribute("aria-label",`${I.directory?"打开目录":"预览"} ${I.name}`);let V=r("span",I.directory?"目录":I.name.includes(".")?I.name.split(".").pop().slice(0,6).toUpperCase():"文件","file-kind");G.append(V,r("span",I.name,"file-label")),G.onclick=()=>{f||c||!a.includes(I)||(I.directory?H(I.path):T(I))};let re=r("div","","file-row-actions");if(!I.directory){let we=r("button","下载");we.type="button",we.title=`下载 ${I.name}`,we.onclick=()=>{!a.includes(I)||f||c||C(I.path,I.name).catch(E)},re.append(we)}let he=r("button","删除","file-remove");he.type="button",he.disabled=v()||c||I.path==="/skills",he.setAttribute("aria-label",`删除 ${I.name}`),he.onclick=()=>$(I),re.append(he),M.append(G,r("span",I.directory?"—":A(I.size),"file-size"),r("time",b(I.modifiedAt),"file-modified"),re),t("file-list").append(M)}t("file-count").textContent=`${P.length}${S?" / "+a.length:""} 项`,_()}async function q(){if(c)return;let S=++l,P=e.connection(),I=e.client(),M=g();f=!0,a=[],t("file-list").replaceChildren(r("div","正在读取目录…","empty-state")),t("file-error").textContent="",t("file-notice").textContent="",F(),_();try{if(!P)throw Error("请先连接当前 BI 账号");let G=await I.api(L());if(S!==l||P!==e.connection()||I!==e.client()||M!==g())return;o=G.path,a=G.entries.map(V=>({...V,path:y(V.name)})),t("file-path").value=o,U(),O()}catch(G){S===l&&E(G)}finally{S===l&&(f=!1,_())}}function H(S){o=S,q()}async function T(S){if(f||c||!a.includes(S))return;let P=l,I=e.connection(),M=e.client(),G=S.path;d=S,t("file-preview").hidden=!1,t("file-preview-name").textContent=S.name,t("file-preview-path").textContent=G,t("file-preview-meta").textContent=`${A(S.size)} · ${b(S.modifiedAt)}`,t("file-preview-content").textContent="",t("file-preview-note").textContent="正在读取…",t("file-preview-download").onclick=()=>C(G,S.name).catch(E),t("file-preview-delete").disabled=v(),t("file-preview-delete").onclick=()=>$(S),O();try{if(S.size>1048576)throw Error("文件超过 1 MiB,请下载查看。");let V=await M.api(L(G),{responseType:"blob"}),re=new Uint8Array(await V.arrayBuffer());if(P!==l||d!==S||I!==e.connection()||M!==e.client())return;if(re.includes(0))throw Error("二进制文件,请下载查看。");t("file-preview-content").textContent=new TextDecoder().decode(re),t("file-preview-note").textContent=""}catch(V){P===l&&d===S&&(t("file-preview-note").textContent=V.message)}}async function C(S,P){let I=e.client(),M=e.connection(),G=await I.api(L(S),{responseType:"blob"});if(M!==e.connection()||I!==e.client())return;let V=URL.createObjectURL(G),re=r("a");re.href=V,re.download=P,re.click(),setTimeout(()=>URL.revokeObjectURL(V),1e3)}function $(S){v()||f||c||!a.includes(S)||S.path==="/skills"||(p={entry:S,path:S.path,connection:e.connection(),client:e.client(),scope:g()},t("file-confirm-name").textContent=S.name,t("file-confirm-path").textContent=p.path,t("file-confirm-hint").textContent=S.directory?"仅能删除空目录。删除后无法恢复。":"此操作会永久删除工作区中的文件,无法恢复。",t("file-confirm").hidden=!1,_(),t("file-delete-cancel").focus())}async function te(){let S=p;if(!S||c||v())return;let{entry:P,path:I,connection:M,client:G}=S;c=!0,_();try{if(await e.refreshCredential(),S!==p||M!==e.connection()||G!==e.client()||S.scope!==g()||(await G.api(L(I),{method:"DELETE"}),M!==e.connection()||G!==e.client()))return;a=a.filter(V=>V.name!==P.name),F(),O(),t("file-notice").textContent=`已删除 ${P.name}`}catch(V){M===e.connection()&&G===e.client()&&(E(V),(!V.status||V.status>=500)&&(t("file-error").textContent+=" · 如状态不确定,请刷新列表确认。"))}finally{c=!1,p===S&&(p=null,t("file-confirm").hidden=!0),_(),O()}}function ne(){l++,a=[],o="/",f=!1,c=!1,F(),t("file-list").replaceChildren(),t("file-search").value="",t("file-path").value="/",t("file-error").textContent="",t("file-notice").textContent="",t("file-count").textContent="0 项",U()}return t("file-refresh").onclick=()=>H(t("file-path").value),t("file-path").onkeydown=S=>{S.key==="Enter"&&t("file-refresh").click()},t("file-parent").onclick=()=>H(o.slice(0,o.lastIndexOf("/"))||"/"),t("file-scope").onchange=()=>H("/"),t("file-preview-close").onclick=()=>{F(),O()},t("file-search").oninput=O,t("file-sort").onchange=O,t("file-layout").onchange=()=>{m=t("file-layout").value,_()},t("file-delete-confirm").onclick=()=>{te()},t("file-delete-cancel").onclick=()=>{p=null,t("file-confirm").hidden=!0},t("file-confirm").onkeydown=S=>{S.key==="Escape"&&!c&&(p=null,t("file-confirm").hidden=!0)},t("file-upload").onchange=async()=>{let S=[...t("file-upload").files],P=l,I=e.connection(),M=e.client(),G=o,V=g();try{if(v())throw Error("旧对话文件仅供读取");await e.refreshCredential();for(let re of S){if(P!==l||I!==e.connection()||M!==e.client()||g()!==V)return;if(re.size>33554432)throw Error(`${re.name} 超过 32 MiB`);await M.api(L((G==="/"?"":G)+"/"+re.name),{method:"PUT",rawBody:re,responseType:"blob"})}P===l&&await q()}catch(re){I===e.connection()&&M===e.client()&&E(re)}finally{t("file-upload").value=""}},{open:q,update:U,reset:ne}}function Xi(n,e){let t=T=>n.getElementById(T),i=n.ownerDocument,r="chat",o=0,l=null,a=null,d="",p=0,f=!1,c="/",m=[],g=0,v=(T,C,$)=>{let te=i.createElement(T);return C&&(te.textContent=C),$&&(te.className=$),te},L=(T,C)=>{let $=e.connection();if(!$)throw Error("请先连接当前 BI 账号");return e.client().api(`/api/workspaces/${$.id}${T}`,C)},A=(T,C)=>{C.name!=="AbortError"&&(t(T).textContent=C.message)};function b(){let T=!!e.connection();t("terminal-input").disabled=!T,t("terminal-run").disabled=!T||f,t("terminal-input").placeholder=d?"输入发送至 stdin…":"输入命令…",t("terminal-run").textContent=d?"输入":"执行",t("terminal-stop").disabled=!d||f,t("terminal-eof").disabled=!d||f,t("terminal-cwd").textContent=c,t("terminal-prompt").textContent=d?"›":"$"}function y(){H.update(),t("workspace-label").title=e.connection()?.workspaceId||"",b()}function E(T){let C=t("terminal-output"),$=C.scrollHeight-C.scrollTop-C.clientHeight<64;C.textContent=(C.textContent+T.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,"").replace(/\x1b\][^\x07]*(?:\x07|$)/g,"")).slice(-5e5),$&&(C.scrollTop=C.scrollHeight)}async function _(){if(a)return;if(l)return l;let T=o,C=(async()=>{await e.refreshCredential();let $=e.connection(),te=e.client(),ne=await L("/terminals",{method:"POST"});if(T!==o||$!==e.connection()||te!==e.client()){te.api(`/api/workspaces/${$.id}/terminals/${ne.id}`,{method:"DELETE"}).catch(()=>{});return}a=ne.id,c=decodeURIComponent(new URL(ne.shell.cwd).pathname),E(`已连接当前应用会话的 GuanVM 工作区。
161
+ `),b()})();l=C;try{return await C}finally{l===C&&(l=null)}}async function U(T,C,$,te,ne){let S=new Map;for(;T===o&&e.active()&&a===te&&d===ne;){let P=await C.api(`/api/workspaces/${$.id}/terminals/${te}`,{method:"POST",body:{action:"read",processId:ne,afterSeq:p}});if(T!==o||a!==te||$!==e.connection())return;for(let I of P.chunks||[]){let M=S.get(I.stream);M||(M=new TextDecoder,S.set(I.stream,M)),E(M.decode(Uint8Array.from(atob(I.chunk),G=>G.charCodeAt(0)),{stream:!0}))}if(p=P.nextSeq,P.shell?.cwd&&(c=decodeURIComponent(new URL(P.shell.cwd).pathname)),P.finished){for(let I of S.values())E(I.decode());E(`
162
+ [exit ${P.exitCode}${P.failure?" · "+String(P.failure):""}]
163
+ `),d="",b();return}}}async function F(T){if(T.preventDefault(),f)return;let C=t("terminal-input").value;if(C.trim()){f=!0,t("terminal-error").textContent="",b();try{if(d){await O(C+`
164
+ `,!1),t("terminal-input").value="";return}if(await e.refreshCredential(),await _(),!a)return;let $=e.connection(),te=e.client(),ne=a,S=Ze();E(`${c} $ ${C}
165
+ `),m.push(C),g=m.length,p=0,d=S,t("terminal-input").value="",await L(`/terminals/${ne}`,{method:"POST",body:{action:"start",command:C,processId:S}}),U(o,te,$,ne,S).catch(P=>{A("terminal-error",P),b()})}catch($){A("terminal-error",$),d&&(t("terminal-error").textContent+=" · 执行状态需确认,请停止或重连,不要重复执行。")}finally{f=!1,b()}}}async function O(T,C){let $=new TextEncoder().encode(T);if($.length>32768)throw Error("单次标准输入上限 32 KiB");await L(`/terminals/${a}`,{method:"POST",body:{action:"stdin",processId:d,data:btoa(String.fromCharCode(...$)),closeStdin:C,writeId:Ze()}})}function q(){if(o++,l=null,H.reset(),a&&e.connection()){let T=e.connection(),C=e.client(),$=a;C.api(`/api/workspaces/${T.id}/terminals/${$}`,{method:"DELETE",timeout:1e4}).catch(()=>{})}a=null,d="",p=0,c="/",m=[],g=0,t("terminal-output").textContent="",t("file-list").replaceChildren(),t("file-preview").hidden=!0,t("file-error").textContent="",t("terminal-error").textContent=""}let H=Yi(n,e);for(let T of n.querySelectorAll("[data-pane]"))T.onclick=()=>{r=T.dataset.pane,t("panel").dataset.pane=r;for(let C of n.querySelectorAll("[data-pane]"))C.setAttribute("aria-selected",String(C.dataset.pane===r));t("files-pane").hidden=r!=="files",t("terminal-pane").hidden=r!=="terminal",t("history-manager").hidden=!0,t("settings").hidden=!0,r==="files"&&H.open(),r==="terminal"&&(b(),_().catch(C=>A("terminal-error",C)))};return t("terminal-form").onsubmit=F,t("terminal-stop").onclick=async()=>{f=!0,b();try{await L(`/terminals/${a}`,{method:"POST",body:{action:"stop",processId:d}})}catch(T){A("terminal-error",T)}finally{f=!1,b()}},t("terminal-eof").onclick=()=>O("",!0).catch(T=>A("terminal-error",T)),t("terminal-clear").onclick=()=>{t("terminal-output").textContent=""},t("terminal-reconnect").onclick=()=>{q(),_().catch(T=>A("terminal-error",T))},t("terminal-input").onkeydown=T=>{(T.ctrlKey||T.metaKey)&&T.key==="c"&&!n.getSelection?.()?.toString()&&d&&(T.preventDefault(),t("terminal-stop").click()),!d&&["ArrowUp","ArrowDown"].includes(T.key)&&(T.preventDefault(),g=Math.max(0,Math.min(m.length,g+(T.key==="ArrowUp"?-1:1))),t("terminal-input").value=m[g]||"")},{update:y,reset:q,idle:()=>!l&&!f&&!d}}function Vi(n,e){let t=p=>n.getElementById(p),i=0,r=!1,o=null;function l(){i++,r=!1,o=null,t("exec-details").hidden=!0;for(let p of["exec-url","exec-token","exec-workspace"])t(p).value="";t("exec-token").type="password",t("exec-toggle-token").textContent="显示凭证",t("exec-toggle-token").setAttribute("aria-pressed","false"),t("exec-status").textContent="",a()}function a(){t("exec-show").disabled=r||!e.connection()||!e.connected(),t("exec-show").textContent=r?"正在读取…":"显示连接信息";for(let p of["exec-toggle-token","exec-copy-token"])t(p).disabled=!o||!e.connection()||!e.connected()}t("exec-show").onclick=async()=>{if(r||!e.connection()||!e.connected())return;l(),r=!0,a();let p=i,f=e.client(),c=e.connection(),m=()=>p===i&&f===e.client()&&c===e.connection()&&e.connected()&&e.active();try{if(await e.refreshCredential(),!m())return;let g=await f.api(`/api/bi-connections/${c.id}/exec-server`,{method:"POST"});if(!m())return;o=g,t("exec-url").value=g.url,t("exec-token").value=g.authBearerToken,t("exec-workspace").value=g.workspaceId,t("exec-details").hidden=!1}catch(g){m()&&(t("exec-status").textContent=`读取失败:${g.message}`)}finally{p===i&&(r=!1,a())}};function d(p){return`请连接以下 GuanVM exec-server,并保留我现有的本地 Codex 环境和工具。
166
+ BI 站点:${p.site}
167
+ domID:${p.domId}
168
+ 账号:${p.principal}
169
+ 共享工作区:${p.workspaceId}
170
+ 环境 ID:${p.environmentId}
156
171
 
157
- ${z}`}}),r("prompt").value="",He()}catch(W){W.submissionStatus==="not_submitted"||!ae?(b=!1,S(F?"\u5DF2\u505C\u6B62\uFF0C\u6D88\u606F\u5C1A\u672A\u53D1\u9001":`\u6D88\u606F\u5C1A\u672A\u53D1\u9001\uFF1A${W.message}\u3002\u53EF\u4EE5\u91CD\u8BD5\uFF0C\u8349\u7A3F\u5DF2\u4FDD\u7559\u3002`,!F)):p&&f?(S(`\u63D0\u4EA4\u72B6\u6001\u9700\u786E\u8BA4\uFF1A${W.message}\u3002\u8BF7\u5237\u65B0\u5386\u53F2\u540E\u518D\u64CD\u4F5C\u3002`,!0),b=!0):(b=!1,D(),de(W))}finally{x=!1,ae=!1,b||(Q=!1),D(),b&&r("status").dataset.error==="true"&&(r("refresh").disabled=!1)}}}),r("stop").addEventListener("click",async()=>{if(!(!f||Q)&&(F=Q=!0,S("\u6B63\u5728\u505C\u6B62\u2026"),D(),!(x&&!ae)))try{await u.api(`/api/conversations/${f}/interrupt`,{method:"POST"}),b=Q=F=!1,D(),S("\u5DF2\u505C\u6B62\uFF0C\u53EF\u4EE5\u7EE7\u7EED\u5BF9\u8BDD")}catch(h){Q=!1,b=!0,D(),r("refresh").disabled=!1,de(h)}}),r("new").addEventListener("click",()=>ze("").catch(de)),r("refresh").addEventListener("click",async()=>{try{await Ue(),await Ne(),await ze(f)}catch(h){de(h)}}),r("launcher").addEventListener("click",()=>{r("panel").hidden=!1,r("launcher").hidden=!0,p||ge(!0)}),r("close").addEventListener("click",()=>{r("panel").hidden=!0,r("launcher").hidden=!1});let M=st(location.pathname);function B(){let h=st(location.pathname);e.hidden=!h,Y(),!h&&E&&ce(),h&&!M&&p&&f&&ze(f).catch(de),h&&!M&&!p&&ge(),M=h}function Z(){ve.reset(),q?.dispose(),N?.dispose(),k=!0,ce(),clearInterval(I),clearInterval(H),clearInterval(J),clearTimeout(R),v.abort(),globalThis.GD?.off("gd-route-change",B),e.remove(),u=p=null}e.addEventListener("guancopilot-dispose",Z,{once:!0}),globalThis.GD?.on("gd-route-change",B),globalThis.addEventListener("popstate",B,{signal:v.signal}),globalThis.addEventListener("pagehide",Z,{signal:v.signal});let J=setInterval(B,750);u=oe(),rt(),H=setInterval(async()=>{if(P||k||!G||q?.state==="denied"||!st(location.pathname))return;P=!0;let h=A,z=u;try{if(await z.health(),z!==u)return;A=!0,(h===!1||h===null&&!p)&&ge()}catch{z===u&&(A=!1)}finally{P=!1}},5e3),I=setInterval(()=>{p&&G&&q?.state!=="denied"&&st(location.pathname)&&document.visibilityState==="visible"&&Ue().catch(()=>{})},6e4),document.body.append(e),B(),D(),M&&S("\u70B9\u51FB\u6253\u5F00 Copilot \u5E76\u8FDE\u63A5\uFF0C\u5728\u6D4F\u89C8\u5668\u6388\u6743\u5F39\u7A97\u4E2D\u9009\u62E9\u300C\u5141\u8BB8\u300D\u3002")}document.body?so():document.addEventListener("DOMContentLoaded",so,{once:!0});})();
172
+ 使用支持 environments.toml 和 auth_bearer_token 的 Codex(本项目验证基线 >= 0.162.1)。将下面配置合并到目标 Codex 的 $CODEX_HOME/environments.toml(默认 ~/.codex/environments.toml):include_local 放在文件顶层;已有相同环境 ID 时替换该环境项,其余环境和 default 保持原值。重新加载目标 Codex 后先检查此环境的 environment/info。若当前客户端无法动态加载环境,请明确说明并给出重新加载步骤。
173
+
174
+ ${p.configSnippet}
175
+ 使用 app-server 的客户端还需在同一个任务的 thread/start 或 turn/start 的 environments 中同时包含 local(cwd 保留本机工作目录)和 ${p.environmentId}(cwd 为 /)。仅写入配置不会给已经运行的任务自动添加环境。BI 命令和远程文件操作明确选择 GuanVM 环境,本地任务继续使用本地环境;GuanVM 连接失败时不要将 BI 命令回退到本机执行。GuanVM 命令使用 /bin/sh、login=false、cwd=/。
176
+
177
+ 这是 exec-server 的 WebSocket 执行协议,连接时通过 Authorization: Bearer 发送上面的 auth_bearer_token;原生客户端不得发送 Origin 或 URL 查询参数。它不是 app-server 或 MCP 地址。
178
+
179
+ 以下约束仅适用于 GuanVM 环境,本地环境继续使用本机工具:
180
+ ${p.instructions}
181
+
182
+ 此配置含工作区执行凭证,可操作当前 BI 账号;不要提交到 Git 或打印到日志。默认 127.0.0.1 地址仅同一台电脑可达。请保持 GuanCopilot 后台运行、当前 BI 登录有效;后台重启或身份解绑后需重新获取连接信息。与插件共享文件,但此地址使用独立执行通道。其他 Codex 请分别获取连接信息,避免同时复用同一条通道。
183
+ `}for(let[p,f]of[["exec-copy-token",c=>c.authBearerToken],["exec-copy-url",c=>c.url],["exec-copy-config",c=>c.configSnippet],["exec-copy-instructions",d]])t(p).onclick=async()=>{if(!o||!e.connected())return;let c=i;try{await n.ownerDocument.defaultView.navigator.clipboard.writeText(f(o)),c===i&&(t("exec-status").textContent=p==="exec-copy-token"?"凭证已复制":"已复制")}catch{c===i&&(t("exec-status").textContent="复制失败,请允许浏览器访问剪贴板后重试。")}};return t("exec-toggle-token").onclick=()=>{if(!o||!e.connected())return;let p=t("exec-token").type==="password";t("exec-token").type=p?"text":"password",t("exec-toggle-token").textContent=p?"隐藏凭证":"显示凭证",t("exec-toggle-token").setAttribute("aria-pressed",String(p))},t("exec-hide").onclick=l,{reset:l,update:a}}var Zi="guanloop-extension-v1",Ki=32<<20;function Qi(n){let e=n.__GUANCOPILOT_EXTENSION_RELAY__;return e?.protocol===1&&/^[a-f0-9]{64}$/.test(e.channel)&&e.origin===n.location.origin?e:null}function Ji(n,e,t,{signal:i}={}){if(t.backend!==e)throw Error("后台地址已更改,请从 Chrome 工具栏重新注入 GuanCopilot");let r=!1,o=new Map,l=c=>{for(let m of o.values())m.cleanup(),m.reject(c);o.clear()},a=c=>n.postMessage({protocol:Zi,direction:"page",channel:t.channel,...c},t.origin),d=c=>{let m=c.data;if(c.source!==n||c.origin!==t.origin||m?.protocol!==Zi||m.direction!=="extension"||m.channel!==t.channel)return;if(m.kind==="disconnected"){l(new TypeError(m.message));return}let g=o.get(m.id);if(g){if(o.delete(m.id),g.cleanup(),m.kind==="error"){let v=new Error(m.message);v.name=m.name||"Error",g.reject(v);return}try{if(m.kind!=="response"||m.body?.byteLength>Ki||!Number.isInteger(m.status)||m.status<200||m.status>599)throw Error("扩展响应无效");g.resolve(new n.Response([204,205,304].includes(m.status)?null:m.body,{status:m.status,headers:m.headers}))}catch(v){g.reject(v)}}};n.addEventListener("message",d);function p(){if(!r){r=!0,i?.removeEventListener("abort",p),n.removeEventListener("message",d);for(let c of o.keys())a({kind:"abort",id:c});l(new Error("扩展通道已关闭"))}}i?.addEventListener("abort",p,{once:!0});async function f(c,m={}){if(r)throw Error("扩展通道已关闭");let g=new URL(c);if(g.origin!==e){if(g.origin===n.location.origin)return n.fetch(c,m);throw Error("扩展只连接当前本机助手")}if(!g.pathname.startsWith("/api/"))throw Error("扩展只连接当前本机助手");m.signal?.throwIfAborted();let v=m.body==null?void 0:typeof m.body=="string"?new n.TextEncoder().encode(m.body).buffer:await new n.Blob([m.body]).arrayBuffer();if(m.signal?.throwIfAborted(),v?.byteLength>Ki)throw Error("扩展请求超过 32 MiB");return new Promise((L,A)=>{let b=Ze(n.crypto),y=()=>m.signal?.removeEventListener("abort",E),E=()=>{o.delete(b),y(),a({kind:"abort",id:b}),A(m.signal.reason||new n.DOMException("Aborted","AbortError"))};o.set(b,{resolve:L,reject:A,cleanup:y}),m.signal?.addEventListener("abort",E,{once:!0});try{a({kind:"request",id:b,path:g.pathname+g.search,method:m.method||"GET",headers:m.headers||{},body:v})}catch(_){o.delete(b),y(),A(_)}})}return{kind:"extension",required:!1,bypassesPageNetworkPolicy:!0,fetch:f,open(){},dispose:p}}function fs(n,e){let t=n.navigator?.userAgent||"",i=new URL(e);return/Safari\//.test(t)&&!/(?:Chrome|Chromium|Edg|CriOS|FxiOS)\//.test(t)&&n.location.protocol==="https:"&&i.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(i.hostname)}function hs(n,e){let t=new URL(e);return n.location.protocol==="http:"&&n.isSecureContext===!1&&t.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(t.hostname)}function eo(n,e,{signal:t,onClosed:i=()=>{},forceWindow:r=!1}={}){let o=Qi(n);if(o)return Ji(n,new URL(e).origin,o,{signal:t});let l=new URL(e).origin,a=n.fetch.bind(n),d=r||fs(n,l)||hs(n,l),p=null,f="",c=null,m,g,v,L=!1,A=null,b=new Map;function y(H){g?.(H);for(let T of b.values())T.cleanup(),T.reject(H);b.clear()}function E(H){if(H.source!==p||H.origin!==l||H.data?.channel!==f)return;let T=H.data;if(T.type==="reconnecting"){y(new Error("本机连接窗口已重置,请求结果未知,请勿自动重放")),U(),F();return}if(T.type==="ready"){clearTimeout(v),m?.();return}let C=b.get(T.id);if(C){if(T.type==="response"){b.delete(T.id),C.cleanup();try{C.resolve(new n.Response([204,205,304].includes(T.status)?null:T.body,{status:T.status,headers:T.headers}))}catch($){C.reject($)}}if(T.type==="error"){b.delete(T.id),C.cleanup();let $=new Error(T.message);$.name=T.name||"Error",C.reject($)}}}n.addEventListener("message",E);function _(){t?.removeEventListener("abort",_),L=!0,clearTimeout(v),clearInterval(A),n.removeEventListener("message",E),y(new Error("本机连接已关闭")),p?.close(),p=null}t?.addEventListener("abort",_,{once:!0});function U(){c=new Promise((H,T)=>{m=H,g=T}),c.catch(()=>{})}function F(){clearTimeout(v),v=setTimeout(()=>{g(new Error("本机连接窗口未就绪,请确认 guancopilot 已更新并启动")),p?.close(),p=null,clearInterval(A),i()},15e3)}function O(){if(d){if(L)throw Error("本机连接已关闭");if(!(p&&!p.closed)){if(f=Ze(n.crypto),U(),p=n.open(l+"/browser-bridge?origin="+encodeURIComponent(n.location.origin)+"&channel="+encodeURIComponent(f),"guanloop-"+f,"popup,width=480,height=320"),!p)throw g(new Error("浏览器未能打开本机连接窗口,请允许此站点的弹出式窗口后重试")),Error("浏览器未能打开本机连接窗口,请允许此站点的弹出式窗口后重试");F(),clearInterval(A),A=setInterval(()=>{p?.closed&&(clearInterval(A),clearTimeout(v),y(new Error("本机连接窗口已关闭,请重新打开 Copilot")),p=null,i())},1e3)}}}async function q(H,T={}){if(!d||new URL(H).origin!==l)return a(H,T);if(!p||p.closed)throw Error("请点击连接,打开本机连接窗口");let C=()=>T.signal?.reason||new n.DOMException("请求已取消","AbortError");if(await new Promise((te,ne)=>{let S=()=>{P(),ne(C())},P=()=>T.signal?.removeEventListener("abort",S);if(T.signal?.aborted){ne(C());return}T.signal?.addEventListener("abort",S,{once:!0}),c.then(()=>{P(),te()},I=>{P(),ne(I)})}),T.signal?.aborted)throw C();let $=T.body==null?void 0:typeof T.body=="string"?new n.TextEncoder().encode(T.body).buffer:await new n.Blob([T.body]).arrayBuffer();if(T.signal?.aborted)throw C();return new Promise((te,ne)=>{let S=Ze(n.crypto),P=()=>T.signal?.removeEventListener("abort",I),I=()=>{b.delete(S),P(),p?.postMessage({type:"abort",id:S,channel:f},l),ne(C())};b.set(S,{resolve:te,reject:ne,cleanup:P}),T.signal?.addEventListener("abort",I,{once:!0});let M=new URL(H).pathname+new URL(H).search;try{p.postMessage({type:"request",channel:f,id:S,path:M,method:T.method||"GET",headers:T.headers,body:$},l)}catch(G){b.delete(S),P(),ne(G)}})}return{required:d,get opened(){return!L&&!!p&&!p.closed},open:O,fetch:q,dispose:_}}function to({navigator:n,address:e,onChange:t=()=>{},signal:i}){let r=new URL(e).hostname,o=["localhost","[::1]"].includes(r)||/^127(?:\.\d{1,3}){3}$/.test(r),l=r.split(".").map(Number),a=r.endsWith(".local")||/^\[(?:fc|fd|fe[89ab])/i.test(r)||l.length===4&&(l[0]===10||l[0]===172&&l[1]>=16&&l[1]<=31||l[0]===192&&l[1]===168||l[0]===169&&l[1]===254),d="unknown",p=null,f=!1,c=null,m=o?["loopback-network","local-network-access"]:["local-network","local-network-access"],g=()=>{f||(d=p.state,t(d))};function v(){f=!0,p?.removeEventListener?.("change",g)}i?.addEventListener("abort",v,{once:!0});async function L(){return f||!o&&!a?d:c||(c=(async()=>{let A=n?.userAgent?.match(/(?:Chrome|Chromium|Edg)\/(\d+)/);if(A&&Number(A[1])<137||!n?.permissions?.query)return d;for(let b of m)try{let y=await n.permissions.query({name:b});return f||(p?.removeEventListener?.("change",g),p=y,p.addEventListener?.("change",g),g()),d}catch{}return d})().finally(()=>{c=null}),c)}return{get state(){return d},check:L,dispose:v}}var An={none:"None",minimal:"Minimal",low:"Low",medium:"Medium",high:"High"};function Sn(n,e){let t=n?.data?.find(r=>r.model===e),i=new Set((t?.supportedReasoningEfforts||[]).map(r=>r.reasoningEffort));return Object.keys(An).filter(r=>i.has(r))}function no(n,e,t=""){let i=Sn(n,e),r=n?.data?.find(o=>o.model===e);for(let o of[t,e===n?.defaultModel?n.defaultReasoningEffort:"",r?.defaultReasoningEffort,"medium","high","low",...i])if(i.includes(o))return o;return""}function ur({openImmediately:n=!1,baseUrl:e="",appId:t=""}={}){let i=Mr(globalThis,n,t),r="guancopilot-local-root",o=document.getElementById(r),l=globalThis.__GUANCOPILOT_EXTENSION_RELAY__?.channel||"";if(n&&o?.dataset.guancopilotRuntime==="6"&&o?.dataset.guancopilotApp===i.manifest.id&&(o?.dataset.relayChannel||"")===l){o.dispatchEvent(new Event("guancopilot-open"));return}document.getElementById(r)?.dispatchEvent(new Event("guancopilot-dispose"));let a=document.createElement("div");a.id=r,a.dataset.guancopilotRuntime="6",a.dataset.relayChannel=l,a.dataset.guancopilotApp=i.manifest.id;let d=n,p=()=>i.active(d),f=a.attachShadow({mode:"open"});f.innerHTML=Gi;let c=h=>f.getElementById(h);c("panel").setAttribute("aria-label",`${i.manifest.name} Copilot`),c("launcher").setAttribute("aria-label",`打开 ${i.manifest.name} Copilot`),f.querySelector("header strong").textContent=`${i.manifest.name} Copilot`;let m=qt;try{m=Pt(e||localStorage.getItem("guanloop.backend")||qt)}catch{}let g="",v=null,L=!1,A=[],b,y,E="",_=!1,U=!1,F=!1,O=!1,q=0,H=null,T=!1,C=null,$=null,te=!1,ne=null,S=!1,P=!1,I=null,M=null,G=null,V=null,re=!1,he=0,we=null,Qe=!i.requiresBrowserTools,rt=Promise.resolve(),Q=null,qe=!1,Ce=!1,vt=!1,$e=new AbortController;a.style.setProperty("--guanloop-font",getComputedStyle(document.body).fontFamily),qi(globalThis,f,$e.signal);let Pe=new Map,Ue=new Map,an=Hi(globalThis);function Z(h,R=!1){c("status").textContent=h,c("status").dataset.error=String(R),c("status").title=h}function J(){let h=F||T;c("activity").dataset.busy=String(_||U||h),c("panel").dataset.busy=String(_||U),c("stop").textContent=Ce?"停止中…":"■ 停止",c("prompt").disabled=!y||!te||!Qe||_||U||h,c("send").disabled=!y||!te||!Qe||_||U||h,c("stop").disabled=!y||!E||!_||Ce,c("history-button").disabled=!y||h||U,c("model").disabled=!y||!L||_||U||h,c("effort").disabled=c("model").disabled||!Sn(v,c("model").value).length,c("settings-button").disabled=_||U||F||T,c("send").disabled||=!L,c("new").disabled=!y||!Qe||_||U||h,c("refresh").disabled=!y||!Qe||_||U||h,xe.update(),We.update()}function ee(){let h=i.identity(y),R=we&&y&&we.id!==y.id;R&&(h.account="联合会话 · 身份未合并"),c("environment").textContent=h.environment,c("account").textContent=h.account;let N=i.requiresBrowserTools;c("workspace-label").textContent=R?"当前联合会话的独立工作区":N?"当前浏览器会话的工作区":"当前 BI 账号的共享工作区",c("file-help").textContent=R?"当前联合会话内共享文件 · 上传/下载上限 32 MiB":N?"当前浏览器会话内共享文件 · 上传/下载上限 32 MiB":"同一 BI URL · domID · 账号共享文件 · 上传/下载上限 32 MiB",f.querySelector(".terminal-help").textContent=R?"运行在当前联合会话的工作区 · 官方查询与原浏览器元数据分开路由 · 支持 stdin;暂不支持全屏 PTY 程序":N?"运行在当前浏览器会话的工作区 · 使用应用工具时请保持页面登录 · 支持 stdin;暂不支持全屏 PTY 程序":"运行在当前账号的共享工作区 · BI 凭证自动注入 · 支持 stdin;暂不支持全屏 PTY 程序",c("environment").title=`环境:${c("environment").textContent}`,c("account").title=`账号:${c("account").textContent}`}function it(h){te=h,h||xe.reset(),c("backend-dot").dataset.connected=String(h),c("backend-label").textContent=`guanloop · ${h?"已连接":"未连接"}`,J()}function W(h){O||h.name==="AbortError"||Z(h.message,!0)}function Le(){q++,H?.abort(),H=null}function Ee(h){O||re||(re=!0,We.reset(),we=null,he++,Et(!0),xe.reset(),Te.reset(),Le(),y=null,A=[],Te.update(),E="",F=!1,Pe.clear(),Ue.clear(),c("messages").replaceChildren(),c("conversation-title").textContent="请重新连接",mt.invalidate(),Te?.reset(),c("setup").hidden=!1,_=!1,J(),ee(),Z(`当前应用连接已失效,请重新连接:${h.message}`,!0))}function Je(){let h=V;return V=null,rt=Promise.allSettled([rt,h?.stop()]).then(()=>{}),rt}function Et(h=!1){let R=b,N=Je();return h&&(rt=N.then(()=>R?.disconnect()).catch(()=>{})),rt}function Me(h){let R=Cr(h),N=h.type==="userMessage"?R.replace(/^当前 BI 页面:https?:\/\/[^\s]+\n\n/,""):R;if(!N)return;let K=c("messages"),se=K.scrollHeight-K.scrollTop-K.clientHeight<64,oe=Pe.get(h.id);if(!oe){oe=document.createElement("article"),oe.dataset.role=h.type,h.type==="userMessage"&&N!==R&&(oe.title=R.split(`
184
+ `,1)[0]);let de=document.createElement("b");if(de.textContent={userMessage:"你",agentMessage:"Copilot",commandExecution:"命令执行"}[h.type],h.type==="commandExecution"){let De=document.createElement("details"),Ae=document.createElement("summary");Ae.textContent=h.command||"执行详情",Ae.title=Ae.textContent;let cn=document.createElement("pre");cn.className="message-body",De.append(Ae,cn),oe.append(de,De)}else{let De=document.createElement(h.type==="agentMessage"?"div":"pre");De.className=h.type==="agentMessage"?"message-body markdown":"message-body",oe.append(de,De)}Pe.set(h.id,oe),c("messages").append(oe)}let X=oe.querySelector(".message-body");h.type==="agentMessage"?an(X,N):X.textContent=N,se&&(K.scrollTop=K.scrollHeight)}function sn(h,R){if(Pe.has(h))return;let N=`stream-${h}`;Ue.set(N,(Ue.get(N)||"")+R),Q===null&&(Q=setTimeout(()=>{Q=null;for(let[K,se]of Ue)Me({id:K,type:"agentMessage",text:se})},80))}async function Be(){let h=await b.api(`/api/conversations?connectionId=${y.id}`);A=h,Te?.update(),c("conversation-title").textContent=h.find(R=>R.id===E)?.title||"新对话",c("conversation-title").title=c("conversation-title").textContent}async function ln(h){let R=await b.api(`/api/conversations/${h}/history`,{signal:H.signal});if(h!==E)return;for(let K of[...R.data||R.turns||[]].reverse())for(let se of K.items||[])Me(se);let N=(R.data||R.turns||[])[0];return N&&(_=N.status==="inProgress"),R.eventSequence||0}async function Ut(h,R,N=0){for(;!O&&R===q&&!H.signal.aborted;)try{let K=await b.api(`/api/conversations/${h}/events?after=${N}`,{signal:H.signal});if(R!==q)return;for(let se of K){N=se.sequence;let{method:oe,params:X={},id:de}=se.message;de!==void 0&&oe&&Z(`Codex 需要交互:${oe}。此简版暂不支持该交互。`,!0),oe==="item/agentMessage/delta"&&(Z("Copilot 正在回复…"),sn(X.itemId,X.delta)),oe==="item/completed"&&(Pe.get(`stream-${X.item.id}`)?.remove(),Pe.delete(`stream-${X.item.id}`),Ue.delete(`stream-${X.item.id}`),Me(X.item)),oe==="turn/started"&&(_=!0,J()),oe==="turn/completed"&&(_=Ce,Ce||(qe=!1),J(),Z(Ce?"正在确认远程命令已停止…":X.turn.status==="completed"?`已完成 · ${y.display}`:X.turn.status==="interrupted"?"已停止,可以继续对话":`对话状态:${X.turn.status}`,X.turn.status==="failed")),oe==="error"&&Z(X.error?.message||"Codex 执行失败",!0)}K.length===0&&await new Promise(se=>setTimeout(se,500))}catch(K){if(R!==q||K.name==="AbortError")return;Z(`事件连接中断:${K.message}。请点击刷新读取历史。`,!0),_=!1,J();return}}async function me(h){Le();let R=q;F=!0,E=h,Pe.clear(),Ue.clear(),c("messages").replaceChildren(),c("conversation-title").textContent=A.find(N=>N.id===h)?.title||"新对话",!h&&v&&(c("model").value=v.defaultModel,Ne()),_=!1,J();try{if(!h||(await ye(),R!==q))return;H=new AbortController;let N=await b.api(`/api/conversations/${h}`);if(R!==q)return;if(N.connectionId!==y.id)throw new Error("此对话属于其他 BI 环境或账号");ft(N.model||v?.defaultModel||""),Ne(N.reasoningEffort),_=["running","unknown"].includes(N.status),J();let K=N.status!=="idle"?await ln(h):0;R===q&&Ut(h,R,K)}finally{R===q&&(F=!1,J())}}async function ye(){let h=b,R=y;try{await h.refresh()}catch(N){throw b===h&&y===R&&Ee(N),N}}function ke(){let h=I?.state==="denied";if(M?.bypassesPageNetworkPolicy){c("connect").textContent="连接本机助手",c("setup-hint").textContent="通过 Chrome 扩展连接本机助手,无需打开连接窗口。请确认本机服务已启动。",c("access-help").hidden=!0;return}c("connect").textContent=M?.required?"打开本机连接窗口":h?"检查授权并重连":"连接本机助手",c("setup-hint").textContent=M?.required?"通过本机连接窗口通信,请保持该窗口打开并返回应用页面。":h?"Chrome 已阻止本机访问。展开下方指引恢复授权后,点击重连。":"首次连接时,请在浏览器弹窗中选择「允许」。仅连接你配置的 guanloop 后台。",c("access-help").hidden=M?.required||!h}function Tt(){if(M?.bypassesPageNetworkPolicy||M?.required){I?.dispose(),I=null,P=!0,ke();return}I?.dispose(),P=!1;let h=to({navigator:globalThis.navigator,address:m,signal:$e.signal,onChange:R=>{I!==h||O||(ke(),R==="denied"&&(P=!1,Le(),it(!1),c("setup").hidden=!1),R==="granted"&&(P=!0,!y&&!T&&Fe()))}});I=h,ke(),h.check()}async function Fe(h=!1){if(T)return;if(!h&&M?.required&&!M.opened){ke();return}if(h&&M?.required)try{M.open()}catch(X){W(X);return}if(!h&&I?.state!=="granted"&&!P){ke();return}if(I?.state==="denied"){let X=I;if(await X.check(),X!==I||O||T)return;if(X.state==="denied"){ke(),Z("浏览器已拒绝本机访问,请按上方指引恢复授权后重连。",!0);return}}P=!0,xe.reset(),Te?.reset();let R=y,N=we,K=We.linked(),se=E;T=!0;let oe=++he;c("connect").disabled=!0,Le(),y=null,A=[],Te.update(),L=!1,c("setup").hidden=!1,c("messages").replaceChildren(),Pe.clear(),Ue.clear(),ee(),J(),Z(M?.required?"正在连接本机窗口…窗口就绪后请返回 BI 页面。":"正在连接本机助手…浏览器若弹出本机访问授权,请选择「允许」。");try{(V||re)&&await Je(),re&&(await rt,b=ot(),re=!1);let X=b,de=await b.health();if(O||oe!==he||X!==b)return;if(i.requiresBrowserTools&&(de.applicationConnectionsProtocol!==1||de.browserToolsProtocol!==1))throw new Error(`${i.manifest.name} 需要新版 guancopilot,请更新本机后台后重试`);if(y=await b.connect(),we=y,O||oe!==he||X!==b)return;if(Qe=!i.requiresBrowserTools,i.requiresBrowserTools&&de.browserToolsProtocol===1){let De=new bn({document,api:b,manifest:i.manifest,connectionId:y.id,tools:G.tools(y),onStatus:Ae=>{V!==De||O||(Ae.terminal&&(Qe=!1,c("setup").hidden=!1,J()),Ae.state==="error"&&Z(Ae.message,!0),Ae.state==="waiting"&&Z(Ae.message))}});if(V=De,await De.start(),O||oe!==he||X!==b)return;Qe=!0}K&&N?.id===we.id&&(y=R),We.connect(),E="",c("setup").hidden=!0,c("messages").replaceChildren(),await Be(),ee(),Z("正在读取 Codex 可用模型…"),await At(),Z(`已连接 ${y.display} · ${y.site}`),se&&R?.principal===y.principal&&R?.site===y.site&&R?.domId===y.domId&&await me(se),J()}catch(X){if(O||oe!==he)return;if(await Je(),y=null,Te.update(),c("setup").hidden=!1,!X.status&&X.name==="TypeError"){let de=I;if(await de?.check(),de!==I||O)return;de?.state!=="granted"&&!M?.opened&&!M?.bypassesPageNetworkPolicy&&(P=!1),(M?.opened||M?.bypassesPageNetworkPolicy)&&(ne=!1),ke(),M?.required?Z(X.message,!0):M?.bypassesPageNetworkPolicy?Z("连接暂不可用,扩展将自动重试。请确认本机服务和当前应用页面可用。",!0):de?.state==="denied"?Z("浏览器已拒绝本机访问,请按上方指引恢复授权后重连。",!0):Z("未能连接 guanloop。请确认本机已运行 guancopilot;若浏览器显示授权弹窗,请选择「允许」后重试。",!0)}else W(X)}finally{T=!1,c("connect").disabled=!1,J()}}function ot(){let h=m,R=g,N=M||eo(globalThis,h,{signal:$e.signal,forceWindow:i.requiresWindowBridge,onClosed:()=>{M===N&&!O&&(P=!1,it(!1),Le(),c("setup").hidden=!1,Z("本机连接窗口已关闭,请点击上方按钮重新打开。",!0))}});M=N;let K=i.session(()=>{G===K&&Ee(new Error(`${i.manifest.name} 登录会话已变化`))});return G=K,K.client({fetch:N.fetch,baseUrl:h,pairingCode:R,active:()=>!O&&h===m&&R===g,onLocalStatus:se=>{h===m&&R===g&&it(se)}})}function ft(h){h&&![...c("model").options].some(R=>R.value===h)&&c("model").add(new Option(`${h}(历史模型)`,h)),c("model").value=h}function Ne(h=""){c("effort").replaceChildren();for(let R of Sn(v,c("model").value))c("effort").add(new Option(An[R],R));c("effort").options.length||c("effort").add(new Option("自动","")),c("effort").value=no(v,c("model").value,h)}async function At(){L=!1,J();try{v=await b.api("/api/models",{timeout:4e4}),c("model").replaceChildren();for(let h of v.data)c("model").add(new Option(`${h.displayName||h.model}${h.model===v.defaultModel?" · 桌面默认":""}`,h.model));ft(A.find(h=>h.id===E)?.model||v.defaultModel),Ne(A.find(h=>h.id===E)?.reasoningEffort),c("model").title=`默认模型配置:${v.configSource}
185
+ 桌面默认:${v.defaultModel}${v.defaultReasoningEffort?" · "+v.defaultReasoningEffort:""}`,L=!0}finally{J()}}async function ht(h){if(h&&Ne(),!E){J();return}let R=c("model").value,N=c("effort").value;F=!0,J();try{await ye(),await b.api(`/api/conversations/${E}`,{method:"PUT",body:{model:R,reasoningEffort:N}}),await Be(),Z(`对话设置已更新:${R} · ${An[N]||"自动"}`)}catch(K){ft(A.find(se=>se.id===E)?.model||v?.defaultModel||""),Ne(A.find(se=>se.id===E)?.reasoningEffort),W(K)}finally{F=!1,J()}}c("model").onchange=()=>ht(!0),c("effort").onchange=()=>ht(!1);let mt=Wi(f,{client:()=>b,connection:()=>y,selected:()=>E,busy:()=>_||U||F,select:me,updated:async()=>{await Be(),A.find(R=>R.id===E)?.archived&&await me("")}}),Te=Xi(f,{client:()=>b,connection:()=>y,conversations:()=>A,refreshCredential:ye,active:()=>!O&&p()}),xe=Vi(f,{client:()=>b,connection:()=>y,connected:()=>te,refreshCredential:ye,active:()=>!O&&p()&&!c("settings").hidden&&!c("panel").hidden});async function St(h){Le(),he++,xe.reset(),Te.reset(),y=h,E="",A=[],F=!1,Pe.clear(),Ue.clear(),c("messages").replaceChildren(),c("conversation-title").textContent="新对话",mt.invalidate(),await Be(),ee(),J()}let We=Fr(f,{manifest:i.manifest,source:()=>we,client:()=>b,idle:()=>!O&&!_&&!U&&!F&&!T&&te&&Te.idle(),assertCurrent:()=>G?.assertCurrent(),signal:$e.signal,linked:async h=>{await St(h),Z("已关联到独立工作区:官方查询与浏览器元数据分开路由,身份未合并")},unlinked:async()=>{await St(we),Z("已返回原浏览器会话,关联工作区未与其合并")},failed:W});c("history-button").addEventListener("click",()=>xe.reset()),c("workspace-tabs").addEventListener("click",()=>xe.reset());function Ye(){let h=!1;try{h=Wt(c("backend-address").value)}catch{}c("pairing-hint").textContent=h?"(远程地址必填)":"(仅服务启用 --expose 时需要)",c("pairing-code").required=h,c("transport-hint").hidden=!h}function et(){_||U||F||T||(mt.close(),xe.reset(),c("backend-address").value=m,c("pairing-code").value=g,c("settings-error").textContent="",c("settings").hidden=!1,Ye())}c("settings-button").onclick=et,c("backend").onclick=et,c("settings-close").onclick=()=>{xe.reset(),c("settings").hidden=!0,c("settings-button").focus()},c("backend-address").oninput=Ye,c("settings-form").onsubmit=async h=>{if(h.preventDefault(),!(_||U||F||T))try{let R=Pt(c("backend-address").value),N=c("pairing-code").value.trim();if(Wt(R)&&!N)throw new Error("远程地址必须填写 pairing code");if(M?.bypassesPageNetworkPolicy&&R!==m){try{localStorage.setItem("guanloop.backend",R)}catch{}throw new Error("后台地址已保存,请从 Chrome 工具栏重新注入 GuanCopilot 以连接新地址。")}await Et(!0),Le(),mt.invalidate(),xe.reset(),Te?.reset(),M?.dispose(),M=null,m=R,g=N,re=!1;try{localStorage.setItem("guanloop.backend",m)}catch{}b=ot(),Tt(),y=null,E="",v=null,L=!1,it(!1),ne=null,c("setup").hidden=!1,c("messages").replaceChildren(),Pe.clear(),Ue.clear(),c("conversation-title").textContent="新对话",c("settings-form").setAttribute("aria-busy","true"),await Fe(!0),y&&L?c("settings").hidden=!0:c("settings-error").textContent=c("status").textContent}catch(R){c("settings-error").textContent=R.message}finally{c("settings-form").removeAttribute("aria-busy"),J()}},c("connect").addEventListener("click",()=>{Fe(!0)});function Xe(){let h=c("prompt");h.style.height="auto",h.style.height=`${Math.min(126,Math.max(36,h.scrollHeight))}px`}c("prompt").addEventListener("input",Xe),c("prompt").addEventListener("keydown",h=>{h.key==="Enter"&&!h.shiftKey&&!h.isComposing&&h.keyCode!==229&&(h.preventDefault(),h.stopPropagation(),c("send").disabled||c("compose").requestSubmit())}),c("compose").addEventListener("submit",async h=>{h.preventDefault();let R=c("prompt").value.trim();if(!(!y||!L||_||U||F||!R)){U=!0,qe=Ce=!1,_=!0,J();try{if(await ye(),qe){_=!1,Z("已停止,消息尚未发送");return}if(E){let N=A.find(K=>K.id===E);(N?.model!==c("model").value||(N?.reasoningEffort||"")!==c("effort").value)&&(await b.api(`/api/conversations/${E}`,{method:"PUT",body:{model:c("model").value,reasoningEffort:c("effort").value}}),await Be())}else{let N=await b.api("/api/conversations",{method:"POST",body:{connectionId:y.id,title:R.slice(0,40),model:c("model").value,reasoningEffort:c("effort").value}});await Be(),await me(N.id)}if(qe){_=!1,Z("已停止,消息尚未发送");return}_=!0,J(),Z("已提交给本地 Codex…"),vt=!0,await b.api(`/api/conversations/${E}/messages`,{method:"POST",body:{clientMessageId:Ze(),text:`当前 BI 页面:${location.origin}${location.pathname}
186
+
187
+ ${R}`}}),c("prompt").value="",Xe()}catch(N){N.submissionStatus==="not_submitted"||!vt?(_=!1,Z(qe?"已停止,消息尚未发送":`消息尚未发送:${N.message}。可以重试,草稿已保留。`,!qe)):y&&E?(Z(`提交状态需确认:${N.message}。请刷新历史后再操作。`,!0),_=!0):(_=!1,J(),W(N))}finally{U=!1,vt=!1,_||(Ce=!1),J(),_&&c("status").dataset.error==="true"&&(c("refresh").disabled=!1)}}}),c("stop").addEventListener("click",async()=>{if(!(!E||Ce)&&(qe=Ce=!0,Z("正在停止…"),J(),!(U&&!vt)))try{await b.api(`/api/conversations/${E}/interrupt`,{method:"POST"}),_=Ce=qe=!1,J(),Z("已停止,可以继续对话")}catch(h){Ce=!1,_=!0,J(),c("refresh").disabled=!1,W(h)}}),c("new").addEventListener("click",()=>me("").catch(W)),c("refresh").addEventListener("click",async()=>{try{await ye(),await Be(),await me(E)}catch(h){W(h)}});let at=c("launcher");function It(){O||!p()||(st(),c("panel").hidden=!1,at.hidden=!0,!y&&!M?.required&&Fe(!0))}at.addEventListener("click",It),c("close").addEventListener("click",()=>{xe.reset(),c("panel").hidden=!0,at.hidden=!1}),a.addEventListener("guancopilot-open",()=>{d=!0,at.remove(),It()},{signal:$e.signal});let gt=p();function st(){let h=p();if(a.hidden=!h,h||xe.reset(),y&&h)try{G?.assertCurrent()}catch(R){Ee(R)}ee(),!h&&H&&Le(),h&&!gt&&y&&E&&me(E).catch(W),h&&!gt&&!y&&Fe(),gt=h}function Bt(){Et(i.requiresBrowserTools&&!We.linked()),We.reset(),he++,xe.reset(),Te.reset(),I?.dispose(),M?.dispose(),O=!0,Le(),clearInterval(C),clearInterval($),clearInterval(Rt),clearTimeout(Q),$e.abort(),a.remove(),b=y=null}a.addEventListener("guancopilot-dispose",Bt,{once:!0}),i.subscribeRoute(st,$e.signal),globalThis.addEventListener("popstate",st,{signal:$e.signal}),globalThis.addEventListener("pagehide",()=>{V?.pagehide(),Bt()},{signal:$e.signal});let Rt=setInterval(st,750);b=ot(),Tt(),$=setInterval(async()=>{if(S||O||!P||I?.state==="denied"||!p())return;S=!0;let h=ne,R=b;try{if(await R.health(),R!==b)return;ne=!0,(h===!1||h===null&&!y)&&Fe()}catch{R===b&&(ne=!1)}finally{S=!1}},5e3),C=setInterval(()=>{y&&P&&I?.state!=="denied"&&p()&&document.visibilityState==="visible"&&ye().catch(()=>{})},6e4),document.body.append(a),st(),J(),gt&&Z("点击打开 Copilot 并连接,在浏览器授权弹窗中选择「允许」。"),n&&(at.remove(),It())}document.body?ur():document.addEventListener("DOMContentLoaded",()=>ur(),{once:!0});})();
158
188
  /*! Bundled license information:
159
189
 
160
190
  dompurify/dist/purify.es.mjs: