@tablestore/tablestore-agent-cli 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard-runtime/dashboard/.next/BUILD_ID +1 -1
- package/dist/dashboard-runtime/dashboard/.next/build-manifest.json +3 -3
- package/dist/dashboard-runtime/dashboard/.next/prerender-manifest.json +3 -3
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/chat/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/chat/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/documents/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/documents/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/qa/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/qa/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/retrieval/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/retrieval/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/settings/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/[name]/settings/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/create/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/knowledge-base/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/[id]/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/new/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/llm-providers/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/messages/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/messages/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/requests/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/requests/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/search/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/search/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/settings/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/settings/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/units/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/[store]/units/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/create/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/memory/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/projects/page.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/(dashboard)/projects/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.html +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.html +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/api/v1/knowledge-bases/[name]/documents/upload/route.js.nft.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/index.html +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/index.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.html +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.rsc +3 -3
- package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_full.segment.rsc +3 -3
- package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_head.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_index.segment.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/_tree.segment.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/onboarding/__PAGE__.segment.rsc +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/app/onboarding.segments/onboarding.segment.rsc +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/0b1r_app_(dashboard)_knowledge-base_[name]_documents_documents-client_tsx_0g2uxmt._.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__09_30hi._.js +3 -0
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0kaiok7._.js +3 -0
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0l937k4._.js +3 -0
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0-dlo4s._.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_01pp~xx._.js +3 -0
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/{_0476v7r._.js → _08j6p-z._.js} +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/{_0ct0n55._.js → _09eom0_._.js} +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/{_0mzxmfh._.js → _0f-may2._.js} +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0fp_nnb._.js +3 -0
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0l6jz-5._.js +3 -0
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/{_0fg6iap._.js → _0ntv66s._.js} +2 -2
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0sc0tpz._.js +3 -0
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0tyxwr3._.js +3 -0
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0u9md36._.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_065m1.j._.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/dashboard_src_app_(dashboard)_knowledge-base_[name]_layout-client_tsx_05momc5._.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/middleware-build-manifest.js +3 -3
- package/dist/dashboard-runtime/dashboard/.next/server/pages/404.html +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/pages/500.html +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/server-reference-manifest.js +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/server-reference-manifest.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0-xqk6wfme5fu.js +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0ltmkqogn8g3t.js → 00.fyg_t3xjc~.js} +1 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/01k-.wkndubwy.js +138 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/07r22x5uhjxjb.js +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0cbu3udngtx-v.js +4 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0h7d69g2fdgs6.js +138 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0iv0g360z0ja5.js +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0jf4ytf.izmzh.js +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/{17nx_vdk_qemm.js → 0m42mmyxmgn-i.js} +1 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0odz1whf-ozqn.css +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0ouxv_2qvf6.9.js +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0rbkgj._oqsb3.js +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0u6u.649ou67b.js +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0vf7~eysvh9bq.js +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/{09qsmnfvk8dm3.js → 0wmaq.ay~r2sn.js} +1 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0i5aqiffpm9jr.js → 0xb0_9t-vmo6e.js} +1 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0yp_2ea75d19v.js +1 -0
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/{0s3mvx9_dr13c.js → 11cizim1aug~b.js} +1 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/13-2ei295hl0-.js +1 -0
- package/dist/dashboard-runtime/dashboard/src/app/(dashboard)/knowledge-base/[name]/qa/page.tsx +23 -1
- package/dist/dashboard-runtime/dashboard/src/components/chat/chat-mount-config.tsx +29 -8
- package/dist/dashboard-runtime/dashboard/src/components/documents/doc-upload-dialog.tsx +370 -91
- package/dist/dashboard-runtime/dashboard/src/components/knowledge-base/kb-card.tsx +8 -5
- package/dist/dashboard-runtime/dashboard/src/components/knowledge-base/kb-header.tsx +23 -13
- package/dist/dashboard-runtime/dashboard/src/components/memory/memory-header.tsx +8 -12
- package/dist/dashboard-runtime/dashboard/src/components/qa/qa-chat-panel.tsx +45 -4
- package/dist/dashboard-runtime/dashboard/src/components/qa/qa-message.tsx +636 -36
- package/dist/dashboard-runtime/dashboard/src/components/shared/confirm-dialog.tsx +8 -1
- package/dist/dashboard-runtime/dashboard/src/components/shared/refresh-button.tsx +102 -86
- package/dist/dashboard-runtime/dashboard/src/hooks/use-qa-chat.ts +261 -58
- package/dist/dashboard-runtime/dashboard/src/lib/chat-message-ops.ts +76 -0
- package/dist/dashboard-runtime/dashboard/src/lib/dev-flags.ts +24 -0
- package/dist/dashboard-runtime/dashboard/src/types/llm-chat.ts +19 -0
- package/package.json +1 -1
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0i0y9.r._.js +0 -3
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0r_6wpx._.js +0 -3
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/[root-of-the-server]__0y8rrcu._.js +0 -3
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_02e0c00._.js +0 -3
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0doczxg._.js +0 -3
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0e9y.xc._.js +0 -3
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0ti~om_._.js +0 -3
- package/dist/dashboard-runtime/dashboard/.next/server/chunks/ssr/_0~s~e-0._.js +0 -3
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/055_bo6_3nt-s.js +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/07l4dodn5t6l4.js +0 -4
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0a5ass8u78k90.js +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0j~63ld9lbb25.js +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0l6znnjqw.4yw.js +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0o-c2g8y5pw-c.js +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0o0i2ke2jbdvq.js +0 -138
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0prl6hk4v0k3i.js +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0u2lo2lzizxy_.js +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/0v.hno.6q74nn.css +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/14ti2gx~1fiub.js +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/14vqmdm7sosj2.js +0 -1
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/17h~onnkksf44.js +0 -138
- package/dist/dashboard-runtime/dashboard/.next/static/chunks/186jubvt5xyuj.js +0 -1
- /package/dist/dashboard-runtime/dashboard/.next/static/{MjeKF5uLzEvAqWkR9O6Ts → BGnMIk4OPjFx_qvLFMTBc}/_buildManifest.js +0 -0
- /package/dist/dashboard-runtime/dashboard/.next/static/{MjeKF5uLzEvAqWkR9O6Ts → BGnMIk4OPjFx_qvLFMTBc}/_clientMiddlewareManifest.js +0 -0
- /package/dist/dashboard-runtime/dashboard/.next/static/{MjeKF5uLzEvAqWkR9O6Ts → BGnMIk4OPjFx_qvLFMTBc}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,20688,(e,t,r)=>{var n={675:function(e,t){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],n=t[1];return(r+n)*3/4-n},t.toByteArray=function(e){var t,r,a=l(e),s=a[0],o=a[1],u=new i((s+o)*3/4-o),c=0,d=o>0?s-4:s;for(r=0;r<d;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],u[c++]=t>>16&255,u[c++]=t>>8&255,u[c++]=255&t;return 2===o&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[c++]=255&t),1===o&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,a=[],s=0,o=n-i;s<o;s+=16383)a.push(function(e,t,n){for(var i,a=[],s=t;s<n;s+=3)i=(e[s]<<16&0xff0000)+(e[s+1]<<8&65280)+(255&e[s+2]),a.push(r[i>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return a.join("")}(e,s,s+16383>o?o:s+16383));return 1===i?a.push(r[(t=e[n-1])>>2]+r[t<<4&63]+"=="):2===i&&a.push(r[(t=(e[n-2]<<8)+e[n-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),a.join("")};for(var r=[],n=[],i="u">typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,o=a.length;s<o;++s)r[s]=a[s],n[a.charCodeAt(s)]=s;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var n=r===t?0:4-r%4;return[r,n]}n[45]=62,n[95]=63},72:function(e,t,r){"use strict";var n=r(675),i=r(783),a="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function s(e){if(e>0x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return c(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var n=e,i=t;if(("string"!=typeof i||""===i)&&(i="utf8"),!o.isEncoding(i))throw TypeError("Unknown encoding: "+i);var a=0|h(n,i),l=s(a),u=l.write(n,i);return u!==a&&(l=l.slice(0,u)),l}if(ArrayBuffer.isView(e))return d(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(I(e,ArrayBuffer)||e&&I(e.buffer,ArrayBuffer)||"u">typeof SharedArrayBuffer&&(I(e,SharedArrayBuffer)||e&&I(e.buffer,SharedArrayBuffer)))return function(e,t,r){var n;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),o.prototype),n}(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var c=e.valueOf&&e.valueOf();if(null!=c&&c!==e)return o.from(c,t,r);var f=function(e){if(o.isBuffer(e)){var t=0|p(e.length),r=s(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||function(e){return e!=e}(e.length)?s(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}(e);if(f)return f;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function c(e){return u(e),s(e<0?0:0|p(e))}function d(e){for(var t=e.length<0?0:0|p(e.length),r=s(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}t.Buffer=o,t.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=0x7fffffff,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),!o.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,r){return(u(e),e<=0)?s(e):void 0!==t?"string"==typeof r?s(e).fill(t,r):s(e).fill(t):s(e)},o.allocUnsafe=function(e){return c(e)},o.allocUnsafeSlow=function(e){return c(e)};function p(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function h(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||I(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return C(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return N(e).length;default:if(i)return n?-1:C(e).length;t=(""+t).toLowerCase(),i=!0}}function f(e,t,r){var i,a,s,o=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",a=t;a<r;++a)i+=L[e[a]];return i}(this,t,r);case"utf8":case"utf-8":return b(this,t,r);case"ascii":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}(this,t,r);case"latin1":case"binary":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}(this,t,r);case"base64":return i=this,a=t,s=r,0===a&&s===i.length?n.fromByteArray(i):n.fromByteArray(i.slice(a,s));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var n=e.slice(t,r),i="",a=0;a<n.length;a+=2)i+=String.fromCharCode(n[a]+256*n[a+1]);return i}(this,t,r);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,i){var a;if(0===e.length)return -1;if("string"==typeof r?(n=r,r=0):r>0x7fffffff?r=0x7fffffff:r<-0x80000000&&(r=-0x80000000),(a=r*=1)!=a&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length)if(i)return -1;else r=e.length-1;else if(r<0)if(!i)return -1;else r=0;if("string"==typeof t&&(t=o.from(t,n)),o.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t){if(t&=255,"function"==typeof Uint8Array.prototype.indexOf)if(i)return Uint8Array.prototype.indexOf.call(e,t,r);else return Uint8Array.prototype.lastIndexOf.call(e,t,r);return y(e,[t],r,n,i)}throw TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var a,s=1,o=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return -1;s=2,o/=2,l/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(a=r;a<o;a++)if(u(e,a)===u(t,-1===c?0:a-c)){if(-1===c&&(c=a),a-c+1===l)return c*s}else -1!==c&&(a-=a-c),c=-1}else for(r+l>o&&(r=o-l),a=r;a>=0;a--){for(var d=!0,p=0;p<l;p++)if(u(e,a+p)!==u(t,p)){d=!1;break}if(d)return a}return -1}o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(I(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),I(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i<a;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:+(n<r)},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,n=o.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var a=e[r];if(I(a,Uint8Array)&&(a=o.from(a)),!o.isBuffer(a))throw TypeError('"list" argument must be an Array of Buffers');a.copy(n,i),i+=a.length}return n},o.byteLength=h,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)m(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},o.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},o.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?b(this,0,e):f.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},a&&(o.prototype[a]=o.prototype.inspect),o.prototype.compare=function(e,t,r,n,i){if(I(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var a=i-n,s=r-t,l=Math.min(a,s),u=this.slice(n,i),c=e.slice(t,r),d=0;d<l;++d)if(u[d]!==c[d]){a=u[d],s=c[d];break}return a<s?-1:+(s<a)},o.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)};function b(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var a,s,o,l,u=e[i],c=null,d=u>239?4:u>223?3:u>191?2:1;if(i+d<=r)switch(d){case 1:u<128&&(c=u);break;case 2:(192&(a=e[i+1]))==128&&(l=(31&u)<<6|63&a)>127&&(c=l);break;case 3:a=e[i+1],s=e[i+2],(192&a)==128&&(192&s)==128&&(l=(15&u)<<12|(63&a)<<6|63&s)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:a=e[i+1],s=e[i+2],o=e[i+3],(192&a)==128&&(192&s)==128&&(192&o)==128&&(l=(15&u)<<18|(63&a)<<12|(63&s)<<6|63&o)>65535&&l<1114112&&(c=l)}null===c?(c=65533,d=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=d}var p=n,h=p.length;if(h<=4096)return String.fromCharCode.apply(String,p);for(var f="",m=0;m<h;)f+=String.fromCharCode.apply(String,p.slice(m,m+=4096));return f}function w(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function x(e,t,r,n,i,a){if(!o.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<a)throw RangeError('"value" argument is out of bounds');if(r+n>e.length)throw RangeError("Index out of range")}function v(e,t,r,n,i,a){if(r+n>e.length||r<0)throw RangeError("Index out of range")}function A(e,t,r,n,a){return t*=1,r>>>=0,a||v(e,t,r,4,34028234663852886e22,-34028234663852886e22),i.write(e,t,r,n,23,4),r+4}function _(e,t,r,n,a){return t*=1,r>>>=0,a||v(e,t,r,8,17976931348623157e292,-17976931348623157e292),i.write(e,t,r,n,52,8),r+8}o.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,a,s,o,l,u,c,d,p=this.length-t;if((void 0===r||r>p)&&(r=p),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var h=!1;;)switch(n){case"hex":return function(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var a=t.length;n>a/2&&(n=a/2);for(var s=0;s<n;++s){var o,l=parseInt(t.substr(2*s,2),16);if((o=l)!=o)break;e[r+s]=l}return s}(this,e,t,r);case"utf8":case"utf-8":return i=t,a=r,E(C(e,this.length-i),this,i,a);case"ascii":return s=t,o=r,E(S(e),this,s,o);case"latin1":case"binary":return function(e,t,r,n){return E(S(t),e,r,n)}(this,e,t,r);case"base64":return l=t,u=r,E(N(e),this,l,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return c=t,d=r,E(function(e,t){for(var r,n,i=[],a=0;a<e.length&&!((t-=2)<0);++a)n=(r=e.charCodeAt(a))>>8,i.push(r%256),i.push(n);return i}(e,this.length-c),this,c,d);default:if(h)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),h=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,o.prototype),n},o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e],i=1,a=0;++a<t&&(i*=256);)n+=this[e+a]*i;return n},o.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},o.prototype.readUInt8=function(e,t){return e>>>=0,t||w(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e],i=1,a=0;++a<t&&(i*=256);)n+=this[e+a]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},o.prototype.readInt8=function(e,t){return(e>>>=0,t||w(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||w(e,4,this.length),i.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||w(e,4,this.length),i.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||w(e,8,this.length),i.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||w(e,8,this.length),i.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;x(this,e,t,r,i,0)}var a=1,s=0;for(this[t]=255&e;++s<r&&(a*=256);)this[t+s]=e/a&255;return t+r},o.prototype.writeUIntBE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;x(this,e,t,r,i,0)}var a=r-1,s=1;for(this[t+a]=255&e;--a>=0&&(s*=256);)this[t+a]=e/s&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,4,0xffffffff,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,4,0xffffffff,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeIntLE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var i=Math.pow(2,8*r-1);x(this,e,t,r,i-1,-i)}var a=0,s=1,o=0;for(this[t]=255&e;++a<r&&(s*=256);)e<0&&0===o&&0!==this[t+a-1]&&(o=1),this[t+a]=(e/s|0)-o&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var i=Math.pow(2,8*r-1);x(this,e,t,r,i-1,-i)}var a=r-1,s=1,o=0;for(this[t+a]=255&e;--a>=0&&(s*=256);)e<0&&0===o&&0!==this[t+a+1]&&(o=1),this[t+a]=(e/s|0)-o&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,4,0x7fffffff,-0x80000000),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||x(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeFloatLE=function(e,t,r){return A(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return A(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return _(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return _(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(!o.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var a=i-1;a>=0;--a)e[a+t]=this[a+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},o.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw TypeError("Unknown encoding: "+n);if(1===e.length){var i,a=e.charCodeAt(0);("utf8"===n&&a<128||"latin1"===n)&&(e=a)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=o.isBuffer(e)?e:o.from(e,n),l=s.length;if(0===l)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=s[i%l]}return this};var k=/[^+/0-9A-Za-z-_]/g;function C(e,t){t=t||1/0;for(var r,n=e.length,i=null,a=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319||s+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return a}function S(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function N(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(k,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function E(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length)&&!(i>=e.length);++i)t[i+r]=e[i];return i}function I(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var L=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)t[n+i]=e[r]+e[i];return t}()},783:function(e,t){t.read=function(e,t,r,n,i){var a,s,o=8*i-n-1,l=(1<<o)-1,u=l>>1,c=-7,d=r?i-1:0,p=r?-1:1,h=e[t+d];for(d+=p,a=h&(1<<-c)-1,h>>=-c,c+=o;c>0;a=256*a+e[t+d],d+=p,c-=8);for(s=a&(1<<-c)-1,a>>=-c,c+=n;c>0;s=256*s+e[t+d],d+=p,c-=8);if(0===a)a=1-u;else{if(a===l)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),a-=u}return(h?-1:1)*s*Math.pow(2,a-n)},t.write=function(e,t,r,n,i,a){var s,o,l,u=8*a-i-1,c=(1<<u)-1,d=c>>1,p=5960464477539062e-23*(23===i),h=n?0:a-1,f=n?1:-1,m=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(o=+!!isNaN(t),s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+d>=1?t+=p/l:t+=p*Math.pow(2,1-d),t*l>=2&&(s++,l/=2),s+d>=c?(o=0,s=c):s+d>=1?(o=(t*l-1)*Math.pow(2,i),s+=d):(o=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=255&o,h+=f,o/=256,i-=8);for(s=s<<i|o,u+=i;u>0;e[r+h]=255&s,h+=f,s/=256,u-=8);e[r+h-f]|=128*m}}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}},s=!0;try{n[e](r,r.exports,a),s=!1}finally{s&&delete i[e]}return r.exports}a.ab="/ROOT/node_modules/.pnpm/next@16.2.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/next/dist/compiled/buffer/",t.exports=a(72)},21122,50657,51024,9012,e=>{"use strict";let t,r,n,i,a;var s,o,l,u=e.i(44501),c=e.i(17635),d=e.i(37769),p=e.i(86620);let h=(0,p.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),f=(0,p.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);var m=e.i(42595),g=e.i(45123),y=e.i(99877),b=e.i(76490);let w=(0,p.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);var x=e.i(9823);let v=(0,p.default)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);var A=e.i(18722),_=e.i(20268),k=e.i(82652),C=e.i(33153),S=e.i(83823),N=e.i(96416),E=e.i(30363),I=e.i(87014),L=e.i(63630),P=e.i(64209),R=e.i(12251);let $=[{id:"abap",name:"ABAP",import:()=>e.A(81107)},{id:"actionscript-3",name:"ActionScript",import:()=>e.A(63750)},{id:"ada",name:"Ada",import:()=>e.A(91813)},{id:"angular-html",name:"Angular HTML",import:()=>e.A(56500)},{id:"angular-ts",name:"Angular TypeScript",import:()=>e.A(16569)},{id:"apache",name:"Apache Conf",import:()=>e.A(34082)},{id:"apex",name:"Apex",import:()=>e.A(96050)},{id:"apl",name:"APL",import:()=>e.A(19847)},{id:"applescript",name:"AppleScript",import:()=>e.A(78893)},{id:"ara",name:"Ara",import:()=>e.A(73785)},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:()=>e.A(70789)},{id:"asm",name:"Assembly",import:()=>e.A(57041)},{id:"astro",name:"Astro",import:()=>e.A(77155)},{id:"awk",name:"AWK",import:()=>e.A(19686)},{id:"ballerina",name:"Ballerina",import:()=>e.A(4821)},{id:"bat",name:"Batch File",aliases:["batch"],import:()=>e.A(81214)},{id:"beancount",name:"Beancount",import:()=>e.A(7827)},{id:"berry",name:"Berry",aliases:["be"],import:()=>e.A(59139)},{id:"bibtex",name:"BibTeX",import:()=>e.A(2523)},{id:"bicep",name:"Bicep",import:()=>e.A(65206)},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:()=>e.A(20766)},{id:"blade",name:"Blade",import:()=>e.A(43021)},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:()=>e.A(590)},{id:"c",name:"C",import:()=>e.A(2328)},{id:"c3",name:"C3",import:()=>e.A(853)},{id:"cadence",name:"Cadence",aliases:["cdc"],import:()=>e.A(87209)},{id:"cairo",name:"Cairo",import:()=>e.A(82927)},{id:"clarity",name:"Clarity",import:()=>e.A(52460)},{id:"clojure",name:"Clojure",aliases:["clj"],import:()=>e.A(85623)},{id:"cmake",name:"CMake",import:()=>e.A(85367)},{id:"cobol",name:"COBOL",import:()=>e.A(93874)},{id:"codeowners",name:"CODEOWNERS",import:()=>e.A(81727)},{id:"codeql",name:"CodeQL",aliases:["ql"],import:()=>e.A(52172)},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:()=>e.A(67432)},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:()=>e.A(92185)},{id:"coq",name:"Coq",import:()=>e.A(83109)},{id:"cpp",name:"C++",aliases:["c++"],import:()=>e.A(63419)},{id:"crystal",name:"Crystal",import:()=>e.A(80210)},{id:"csharp",name:"C#",aliases:["c#","cs"],import:()=>e.A(37160)},{id:"css",name:"CSS",import:()=>e.A(35302)},{id:"csv",name:"CSV",import:()=>e.A(4163)},{id:"cue",name:"CUE",import:()=>e.A(2170)},{id:"cypher",name:"Cypher",aliases:["cql"],import:()=>e.A(59146)},{id:"d",name:"D",import:()=>e.A(53717)},{id:"dart",name:"Dart",import:()=>e.A(40194)},{id:"dax",name:"DAX",import:()=>e.A(96874)},{id:"desktop",name:"Desktop",import:()=>e.A(17925)},{id:"diff",name:"Diff",import:()=>e.A(58196)},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:()=>e.A(41274)},{id:"dotenv",name:"dotEnv",import:()=>e.A(169)},{id:"dream-maker",name:"Dream Maker",import:()=>e.A(86068)},{id:"edge",name:"Edge",import:()=>e.A(24716)},{id:"elixir",name:"Elixir",import:()=>e.A(62285)},{id:"elm",name:"Elm",import:()=>e.A(35711)},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:()=>e.A(70112)},{id:"erb",name:"ERB",import:()=>e.A(19341)},{id:"erlang",name:"Erlang",aliases:["erl"],import:()=>e.A(16686)},{id:"fennel",name:"Fennel",import:()=>e.A(6581)},{id:"fish",name:"Fish",import:()=>e.A(14037)},{id:"fluent",name:"Fluent",aliases:["ftl"],import:()=>e.A(35601)},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:()=>e.A(83987)},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:()=>e.A(6099)},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:()=>e.A(83499)},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:()=>e.A(87861)},{id:"gdscript",name:"GDScript",aliases:["gd"],import:()=>e.A(80083)},{id:"gdshader",name:"GDShader",import:()=>e.A(38264)},{id:"genie",name:"Genie",import:()=>e.A(7204)},{id:"gherkin",name:"Gherkin",import:()=>e.A(13549)},{id:"git-commit",name:"Git Commit Message",import:()=>e.A(97183)},{id:"git-rebase",name:"Git Rebase Message",import:()=>e.A(32046)},{id:"gleam",name:"Gleam",import:()=>e.A(7826)},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:()=>e.A(7076)},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:()=>e.A(25338)},{id:"glsl",name:"GLSL",import:()=>e.A(20366)},{id:"gn",name:"GN",import:()=>e.A(7005)},{id:"gnuplot",name:"Gnuplot",import:()=>e.A(9742)},{id:"go",name:"Go",import:()=>e.A(32961)},{id:"graphql",name:"GraphQL",aliases:["gql"],import:()=>e.A(28949)},{id:"groovy",name:"Groovy",import:()=>e.A(99953)},{id:"hack",name:"Hack",import:()=>e.A(94818)},{id:"haml",name:"Ruby Haml",import:()=>e.A(45962)},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:()=>e.A(54989)},{id:"haskell",name:"Haskell",aliases:["hs"],import:()=>e.A(19766)},{id:"haxe",name:"Haxe",import:()=>e.A(36800)},{id:"hcl",name:"HashiCorp HCL",import:()=>e.A(48226)},{id:"hjson",name:"Hjson",import:()=>e.A(82962)},{id:"hlsl",name:"HLSL",import:()=>e.A(44097)},{id:"html",name:"HTML",import:()=>e.A(63665)},{id:"html-derivative",name:"HTML (Derivative)",import:()=>e.A(94224)},{id:"http",name:"HTTP",import:()=>e.A(67513)},{id:"hurl",name:"Hurl",import:()=>e.A(81432)},{id:"hxml",name:"HXML",import:()=>e.A(62205)},{id:"hy",name:"Hy",import:()=>e.A(79622)},{id:"imba",name:"Imba",import:()=>e.A(92033)},{id:"ini",name:"INI",aliases:["properties"],import:()=>e.A(80261)},{id:"java",name:"Java",import:()=>e.A(44410)},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:()=>e.A(91941)},{id:"jinja",name:"Jinja",import:()=>e.A(61819)},{id:"jison",name:"Jison",import:()=>e.A(12957)},{id:"json",name:"JSON",import:()=>e.A(69035)},{id:"json5",name:"JSON5",import:()=>e.A(15864)},{id:"jsonc",name:"JSON with Comments",import:()=>e.A(61453)},{id:"jsonl",name:"JSON Lines",import:()=>e.A(27145)},{id:"jsonnet",name:"Jsonnet",import:()=>e.A(72102)},{id:"jssm",name:"JSSM",aliases:["fsl"],import:()=>e.A(61866)},{id:"jsx",name:"JSX",import:()=>e.A(47375)},{id:"julia",name:"Julia",aliases:["jl"],import:()=>e.A(79483)},{id:"just",name:"Just",import:()=>e.A(27549)},{id:"kdl",name:"KDL",import:()=>e.A(78226)},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:()=>e.A(89992)},{id:"kusto",name:"Kusto",aliases:["kql"],import:()=>e.A(96473)},{id:"latex",name:"LaTeX",import:()=>e.A(39084)},{id:"lean",name:"Lean 4",aliases:["lean4"],import:()=>e.A(87185)},{id:"less",name:"Less",import:()=>e.A(67110)},{id:"liquid",name:"Liquid",import:()=>e.A(77875)},{id:"llvm",name:"LLVM IR",import:()=>e.A(67140)},{id:"log",name:"Log file",import:()=>e.A(92086)},{id:"logo",name:"Logo",import:()=>e.A(96265)},{id:"lua",name:"Lua",import:()=>e.A(19030)},{id:"luau",name:"Luau",import:()=>e.A(56786)},{id:"make",name:"Makefile",aliases:["makefile"],import:()=>e.A(43167)},{id:"markdown",name:"Markdown",aliases:["md"],import:()=>e.A(90015)},{id:"marko",name:"Marko",import:()=>e.A(77121)},{id:"matlab",name:"MATLAB",import:()=>e.A(93408)},{id:"mdc",name:"MDC",import:()=>e.A(81294)},{id:"mdx",name:"MDX",import:()=>e.A(42248)},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:()=>e.A(18803)},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:()=>e.A(89643)},{id:"mojo",name:"Mojo",import:()=>e.A(29681)},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:()=>e.A(75864)},{id:"move",name:"Move",import:()=>e.A(1566)},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:()=>e.A(17849)},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:()=>e.A(68450)},{id:"nextflow-groovy",name:"nextflow-groovy",import:()=>e.A(44946)},{id:"nginx",name:"Nginx",import:()=>e.A(35471)},{id:"nim",name:"Nim",import:()=>e.A(24230)},{id:"nix",name:"Nix",import:()=>e.A(91052)},{id:"nushell",name:"nushell",aliases:["nu"],import:()=>e.A(40785)},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:()=>e.A(65479)},{id:"objective-cpp",name:"Objective-C++",import:()=>e.A(74546)},{id:"ocaml",name:"OCaml",import:()=>e.A(64834)},{id:"odin",name:"Odin",import:()=>e.A(91473)},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:()=>e.A(31836)},{id:"pascal",name:"Pascal",import:()=>e.A(86958)},{id:"perl",name:"Perl",import:()=>e.A(98959)},{id:"php",name:"PHP",import:()=>e.A(6721)},{id:"pkl",name:"Pkl",import:()=>e.A(98326)},{id:"plsql",name:"PL/SQL",import:()=>e.A(93909)},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:()=>e.A(19867)},{id:"polar",name:"Polar",import:()=>e.A(67362)},{id:"postcss",name:"PostCSS",import:()=>e.A(44583)},{id:"powerquery",name:"PowerQuery",import:()=>e.A(65129)},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:()=>e.A(69514)},{id:"prisma",name:"Prisma",import:()=>e.A(43874)},{id:"prolog",name:"Prolog",import:()=>e.A(65557)},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:()=>e.A(53316)},{id:"pug",name:"Pug",aliases:["jade"],import:()=>e.A(6098)},{id:"puppet",name:"Puppet",import:()=>e.A(32516)},{id:"purescript",name:"PureScript",import:()=>e.A(58805)},{id:"python",name:"Python",aliases:["py"],import:()=>e.A(86636)},{id:"qml",name:"QML",import:()=>e.A(48377)},{id:"qmldir",name:"QML Directory",import:()=>e.A(28449)},{id:"qss",name:"Qt Style Sheets",import:()=>e.A(80279)},{id:"r",name:"R",import:()=>e.A(74190)},{id:"racket",name:"Racket",import:()=>e.A(22166)},{id:"raku",name:"Raku",aliases:["perl6"],import:()=>e.A(43712)},{id:"razor",name:"ASP.NET Razor",import:()=>e.A(94256)},{id:"reg",name:"Windows Registry Script",import:()=>e.A(10369)},{id:"regexp",name:"RegExp",aliases:["regex"],import:()=>e.A(27379)},{id:"rel",name:"Rel",import:()=>e.A(62502)},{id:"riscv",name:"RISC-V",import:()=>e.A(36578)},{id:"ron",name:"RON",import:()=>e.A(34463)},{id:"rosmsg",name:"ROS Interface",import:()=>e.A(57616)},{id:"rst",name:"reStructuredText",import:()=>e.A(25130)},{id:"ruby",name:"Ruby",aliases:["rb"],import:()=>e.A(70562)},{id:"rust",name:"Rust",aliases:["rs"],import:()=>e.A(20768)},{id:"sas",name:"SAS",import:()=>e.A(93376)},{id:"sass",name:"Sass",import:()=>e.A(84802)},{id:"scala",name:"Scala",import:()=>e.A(87506)},{id:"scheme",name:"Scheme",import:()=>e.A(23504)},{id:"scss",name:"SCSS",import:()=>e.A(4006)},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:()=>e.A(31324)},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:()=>e.A(90222)},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:()=>e.A(17085)},{id:"shellsession",name:"Shell Session",aliases:["console"],import:()=>e.A(36141)},{id:"smalltalk",name:"Smalltalk",import:()=>e.A(73046)},{id:"solidity",name:"Solidity",import:()=>e.A(37320)},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:()=>e.A(12549)},{id:"sparql",name:"SPARQL",import:()=>e.A(55388)},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:()=>e.A(71559)},{id:"sql",name:"SQL",import:()=>e.A(62250)},{id:"ssh-config",name:"SSH Config",import:()=>e.A(79140)},{id:"stata",name:"Stata",import:()=>e.A(58405)},{id:"stylus",name:"Stylus",aliases:["styl"],import:()=>e.A(96543)},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:()=>e.A(13164)},{id:"svelte",name:"Svelte",import:()=>e.A(76180)},{id:"swift",name:"Swift",import:()=>e.A(83238)},{id:"system-verilog",name:"SystemVerilog",import:()=>e.A(20599)},{id:"systemd",name:"Systemd Units",import:()=>e.A(33838)},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:()=>e.A(24411)},{id:"tasl",name:"Tasl",import:()=>e.A(13935)},{id:"tcl",name:"Tcl",import:()=>e.A(20474)},{id:"templ",name:"Templ",import:()=>e.A(53318)},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:()=>e.A(79228)},{id:"tex",name:"TeX",import:()=>e.A(40618)},{id:"toml",name:"TOML",import:()=>e.A(5470)},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:()=>e.A(30537)},{id:"tsv",name:"TSV",import:()=>e.A(40623)},{id:"tsx",name:"TSX",import:()=>e.A(24096)},{id:"turtle",name:"Turtle",import:()=>e.A(27542)},{id:"twig",name:"Twig",import:()=>e.A(77825)},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:()=>e.A(19350)},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:()=>e.A(86116)},{id:"typst",name:"Typst",aliases:["typ"],import:()=>e.A(72085)},{id:"v",name:"V",import:()=>e.A(56293)},{id:"vala",name:"Vala",import:()=>e.A(3131)},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:()=>e.A(67619)},{id:"verilog",name:"Verilog",import:()=>e.A(86165)},{id:"vhdl",name:"VHDL",import:()=>e.A(35200)},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:()=>e.A(33464)},{id:"vue",name:"Vue",import:()=>e.A(54049)},{id:"vue-html",name:"Vue HTML",import:()=>e.A(499)},{id:"vue-vine",name:"Vue Vine",import:()=>e.A(6993)},{id:"vyper",name:"Vyper",aliases:["vy"],import:()=>e.A(80598)},{id:"wasm",name:"WebAssembly",import:()=>e.A(72318)},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:()=>e.A(84860)},{id:"wgsl",name:"WGSL",import:()=>e.A(46196)},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:()=>e.A(19331)},{id:"wit",name:"WebAssembly Interface Types",import:()=>e.A(25277)},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:()=>e.A(68013)},{id:"xml",name:"XML",import:()=>e.A(64046)},{id:"xsl",name:"XSL",import:()=>e.A(7544)},{id:"yaml",name:"YAML",aliases:["yml"],import:()=>e.A(18299)},{id:"zenscript",name:"ZenScript",import:()=>e.A(36493)},{id:"zig",name:"Zig",import:()=>e.A(76720)}],T=Object.fromEntries($.map(e=>[e.id,e.import])),j=Object.fromEntries($.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),M={...T,...j};class B extends Error{constructor(e){super(e),this.name="ShikiError"}}var O=e.i(35884);function D(e,...t){return t.forEach(t=>{for(let r in t)e[r]=t[r]}),e}var G=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,U=class{static hasCaptures(e){return null!==e&&(G.lastIndex=0,G.test(e))}static replaceCaptures(e,t,r){return e.replace(G,(e,n,i,a)=>{let s=r[parseInt(n||i,10)];if(!s)return e;{let e=t.substring(s.start,s.end);for(;"."===e[0];)e=e.substring(1);switch(a){case"downcase":return e.toLowerCase();case"upcase":return e.toUpperCase();default:return e}}})}};function F(e,t){if(null===e&&null===t)return 0;if(!e)return -1;if(!t)return 1;let r=e.length,n=t.length;if(r===n){for(let n=0;n<r;n++){var i,a;let r=(i=e[n],i<(a=t[n])?-1:+(i>a));if(0!==r)return r}return 0}return r-n}function W(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function z(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var q=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},H=class{constructor(e,t,r){this._colorMap=e,this._defaults=t,this._root=r}static createFromRawTheme(e,t){return this.createFromParsedTheme(function(e){if(!e||!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,r=[],n=0;for(let e=0,i=t.length;e<i;e++){let i,a=t[e];if(!a.settings)continue;if("string"==typeof a.scope){let e=a.scope;i=(e=(e=e.replace(/^[,]+/,"")).replace(/[,]+$/,"")).split(",")}else i=Array.isArray(a.scope)?a.scope:[""];let s=-1;if("string"==typeof a.settings.fontStyle){s=0;let e=a.settings.fontStyle.split(" ");for(let t=0,r=e.length;t<r;t++)switch(e[t]){case"italic":s|=1;break;case"bold":s|=2;break;case"underline":s|=4;break;case"strikethrough":s|=8}}let o=null;"string"==typeof a.settings.foreground&&W(a.settings.foreground)&&(o=a.settings.foreground);let l=null;"string"==typeof a.settings.background&&W(a.settings.background)&&(l=a.settings.background);for(let t=0,a=i.length;t<a;t++){let a=i[t].trim().split(" "),u=a[a.length-1],c=null;a.length>1&&(c=a.slice(0,a.length-1)).reverse(),r[n++]=new K(u,c,e,s,o,l)}}return r}(e),t)}static createFromParsedTheme(e,t){return function(e,t){e.sort((e,t)=>{var r,n;let i=(r=e.scope,r<(n=t.scope)?-1:+(r>n));return 0!==i||0!==(i=F(e.parentScopes,t.parentScopes))?i:e.index-t.index});let r=0,n="#000000",i="#ffffff";for(;e.length>=1&&""===e[0].scope;){let t=e.shift();-1!==t.fontStyle&&(r=t.fontStyle),null!==t.foreground&&(n=t.foreground),null!==t.background&&(i=t.background)}let a=new J(t),s=new Q(r,a.getId(n),a.getId(i)),o=new ee(new Y(0,null,-1,0,0),[]);for(let t=0,r=e.length;t<r;t++){let r=e[t];o.insert(0,r.scope,r.parentScopes,r.fontStyle,a.getId(r.foreground),a.getId(r.background))}return new H(a,s,o)}(e,t)}_cachedMatchRoot=new q(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(null===e)return this._defaults;let t=e.scopeName,r=this._cachedMatchRoot.get(t).find(t=>(function(e,t){if(0===t.length)return!0;for(let i=0;i<t.length;i++){var r,n;let a=t[i],s=!1;if(">"===a){if(i===t.length-1)return!1;a=t[++i],s=!0}for(;e&&(r=e.scopeName,!((n=a)===r||r.startsWith(n)&&"."===r[n.length]));){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0})(e.parent,t.parentScopes));return r?new Q(r.fontStyle,r.foreground,r.background):null}},V=class e{constructor(e,t){this.parent=e,this.scopeName=t}static push(t,r){for(let n of r)t=new e(t,n);return t}static from(...t){let r=null;for(let n=0;n<t.length;n++)r=new e(r,t[n]);return r}push(t){return new e(this,t)}getSegments(){let e=this,t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(" ")}extends(e){return this===e||null!==this.parent&&this.parent.extends(e)}getExtensionIfDefined(e){let t=[],r=this;for(;r&&r!==e;)t.push(r.scopeName),r=r.parent;return r===e?t.reverse():void 0}},Q=class{constructor(e,t,r){this.fontStyle=e,this.foregroundId=t,this.backgroundId=r}},K=class{constructor(e,t,r,n,i,a){this.scope=e,this.parentScopes=t,this.index=r,this.fontStyle=n,this.foreground=i,this.background=a}},X=((s=X||{})[s.NotSet=-1]="NotSet",s[s.None=0]="None",s[s.Italic=1]="Italic",s[s.Bold=2]="Bold",s[s.Underline=4]="Underline",s[s.Strikethrough=8]="Strikethrough",s),J=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,r=e.length;t<r;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(null===e)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Z=Object.freeze([]),Y=class e{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,r,n,i){this.scopeDepth=e,this.parentScopes=t||Z,this.fontStyle=r,this.foreground=n,this.background=i}clone(){return new e(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let r=0,n=e.length;r<n;r++)t[r]=e[r].clone();return t}acceptOverwrite(e,t,r,n){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,-1!==t&&(this.fontStyle=t),0!==r&&(this.foreground=r),0!==n&&(this.background=n)}},ee=class e{constructor(e,t=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let r=0,n=0;for(;">"===e.parentScopes[r]&&r++,">"===t.parentScopes[n]&&n++,!(r>=e.parentScopes.length)&&!(n>=t.parentScopes.length);){let i=t.parentScopes[n].length-e.parentScopes[r].length;if(0!==i)return i;r++,n++}return t.parentScopes.length-e.parentScopes.length}match(t){if(""!==t){let e,r,n=t.indexOf(".");if(-1===n?(e=t,r=""):(e=t.substring(0,n),r=t.substring(n+1)),this._children.hasOwnProperty(e))return this._children[e].match(r)}let r=this._rulesWithParentScopes.concat(this._mainRule);return r.sort(e._cmpBySpecificity),r}insert(t,r,n,i,a,s){let o,l,u;if(""===r)return void this._doInsertHere(t,n,i,a,s);let c=r.indexOf(".");-1===c?(o=r,l=""):(o=r.substring(0,c),l=r.substring(c+1)),this._children.hasOwnProperty(o)?u=this._children[o]:(u=new e(this._mainRule.clone(),Y.cloneArr(this._rulesWithParentScopes)),this._children[o]=u),u.insert(t+1,l,n,i,a,s)}_doInsertHere(e,t,r,n,i){if(null===t)return void this._mainRule.acceptOverwrite(e,r,n,i);for(let a=0,s=this._rulesWithParentScopes.length;a<s;a++){let s=this._rulesWithParentScopes[a];if(0===F(s.parentScopes,t))return void s.acceptOverwrite(e,r,n,i)}-1===r&&(r=this._mainRule.fontStyle),0===n&&(n=this._mainRule.foreground),0===i&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new Y(e,t,r,n,i))}},et=class e{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(t){let r=e.getLanguageId(t),n=e.getTokenType(t),i=e.getFontStyle(t);console.log({languageId:r,tokenType:n,fontStyle:i,foreground:e.getForeground(t),background:e.getBackground(t)})}static getLanguageId(e){return(255&e)>>>0}static getTokenType(e){return(768&e)>>>8}static containsBalancedBrackets(e){return(1024&e)!=0}static getFontStyle(e){return(30720&e)>>>11}static getForeground(e){return(0xff8000&e)>>>15}static getBackground(e){return(0xff000000&e)>>>24}static set(t,r,n,i,a,s,o){let l=e.getLanguageId(t),u=e.getTokenType(t),c=+!!e.containsBalancedBrackets(t),d=e.getFontStyle(t),p=e.getForeground(t),h=e.getBackground(t);return 0!==r&&(l=r),8!==n&&(u=n),null!==i&&(c=+!!i),-1!==a&&(d=a),0!==s&&(p=s),0!==o&&(h=o),(l|u<<8|c<<10|d<<11|p<<15|h<<24)>>>0}};function er(e,t){var r;let n,i,a=[],s=(r=e,i=(n=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g).exec(r),{next:()=>{if(!i)return null;let e=i[0];return i=n.exec(r),e}}),o=s.next();for(;null!==o;){let e=0;if(2===o.length&&":"===o.charAt(1)){switch(o.charAt(0)){case"R":e=1;break;case"L":e=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=s.next()}let t=u();if(a.push({matcher:t,priority:e}),","!==o)break;o=s.next()}return a;function l(){if("-"===o){o=s.next();let e=l();return t=>!!e&&!e(t)}if("("===o){o=s.next();let e=function(){let e=[],t=u();for(;t&&(e.push(t),"|"===o||","===o);){do o=s.next();while("|"===o||","===o)t=u()}return t=>e.some(e=>e(t))}();return")"===o&&(o=s.next()),e}if(en(o)){let e=[];do e.push(o),o=s.next();while(en(o))return r=>t(e,r)}return null}function u(){let e=[],t=l();for(;t;)e.push(t),t=l();return t=>e.every(e=>e(t))}}function en(e){return!!e&&!!e.match(/[\w\.:]+/)}var ei=((o=ei||{})[o.None=0]="None",o[o.NotBeginString=1]="NotBeginString",o[o.NotEndString=2]="NotEndString",o[o.NotBeginPosition=4]="NotBeginPosition",o[o.DebugCall=8]="DebugCall",o);function ea(e){"function"==typeof e.dispose&&e.dispose()}var es=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},eo=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},el=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},eu=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new es(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new el;for(let r of e)!function(e,t,r,n){let i=r.lookup(e.scopeName);if(!i){if(e.scopeName===t)throw Error(`No grammar provided for <${t}>`);return}let a=r.lookup(t);e instanceof es?ed({baseGrammar:a,selfGrammar:i},n):ec(e.ruleName,{baseGrammar:a,selfGrammar:i,repository:i.repository},n);let s=r.injections(e.scopeName);if(s)for(let e of s)n.add(new es(e))}(r,this.initialScopeName,this.repo,t);for(let e of t.references)if(e instanceof es){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName)||this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};function ec(e,t,r){t.repository&&t.repository[e]&&ep([t.repository[e]],t,r)}function ed(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&ep(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&ep(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function ep(e,t,r){for(let n of e){if(r.visitedRule.has(n))continue;r.visitedRule.add(n);let e=n.repository?D({},t.repository,n.repository):t.repository;Array.isArray(n.patterns)&&ep(n.patterns,{...t,repository:e},r);let i=n.include;if(!i)continue;let a=eb(i);switch(a.kind){case 0:ed({...t,selfGrammar:t.baseGrammar},r);break;case 1:ed(t,r);break;case 2:ec(a.ruleName,{...t,repository:e},r);break;case 3:case 4:let s=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(s){let n={baseGrammar:t.baseGrammar,selfGrammar:s,repository:e};4===a.kind?ec(a.ruleName,n,r):ed(n,r)}else 4===a.kind?r.add(new eo(a.scopeName,a.ruleName)):r.add(new es(a.scopeName))}}}var eh=class{kind=0},ef=class{kind=1},em=class{constructor(e){this.ruleName=e}kind=2},eg=class{constructor(e){this.scopeName=e}kind=3},ey=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function eb(e){if("$base"===e)return new eh;if("$self"===e)return new ef;let t=e.indexOf("#");return -1===t?new eg(e):0===t?new em(e.substring(1)):new ey(e.substring(0,t),e.substring(t+1))}var ew=/\\(\d+)/,ex=/\\(\d+)/g;Symbol("RuleId");var ev=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,r,n){this.$location=e,this.id=t,this._name=r||null,this._nameIsCapturing=U.hasCaptures(this._name),this._contentName=n||null,this._contentNameIsCapturing=U.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${function e(t){let r=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return 0===r?t:~r==t.length-1?e(t.substring(0,t.length-1)):t.substr(~r+1)}(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return this._nameIsCapturing&&null!==this._name&&null!==e&&null!==t?U.replaceCaptures(this._name,e,t):this._name}getContentName(e,t){return this._contentNameIsCapturing&&null!==this._contentName?U.replaceCaptures(this._contentName,e,t):this._contentName}},eA=class extends ev{retokenizeCapturedWithRuleId;constructor(e,t,r,n,i){super(e,t,r,n),this.retokenizeCapturedWithRuleId=i}dispose(){}collectPatterns(e,t){throw Error("Not supported!")}compile(e,t){throw Error("Not supported!")}compileAG(e,t,r,n){throw Error("Not supported!")}},e_=class extends ev{_match;captures;_cachedCompiledPatterns;constructor(e,t,r,n,i){super(e,t,r,null),this._match=new eE(n,this.id),this.captures=i,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e).compileAG(e,r,n)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new eI,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ek=class extends ev{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,r,n,i){super(e,t,r,n),this.patterns=i.patterns,this.hasMissingPatterns=i.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let r of this.patterns)e.getRule(r).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e).compileAG(e,r,n)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new eI,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},eC=class extends ev{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,r,n,i,a,s,o,l,u){super(e,t,r,n),this._begin=new eE(i,this.id),this.beginCaptures=a,this._end=new eE(s||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=o,this.applyEndPatternLast=l||!1,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e,t).compileAG(e,r,n)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){for(let t of(this._cachedCompiledPatterns=new eI,this.patterns))e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},eS=class extends ev{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,r,n,i,a,s,o,l){super(e,t,r,n),this._begin=new eE(i,this.id),this.beginCaptures=a,this.whileCaptures=o,this._while=new eE(s,-2),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,r,n){return this._getCachedCompiledPatterns(e).compileAG(e,r,n)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns)for(let t of(this._cachedCompiledPatterns=new eI,this.patterns))e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,r,n){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,r,n)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new eI,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||""),this._cachedCompiledWhilePatterns}},eN=class e{static createCaptureRule(e,t,r,n,i){return e.registerRule(e=>new eA(t,e,r,n,i))}static getCompiledRuleId(t,r,n){return t.id||r.registerRule(i=>{if(t.id=i,t.match)return new e_(t.$vscodeTextmateLocation,t.id,t.name,t.match,e._compileCaptures(t.captures,r,n));if(void 0===t.begin){t.repository&&(n=D({},n,t.repository));let i=t.patterns;return void 0===i&&t.include&&(i=[{include:t.include}]),new ek(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,e._compilePatterns(i,r,n))}return t.while?new eS(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,r,n),t.while,e._compileCaptures(t.whileCaptures||t.captures,r,n),e._compilePatterns(t.patterns,r,n)):new eC(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,e._compileCaptures(t.beginCaptures||t.captures,r,n),t.end,e._compileCaptures(t.endCaptures||t.captures,r,n),t.applyEndPatternLast,e._compilePatterns(t.patterns,r,n))}),t.id}static _compileCaptures(t,r,n){let i=[];if(t){let a=0;for(let e in t){if("$vscodeTextmateLocation"===e)continue;let t=parseInt(e,10);t>a&&(a=t)}for(let e=0;e<=a;e++)i[e]=null;for(let a in t){if("$vscodeTextmateLocation"===a)continue;let s=parseInt(a,10),o=0;t[a].patterns&&(o=e.getCompiledRuleId(t[a],r,n)),i[s]=e.createCaptureRule(r,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,o)}}return i}static _compilePatterns(t,r,n){let i=[];if(t)for(let a=0,s=t.length;a<s;a++){let s=t[a],o=-1;if(s.include){let t=eb(s.include);switch(t.kind){case 0:case 1:o=e.getCompiledRuleId(n[s.include],r,n);break;case 2:let i=n[t.ruleName];i&&(o=e.getCompiledRuleId(i,r,n));break;case 3:case 4:let a=t.scopeName,l=4===t.kind?t.ruleName:null,u=r.getExternalGrammar(a,n);if(u)if(l){let t=u.repository[l];t&&(o=e.getCompiledRuleId(t,r,u.repository))}else o=e.getCompiledRuleId(u.repository.$self,r,u.repository)}}else o=e.getCompiledRuleId(s,r,n);if(-1!==o){let e=r.getRule(o),t=!1;if((e instanceof ek||e instanceof eC||e instanceof eS)&&e.hasMissingPatterns&&0===e.patterns.length&&(t=!0),t)continue;i.push(o)}}return{patterns:i,hasMissingPatterns:(t?t.length:0)!==i.length}}},eE=class e{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&"string"==typeof e){const t=e.length;let r=0,n=[],i=!1;for(let a=0;a<t;a++)if("\\"===e.charAt(a)&&a+1<t){const t=e.charAt(a+1);"z"===t?(n.push(e.substring(r,a)),n.push("$(?!\\n)(?<!\\n)"),r=a+2):("A"===t||"G"===t)&&(i=!0),a++}this.hasAnchor=i,0===r?this.source=e:(n.push(e.substring(r,t)),this.source=n.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,"string"==typeof this.source?this.hasBackReferences=ew.test(this.source):this.hasBackReferences=!1}clone(){return new e(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if("string"!=typeof this.source)throw Error("This method should only be called if the source is a string");let r=t.map(t=>e.substring(t.start,t.end));return ex.lastIndex=0,this.source.replace(ex,(e,t)=>z(r[parseInt(t,10)]||""))}_buildAnchorCache(){let e,t,r,n;if("string"!=typeof this.source)throw Error("This method should only be called if the source is a string");let i=[],a=[],s=[],o=[];for(e=0,t=this.source.length;e<t;e++)r=this.source.charAt(e),i[e]=r,a[e]=r,s[e]=r,o[e]=r,"\\"===r&&e+1<t&&("A"===(n=this.source.charAt(e+1))?(i[e+1]="",a[e+1]="",s[e+1]="A",o[e+1]="A"):"G"===n?(i[e+1]="",a[e+1]="G",s[e+1]="",o[e+1]="G"):(i[e+1]=n,a[e+1]=n,s[e+1]=n,o[e+1]=n),e++);return{A0_G0:i.join(""),A0_G1:a.join(""),A1_G0:s.join(""),A1_G1:o.join("")}}resolveAnchors(e,t){if(!this.hasAnchor||!this._anchorCache||"string"!=typeof this.source)return this.source;if(e)if(t)return this._anchorCache.A1_G1;else return this._anchorCache.A1_G0;return t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},eI=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(e=>e.source);this._cached=new eL(e,t,this._items.map(e=>e.ruleId))}return this._cached}compileAG(e,t,r){if(!this._hasAnchors)return this.compile(e);if(t)if(r)return this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,r)),this._anchorCache.A1_G1;else return this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,r)),this._anchorCache.A1_G0;return r?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,r)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,r)),this._anchorCache.A0_G0)}_resolveAnchors(e,t,r){return new eL(e,this._items.map(e=>e.resolveAnchors(t,r)),this._items.map(e=>e.ruleId))}},eL=class{constructor(e,t,r){this.regExps=t,this.rules=r,this.scanner=e.createOnigScanner(t)}scanner;dispose(){"function"==typeof this.scanner.dispose&&this.scanner.dispose()}toString(){let e=[];for(let t=0,r=this.rules.length;t<r;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join("\n")}findNextMatchSync(e,t,r){let n=this.scanner.findNextMatchSync(e,t,r);return n?{ruleId:this.rules[n.index],captureIndices:n.captureIndices}:null}},eP=class{constructor(e,t){this.languageId=e,this.tokenType=t}},eR=class e{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new eP(e,8),this._embeddedLanguagesMatcher=new e$(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return null===t?e._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new eP(0,0);_getBasicScopeAttributes=new q(e=>new eP(this._scopeToLanguage(e),this._toStandardTokenType(e)));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(t){let r=t.match(e.STANDARD_TOKEN_TYPE_REGEXP);if(!r)return 8;switch(r[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},e$=class{values;scopesRegExp;constructor(e){if(0===e.length)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([e,t])=>z(e));t.sort(),t.reverse(),this.scopesRegExp=RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}};void 0!==O.default&&O.default.env.VSCODE_TEXTMATE_DEBUG;var eT=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function ej(e,t,r,n,i,a,s,o){let l=t.content.length,u=!1,c=-1;if(s){let s=function(e,t,r,n,i,a){let s=i.beginRuleCapturedEOL?0:-1,o=[];for(let t=i;t;t=t.pop()){let r=t.getRule(e);r instanceof eS&&o.push({rule:r,stack:t})}for(let h=o.pop();h;h=o.pop()){var l,u,c,d,p;let{ruleScanner:o,findOptions:f}=(l=h.rule,u=e,c=h.stack.endRule,d=r,p=n===s,{ruleScanner:l.compileWhileAG(u,c,d,p),findOptions:0}),m=o.findNextMatchSync(t,n,f);if(m){if(-2!==m.ruleId){i=h.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(a.produce(h.stack,m.captureIndices[0].start),eB(e,t,r,h.stack,a,h.rule.whileCaptures,m.captureIndices),a.produce(h.stack,m.captureIndices[0].end),s=m.captureIndices[0].end,m.captureIndices[0].end>n&&(n=m.captureIndices[0].end,r=!1))}else{i=h.stack.pop();break}}return{stack:i,linePos:n,anchorPosition:s,isFirstLine:r}}(e,t,r,n,i,a);i=s.stack,n=s.linePos,r=s.isFirstLine,c=s.anchorPosition}let d=Date.now();for(;!u;){if(0!==o&&Date.now()-d>o)return new eT(i,!0);!function(){let s=function(e,t,r,n,i,a){let s=function(e,t,r,n,i,a){let{ruleScanner:s,findOptions:o}=eM(i.getRule(e),e,i.endRule,r,n===a),l=s.findNextMatchSync(t,n,o);return l?{captureIndices:l.captureIndices,matchedRuleId:l.ruleId}:null}(e,t,r,n,i,a),o=e.getInjections();if(0===o.length)return s;let l=function(e,t,r,n,i,a,s){let o,l=Number.MAX_VALUE,u=null,c=0,d=a.contentNameScopesList.getScopeNames();for(let a=0,p=e.length;a<p;a++){let p=e[a];if(!p.matcher(d))continue;let{ruleScanner:h,findOptions:f}=eM(t.getRule(p.ruleId),t,null,n,i===s),m=h.findNextMatchSync(r,i,f);if(!m)continue;let g=m.captureIndices[0].start;if(!(g>=l)&&(l=g,u=m.captureIndices,o=m.ruleId,c=p.priority,l===i))break}return u?{priorityMatch:-1===c,captureIndices:u,matchedRuleId:o}:null}(o,e,t,r,n,i,a);if(!l)return s;if(!s)return l;let u=s.captureIndices[0].start,c=l.captureIndices[0].start;return c<u||l.priorityMatch&&c===u?l:s}(e,t,r,n,i,c);if(!s){a.produce(i,l),u=!0;return}let o=s.captureIndices,d=s.matchedRuleId,p=!!o&&o.length>0&&o[0].end>n;if(-1===d){let s=i.getRule(e);a.produce(i,o[0].start),i=i.withContentNameScopesList(i.nameScopesList),eB(e,t,r,i,a,s.endCaptures,o),a.produce(i,o[0].end);let d=i;if(i=i.parent,c=d.getAnchorPos(),!p&&d.getEnterPos()===n){i=d,a.produce(i,l),u=!0;return}}else{let s=e.getRule(d);a.produce(i,o[0].start);let h=i,f=s.getName(t.content,o),m=i.contentNameScopesList.pushAttributed(f,e);if(i=i.push(d,n,c,o[0].end===l,null,m,m),s instanceof eC){eB(e,t,r,i,a,s.beginCaptures,o),a.produce(i,o[0].end),c=o[0].end;let n=s.getContentName(t.content,o),d=m.pushAttributed(n,e);if(i=i.withContentNameScopesList(d),s.endHasBackReferences&&(i=i.withEndRule(s.getEndWithResolvedBackReferences(t.content,o))),!p&&h.hasSameRuleAs(i)){i=i.pop(),a.produce(i,l),u=!0;return}}else if(s instanceof eS){eB(e,t,r,i,a,s.beginCaptures,o),a.produce(i,o[0].end),c=o[0].end;let n=s.getContentName(t.content,o),d=m.pushAttributed(n,e);if(i=i.withContentNameScopesList(d),s.whileHasBackReferences&&(i=i.withEndRule(s.getWhileWithResolvedBackReferences(t.content,o))),!p&&h.hasSameRuleAs(i)){i=i.pop(),a.produce(i,l),u=!0;return}}else if(eB(e,t,r,i,a,s.captures,o),a.produce(i,o[0].end),i=i.pop(),!p){i=i.safePop(),a.produce(i,l),u=!0;return}}o[0].end>n&&(n=o[0].end,r=!1)}()}return new eT(i,!1)}function eM(e,t,r,n,i){return{ruleScanner:e.compileAG(t,r,n,i),findOptions:0}}function eB(e,t,r,n,i,a,s){if(0===a.length)return;let o=t.content,l=Math.min(a.length,s.length),u=[],c=s[0].end;for(let t=0;t<l;t++){let l=a[t];if(null===l)continue;let d=s[t];if(0===d.length)continue;if(d.start>c)break;for(;u.length>0&&u[u.length-1].endPos<=d.start;)i.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop();if(u.length>0?i.produceFromScopes(u[u.length-1].scopes,d.start):i.produce(n,d.start),l.retokenizeCapturedWithRuleId){let t=l.getName(o,s),a=n.contentNameScopesList.pushAttributed(t,e),u=l.getContentName(o,s),c=a.pushAttributed(u,e),p=n.push(l.retokenizeCapturedWithRuleId,d.start,-1,!1,null,a,c),h=e.createOnigString(o.substring(0,d.end));ej(e,h,r&&0===d.start,d.start,p,i,!1,0),ea(h);continue}let p=l.getName(o,s);if(null!==p){let t=(u.length>0?u[u.length-1].scopes:n.contentNameScopesList).pushAttributed(p,e);u.push(new eO(t,d.end))}}for(;u.length>0;)i.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var eO=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function eD(e,t,r,n,i){let a=er(t,eG),s=eN.getCompiledRuleId(r,n,i.repository);for(let r of a)e.push({debugSelector:t,matcher:r.matcher,ruleId:s,grammar:i,priority:r.priority})}function eG(e,t){if(t.length<e.length)return!1;let r=0;return e.every(e=>{for(let n=r;n<t.length;n++)if(function(e,t){if(!e)return!1;if(e===t)return!0;let r=t.length;return e.length>r&&e.substr(0,r)===t&&"."===e[r]}(t[n],e))return r=n+1,!0;return!1})}var eU=class{constructor(e,t,r,n,i,a,s,o){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=o,this._basicScopeAttributesProvider=new eR(r,n),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=s,this._grammar=eF(t,null),this._injections=null,this._tokenTypeMatchers=[],i)for(const e of Object.keys(i))for(const t of er(e,eG))this._tokenTypeMatchers.push({matcher:t.matcher,type:i[e]})}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e=[],t=this._rootScopeName,r=({lookup:e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e),injections:e=>this._grammarRepository.injections(e)}).lookup(t);if(r){let n=r.injections;if(n)for(let t in n)eD(e,t,n[t],this,r);let i=this._grammarRepository.injections(t);i&&i.forEach(t=>{let r=this.getExternalGrammar(t);if(r){let t=r.injectionSelector;t&&eD(e,t,r,this,r)}})}return e.sort((e,t)=>e.priority-t.priority),e}getInjections(){return null===this._injections&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,r=e(t);return this._ruleId2desc[t]=r,r}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let r=this._grammarRepository.lookup(e);if(r)return this._includedGrammars[e]=eF(r,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,r=0){let n=this._tokenize(e,t,!1,r);return{tokens:n.lineTokens.getResult(n.ruleStack,n.lineLength),ruleStack:n.ruleStack,stoppedEarly:n.stoppedEarly}}tokenizeLine2(e,t,r=0){let n=this._tokenize(e,t,!0,r);return{tokens:n.lineTokens.getBinaryResult(n.ruleStack,n.lineLength),ruleStack:n.ruleStack,stoppedEarly:n.stoppedEarly}}_tokenize(e,t,r,n){let i;if(-1===this._rootId&&(this._rootId=eN.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections()),t&&t!==ez.NULL)i=!1,t.reset();else{let e;i=!0;let r=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),a=et.set(0,r.languageId,r.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),s=this.getRule(this._rootId).getName(null,null);e=s?eW.createRootAndLookUpScopeName(s,a,this):eW.createRoot("unknown",a),t=new ez(null,this._rootId,-1,-1,!1,null,e,e)}e+="\n";let a=this.createOnigString(e),s=a.content.length,o=new eH(r,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=ej(this,a,i,0,t,o,!0,n);return ea(a),{lineLength:s,lineTokens:o,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function eF(e,t){return(e=function e(t){return Array.isArray(t)?function(t){let r=[];for(let n=0,i=t.length;n<i;n++)r[n]=e(t[n]);return r}(t):t instanceof RegExp?t:"object"==typeof t?function(t){let r={};for(let n in t)r[n]=e(t[n]);return r}(t):t}(e)).repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var eW=class e{constructor(e,t,r){this.parent=e,this.scopePath=t,this.tokenAttributes=r}static fromExtension(t,r){let n=t,i=t?.scopePath??null;for(let t of r)n=new e(n,i=V.push(i,t.scopeNames),t.encodedTokenAttributes);return n}static createRoot(t,r){return new e(null,new V(null,t),r)}static createRootAndLookUpScopeName(t,r,n){let i=n.getMetadataForScope(t),a=new V(null,t),s=n.themeProvider.themeMatch(a),o=e.mergeAttributes(r,i,s);return new e(null,a,o)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return e.equals(this,t)}static equals(e,t){for(;;){if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}}static mergeAttributes(e,t,r){let n=-1,i=0,a=0;return null!==r&&(n=r.fontStyle,i=r.foregroundId,a=r.backgroundId),et.set(e,t.languageId,t.tokenType,null,n,i,a)}pushAttributed(t,r){if(null===t)return this;if(-1===t.indexOf(" "))return e._pushAttributed(this,t,r);let n=t.split(/ /g),i=this;for(let t of n)i=e._pushAttributed(i,t,r);return i}static _pushAttributed(t,r,n){let i=n.getMetadataForScope(r),a=t.scopePath.push(r),s=n.themeProvider.themeMatch(a),o=e.mergeAttributes(t.tokenAttributes,i,s);return new e(t,a,o)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let t=[],r=this;for(;r&&r!==e;)t.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?t.reverse():void 0}},ez=class e{constructor(e,t,r,n,i,a,s,o){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=s,this.contentNameScopesList=o,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=n}_stackElementBrand=void 0;static NULL=new e(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return null!==t&&e._equals(this,t)}static _equals(e,t){return e===t||!!this._structuralEquals(e,t)&&eW.equals(e.contentNameScopesList,t.contentNameScopesList)}static _structuralEquals(e,t){for(;;){if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){e._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,r,n,i,a,s,o){return new e(this,t,r,n,i,a,s,o)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(t){return this.endRule===t?this:new e(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,r){let n=eW.fromExtension(t?.nameScopesList??null,r.nameScopesList);return new e(t,r.ruleId,r.enterPos??-1,r.anchorPos??-1,r.beginRuleCapturedEOL,r.endRule,n,eW.fromExtension(n,r.contentNameScopesList))}},eq=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(e=>"*"===e?(this.allowAny=!0,[]):er(e,eG).map(e=>e.matcher)),this.unbalancedBracketScopes=t.flatMap(e=>er(e,eG).map(e=>e.matcher))}get matchesAlways(){return this.allowAny&&0===this.unbalancedBracketScopes.length}get matchesNever(){return 0===this.balancedBracketScopes.length&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},eH=class{constructor(e,t,r,n){this.balancedBracketSelectors=n,this._emitBinaryTokens=e,this._tokenTypeOverrides=r,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,n=!1;if(this.balancedBracketSelectors?.matchesAlways&&(n=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let t=e?.getScopeNames()??[];for(let e of this._tokenTypeOverrides)e.matcher(t)&&(r=et.set(r,0,e.type,null,-1,0,0));this.balancedBracketSelectors&&(n=this.balancedBracketSelectors.match(t))}if(n&&(r=et.set(r,0,8,n,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}let r=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:r}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),0===this._tokens.length&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),0===this._binaryTokens.length&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let r=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e<t;e++)r[e]=this._binaryTokens[e];return r}},eV=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,r,n,i){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,new eU(e,a,t,r,n,i,this,this._onigLib))}return this._grammars.get(e)}},eQ=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new eV(H.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(H.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,r){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:r})}loadGrammarWithConfiguration(e,t,r){return this._loadGrammar(e,t,r.embeddedLanguages,r.tokenTypes,new eq(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,r,n,i){let a=new eu(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(e=>this._loadSingleGrammar(e.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,r,n,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let r="function"==typeof this._options.getInjections?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,r)}}addGrammar(e,t=[],r=0,n=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,r,n)}_grammarForScopeName(e,t=0,r=null,n=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,r,n,i)}},eK=ez.NULL,eX=e.i(577),eJ=e.i(61634),eZ=e.i(79694);let eY=/["&'<>`]/g,e0=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,e1=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,e2=/[|\\{}()[\]^$+*?.]/g,e5=new WeakMap,e6=/[\dA-Fa-f]/,e3=/\d/,e8=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],e4={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},e9=["cent","copy","divide","gt","lt","not","para","times"],e7={}.hasOwnProperty,te={};for(t in e4)e7.call(e4,t)&&(te[e4[t]]=t);let tt=/[^\dA-Za-z]/;function tr(e,t,r){var n,i;let a,s,o=(n=r.omitOptionalSemicolons,a="&#x"+e.toString(16).toUpperCase(),n&&t&&!e6.test(String.fromCharCode(t))?a:a+";");if((r.useNamedReferences||r.useShortestReferences)&&(s=function(e,t,r,n){let i=String.fromCharCode(e);if(e7.call(te,i)){let e=te[i],a="&"+e;return r&&e8.includes(e)&&!e9.includes(e)&&(!n||t&&61!==t&&tt.test(String.fromCharCode(t)))?a:a+";"}return""}(e,t,r.omitOptionalSemicolons,r.attribute)),(r.useShortestReferences||!s)&&r.useShortestReferences){let n,a=(i=r.omitOptionalSemicolons,n="&#"+String(e),i&&t&&!e3.test(String.fromCharCode(t))?n:n+";");a.length<o.length&&(o=a)}return s&&(!r.useShortestReferences||s.length<o.length)?s:o}function tn(e,t){let r;var n,i=e,a=Object.assign({format:tr},t);if(i=i.replace(a.subset?(n=a.subset,(r=e5.get(n))||(r=function(e){let t=[],r=-1;for(;++r<e.length;)t.push(e[r].replace(e2,"\\$&"));return RegExp("(?:"+t.join("|")+")","g")}(n),e5.set(n,r)),r):eY,s),a.subset||a.escapeOnly)return i;return i.replace(e0,function(e,t,r){return a.format((e.charCodeAt(0)-55296)*1024+e.charCodeAt(1)-56320+65536,r.charCodeAt(t+2),a)}).replace(e1,s);function s(e,t,r){return a.format(e.charCodeAt(0),r.charCodeAt(t+1),a)}}let ti=/^>|^->|<!--|-->|--!>|<!-$/g,ta=[">"],ts=["<",">"];var to=e.i(70284),tl=e.i(16220),tu=e.i(73638),tc=e.i(82772),td=e.i(58206);let tp=tm(1),th=tm(-1),tf=[];function tm(e){return function(t,r,n){let i=t?t.children:tf,a=(r||0)+e,s=i[a];if(!n)for(;s&&(0,td.whitespace)(s);)a+=e,s=i[a];return s}}let tg={}.hasOwnProperty;function ty(e){return function(t,r,n){return tg.call(e,t.tagName)&&e[t.tagName](t,r,n)}}let tb=ty({body:function(e,t,r){let n=tp(r,t);return!n||"comment"!==n.type},caption:tw,colgroup:tw,dd:function(e,t,r){let n=tp(r,t);return!n||"element"===n.type&&("dt"===n.tagName||"dd"===n.tagName)},dt:function(e,t,r){let n=tp(r,t);return!!(n&&"element"===n.type&&("dt"===n.tagName||"dd"===n.tagName))},head:tw,html:function(e,t,r){let n=tp(r,t);return!n||"comment"!==n.type},li:function(e,t,r){let n=tp(r,t);return!n||"element"===n.type&&"li"===n.tagName},optgroup:function(e,t,r){let n=tp(r,t);return!n||"element"===n.type&&"optgroup"===n.tagName},option:function(e,t,r){let n=tp(r,t);return!n||"element"===n.type&&("option"===n.tagName||"optgroup"===n.tagName)},p:function(e,t,r){let n=tp(r,t);return n?"element"===n.type&&("address"===n.tagName||"article"===n.tagName||"aside"===n.tagName||"blockquote"===n.tagName||"details"===n.tagName||"div"===n.tagName||"dl"===n.tagName||"fieldset"===n.tagName||"figcaption"===n.tagName||"figure"===n.tagName||"footer"===n.tagName||"form"===n.tagName||"h1"===n.tagName||"h2"===n.tagName||"h3"===n.tagName||"h4"===n.tagName||"h5"===n.tagName||"h6"===n.tagName||"header"===n.tagName||"hgroup"===n.tagName||"hr"===n.tagName||"main"===n.tagName||"menu"===n.tagName||"nav"===n.tagName||"ol"===n.tagName||"p"===n.tagName||"pre"===n.tagName||"section"===n.tagName||"table"===n.tagName||"ul"===n.tagName):!r||"element"!==r.type||"a"!==r.tagName&&"audio"!==r.tagName&&"del"!==r.tagName&&"ins"!==r.tagName&&"map"!==r.tagName&&"noscript"!==r.tagName&&"video"!==r.tagName},rp:tx,rt:tx,tbody:function(e,t,r){let n=tp(r,t);return!n||"element"===n.type&&("tbody"===n.tagName||"tfoot"===n.tagName)},td:tv,tfoot:function(e,t,r){return!tp(r,t)},th:tv,thead:function(e,t,r){let n=tp(r,t);return!!(n&&"element"===n.type&&("tbody"===n.tagName||"tfoot"===n.tagName))},tr:function(e,t,r){let n=tp(r,t);return!n||"element"===n.type&&"tr"===n.tagName}});function tw(e,t,r){let n=tp(r,t,!0);return!n||"comment"!==n.type&&!("text"===n.type&&(0,td.whitespace)(n.value.charAt(0)))}function tx(e,t,r){let n=tp(r,t);return!n||"element"===n.type&&("rp"===n.tagName||"rt"===n.tagName)}function tv(e,t,r){let n=tp(r,t);return!n||"element"===n.type&&("td"===n.tagName||"th"===n.tagName)}let tA=ty({body:function(e){let t=tp(e,-1,!0);return!t||"comment"!==t.type&&!("text"===t.type&&(0,td.whitespace)(t.value.charAt(0)))&&("element"!==t.type||"meta"!==t.tagName&&"link"!==t.tagName&&"script"!==t.tagName&&"style"!==t.tagName&&"template"!==t.tagName)},colgroup:function(e,t,r){let n=th(r,t),i=tp(e,-1,!0);return!(r&&n&&"element"===n.type&&"colgroup"===n.tagName&&tb(n,r.children.indexOf(n),r))&&!!(i&&"element"===i.type&&"col"===i.tagName)},head:function(e){let t=new Set;for(let r of e.children)if("element"===r.type&&("base"===r.tagName||"title"===r.tagName)){if(t.has(r.tagName))return!1;t.add(r.tagName)}let r=e.children[0];return!r||"element"===r.type},html:function(e){let t=tp(e,-1);return!t||"comment"!==t.type},tbody:function(e,t,r){let n=th(r,t),i=tp(e,-1);return!(r&&n&&"element"===n.type&&("thead"===n.tagName||"tbody"===n.tagName)&&tb(n,r.children.indexOf(n),r))&&!!(i&&"element"===i.type&&"tr"===i.tagName)}}),t_={name:[[" \n\f\r &/=>".split("")," \n\f\r \"&'/=>`".split("")],["\0 \n\f\r \"&'/<=>".split(""),"\0 \n\f\r \"&'/<=>`".split("")]],unquoted:[[" \n\f\r &>".split(""),"\0 \n\f\r \"&'<=>`".split("")],["\0 \n\f\r \"&'<=>`".split(""),"\0 \n\f\r \"&'<=>`".split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]},tk=["<","&"];function tC(e,t,r,n){return r&&"element"===r.type&&("script"===r.tagName||"style"===r.tagName)?e.value:tn(e.value,Object.assign({},n.settings.characterReferences,{subset:tk}))}let tS=(0,eZ.zwitch)("type",{invalid:function(e){throw Error("Expected node, not `"+e+"`")},unknown:function(e){throw Error("Cannot compile unknown node `"+e.type+"`")},handlers:{comment:function(e,t,r,n){return n.settings.bogusComments?"<?"+tn(e.value,Object.assign({},n.settings.characterReferences,{subset:ta}))+">":"<!--"+e.value.replace(ti,function(e){return tn(e,Object.assign({},n.settings.characterReferences,{subset:ts}))})+"-->"},doctype:function(e,t,r,n){return"<!"+(n.settings.upperDoctype?"DOCTYPE":"doctype")+(n.settings.tightDoctype?"":" ")+"html>"},element:function(e,t,r,n){let i,a=n.schema,s="svg"!==a.space&&n.settings.omitOptionalTags,o="svg"===a.space?n.settings.closeEmptyElements:n.settings.voids.includes(e.tagName.toLowerCase()),l=[];"html"===a.space&&"svg"===e.tagName&&(n.schema=eJ.svg);let u=function(e,t){let r,n=[],i=-1;if(t){for(r in t)if(null!==t[r]&&void 0!==t[r]){let i=function(e,t,r){let n,i=(0,tu.find)(e.schema,t),a=e.settings.allowParseErrors&&"html"===e.schema.space?0:1,s=+!e.settings.allowDangerousCharacters,o=e.quote;if(i.overloadedBoolean&&(r===i.attribute||""===r)?r=!0:(i.boolean||i.overloadedBoolean)&&("string"!=typeof r||r===i.attribute||""===r)&&(r=!!r),null==r||!1===r||"number"==typeof r&&Number.isNaN(r))return"";let l=tn(i.attribute,Object.assign({},e.settings.characterReferences,{subset:t_.name[a][s]}));return!0===r||(r=Array.isArray(r)?(i.commaSeparated?tl.stringify:tc.stringify)(r,{padLeft:!e.settings.tightCommaSeparatedLists}):String(r),e.settings.collapseEmptyAttributes&&!r)?l:(e.settings.preferUnquoted&&(n=tn(r,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:t_.unquoted[a][s]}))),n!==r&&(e.settings.quoteSmart&&(0,to.ccount)(r,o)>(0,to.ccount)(r,e.alternative)&&(o=e.alternative),n=o+tn(r,Object.assign({},e.settings.characterReferences,{subset:("'"===o?t_.single:t_.double)[a][s],attribute:!0}))+o),l+(n?"="+n:n))}(e,r,t[r]);i&&n.push(i)}}for(;++i<n.length;){let t=e.settings.tightAttributes?n[i].charAt(n[i].length-1):void 0;i!==n.length-1&&'"'!==t&&"'"!==t&&(n[i]+=" ")}return n.join("")}(n,e.properties),c=n.all("html"===a.space&&"template"===e.tagName?e.content:e);return n.schema=a,c&&(o=!1),!u&&s&&tA(e,t,r)||(l.push("<",e.tagName,u?" "+u:""),o&&("svg"===a.space||n.settings.closeSelfClosing)&&(i=u.charAt(u.length-1),(!n.settings.tightSelfClosing||"/"===i||i&&'"'!==i&&"'"!==i)&&l.push(" "),l.push("/")),l.push(">")),l.push(c),o||s&&tb(e,t,r)||l.push("</"+e.tagName+">"),l.join("")},raw:function(e,t,r,n){return n.settings.allowDangerousHtml?e.value:tC(e,t,r,n)},root:function(e,t,r,n){return n.all(e)},text:tC}}),tN={},tE={},tI=[];function tL(e,t,r){return tS(e,t,r,this)}function tP(e){let t=[],r=e&&e.children||tI,n=-1;for(;++n<r.length;)t[n]=this.one(r[n],n,e);return t.join("")}function tR(e,t){let r="string"==typeof e?{}:{...e.colorReplacements},n="string"==typeof e?e:e.name;for(let[e,i]of Object.entries(t?.colorReplacements||{}))"string"==typeof i?r[e]=i:e===n&&Object.assign(r,i);return r}function t$(e,t){return e&&t?.[e?.toLowerCase()]||e}async function tT(e){return Promise.resolve("function"==typeof e?e():e).then(e=>e.default||e)}function tj(e){return!e||["plaintext","txt","text","plain"].includes(e)}function tM(e){return"ansi"===e||tj(e)}function tB(e){return"none"===e}function tO(e,t){if(!t)return e;for(let r of(e.properties||={},e.properties.class||=[],"string"==typeof e.properties.class&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]),Array.isArray(t)?t:t.split(/\s+/g)))r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}function tD(e,t=!1){if(0===e.length)return[["",0]];let r=e.split(/(\r?\n)/g),n=0,i=[];for(let e=0;e<r.length;e+=2){let a=t?r[e]+(r[e+1]||""):r[e];i.push([a,n]),n+=r[e].length,n+=r[e+1]?.length||0}return i}let tG="light-dark()",tU=["color","background-color"];function tF(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&X.Italic&&(t["font-style"]="italic"),e.fontStyle&X.Bold&&(t["font-weight"]="bold");let r=[];e.fontStyle&X.Underline&&r.push("underline"),e.fontStyle&X.Strikethrough&&r.push("line-through"),r.length&&(t["text-decoration"]=r.join(" "))}return t}function tW(e){return"string"==typeof e?e:Object.entries(e).map(([e,t])=>`${e}:${t}`).join(";")}let tz=new WeakMap;function tq(e,t){tz.set(e,t)}function tH(e){return tz.get(e)}class tV{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,t){return new tV(Object.fromEntries((Array.isArray(t)?t:[t]).map(e=>[e,eK])),e)}constructor(...e){if(2===e.length){const[t,r]=e;this.lang=r,this._stacks=t}else{const[t,r,n]=e;this.lang=r,this._stacks={[n]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){var t;let r,n;return t=this._stacks[e],r=[],n=new Set,!function e(t){if(n.has(t))return;n.add(t);let i=t?.nameScopesList?.scopeName;i&&r.push(i),t.parent&&e(t.parent)}(t),r}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}let tQ=[function(){let e=new WeakMap;function t(t){if(!e.has(t.meta)){var r;let n,i=function(e){if("number"==typeof e){if(e<0||e>t.source.length)throw new B(`Invalid decoration offset: ${e}. Code length: ${t.source.length}`);return{...a.indexToPos(e),offset:e}}{let t=a.lines[e.line];if(void 0===t)throw new B(`Invalid decoration position ${JSON.stringify(e)}. Lines length: ${a.lines.length}`);let r=e.character;if(r<0&&(r=t.length+r),r<0||r>t.length)throw new B(`Invalid decoration position ${JSON.stringify(e)}. Line ${e.line} length: ${t.length}`);return{...e,character:r,offset:a.posToIndex(e.line,r)}}},a={lines:n=tD(r=t.source,!0).map(([e])=>e),indexToPos:function(e){if(e===r.length)return{line:n.length-1,character:n[n.length-1].length};let t=e,i=0;for(let e of n){if(t<e.length)break;t-=e.length,i++}return{line:i,character:t}},posToIndex:function(e,t){let r=0;for(let t=0;t<e;t++)r+=n[t].length;return r+t}},s=(t.options.decorations||[]).map(e=>({...e,start:i(e.start),end:i(e.end)}));(function(e){for(let t=0;t<e.length;t++){let r=e[t];if(r.start.offset>r.end.offset)throw new B(`Invalid decoration range: ${JSON.stringify(r.start)} - ${JSON.stringify(r.end)}`);for(let n=t+1;n<e.length;n++){let t=e[n],i=r.start.offset<=t.start.offset&&t.start.offset<r.end.offset,a=r.start.offset<t.end.offset&&t.end.offset<=r.end.offset,s=t.start.offset<=r.start.offset&&r.start.offset<t.end.offset,o=t.start.offset<r.end.offset&&r.end.offset<=t.end.offset;if(i||a||s||o){if(i&&a||s&&o||s&&r.start.offset===r.end.offset||a&&t.start.offset===t.end.offset)continue;throw new B(`Decorations ${JSON.stringify(r.start)} and ${JSON.stringify(t.start)} intersect.`)}}}})(s),e.set(t.meta,{decorations:s,converter:a,source:t.source})}return e.get(t.meta)}return{name:"shiki:decorations",tokens(e){let r;if(!this.options.decorations?.length)return;let n=t(this).decorations.flatMap(e=>[e.start.offset,e.end.offset]);return(r=Array.from(n instanceof Set?n:new Set(n)).sort((e,t)=>e-t)).length?e.map(e=>e.flatMap(e=>{let t=r.filter(t=>e.offset<t&&t<e.offset+e.content.length).map(t=>t-e.offset).sort((e,t)=>e-t);if(!t.length)return e;let n=0,i=[];for(let r of t)r>n&&i.push({...e,content:e.content.slice(n,r),offset:e.offset+n}),n=r;return n<e.content.length&&i.push({...e,content:e.content.slice(n),offset:e.offset+n}),i})):e},code(e){if(!this.options.decorations?.length)return;let r=t(this),n=Array.from(e.children).filter(e=>"element"===e.type&&"span"===e.tagName);if(n.length!==r.converter.lines.length)throw new B(`Number of lines in code element (${n.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function i(e,t,r,i){let s=n[e],o="",l=-1,u=-1;if(0===t&&(l=0),0===r&&(u=0),r===1/0&&(u=s.children.length),-1===l||-1===u)for(let e=0;e<s.children.length;e++)o+=function e(t){return"text"===t.type?t.value:"element"===t.type?t.children.map(e).join(""):""}(s.children[e]),-1===l&&o.length===t&&(l=e+1),-1===u&&o.length===r&&(u=e+1);if(-1===l)throw new B(`Failed to find start index for decoration ${JSON.stringify(i.start)}`);if(-1===u)throw new B(`Failed to find end index for decoration ${JSON.stringify(i.end)}`);let c=s.children.slice(l,u);if(i.alwaysWrap||c.length!==s.children.length)if(i.alwaysWrap||1!==c.length||"element"!==c[0].type){let e={type:"element",tagName:"span",properties:{},children:c};a(e,i,"wrapper"),s.children.splice(l,c.length,e)}else a(c[0],i,"token");else a(s,i,"line")}function a(e,t,r){let n=t.properties||{},i=t.transform||(e=>e);return e.tagName=t.tagName||"span",e.properties={...e.properties,...n,class:e.properties.class},t.properties?.class&&tO(e,t.properties.class),e=i(e,r)||e}let s=[];for(let e of r.decorations.sort((e,t)=>t.start.offset-e.start.offset||e.end.offset-t.end.offset)){let{start:t,end:r}=e;if(t.line===r.line)i(t.line,t.character,r.character,e);else if(t.line<r.line){i(t.line,t.character,1/0,e);for(let i=t.line+1;i<r.line;i++)s.unshift(()=>{var t;n[t=i]=a(n[t],e,"line")});i(r.line,0,r.character,e)}}s.forEach(e=>e())}}}()];function tK(e){let t=function(e){let t=[],r=[],n=[];for(let i of e)switch(i.enforce){case"pre":t.push(i);break;case"post":r.push(i);break;default:n.push(i)}return{pre:t,post:r,normal:n}}(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...tQ]}var tX=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],tJ={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function tZ(e){let t=e.shift();if("2"===t){let t=e.splice(0,3).map(e=>Number.parseInt(e));if(3!==t.length||t.some(e=>Number.isNaN(e)))return;return{type:"rgb",rgb:t}}if("5"===t){let t=e.shift();if(t)return{type:"table",index:Number(t)}}}var tY={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};let t0={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function t1(e,t,r={}){var n,i;let a,s,{theme:o=e.getLoadedThemes()[0]}=r,l=e.resolveLangAlias(r.lang||"text");if(tj(l)||tB(o))return tD(t).map(e=>[{content:e[0],offset:e[1]}]);let{theme:u,colorMap:c}=e.setTheme(o);if("ansi"===l){let e,n,i,a,s,o,l;return e=tR(u,r),n=tD(t),i=function(e=tY){let t;function r(e){return`#${e.map(e=>Math.max(0,Math.min(e,255)).toString(16).padStart(2,"0")).join("")}`}return{value:function(n){switch(n.type){case"named":return e[n.name];case"rgb":return r(n.rgb);case"table":var i;return i=n.index,function(){if(t)return t;t=[];for(let r=0;r<tX.length;r++)t.push(e[tX[r]]);let n=[0,95,135,175,215,255];for(let e=0;e<6;e++)for(let i=0;i<6;i++)for(let a=0;a<6;a++)t.push(r([n[e],n[i],n[a]]));let i=8;for(let e=0;e<24;e++,i+=10)t.push(r([i,i,i]));return t}()[i]}}}}(Object.fromEntries(tX.map(e=>{let t=`terminal.ansi${e[0].toUpperCase()}${e.substring(1)}`;return[e,u.colors?.[t]||t0[e]]}))),a=null,s=null,o=new Set,l={parse(e){let t=[],r=0;do{let n=function(e,t){let r=e.indexOf("\x1b",t);if(-1!==r&&"["===e[r+1]){let t=e.indexOf("m",r);if(-1!==t)return{sequence:e.substring(r+2,t).split(";"),startPosition:r,position:t+1}}return{position:e.length}}(e,r),i=n.sequence?e.substring(r,n.startPosition):e.substring(r);if(i.length>0&&t.push({value:i,foreground:a,background:s,decorations:new Set(o)}),n.sequence){let e=function(e){let t=[];for(;e.length>0;){let r=e.shift();if(!r)continue;let n=Number.parseInt(r);if(!Number.isNaN(n))if(0===n)t.push({type:"resetAll"});else if(n<=9)tJ[n]&&t.push({type:"setDecoration",value:tJ[n]});else if(n<=29){let e=tJ[n-20];e&&(t.push({type:"resetDecoration",value:e}),"dim"===e&&t.push({type:"resetDecoration",value:"bold"}))}else if(n<=37)t.push({type:"setForegroundColor",value:{type:"named",name:tX[n-30]}});else if(38===n){let r=tZ(e);r&&t.push({type:"setForegroundColor",value:r})}else if(39===n)t.push({type:"resetForegroundColor"});else if(n<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:tX[n-40]}});else if(48===n){let r=tZ(e);r&&t.push({type:"setBackgroundColor",value:r})}else 49===n?t.push({type:"resetBackgroundColor"}):53===n?t.push({type:"setDecoration",value:"overline"}):55===n?t.push({type:"resetDecoration",value:"overline"}):n>=90&&n<=97?t.push({type:"setForegroundColor",value:{type:"named",name:tX[n-90+8]}}):n>=100&&n<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:tX[n-100+8]}})}return t}(n.sequence);for(let t of e)"resetAll"===t.type?(a=null,s=null,o.clear()):"resetForegroundColor"===t.type?a=null:"resetBackgroundColor"===t.type?s=null:"resetDecoration"===t.type&&o.delete(t.value);for(let t of e)"setForegroundColor"===t.type?a=t.value:"setBackgroundColor"===t.type?s=t.value:"setDecoration"===t.type&&o.add(t.value)}r=n.position}while(r<e.length)return t}},n.map(t=>l.parse(t[0]).map(r=>{let n,a;r.decorations.has("reverse")?(n=r.background?i.value(r.background):u.bg,a=r.foreground?i.value(r.foreground):u.fg):(n=r.foreground?i.value(r.foreground):u.fg,a=r.background?i.value(r.background):void 0),n=t$(n,e),a=t$(a,e),r.decorations.has("dim")&&(n=function(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let e=t[1];if(8===e.length){let t=Math.round(Number.parseInt(e.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${e.slice(0,6)}${t}`}if(6===e.length)return`#${e}80`;if(4===e.length){let t=e[0],r=e[1],n=e[2],i=e[3],a=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${t}${t}${r}${r}${n}${n}${a}`}else if(3===e.length){let t=e[0],r=e[1],n=e[2];return`#${t}${t}${r}${r}${n}${n}80`}}let r=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return r?`var(${r[1]}-dim)`:e}(n));let s=X.None;return r.decorations.has("bold")&&(s|=X.Bold),r.decorations.has("italic")&&(s|=X.Italic),r.decorations.has("underline")&&(s|=X.Underline),r.decorations.has("strikethrough")&&(s|=X.Strikethrough),{content:r.value,offset:t[1],color:n,bgColor:a,fontStyle:s}}))}let d=e.getLanguage(r.lang||"text");if(r.grammarState){if(r.grammarState.lang!==d.name)throw new B(`Grammar state language "${r.grammarState.lang}" does not match highlight language "${d.name}"`);if(!r.grammarState.themes.includes(u.name))throw new B(`Grammar state themes "${r.grammarState.themes}" do not contain highlight theme "${u.name}"`)}return s=new tV((a=t2(t,n=d,i=u,c,r)).stateStack,n.name,i.name),tq(a.tokens,s),a.tokens}function t2(e,t,r,n,i){let a=tR(r,i),{tokenizeMaxLineLength:s=0,tokenizeTimeLimit:o=500}=i,l=tD(e),u=i.grammarState?function(e,t){if(!(e instanceof tV))throw new B("Invalid grammar state");return e.getInternalStack(t)}(i.grammarState,r.name)??eK:null!=i.grammarContextCode?t2(i.grammarContextCode,t,r,n,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack:eK,c=[],d=[];for(let e=0,p=l.length;e<p;e++){let p,h,[f,m]=l[e];if(""===f){c=[],d.push([]);continue}if(s>0&&f.length>=s){c=[],d.push([{content:f,offset:m,color:"",fontStyle:0}]);continue}i.includeExplanation&&(p=t.tokenizeLine(f,u,o).tokens,h=0);let g=t.tokenizeLine2(f,u,o),y=g.tokens.length/2;for(let e=0;e<y;e++){let t=g.tokens[2*e],s=e+1<y?g.tokens[2*e+2]:f.length;if(t===s)continue;let o=g.tokens[2*e+1],l=t$(n[et.getForeground(o)],a),u=et.getFontStyle(o),d={content:f.substring(t,s),offset:m+t,color:l,fontStyle:u};if(i.includeExplanation){let e=[];if("scopeName"!==i.includeExplanation)for(let t of r.settings){let r;switch(typeof t.scope){case"string":r=t.scope.split(/,/).map(e=>e.trim());break;case"object":r=t.scope;break;default:continue}e.push({settings:t,selectors:r.map(e=>e.split(/ /))})}d.explanation=[];let n=0;for(;t+n<s;){let t=p[h],r=f.substring(t.startIndex,t.endIndex);n+=r.length,d.explanation.push({content:r,scopes:"scopeName"===i.includeExplanation?t.scopes.map(e=>({scopeName:e})):function(e,t){let r=[];for(let n=0,i=t.length;n<i;n++){let i=t[n];r[n]={scopeName:i,themeMatches:function(e,t,r){let n=[];for(let{selectors:i,settings:a}of e)for(let e of i)if(function(e,t,r){if(!t5(e[e.length-1],t))return!1;let n=e.length-2,i=r.length-1;for(;n>=0&&i>=0;)t5(e[n],r[i])&&(n-=1),i-=1;return -1===n}(e,t,r)){n.push(a);break}return n}(e,i,t.slice(0,n))}}return r}(e,t.scopes)}),h+=1}}c.push(d)}d.push(c),c=[],u=g.ruleStack}return{tokens:d,stateStack:u}}function t5(e,t){return e===t||t.substring(0,e.length)===e&&"."===t[e.length]}function t6(e,t,r){let n=Object.entries(r.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})),i=n.map(n=>{let i=t1(e,t,{...r,theme:n.theme}),a=tH(i);return{tokens:i,state:a,theme:"string"==typeof n.theme?n.theme:n.theme.name}}),a=function(...e){let t=e.map(()=>[]),r=e.length;for(let n=0;n<e[0].length;n++){let i=e.map(e=>e[n]),a=t.map(()=>[]);t.forEach((e,t)=>e.push(a[t]));let s=i.map(()=>0),o=i.map(e=>e[0]);for(;o.every(e=>e);){let e=Math.min(...o.map(e=>e.content.length));for(let t=0;t<r;t++){let r=o[t];r.content.length===e?(a[t].push(r),s[t]+=1,o[t]=i[t][s[t]]):(a[t].push({...r,content:r.content.slice(0,e)}),o[t]={...r,content:r.content.slice(e),offset:r.offset+e})}}}return t}(...i.map(e=>e.tokens)),s=a[0].map((e,t)=>e.map((e,i)=>{let s={content:e.content,variants:{},offset:e.offset};return"includeExplanation"in r&&r.includeExplanation&&(s.explanation=e.explanation),a.forEach((e,r)=>{let{content:a,explanation:o,offset:l,...u}=e[t][i];s.variants[n[r].color]=u}),s})),o=i[0].state?new tV(Object.fromEntries(i.map(e=>[e.theme,e.state?.getInternalStack(e.theme)])),i[0].state.lang):void 0;return o&&tq(s,o),s}function t3(e,t,r){let n,i,a,s,o,l;if("themes"in r){let{defaultColor:u="light",cssVariablePrefix:c="--shiki-",colorsRendering:d="css-vars"}=r,p=Object.entries(r.themes).filter(e=>e[1]).map(e=>({color:e[0],theme:e[1]})).sort((e,t)=>e.color===u?-1:+(t.color===u));if(0===p.length)throw new B("`themes` option must not be empty");let h=t6(e,t,r);if(l=tH(h),u&&tG!==u&&!p.find(e=>e.color===u))throw new B(`\`themes\` option must contain the defaultColor key \`${u}\``);let f=p.map(t=>e.getTheme(t.theme)),m=p.map(e=>e.color);a=h.map(e=>e.map(e=>(function(e,t,r,n,i="css-vars"){let a={content:e.content,explanation:e.explanation,offset:e.offset},s=t.map(t=>tF(e.variants[t])),o=new Set(s.flatMap(e=>Object.keys(e))),l={},u=(e,n)=>{let i="color"===n?"":"background-color"===n?"-bg":`-${n}`;return r+t[e]+("color"===n?"":i)};return s.forEach((e,r)=>{for(let a of o){let o=e[a]||"inherit";if(0===r&&n&&tU.includes(a))if(n===tG&&s.length>1){let e=t.findIndex(e=>"light"===e),n=t.findIndex(e=>"dark"===e);if(-1===e||-1===n)throw new B('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let c=s[e][a]||"inherit",d=s[n][a]||"inherit";l[a]=`light-dark(${c}, ${d})`,"css-vars"===i&&(l[u(r,a)]=o)}else l[a]=o;else"css-vars"===i&&(l[u(r,a)]=o)}}),a.htmlStyle=l,a})(e,m,c,u,d))),l&&tq(a,l);let g=p.map(e=>tR(e.theme,r));i=t8(p,f,g,c,u,"fg",d),n=t8(p,f,g,c,u,"bg",d),s=`shiki-themes ${f.map(e=>e.name).join(" ")}`,o=u?void 0:[i,n].join(";")}else if("theme"in r){let o=tR(r.theme,r);a=t1(e,t,r);let u=e.getTheme(r.theme);n=t$(u.bg,o),i=t$(u.fg,o),s=u.name,l=tH(a)}else throw new B("Invalid options, either `theme` or `themes` must be provided");return{tokens:a,fg:i,bg:n,themeName:s,rootStyle:o,grammarState:l}}function t8(e,t,r,n,i,a,s){return e.map((o,l)=>{let u=t$(t[l][a],r[l])||"inherit",c=`${n+o.color}${"bg"===a?"-bg":""}:${u}`;if(0===l&&i){if(i===tG&&e.length>1){let n=e.findIndex(e=>"light"===e.color),i=e.findIndex(e=>"dark"===e.color);if(-1===n||-1===i)throw new B('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let s=t$(t[n][a],r[n])||"inherit",o=t$(t[i][a],r[i])||"inherit";return`light-dark(${s}, ${o});${c}`}return u}return"css-vars"===s?c:null}).filter(e=>!!e).join(";")}function t4(e,t,r,n={meta:{},options:r,codeToHast:(t,r)=>t4(e,t,r),codeToTokens:(t,r)=>t3(e,t,r)}){let i=t;for(let e of tK(r))i=e.preprocess?.call(n,i,r)||i;let{tokens:a,fg:s,bg:o,themeName:l,rootStyle:u,grammarState:c}=t3(e,i,r),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=r;!0===d?a=a.map(e=>{let t,r=[],n="";return e.forEach((i,a)=>{let s=!(i.fontStyle&&(i.fontStyle&X.Underline||i.fontStyle&X.Strikethrough));s&&i.content.match(/^\s+$/)&&e[a+1]?(void 0===t&&(t=i.offset),n+=i.content):n?(s?r.push({...i,offset:t,content:n+i.content}):r.push({content:n,offset:t},i),t=void 0,n=""):r.push(i)}),r}):"never"===d&&(a=a.map(e=>e.flatMap(e=>{if(e.content.match(/^\s+$/))return e;let t=e.content.match(/^(\s*)(.*?)(\s*)$/);if(!t)return e;let[,r,n,i]=t;if(!r&&!i)return e;let a=[{...e,offset:e.offset+r.length,content:n}];return r&&a.unshift({content:r,offset:e.offset}),i&&a.push({content:i,offset:e.offset+r.length+n.length}),a}))),p&&(a=a.map(e=>{let t=[];for(let r of e){if(0===t.length){t.push({...r});continue}let e=t[t.length-1],n=tW(e.htmlStyle||tF(e)),i=tW(r.htmlStyle||tF(r)),a=e.fontStyle&&(e.fontStyle&X.Underline||e.fontStyle&X.Strikethrough),s=r.fontStyle&&(r.fontStyle&X.Underline||r.fontStyle&X.Strikethrough);a||s||n!==i?t.push({...r}):e.content+=r.content}return t}));let h={...n,get source(){return i}};for(let e of tK(r))a=e.tokens?.call(h,a)||a;return function(e,t,r,n=tH(e)){let i=tK(t),a=[],s={type:"root",children:[]},{structure:o="classic",tabindex:l="0"}=t,u={class:`shiki ${t.themeName||""}`};for(let[e,r]of(!1!==t.rootStyle&&(null!=t.rootStyle?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),!1!==l&&null!=l&&(u.tabindex=l.toString()),Object.entries(t.meta||{})))e.startsWith("_")||(u[e]=r);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:a},p=[],h={...r,structure:o,addClassToHast:tO,get source(){return r.source},get tokens(){return e},get options(){return t},get root(){return s},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((e,t)=>{t&&("inline"===o?s.children.push({type:"element",tagName:"br",properties:{},children:[]}):"classic"===o&&a.push({type:"text",value:"\n"}));let r={type:"element",tagName:"span",properties:{class:"line"},children:[]},n=0;for(let a of e){let e={type:"element",tagName:"span",properties:{...a.htmlAttrs},children:[{type:"text",value:a.content}]},l=tW(a.htmlStyle||tF(a));for(let s of(l&&(e.properties.style=l),i))e=s?.span?.call(h,e,t+1,n,r,a)||e;"inline"===o?s.children.push(e):"classic"===o&&r.children.push(e),n+=a.content.length}if("classic"===o){for(let e of i)r=e?.line?.call(h,r,t+1)||r;p.push(r),a.push(r)}else"inline"===o&&p.push(r)}),"classic"===o){for(let e of i)d=e?.code?.call(h,d)||d;for(let e of(c.children.push(d),i))c=e?.pre?.call(h,c)||c;s.children.push(c)}else if("inline"===o){let e=[],t={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let r of s.children)"element"===r.type&&"br"===r.tagName?(e.push(t),t={type:"element",tagName:"span",properties:{class:"line"},children:[]}):("element"===r.type||"text"===r.type)&&t.children.push(r);e.push(t);let r={type:"element",tagName:"code",properties:{},children:e};for(let e of i)r=e?.code?.call(h,r)||r;s.children=[];for(let e=0;e<r.children.length;e++){e>0&&s.children.push({type:"element",tagName:"br",properties:{},children:[]});let t=r.children[e];"element"===t.type&&s.children.push(...t.children)}}let f=s;for(let e of i)f=e?.root?.call(h,f)||f;return n&&tq(f,n),f}(a,{...r,fg:s,bg:o,themeName:l,rootStyle:!1!==r.rootStyle&&(r.rootStyle??u)},h,c)}let t9=function(e,t){let r=t||tN,n=r.quote||'"';if('"'!==n&&"'"!==n)throw Error("Invalid quote `"+n+"`, expected `'` or `\"`");return({one:tL,all:tP,settings:{omitOptionalTags:r.omitOptionalTags||!1,allowParseErrors:r.allowParseErrors||!1,allowDangerousCharacters:r.allowDangerousCharacters||!1,quoteSmart:r.quoteSmart||!1,preferUnquoted:r.preferUnquoted||!1,tightAttributes:r.tightAttributes||!1,upperDoctype:r.upperDoctype||!1,tightDoctype:r.tightDoctype||!1,bogusComments:r.bogusComments||!1,tightCommaSeparatedLists:r.tightCommaSeparatedLists||!1,tightSelfClosing:r.tightSelfClosing||!1,collapseEmptyAttributes:r.collapseEmptyAttributes||!1,allowDangerousHtml:r.allowDangerousHtml||!1,voids:r.voids||eX.htmlVoidElements,characterReferences:r.characterReferences||tE,closeSelfClosing:r.closeSelfClosing||!1,closeEmptyElements:r.closeEmptyElements||!1},schema:"svg"===r.space?eJ.svg:eJ.html,quote:n,alternative:'"'===n?"'":'"'}).one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)},t7="__shiki_resolved";function re(e){if(e?.[t7])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:r,fg:n}=t;if(!r||!n){let e=t.settings?t.settings.find(e=>!e.name&&!e.scope):void 0;e?.settings?.foreground&&(n=e.settings.foreground),e?.settings?.background&&(r=e.settings.background),!n&&t?.colors?.["editor.foreground"]&&(n=t.colors["editor.foreground"]),!r&&t?.colors?.["editor.background"]&&(r=t.colors["editor.background"]),n||(n="light"===t.type?"#333333":"#bbbbbb"),r||(r="light"===t.type?"#fffffe":"#1e1e1e"),t.fg=n,t.bg=r}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0,a=new Map;function s(e){if(a.has(e))return a.get(e);i+=1;let r=`#${i.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${r}`]?s(e):(a.set(e,r),r)}for(let e of(t.settings=t.settings.map(e=>{let r=e.settings?.foreground&&!e.settings.foreground.startsWith("#"),n=e.settings?.background&&!e.settings.background.startsWith("#");if(!r&&!n)return e;let i={...e,settings:{...e.settings}};if(r){let r=s(e.settings.foreground);t.colorReplacements[r]=e.settings.foreground,i.settings.foreground=r}if(n){let r=s(e.settings.background);t.colorReplacements[r]=e.settings.background,i.settings.background=r}return i}),Object.keys(t.colors||{})))if(("editor.foreground"===e||"editor.background"===e||e.startsWith("terminal.ansi"))&&!t.colors[e]?.startsWith("#")){let r=s(t.colors[e]);t.colorReplacements[r]=t.colors[e],t.colors[e]=r}return Object.defineProperty(t,t7,{enumerable:!1,writable:!1,value:!0}),t}async function rt(e){return Array.from(new Set((await Promise.all(e.filter(e=>!tM(e)).map(async e=>await tT(e).then(e=>Array.isArray(e)?e:[e])))).flat()))}async function rr(e){return(await Promise.all(e.map(async e=>tB(e)?null:re(await tT(e))))).filter(e=>!!e)}class rn extends Error{constructor(e){super(e),this.name="ShikiError"}}function ri(e,t){if(!t)return e;if(t[e]){let r=new Set([e]);for(;t[e];){if(e=t[e],r.has(e))throw new rn(`Circular alias \`${Array.from(r).join(" -> ")} -> ${e}\``);r.add(e)}}return e}class ra extends eQ{constructor(e,t,r,n={}){super(e),this._resolver=e,this._themes=t,this._langs=r,this._alias=n,this._themes.map(e=>this.loadTheme(e)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return"string"==typeof e?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=re(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=H.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=ri(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(t=>t.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let r={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let n=this.loadGrammarWithConfiguration(e.scopeName,1,r);if(n.name=e.name,this._resolvedGrammars.set(e.name,n),e.aliases&&e.aliases.forEach(t=>{this._alias[t]=e.name}),this._loadedLanguagesCache=null,t.size)for(let e of t)this._resolvedGrammars.delete(e.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(e.scopeName),this._syncRegistry?._grammars?.delete(e.scopeName),this.loadLanguage(this._langMap.get(e.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let t of e)this.resolveEmbeddedLanguages(t);let t=Array.from(this._langGraph.entries()),r=t.filter(([e,t])=>!t);if(r.length){let e=t.filter(([e,t])=>{if(!t)return!1;let n=t.embeddedLanguages||t.embeddedLangs;return n?.some(e=>r.map(([e])=>e).includes(e))}).filter(e=>!r.includes(e));throw new rn(`Missing languages ${r.map(([e])=>`\`${e}\``).join(", ")}, required by ${e.map(([e])=>`\`${e}\``).join(", ")}`)}for(let[e,r]of t)this._resolver.addLanguage(r);for(let[e,r]of t)this.loadLanguage(r)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let e of t)this._langGraph.set(e,this._langMap.get(e))}}class rs{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:t=>e.createScanner(t),createOnigString:t=>e.createString(t)},t.forEach(e=>this.addLanguage(e))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split("."),r=[];for(let e=1;e<=t.length;e++){let n=t.slice(0,e).join(".");r=[...r,...this._injections.get(n)||[]]}return r}}let ro=0;async function rl(e){e.engine||function(e,t=3){if(!(t>3))if(1)console.trace(`[SHIKI DEPRECATE]: ${e}`);else throw Error(`[SHIKI DEPRECATE]: ${e}`)}("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,r,n]=await Promise.all([rr(e.themes||[]),rt(e.langs||[]),e.engine]);return function(e){let t;ro+=1,!1!==e.warnings&&ro>=10&&ro%10==0&&console.warn(`[Shiki] ${ro} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let r=!1;if(!e.engine)throw new rn("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),i=(e.themes||[]).flat(1).map(re),a=new ra(new rs(e.engine,n),i,n,e.langAlias);function s(e){if("none"===e)return{bg:"",fg:"",name:"none",settings:[],type:"dark"};u();let t=a.getTheme(e);if(!t)throw new rn(`Theme \`${e}\` not found, you may need to load it first`);return t}function o(...e){u(),a.loadLanguages(e.flat(1))}function l(...e){for(let t of(u(),e.flat(1)))a.loadTheme(t)}function u(){if(r)throw new rn("Shiki instance has been disposed")}function c(){r||(r=!0,a.dispose(),ro-=1)}return{setTheme:function(e){u();let r=s(e);return t!==e&&(a.setTheme(r),t=e),{theme:r,colorMap:a.getColorMap()}},getTheme:s,getLanguage:function(e){u();let t=a.getGrammar("string"==typeof e?e:e.name);if(!t)throw new rn(`Language \`${e}\` not found, you may need to load it first`);return t},getLoadedThemes:function(){return u(),a.getLoadedThemes()},getLoadedLanguages:function(){return u(),a.getLoadedLanguages()},resolveLangAlias:function(t){return ri(t,e.langAlias)},loadLanguage:async function(...e){return o(await rt(e))},loadLanguageSync:o,loadTheme:async function(...e){return u(),l(await rr(e))},loadThemeSync:l,dispose:c,[Symbol.dispose]:c}}({...e,themes:t,langs:r,engine:n})}async function ru(e){let t=await rl(e);return{getLastGrammarState:(...e)=>(function(...e){if(2===e.length)return tH(e[1]);let[t,r,n={}]=e,{lang:i="text",theme:a=t.getLoadedThemes()[0]}=n;if(tj(i)||tB(a))throw new B("Plain language does not have grammar state");if("ansi"===i)throw new B("ANSI language does not have grammar state");let{theme:s,colorMap:o}=t.setTheme(a),l=t.getLanguage(i);return new tV(t2(r,l,s,o,n).stateStack,l.name,s.name)})(t,...e),codeToTokensBase:(e,r)=>t1(t,e,r),codeToTokensWithThemes:(e,r)=>t6(t,e,r),codeToTokens:(e,r)=>t3(t,e,r),codeToHast:(e,r)=>t4(t,e,r),codeToHtml:(e,r)=>(function(e,t,r){let n={meta:{},options:r,codeToHast:(t,r)=>t4(e,t,r),codeToTokens:(t,r)=>t3(e,t,r)},i=t9(t4(e,t,r,n));for(let e of tK(r))i=e.postprocess?.call(n,i,r)||i;return i})(t,e,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}let rc=Object.fromEntries([{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:()=>e.A(71233)},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:()=>e.A(69905)},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:()=>e.A(21579)},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:()=>e.A(17347)},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:()=>e.A(79579)},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:()=>e.A(17235)},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:()=>e.A(82774)},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:()=>e.A(52161)},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:()=>e.A(10803)},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:()=>e.A(60897)},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:()=>e.A(88958)},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:()=>e.A(24347)},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:()=>e.A(39415)},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:()=>e.A(12625)},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:()=>e.A(88984)},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:()=>e.A(99547)},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:()=>e.A(26878)},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:()=>e.A(97301)},{id:"github-light",displayName:"GitHub Light",type:"light",import:()=>e.A(4877)},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:()=>e.A(36193)},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:()=>e.A(40608)},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:()=>e.A(96394)},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:()=>e.A(21243)},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:()=>e.A(10707)},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:()=>e.A(17644)},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:()=>e.A(5583)},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:()=>e.A(17669)},{id:"horizon",displayName:"Horizon",type:"dark",import:()=>e.A(63824)},{id:"horizon-bright",displayName:"Horizon Bright",type:"dark",import:()=>e.A(86278)},{id:"houston",displayName:"Houston",type:"dark",import:()=>e.A(27289)},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:()=>e.A(88348)},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:()=>e.A(44132)},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:()=>e.A(14230)},{id:"laserwave",displayName:"LaserWave",type:"dark",import:()=>e.A(71202)},{id:"light-plus",displayName:"Light Plus",type:"light",import:()=>e.A(25402)},{id:"material-theme",displayName:"Material Theme",type:"dark",import:()=>e.A(14117)},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:()=>e.A(90077)},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:()=>e.A(32896)},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:()=>e.A(26230)},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:()=>e.A(16100)},{id:"min-dark",displayName:"Min Dark",type:"dark",import:()=>e.A(47952)},{id:"min-light",displayName:"Min Light",type:"light",import:()=>e.A(28043)},{id:"monokai",displayName:"Monokai",type:"dark",import:()=>e.A(17390)},{id:"night-owl",displayName:"Night Owl",type:"dark",import:()=>e.A(67165)},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:()=>e.A(34685)},{id:"nord",displayName:"Nord",type:"dark",import:()=>e.A(87e3)},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:()=>e.A(93697)},{id:"one-light",displayName:"One Light",type:"light",import:()=>e.A(52159)},{id:"plastic",displayName:"Plastic",type:"dark",import:()=>e.A(71284)},{id:"poimandres",displayName:"Poimandres",type:"dark",import:()=>e.A(1663)},{id:"red",displayName:"Red",type:"dark",import:()=>e.A(20216)},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:()=>e.A(55440)},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:()=>e.A(78800)},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:()=>e.A(23257)},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:()=>e.A(55807)},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:()=>e.A(95487)},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:()=>e.A(36490)},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:()=>e.A(48663)},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:()=>e.A(15839)},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:()=>e.A(35719)},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:()=>e.A(39152)},{id:"vesper",displayName:"Vesper",type:"dark",import:()=>e.A(2271)},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:()=>e.A(13655)},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:()=>e.A(61619)},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:()=>e.A(55196)}].map(e=>[e.id,e.import]));var rd=e.i(20688);class rp extends Error{constructor(e){super(e),this.name="ShikiError"}}function rh(){return"u">typeof performance?performance.now():Date.now()}let rf=(e,t)=>e+(t-e%t)%t;async function rm(e){let t,r,n={};function i(e){r=e,n.HEAPU8=new Uint8Array(e),n.HEAPU32=new Uint32Array(e)}let a="u">typeof TextDecoder?new TextDecoder("utf8"):void 0;function s(e,t){return e?function(e,t,r=1024){let n=t+r,i=t;for(;e[i]&&!(i>=n);)++i;if(i-t>16&&e.buffer&&a)return a.decode(e.subarray(t,i));let s="";for(;t<i;){let r=e[t++];if(!(128&r)){s+=String.fromCharCode(r);continue}let n=63&e[t++];if((224&r)==192){s+=String.fromCharCode((31&r)<<6|n);continue}let i=63&e[t++];if((r=(240&r)==224?(15&r)<<12|n<<6|i:(7&r)<<18|n<<12|i<<6|63&e[t++])<65536)s+=String.fromCharCode(r);else{let e=r-65536;s+=String.fromCharCode(55296|e>>10,56320|1023&e)}}return s}(n.HEAPU8,e,t):""}let o={emscripten_get_now:rh,emscripten_memcpy_big:function(e,t,r){n.HEAPU8.copyWithin(e,t,t+r)},emscripten_resize_heap:function(e){let a=n.HEAPU8.length;if((e>>>=0)>0x80000000)return!1;for(let n=1;n<=4;n*=2){let s=a*(1+.2/n);if(s=Math.min(s,e+0x6000000),function(e){try{return t.grow(e-r.byteLength+65535>>>16),i(t.buffer),1}catch{}}(Math.min(0x80000000,rf(Math.max(e,s),65536))))return!0}return!1},fd_write:()=>0};async function l(){let r=await e({env:o,wasi_snapshot_preview1:o});i((t=r.memory).buffer),Object.assign(n,r),n.UTF8ToString=s}return await l(),n}var rg=Object.defineProperty,ry=(e,t,r)=>{let n;return(n="symbol"!=typeof t?t+"":t)in e?rg(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r};let rb=null;class rw{constructor(e){ry(this,"utf16Length"),ry(this,"utf8Length"),ry(this,"utf16Value"),ry(this,"utf8Value"),ry(this,"utf16OffsetToUtf8"),ry(this,"utf8OffsetToUtf16");const t=e.length,r=rw._utf8ByteLength(e),n=r!==t,i=n?new Uint32Array(t+1):null;n&&(i[t]=r);const a=n?new Uint32Array(r+1):null;n&&(a[r]=t);const s=new Uint8Array(r);let o=0;for(let r=0;r<t;r++){const l=e.charCodeAt(r);let u=l,c=!1;if(l>=55296&&l<=56319&&r+1<t){const t=e.charCodeAt(r+1);t>=56320&&t<=57343&&(u=(l-55296<<10)+65536|t-56320,c=!0)}n&&(i[r]=o,c&&(i[r+1]=o),u<=127?a[o+0]=r:u<=2047?(a[o+0]=r,a[o+1]=r):u<=65535?(a[o+0]=r,a[o+1]=r,a[o+2]=r):(a[o+0]=r,a[o+1]=r,a[o+2]=r,a[o+3]=r)),u<=127?s[o++]=u:(u<=2047?s[o++]=192|(1984&u)>>>6:(u<=65535?s[o++]=224|(61440&u)>>>12:(s[o++]=240|(1835008&u)>>>18,s[o++]=128|(258048&u)>>>12),s[o++]=128|(4032&u)>>>6),s[o++]=128|(63&u)>>>0),c&&r++}this.utf16Length=t,this.utf8Length=r,this.utf16Value=e,this.utf8Value=s,this.utf16OffsetToUtf8=i,this.utf8OffsetToUtf16=a}static _utf8ByteLength(e){let t=0;for(let r=0,n=e.length;r<n;r++){let i=e.charCodeAt(r),a=i,s=!1;if(i>=55296&&i<=56319&&r+1<n){let t=e.charCodeAt(r+1);t>=56320&&t<=57343&&(a=(i-55296<<10)+65536|t-56320,s=!0)}a<=127?t+=1:a<=2047?t+=2:a<=65535?t+=3:t+=4,s&&r++}return t}createString(e){let t=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}}let rx=class e{constructor(t){if(ry(this,"id",++e.LAST_ID),ry(this,"_onigBinding"),ry(this,"content"),ry(this,"utf16Length"),ry(this,"utf8Length"),ry(this,"utf16OffsetToUtf8"),ry(this,"utf8OffsetToUtf16"),ry(this,"ptr"),!rb)throw new rp("Must invoke loadWasm first.");this._onigBinding=rb,this.content=t;const r=new rw(t);this.utf16Length=r.utf16Length,this.utf8Length=r.utf8Length,this.utf16OffsetToUtf8=r.utf16OffsetToUtf8,this.utf8OffsetToUtf16=r.utf8OffsetToUtf16,this.utf8Length<1e4&&!e._sharedPtrInUse?(e._sharedPtr||(e._sharedPtr=rb.omalloc(1e4)),e._sharedPtrInUse=!0,rb.HEAPU8.set(r.utf8Value,e._sharedPtr),this.ptr=e._sharedPtr):this.ptr=r.createString(rb)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===e._sharedPtr?e._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};ry(rx,"LAST_ID",0),ry(rx,"_sharedPtr",0),ry(rx,"_sharedPtrInUse",!1);class rv{constructor(e){if(ry(this,"_onigBinding"),ry(this,"_ptr"),!rb)throw new rp("Must invoke loadWasm first.");const t=[],r=[];for(let n=0,i=e.length;n<i;n++){const i=new rw(e[n]);t[n]=i.createString(rb),r[n]=i.utf8Length}const n=rb.omalloc(4*e.length);rb.HEAPU32.set(t,n/4);const i=rb.omalloc(4*e.length);rb.HEAPU32.set(r,i/4);const a=rb.createOnigScanner(n,i,e.length);for(let r=0,n=e.length;r<n;r++)rb.ofree(t[r]);rb.ofree(i),rb.ofree(n),0===a&&function(e){throw new rp(e.UTF8ToString(e.getLastOnigError()))}(rb),this._onigBinding=rb,this._ptr=a}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,t,r){let n=0;if("number"==typeof r&&(n=r),"string"==typeof e){e=new rx(e);let r=this._findNextMatchSync(e,t,!1,n);return e.dispose(),r}return this._findNextMatchSync(e,t,!1,n)}_findNextMatchSync(e,t,r,n){let i=this._onigBinding,a=i.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(t),n);if(0===a)return null;let s=i.HEAPU32,o=a/4,l=s[o++],u=s[o++],c=[];for(let t=0;t<u;t++){let r=e.convertUtf8OffsetToUtf16(s[o++]),n=e.convertUtf8OffsetToUtf16(s[o++]);c[t]={start:r,end:n,length:n-r}}return{index:l,captureIndices:c}}}function rA(e){return t=>WebAssembly.instantiate(e,t)}async function r_(e){return e&&await (r||(r=async function(){rb=await rm(async t=>{let r=e;if("function"==typeof(r=await r)&&(r=await r(t)),"function"==typeof r&&(r=await r(t)),"function"==typeof r.instantiator)r=await r.instantiator(t);else if("function"==typeof r.default)r=await r.default(t);else{var n,i,a,s;if(void 0!==r.data&&(r=r.data),n=r,"u">typeof Response&&n instanceof Response){r="function"==typeof WebAssembly.instantiateStreaming?await (a=r,e=>WebAssembly.instantiateStreaming(a,e))(t):await (s=r,async e=>{let t=await s.arrayBuffer();return WebAssembly.instantiate(t,e)})(t)}else(i=r,"u">typeof ArrayBuffer&&(i instanceof ArrayBuffer||ArrayBuffer.isView(i))||void 0!==rd.Buffer&&rd.Buffer.isBuffer?.(i)||"u">typeof SharedArrayBuffer&&i instanceof SharedArrayBuffer||"u">typeof Uint32Array&&i instanceof Uint32Array||r instanceof WebAssembly.Module)?r=await rA(r)(t):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await rA(r.default)(t))}return"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}())),{createScanner:e=>new rv(e.map(e=>"string"==typeof e?e:e.source)),createString:e=>new rx(e)}}let rk=(n=(l={langs:M,themes:rc,engine:()=>r_(e.A(62631))}).langs,i=l.themes,a=l.engine,async function(e){function t(t){if("string"==typeof t){if(tM(t=e.langAlias?.[t]||t))return[];let r=n[t];if(!r)throw new B(`Language \`${t}\` is not included in this bundle. You may want to load it from external source.`);return r}return t}function r(e){if(tB(e))return"none";if("string"==typeof e){let t=i[e];if(!t)throw new B(`Theme \`${e}\` is not included in this bundle. You may want to load it from external source.`);return t}return e}let s=(e.themes??[]).map(e=>r(e)),o=(e.langs??[]).map(e=>t(e)),l=await ru({engine:e.engine??a(),...e,themes:s,langs:o});return{...l,loadLanguage:(...e)=>l.loadLanguage(...e.map(t)),loadTheme:(...e)=>l.loadTheme(...e.map(r)),getBundledLanguages:()=>n,getBundledThemes:()=>i}});function rC(e){if(1!=[...e].length)throw Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}let rS=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),rN=String.raw;function rE(e,t){if(null==e)throw Error(t??"Value expected");return e}let rI=rN`\[\^?`,rL=`c.? | C(?:-.?)?|${rN`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${rN`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${rN`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${rN`o\{[^\}]*\}?`}|${rN`\d{1,3}`}`,rP=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,rR=RegExp(rN`
|
|
2
|
+
\\ (?:
|
|
3
|
+
${rL}
|
|
4
|
+
| [gk]<[^>]*>?
|
|
5
|
+
| [gk]'[^']*'?
|
|
6
|
+
| .
|
|
7
|
+
)
|
|
8
|
+
| \( (?:
|
|
9
|
+
\? (?:
|
|
10
|
+
[:=!>({]
|
|
11
|
+
| <[=!]
|
|
12
|
+
| <[^>]*>
|
|
13
|
+
| '[^']*'
|
|
14
|
+
| ~\|?
|
|
15
|
+
| #(?:[^)\\]|\\.?)*
|
|
16
|
+
| [^:)]*[:)]
|
|
17
|
+
)?
|
|
18
|
+
| \*[^\)]*\)?
|
|
19
|
+
)?
|
|
20
|
+
| (?:${rP.source})+
|
|
21
|
+
| ${rI}
|
|
22
|
+
| .
|
|
23
|
+
`.replace(/\s+/g,""),"gsu"),r$=RegExp(rN`
|
|
24
|
+
\\ (?:
|
|
25
|
+
${rL}
|
|
26
|
+
| .
|
|
27
|
+
)
|
|
28
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
29
|
+
| ${rI}
|
|
30
|
+
| &&
|
|
31
|
+
| .
|
|
32
|
+
`.replace(/\s+/g,""),"gsu");function rT(e,{inCharClass:t}){let r=e[1];if("c"===r||"C"===r){var n,i=e;let t="c"===i[1]?i[2]:i[3];if(!t||!/[A-Za-z]/.test(t))throw Error(`Unsupported control character "${i}"`);return rB(rC(t.toUpperCase())-64,i)}if("dDhHsSwW".includes(r)){let t;return rD({d:"digit",h:"hex",s:"space",w:"word"}[t=(n=e)[1].toLowerCase()],n,{negate:n[1]!==t})}if(e.startsWith(rN`\o{`))throw Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(3===e.length)throw Error(`Incomplete or invalid Unicode property "${e}"`);return function(e){let{p:t,neg:r,value:n}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return rD("property",e,{value:n,negate:"P"===t&&!r||"p"===t&&!!r})}(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let t=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),r=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(t)),n=new TextEncoder;return[...r].map(e=>{let t=[...n.encode(e)].map(e=>`\\x${e.toString(16)}`).join("");return rB(rC(e),t)})}catch{throw Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if("u"===r||"x"===r)return rB(function(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw Error(`Incomplete or invalid escape "${e}"`);return parseInt("{"===e[2]?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2),16)}(e),e);if(rW.has(r))return rB(rW.get(r),e);if(/\d/.test(r))return{type:"EscapedNumber",inCharClass:t,raw:e};if("\\"===e)throw Error(rN`Incomplete escape "\"`);if("M"===r)throw Error(`Unsupported meta "${e}"`);if(2==[...e].length)return rB(e.codePointAt(1),e);throw Error(`Unexpected escape "${e}"`)}function rj(e,t){return{type:"Assertion",kind:e,raw:t}}function rM(e){return{type:"Backreference",raw:e}}function rB(e,t){return{type:"Character",value:e,raw:t}}function rO(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function rD(e,t,r={}){return{type:"CharacterSet",kind:e,...r,raw:t}}function rG(e,t,r={}){return"keep"===e?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:rE(r.flags),raw:t}}function rU(e,t,r={}){return{type:"GroupOpen",kind:e,...r,raw:t}}let rF=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),rW=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function rz(e){let t=null,r,n;if("{"===e[0]){let{minStr:i,maxStr:a}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups;if(+i>1e5||a&&+a>1e5)throw Error("Quantifier value unsupported in Oniguruma");if((r=+i)>(n=void 0===a?+i:""===a?1/0:+a)&&(t="possessive",[r,n]=[n,r]),e.endsWith("?")){if("possessive"===t)throw Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else r=+("+"===e[0]),n="?"===e[0]?1:1/0,t="+"===e[1]?"possessive":"?"===e[1]?"lazy":"greedy";return{type:"Quantifier",kind:t,min:r,max:n,raw:e}}function rq(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function rH(e,t){if(!Array.isArray(e.body))throw Error("Expected node with body array");if(1!==e.body.length)return!1;let r=e.body[0];return!t||Object.keys(t).every(e=>t[e]===r[e])}let rV=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function rQ(e,t={}){var r;let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},i=function(e,t={}){let r={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if("string"!=typeof e)throw Error("String expected as pattern");let n=function(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let r=0;r<e.length;r++){let n=e[r];if(!"imxDPSWy".includes(n))throw Error(`Invalid flag "${n}"`);if("y"===n){if(!/^y{[gw]}/.test(e.slice(r)))throw Error('Invalid or unspecified flag "y" mode');t.textSegmentMode="g"===e[r+2]?"grapheme":"word",r+=3;continue}t[({i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"})[n]]=!0}return t}(r.flags),i=[n.extended],a={captureGroup:r.rules.captureGroup,getCurrentModX:()=>i.at(-1),numOpenGroups:0,popModX(){i.pop()},pushModX(e){i.push(e)},replaceCurrentModX(e){i[i.length-1]=e},singleline:r.rules.singleline},s=[],o;for(rR.lastIndex=0;o=rR.exec(e);){let t=function(e,t,r,n){let[i,a]=r;if("["===r||"[^"===r){let e=function(e,t,r){let n=[rO("^"===t[1],t)],i=1,a;for(r$.lastIndex=r;a=r$.exec(e);){let e=a[0];if("["===e[0]&&":"!==e[1])i++,n.push(rO("^"===e[1],e));else if("]"===e){if("CharacterClassOpen"===n.at(-1).type)n.push(rB(93,e));else if(i--,n.push({type:"CharacterClassClose",raw:e}),!i)break}else{let t=function(e){if("\\"===e[0])return rT(e,{inCharClass:!0});if("["===e[0]){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!rS.has(t.groups.name))throw Error(`Invalid POSIX class "${e}"`);return rD("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return"-"===e?{type:"CharacterClassHyphen",raw:e}:"&&"===e?{type:"CharacterClassIntersector",raw:e}:rB(rC(e),e)}(e);Array.isArray(t)?n.push(...t):n.push(t)}}return{tokens:n,lastIndex:r$.lastIndex||e.length}}(t,r,n);return{tokens:e.tokens,lastIndex:e.lastIndex}}if("\\"===i){if("AbBGyYzZ".includes(a))return{token:rj(r,r)};if(/^\\g[<']/.test(r)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(r))throw Error(`Invalid group name "${r}"`);return{token:{type:"Subroutine",raw:r}}}if(/^\\k[<']/.test(r)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(r))throw Error(`Invalid group name "${r}"`);return{token:rM(r)}}if("K"===a)return{token:rG("keep",r)};if("N"===a||"R"===a)return{token:rD("newline",r,{negate:"N"===a})};if("O"===a)return{token:rD("any",r)};if("X"===a)return{token:rD("text_segment",r)};let e=rT(r,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if("("===i){if("*"===a)return{token:function(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw Error(`Incomplete or invalid named callout "${e}"`);let{name:r,tag:n,args:i}=t.groups;if(!r)throw Error(`Invalid named callout "${e}"`);if(""===n)throw Error(`Named callout tag with empty value not allowed "${e}"`);let a=i?i.split(",").filter(e=>""!==e).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[s,o,l]=a,u=rF.has(r)?r.toLowerCase():"custom";switch(u){case"fail":case"mismatch":case"skip":if(a.length>0)throw Error(`Named callout arguments not allowed "${a}"`);break;case"error":if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if("string"==typeof s)throw Error(`Named callout argument must be a number "${s}"`);break;case"max":if(!a.length||a.length>2)throw Error(`Named callout must have one or two arguments "${a}"`);if("string"==typeof s&&!/^[A-Za-z_]\w*$/.test(s))throw Error(`Named callout argument one must be a tag or number "${s}"`);if(2===a.length&&("number"==typeof o||!/^[<>X]$/.test(o)))throw Error(`Named callout optional argument two must be '<', '>', or 'X' "${o}"`);break;case"count":case"total_count":if(a.length>1)throw Error(`Named callout allows only one argument "${a}"`);if(1===a.length&&("number"==typeof s||!/^[<>X]$/.test(s)))throw Error(`Named callout optional argument must be '<', '>', or 'X' "${s}"`);break;case"cmp":if(3!==a.length)throw Error(`Named callout must have three arguments "${a}"`);if("string"==typeof s&&!/^[A-Za-z_]\w*$/.test(s))throw Error(`Named callout argument one must be a tag or number "${s}"`);if("number"==typeof o||!/^(?:[<>!=]=|[<>])$/.test(o))throw Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${o}"`);if("string"==typeof l&&!/^[A-Za-z_]\w*$/.test(l))throw Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw Error(`Undefined callout name "${r}"`);default:throw Error(`Unexpected named callout kind "${u}"`)}return{type:"NamedCallout",kind:u,tag:n??null,arguments:i?.split(",")??null,raw:e}}(r)};if("(?{"===r)throw Error(`Unsupported callout "${r}"`);if(r.startsWith("(?#")){if(")"!==t[n])throw Error('Unclosed comment group "(?#"');return{lastIndex:n+1}}if(/^\(\?[-imx]+[:)]$/.test(r))return{token:function(e,t){let{on:r,off:n}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;n??="";let i=(t.getCurrentModX()||r.includes("x"))&&!n.includes("x"),a=rq(r),s=rq(n),o={};if(a&&(o.enable=a),s&&(o.disable=s),e.endsWith(")"))return t.replaceCurrentModX(i),rG("flags",e,{flags:o});if(e.endsWith(":"))return t.pushModX(i),t.numOpenGroups++,rU("group",e,{...(a||s)&&{flags:o}});throw Error(`Unexpected flag modifier "${e}"`)}(r,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,"("===r&&!e.captureGroup||"(?:"===r)return{token:rU("group",r)};if("(?>"===r)return{token:rU("atomic",r)};if("(?="===r||"(?!"===r||"(?<="===r||"(?<!"===r)return{token:rU("<"===r[2]?"lookbehind":"lookahead",r,{negate:r.endsWith("!")})};if("("===r&&e.captureGroup||r.startsWith("(?<")&&r.endsWith(">")||r.startsWith("(?'")&&r.endsWith("'"))return{token:rU("capturing",r,{..."("!==r&&{name:r.slice(3,-1)}})};if(r.startsWith("(?~")){if("(?~|"===r)throw Error(`Unsupported absence function kind "${r}"`);return{token:rU("absence_repeater",r)}}throw"(?("===r?Error(`Unsupported conditional "${r}"`):Error(`Invalid or unsupported group option "${r}"`)}if(")"===r){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw Error('Unmatched ")"');return{token:{type:"GroupClose",raw:r}}}if(e.getCurrentModX()){if("#"===r){let e=t.indexOf(`
|
|
33
|
+
`,n);return{lastIndex:-1===e?t.length:e}}if(/^\s$/.test(r)){let e=/\s+/y;return e.lastIndex=n,{lastIndex:e.exec(t)?e.lastIndex:n}}}return"."===r?{token:rD("dot",r)}:"^"===r||"$"===r?{token:rj(e.singleline?({"^":rN`\A`,$:rN`\Z`})[r]:r,r)}:"|"===r?{token:{type:"Alternator",raw:r}}:rP.test(r)?{tokens:function(e){let t,r=[],n=RegExp(rP,"gy");for(;t=n.exec(e);){let e=t[0];if("{"===e[0]){let t=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(e);if(t){let{min:i,max:a}=t.groups;if(+i>+a&&e.endsWith("?")){n.lastIndex--,r.push(rz(e.slice(0,-1)));continue}}}r.push(rz(e))}return r}(r)}:{token:rB(rC(r),r)}}(a,e,o[0],rR.lastIndex);t.tokens?s.push(...t.tokens):t.token&&s.push(t.token),void 0!==t.lastIndex&&(rR.lastIndex=t.lastIndex)}let l=[],u=0;s.filter(e=>"GroupOpen"===e.type).forEach(e=>{"capturing"===e.kind?e.number=++u:"("===e.raw&&l.push(e)}),u||l.forEach((e,t)=>{e.kind="capturing",e.number=t+1});let c=u||l.length;return{tokens:s.map(e=>"EscapedNumber"===e.type?function(e,t){let{raw:r,inCharClass:n}=e,i=r.slice(1);if(!n&&("0"!==i&&1===i.length||"0"!==i[0]&&+i<=t))return[rM(r)];let a=[],s=i.match(/^[0-7]+|\d/g);for(let e=0;e<s.length;e++){let t,n=s[e];if(0===e&&"8"!==n&&"9"!==n){if((t=parseInt(n,8))>127)throw Error(rN`Octal encoded byte above 177 unsupported "${r}"`)}else t=rC(n);a.push(rB(t,(0===e?"\\":"")+n))}return a}(e,c):e).flat(),flags:n}}(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(e,t)=>{let r=i.tokens[s.nextIndex];switch(s.parent=e,s.nextIndex++,r.type){case"Alternator":return rK();case"Assertion":return function({kind:e}){return rX(rE({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===rN`\B`||e===rN`\Y`})}(r);case"Backreference":return function({raw:e},t){let r=/^\\k[<']/.test(e),n=r?e.slice(3,-1):e.slice(1),i=(r,n=!1)=>{let i=t.capturingGroups.length,a=!1;if(r>i)if(t.skipBackrefValidation)a=!0;else throw Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,rJ(n?i+1-r:r,{orphan:a})};if(r){let r=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(n);if(r)return i(+r.groups.num,!!r.groups.sign);if(/[-+]/.test(n))throw Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(n))throw Error(`Group name not defined to the left "${e}"`);return rJ(n)}return i(+n)}(r,s);case"Character":return rY(r.value,{useLastValid:!!t.isCheckingRangeEnd});case"CharacterClassHyphen":return function(e,t){let{tokens:r,walk:n}=e,i=e.parent,a=i.body.at(-1),s=r[e.nextIndex];if(!t.isCheckingRangeEnd&&a&&"CharacterClass"!==a.type&&"CharacterClassRange"!==a.type&&s&&"CharacterClassOpen"!==s.type&&"CharacterClassClose"!==s.type&&"CharacterClassIntersector"!==s.type){let e=n(i,{...t,isCheckingRangeEnd:!0});if("Character"===a.type&&"Character"===e.type)return i.body.pop(),function(e,t){if(t.value<e.value)throw Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}(a,e);throw Error("Invalid character class range")}return rY(rC("-"))}(s,t);case"CharacterClassOpen":return function({negate:e},t,r){let{tokens:n,walk:i}=t,a=[r0()],s=n[t.nextIndex],o=nr(s);for(;"CharacterClassClose"!==o.type;){if("CharacterClassIntersector"===o.type)a.push(r0()),t.nextIndex++;else{let e=a.at(-1);e.body.push(i(e,r))}o=nr(n[t.nextIndex],s)}let l=r0({negate:e});return 1===a.length?l.body=a[0].body:(l.kind="intersection",l.body=a.map(e=>1===e.body.length?e.body[0]:e)),t.nextIndex++,l}(r,s,t);case"CharacterSet":return function({kind:e,negate:t,value:r},n){let{normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:s}=n;if("property"===e){let n=nt(r);if(!rS.has(n)||s?.has(n))return r8(r,{negate:t,normalizeUnknownPropertyNames:i,skipPropertyNameValidation:a,unicodePropertyMap:s});e="posix",r=n}return"posix"===e?function(e,t){let r=!!t?.negate;if(!rS.has(e))throw Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:r}}(r,{negate:t}):r1(e,{negate:t})}(r,s);case"Directive":return function(e,t={}){if("keep"===e)return{type:"Directive",kind:e};if("flags"===e)return{type:"Directive",kind:e,flags:rE(t.flags)};throw Error(`Unexpected directive kind "${e}"`)}(r.kind,{flags:r.flags});case"GroupOpen":return function(e,t,r){var n,i;let{tokens:a,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:l,walk:u}=t,c=function({flags:e,kind:t,name:r,negate:n,number:i}){switch(t){case"absence_repeater":var a="repeater";!1;return{type:"AbsenceFunction",kind:a,body:r4(void 0)};case"atomic":return r2({atomic:!0});case"capturing":return rZ(i,{name:r});case"group":return r2({flags:e});case"lookahead":case"lookbehind":return r5({behind:"lookbehind"===t,negate:n});default:throw Error(`Unexpected group kind "${t}"`)}}(e),d="AbsenceFunction"===c.type,p=ne(c),h=p&&c.negate;if("CapturingGroup"===c.type&&(s.push(c),c.name&&(n=c.name,i=[],o.has(n)||o.set(n,i),o.get(n)).push(c)),d&&r.isInAbsenceFunction)throw Error("Nested absence function not supported by Oniguruma");let f=nn(a[t.nextIndex]);for(;"GroupClose"!==f.type;){if("Alternator"===f.type)c.body.push(rK()),t.nextIndex++;else{let e=c.body.at(-1),t=u(e,{...r,isInAbsenceFunction:r.isInAbsenceFunction||d,isInLookbehind:r.isInLookbehind||p,isInNegLookbehind:r.isInNegLookbehind||h});if(e.body.push(t),(p||r.isInLookbehind)&&!l){let e="Lookbehind includes a pattern not allowed by Oniguruma";if(h||r.isInNegLookbehind){if(r7(t)||"CapturingGroup"===t.type)throw Error(e)}else if(r7(t)||ne(t)&&t.negate)throw Error(e)}}f=nn(a[t.nextIndex])}return t.nextIndex++,c}(r,s,t);case"NamedCallout":var n,a;return n=r.kind,a=r.tag,{type:"NamedCallout",kind:n,tag:a,arguments:r.arguments};case"Quantifier":return function({kind:e,min:t,max:r},n){let i=n.parent,a=i.body.at(-1);if(!a||!rV.has(a.type))throw Error("Quantifier requires a repeatable token");let s=r6(e,t,r,a);return i.body.pop(),s}(r,s);case"Subroutine":return function({raw:e},t){let{capturingGroups:r,subroutines:n}=t,i=e.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i);if(a){let e=+a.groups.num,n=r.length;if(t.hasNumberedRef=!0,(i=({"":e,"+":n+e,"-":n+1-e})[a.groups.sign])<1)throw Error("Invalid subroutine number")}else"0"===i&&(i=0);let s=r3(i);return n.push(s),s}(r,s);default:throw Error(`Unexpected token type "${r.type}"`)}},s={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:i.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:a},o=(r={type:"Flags",...i.flags},{type:"Regex",body:r4(void 0),flags:r}),l=o.body[0];for(;s.nextIndex<i.tokens.length;){let e=a(l,{});"Alternative"===e.type?(o.body.push(e),l=e):l.body.push(e)}let{capturingGroups:u,hasNumberedRef:c,namedGroupsByName:d,subroutines:p}=s;if(c&&d.size&&!n.rules.captureGroup)throw Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:e}of p)if("number"==typeof e){if(e>u.length)throw Error("Subroutine uses a group number that's not defined");e&&(u[e-1].isSubroutined=!0)}else if(d.has(e)){if(d.get(e).length>1)throw Error(rN`Subroutine uses a duplicate group name "\g<${e}>"`);d.get(e)[0].isSubroutined=!0}else throw Error(rN`Subroutine uses a group name that's not defined "\g<${e}>"`);return o}function rK(e){return{type:"Alternative",body:r9(e?.body)}}function rX(e,t){let r={type:"Assertion",kind:e};return("word_boundary"===e||"text_segment_boundary"===e)&&(r.negate=!!t?.negate),r}function rJ(e,t){let r=!!t?.orphan;return{type:"Backreference",ref:e,...r&&{orphan:r}}}function rZ(e,t){var r;let n={name:void 0,isSubroutined:!1,...t};if(void 0!==n.name&&(r=n.name,!/^[\p{Alpha}\p{Pc}][^)]*$/u.test(r)))throw Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:r4(t?.body)}}function rY(e,t){let r={useLastValid:!1,...t};if(e>1114111){let t=e.toString(16);if(r.useLastValid)e=1114111;else throw e>1310719?Error(`Invalid code point out of range "\\x{${t}}"`):Error(`Invalid code point out of range in JS "\\x{${t}}"`)}return{type:"Character",value:e}}function r0(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:r9(e?.body)}}function r1(e,t){let r=!!t?.negate,n={type:"CharacterSet",kind:e};return("digit"===e||"hex"===e||"newline"===e||"space"===e||"word"===e)&&(n.negate=r),"text_segment"!==e&&("newline"!==e||r)||(n.variableLength=!0),n}function r2(e){let t=e?.atomic,r=e?.flags;if(t&&r)throw Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...r&&{flags:r},body:r4(e?.body)}}function r5(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:r4(e?.body)}}function r6(e,t,r,n){if(t>r)throw Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:r,body:n}}function r3(e){return{type:"Subroutine",ref:e}}function r8(e,t){let r={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},n=r.unicodePropertyMap?.get(nt(e));if(!n){if(r.normalizeUnknownPropertyNames)n=e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase());else if(r.unicodePropertyMap&&!r.skipPropertyNameValidation)throw Error(rN`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:n??e,negate:r.negate}}function r4(e){if(void 0===e)e=[rK()];else if(!Array.isArray(e)||!e.length||!e.every(e=>"Alternative"===e.type))throw Error("Invalid body; expected array of one or more Alternative nodes");return e}function r9(e){if(void 0===e)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw Error("Invalid body; expected array of nodes");return e}function r7(e){return"LookaroundAssertion"===e.type&&"lookahead"===e.kind}function ne(e){return"LookaroundAssertion"===e.type&&"lookbehind"===e.kind}function nt(e){return e.replace(/[- _]+/g,"").toLowerCase()}function nr(e,t){return rE(e,`Unclosed character class${t?.type==="Character"&&93===t.value&&"]"===t.raw?' (started with "]")':""}`)}function nn(e){return rE(e,"Unclosed group")}function ni(e,t,r=null){function n(e,t){for(let r=0;r<e.length;r++){let n=i(e[r],t,r,e);r=Math.max(-1,r+n)}}function i(a,s=null,o=null,l=null){let u=0,c=!1,d={node:a,parent:s,key:o,container:l,root:e,remove(){na(l).splice(Math.max(0,ns(o)+u),1),u--,c=!0},removeAllNextSiblings:()=>na(l).splice(ns(o)+1),removeAllPrevSiblings(){let e=ns(o)+u;return u-=e,na(l).splice(0,Math.max(0,e))},replaceWith(e,t={}){let r=!!t.traverse;l?l[Math.max(0,ns(o)+u)]=e:rE(s,"Can't replace root node")[o]=e,r&&i(e,s,o,l),c=!0},replaceWithMultiple(e,t={}){let r=!!t.traverse;if(na(l).splice(Math.max(0,ns(o)+u),1,...e),u+=e.length-1,r){let t=0;for(let r=0;r<e.length;r++)t+=i(e[r],s,ns(o)+r+t,l)}c=!0},skip(){c=!0}},{type:p}=a,h=t["*"],f=t[p],m="function"==typeof h?h:h?.enter,g="function"==typeof f?f:f?.enter;if(m?.(d,r),g?.(d,r),!c)switch(p){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":n(a.body,a);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":i(a.min,a,"min"),i(a.max,a,"max");break;case"Quantifier":i(a.body,a,"body");break;case"Regex":n(a.body,a),i(a.flags,a,"flags");break;default:throw Error(`Unexpected node type "${p}"`)}return f?.exit?.(d,r),h?.exit?.(d,r),u}return i(e),e}function na(e){if(!Array.isArray(e))throw Error("Container expected");return e}function ns(e){if("number"!=typeof e)throw Error("Numeric key expected");return e}let no=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`,nl=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function nu(e,t,r,n){let i=RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1],s=0,o="";for(let t of e.matchAll(i)){let{0:e,groups:{$skip:i}}=t;if(!i&&(!n||n===nl.DEFAULT==!s)){r instanceof Function?o+=r(t,{context:s?nl.CHAR_CLASS:nl.DEFAULT,negated:a[a.length-1]}):o+=r;continue}"["===e[0]?(s++,a.push("^"===e[1])):"]"===e&&s&&(s--,a.pop()),o+=e}return o}function nc(e,t,r){return!!function(e,t,r=0,n){let i;if(!RegExp(t,"su").test(e))return null;let a=RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=r;let s=0;for(;i=a.exec(e);){let{0:e,groups:{$skip:t}}=i;if(!t&&(!n||n===nl.DEFAULT==!s))return i;"["===e?s++:"]"===e&&s&&s--,a.lastIndex==i.index&&a.lastIndex++}return null}(e,t,0,r)}let nd=RegExp(String.raw`(?<noncapturingStart>${no})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu"),np=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,nh=RegExp(String.raw`
|
|
34
|
+
\\(?: \d+
|
|
35
|
+
| c[A-Za-z]
|
|
36
|
+
| [gk]<[^>]+>
|
|
37
|
+
| [pPu]\{[^\}]+\}
|
|
38
|
+
| u[A-Fa-f\d]{4}
|
|
39
|
+
| x[A-Fa-f\d]{2}
|
|
40
|
+
)
|
|
41
|
+
| \((?: \? (?: [:=!>]
|
|
42
|
+
| <(?:[=!]|[^>]+>)
|
|
43
|
+
| [A-Za-z\-]+:
|
|
44
|
+
| \(DEFINE\)
|
|
45
|
+
))?
|
|
46
|
+
| (?<qBase>${np})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
47
|
+
| \\?.
|
|
48
|
+
`.replace(/\s+/g,""),"gsu"),nf=String.raw,nm=nf`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,ng=nf`\(\?R=(?<rDepth>[^\)]+)\)|${nm}`,ny=nf`\(\?<(?![=!])(?<captureName>[^>]+)>`,nb=nf`${ny}|(?<unnamed>\()(?!\?)`,nw=RegExp(nf`${ny}|${ng}|\(\?|\\?.`,"gsu"),nx="Cannot use multiple overlapping recursions";function nv(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e)||(e*=1)<2||e>100)throw Error(t)}function nA(e,t,r,n,i,a,s){let o=new Set;n&&nu(e+t,ny,({groups:{captureName:e}})=>{o.add(e)},nl.DEFAULT);let l=[r,n?o:null,i,a,s];return`${e}${n_(`(?:${e}`,"forward",...l)}(?:)${n_(`${t})`,"backward",...l)}${t}`}function n_(e,t,r,n,i,a,s){let o=e=>"forward"===t?e+2:r-e+2-1,l="";for(let t=0;t<r;t++){let r=o(t);l+=nu(e,nf`${nb}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:o,backref:l}})=>{if(l&&n&&!n.has(l))return e;let u=`_$${r}`;if(o||t){let r=s+a.length+1;return a.push(r),function(e,t){for(let r=0;r<e.length;r++)e[r]>=t&&e[r]++}(i,r),o?e:`(?<${t}${u}>`}return nf`\k<${l}${u}>`},nl.DEFAULT)}return l}function nk(e,t,r,n,i,a){if(e.size&&n){let s=0;nu(t,nb,()=>s++,nl.DEFAULT);let o=a-s+i,l=new Map;return e.forEach((e,t)=>{let i=(n-s*r)/r,a=s*r,u=t>o+s?t+n:t,c=[];for(let t of e)if(t<=o)c.push(t);else if(t>o+s+i)c.push(t+n);else if(t<=o+s)for(let e=0;e<=r;e++)c.push(t+s*e);else for(let e=0;e<=r;e++)c.push(t+a+i*e);l.set(u,c)}),l}return e}var nC=String.fromCodePoint,nS=String.raw,nN={},nE=globalThis.RegExp;function nI(e,{enable:t,disable:r}){return{dotAll:!r?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!r?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function nL(e,t,r){return e.has(t)||e.set(t,r),e.get(t)}nN.flagGroups=(()=>{try{new nE("(?i:)")}catch{return!1}return!0})(),nN.unicodeSets=(()=>{try{new nE("[[]]","v")}catch{return!1}return!0})(),nN.bugFlagVLiteralHyphenIsRange=!!nN.unicodeSets&&(()=>{try{new nE(nS`[\d\-a]`,"v")}catch{return!0}return!1})(),nN.bugNestedClassIgnoresNegation=nN.unicodeSets&&new nE("[[^a]]","v").test("a");var nP={ES2025:2025,ES2024:2024,ES2018:2018},nR={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function n$(e={}){if("[object Object]"!==({}).toString.call(e))throw Error("Unexpected options");if(void 0!==e.target&&!nR[e.target])throw Error(`Unexpected target "${e.target}"`);let t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return"auto"===t.target&&(t.target=nN.flagGroups?"ES2025":nN.unicodeSets?"ES2024":"ES2018"),t}var nT=new Set([nC(304),nC(305)]),nj=nS`[\p{L}\p{M}\p{N}\p{Pc}]`;function nM(e){if(nT.has(e))return[e];let t=new Set,r=e.toLowerCase(),n=r.toUpperCase(),i=nG.get(r),a=nO.get(r),s=nD.get(r);return 1==[...n].length&&t.add(n),s&&t.add(s),i&&t.add(i),t.add(r),a&&t.add(a),[...t]}var nB=new Map(`C Other
|
|
49
|
+
Cc Control cntrl
|
|
50
|
+
Cf Format
|
|
51
|
+
Cn Unassigned
|
|
52
|
+
Co Private_Use
|
|
53
|
+
Cs Surrogate
|
|
54
|
+
L Letter
|
|
55
|
+
LC Cased_Letter
|
|
56
|
+
Ll Lowercase_Letter
|
|
57
|
+
Lm Modifier_Letter
|
|
58
|
+
Lo Other_Letter
|
|
59
|
+
Lt Titlecase_Letter
|
|
60
|
+
Lu Uppercase_Letter
|
|
61
|
+
M Mark Combining_Mark
|
|
62
|
+
Mc Spacing_Mark
|
|
63
|
+
Me Enclosing_Mark
|
|
64
|
+
Mn Nonspacing_Mark
|
|
65
|
+
N Number
|
|
66
|
+
Nd Decimal_Number digit
|
|
67
|
+
Nl Letter_Number
|
|
68
|
+
No Other_Number
|
|
69
|
+
P Punctuation punct
|
|
70
|
+
Pc Connector_Punctuation
|
|
71
|
+
Pd Dash_Punctuation
|
|
72
|
+
Pe Close_Punctuation
|
|
73
|
+
Pf Final_Punctuation
|
|
74
|
+
Pi Initial_Punctuation
|
|
75
|
+
Po Other_Punctuation
|
|
76
|
+
Ps Open_Punctuation
|
|
77
|
+
S Symbol
|
|
78
|
+
Sc Currency_Symbol
|
|
79
|
+
Sk Modifier_Symbol
|
|
80
|
+
Sm Math_Symbol
|
|
81
|
+
So Other_Symbol
|
|
82
|
+
Z Separator
|
|
83
|
+
Zl Line_Separator
|
|
84
|
+
Zp Paragraph_Separator
|
|
85
|
+
Zs Space_Separator
|
|
86
|
+
ASCII
|
|
87
|
+
ASCII_Hex_Digit AHex
|
|
88
|
+
Alphabetic Alpha
|
|
89
|
+
Any
|
|
90
|
+
Assigned
|
|
91
|
+
Bidi_Control Bidi_C
|
|
92
|
+
Bidi_Mirrored Bidi_M
|
|
93
|
+
Case_Ignorable CI
|
|
94
|
+
Cased
|
|
95
|
+
Changes_When_Casefolded CWCF
|
|
96
|
+
Changes_When_Casemapped CWCM
|
|
97
|
+
Changes_When_Lowercased CWL
|
|
98
|
+
Changes_When_NFKC_Casefolded CWKCF
|
|
99
|
+
Changes_When_Titlecased CWT
|
|
100
|
+
Changes_When_Uppercased CWU
|
|
101
|
+
Dash
|
|
102
|
+
Default_Ignorable_Code_Point DI
|
|
103
|
+
Deprecated Dep
|
|
104
|
+
Diacritic Dia
|
|
105
|
+
Emoji
|
|
106
|
+
Emoji_Component EComp
|
|
107
|
+
Emoji_Modifier EMod
|
|
108
|
+
Emoji_Modifier_Base EBase
|
|
109
|
+
Emoji_Presentation EPres
|
|
110
|
+
Extended_Pictographic ExtPict
|
|
111
|
+
Extender Ext
|
|
112
|
+
Grapheme_Base Gr_Base
|
|
113
|
+
Grapheme_Extend Gr_Ext
|
|
114
|
+
Hex_Digit Hex
|
|
115
|
+
IDS_Binary_Operator IDSB
|
|
116
|
+
IDS_Trinary_Operator IDST
|
|
117
|
+
ID_Continue IDC
|
|
118
|
+
ID_Start IDS
|
|
119
|
+
Ideographic Ideo
|
|
120
|
+
Join_Control Join_C
|
|
121
|
+
Logical_Order_Exception LOE
|
|
122
|
+
Lowercase Lower
|
|
123
|
+
Math
|
|
124
|
+
Noncharacter_Code_Point NChar
|
|
125
|
+
Pattern_Syntax Pat_Syn
|
|
126
|
+
Pattern_White_Space Pat_WS
|
|
127
|
+
Quotation_Mark QMark
|
|
128
|
+
Radical
|
|
129
|
+
Regional_Indicator RI
|
|
130
|
+
Sentence_Terminal STerm
|
|
131
|
+
Soft_Dotted SD
|
|
132
|
+
Terminal_Punctuation Term
|
|
133
|
+
Unified_Ideograph UIdeo
|
|
134
|
+
Uppercase Upper
|
|
135
|
+
Variation_Selector VS
|
|
136
|
+
White_Space space
|
|
137
|
+
XID_Continue XIDC
|
|
138
|
+
XID_Start XIDS`.split(/\s/).map(e=>[nt(e),e])),nO=new Map([["s",nC(383)],[nC(383),"s"]]),nD=new Map([[nC(223),nC(7838)],[nC(107),nC(8490)],[nC(229),nC(8491)],[nC(969),nC(8486)]]),nG=new Map([nF(453),nF(456),nF(459),nF(498),...nW(8072,8079),...nW(8088,8095),...nW(8104,8111),nF(8124),nF(8140),nF(8188)]),nU=new Map([["alnum",nS`[\p{Alpha}\p{Nd}]`],["alpha",nS`\p{Alpha}`],["ascii",nS`\p{ASCII}`],["blank",nS`[\p{Zs}\t]`],["cntrl",nS`\p{Cc}`],["digit",nS`\p{Nd}`],["graph",nS`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",nS`\p{Lower}`],["print",nS`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",nS`[\p{P}\p{S}]`],["space",nS`\p{space}`],["upper",nS`\p{Upper}`],["word",nS`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",nS`\p{AHex}`]]);function nF(e){let t=nC(e);return[t.toLowerCase(),t]}function nW(e,t){return(function(e,t){let r=[];for(let n=e;n<=t;n++)r.push(n);return r})(e,t).map(e=>nF(e))}var nz=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]),nq={AbsenceFunction({node:e,parent:t,replaceWith:r}){let{body:n,kind:i}=e;if("repeater"===i){let e=r2();e.body[0].body.push(r5({negate:!0,body:n}),r8("Any"));let i=r2();i.body[0].body.push(r6("greedy",0,1/0,e)),r(n5(i,t),{traverse:!0})}else throw Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:r},{flagDirectivesByAlt:n}){let i=e.body.filter(e=>"flags"===e.kind);for(let e=r+1;e<t.body.length;e++)nL(n,t.body[e],[]).push(...i)},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let r=nJ(t.get(e));if(r){let t=r2({flags:r});t.body[0].body=e.body,e.body=[n5(t,e)]}}}},Assertion({node:e,parent:t,key:r,container:n,root:i,remove:a,replaceWith:s},o){let{kind:l,negate:u}=e,{asciiWordBoundaries:c,avoidSubclass:d,supportedGNodes:p,wordIsAscii:h}=o;if("text_segment_boundary"===l)throw Error(`Unsupported text segment boundary "\\${u?"Y":"y"}"`);if("line_end"===l)s(n5(r5({body:[rK({body:[rX("string_end")]}),rK({body:[rY(10)]})]}),t));else if("line_start"===l)s(n5(n0(nS`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if("search_start"===l)if(p.has(e))i.flags.sticky=!0,a();else{var f;let e,i=n[r-1];if(i&&((e=["Character","CharacterClass","CharacterSet"]).includes((f=i).type)||"Quantifier"===f.type&&f.min&&e.includes(f.body.type)))s(n5(r5({negate:!0}),t));else if(d)throw Error(nS`Uses "\G" in a way that requires a subclass`);else s(n2(rX("string_start"),t)),o.strategy="clip_search"}else if("string_end"===l||"string_start"===l);else if("string_end_newline"===l)s(n5(n0(nS`(?=\n?\z)`),t));else if("word_boundary"===l){if(!h&&!c){let e=`(?:(?<=${nj})(?!${nj})|(?<!${nj})(?=${nj}))`,r=`(?:(?<=${nj})(?=${nj})|(?<!${nj})(?!${nj}))`;s(n5(n0(u?r:e),t))}}else throw Error(`Unexpected assertion kind "${l}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:r}=e;"string"!=typeof r||nY(r)||(e.ref=r=nX(r,t))},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:r}){let{name:n}=e;n&&!nY(n)&&(e.name=n=nX(n,t)),r.set(e.number,e),n&&r.set(n,e)},CharacterClassRange({node:e,parent:t,replaceWith:r}){"intersection"===t.kind&&r(n5(r0({body:[e]}),t),{traverse:!0})},CharacterSet({node:e,parent:t,replaceWith:r},{accuracy:n,minTargetEs2024:i,digitIsAscii:a,spaceIsAscii:s,wordIsAscii:o}){let{kind:l,negate:u,value:c}=e;if(a&&("digit"===l||"digit"===c))return void r(n2(r1("digit",{negate:u}),t));if(s&&("space"===l||"space"===c))return void r(n5(n1(n0("[ -\r ]"),u),t));if(o&&("word"===l||"word"===c))return void r(n2(r1("word",{negate:u}),t));if("any"===l)r(n2(r8("Any"),t));else if("digit"===l)r(n2(r8("Nd",{negate:u}),t));else if("dot"===l);else if("text_segment"===l){if("strict"===n)throw Error(nS`Use of "\X" requires non-strict accuracy`);let e="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",a=nS`\p{RI}{2}|${e}(?:\u200D${e})*`;r(n5(n0(nS`(?>\r\n|${i?nS`\p{RGI_Emoji}`:a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if("hex"===l)r(n2(r8("AHex",{negate:u}),t));else if("newline"===l)r(n5(n0(u?"[^\n]":"(?>\r\n?|[\n\v\f
\u2028\u2029])"),t));else if("posix"===l)if(i||"graph"!==c&&"print"!==c)r(n5(n1(n0(nU.get(c)),u),t));else{if("strict"===n)throw Error(`POSIX class "${c}" requires min target ES2024 or non-strict accuracy`);let e={graph:"!-~",print:" -~"}[c];u&&(e=`\0-${nC(e.codePointAt(0)-1)}${nC(e.codePointAt(2)+1)}-\u{10FFFF}`),r(n5(n0(`[${e}]`),t))}else if("property"===l)nB.has(nt(c))||(e.key="sc");else if("space"===l)r(n2(r8("space",{negate:u}),t));else if("word"===l)r(n5(n1(n0(nj),u),t));else throw Error(`Unexpected character set kind "${l}"`)},Directive({node:e,parent:t,root:r,remove:n,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:s}){let{kind:o,flags:l}=e;if("flags"===o)if(l.enable||l.disable){let e=r2({flags:l});e.body[0].body=s(),i(n5(e,t),{traverse:!0})}else n();else if("keep"===o){let e=r.body[0],n=1===r.body.length&&rH(e,{type:"Group"})&&1===e.body[0].body.length?e.body[0]:r;if(t.parent!==n||n.body.length>1)throw Error(nS`Uses "\K" in a way that's unsupported`);let s=r5({behind:!0});s.body[0].body=a(),i(n5(s,t))}else throw Error(`Unexpected directive kind "${o}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error('Unsupported flag "P"');if("word"===e.textSegmentMode)throw Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:r}=e.flags;t?.extended&&delete t.extended,r?.extended&&delete r.extended,t?.dotAll&&r?.dotAll&&delete t.dotAll,t?.ignoreCase&&r?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,r&&!Object.keys(r).length&&delete e.flags.disable,e.flags.enable||e.flags.disable||delete e.flags},LookaroundAssertion({node:e},t){let{kind:r}=e;"lookbehind"===r&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:r}){let{kind:n}=e;if("fail"===n)r(n5(r5({negate:!0}),t));else throw Error(`Unsupported named callout "(*${n.toUpperCase()}"`)},Quantifier({node:e}){if("Quantifier"===e.body.type){let t=r2();t.body[0].body.push(e.body),e.body=n5(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let r=[],n=!1,i=!1;for(let t of e.body)if(1===t.body.length&&"search_start"===t.body[0].kind)t.body.pop();else{let e=function e(t){let r=t.find(e=>"search_start"===e.kind||function(e,t){let r={negate:null,...t};return"LookaroundAssertion"===e.type&&(null===r.negate||e.negate===r.negate)&&1===e.body.length&&rH(e.body[0],{type:"Assertion",kind:"search_start"})}(e,{negate:!1})||!function({type:e}){return"Assertion"===e||"Directive"===e||"LookaroundAssertion"===e}(e));if(!r)return null;if("search_start"===r.kind)return r;if("LookaroundAssertion"===r.type)return r.body[0].body[0];if("CapturingGroup"===r.type||"Group"===r.type){let t=[];for(let n of r.body){let r=e(n.body);if(!r)return null;Array.isArray(r)?t.push(...r):t.push(r)}return t}return null}(t.body);e?(n=!0,Array.isArray(e)?r.push(...e):r.push(e)):i=!0}n&&!i&&r.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:r,strategy:n}){if("strict"===t&&r&&n)throw Error(nS`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:r}=e;"string"!=typeof r||nY(r)||(e.ref=r=nX(r,t))}},nH={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:r}){let{orphan:n,ref:i}=e;n||r.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:r,skip:n},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:s,openRefs:o,reffedNodesByReferencer:l}){let u=i.get(e);if(u&&o.has(e.number)){let n=n2(nK(e.number),t);l.set(n,o.get(e.number)),r(n);return}o.set(e.number,e),s.set(e.number,[]),e.name&&nL(s,e.name,[]);let c=s.get(e.name??e.number);for(let t=0;t<c.length;t++){let r=c[t];if(u===r.node||u&&u===r.origin||e===r.origin){c.splice(t,1);break}}if(s.get(e.number).push({node:e,origin:u}),e.name&&s.get(e.name).push({node:e,origin:u}),e.name){let t=nL(a,e.name,new Map),r=!1;if(u)r=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){r=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:r})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=nI(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:r},n){let{isRecursive:i,ref:a}=e;if(i){let r=t;for(;(r=r.parent)&&("CapturingGroup"!==r.type||r.name!==a&&r.number!==a););n.reffedNodesByReferencer.set(e,r);return}let s=n.subroutineRefMap.get(a),o=0===a,l=o?nK(0):function e(t,r,n,i){let a=Array.isArray(t)?[]:{};for(let[s,o]of Object.entries(t))"parent"===s?a.parent=Array.isArray(n)?i:n:o&&"object"==typeof o?a[s]=e(o,r,a,n):("type"===s&&"CapturingGroup"===o&&r.set(a,r.get(t)??t),a[s]=o);return a}(s,n.groupOriginByCopy,null),u=l;if(!o){var c,d;let e=nJ(function(e,t){let r=[];for(;e=e.parent;)(!t||t(e))&&r.push(e);return r}(s,e=>"Group"===e.type&&!!e.flags)),t=e?nI(n.globalFlags,e):n.globalFlags;c=t,d=n.currentFlags,(c.dotAll!==d.dotAll||c.ignoreCase!==d.ignoreCase)&&(u=r2({flags:function({dotAll:e,ignoreCase:t}){let r={};return(e||t)&&(r.enable={},e&&(r.enable.dotAll=!0),t&&(r.enable.ignoreCase=!0)),e&&t||(r.disable={},e||(r.disable.dotAll=!0),t||(r.disable.ignoreCase=!0)),r}(t)})).body[0].body.push(l)}r(n5(u,t),{traverse:!o})}},nV={Backreference({node:e,parent:t,replaceWith:r},n){if(e.orphan){n.highestOrphanBackref=Math.max(n.highestOrphanBackref,e.ref);return}let i=n.reffedNodesByReferencer.get(e).filter(t=>(function(e,t){let r=t;do{if("Regex"===r.type)return!1;if("Alternative"===r.type)continue;if(r===e)return!1;for(let t of nZ(r.parent)){if(t===r)break;if(t===e||function e(t,r){for(let n of nZ(t)??[])if(n===r||e(n,r))return!0;return!1}(t,e))return!0}}while(r=r.parent)throw Error("Unexpected path")})(t,e));i.length?i.length>1?r(n5(r2({atomic:!0,body:i.reverse().map(e=>rK({body:[rJ(e.number)]}))}),t)):e.ref=i[0].number:r(n5(r5({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let r=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<r;t++){let t=rZ();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){e.isRecursive&&0!==e.ref&&(e.ref=t.reffedNodesByReferencer.get(e).number)}};function nQ(e){ni(e,{"*"({node:e,parent:t}){e.parent=t}})}function nK(e){let t=r3(e);return t.isRecursive=!0,t}function nX(e,t){if(t.has(e))return t.get(e);let r=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,r),r}function nJ(e){let t=["dotAll","ignoreCase"],r={enable:{},disable:{}};return(e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete r.disable[t],r.enable[t]=!0),e.disable?.[t]&&(r.disable[t]=!0)})}),Object.keys(r.enable).length||delete r.enable,Object.keys(r.disable).length||delete r.disable,r.enable||r.disable)?r:null}function nZ(e){if(!e)throw Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function nY(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function n0(e,t){let r=rQ(e,{...t,unicodePropertyMap:nB}).body;return r.length>1||r[0].body.length>1?r2({body:r}):r[0].body[0]}function n1(e,t){return e.negate=t,e}function n2(e,t){return e.parent=t,e}function n5(e,t){return nQ(e),e.parent=t,e}var n6={"*":{enter({node:e},t){if(ia(e)){let r=t.getCurrentModI();t.pushModI(e.flags?nI({ignoreCase:r},e.flags).ignoreCase:r)}},exit({node:e},t){ia(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){it(nC(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},r){t(),ir(e,{firstOnly:!0}).length&&r.setHasCasedChar()},CharacterSet({node:e},t){"property"===e.kind&&nz.has(e.value)&&t.setHasCasedChar()}},n3={Alternative:({body:e},t,r)=>e.map(r).join(""),Assertion({kind:e,negate:t}){if("string_end"===e)return"$";if("string_start"===e)return"^";if("word_boundary"===e)return t?nS`\B`:nS`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if("number"!=typeof e)throw Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&"strict"===t.accuracy&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,r){let{body:n,name:i,number:a}=e,s={ignoreCase:t.currentFlags.ignoreCase},o=t.originMap.get(e);return o&&(s.hidden=!0,a>o.number&&(s.transferTo=o.number)),t.captureMap.set(a,s),`(${i?`?<${i}>`:""}${n.map(r).join("|")})`},Character({value:e},t){let r=nC(e),n=ii(e,{escDigit:"Backreference"===t.lastNode.type,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(n!==r)return n;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&it(r)){let e=nM(r);return t.inCharClass?e.join(""):e.length>1?`[${e.join("")}]`:e[0]}return r},CharacterClass(e,t,r){let{kind:n,negate:i,parent:a}=e,{body:s}=e;if("intersection"===n&&!t.useFlagV)throw Error("Use of character class intersection requires min target ES2024");nN.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&s.some(is)&&(s=[rY(45),...s.filter(e=>!is(e))]);let o=()=>`[${i?"^":""}${s.map(r).join("intersection"===n?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||nN.bugNestedClassIgnoresNegation)&&!i){let t=s.filter(e=>"CharacterClass"===e.type&&"union"===e.kind&&e.negate);if(t.length){let n=r2(),i=n.body[0];return n.parent=a,i.parent=n,e.body=s=s.filter(e=>!t.includes(e)),s.length?(e.parent=i,i.body.push(e)):n.body.pop(),t.forEach(e=>{let t=rK({body:[e]});e.parent=t,t.parent=n,n.body.push(t)}),r(n)}}t.inCharClass=!0;let n=o();return t.inCharClass=!1,n}let l=s[0];if("union"===n&&!i&&l&&((!t.useFlagV||!t.verbose)&&"union"===a.kind&&!(nN.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&"intersection"===a.kind&&1===s.length&&"CharacterClassRange"!==l.type))return s.map(r).join("");if(!t.useFlagV&&"CharacterClass"===a.type)throw Error("Uses nested character class in a way that requires min target ES2024");return o()},CharacterClassRange(e,t){let r=e.min.value,n=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=ii(r,i),s=ii(n,i),o=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&(function(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),r=[],n=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?n??=t[e]:null===n?r.push(t[e]):(r.push([n,t[e]]),n=null);return r})(ir(e)).forEach(e=>{o.add(Array.isArray(e)?`${ii(e[0],i)}-${ii(e[1],i)}`:ii(e,i))}),`${a}-${s}${[...o].join("")}`},CharacterSet({kind:e,negate:t,value:r,key:n},i){if("dot"===e)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?".":"[^]":nS`[^\n]`;if("digit"===e)return t?nS`\D`:nS`\d`;if("property"===e){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&nz.has(r))throw Error(`Unicode property "${r}" can't be case-insensitive when other chars have specific case`);return`${t?nS`\P`:nS`\p`}{${n?`${n}=`:""}${r}}`}if("word"===e)return t?nS`\W`:nS`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags:(e,t)=>(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":""),Group({atomic:e,body:t,flags:r,parent:n},i,a){let s=i.currentFlags;r&&(i.currentFlags=nI(s,r));let o=t.map(a).join("|"),l=i.verbose||1!==t.length||"Quantifier"===n.type||e||i.useFlagMods&&r?`(?${function(e,t,r){if(e)return">";let n="";if(t&&r){let{enable:e,disable:r}=t;n=(e?.ignoreCase?"i":"")+(e?.dotAll?"s":"")+(r?"-":"")+(r?.ignoreCase?"i":"")+(r?.dotAll?"s":"")}return`${n}:`}(e,r,i.useFlagMods)}${o})`:o;return i.currentFlags=s,l},LookaroundAssertion({body:e,kind:t,negate:r},n,i){let a=`${"lookahead"===t?"":"<"}${r?"!":"="}`;return`(?${a}${e.map(i).join("|")})`},Quantifier:(e,t,r)=>r(e.body)+function({kind:e,max:t,min:r}){return(r||1!==t?r||t!==1/0?1===r&&t===1/0?"+":r===t?`{${r}}`:`{${r},${t===1/0?"":t}}`:"*":"?")+({greedy:"",lazy:"?",possessive:"+"})[e]}(e),Subroutine({isRecursive:e,ref:t},r){if(!e)throw Error("Unexpected non-recursive subroutine in transformed AST");let n=r.recursionLimit;return 0===t?`(?R=${n})`:nS`\g<${t}&R=${n}>`}},n8=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),n4=new Set(["-","\\","]","^","["]),n9=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),n7=new Map([[9,nS`\t`],[10,nS`\n`],[11,nS`\v`],[12,nS`\f`],[13,nS`\r`],[8232,nS`\u2028`],[8233,nS`\u2029`],[65279,nS`\uFEFF`]]),ie=/^\p{Cased}$/u;function it(e){return ie.test(e)}function ir(e,t){let r=!!t?.firstOnly,n=e.min.value,i=e.max.value,a=[];if(n<65&&(65535===i||i>=131071)||65536===n&&i>=131071)return a;for(let e=n;e<=i;e++){let t=nC(e);if(!it(t))continue;let s=nM(t).filter(e=>{let t=e.codePointAt(0);return t<n||t>i});if(s.length&&(a.push(...s),r))break}return a}function ii(e,{escDigit:t,inCharClass:r,useFlagV:n}){var i;if(n7.has(e))return n7.get(e);if(e<32||e>126&&e<160||e>262143||t&&(i=e)>47&&i<58)return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let a=nC(e);return((r?n?n9:n4:n8).has(a)?"\\":"")+a}function ia({type:e}){return"CapturingGroup"===e||"Group"===e||"LookaroundAssertion"===e}function is({type:e,value:t}){return"Character"===e&&45===t}var io=class e extends RegExp{#e=new Map;#t=null;#r;#n=null;#i=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(t,r,n){const i=!!n?.lazyCompile;if(t instanceof RegExp){if(n)throw Error("Cannot provide options when copying a regexp");super(t,r),this.#r=t.source,t instanceof e&&(this.#e=t.#e,this.#n=t.#n,this.#i=t.#i,this.rawOptions=t.rawOptions)}else{const e={hiddenCaptures:[],strategy:null,transfers:[],...n};super(i?"":t,r),this.#r=t,this.#e=function(e,t){let r=new Map;for(let t of e)r.set(t,{hidden:!0});for(let[e,n]of t)for(let t of n)nL(r,t,{}).transferTo=e;return r}(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=n??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...r}=this.rawOptions;this.#t=new e(this.#r,this.flags,r)}let r=this.global||this.sticky,n=this.lastIndex;if("clip_search"===this.#i&&r&&n){this.lastIndex=0;let e=this.#a(t.slice(n));return e&&(function(e,t,r,n){if(e.index+=t,e.input=r,n){let r=e.indices;for(let e=0;e<r.length;e++){let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])}let n=r.groups;n&&Object.keys(n).forEach(e=>{let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])})}}(e,n,t,this.hasIndices),this.lastIndex+=n),e}return this.#a(t)}#a(e){let t;this.#t.lastIndex=this.lastIndex;let r=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!r||!this.#e.size)return r;let n=[...r];r.length=1,this.hasIndices&&(t=[...r.indices],r.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:s}=this.#e.get(e)??{};if(a?i.push(null):(i.push(r.length),r.push(n[e]),this.hasIndices&&r.indices.push(t[e])),s&&void 0!==n[e]){let a=i[s];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(r[a]=n[e],this.hasIndices&&(r.indices[a]=t[e]),r.groups){this.#n||(this.#n=function(e){let t,r=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,i=0,a=0;for(;t=r.exec(e);){let{0:e,groups:{capture:r,name:s}}=t;"["===e?i++:i?"]"===e&&i--:r&&(a++,s&&n.set(a,s))}return n}(this.source));let i=this.#n.get(s);i&&(r.groups[i]=n[e],this.hasIndices&&(r.indices.groups[i]=t[e]))}}}return r}};class il{constructor(e,t={}){this.patterns=e,this.options=t;const{forgiving:r=!1,cache:n,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if("string"!=typeof e)return e;let t=n?.get(e);if(t){if(t instanceof RegExp)return t;if(r)return null;throw t}try{let t=i(e);return n?.set(e,t),t}catch(t){if(n?.set(e,t),r)return null;throw t}})}regexps;findNextMatchSync(e,t,r){let n="string"==typeof e?e:e.content,i=[];function a(e,t,r=0){return{index:e,captureIndices:t.indices.map(e=>null==e?{start:0xffffffff,end:0xffffffff,length:0}:{start:e[0]+r,end:e[1]+r,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){let r=this.regexps[e];if(r)try{r.lastIndex=t;let s=r.exec(n);if(!s)continue;if(s.index===t)return a(e,s,0);i.push([e,s,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(i.length){let e=Math.min(...i.map(e=>e[1].index));for(let[t,r,n]of i)if(r.index===e)return a(t,r,n)}return null}}var iu=function(e={}){let t=Object.assign({target:"auto",cache:new Map},e);return t.regexConstructor||=e=>{let r;return(r=function(e,t){var r;let n,i,a,s,o=n$(t),l=(r=rQ(e,{flags:o.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:o.rules.captureGroup,singleline:o.rules.singleline},skipBackrefValidation:o.rules.allowOrphanBackrefs,unicodePropertyMap:nB}),n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...{accuracy:o.accuracy,asciiWordBoundaries:o.rules.asciiWordBoundaries,avoidSubclass:o.avoidSubclass,bestEffortTarget:o.target}},nQ(r),i={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:nP[n.bestEffortTarget]>=nP.ES2024,passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:r.flags.digitIsAscii,spaceIsAscii:r.flags.spaceIsAscii,wordIsAscii:r.flags.wordIsAscii},ni(r,nq,i),s={currentFlags:a={dotAll:r.flags.dotAll,ignoreCase:r.flags.ignoreCase},prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:i.subroutineRefMap},ni(r,nH,s),ni(r,nV,{groupsByName:s.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:s.reffedNodesByReferencer}),r._originMap=s.groupOriginByCopy,r._strategy=i.strategy,r),u=function(e,t){let r=n$(t),n=nP[r.target]>=nP.ES2024,i=nP[r.target]>=nP.ES2025,a=r.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error("Invalid recursionLimit; use 2-20");let s=null,o=null;if(!i){let t=[e.flags.ignoreCase];ni(e,n6,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?s=!0:o=!0}})}let l={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||s)&&!o)},u=e,c={accuracy:r.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:u,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&s&&o),useFlagMods:i,useFlagV:n,verbose:r.verbose};function d(e){return c.lastNode=u,u=e,(function(e,t){if(null==e)throw Error(t??"Value expected");return e})(n3[e.type],`Unexpected node type "${e.type}"`)(e,c,d)}let p={pattern:e.body.map(d).join("|"),flags:d(e.flags),options:{...e.options}};return n||(delete p.options.force.v,p.options.disable.v=!0,p.options.unicodeSetsPlugin=null),p._captureTransfers=new Map,p._hiddenCaptures=[],c.captureMap.forEach((e,t)=>{e.hidden&&p._hiddenCaptures.push(t),e.transferTo&&nL(p._captureTransfers,e.transferTo,[]).push(t)}),p}(l,o),c=function(e,t){let r,{hiddenCaptures:n,mode:i}={hiddenCaptures:[],mode:"plugin",...t},a=t?.captureTransfers??new Map;if(!RegExp(ng,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if("plugin"===i&&nc(e,nf`\(\?\(DEFINE\)`,nl.DEFAULT))throw Error("DEFINE groups cannot be used with recursion");let s=[],o=nc(e,nf`\\[1-9]`,nl.DEFAULT),l=new Map,u=[],c=!1,d=0,p=0;for(nw.lastIndex=0;r=nw.exec(e);){let{0:t,groups:{captureName:h,rDepth:f,gRNameOrNum:m,gRDepth:g}}=r;if("["===t)d++;else if(d)"]"===t&&d--;else if(f){if(nv(f),c)throw Error(nx);if(o)throw Error(`${"external"===i?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);let t=e.slice(0,r.index),l=e.slice(nw.lastIndex);if(nc(l,ng,nl.DEFAULT))throw Error(nx);let u=f-1;e=nA(t,l,u,!1,n,s,p),a=nk(a,t,u,s.length,0,p);break}else if(m){nv(g);let d=!1;for(let e of u)if(e.name===m||e.num===+m){if(d=!0,e.hasRecursedWithin)throw Error(nx);break}if(!d)throw Error(nf`Recursive \g cannot be used outside the referenced group "${"external"===i?m:nf`\g<${m}&R=${g}>`}"`);let h=l.get(m),f=function(e,t){let r,n=/\\?./gsu;n.lastIndex=t;let i=e.length,a=0,s=1;for(;r=n.exec(e);){let[e]=r;if("["===e)a++;else if(a)"]"===e&&a--;else if("("===e)s++;else if(")"===e&&!--s){i=r.index;break}}return e.slice(t,i)}(e,h);if(o&&nc(f,nf`${ny}|\((?!\?)`,nl.DEFAULT))throw Error(`${"external"===i?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);let y=e.slice(h,r.index),b=f.slice(y.length+t.length),w=s.length,x=g-1,v=nA(y,b,x,!0,n,s,p);a=nk(a,y,x,s.length-w,w,p);let A=e.slice(0,h),_=e.slice(h+f.length);e=`${A}${v}${_}`,nw.lastIndex+=v.length-t.length-y.length-b.length,u.forEach(e=>e.hasRecursedWithin=!0),c=!0}else if(h)p++,l.set(String(p),nw.lastIndex),l.set(h,nw.lastIndex),u.push({num:p,name:h});else if("("===t[0]){let e="("===t;e&&(p++,l.set(String(p),nw.lastIndex)),u.push(e?{num:p}:{})}else")"===t&&u.pop()}return n.push(...s),{pattern:e,captureTransfers:a,hiddenCaptures:n}}(u.pattern,{captureTransfers:u._captureTransfers,hiddenCaptures:u._hiddenCaptures,mode:"external"}),d=function(e,t){let r,n=t?.hiddenCaptures??[],i=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:i,hiddenCaptures:n};let a="(?:(?=(",s=[0],o=[],l=0,u=0,c=NaN;do{let t;r=!1;let d=0,p=0,h=!1;for(nd.lastIndex=Number.isNaN(c)?0:c+a.length;t=nd.exec(e);){let{0:f,index:m,groups:{capturingStart:g,noncapturingStart:y}}=t;if("["===f)d++;else if(d)"]"===f&&d--;else if("(?>"!==f||h){if(h&&y)p++;else if(g)h?p++:(l++,s.push(l+u));else if(")"===f&&h){if(!p){let t=l+ ++u;e=`${e.slice(0,c)}${a}${e.slice(c+3,m)}))<$$${t}>)${e.slice(m+1)}`,r=!0,o.push(t);for(let e=0;e<n.length;e++)n[e]>=t&&n[e]++;if(i.size){let e=new Map;i.forEach((r,n)=>{e.set(n>=t?n+1:n,r.map(e=>e>=t?e+1:e))}),i=e}break}p--}}else c=m,h=!0}}while(r)return n.push(...o),{pattern:e=nu(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:t,wrappedBackrefNum:r}})=>{if(t){let r=+t;if(r>s.length-1)throw Error(`Backref "${e}" greater than number of captures`);return`\\${s[r]}`}return`\\${r}`},nl.DEFAULT),captureTransfers:i,hiddenCaptures:n}}(function(e){let t;if(!RegExp(`${np}\\+`).test(e))return{pattern:e};let r=[],n=null,i=null,a="",s=0;for(nh.lastIndex=0;t=nh.exec(e);){let{0:u,index:c,groups:{qBase:d,qMod:p,invalidQ:h}}=t;if("["===u)s||(i=c),s++;else if("]"===u)s?s--:i=null;else if(!s)if("+"===p&&a&&!a.startsWith("(")){if(h)throw Error(`Invalid quantifier "${u}"`);let t=-1;if(/^\{\d+\}$/.test(d)){var o,l;o=e,l=c+d.length,e=o.slice(0,l)+""+o.slice(l+p.length)}else{if(")"===a||"]"===a){let t=")"===a?n:i;if(null===t)throw Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,t)}(?>${e.slice(t,c)}${d})${e.slice(c+u.length)}`}else e=`${e.slice(0,c-a.length)}(?>${a}${d})${e.slice(c+u.length)}`;t+=4}nh.lastIndex+=t}else"("===u[0]?r.push(c):")"===u&&(n=r.length?r.pop():null);a=u}return{pattern:e}}(c.pattern).pattern,{captureTransfers:c.captureTransfers,hiddenCaptures:c.hiddenCaptures}),p={pattern:d.pattern,flags:`${o.hasIndices?"d":""}${o.global?"g":""}${u.flags}${u.options.disable.v?"u":"v"}`};if(o.avoidSubclass){if(o.lazyCompileLength!==1/0)throw Error("Lazy compilation requires subclass")}else{let e=d.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(d.captureTransfers),r=l._strategy,n=p.pattern.length>=o.lazyCompileLength;(e.length||t.length||r||n)&&(p.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...r&&{strategy:r},...n&&{lazyCompile:n}})}return p}(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...{target:t.target}})).options?new io(r.pattern,r.flags,r.options):new RegExp(r.pattern,r.flags)},{createScanner:e=>new il(e,t),createString:e=>({content:e})}}({forgiving:!0}),ic=Object.fromEntries($.flatMap(e=>{var t;return(null!=(t=e.aliases)?t:[]).map(t=>[t,e.id])})),id=new Set(Object.keys(M)),ip=e=>{let t=e.trim().toLowerCase();return ic[t]||(id.has(t),t)},ih=new Map,im=new Map,ig=new Map,iy=e=>{var t;return"string"==typeof e?e:null!=(t=e.name)?t:"custom"},ib=function(e={}){var t;let r=null!=(t=e.themes)?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(e){let t=ip(e);return id.has(t)},getSupportedLanguages:()=>Array.from(id),getThemes:()=>r,highlight({code:e,language:t,themes:r},n){let i,a,s=ip(t),o=[iy(r[0]),iy(r[1])],l=(i=e.slice(0,100),a=e.length>100?e.slice(-100):"",`${s}:${o[0]}:${o[1]}:${e.length}:${i}:${a}`);return im.has(l)?im.get(l):(n&&(ig.has(l)||ig.set(l,new Set),ig.get(l).add(n)),((e,t)=>{let r=`${e}-${iy(t[0])}-${iy(t[1])}`;if(ih.has(r))return ih.get(r);let n=rk({themes:t,langs:[e],engine:iu});return ih.set(r,n),n})(id.has(s)?s:"text",r).then(t=>{let r=t.getLoadedLanguages().includes(s)?s:"text",n=t.codeToTokens(e,{lang:r,themes:{light:o[0],dark:o[1]}});im.set(l,n);let i=ig.get(l);if(i){for(let e of i)e(n);ig.delete(l)}}).catch(e=>{console.error("[Streamdown Code] Failed to highlight code:",e),ig.delete(l)}),null)}}}(),iw=e.i(76116),ix=e.i(6703);function iv({className:e,children:t,node:r,...n}){let i=(0,c.useRef)(null),[a,s]=(0,c.useState)(!1),o=function(e){for(let t of c.Children.toArray(e)){if(!(0,c.isValidElement)(t))continue;let e=t.props;if("string"!=typeof e?.className)continue;let r=e.className.match(/language-([a-z0-9+#-]+)/i);if(r)return r[1]}}(t)??"",l=(0,c.useCallback)(async()=>{let e=i.current?.innerText??"";if(e)try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),2e3)}catch{}},[]);return(0,u.jsxs)("div",{className:"group relative my-2 overflow-hidden rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--muted)/0.5)]",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between border-b border-[hsl(var(--border))] bg-[hsl(var(--muted)/0.8)] px-3 py-1.5",children:[(0,u.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:o||"text"}),(0,u.jsx)("button",{type:"button",onClick:l,className:(0,b.cn)("inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground","opacity-0 transition-opacity hover:bg-[hsl(var(--accent))] hover:text-foreground","group-hover:opacity-100 focus-visible:opacity-100",a&&"opacity-100 text-primary"),"aria-label":"复制代码",children:a?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(ix.Check,{className:"h-3 w-3"}),"已复制"]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(k.Copy,{className:"h-3 w-3"}),"复制"]})})]}),(0,u.jsx)("pre",{ref:i,className:(0,b.cn)("overflow-x-auto p-3 text-xs leading-relaxed","[&_code]:bg-transparent [&_code]:p-0",e),...n,children:t})]})}let iA=["https://","http://","mailto:","#","/"],i_=["https://","data:image/"],ik=(e,t)=>{let r=e.toLowerCase();return("src"===t?i_:iA).some(e=>r.startsWith(e))?e:""};function iC({children:e,className:t}){return(0,u.jsx)("div",{className:(0,b.cn)("text-sm leading-relaxed text-foreground/90","[&_p]:my-2 [&_ul]:my-2 [&_ol]:my-2 [&_li]:my-0.5","[&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5","[&_h1]:mt-4 [&_h1]:mb-2 [&_h1]:text-lg [&_h1]:font-semibold","[&_h2]:mt-3 [&_h2]:mb-2 [&_h2]:text-base [&_h2]:font-semibold","[&_h3]:mt-3 [&_h3]:mb-1.5 [&_h3]:text-sm [&_h3]:font-semibold","[&_a]:text-primary [&_a]:underline [&_a]:underline-offset-2","[&_:not(pre)>code]:rounded [&_:not(pre)>code]:bg-[hsl(var(--muted))] [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:text-[0.85em]","[&_table]:my-2 [&_table]:w-full [&_table]:border-collapse","[&_th]:border [&_th]:border-[hsl(var(--border))] [&_th]:px-2 [&_th]:py-1 [&_th]:text-left [&_th]:font-semibold","[&_td]:border [&_td]:border-[hsl(var(--border))] [&_td]:px-2 [&_td]:py-1","[&_blockquote]:my-2 [&_blockquote]:border-l-2 [&_blockquote]:border-[hsl(var(--border))] [&_blockquote]:pl-3 [&_blockquote]:text-muted-foreground","[&_hr]:my-3 [&_hr]:border-[hsl(var(--border))]",t),children:(0,u.jsx)(iw.C,{parseIncompleteMarkdown:!0,skipHtml:!0,urlTransform:ik,plugins:{code:ib},components:{pre:iv},controls:{code:!1,table:!1,mermaid:!1},children:e})})}let iS=(0,c.memo)(function({message:e,busy:t,onDelete:r,onResend:n,onRegenerate:i,onEditSave:a}){return"user"===e.role?(0,u.jsx)(iP,{message:e,busy:t,onDelete:r,onResend:n,onEditSave:a}):(0,u.jsx)(iR,{message:e,busy:t,onDelete:r,onRegenerate:i})},(e,t)=>e.message===t.message&&e.busy===t.busy);function iN({align:e,disabled:t,onCopy:r,onDelete:n,onEdit:i,onResend:a,onRegenerate:s}){return(0,u.jsxs)("div",{className:(0,b.cn)("mt-1 flex items-center gap-0.5 opacity-0 transition-opacity duration-150","group-hover:opacity-100 group-focus-within:opacity-100","group-data-[touched=true]:opacity-100","right"===e?"justify-end":"justify-start"),children:[(0,u.jsx)(iE,{title:"复制",disabled:t,onClick:r,children:(0,u.jsx)(k.Copy,{className:"h-3.5 w-3.5"})}),i&&(0,u.jsx)(iE,{title:"编辑",disabled:t,onClick:i,children:(0,u.jsx)(C.Pencil,{className:"h-3.5 w-3.5"})}),a&&(0,u.jsx)(iE,{title:"重新发送",disabled:t,onClick:a,children:(0,u.jsx)(h,{className:"h-3.5 w-3.5"})}),s&&(0,u.jsx)(iE,{title:"重新生成",disabled:t,onClick:s,children:(0,u.jsx)(S.RotateCcw,{className:"h-3.5 w-3.5"})}),(0,u.jsx)(iE,{title:"删除",disabled:t,onClick:n,destructive:!0,children:(0,u.jsx)(E.Trash2,{className:"h-3.5 w-3.5"})})]})}function iE({title:e,disabled:t,destructive:r,onClick:n,children:i}){return(0,u.jsx)(m.Button,{type:"button",variant:"ghost",size:"icon",title:e,"aria-label":e,disabled:t,onClick:n,className:(0,b.cn)("h-7 w-7 text-muted-foreground hover:text-foreground",r&&"hover:text-[hsl(var(--destructive))] hover:bg-[hsl(var(--destructive))]/10"),children:i})}function iI({rewriteFailed:e,rewriteError:t,failedKbCount:r,failedKbDetails:n}){let i=!!e,a=(r??0)>0;return i||a?(0,u.jsxs)("div",{className:"space-y-1.5",children:[i&&(0,u.jsx)(iL,{label:"意图重写失败 · 已回退到原问题",detail:t??"rewriter 返回空结果或抛错"}),a&&n&&(0,u.jsx)(iL,{label:`${r} 个知识库检索失败`,detail:n.map(e=>`• ${e.name}: ${e.reason}`).join("\n")})]}):null}function iL({label:e,detail:t}){let[r,n]=(0,c.useState)(!1);return(0,u.jsxs)("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/5",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),className:(0,b.cn)("flex w-full items-center gap-1.5 px-2 py-1 text-xs","text-amber-700 hover:bg-amber-500/10 dark:text-amber-300"),children:[(0,u.jsx)(x.AlertTriangle,{className:"h-3.5 w-3.5 shrink-0"}),(0,u.jsx)("span",{className:"flex-1 text-left",children:e}),(0,u.jsx)(_.ChevronDown,{className:(0,b.cn)("h-3 w-3 opacity-60 transition-transform duration-150",r&&"rotate-180")})]}),r&&(0,u.jsx)("pre",{className:"border-t border-amber-500/20 px-2 py-1.5 text-[11px] leading-relaxed text-amber-700/80 dark:text-amber-300/80 whitespace-pre-wrap font-mono",children:t})]})}function iP({message:e,busy:t,onDelete:r,onResend:n,onEditSave:i}){let[a,s]=(0,c.useState)(!1),[o,l]=(0,c.useState)(!1),[d,p]=(0,c.useState)(e.content),[h,f]=(0,c.useState)(!1),[y,b]=(0,c.useState)(!1),[w,x]=(0,c.useState)(!0),v=(0,c.useCallback)(()=>{navigator.clipboard.writeText(e.content),I.toast.success("已复制")},[e.content]),A=(0,c.useCallback)(()=>{let t=d.trim();if(!t||t===e.content){l(!1),p(e.content);return}l(!1),i(e.id,t)},[d,e.content,e.id,i]),_=(0,c.useCallback)(()=>{p(e.content),l(!1)},[e.content]),k=(0,c.useCallback)(e=>{"Escape"===e.key?(e.preventDefault(),_()):"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),A())},[A,_]);return(0,u.jsxs)("div",{className:"group flex justify-end","data-touched":a?"true":void 0,onClickCapture:()=>s(!0),children:[(0,u.jsxs)("div",{className:"flex max-w-[85%] flex-col items-end",children:[o?(0,u.jsxs)("div",{className:"w-full max-w-2xl rounded-2xl border border-[hsl(var(--primary))] bg-[hsl(var(--background))] p-2",children:[(0,u.jsx)(g.Textarea,{autoFocus:!0,value:d,onChange:e=>p(e.target.value),onKeyDown:k,className:"min-h-[80px] resize-y border-0 p-2 text-sm shadow-none focus-visible:ring-0"}),(0,u.jsxs)("div",{className:"mt-1 flex justify-end gap-2",children:[(0,u.jsx)(m.Button,{type:"button",variant:"ghost",size:"sm",onClick:_,children:"取消"}),(0,u.jsx)(m.Button,{type:"button",size:"sm",disabled:!d.trim()||d.trim()===e.content,onClick:A,children:"保存并重发"})]})]}):(0,u.jsx)("div",{className:"rounded-2xl rounded-tr-sm bg-[hsl(var(--muted)/0.7)] px-4 py-2.5 text-sm leading-relaxed text-foreground whitespace-pre-wrap",children:e.content}),!o&&(0,u.jsx)(iN,{align:"right",disabled:t,onCopy:v,onEdit:()=>{p(e.content),l(!0)},onResend:()=>b(!0),onDelete:()=>f(!0)})]}),(0,u.jsx)(R.ConfirmDialog,{open:h,onOpenChange:f,title:"删除此消息?",description:"该操作不可撤销。",confirmText:"删除",variant:"danger",onConfirm:()=>{r(e.id,{withNextAssistant:w}),f(!1)},children:(0,u.jsxs)("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[(0,u.jsx)(L.Checkbox,{checked:w,onCheckedChange:e=>x(!0===e)}),"同时删除下方的 AI 回复"]})}),(0,u.jsx)(R.ConfirmDialog,{open:y,onOpenChange:b,title:"重新发送此消息?",description:"将丢弃下方所有消息并重新生成回答。",confirmText:"重新发送",onConfirm:()=>{b(!1),n(e.id)}})]})}function iR({message:e,busy:t,onDelete:r,onRegenerate:n}){let[i,a]=(0,c.useState)(!1),[s,o]=(0,c.useState)(!1),[l,d]=(0,c.useState)(!1),p="streaming"===e.status,h="error"===e.status,f=(e.reasoning?.length??0)>0,m=(e.content?.length??0)>0,g=f||p&&!m,y=!!e.usingRag&&!e.retrievalQuery,b=!!e.retrievalQuery&&!e.retrievedChunks,x=(e.retrievalGroups??[]).filter(e=>e.error).map(e=>({name:e.knowledgeBaseName,reason:e.error??""})),v=(0,c.useCallback)(()=>{navigator.clipboard.writeText(e.content),I.toast.success("已复制")},[e.content]);return(0,u.jsxs)("div",{className:"group space-y-3 text-sm leading-relaxed","data-touched":i?"true":void 0,onClickCapture:()=>a(!0),children:[g?(0,u.jsx)(i$,{reasoning:e.reasoning??"",streaming:p,startedAt:e.reasoningStartedAt,completedAt:e.reasoningCompletedAt,intentExtracting:y,retrievalInFlight:b}):null,(0,u.jsx)(iI,{rewriteFailed:e.queryRewriteFailed,rewriteError:e.queryRewriteError,failedKbCount:x.length,failedKbDetails:x}),e.retrievalQueryRewritten&&e.retrievalQuery?(0,u.jsxs)("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md bg-[hsl(var(--muted)/0.4)] px-2 py-1 text-xs text-muted-foreground",children:[(0,u.jsx)(N.Search,{className:"h-3 w-3 shrink-0"}),(0,u.jsx)("span",{className:"font-medium shrink-0",children:"检索关键词:"}),(0,u.jsx)("span",{className:"truncate font-mono text-foreground/80",children:e.retrievalQuery})]}):null,e.retrievedChunks&&e.retrievedChunks.length>0?(0,u.jsx)(iT,{chunks:e.retrievedChunks,groups:e.retrievalGroups}):null,h?(0,u.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-[hsl(var(--destructive))/0.3] bg-[hsl(var(--destructive))/0.05] px-3 py-2 text-[hsl(var(--destructive))]",children:[(0,u.jsx)(w,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,u.jsx)("span",{className:"text-xs",children:e.errorMessage??"生成失败"})]}):(0,u.jsxs)("div",{className:"text-foreground/90",children:[(0,u.jsx)(iC,{children:e.content}),p?(0,u.jsx)("span",{className:"ml-0.5 inline-block h-3.5 w-1.5 animate-pulse bg-foreground align-baseline"}):null]}),(0,u.jsx)(iN,{align:"left",disabled:t||p,onCopy:v,onRegenerate:()=>d(!0),onDelete:()=>o(!0)}),(0,u.jsx)(R.ConfirmDialog,{open:s,onOpenChange:o,title:"删除此回复?",description:"该操作不可撤销。",confirmText:"删除",variant:"danger",onConfirm:()=>{r(e.id),o(!1)}}),(0,u.jsx)(R.ConfirmDialog,{open:l,onOpenChange:d,title:"重新生成此回复?",description:"将丢弃下方所有消息并重新生成。",confirmText:"重新生成",onConfirm:()=>{d(!1),n(e.id)}})]})}function i$({reasoning:e,streaming:t,startedAt:r,completedAt:n,intentExtracting:i,retrievalInFlight:a}){var s,o;let l,d,p,[h,f]=(0,c.useState)(!1),m=function(e,t){let[r,n]=(0,c.useState)(()=>Date.now());return((0,c.useEffect)(()=>{if(!e||t)return;let r=window.setInterval(()=>n(Date.now()),250);return()=>window.clearInterval(r)},[e,t]),e)?Math.max(0,(t??r)-e):null}(r,n),g=null!=m?(s=m,o=!t||!!n,d=Math.floor((l=Math.floor(s/1e3))/60),p=l%60,o?0===d?`用时 ${p} 秒`:`用时 ${d} 分 ${p} 秒`:`${d}:${String(p).padStart(2,"0")}`):null,y=t&&!n,w=e.length>0,x="正在思考";return w?x="深度思考中":a?x="正在检索知识库":i&&(x="检索意图提取"),(0,u.jsxs)(P.Collapsible,{open:h,onOpenChange:f,children:[(0,u.jsx)(P.CollapsibleTrigger,{asChild:!0,children:(0,u.jsxs)("button",{type:"button",disabled:!w,className:(0,b.cn)("group inline-flex items-center gap-2 rounded-full pl-1.5 pr-2.5 py-1 text-xs font-medium transition-all duration-200",y?"bg-[hsl(var(--primary)/0.08)] text-[hsl(var(--primary))] ring-1 ring-[hsl(var(--primary)/0.25)] shadow-[0_0_0_4px_hsl(var(--primary)/0.06)]":"bg-[hsl(var(--muted)/0.6)] text-muted-foreground hover:bg-[hsl(var(--accent))] hover:text-foreground",!w&&"cursor-default"),"aria-live":y?"polite":"off",children:[(0,u.jsxs)("span",{className:"relative inline-flex h-5 w-5 items-center justify-center",children:[y&&(0,u.jsx)("span",{"aria-hidden":!0,className:"absolute inset-0 rounded-full bg-[hsl(var(--primary))] opacity-40 blur-[6px] animate-thinking-aurora"}),(0,u.jsx)(A.Brain,{className:(0,b.cn)("relative h-3.5 w-3.5",y&&"animate-thinking-icon text-[hsl(var(--primary))]")})]}),y?(0,u.jsx)("span",{className:"animate-text-shimmer bg-[linear-gradient(90deg,hsl(var(--primary)/0.55)_0%,hsl(var(--primary))_50%,hsl(var(--primary)/0.55)_100%)] bg-[length:200%_100%] bg-clip-text text-transparent",children:x}):(0,u.jsx)("span",{children:"已深度思考"}),g&&(0,u.jsxs)("span",{className:(0,b.cn)("tabular-nums text-[11px]",y?"text-[hsl(var(--primary)/0.75)]":"text-muted-foreground/80"),children:["· ",g]}),w&&(0,u.jsx)(_.ChevronDown,{className:(0,b.cn)("h-3 w-3 opacity-60 transition-transform duration-200",h&&"rotate-180",y&&"text-[hsl(var(--primary))]")})]})}),w&&(0,u.jsx)(P.CollapsibleContent,{children:(0,u.jsx)("div",{className:"mt-2 border-l-2 border-[hsl(var(--border))] pl-3 text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap",children:e})})]})}function iT({chunks:e,groups:t}){let[r,n]=(0,c.useState)(!1),i=new Map;e.forEach((e,t)=>{i.set(`${e.docId}#${e.chunkId}`,t+1)});let a=(t??[]).filter(e=>!e.error),s=(t??[]).filter(e=>e.error),o=a.length>=2||s.length>0;return(0,u.jsxs)(P.Collapsible,{open:r,onOpenChange:n,children:[(0,u.jsx)(P.CollapsibleTrigger,{asChild:!0,children:(0,u.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-[hsl(var(--accent))] hover:text-foreground",children:[(0,u.jsx)(v,{className:"h-3.5 w-3.5"}),"查看 ",e.length," 个引用",o?(0,u.jsxs)("span",{className:"text-muted-foreground/70",children:["· ",a.length," 个知识库",s.length>0?`(${s.length} 失败)`:""]}):null,(0,u.jsx)(_.ChevronDown,{className:(0,b.cn)("h-3 w-3 transition-transform duration-200",r&&"rotate-180")})]})}),(0,u.jsx)(P.CollapsibleContent,{children:(0,u.jsx)("div",{className:"mt-2 space-y-3",children:o?(0,u.jsxs)(u.Fragment,{children:[a.map(e=>(0,u.jsx)(ij,{group:e,indexByKey:i},`ok-${e.knowledgeBaseName}`)),s.map(e=>(0,u.jsxs)("div",{className:"rounded-md border border-[hsl(var(--destructive))/0.3] bg-[hsl(var(--destructive))/0.05] px-3 py-2 text-xs text-[hsl(var(--destructive))]",children:[(0,u.jsx)("span",{className:"font-medium",children:e.knowledgeBaseName}),(0,u.jsxs)("span",{className:"ml-2 text-[hsl(var(--destructive))/0.8]",children:["检索失败:",e.error]})]},`err-${e.knowledgeBaseName}`))]}):(0,u.jsx)("div",{className:"space-y-2",children:e.map((e,t)=>(0,u.jsx)(iM,{chunk:e,index:t+1},`${e.docId}-${e.chunkId}`))})})})]})}function ij({group:e,indexByKey:t}){return(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[(0,u.jsx)("span",{className:"text-foreground/80",children:e.knowledgeBaseName}),(0,u.jsxs)("span",{children:["· ",e.chunks.length," 条"]})]}),(0,u.jsx)("div",{className:"space-y-2 border-l-2 border-[hsl(var(--border))] pl-3",children:e.chunks.map(e=>{let r=`${e.docId}#${e.chunkId}`,n=t.get(r)??0;return(0,u.jsx)(iM,{chunk:e,index:n},`${e.docId}-${e.chunkId}`)})})]})}function iM({chunk:e,index:t}){let r=e.ossKey?.split("/").pop()||e.ossKey||"未知文件";return(0,u.jsxs)("div",{className:"rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--muted)/0.3)] p-3",children:[(0,u.jsxs)("div",{className:"mb-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,u.jsx)("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-[hsl(var(--primary-50))] font-semibold text-primary",children:t>0?t:"–"}),(0,u.jsx)("span",{className:"font-medium text-foreground/80",children:r}),(0,u.jsxs)("span",{children:["Chunk #",e.chunkId]}),(0,u.jsx)("span",{className:"ml-auto font-mono",children:e.score.toFixed(4)})]}),(0,u.jsx)("p",{className:"line-clamp-4 whitespace-pre-wrap text-xs text-foreground/80",children:e.content})]})}iS.displayName="QaMessage",e.s(["QaChatPanel",0,function({messages:e,isStreaming:t,canSend:r,error:n,onSend:i,onStop:a,onDelete:s,onResend:o,onRegenerate:l,onEditSave:p,emptyState:w,disabledPlaceholder:x}){let[v,A]=(0,c.useState)(""),_=(0,c.useRef)(null),k=(0,c.useRef)(e.length);(0,c.useEffect)(()=>{let t=_.current;if(!t)return;let r=e.length>k.current;(k.current=e.length,r)?requestAnimationFrame(()=>{t.scrollTo({top:t.scrollHeight,behavior:"smooth"})}):t.scrollHeight-t.scrollTop-t.clientHeight<120&&t.scrollTo({top:t.scrollHeight,behavior:"smooth"})},[e]);let C=()=>{let e=v.trim();e&&r&&!t&&(i(e),A(""))};return(0,u.jsxs)("div",{className:"flex h-full flex-col rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--surface))]",children:[(0,u.jsx)("div",{ref:_,role:"log","aria-live":"polite","aria-relevant":"additions text","aria-busy":t,className:"flex-1 space-y-6 overflow-y-auto px-6 py-5",children:0===e.length?(0,u.jsx)("div",{className:"flex h-full min-h-[320px] items-center justify-center",children:(0,u.jsx)(y.EmptyState,{icon:d.MessageSquare,title:w?.title??"开始对话",description:w?.description??"输入问题,系统会先从知识库检索相关内容,再让大模型基于检索结果回答",action:w?.actionLabel&&w?.onAction?(0,u.jsx)(m.Button,{type:"button",onClick:w.onAction,children:w.actionLabel}):void 0})}):e.map(e=>(0,u.jsx)(iS,{message:e,busy:t,onDelete:s,onResend:o,onRegenerate:l,onEditSave:p},e.id))}),(0,u.jsxs)("div",{className:"border-t border-[hsl(var(--border))] bg-[hsl(var(--surface)/0.6)] px-4 py-3",children:[n&&(0,u.jsx)("p",{className:"mb-2 text-xs text-[hsl(var(--destructive))]",children:n}),(0,u.jsxs)("div",{className:"flex items-end gap-2",children:[(0,u.jsx)(g.Textarea,{value:v,onChange:e=>A(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),C())},placeholder:r?"输入问题,Enter 发送,Shift+Enter 换行":x??"请先在左侧选择模型...",disabled:!r,className:(0,b.cn)("min-h-[44px] max-h-40 resize-none text-sm"),rows:1}),t?(0,u.jsx)(m.Button,{type:"button",variant:"outline",size:"icon",onClick:a,title:"停止",children:(0,u.jsx)(f,{className:"h-4 w-4 fill-current"})}):(0,u.jsx)(m.Button,{type:"button",size:"icon",disabled:!r||!v.trim(),onClick:C,title:"发送",children:(0,u.jsx)(h,{className:"h-4 w-4"})})]})]})]})}],21122);var iB=e.i(51517),iO=e.i(30068),iD=e.i(23888),iG=e.i(66476),iU=e.i(66473),iF=e.i(70036),iW=e.i(43876),iz=e.i(92820);e.s(["LLMModelSelector",0,function({providerId:e,model:t,onProviderChange:r,onModelChange:n,allowFreeText:i=!1,autoSelectFirst:a=!1,providerLabel:s="Provider",modelLabel:o="Model"}){let{data:l=[],isLoading:d}=(0,iF.useLLMProviders)(),{data:p,isFetching:h,refetch:f}=function(e,t={}){return(0,iW.useQuery)({queryKey:["llm-provider-models",e],queryFn:()=>(0,iz.fetchProviderModels)(e),enabled:!!e&&(t.enabled??!0),staleTime:3e5,retry:!1})}(e||void 0,{enabled:!!e});(0,c.useEffect)(()=>{if(!a||e||0===l.length)return;let t=l[0];r(t.id,t.defaultModel??"")},[a,e,l]);let g=(0,c.useMemo)(()=>{let r=new Set;for(let e of(t&&r.add(t),p??[]))r.add(e.id);let n=l.find(t=>t.id===e);return n?.defaultModel&&r.add(n.defaultModel),Array.from(r)},[t,p,l,e]);return(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)(iG.Label,{className:"text-sm font-medium",children:s}),(0,u.jsxs)(iU.Select,{value:e,onValueChange:e=>{let t=l.find(t=>t.id===e);r(e,t?.defaultModel??"")},disabled:d||0===l.length,children:[(0,u.jsx)(iU.SelectTrigger,{children:(0,u.jsx)(iU.SelectValue,{placeholder:d?"加载中...":0===l.length?"请先在「大模型」中创建配置":"选择 Provider"})}),(0,u.jsx)(iU.SelectContent,{children:l.map(e=>(0,u.jsx)(iU.SelectItem,{value:e.id,children:e.name},e.id))})]})]}),(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsx)(iG.Label,{className:"text-sm font-medium",children:o}),(0,u.jsxs)(m.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",disabled:!e||h,onClick:()=>f(),children:[h?(0,u.jsx)(iB.Loader2,{className:"mr-1 h-3 w-3 animate-spin"}):(0,u.jsx)(iO.RefreshCw,{className:"mr-1 h-3 w-3"}),"刷新列表"]})]}),i?(0,u.jsxs)("div",{className:"flex gap-2",children:[(0,u.jsxs)(iU.Select,{value:g.includes(t)?t:"",onValueChange:n,disabled:!e,children:[(0,u.jsx)(iU.SelectTrigger,{className:"flex-1",children:(0,u.jsx)(iU.SelectValue,{placeholder:"选择或输入模型名"})}),(0,u.jsx)(iU.SelectContent,{children:0===g.length?(0,u.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"点击「刷新列表」拉取可用模型"}):g.map(e=>(0,u.jsx)(iU.SelectItem,{value:e,children:e},e))})]}),(0,u.jsx)(iD.Input,{placeholder:"或手动输入",value:t,onChange:e=>n(e.target.value),className:"flex-1"})]}):(0,u.jsxs)(iU.Select,{value:t,onValueChange:n,disabled:!e,children:[(0,u.jsx)(iU.SelectTrigger,{children:(0,u.jsx)(iU.SelectValue,{placeholder:"选择模型"})}),(0,u.jsx)(iU.SelectContent,{children:0===g.length?(0,u.jsx)(iU.SelectItem,{value:"__empty",disabled:!0,children:"无可用模型"}):g.map(e=>(0,u.jsx)(iU.SelectItem,{value:e,children:e},e))})]})]})]})}],50657),e.s(["SystemPromptInput",0,function({value:e,onChange:t,placeholder:r,helperText:n,rows:i=3,label:a="系统提示词"}){return(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)(iG.Label,{className:"text-sm font-medium",children:a}),(0,u.jsx)(g.Textarea,{rows:i,value:e,onChange:e=>t(e.target.value),placeholder:r,className:"text-sm"}),n&&(0,u.jsx)("p",{className:"text-xs text-muted-foreground",children:n})]})}],51024);var iq=e.i(27069),iH=e.i(91967),iV=e.i(67928),iQ=e.i(43250),iK=e.i(17256),iX=e.i(25486),iJ=e.i(84017),iZ=e.i(61614),iY=e.i(80939),i0=e.i(41986),i1=["PageUp","PageDown"],i2=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],i5={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},i6="Slider",[i3,i8,i4]=(0,i0.createCollection)(i6),[i9,i7]=(0,iQ.createContextScope)(i6,[i4]),[ae,at]=i9(i6),ar=c.forwardRef((e,t)=>{let{name:r,min:n=0,max:i=100,step:a=1,orientation:s="horizontal",disabled:o=!1,minStepsBetweenThumbs:l=0,defaultValue:d=[n],value:p,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:m=!1,form:g,...y}=e,b=c.useRef(new Set),w=c.useRef(0),x="horizontal"===s,[v=[],A]=(0,iK.useControllableState)({prop:p,defaultProp:d,onChange:e=>{let t=[...b.current];t[w.current]?.focus(),h(e)}}),_=c.useRef(v);function k(e,t,{commit:r}={commit:!1}){let s,o=(String(a).split(".")[1]||"").length,u=Math.round((Math.round((e-n)/a)*a+n)*(s=Math.pow(10,o)))/s,c=(0,iq.clamp)(u,[n,i]);A((e=[])=>{let n=function(e=[],t,r){let n=[...e];return n[r]=t,n.sort((e,t)=>e-t)}(e,c,t);if(!function(e,t){if(t>0)return Math.min(...e.slice(0,-1).map((t,r)=>e[r+1]-t))>=t;return!0}(n,l*a))return e;{w.current=n.indexOf(c);let t=String(n)!==String(e);return t&&r&&f(n),t?n:e}})}return(0,u.jsx)(ae,{scope:e.__scopeSlider,name:r,disabled:o,min:n,max:i,valueIndexToChangeRef:w,thumbs:b.current,values:v,orientation:s,form:g,children:(0,u.jsx)(i3.Provider,{scope:e.__scopeSlider,children:(0,u.jsx)(i3.Slot,{scope:e.__scopeSlider,children:(0,u.jsx)(x?aa:as,{"aria-disabled":o,"data-disabled":o?"":void 0,...y,ref:t,onPointerDown:(0,iH.composeEventHandlers)(y.onPointerDown,()=>{o||(_.current=v)}),min:n,max:i,inverted:m,onSlideStart:o?void 0:function(e){let t=function(e,t){if(1===e.length)return 0;let r=e.map(e=>Math.abs(e-t)),n=Math.min(...r);return r.indexOf(n)}(v,e);k(e,t)},onSlideMove:o?void 0:function(e){k(e,w.current)},onSlideEnd:o?void 0:function(){let e=_.current[w.current];v[w.current]!==e&&f(v)},onHomeKeyDown:()=>!o&&k(n,0,{commit:!0}),onEndKeyDown:()=>!o&&k(i,v.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!o){let r=i1.includes(e.key)||e.shiftKey&&i2.includes(e.key),n=w.current;k(v[n]+a*(r?10:1)*t,n,{commit:!0})}}})})})})});ar.displayName=i6;var[an,ai]=i9(i6,{startEdge:"left",endEdge:"right",size:"width",direction:1}),aa=c.forwardRef((e,t)=>{let{min:r,max:n,dir:i,inverted:a,onSlideStart:s,onSlideMove:o,onSlideEnd:l,onStepKeyDown:d,...p}=e,[h,f]=c.useState(null),m=(0,iV.useComposedRefs)(t,e=>f(e)),g=c.useRef(void 0),y=(0,iX.useDirection)(i),b="ltr"===y,w=b&&!a||!b&&a;function x(e){let t=g.current||h.getBoundingClientRect(),i=ay([0,t.width],w?[r,n]:[n,r]);return g.current=t,i(e-t.left)}return(0,u.jsx)(an,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:(0,u.jsx)(ao,{dir:y,"data-orientation":"horizontal",...p,ref:m,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{let t=x(e.clientX);s?.(t)},onSlideMove:e=>{let t=x(e.clientX);o?.(t)},onSlideEnd:()=>{g.current=void 0,l?.()},onStepKeyDown:e=>{let t=i5[w?"from-left":"from-right"].includes(e.key);d?.({event:e,direction:t?-1:1})}})})}),as=c.forwardRef((e,t)=>{let{min:r,max:n,inverted:i,onSlideStart:a,onSlideMove:s,onSlideEnd:o,onStepKeyDown:l,...d}=e,p=c.useRef(null),h=(0,iV.useComposedRefs)(t,p),f=c.useRef(void 0),m=!i;function g(e){let t=f.current||p.current.getBoundingClientRect(),i=ay([0,t.height],m?[n,r]:[r,n]);return f.current=t,i(e-t.top)}return(0,u.jsx)(an,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:(0,u.jsx)(ao,{"data-orientation":"vertical",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{let t=g(e.clientY);a?.(t)},onSlideMove:e=>{let t=g(e.clientY);s?.(t)},onSlideEnd:()=>{f.current=void 0,o?.()},onStepKeyDown:e=>{let t=i5[m?"from-bottom":"from-top"].includes(e.key);l?.({event:e,direction:t?-1:1})}})})}),ao=c.forwardRef((e,t)=>{let{__scopeSlider:r,onSlideStart:n,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:s,onEndKeyDown:o,onStepKeyDown:l,...c}=e,d=at(i6,r);return(0,u.jsx)(iY.Primitive.span,{...c,ref:t,onKeyDown:(0,iH.composeEventHandlers)(e.onKeyDown,e=>{"Home"===e.key?(s(e),e.preventDefault()):"End"===e.key?(o(e),e.preventDefault()):i1.concat(i2).includes(e.key)&&(l(e),e.preventDefault())}),onPointerDown:(0,iH.composeEventHandlers)(e.onPointerDown,e=>{let t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),d.thumbs.has(t)?t.focus():n(e)}),onPointerMove:(0,iH.composeEventHandlers)(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&i(e)}),onPointerUp:(0,iH.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),a(e))})})}),al="SliderTrack",au=c.forwardRef((e,t)=>{let{__scopeSlider:r,...n}=e,i=at(al,r);return(0,u.jsx)(iY.Primitive.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...n,ref:t})});au.displayName=al;var ac="SliderRange",ad=c.forwardRef((e,t)=>{let{__scopeSlider:r,...n}=e,i=at(ac,r),a=ai(ac,r),s=c.useRef(null),o=(0,iV.useComposedRefs)(t,s),l=i.values.length,d=i.values.map(e=>ag(e,i.min,i.max)),p=l>1?Math.min(...d):0,h=100-Math.max(...d);return(0,u.jsx)(iY.Primitive.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...n,ref:o,style:{...e.style,[a.startEdge]:p+"%",[a.endEdge]:h+"%"}})});ad.displayName=ac;var ap="SliderThumb",ah=c.forwardRef((e,t)=>{let r=i8(e.__scopeSlider),[n,i]=c.useState(null),a=(0,iV.useComposedRefs)(t,e=>i(e)),s=c.useMemo(()=>n?r().findIndex(e=>e.ref.current===n):-1,[r,n]);return(0,u.jsx)(af,{...e,ref:a,index:s})}),af=c.forwardRef((e,t)=>{var r,n,i,a,s;let o,l,{__scopeSlider:d,index:p,name:h,...f}=e,m=at(ap,d),g=ai(ap,d),[y,b]=c.useState(null),w=(0,iV.useComposedRefs)(t,e=>b(e)),x=!y||m.form||!!y.closest("form"),v=(0,iZ.useSize)(y),A=m.values[p],_=void 0===A?0:ag(A,m.min,m.max),k=(r=p,(n=m.values.length)>2?`Value ${r+1} of ${n}`:2===n?["Minimum","Maximum"][r]:void 0),C=v?.[g.size],S=C?(i=C,a=_,s=g.direction,l=ay([0,50],[0,o=i/2]),(o-l(a)*s)*s):0;return c.useEffect(()=>{if(y)return m.thumbs.add(y),()=>{m.thumbs.delete(y)}},[y,m.thumbs]),(0,u.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[g.startEdge]:`calc(${_}% + ${S}px)`},children:[(0,u.jsx)(i3.ItemSlot,{scope:e.__scopeSlider,children:(0,u.jsx)(iY.Primitive.span,{role:"slider","aria-label":e["aria-label"]||k,"aria-valuemin":m.min,"aria-valuenow":A,"aria-valuemax":m.max,"aria-orientation":m.orientation,"data-orientation":m.orientation,"data-disabled":m.disabled?"":void 0,tabIndex:m.disabled?void 0:0,...f,ref:w,style:void 0===A?{display:"none"}:e.style,onFocus:(0,iH.composeEventHandlers)(e.onFocus,()=>{m.valueIndexToChangeRef.current=p})})}),x&&(0,u.jsx)(am,{name:h??(m.name?m.name+(m.values.length>1?"[]":""):void 0),form:m.form,value:A},p)]})});ah.displayName=ap;var am=c.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{let i=c.useRef(null),a=(0,iV.useComposedRefs)(i,n),s=(0,iJ.usePrevious)(t);return c.useEffect(()=>{let e=i.current;if(!e)return;let r=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;if(s!==t&&r){let n=new Event("input",{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[s,t]),(0,u.jsx)(iY.Primitive.input,{style:{display:"none"},...r,ref:a,defaultValue:t})});function ag(e,t,r){return(0,iq.clamp)(100/(r-t)*(e-t),[0,100])}function ay(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}am.displayName="RadioBubbleInput";let ab=c.forwardRef(({className:e,...t},r)=>(0,u.jsxs)(ar,{ref:r,className:(0,b.cn)("relative flex w-full touch-none select-none items-center",e),...t,children:[(0,u.jsx)(au,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-[hsl(var(--muted))]",children:(0,u.jsx)(ad,{className:"absolute h-full bg-[hsl(var(--primary))]"})}),(0,u.jsx)(ah,{className:"block h-4 w-4 rounded-full border border-[hsl(var(--primary))] bg-[hsl(var(--background))] shadow-sm ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));ab.displayName=ar.displayName,e.s(["TemperatureSlider",0,function({value:e,onChange:t,min:r=0,max:n=2,step:i=.05,fallback:a=.7,label:s="温度"}){let o=(e??a).toFixed(2);return(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,u.jsx)("span",{className:"font-medium",children:s}),(0,u.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:o})]}),(0,u.jsx)(ab,{value:[e??a],min:r,max:n,step:i,onValueChange:e=>t(e[0]??a)})]})}],9012)},6962,e=>{"use strict";e.s(["newId",0,function(e="id"){return"u">typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${e}_${Date.now()}_${Math.random().toString(36).slice(2)}`}])},84625,e=>{"use strict";async function*t(e,t){let n=await fetch("/api/v1/llm/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t});if(!n.ok||!n.body){let e=`Chat request failed with status ${n.status}`,t="STREAM_ERROR";try{let r=await n.json();e=r.message??e,t=r.code??t}catch{}yield{type:"error",code:t,message:e};return}let i=n.body.getReader(),a=new TextDecoder("utf-8"),s="";for(;;){let{value:e,done:t}=await i.read();if(t)break;let n=(s+=a.decode(e,{stream:!0})).indexOf("\n\n");for(;-1!==n;){let e=s.slice(0,n);s=s.slice(n+2);let t=r(e);t&&(yield t),n=s.indexOf("\n\n")}}if(s.trim()){let e=r(s);e&&(yield e)}}function r(e){let t=e.split("\n"),r=[];for(let e of t)!(!e||e.startsWith(":"))&&e.startsWith("data:")&&r.push(e.slice(5).trimStart());if(0===r.length)return null;try{return JSON.parse(r.join("\n"))}catch{return null}}e.s(["streamChat",0,t])},40596,86196,e=>{"use strict";var t=e.i(17635),r=e.i(84625),n=e.i(6962);function i(e,t){let r=e.findIndex(e=>e.id===t);return r<0?e:e.slice(0,r+1)}function a(e,t){let r=e.findIndex(e=>e.id===t);if(r<0)return e;let n=e.slice();return n.splice(r,1),n}function s(e,t){let r=e.findIndex(e=>e.id===t);if(r<0)return e;let n=e.slice(),i=e[r+1]&&"assistant"===e[r+1].role?2:1;return n.splice(r,i),n}e.s(["findUserAnchorAbove",0,function(e,t){let r=e.findIndex(e=>e.id===t);if(r<0)return null;for(let t=r-1;t>=0;t-=1)if("user"===e[t].role)return e[t];return null},"removeAt",0,a,"removePair",0,s,"truncateUpToAndIncluding",0,i],86196),e.s(["useQaChat",0,function(e){let[o,l]=(0,t.useState)([]),[u,c]=(0,t.useState)(!1),[d,p]=(0,t.useState)(null),h=(0,t.useRef)(null),f=(0,t.useRef)(e.onPersist);f.current=e.onPersist;let m=(0,t.useRef)(o);m.current=o;let g=(0,t.useRef)(e);g.current=e;let y=(0,t.useRef)(u);y.current=u;let b=(0,t.useRef)(new Map),w=(0,t.useRef)(null),x=(0,t.useCallback)(()=>{w.current=null;let e=b.current;if(0===e.size)return;let t=new Map(e);e.clear(),l(e=>e.map(e=>{let r=t.get(e.id);return r?{...e,...r.content?{content:e.content+r.content}:null,...r.reasoning?{reasoning:(e.reasoning??"")+r.reasoning}:null}:e}))},[]),v=(0,t.useCallback)(()=>{if(null===w.current){if("u"<typeof requestAnimationFrame)return void x();w.current=requestAnimationFrame(x)}},[x]),A=(0,t.useCallback)(()=>{null!==w.current&&"u">typeof cancelAnimationFrame&&cancelAnimationFrame(w.current),w.current=null},[]);(0,t.useEffect)(()=>A,[A]);let _=(0,t.useCallback)(()=>{h.current?.abort()},[]),k=(0,t.useCallback)(()=>{h.current?.abort(),m.current=[],l([]),p(null)},[]),C=(0,t.useCallback)(e=>{h.current?.abort(),m.current=e,l(e),p(null)},[]),S=(0,t.useCallback)(async(e,t)=>{let n=g.current,i=new AbortController;h.current=i;let a={current:!1},s={current:!1},o=t=>{l(r=>r.map(r=>r.id===e?{...r,...t}:r))};try{let l={providerId:n.providerId,model:n.model,messages:t,systemPrompt:n.systemPrompt,temperature:n.temperature,rag:n.rag};for await(let u of(function(e){try{return"1"===window.localStorage.getItem("tsagent.dev."+e)}catch{return!1}}("logChatRequest")&&(console.groupCollapsed("[chat] outgoing turn"),console.log("assistantId",e),console.log("messages",t),console.log("rag.knowledgeBases",n.rag?.knowledgeBases),console.groupEnd()),(0,r.streamChat)(l,i.signal)))if("query.rewritten"===u.type)o({retrievalQuery:u.query,retrievalQueryRewritten:u.query!==u.original});else if("query.fallback"===u.type)o({retrievalQuery:u.original,retrievalQueryRewritten:!1,queryRewriteFailed:!0,queryRewriteError:u.reason});else if("retrieval.done"===u.type)o({retrievedChunks:u.chunks,retrievalGroups:u.byKnowledgeBase});else if("reasoning.delta"===u.type){let t=b.current.get(e)??{};t.reasoning=(t.reasoning??"")+u.delta,b.current.set(e,t),a.current||(a.current=!0,o({reasoningStartedAt:Date.now()})),v()}else if("content.delta"===u.type){let t=b.current.get(e)??{};t.content=(t.content??"")+u.delta,b.current.set(e,t),a.current&&!s.current&&(s.current=!0,o({reasoningCompletedAt:Date.now()})),v()}else if("error"===u.type){A(),x();let e={status:"error",errorMessage:`${u.code}: ${u.message}`};a.current&&!s.current&&(e.reasoningCompletedAt=Date.now()),o(e),p(u.message);break}else if("done"===u.type){A(),x();let e={status:"done"};a.current&&!s.current&&(e.reasoningCompletedAt=Date.now()),o(e);break}}catch(r){A(),x();let e=r instanceof DOMException&&"AbortError"===r.name,t=a.current&&!s.current?{reasoningCompletedAt:Date.now()}:void 0;if(e)o({status:"done",...t});else{let e=r instanceof Error?r.message:String(r);o({status:"error",errorMessage:e,...t}),p(e)}}finally{c(!1),h.current=null;let e=f.current;e&&l(t=>(e(t),t))}},[v,x,A]),N=(0,t.useCallback)(async e=>{let t=e.trim();if(!t||y.current)return;let r=g.current;if(!r.providerId||!r.model)return void p("请先选择模型与 Provider");p(null);let i={id:(0,n.newId)(),role:"user",content:t,createdAt:Date.now(),status:"done"},a=(0,n.newId)(),s=(r.rag?.knowledgeBases?.length??0)>0,o={id:a,role:"assistant",content:"",reasoning:"",createdAt:Date.now(),status:"streaming",usingRag:s},u=[...m.current,i].map(e=>({role:e.role,content:e.content})),d=[...m.current,i,o];m.current=d,l(d),c(!0),await S(a,u)},[S]),E=(0,t.useCallback)(async e=>{if(y.current)return;let t=g.current;if(!t.providerId||!t.model)return void p("请先选择模型与 Provider");let r=i(m.current,e),a=r[r.length-1];if(!a||"user"!==a.role)return;p(null);let s=(0,n.newId)(),o=(t.rag?.knowledgeBases?.length??0)>0,u={id:s,role:"assistant",content:"",reasoning:"",createdAt:Date.now(),status:"streaming",usingRag:o},d=r.map(e=>({role:e.role,content:e.content})),h=[...r,u];m.current=h,l(h),c(!0),await S(s,d)},[S]);return{messages:o,isStreaming:u,error:d,send:N,reissueTurn:E,deleteMessage:(0,t.useCallback)((e,t)=>{if(y.current)return;let r=m.current,n=r.find(t=>t.id===e);if(!n)return;let i="user"===n.role&&t?.withNextAssistant?s(r,e):a(r,e);m.current=i,l(i),f.current?.(i)},[]),editUserMessage:(0,t.useCallback)((e,t)=>{let r=m.current,n=r.findIndex(t=>t.id===e);if(n<0||"user"!==r[n].role)return null;let i=r.slice();return i[n]={...r[n],content:t},m.current=i,l(i),e},[]),stop:_,clear:k,setMessages:C}}],40596)}]);
|